1 | package P1 |
---|
2 | model M1 |
---|
3 | extends Modelica.Blocks.Interfaces.SISO; |
---|
4 | Boolean Flag = false; |
---|
5 | Real x = if Flag then u else 0; |
---|
6 | equation |
---|
7 | y = 0.5*x; |
---|
8 | end M1; |
---|
9 | |
---|
10 | model M2 |
---|
11 | extends Modelica.Blocks.Interfaces.SISO; |
---|
12 | replaceable model Mx = P1.M1; |
---|
13 | Mx mx annotation(Placement(visible = true, transformation(origin = {-2, 0}, extent = {{-10, -10}, {10, 10}}, rotation = 0))); |
---|
14 | equation |
---|
15 | connect(mx.y, y) annotation( |
---|
16 | Line(points = {{9, 0}, {110, 0}}, color = {0, 0, 127})); |
---|
17 | connect(u, mx.u) annotation( |
---|
18 | Line(points = {{-120, 0}, {-14, 0}}, color = {0, 0, 127})); |
---|
19 | end M2; |
---|
20 | |
---|
21 | |
---|
22 | model M3 |
---|
23 | P1.M2 m2(redeclare model Mx=P1.M1(Flag=true)) annotation(Placement(visible = true, transformation(origin = {-2, 0}, extent = {{-10, -10}, {10, 10}}, rotation = 0))); |
---|
24 | Modelica.Blocks.Sources.Step step1(startTime = 0.5) annotation(Placement(visible = true, transformation(origin = {-36, 0}, extent = {{-10, -10}, {10, 10}}, rotation = 0))); |
---|
25 | equation |
---|
26 | connect(step1.y, m2.u) annotation(Line(points = {{-24, 0}, {-14, 0}}, color = {0, 0, 127})); |
---|
27 | end M3; |
---|
28 | end P1; |
---|