-
Notifications
You must be signed in to change notification settings - Fork 49
/
fmiattributes19.lua
176 lines (161 loc) · 5.73 KB
/
fmiattributes19.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
-- status: correct
-- teardown_command: rm -rf fmi_attributes_lua/
-- linux: no
-- mingw32: no
-- mingw64: yes
-- win: yes
-- mac: no
oms_setCommandLineOption("--suppressPath=true")
oms_setTempDirectory("./fmi_attributes_lua/")
oms_newModel("model")
oms_addSystem("model.root", oms_system_wc)
oms_addSubModel("model.root.A", "../resources/fmi_attributes_19.fmu")
oms_setResultFile("model", "fmi_attributes.mat")
oms_setStopTime("model", 10.0)
oms_setSolver("model", oms_solver_wc_mav)
oms_export("model", "fmi_attributes_19.ssp")
oms_terminate("model")
oms_delete("model")
oms_importFile("fmi_attributes_19.ssp")
src, status = oms_exportSnapshot("model")
print(src)
oms_instantiate("model")
oms_initialize("model")
print("info: Initialization")
print("info: model.root.A.x1 : " .. oms_getReal("model.root.A.x1"))
print("info: model.root.A.rp1 : " .. oms_getReal("model.root.A.rp1"))
print("info: model.root.A.rp2 : " .. oms_getInteger("model.root.A.rp2"))
print("info: model.root.A.rp3 : " .. oms_getBoolean("model.root.A.rp3"))
oms_simulate("model")
print("info: Simulation")
print("info: model.root.A.x1 : " .. oms_getReal("model.root.A.x1"))
print("info: model.root.A.rp1 : " .. oms_getReal("model.root.A.rp1"))
print("info: model.root.A.rp2 : " .. oms_getInteger("model.root.A.rp2"))
print("info: model.root.A.rp3 : " .. oms_getBoolean("model.root.A.rp3"))
oms_terminate("model")
oms_delete("model")
-- 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="model"
-- version="1.0">
-- <ssd:System
-- name="root">
-- <ssd:Elements>
-- <ssd:Component
-- name="A"
-- type="application/x-fmu-sharedlibrary"
-- source="resources/0001_A.fmu">
-- <ssd:Connectors>
-- <ssd:Connector
-- name="rp1"
-- kind="parameter">
-- <ssc:Real />
-- </ssd:Connector>
-- <ssd:Connector
-- name="rp2"
-- kind="parameter">
-- <ssc:Integer />
-- </ssd:Connector>
-- <ssd:Connector
-- name="rp3"
-- kind="parameter">
-- <ssc:Boolean />
-- </ssd:Connector>
-- </ssd:Connectors>
-- </ssd:Component>
-- </ssd:Elements>
-- <ssd:Annotations>
-- <ssc:Annotation
-- type="org.openmodelica">
-- <oms:Annotations>
-- <oms:SimulationInformation>
-- <oms:VariableStepMaster
-- description="oms-mav"
-- initialStepSize="0.000001"
-- minimumStepSize="0.000000"
-- maximumStepSize="0.001000"
-- absoluteTolerance="0.000000"
-- relativeTolerance="0.000000" />
-- </oms:SimulationInformation>
-- </oms:Annotations>
-- </ssc:Annotation>
-- </ssd:Annotations>
-- </ssd:System>
-- <ssd:DefaultExperiment
-- startTime="0.000000"
-- stopTime="10.000000">
-- <ssd:Annotations>
-- <ssc:Annotation
-- type="org.openmodelica">
-- <oms:Annotations>
-- <oms:SimulationInformation
-- resultFile="fmi_attributes.mat"
-- loggingInterval="0.000000"
-- bufferSize="1"
-- signalFilter="resources/signalFilter.xml" />
-- </oms:Annotations>
-- </ssc:Annotation>
-- </ssd:Annotations>
-- </ssd:DefaultExperiment>
-- </ssd:SystemStructureDescription>
-- </oms:file>
-- <oms:file
-- name="resources/signalFilter.xml">
-- <oms:SignalFilter
-- version="1.0">
-- <oms:Variable
-- name="model.root.A.x"
-- type="Real"
-- kind="unknown" />
-- <oms:Variable
-- name="model.root.A.x1"
-- type="Real"
-- kind="unknown" />
-- <oms:Variable
-- name="model.root.A.rp1"
-- type="Real"
-- kind="parameter" />
-- <oms:Variable
-- name="model.root.A.x2"
-- type="Integer"
-- kind="unknown" />
-- <oms:Variable
-- name="model.root.A.rp2"
-- type="Integer"
-- kind="parameter" />
-- <oms:Variable
-- name="model.root.A.x3"
-- type="Bool"
-- kind="unknown" />
-- <oms:Variable
-- name="model.root.A.rp3"
-- type="Bool"
-- kind="parameter" />
-- </oms:SignalFilter>
-- </oms:file>
-- </oms:snapshot>
--
-- info: Result file: fmi_attributes.mat (bufferSize=1)
-- info: Initialization
-- info: model.root.A.x1 : 3.0
-- info: model.root.A.rp1 : 6.0
-- info: model.root.A.rp2 : 7
-- info: model.root.A.rp3 : 1
-- info: Simulation
-- info: model.root.A.x1 : 3.0
-- info: model.root.A.rp1 : 6.0
-- info: model.root.A.rp2 : 7
-- info: model.root.A.rp3 : 1
-- endResult