Opened 7 years ago

Last modified 7 years ago

#4530 closed defect

Wrong implementation of sub/superSample in conjunction with shiftSample — at Initial Version

Reported by: Rüdiger Franke Owned by: Volker Waurich
Priority: high Milestone: 1.12.0
Component: Backend Version:
Keywords: Cc: Adrian Pop, Volker Waurich

Description

Modelica spec 3.3 Rev1, section 16.5.2 Sub-clock conversion specifies that subSample and superSample do not change the initial tick of a clock. See the following example:

model TwoClocks
  Real x1(start = 0);
  Real x2(start = 0);
  Clock c1 = shiftSample(Clock(1.0), 1, 2);
  Clock c2 = superSample(c1, 2);
equation
  when c1 then
    x1 = sample(time);
  end when;
  when c2 then
    x2 = sample(time);
  end when;
end TwoClocks;

Here the first tick of c1 and c2 should be at 1/2s. The Cpp runtime generates the first tick of c2 at 1/4s.

Two attempts were made to fix this:

The first rigorous attempt destroyed event clocks:
https://github.com/OpenModelica/OMCompiler/commit/edd5dda09c83358f72eaa91013e93b0dbc3a619d

The second attempt still resulted in failed validations for Modelica_Synchronous_cpp:
https://github.com/OpenModelica/OMCompiler/commit/6554061cfcd98080c64f4756464dc3f1895a78f8

The validation failed for the following models:

    Modelica_Synchronous.Examples.Elementary.BooleanSignals.BackSample
    Modelica_Synchronous.Examples.Elementary.BooleanSignals.Hold
    Modelica_Synchronous.Examples.Elementary.BooleanSignals.ShiftSample
    Modelica_Synchronous.Examples.Elementary.ClockSignals.ShiftSample
    Modelica_Synchronous.Examples.Elementary.IntegerSignals.BackSample
    Modelica_Synchronous.Examples.Elementary.IntegerSignals.Hold
    Modelica_Synchronous.Examples.Elementary.IntegerSignals.ShiftSample
    Modelica_Synchronous.Examples.Elementary.RealSignals.BackSample
    Modelica_Synchronous.Examples.Elementary.RealSignals.FractionalDelay
    Modelica_Synchronous.Examples.Elementary.RealSignals.Hold
    Modelica_Synchronous.Examples.Elementary.RealSignals.HoldWithDAeffects1
    Modelica_Synchronous.Examples.Elementary.RealSignals.HoldWithDAeffects2
    Modelica_Synchronous.Examples.Elementary.RealSignals.ShiftSample

Both attempts have been reverted. The problem persists.

Change History (0)

Note: See TracTickets for help on using tickets.