/**************************************************************************** Module Angels_MasterMachine.c Description This is the master state machine for the Charlie's Angels ME218B project. ****************************************************************************/ /*---------------------------- Module Variables ---------------------------*/ static uint8_t MyPriority; /*------------------------------ Module Code ------------------------------*/ /**************************************************************************** Function InitMasterSM Saves away the priority, and starts the top level SM Takes uint8_t : the priority of this service Returns false if error in initialization, True otherwise ****************************************************************************/ Create an event with type ES_Entry Set MyPriority = Priority Send the event to StartMasterSM() to start the master SM Return True End of function /**************************************************************************** Function PostMasterSM Posts an event to this state machine's queue Takes an event ThisEvent to post to the queue Returns False if the Enqueue operation failed, True otherwise ****************************************************************************/ Call ES_PostToService( MyPriority, ThisEvent) and return what it returns /**************************************************************************** Function RunMasterSM Runs the master state machine for the 'bot. Takes an event to process, CurrentEvent. Returns an event ****************************************************************************/ Call DuringMaster with parameter CurrentEvent in the absence of an error, return ES_NO_EVENT End of function /**************************************************************************** Function StartMasterSM Starts the master state machine for the 'bot. Takes an event to process, CurrentEvent. Returns an event ****************************************************************************/ Initialize an event LocalEvent = CurrentEvent Call RunMasterSM(LocalEvent) End of function /*************************************************************************** 'During' functions ***************************************************************************/ DuringMaster Entry functions: Start Robot SM Start Turret SM (eliminated with Turret) Exit functions: none Run Robot SM with Exit event Run Turret SM with Exit event (eliminated with Turret) During functions: none Run Robot SM Run Turret SM (eliminated) End of function