Opened 7 years ago

Closed 7 years ago

#4618 closed defect (fixed)

states in statemachine are computed when they are not activated

Reported by: Volker Waurich Owned by: Bernhard Thiele
Priority: high Milestone: Future
Component: Frontend Version:
Keywords: statemachine Cc: Adrian Pop, Martin Sjölund, Lennart Ochel

Description

Hi,

Please consider the attached model.
There are 2 states which are calculating the sum of a variable with its previous value at each tick. If I understood correctly, equations in a statemachine are only active if the state is active, but omc calculates alle equations in all states no matter which one is active. So s2.x2 should be 0 until s2 is activated.

Attachments (2)

stateMachine.mo (596 bytes ) - added by Volker Waurich 7 years ago.
stateMachine2.mo (459 bytes ) - added by Bernhard Thiele 7 years ago.
Modified stateMachine.mo example without when-clause

Download all attachments as: .zip

Change History (5)

by Volker Waurich, 7 years ago

Attachment: stateMachine.mo added

by Bernhard Thiele, 7 years ago

Attachment: stateMachine2.mo added

Modified stateMachine.mo example without when-clause

comment:1 by Bernhard Thiele, 7 years ago

Okay, I haven't tested models which use when Clock(c) then within states. It is redundant in the sense that clock inference will ensure that all equations within a state machine run on the same clock (a modified example is attached). However, it is not forbidden to use the construct in the way as you do in the example, so it needs to be fixed.

comment:2 by Volker Waurich, 7 years ago

Thank you for the remark. The when construct occurs when using Modelica_Synchronous.RealSignals.Periodic.PI. Using a discrete PI-blocks without when works perfectly with omc.

comment:3 by Bernhard Thiele, 7 years ago

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