SinelaboreRT Header Logo

SinelaboreRT

As simple as possible, but not any simpler!

User Tools

Site Tools


wiki:manual:editoriii

State Diagram Editor Introduction Part III

In the first part of the tutorial you learned how to create a first state diagram and to generate code from it. Then in the second part you learned the use of regions and what can be done with them.

In this third part of the tutorial you will learn how to simulate a created model to see for yourself if the machine does what it is supposed to do. Or to run through a model with colleagues or customers and confirm that the behavior is as expected.

A model can only be simulated if it is error free. The absence of errors can be checked with the check button in the button bar. If there are no errors, the simulation is possible in the Tree View (see Figure 1).

Simulation window with manual timer simulation. Note: press pause where needed to better follow what's going on.

Simulation without timer

The simulation can be started with the button “Start”. Once the simulation has been started, the events processed by the currently active state (in red) and its parents (also in red) are displayed. A click on an event triggers the state change. Afterwards, the possible events that originate from the new state are displayed. Events of a timer have to be triggered by a click just like all other events. A click on the “Stop” button ends the simulation.

The code “executed” in the actions is recorded in the output window. This makes it possible to track which actions are executed when the state changes.

Note: Actions refer to the code that you have entered as Entry/Exit/Do code or for transitions.

Simulation with timer

In statemachines, one or more timers are very often used to trigger time-controlled actions. Timers send a user defined event to the machine at timeout. To simulate this semi-automatically, it is possible to specify timer commands in the comment of actions in a predefined notation. The timer commands are introduced by a special sequence, by default these are three “@@@”. Then the timer command follows in XML syntax. This makes it possible to create, start or stop timers and thus make the simulation more realistic.

To activate the timer simulation, check the “Activate Timers” option before starting the simulation. If timers fire faster than approx. 200ms (depending on the computer a little more or less), a reduction should be set at “Timer Ratio”, otherwise the real-time image build-up is no longer possible. Or other events can no longer be clicked. By default the “Timer Ratio” is 1:1.

The following functions are available. Times are always specified in ms. A unique timer ID is required in each case. When creating a timer, the event must be specified (in the example evTimeout), which is injected into the simulator when the time expires. Timers can fire cyclically or once.

<TimerCreate timeout_ms="400" id="T1" event="evTimeout/>
<TimerIncrement value_ms="100" id="T1"/>
<TimerDecrement value_ms="100" id="T1"/>
<TimerSetTimeout timeout_ms="400" id="T1" />
<TimerStartAcyclic id="T1" />"
<TimerStartOnce id="T1"/>
<TimerStop id="T1" />

In the following video you can see how to work with the simulation. After switching on the microwave oven the timer T1 was created. The user can now increase or decrease the time via evDec/evInc. If he closes the door, the timer T1 starts running. After the time has elapsed, the sent evTimeout event automatically switches to the Completet state. In between, the time can still be changed via evDec/evInc.

Note: It is important to pay attention to the fact that the entered program code with the timer later e.g. in C or C++ are realized, agrees with the simulation code in the comment! Since this takes place however in the same input field this is not difficult (it in the picture above at the example of a transition).

Summary

With the simulation of your design you can easily understand its function and check if transitions etc. have been forgotten. By using the timer simulation this is further simplified and the simulation is more realistic.

This website uses cookies. By using the website, you agree with storing cookies on your computer. Also you acknowledge that you have read and understand our Privacy Policy. If you do not agree leave the website.More information about cookies
wiki/manual/editoriii.txt · Last modified: 2023/09/08 15:52 by webmin

Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki