tin  1.5.9
tsm.h File Reference

Main include for authoring and running hierarchical state machines. More...

#include <functional>
#include <array>
#include <concepts>
#include <cstddef>
#include <cstdint>
#include <new>
#include <tuple>
#include <type_traits>
#include <utility>
#include "tsm/platform/profile.h"
#include "tsm/policies.h"
#include "tsm/runtime/static_ring.h"
#include "tsm/ticks.h"
#include "tsm/transition.h"
#include "tsm/type_list.h"
#include "tsm/core_algorithms.h"
#include "tsm/linux.h"
#include "tsm/freertos.h"
#include "tsm/runtime.h"
Include dependency graph for tsm.h:

Go to the source code of this file.

Namespaces

 tsm
 
 tsm::detail
 

Macros

#define TSM_TRANSITION(Name, From, Event, To)
 
#define TSM_TRANSITION_ACTION(Name, From, Event, To, Action)
 
#define TSM_TRANSITION_GUARD(Name, From, Event, To, Guard)
 
#define TSM_TRANSITION_GUARD_ACTION(Name, From, Event, To, Guard, Action)
 
#define TSM_TRANSITIONS(...)   using transitions = ::tsm::Ts<__VA_ARGS__>
 

Typedefs

template<typename From , typename Event , typename TransitionList >
using tsm::detail::find_transition_t = typename matching_transition< From, Event, TransitionList >::type
 find transition More...
 
template<typename T >
using tsm::detail::context_type_of_t = typename context_type_of< T >::type
 
template<typename T >
using tsm::detail::deferred_of_t = typename deferred_of< T >::type
 
template<typename DeferredList >
using tsm::detail::deferred_event_list_t = typename deferred_event_list< DeferredList >::type
 
template<typename Events , std::size_t Capacity>
using tsm::detail::deferred_queue_storage_t = typename deferred_queue_storage< Events, Capacity >::type
 
template<typename Definition >
using tsm::detail::transition_entries_t = filter_type_list_t< is_transition, as_type_list_t< Definition > >
 
template<typename Definition >
using tsm::detail::synchronization_entries_t = filter_type_list_t< is_synchronization_rule, as_type_list_t< Definition > >
 
template<typename T >
using tsm::detail::make_hsm_t = typename make_hsm< T >::type
 
template<typename T >
using tsm::detail::wrap_transition_t = typename wrap_transition< T >::type
 
template<typename T >
using tsm::detail::wrap_transitions_t = typename wrap_transitions< as_type_list_t< T > >::type
 
template<typename T >
using tsm::detail::synchronization_entries_of_t = typename synchronization_entries_of< T >::type
 
template<typename Join , typename Rules >
using tsm::detail::join_to_rule_for_t = typename join_to_rule_for< Join, Rules >::type
 
template<typename HsmType >
using tsm::detail::get_events_t = unique_tuple_t< typename get_events_from_hsm< HsmType >::type >
 
template<typename HsmType , std::size_t Capacity>
using tsm::detail::TickScheduler = tick_scheduler< HsmType, Capacity >
 
template<typename... Tasks>
using tsm::thread_executor = detail::thread_executor< Tasks... >
 
template<typename... Tasks>
using tsm::realtime_thread_executor = detail::realtime_thread_executor< Tasks... >
 
template<typename... Deferred>
using tsm::deferred_events = detail::type_list< Deferred... >
 
template<typename... Rules>
using tsm::synchronization = detail::type_list< Rules... >
 
template<typename... TransitionEntries>
using tsm::transition_table = detail::type_list< TransitionEntries... >
 
template<typename... TransitionEntries>
using tsm::Ts = transition_table< TransitionEntries... >
 

Functions

template<typename Callable , typename Context , typename Event >
bool tsm::detail::invoke_guard (Callable &&callable, Context &ctx, Event &e)
 
template<typename Callable , typename Context , typename Event >
void tsm::detail::invoke_action (Callable &&callable, Context &ctx, Event &e)
 
template<detail::transition_like... TransitionEntries>
consteval auto tsm::transitions (TransitionEntries...)
 

Variables

template<typename State , typename Event , typename TransitionList >
constexpr bool tsm::detail::has_valid_transition_v
 variable template to check for the existence of a valid transition More...
 
template<typename State , typename Event , typename TransitionList >
concept tsm::detail::transition_available
 
template<typename T >
concept tsm::detail::state_has_exit
 
template<typename T >
concept tsm::detail::state_has_entry
 
template<typename T >
concept tsm::detail::state_has_guard
 
template<typename T >
concept tsm::detail::state_has_action
 
template<typename T >
concept tsm::detail::has_hierarchy_c
 
template<typename T >
concept tsm::detail::has_deferred_type_c
 
template<typename T >
constexpr bool tsm::detail::has_transitions_v = has_transitions_c<T>
 
template<typename State , typename Event , typename Context >
concept tsm::detail::state_handles_event
 
template<typename T >
concept tsm::detail::hsm_like
 
template<typename T >
constexpr bool tsm::detail::is_hsm_trait_v = hsm_like<T>
 
template<typename T >
constexpr bool tsm::detail::is_state_trait_v = has_transitions_c<T> && !hsm_like<T>
 Define a helper to check for 'from' and 'to' types in transitions,. More...
 
template<typename T >
concept tsm::detail::clocked_hsm_like
 
template<typename T >
constexpr bool tsm::detail::is_clocked_hsm_v = clocked_hsm_like<T>
 
template<typename... >
constexpr bool tsm::detail::dependent_false_v = false
 
template<typename Callable , typename Context , typename Event >
concept tsm::detail::guard_with_context_event
 
template<typename Callable , typename Context >
concept tsm::detail::guard_with_context
 
template<typename Callable , typename Event >
concept tsm::detail::guard_with_event
 
template<typename Callable >
concept tsm::detail::guard_without_args
 
template<typename Callable , typename Context , typename Event >
concept tsm::detail::transition_guard
 
template<typename Callable , typename Context , typename Event >
concept tsm::detail::action_with_context_event
 
template<typename Callable , typename Context >
concept tsm::detail::action_with_context
 
template<typename Callable , typename Event >
concept tsm::detail::action_with_event
 
template<typename Callable >
concept tsm::detail::action_without_args
 
template<typename Callable , typename Context , typename Event >
concept tsm::detail::transition_action
 

Detailed Description

Main include for authoring and running hierarchical state machines.

Defines tsm::hsm<T> and the runtime machinery for transition selection, hierarchy traversal, entry/exit sequencing, history, deferred events, orthogonal regions, synchronization pseudostates, erased local events, and tick-driven delayed events.

Macro Definition Documentation

◆ TSM_TRANSITION

#define TSM_TRANSITION (   Name,
  From,
  Event,
  To 
)
Value:
struct Name { \
using from = From; \
using event = Event; \
using to = To; \
}

◆ TSM_TRANSITION_ACTION

#define TSM_TRANSITION_ACTION (   Name,
  From,
  Event,
  To,
  Action 
)
Value:
struct Name { \
using from = From; \
using event = Event; \
using to = To; \
static constexpr auto action = Action; \
}

◆ TSM_TRANSITION_GUARD

#define TSM_TRANSITION_GUARD (   Name,
  From,
  Event,
  To,
  Guard 
)
Value:
struct Name { \
using from = From; \
using event = Event; \
using to = To; \
static constexpr auto guard = Guard; \
}

◆ TSM_TRANSITION_GUARD_ACTION

#define TSM_TRANSITION_GUARD_ACTION (   Name,
  From,
  Event,
  To,
  Guard,
  Action 
)
Value:
struct Name { \
using from = From; \
using event = Event; \
using to = To; \
static constexpr auto guard = Guard; \
static constexpr auto action = Action; \
}

◆ TSM_TRANSITIONS

#define TSM_TRANSITIONS (   ...)    using transitions = ::tsm::Ts<__VA_ARGS__>