18static LOG_TAG TAG =
"State Manager";
22static int currentNotifyCode = 0;
25 lastState = currentState;
34 Log.
f(ID,
"UNHANDLED STATE!");
42 return &UnhandledState;
46 currentNotifyCode = code;
50 return this->notifyCode;
62 State_t *startingState = &entry;
65 Log.
d(TAG,
"Starting State Machine");
67 currentNotifyCode = 0;
71 State_t *queuedState = currentState->
run();
73 Log.
d(TAG,
"State returned code", currentNotifyCode);
76 setNextState(startingState);
78 setNextState(queuedState);
84 Log.
f(TAG,
"STATE MACHINE STOPPED");
Special logging functionality.
uint32_t TAG2NUM(LOG_TAG tagValue)
Return the final numbervalue of a LOG_TAG.
const char * LOG_TAG
Type definition of logging tags This typedef is necessary to allow for easier manipulation of code by...
Logging::Log_t Log
The global logging object.
Update, set, and get predefined pin values.
void setInternalValue(uint8_t Internal_Pin, int value)
Set the value of an internal pin.
@ E_RESTART
Special code that makes the state machine start from the first state again.
@ E_FATAL
Special code that makes the state machine completely stop.
void begin(State_t &entry)
Begin the state machine with a pointer to a state.
void d(LOG_TAG TAG, LOG_MSG message)
Log a string using a debug tag.
void f(LOG_TAG TAG, LOG_MSG message)
Log a string using a fatal tag.
The parent state structure to extend from to create more states.
int notifyCode
Used for receiving values from other states.
void notify(int notify)
Send a code to the next state.
virtual LOG_TAG getID(void)
Returns the LOG_TAG of the state.
virtual State_t * run(void)
Runs the state.
State_t * getLastState()
Get a pointer of the last state.
int getNotify(void)
Get the code of the previous state.