Created
June 19, 2019 18:18
-
-
Save dheeptuck/aa114c991c6903bae45f483f3336ec62 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
void StateMachineHandler() | |
{ | |
int idx = 0; | |
if(EVT_NO_EVENT != eCurrentEvent) | |
{ | |
for(;idx < sizeof(stStm)/sizeof(stStmRow); idx++) | |
{ | |
if( (stStm[idx].pSrcState == stCurrentState) && | |
(stStm[idx].eEvt == eCurrentEvent)) | |
{ | |
/// Clear event | |
eCurrentEvent = EVT_NO_EVENT; | |
/// Notify the state that the exit is imminent; | |
bIsStateAboutToExit = true; | |
stCurrentState(); | |
/// Move to new state | |
stCurrentState = stStm[idx].pDestState; | |
/// Flag that this is the first entry to the state | |
bIsStateFirstEntry = true; | |
} | |
} | |
} | |
if(NULL != stCurrentState) | |
{ | |
/// Run the state | |
stCurrentState(); | |
/// Unfllag first entry | |
bIsStateFirstEntry = false; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment