From 0844b0d2624bc9b7ae9d6fafd189a75f837e0a4e Mon Sep 17 00:00:00 2001 From: Bernhard Thiele Date: Fri, 12 Jan 2018 11:49:41 +0100 Subject: [PATCH] Test for Ticket:4618 Belonging to [master]: - OpenModelica/OMCompiler#2105 - OpenModelica/OpenModelica-testsuite#818 --- simulation/modelica/statemachines/Makefile | 1 + .../modelica/statemachines/Ticket4618.mo | 27 +++++++++++++++++++ .../modelica/statemachines/Ticket4618.mos | 19 +++++++++++++ 3 files changed, 47 insertions(+) create mode 100644 simulation/modelica/statemachines/Ticket4618.mo create mode 100644 simulation/modelica/statemachines/Ticket4618.mos diff --git a/simulation/modelica/statemachines/Makefile b/simulation/modelica/statemachines/Makefile index 27b878952..533fe5897 100644 --- a/simulation/modelica/statemachines/Makefile +++ b/simulation/modelica/statemachines/Makefile @@ -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 diff --git a/simulation/modelica/statemachines/Ticket4618.mo b/simulation/modelica/statemachines/Ticket4618.mo new file mode 100644 index 000000000..d9b261e66 --- /dev/null +++ b/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; diff --git a/simulation/modelica/statemachines/Ticket4618.mos b/simulation/modelica/statemachines/Ticket4618.mos new file mode 100644 index 000000000..941e26c7c --- /dev/null +++ b/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