Opened 9 years ago

Closed 9 years ago

Last modified 9 years ago

#3482 closed defect (duplicate)

Wrong creation of Clock with real interval

Reported by: Rüdiger Franke Owned by: somebody
Priority: high Milestone: 1.9.4
Component: Backend Version:
Keywords: Cc:

Description

The following model creates a clock with Real interval. It worked if dt was constant; it fails if dt is a parameter (see e.g. Modelica_Synchronous):

model RealParameterClock
  parameter Real dt = 0.1 annotation(Evaluate = true);
  input Real u;
  output Real y(start = 0);
equation
  when Clock(dt) then
    y = previous(y) + u;
  end when;
end RealParameterClock;

The code attempts to access the non existing previous(dt):

RealParameterClock_15syn.c:63:53: error: ‘$P$CLKPRE$Pdt’ undeclared (first use in this function)
       data->simulationInfo.clocksData[i].interval = $P$CLKPRE$Pdt;
                                                     ^

Alternatively in the Cpp runtime (+simCodeTarget=Cpp):

OMCppRealParameterClock.cpp: In member function ‘virtual void RealParameterClock::getTimeEvent(time_event_type&)’:
OMCppRealParameterClock.cpp:402:45: error: ‘_$CLKPRE_P_dt’ was not declared in this scope
   time_events.push_back(std::make_pair(0.0, _$CLKPRE_P_dt));
                                             ^

Change History (7)

comment:1 by Rüdiger Franke, 9 years ago

Resolution: fixed
Status: newclosed

duplicate #3498

comment:2 by Lennart Ochel, 9 years ago

Component: FrontendBackend

comment:3 by Lennart Ochel, 9 years ago

I guess this could be easily fixed by modifying back end module clockPartitioning. The function SynchronousFeatures.substClockExp should only wrap the inExp if it is variable (not constant nor parameter expression of type real).

comment:4 by Lennart Ochel, 9 years ago

Resolution: fixed
Status: closedreopened

comment:5 by Lennart Ochel, 9 years ago

Resolution: duplicate
Status: reopenedclosed

comment:6 by Martin Sjölund, 9 years ago

Milestone: 1.9.41.9.4-1.9.x

Milestone renamed

comment:7 by Martin Sjölund, 9 years ago

Milestone: 1.9.4-1.9.x1.9.4

Milestone renamed

Note: See TracTickets for help on using tickets.