Skip to content

Commit

Permalink
Test for transitions APIs.
Browse files Browse the repository at this point in the history
  • Loading branch information
adeas31 authored and OpenModelica-Hudson committed Aug 22, 2016
1 parent f12e83b commit 425e279
Show file tree
Hide file tree
Showing 2 changed files with 56 additions and 0 deletions.
28 changes: 28 additions & 0 deletions openmodelica/interactive-API/StateMachine.mo
@@ -0,0 +1,28 @@
within;
model StateMachine
model State1
end State1;
State1 state1;
model State2
end State2;
State2 state2;
equation
connect(a, b) annotation (Line(
points={{-28,36},{0,72}},
color={175,175,175},
thickness=0.25,
smooth=Smooth.Bezier,
arrow={Arrow.Filled,Arrow.None}));
transition(state1, state2, i > 10, true, immediate=false) annotation (Line(
points={{-8,6},{0,72}},
color={175,175,175},
thickness=0.25,
arrow={Arrow.Filled,Arrow.None}));
initialState(state1);
transition(state2, state1, b > 10, reset=false);
transition(state2, state1, c > 20, false, false, true) annotation (Line(
points={{-8,6},{0,72}},
color={175,175,175},
thickness=0.25,
arrow={Arrow.Filled,Arrow.None}));
end StateMachine;
28 changes: 28 additions & 0 deletions openmodelica/interactive-API/StateMachine.mos
@@ -0,0 +1,28 @@
// name: StateMachine
// keywords:
// status: correct
//
// Tests the getTransitions, addTransition and deleteTransition APIs.
//

loadFile("StateMachine.mo"); getErrorString();
getTransitions(StateMachine); getErrorString();
addTransition(StateMachine, "state1", "state2", "a > 1", annotate = Line(points={{-20,50},{22,34},{-20,6}},color={175,175,175},thickness=0.25,smooth=Smooth.Bezier)); getErrorString();
getTransitions(StateMachine); getErrorString();
deleteTransition(StateMachine, "state1", "state2", "a > 1", true, true, false, 1); getErrorString();
getTransitions(StateMachine); getErrorString();

// Result:
// true
// ""
// {{"state1","state2","i > 10","false","true","false","1","Line(true, {0.0, 0.0}, 0, {{-8, 6}, {0, 72}}, {175, 175, 175}, LinePattern.Solid, 0.25, {Arrow.Filled, Arrow.None}, 3, Smooth.None)"},{"state2","state1","b > 10","true","false","false","1",""},{"state2","state1","c > 20","false","false","true","1","Line(true, {0.0, 0.0}, 0, {{-8, 6}, {0, 72}}, {175, 175, 175}, LinePattern.Solid, 0.25, {Arrow.Filled, Arrow.None}, 3, Smooth.None)"}}
// ""
// true
// ""
// {{"state1","state2","a > 1","true","true","false","1","Line(true, {0.0, 0.0}, 0, {{-20, 50}, {22, 34}, {-20, 6}}, {175, 175, 175}, LinePattern.Solid, 0.25, {Arrow.None, Arrow.None}, 3, Smooth.Bezier)"},{"state1","state2","i > 10","false","true","false","1","Line(true, {0.0, 0.0}, 0, {{-8, 6}, {0, 72}}, {175, 175, 175}, LinePattern.Solid, 0.25, {Arrow.Filled, Arrow.None}, 3, Smooth.None)"},{"state2","state1","b > 10","true","false","false","1",""},{"state2","state1","c > 20","false","false","true","1","Line(true, {0.0, 0.0}, 0, {{-8, 6}, {0, 72}}, {175, 175, 175}, LinePattern.Solid, 0.25, {Arrow.Filled, Arrow.None}, 3, Smooth.None)"}}
// ""
// true
// ""
// {{"state1","state2","i > 10","false","true","false","1","Line(true, {0.0, 0.0}, 0, {{-8, 6}, {0, 72}}, {175, 175, 175}, LinePattern.Solid, 0.25, {Arrow.Filled, Arrow.None}, 3, Smooth.None)"},{"state2","state1","b > 10","true","false","false","1",""},{"state2","state1","c > 20","false","false","true","1","Line(true, {0.0, 0.0}, 0, {{-8, 6}, {0, 72}}, {175, 175, 175}, LinePattern.Solid, 0.25, {Arrow.Filled, Arrow.None}, 3, Smooth.None)"}}
// ""
// endResult

0 comments on commit 425e279

Please sign in to comment.