Sie sind auf Seite 1von 1

DetectBeacon State Machine

ES_Event RunDetectBeacon( ES_Event ThisEvent )


{
// set event type to ES_NO_EVENT; assume no errors
//set NextState to CurrentState;
//define an event generated here in runDetectBeacon, if applicable
//if current state
{
//if current state is InitDetectBeaconState
// if this event type is ES_INIT
// set NextState to BeaconIdleState
}
//end if
//if current state BeaconIdleState:
//if this event type is ES_ALIGN2TARGET
// Unmask interrupt
//EnableInputCaptureBeaconPeriod();
// Set next state to look for beacon
//set NextState to DetectingBeaconState
// Start a timer
// ES_Timer_InitTimer( BEACON_TIMER, BEACON_TIME )
}
//end if
//if current state is DetectingBeaconState
// If beacon is found
{
// Calculate BeaconFrequency, first multiply by clock ticks rate
// Change units from ms to seconds
// BeaconFrequency = (TICKS_PER_MS *1000/ BeaconPeriod)
// If BeaconFrequency is within bounds
//if the last detected beacon frequency is within a tolerance of a bucket
//beacon frequency
// Mask interrupt (disable)
//DisableInputCaptureBeaconPeriod();
// Post to Manager that beacon was found
//the event indicates that we've successfully found a bucket
//beacon
//post to the game master, which will pass the event down to the
//Shooting state machine
// Set next state back to idle
// Else start a time to keep waiting for beacon
{
// Start a timer
// Stay in the same state
}
}
//end if
} // end SM

// set CurrentState to NextState


//return ReturnEvent
}

Das könnte Ihnen auch gefallen