Fork me on GitHub

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

sample yEd report

csv Report

SourceEntryExitChildren
OnFloorAnnounceFloorBeep, BeepDoorClosed, DoorOpen
Moving MovingUp, MovingDown
Healthy OnFloor, Moving
MovingUp
MovingDown
DoorClosed
DoorOpen
Error
SourceEventGuardTargetActions
OnFloorCloseDoorDoorClosed
OnFloorOpenDoorDoorOpen
OnFloorGoUpCheckOverloadMovingUp
OnFloorGoUp internal transition AnnounceOverload, Beep
OnFloorGoDownCheckOverloadMovingDown
OnFloorGoDowninternal transition AnnounceOverload
MovingStopOnFloor
HealthyErrorOccured Error
ErrorResetHealthy
ErrorErrorOccuredinternal 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: