uOttawaUniversity of Ottawa - Canadas University
list of dots

Umple User Manual    [Previous]   [Next]   

Loading

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

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;
}
      

Load the above code into UmpleOnline

 

Another Example

class LightBulb
{
  status
  {
    On { 
      flip -> Off;
    }
    Off { 
      flip -> On;
    }
  }
  // trace any triggering of event flip
  trace flip;
}
      

Load the above code into UmpleOnline

 

Another Example

// this example will trace all states of State machine GarageDoor 

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;
}
      

Load the above code into UmpleOnline

 

Syntax


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

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