Page 876 - Mechatronics with Experiments
P. 876
862 MECHATRONICS
Transmission Heat
Neutral Switch_on
Clutch_engaged On
Off
Engaged H Switch_off
First (Speed > threshold)
Lights
Second
On Switch_off
Off
Switch_on
Exclusive states
Parallel states
FIGURE A.36: Decomposition of states: exclusive (OR) or parallel (AND) states. At a
super-state, only one of the exclusive states can be active, whereas multiple parallel states
(AND states) can be concurrently active.
Step 3: Define State Actions and Data Variables. The hierarchy of states describes
the type structure of the logic. The actual logic, that is the actions, and the data acted on
in each state defines the details of the algorithm. Actions can be present either in the state
logic or in the transitions.
There are four different categories of actions in each state (Figure A.37):
entry:
action1(); % executed once when the state is activated
during: % executed every sampling period while the
state is active
action21();
action22();
exit: % executed once when transition from that
state to another state
action3(); % occurs and this state is ’exited’
on_"EventName1": % executed on every occurance of the named
event
action41();
action42();
on_"EventName2": % executed on every occurance of the named
event
action43();
action44();
action45();
When a state is “active”, some of the actions are executed depending on the condition of
the state. For instance, on the first entry to the state, the actions in the “entry:” block are