/**************************************************************************** Module EndGameSM.c Revision 1.0.1 Description EndGame state machine for 218b Final project. Notes History When Who What/Why -------------- --- -------- 02/06/12 23:13 jec converted to Gen2 Events and Services Framework 02/13/10 11:50 jec converted During functions to return Event_t so that they match the template 02/21/07 17:04 jec converted to pass Event_t to Start...() 02/20/07 21:37 jec converted to use enumerated type for events 02/21/05 12:21 jec Began Coding ****************************************************************************/ /*----------------------------- Include Files -----------------------------*/ /* include header files for this state machine as well as any machines at the next lower level in the hierarchy that are sub-machines to this machine */ /*----------------------------- Module Defines ----------------------------*/ // define constants for the states for this machine // and any other local defines /*---------------------------- Module Functions ---------------------------*/ /* prototypes for private functions for this machine, things like during functions, entry & exit functions.They should be functions relevant to the behavior of this state machine */ /*---------------------------- Module Variables ---------------------------*/ // everybody needs a state variable, you may need others as well /*------------------------------ Module Code ------------------------------*/ /**************************************************************************** Function RunEndGameSM Parameters ES_Event CurrentEvent: the event to process Returns ES_Event Description Implements the timer state machine for the microwave oven Notes uses nested switch/case to implement the machine. Author J. Edward Carryer, 2/21/05, 12:30PM ****************************************************************************/ // make recursive call warning into info { //declare all needed variables /* are we making a state transition? */ // assume we are not consuming event //base response on current state { //if the current state is waiting //process any events //If an event is active { //base respone on current event type { //if the event was a entry event { //print an update to the screen //Set all the motors to off //Consume the event //Query to see if wall angle is tolerable // if not tolerable { //set the next state to attacking //mark that we are making a transition } //Otherwise, query if wall is moving { //check if the wall is moving // -> if it is { //set the next state to defending //mark that we are making a transition } //Otherwise { //set the next state to waiting //mark that we are making a transition } } } //if the event is a game over event //print an update to the screen. //do not consume the event } } //if we are in an attacking state //print an update to the screen //process any events //If an event is active { //base response on the event type { //if we get the start event //print an update to the screen //detemine if most scored in bin is owned //If its not, drive to this bin { //switch based on that bin drive to that position { //if it is bin 1 //select appropriate coordinates //if it is bin 2 //select appropriate coordinates //if it is bin 3 //select appropriate coordinates //if it is bin 4 //select appropriate coordinates } }//Otherwise drive to the second bin to win { { //if it is bin 1 //select appropriate coordinates //if it is bin 2 //select appropriate coordinates //if it is bin 3 //select appropriate coordinates //if it is bin 4 //select appropriate coordinates } } //post an appropriate event to the driving sm //Consume the event //if the event is a pushing blocked wall event //print an update to the screen //drive to point of larger moment arm //post the event to the driving sm //Consume the event //if the event was game over //print an update to the screen } } //if we are in the defending state //print an update to the screen //process any events //If an event is active { //base response to the event type { //if we are pushing a blocked wall //print an update to the screen //drive to point of larger moment arm //post the event to the driving sm //Consume the event //if we get a start event //print an update to the screen //detemine if we need to drive CW or CCW //if the wall is moving CW //drive CCW //otherwise //drive CW //Call the appropriate driving DrivingCommand //Consume the event //if we get the game over event //print an appropriate message to the screen } } } // If we are making a state transition { // Execute exit function for current state //Modify state variable // Execute entry function for new state } } /**************************************************************************** Function StartEndGameSM Parameters ES_Event CurrentEvent Returns None Description Does any required initialization for this state machine Notes Author J. Edward Carryer, 2/21/05, 12:54PM ****************************************************************************/ //void StartEndGameSM ( ES_Event CurrentEvent ) { // local variable to get debugger to display the value of CurrentEvent //init us into this state // call the entry function (if any) for the ENTRY_STATE } /**************************************************************************** Function QueryEndGameSM Parameters None Returns TimerState The current state of the Timer state machine Description returns the current state of the Template state machine Notes Author J. Edward Carryer, 2/21/05, 12:59PM ****************************************************************************/ //EndGameSubState QueryEndGameSM ( void ) { }