SMACC2
Loading...
Searching...
No Matches
Public Member Functions | List of all members
smacc2::SmaccStateMachineBase< DerivedStateMachine, InitialStateType > Struct Template Reference

State Machine. More...

#include <smacc_state_machine_base.hpp>

Inheritance diagram for smacc2::SmaccStateMachineBase< DerivedStateMachine, InitialStateType >:
Inheritance graph
Collaboration diagram for smacc2::SmaccStateMachineBase< DerivedStateMachine, InitialStateType >:
Collaboration graph

Public Member Functions

 SmaccStateMachineBase (my_context ctx, SignalDetector *signalDetector)
 
virtual ~SmaccStateMachineBase ()
 
void reset () override
 
void stop () override
 
void eStop () override
 
void initiate_impl () override
 
- Public Member Functions inherited from smacc2::ISmaccStateMachine
 ISmaccStateMachine (std::string stateMachineName, SignalDetector *signalDetector)
 
virtual ~ISmaccStateMachine ()
 
virtual void reset ()
 
virtual void stop ()
 
virtual void eStop ()
 
template<typename TOrthogonal >
TOrthogonal * getOrthogonal ()
 
const std::map< std::string, std::shared_ptr< smacc2::ISmaccOrthogonal > > & getOrthogonals () const
 
template<typename SmaccComponentType >
void requiresComponent (SmaccComponentType *&storage, bool throwsException=false)
 
template<typename EventType >
void postEvent (EventType *ev, EventLifeTime evlifetime=EventLifeTime::ABSOLUTE)
 
template<typename EventType >
void postEvent (EventLifeTime evlifetime=EventLifeTime::ABSOLUTE)
 
template<typename T >
bool getGlobalSMData (std::string name, T &ret)
 
template<typename T >
void setGlobalSMData (std::string name, T value)
 
template<typename StateField , typename BehaviorType >
void mapBehavior ()
 
std::string getStateMachineName ()
 
void state_machine_visualization ()
 
std::shared_ptr< SmaccStateInfogetCurrentStateInfo ()
 
void publishTransition (const SmaccTransitionInfo &transitionInfo)
 
virtual void onInitialize ()
 this function should be implemented by the user to create the orthogonals More...
 
void getTransitionLogHistory (const std::shared_ptr< rmw_request_id_t > request_header, const std::shared_ptr< smacc2_msgs::srv::SmaccGetTransitionHistory::Request > req, std::shared_ptr< smacc2_msgs::srv::SmaccGetTransitionHistory::Response > res)
 
template<typename TSmaccSignal , typename TMemberFunctionPrototype , typename TSmaccObjectType >
boost::signals2::connection createSignalConnection (TSmaccSignal &signal, TMemberFunctionPrototype callback, TSmaccObjectType *object)
 
void disconnectSmaccSignalObject (void *object)
 
template<typename StateType >
void notifyOnStateEntryStart (StateType *state)
 
template<typename StateType >
void notifyOnStateEntryEnd (StateType *state)
 
template<typename StateType >
void notifyOnRuntimeConfigured (StateType *state)
 
template<typename StateType >
void notifyOnStateExitting (StateType *state)
 
template<typename StateType >
void notifyOnStateExited (StateType *state)
 
template<typename StateType >
void notifyOnRuntimeConfigurationFinished (StateType *state)
 
uint64_t getCurrentStateCounter () const
 
ISmaccStategetCurrentState () const
 
const SmaccStateMachineInfogetStateMachineInfo ()
 
template<typename InitialStateType >
void buildStateMachineInfo ()
 
rclcpp::Node::SharedPtr getNode ()
 
rclcpp::Logger getLogger ()
 
std::recursive_mutex & getMutex ()
 

Additional Inherited Members

- Protected Member Functions inherited from smacc2::ISmaccStateMachine
void checkStateMachineConsistence ()
 
void initializeROS (std::string smshortname)
 
void onInitialized ()
 
template<typename TOrthogonal >
void createOrthogonal ()
 
- Protected Attributes inherited from smacc2::ISmaccStateMachine
rclcpp::Node::SharedPtr nh_
 
rclcpp::TimerBase::SharedPtr timer_
 
rclcpp::Publisher< smacc2_msgs::msg::SmaccStateMachine >::SharedPtr stateMachinePub_
 
rclcpp::Publisher< smacc2_msgs::msg::SmaccStatus >::SharedPtr stateMachineStatusPub_
 
rclcpp::Publisher< smacc2_msgs::msg::SmaccTransitionLogEntry >::SharedPtr transitionLogPub_
 
rclcpp::Service< smacc2_msgs::srv::SmaccGetTransitionHistory >::SharedPtr transitionHistoryService_
 
std::vector< ISmaccState * > currentState_
 
std::shared_ptr< SmaccStateInfocurrentStateInfo_
 
smacc2_msgs::msg::SmaccStatus status_msg_
 
std::map< std::string, std::shared_ptr< smacc2::ISmaccOrthogonal > > orthogonals_
 
std::shared_ptr< SmaccStateMachineInfostateMachineInfo_
 

Detailed Description

template<typename DerivedStateMachine, typename InitialStateType>
struct smacc2::SmaccStateMachineBase< DerivedStateMachine, InitialStateType >

State Machine.

Definition at line 30 of file smacc_state_machine_base.hpp.

Constructor & Destructor Documentation

◆ SmaccStateMachineBase()

template<typename DerivedStateMachine , typename InitialStateType >
smacc2::SmaccStateMachineBase< DerivedStateMachine, InitialStateType >::SmaccStateMachineBase ( my_context  ctx,
SignalDetector signalDetector 
)
inline

Definition at line 36 of file smacc_state_machine_base.hpp.

37 : ISmaccStateMachine(smacc2::utils::cleanShortTypeName<DerivedStateMachine>(), signalDetector),
39 DerivedStateMachine, InitialStateType, SmaccFifoScheduler, SmaccAllocator>(ctx)
40 {
41 }
ISmaccStateMachine(std::string stateMachineName, SignalDetector *signalDetector)
boost::statechart::fifo_scheduler< SmaccFifoWorker, SmaccAllocator > SmaccFifoScheduler
std::allocator< boost::statechart::none > SmaccAllocator

◆ ~SmaccStateMachineBase()

template<typename DerivedStateMachine , typename InitialStateType >
virtual smacc2::SmaccStateMachineBase< DerivedStateMachine, InitialStateType >::~SmaccStateMachineBase ( )
inlinevirtual

Definition at line 43 of file smacc_state_machine_base.hpp.

44 {
45 //updateCurrentState<InitialStateType>(false);
46 }

Member Function Documentation

◆ eStop()

template<typename DerivedStateMachine , typename InitialStateType >
void smacc2::SmaccStateMachineBase< DerivedStateMachine, InitialStateType >::eStop ( )
inlineoverridevirtual

Reimplemented from smacc2::ISmaccStateMachine.

Definition at line 61 of file smacc_state_machine_base.hpp.

62 {
64 this->terminate();
65 }

References smacc2::ISmaccStateMachine::eStop().

Here is the call graph for this function:

◆ initiate_impl()

template<typename DerivedStateMachine , typename InitialStateType >
void smacc2::SmaccStateMachineBase< DerivedStateMachine, InitialStateType >::initiate_impl ( )
inlineoverride

Definition at line 67 of file smacc_state_machine_base.hpp.

68 {
69 globalNh_ = this->getNode();
70
71 // this is before because this creates orthogonals
72 this->onInitialize();
73
74 RCLCPP_INFO(getLogger(), "[SmaccStateMachine] Introspecting state machine via typeWalker");
75 this->buildStateMachineInfo<InitialStateType>();
76
77 RCLCPP_INFO(getLogger(), "[SmaccStateMachine] initiate_impl");
78 auto shortname = smacc2::utils::cleanShortTypeName(typeid(DerivedStateMachine));
79
80 this->initializeROS(shortname);
81
82 RCLCPP_INFO(getLogger(), "[SmaccStateMachine] Initializing ROS communication mechanisms");
83 this->onInitialized();
84
85 // publish startup state machine transition info
86 auto transitionInfo = std::make_shared<SmaccTransitionInfo>();
87 transitionInfo->destinyState = this->stateMachineInfo_->getState<InitialStateType>();
88 this->publishTransition(*transitionInfo);
89
90 RCLCPP_INFO(getLogger(), "[SmaccStateMachine] Initializing state machine");
91 sc::state_machine<DerivedStateMachine, InitialStateType, SmaccAllocator>::initiate();
92 }
void publishTransition(const SmaccTransitionInfo &transitionInfo)
rclcpp::Node::SharedPtr getNode()
virtual void onInitialize()
this function should be implemented by the user to create the orthogonals
void initializeROS(std::string smshortname)
std::shared_ptr< SmaccStateMachineInfo > stateMachineInfo_
rclcpp::Node::SharedPtr globalNh_
Definition: reflection.cpp:28
std::string cleanShortTypeName()
Definition: common.hpp:61

References smacc2::utils::cleanShortTypeName(), smacc2::ISmaccStateMachine::getLogger(), smacc2::ISmaccStateMachine::getNode(), smacc2::introspection::globalNh_, smacc2::ISmaccStateMachine::initializeROS(), smacc2::ISmaccStateMachine::onInitialize(), smacc2::ISmaccStateMachine::onInitialized(), smacc2::ISmaccStateMachine::publishTransition(), and smacc2::ISmaccStateMachine::stateMachineInfo_.

Here is the call graph for this function:

◆ reset()

template<typename DerivedStateMachine , typename InitialStateType >
void smacc2::SmaccStateMachineBase< DerivedStateMachine, InitialStateType >::reset ( )
inlineoverridevirtual

Reimplemented from smacc2::ISmaccStateMachine.

Definition at line 48 of file smacc_state_machine_base.hpp.

49 {
51 this->terminate();
52 smacc2::run<DerivedStateMachine>();
53 }

References smacc2::ISmaccStateMachine::reset().

Here is the call graph for this function:

◆ stop()

template<typename DerivedStateMachine , typename InitialStateType >
void smacc2::SmaccStateMachineBase< DerivedStateMachine, InitialStateType >::stop ( )
inlineoverridevirtual

Reimplemented from smacc2::ISmaccStateMachine.

Definition at line 55 of file smacc_state_machine_base.hpp.

56 {
58 this->terminate();
59 }

References smacc2::ISmaccStateMachine::stop().

Here is the call graph for this function:

The documentation for this struct was generated from the following file: