tsm  0.1.0
Classes | Typedefs | Variables
tsm Namespace Reference

Classes

struct  wrap_type_impl
 
struct  wrap_type_impl< Wrapper, std::tuple< Ts... > >
 
struct  append_unique_impl
 
struct  append_unique_impl< T, std::tuple<> >
 
struct  append_unique_impl< T, std::tuple< Ts... > >
 
struct  unique_tuple_impl
 
struct  unique_tuple_impl< std::tuple<>, std::tuple< Us... > >
 
struct  unique_tuple_impl< std::tuple< T, Ts... >, std::tuple< Us... > >
 
struct  unique_tuple
 
struct  tuple_to_variant_impl
 
struct  tuple_to_variant_impl< std::tuple< Ts... > >
 
struct  Event
 
struct  wrapped_event
 
struct  BaseTransition
 
struct  Transition
 
struct  ClockTickEvent
 
struct  ClockedTransition
 
struct  get_states_impl
 
struct  get_states_impl< Tuple >
 
struct  get_states_impl< Tuple, First, Rest... >
 
struct  get_states
 
struct  get_states< std::tuple< Ts... > >
 
struct  transition_map_helper
 
struct  is_transition_match
 
struct  is_transition_match< Transition< From, Event, To, Action, Guard >, From, Event >
 
struct  transition_map_helper< From, Event, std::tuple< Transitions... >, Index, std::enable_if_t<(Index< sizeof...(Transitions))> >
 
struct  transition_map_helper< From, Event, std::tuple< Transitions... >, Index, std::enable_if_t<!(Index< sizeof...(Transitions))> >
 
struct  TransitionMap
 
struct  has_exit
 
struct  has_exit< T, Event, std::void_t< std::disjunction< std::is_invocable< decltype(&T::exit), T >, std::is_invocable< decltype(&T::exit), T, T & >, std::is_invocable< decltype(&T::exit), T, Event > > > >
 
struct  has_entry
 
struct  has_entry< T, Event, std::void_t< std::disjunction< std::is_invocable< decltype(&T::entry), T >, std::is_invocable< decltype(&T::entry), T & >, std::is_invocable< decltype(&T::entry), T, Event > > > >
 
struct  has_guard
 
struct  has_guard< T, Event, std::void_t< std::disjunction< std::is_invocable< decltype(&T::guard), T >, std::is_invocable< decltype(&T::guard), T & >, std::is_invocable< decltype(&T::guard), T, Event > > > >
 
struct  has_action
 
struct  has_action< T, Event, std::void_t< std::disjunction< std::is_invocable< decltype(&T::action), T >, std::is_invocable< decltype(&T::action), T & >, std::is_invocable< decltype(&T::action), T, Event > > > >
 
struct  has_transitions
 
struct  has_transitions< T, std::void_t< typename T::transitions > >
 
struct  has_handle_method
 
struct  has_handle_method< State, Event, Context, std::void_t< decltype(std::declval< State >().handle(std::declval< Context & >(), std::declval< Event >()))> >
 
struct  is_hsm_trait
 
struct  is_hsm_trait< T, std::void_t< decltype(T::is_hsm)> >
 
struct  is_clocked_hsm
 
struct  is_clocked_hsm< T, std::void_t< decltype(T::is_clocked_hsm)> >
 
struct  Hsm
 
struct  make_hsm
 
struct  make_hsm< T, std::enable_if_t<!is_state_trait_v< T > > >
 
struct  wrap_transition
 
struct  wrap_transitions
 
struct  wrap_transitions< std::tuple< Ts... > >
 
struct  ClockedHsm
 
struct  make_hsm< T, std::enable_if_t< is_state_trait_v< T > > >
 
struct  OrthogonalExecutionPolicy
 
struct  EventQueueT
 
class  FreeRTOSMutex
 
class  FreeRTOSConditionVariable
 
struct  FreeRTOSClock
 
struct  ThreadedExecutionPolicy
 
struct  get_events_from_hsm
 
struct  get_events_from_transition
 
struct  aggregate_events
 
struct  aggregate_events< std::tuple< Transitions... > >
 
struct  aggregate_events< std::tuple<> >
 
struct  get_events_from_hsm< HsmType, std::enable_if_t< has_transitions_v< HsmType > > >
 
struct  get_events_from_hsm< HsmType, std::enable_if_t<!has_transitions_v< HsmType > > >
 
struct  SingleThreadedExecutionPolicy
 
struct  BlockingObserverT
 
struct  CallbackObserver
 
struct  ThreadedExecWithObserver
 
struct  Timer
 Helper to implement a Timed Execution Policy. More...
 
struct  IntervalTimer
 
struct  PeriodicSleepTimer
 
struct  RealtimeConfigurator
 
struct  RealtimeExecutionPolicy
 
struct  PeriodicExecutionPolicy
 
struct  RealtimePeriodicExecutionPolicy
 
struct  ConcurrentExecutionPolicy
 
struct  make_concurrent_hsm
 

Typedefs

template<typename Context , template< class > class Policy = SingleThreadedExecutionPolicy>
using SingleThreadedHsm = Policy< Context >
 
template<typename Context , template< class > class Policy = ThreadedExecutionPolicy>
using ThreadedHsm = Policy< Context >
 
template<typename Context , template< class > class Policy = PeriodicExecutionPolicy>
using PeriodicHsm = Policy< Context >
 
template<typename Context , template< class > class Policy = RealtimePeriodicExecutionPolicy>
using RealtimePeriodicHsm = Policy< Context >
 
template<typename Context , template< class > class Policy = RealtimeExecutionPolicy>
using RealtimeHsm = Policy< Context >
 
template<template< typename > class Policy = ThreadedExecutionPolicy, typename... Contexts>
using ConcurrentHsm = make_concurrent_hsm_t< Policy, Contexts... >
 
template<template< class > class Wrapper, typename Tuple >
using wrap_type = typename wrap_type_impl< Wrapper, Tuple >::type
 
template<typename T , typename Tuple >
using append_unique = typename append_unique_impl< T, Tuple >::type
 
template<typename Ts >
using unique_tuple_t = typename unique_tuple< Ts >::type
 
template<typename Tuple >
using tuple_to_variant_t = typename tuple_to_variant_impl< Tuple >::type
 
template<typename... Ts>
using get_states_t = typename get_states< Ts... >::type
 
template<typename From , typename Event , typename Transitions >
using find_transition_t = typename TransitionMap< From, Event, Transitions >::type
 
template<typename T >
using has_transitions_t = typename has_transitions< T >::type
 
template<typename T >
using is_hsm_trait_t = typename is_hsm_trait< T >::type
 
template<typename T >
using make_hsm_t = typename make_hsm< T >::type
 
template<typename T >
using wrap_transition_t = typename wrap_transition< T >::type
 
template<typename... Ts>
using wrap_transitions_t = typename wrap_transitions< Ts... >::type
 
template<typename Event >
using EventQueue = EventQueueT< Event, FreeRTOSMutex, FreeRTOSConditionVariable >
 
template<typename HsmType >
using get_events_t = unique_tuple_t< typename get_events_from_hsm< HsmType >::type >
 
using BlockingObserver = BlockingObserverT< FreeRTOSMutex, FreeRTOSConditionVariable >
 
template<typename Context >
using ThreadedBlockingObserver = ThreadedExecWithObserver< Context, BlockingObserver >
 
template<template< typename > class Policy = ThreadedExecutionPolicy, typename... Ts>
using make_concurrent_hsm_t = typename make_concurrent_hsm< Policy, Ts... >::type
 

Variables

template<typename State , typename Event , typename Transitions >
constexpr bool has_valid_transition_v
 
template<typename T , typename Event >
constexpr bool has_exit_v = has_exit<T, Event>::value
 
template<typename T , typename Event >
constexpr bool has_entry_v = has_entry<T, Event>::value
 
template<typename T , typename Event >
constexpr bool has_guard_v = has_guard<T, Event>::value
 
template<typename T , typename Event >
constexpr bool has_action_v = has_action<T, Event>::value
 
template<typename T >
constexpr bool has_transitions_v = has_transitions<T>::value
 
template<typename State , typename Event , typename Context >
constexpr bool has_handle_method_v
 
template<typename T >
constexpr bool is_hsm_trait_v = is_hsm_trait<T>::value
 
template<typename T >
constexpr bool is_state_trait_v
 
template<typename T >
constexpr bool is_clocked_hsm_v = is_clocked_hsm<T>::value
 
constexpr int MaxEvents = 10
 

Typedef Documentation

◆ append_unique

template<typename T , typename Tuple >
using tsm::append_unique = typedef typename append_unique_impl<T, Tuple>::type

◆ BlockingObserver

◆ ConcurrentHsm

template<template< typename > class Policy = ThreadedExecutionPolicy, typename... Contexts>
using tsm::ConcurrentHsm = typedef make_concurrent_hsm_t<Policy, Contexts...>

◆ EventQueue

template<typename Event >
using tsm::EventQueue = typedef EventQueueT<Event, FreeRTOSMutex, FreeRTOSConditionVariable>

◆ find_transition_t

template<typename From , typename Event , typename Transitions >
using tsm::find_transition_t = typedef typename TransitionMap<From, Event, Transitions>::type

◆ get_events_t

template<typename HsmType >
using tsm::get_events_t = typedef unique_tuple_t<typename get_events_from_hsm<HsmType>::type>

◆ get_states_t

template<typename... Ts>
using tsm::get_states_t = typedef typename get_states<Ts...>::type

◆ has_transitions_t

template<typename T >
using tsm::has_transitions_t = typedef typename has_transitions<T>::type

◆ is_hsm_trait_t

template<typename T >
using tsm::is_hsm_trait_t = typedef typename is_hsm_trait<T>::type

◆ make_concurrent_hsm_t

template<template< typename > class Policy = ThreadedExecutionPolicy, typename... Ts>
using tsm::make_concurrent_hsm_t = typedef typename make_concurrent_hsm<Policy, Ts...>::type

◆ make_hsm_t

template<typename T >
using tsm::make_hsm_t = typedef typename make_hsm<T>::type

◆ PeriodicHsm

template<typename Context , template< class > class Policy = PeriodicExecutionPolicy>
using tsm::PeriodicHsm = typedef Policy<Context>

A Periodic state machine. This state machine is driven by a periodic timer. E.g. template<typename Context> using MyPeriodic1HzPolicy = PeriodicExecutionPolicy<Context, ThreadedExecutionPolicy, PeriodicTimer<std::chrono::steady_clock, std::chrono::seconds>>; using MyPeriodic1HzHsm = MyPeriodic1HzPolicy<MyContext>; MyPeriodic1HzHsm sm; sm.start(); This will start the state machine and send ClockTick events to the state context every 1 second. To stop the state machine, call sm.stop();

◆ RealtimeHsm

template<typename Context , template< class > class Policy = RealtimeExecutionPolicy>
using tsm::RealtimeHsm = typedef Policy<Context>

◆ RealtimePeriodicHsm

template<typename Context , template< class > class Policy = RealtimePeriodicExecutionPolicy>
using tsm::RealtimePeriodicHsm = typedef Policy<Context>

Real-time state machine. This state machine is driven by a periodic timer. E.g. template<typename Context> using MyRealtimePeriodic1KhzPolicy = RealtimePeriodicExecutionPolicy<Context, RealtimeExecutionPolicy, PeriodicTimer<std::chrono::steady_clock, std::chrono::milliseconds>>; using MyRealtimePeriodic1KhzHsm = MyRealtimePeriodic1KhzPolicy<MyContext>; MyRealtimePeriodic1KhzHsm sm; sm.start();

◆ SingleThreadedHsm

template<typename Context , template< class > class Policy = SingleThreadedExecutionPolicy>
using tsm::SingleThreadedHsm = typedef Policy<Context>

A "simple" state machine. It executes in the context of the parent thread. The user is expected to instantiate this with their state machine context. Use it like this:

  1. The first step is to create your own Context type. struct MyContext { // States (structs) struct State1 {}; struct State2 {}; // Events (structs) struct Event1 {}; // e.g. transition where using transitions = std::tuple<Transition<State1, Event1, State2>>; };
  2. To create any statemachine, wrap an execution policy around the context type. Here we use the SingleThreadedExecutionPolicy.
  3. Now that you have your own SingleThreadedHsm, instantiate an object of your state machine type. SingleThreadedHsm<MyContext> sm;
  4. Send events to it using the sendEvent method. sm.send_event(MyContext::Event1{});
  5. To process the event, call the step method sm.step();
  6. To immediately process the event, call the handle() method sm.handle(MyContext::Event1{});

◆ ThreadedBlockingObserver

template<typename Context >
using tsm::ThreadedBlockingObserver = typedef ThreadedExecWithObserver<Context, BlockingObserver>

Execution policy that uses a BlockingObserver. This is illustrative of chaining policies together.

◆ ThreadedHsm

template<typename Context , template< class > class Policy = ThreadedExecutionPolicy>
using tsm::ThreadedHsm = typedef Policy<Context>

An Asynchronous state machine. Event processing is done in a separate thread. Usage is similar to SingleThreadedHsm above. The final call to "step" is not required. The state machine is blocked waiting on the next event to be processed. As soon as an event is sent to it (sendEvent), the client/parent thread returns and the event is processed in a separate thread. This design forces events to be immediately processed as soon as the HsmDefinition is done processing the previous event. It also simplifies the interface in that only one call to sendEvent is required.

◆ tuple_to_variant_t

template<typename Tuple >
using tsm::tuple_to_variant_t = typedef typename tuple_to_variant_impl<Tuple>::type

◆ unique_tuple_t

template<typename Ts >
using tsm::unique_tuple_t = typedef typename unique_tuple<Ts>::type

◆ wrap_transition_t

template<typename T >
using tsm::wrap_transition_t = typedef typename wrap_transition<T>::type

◆ wrap_transitions_t

template<typename... Ts>
using tsm::wrap_transitions_t = typedef typename wrap_transitions<Ts...>::type

◆ wrap_type

template<template< class > class Wrapper, typename Tuple >
using tsm::wrap_type = typedef typename wrap_type_impl<Wrapper, Tuple>::type

Variable Documentation

◆ has_action_v

template<typename T , typename Event >
constexpr bool tsm::has_action_v = has_action<T, Event>::value
inlineconstexpr

◆ has_entry_v

template<typename T , typename Event >
constexpr bool tsm::has_entry_v = has_entry<T, Event>::value
inlineconstexpr

◆ has_exit_v

template<typename T , typename Event >
constexpr bool tsm::has_exit_v = has_exit<T, Event>::value
inlineconstexpr

◆ has_guard_v

template<typename T , typename Event >
constexpr bool tsm::has_guard_v = has_guard<T, Event>::value
inlineconstexpr

◆ has_handle_method_v

template<typename State , typename Event , typename Context >
constexpr bool tsm::has_handle_method_v
inlineconstexpr
Initial value:
=
has_handle_method<State, Event, Context>::value

◆ has_transitions_v

template<typename T >
constexpr bool tsm::has_transitions_v = has_transitions<T>::value
inlineconstexpr

◆ has_valid_transition_v

template<typename State , typename Event , typename Transitions >
constexpr bool tsm::has_valid_transition_v
inlineconstexpr
Initial value:
=
!std::is_same_v<typename TransitionMap<State, Event, Transitions>::type,
void>

◆ is_clocked_hsm_v

template<typename T >
constexpr bool tsm::is_clocked_hsm_v = is_clocked_hsm<T>::value
inlineconstexpr

◆ is_hsm_trait_v

template<typename T >
constexpr bool tsm::is_hsm_trait_v = is_hsm_trait<T>::value
inlineconstexpr

◆ is_state_trait_v

template<typename T >
constexpr bool tsm::is_state_trait_v
inlineconstexpr
Initial value:
=
std::conjunction_v<has_transitions<T>, std::negation<is_hsm_trait<T>>>

◆ MaxEvents

constexpr int tsm::MaxEvents = 10
constexpr