Skip to content

Commit

Permalink
add booolean sub clock test for cpp
Browse files Browse the repository at this point in the history
  • Loading branch information
vwaurich authored and OpenModelica-Hudson committed Apr 27, 2017
1 parent bcc9445 commit c0043fe
Show file tree
Hide file tree
Showing 3 changed files with 109 additions and 0 deletions.
1 change: 1 addition & 0 deletions simulation/modelica/synchronous/Makefile
@@ -1,6 +1,7 @@
TEST = ../../../rtest -v

TESTFILES = \
boolSubClocks.mos \
Bug3503.mos \
EventClock.mos \
EventClock_cpp.mos \
Expand Down
56 changes: 56 additions & 0 deletions simulation/modelica/synchronous/boolSubClocks.mo
@@ -0,0 +1,56 @@
within ;
model boolSubClocks
// Rational interval clock 1
Clock u = Clock(3, 10); // ticks: 0, 3/10, 6/10
Clock y1 = shiftSample(u,3); // ticks: 9/10, 12/10,
Clock y2 = backSample(y1,2); // ticks: 3/10, 6/10,
//Clock y3 = backSample(y1,4); // error (ticks before u)
Clock y4 = shiftSample(u,2,3); // ticks: 2/10, 5/10,
Clock y5 = backSample(y4,1,3); // ticks: 1/10, 4/10,
// Boolean clock
Clock v = Clock(sin(2*Modelica.Constants.pi*time) > 0, 0); // ticks: 0, 1.0, 2.0, 3.0,
Clock z1 = shiftSample(v,3); // ticks: 3.0, 4.0,
Clock z2 = backSample(z1,2); // ticks: 1.0, 2.0,

Real x1,x2,x3,x4,x5,x6;
Real a1,a2,a3;
Real b1,b2;
equation
when sample(1.3, 0.5) then
b1 = time;
end when;
when u then
x1 = sample(time);
end when;
when y1 then
x2 = sample(time);
end when;
when y2 then
x3 = sample(time);
end when;
when y4 then
x4 = sample(time);
end when;
when y5 then
x5 = sample(time);
end when;
when u then
x6 = sample(time);
end when;

when v then
a1 = sample(time);
end when;
when z1 then
a2 = sample(time);
end when;
when z2 then
a3 = sample(time);
end when;
when sample(0.8, 1.5) then
b2 = 1.5*time;
end when;
annotation (uses(Modelica(version="3.2.1")),
experiment(StopTime=5),
__Dymola_experimentSetupOutput);
end boolSubClocks;
52 changes: 52 additions & 0 deletions simulation/modelica/synchronous/boolSubClocks.mos
@@ -0,0 +1,52 @@
// name: boolSubClocks
// keywords: synchronous features, cpp
// status: correct
//
loadModel(Modelica, languageStandard="3.3");getErrorString();

loadFile("boolSubClocks.mo");
setCommandLineOptions("+simCodeTarget=Cpp"); getErrorString();

simulate(boolSubClocks); getErrorString();
val(a1,2.5);
val(a2,2.5);
val(a2,3.0);
val(a3,2.5);
val(x1,0.5);
val(x1,1.0);
val(x2,0.5);
val(x2,1.0);
val(x3,2.5);
val(x4,0.5);
val(x4,1.0);
val(x5,0.5);
val(x5,1.0);

// Result:
// true
// ""
// true
// true
// ""
// record SimulationResult
// resultFile = "boolSubClocks_res.mat",
// simulationOptions = "startTime = 0.0, stopTime = 5.0, numberOfIntervals = 500, tolerance = 1e-006, method = 'dassl', fileNamePrefix = 'boolSubClocks', options = '', outputFormat = 'mat', variableFilter = '.*', cflags = '', simflags = ''",
// messages = ""
// end SimulationResult;
// "Warning: Requested package Modelica of version 3.2.1, but this package was already loaded with version 3.2.2. You might experience problems if these versions are incompatible.
// Warning: The initial conditions are not fully specified. For more information set -d=initialization. In OMEdit Tools->Options->Simulation->OMCFlags, in OMNotebook call setCommandLineOptions("-d=initialization").
// "
// 2.000000000159155
// 0.0
// 0.0
// 2.000000000159155
// 0.3
// 0.8999999999999999
// 0.0
// 0.8999999999999999
// 2.4
// 0.5
// 0.8
// 0.4
// 1.0
// endResult

0 comments on commit c0043fe

Please sign in to comment.