Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
90 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,89 @@ | ||
// keywords: fmu export import | ||
// status: correct | ||
// teardown_command: rm -rf reset.lua reset.fmu reset.log reset_systemCall.log temp-reset/ | ||
|
||
loadString(" | ||
model reset | ||
parameter Real a = -1; | ||
parameter Real x_start = 1; | ||
Real x(start=x_start, fixed=true); | ||
equation | ||
der(x) = a*x; | ||
end reset;"); getErrorString(); | ||
|
||
buildModelFMU(reset, version="2.0", fmuType="cs", platforms={"static"}); getErrorString(); | ||
|
||
writeFile("reset.lua", " | ||
oms_setCommandLineOption(\"--suppressPath=true\") | ||
oms_setTempDirectory(\"./temp-reset/\") | ||
|
||
oms_newModel(\"test\") | ||
oms_addSystem(\"test.root\", oms_system_wc) | ||
oms_addSubModel(\"test.root.A\", \"reset.fmu\") | ||
oms_setResultFile(\"test\", \"\") | ||
|
||
oms_instantiate(\"test\") | ||
oms_initialize(\"test\") | ||
|
||
print(\"info: Initialization\") | ||
print(\"info: A.x_start: \" .. oms_getReal(\"test.root.A.x_start\")) | ||
print(\"info: A.x: \" .. oms_getReal(\"test.root.A.x\")) | ||
|
||
oms_simulate(\"test\") | ||
print(\"info: Simulation\") | ||
print(\"info: A.x_start: \" .. oms_getReal(\"test.root.A.x_start\")) | ||
print(\"info: A.x: \" .. oms_getReal(\"test.root.A.x\")) | ||
|
||
for i=1,2 do | ||
oms_reset(\"test\") | ||
oms_setReal(\"test.root.A.x_start\", 1.5) | ||
oms_initialize(\"test\") | ||
|
||
print(\"info: Initialization\") | ||
print(\"info: A.x_start: \" .. oms_getReal(\"test.root.A.x_start\")) | ||
print(\"info: A.x: \" .. oms_getReal(\"test.root.A.x\")) | ||
|
||
oms_simulate(\"test\") | ||
print(\"info: Simulation\") | ||
print(\"info: A.x_start: \" .. oms_getReal(\"test.root.A.x_start\")) | ||
print(\"info: A.x: \" .. oms_getReal(\"test.root.A.x\")) | ||
end | ||
|
||
oms_terminate(\"test\") | ||
oms_delete(\"test\") | ||
"); getErrorString(); | ||
|
||
system(getInstallationDirectoryPath() + "/bin/OMSimulator reset.lua", "reset_systemCall.log"); | ||
readFile("reset_systemCall.log"); | ||
|
||
// Result: | ||
// true | ||
// "" | ||
// "reset.fmu" | ||
// "" | ||
// true | ||
// "" | ||
// 0 | ||
// "info: No result file will be created | ||
// info: Initialization | ||
// info: A.x_start: 1.0 | ||
// info: A.x: 1.0 | ||
// info: Simulation | ||
// info: A.x_start: 1.0 | ||
// info: A.x: 0.3486784401 | ||
// info: No result file will be created | ||
// info: Initialization | ||
// info: A.x_start: 1.5 | ||
// info: A.x: 1.5 | ||
// info: Simulation | ||
// info: A.x_start: 1.5 | ||
// info: A.x: 0.52301766015 | ||
// info: No result file will be created | ||
// info: Initialization | ||
// info: A.x_start: 1.5 | ||
// info: A.x: 1.5 | ||
// info: Simulation | ||
// info: A.x_start: 1.5 | ||
// info: A.x: 0.52301766015 | ||
// " | ||
// endResult |