Opened 9 years ago
Closed 8 years ago
#3772 closed defect (fixed)
event clock error
Reported by: | Niklas Worschech | Owned by: | Rüdiger Franke |
---|---|---|---|
Priority: | blocker | Milestone: | Future |
Component: | Backend | Version: | |
Keywords: | Modelica_Synchronous, synchronous features, cpp runtime | Cc: | Rüdiger Franke, Bernhard Thiele, Volker Waurich |
Description (last modified by )
For the following example the clock interval is unknown in SimCode.
The model is from the cpp runtime testfolder.
model EventClock "See Modelica 3.3 spec, section 16.3 Clock Constructors" Integer nextInterval(start = 1); Real nextTick(start = 0); equation when Clock(time > hold(nextTick) / 210) then nextInterval = previous(nextInterval) + 1; nextTick = previous(nextTick) + nextInterval; end when; end EventClock;
The generated cpp code equation for the interval calculation is:
_clockInterval[0] = 0.0 * 1.0 / 1.0;
But the interval values should be 0.00953,0.0238,0.042 ...
Change History (6)
comment:2 by , 9 years ago
Description: | modified (diff) |
---|---|
Summary: | unknown clock interval → event clock error |
comment:3 by , 9 years ago
Cc: | added |
---|
comment:4 by , 9 years ago
Keywords: | Modelica_Synchronous added |
---|
comment:5 by , 8 years ago
Owner: | changed from | to
---|---|
Status: | new → accepted |
The example uses an event clock and produces the correct simulation result. The varying clock interval is updated during the simulation.
499d340/OMCompiler changes the initialization to use the dedicated startInterval
instead of constant 0 for event clocks.
The Cpp code contains both: a generic event and a time event. The time event might be skipped in this case.
comment:6 by , 8 years ago
Resolution: | → fixed |
---|---|
Status: | accepted → closed |
See #3752
Both the C and the Cpp templates currently call the frontend function Expression.getClockInterval. It returns 0.0 for an unknown (inferred) clock.
The runtime code generation should introduce a default clock in #3752.
Here we have an event clock, for which Expression.getClockInterval returns 0.0 too. The runtime code generation must treat the event clock in that case.
See: https://github.com/OpenModelica/OpenModelica-testsuite/blob/master/openmodelica/cppruntime/clockedEventTest.mos