Skip to content

Commit a78d0d2

Browse files
Added test for ticksInState()
1 parent 52d2ee5 commit a78d0d2

File tree

3 files changed

+54
-0
lines changed

3 files changed

+54
-0
lines changed

simulation/modelica/statemachines/Makefile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ TESTFILES = \
44
ConferenceTut1.mos \
55
Maraninchi2003_2.mos \
66
SMMin.mos \
7+
TicksInState.mos \
78

89
# test that currently fail. Move up when fixed.
910
# Run make failingtest
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
within ;
2+
model TicksInState "Test for TicksInState"
3+
inner Integer i(start = 0);
4+
5+
block State1
6+
outer output Integer i;
7+
equation
8+
i = previous(i) + 2;
9+
annotation(Icon(graphics={ Text(extent = {{-100, 100}, {100, -100}}, lineColor = {0, 0, 0}, textString = "%name")}),
10+
Diagram(graphics={ Text(extent = {{-100, 100}, {100, -100}}, lineColor = {0, 0, 0}, textString = "%stateText", fontSize = 10)}), showDiagram = true, singleInstance = true);
11+
end State1;
12+
13+
State1 state1 annotation(Placement(transformation(extent={{-56,62},{-10,76}})));
14+
15+
block State2
16+
outer output Integer i;
17+
equation
18+
i = previous(i) - 1;
19+
annotation(Icon(graphics={ Text(extent = {{-100, 100}, {100, -100}}, lineColor = {0, 0, 0}, textString = "%name")}), Diagram(graphics={ Text(extent = {{-100, 100}, {100, -100}}, lineColor = {0, 0, 0}, textString = "%stateText", fontSize = 10)}), showDiagram = true, singleInstance = true);
20+
end State2;
21+
22+
State2 state2 annotation(Placement(transformation(extent={{-56,40},{-12,54}})));
23+
equation
24+
transition(state1, state2,ticksInState() > 4,
25+
immediate=false, reset=true, synchronize=false, priority=1) annotation(Line(points={{-8,69},
26+
{-4,58},{-10,47}}, color = {175, 175, 175}, thickness = 0.25, smooth = Smooth.Bezier), Text(string = "%condition", extent = {{6, -4}, {6, -10}}, lineColor = {95, 95, 95}, fontSize=10, textStyle = {TextStyle.Bold}, horizontalAlignment = TextAlignment.Left));
27+
transition(state2, state1,ticksInState() > 5,
28+
immediate=false, reset=true, synchronize=false, priority=1) annotation(Line(points={{-58,47},
29+
{-66,58},{-58,69}}, color = {175, 175, 175}, thickness = 0.25, smooth = Smooth.Bezier), Text(string = "%condition", extent = {{-6, 4}, {-6, 10}}, lineColor = {95, 95, 95}, fontSize=10, textStyle = {TextStyle.Bold}, horizontalAlignment = TextAlignment.Right));
30+
initialState(state1) annotation(Line(points={{-34.5336,78},{-36,84}}, color = {175, 175, 175}, thickness = 0.25, smooth = Smooth.Bezier, arrow = {Arrow.Filled, Arrow.None}));
31+
annotation(Diagram(coordinateSystem(preserveAspectRatio = false, extent = {{-100, -100}, {100, 100}}), graphics={ Text(extent = {{-62, 94}, {-12, 84}}, lineColor = {0, 0, 0}, fontSize = 10,
32+
horizontalAlignment = TextAlignment.Left, textString = "%declarations")}));
33+
end TicksInState;
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
// name: TicksInState
2+
// keywords: state machines
3+
// status: correct
4+
//
5+
6+
loadFile("TicksInState.mo");
7+
simulate(TicksInState, startTime=0, stopTime=30, numberOfIntervals=0); getErrorString();
8+
val(i,30.0);
9+
10+
// Result:
11+
// true
12+
// record SimulationResult
13+
// resultFile = "TicksInState_res.mat",
14+
// simulationOptions = "startTime = 0.0, stopTime = 30.0, numberOfIntervals = 0, tolerance = 1e-06, method = 'dassl', fileNamePrefix = 'TicksInState', options = '', outputFormat = 'mat', variableFilter = '.*', cflags = '', simflags = ''",
15+
// messages = ""
16+
// end SimulationResult;
17+
// "Warning: The initial conditions are not fully specified. Use +d=initialization for more information.
18+
// "
19+
// 14.0
20+
// endResult

0 commit comments

Comments
 (0)