WOLFRAM SYSTEM MODELER
StateMachinesState Machines |
|
SystemModel["ModelicaReference.StateMachines"]

This information is part of the Modelica Standard Library maintained by the Modelica Association.
The state machines defined in the Modelica Language are based on the synchronous language elements. Note that the state machines defined in the Modelica Standard Library are not based on this.
inner Integer v(start=0);
block Increase
outer output Integer v;
equation
v = previous(v) + 2;
end Increase;
Increase increase;
block Decrease
outer output Integer v;
equation
v = previous(v) - 1;
end Decrease;
Decrease decrease;
equation
initialState(increase);
transition(increase, decrease, v>=6, immediate=false);
transition(decrease, increase, v==0, immediate=false);
In this example we will start in increase and increase v until a limit, and then decrease it, and repeat.