To perform a simulation we need the following:
These FMU’s are cross compiles to all supported platforms:
Also fetch the COE, see the download page.
This is just a proposed file structure, chose what you like.
coe.jar
hereCreate a file named config.json
with the following content:
{
"fmus":{
"{fmu1}":"../fmus/tankcontroller.fmu",
"{fmu2}":"../fmus/tank.fmu"
},
"connections":{
"{fmu1}.controller.valve":
["{fmu2}.tank.valve"],
"{fmu2}.tank.level":
["{fmu1}.controller.level"]
},
"parameters":{
"{fmu1}.controller.maxLevel":8,
"{fmu1}.controller.minLevel":2
},
"algorithm":{
"type":"fixed-step",
"size":0.1
}
}
Note that the connections is Output to Inputs i.e. a map from String -> Set of String. So here "a":["b","c"]
means that input b
and c
is provided by a
.
cd coe
java -jar coe.jar
sessionIdJson=$(curl -s http://localhost:8082/createSession)
sessionId=`echo $sessionIdJson | cut -d ":" -f 2- | cut -d "}" -f 1`
curl -s -H "Content-Type: application/json" --data @config.json http://localhost:8082/initialize/$sessionId
endTime=4
curl -s -H "Content-Type: application/json" --data '{"startTime":0.0, "endTime":'$endTime'}' http://localhost:8082/simulate/$sessionId
note that the above json string must be expressed as follows on windows platforms:
--data "{\"startTime\":0.0, \"endTime\":%endTime%}"
curl -s http://localhost:8082/result/$sessionId