andrew-gresyk on 2.1.1
andrew-gresyk on master
2.1.1 * added `Root::isActive(… (compare)
andrew-gresyk on 2.1.0
andrew-gresyk on experimental
andrew-gresyk on master
2.1.0 + added `activeSubState(… (compare)
andrew-gresyk on experimental
added activeSubState() on root … (compare)
andrew-gresyk on 2.0.0
andrew-gresyk on experimental
andrew-gresyk on master
2.0.0 - added `select<>()` tra… (compare)
andrew-gresyk on experimental
disabled snippets (compare)
andrew-gresyk on experimental
fixing GCC build (compare)
Hey @spiderkeys_gitlab
Thank you!
What you can do - is use event handling for handling errors.
There's an example in https://github.com/andrew-gresyk/HFSM2/blob/master/examples/advanced_event_handling/main.cpp for that.
You can have your FSM react()
to CheckForErrors
event before the recursive update()
#define HFSM2_ENABLE_PLANS
#include <hfsm2/machine.hpp>
#include <doctest/doctest.h>
template<typename E>
class CtrlBTempl {
public:
CtrlBTempl():
_machine(*this){};
E f(){return E{};};
private:
//states
struct RegionDisabledState;
struct RegionEnabledState;
struct ReadyState;
struct SuspendedState;
using Config = typename hfsm2::Config::ContextT<CtrlBTempl<E>&>;
using Machine = typename hfsm2::MachineT<Config>;
using HFSM = typename Machine::template PeerRoot< RegionDisabledState,
typename Machine::template Composite<RegionEnabledState,
ReadyState,
SuspendedState
>
>;
struct RegionDisabledState : HFSM::State {
using HFSM::State::react;
// error: ‘Control’ has not been declared
// void enter(Control& control){control._().f(); };
// void react(const E&, FullControl& control) {control.changeTo<RegionEnabledState>();}
};
struct RegionEnabledState : HFSM::State {
using HFSM::State::react;
};
struct ReadyState : HFSM::State {
using HFSM::State::react;
};
struct SuspendedState : HFSM::State {
using HFSM::State::react;
};
typename HFSM::Instance _machine;
};
TEST_CASE("template_context_test")
{
CtrlBTempl<int> cbt;
}
Adding using typename HFSM::State::PlanControl;
to the state declarations fixes the problem.
Also, keep in mind that both enter()
and exit()
take PlanControl
, not Control
.
Here's the complete list:
void entryGuard (GuardControl&)
void exitGuard (GuardControl&)
void enter (PlanControl&)
void reenter (PlanControl&)
void exit (PlanControl&)
void update (FullControl&)
void react (const TEvent&, FullControl&)
void planSucceeded(FullControl&)
void planFailed (FullControl&)