Gameplay HSM Pseudo Code
Gameplay HSM Pseudo Code
c
Define OPTO_CHECK_TIME and PUSH_TIME variables
Module level function definitions
Module level variables: CurrentState with type GameplayState_t
RunGameplaySM
Returns ES_NO_EVENT if no errors
StartGameplaySM
Takes an event as a parameter
DuringAlign
Takes an event as a parameter and returns an event
Set the ReturnEvent to the event that was passed into the function
If the event is ES_ENTRY
Call the StartAlignSM function
Else if the event is ES_EXIT
Call the RunAlignSM function
Else set the ReturnEvent variable to the returned value from the
RunAlignSM
Return ReturnEvent
End of DuringAlign
DuringInRepo
Takes an event as a parameter and returns an event
Set the ReturnEvent to the event that was passed into the function
If the event is ES_ENTRY
Send command to follower to turn on green interaction LED
Initialize the button timer (how often to check button between
presses)
Call the StartInRepoSM function
Else if the event is ES_EXIT
Call the RunInRepoSM function
Send command to follower to turn off green interaction LED
Else set the ReturnEvent variable to the returned value from the
RunInRepoSM
Return ReturnEvent
End of DuringInRepo
DuringTapeFollowForward
Takes an event as a parameter and returns an event
Set the ReturnEvent to the event that was passed into the function
If the event is ES_ENTRY
Send command to follower to drive forwards
Initialize the push timer
Initialize the check opto timer
Else if the event is ES_EXIT
Send command to follower to communicate the end of tape following
forward
Return ReturnEvent
End of DuringTapeFollowForward
DuringTapeFollowReverse
Takes an event as a parameter and returns an event
Set the ReturnEvent to the event that was passed into the function
If the event is ES_ENTRY
Initialize the check opto timer
Return ReturnEvent
End of DuringTapeFollowForward