Skip to content

Commit

Permalink
Added test for ticksInState()
Browse files Browse the repository at this point in the history
  • Loading branch information
bernhard-thiele committed Sep 13, 2015
1 parent 52d2ee5 commit a78d0d2
Show file tree
Hide file tree
Showing 3 changed files with 54 additions and 0 deletions.
1 change: 1 addition & 0 deletions simulation/modelica/statemachines/Makefile
Expand Up @@ -4,6 +4,7 @@ TESTFILES = \
ConferenceTut1.mos \
Maraninchi2003_2.mos \
SMMin.mos \
TicksInState.mos \

# test that currently fail. Move up when fixed.
# Run make failingtest
Expand Down
33 changes: 33 additions & 0 deletions simulation/modelica/statemachines/TicksInState.mo
@@ -0,0 +1,33 @@
within ;
model TicksInState "Test for TicksInState"
inner Integer i(start = 0);

block State1
outer output Integer i;
equation
i = previous(i) + 2;
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);
end State1;

State1 state1 annotation(Placement(transformation(extent={{-56,62},{-10,76}})));

block State2
outer output Integer i;
equation
i = previous(i) - 1;
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);
end State2;

State2 state2 annotation(Placement(transformation(extent={{-56,40},{-12,54}})));
equation
transition(state1, state2,ticksInState() > 4,
immediate=false, reset=true, synchronize=false, priority=1) annotation(Line(points={{-8,69},
{-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));
transition(state2, state1,ticksInState() > 5,
immediate=false, reset=true, synchronize=false, priority=1) annotation(Line(points={{-58,47},
{-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));
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}));
annotation(Diagram(coordinateSystem(preserveAspectRatio = false, extent = {{-100, -100}, {100, 100}}), graphics={ Text(extent = {{-62, 94}, {-12, 84}}, lineColor = {0, 0, 0}, fontSize = 10,
horizontalAlignment = TextAlignment.Left, textString = "%declarations")}));
end TicksInState;
20 changes: 20 additions & 0 deletions simulation/modelica/statemachines/TicksInState.mos
@@ -0,0 +1,20 @@
// name: TicksInState
// keywords: state machines
// status: correct
//

loadFile("TicksInState.mo");
simulate(TicksInState, startTime=0, stopTime=30, numberOfIntervals=0); getErrorString();
val(i,30.0);

// Result:
// true
// record SimulationResult
// resultFile = "TicksInState_res.mat",
// simulationOptions = "startTime = 0.0, stopTime = 30.0, numberOfIntervals = 0, tolerance = 1e-06, method = 'dassl', fileNamePrefix = 'TicksInState', options = '', outputFormat = 'mat', variableFilter = '.*', cflags = '', simflags = ''",
// messages = ""
// end SimulationResult;
// "Warning: The initial conditions are not fully specified. Use +d=initialization for more information.
// "
// 14.0
// endResult

0 comments on commit a78d0d2

Please sign in to comment.