Pseudo-Code For The Eye Clock Module (A Service That Implements A State Machine) Initializeeyeclock
Pseudo-Code For The Eye Clock Module (A Service That Implements A State Machine) Initializeeyeclock
Pseudo-Code For The Eye Clock Module (A Service That Implements A State Machine) Initializeeyeclock
Pseudo-code for the Eye Clock module (a service that implements a state machine)
InitializeEyeClock
Takes a priority number, returns True.
CurrentState is AllOff
If ThisEvent is ES_INIT
Turn on all LEDs
Set NextState to SixLEDOn
Endif
If ThisEvent is ES_RESET_BUTTON
Turn on all LEDs
Set NextState to SixLEDOn
End AllOff Block
CurrentState is SixLEDOn
If ThisEvent is ES_TIMEOUT and parameter is EYE_TIMER
Turn off LED 1
Set EYE_TIMER to be 10s and start timer
Set NextState to FiveLEDOn
EndIf
If ThisEvent is ES_LEAF_INSERTED
Turn on all LEDs
Set EYE_TIMER to be 10s and start timer
EndIf
If ThisEvent is ES_GAME_WON
Turn on all LEDs
Set NextState to SixLEDOn
Stop EYE_TIMER
EndIf
If ThisEvent is ES_GAME_LOST
Turn off all LEDs
Set NextState to SixLEDOn
Stop EYE_TIMER
EndIf
If ThisEvent is ES_RESET_BUTTON
Turn on all LEDs
Set NextState to SixLEDOn
Stop EYE_TIMER
EndIf
If ThisEvent is ES_NO_ACTIVITY
Set EventType to ES_ERROR
Set EventParam to line number
EndIf
End SixLEDOn block
CurrentState is FiveLEDOn
If ThisEvent is ES_TIMEOUT and parameter is EYE_TIMER
Turn off LED 2
Set EYE_TIMER to be 10s and start timer
Set NextState to FourLEDOn
EndIf
If ThisEvent is ES_GAME_LOST
Turn off All LEDs
Set NextState to AllOff
Stop EYE_TIMER
EndIf
If ThisEvent is ES_GAME_WON
Turn on all LEDs
Set NextState to SixLEDOn
Stop EYE_TIMER
EndIf
If ThisEvent is ES_RESET_BUTTON
Turn on all LEDs
Set NextState to SixLEDOn
Stop EYE_TIMER
EndIf
End FiveLEDOn block
CurrentState is FourLEDOn
If ThisEvent is ES_TIMEOUT and parameter is EYE_TIMER
Turn off LED 3
Set EYE_TIMER to be 10s and start timer
Set NextState to ThreeLEDOn
EndIf
If ThisEvent is ES_GAME_LOST
Turn off all LEDs
Set NextState to AllOff
Stop EYE_TIMER
EndIf
If ThisEvent is ES_GAME_WON
Turn on all LEDs
Set NextState to SixLEDOn
Stop EYE_TIMER
EndIf
If ThisEvent is ES_RESET_BUTTON
Turn on all LEDs
Set NextState to SixLEDOn
Stop EYE_TIMER
EndIf
End FourLEDOn block
CurrentState is ThreeLEDOn
If ThisEvent is ES_TIMEOUT and parameter is EYE_TIMER
Turn off LED 4
Set EYE_TIMER to be 10s and start timer
Set NextState to TwoLEDOn
EndIf
If ThisEvent is ES_GAME_LOST
Turn off all LEDs
Set NextState to AllOff
Stop EYE_TIMER
EndIf
If ThisEvent is ES_GAME_WON
Turn on all LEDs
Set NextState to SixLEDOn
Stop EYE_TIMER
EndIf
If ThisEvent is ES_RESET_BUTTON
Turn on all LEDs
Set NextState to SixLEDOn
Stop EYE_TIMER
EndIf
End ThreeLEDOn block
CurrentState is TwoLEDOn
If ThisEvent is ES_TIMEOUT and parameter is EYE_TIMER
Turn off LED 5
Set EYE_TIMER to be 10s and start timer
Set NextState to OneLEDOn
EndIf
If ThisEvent is ES_GAME_LOST
Turn off all LEDs
Set NextState to AllOff
Stop EYE_TIMER
EndIf
If ThisEvent is ES_GAME_WON
Turn on all LEDs
Set NextState to SixLEDOn
Stop EYE_TIMER
EndIf
If ThisEvent is ES_RESET_BUTTON
Turn on all LEDs
Set NextState to SixLEDOn
Stop EYE_TIMER
EndIf
End TwoLEDOn block
CurrentState is OneLEDOn
If ThisEvent is ES_TIMEOUT and parameter is EYE_TIMER
Turn off all LED
Post ES_GAME_LOST to List2
Set NextState to AllOff
EndIf
If ThisEvent is ES_GAME_LOST
Turn off all LEDs
Set NextState to AllOff
Stop EYE_TIMER
If ThisEvent is ES_GAME_WON
Turn on all LEDs
Set NextState to SixLEDOn
Stop EYE_TIMER
EndIf
If ThisEvent is ES_RESET_BUTTON
Turn on all LEDs
Set NextState to SixLEDOn
Stop EYE_TIMER
EndIf
End OneLEDOn block