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 Niklas Worschech)

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:1 by Rüdiger Franke, 9 years ago

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

Last edited 9 years ago by Rüdiger Franke (previous) (diff)

comment:2 by Niklas Worschech, 9 years ago

Description: modified (diff)
Summary: unknown clock intervalevent clock error

comment:3 by Niklas Worschech, 9 years ago

Cc: Volker Waurich added

comment:4 by Lennart Ochel, 9 years ago

Keywords: Modelica_Synchronous added

comment:5 by Rüdiger Franke, 8 years ago

Owner: changed from Lennart Ochel to Rüdiger Franke
Status: newaccepted

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 Rüdiger Franke, 8 years ago

Resolution: fixed
Status: acceptedclosed
Note: See TracTickets for help on using tickets.