Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
52d2ee5
commit a78d0d2
Showing
3 changed files
with
54 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
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 @@ | ||
within ; | ||
model TicksInState "Test for TicksInState" | ||
inner Integer i(start = 0); | ||
|
||
block State1 | ||
outer output Integer i; | ||
equation | ||
i = previous(i) + 2; | ||
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)}), showDiagram = true, singleInstance = true); | ||
end State1; | ||
|
||
State1 state1 annotation(Placement(transformation(extent={{-56,62},{-10,76}}))); | ||
|
||
block State2 | ||
outer output Integer i; | ||
equation | ||
i = previous(i) - 1; | ||
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)}), showDiagram = true, singleInstance = true); | ||
end State2; | ||
|
||
State2 state2 annotation(Placement(transformation(extent={{-56,40},{-12,54}}))); | ||
equation | ||
transition(state1, state2,ticksInState() > 4, | ||
immediate=false, reset=true, synchronize=false, priority=1) annotation(Line(points={{-8,69}, | ||
{-4,58},{-10,47}}, 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.Left)); | ||
transition(state2, state1,ticksInState() > 5, | ||
immediate=false, reset=true, synchronize=false, priority=1) annotation(Line(points={{-58,47}, | ||
{-66,58},{-58,69}}, 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)); | ||
initialState(state1) annotation(Line(points={{-34.5336,78},{-36,84}}, color = {175, 175, 175}, thickness = 0.25, smooth = Smooth.Bezier, arrow = {Arrow.Filled, Arrow.None})); | ||
annotation(Diagram(coordinateSystem(preserveAspectRatio = false, extent = {{-100, -100}, {100, 100}}), graphics={ Text(extent = {{-62, 94}, {-12, 84}}, lineColor = {0, 0, 0}, fontSize = 10, | ||
horizontalAlignment = TextAlignment.Left, textString = "%declarations")})); | ||
end TicksInState; |
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,20 @@ | ||
// name: TicksInState | ||
// keywords: state machines | ||
// status: correct | ||
// | ||
|
||
loadFile("TicksInState.mo"); | ||
simulate(TicksInState, startTime=0, stopTime=30, numberOfIntervals=0); getErrorString(); | ||
val(i,30.0); | ||
|
||
// Result: | ||
// true | ||
// record SimulationResult | ||
// resultFile = "TicksInState_res.mat", | ||
// simulationOptions = "startTime = 0.0, stopTime = 30.0, numberOfIntervals = 0, tolerance = 1e-06, method = 'dassl', fileNamePrefix = 'TicksInState', options = '', outputFormat = 'mat', variableFilter = '.*', cflags = '', simflags = ''", | ||
// messages = "" | ||
// end SimulationResult; | ||
// "Warning: The initial conditions are not fully specified. Use +d=initialization for more information. | ||
// " | ||
// 14.0 | ||
// endResult |