Created
June 12, 2012 11:35
-
-
Save neilmanuell/2917012 to your computer and use it in GitHub Desktop.
FSM for a latchable door
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private function configProcesses():void | |
{ | |
// LOCK Process | |
fsmConfig.configureProcess( LOCK ) | |
.ifCurrentState( CLOSED ) | |
.transitionTo( LOCK ); | |
fsmConfig.configureProcess( LOCK ) | |
.ifCurrentState( OPENED ) | |
.transitionTo( CLOSED, LOCK ); | |
fsmConfig.configureProcess( LOCK ) | |
.ifCurrentState( LATCHED ) | |
.transitionTo( OPENED, CLOSED, LOCK ); | |
// CLOSE Process | |
fsmConfig.configureProcess( CLOSE ) | |
.ifCurrentState( OPENED ) | |
.transitionTo( CLOSED ); | |
fsmConfig.configureProcess( CLOSE ) | |
.ifCurrentState( LATCHED ) | |
.transitionTo( OPENED, CLOSED ); | |
// OPEN Process | |
fsmConfig.configureProcess( OPEN ) | |
.ifCurrentState( LOCKED ) | |
.transitionTo( CLOSED, OPENED ); | |
fsmConfig.configureProcess( OPEN ) | |
.ifCurrentState( CLOSED ) | |
.transitionTo( OPENED ); | |
// LATCH Process | |
fsmConfig.configureProcess( LATCH ) | |
.ifCurrentState( OPENED ) | |
.transitionTo( LATCHED ); | |
fsmConfig.configureProcess( LATCH ) | |
.ifCurrentState( CLOSED ) | |
.transitionTo( OPENED, LATCHED ); | |
fsmConfig.configureProcess( LATCH ) | |
.ifCurrentState( LOCKED ) | |
.transitionTo( CLOSED, OPENED, LATCHED ); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private function configStates():void | |
{ | |
fsmConfig.configureState( LOCKED ) | |
.withEnteringGuards( OnlyIfKeyFits ) | |
.withExitingGuards( OnlyIfKeyFits ) | |
.withTransitionTargets( CLOSED ); | |
fsmConfig.configureState( CLOSED ) | |
.withTransitionTargets( LOCKED, OPENED ); | |
fsmConfig.configureState( OPENED ) | |
.withTransitionTargets( CLOSED, LATCHED ); | |
fsmConfig.configureState( LATCHED ) | |
.withTransitionTargets( OPENED ); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment