1 | /* |
---|
2 | Copyright (C) 2013 Modelon AB |
---|
3 | |
---|
4 | This program is free software: you can redistribute it and/or modify |
---|
5 | it under the terms of the GNU General Public License as published by |
---|
6 | the Free Software Foundation, version 3 of the License. |
---|
7 | |
---|
8 | This program is distributed in the hope that it will be useful, |
---|
9 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
---|
10 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
---|
11 | GNU General Public License for more details. |
---|
12 | |
---|
13 | You should have received a copy of the GNU General Public License |
---|
14 | along with this program. If not, see <http://www.gnu.org/licenses/>. |
---|
15 | */ |
---|
16 | |
---|
17 | within; |
---|
18 | |
---|
19 | package ExpandableConnectors |
---|
20 | |
---|
21 | model Expandable1 |
---|
22 | expandable connector EC |
---|
23 | end EC; |
---|
24 | |
---|
25 | connector C = Real; |
---|
26 | |
---|
27 | EC ec1, ec2, ec3; |
---|
28 | C c1, c2; |
---|
29 | equation |
---|
30 | connect(c1, ec1.a); |
---|
31 | connect(ec1, ec2); |
---|
32 | connect(ec2, ec3); |
---|
33 | connect(ec3.a, c2); |
---|
34 | c1 = time; |
---|
35 | |
---|
36 | annotation(__JModelica(UnitTesting(tests={ |
---|
37 | FlatteningTestCase( |
---|
38 | name="Expandable1", |
---|
39 | description="Basic test of expandable connectors", |
---|
40 | flatModel=" |
---|
41 | fclass ExpandableConnectors.Expandable1 |
---|
42 | Real ec1.a; |
---|
43 | Real ec2.a; |
---|
44 | Real ec3.a; |
---|
45 | Real c1; |
---|
46 | Real c2; |
---|
47 | equation |
---|
48 | c1 = time; |
---|
49 | c1 = c2; |
---|
50 | c2 = ec1.a; |
---|
51 | ec1.a = ec2.a; |
---|
52 | ec2.a = ec3.a; |
---|
53 | end ExpandableConnectors.Expandable1; |
---|
54 | ")}))); |
---|
55 | end Expandable1; |
---|
56 | |
---|
57 | |
---|
58 | model Expandable2 |
---|
59 | expandable connector EC |
---|
60 | end EC; |
---|
61 | |
---|
62 | connector C |
---|
63 | Real a; |
---|
64 | flow Real b; |
---|
65 | end C; |
---|
66 | |
---|
67 | EC ec1, ec2, ec3; |
---|
68 | C c1, c2, c3, c4, c5; |
---|
69 | equation |
---|
70 | connect(ec1, ec2); |
---|
71 | connect(ec2, ec3); |
---|
72 | connect(c1, ec1.x); |
---|
73 | connect(c2, ec1.y); |
---|
74 | connect(ec3.x, c3); |
---|
75 | connect(ec3.y, c4); |
---|
76 | connect(ec2.x, c5); |
---|
77 | |
---|
78 | annotation(__JModelica(UnitTesting(tests={ |
---|
79 | FlatteningTestCase( |
---|
80 | name="Expandable2", |
---|
81 | description="Expandable connectors: adding composite connectors", |
---|
82 | flatModel=" |
---|
83 | fclass ExpandableConnectors.Expandable2 |
---|
84 | Real ec1.x.a; |
---|
85 | Real ec1.x.b; |
---|
86 | Real ec1.y.a; |
---|
87 | Real ec1.y.b; |
---|
88 | Real ec2.x.a; |
---|
89 | Real ec2.x.b; |
---|
90 | Real ec2.y.a; |
---|
91 | Real ec2.y.b; |
---|
92 | Real ec3.x.a; |
---|
93 | Real ec3.x.b; |
---|
94 | Real ec3.y.a; |
---|
95 | Real ec3.y.b; |
---|
96 | Real c1.a; |
---|
97 | input Real c1.b; |
---|
98 | Real c2.a; |
---|
99 | input Real c2.b; |
---|
100 | Real c3.a; |
---|
101 | input Real c3.b; |
---|
102 | Real c4.a; |
---|
103 | input Real c4.b; |
---|
104 | Real c5.a; |
---|
105 | input Real c5.b; |
---|
106 | equation |
---|
107 | c1.a = c3.a; |
---|
108 | c3.a = c5.a; |
---|
109 | c5.a = ec1.x.a; |
---|
110 | ec1.x.a = ec2.x.a; |
---|
111 | ec2.x.a = ec3.x.a; |
---|
112 | - c1.b - c3.b - c5.b - ec1.x.b - ec2.x.b - ec3.x.b = 0.0; |
---|
113 | c2.a = c4.a; |
---|
114 | c4.a = ec1.y.a; |
---|
115 | ec1.y.a = ec2.y.a; |
---|
116 | ec2.y.a = ec3.y.a; |
---|
117 | - c2.b - c4.b - ec1.y.b - ec2.y.b - ec3.y.b = 0.0; |
---|
118 | ec1.x.b = 0.0; |
---|
119 | ec1.y.b = 0.0; |
---|
120 | ec2.x.b = 0.0; |
---|
121 | ec2.y.b = 0.0; |
---|
122 | ec3.x.b = 0.0; |
---|
123 | ec3.y.b = 0.0; |
---|
124 | end ExpandableConnectors.Expandable2; |
---|
125 | ")}))); |
---|
126 | end Expandable2; |
---|
127 | |
---|
128 | |
---|
129 | model Expandable3 |
---|
130 | expandable connector EC |
---|
131 | end EC; |
---|
132 | |
---|
133 | connector C = Real[2]; |
---|
134 | |
---|
135 | model M |
---|
136 | EC ec1, ec2, ec3; |
---|
137 | C c1, c2; |
---|
138 | equation |
---|
139 | connect(c1, ec1.a); |
---|
140 | connect(ec1, ec2); |
---|
141 | connect(ec2, ec3); |
---|
142 | connect(ec3.a, c2); |
---|
143 | end M; |
---|
144 | |
---|
145 | M m[2]; |
---|
146 | |
---|
147 | annotation(__JModelica(UnitTesting(tests={ |
---|
148 | FlatteningTestCase( |
---|
149 | name="Expandable3", |
---|
150 | description="Expandable connectors: adding entire array without subscripts, within array component", |
---|
151 | flatModel=" |
---|
152 | fclass ExpandableConnectors.Expandable3 |
---|
153 | ExpandableConnectors.Expandable3.C m[1].ec1.a[2]; |
---|
154 | ExpandableConnectors.Expandable3.C m[1].ec2.a[2]; |
---|
155 | ExpandableConnectors.Expandable3.C m[1].ec3.a[2]; |
---|
156 | ExpandableConnectors.Expandable3.C m[1].c1[2]; |
---|
157 | ExpandableConnectors.Expandable3.C m[1].c2[2]; |
---|
158 | ExpandableConnectors.Expandable3.C m[2].ec1.a[2]; |
---|
159 | ExpandableConnectors.Expandable3.C m[2].ec2.a[2]; |
---|
160 | ExpandableConnectors.Expandable3.C m[2].ec3.a[2]; |
---|
161 | ExpandableConnectors.Expandable3.C m[2].c1[2]; |
---|
162 | ExpandableConnectors.Expandable3.C m[2].c2[2]; |
---|
163 | equation |
---|
164 | m[1].c1[1] = m[1].c2[1]; |
---|
165 | m[1].c2[1] = m[1].ec1.a[1]; |
---|
166 | m[1].ec1.a[1] = m[1].ec2.a[1]; |
---|
167 | m[1].ec2.a[1] = m[1].ec3.a[1]; |
---|
168 | m[1].c1[2] = m[1].c2[2]; |
---|
169 | m[1].c2[2] = m[1].ec1.a[2]; |
---|
170 | m[1].ec1.a[2] = m[1].ec2.a[2]; |
---|
171 | m[1].ec2.a[2] = m[1].ec3.a[2]; |
---|
172 | m[2].c1[1] = m[2].c2[1]; |
---|
173 | m[2].c2[1] = m[2].ec1.a[1]; |
---|
174 | m[2].ec1.a[1] = m[2].ec2.a[1]; |
---|
175 | m[2].ec2.a[1] = m[2].ec3.a[1]; |
---|
176 | m[2].c1[2] = m[2].c2[2]; |
---|
177 | m[2].c2[2] = m[2].ec1.a[2]; |
---|
178 | m[2].ec1.a[2] = m[2].ec2.a[2]; |
---|
179 | m[2].ec2.a[2] = m[2].ec3.a[2]; |
---|
180 | |
---|
181 | public |
---|
182 | type ExpandableConnectors.Expandable3.C = Real; |
---|
183 | end ExpandableConnectors.Expandable3; |
---|
184 | ")}))); |
---|
185 | end Expandable3; |
---|
186 | |
---|
187 | |
---|
188 | model Expandable4 |
---|
189 | expandable connector EC |
---|
190 | end EC; |
---|
191 | |
---|
192 | model A |
---|
193 | replaceable EC ec; |
---|
194 | end A; |
---|
195 | |
---|
196 | connector C = Real; |
---|
197 | |
---|
198 | A a1(redeclare EC ec); |
---|
199 | A a2(redeclare EC ec); |
---|
200 | A a3(redeclare EC ec); |
---|
201 | C c1, c2; |
---|
202 | equation |
---|
203 | connect(c1, a1.ec.b); |
---|
204 | connect(a1.ec, a2.ec); |
---|
205 | connect(a2.ec, a3.ec); |
---|
206 | connect(a3.ec.b, c2); |
---|
207 | |
---|
208 | annotation(__JModelica(UnitTesting(tests={ |
---|
209 | FlatteningTestCase( |
---|
210 | name="Expandable4", |
---|
211 | description="Added support for redeclaring expandable connectors", |
---|
212 | flatModel=" |
---|
213 | fclass ExpandableConnectors.Expandable4 |
---|
214 | Real a1.ec.b; |
---|
215 | Real a2.ec.b; |
---|
216 | Real a3.ec.b; |
---|
217 | Real c1; |
---|
218 | Real c2; |
---|
219 | equation |
---|
220 | a1.ec.b = a2.ec.b; |
---|
221 | a2.ec.b = a3.ec.b; |
---|
222 | a3.ec.b = c1; |
---|
223 | c1 = c2; |
---|
224 | end ExpandableConnectors.Expandable4; |
---|
225 | ")}))); |
---|
226 | end Expandable4; |
---|
227 | |
---|
228 | |
---|
229 | model Expandable5 |
---|
230 | expandable connector EC |
---|
231 | end EC; |
---|
232 | |
---|
233 | connector C = Real; |
---|
234 | |
---|
235 | EC ec1, ec2, ec3; |
---|
236 | C c1 = 1; |
---|
237 | C c2; |
---|
238 | equation |
---|
239 | connect(c1, ec1.a); |
---|
240 | connect(ec1, ec2); |
---|
241 | connect(ec2, ec3); |
---|
242 | connect(ec3.a, c2); |
---|
243 | |
---|
244 | annotation(__JModelica(UnitTesting(tests={ |
---|
245 | FlatteningTestCase( |
---|
246 | name="Expandable5", |
---|
247 | description="Adding to expandable connectors from var with binding exp", |
---|
248 | flatModel=" |
---|
249 | fclass ExpandableConnectors.Expandable5 |
---|
250 | Real ec1.a; |
---|
251 | Real ec2.a; |
---|
252 | Real ec3.a; |
---|
253 | Real c1 = 1; |
---|
254 | Real c2; |
---|
255 | equation |
---|
256 | c1 = c2; |
---|
257 | c2 = ec1.a; |
---|
258 | ec1.a = ec2.a; |
---|
259 | ec2.a = ec3.a; |
---|
260 | end ExpandableConnectors.Expandable5; |
---|
261 | ")}))); |
---|
262 | end Expandable5; |
---|
263 | |
---|
264 | |
---|
265 | model Expandable5b |
---|
266 | expandable connector EC |
---|
267 | end EC; |
---|
268 | |
---|
269 | connector C |
---|
270 | Real x; |
---|
271 | Real y; |
---|
272 | end C; |
---|
273 | |
---|
274 | EC ec1, ec2, ec3; |
---|
275 | C c1(x = 1, y = 2); |
---|
276 | C c2; |
---|
277 | equation |
---|
278 | connect(c1, ec1.a); |
---|
279 | connect(ec1, ec2); |
---|
280 | connect(ec2, ec3); |
---|
281 | connect(ec3.a, c2); |
---|
282 | |
---|
283 | annotation(__JModelica(UnitTesting(tests={ |
---|
284 | FlatteningTestCase( |
---|
285 | name="Expandable5b", |
---|
286 | description="Adding to expandable connectors from composite with binding exps", |
---|
287 | flatModel=" |
---|
288 | fclass ExpandableConnectors.Expandable5b |
---|
289 | Real ec1.a.x; |
---|
290 | Real ec1.a.y; |
---|
291 | Real ec2.a.x; |
---|
292 | Real ec2.a.y; |
---|
293 | Real ec3.a.x; |
---|
294 | Real ec3.a.y; |
---|
295 | Real c1.x = 1; |
---|
296 | Real c1.y = 2; |
---|
297 | Real c2.x; |
---|
298 | Real c2.y; |
---|
299 | equation |
---|
300 | c1.x = c2.x; |
---|
301 | c2.x = ec1.a.x; |
---|
302 | ec1.a.x = ec2.a.x; |
---|
303 | ec2.a.x = ec3.a.x; |
---|
304 | c1.y = c2.y; |
---|
305 | c2.y = ec1.a.y; |
---|
306 | ec1.a.y = ec2.a.y; |
---|
307 | ec2.a.y = ec3.a.y; |
---|
308 | end ExpandableConnectors.Expandable5b; |
---|
309 | ")}))); |
---|
310 | end Expandable5b; |
---|
311 | |
---|
312 | |
---|
313 | model Expandable6 |
---|
314 | expandable connector EC |
---|
315 | end EC; |
---|
316 | |
---|
317 | connector C = Real; |
---|
318 | |
---|
319 | EC ec1, ec2, ec3; |
---|
320 | C c[2]; |
---|
321 | equation |
---|
322 | connect(c[1], ec1.a); |
---|
323 | connect(ec1, ec2); |
---|
324 | connect(ec2, ec3); |
---|
325 | connect(ec3.a, c[2]); |
---|
326 | |
---|
327 | annotation(__JModelica(UnitTesting(tests={ |
---|
328 | FlatteningTestCase( |
---|
329 | name="Expandable6", |
---|
330 | description="Expandable connectors: connect to single element in array", |
---|
331 | flatModel=" |
---|
332 | fclass ExpandableConnectors.Expandable6 |
---|
333 | Real ec1.a; |
---|
334 | Real ec2.a; |
---|
335 | Real ec3.a; |
---|
336 | Real c[2]; |
---|
337 | equation |
---|
338 | c[1] = c[2]; |
---|
339 | c[2] = ec1.a; |
---|
340 | ec1.a = ec2.a; |
---|
341 | ec2.a = ec3.a; |
---|
342 | end ExpandableConnectors.Expandable6; |
---|
343 | ")}))); |
---|
344 | end Expandable6; |
---|
345 | |
---|
346 | |
---|
347 | model Expandable7 |
---|
348 | expandable connector EC |
---|
349 | end EC; |
---|
350 | |
---|
351 | connector C = Real; |
---|
352 | |
---|
353 | EC ec1, ec2, ec3; |
---|
354 | C c[4]; |
---|
355 | equation |
---|
356 | connect(c[1:2], ec1.a); |
---|
357 | connect(ec1, ec2); |
---|
358 | connect(ec2, ec3); |
---|
359 | connect(ec3.a, c[3:4]); |
---|
360 | |
---|
361 | annotation(__JModelica(UnitTesting(tests={ |
---|
362 | FlatteningTestCase( |
---|
363 | name="Expandable7", |
---|
364 | description="Expandable connectors: connect to slice", |
---|
365 | flatModel=" |
---|
366 | fclass ExpandableConnectors.Expandable7 |
---|
367 | Real ec1.a[2]; |
---|
368 | Real ec2.a[2]; |
---|
369 | Real ec3.a[2]; |
---|
370 | Real c[4]; |
---|
371 | equation |
---|
372 | c[1] = c[3]; |
---|
373 | c[3] = ec1.a[1]; |
---|
374 | ec1.a[1] = ec2.a[1]; |
---|
375 | ec2.a[1] = ec3.a[1]; |
---|
376 | c[2] = c[4]; |
---|
377 | c[4] = ec1.a[2]; |
---|
378 | ec1.a[2] = ec2.a[2]; |
---|
379 | ec2.a[2] = ec3.a[2]; |
---|
380 | end ExpandableConnectors.Expandable7; |
---|
381 | ")}))); |
---|
382 | end Expandable7; |
---|
383 | |
---|
384 | |
---|
385 | model Expandable8 |
---|
386 | expandable connector EC |
---|
387 | end EC; |
---|
388 | |
---|
389 | connector C = Real; |
---|
390 | |
---|
391 | EC ec1, ec2, ec3; |
---|
392 | C c1, c2, c3, c4; |
---|
393 | equation |
---|
394 | connect(c1, ec1.a[1]); |
---|
395 | connect(c2, ec1.a[2]); |
---|
396 | connect(ec1, ec2); |
---|
397 | connect(ec2, ec3); |
---|
398 | connect(ec3.a[1], c3); |
---|
399 | connect(ec3.a[2], c4); |
---|
400 | |
---|
401 | annotation(__JModelica(UnitTesting(tests={ |
---|
402 | FlatteningTestCase( |
---|
403 | name="Expandable8", |
---|
404 | description="Connecting to cell of array in expandable connector", |
---|
405 | flatModel=" |
---|
406 | fclass ExpandableConnectors.Expandable8 |
---|
407 | Real ec1.a[2]; |
---|
408 | Real ec2.a[2]; |
---|
409 | Real ec3.a[2]; |
---|
410 | Real c1; |
---|
411 | Real c2; |
---|
412 | Real c3; |
---|
413 | Real c4; |
---|
414 | equation |
---|
415 | c1 = c3; |
---|
416 | c3 = ec1.a[1]; |
---|
417 | ec1.a[1] = ec2.a[1]; |
---|
418 | ec2.a[1] = ec3.a[1]; |
---|
419 | c2 = c4; |
---|
420 | c4 = ec1.a[2]; |
---|
421 | ec1.a[2] = ec2.a[2]; |
---|
422 | ec2.a[2] = ec3.a[2]; |
---|
423 | end ExpandableConnectors.Expandable8; |
---|
424 | ")}))); |
---|
425 | end Expandable8; |
---|
426 | |
---|
427 | |
---|
428 | model Expandable9 |
---|
429 | connector C = Real; |
---|
430 | |
---|
431 | expandable connector EC |
---|
432 | C x; |
---|
433 | end EC; |
---|
434 | |
---|
435 | EC ec1, ec2; |
---|
436 | C x = time; |
---|
437 | equation |
---|
438 | connect(ec1.x, ec2.x); |
---|
439 | connect(ec1.x, x); |
---|
440 | |
---|
441 | annotation(__JModelica(UnitTesting(tests={ |
---|
442 | FlatteningTestCase( |
---|
443 | name="Expandable9", |
---|
444 | description="Connecting two declared members of expandable connectors", |
---|
445 | flatModel=" |
---|
446 | fclass ExpandableConnectors.Expandable9 |
---|
447 | Real ec1.x; |
---|
448 | Real ec2.x; |
---|
449 | Real x = time; |
---|
450 | equation |
---|
451 | ec1.x = ec2.x; |
---|
452 | ec2.x = x; |
---|
453 | end ExpandableConnectors.Expandable9; |
---|
454 | ")}))); |
---|
455 | end Expandable9; |
---|
456 | |
---|
457 | |
---|
458 | model Expandable10 |
---|
459 | expandable connector EC |
---|
460 | end EC; |
---|
461 | |
---|
462 | connector C = Real; |
---|
463 | |
---|
464 | EC ec1, ec2, ec3; |
---|
465 | C c1[5], c2[5]; |
---|
466 | equation |
---|
467 | connect(c1[1:2], ec1.a[1:2:3]); |
---|
468 | connect(c1[3:4], ec1.a[2:2:4]); |
---|
469 | connect(ec1, ec2); |
---|
470 | connect(ec2, ec3); |
---|
471 | connect(ec3.a[1:2:3], c2[1:2]); |
---|
472 | connect(ec3.a[2:2:4], c2[3:4]); |
---|
473 | |
---|
474 | annotation(__JModelica(UnitTesting(tests={ |
---|
475 | FlatteningTestCase( |
---|
476 | name="Expandable10", |
---|
477 | description="Connecting to slice of array in expandable connector", |
---|
478 | flatModel=" |
---|
479 | fclass ExpandableConnectors.Expandable10 |
---|
480 | Real ec1.a[4]; |
---|
481 | Real ec2.a[4]; |
---|
482 | Real ec3.a[4]; |
---|
483 | Real c1[5]; |
---|
484 | Real c2[5]; |
---|
485 | equation |
---|
486 | c1[1] = c2[1]; |
---|
487 | c2[1] = ec1.a[1]; |
---|
488 | ec1.a[1] = ec2.a[1]; |
---|
489 | ec2.a[1] = ec3.a[1]; |
---|
490 | c1[2] = c2[2]; |
---|
491 | c2[2] = ec1.a[3]; |
---|
492 | ec1.a[3] = ec2.a[3]; |
---|
493 | ec2.a[3] = ec3.a[3]; |
---|
494 | c1[3] = c2[3]; |
---|
495 | c2[3] = ec1.a[2]; |
---|
496 | ec1.a[2] = ec2.a[2]; |
---|
497 | ec2.a[2] = ec3.a[2]; |
---|
498 | c1[4] = c2[4]; |
---|
499 | c2[4] = ec1.a[4]; |
---|
500 | ec1.a[4] = ec2.a[4]; |
---|
501 | ec2.a[4] = ec3.a[4]; |
---|
502 | end ExpandableConnectors.Expandable10; |
---|
503 | ")}))); |
---|
504 | end Expandable10; |
---|
505 | |
---|
506 | |
---|
507 | model Expandable11 |
---|
508 | expandable connector EC |
---|
509 | end EC; |
---|
510 | |
---|
511 | connector C = Real; |
---|
512 | |
---|
513 | EC ec1, ec2; |
---|
514 | C c1[2], c2[2,2]; |
---|
515 | equation |
---|
516 | connect(ec1, ec2); |
---|
517 | connect(ec1.a[1,:], c1); |
---|
518 | connect(ec1.b[:,1:2], c2); |
---|
519 | |
---|
520 | annotation(__JModelica(UnitTesting(tests={ |
---|
521 | FlatteningTestCase( |
---|
522 | name="Expandable11", |
---|
523 | description="Connecting to slice with colon of array in expandable connector", |
---|
524 | flatModel=" |
---|
525 | fclass ExpandableConnectors.Expandable11 |
---|
526 | Real ec1.a[1,2]; |
---|
527 | Real ec1.b[2,2]; |
---|
528 | Real ec2.a[1,2]; |
---|
529 | Real ec2.b[2,2]; |
---|
530 | Real c1[2]; |
---|
531 | Real c2[2,2]; |
---|
532 | equation |
---|
533 | c1[1] = ec1.a[1,1]; |
---|
534 | ec1.a[1,1] = ec2.a[1,1]; |
---|
535 | c1[2] = ec1.a[1,2]; |
---|
536 | ec1.a[1,2] = ec2.a[1,2]; |
---|
537 | c2[1,1] = ec1.b[1,1]; |
---|
538 | ec1.b[1,1] = ec2.b[1,1]; |
---|
539 | c2[1,2] = ec1.b[1,2]; |
---|
540 | ec1.b[1,2] = ec2.b[1,2]; |
---|
541 | c2[2,1] = ec1.b[2,1]; |
---|
542 | ec1.b[2,1] = ec2.b[2,1]; |
---|
543 | c2[2,2] = ec1.b[2,2]; |
---|
544 | ec1.b[2,2] = ec2.b[2,2]; |
---|
545 | end ExpandableConnectors.Expandable11; |
---|
546 | ")}))); |
---|
547 | end Expandable11; |
---|
548 | |
---|
549 | |
---|
550 | model Expandable12 |
---|
551 | expandable connector EC |
---|
552 | end EC; |
---|
553 | |
---|
554 | connector C = Real; |
---|
555 | |
---|
556 | EC ec1; |
---|
557 | C c1[3], c2; |
---|
558 | equation |
---|
559 | connect(c1, ec1.a); |
---|
560 | connect(c2, ec1.a[3]); |
---|
561 | |
---|
562 | annotation(__JModelica(UnitTesting(tests={ |
---|
563 | FlatteningTestCase( |
---|
564 | name="Expandable12", |
---|
565 | description="Connecting to entire array and to single element", |
---|
566 | flatModel=" |
---|
567 | fclass ExpandableConnectors.Expandable12 |
---|
568 | Real ec1.a[3]; |
---|
569 | Real c1[3]; |
---|
570 | Real c2; |
---|
571 | equation |
---|
572 | c1[1] = ec1.a[1]; |
---|
573 | c1[2] = ec1.a[2]; |
---|
574 | c1[3] = c2; |
---|
575 | c2 = ec1.a[3]; |
---|
576 | end ExpandableConnectors.Expandable12; |
---|
577 | ")}))); |
---|
578 | end Expandable12; |
---|
579 | |
---|
580 | |
---|
581 | model Expandable13 |
---|
582 | expandable connector EC |
---|
583 | Real x; |
---|
584 | Real y; |
---|
585 | end EC; |
---|
586 | |
---|
587 | connector C = Real; |
---|
588 | |
---|
589 | EC ec; |
---|
590 | C c; |
---|
591 | equation |
---|
592 | connect(c, ec.x); |
---|
593 | |
---|
594 | annotation(__JModelica(UnitTesting(tests={ |
---|
595 | FlatteningTestCase( |
---|
596 | name="Expandable13", |
---|
597 | description="Expandable connector with members", |
---|
598 | flatModel=" |
---|
599 | fclass ExpandableConnectors.Expandable13 |
---|
600 | Real ec.x; |
---|
601 | Real c; |
---|
602 | equation |
---|
603 | c = ec.x; |
---|
604 | end ExpandableConnectors.Expandable13; |
---|
605 | ")}))); |
---|
606 | end Expandable13; |
---|
607 | |
---|
608 | |
---|
609 | model Expandable14 |
---|
610 | expandable connector EC |
---|
611 | Real a[3]; |
---|
612 | end EC; |
---|
613 | |
---|
614 | connector C = Real; |
---|
615 | |
---|
616 | EC ec; |
---|
617 | C c[3]; |
---|
618 | equation |
---|
619 | connect(c, ec.a); |
---|
620 | |
---|
621 | annotation(__JModelica(UnitTesting(tests={ |
---|
622 | FlatteningTestCase( |
---|
623 | name="Expandable14", |
---|
624 | description="Expandable connector with members: array", |
---|
625 | flatModel=" |
---|
626 | fclass ExpandableConnectors.Expandable14 |
---|
627 | Real ec.a[3]; |
---|
628 | Real c[3]; |
---|
629 | equation |
---|
630 | c[1] = ec.a[1]; |
---|
631 | c[2] = ec.a[2]; |
---|
632 | c[3] = ec.a[3]; |
---|
633 | end ExpandableConnectors.Expandable14; |
---|
634 | ")}))); |
---|
635 | end Expandable14; |
---|
636 | |
---|
637 | |
---|
638 | model Expandable15 |
---|
639 | expandable connector EC |
---|
640 | C a; |
---|
641 | end EC; |
---|
642 | |
---|
643 | connector C |
---|
644 | Real x; |
---|
645 | Real y; |
---|
646 | end C; |
---|
647 | |
---|
648 | EC ec; |
---|
649 | C c; |
---|
650 | equation |
---|
651 | connect(c, ec.a); |
---|
652 | |
---|
653 | annotation(__JModelica(UnitTesting(tests={ |
---|
654 | FlatteningTestCase( |
---|
655 | name="Expandable15", |
---|
656 | description="Expandable connector with members: composite", |
---|
657 | flatModel=" |
---|
658 | fclass ExpandableConnectors.Expandable15 |
---|
659 | Real ec.a.x; |
---|
660 | Real ec.a.y; |
---|
661 | Real c.x; |
---|
662 | Real c.y; |
---|
663 | equation |
---|
664 | c.x = ec.a.x; |
---|
665 | c.y = ec.a.y; |
---|
666 | end ExpandableConnectors.Expandable15; |
---|
667 | ")}))); |
---|
668 | end Expandable15; |
---|
669 | |
---|
670 | |
---|
671 | model Expandable16 |
---|
672 | expandable connector EC |
---|
673 | Real x; |
---|
674 | end EC; |
---|
675 | |
---|
676 | connector C = Real; |
---|
677 | |
---|
678 | C c; |
---|
679 | EC ec; |
---|
680 | Real y; |
---|
681 | equation |
---|
682 | connect(c, ec.x); |
---|
683 | y = ec.x; |
---|
684 | |
---|
685 | annotation(__JModelica(UnitTesting(tests={ |
---|
686 | FlatteningTestCase( |
---|
687 | name="Expandable16", |
---|
688 | description="Using member of expandable connector that is connected to", |
---|
689 | flatModel=" |
---|
690 | fclass ExpandableConnectors.Expandable16 |
---|
691 | Real c; |
---|
692 | Real ec.x; |
---|
693 | Real y; |
---|
694 | equation |
---|
695 | y = ec.x; |
---|
696 | c = ec.x; |
---|
697 | end ExpandableConnectors.Expandable16; |
---|
698 | ")}))); |
---|
699 | end Expandable16; |
---|
700 | |
---|
701 | |
---|
702 | model Expandable17 |
---|
703 | expandable connector EC |
---|
704 | Real x; |
---|
705 | end EC; |
---|
706 | |
---|
707 | connector C = Real; |
---|
708 | |
---|
709 | C c; |
---|
710 | EC ec; |
---|
711 | Real y = ec.x; |
---|
712 | equation |
---|
713 | connect(c, ec.x); |
---|
714 | |
---|
715 | annotation(__JModelica(UnitTesting(tests={ |
---|
716 | FlatteningTestCase( |
---|
717 | name="Expandable17", |
---|
718 | description="Using member of expandable connector that is connected to", |
---|
719 | flatModel=" |
---|
720 | fclass ExpandableConnectors.Expandable17 |
---|
721 | Real c; |
---|
722 | Real ec.x; |
---|
723 | Real y = ec.x; |
---|
724 | equation |
---|
725 | c = ec.x; |
---|
726 | end ExpandableConnectors.Expandable17; |
---|
727 | ")}))); |
---|
728 | end Expandable17; |
---|
729 | |
---|
730 | |
---|
731 | model Expandable18 |
---|
732 | expandable connector EC |
---|
733 | Real x; |
---|
734 | end EC; |
---|
735 | |
---|
736 | model A |
---|
737 | Real y; |
---|
738 | end A; |
---|
739 | |
---|
740 | connector C = Real; |
---|
741 | |
---|
742 | C c; |
---|
743 | EC ec; |
---|
744 | A a(y = ec.x); |
---|
745 | equation |
---|
746 | connect(c, ec.x); |
---|
747 | |
---|
748 | annotation(__JModelica(UnitTesting(tests={ |
---|
749 | FlatteningTestCase( |
---|
750 | name="Expandable18", |
---|
751 | description="Using member of expandable connector that is connected to", |
---|
752 | flatModel=" |
---|
753 | fclass ExpandableConnectors.Expandable18 |
---|
754 | Real c; |
---|
755 | Real ec.x; |
---|
756 | Real a.y = ec.x; |
---|
757 | equation |
---|
758 | c = ec.x; |
---|
759 | end ExpandableConnectors.Expandable18; |
---|
760 | ")}))); |
---|
761 | end Expandable18; |
---|
762 | |
---|
763 | |
---|
764 | model Expandable19 |
---|
765 | expandable connector EC1 |
---|
766 | Real x; |
---|
767 | end EC1; |
---|
768 | |
---|
769 | expandable connector EC2 |
---|
770 | end EC2; |
---|
771 | |
---|
772 | connector C = Real; |
---|
773 | |
---|
774 | C c; |
---|
775 | EC1 ec1a, ec1b; |
---|
776 | EC2 ec2; |
---|
777 | Real y; |
---|
778 | equation |
---|
779 | connect(ec1a, ec1b); |
---|
780 | connect(ec1b, ec2); |
---|
781 | connect(c, ec2.x); |
---|
782 | y = ec1b.x; |
---|
783 | |
---|
784 | annotation(__JModelica(UnitTesting(tests={ |
---|
785 | FlatteningTestCase( |
---|
786 | name="Expandable19", |
---|
787 | description="Using member of expandable connector that is connected to", |
---|
788 | flatModel=" |
---|
789 | fclass ExpandableConnectors.Expandable19 |
---|
790 | Real c; |
---|
791 | Real ec1a.x; |
---|
792 | Real ec1b.x; |
---|
793 | Real ec2.x; |
---|
794 | Real y; |
---|
795 | equation |
---|
796 | y = ec1b.x; |
---|
797 | c = ec1a.x; |
---|
798 | ec1a.x = ec1b.x; |
---|
799 | ec1b.x = ec2.x; |
---|
800 | end ExpandableConnectors.Expandable19; |
---|
801 | ")}))); |
---|
802 | end Expandable19; |
---|
803 | |
---|
804 | |
---|
805 | model Expandable20 |
---|
806 | expandable connector EC1 |
---|
807 | Real x; |
---|
808 | end EC1; |
---|
809 | |
---|
810 | expandable connector EC2 |
---|
811 | end EC2; |
---|
812 | |
---|
813 | connector C = Real; |
---|
814 | |
---|
815 | C c; |
---|
816 | EC1 ec1a, ec1b; |
---|
817 | EC2 ec2; |
---|
818 | Real y = ec1b.x; |
---|
819 | equation |
---|
820 | connect(ec1a, ec1b); |
---|
821 | connect(ec1b, ec2); |
---|
822 | connect(c, ec2.x); |
---|
823 | |
---|
824 | annotation(__JModelica(UnitTesting(tests={ |
---|
825 | FlatteningTestCase( |
---|
826 | name="Expandable20", |
---|
827 | description="Using member of expandable connector that is connected to", |
---|
828 | flatModel=" |
---|
829 | fclass ExpandableConnectors.Expandable20 |
---|
830 | Real c; |
---|
831 | Real ec1a.x; |
---|
832 | Real ec1b.x; |
---|
833 | Real ec2.x; |
---|
834 | Real y = ec1b.x; |
---|
835 | equation |
---|
836 | c = ec1a.x; |
---|
837 | ec1a.x = ec1b.x; |
---|
838 | ec1b.x = ec2.x; |
---|
839 | end ExpandableConnectors.Expandable20; |
---|
840 | ")}))); |
---|
841 | end Expandable20; |
---|
842 | |
---|
843 | |
---|
844 | model Expandable21 |
---|
845 | expandable connector EC1 |
---|
846 | Real x; |
---|
847 | end EC1; |
---|
848 | |
---|
849 | expandable connector EC2 |
---|
850 | end EC2; |
---|
851 | |
---|
852 | model A |
---|
853 | Real y; |
---|
854 | end A; |
---|
855 | |
---|
856 | connector C = Real; |
---|
857 | |
---|
858 | C c; |
---|
859 | EC1 ec1a, ec1b; |
---|
860 | EC2 ec2; |
---|
861 | A a(y = ec1b.x); |
---|
862 | equation |
---|
863 | connect(ec1a, ec1b); |
---|
864 | connect(ec1b, ec2); |
---|
865 | connect(c, ec2.x); |
---|
866 | |
---|
867 | annotation(__JModelica(UnitTesting(tests={ |
---|
868 | FlatteningTestCase( |
---|
869 | name="Expandable21", |
---|
870 | description="Using member of expandable connector that is connected to", |
---|
871 | flatModel=" |
---|
872 | fclass ExpandableConnectors.Expandable21 |
---|
873 | Real c; |
---|
874 | Real ec1a.x; |
---|
875 | Real ec1b.x; |
---|
876 | Real ec2.x; |
---|
877 | Real a.y = ec1b.x; |
---|
878 | equation |
---|
879 | c = ec1a.x; |
---|
880 | ec1a.x = ec1b.x; |
---|
881 | ec1b.x = ec2.x; |
---|
882 | end ExpandableConnectors.Expandable21; |
---|
883 | ")}))); |
---|
884 | end Expandable21; |
---|
885 | |
---|
886 | |
---|
887 | model Expandable22 |
---|
888 | expandable connector EC |
---|
889 | end EC; |
---|
890 | |
---|
891 | connector C = Real; |
---|
892 | |
---|
893 | EC ec; |
---|
894 | C c; |
---|
895 | equation |
---|
896 | connect(c, ec.x[2]); |
---|
897 | |
---|
898 | annotation(__JModelica(UnitTesting(tests={ |
---|
899 | FlatteningTestCase( |
---|
900 | name="Expandable22", |
---|
901 | description="Expandable connectors: Connecting to only some elements of array", |
---|
902 | flatModel=" |
---|
903 | fclass ExpandableConnectors.Expandable22 |
---|
904 | Real ec.x[2]; |
---|
905 | Real c; |
---|
906 | equation |
---|
907 | c = ec.x[2]; |
---|
908 | ec.x[1] = 0.0; |
---|
909 | end ExpandableConnectors.Expandable22; |
---|
910 | ")}))); |
---|
911 | end Expandable22; |
---|
912 | |
---|
913 | |
---|
914 | model Expandable23 |
---|
915 | expandable connector EC |
---|
916 | Real x[3]; |
---|
917 | end EC; |
---|
918 | |
---|
919 | connector C = Real; |
---|
920 | |
---|
921 | EC ec; |
---|
922 | C c; |
---|
923 | equation |
---|
924 | connect(c, ec.x[2]); |
---|
925 | |
---|
926 | annotation(__JModelica(UnitTesting(tests={ |
---|
927 | FlatteningTestCase( |
---|
928 | name="Expandable23", |
---|
929 | description="Expandable connectors: Connecting to only some elements of array", |
---|
930 | flatModel=" |
---|
931 | fclass ExpandableConnectors.Expandable23 |
---|
932 | Real ec.x[3]; |
---|
933 | Real c; |
---|
934 | equation |
---|
935 | c = ec.x[2]; |
---|
936 | ec.x[1] = 0.0; |
---|
937 | ec.x[3] = 0.0; |
---|
938 | end ExpandableConnectors.Expandable23; |
---|
939 | ")}))); |
---|
940 | end Expandable23; |
---|
941 | |
---|
942 | |
---|
943 | model Expandable24 |
---|
944 | expandable connector EC |
---|
945 | end EC; |
---|
946 | |
---|
947 | connector C |
---|
948 | Real x; |
---|
949 | Real y; |
---|
950 | end C; |
---|
951 | |
---|
952 | EC ec; |
---|
953 | C c; |
---|
954 | equation |
---|
955 | connect(c, ec.x[2]); |
---|
956 | |
---|
957 | annotation(__JModelica(UnitTesting(tests={ |
---|
958 | FlatteningTestCase( |
---|
959 | name="Expandable24", |
---|
960 | description="Expandable connectors: Connecting to only some elements of array", |
---|
961 | flatModel=" |
---|
962 | fclass ExpandableConnectors.Expandable24 |
---|
963 | Real ec.x[1].x; |
---|
964 | Real ec.x[1].y; |
---|
965 | Real ec.x[2].x; |
---|
966 | Real ec.x[2].y; |
---|
967 | Real c.x; |
---|
968 | Real c.y; |
---|
969 | equation |
---|
970 | c.x = ec.x[2].x; |
---|
971 | c.y = ec.x[2].y; |
---|
972 | ec.x[1].x = 0.0; |
---|
973 | ec.x[1].y = 0.0; |
---|
974 | end ExpandableConnectors.Expandable24; |
---|
975 | ")}))); |
---|
976 | end Expandable24; |
---|
977 | |
---|
978 | |
---|
979 | model Expandable25 |
---|
980 | expandable connector EC |
---|
981 | C x[3]; |
---|
982 | end EC; |
---|
983 | |
---|
984 | connector C |
---|
985 | Real x; |
---|
986 | Real y; |
---|
987 | end C; |
---|
988 | |
---|
989 | EC ec; |
---|
990 | C c; |
---|
991 | equation |
---|
992 | connect(c, ec.x[2]); |
---|
993 | |
---|
994 | annotation(__JModelica(UnitTesting(tests={ |
---|
995 | FlatteningTestCase( |
---|
996 | name="Expandable25", |
---|
997 | description="Expandable connectors: Connecting to only some elements of array", |
---|
998 | flatModel=" |
---|
999 | fclass ExpandableConnectors.Expandable25 |
---|
1000 | Real ec.x[1].x; |
---|
1001 | Real ec.x[1].y; |
---|
1002 | Real ec.x[2].x; |
---|
1003 | Real ec.x[2].y; |
---|
1004 | Real ec.x[3].x; |
---|
1005 | Real ec.x[3].y; |
---|
1006 | Real c.x; |
---|
1007 | Real c.y; |
---|
1008 | equation |
---|
1009 | c.x = ec.x[2].x; |
---|
1010 | c.y = ec.x[2].y; |
---|
1011 | ec.x[1].x = 0.0; |
---|
1012 | ec.x[1].y = 0.0; |
---|
1013 | ec.x[3].x = 0.0; |
---|
1014 | ec.x[3].y = 0.0; |
---|
1015 | end ExpandableConnectors.Expandable25; |
---|
1016 | ")}))); |
---|
1017 | end Expandable25; |
---|
1018 | |
---|
1019 | |
---|
1020 | model Expandable26 |
---|
1021 | expandable connector EC1 |
---|
1022 | EC2 ec2; |
---|
1023 | end EC1; |
---|
1024 | |
---|
1025 | expandable connector EC2 |
---|
1026 | end EC2; |
---|
1027 | |
---|
1028 | connector C = Real; |
---|
1029 | |
---|
1030 | EC1 ec1; |
---|
1031 | C c; |
---|
1032 | equation |
---|
1033 | connect(c, ec1.ec2.a); |
---|
1034 | |
---|
1035 | annotation(__JModelica(UnitTesting(tests={ |
---|
1036 | FlatteningTestCase( |
---|
1037 | name="Expandable26", |
---|
1038 | description="Nested declared expandable connectors: basic test", |
---|
1039 | flatModel=" |
---|
1040 | fclass ExpandableConnectors.Expandable26 |
---|
1041 | Real ec1.ec2.a; |
---|
1042 | Real c; |
---|
1043 | equation |
---|
1044 | c = ec1.ec2.a; |
---|
1045 | end ExpandableConnectors.Expandable26; |
---|
1046 | ")}))); |
---|
1047 | end Expandable26; |
---|
1048 | |
---|
1049 | |
---|
1050 | model Expandable27 |
---|
1051 | expandable connector EC1 |
---|
1052 | C1 c1; |
---|
1053 | end EC1; |
---|
1054 | |
---|
1055 | connector C1 |
---|
1056 | EC2 ec2; |
---|
1057 | Real x; |
---|
1058 | end C1; |
---|
1059 | |
---|
1060 | expandable connector EC2 |
---|
1061 | end EC2; |
---|
1062 | |
---|
1063 | connector C2 = Real; |
---|
1064 | |
---|
1065 | EC1 ec1; |
---|
1066 | C2 c2; |
---|
1067 | |
---|
1068 | annotation(__JModelica(UnitTesting(tests={ |
---|
1069 | FlatteningTestCase( |
---|
1070 | name="Expandable27", |
---|
1071 | description="Nested declared expandable connectors: not connected to", |
---|
1072 | flatModel=" |
---|
1073 | fclass ExpandableConnectors.Expandable27 |
---|
1074 | Real c2; |
---|
1075 | end ExpandableConnectors.Expandable27; |
---|
1076 | ")}))); |
---|
1077 | end Expandable27; |
---|
1078 | |
---|
1079 | |
---|
1080 | model Expandable28 |
---|
1081 | expandable connector EC1 |
---|
1082 | EC2 ec2; |
---|
1083 | end EC1; |
---|
1084 | |
---|
1085 | expandable connector EC2 |
---|
1086 | EC3 ec3; |
---|
1087 | end EC2; |
---|
1088 | |
---|
1089 | expandable connector EC3 |
---|
1090 | end EC3; |
---|
1091 | |
---|
1092 | connector C = Real; |
---|
1093 | |
---|
1094 | EC1 ec1; |
---|
1095 | C c; |
---|
1096 | equation |
---|
1097 | connect(c, ec1.ec2.ec3.a); |
---|
1098 | |
---|
1099 | annotation(__JModelica(UnitTesting(tests={ |
---|
1100 | FlatteningTestCase( |
---|
1101 | name="Expandable28", |
---|
1102 | description="Nested declared expandable connectors: three deep", |
---|
1103 | flatModel=" |
---|
1104 | fclass ExpandableConnectors.Expandable28 |
---|
1105 | Real ec1.ec2.ec3.a; |
---|
1106 | Real c; |
---|
1107 | equation |
---|
1108 | c = ec1.ec2.ec3.a; |
---|
1109 | end ExpandableConnectors.Expandable28; |
---|
1110 | ")}))); |
---|
1111 | end Expandable28; |
---|
1112 | |
---|
1113 | |
---|
1114 | model Expandable29 |
---|
1115 | expandable connector EC1 |
---|
1116 | EC2 ec2; |
---|
1117 | end EC1; |
---|
1118 | |
---|
1119 | expandable connector EC2 |
---|
1120 | end EC2; |
---|
1121 | |
---|
1122 | connector C = Real; |
---|
1123 | |
---|
1124 | EC1 ec1; |
---|
1125 | C c1, c2; |
---|
1126 | equation |
---|
1127 | connect(c1, ec1.ec2.a); |
---|
1128 | connect(c2, ec1.b); |
---|
1129 | |
---|
1130 | annotation(__JModelica(UnitTesting(tests={ |
---|
1131 | FlatteningTestCase( |
---|
1132 | name="Expandable29", |
---|
1133 | description="Nested declared expandable connectors: adding members to both levels", |
---|
1134 | flatModel=" |
---|
1135 | fclass ExpandableConnectors.Expandable29 |
---|
1136 | Real ec1.b; |
---|
1137 | Real ec1.ec2.a; |
---|
1138 | Real c1; |
---|
1139 | Real c2; |
---|
1140 | equation |
---|
1141 | c1 = ec1.ec2.a; |
---|
1142 | c2 = ec1.b; |
---|
1143 | end ExpandableConnectors.Expandable29; |
---|
1144 | ")}))); |
---|
1145 | end Expandable29; |
---|
1146 | |
---|
1147 | |
---|
1148 | model Expandable30 |
---|
1149 | expandable connector EC1 |
---|
1150 | EC2 a; |
---|
1151 | end EC1; |
---|
1152 | |
---|
1153 | expandable connector EC2 |
---|
1154 | end EC2; |
---|
1155 | |
---|
1156 | connector C = Real; |
---|
1157 | |
---|
1158 | EC1 ec1_1, ec1_2; |
---|
1159 | EC2 ec2_1, ec2_2; |
---|
1160 | C c1, c2; |
---|
1161 | equation |
---|
1162 | connect(ec1_1, ec1_2); |
---|
1163 | connect(ec1_1.a, ec2_1); |
---|
1164 | connect(ec1_2.a, ec2_2); |
---|
1165 | connect(ec2_1.b, c1); |
---|
1166 | connect(ec2_2.c, c2); |
---|
1167 | |
---|
1168 | annotation(__JModelica(UnitTesting(tests={ |
---|
1169 | FlatteningTestCase( |
---|
1170 | name="Expandable30", |
---|
1171 | description="Connect expandable connectors containing other expandable connectors", |
---|
1172 | flatModel=" |
---|
1173 | fclass ExpandableConnectors.Expandable30 |
---|
1174 | Real ec1_1.a.b; |
---|
1175 | Real ec1_1.a.c; |
---|
1176 | Real ec1_2.a.b; |
---|
1177 | Real ec1_2.a.c; |
---|
1178 | Real ec2_1.b; |
---|
1179 | Real ec2_1.c; |
---|
1180 | Real ec2_2.b; |
---|
1181 | Real ec2_2.c; |
---|
1182 | Real c1; |
---|
1183 | Real c2; |
---|
1184 | equation |
---|
1185 | c1 = ec1_1.a.b; |
---|
1186 | ec1_1.a.b = ec1_2.a.b; |
---|
1187 | ec1_2.a.b = ec2_1.b; |
---|
1188 | ec2_1.b = ec2_2.b; |
---|
1189 | c2 = ec1_1.a.c; |
---|
1190 | ec1_1.a.c = ec1_2.a.c; |
---|
1191 | ec1_2.a.c = ec2_1.c; |
---|
1192 | ec2_1.c = ec2_2.c; |
---|
1193 | end ExpandableConnectors.Expandable30; |
---|
1194 | ")}))); |
---|
1195 | end Expandable30; |
---|
1196 | |
---|
1197 | |
---|
1198 | model Expandable31 |
---|
1199 | expandable connector EC |
---|
1200 | end EC; |
---|
1201 | |
---|
1202 | connector C = Real; |
---|
1203 | |
---|
1204 | model A |
---|
1205 | EC ec; |
---|
1206 | end A; |
---|
1207 | |
---|
1208 | A a; |
---|
1209 | EC ec; |
---|
1210 | C c1[2], c2[2]; |
---|
1211 | equation |
---|
1212 | connect(ec, a.ec); |
---|
1213 | connect(ec.b1, c1); |
---|
1214 | connect(a.ec.b2, c2); |
---|
1215 | |
---|
1216 | annotation(__JModelica(UnitTesting(tests={ |
---|
1217 | FlatteningTestCase( |
---|
1218 | name="Expandable31", |
---|
1219 | description="Make sure that extra equations aren't added for combinations of inner/outer connections", |
---|
1220 | flatModel=" |
---|
1221 | fclass ExpandableConnectors.Expandable31 |
---|
1222 | Real a.ec.b1[2]; |
---|
1223 | Real a.ec.b2[2]; |
---|
1224 | Real ec.b1[2]; |
---|
1225 | Real ec.b2[2]; |
---|
1226 | Real c1[2]; |
---|
1227 | Real c2[2]; |
---|
1228 | equation |
---|
1229 | a.ec.b1[1] = c1[1]; |
---|
1230 | c1[1] = ec.b1[1]; |
---|
1231 | a.ec.b1[2] = c1[2]; |
---|
1232 | c1[2] = ec.b1[2]; |
---|
1233 | a.ec.b2[1] = c2[1]; |
---|
1234 | c2[1] = ec.b2[1]; |
---|
1235 | a.ec.b2[2] = c2[2]; |
---|
1236 | c2[2] = ec.b2[2]; |
---|
1237 | end ExpandableConnectors.Expandable31; |
---|
1238 | ")}))); |
---|
1239 | end Expandable31; |
---|
1240 | |
---|
1241 | model Expandable32 |
---|
1242 | connector C = Real[2]; |
---|
1243 | |
---|
1244 | expandable connector EC |
---|
1245 | end EC; |
---|
1246 | |
---|
1247 | EC ec1, ec2; |
---|
1248 | C x = { time, 2 * time }; |
---|
1249 | equation |
---|
1250 | connect(ec1.x, x); |
---|
1251 | connect(ec1, ec2.ec); |
---|
1252 | |
---|
1253 | annotation(__JModelica(UnitTesting(tests={ |
---|
1254 | FlatteningTestCase( |
---|
1255 | name="Expandable32", |
---|
1256 | description="Array in nested expandable connector", |
---|
1257 | flatModel=" |
---|
1258 | fclass ExpandableConnectors.Expandable32 |
---|
1259 | ExpandableConnectors.Expandable32.C ec1.x[2]; |
---|
1260 | ExpandableConnectors.Expandable32.C ec2.ec.x[2]; |
---|
1261 | ExpandableConnectors.Expandable32.C x[2] = {time, 2 * time}; |
---|
1262 | equation |
---|
1263 | ec1.x[1] = ec2.ec.x[1]; |
---|
1264 | ec2.ec.x[1] = x[1]; |
---|
1265 | ec1.x[2] = ec2.ec.x[2]; |
---|
1266 | ec2.ec.x[2] = x[2]; |
---|
1267 | |
---|
1268 | public |
---|
1269 | type ExpandableConnectors.Expandable32.C = Real; |
---|
1270 | end ExpandableConnectors.Expandable32; |
---|
1271 | ")}))); |
---|
1272 | end Expandable32; |
---|
1273 | |
---|
1274 | |
---|
1275 | model Expandable33 |
---|
1276 | expandable connector EC |
---|
1277 | end EC; |
---|
1278 | connector C = Real; |
---|
1279 | EC ec1; |
---|
1280 | C c1; |
---|
1281 | |
---|
1282 | equation |
---|
1283 | connect(c1, ec1.a) annotation (Line( |
---|
1284 | points={{-22,2},{-43,2}}, |
---|
1285 | color={0,0,255}, |
---|
1286 | smooth=Smooth.None)); |
---|
1287 | c1 = time; |
---|
1288 | |
---|
1289 | annotation(__JModelica(UnitTesting(tests={ |
---|
1290 | FlatteningTestCase( |
---|
1291 | name="Expandable33", |
---|
1292 | description="Test expandable connector and connect equation with annotation, caused crash bug", |
---|
1293 | flatModel=" |
---|
1294 | fclass ExpandableConnectors.Expandable33 |
---|
1295 | Real ec1.a; |
---|
1296 | Real c1; |
---|
1297 | equation |
---|
1298 | c1 = time; |
---|
1299 | c1 = ec1.a; |
---|
1300 | end ExpandableConnectors.Expandable33; |
---|
1301 | ")}))); |
---|
1302 | end Expandable33; |
---|
1303 | |
---|
1304 | |
---|
1305 | model ExpandableWithInputOutput1 |
---|
1306 | connector CI = input Real; |
---|
1307 | connector CO = output Real; |
---|
1308 | connector C = Real; |
---|
1309 | |
---|
1310 | expandable connector EC |
---|
1311 | end EC; |
---|
1312 | |
---|
1313 | EC ec; |
---|
1314 | CI ci1; |
---|
1315 | CO co1; |
---|
1316 | input C ci2; |
---|
1317 | output C co2; |
---|
1318 | equation |
---|
1319 | connect(ci1, ec.ci1); |
---|
1320 | connect(ci2, ec.ci2); |
---|
1321 | connect(co1, ec.co1); |
---|
1322 | connect(co2, ec.co2); |
---|
1323 | |
---|
1324 | annotation(__JModelica(UnitTesting(tests={ |
---|
1325 | FlatteningTestCase( |
---|
1326 | name="ExpandableWithInputOutput1", |
---|
1327 | description="Created variables in expandable connectors shouldn't be considered top-level input/outputs", |
---|
1328 | flatModel=" |
---|
1329 | fclass ExpandableConnectors.ExpandableWithInputOutput1 |
---|
1330 | ExpandableConnectors.ExpandableWithInputOutput1.CI ec.ci1; |
---|
1331 | Real ec.ci2; |
---|
1332 | ExpandableConnectors.ExpandableWithInputOutput1.CO ec.co1; |
---|
1333 | Real ec.co2; |
---|
1334 | input ExpandableConnectors.ExpandableWithInputOutput1.CI ci1; |
---|
1335 | output ExpandableConnectors.ExpandableWithInputOutput1.CO co1; |
---|
1336 | input Real ci2; |
---|
1337 | output Real co2; |
---|
1338 | equation |
---|
1339 | ci1 = ec.ci1; |
---|
1340 | ci2 = ec.ci2; |
---|
1341 | co1 = ec.co1; |
---|
1342 | co2 = ec.co2; |
---|
1343 | |
---|
1344 | public |
---|
1345 | type ExpandableConnectors.ExpandableWithInputOutput1.CI = Real; |
---|
1346 | type ExpandableConnectors.ExpandableWithInputOutput1.CO = Real; |
---|
1347 | end ExpandableConnectors.ExpandableWithInputOutput1; |
---|
1348 | ")}))); |
---|
1349 | end ExpandableWithInputOutput1; |
---|
1350 | |
---|
1351 | |
---|
1352 | model FlowInExpandable1 |
---|
1353 | connector C |
---|
1354 | Real p; |
---|
1355 | flow Real f; |
---|
1356 | end C; |
---|
1357 | |
---|
1358 | expandable connector EC |
---|
1359 | end EC; |
---|
1360 | |
---|
1361 | model A |
---|
1362 | B b; |
---|
1363 | EC ec; |
---|
1364 | equation |
---|
1365 | connect(b.c, ec.c); |
---|
1366 | end A; |
---|
1367 | |
---|
1368 | model B |
---|
1369 | C c; |
---|
1370 | end B; |
---|
1371 | |
---|
1372 | A a; |
---|
1373 | B b; |
---|
1374 | EC ec; |
---|
1375 | equation |
---|
1376 | connect(a.ec, ec); |
---|
1377 | connect(b.c, ec.c); |
---|
1378 | |
---|
1379 | annotation(__JModelica(UnitTesting(tests={ |
---|
1380 | FlatteningTestCase( |
---|
1381 | name="FlowInExpandable1", |
---|
1382 | description="Check that flow variables in expandable connectors get zero equations as needed", |
---|
1383 | flatModel=" |
---|
1384 | fclass ExpandableConnectors.FlowInExpandable1 |
---|
1385 | Real a.b.c.p; |
---|
1386 | Real a.b.c.f; |
---|
1387 | Real a.ec.c.p; |
---|
1388 | Real a.ec.c.f; |
---|
1389 | Real b.c.p; |
---|
1390 | Real b.c.f; |
---|
1391 | Real ec.c.p; |
---|
1392 | Real ec.c.f; |
---|
1393 | equation |
---|
1394 | a.b.c.f - a.ec.c.f = 0.0; |
---|
1395 | a.ec.c.f + b.c.f - ec.c.f = 0.0; |
---|
1396 | a.ec.c.p = b.c.p; |
---|
1397 | b.c.p = ec.c.p; |
---|
1398 | a.b.c.p = a.ec.c.p; |
---|
1399 | ec.c.f = 0.0; |
---|
1400 | end ExpandableConnectors.FlowInExpandable1; |
---|
1401 | ")}))); |
---|
1402 | end FlowInExpandable1; |
---|
1403 | |
---|
1404 | |
---|
1405 | package Error |
---|
1406 | |
---|
1407 | model ExpandableErr1 |
---|
1408 | expandable connector EC |
---|
1409 | end EC; |
---|
1410 | |
---|
1411 | connector C = Real; |
---|
1412 | |
---|
1413 | EC ec1; |
---|
1414 | C c[3]; |
---|
1415 | equation |
---|
1416 | connect(c, ec1.a[1:2]); |
---|
1417 | |
---|
1418 | annotation(__JModelica(UnitTesting(tests={ |
---|
1419 | ErrorTestCase( |
---|
1420 | name="ExpandableErr1", |
---|
1421 | description="Exandable connectors: local size error in connection, length differs", |
---|
1422 | errorMessage=" |
---|
1423 | 1 errors found: |
---|
1424 | |
---|
1425 | Error at line 10, column 9, in file 'Compiler/ModelicaFrontEnd/test/modelica/ExpandableConnectors.mo': |
---|
1426 | Can not match size of connector to access introducing member in external connector |
---|
1427 | ")}))); |
---|
1428 | end ExpandableErr1; |
---|
1429 | |
---|
1430 | |
---|
1431 | model ExpandableErr2 |
---|
1432 | expandable connector EC |
---|
1433 | end EC; |
---|
1434 | |
---|
1435 | connector C = Real; |
---|
1436 | |
---|
1437 | EC ec1; |
---|
1438 | C c[3]; |
---|
1439 | equation |
---|
1440 | connect(c, ec1.a[:,1:2]); |
---|
1441 | |
---|
1442 | annotation(__JModelica(UnitTesting(tests={ |
---|
1443 | ErrorTestCase( |
---|
1444 | name="ExpandableErr2", |
---|
1445 | description="Exandable connectors: local size error in connection, number of dimensions differ", |
---|
1446 | errorMessage=" |
---|
1447 | 1 errors found: |
---|
1448 | |
---|
1449 | Error at line 10, column 9, in file 'Compiler/ModelicaFrontEnd/test/modelica/ExpandableConnectors.mo': |
---|
1450 | Can not match size of connector to access introducing member in external connector |
---|
1451 | ")}))); |
---|
1452 | end ExpandableErr2; |
---|
1453 | |
---|
1454 | |
---|
1455 | model ExpandableErr3 |
---|
1456 | expandable connector EC |
---|
1457 | end EC; |
---|
1458 | |
---|
1459 | connector C = Real; |
---|
1460 | |
---|
1461 | EC ec1; |
---|
1462 | C c[3,3]; |
---|
1463 | equation |
---|
1464 | connect(c, ec1.a[:]); |
---|
1465 | |
---|
1466 | annotation(__JModelica(UnitTesting(tests={ |
---|
1467 | ErrorTestCase( |
---|
1468 | name="ExpandableErr3", |
---|
1469 | description="Exandable connectors: local size error in connection, number of dimensions differ", |
---|
1470 | errorMessage=" |
---|
1471 | 1 errors found: |
---|
1472 | |
---|
1473 | Error at line 10, column 9, in file 'Compiler/ModelicaFrontEnd/test/modelica/ExpandableConnectors.mo': |
---|
1474 | Can not match size of connector to access introducing member in external connector |
---|
1475 | ")}))); |
---|
1476 | end ExpandableErr3; |
---|
1477 | |
---|
1478 | |
---|
1479 | model ExpandableErr3b |
---|
1480 | expandable connector EC |
---|
1481 | end EC; |
---|
1482 | |
---|
1483 | connector C = Real; |
---|
1484 | |
---|
1485 | EC ec1; |
---|
1486 | C c[3,3]; |
---|
1487 | equation |
---|
1488 | connect(c, ec1.a[:,1]); |
---|
1489 | |
---|
1490 | annotation(__JModelica(UnitTesting(tests={ |
---|
1491 | ErrorTestCase( |
---|
1492 | name="ExpandableErr3b", |
---|
1493 | description="Exandable connectors: local size error in connection, number of dimensions differ", |
---|
1494 | errorMessage=" |
---|
1495 | 1 errors found: |
---|
1496 | |
---|
1497 | Error at line 10, column 9, in file 'Compiler/ModelicaFrontEnd/test/modelica/ExpandableConnectors.mo': |
---|
1498 | Can not match size of connector to access introducing member in external connector |
---|
1499 | ")}))); |
---|
1500 | end ExpandableErr3b; |
---|
1501 | |
---|
1502 | |
---|
1503 | model ExpandableErr4 |
---|
1504 | expandable connector EC |
---|
1505 | end EC; |
---|
1506 | |
---|
1507 | connector C = Real; |
---|
1508 | |
---|
1509 | EC ec1; |
---|
1510 | C c1[3], c2; |
---|
1511 | equation |
---|
1512 | connect(c1, ec1.a); |
---|
1513 | connect(c2, ec1.a[4]); |
---|
1514 | |
---|
1515 | annotation(__JModelica(UnitTesting(tests={ |
---|
1516 | ErrorTestCase( |
---|
1517 | name="ExpandableErr4", |
---|
1518 | description="Exandable connectors: size mismatch between connections, access to specific element > fixed size", |
---|
1519 | errorMessage=" |
---|
1520 | 1 errors found: |
---|
1521 | |
---|
1522 | Error at line 11, column 9, in file 'Compiler/ModelicaFrontEnd/test/modelica/ExpandableConnectors.mo': |
---|
1523 | Size introduced for external connector member does not match other connections to same name in connection set or component declared in connector |
---|
1524 | ")}))); |
---|
1525 | end ExpandableErr4; |
---|
1526 | |
---|
1527 | |
---|
1528 | model ExpandableErr5 |
---|
1529 | expandable connector EC |
---|
1530 | end EC; |
---|
1531 | |
---|
1532 | connector C = Real; |
---|
1533 | |
---|
1534 | EC ec1; |
---|
1535 | C c1[3], c2; |
---|
1536 | equation |
---|
1537 | connect(c2, ec1.a[4]); |
---|
1538 | connect(c1, ec1.a); |
---|
1539 | |
---|
1540 | annotation(__JModelica(UnitTesting(tests={ |
---|
1541 | ErrorTestCase( |
---|
1542 | name="ExpandableErr5", |
---|
1543 | description="Exandable connectors: size mismatch between connections, access to specific element > fixed size", |
---|
1544 | errorMessage=" |
---|
1545 | 1 errors found: |
---|
1546 | |
---|
1547 | Error at line 11, column 9, in file 'Compiler/ModelicaFrontEnd/test/modelica/ExpandableConnectors.mo': |
---|
1548 | Size introduced for external connector member does not match other connections to same name in connection set or component declared in connector |
---|
1549 | ")}))); |
---|
1550 | end ExpandableErr5; |
---|
1551 | |
---|
1552 | |
---|
1553 | model ExpandableErr6 |
---|
1554 | expandable connector EC |
---|
1555 | end EC; |
---|
1556 | |
---|
1557 | connector C = Real; |
---|
1558 | |
---|
1559 | EC ec1; |
---|
1560 | C c1[3], c2; |
---|
1561 | equation |
---|
1562 | connect(c1, ec1.a); |
---|
1563 | connect(c2, ec1.a[3,1]); |
---|
1564 | |
---|
1565 | annotation(__JModelica(UnitTesting(tests={ |
---|
1566 | ErrorTestCase( |
---|
1567 | name="ExpandableErr6", |
---|
1568 | description="Exandable connectors: size mismatch between connections, number of dimensions differ", |
---|
1569 | errorMessage=" |
---|
1570 | 1 errors found: |
---|
1571 | |
---|
1572 | Error at line 11, column 9, in file 'Compiler/ModelicaFrontEnd/test/modelica/ExpandableConnectors.mo': |
---|
1573 | Size introduced for external connector member does not match other connections to same name in connection set or component declared in connector |
---|
1574 | ")}))); |
---|
1575 | end ExpandableErr6; |
---|
1576 | |
---|
1577 | |
---|
1578 | model ExpandableErr7 |
---|
1579 | expandable connector EC |
---|
1580 | end EC; |
---|
1581 | |
---|
1582 | connector C = Real; |
---|
1583 | |
---|
1584 | EC ec1; |
---|
1585 | C c1[3], c2; |
---|
1586 | equation |
---|
1587 | connect(c2, ec1.a[3,1]); |
---|
1588 | connect(c1, ec1.a); |
---|
1589 | |
---|
1590 | annotation(__JModelica(UnitTesting(tests={ |
---|
1591 | ErrorTestCase( |
---|
1592 | name="ExpandableErr7", |
---|
1593 | description="Exandable connectors: size mismatch between connections, number of dimensions differ", |
---|
1594 | errorMessage=" |
---|
1595 | 1 errors found: |
---|
1596 | |
---|
1597 | Error at line 11, column 9, in file 'Compiler/ModelicaFrontEnd/test/modelica/ExpandableConnectors.mo': |
---|
1598 | Size introduced for external connector member does not match other connections to same name in connection set or component declared in connector |
---|
1599 | ")}))); |
---|
1600 | end ExpandableErr7; |
---|
1601 | |
---|
1602 | |
---|
1603 | model ExpandableErr8 |
---|
1604 | expandable connector EC |
---|
1605 | end EC; |
---|
1606 | |
---|
1607 | connector C = Real; |
---|
1608 | |
---|
1609 | EC ec1; |
---|
1610 | C c1[3], c2[4]; |
---|
1611 | equation |
---|
1612 | connect(c1, ec1.a); |
---|
1613 | connect(c2, ec1.a); |
---|
1614 | |
---|
1615 | annotation(__JModelica(UnitTesting(tests={ |
---|
1616 | ErrorTestCase( |
---|
1617 | name="ExpandableErr8", |
---|
1618 | description="Exandable connectors: size mismatch between connections, different fixed sizes", |
---|
1619 | errorMessage=" |
---|
1620 | 1 errors found: |
---|
1621 | |
---|
1622 | Error at line 11, column 9, in file 'Compiler/ModelicaFrontEnd/test/modelica/ExpandableConnectors.mo': |
---|
1623 | Size introduced for external connector member does not match other connections to same name in connection set or component declared in connector |
---|
1624 | ")}))); |
---|
1625 | end ExpandableErr8; |
---|
1626 | |
---|
1627 | |
---|
1628 | model ExpandableErr9 |
---|
1629 | expandable connector EC |
---|
1630 | end EC; |
---|
1631 | |
---|
1632 | connector C1 |
---|
1633 | Real x; |
---|
1634 | end C1; |
---|
1635 | |
---|
1636 | connector C2 |
---|
1637 | Real y; |
---|
1638 | end C2; |
---|
1639 | |
---|
1640 | EC ec; |
---|
1641 | C1 c1; |
---|
1642 | C2 c2; |
---|
1643 | equation |
---|
1644 | connect(c1, ec.a); |
---|
1645 | connect(c2, ec.a); |
---|
1646 | |
---|
1647 | annotation(__JModelica(UnitTesting(tests={ |
---|
1648 | ErrorTestCase( |
---|
1649 | name="ExpandableErr9", |
---|
1650 | description="", |
---|
1651 | errorMessage=" |
---|
1652 | 1 errors found: |
---|
1653 | |
---|
1654 | Error at line 18, column 9, in file 'Compiler/ModelicaFrontEnd/test/modelica/ExpandableConnectors.mo': |
---|
1655 | Type of component introduced to external connector does not match other connections to same name in connection set or component declared in connector |
---|
1656 | ")}))); |
---|
1657 | end ExpandableErr9; |
---|
1658 | |
---|
1659 | |
---|
1660 | model ExpandableErr10 |
---|
1661 | expandable connector EC |
---|
1662 | end EC; |
---|
1663 | |
---|
1664 | connector C1 = Real; |
---|
1665 | |
---|
1666 | connector C2 = Boolean; |
---|
1667 | |
---|
1668 | EC ec; |
---|
1669 | C1 c1; |
---|
1670 | C2 c2; |
---|
1671 | equation |
---|
1672 | connect(c1, ec.a[1]); |
---|
1673 | connect(c2, ec.a[2]); |
---|
1674 | |
---|
1675 | annotation(__JModelica(UnitTesting(tests={ |
---|
1676 | ErrorTestCase( |
---|
1677 | name="ExpandableErr10", |
---|
1678 | description="", |
---|
1679 | errorMessage=" |
---|
1680 | 1 errors found: |
---|
1681 | |
---|
1682 | Error at line 14, column 9, in file 'Compiler/ModelicaFrontEnd/test/modelica/ExpandableConnectors.mo': |
---|
1683 | Type of component introduced to external connector does not match other connections to same name in connection set or component declared in connector |
---|
1684 | ")}))); |
---|
1685 | end ExpandableErr10; |
---|
1686 | |
---|
1687 | |
---|
1688 | model ExpandableErr11 |
---|
1689 | expandable connector EC |
---|
1690 | Real a; |
---|
1691 | end EC; |
---|
1692 | |
---|
1693 | connector C = Boolean; |
---|
1694 | |
---|
1695 | EC ec; |
---|
1696 | C c; |
---|
1697 | equation |
---|
1698 | connect(c, ec.a); |
---|
1699 | |
---|
1700 | annotation(__JModelica(UnitTesting(tests={ |
---|
1701 | ErrorTestCase( |
---|
1702 | name="ExpandableErr11", |
---|
1703 | description="", |
---|
1704 | errorMessage=" |
---|
1705 | 1 errors found: |
---|
1706 | |
---|
1707 | Error at line 11, column 9, in file 'Compiler/ModelicaFrontEnd/test/modelica/ExpandableConnectors.mo': |
---|
1708 | Type of component introduced to external connector does not match other connections to same name in connection set or component declared in connector |
---|
1709 | ")}))); |
---|
1710 | end ExpandableErr11; |
---|
1711 | |
---|
1712 | |
---|
1713 | model ExpandableErr12 |
---|
1714 | expandable connector EC |
---|
1715 | Real a[3]; |
---|
1716 | end EC; |
---|
1717 | |
---|
1718 | connector C = Real; |
---|
1719 | |
---|
1720 | EC ec; |
---|
1721 | C c[3]; |
---|
1722 | equation |
---|
1723 | connect(c[1:2], ec.a); |
---|
1724 | |
---|
1725 | annotation(__JModelica(UnitTesting(tests={ |
---|
1726 | ErrorTestCase( |
---|
1727 | name="ExpandableErr12", |
---|
1728 | description="", |
---|
1729 | errorMessage=" |
---|
1730 | 1 errors found: |
---|
1731 | |
---|
1732 | Error at line 11, column 9, in file 'Compiler/ModelicaFrontEnd/test/modelica/ExpandableConnectors.mo': |
---|
1733 | Size introduced for external connector member does not match other connections to same name in connection set or component declared in connector |
---|
1734 | ")}))); |
---|
1735 | end ExpandableErr12; |
---|
1736 | |
---|
1737 | |
---|
1738 | model ExpandableErr13 |
---|
1739 | expandable connector EC1 |
---|
1740 | Real a; |
---|
1741 | end EC1; |
---|
1742 | |
---|
1743 | expandable connector EC2 |
---|
1744 | end EC2; |
---|
1745 | |
---|
1746 | connector C = Boolean; |
---|
1747 | |
---|
1748 | EC1 ec1; |
---|
1749 | EC2 ec2; |
---|
1750 | C c; |
---|
1751 | equation |
---|
1752 | connect(ec1, ec2); |
---|
1753 | connect(c, ec2.a); |
---|
1754 | |
---|
1755 | annotation(__JModelica(UnitTesting(tests={ |
---|
1756 | ErrorTestCase( |
---|
1757 | name="ExpandableErr13", |
---|
1758 | description="", |
---|
1759 | errorMessage=" |
---|
1760 | 1 errors found: |
---|
1761 | |
---|
1762 | Error at line 16, column 9, in file 'Compiler/ModelicaFrontEnd/test/modelica/ExpandableConnectors.mo': |
---|
1763 | Type of component introduced to external connector does not match other connections to same name in connection set or component declared in connector |
---|
1764 | ")}))); |
---|
1765 | end ExpandableErr13; |
---|
1766 | |
---|
1767 | |
---|
1768 | model ExpandableErr14 |
---|
1769 | expandable connector EC1 |
---|
1770 | Real a; |
---|
1771 | end EC1; |
---|
1772 | |
---|
1773 | expandable connector EC2 |
---|
1774 | Boolean a; |
---|
1775 | end EC2; |
---|
1776 | |
---|
1777 | EC1 ec1; |
---|
1778 | EC2 ec2; |
---|
1779 | equation |
---|
1780 | connect(ec1, ec2); |
---|
1781 | |
---|
1782 | annotation(__JModelica(UnitTesting(tests={ |
---|
1783 | ErrorTestCase( |
---|
1784 | name="ExpandableErr14", |
---|
1785 | description="", |
---|
1786 | errorMessage=" |
---|
1787 | 1 errors found: |
---|
1788 | |
---|
1789 | Error at line 13, column 9, in file 'Compiler/ModelicaFrontEnd/test/modelica/ExpandableConnectors.mo', TYPE_MISMATCH_IN_CONNECT: |
---|
1790 | Types of connected components do not match |
---|
1791 | ")}))); |
---|
1792 | end ExpandableErr14; |
---|
1793 | |
---|
1794 | |
---|
1795 | model ExpandableErr15 |
---|
1796 | expandable connector EC1 |
---|
1797 | Real a[3]; |
---|
1798 | end EC1; |
---|
1799 | |
---|
1800 | expandable connector EC2 |
---|
1801 | Real a[4]; |
---|
1802 | end EC2; |
---|
1803 | |
---|
1804 | EC1 ec1; |
---|
1805 | EC2 ec2; |
---|
1806 | equation |
---|
1807 | connect(ec1, ec2); |
---|
1808 | |
---|
1809 | annotation(__JModelica(UnitTesting(tests={ |
---|
1810 | ErrorTestCase( |
---|
1811 | name="ExpandableErr15", |
---|
1812 | description="", |
---|
1813 | errorMessage=" |
---|
1814 | 1 errors found: |
---|
1815 | |
---|
1816 | Error at line 13, column 9, in file 'Compiler/ModelicaFrontEnd/test/modelica/ExpandableConnectors.mo', TYPE_MISMATCH_IN_CONNECT: |
---|
1817 | Types of connected components do not match |
---|
1818 | ")}))); |
---|
1819 | end ExpandableErr15; |
---|
1820 | |
---|
1821 | |
---|
1822 | model ExpandableErr16 |
---|
1823 | expandable connector EC1 |
---|
1824 | Real a; |
---|
1825 | end EC1; |
---|
1826 | |
---|
1827 | expandable connector EC2 |
---|
1828 | end EC2; |
---|
1829 | |
---|
1830 | expandable connector EC3 |
---|
1831 | Boolean a; |
---|
1832 | end EC3; |
---|
1833 | |
---|
1834 | connector C = Real; |
---|
1835 | |
---|
1836 | EC1 ec1; |
---|
1837 | EC2 ec2; |
---|
1838 | EC3 ec3; |
---|
1839 | C c; |
---|
1840 | equation |
---|
1841 | connect(ec1, ec2); |
---|
1842 | connect(ec2, ec3); |
---|
1843 | connect(c, ec1.a); |
---|
1844 | |
---|
1845 | annotation(__JModelica(UnitTesting(tests={ |
---|
1846 | ErrorTestCase( |
---|
1847 | name="ExpandableErr16", |
---|
1848 | description="", |
---|
1849 | errorMessage=" |
---|
1850 | 1 errors found: |
---|
1851 | |
---|
1852 | Error at line 10, column 13, in file 'Compiler/ModelicaFrontEnd/test/modelica/ExpandableConnectors.mo': |
---|
1853 | Type of declared member of expandable connector does not match declarations in other expandable connectors in same connection set |
---|
1854 | ")}))); |
---|
1855 | end ExpandableErr16; |
---|
1856 | |
---|
1857 | |
---|
1858 | model ExpandableErr17 |
---|
1859 | expandable connector EC1 |
---|
1860 | Real a[3]; |
---|
1861 | end EC1; |
---|
1862 | |
---|
1863 | expandable connector EC2 |
---|
1864 | end EC2; |
---|
1865 | |
---|
1866 | expandable connector EC3 |
---|
1867 | Real a[4]; |
---|
1868 | end EC3; |
---|
1869 | |
---|
1870 | connector C = Real; |
---|
1871 | |
---|
1872 | EC1 ec1; |
---|
1873 | EC2 ec2; |
---|
1874 | EC3 ec3; |
---|
1875 | C c[3]; |
---|
1876 | equation |
---|
1877 | connect(ec1, ec2); |
---|
1878 | connect(ec2, ec3); |
---|
1879 | connect(c, ec1.a); |
---|
1880 | |
---|
1881 | annotation(__JModelica(UnitTesting(tests={ |
---|
1882 | ErrorTestCase( |
---|
1883 | name="ExpandableErr17", |
---|
1884 | description="", |
---|
1885 | errorMessage=" |
---|
1886 | 1 errors found: |
---|
1887 | |
---|
1888 | Error at line 10, column 13, in file 'Compiler/ModelicaFrontEnd/test/modelica/ExpandableConnectors.mo': |
---|
1889 | Size of declared member of expandable connector does not match declarations in other expandable connectors in same connection set |
---|
1890 | ")}))); |
---|
1891 | end ExpandableErr17; |
---|
1892 | |
---|
1893 | |
---|
1894 | model ExpandableErr18 |
---|
1895 | expandable connector EC |
---|
1896 | Real x; |
---|
1897 | end EC; |
---|
1898 | |
---|
1899 | connector C |
---|
1900 | Real x; |
---|
1901 | end C; |
---|
1902 | |
---|
1903 | EC ec; |
---|
1904 | C c; |
---|
1905 | equation |
---|
1906 | connect(ec, c); |
---|
1907 | |
---|
1908 | annotation(__JModelica(UnitTesting(tests={ |
---|
1909 | ErrorTestCase( |
---|
1910 | name="ExpandableErr18", |
---|
1911 | description="", |
---|
1912 | errorMessage=" |
---|
1913 | 1 errors found: |
---|
1914 | |
---|
1915 | Error at line 13, column 9, in file 'Compiler/ModelicaFrontEnd/test/modelica/ExpandableConnectors.mo', CONNECT_EXPANDABLE_AND_NON_EXPANDABLE_TYPE: |
---|
1916 | Connecting an expandable connector to a non-expandable connector is not allowed |
---|
1917 | ")}))); |
---|
1918 | end ExpandableErr18; |
---|
1919 | |
---|
1920 | |
---|
1921 | model ExpandableErr19 |
---|
1922 | expandable connector EC |
---|
1923 | Real x; |
---|
1924 | end EC; |
---|
1925 | |
---|
1926 | EC ec; |
---|
1927 | Real y; |
---|
1928 | equation |
---|
1929 | y = ec.x; |
---|
1930 | |
---|
1931 | annotation(__JModelica(UnitTesting(tests={ |
---|
1932 | ErrorTestCase( |
---|
1933 | name="ExpandableErr19", |
---|
1934 | description="Using member of expandable connector that is not connected to", |
---|
1935 | errorMessage=" |
---|
1936 | 1 errors found: |
---|
1937 | |
---|
1938 | Error at line 9, column 13, in file 'Compiler/ModelicaFrontEnd/test/modelica/ExpandableConnectors.mo': |
---|
1939 | Using member of expandable connector is only allowed if the member is connected to in the connection set |
---|
1940 | ")}))); |
---|
1941 | end ExpandableErr19; |
---|
1942 | |
---|
1943 | |
---|
1944 | model ExpandableErr20 |
---|
1945 | expandable connector EC |
---|
1946 | Real x; |
---|
1947 | end EC; |
---|
1948 | |
---|
1949 | EC ec; |
---|
1950 | Real y = ec.x; |
---|
1951 | |
---|
1952 | annotation(__JModelica(UnitTesting(tests={ |
---|
1953 | ErrorTestCase( |
---|
1954 | name="ExpandableErr20", |
---|
1955 | description="Using member of expandable connector that is not connected to", |
---|
1956 | errorMessage=" |
---|
1957 | 1 errors found: |
---|
1958 | |
---|
1959 | Error at line 7, column 18, in file 'Compiler/ModelicaFrontEnd/test/modelica/ExpandableConnectors.mo': |
---|
1960 | Using member of expandable connector is only allowed if the member is connected to in the connection set |
---|
1961 | ")}))); |
---|
1962 | end ExpandableErr20; |
---|
1963 | |
---|
1964 | |
---|
1965 | model ExpandableErr21 |
---|
1966 | expandable connector EC |
---|
1967 | Real x; |
---|
1968 | end EC; |
---|
1969 | |
---|
1970 | model A |
---|
1971 | Real y; |
---|
1972 | end A; |
---|
1973 | |
---|
1974 | EC ec; |
---|
1975 | A a(y = ec.x); |
---|
1976 | |
---|
1977 | annotation(__JModelica(UnitTesting(tests={ |
---|
1978 | ErrorTestCase( |
---|
1979 | name="ExpandableErr21", |
---|
1980 | description="Using member of expandable connector that is not connected to", |
---|
1981 | errorMessage=" |
---|
1982 | 1 errors found: |
---|
1983 | |
---|
1984 | Error at line 11, column 17, in file 'Compiler/ModelicaFrontEnd/test/modelica/ExpandableConnectors.mo': |
---|
1985 | Using member of expandable connector is only allowed if the member is connected to in the connection set |
---|
1986 | ")}))); |
---|
1987 | end ExpandableErr21; |
---|
1988 | |
---|
1989 | |
---|
1990 | model ExpandableErr22 |
---|
1991 | connector A |
---|
1992 | Real x; |
---|
1993 | end A; |
---|
1994 | |
---|
1995 | connector B |
---|
1996 | Real x; |
---|
1997 | Real y; |
---|
1998 | end B; |
---|
1999 | |
---|
2000 | expandable connector C |
---|
2001 | end C; |
---|
2002 | |
---|
2003 | C c1, c2; |
---|
2004 | A a; |
---|
2005 | B b; |
---|
2006 | equation |
---|
2007 | connect(a, c1.d); |
---|
2008 | connect(b, c2.d); |
---|
2009 | connect(c1, c2); |
---|
2010 | |
---|
2011 | annotation(__JModelica(UnitTesting(tests={ |
---|
2012 | ErrorTestCase( |
---|
2013 | name="ExpandableErr22", |
---|
2014 | description="", |
---|
2015 | errorMessage=" |
---|
2016 | 1 errors found: |
---|
2017 | |
---|
2018 | Error at line 19, column 5, in file 'Compiler/ModelicaFrontEnd/test/modelica/ExpandableConnectors.mo': |
---|
2019 | Type of component introduced to external connector does not match other connections to same name in connection set or component declared in connector |
---|
2020 | ")}))); |
---|
2021 | end ExpandableErr22; |
---|
2022 | |
---|
2023 | |
---|
2024 | end Error; |
---|
2025 | |
---|
2026 | |
---|
2027 | |
---|
2028 | package Compliance |
---|
2029 | |
---|
2030 | model ExpandableCompliance1 |
---|
2031 | expandable connector EC |
---|
2032 | end EC; |
---|
2033 | |
---|
2034 | connector C = Real; |
---|
2035 | |
---|
2036 | EC ec; |
---|
2037 | C c; |
---|
2038 | equation |
---|
2039 | connect(c, ec.a1.a2); |
---|
2040 | connect(ec.b1.b2, c); |
---|
2041 | |
---|
2042 | annotation(__JModelica(UnitTesting(tests={ |
---|
2043 | ComplianceErrorTestCase( |
---|
2044 | name="ExpandableCompliance1", |
---|
2045 | description="Nested expandable connectors: connecting with more than one unknown name", |
---|
2046 | errorMessage=" |
---|
2047 | 2 errors found: |
---|
2048 | |
---|
2049 | Compliance error at line 10, column 20, in file 'Compiler/ModelicaFrontEnd/test/modelica/ExpandableConnectors.mo': |
---|
2050 | Nested expandable connectors where some of the intermediate expandable connectors are neither connected to or declared are not supported |
---|
2051 | |
---|
2052 | Compliance error at line 11, column 17, in file 'Compiler/ModelicaFrontEnd/test/modelica/ExpandableConnectors.mo': |
---|
2053 | Nested expandable connectors where some of the intermediate expandable connectors are neither connected to or declared are not supported |
---|
2054 | ")}))); |
---|
2055 | end ExpandableCompliance1; |
---|
2056 | |
---|
2057 | |
---|
2058 | model ExpandableCompliance2 |
---|
2059 | expandable connector EC |
---|
2060 | end EC; |
---|
2061 | |
---|
2062 | connector C |
---|
2063 | EC ec; |
---|
2064 | end C; |
---|
2065 | |
---|
2066 | EC ec; |
---|
2067 | C c; |
---|
2068 | equation |
---|
2069 | connect(c, ec.c); |
---|
2070 | |
---|
2071 | annotation(__JModelica(UnitTesting(tests={ |
---|
2072 | ComplianceErrorTestCase( |
---|
2073 | name="ExpandableCompliance2", |
---|
2074 | description="Adding normal connector containing expandable connector to expandable connector", |
---|
2075 | errorMessage=" |
---|
2076 | 1 errors found: |
---|
2077 | |
---|
2078 | Compliance error at line 12, column 9, in file 'Compiler/ModelicaFrontEnd/test/modelica/ExpandableConnectors.mo': |
---|
2079 | Expandable connectors containing a non-expandable connector component, that in turn contains an expandable connector, is not supported |
---|
2080 | ")}))); |
---|
2081 | end ExpandableCompliance2; |
---|
2082 | |
---|
2083 | end Compliance; |
---|
2084 | |
---|
2085 | |
---|
2086 | |
---|
2087 | package Nested |
---|
2088 | |
---|
2089 | model NestedExpandable1 |
---|
2090 | expandable connector EC |
---|
2091 | end EC; |
---|
2092 | |
---|
2093 | connector C = Real; |
---|
2094 | |
---|
2095 | EC ec1; |
---|
2096 | EC ec2; |
---|
2097 | C c; |
---|
2098 | equation |
---|
2099 | connect(ec1.sub1, ec2); |
---|
2100 | connect(ec1.sub1.c, c); |
---|
2101 | |
---|
2102 | annotation(__JModelica(UnitTesting(tests={ |
---|
2103 | FlatteningTestCase( |
---|
2104 | name="NestedExpandable1", |
---|
2105 | description="Adding expandable connector member to expandable connector, member of parent first", |
---|
2106 | flatModel=" |
---|
2107 | fclass ExpandableConnectors.Nested.NestedExpandable1 |
---|
2108 | Real ec1.sub1.c; |
---|
2109 | Real ec2.c; |
---|
2110 | Real c; |
---|
2111 | equation |
---|
2112 | c = ec1.sub1.c; |
---|
2113 | ec1.sub1.c = ec2.c; |
---|
2114 | end ExpandableConnectors.Nested.NestedExpandable1; |
---|
2115 | ")}))); |
---|
2116 | end NestedExpandable1; |
---|
2117 | |
---|
2118 | |
---|
2119 | model NestedExpandable2 |
---|
2120 | expandable connector EC |
---|
2121 | end EC; |
---|
2122 | |
---|
2123 | connector C = Real; |
---|
2124 | |
---|
2125 | EC ec1; |
---|
2126 | EC ec2; |
---|
2127 | C c; |
---|
2128 | equation |
---|
2129 | connect(ec1.sub1.c, c); |
---|
2130 | connect(ec1.sub1, ec2); |
---|
2131 | |
---|
2132 | annotation(__JModelica(UnitTesting(tests={ |
---|
2133 | FlatteningTestCase( |
---|
2134 | name="NestedExpandable2", |
---|
2135 | description="Adding expandable connector member to expandable connector, member of child first", |
---|
2136 | flatModel=" |
---|
2137 | fclass ExpandableConnectors.Nested.NestedExpandable2 |
---|
2138 | Real ec1.sub1.c; |
---|
2139 | Real ec2.c; |
---|
2140 | Real c; |
---|
2141 | equation |
---|
2142 | c = ec1.sub1.c; |
---|
2143 | ec1.sub1.c = ec2.c; |
---|
2144 | end ExpandableConnectors.Nested.NestedExpandable2; |
---|
2145 | ")}))); |
---|
2146 | end NestedExpandable2; |
---|
2147 | |
---|
2148 | |
---|
2149 | model NestedExpandable3 |
---|
2150 | expandable connector EC |
---|
2151 | end EC; |
---|
2152 | |
---|
2153 | connector C = Real; |
---|
2154 | |
---|
2155 | EC ec1_1, ec1_2; |
---|
2156 | EC ec2_1, ec2_2; |
---|
2157 | C c1, c2; |
---|
2158 | equation |
---|
2159 | connect(ec1_1, ec1_2); |
---|
2160 | connect(ec1_1.a, ec2_1); |
---|
2161 | connect(ec1_2.a, ec2_2); |
---|
2162 | connect(ec1_1.a.b, c1); |
---|
2163 | connect(ec1_2.a.c, c2); |
---|
2164 | |
---|
2165 | annotation(__JModelica(UnitTesting(tests={ |
---|
2166 | FlatteningTestCase( |
---|
2167 | name="NestedExpandable3", |
---|
2168 | description="Adding expandable connector member to expandable connector, more complicated test", |
---|
2169 | flatModel=" |
---|
2170 | fclass ExpandableConnectors.Nested.NestedExpandable3 |
---|
2171 | Real ec1_1.a.b; |
---|
2172 | Real ec1_1.a.c; |
---|
2173 | Real ec1_2.a.b; |
---|
2174 | Real ec1_2.a.c; |
---|
2175 | Real ec2_1.b; |
---|
2176 | Real ec2_1.c; |
---|
2177 | Real ec2_2.b; |
---|
2178 | Real ec2_2.c; |
---|
2179 | Real c1; |
---|
2180 | Real c2; |
---|
2181 | equation |
---|
2182 | c1 = ec1_1.a.b; |
---|
2183 | ec1_1.a.b = ec1_2.a.b; |
---|
2184 | ec1_2.a.b = ec2_1.b; |
---|
2185 | ec2_1.b = ec2_2.b; |
---|
2186 | c2 = ec1_1.a.c; |
---|
2187 | ec1_1.a.c = ec1_2.a.c; |
---|
2188 | ec1_2.a.c = ec2_1.c; |
---|
2189 | ec2_1.c = ec2_2.c; |
---|
2190 | end ExpandableConnectors.Nested.NestedExpandable3; |
---|
2191 | ")}))); |
---|
2192 | end NestedExpandable3; |
---|
2193 | |
---|
2194 | |
---|
2195 | model NestedExpandable4 |
---|
2196 | expandable connector EC |
---|
2197 | end EC; |
---|
2198 | |
---|
2199 | connector C = Real; |
---|
2200 | |
---|
2201 | EC ec1, ec2, ec3; |
---|
2202 | C c; |
---|
2203 | equation |
---|
2204 | connect(ec2, ec1.ec2); |
---|
2205 | connect(ec3, ec1.ec2.ec3); |
---|
2206 | connect(c, ec1.ec2.ec3.a); |
---|
2207 | |
---|
2208 | annotation(__JModelica(UnitTesting(tests={ |
---|
2209 | FlatteningTestCase( |
---|
2210 | name="NestedExpandable4", |
---|
2211 | description="Adding expandable connector member to expandable connector, several levels", |
---|
2212 | flatModel=" |
---|
2213 | fclass ExpandableConnectors.Nested.NestedExpandable4 |
---|
2214 | Real ec1.ec2.ec3.a; |
---|
2215 | Real ec2.ec3.a; |
---|
2216 | Real ec3.a; |
---|
2217 | Real c; |
---|
2218 | equation |
---|
2219 | c = ec1.ec2.ec3.a; |
---|
2220 | ec1.ec2.ec3.a = ec2.ec3.a; |
---|
2221 | ec2.ec3.a = ec3.a; |
---|
2222 | end ExpandableConnectors.Nested.NestedExpandable4; |
---|
2223 | ")}))); |
---|
2224 | end NestedExpandable4; |
---|
2225 | |
---|
2226 | |
---|
2227 | model NestedExpandable5 |
---|
2228 | expandable connector EC |
---|
2229 | end EC; |
---|
2230 | |
---|
2231 | connector C = Real; |
---|
2232 | |
---|
2233 | EC ec1, ec2, ec3; |
---|
2234 | C c; |
---|
2235 | equation |
---|
2236 | connect(c, ec1.ec2.ec3.a); |
---|
2237 | connect(ec3, ec1.ec2.ec3); |
---|
2238 | connect(ec2, ec1.ec2); |
---|
2239 | |
---|
2240 | annotation(__JModelica(UnitTesting(tests={ |
---|
2241 | FlatteningTestCase( |
---|
2242 | name="NestedExpandable5", |
---|
2243 | description="Adding expandable connector member to expandable connector, several levels, members first", |
---|
2244 | flatModel=" |
---|
2245 | fclass ExpandableConnectors.Nested.NestedExpandable5 |
---|
2246 | Real ec1.ec2.ec3.a; |
---|
2247 | Real ec2.ec3.a; |
---|
2248 | Real ec3.a; |
---|
2249 | Real c; |
---|
2250 | equation |
---|
2251 | c = ec1.ec2.ec3.a; |
---|
2252 | ec1.ec2.ec3.a = ec2.ec3.a; |
---|
2253 | ec2.ec3.a = ec3.a; |
---|
2254 | end ExpandableConnectors.Nested.NestedExpandable5; |
---|
2255 | ")}))); |
---|
2256 | end NestedExpandable5; |
---|
2257 | |
---|
2258 | |
---|
2259 | model NestedExpandable6 |
---|
2260 | expandable connector EC |
---|
2261 | end EC; |
---|
2262 | |
---|
2263 | connector C1 |
---|
2264 | C2 a; |
---|
2265 | end C1; |
---|
2266 | |
---|
2267 | connector C2 = Real; |
---|
2268 | |
---|
2269 | EC ec; |
---|
2270 | C1 c1; |
---|
2271 | C2 c2; |
---|
2272 | equation |
---|
2273 | connect(ec.sub1, c1); |
---|
2274 | connect(ec.sub1.a, c2); |
---|
2275 | |
---|
2276 | annotation(__JModelica(UnitTesting(tests={ |
---|
2277 | FlatteningTestCase( |
---|
2278 | name="NestedExpandable6", |
---|
2279 | description="Connecting to existing member of normal connector in expandable connector", |
---|
2280 | flatModel=" |
---|
2281 | fclass ExpandableConnectors.Nested.NestedExpandable6 |
---|
2282 | Real ec.sub1.a; |
---|
2283 | Real c1.a; |
---|
2284 | Real c2; |
---|
2285 | equation |
---|
2286 | c1.a = c2; |
---|
2287 | c2 = ec.sub1.a; |
---|
2288 | end ExpandableConnectors.Nested.NestedExpandable6; |
---|
2289 | ")}))); |
---|
2290 | end NestedExpandable6; |
---|
2291 | |
---|
2292 | |
---|
2293 | model NestedExpandable7 |
---|
2294 | expandable connector EC |
---|
2295 | end EC; |
---|
2296 | |
---|
2297 | connector C |
---|
2298 | Real p; |
---|
2299 | flow Real f; |
---|
2300 | end C; |
---|
2301 | |
---|
2302 | EC ec1, ec2; |
---|
2303 | C c1[2], c2[2]; |
---|
2304 | equation |
---|
2305 | connect(ec1, ec2); |
---|
2306 | connect(ec1.ec.c1, c1); |
---|
2307 | connect(ec2.ec.c2, c2); |
---|
2308 | connect(ec1.ec, ec2); |
---|
2309 | |
---|
2310 | annotation(__JModelica(UnitTesting(tests={ |
---|
2311 | ErrorTestCase( |
---|
2312 | name="NestedExpandable7", |
---|
2313 | description="Check that recursive strucures are detected while elaborating expandable connectors", |
---|
2314 | errorMessage=" |
---|
2315 | 1 errors found: |
---|
2316 | |
---|
2317 | Error at line 16, column 9, in file 'Compiler/ModelicaFrontEnd/test/modelica/ExpandableConnectors.mo': |
---|
2318 | Connect introduces a copy of ec2 into a connector that is (possibly indirectly) connected back to ec2. This creates an infinite recursive structure, and is not allowed: |
---|
2319 | connect(ec1.ec, ec2) |
---|
2320 | ")}))); |
---|
2321 | end NestedExpandable7; |
---|
2322 | |
---|
2323 | |
---|
2324 | model NestedExpandable8 |
---|
2325 | expandable connector EC |
---|
2326 | end EC; |
---|
2327 | |
---|
2328 | EC ec1, ec2, ec3; |
---|
2329 | equation |
---|
2330 | connect(ec1.ec, ec2); |
---|
2331 | connect(ec2.ec, ec3); |
---|
2332 | connect(ec1, ec3); |
---|
2333 | |
---|
2334 | annotation(__JModelica(UnitTesting(tests={ |
---|
2335 | ErrorTestCase( |
---|
2336 | name="NestedExpandable8", |
---|
2337 | description="Check that recursive strucures are detected while elaborating expandable connectors", |
---|
2338 | errorMessage=" |
---|
2339 | 2 errors found: |
---|
2340 | |
---|
2341 | Error at line 7, column 9, in file 'Compiler/ModelicaFrontEnd/test/modelica/ExpandableConnectors.mo': |
---|
2342 | Connect introduces a copy of ec2 into a connector that is (possibly indirectly) connected back to ec2. This creates an infinite recursive structure, and is not allowed: |
---|
2343 | connect(ec1.ec, ec2) |
---|
2344 | |
---|
2345 | Error at line 8, column 9, in file 'Compiler/ModelicaFrontEnd/test/modelica/ExpandableConnectors.mo': |
---|
2346 | Connect introduces a copy of ec3 into a connector that is (possibly indirectly) connected back to ec3. This creates an infinite recursive structure, and is not allowed: |
---|
2347 | connect(ec2.ec, ec3) |
---|
2348 | ")}))); |
---|
2349 | end NestedExpandable8; |
---|
2350 | |
---|
2351 | |
---|
2352 | model NestedExpandable9 |
---|
2353 | expandable connector EC |
---|
2354 | end EC; |
---|
2355 | |
---|
2356 | connector C = Real; |
---|
2357 | |
---|
2358 | EC ec1, ec2, ec3; |
---|
2359 | C c1, c2, c3; |
---|
2360 | equation |
---|
2361 | connect(c1, ec1.ec.c1); |
---|
2362 | connect(c2, ec2.ec.c2); |
---|
2363 | connect(c3, ec1.c3); |
---|
2364 | connect(ec1.ec, ec3); |
---|
2365 | connect(ec2.ec, ec3); |
---|
2366 | |
---|
2367 | annotation(__JModelica(UnitTesting(tests={ |
---|
2368 | FlatteningTestCase( |
---|
2369 | name="NestedExpandable9", |
---|
2370 | description="Same expandable connector added as nested connector in two separate expandable connectors", |
---|
2371 | flatModel=" |
---|
2372 | fclass ExpandableConnectors.Nested.NestedExpandable9 |
---|
2373 | Real ec1.c3; |
---|
2374 | Real ec1.ec.c1; |
---|
2375 | Real ec1.ec.c2; |
---|
2376 | Real ec2.ec.c1; |
---|
2377 | Real ec2.ec.c2; |
---|
2378 | Real ec3.c1; |
---|
2379 | Real ec3.c2; |
---|
2380 | Real c1; |
---|
2381 | Real c2; |
---|
2382 | Real c3; |
---|
2383 | equation |
---|
2384 | c1 = ec1.ec.c1; |
---|
2385 | ec1.ec.c1 = ec2.ec.c1; |
---|
2386 | ec2.ec.c1 = ec3.c1; |
---|
2387 | c2 = ec1.ec.c2; |
---|
2388 | ec1.ec.c2 = ec2.ec.c2; |
---|
2389 | ec2.ec.c2 = ec3.c2; |
---|
2390 | c3 = ec1.c3; |
---|
2391 | end ExpandableConnectors.Nested.NestedExpandable9; |
---|
2392 | ")}))); |
---|
2393 | end NestedExpandable9; |
---|
2394 | |
---|
2395 | |
---|
2396 | model NestedExpandable10 |
---|
2397 | expandable connector EC |
---|
2398 | end EC; |
---|
2399 | |
---|
2400 | connector C = Real; |
---|
2401 | |
---|
2402 | EC ec1, ec2, ec3, ec4, ec5; |
---|
2403 | C c1, c2, c3; |
---|
2404 | equation |
---|
2405 | connect(c1, ec1.ec.c1); |
---|
2406 | connect(c2, ec2.ec.c2); |
---|
2407 | connect(c3, ec1.c3); |
---|
2408 | connect(ec1.ec, ec3); |
---|
2409 | connect(ec2.ec, ec4); |
---|
2410 | connect(ec1, ec5); |
---|
2411 | connect(ec5, ec2); |
---|
2412 | |
---|
2413 | annotation(__JModelica(UnitTesting(tests={ |
---|
2414 | FlatteningTestCase( |
---|
2415 | name="NestedExpandable10", |
---|
2416 | description="", |
---|
2417 | flatModel=" |
---|
2418 | fclass ExpandableConnectors.Nested.NestedExpandable10 |
---|
2419 | Real ec1.c3; |
---|
2420 | Real ec1.ec.c1; |
---|
2421 | Real ec1.ec.c2; |
---|
2422 | Real ec2.c3; |
---|
2423 | Real ec2.ec.c1; |
---|
2424 | Real ec2.ec.c2; |
---|
2425 | Real ec3.c1; |
---|
2426 | Real ec3.c2; |
---|
2427 | Real ec4.c1; |
---|
2428 | Real ec4.c2; |
---|
2429 | Real ec5.c3; |
---|
2430 | Real ec5.ec.c1; |
---|
2431 | Real ec5.ec.c2; |
---|
2432 | Real c1; |
---|
2433 | Real c2; |
---|
2434 | Real c3; |
---|
2435 | equation |
---|
2436 | c1 = ec1.ec.c1; |
---|
2437 | ec1.ec.c1 = ec2.ec.c1; |
---|
2438 | ec2.ec.c1 = ec3.c1; |
---|
2439 | ec3.c1 = ec4.c1; |
---|
2440 | ec4.c1 = ec5.ec.c1; |
---|
2441 | c3 = ec1.c3; |
---|
2442 | ec1.c3 = ec2.c3; |
---|
2443 | ec2.c3 = ec5.c3; |
---|
2444 | c2 = ec1.ec.c2; |
---|
2445 | ec1.ec.c2 = ec2.ec.c2; |
---|
2446 | ec2.ec.c2 = ec3.c2; |
---|
2447 | ec3.c2 = ec4.c2; |
---|
2448 | ec4.c2 = ec5.ec.c2; |
---|
2449 | end ExpandableConnectors.Nested.NestedExpandable10; |
---|
2450 | ")}))); |
---|
2451 | end NestedExpandable10; |
---|
2452 | |
---|
2453 | |
---|
2454 | model NestedExpandable11 |
---|
2455 | expandable connector EC1 |
---|
2456 | EC2[1] ec2; |
---|
2457 | end EC1; |
---|
2458 | |
---|
2459 | expandable connector EC2 |
---|
2460 | end EC2; |
---|
2461 | |
---|
2462 | connector C = Real; |
---|
2463 | |
---|
2464 | EC1 ec1; |
---|
2465 | model M |
---|
2466 | EC2 ec2; |
---|
2467 | end M; |
---|
2468 | C c; |
---|
2469 | M[1] m; |
---|
2470 | equation |
---|
2471 | connect(c, ec1.ec2[1].a); |
---|
2472 | for i in 1:1 loop |
---|
2473 | connect(ec1.ec2[i], m[i].ec2); |
---|
2474 | end for; |
---|
2475 | |
---|
2476 | annotation(__JModelica(UnitTesting(tests={ |
---|
2477 | FlatteningTestCase( |
---|
2478 | name="NestedExpandable11", |
---|
2479 | description="Nested with for index on last part", |
---|
2480 | flatModel=" |
---|
2481 | fclass ExpandableConnectors.Nested.NestedExpandable11 |
---|
2482 | Real ec1.ec2[1].a; |
---|
2483 | Real c; |
---|
2484 | Real m[1].ec2.a; |
---|
2485 | equation |
---|
2486 | c = ec1.ec2[1].a; |
---|
2487 | ec1.ec2[1].a = m[1].ec2.a; |
---|
2488 | end ExpandableConnectors.Nested.NestedExpandable11; |
---|
2489 | ")}))); |
---|
2490 | end NestedExpandable11; |
---|
2491 | |
---|
2492 | |
---|
2493 | package NestedError |
---|
2494 | |
---|
2495 | model NestedExpandableError1 |
---|
2496 | expandable connector EC |
---|
2497 | end EC; |
---|
2498 | |
---|
2499 | connector C1 |
---|
2500 | C2 c2; |
---|
2501 | end C1; |
---|
2502 | |
---|
2503 | connector C2 = Real; |
---|
2504 | |
---|
2505 | EC ec; |
---|
2506 | C1 c1; |
---|
2507 | C2 c2; |
---|
2508 | equation |
---|
2509 | connect(ec.c1, c1); |
---|
2510 | connect(ec.c1.a, c2); |
---|
2511 | |
---|
2512 | annotation(__JModelica(UnitTesting(tests={ |
---|
2513 | ErrorTestCase( |
---|
2514 | name="NestedExpandableError1", |
---|
2515 | description="Connecting to non-existing member of non-expandable connector in expandable connector", |
---|
2516 | errorMessage=" |
---|
2517 | 1 errors found: |
---|
2518 | |
---|
2519 | Error at line 16, column 9, in file 'Compiler/ModelicaFrontEnd/test/modelica/ExpandableConnectors.mo': |
---|
2520 | Can not connect to non-existing member of non-expandable connector in expandable connector |
---|
2521 | ")}))); |
---|
2522 | end NestedExpandableError1; |
---|
2523 | |
---|
2524 | |
---|
2525 | model NestedExpandableError2 |
---|
2526 | expandable connector EC |
---|
2527 | end EC; |
---|
2528 | |
---|
2529 | connector C1 |
---|
2530 | C2 c2; |
---|
2531 | end C1; |
---|
2532 | |
---|
2533 | connector C2 |
---|
2534 | C3 c3; |
---|
2535 | end C2; |
---|
2536 | |
---|
2537 | connector C3 = Real; |
---|
2538 | |
---|
2539 | EC ec; |
---|
2540 | C1 c1; |
---|
2541 | C3 c3; |
---|
2542 | equation |
---|
2543 | connect(ec.c1, c1); |
---|
2544 | connect(ec.c1.c2.a, c3); |
---|
2545 | |
---|
2546 | annotation(__JModelica(UnitTesting(tests={ |
---|
2547 | ErrorTestCase( |
---|
2548 | name="NestedExpandableError2", |
---|
2549 | description="Connecting to non-existing member of nested non-expandable connector in expandable connector", |
---|
2550 | errorMessage=" |
---|
2551 | 1 errors found: |
---|
2552 | |
---|
2553 | Error at line 20, column 9, in file 'Compiler/ModelicaFrontEnd/test/modelica/ExpandableConnectors.mo': |
---|
2554 | Can not connect to non-existing member of non-expandable connector in expandable connector |
---|
2555 | ")}))); |
---|
2556 | end NestedExpandableError2; |
---|
2557 | |
---|
2558 | end NestedError; |
---|
2559 | |
---|
2560 | end Nested; |
---|
2561 | |
---|
2562 | |
---|
2563 | |
---|
2564 | model DuplicatedExpandable1 |
---|
2565 | expandable connector EC |
---|
2566 | end EC; |
---|
2567 | |
---|
2568 | connector C = Real; |
---|
2569 | |
---|
2570 | model A |
---|
2571 | extends D; |
---|
2572 | EC ec; |
---|
2573 | B b; |
---|
2574 | equation |
---|
2575 | connect(b.c, ec.c); |
---|
2576 | end A; |
---|
2577 | |
---|
2578 | model B |
---|
2579 | C c = time; |
---|
2580 | end B; |
---|
2581 | |
---|
2582 | model D |
---|
2583 | EC ec; |
---|
2584 | end D; |
---|
2585 | |
---|
2586 | A a; |
---|
2587 | |
---|
2588 | annotation(__JModelica(UnitTesting(tests={ |
---|
2589 | FlatteningTestCase( |
---|
2590 | name="DuplicatedExpandable1", |
---|
2591 | description="Expandable connector with same name declared in both instantiated class and inherited class", |
---|
2592 | flatModel=" |
---|
2593 | fclass ExpandableConnectors.DuplicatedExpandable1 |
---|
2594 | Real a.b.c = time; |
---|
2595 | Real a.ec.c; |
---|
2596 | equation |
---|
2597 | a.b.c = a.ec.c; |
---|
2598 | end ExpandableConnectors.DuplicatedExpandable1; |
---|
2599 | ")}))); |
---|
2600 | end DuplicatedExpandable1; |
---|
2601 | |
---|
2602 | |
---|
2603 | model DuplicatedExpandable2 |
---|
2604 | expandable connector EC |
---|
2605 | end EC; |
---|
2606 | |
---|
2607 | connector C = Real; |
---|
2608 | |
---|
2609 | model A |
---|
2610 | extends D; |
---|
2611 | EC ec; |
---|
2612 | B b; |
---|
2613 | equation |
---|
2614 | connect(b.c, ec.c); |
---|
2615 | end A; |
---|
2616 | |
---|
2617 | model B |
---|
2618 | C c = time; |
---|
2619 | end B; |
---|
2620 | |
---|
2621 | model D |
---|
2622 | EC ec; |
---|
2623 | B b2; |
---|
2624 | equation |
---|
2625 | connect(b2.c, ec.c2); |
---|
2626 | end D; |
---|
2627 | |
---|
2628 | A a; |
---|
2629 | |
---|
2630 | annotation(__JModelica(UnitTesting(tests={ |
---|
2631 | FlatteningTestCase( |
---|
2632 | name="DuplicatedExpandable2", |
---|
2633 | description="Expandable connector with same name declared in both instantiated class and inherited class", |
---|
2634 | flatModel=" |
---|
2635 | fclass ExpandableConnectors.DuplicatedExpandable2 |
---|
2636 | Real a.b.c = time; |
---|
2637 | Real a.ec.c; |
---|
2638 | Real a.ec.c2; |
---|
2639 | Real a.b2.c = time; |
---|
2640 | equation |
---|
2641 | a.b.c = a.ec.c; |
---|
2642 | a.b2.c = a.ec.c2; |
---|
2643 | end ExpandableConnectors.DuplicatedExpandable2; |
---|
2644 | ")}))); |
---|
2645 | end DuplicatedExpandable2; |
---|
2646 | |
---|
2647 | |
---|
2648 | model AddToNestedAndConnectTopLevel |
---|
2649 | expandable connector EC |
---|
2650 | end EC; |
---|
2651 | |
---|
2652 | expandable connector EC2 |
---|
2653 | EC ec; |
---|
2654 | end EC2; |
---|
2655 | |
---|
2656 | connector C = Real; |
---|
2657 | |
---|
2658 | EC ec1; |
---|
2659 | EC2 ec2; |
---|
2660 | C c; |
---|
2661 | equation |
---|
2662 | connect(ec1, ec2); |
---|
2663 | connect(ec2.ec.c, c); |
---|
2664 | |
---|
2665 | annotation(__JModelica(UnitTesting(tests={ |
---|
2666 | FlatteningTestCase( |
---|
2667 | name="AddToNestedAndConnectTopLevel", |
---|
2668 | description="Make sure that nested connectors that are only declared to work correctly.", |
---|
2669 | flatModel=" |
---|
2670 | fclass ExpandableConnectors.AddToNestedAndConnectTopLevel |
---|
2671 | Real ec1.ec.c; |
---|
2672 | Real ec2.ec.c; |
---|
2673 | Real c; |
---|
2674 | equation |
---|
2675 | c = ec1.ec.c; |
---|
2676 | ec1.ec.c = ec2.ec.c; |
---|
2677 | end ExpandableConnectors.AddToNestedAndConnectTopLevel; |
---|
2678 | ")}))); |
---|
2679 | end AddToNestedAndConnectTopLevel; |
---|
2680 | |
---|
2681 | |
---|
2682 | package ConnectorArrays |
---|
2683 | |
---|
2684 | model ConnectorArray1 |
---|
2685 | connector C |
---|
2686 | flow Real a[1]; |
---|
2687 | flow Real b; |
---|
2688 | Real c[2]; |
---|
2689 | end C; |
---|
2690 | |
---|
2691 | expandable connector EC |
---|
2692 | end EC; |
---|
2693 | |
---|
2694 | C c[1]; |
---|
2695 | EC ec; |
---|
2696 | equation |
---|
2697 | connect(c[1], ec.x); |
---|
2698 | |
---|
2699 | annotation(__JModelica(UnitTesting(tests={ |
---|
2700 | FlatteningTestCase( |
---|
2701 | name="ConnectorArray1", |
---|
2702 | description="Connecting to array of connectors", |
---|
2703 | flatModel=" |
---|
2704 | fclass ExpandableConnectors.ConnectorArrays.ConnectorArray1 |
---|
2705 | input Real c[1].a[1]; |
---|
2706 | input Real c[1].b; |
---|
2707 | Real c[1].c[2]; |
---|
2708 | Real ec.x.a[1]; |
---|
2709 | Real ec.x.b; |
---|
2710 | Real ec.x.c[2]; |
---|
2711 | equation |
---|
2712 | - c[1].a[1:1] - ec.x.a[1:1] = zeros(1); |
---|
2713 | - c[1].b - ec.x.b = 0.0; |
---|
2714 | c[1].c[1:2] = ec.x.c[1:2]; |
---|
2715 | ec.x.a[1:1] = zeros(1); |
---|
2716 | ec.x.b = 0.0; |
---|
2717 | end ExpandableConnectors.ConnectorArrays.ConnectorArray1; |
---|
2718 | ")}))); |
---|
2719 | end ConnectorArray1; |
---|
2720 | |
---|
2721 | |
---|
2722 | model ConnectorArray2 |
---|
2723 | connector C |
---|
2724 | flow Real a[1]; |
---|
2725 | flow Real b; |
---|
2726 | Real c[2]; |
---|
2727 | end C; |
---|
2728 | |
---|
2729 | expandable connector EC |
---|
2730 | end EC; |
---|
2731 | |
---|
2732 | C c[2]; |
---|
2733 | EC ec; |
---|
2734 | equation |
---|
2735 | connect(c, ec.x); |
---|
2736 | |
---|
2737 | annotation(__JModelica(UnitTesting(tests={ |
---|
2738 | FlatteningTestCase( |
---|
2739 | name="ConnectorArray2", |
---|
2740 | description="Connecting to array of connectors", |
---|
2741 | flatModel=" |
---|
2742 | fclass ExpandableConnectors.ConnectorArrays.ConnectorArray2 |
---|
2743 | input Real c[1].a[1]; |
---|
2744 | input Real c[1].b; |
---|
2745 | Real c[1].c[2]; |
---|
2746 | input Real c[2].a[1]; |
---|
2747 | input Real c[2].b; |
---|
2748 | Real c[2].c[2]; |
---|
2749 | Real ec.x[1].a[1]; |
---|
2750 | Real ec.x[1].b; |
---|
2751 | Real ec.x[1].c[2]; |
---|
2752 | Real ec.x[2].a[1]; |
---|
2753 | Real ec.x[2].b; |
---|
2754 | Real ec.x[2].c[2]; |
---|
2755 | equation |
---|
2756 | - c[1].a[1:1] - ec.x[1].a[1:1] = zeros(1); |
---|
2757 | - c[1].b - ec.x[1].b = 0.0; |
---|
2758 | c[1].c[1:2] = ec.x[1].c[1:2]; |
---|
2759 | - c[2].a[1:1] - ec.x[2].a[1:1] = zeros(1); |
---|
2760 | - c[2].b - ec.x[2].b = 0.0; |
---|
2761 | c[2].c[1:2] = ec.x[2].c[1:2]; |
---|
2762 | ec.x[1].a[1:1] = zeros(1); |
---|
2763 | ec.x[1].b = 0.0; |
---|
2764 | ec.x[2].a[1:1] = zeros(1); |
---|
2765 | ec.x[2].b = 0.0; |
---|
2766 | end ExpandableConnectors.ConnectorArrays.ConnectorArray2; |
---|
2767 | ")}))); |
---|
2768 | end ConnectorArray2; |
---|
2769 | |
---|
2770 | |
---|
2771 | model ConnectorArray3 |
---|
2772 | connector C |
---|
2773 | flow Real a[1]; |
---|
2774 | flow Real b; |
---|
2775 | Real c[2]; |
---|
2776 | end C; |
---|
2777 | |
---|
2778 | expandable connector EC |
---|
2779 | end EC; |
---|
2780 | |
---|
2781 | C c[3]; |
---|
2782 | EC ec; |
---|
2783 | equation |
---|
2784 | connect(c[2:3], ec.x); |
---|
2785 | |
---|
2786 | annotation(__JModelica(UnitTesting(tests={ |
---|
2787 | FlatteningTestCase( |
---|
2788 | name="ConnectorArray3", |
---|
2789 | description="Connecting to array of connectors", |
---|
2790 | flatModel=" |
---|
2791 | fclass ExpandableConnectors.ConnectorArrays.ConnectorArray3 |
---|
2792 | input Real c[1].a[1]; |
---|
2793 | input Real c[1].b; |
---|
2794 | Real c[1].c[2]; |
---|
2795 | input Real c[2].a[1]; |
---|
2796 | input Real c[2].b; |
---|
2797 | Real c[2].c[2]; |
---|
2798 | input Real c[3].a[1]; |
---|
2799 | input Real c[3].b; |
---|
2800 | Real c[3].c[2]; |
---|
2801 | Real ec.x[1].a[1]; |
---|
2802 | Real ec.x[1].b; |
---|
2803 | Real ec.x[1].c[2]; |
---|
2804 | Real ec.x[2].a[1]; |
---|
2805 | Real ec.x[2].b; |
---|
2806 | Real ec.x[2].c[2]; |
---|
2807 | equation |
---|
2808 | - c[2].a[1:1] - ec.x[1].a[1:1] = zeros(1); |
---|
2809 | - c[2].b - ec.x[1].b = 0.0; |
---|
2810 | c[2].c[1:2] = ec.x[1].c[1:2]; |
---|
2811 | - c[3].a[1:1] - ec.x[2].a[1:1] = zeros(1); |
---|
2812 | - c[3].b - ec.x[2].b = 0.0; |
---|
2813 | c[3].c[1:2] = ec.x[2].c[1:2]; |
---|
2814 | ec.x[1].a[1:1] = zeros(1); |
---|
2815 | ec.x[1].b = 0.0; |
---|
2816 | ec.x[2].a[1:1] = zeros(1); |
---|
2817 | ec.x[2].b = 0.0; |
---|
2818 | end ExpandableConnectors.ConnectorArrays.ConnectorArray3; |
---|
2819 | ")}))); |
---|
2820 | end ConnectorArray3; |
---|
2821 | |
---|
2822 | |
---|
2823 | model ConnectorArray4 |
---|
2824 | connector C |
---|
2825 | flow Real a[1]; |
---|
2826 | flow Real b; |
---|
2827 | Real c[2]; |
---|
2828 | end C; |
---|
2829 | |
---|
2830 | expandable connector EC |
---|
2831 | end EC; |
---|
2832 | |
---|
2833 | C c1, c2; |
---|
2834 | EC ec; |
---|
2835 | equation |
---|
2836 | connect(c1, ec.x[1]); |
---|
2837 | connect(c2, ec.x[3]); |
---|
2838 | |
---|
2839 | annotation(__JModelica(UnitTesting(tests={ |
---|
2840 | FlatteningTestCase( |
---|
2841 | name="ConnectorArray4", |
---|
2842 | description="Connecting to array of connectors", |
---|
2843 | flatModel=" |
---|
2844 | fclass ExpandableConnectors.ConnectorArrays.ConnectorArray4 |
---|
2845 | input Real c1.a[1]; |
---|
2846 | input Real c1.b; |
---|
2847 | Real c1.c[2]; |
---|
2848 | input Real c2.a[1]; |
---|
2849 | input Real c2.b; |
---|
2850 | Real c2.c[2]; |
---|
2851 | Real ec.x[1].a[1]; |
---|
2852 | Real ec.x[1].b; |
---|
2853 | Real ec.x[1].c[2]; |
---|
2854 | Real ec.x[2].a[1]; |
---|
2855 | Real ec.x[2].b; |
---|
2856 | Real ec.x[2].c[2]; |
---|
2857 | Real ec.x[3].a[1]; |
---|
2858 | Real ec.x[3].b; |
---|
2859 | Real ec.x[3].c[2]; |
---|
2860 | equation |
---|
2861 | - c1.a[1:1] - ec.x[1].a[1:1] = zeros(1); |
---|
2862 | - c1.b - ec.x[1].b = 0.0; |
---|
2863 | c1.c[1:2] = ec.x[1].c[1:2]; |
---|
2864 | - c2.a[1:1] - ec.x[3].a[1:1] = zeros(1); |
---|
2865 | - c2.b - ec.x[3].b = 0.0; |
---|
2866 | c2.c[1:2] = ec.x[3].c[1:2]; |
---|
2867 | - ec.x[2].a[1:1] = zeros(1); |
---|
2868 | - ec.x[2].b = 0.0; |
---|
2869 | ec.x[2].c[1:2] = zeros(2); |
---|
2870 | ec.x[1].a[1:1] = zeros(1); |
---|
2871 | ec.x[1].b = 0.0; |
---|
2872 | ec.x[2].a[1:1] = zeros(1); |
---|
2873 | ec.x[2].b = 0.0; |
---|
2874 | ec.x[3].a[1:1] = zeros(1); |
---|
2875 | ec.x[3].b = 0.0; |
---|
2876 | end ExpandableConnectors.ConnectorArrays.ConnectorArray4; |
---|
2877 | ")}))); |
---|
2878 | end ConnectorArray4; |
---|
2879 | |
---|
2880 | |
---|
2881 | model ConnectorArray5 |
---|
2882 | connector C |
---|
2883 | parameter Integer n(min = 1); |
---|
2884 | flow Real a[n]; |
---|
2885 | Real b[n]; |
---|
2886 | end C; |
---|
2887 | |
---|
2888 | expandable connector EC |
---|
2889 | end EC; |
---|
2890 | |
---|
2891 | C c[2](n={2,3}); |
---|
2892 | EC ec; |
---|
2893 | equation |
---|
2894 | connect(ec.x, c); |
---|
2895 | |
---|
2896 | annotation(__JModelica(UnitTesting(tests={ |
---|
2897 | FlatteningTestCase( |
---|
2898 | name="ConnectorArray5", |
---|
2899 | description="Structural parameters in connector", |
---|
2900 | flatModel=" |
---|
2901 | fclass ExpandableConnectors.ConnectorArrays.ConnectorArray5 |
---|
2902 | structural parameter Integer c[1].n = 2 /* 2 */; |
---|
2903 | input Real c[1].a[2]; |
---|
2904 | Real c[1].b[2]; |
---|
2905 | structural parameter Integer c[2].n = 3 /* 3 */; |
---|
2906 | input Real c[2].a[3]; |
---|
2907 | Real c[2].b[3]; |
---|
2908 | structural parameter Integer ec.x[1].n = 2 /* 2 */; |
---|
2909 | Real ec.x[1].a[2]; |
---|
2910 | Real ec.x[1].b[2]; |
---|
2911 | structural parameter Integer ec.x[2].n = 3 /* 3 */; |
---|
2912 | Real ec.x[2].a[3]; |
---|
2913 | Real ec.x[2].b[3]; |
---|
2914 | equation |
---|
2915 | - c[1].a[1:2] - ec.x[1].a[1:2] = zeros(2); |
---|
2916 | c[1].b[1:2] = ec.x[1].b[1:2]; |
---|
2917 | - c[2].a[1:3] - ec.x[2].a[1:3] = zeros(3); |
---|
2918 | c[2].b[1:3] = ec.x[2].b[1:3]; |
---|
2919 | ec.x[1].a[1:2] = zeros(2); |
---|
2920 | ec.x[2].a[1:3] = zeros(3); |
---|
2921 | end ExpandableConnectors.ConnectorArrays.ConnectorArray5; |
---|
2922 | ")}))); |
---|
2923 | end ConnectorArray5; |
---|
2924 | |
---|
2925 | |
---|
2926 | model ConnectorArray6 |
---|
2927 | connector C |
---|
2928 | flow Real a; |
---|
2929 | stream Real b; |
---|
2930 | Real c; |
---|
2931 | end C; |
---|
2932 | |
---|
2933 | expandable connector EC |
---|
2934 | end EC; |
---|
2935 | |
---|
2936 | C c1, c2; |
---|
2937 | EC ec; |
---|
2938 | equation |
---|
2939 | connect(c1, ec.x[1]); |
---|
2940 | connect(c2, ec.x[3]); |
---|
2941 | |
---|
2942 | annotation(__JModelica(UnitTesting(tests={ |
---|
2943 | FlatteningTestCase( |
---|
2944 | name="ConnectorArray6", |
---|
2945 | description="Array of stream connectors, with gap", |
---|
2946 | flatModel=" |
---|
2947 | fclass ExpandableConnectors.ConnectorArrays.ConnectorArray6 |
---|
2948 | input Real c1.a; |
---|
2949 | Real c1.b; |
---|
2950 | Real c1.c; |
---|
2951 | input Real c2.a; |
---|
2952 | Real c2.b; |
---|
2953 | Real c2.c; |
---|
2954 | Real ec.x[1].a; |
---|
2955 | Real ec.x[1].b; |
---|
2956 | Real ec.x[1].c; |
---|
2957 | Real ec.x[2].a; |
---|
2958 | Real ec.x[2].b; |
---|
2959 | Real ec.x[2].c; |
---|
2960 | Real ec.x[3].a; |
---|
2961 | Real ec.x[3].b; |
---|
2962 | Real ec.x[3].c; |
---|
2963 | equation |
---|
2964 | - c1.a - ec.x[1].a = 0.0; |
---|
2965 | c1.b = inStream(ec.x[1].b); |
---|
2966 | ec.x[1].b = inStream(c1.b); |
---|
2967 | c1.c = ec.x[1].c; |
---|
2968 | - c2.a - ec.x[3].a = 0.0; |
---|
2969 | c2.b = inStream(ec.x[3].b); |
---|
2970 | ec.x[3].b = inStream(c2.b); |
---|
2971 | c2.c = ec.x[3].c; |
---|
2972 | - ec.x[2].a = 0.0; |
---|
2973 | ec.x[2].b = 0.0; |
---|
2974 | ec.x[2].c = 0.0; |
---|
2975 | ec.x[1].a = 0.0; |
---|
2976 | ec.x[2].a = 0.0; |
---|
2977 | ec.x[3].a = 0.0; |
---|
2978 | end ExpandableConnectors.ConnectorArrays.ConnectorArray6; |
---|
2979 | ")}))); |
---|
2980 | end ConnectorArray6; |
---|
2981 | |
---|
2982 | |
---|
2983 | model ConnectorArray7 |
---|
2984 | connector C |
---|
2985 | flow Real a; |
---|
2986 | Real b; |
---|
2987 | end C; |
---|
2988 | |
---|
2989 | expandable connector EC |
---|
2990 | end EC; |
---|
2991 | |
---|
2992 | model A |
---|
2993 | parameter Real p = 1; |
---|
2994 | C c(a(start=p)); |
---|
2995 | end A; |
---|
2996 | |
---|
2997 | A a; |
---|
2998 | EC ec; |
---|
2999 | equation |
---|
3000 | connect(ec.c, a.c); |
---|
3001 | |
---|
3002 | annotation(__JModelica(UnitTesting(tests={ |
---|
3003 | FlatteningTestCase( |
---|
3004 | name="ConnectorArray7", |
---|
3005 | description="Modicication on connected component referring to parameter outside of it", |
---|
3006 | flatModel=" |
---|
3007 | fclass ExpandableConnectors.ConnectorArrays.ConnectorArray7 |
---|
3008 | parameter Real a.p = 1 /* 1 */; |
---|
3009 | Real a.c.a(start = a.p); |
---|
3010 | Real a.c.b; |
---|
3011 | Real ec.c.a(start = a.p); |
---|
3012 | Real ec.c.b; |
---|
3013 | equation |
---|
3014 | a.c.a - ec.c.a = 0.0; |
---|
3015 | a.c.b = ec.c.b; |
---|
3016 | ec.c.a = 0.0; |
---|
3017 | end ExpandableConnectors.ConnectorArrays.ConnectorArray7; |
---|
3018 | ")}))); |
---|
3019 | end ConnectorArray7; |
---|
3020 | |
---|
3021 | model ConnectorArray8 |
---|
3022 | expandable connector EC |
---|
3023 | end EC; |
---|
3024 | |
---|
3025 | connector C = Real; |
---|
3026 | |
---|
3027 | EC ec1; |
---|
3028 | C c[2]; |
---|
3029 | equation |
---|
3030 | for i in 1:2 loop |
---|
3031 | connect(c[i], ec1.a[i]); |
---|
3032 | end for; |
---|
3033 | |
---|
3034 | annotation(__JModelica(UnitTesting(tests={ |
---|
3035 | FlatteningTestCase( |
---|
3036 | name="ConnectorArray8", |
---|
3037 | description="Expandable connector with for index", |
---|
3038 | flatModel=" |
---|
3039 | fclass ExpandableConnectors.ConnectorArrays.ConnectorArray8 |
---|
3040 | Real ec1.a[2]; |
---|
3041 | Real c[2]; |
---|
3042 | equation |
---|
3043 | c[1] = ec1.a[1]; |
---|
3044 | c[2] = ec1.a[2]; |
---|
3045 | end ExpandableConnectors.ConnectorArrays.ConnectorArray8; |
---|
3046 | ")}))); |
---|
3047 | end ConnectorArray8; |
---|
3048 | |
---|
3049 | model ConnectorArray9 |
---|
3050 | expandable connector EC |
---|
3051 | end EC; |
---|
3052 | |
---|
3053 | connector C = Real; |
---|
3054 | |
---|
3055 | EC ec1; |
---|
3056 | C c[2]; |
---|
3057 | equation |
---|
3058 | for i in 1:1 loop |
---|
3059 | connect(c, ec1.a[i:i+1]); |
---|
3060 | end for; |
---|
3061 | |
---|
3062 | annotation(__JModelica(UnitTesting(tests={ |
---|
3063 | FlatteningTestCase( |
---|
3064 | name="ConnectorArray9", |
---|
3065 | description="Expandable connector with for index", |
---|
3066 | flatModel=" |
---|
3067 | fclass ExpandableConnectors.ConnectorArrays.ConnectorArray9 |
---|
3068 | Real ec1.a[2]; |
---|
3069 | Real c[2]; |
---|
3070 | equation |
---|
3071 | c[1] = ec1.a[1]; |
---|
3072 | c[2] = ec1.a[2]; |
---|
3073 | end ExpandableConnectors.ConnectorArrays.ConnectorArray9; |
---|
3074 | ")}))); |
---|
3075 | end ConnectorArray9; |
---|
3076 | |
---|
3077 | |
---|
3078 | end ConnectorArrays; |
---|
3079 | |
---|
3080 | |
---|
3081 | |
---|
3082 | end ExpandableConnectors; |
---|