-
Notifications
You must be signed in to change notification settings - Fork 49
/
snapshot.lua
198 lines (188 loc) · 6.24 KB
/
snapshot.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
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
-- status: correct
-- teardown_command: rm -rf snapshot_lua/
-- linux: yes
-- ucrt64: yes
-- win: yes
-- mac: no
oms_setCommandLineOption("--suppressPath=true")
oms_setTempDirectory("./snapshot_lua/")
oms_setWorkingDirectory("./snapshot_lua/")
oms_newModel("snapshot")
oms_addSystem("snapshot.root", oms_system_wc)
oms_newResources("snapshot.root:snapshot.ssv")
oms_addConnector("snapshot.root.C1", oms_causality_input, oms_signal_type_real)
oms_setReal("snapshot.root.C1", -10)
oms_addSubModel("snapshot.root.add", "../../resources/Modelica.Blocks.Math.Add.fmu")
oms_setReal("snapshot.root.add.u1", 10)
oms_setReal("snapshot.root.add.k1", 30)
snapshot = oms_exportSnapshot("snapshot")
--print(snapshot)
oms_setReal("snapshot.root.add.u1", 3.5)
oms_importSnapshot("snapshot", snapshot)
snapshot = oms_exportSnapshot("snapshot")
print(snapshot)
oms_delete("snapshot")
-- Result:
-- <?xml version="1.0"?>
-- <oms:snapshot
-- xmlns:oms="https://raw.githubusercontent.com/OpenModelica/OMSimulator/master/schema/oms.xsd"
-- partial="false">
-- <oms:file
-- name="SystemStructure.ssd">
-- <ssd:SystemStructureDescription
-- xmlns:ssc="http://ssp-standard.org/SSP1/SystemStructureCommon"
-- xmlns:ssd="http://ssp-standard.org/SSP1/SystemStructureDescription"
-- xmlns:ssv="http://ssp-standard.org/SSP1/SystemStructureParameterValues"
-- xmlns:ssm="http://ssp-standard.org/SSP1/SystemStructureParameterMapping"
-- xmlns:ssb="http://ssp-standard.org/SSP1/SystemStructureSignalDictionary"
-- xmlns:oms="https://raw.githubusercontent.com/OpenModelica/OMSimulator/master/schema/oms.xsd"
-- name="snapshot"
-- version="1.0">
-- <ssd:System
-- name="root">
-- <ssd:Connectors>
-- <ssd:Connector
-- name="C1"
-- kind="input">
-- <ssc:Real />
-- </ssd:Connector>
-- </ssd:Connectors>
-- <ssd:ParameterBindings>
-- <ssd:ParameterBinding
-- source="resources/snapshot.ssv" />
-- </ssd:ParameterBindings>
-- <ssd:Elements>
-- <ssd:Component
-- name="add"
-- type="application/x-fmu-sharedlibrary"
-- source="resources/0001_add.fmu">
-- <ssd:Connectors>
-- <ssd:Connector
-- name="u1"
-- kind="input">
-- <ssc:Real />
-- <ssd:ConnectorGeometry
-- x="0.000000"
-- y="0.333333" />
-- </ssd:Connector>
-- <ssd:Connector
-- name="u2"
-- kind="input">
-- <ssc:Real />
-- <ssd:ConnectorGeometry
-- x="0.000000"
-- y="0.666667" />
-- </ssd:Connector>
-- <ssd:Connector
-- name="y"
-- kind="output">
-- <ssc:Real />
-- <ssd:ConnectorGeometry
-- x="1.000000"
-- y="0.500000" />
-- </ssd:Connector>
-- <ssd:Connector
-- name="k1"
-- kind="parameter">
-- <ssc:Real />
-- </ssd:Connector>
-- <ssd:Connector
-- name="k2"
-- kind="parameter">
-- <ssc:Real />
-- </ssd:Connector>
-- </ssd:Connectors>
-- </ssd:Component>
-- </ssd:Elements>
-- <ssd:Annotations>
-- <ssc:Annotation
-- type="org.openmodelica">
-- <oms:Annotations>
-- <oms:SimulationInformation>
-- <oms:FixedStepMaster
-- description="oms-ma"
-- stepSize="0.001000"
-- absoluteTolerance="0.000100"
-- relativeTolerance="0.000100" />
-- </oms:SimulationInformation>
-- </oms:Annotations>
-- </ssc:Annotation>
-- </ssd:Annotations>
-- </ssd:System>
-- <ssd:DefaultExperiment
-- startTime="0.000000"
-- stopTime="1.000000">
-- <ssd:Annotations>
-- <ssc:Annotation
-- type="org.openmodelica">
-- <oms:Annotations>
-- <oms:SimulationInformation
-- resultFile="snapshot_res.mat"
-- loggingInterval="0.000000"
-- bufferSize="10"
-- signalFilter="resources/signalFilter.xml" />
-- </oms:Annotations>
-- </ssc:Annotation>
-- </ssd:Annotations>
-- </ssd:DefaultExperiment>
-- </ssd:SystemStructureDescription>
-- </oms:file>
-- <oms:file
-- name="resources/snapshot.ssv">
-- <ssv:ParameterSet
-- xmlns:ssc="http://ssp-standard.org/SSP1/SystemStructureCommon"
-- xmlns:ssv="http://ssp-standard.org/SSP1/SystemStructureParameterValues"
-- version="1.0"
-- name="parameters">
-- <ssv:Parameters>
-- <ssv:Parameter
-- name="add.u1">
-- <ssv:Real
-- value="10" />
-- </ssv:Parameter>
-- <ssv:Parameter
-- name="add.k1">
-- <ssv:Real
-- value="30" />
-- </ssv:Parameter>
-- <ssv:Parameter
-- name="C1">
-- <ssv:Real
-- value="-10" />
-- </ssv:Parameter>
-- </ssv:Parameters>
-- </ssv:ParameterSet>
-- </oms:file>
-- <oms:file
-- name="resources/signalFilter.xml">
-- <oms:SignalFilter
-- version="1.0">
-- <oms:Variable
-- name="snapshot.root.C1"
-- type="Real"
-- kind="input" />
-- <oms:Variable
-- name="snapshot.root.add.u1"
-- type="Real"
-- kind="input" />
-- <oms:Variable
-- name="snapshot.root.add.u2"
-- type="Real"
-- kind="input" />
-- <oms:Variable
-- name="snapshot.root.add.y"
-- type="Real"
-- kind="output" />
-- <oms:Variable
-- name="snapshot.root.add.k1"
-- type="Real"
-- kind="parameter" />
-- <oms:Variable
-- name="snapshot.root.add.k2"
-- type="Real"
-- kind="parameter" />
-- </oms:SignalFilter>
-- </oms:file>
-- </oms:snapshot>
--
-- endResult