-
Notifications
You must be signed in to change notification settings - Fork 49
/
renameNewCref_1.lua
95 lines (87 loc) · 2.55 KB
/
renameNewCref_1.lua
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
-- status: correct
-- teardown_command: rm -rf renameNewCref_1_lua/
-- linux: yes
-- ucrt64: yes
-- win: yes
-- mac: yes
oms_setCommandLineOption("--suppressPath=true")
oms_setTempDirectory("./renameNewCref_1_lua/")
oms_setWorkingDirectory("./renameNewCref_1_lua/")
oms_newModel("model")
oms_addSystem("model.root", oms_system_wc)
oms_addSubModel("model.root.gain", "../../resources/Modelica.Blocks.Math.Gain.fmu")
-- error snapshot as subcomponent gain is missing
systemSnapshot = [[
<?xml version="1.0"?>
<oms:snapshot
partial="true">
<oms:file
name="SystemStructure.ssd"
node="model.root">
<ssd:System
name="root_3">
<ssd:Annotations>
<ssc:Annotation
type="org.openmodelica">
<oms:Annotations>
<oms:SimulationInformation>
<oms:FixedStepMaster
description="oms-ma"
stepSize="0.100000"
absoluteTolerance="0.000100"
relativeTolerance="0.000100" />
</oms:SimulationInformation>
</oms:Annotations>
</ssc:Annotation>
</ssd:Annotations>
</ssd:System>
</oms:file>
</oms:snapshot>
]]
newcref, status = oms_importSnapshot("model", systemSnapshot)
print(newcref)
componentSnapshot = [[
<?xml version="1.0"?>
<oms:snapshot
xmlns:oms="https://raw.githubusercontent.com/OpenModelica/OMSimulator/master/schema/oms.xsd"
partial="true">
<oms:file
name="SystemStructure.ssd"
node="model.root.gain">
<ssd:Component
name="gain_1"
type="application/x-fmu-sharedlibrary"
source="resources/0001_gain.fmu">
<ssd:Connectors>
<ssd:Connector
name="u"
kind="input">
<ssc:Real />
<ssd:ConnectorGeometry
x="0.000000"
y="0.500000" />
</ssd:Connector>
<ssd:Connector
name="y"
kind="output">
<ssc:Real />
<ssd:ConnectorGeometry
x="1.000000"
y="0.500000" />
</ssd:Connector>
<ssd:Connector
name="k"
kind="parameter">
<ssc:Real />
</ssd:Connector>
</ssd:Connectors>
</ssd:Component>
</oms:file>
</oms:snapshot>
]]
newcref, status = oms_importSnapshot("model", componentSnapshot)
print(newcref)
-- Result:
-- root_3
-- gain_1
-- endResult