Professional Documents
Culture Documents
PublicFunctions:RunCaptureCitySM,StartCaptureCitySM
ModuleFunctions:DuringWaiting,DuringRequesting,DuringQuerying
ModuleVariables:CurrentCaptureCityState
RunCaptureCitySM
LocalVariables:MakeTransition,NextState,EntryEventKind,ReturnEvent
SwitchCurrentState
CaseWaiting:
CurrentEventisDuringWaiting
IfCurrentEvent.EventTypeisnotES_NO_EVENT
SwitchCurrentEvent.EventType
Case:ES_TIMEOUTEvent
IfCurrentEvent.EventParamis
HALL_EFFECT_DEBOUNCE
NextStateisRequesting
MakeTransitionisTrue
EntryEventKindisnothistoryentry
EndIf
EndBlock
EndSwitch
EndIf
EndBlock
CaseRequesting:
CurrentEventisDuringRequesting
IfCurrentEvent.EventTypeisnotES_NO_EVENT
SwitchCurrentEvent.EventType
Case:NEW_COMMANDEvent
NextStateisQuerying
MakeTransitionisTrue
EntryEventKindisnothistoryentry
EndBlock
Case:ES_TIMEOUTEvent
IfCurrentEvent.EventParamisDETECT_TIMER
NextStateisQuerying
MakeTransitionisTrue
EntryEventKindisnothistoryentry
EndIf
EndBlock
EndSwitch
EndIf
EndBlock
CaseQuerying:
CurrentEventisDuringQuerying
IfCurrentEvent.EventTypeisnotES_NO_EVENT
SwitchCurrentEvent.EventType
Case:RESPONSE_READYEvent
NextStateisRequesting
MakeTransitionisTrue
EntryEventKindisnothistoryentry
EndBlock
Case:CITY_ENCOUNTEREDEvent
NextStateisWaiting
MakeTransitionisTrue
EntryEventKindisnothistoryentry
EndBlock
EndSwitch
EndIf
EndBlock
EndSwitch
IfMakeTransitionistrue
Executeexitfunctionforcurrentstate
CallRunMasterSMfunctionforCurrentEvent
CurrentStateequalsNextState
Executeentryfunctionforcurrentstate
CallRunMasterSMfunctionforEntryEventKind
EndIf
EndRunCaptureCitySM
StartCaptureCitySM
IfCurrentEventisnotES_ENTRY_HISTORYevent
CurrentStateequalsEntryState
EndIf
CalltherunfunctionfortheSM
EndStartCaptureCitySM
DuringRequesting
DefineReturnEvent
IfES_ENTRYevent
QueryPACserviceforfrequencycode
Disablehalleffectinterrupt
IfcolorisRED
SendfrequencyguessoutwithREDstartnibble
ElseifcolorisBLUE
Sendfrequencyguessoutwithbluestartnibble
Send4more0x00bytesout
DisableSSIinterrupt
ElseifES_EXITevent
InitializeDETECT_TIMER
Else
EndIf
ReturnReturnEvent
EndDuringRequesting
DuringQuerying
DefineReturnEvent
IfES_ENTRYevent
Startdetecttimer
ElseifES_EXITevent
Else
IfDETECT_TIMERtimeout
IfThirdByteis0xAA
IfFourthByteisanACK
IfCounter=1(need2successfulevents)
IflocationisnotMiamiorBillings
ReturnEventisCITY_CAPTUREDevent
PostMasterSMwithReturnEvent
ElseiflocationisBillings
ReturnEventisATTACK_CITYevent
PostMasterSMwithReturnEvent
ElseiflocationisMiami
ReturnEventisATTACK_CITYevent
PostMasterSMwithReturnEvent
EndIf
Resetcounterto0
Else
Incrementcounter
EnableHALL_EFFECT_DEBOUNCE
EndIf
Else
Counterstaysthesame
EndIf
ReturnEventisRESPONSE_READYevent
PostMasterSMwithReturnEvent
Else
StartDETECT_TIMER
WritetoPACwithQUERY_BYTE
DisableSSIinterrupt
EndIf
EndIf
EndIf
ReturnReturnEvent
EndDuringQuerying
DuringWaiting
DefineReturnEvent
IfES_ENTRYevent
ElseifES_EXITevent
Stopmotors
Else
EndIf
ReturnReturnEvent
EndDuringWaiting
EndCaptureCitySM