|
Mixsets with State Machine
[Previous]  [Next] 
|
![]() |
User Manual [Previous]  [Next] Mixsets with State MachineState machine models can contain variant units by employing mixsets. These can be inline (directly specified within a state macine) or compositional (in a separate file). For example, the mixset “HalfOpenFeature” in the code below captures the state “HalfOpen” and with a transition from "Opening" to the “HalfOpen” state. The second code example shows an equivalent state machine model, but with a compositional mixset. Example showing conditional transitions specified using a mixset
// This example shows how a state machine model can incorporate inline mixsets.
class GarageDoor
{
status {
Open { buttonOrObstacle -> Closing; }
Closing {
buttonOrObstacle -> Opening;
reachBottom -> Closed;
}
Closed { buttonOrObstacle -> Opening; }
Opening {
// HalfOpenFeature mixset below is an inline mixset.
// It contains an event (a part of the state machine).
mixset HalfOpenFeature {
buttonOrObstacle -> HalfOpen;
}
// end of HalfOpenFeature.
reachTop -> Open;
}
// HalfOpenFeature mixset here contains a state (with its content)
mixset HalfOpenFeature {
HalfOpen { buttonOrObstacle -> Opening; }
}
}
}
// A use statement to activate HalfOpenFeature mixset.
use HalfOpenFeature;
Load the above code into UmpleOnline Example of a mixset incorporated compositionally to modify a state machine
class GarageDoor
{
status {
Open { buttonOrObstacle -> Closing; }
Closing {
buttonOrObstacle -> Opening;
reachBottom -> Closed;
}
Closed { buttonOrObstacle -> Opening; }
Opening {
reachTop -> Open;
}
}
}
// The mixset below contains a compostional mixsets.
mixset HalfOpenFeature {
class GarageDoor
{
status {
Opening {
buttonOrObstacle -> HalfOpen;
}
HalfOpen { buttonOrObstacle -> Opening; }
}
}
}
// A use statement to activate HalfOpenFeature mixset.
use HalfOpenFeature;
Load the above code into UmpleOnline Syntax//Issue 148 inlineStateMachine : [=queued]? [=pooled]? [~name] {  ( [[comment]]  | [[state]]  | [[trace]]  | [[mixsetDefinition]]  | [=||]  | [[standAloneTransition]]  )* } stateEntity- : [=||]  | [[mixsetDefinition]]  | [[entryOrExitAction]]  | [[autoTransition]]  | [[transition]]  | [[activity]]  | [[state]]  | [[displayColor]]  | [[trace]]  | ; mixsetDefinition : mixset [mixsetName]  ( [[mixsetInnerContent]]  | [[requirement]]  | [[mixsetInlineDefinition]]  ) |