Skip to content

Commit

Permalink
add test for different types of clocked variables
Browse files Browse the repository at this point in the history
  • Loading branch information
rfranke committed Oct 14, 2015
1 parent 18ff445 commit 47f4c84
Show file tree
Hide file tree
Showing 2 changed files with 52 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 \
clockedTypesTest.mos \
mathFunctionsTest.mos \
functionPointerTest.mos \
recordTupleReturnTest.mos \
Expand Down
51 changes: 51 additions & 0 deletions openmodelica/cppruntime/clockedTypesTest.mos
@@ -0,0 +1,51 @@
// name: clockedTypesTest
// keywords: synchronous clocked equations types
// status: correct
// teardown_command: rm -f *ClockedTypes*

setCommandLineOptions("+simCodeTarget=Cpp");

loadString("
model ClockedTypes
Boolean firstTick(start = true);
Boolean pulse(start = false);
Integer counter(start = 0);
String text(start = \"\");
equation
when Clock(0.5) then
firstTick = false;
pulse = not previous(pulse);
counter = previous(counter) + 1;
text = previous(text) + \", \" + String(counter);
end when;
end ClockedTypes;
");
getErrorString();

simulate(ClockedTypes);
val(firstTick, 0.0);
val(firstTick, 1.0);
val(pulse, 0.0);
val(pulse, 1.0);
val(counter, 0.0);
val(counter, 1.0);
//val(text, 1.0); // not supported in results file?
getErrorString();

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

0 comments on commit 47f4c84

Please sign in to comment.