*********Pseudo-code for the Master state machine module*********** **** #includes **** header file containing stamp function header file containing flip polar bear function header file that gives access to state of leaf inserted/not inserted **** module level variables **** MyPriority, CurrentState **** public functions **** InitializeMaster() Takes a priority number, returns True. Initialize the MyPriority variable with the passed in parameter. Call Timer Inits for Game Timer, Inactivity Timer and CelebTimer You may need to initialize servos for stamping and polar bear here (ask Allan) Set CurrentState to MasterPseudoState Pass ES_INIT event to the post function of this service ES_PostToService() RunMaster() Takes an Event and returns an ES_NO_EVENT Initialize local variable NextState Set NextState to CurrentState Case Current State: Current State is MasterPseudoState if ThisEvent is ES_INIT NextState = Welcome FlipPolarBear down endif end MasterPseudoState block CurrentState is Welcome if ThisEvent is STARTBUTTON and LeafInserted==True NextState = Playing Start GameTimer to 60 seconds Start InactivityTimer to 30 seconds PostAll GAME_START event end Welcome block CurrentState is Playing if ThisEvent is INACTIVITY_TIMER_TIMEOUT PostAll RESET event FlipPolarBear down Clear the GameTimer NextState = Welcome if ThisEvent is LEAF_REMOVED PostAll RESET event FlipPolarBear down Clear InactivityTimer Clear GameTimer NextState = Welcome if ThisEvent is GAME_TIMER_TIMEOUT PostAll GAME_OVER event Clear InactivityTimer Start CelebTimer FlipPolarBear up Stamp() NextState = Celebration end Playing block CurrentState is Celebration if ThisEvent is CELEB_TIMER_TIMEOUT PostAll RESET event FlipPolarBear down NextState = Welcome end Celebration block end Case Set CurrentState to NextState return ES_NO_EVENT end of RunMaster() ***** event checkers ***** ***** private functions ***** ****************************End Master*****************************