1 | package TwoStatesMachine2
|
---|
2 | model State1
|
---|
3 | outer output Integer i;
|
---|
4 | equation
|
---|
5 | i = previous(i)+2;
|
---|
6 | annotation(
|
---|
7 | Icon(graphics = {Text(extent = {{-100, 100}, {100, -100}}, textString = "%name")}, coordinateSystem(initialScale = 0.1)),
|
---|
8 | __Dymola_state = true,
|
---|
9 | singleInstance = true,
|
---|
10 | Diagram(coordinateSystem(extent = {{-200, -100}, {200, 100}})));
|
---|
11 | end State1;
|
---|
12 |
|
---|
13 | model State2
|
---|
14 | outer output Integer i;
|
---|
15 | equation
|
---|
16 | i = previous(i)-1;
|
---|
17 |
|
---|
18 | annotation(
|
---|
19 | Icon(graphics = {Text(extent = {{-100, 100}, {100, -100}}, textString = "%name")}, coordinateSystem(initialScale = 0.1)),
|
---|
20 | __Dymola_state = true,
|
---|
21 | singleInstance = true,
|
---|
22 | Diagram(coordinateSystem(extent = {{-200, -100}, {200, 100}})));
|
---|
23 | end State2;
|
---|
24 |
|
---|
25 | model Machine
|
---|
26 | inner Integer i(start=0);
|
---|
27 | TwoStatesMachine2.State1 state1 annotation(
|
---|
28 | Placement(visible = true, transformation(origin = {-12, 50}, extent = {{-10, -10}, {10, 10}}, rotation = 0)));
|
---|
29 | TwoStatesMachine2.State2 state2 annotation(
|
---|
30 | Placement(visible = true, transformation(origin = {-12, 10}, extent = {{-10, -10}, {10, 10}}, rotation = 0)));
|
---|
31 | annotation(
|
---|
32 | Icon(coordinateSystem(grid = {0.1, 0.1})),
|
---|
33 | Diagram(coordinateSystem(extent = {{-200, -100}, {200, 100}})));
|
---|
34 | end Machine;
|
---|
35 |
|
---|
36 |
|
---|
37 |
|
---|
38 | annotation(
|
---|
39 | Icon(coordinateSystem(grid = {0.1, 0.1})),
|
---|
40 | Diagram(coordinateSystem(extent = {{-200, -100}, {200, 100}})));
|
---|
41 | end TwoStatesMachine2;
|
---|