Skip to content

Commit

Permalink
Added test case for state machines
Browse files Browse the repository at this point in the history
The test case is currently failing. See FIXME statement in function
StateMachineFlatten.addStateActivationAndReset(..).
  • Loading branch information
bernhard-thiele authored and OpenModelica-Hudson committed Feb 20, 2017
1 parent 13853a5 commit cd62054
Show file tree
Hide file tree
Showing 3 changed files with 53 additions and 1 deletion.
25 changes: 25 additions & 0 deletions simulation/modelica/statemachines/AccessFromOutside.mo
@@ -0,0 +1,25 @@
model AccessFromOutside "Access previous value from local state variable from outside"
output Real y;
model State1
output Integer i(start=2);
equation
i = previous(i) + 2;
end State1;
State1 state1;
model State2
end State2;
State2 state2;
equation
initialState(state1);
transition(
state1,
state2,
state1.i > 10,
immediate=false);
transition(
state2,
state1,
true,
immediate=false);
y = previous(state1.i);
end AccessFromOutside;
27 changes: 27 additions & 0 deletions simulation/modelica/statemachines/AccessFromOutside.mos
@@ -0,0 +1,27 @@
// name: AccessFromOutside
// keywords: state machines
// status: correct
//

loadFile("AccessFromOutside.mo");
echo(false);
setCommandLineOptions({"+simCodeTarget=Cpp"}); getErrorString();
simulate(AccessFromOutside, startTime=0, stopTime=10, numberOfIntervals = 0); getErrorString();
echo(true);
val(state1.i,4.0);
val(y,4.0);
val(state1.i,5.0);
val(y,5.0);
val(state1.i,6.0);
val(y,6.0);

// Result:
// true
// true
// 12.0
// 10.0
// 12.0
// 12.0
// 4.0
// 2.0
// endResult
2 changes: 1 addition & 1 deletion simulation/modelica/statemachines/Makefile
Expand Up @@ -15,7 +15,7 @@ EnteringByReset.mos \
# Run make failingtest
FAILINGTESTFILES = \
SingleState.mos \

AccessFromOutside.mos \

# Dependency files that are not .mo .mos or Makefile
# Add them here or they will be cleaned.
Expand Down

0 comments on commit cd62054

Please sign in to comment.