list of dots Digital Research Alliance of Canada logo  NSERC logo  University of Ottawa logo / UniversitĂ© d'Ottawa

User Manual    [Previous]   [Next]   

Tracing State Machines

State 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.

  • State machine: State Machines can be traced as a whole, considering all states, nested states, events, etc.
  • State: Tracing a state involves the tracing of its entry/exit actions, incoming/outgoing events, and do-activities. In case of composite states, all nested states will be traced accordingly.
  • Event: A targeted event can be traced specifically. Tracing an event records previous state before the triggering of the traced event with the resulting new state after the transition.

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

 

Syntax


traceDirective : trace [[Prefix]]? [[traceEntity]] [[Postfix]] ;

traceEntity- : [traceEntity]
  ((
  )?
  ()
  )?
  ( , [traceEntity]
  ((
  )?
  ()
  )?
  )*