Skip to content

Conversation

@PTaeuberDS
Copy link
Contributor

@PTaeuberDS PTaeuberDS commented Jun 6, 2025

This pull request clarifies the definition and usage of Clock intervals, primarily by making fmi3GetInterval more flexible and explicitly defining its behavior in all situations.

Key Changes:

  • Broaden fmi3GetInterval calling conditions: The function may now be called for any time-based Clock at any time in InitializationMode, EventMode, ClockActivationMode, and ClockUpdateMode.
  • Define fmi3IntervalQualifier return values: A new table is introduced to rigorously define the allowed fmi3IntervalQualifier return values for every time-based Clock in different states.
  • Clarify interval definitions: The definition of what an "interval" represents has been made more precise across different Clock types and situations:
    • The special case for a tunable Clock's interval at the moment of a change is now explicitly covered.
    • The distinction in behavior for fixed/tunable Clocks based on whether the intervalDecimal attribute is specified is sharpened.

Resolves #2018

@PTaeuberDS PTaeuberDS self-assigned this Jun 6, 2025
@PTaeuberDS PTaeuberDS force-pushed the fixGetIntervalDescription branch from 227daca to 18448dd Compare August 22, 2025 08:59
@PTaeuberDS PTaeuberDS force-pushed the fixGetIntervalDescription branch from bfec03e to d7ce096 Compare August 28, 2025 16:13
@PTaeuberDS PTaeuberDS marked this pull request as ready for review August 29, 2025 09:28
@chrbertsch chrbertsch requested a review from clagms October 8, 2025 17:37
|Generally, the time interval from the previous Clock tick to the current Clock tick.
An exception applies to a tunable Clock whose interval has just changed in <<EventMode>> or <<ClockActivationMode>>.
In this specific case, the new interval is relative to the time of the current <<EventMode>> or <<ClockActivationMode>>, not to the time of the previous Clock tick.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would't it be more concise if we say: "The time interval from the current Clock tick to the next Clock tick, specified differently for the different Clock types." That would hold for Tunable clock too.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, it wouldn't. The interval of a tunable clock can change at any (event) time without the clock having ticked. So there is not necessarily a current clock tick.

@masoud-najafi
Copy link
Collaborator

I wonder if there is a way to visualize the tables? Any artifact has been created for these changes?

@chrbertsch
Copy link
Collaborator

I wonder if there is a way to visualize the tables? Any artifact has been created for these changes?

@masoud-najafi :
The Specification is created at every commit via GitHub Actions. You can download and inspect the created specificiation without any local installation of AsciiDoc:
grafik
grafik
grafik

The importer must use <<fmi3GetShift>> to retrieve the Clock shift in <<InitializationMode>>.

+
In both cases, when an interval changes, the new interval is relative to the time of the current <<EventMode>> or <<ClockActivationMode>>, not to the time of the previous Clock tick.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure if I understand this correctly. Suppose the previous clock tick has been at time=T_k and the next tick will be at time=T_{k+1}=T_K+DT, where DT is the current interval of the clock. If an event happens at T_e where T_K< T_e <T_{k+1}, and at this time event the interval of the clock is changed by the importer to DT2, what would be the time of the next clock tick?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In this case T_e + DT2, as the interval is defined from the current event time to the next clock tick.

_Subsequent Clock ticks follow the general interval definition for periodic Clocks until the tunable interval changes again._

^|_(7)_
|_In super state <<Initialized>>, for a changing Clock, <<fmi3IntervalChanged>> is returned if and only if the Clock has just ticked._
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I do not understand why you have extended this part to the superState . The GetInterval cannot return fmi3IntervalChanged in other state than EventMode.

Comment on lines +668 to +669

is a time-based Clock with a constant interval, except when <<intervalVariability>> = <<tunable>>, which indicates that the interval can change.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Minor remark:
I wouldn't use "when" in this context it might be confusing because when might indicate a certain time point.
"except for Clocks with <> = <>"

[[fmi3IntervalUnchanged,`fmi3IntervalUnchanged`]]
* `fmi3IntervalUnchanged` is returned if a previous call to <<fmi3GetInterval>> already returned a value qualified with <<fmi3IntervalChanged>> which has not changed since.
* `fmi3IntervalUnchanged` is returned if a previous call to <<fmi3GetInterval>> already returned a value qualified with <<fmi3IntervalChanged>> which has not changed since, or if the FMU is not allowed to change the interval because it is meant to be set by the importer or already fixed for the simulation (e.g., the interval of a constant Clock).
In this case, <<intervals-get>> returns the old unchanged interval.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"old unchanged interval" relative to what time? The current time instant or the time instant when the qualifier for this clock was "fmi3IntervalChanged" the last time.
Shouldn't we change this to "has no meaning"?

* `fmi3IntervalNotYetKnown` is returned for a <<countdown-aperiodic-clock,`countdown`>> Clock for which the next interval is not yet known.
This qualifier value can only be returned directly after the Clock was active and previous calls to <<fmi3GetInterval>> never returned <<fmi3IntervalChanged>> (nor <<fmi3IntervalUnchanged>>).
In Scheduled Execution this return value means that the corresponding model partition cannot be scheduled yet.
* `fmi3IntervalNotYetKnown` is returned for a <<countdown-aperiodic-clock,`countdown`>> Clock for which the next interval is not yet known.
Copy link
Collaborator

@klausschuch klausschuch Nov 18, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we use "known" for 2 different perspectives here:

  1. the FMU doesn't know it yet
  2. the importer doesn't know it yet and hence has to ask the FMU

Here it is option (1) but above it was option (2).
I suggest to distinguish between these two explicitly.

This qualifier value can only be returned directly after the Clock was active and previous calls to <<fmi3GetInterval>> never returned <<fmi3IntervalChanged>> (nor <<fmi3IntervalUnchanged>>).
In Scheduled Execution this return value means that the corresponding model partition cannot be scheduled yet.
* `fmi3IntervalNotYetKnown` is returned for a <<countdown-aperiodic-clock,`countdown`>> Clock for which the next interval is not yet known.
This qualifier value can only be returned directly after the Clock was active and previous calls to <<fmi3GetInterval>> never returned <<fmi3IntervalChanged>> (nor <<fmi3IntervalUnchanged>>).
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To me this reads like the clock cannot have an undefined interval at all anymore after it had an interval once, even after the clock was active already.
This is not what I would expect

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Clarify rules on fmi3GetInterval*/fmi3GetShift* functions with regards to periodic input clocks

5 participants