Pseudocode for GameTimerService: ES_Event RunGameTimerService( ES_Event ThisEvent ) ES_Event ReturnEvent; Pseudocode for GameTimerService ES_Event RunGameTimerService( ES_Event ThisEvent ) ES_Event ReturnEvent; ES_Event PostEvent; ReturnEvent.EventType = ES_NO_EVENT PostEvent.EventType = ES_NO_EVENT static GameTimerState_t CurrentState; static boolean time_almost_out_status; static uint8_t MyPriority; ES_Event RunGameTimerService( ES_Event ThisEvent ) If current state is initial Psedudo State If event is ES_INIT Update CurrentState to NormalGameTimerState; Set time_almost_out_status to False; End if If current state is NormalGameTimerState : static uchar time_left = GAME_DURATION; If event is ES_START Start the timer at 1ms rate with a 1 second timout End if If event is ES_TIMEOUT: Decrement time_left by 1 second Reset timer to 1 second If time_left equals WARNING_1 Post event EV_HOPPERFULL to GamePlayHSM else if time_left equals WARNING_2 Post event EV_HOPPERFULL to GamePlayHSM Set time_almost_out_status to true else if time_left is 0 Post event EV_GAME_OVER to GamePlayHSM Post event StopRobot to DrivingSM Set time_almost_out_status to true Turn off the front roller Set CurrentState to TwoMinTimeout End if End if If current state is TwoMinTimeout Don’t respond to any events End if return ReturnEvent; Global functions: GameTimerState_t QueryGameTimerService( void ) return(CurrentState); boolean IsTimeReallyAlmostOut (void) return time_almost_out_status;