Skip to content

Commit

Permalink
add test for event clock
Browse files Browse the repository at this point in the history
  • Loading branch information
rfranke committed Feb 29, 2016
1 parent da23935 commit af1d80f
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 0 deletions.
1 change: 1 addition & 0 deletions openmodelica/cppruntime/Makefile
Expand Up @@ -5,6 +5,7 @@ tearnonlin1.mos \
WhenStatement1.mos \
BouncingBall.mos \
clockedTest.mos \
clockedEventTest.mos \
clockedTypesTest.mos \
mathFunctionsTest.mos \
functionPointerTest.mos \
Expand Down
40 changes: 40 additions & 0 deletions openmodelica/cppruntime/clockedEventTest.mos
@@ -0,0 +1,40 @@
// name: clockedEventTest
// keywords: synchronous clocked equations
// status: correct
// teardown_command: rm -f *EvenClock*

setCommandLineOptions("+simCodeTarget=Cpp");

loadString("
model EventClock
Boolean pulse(start = false, fixed = true);
Integer count(start = 0);
equation
when sample(0, 0.1) then
pulse = not pre(pulse);
end when;
when Clock(pulse) then
count = previous(count) + 1;
end when;
end EventClock;
");
getErrorString();

simulate(EventClock);
val(count, 0.0);
val(count, 1.0);
getErrorString();

// Result:
// true
// true
// ""
// record SimulationResult
// resultFile = "EventClock_res.mat",
// simulationOptions = "startTime = 0.0, stopTime = 1.0, numberOfIntervals = 500, tolerance = 1e-06, method = 'dassl', fileNamePrefix = 'EventClock', options = '', outputFormat = 'mat', variableFilter = '.*', cflags = '', simflags = ''",
// messages = ""
// end SimulationResult;
// 1.0
// 6.0
// ""
// endResult

0 comments on commit af1d80f

Please sign in to comment.