| 1 | within ;
|
|---|
| 2 | package SMGraphicalTestCases
|
|---|
| 3 | "Some graphical test cases for Modelica State Machines"
|
|---|
| 4 | model SimpleSMwithAnnotations "Simple state machine"
|
|---|
| 5 | inner Integer i(start = 0);
|
|---|
| 6 | Integer j;
|
|---|
| 7 |
|
|---|
| 8 | block State1
|
|---|
| 9 | outer output Integer i;
|
|---|
| 10 | output Integer j(start = 10);
|
|---|
| 11 | equation
|
|---|
| 12 | i = previous(i) + 2;
|
|---|
| 13 | j = previous(j) - 1
|
|---|
| 14 | annotation(Icon(graphics={ Text(extent = {{-100, 100}, {100, -100}}, lineColor = {0, 0, 0}, textString = "%name")}), Diagram(graphics={ Text(extent = {{-100, 100}, {100, -100}}, lineColor = {0, 0, 0}, textString = "%stateText", fontSize = 10)}), __Dymola_state = true, showDiagram = true, singleInstance = true);
|
|---|
| 15 | end State1;
|
|---|
| 16 |
|
|---|
| 17 | State1 state1 annotation(Placement(transformation(extent={{-62,40},{-26,76}})));
|
|---|
| 18 |
|
|---|
| 19 | block State2
|
|---|
| 20 | outer output Integer i;
|
|---|
| 21 | equation
|
|---|
| 22 | i = previous(i) - 1;
|
|---|
| 23 | annotation(Icon(graphics={ Text(extent = {{-100, 100}, {100, -100}}, lineColor = {0, 0, 0}, textString = "%name")}), Diagram(graphics={ Text(extent = {{-100, 100}, {100, -100}}, lineColor = {0, 0, 0}, textString = "%stateText", fontSize = 10)}), __Dymola_state = true, showDiagram = true, singleInstance = true);
|
|---|
| 24 | end State2;
|
|---|
| 25 |
|
|---|
| 26 | State2 state2 annotation(Placement(transformation(extent={{-64,-8},{-26,30}})));
|
|---|
| 27 | equation
|
|---|
| 28 | j = 2*state1.j;
|
|---|
| 29 | transition(state1, state2, i > 10, immediate = false, reset = true, synchronize = false, priority = 1) annotation(Line(points={{-24,58},
|
|---|
| 30 | {-16,50},{-24,11}}, color = {175, 175, 175}, thickness = 0.25, smooth = Smooth.Bezier), Text(string = "%condition", extent={{12,-2},
|
|---|
| 31 | {12,-8}}, lineColor = {95, 95, 95}, fontSize = 10, textStyle = {TextStyle.Bold}, horizontalAlignment = TextAlignment.Left));
|
|---|
| 32 | transition(state2, state1, i < 1, immediate = false, reset = true, synchronize = false, priority = 1) annotation(Line(points={{-66,11},
|
|---|
| 33 | {-76,42},{-64,58}}, color = {175, 175, 175}, thickness = 0.25, smooth = Smooth.Bezier), Text(string = "%condition", extent = {{-6, 4}, {-6, 10}}, lineColor = {95, 95, 95}, fontSize = 10, textStyle = {TextStyle.Bold}, horizontalAlignment = TextAlignment.Right));
|
|---|
| 34 | initialState(state1) annotation(Line(points={{-45.2004,78},{-46,86}}, color = {175, 175, 175}, thickness = 0.25, smooth = Smooth.Bezier, arrow = {Arrow.Filled, Arrow.None}));
|
|---|
| 35 | annotation(Diagram(coordinateSystem(preserveAspectRatio = false, extent = {{-100, -100}, {100, 100}}), graphics={ Text(extent={{
|
|---|
| 36 | -72,96},{-22,86}}, lineColor = {0, 0, 0}, fontSize = 10,
|
|---|
| 37 | horizontalAlignment = TextAlignment.Left, textString = "%declarations"),
|
|---|
| 38 | Text(extent={{
|
|---|
| 39 | -58,-12},{-8,-22}}, lineColor=
|
|---|
| 40 | {0,0,0}, fontSize=
|
|---|
| 41 | 10,
|
|---|
| 42 | horizontalAlignment=TextAlignment.Left,
|
|---|
| 43 | textString="%equations")}), experiment(StopTime = 30), __Dymola_experimentSetupOutput);
|
|---|
| 44 | end SimpleSMwithAnnotations;
|
|---|
| 45 |
|
|---|
| 46 | model InnerOuter "Hierarchical State Machine with inner outer variables"
|
|---|
| 47 | inner Integer i(start = 0);
|
|---|
| 48 | State1 state1 annotation(Placement(transformation(extent = {{-58, 22}, {18, 78}})));
|
|---|
| 49 | State2 state2 annotation(Placement(transformation(extent = {{-58, -58}, {18, -2}})));
|
|---|
| 50 |
|
|---|
| 51 | model State1
|
|---|
| 52 | inner outer output Integer i;
|
|---|
| 53 | A1 a1 annotation(Placement(transformation(extent = {{-68, -12}, {68, 44}})));
|
|---|
| 54 | A2 a2 annotation(Placement(transformation(extent = {{-68, -90}, {68, -30}})));
|
|---|
| 55 |
|
|---|
| 56 | model A1
|
|---|
| 57 | outer output Integer i;
|
|---|
| 58 | equation
|
|---|
| 59 | i = previous(i) + 2;
|
|---|
| 60 | annotation(Icon(graphics={ Text(extent = {{-100, 100}, {100, -100}}, lineColor = {0, 0, 0}, textString = "%name")}), Diagram(graphics={ Text(extent = {{-100, 100}, {100, -100}}, lineColor = {0, 0, 0}, textString = "%stateText", fontSize = 10)}), __Dymola_state = true, showDiagram = true, singleInstance = true);
|
|---|
| 61 | end A1;
|
|---|
| 62 |
|
|---|
| 63 | model A2
|
|---|
| 64 | outer output Integer i;
|
|---|
| 65 | equation
|
|---|
| 66 | i = previous(i) - 1;
|
|---|
| 67 | annotation(Icon(graphics={ Text(extent = {{-100, 100}, {100, -100}}, lineColor = {0, 0, 0}, textString = "%name")}), Diagram(graphics={ Text(extent = {{-100, 100}, {100, -100}}, lineColor = {0, 0, 0}, textString = "%stateText", fontSize = 10)}), __Dymola_state = true, showDiagram = true, singleInstance = true);
|
|---|
| 68 | end A2;
|
|---|
| 69 | equation
|
|---|
| 70 | initialState(a1) annotation(Line(points={{-8,46},{-8,68}}, color = {175, 175, 175}, thickness = 0.25, smooth = Smooth.Bezier, arrow = {Arrow.Filled, Arrow.None}));
|
|---|
| 71 | transition(a1, a2, i < 1, immediate = false) annotation(Line(points={{-70,18},
|
|---|
| 72 | {-96,-28},{-70,-66}}, color = {175, 175, 175}, thickness = 0.25, smooth = Smooth.Bezier), Text(string = "%condition", extent = {{-4, -4}, {-4, -10}}, lineColor = {95, 95, 95}, fontSize = 10, textStyle = {TextStyle.Bold}, horizontalAlignment = TextAlignment.Right));
|
|---|
| 73 | transition(a2, a1, i > 10, immediate = false) annotation(Line(points={{70,-68},
|
|---|
| 74 | {92,-30},{70,18}}, color = {175, 175, 175}, thickness = 0.25, smooth = Smooth.Bezier), Text(string = "%condition", extent = {{4, 4}, {4, 10}}, lineColor = {95, 95, 95}, fontSize = 10, textStyle = {TextStyle.Bold}, horizontalAlignment = TextAlignment.Left));
|
|---|
| 75 | annotation(Icon(graphics={ Text(extent = {{-100, 100}, {100, -100}}, lineColor = {0, 0, 0}, textString = "%name")}), Diagram(coordinateSystem(preserveAspectRatio = false, extent = {{-100, -100}, {100, 100}}), graphics={ Text(extent = {{-100, 102}, {100, -98}}, lineColor = {0, 0, 0}, textString = "%stateText", fontSize = 10)}), __Dymola_state = true, showDiagram = true, singleInstance = true);
|
|---|
| 76 | end State1;
|
|---|
| 77 |
|
|---|
| 78 | model State2
|
|---|
| 79 | outer output Integer i;
|
|---|
| 80 | equation
|
|---|
| 81 | i = 42;
|
|---|
| 82 | annotation(Icon(graphics={ Text(extent = {{-100, 100}, {100, -100}}, lineColor = {0, 0, 0}, textString = "%name")}), Diagram(graphics={ Text(extent = {{-100, 100}, {100, -100}}, lineColor = {0, 0, 0}, textString = "%stateText", fontSize = 10)}), __Dymola_state = true, showDiagram = true, singleInstance = true);
|
|---|
| 83 | end State2;
|
|---|
| 84 | equation
|
|---|
| 85 |
|
|---|
| 86 | initialState(state1) annotation(Line(points={{-26,80},{-26,92}}, color = {175, 175, 175}, thickness = 0.25, smooth = Smooth.Bezier, arrow = {Arrow.Filled, Arrow.None}));
|
|---|
| 87 | transition(state2, state1, true, immediate = false) annotation(Line(points={{-60,-32},
|
|---|
| 88 | {-86,22},{-60,58}}, color = {175, 175, 175}, thickness = 0.25, smooth = Smooth.Bezier), Text(string = "%condition", extent = {{-4, 4}, {-4, 10}}, lineColor = {95, 95, 95}, fontSize = 10, textStyle = {TextStyle.Bold}, horizontalAlignment = TextAlignment.Right));
|
|---|
| 89 | transition(state1, state2, i > 8, immediate = false) annotation(Line(points={{20,50},
|
|---|
| 90 | {42,2},{20,-30}}, color = {175, 175, 175}, thickness = 0.25, smooth = Smooth.Bezier), Text(string = "%condition", extent = {{4, -4}, {4, -10}}, lineColor = {95, 95, 95}, fontSize = 10, textStyle = {TextStyle.Bold}, horizontalAlignment = TextAlignment.Left));
|
|---|
| 91 | annotation(Diagram(coordinateSystem(preserveAspectRatio = false, extent = {{-100, -100}, {100, 100}}), graphics={ Text(extent = {{-94, 96}, {-34, 86}}, lineColor = {0, 0, 0}, fontSize = 10,
|
|---|
| 92 | horizontalAlignment = TextAlignment.Left, textString = "%declarations")}), experiment(StopTime = 30), __Dymola_experimentSetupOutput);
|
|---|
| 93 | end InnerOuter;
|
|---|
| 94 |
|
|---|
| 95 | model Maraninchi2003_2 "Figure 2 from Maraninchi 2003"
|
|---|
| 96 | inner Integer x(start=0);
|
|---|
| 97 | inner Integer z(start=0);
|
|---|
| 98 | inner Integer y(start=0);
|
|---|
| 99 | constant Boolean i = true;
|
|---|
| 100 | constant Boolean j = false;
|
|---|
| 101 | model A
|
|---|
| 102 | outer output Integer x;
|
|---|
| 103 | inner outer output Integer y;
|
|---|
| 104 | inner outer output Integer z;
|
|---|
| 105 | C c annotation (Placement(transformation(extent={{-78,12},{-8,42}})));
|
|---|
| 106 | D d annotation (Placement(transformation(extent={{8,10},{80,42}})));
|
|---|
| 107 | E e annotation (Placement(transformation(extent={{-68,-78},{-8,-44}})));
|
|---|
| 108 | F f annotation (Placement(transformation(extent={{16,-78},{78,-44}})));
|
|---|
| 109 | model C
|
|---|
| 110 | outer output Integer y;
|
|---|
| 111 | equation
|
|---|
| 112 | y = previous(y)+1;
|
|---|
| 113 | annotation (
|
|---|
| 114 | Icon(graphics={Text(
|
|---|
| 115 | extent={{-100,100},{100,-100}},
|
|---|
| 116 | lineColor={0,0,0},
|
|---|
| 117 | textString="%name")}),
|
|---|
| 118 | Diagram(graphics={Text(
|
|---|
| 119 | extent={{-100,100},{100,-100}},
|
|---|
| 120 | lineColor={0,0,0},
|
|---|
| 121 | textString="%stateText",
|
|---|
| 122 | fontSize=10)}),
|
|---|
| 123 | __Dymola_state=true,
|
|---|
| 124 | showDiagram=true,
|
|---|
| 125 | singleInstance=true);
|
|---|
| 126 | end C;
|
|---|
| 127 | equation
|
|---|
| 128 | initialState(c) annotation (Line(
|
|---|
| 129 | points={{-80,30},{-96,30}},
|
|---|
| 130 | color={175,175,175},
|
|---|
| 131 | thickness=0.25,
|
|---|
| 132 | smooth=Smooth.Bezier,
|
|---|
| 133 | arrow={Arrow.Filled,Arrow.None}));
|
|---|
| 134 | public
|
|---|
| 135 | model D
|
|---|
| 136 | outer output Integer y;
|
|---|
| 137 | equation
|
|---|
| 138 | y = previous(y) - 1;
|
|---|
| 139 | annotation (
|
|---|
| 140 | Icon(graphics={Text(
|
|---|
| 141 | extent={{-100,100},{100,-100}},
|
|---|
| 142 | lineColor={0,0,0},
|
|---|
| 143 | textString="%name")}),
|
|---|
| 144 | Diagram(graphics={Text(
|
|---|
| 145 | extent={{-100,100},{100,-100}},
|
|---|
| 146 | lineColor={0,0,0},
|
|---|
| 147 | textString="%stateText",
|
|---|
| 148 | fontSize=10)}),
|
|---|
| 149 | __Dymola_state=true,
|
|---|
| 150 | showDiagram=true,
|
|---|
| 151 | singleInstance=true);
|
|---|
| 152 | end D;
|
|---|
| 153 | equation
|
|---|
| 154 | transition(
|
|---|
| 155 | c,
|
|---|
| 156 | d,y == 10,
|
|---|
| 157 | immediate=false,reset=true,synchronize=false,priority=1)
|
|---|
| 158 | annotation (Line(
|
|---|
| 159 | points={{-22,44},{-6,48},{22.4,44}},
|
|---|
| 160 | color={175,175,175},
|
|---|
| 161 | thickness=0.25,
|
|---|
| 162 | smooth=Smooth.Bezier), Text(
|
|---|
| 163 | string="%condition",
|
|---|
| 164 | extent={{4,4},{4,10}},
|
|---|
| 165 | lineColor={95,95,95},
|
|---|
| 166 | fontSize=10,
|
|---|
| 167 | textStyle={TextStyle.Bold},
|
|---|
| 168 | horizontalAlignment=TextAlignment.Left));
|
|---|
| 169 | transition(
|
|---|
| 170 | d,
|
|---|
| 171 | c,y == 0,
|
|---|
| 172 | immediate=false,reset=true,synchronize=false,priority=1)
|
|---|
| 173 | annotation (Line(
|
|---|
| 174 | points={{36.8,8},{-4,0},{-36,10}},
|
|---|
| 175 | color={175,175,175},
|
|---|
| 176 | thickness=0.25,
|
|---|
| 177 | smooth=Smooth.Bezier), Text(
|
|---|
| 178 | string="%condition",
|
|---|
| 179 | extent={{-8,-12},{-8,-6}},
|
|---|
| 180 | lineColor={95,95,95},
|
|---|
| 181 | fontSize=10,
|
|---|
| 182 | textStyle={TextStyle.Bold},
|
|---|
| 183 | horizontalAlignment=TextAlignment.Left));
|
|---|
| 184 | x = previous(x) + 1;
|
|---|
| 185 | public
|
|---|
| 186 | model E
|
|---|
| 187 | outer output Integer z;
|
|---|
| 188 | outer input Integer y;
|
|---|
| 189 | equation
|
|---|
| 190 | z = previous(z) + y;
|
|---|
| 191 | annotation (
|
|---|
| 192 | Icon(graphics={Text(
|
|---|
| 193 | extent={{-100,100},{100,-100}},
|
|---|
| 194 | lineColor={0,0,0},
|
|---|
| 195 | textString="%name")}),
|
|---|
| 196 | Diagram(graphics={Text(
|
|---|
| 197 | extent={{-100,100},{100,-100}},
|
|---|
| 198 | lineColor={0,0,0},
|
|---|
| 199 | textString="%stateText",
|
|---|
| 200 | fontSize=10)}),
|
|---|
| 201 | __Dymola_state=true,
|
|---|
| 202 | showDiagram=true,
|
|---|
| 203 | singleInstance=true);
|
|---|
| 204 | end E;
|
|---|
| 205 |
|
|---|
| 206 | model F
|
|---|
| 207 | outer output Integer z;
|
|---|
| 208 | outer input Integer y;
|
|---|
| 209 | equation
|
|---|
| 210 | z = previous(z) - y;
|
|---|
| 211 | annotation (
|
|---|
| 212 | Icon(graphics={Text(
|
|---|
| 213 | extent={{-100,100},{100,-100}},
|
|---|
| 214 | lineColor={0,0,0},
|
|---|
| 215 | textString="%name")}),
|
|---|
| 216 | Diagram(graphics={Text(
|
|---|
| 217 | extent={{-100,100},{100,-100}},
|
|---|
| 218 | lineColor={0,0,0},
|
|---|
| 219 | textString="%stateText",
|
|---|
| 220 | fontSize=10)}),
|
|---|
| 221 | __Dymola_state=true,
|
|---|
| 222 | showDiagram=true,
|
|---|
| 223 | singleInstance=true);
|
|---|
| 224 | end F;
|
|---|
| 225 | equation
|
|---|
| 226 | initialState(e) annotation (Line(
|
|---|
| 227 | points={{-70,-64},{-90,-64}},
|
|---|
| 228 | color={175,175,175},
|
|---|
| 229 | thickness=0.25,
|
|---|
| 230 | smooth=Smooth.Bezier,
|
|---|
| 231 | arrow={Arrow.Filled,Arrow.None}));
|
|---|
| 232 | transition(
|
|---|
| 233 | e,
|
|---|
| 234 | f,
|
|---|
| 235 | z > 100,
|
|---|
| 236 | immediate=false) annotation (Line(
|
|---|
| 237 | points={{-40,-42},{0,-30},{38,-42}},
|
|---|
| 238 | color={175,175,175},
|
|---|
| 239 | thickness=0.25,
|
|---|
| 240 | smooth=Smooth.Bezier), Text(
|
|---|
| 241 | string="%condition",
|
|---|
| 242 | extent={{4,4},{4,10}},
|
|---|
| 243 | lineColor={95,95,95},
|
|---|
| 244 | fontSize=10,
|
|---|
| 245 | textStyle={TextStyle.Bold},
|
|---|
| 246 | horizontalAlignment=TextAlignment.Left));
|
|---|
| 247 | transition(
|
|---|
| 248 | f,
|
|---|
| 249 | e,
|
|---|
| 250 | z < 50,
|
|---|
| 251 | immediate=false,
|
|---|
| 252 | reset=true,
|
|---|
| 253 | synchronize=false,
|
|---|
| 254 | priority=1) annotation (Line(
|
|---|
| 255 | points={{44,-80},{0,-92},{-38,-80}},
|
|---|
| 256 | color={175,175,175},
|
|---|
| 257 | thickness=0.25,
|
|---|
| 258 | smooth=Smooth.Bezier), Text(
|
|---|
| 259 | string="%condition",
|
|---|
| 260 | extent={{-12,-14},{-12,-8}},
|
|---|
| 261 | lineColor={95,95,95},
|
|---|
| 262 | fontSize=10,
|
|---|
| 263 | textStyle={TextStyle.Bold},
|
|---|
| 264 | horizontalAlignment=TextAlignment.Left));
|
|---|
| 265 | annotation (
|
|---|
| 266 | Icon(graphics={Text(
|
|---|
| 267 | extent={{-100,100},{100,-100}},
|
|---|
| 268 | lineColor={0,0,0},
|
|---|
| 269 | textString="%name")}),
|
|---|
| 270 | Diagram(coordinateSystem(preserveAspectRatio=false, extent={{-100,-100},{100,
|
|---|
| 271 | 100}}), graphics={Text(
|
|---|
| 272 | extent={{-100,98},{100,-102}},
|
|---|
| 273 | lineColor={0,0,0},
|
|---|
| 274 | textString="%stateText",
|
|---|
| 275 | fontSize=10)}),
|
|---|
| 276 | __Dymola_state=true,
|
|---|
| 277 | showDiagram=true,
|
|---|
| 278 | singleInstance=true);
|
|---|
| 279 | end A;
|
|---|
| 280 | A a annotation (Placement(transformation(extent={{-74,-52},{26,28}})));
|
|---|
| 281 | B b annotation (Placement(transformation(extent={{48,-26},{76,-6}})));
|
|---|
| 282 | equation
|
|---|
| 283 | initialState(a) annotation (Line(
|
|---|
| 284 | points={{-36,30},{-38,38}},
|
|---|
| 285 | color={175,175,175},
|
|---|
| 286 | thickness=0.25,
|
|---|
| 287 | smooth=Smooth.Bezier,
|
|---|
| 288 | arrow={Arrow.Filled,Arrow.None}));
|
|---|
| 289 | public
|
|---|
| 290 | model B
|
|---|
| 291 | outer output Integer x;
|
|---|
| 292 | equation
|
|---|
| 293 | x = previous(x) - 1
|
|---|
| 294 | annotation (
|
|---|
| 295 | Icon(graphics={Text(
|
|---|
| 296 | extent={{-100,100},{100,-100}},
|
|---|
| 297 | lineColor={0,0,0},
|
|---|
| 298 | textString="%name")}),
|
|---|
| 299 | Diagram(graphics={Text(
|
|---|
| 300 | extent={{-100,100},{100,-100}},
|
|---|
| 301 | lineColor={0,0,0},
|
|---|
| 302 | textString="%stateText",
|
|---|
| 303 | fontSize=10)}),
|
|---|
| 304 | __Dymola_state=true,
|
|---|
| 305 | showDiagram=true,
|
|---|
| 306 | singleInstance=true);
|
|---|
| 307 | end B;
|
|---|
| 308 | equation
|
|---|
| 309 | transition(
|
|---|
| 310 | a,
|
|---|
| 311 | b,(z > 100 and i) or j,
|
|---|
| 312 | immediate=false,
|
|---|
| 313 | reset=true,
|
|---|
| 314 | synchronize=false,
|
|---|
| 315 | priority=1) annotation (Line(
|
|---|
| 316 | points={{28,6},{40,6},{52,-4}},
|
|---|
| 317 | color={175,175,175},
|
|---|
| 318 | thickness=0.25,
|
|---|
| 319 | smooth=Smooth.Bezier), Text(
|
|---|
| 320 | string="%condition",
|
|---|
| 321 | extent={{4,4},{4,10}},
|
|---|
| 322 | lineColor={95,95,95},
|
|---|
| 323 | fontSize=10,
|
|---|
| 324 | textStyle={TextStyle.Bold},
|
|---|
| 325 | horizontalAlignment=TextAlignment.Left));
|
|---|
| 326 | transition(
|
|---|
| 327 | b,
|
|---|
| 328 | a,x == 0,
|
|---|
| 329 | immediate=false,
|
|---|
| 330 | reset=true,synchronize=false,priority=1)
|
|---|
| 331 | annotation (Line(
|
|---|
| 332 | points={{52,-28},{44,-38},{28,-30}},
|
|---|
| 333 | color={175,175,175},
|
|---|
| 334 | thickness=0.25,
|
|---|
| 335 | smooth=Smooth.Bezier), Text(
|
|---|
| 336 | string="%condition",
|
|---|
| 337 | extent={{-6,-14},{-6,-8}},
|
|---|
| 338 | lineColor={95,95,95},
|
|---|
| 339 | fontSize=10,
|
|---|
| 340 | textStyle={TextStyle.Bold},
|
|---|
| 341 | horizontalAlignment=TextAlignment.Left));
|
|---|
| 342 | annotation (Diagram(coordinateSystem(extent={{-80,-60},{80,60}},
|
|---|
| 343 | preserveAspectRatio=false),
|
|---|
| 344 | graphics={
|
|---|
| 345 | Text(
|
|---|
| 346 | extent={{-68,56},{-8,46}},
|
|---|
| 347 | lineColor={0,0,0},
|
|---|
| 348 | fontSize=10,
|
|---|
| 349 | horizontalAlignment=TextAlignment.Left,
|
|---|
| 350 | textString="%declarations"), Rectangle(extent={{
|
|---|
| 351 | -80,60},{80,-60}}, lineColor={95,95,95}),
|
|---|
| 352 | Text(
|
|---|
| 353 | extent={{-90,36},{-80,26}},
|
|---|
| 354 | lineColor={255,0,255},
|
|---|
| 355 | fillColor={0,0,255},
|
|---|
| 356 | fillPattern=FillPattern.Solid,
|
|---|
| 357 | textString="i"),
|
|---|
| 358 | Text(
|
|---|
| 359 | extent={{-90,-46},{-80,-56}},
|
|---|
| 360 | lineColor={255,0,255},
|
|---|
| 361 | fillColor={0,0,255},
|
|---|
| 362 | fillPattern=FillPattern.Solid,
|
|---|
| 363 | textString="j")}), Icon(coordinateSystem(extent={{-80,-60},
|
|---|
| 364 | {80,60}}, preserveAspectRatio=false), graphics={Rectangle(extent={
|
|---|
| 365 | {-100,100},{100,-80}}, lineColor={95,95,95})}),
|
|---|
| 366 | showDiagram=true);
|
|---|
| 367 | end Maraninchi2003_2;
|
|---|
| 368 |
|
|---|
| 369 | model MLSWA "Example from the MLS 3.3, Section 17.3.7 with annotations"
|
|---|
| 370 | inner Integer v(start=0);
|
|---|
| 371 | model State1
|
|---|
| 372 | inner Integer count(start=0);
|
|---|
| 373 | inner outer output Integer v;
|
|---|
| 374 | StateA stateA
|
|---|
| 375 | annotation (Placement(transformation(extent={{-78,42},{-12,64}})));
|
|---|
| 376 | StateB stateB
|
|---|
| 377 | annotation (Placement(transformation(extent={{-78,2},{-12,26}})));
|
|---|
| 378 | StateC stateC
|
|---|
| 379 | annotation (Placement(transformation(extent={{-78,-46},{-12,-20}})));
|
|---|
| 380 | StateD stateD
|
|---|
| 381 | annotation (Placement(transformation(extent={{-78,-84},{-12,-68}})));
|
|---|
| 382 | StateX stateX
|
|---|
| 383 | annotation (Placement(transformation(extent={{10,2},{86,58}})));
|
|---|
| 384 | StateY stateY
|
|---|
| 385 | annotation (Placement(transformation(extent={{10,-78},{86,-24}})));
|
|---|
| 386 | model StateA
|
|---|
| 387 | outer output Integer v;
|
|---|
| 388 | equation
|
|---|
| 389 | v = previous(v) + 2;
|
|---|
| 390 | annotation (
|
|---|
| 391 | Icon(graphics={Text(
|
|---|
| 392 | extent={{-100,100},{100,-100}},
|
|---|
| 393 | lineColor={0,0,0},
|
|---|
| 394 | textString="%name")}),
|
|---|
| 395 | Diagram(graphics={Text(
|
|---|
| 396 | extent={{-100,100},{100,-100}},
|
|---|
| 397 | lineColor={0,0,0},
|
|---|
| 398 | textString="%stateText",
|
|---|
| 399 | fontSize=10)}),
|
|---|
| 400 | __Dymola_state=true,
|
|---|
| 401 | showDiagram=true,
|
|---|
| 402 | singleInstance=true);
|
|---|
| 403 | end StateA;
|
|---|
| 404 |
|
|---|
| 405 | model StateB
|
|---|
| 406 | outer output Integer v;
|
|---|
| 407 | equation
|
|---|
| 408 | v = previous(v) - 1;
|
|---|
| 409 | annotation (
|
|---|
| 410 | Icon(graphics={Text(
|
|---|
| 411 | extent={{-100,100},{100,-100}},
|
|---|
| 412 | lineColor={0,0,0},
|
|---|
| 413 | textString="%name")}),
|
|---|
| 414 | Diagram(graphics={Text(
|
|---|
| 415 | extent={{-100,100},{100,-100}},
|
|---|
| 416 | lineColor={0,0,0},
|
|---|
| 417 | textString="%stateText",
|
|---|
| 418 | fontSize=10)}),
|
|---|
| 419 | __Dymola_state=true,
|
|---|
| 420 | showDiagram=true,
|
|---|
| 421 | singleInstance=true);
|
|---|
| 422 | end StateB;
|
|---|
| 423 |
|
|---|
| 424 | model StateC
|
|---|
| 425 | outer output Integer count;
|
|---|
| 426 | equation
|
|---|
| 427 | count = previous(count) + 1;
|
|---|
| 428 | annotation (
|
|---|
| 429 | Icon(graphics={Text(
|
|---|
| 430 | extent={{-100,100},{100,-100}},
|
|---|
| 431 | lineColor={0,0,0},
|
|---|
| 432 | textString="%name")}),
|
|---|
| 433 | Diagram(graphics={Text(
|
|---|
| 434 | extent={{-100,100},{100,-100}},
|
|---|
| 435 | lineColor={0,0,0},
|
|---|
| 436 | textString="%stateText",
|
|---|
| 437 | fontSize=10)}),
|
|---|
| 438 | __Dymola_state=true,
|
|---|
| 439 | showDiagram=true,
|
|---|
| 440 | singleInstance=true);
|
|---|
| 441 | end StateC;
|
|---|
| 442 |
|
|---|
| 443 | model StateD
|
|---|
| 444 | annotation (
|
|---|
| 445 | Icon(graphics={Text(
|
|---|
| 446 | extent={{-100,100},{100,-100}},
|
|---|
| 447 | lineColor={0,0,0},
|
|---|
| 448 | textString="%name")}),
|
|---|
| 449 | Diagram(graphics={Text(
|
|---|
| 450 | extent={{-100,100},{100,-100}},
|
|---|
| 451 | lineColor={0,0,0},
|
|---|
| 452 | textString="%stateText",
|
|---|
| 453 | fontSize=10)}),
|
|---|
| 454 | __Dymola_state=true,
|
|---|
| 455 | showDiagram=true,
|
|---|
| 456 | singleInstance=true);
|
|---|
| 457 | end StateD;
|
|---|
| 458 | equation
|
|---|
| 459 | transition(
|
|---|
| 460 | stateA,
|
|---|
| 461 | stateB,
|
|---|
| 462 | v >= 6,
|
|---|
| 463 | immediate=false) annotation (Line(
|
|---|
| 464 | points={{-45,40},{-45,28}},
|
|---|
| 465 | color={175,175,175},
|
|---|
| 466 | thickness=0.25,
|
|---|
| 467 | smooth=Smooth.Bezier), Text(
|
|---|
| 468 | string="%condition",
|
|---|
| 469 | extent={{-4,-4},{-4,-10}},
|
|---|
| 470 | lineColor={95,95,95},
|
|---|
| 471 | fontSize=10,
|
|---|
| 472 | textStyle={TextStyle.Bold},
|
|---|
| 473 | horizontalAlignment=TextAlignment.Right));
|
|---|
| 474 | transition(
|
|---|
| 475 | stateB,
|
|---|
| 476 | stateC,
|
|---|
| 477 | v == 0,
|
|---|
| 478 | immediate=false) annotation (Line(
|
|---|
| 479 | points={{-45,0},{-45,-18}},
|
|---|
| 480 | color={175,175,175},
|
|---|
| 481 | thickness=0.25,
|
|---|
| 482 | smooth=Smooth.Bezier), Text(
|
|---|
| 483 | string="%condition",
|
|---|
| 484 | extent={{-4,-4},{-4,-10}},
|
|---|
| 485 | lineColor={95,95,95},
|
|---|
| 486 | fontSize=10,
|
|---|
| 487 | textStyle={TextStyle.Bold},
|
|---|
| 488 | horizontalAlignment=TextAlignment.Right));
|
|---|
| 489 | transition(
|
|---|
| 490 | stateC,
|
|---|
| 491 | stateD,
|
|---|
| 492 | count >= 2,
|
|---|
| 493 | immediate=false) annotation (Line(
|
|---|
| 494 | points={{-21.4285,-48},{-21.4285,-66}},
|
|---|
| 495 | color={175,175,175},
|
|---|
| 496 | thickness=0.25,
|
|---|
| 497 | smooth=Smooth.Bezier), Text(
|
|---|
| 498 | string="%condition",
|
|---|
| 499 | extent={{-4,-4},{-4,-10}},
|
|---|
| 500 | lineColor={95,95,95},
|
|---|
| 501 | fontSize=10,
|
|---|
| 502 | textStyle={TextStyle.Bold},
|
|---|
| 503 | horizontalAlignment=TextAlignment.Right));
|
|---|
| 504 | transition(
|
|---|
| 505 | stateC,
|
|---|
| 506 | stateA,
|
|---|
| 507 | true,
|
|---|
| 508 | immediate=false,
|
|---|
| 509 | priority=2) annotation (Line(
|
|---|
| 510 | points={{-63.857,-48},{-66,-48},{-90,-48},{-90,76},{-79,65}},
|
|---|
| 511 | color={175,175,175},
|
|---|
| 512 | thickness=0.25,
|
|---|
| 513 | smooth=Smooth.Bezier), Text(
|
|---|
| 514 | string="%condition",
|
|---|
| 515 | extent={{-4,-4},{-4,-10}},
|
|---|
| 516 | lineColor={95,95,95},
|
|---|
| 517 | fontSize=10,
|
|---|
| 518 | textStyle={TextStyle.Bold},
|
|---|
| 519 | horizontalAlignment=TextAlignment.Right));
|
|---|
| 520 | initialState(stateA) annotation (Line(
|
|---|
| 521 | points={{-45,66},{-50,72}},
|
|---|
| 522 | color={175,175,175},
|
|---|
| 523 | thickness=0.25,
|
|---|
| 524 | smooth=Smooth.Bezier,
|
|---|
| 525 | arrow={Arrow.Filled,Arrow.None}));
|
|---|
| 526 | public
|
|---|
| 527 | model StateX
|
|---|
| 528 | outer input Integer v;
|
|---|
| 529 | Integer i(start=0);
|
|---|
| 530 | Integer w;
|
|---|
| 531 | equation
|
|---|
| 532 | i = previous(i) + 1;
|
|---|
| 533 | w = v;
|
|---|
| 534 | annotation (
|
|---|
| 535 | Icon(graphics={Text(
|
|---|
| 536 | extent={{-100,100},{100,-100}},
|
|---|
| 537 | lineColor={0,0,0},
|
|---|
| 538 | textString="%name")}),
|
|---|
| 539 | Diagram(graphics={Text(
|
|---|
| 540 | extent={{-100,100},{100,-100}},
|
|---|
| 541 | lineColor={0,0,0},
|
|---|
| 542 | textString="%stateText",
|
|---|
| 543 | fontSize=10)}),
|
|---|
| 544 | __Dymola_state=true,
|
|---|
| 545 | showDiagram=true,
|
|---|
| 546 | singleInstance=true);
|
|---|
| 547 | end StateX;
|
|---|
| 548 |
|
|---|
| 549 | model StateY
|
|---|
| 550 | Integer j(start=0);
|
|---|
| 551 | equation
|
|---|
| 552 | j = previous(j) + 1;
|
|---|
| 553 | annotation (
|
|---|
| 554 | Icon(graphics={Text(
|
|---|
| 555 | extent={{-100,100},{100,-100}},
|
|---|
| 556 | lineColor={0,0,0},
|
|---|
| 557 | textString="%name")}),
|
|---|
| 558 | Diagram(graphics={Text(
|
|---|
| 559 | extent={{-100,100},{100,-100}},
|
|---|
| 560 | lineColor={0,0,0},
|
|---|
| 561 | textString="%stateText",
|
|---|
| 562 | fontSize=10)}),
|
|---|
| 563 | __Dymola_state=true,
|
|---|
| 564 | showDiagram=true,
|
|---|
| 565 | singleInstance=true);
|
|---|
| 566 | end StateY;
|
|---|
| 567 | equation
|
|---|
| 568 | transition(
|
|---|
| 569 | stateX,
|
|---|
| 570 | stateY,
|
|---|
| 571 | stateX.i > 20,
|
|---|
| 572 | immediate=false) annotation (Line(
|
|---|
| 573 | points={{48,0},{48,-22}},
|
|---|
| 574 | color={175,175,175},
|
|---|
| 575 | thickness=0.25,
|
|---|
| 576 | smooth=Smooth.Bezier), Text(
|
|---|
| 577 | string="%condition",
|
|---|
| 578 | extent={{-4,-4},{-4,-10}},
|
|---|
| 579 | lineColor={95,95,95},
|
|---|
| 580 | fontSize=10,
|
|---|
| 581 | textStyle={TextStyle.Bold},
|
|---|
| 582 | horizontalAlignment=TextAlignment.Right));
|
|---|
| 583 | initialState(stateX) annotation (Line(
|
|---|
| 584 | points={{48,60},{48,72}},
|
|---|
| 585 | color={175,175,175},
|
|---|
| 586 | thickness=0.25,
|
|---|
| 587 | smooth=Smooth.Bezier,
|
|---|
| 588 | arrow={Arrow.Filled,Arrow.None}));
|
|---|
| 589 | annotation (
|
|---|
| 590 | Icon(graphics={Text(
|
|---|
| 591 | extent={{-100,100},{100,-100}},
|
|---|
| 592 | lineColor={0,0,0},
|
|---|
| 593 | textString="%name")}),
|
|---|
| 594 | Diagram(coordinateSystem(preserveAspectRatio=false, extent={{-100,-100},{100,
|
|---|
| 595 | 100}}),
|
|---|
| 596 | graphics={Text(
|
|---|
| 597 | extent={{-100,98},{100,-102}},
|
|---|
| 598 | lineColor={0,0,0},
|
|---|
| 599 | textString="%stateText",
|
|---|
| 600 | fontSize=10)}),
|
|---|
| 601 | __Dymola_state=true,
|
|---|
| 602 | showDiagram=true,
|
|---|
| 603 | singleInstance=true);
|
|---|
| 604 | end State1;
|
|---|
| 605 | State1 state1
|
|---|
| 606 | annotation (Placement(transformation(extent={{-80,-58},{78,78}})));
|
|---|
| 607 | model State2
|
|---|
| 608 | outer output Integer v;
|
|---|
| 609 | equation
|
|---|
| 610 | v = previous(v) + 5;
|
|---|
| 611 | annotation (
|
|---|
| 612 | Icon(graphics={Text(
|
|---|
| 613 | extent={{-100,100},{100,-100}},
|
|---|
| 614 | lineColor={0,0,0},
|
|---|
| 615 | textString="%name")}),
|
|---|
| 616 | Diagram(graphics={Text(
|
|---|
| 617 | extent={{-100,100},{100,-100}},
|
|---|
| 618 | lineColor={0,0,0},
|
|---|
| 619 | textString="%stateText",
|
|---|
| 620 | fontSize=10)}),
|
|---|
| 621 | __Dymola_state=true,
|
|---|
| 622 | showDiagram=true,
|
|---|
| 623 | singleInstance=true);
|
|---|
| 624 | end State2;
|
|---|
| 625 | State2 state2
|
|---|
| 626 | annotation (Placement(transformation(extent={{-78,-92},{78,-76}})));
|
|---|
| 627 | equation
|
|---|
| 628 | transition(
|
|---|
| 629 | state1,
|
|---|
| 630 | state2,
|
|---|
| 631 | activeState(state1.stateD) and activeState(state1.stateY),
|
|---|
| 632 | immediate=false) annotation (Line(
|
|---|
| 633 | points={{-69.8718,-60},{-36,-74}},
|
|---|
| 634 | color={175,175,175},
|
|---|
| 635 | thickness=0.25,
|
|---|
| 636 | smooth=Smooth.Bezier), Text(
|
|---|
| 637 | string="%condition",
|
|---|
| 638 | extent={{76,-4},{76,-10}},
|
|---|
| 639 | lineColor={95,95,95},
|
|---|
| 640 | fontSize=10,
|
|---|
| 641 | textStyle={TextStyle.Bold},
|
|---|
| 642 | horizontalAlignment=TextAlignment.Right));
|
|---|
| 643 | transition(
|
|---|
| 644 | state2,
|
|---|
| 645 | state1,
|
|---|
| 646 | v >= 20,
|
|---|
| 647 | immediate=false) annotation (Line(
|
|---|
| 648 | points={{20,-74},{59.7692,-60}},
|
|---|
| 649 | color={175,175,175},
|
|---|
| 650 | thickness=0.25,
|
|---|
| 651 | smooth=Smooth.Bezier), Text(
|
|---|
| 652 | string="%condition",
|
|---|
| 653 | extent={{4,4},{4,10}},
|
|---|
| 654 | lineColor={95,95,95},
|
|---|
| 655 | fontSize=10,
|
|---|
| 656 | textStyle={TextStyle.Bold},
|
|---|
| 657 | horizontalAlignment=TextAlignment.Left));
|
|---|
| 658 | initialState(state1) annotation (Line(
|
|---|
| 659 | points={{-1,80},{0,94}},
|
|---|
| 660 | color={175,175,175},
|
|---|
| 661 | thickness=0.25,
|
|---|
| 662 | smooth=Smooth.Bezier,
|
|---|
| 663 | arrow={Arrow.Filled,Arrow.None}));
|
|---|
| 664 | annotation (Diagram(coordinateSystem(preserveAspectRatio=false,
|
|---|
| 665 | extent={{-100,-100},{100,100}}), graphics={Text(
|
|---|
| 666 | extent={{-96,94},{-58,90}},
|
|---|
| 667 | lineColor={0,0,0},
|
|---|
| 668 | textString="%declarations")}));
|
|---|
| 669 | end MLSWA;
|
|---|
| 670 |
|
|---|
| 671 | model CDF "Example from \\cite{Elmqvist2012}"
|
|---|
| 672 | Components.Increment state1(increment=1)
|
|---|
| 673 | annotation (Placement(transformation(extent={{-26,28},{-14,40}})));
|
|---|
| 674 | Components.Increment state2(increment=-1)
|
|---|
| 675 | annotation (Placement(transformation(extent={{-26,-8},{-14,4}})));
|
|---|
| 676 | protected
|
|---|
| 677 | Components.IntegerOutput i
|
|---|
| 678 | annotation (Placement(transformation(extent={{6,6},{26,26}})));
|
|---|
| 679 | public
|
|---|
| 680 | Components.Prev prev
|
|---|
| 681 | annotation (Placement(transformation(extent={{30,10},{42,22}})));
|
|---|
| 682 | equation
|
|---|
| 683 | initialState(state1) annotation (Line(
|
|---|
| 684 | points={{-20,42},{-20,50}},
|
|---|
| 685 | color={175,175,175},
|
|---|
| 686 | thickness=0.25,
|
|---|
| 687 | smooth=Smooth.Bezier,
|
|---|
| 688 | arrow={Arrow.Filled,Arrow.None}));
|
|---|
| 689 | transition(
|
|---|
| 690 | state1,
|
|---|
| 691 | state2,
|
|---|
| 692 | i > 10,
|
|---|
| 693 | immediate=false) annotation (Line(
|
|---|
| 694 | points={{-20,26},{-20,6}},
|
|---|
| 695 | color={175,175,175},
|
|---|
| 696 | thickness=0.25,
|
|---|
| 697 | smooth=Smooth.Bezier), Text(
|
|---|
| 698 | string="%condition",
|
|---|
| 699 | extent={{-4,-4},{-4,-10}},
|
|---|
| 700 | lineColor={95,95,95},
|
|---|
| 701 | fontSize=10,
|
|---|
| 702 | textStyle={TextStyle.Bold},
|
|---|
| 703 | horizontalAlignment=TextAlignment.Right));
|
|---|
| 704 | transition(
|
|---|
| 705 | state2,
|
|---|
| 706 | state1,
|
|---|
| 707 | i < 1,
|
|---|
| 708 | immediate=false) annotation (Line(
|
|---|
| 709 | points={{-20,-10},{-20,-16},{-42,-16},{-42,46},{-28,46},{-27,41}},
|
|---|
| 710 | color={175,175,175},
|
|---|
| 711 | thickness=0.25,
|
|---|
| 712 | smooth=Smooth.Bezier), Text(
|
|---|
| 713 | string="%condition",
|
|---|
| 714 | extent={{-4,-4},{-4,-10}},
|
|---|
| 715 | lineColor={95,95,95},
|
|---|
| 716 | fontSize=10,
|
|---|
| 717 | textStyle={TextStyle.Bold},
|
|---|
| 718 | horizontalAlignment=TextAlignment.Right));
|
|---|
| 719 | connect(prev.u, i) annotation (Line(
|
|---|
| 720 | points={{27.6,16},{16,16}},
|
|---|
| 721 | color={255,127,0},
|
|---|
| 722 | smooth=Smooth.None));
|
|---|
| 723 | connect(i, state1.y) annotation (Line(
|
|---|
| 724 | points={{16,16},{-4,16},{-4,34},{-12.8,34}},
|
|---|
| 725 | color={255,127,0},
|
|---|
| 726 | smooth=Smooth.None));
|
|---|
| 727 | connect(i, state2.y) annotation (Line(
|
|---|
| 728 | points={{16,16},{-4,16},{-4,-2},{-12.8,-2}},
|
|---|
| 729 | color={255,127,0},
|
|---|
| 730 | smooth=Smooth.None));
|
|---|
| 731 | connect(prev.y, state1.u) annotation (Line(
|
|---|
| 732 | points={{43.2,16},{48,16},{48,-24},{-52,-24},{-52,34},{-28.4,34}},
|
|---|
| 733 | color={255,127,0},
|
|---|
| 734 | smooth=Smooth.None));
|
|---|
| 735 | connect(state2.u, prev.y) annotation (Line(
|
|---|
| 736 | points={{-28.4,-2},{-52,-2},{-52,-24},{48,-24},{48,16},{43.2,16}},
|
|---|
| 737 | color={255,127,0},
|
|---|
| 738 | smooth=Smooth.None));
|
|---|
| 739 | annotation (Diagram(coordinateSystem(preserveAspectRatio=false, extent={{-100,
|
|---|
| 740 | -100},{100,100}}), graphics));
|
|---|
| 741 | end CDF;
|
|---|
| 742 |
|
|---|
| 743 | package Components
|
|---|
| 744 | partial block PartialIntegerSISO
|
|---|
| 745 | "Partial block with a IntegerInput and an IntegerOutput signal"
|
|---|
| 746 |
|
|---|
| 747 | IntegerInput u "Integer input signal"
|
|---|
| 748 | annotation (Placement(transformation(extent={{-180,-40},{-100,40}})));
|
|---|
| 749 | IntegerOutput y "Integer output signal"
|
|---|
| 750 | annotation (Placement(transformation(extent={{100,-20},{140,20}})));
|
|---|
| 751 | annotation (Icon(coordinateSystem(
|
|---|
| 752 | preserveAspectRatio=false,
|
|---|
| 753 | extent={{-100,-100},{100,100}},
|
|---|
| 754 | initialScale=0.06), graphics={
|
|---|
| 755 | Text(
|
|---|
| 756 | extent={{110,-50},{250,-70}},
|
|---|
| 757 | lineColor={0,0,0},
|
|---|
| 758 | textString=DynamicSelect(" ", String(
|
|---|
| 759 | y,
|
|---|
| 760 | minimumLength=1,
|
|---|
| 761 | significantDigits=0))),
|
|---|
| 762 | Text(
|
|---|
| 763 | extent={{-250,170},{250,110}},
|
|---|
| 764 | textString="%name",
|
|---|
| 765 | lineColor={0,0,255}),
|
|---|
| 766 | Rectangle(
|
|---|
| 767 | extent={{-100,100},{100,-100}},
|
|---|
| 768 | lineColor={0,0,0},
|
|---|
| 769 | lineThickness=5.0,
|
|---|
| 770 | fillColor={255,213,170},
|
|---|
| 771 | fillPattern=FillPattern.Solid,
|
|---|
| 772 | borderPattern=BorderPattern.Raised)}));
|
|---|
| 773 | end PartialIntegerSISO;
|
|---|
| 774 |
|
|---|
| 775 | connector IntegerInput = input Integer "'input Integer' as connector"
|
|---|
| 776 | annotation (
|
|---|
| 777 | defaultComponentName="u",
|
|---|
| 778 | Icon(graphics={Polygon(
|
|---|
| 779 | points={{-100,100},{100,0},{-100,-100},{-100,100}},
|
|---|
| 780 | lineColor={255,127,0},
|
|---|
| 781 | fillColor={255,127,0},
|
|---|
| 782 | fillPattern=FillPattern.Solid)}, coordinateSystem(
|
|---|
| 783 | extent={{-100,-100},{100,100}},
|
|---|
| 784 | preserveAspectRatio=true,
|
|---|
| 785 | initialScale=0.2)),
|
|---|
| 786 | Diagram(coordinateSystem(
|
|---|
| 787 | preserveAspectRatio=true,
|
|---|
| 788 | initialScale=0.2,
|
|---|
| 789 | extent={{-100,-100},{100,100}}), graphics={Polygon(
|
|---|
| 790 | points={{0,50},{100,0},{0,-50},{0,50}},
|
|---|
| 791 | lineColor={255,127,0},
|
|---|
| 792 | fillColor={255,127,0},
|
|---|
| 793 | fillPattern=FillPattern.Solid), Text(
|
|---|
| 794 | extent={{-10,85},{-10,60}},
|
|---|
| 795 | lineColor={255,127,0},
|
|---|
| 796 | textString="%name")}),
|
|---|
| 797 | Documentation(info="<html>
|
|---|
| 798 | <p>
|
|---|
| 799 | Connector with one input signal of type Integer.
|
|---|
| 800 | </p>
|
|---|
| 801 | </html>"));
|
|---|
| 802 | connector IntegerOutput = output Integer "'output Integer' as connector"
|
|---|
| 803 | annotation (
|
|---|
| 804 | defaultComponentName="y",
|
|---|
| 805 | Icon(coordinateSystem(
|
|---|
| 806 | preserveAspectRatio=true,
|
|---|
| 807 | extent={{-100,-100},{100,100}}), graphics={Polygon(
|
|---|
| 808 | points={{-100,100},{100,0},{-100,-100},{-100,100}},
|
|---|
| 809 | lineColor={255,127,0},
|
|---|
| 810 | fillColor={255,255,255},
|
|---|
| 811 | fillPattern=FillPattern.Solid)}),
|
|---|
| 812 | Diagram(coordinateSystem(
|
|---|
| 813 | preserveAspectRatio=true,
|
|---|
| 814 | extent={{-100,-100},{100,100}}), graphics={Polygon(
|
|---|
| 815 | points={{-100,50},{0,0},{-100,-50},{-100,50}},
|
|---|
| 816 | lineColor={255,127,0},
|
|---|
| 817 | fillColor={255,255,255},
|
|---|
| 818 | fillPattern=FillPattern.Solid), Text(
|
|---|
| 819 | extent={{30,110},{30,60}},
|
|---|
| 820 | lineColor={255,127,0},
|
|---|
| 821 | textString="%name")}),
|
|---|
| 822 | Documentation(info="<html>
|
|---|
| 823 | <p>
|
|---|
| 824 | Connector with one output signal of type Integer.
|
|---|
| 825 | </p>
|
|---|
| 826 | </html>"));
|
|---|
| 827 | block Increment
|
|---|
| 828 | extends PartialIntegerSISO;
|
|---|
| 829 | parameter Integer increment;
|
|---|
| 830 | equation
|
|---|
| 831 | y = u + increment;
|
|---|
| 832 | end Increment;
|
|---|
| 833 |
|
|---|
| 834 | block Prev
|
|---|
| 835 | extends PartialIntegerSISO;
|
|---|
| 836 | equation
|
|---|
| 837 | y = previous(u);
|
|---|
| 838 | end Prev;
|
|---|
| 839 | end Components;
|
|---|
| 840 |
|
|---|
| 841 | model DeepHierarchy "SM Example with a slightly deeper hierarchy"
|
|---|
| 842 | block L1Start
|
|---|
| 843 | annotation (
|
|---|
| 844 | Icon(graphics={Text(
|
|---|
| 845 | extent={{-100,100},{100,-100}},
|
|---|
| 846 | lineColor={0,0,0},
|
|---|
| 847 | textString="%name")}),
|
|---|
| 848 | Diagram(graphics={Text(
|
|---|
| 849 | extent={{-100,100},{100,-100}},
|
|---|
| 850 | lineColor={0,0,0},
|
|---|
| 851 | textString="%stateText",
|
|---|
| 852 | fontSize=10)}),
|
|---|
| 853 | __Dymola_state=true,
|
|---|
| 854 | showDiagram=true,
|
|---|
| 855 | singleInstance=true);
|
|---|
| 856 | end L1Start;
|
|---|
| 857 | L1Start l1Start
|
|---|
| 858 | annotation (Placement(transformation(extent={{-18,22},{18,58}})));
|
|---|
| 859 | block L1Composite
|
|---|
| 860 | Integer count(start=0);
|
|---|
| 861 | block L2Start
|
|---|
| 862 |
|
|---|
| 863 | annotation (
|
|---|
| 864 | Icon(graphics={Text(
|
|---|
| 865 | extent={{-100,100},{100,-100}},
|
|---|
| 866 | lineColor={0,0,0},
|
|---|
| 867 | textString="%name")}),
|
|---|
| 868 | Diagram(graphics={Text(
|
|---|
| 869 | extent={{-100,100},{100,-100}},
|
|---|
| 870 | lineColor={0,0,0},
|
|---|
| 871 | textString="%stateText",
|
|---|
| 872 | fontSize=10)}),
|
|---|
| 873 | __Dymola_state=true,
|
|---|
| 874 | showDiagram=true,
|
|---|
| 875 | singleInstance=true);
|
|---|
| 876 | end L2Start;
|
|---|
| 877 | L2Start l2Start
|
|---|
| 878 | annotation (Placement(transformation(extent={{-58,2},{-22,38}})));
|
|---|
| 879 | block L2Composite
|
|---|
| 880 | block L3Start
|
|---|
| 881 |
|
|---|
| 882 | annotation (
|
|---|
| 883 | Icon(graphics={Text(
|
|---|
| 884 | extent={{-100,100},{100,-100}},
|
|---|
| 885 | lineColor={0,0,0},
|
|---|
| 886 | textString="%name")}),
|
|---|
| 887 | Diagram(graphics={Text(
|
|---|
| 888 | extent={{-100,100},{100,-100}},
|
|---|
| 889 | lineColor={0,0,0},
|
|---|
| 890 | textString="%stateName",
|
|---|
| 891 | fontSize=10)}),
|
|---|
| 892 | __Dymola_state=true,
|
|---|
| 893 | showDiagram=true,
|
|---|
| 894 | singleInstance=true);
|
|---|
| 895 | end L3Start;
|
|---|
| 896 | L3Start l3Start
|
|---|
| 897 | annotation (Placement(transformation(extent={{-38,2},{38,78}})));
|
|---|
| 898 | block L3Final
|
|---|
| 899 |
|
|---|
| 900 | annotation (
|
|---|
| 901 | Icon(graphics={Text(
|
|---|
| 902 | extent={{-100,100},{100,-100}},
|
|---|
| 903 | lineColor={0,0,0},
|
|---|
| 904 | textString="%name")}),
|
|---|
| 905 | Diagram(graphics={Text(
|
|---|
| 906 | extent={{-100,100},{100,-100}},
|
|---|
| 907 | lineColor={0,0,0},
|
|---|
| 908 | textString="%stateText",
|
|---|
| 909 | fontSize=10)}),
|
|---|
| 910 | __Dymola_state=true,
|
|---|
| 911 | showDiagram=true,
|
|---|
| 912 | singleInstance=true);
|
|---|
| 913 | end L3Final;
|
|---|
| 914 | L3Final l3Final
|
|---|
| 915 | annotation (Placement(transformation(extent={{-38,-98},{38,-22}})));
|
|---|
| 916 | equation
|
|---|
| 917 | transition(
|
|---|
| 918 | l3Start,
|
|---|
| 919 | l3Final,
|
|---|
| 920 | true,
|
|---|
| 921 | immediate=false) annotation (Line(
|
|---|
| 922 | points={{0,0},{0,-20}},
|
|---|
| 923 | color={175,175,175},
|
|---|
| 924 | thickness=0.25,
|
|---|
| 925 | smooth=Smooth.Bezier), Text(
|
|---|
| 926 | string="%condition",
|
|---|
| 927 | extent={{-4,-4},{-4,-10}},
|
|---|
| 928 | fontSize=10,
|
|---|
| 929 | textStyle={TextStyle.Bold},
|
|---|
| 930 | horizontalAlignment=TextAlignment.Right));
|
|---|
| 931 | initialState(l3Start) annotation (Line(
|
|---|
| 932 | points={{-40,40},{-72,40}},
|
|---|
| 933 | color={175,175,175},
|
|---|
| 934 | thickness=0.25,
|
|---|
| 935 | smooth=Smooth.Bezier,
|
|---|
| 936 | arrow={Arrow.Filled,Arrow.None}));
|
|---|
| 937 | annotation (
|
|---|
| 938 | Icon(graphics={Text(
|
|---|
| 939 | extent={{-100,100},{100,-100}},
|
|---|
| 940 | lineColor={0,0,0},
|
|---|
| 941 | textString="%name")}),
|
|---|
| 942 | Diagram(graphics={Text(
|
|---|
| 943 | extent={{-100,100},{100,-100}},
|
|---|
| 944 | lineColor={0,0,0},
|
|---|
| 945 | textString="%stateText",
|
|---|
| 946 | fontSize=10)}),
|
|---|
| 947 | __Dymola_state=true,
|
|---|
| 948 | showDiagram=true,
|
|---|
| 949 | singleInstance=true);
|
|---|
| 950 | end L2Composite;
|
|---|
| 951 | L2Composite l2Composite
|
|---|
| 952 | annotation (Placement(transformation(extent={{-78,-98},{-2,-22}})));
|
|---|
| 953 | L2Final l2Final
|
|---|
| 954 | annotation (Placement(transformation(extent={{60,2},{96,38}})));
|
|---|
| 955 | equation
|
|---|
| 956 | transition(
|
|---|
| 957 | l2Start,
|
|---|
| 958 | l2Composite,
|
|---|
| 959 | true,
|
|---|
| 960 | immediate=false,
|
|---|
| 961 | reset=true,
|
|---|
| 962 | synchronize=false,
|
|---|
| 963 | priority=2) annotation (Line(
|
|---|
| 964 | points={{-20,10},{92,-34},{0,-60}},
|
|---|
| 965 | color={175,175,175},
|
|---|
| 966 | thickness=0.25,
|
|---|
| 967 | smooth=Smooth.Bezier), Text(
|
|---|
| 968 | string="%condition",
|
|---|
| 969 | extent={{40,0},{40,-6}},
|
|---|
| 970 | fontSize=10,
|
|---|
| 971 | textStyle={TextStyle.Bold},
|
|---|
| 972 | horizontalAlignment=TextAlignment.Right));
|
|---|
| 973 | transition(
|
|---|
| 974 | l2Composite,
|
|---|
| 975 | l2Start,
|
|---|
| 976 | activeState(l2Composite.l3Final),
|
|---|
| 977 | immediate=false,
|
|---|
| 978 | reset=true,
|
|---|
| 979 | synchronize=false,
|
|---|
| 980 | priority=1) annotation (Line(
|
|---|
| 981 | points={{-79,-21},{-59,1}},
|
|---|
| 982 | color={175,175,175},
|
|---|
| 983 | thickness=0.25,
|
|---|
| 984 | smooth=Smooth.Bezier), Text(
|
|---|
| 985 | string="%condition",
|
|---|
| 986 | extent={{4,4},{4,10}},
|
|---|
| 987 | fontSize=10,
|
|---|
| 988 | textStyle={TextStyle.Bold},
|
|---|
| 989 | horizontalAlignment=TextAlignment.Left));
|
|---|
| 990 | initialState(l2Start) annotation (Line(
|
|---|
| 991 | points={{-60,20},{-80,20}},
|
|---|
| 992 | color={175,175,175},
|
|---|
| 993 | thickness=0.25,
|
|---|
| 994 | smooth=Smooth.Bezier,
|
|---|
| 995 | arrow={Arrow.Filled,Arrow.None}));
|
|---|
| 996 | public
|
|---|
| 997 | block L2Final
|
|---|
| 998 |
|
|---|
| 999 | annotation (
|
|---|
| 1000 | Icon(graphics={Text(
|
|---|
| 1001 | extent={{-100,100},{100,-100}},
|
|---|
| 1002 | lineColor={0,0,0},
|
|---|
| 1003 | textString="%name")}),
|
|---|
| 1004 | Diagram(graphics={Text(
|
|---|
| 1005 | extent={{-100,100},{100,-100}},
|
|---|
| 1006 | lineColor={0,0,0},
|
|---|
| 1007 | textString="%stateText",
|
|---|
| 1008 | fontSize=10)}),
|
|---|
| 1009 | __Dymola_state=true,
|
|---|
| 1010 | showDiagram=true,
|
|---|
| 1011 | singleInstance=true);
|
|---|
| 1012 | end L2Final;
|
|---|
| 1013 | equation
|
|---|
| 1014 | count = previous(count) + 1;
|
|---|
| 1015 | transition(
|
|---|
| 1016 | l2Start,
|
|---|
| 1017 | l2Final,count >= 2,
|
|---|
| 1018 | immediate=false,
|
|---|
| 1019 | priority=1,
|
|---|
| 1020 | reset=true,
|
|---|
| 1021 | synchronize=false) annotation (Line(
|
|---|
| 1022 | points={{-20,22},{58,22}},
|
|---|
| 1023 | color={175,175,175},
|
|---|
| 1024 | thickness=0.25,
|
|---|
| 1025 | smooth=Smooth.Bezier), Text(
|
|---|
| 1026 | string="%condition",
|
|---|
| 1027 | extent={{4,4},{4,10}},
|
|---|
| 1028 | fontSize=10,
|
|---|
| 1029 | textStyle={TextStyle.Bold},
|
|---|
| 1030 | horizontalAlignment=TextAlignment.Left));
|
|---|
| 1031 | annotation (
|
|---|
| 1032 | Icon(graphics={Text(
|
|---|
| 1033 | extent={{-100,100},{100,-100}},
|
|---|
| 1034 | lineColor={0,0,0},
|
|---|
| 1035 | textString="%name")}),
|
|---|
| 1036 | Diagram(graphics={Text(
|
|---|
| 1037 | extent={{-100,98},{100,-102}},
|
|---|
| 1038 | lineColor={0,0,0},
|
|---|
| 1039 | textString="%stateText",
|
|---|
| 1040 | fontSize=10)}),
|
|---|
| 1041 | __Dymola_state=true,
|
|---|
| 1042 | showDiagram=true,
|
|---|
| 1043 | singleInstance=true);
|
|---|
| 1044 | end L1Composite;
|
|---|
| 1045 | L1Composite l1Composite
|
|---|
| 1046 | annotation (Placement(transformation(extent={{-38,-78},{38,-2}})));
|
|---|
| 1047 | equation
|
|---|
| 1048 | initialState(l1Start) annotation (Line(
|
|---|
| 1049 | points={{-3.6,60},{-4,82}},
|
|---|
| 1050 | color={175,175,175},
|
|---|
| 1051 | thickness=0.25,
|
|---|
| 1052 | smooth=Smooth.Bezier,
|
|---|
| 1053 | arrow={Arrow.Filled,Arrow.None}));
|
|---|
| 1054 | transition(
|
|---|
| 1055 | l1Start,
|
|---|
| 1056 | l1Composite,
|
|---|
| 1057 | timeInState() > 1.9,
|
|---|
| 1058 | immediate=false,
|
|---|
| 1059 | reset=true,
|
|---|
| 1060 | synchronize=false,
|
|---|
| 1061 | priority=1) annotation (Line(
|
|---|
| 1062 | points={{20,40},{34,0}},
|
|---|
| 1063 | color={175,175,175},
|
|---|
| 1064 | thickness=0.25,
|
|---|
| 1065 | smooth=Smooth.Bezier), Text(
|
|---|
| 1066 | string="%condition",
|
|---|
| 1067 | extent={{36,-6},{36,-12}},
|
|---|
| 1068 | fontSize=10,
|
|---|
| 1069 | textStyle={TextStyle.Bold},
|
|---|
| 1070 | horizontalAlignment=TextAlignment.Right));
|
|---|
| 1071 | transition(
|
|---|
| 1072 | l1Composite,
|
|---|
| 1073 | l1Start,
|
|---|
| 1074 | activeState(l1Composite.l2Final),
|
|---|
| 1075 | immediate=false,
|
|---|
| 1076 | reset=true,
|
|---|
| 1077 | synchronize=false,
|
|---|
| 1078 | priority=1) annotation (Line(
|
|---|
| 1079 | points={{-39,-1},{-20,40}},
|
|---|
| 1080 | color={175,175,175},
|
|---|
| 1081 | thickness=0.25,
|
|---|
| 1082 | smooth=Smooth.Bezier), Text(
|
|---|
| 1083 | string="%condition",
|
|---|
| 1084 | extent={{4,4},{4,10}},
|
|---|
| 1085 | fontSize=10,
|
|---|
| 1086 | textStyle={TextStyle.Bold},
|
|---|
| 1087 | horizontalAlignment=TextAlignment.Left));
|
|---|
| 1088 | annotation (Icon(coordinateSystem(preserveAspectRatio=false)), Diagram(
|
|---|
| 1089 | coordinateSystem(preserveAspectRatio=false)));
|
|---|
| 1090 | end DeepHierarchy;
|
|---|
| 1091 | annotation (uses(Modelica(version="3.2.2")));
|
|---|
| 1092 | end SMGraphicalTestCases;
|
|---|