Ticket #4618: stateMachine.mo

File stateMachine.mo, 596 bytes (added by Volker Waurich, 7 years ago)
Line 
1model stateMachine
2
3 firstState s1;
4 secondState s2;
5 Real t;
6 inner Clock c = Clock(0.01);
7
8 block firstState
9 Real x1;
10 outer Clock c;
11 equation
12 when c then
13 x1 = previous(x1)+interval();
14 end when;
15 end firstState;
16
17 block secondState
18 Real x2;
19 outer Clock c;
20 equation
21 when c then
22 x2 = previous(x2)+interval();
23 end when;
24 end secondState;
25
26equation
27 t = sample(time,c);
28 initialState(s1);
29 transition(s1, s2, t > 0.5, immediate= false, reset= true, synchronize= false, priority= 1);
30
31end stateMachine;