Opened 9 years ago

Closed 8 years ago

#3772 closed defect (fixed)

event clock error

Reported by: niklwors Owned by: rfranke
Priority: blocker Milestone: Future
Component: Backend Version:
Keywords: Modelica_Synchronous, synchronous features, cpp runtime Cc: rfranke, bthiele, vwaurich

Description (last modified by niklwors)

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 Changed 9 years ago by rfranke

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 rfranke (previous) (diff)

comment:2 Changed 9 years ago by niklwors

  • Description modified (diff)
  • Summary changed from unknown clock interval to event clock error

comment:3 Changed 8 years ago by niklwors

  • Cc vwaurich added

comment:4 Changed 8 years ago by lochel

  • Keywords Modelica_Synchronous added

comment:5 Changed 8 years ago by rfranke

  • Owner changed from lochel to rfranke
  • Status changed from new to 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 Changed 8 years ago by rfranke

  • Resolution set to fixed
  • Status changed from accepted to closed
Note: See TracTickets for help on using tickets.