forked from OpenModelica/OMSimulator
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix replaceSubModel from memory (OpenModelica#1264)
- Loading branch information
Showing
9 changed files
with
114 additions
and
22 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
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
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
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,44 @@ | ||
## status: correct | ||
## teardown_command: rm -rf replacesubmodel_13_py/ | ||
## linux: no | ||
## mingw32: no | ||
## mingw64: yes | ||
## win: no | ||
## mac: no | ||
|
||
from OMSimulator import OMSimulator | ||
oms = OMSimulator() | ||
|
||
oms.setCommandLineOption("--suppressPath=true") | ||
oms.setTempDirectory("./replacesubmodel_13_py/") | ||
oms.setWorkingDirectory("./replacesubmodel_13_py/") | ||
|
||
oms.newModel("model") | ||
|
||
oms.addSystem("model.root", oms.system_wc) | ||
|
||
oms.addSubModel("model.root.A", "../../resources/replaceA.fmu") | ||
|
||
## priority over modeldescription.xml | ||
oms.setReal("model.root.A.u", 10.0) | ||
|
||
print("info: Before replacing the Model") | ||
print("info: model.root.A.u : " , oms.getReal("model.root.A.u")[0]) | ||
|
||
oms.replaceSubModel("model.root.A", "../../resources/replaceA_extended.fmu", False) | ||
|
||
# src, status = oms.exportSnapshot("model") | ||
# print(src) | ||
|
||
print("info: After replacing the Model") | ||
print("info: model.root.A.u : " , oms.getReal("model.root.A.u")[0]) | ||
|
||
oms.terminate("model") | ||
oms.delete("model") | ||
|
||
## Result: | ||
## info: Before replacing the Model | ||
## info: model.root.A.u : 10.0 | ||
## info: After replacing the Model | ||
## info: model.root.A.u : 10.0 | ||
## endResult |
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,39 @@ | ||
## status: correct | ||
## teardown_command: rm -rf replacesubmodel_14_py/ | ||
## linux: no | ||
## mingw32: no | ||
## mingw64: yes | ||
## win: no | ||
## mac: no | ||
|
||
from OMSimulator import OMSimulator | ||
oms = OMSimulator() | ||
|
||
oms.setCommandLineOption("--suppressPath=true") | ||
oms.setTempDirectory("./replacesubmodel_14_py/") | ||
oms.setWorkingDirectory("./replacesubmodel_14_py/") | ||
|
||
oms.newModel("model") | ||
|
||
oms.addSystem("model.root", oms.system_wc) | ||
|
||
oms.addSubModel("model.root.A", "../../resources/replaceA.fmu") | ||
|
||
print("info: Before replacing the Model") | ||
print("info: model.root.A.u : " , oms.getReal("model.root.A.u")[0]) | ||
|
||
oms.replaceSubModel("model.root.A", "../../resources/replaceA_extended.fmu", False) | ||
|
||
## no priority exists read the new value from modeldescription.xml from the replaced component | ||
print("info: After replacing the Model") | ||
print("info: model.root.A.u : " , oms.getReal("model.root.A.u")[0]) | ||
|
||
oms.terminate("model") | ||
oms.delete("model") | ||
|
||
## Result: | ||
## info: Before replacing the Model | ||
## info: model.root.A.u : 5.0 | ||
## info: After replacing the Model | ||
## info: model.root.A.u : 7.0 | ||
## endResult |