/****************************************************************************
Module
MasterSM.c
2.0.1
Description
This is a template for the top level Hierarchical state machine
Notes
****************************************************************************/
/*---------------------------- Module Variables ---------------------------*/
MyPriority;
/*------------------------------ Module Code ------------------------------*/
/****************************************************************************
Function
InitMasterSM
Parameters
uint8_t : the priorty of this service
Returns
boolean, False if error in initialization, True otherwise
Description
Saves away the priority, and starts
the top level state machine
Notes
Author
J. Edward Carryer, 02/06/12, 22:06
****************************************************************************/
if the event type is ES_ENTRY
call StartMasterSM function with the event
/****************************************************************************
Function
PostMasterSM
Parameters
ES_Event ThisEvent , the event to post to the queue
Returns
boolean False if the post operation failed, True otherwise
Description
Posts an event to this state machine's queue
Notes
Author
J. Edward Carryer, 10/23/11, 19:25
****************************************************************************/
post the event with the priority
/****************************************************************************
Function
RunMasterSM
Parameters
ES_Event: the event to process
Returns
ES_Event: an event to return
Description
the run function for the top level state machine
Notes
uses nested switch/case to implement the machine.
Author
J. Edward Carryer, 02/06/12, 22:09
****************************************************************************/
// make recursive call warning into info
#pragma MESSAGE INFORMATION C1855
run the during function for this state
/**************************/
/*Always IN GAMEPLAY state*/
if the event is ES_EXIT
pass on the event to lower state machine SM
set the CurrentEvent event type to ES_ENTRY
re-enter the current state machine with CurrentEvent
turn off LED
//Turn off LED
if CurrentEvent is ES_NO_EVENT
return CurrentEvent
/****************************************************************************
Function
StartMasterSM
Parameters
ES_Event CurrentEvent
Returns
nothing
Description
Does any required initialization for this state machine
Notes
Author
J. Edward Carryer, 02/06/12, 22:15
****************************************************************************/
call function RunMasterSM
/***************************************************************************
private functions
***************************************************************************/
/********************************************************************/
DuringMaster
/********************************************************************/
// process ES_ENTRY & ES_EXIT events
if event is ES_ENTRY
call StartGameSM with the given event
if event is ES_EXIT
run exit functoin for the GameSM
turn off all motors and ball launcher
else
pass the event to lower state machine, GameSM
Module
MasterSM.c
2.0.1
Description
This is a template for the top level Hierarchical state machine
Notes
****************************************************************************/
/*---------------------------- Module Variables ---------------------------*/
MyPriority;
/*------------------------------ Module Code ------------------------------*/
/****************************************************************************
Function
InitMasterSM
Parameters
uint8_t : the priorty of this service
Returns
boolean, False if error in initialization, True otherwise
Description
Saves away the priority, and starts
the top level state machine
Notes
Author
J. Edward Carryer, 02/06/12, 22:06
****************************************************************************/
if the event type is ES_ENTRY
call StartMasterSM function with the event
/****************************************************************************
Function
PostMasterSM
Parameters
ES_Event ThisEvent , the event to post to the queue
Returns
boolean False if the post operation failed, True otherwise
Description
Posts an event to this state machine's queue
Notes
Author
J. Edward Carryer, 10/23/11, 19:25
****************************************************************************/
post the event with the priority
/****************************************************************************
Function
RunMasterSM
Parameters
ES_Event: the event to process
Returns
ES_Event: an event to return
Description
the run function for the top level state machine
Notes
uses nested switch/case to implement the machine.
Author
J. Edward Carryer, 02/06/12, 22:09
****************************************************************************/
// make recursive call warning into info
#pragma MESSAGE INFORMATION C1855
run the during function for this state
/**************************/
/*Always IN GAMEPLAY state*/
if the event is ES_EXIT
pass on the event to lower state machine SM
set the CurrentEvent event type to ES_ENTRY
re-enter the current state machine with CurrentEvent
turn off LED
//Turn off LED
if CurrentEvent is ES_NO_EVENT
return CurrentEvent
/****************************************************************************
Function
StartMasterSM
Parameters
ES_Event CurrentEvent
Returns
nothing
Description
Does any required initialization for this state machine
Notes
Author
J. Edward Carryer, 02/06/12, 22:15
****************************************************************************/
call function RunMasterSM
/***************************************************************************
private functions
***************************************************************************/
/********************************************************************/
DuringMaster
/********************************************************************/
// process ES_ENTRY & ES_EXIT events
if event is ES_ENTRY
call StartGameSM with the given event
if event is ES_EXIT
run exit functoin for the GameSM
turn off all motors and ball launcher
else
pass the event to lower state machine, GameSM