38static constexpr int8_t HSM_MAX_NEST_DEPTH = 5;
61 unsigned int stacksize = miosix::STACK_DEFAULT_FOR_PTHREAD,
62 miosix::Priority priority = miosix::MAIN_PRIORITY)
65 state = &T::state_top;
136 retState = (
static_cast<T*
>(
this)->*source)(event);
142 retState = (
static_cast<T*
>(
this)->*source)({
EV_EMPTY});
156 }
while (retState ==
SUPER);
165 if (retState ==
TRAN)
169 int8_t tempIndex = 0;
175 path[0] = this->
temp;
184 while (target != source)
191 (void)(
static_cast<T*
>(
this)->*target)({
EV_EMPTY});
210 if (source == target)
213 (
static_cast<T*
>(
this)->*source)({
EV_EXIT});
221 (
static_cast<T*
>(
this)->*target)({
EV_EMPTY});
228 if (source == target)
236 (
static_cast<T*
>(
this)->*source)({
EV_EMPTY});
240 if (this->temp == target)
243 (
static_cast<T*
>(
this)->*source)({
EV_EXIT});
247 else if (this->temp == path[0])
250 (
static_cast<T*
>(
this)->*source)({
EV_EXIT});
270 (
static_cast<T*
>(
this)->*path[1])({
EV_EMPTY});
274 while (retState ==
SUPER)
279 path[index] = this->
temp;
282 if (this->temp == source)
288 D(assert(index < (int8_t)HSM_MAX_NEST_DEPTH));
310 D(assert(index < HSM_MAX_NEST_DEPTH));
313 (
static_cast<T*
>(
this)->*source)({
EV_EXIT});
325 if (target == path[tempIndex])
331 index = tempIndex - 1;
339 }
while (tempIndex >= 0);
351 if ((
static_cast<T*
>(
this)->*target)(
354 (
static_cast<T*
>(
this)->*target)(
365 if (target == path[tempIndex])
369 index = tempIndex - 1;
377 }
while (tempIndex >= 0);
386 for (; index >= 0; index--)
387 (
static_cast<T*
>(
this)->*path[index])({
EV_ENTRY});
394 while ((
static_cast<T*
>(
this)->*target)({
EV_INIT}) ==
TRAN)
397 path[0] = this->
temp;
402 while (this->temp != target)
405 path[index] = this->
temp;
409 this->temp = path[0];
411 D(assert(index < (int8_t)HSM_MAX_NEST_DEPTH));
416 (
static_cast<T*
>(
this)->*path[index])({
EV_ENTRY});
418 }
while (index >= (int8_t)0);
425 this->state = target;
467 statePath[0] = this->
temp;
476 while (this->temp != target && index < HSM_MAX_NEST_DEPTH - 1)
481 statePath[index] = this->
temp;
487 D(assert(index < HSM_MAX_NEST_DEPTH));
494 this->temp = statePath[0];
500 (void)(
static_cast<T*
>(
this)->*statePath[index])({
EV_ENTRY});
502 }
while (index >= 0);
505 target = statePath[0];
508 retState = (
static_cast<T*
>(
this)->*
temp)({
EV_INIT});
512 }
while (retState ==
TRAN);
514 this->state = target;
virtual bool start()
Start the thread associated with this active object.
HSM(StateHandler initialState, unsigned int stacksize=miosix::STACK_DEFAULT_FOR_PTHREAD, miosix::Priority priority=miosix::MAIN_PRIORITY)
State state_top(const Event &)
State(T::* StateHandler)(const Event &)
void handleEvent(const Event &event) override
Makes the current state handle the event and changes the state accordingly.
State transition(StateHandler nextState)
Performs a transition to the specified state.
bool testState(StateHandler testState)
Test if the state machine is in the specified state.
State tranSuper(StateHandler superState)
Performs a transaction to the specified super state.
bool start() override
Start the thread associated with this active object.
This file includes all the types the logdecoder script will decode.
@ UNHANDLED
Event unhandled.
@ TRAN
A transition to another state was taken.
@ SUPER
A transition to a parent state was taken.