-
Notifications
You must be signed in to change notification settings - Fork 297
/
exposeLocalIOs.mos
283 lines (270 loc) · 7.22 KB
/
exposeLocalIOs.mos
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
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
// name: exposeLocalIOs
// keywords: FMI input output
// status: correct
// teardown_command: rm -f *LocalIOs.System* modelDescription.tmp.xml
setCommandLineOptions("--simCodeTarget=Cpp");
setCommandLineOptions("--nonStdExposeLocalIOs=10"); getErrorString();
loadString("
package LocalIOs
connector RealInput = input Real;
connector RealOutput = output Real;
connector PhysicalConnector
Real p;
flow Real f;
end PhysicalConnector;
model Source
parameter Real u_par = 2;
parameter Boolean use_u_in = false;
RealInput u_in(start = u_par) if use_u_in;
RealOutput yp;
RealOutput yf;
RealOutput[2] y;
PhysicalConnector c;
protected
RealInput u_in_internal;
equation
connect(u_in, u_in_internal);
if not use_u_in then
u_in_internal = u_par;
end if;
c.p = u_in_internal;
connect(u_in_internal, yp);
yf = c.f;
y = {c.p, c.f};
end Source;
function f
input Real u;
output Real y;
algorithm
y := 0.5*u;
end f;
model Component
PhysicalConnector c;
input Real modifiedInput annotation(Dialog(enable=true));
output Real simpleOutput = signaling.y;
RealOutput measurement;
protected
Signaling signaling(u1 = 1);
equation
signaling.u2 = 2;
signaling.u = 3:4;
c.f = f(c.p) + modifiedInput + signaling.y;
connect(signaling.y, measurement);
end Component;
block Signaling
RealInput u1;
RealInput u2;
RealInput[2] u;
RealOutput y;
equation
y = u1 + u2 + sum(u);
end Signaling;
model System
Source source(use_u_in = true);
Component component(modifiedInput = 1);
Signaling signaling;
equation
connect(source.c, component.c);
connect(source.yf, signaling.u1);
connect(source.y, signaling.u);
end System;
end LocalIOs;
");
getErrorString();
buildModelFMU(LocalIOs.System, version="2.0", fileNamePrefix="LocalIOs.System"); getErrorString();
// unzip to console, quiet, extra quiet
system("unzip -cqq LocalIOs.System.fmu modelDescription.xml | grep -v guid | grep -v generationDateAndTime | grep -v generationTool > modelDescription.tmp.xml");
readFile("modelDescription.tmp.xml");
// Result:
// true
// true
// ""
// true
// ""
// "LocalIOs.System.fmu"
// ""
// 0
// "<?xml version=\"1.0\" encoding=\"UTF-8\"?>
// <fmiModelDescription
// fmiVersion=\"2.0\"
// modelName=\"LocalIOs.System\"
// description=\"\"
// variableNamingConvention=\"structured\"
// numberOfEventIndicators=\"0\">
// <ModelExchange
// modelIdentifier=\"LocalIOs_System\">
// </ModelExchange>
// <LogCategories>
// <Category name=\"logEvents\" />
// <Category name=\"logSingularLinearSystems\" />
// <Category name=\"logNonlinearSystems\" />
// <Category name=\"logDynamicStateSelection\" />
// <Category name=\"logStatusWarning\" />
// <Category name=\"logStatusDiscard\" />
// <Category name=\"logStatusError\" />
// <Category name=\"logStatusFatal\" />
// <Category name=\"logStatusPending\" />
// <Category name=\"logAll\" />
// <Category name=\"logFmi2Call\" />
// </LogCategories>
// <DefaultExperiment startTime=\"0.0\" stopTime=\"1.0\" tolerance=\"1e-06\"/>
// <ModelVariables>
// <!-- Index of variable = \"1\" -->
// <ScalarVariable
// name=\"component.measurement\"
// valueReference=\"1\"
// causality=\"output\"
// >
// <Real/>
// </ScalarVariable>
// <!-- Index of variable = \"2\" -->
// <ScalarVariable
// name=\"component.modifiedInput\"
// valueReference=\"2\"
// initial=\"exact\">
// <Real start=\"0.0\"/>
// </ScalarVariable>
// <!-- Index of variable = \"3\" -->
// <ScalarVariable
// name=\"signaling.u2\"
// valueReference=\"7\"
// causality=\"input\"
// >
// <Real start=\"0.0\"/>
// </ScalarVariable>
// <!-- Index of variable = \"4\" -->
// <ScalarVariable
// name=\"signaling.y\"
// valueReference=\"8\"
// causality=\"output\"
// >
// <Real/>
// </ScalarVariable>
// <!-- Index of variable = \"5\" -->
// <ScalarVariable
// name=\"source.u_in\"
// valueReference=\"9\"
// causality=\"input\"
// >
// <Real start=\"2.0\"/>
// </ScalarVariable>
// <!-- Index of variable = \"6\" -->
// <ScalarVariable
// name=\"source.y[2]\"
// valueReference=\"10\"
// >
// <Real/>
// </ScalarVariable>
// <!-- Index of variable = \"7\" -->
// <ScalarVariable
// name=\"source.yp\"
// valueReference=\"11\"
// causality=\"output\"
// >
// <Real/>
// </ScalarVariable>
// <!-- Index of variable = \"8\" -->
// <ScalarVariable
// name=\"source.u_par\"
// valueReference=\"12\"
// variability=\"fixed\"
// causality=\"parameter\"
// >
// <Real start=\"2.0\"/>
// </ScalarVariable>
// <!-- Index of variable = \"9\" -->
// <ScalarVariable
// name=\"component.c.f\"
// valueReference=\"16\"
// >
// <Real/>
// </ScalarVariable>
// <!-- Index of variable = \"10\" -->
// <ScalarVariable
// name=\"component.c.p\"
// valueReference=\"9\"
// >
// <Real/>
// </ScalarVariable>
// <!-- Index of variable = \"11\" -->
// <ScalarVariable
// name=\"component.simpleOutput\"
// valueReference=\"1\"
// >
// <Real/>
// </ScalarVariable>
// <!-- Index of variable = \"12\" -->
// <ScalarVariable
// name=\"signaling.u[1]\"
// valueReference=\"9\"
// >
// <Real/>
// </ScalarVariable>
// <!-- Index of variable = \"13\" -->
// <ScalarVariable
// name=\"signaling.u[2]\"
// valueReference=\"10\"
// >
// <Real/>
// </ScalarVariable>
// <!-- Index of variable = \"14\" -->
// <ScalarVariable
// name=\"signaling.u1\"
// valueReference=\"10\"
// >
// <Real/>
// </ScalarVariable>
// <!-- Index of variable = \"15\" -->
// <ScalarVariable
// name=\"source.c.f\"
// valueReference=\"10\"
// >
// <Real/>
// </ScalarVariable>
// <!-- Index of variable = \"16\" -->
// <ScalarVariable
// name=\"source.c.p\"
// valueReference=\"9\"
// >
// <Real/>
// </ScalarVariable>
// <!-- Index of variable = \"17\" -->
// <ScalarVariable
// name=\"source.y[1]\"
// valueReference=\"9\"
// >
// <Real/>
// </ScalarVariable>
// <!-- Index of variable = \"18\" -->
// <ScalarVariable
// name=\"source.yf\"
// valueReference=\"10\"
// >
// <Real/>
// </ScalarVariable>
// <!-- Index of variable = \"19\" -->
// <ScalarVariable
// name=\"source.use_u_in\"
// valueReference=\"0\"
// variability=\"fixed\"
// causality=\"calculatedParameter\"
// >
// <Boolean/>
// </ScalarVariable>
// </ModelVariables>
// <ModelStructure>
// <Outputs>
// <Unknown index=\"1\" dependencies=\"\" dependenciesKind=\"\" />
// <Unknown index=\"4\" dependencies=\"3 5\" dependenciesKind=\"dependent dependent\" />
// <Unknown index=\"7\" dependencies=\"5\" dependenciesKind=\"dependent\" />
// </Outputs>
// <InitialUnknowns>
// <Unknown index=\"1\" dependencies=\"\" dependenciesKind=\"\" />
// <Unknown index=\"4\" dependencies=\"3 5\" dependenciesKind=\"dependent dependent\" />
// <Unknown index=\"7\" dependencies=\"5\" dependenciesKind=\"dependent\" />
// <Unknown index=\"19\" dependencies=\"\" dependenciesKind=\"\" />
// </InitialUnknowns>
// </ModelStructure>
// </fmiModelDescription>
// "
// endResult