Skip to content

Commit

Permalink
Test for Ticket:4618
Browse files Browse the repository at this point in the history
  • Loading branch information
bernhard-thiele authored and OpenModelica-Hudson committed Jan 12, 2018
1 parent 7a63969 commit 0844b0d
Show file tree
Hide file tree
Showing 3 changed files with 47 additions and 0 deletions.
1 change: 1 addition & 0 deletions simulation/modelica/statemachines/Makefile
Expand Up @@ -12,6 +12,7 @@ ticket4271.mos \
EnteringByReset.mos \
ConferenceTut1DeadEnd.mos \
SMGraphicalTestCases_DeepHierarchy.mos \
Ticket4618.mos \

# test that currently fail. Move up when fixed.
# Run make failingtest
Expand Down
27 changes: 27 additions & 0 deletions simulation/modelica/statemachines/Ticket4618.mo
@@ -0,0 +1,27 @@
model Ticket4618
firstState s1;
secondState s2;
Real t;
inner Clock c = Clock(0.1);
block firstState
Real x1;
outer Clock c;
equation
when c then
x1 = previous(x1)+interval();
end when;
end firstState;

block secondState
Real x2;
outer Clock c;
equation
when c then
x2 = previous(x2)+interval();
end when;
end secondState;
equation
t = sample(time,c);
initialState(s1);
transition(s1, s2, t > 0.5, immediate = false, reset = true, synchronize = false, priority = 1);
end Ticket4618;
19 changes: 19 additions & 0 deletions simulation/modelica/statemachines/Ticket4618.mos
@@ -0,0 +1,19 @@
// name: Ticket4618
// keywords: state machines
// status: correct
//

loadFile("Ticket4618.mo");
echo(false);
setCommandLineOptions("--simCodeTarget=Cpp"); getErrorString();
simulate(Ticket4618, startTime=0, stopTime=1.0, numberOfIntervals=0); getErrorString();
echo(true);
val(s1.x1,1.0);
val(s2.x2,1.0);

// Result:
// true
// true
// 0.7
// 0.4
// endResult

0 comments on commit 0844b0d

Please sign in to comment.