Skip to content
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
159 changes: 154 additions & 5 deletions Modelica/StateGraph.mo
Original file line number Diff line number Diff line change
Expand Up @@ -809,7 +809,31 @@ package Examples
annotation (Line(points={{30.5,10},{46,10}}));
connect(transition2.outPort, initialStep.inPort[1]) annotation (Line(points=
{{51.5,10},{70,10},{70,32},{-62,32},{-62,10},{-49,10}}));
annotation (experiment(StopTime=5.5));
annotation (
Documentation(
figures = {
Figure(
title = "Boolean signal in system",
identifier = "ef029",
preferred = true,
plots = {
Plot(
curves = {
Curve(y = initialStep.active, legend = "Output from initialStep"),
Curve(y = transition1.t, legend = "transition1 wait time")
}
),
Plot(
curves = {
Curve(y = step.active, legend = "Output from step"),
Curve(y = transition2.t, legend = "transition2 wait time")
}
)
}
)
}
),
experiment(StopTime=5.5));
Comment on lines +812 to +836
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
annotation (
Documentation(
figures = {
Figure(
title = "Boolean signal in system",
identifier = "ef029",
preferred = true,
plots = {
Plot(
curves = {
Curve(y = initialStep.active, legend = "Output from initialStep"),
Curve(y = transition1.t, legend = "transition1 wait time")
}
),
Plot(
curves = {
Curve(y = step.active, legend = "Output from step"),
Curve(y = transition2.t, legend = "transition2 wait time")
}
)
}
)
}
),
experiment(StopTime=5.5));
annotation (
Documentation(
figures = {
Figure(
title = "Cyclic activation of the states",
identifier = "ef029",
preferred = true,
caption="Shows how the system cycles from initialStep to Step, and then repeated.\nThe time before transition is determined by the waitTime (1s) of the transitions.",
plots = {
Plot(
curves = {
Curve(y = initialStep.active, legend = "Active initialStep"),
Curve(y = step.active, legend = "Active step")}),
Plot(
curves = {
Curve(y = transition1.t, legend = "transition1 time waiting"),
Curve(y = transition2.waitTime, legend = "transition1 waitTime parameter")})})}),
experiment(StopTime=5.5));

After some thinking I would prefer to re-order, and re-name the plots like that, except I'm not happy with the "waitTime parameter" part.

The reasons are:

  • Having activations in one plot may make it clearer that just one state is active.
  • Calling it "Active initialStep" was as indicated clearer to me
  • Given that there is a parameter "waitTime" (the time until transition triggers) plotting another variable as "wait time" was a bit confusing to me, so I renamed it to "time waiting".
  • One could add another sub-plot for transition2, but I don't think it is needed.

At first I had the existing two transition*.t in one plot - but it was harder to understand for me - especially if one plotted waitTime as well.

end FirstExample;

model FirstExample_Variant2
Expand Down Expand Up @@ -845,7 +869,33 @@ package Examples
-30},{62,-30},{62,-2}}, color={255,0,255}));
connect(transition2.outPort, initialStep.inPort[1]) annotation (Line(points=
{{63.5,10},{82,10},{82,32},{-80,32},{-80,10},{-71,10}}));
annotation (experiment(StopTime=5.5));
annotation (
Documentation(
figures = {
Figure(
title = "Boolean signal in system",
identifier = "72ddc",
preferred = true,
plots = {
Plot(
curves = {
Curve(y = initialStep.active, legend = "Output from initialStep"),
Curve(y = transition1.t, legend = "transition1 wait time")
},
x = Axis(min = 0, max = 5)
),
Plot(
curves = {
Curve(y = step.active, legend = "Output from step"),
Curve(y = timer.y, legend = "Output from timer")
},
x = Axis(min = 0, max = 5)
)
}
)
}
),
experiment(StopTime=5.5));
end FirstExample_Variant2;

model FirstExample_Variant3
Expand Down Expand Up @@ -883,7 +933,31 @@ package Examples
{{67.5,10},{82,10},{82,32},{-80,32},{-80,10},{-71,10}}));
connect(SetBoolean1.y, transition2.condition) annotation (Line(points={{
61.6,-30},{66,-30},{66,-2}}, color={255,0,255}));
annotation (experiment(StopTime=5.5));
annotation (
Documentation(
figures = {
Figure(
title = "Boolean signal in system",
identifier = "96375",
preferred = true,
plots = {
Plot(
curves = {
Curve(y = initialStep.active, legend = "Output from initialStep"),
Curve(y = transition1.t, legend = "transition1 wait time")
}
),
Plot(
curves = {
Curve(y = step.active, legend = "Output from step"),
Curve(y = timer.y, legend = "Output from timer, controlling transition2")
}
)
}
)
}
),
experiment(StopTime=5.5));
end FirstExample_Variant3;

model ExecutionPaths
Expand Down Expand Up @@ -1076,7 +1150,46 @@ has a higher priority to fire as alternative.split[2]).
This is the same example as \"ExecutionPaths\". The only difference
is that the alternative paths are included in a \"CompositeStep\".
</p>
</html>"), experiment(StopTime=15));
</html>",
figures = {
Figure(
title = "Boolean signal in system",
identifier = "22111",
preferred = true,
plots = {
Plot(
curves = {
Curve(y = step0.active, legend = "Output from step0"),
Curve(y = transition1.t, legend = "transition1 wait time")
}
),
Plot(
curves = {
Curve(y = step1.active, legend = "Output from step1")
}
),
Plot(
curves = {
Curve(y = compositeStep.active, legend = "Output from entire compositeStep block = sum of initStep, step3, and exitStep"),
Curve(y = compositeStep.initStep.active, legend = "Output from initStep"),
Curve(y = compositeStep.step3.active, legend = "Output from step3"),
Curve(y = compositeStep.exitStep.active, legend = "Output from exitStep"),
Curve(y = compositeStep.transition3.t, legend = "transistion3 wait time"),
Curve(y = compositeStep.transition5.t, legend = "transition5 wait time"),
Curve(y = compositeStep.transition5.waitTime, legend = "transition5 target wait time"),
Curve(y = transition2.t, legend = "transition2 wait time")
}
),
Plot(
curves = {
Curve(y = step6.active, legend = "Output from step6"),
Curve(y = transition7.condition, legend = "transition7 condition for firing status")
}
)
}
)
}
), experiment(StopTime=15));
Comment on lines +1154 to +1192
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
figures = {
Figure(
title = "Boolean signal in system",
identifier = "22111",
preferred = true,
plots = {
Plot(
curves = {
Curve(y = step0.active, legend = "Output from step0"),
Curve(y = transition1.t, legend = "transition1 wait time")
}
),
Plot(
curves = {
Curve(y = step1.active, legend = "Output from step1")
}
),
Plot(
curves = {
Curve(y = compositeStep.active, legend = "Output from entire compositeStep block = sum of initStep, step3, and exitStep"),
Curve(y = compositeStep.initStep.active, legend = "Output from initStep"),
Curve(y = compositeStep.step3.active, legend = "Output from step3"),
Curve(y = compositeStep.exitStep.active, legend = "Output from exitStep"),
Curve(y = compositeStep.transition3.t, legend = "transistion3 wait time"),
Curve(y = compositeStep.transition5.t, legend = "transition5 wait time"),
Curve(y = compositeStep.transition5.waitTime, legend = "transition5 target wait time"),
Curve(y = transition2.t, legend = "transition2 wait time")
}
),
Plot(
curves = {
Curve(y = step6.active, legend = "Output from step6"),
Curve(y = transition7.condition, legend = "transition7 condition for firing status")
}
)
}
)
}
), experiment(StopTime=15));
figures = {
Figure(
title = "Cyclic activation of a parallel and alternative steps.",
caption="This shows that steps can be in parallel (synchronized at the end).\nAdditionally it contains alternatives, that are selected based on priority.\nThe compositeStep shows how to build structure"
identifier = "22111",
preferred = true,
plots = {
Plot(
curves = {
Curve(y = step0.active, legend = "Active step0"),
Curve(y = compositeStep.active, legend = "Active compositeStep - parallel to step1"),
Curve(y = step1.active, legend = "Active step1"),
Curve(y = step6.active, legend = "Active step6")}),
Plot(
curves={
Curve(y = compositeStep.active, legend = "Active compositeStep - where step3, step4, step4a are alternatives"),
Curve(y = compositeStep.initStep.active, legend = "Active compositeStep.initStep"),
Curve(y = compositeStep.step3.active, legend = "Active compositeStep.step3"),
Curve(y = compositeStep.step4.active, legend = "Active compositeStep.step4"),
Curve(y = compositeStep.step4a.active, legend = "Active compositeStep.step4a"),
Curve(y = compositeStep.exitStep.active, legend = "Active compositeStep.exitStep")
}
)
}
)
}
),
experiment(StopTime=15));

As I understand it, this illustrates the main point of the example as:

  • step1 and compositeStep are in parallel; so both are active at the same time (there's a synchronization when ending)
  • inside compositeStep there are alternatives (step3, step4, step4a) - where only one is active.

The actual timings etc aren't the focus, so don't plot them.
(Should have a similar figure for ExecutionPaths.)

I believe the example would be clearer if different alternatives were selected for the different cycles.

end ShowCompositeStep;

model ShowExceptions
Expand Down Expand Up @@ -1133,7 +1246,43 @@ via its \"resume\" port, all steps within \"compositeStep\" are activated
according to their setting before leaving the \"compositeStep\" via its
\"suspend\" port.
</p>
</html>"),experiment(StopTime=20));
</html>",
figures = {
Figure(
title = "Boolean signal in system",
identifier = "214ea",
preferred = true,
plots = {
Plot(
curves = {
Curve(y = initialStep.active, legend = "Output of initalStep"),
Curve(y = transition1.t, legend = "transition1 wait time")
}
),
Plot(
curves = {
Curve(y = compositeStep.active, legend = "Output from entire compositeStep block"),
Curve(y = transition3.t, legend = "transition3 wait time")
}
),
Plot(
curves = {
Curve(y = step1.active, legend = "Output from step1"),
Curve(y = transition4.t, legend = "transition4 wait time")
}
),
Plot(
curves = {
Curve(y = compositeStep.initStep.active, legend = "Output of initStep in compositeStep"),
Curve(y = compositeStep.compositeStep11.active, legend = "Output of compositeStep11 in compositeStep"),
Curve(y = compositeStep.compositeStep12.active, legend = "Output of compositeStep12 in compositeStep"),
Curve(y = compositeStep.exitStep.active, legend = "Output of exitStep in compositeStep")
}
)
}
)
}
),experiment(StopTime=20));
end ShowExceptions;

model ControlledTanks
Expand Down