Add Code Example for Event Mode with Clocks#2098
Add Code Example for Event Mode with Clocks#2098MarioHarter wants to merge 10 commits intomodelica:mainfrom
Conversation
|
Update: Added handling for the first-time transition into Event Mode. The system enters Event Mode directly following |
|
FMI Design Meeting: |
|
@masoud-najafi To validate the issue here, I reviewed the outputs of your example C2_clocked_toggle. The section suggests to me that some getting and setting of clocks and clocked variables must already be happening inside the (Also, I was wondering which tool you used to generate this output?) |
The given result in the csv file is just to show the form of the resulting curve and does not indicate how/how many times or where get/getClock or set/setXX have been called. If your results LOOKS LIKE this curves, that should be fine. |
clagms
left a comment
There was a problem hiding this comment.
thank you for the example! I think that at the moment it is violating the standard (See my comments). Also see my other comments.
|
Mario: the comments have been addressed, please review |
|
Hi, It's a good time to add these items to the spec, but If you think it's out of scope of this PR, then I approve this PR. |
|
Thank you for the feedback @masoud-najafi I agree that the points you’ve raised would be very worthwhile additions to the FMI standard. However, I intentionally scoped this PR to focus on a simple implementation. While this sacrifices some nuance, the primary goal is to establish a foundational code example for clocked variables. By keeping the logic simple, we ensure the core clock mechanics aren't obscured by other code. So let’s keep this as the "Hello World" of clocked variables and address the further topics in separate issues! I’m happy to help capture these suggestions and created issue #2127 for this. |
|
Maybe a remark can be added next to the example showing what is not covered? This would give people an idea of how simplistic the example is... best to not delude the reader into thinking clocks are simple? |
|
Good idea! I was able to edit the section introduction so that the scope of this example is clearer. (I did not include a list of things omitted, as the other examples do not either, but I specified the focus of this example.) |
masoud-najafi
left a comment
There was a problem hiding this comment.
Since the purpose of this PR is not to demonstrate the use of all clock types, it should be stated that the example code handles only "independent output clocks", that is, clocks with unpredictable timing that are detected during doStep().
Noting that the concept of Clocks is often difficult for newcomers to the FMI standard, and following the discussion in Issue #2079, I believe it is highly valuable to include a clarifying code example. The existing Co‑Simulation examples do not sufficiently cover Clocks, which can make the Event Mode specification hard to fully understand.
This PR introduces:
To keep the example as accessible as possible, it intentionally does not cover early return or intermediate updates.
Feedback is very welcome.