You are on page 1of 2

CheckingIn State Machine

ES_Event runCheckingInSM(ES_Event CurrentEvent){ //This function runs the top level hierarchical state machine
for the CheckingInSM service
//assume we're not making a transition
//assume we'll be staying in the same state
//an entry event without history
//assume we won't consume the current event

//take different actions depending on the current state of the Gameplay SM


//if the current state is moving along the wire to a target
//re-assign the current event to allow for lower level consumption of the event
//take different actions depending on the current event type
// if current event ES_UPDATED_STATUS:
//retrieve the response bytes from the SSI service
//getReportBytes()
//if current state is reportsAllowed {
// if the response ready byte was sent, then the report
//status byte will contain the status of the staging
//area
//if the frequency was correct and the
//staging area is active
//get the current location from the
//LOC response byte's location
//fields
//update the last known location at
//the GamePlay SM level
//then switch to the second waiting
//for response state
//indicate that we're switching
//states
//if the frequency was incorrect
//then self transition, so we'll try
//to make the report again
//indicate that we're switching
//states
//if the frequency was correct but the
//staging area is inactive
//then we must update the
//location with the current inactive
//staging area location, exit checking in
//and move back to following wire
//get the current location
//from the LOC response byte's location fields
//update the last known
//location at the GamePlay SM level
//remap the return event
//to indicate that the staging area is inactive
//if the LOC did not just send the report status
//response
//if the 200ms timer has expired
//query the LOC to see if the report
//status is ready
//create a new event
//the event is a command to the SSI
//service to make a frequency report
//specify making a frequency report
//with the command-specific parameter
//post the make report event to the
//SSI service
//end if
//if a timer has expired
//if the expired timer is indicating that at least 200 ms has
//passed since our last frequency report
//then sending a frequency report is allowed
//query the LOC to see if the report status is ready
//create a new event
//the event is a command to the SSI service to make a
//frequency report
//specify making a frequency report with the command-
//specific parameter
//post the make report event to the SSI service
//end if
//end if
//if current state is
//re-assign the current event to allow for lower level consumption of the event
//if current event
//case ES_UPDATED_STATUS:
//retrieve the response bytes from the SSI service
//getReportBytes()
// if the response ready byte was sent, then the report status byte will
//contain the status of the staging area
// if the report status byte acknowledges the frequency we sent
//remap the current event to indicate to the upper SMs
//that a staging area is now open
//shut off the hall sensor service by posting that
//we've succesfully checked in
//if the frequency was incorrect
//then switch to waiting 4 response one, and
//we'll try to send the first report again
//indicate that we're switching states
//end if
//if a timer has expired
//if the expired timer is indicating that at least 200 ms has
//passed since our last frequency report
//then sending a frequency report is allowed
//query the LOC to see if the report status is ready
//create a new event
//the event is a command to the SSI service to make a
//frequency report
//specify making a frequency report with the command-
//specific parameter
//post the make report event to the SSI service
//end if
//end if
}

//make a state transition if necessary


//if we should switch to the next state
//declare a state exit event
//recursively call the runDrivingToTargetSM to allow the current state to exit
//switch the current state to the next state
//declare a state entry event
//recursively call the runDrivingToTargetSM to enter the next state

//return the event


}

You might also like