Вы находитесь на странице: 1из 4

*************************************************************************************

Psuedo-code for LEDStripService service

InitializeLEDStripService
Takes a priority number, returns True.

Initialize the MyPriority variable with the passed in parameter.


Set CurrentState to LEDStripStatic
Post ES_CHANGE_LED_STRIP_COLOR_STATIC to this service with EventParam Off
End of InitializeLEDStripService

RunDoorService
Set ReturnEvent to ES_NO_EVENT
Set NextState to CurrentState

Based on the state of the CurrentState variable choose one of the following blocks of code:
CurrentState is LEDStripStatic
If ThisEvent is ES_CHANGE_LED_STRIP_COLOR_STATIC
If GameState is not WrongEvent and EveState is not HeartOn
Set LEDStrip to EventParam
EndIf
EndIf
If ThisEvent is ES_CHANGE_LED_STRIP_COLOR_FLASHING
If GameState is not WrongEvent and EveState is not HeartOn
Set LEDStrip to EventParam
Set LED_STRIP_TIMER to FLASH_TIME and start timer
Set NextState to LEDStripFlashingOn
EndIf
EndIf
If ThisEvent is ES_GAME_LOST
Set LEDStrip to appropriate color
EndIf
If ThisEvent is ES_GAME_WON
Set LEDStrip to appropriate color
EndIf
If ThisEvent is ES_NEED_EVE
Set LEDStrip to appropriate color
EndIf
If ThisEvent is ES_INCORRECT_ANSWER
If EveState is not HeartOn
Set LEDStrip to appropriate color
Set LED_STRIP_TIMER to FLASH_TIME and start timer
Set NextState to LedStripFlashingOn
EndIf
EndIf
End of LEDStripStatic Block

CurrentState is LEDStripFlashingOff
If ThisEvent is ES_CHANGE_LED_STRIP_COLOR_STATIC
If GameState is not WrongEvent and EveState is not HeartOn
Set LEDStrip to EventParam color
Set NextState to LEDStripStatic
EndIf
EndIf
If ThisEvent is ES_CHANGE_LED_STRIP_COLOR_FLASHING
If GameState is not WrongEvent and EveState is not HeartOn
Set LEDStrip to EventParam color
Set NextState to LEDStripStatic
Set LED_STRIP_TIMER to FLASH_TIME and start timer
Set NextState to LEDStripFlashingOn
EndIf
EndIf
If ThisEvent is ES_TIMEOUT and EventParam is LED_STRIP_TIMER
Set LEDStrip to FlashingColor
Set LED_STRIP_TIMER to FLASH_TIME and start timer
Set NextState to LEDStripFlashingOn
EndIf
If ThisEvent is ES_GAME_LOST
Set LEDStrip to appropriate color
Set NextState to LEDStripStatic
EndIf
If ThisEvent is ES_GAME_WON
Set LEDStrip to appropriate color
Set NextState to LEDStripStatic
EndIf
If ThisEvent is ES_NEED_EVE
Set LEDStrip to appropriate color
Set NextState to LEDStripStatic
EndIf
If ThisEvent is ES_INCORRECT_ANSWER
If EveState is not HeartOn
Set LEDStrip to appropriate color
Set LED_STRIP_TIMER to FLASH_TIME and start timer
Set NextState to LedStripFlashingOn
EndIf
EndIf
End LEDStripFlashingOff Block
CurrentState is LEDStripFlashingOn
If ThisEvent is ES_CHANGE_LED_STRIP_COLOR_STATIC
If GameState is not WrongEvent and EveState is not HeartOn
Set LEDStrip to EventParam color
Set NextState to LEDStripStatic
EndIf
EndIf
If ThisEvent is ES_CHANGE_LED_STRIP_COLOR_FLASHING
If GameState is not WrongEvent and EveState is not HeartOn
Set LEDStrip to EventParam color
Set NextState to LEDStripStatic
Set LED_STRIP_TIMER to FLASH_TIME and start timer
Set NextState to LEDStripFlashingOn
EndIf
EndIf
If ThisEvent is ES_TIMEOUT and EventParam is LED_STRIP_TIMER
Set LEDStrip to FlashingColor
Set LED_STRIP_TIMER to FLASH_TIME and start timer
Set NextState to LEDStripFlashingOff
EndIf
If ThisEvent is ES_GAME_LOST
Set LEDStrip to appropriate color
Set NextState to LEDStripStatic
EndIf
If ThisEvent is ES_GAME_WON
Set LEDStrip to appropriate color
Set NextState to LEDStripStatic
EndIf
If ThisEvent is ES_NEED_EVE
Set LEDStrip to appropriate color
Set NextState to LEDStripStatic
EndIf
If ThisEvent is ES_INCORRECT_ANSWER
If EveState is not HeartOn
Set LEDStrip to appropriate color
Set LED_STRIP_TIMER to FLASH_TIME and start timer
Set NextState to LedStripFlashingOn
EndIf
EndIf
End LEDStripFlashingOn Block

Set CurrentState to NextState


Return ReturnEvent
End RunLEDStripService
End LEDStripService

Вам также может понравиться