Sample State Machine
This is a sample state machine.
Definition
The above state machine uses these actions and guards:
Run the State Machine
This is a small sample to show how to interact with the state machine:
Log
If you add the log4net log extensions available in the Appccelerate.SourceTemplate package:
to the above code then these are the log messages (if all are enabled - see log4net documentation on how to configure log messages). Note how the state exits and enters are logged, especially for hierarchical transitions.
You can write your own extension for different logging.
Reports
yEd Report
csv Report
Source | Entry | Exit | Children |
OnFloor | AnnounceFloor | Beep, Beep | DoorClosed, DoorOpen |
Moving | MovingUp, MovingDown | ||
Healthy | OnFloor, Moving | ||
MovingUp | |||
MovingDown | |||
DoorClosed | |||
DoorOpen | |||
Error |
Source | Event | Guard | Target | Actions |
OnFloor | CloseDoor | DoorClosed | ||
OnFloor | OpenDoor | DoorOpen | ||
OnFloor | GoUp | CheckOverload | MovingUp | |
OnFloor | GoUp | internal transition | AnnounceOverload, Beep | |
OnFloor | GoDown | CheckOverload | MovingDown | |
OnFloor | GoDown | internal transition | AnnounceOverload | |
Moving | Stop | OnFloor | ||
Healthy | ErrorOccured | Error | ||
Error | Reset | Healthy | ||
Error | ErrorOccured | internal transition |
Textual Report
Elevator: initial state = OnFloor Healthy: initial state = OnFloor history type = Deep entry action: exit action: ErrorOccured -> Error actions: guard: OnFloor: initial state = DoorClosed history type = None entry action: AnnounceFloor exit action: Beep, Beep CloseDoor -> DoorClosed actions: guard: OpenDoor -> DoorOpen actions: guard: GoUp -> MovingUp actions: guard: CheckOverload GoUp -> internal actions: AnnounceOverload, Beep guard: GoDown -> MovingDown actions: guard: CheckOverload GoDown -> internal actions: AnnounceOverload guard: DoorClosed: initial state = None history type = None entry action: exit action: DoorOpen: initial state = None history type = None entry action: exit action: Moving: initial state = MovingUp history type = Shallow entry action: exit action: Stop -> OnFloor actions: guard: MovingUp: initial state = None history type = None entry action: exit action: MovingDown: initial state = None history type = None entry action: exit action: Error: initial state = None history type = None entry action: exit action: Reset -> Healthy actions: guard: ErrorOccured -> internal actions: guard: