Skip to content

Advanced Plans

Andrew Gresyk edited this page Apr 1, 2022 · 4 revisions

Plans

  1. Plans are sequences of transitions.

  2. Plans are attached to regions.

  3. Planned transitions link origin and destination states.

  4. Planned transitions can have payloads.

  5. Planned transitions are triggered when origin state succeeds.

Tests

  1. Enable plan support

    #define FFSM2_ENABLE_PLANS
    #include <ffsm2/machine.hpp>
  1. Set maximum number of tasks across all plans of the FSM instance

    using Config = ffsm2::Config
                        ::TaskCapacityN<N>;
    
    using M = ffsm2::MachineT<Config>;

Control Methods

Method Description
CPlan PlanControl::plan() const;
Plan PlanControl::plan();
Access constant plan
Access mutable plan
void PlanControl::succeed();
void PlanControl::fail();
Called when all [Plans](../wiki/Advanced-Plans) tasks succeeded
Called when all plan tasks failed

Plan Methods

Method Description
operator CPlan::bool() const; Check if plan isn't empty
CIterator CPlan::first() const;
Iterator Plan::first();
Range-based for loop
iteration over plan tasks
void Plan::clear(); Clear plan
bool Plan::change(const StateID, const StateID);
bool Plan::change<TOrigin>(const StateID);
bool Plan::change<TOrigin, TDestination>();
Append a default transition
to the plan
bool Plan::changeWith(const StateID, const StateID, const Payload&);
bool Plan::changeWith<TOrigin>(const StateID, const Payload&);
bool Plan::changeWith<TOrigin, TDestination>(const Payload&);
Append a default transition
with const payload
bool Plan::changeWith(const StateID, const StateID, Payload&&);
bool Plan::changeWith<TOrigin>(const StateID, Payload&&);
bool Plan::changeWith<TOrigin, TDestination>(Payload&&);
Append a default transition
with moved payload