Skip to content

Commit

Permalink
add a simple alternative test for Cpp FMI 1.0
Browse files Browse the repository at this point in the history
  • Loading branch information
rfranke committed Sep 16, 2015
1 parent 555c096 commit 9bc75fc
Show file tree
Hide file tree
Showing 2 changed files with 60 additions and 0 deletions.
59 changes: 59 additions & 0 deletions openmodelica/cppruntime/fmu/modelExchange/1.0/DIC_FMU1_CPP.mos
@@ -0,0 +1,59 @@
// name: DIC_FMU1_CPP
// keywords: double integrator FMI-Export FMI-Import
// status: correct
// teardown_command: rm -rf binaries sources modelDescription.xml DIC.fmu *DIC*.so OMCppDIC*.cpp OMCppDIC*.h OMCppDIC*.o DIC*.json DIC_me_FMU.mo
// Real variables, Real input variable, continuous-time states, state events, event iteration

setCommandLineOptions("+simCodeTarget=Cpp"); getErrorString();
loadString("
model DIC
parameter Real p = 1;
parameter Real y1_start = 1;
parameter Real y2_start = 0;
input Real u(start = 0);
output Real y1, y2;
initial equation
y1 = y1_start;
y2 = y2_start;
equation
der(y1) = p * (u - 2);
der(y2) = y1;
end DIC;
");
translateModelFMU(DIC, version = "2.0"); getErrorString();

loadModel(Modelica); getErrorString();
importFMU("DIC.fmu"); getErrorString();
loadFile("DIC_me_FMU.mo"); getErrorString();
simulate(DIC_me_FMU); getErrorString();

val(u, 0);
val(y1, 0);
val(y2, 0);
val(y1, 1);
val(y2, 1);

// Result:
// true
// ""
// true
// "SimCode: The model DIC has been translated to FMU"
// ""
// true
// ""
// "DIC_me_FMU.mo"
// ""
// true
// ""
// record SimulationResult
// resultFile = "DIC_me_FMU_res.mat",
// simulationOptions = "startTime = 0.0, stopTime = 1.0, numberOfIntervals = 500, tolerance = 1e-06, method = 'dassl', fileNamePrefix = 'DIC_me_FMU', options = '', outputFormat = 'mat', variableFilter = '.*', cflags = '', simflags = ''",
// messages = ""
// end SimulationResult;
// ""
// 0.0
// 1.0
// 0.0
// -1.0
// 0.0
// endResult
1 change: 1 addition & 0 deletions openmodelica/cppruntime/fmu/modelExchange/1.0/Makefile
Expand Up @@ -2,6 +2,7 @@ TEST = ../../../../../rtest -v


TESTFILES = \
DIC_FMU1_CPP.mos

FAILINGTESTFILES = \
Crane_FMU1_CPP.mos \
Expand Down

0 comments on commit 9bc75fc

Please sign in to comment.