Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Belonging to [master]: - OpenModelica/OMCompiler#2022 - OpenModelica/OpenModelica-testsuite#782
- Loading branch information
1 parent
2bdb8a0
commit 4d95b57
Showing
5 changed files
with
151 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
// name: ForConnect1 | ||
// keywords: | ||
// status: correct | ||
// cflags: -d=newInst | ||
// | ||
// | ||
|
||
connector C | ||
Real e; | ||
flow Real f; | ||
end C; | ||
|
||
model ForConnect1 | ||
C c1[3], c2[3]; | ||
equation | ||
for i in 1:3 loop | ||
connect(c1[i], c2[i]); | ||
end for; | ||
end ForConnect1; | ||
|
||
// Result: | ||
// class ForConnect1 | ||
// Real c1[1].e; | ||
// Real c1[1].f; | ||
// Real c1[2].e; | ||
// Real c1[2].f; | ||
// Real c1[3].e; | ||
// Real c1[3].f; | ||
// Real c2[1].e; | ||
// Real c2[1].f; | ||
// Real c2[2].e; | ||
// Real c2[2].f; | ||
// Real c2[3].e; | ||
// Real c2[3].f; | ||
// equation | ||
// c1[1].e = c2[1].e; | ||
// (-c1[1].f) + (-c2[1].f) = 0.0; | ||
// c1[2].e = c2[2].e; | ||
// (-c1[2].f) + (-c2[2].f) = 0.0; | ||
// c1[3].e = c2[3].e; | ||
// (-c1[3].f) + (-c2[3].f) = 0.0; | ||
// c1[1].f = 0.0; | ||
// c1[2].f = 0.0; | ||
// c1[3].f = 0.0; | ||
// c2[1].f = 0.0; | ||
// c2[2].f = 0.0; | ||
// c2[3].f = 0.0; | ||
// end ForConnect1; | ||
// endResult |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
// name: IfConnect1 | ||
// keywords: | ||
// status: correct | ||
// cflags: -d=newInst | ||
// | ||
// | ||
|
||
connector C | ||
Real e; | ||
flow Real f; | ||
end C; | ||
|
||
model IfConnect1 | ||
parameter Boolean b = true; | ||
C c1, c2; | ||
equation | ||
if b then | ||
connect(c1, c2); | ||
end if; | ||
end IfConnect1; | ||
|
||
// Result: | ||
// class IfConnect1 | ||
// parameter Boolean b = true; | ||
// Real c1.e; | ||
// Real c1.f; | ||
// Real c2.e; | ||
// Real c2.f; | ||
// equation | ||
// c1.e = c2.e; | ||
// (-c1.f) + (-c2.f) = 0.0; | ||
// c1.f = 0.0; | ||
// c2.f = 0.0; | ||
// end IfConnect1; | ||
// endResult |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
// name: IfConnect2 | ||
// keywords: | ||
// status: correct | ||
// cflags: -d=newInst | ||
// | ||
// | ||
|
||
connector C | ||
Real e; | ||
flow Real f; | ||
end C; | ||
|
||
model IfConnect2 | ||
parameter Boolean b = false; | ||
C c1, c2; | ||
equation | ||
if b then | ||
connect(c1, c2); | ||
end if; | ||
end IfConnect2; | ||
|
||
// Result: | ||
// class IfConnect2 | ||
// parameter Boolean b = false; | ||
// Real c1.e; | ||
// Real c1.f; | ||
// Real c2.e; | ||
// Real c2.f; | ||
// equation | ||
// c1.f = 0.0; | ||
// c2.f = 0.0; | ||
// end IfConnect2; | ||
// endResult |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
// name: IfConnect3 | ||
// keywords: | ||
// status: incorrect | ||
// cflags: -d=newInst | ||
// | ||
// | ||
|
||
connector C | ||
Real e; | ||
flow Real f; | ||
end C; | ||
|
||
model IfConnect3 | ||
Boolean b = true; | ||
C c1, c2; | ||
equation | ||
if b then | ||
connect(c1, c2); | ||
end if; | ||
end IfConnect3; | ||
|
||
// Result: | ||
// Error processing file: IfConnect3.mo | ||
// [flattening/modelica/scodeinst/IfConnect3.mo:18:5-18:20:writable] Error: connect may not be used inside if-equations with non-parametric conditions (found connect(c1, c2)). | ||
// | ||
// # Error encountered! Exiting... | ||
// # Please check the error message and the flags. | ||
// | ||
// Execution failed! | ||
// endResult |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters