|
Tracing State Machines
[Previous]  [Next] 
|
![]() |
User Manual [Previous]  [Next] Tracing State MachinesState machines are representations of system behaviour. States can have entry or exit actions and do activities; they can also be composite (i.e. nested) or concurrent. MOTL provides modellers with the capability of specifying tracing for all these modelling elements.
Example
@SuppressWarnings("deprecation")
class LightBulb
{
Integer v = 0;
status
{
On {
entry / { setV(1); }
flip -> Off;
}
Off {
entry / { setV(2); }
flip -> On;
}
}
// trace whenever we enter/exit state On
trace On;
// trace whenever we exit state Off and
// report value of attribute v
trace exit Off record v;
}
// @@@skipphpcompile See issue 596 (PHP tracing causes issues)
Load the above code into UmpleOnline Another Example
@SuppressWarnings("deprecation")
class LightBulb
{
status
{
On {
flip -> Off;
}
Off {
flip -> On;
}
}
// trace any triggering of event flip
trace flip;
}
// @@@skipphpcompile See issue 596 (PHP tracing causes issues)
Load the above code into UmpleOnline Another Example
// this example will trace all states of
// State machine GarageDoor
@SuppressWarnings("deprecation")
class GarageDoor
{
// UML state machine digram for a Garage door,
// written in Umple
status {
Open { buttonOrObstacle -> Closing; }
Closing {
buttonOrObstacle -> Opening;
reachBottom -> Closed;
}
Closed { buttonOrObstacle -> Opening; }
Opening {
buttonOrObstacle -> HalfOpen;
reachTop -> Open;
}
HalfOpen { buttonOrObstacle -> Opening; }
}
// trace whole state machine
trace status;
}
// @@@skipphpcompile See issue 596 (PHP tracing causes issues)
Load the above code into UmpleOnline SyntaxtraceDirective : trace [[Prefix]]? [[traceEntity]] [[Postfix]] ; traceEntity- : [traceEntity]  ((  )?  ()  )?  ( , [traceEntity]  ((  )?  ()  )?  )* |