Professional Documents
Culture Documents
Shooting Pseudocode
Shooting Pseudocode
CurrentState is LoadingInShooting
Set ReturnEvent equal to CurrentEvent equal to return of
DuringLoadingInShooting()
If CurrentEvent.EventType is not equal to ES_NO_EVENT
ThisEvent is ES_TIMEOUT
If EventParam is SHOOTING_TIMER
Set NextState to ShootingInShooting
Set MakeTransition to true
EndIf
Else if EventParam is LAUNCH_WINDUP_TIMER
Set NextState to AligningInShooting
Set FirstShot to false
Set MakeTransition to true
EndElse
EndIf
End LoadingInShooting block
CurrentState is AligningInShooting
Set ReturnEvent equal to CurrentEvent equal to return of
DuringAligningInShooting()
If CurrentEvent.EventType is not equal to ES_NO_EVENT
ThisEvent is AR1_ALIGN
Start KICKBACK_TIMER
Post DRIVE_CW to MotorService
Set MakeTransition equal to false
ThisEvent is NOT_ALIGNED
Post ES_ALIGN_QUERY to SPILeaderService
ThisEvent is ES_TIMEOUT
If EventParam is KICKBACK_TIMER
Set NextState to ShootingInShooting
Set MakeTransition to true
EndIf
End AligningInShooting block
CurrentState is ShootingInShooting
Set ReturnEvent equal to CurrentEvent equal to return of
DuringShootingInShooting()
If CurrentEvent.EventType is not equal to ES_NO_EVENT
ThisEvent is ES_TIMEOUT
If EventParam is SHOOTING_TIMER
If Ball_Count is greater than 0
Set NextState to LoadingInShooting
Set MakeTransition to ture
EndIf
Else
Set NextState to WaitingInShooting
Post STOP_SHOOTING to MasterSM
EndElse
EndIf
End ShootingInShooting block
Return ReturnEvent
End of RunShootingSM
StartShootingSM
Takes CurrentEvent as parameter, returns nothing.
DuringLoadingInShooting
Takes Event as parameter, returns Event.
If Event is ES_ENTRY
Post ES_INDEX_OPEN to SPILeaderService
Endif
Endif
Else
EndElse
Return Event
End of DuringLoadingInShooting
DuringAligningInShooting
Takes Event as parameter, returns Event.
If Event is ES_ENTRY
Post DRIVE_CW to MotorService
Post ES_ALIGN_QUERY to SPILeaderService
Endif
Else
EndElse
Return Event
End of DuringAligningInShooting
DuringShootingInShooting
Takes Event as parameter, returns Event.
If Event is ES_ENTRY
Post ES_INDEX_CLOSE to SPILeaderService
Ball_Count –-
Start SHOOTING_TIMER
Endif
Else
EndElse
Return Event
End of DuringShootingInShooting