/****************************************************************************
Module
Round2DriveSM.c
Revision
2.0.1
Description
This is a template file for implementing state machines.
Notes
****************************************************************************/
/*---------------------------- Module Variables ---------------------------*/
CurrentState;
/*------------------------------ Module Code ------------------------------*/
/****************************************************************************
Function
RunRound2DriveSM
Parameters
ES_Event: the event to process
Returns
ES_Event: an event to return
Description
add your description here
Notes
uses nested switch/case to implement the machine.
Author
J. Edward Carryer, 2/11/05, 10:45AM
****************************************************************************/
switch CurrentState
{
case ST_Shooting
run during function for this state
switch event type
case ES_TIMEOUT:
if event parameter is SHOOTING_TIMER
set NextState as ST_Round2Driving
mark that we are taking a transition
Set CurrentEvent as the ReturnEvent
end switch event type
case ST_Round2Driving
run during function for this state
end switch CurrentState
if we are making a state transition
Execute exit function for current state
Set CurrentState to NextState
Execute Entry function for new current state
/****************************************************************************
Function
StartRound2DriveSM
Parameters
None
Returns
None
Description
Does any required initialization for this state machine
Notes
Author
J. Edward Carryer, 2/18/99, 10:38AM
****************************************************************************/
if not entering in ES_ENTRY_HISTORY event type
set CurrentState as ST_SHOOTING
run entry function for the current state in RunRound2DriveSM
/****************************************************************************
Function
QueryRound2DriveSM
Parameters
None
Returns
TemplateState_t The current state of the Template state machine
Description
returns the current state of the Template state machine
Notes
Author
J. Edward Carryer, 2/11/05, 10:38AM
****************************************************************************/
return CurrentState
/***************************************************************************
private functions
***************************************************************************/
/*****************************************************************************/
DuringShooting
/****************************************************************************/
if entering as ES_ENTRY or ES_ENTRY_HISTORY
start SHOOTING_TIMER
Release the ball gate and turn on the launcher motor
if entering event type is ES_EXIT
turn off launcher motor and close the ball gate
/*****************************************************************************/
DuringRound2Driving
/****************************************************************************/
if entering as ES_ENTRY or ES_ENTRY_HISTORY
start state machine SimpleDriveToASM
if entering event type is ES_EXIT
run the exit function of the lower state machine and remap the return event
else
run lower state machine and allow event re-mapping
Module
Round2DriveSM.c
Revision
2.0.1
Description
This is a template file for implementing state machines.
Notes
****************************************************************************/
/*---------------------------- Module Variables ---------------------------*/
CurrentState;
/*------------------------------ Module Code ------------------------------*/
/****************************************************************************
Function
RunRound2DriveSM
Parameters
ES_Event: the event to process
Returns
ES_Event: an event to return
Description
add your description here
Notes
uses nested switch/case to implement the machine.
Author
J. Edward Carryer, 2/11/05, 10:45AM
****************************************************************************/
switch CurrentState
{
case ST_Shooting
run during function for this state
switch event type
case ES_TIMEOUT:
if event parameter is SHOOTING_TIMER
set NextState as ST_Round2Driving
mark that we are taking a transition
Set CurrentEvent as the ReturnEvent
end switch event type
case ST_Round2Driving
run during function for this state
end switch CurrentState
if we are making a state transition
Execute exit function for current state
Set CurrentState to NextState
Execute Entry function for new current state
/****************************************************************************
Function
StartRound2DriveSM
Parameters
None
Returns
None
Description
Does any required initialization for this state machine
Notes
Author
J. Edward Carryer, 2/18/99, 10:38AM
****************************************************************************/
if not entering in ES_ENTRY_HISTORY event type
set CurrentState as ST_SHOOTING
run entry function for the current state in RunRound2DriveSM
/****************************************************************************
Function
QueryRound2DriveSM
Parameters
None
Returns
TemplateState_t The current state of the Template state machine
Description
returns the current state of the Template state machine
Notes
Author
J. Edward Carryer, 2/11/05, 10:38AM
****************************************************************************/
return CurrentState
/***************************************************************************
private functions
***************************************************************************/
/*****************************************************************************/
DuringShooting
/****************************************************************************/
if entering as ES_ENTRY or ES_ENTRY_HISTORY
start SHOOTING_TIMER
Release the ball gate and turn on the launcher motor
if entering event type is ES_EXIT
turn off launcher motor and close the ball gate
/*****************************************************************************/
DuringRound2Driving
/****************************************************************************/
if entering as ES_ENTRY or ES_ENTRY_HISTORY
start state machine SimpleDriveToASM
if entering event type is ES_EXIT
run the exit function of the lower state machine and remap the return event
else
run lower state machine and allow event re-mapping