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