RunCheckIngInSM If current state is FirstReportWait Execute During function for FirstReportWait. If an event is active If event is event ES_TIMEOUT Next State is Query4FirstResponse Mark that we are taking a transition Consume event Else Return CurrentEvent If current state is state Query4FirstResponse Execute During function for state Query4FirstResponse If an event is active If LOC has a response Read ResponseReady if ResponseReadyByte is not ready Request Query Command Consume Event else if ResponseReadyByte is ready Read and store StatusReportByte if StatusReportByte is ACK or NACK Transition to SecondReportWait Mark that we are taking a transition Consume event else if StatusReportByte is Inactive ReturnEvent EventType is ES_WRONG_STAGE ReturnEvent Event Param is the LOC returned in StatusReport Parse code into STAGE_1, STAGE_2, STAGE_3 else if we receive a bad freq report Transition to FirstReportWait Mark that we are taking a transition Consume event endif endif Else Return CurrentEvent Endif If current state is SecondReportWait Execute During function for state SecondReportWait If an event is active If event is event ES_TIMEOUT Next State is Query4SecondResponse Mark that we are taking a transition Consume event If current state is state Query4SecondResponse Execute During function If an event is active If LOC has a response Read ResponseReady if ResponseReadyByte is not ready Request Query Command Consume Event Endif else if ResponseReadyByte is ready Read and store StatusReportByte if StatusReportByte is ACK Return check-in done! Read the target goal else if StatusReportByte is Inactive Then transition to FirstReportWait Mark that we are taking a transition Consume event endif Endif end eventtype switch DuringFirstReportWait On Entry Report frequency to LOC Start 200 ms timer for LOC to be ready DuringQuery4FirstResponse On Entry Request Query response DuringSecondReportWait On Entry Report frequency to LOC Start 200 ms timer for LOC to be ready DuringQuery4SecondResponse On Entry Request Query response GetSRLocation Get Location code from StatusReport Byte if the location code is 1R or 1G return STAGE_1 if the location code is 2R or 2G return STAGE_2 if the location code is 3R or 3G return STAGE_3 if invalid stage location from status report return 0