|
Composing State Machines
[Previous]  [Next] 
|
![]() |
User Manual [Previous]  [Next] Composing State MachinesState machines can be built from parts. Elements of state machines can be added in several ways:
Illustration of various ways of adding details to a state machine
class X {
sm {
a {
// Ordinary transition
e1-> bsub1;
}
b {
bsub1 {
// transition in substate
e2 -> bsub2;
}
bsub2 {}
}
// Standalone transition
// at to level
e3 b -> a;
// Standalone transition
// between substate
e4 bsub2 -> bsub1;
}
}
// Mixin for class that mixes in
// more details into the state machine
class X {
// Supplemental detail for same
// state machine
sm {
// Standalone transition
e5 bsub1 -> a;
// Another way of adding a transition
a {e6 -> bsub2;}
}
}
// Mixset to optionally add more detail
mixset extra class X {
sm {
// Adding a new state
c {}
// Adding a transition
e7 b -> c;
}
}
// Activating the above mixset
use extra;
Load the above code into UmpleOnline Syntax// State machine elements in Umple. See user manual page: BasicStateMachines stateMachineDefinition : statemachine [=queued]? [=pooled]? [name] { [[state]]* } state : [=final]? [stateName] { [[stateInternal]]* } // A transition guard can come before or after the arrow // The order of guard and event definition can also be interchanged transition :  ( [[eventDefinition]] [[guard]]  | [[guard]] [[eventDefinition]]  | [=unspecified]? [[guard]]  | [[eventDefinition]]  )?  ( [[action]] ->  | -> [[action]]  | ->  ) [stateName] ; //Issue148 standAloneTransition :  ( [[eventDefinition]] [[guard]]  | [[guard]] [[eventDefinition]]  | [=unspecified]? [[guard]]  | [[eventDefinition]]  )? [~fromState]  ( [[action]] ->  | -> [[action]]  | ->  ) [~toState] ; |