SMACC2
Loading...
Searching...
No Matches
Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
cl_ros_timer::ClRosTimer Class Reference

#include <cl_ros_timer.hpp>

Inheritance diagram for cl_ros_timer::ClRosTimer:
Inheritance graph
Collaboration diagram for cl_ros_timer::ClRosTimer:
Collaboration graph

Public Member Functions

 ClRosTimer (rclcpp::Duration duration, bool oneshot=false)
 
virtual ~ClRosTimer ()
 
virtual void initialize ()
 
template<typename T >
boost::signals2::connection onTimerTick (void(T::*callback)(), T *object)
 
template<typename TOrthogonal , typename TSourceObject >
void onOrthogonalAllocation ()
 
 ClRosTimer (rclcpp::Duration duration, bool oneshot=false)
 
virtual ~ClRosTimer ()
 
virtual void onInitialize () override
 
template<typename T >
boost::signals2::connection onTimerTick (void(T::*callback)(), T *object)
 
template<typename TOrthogonal , typename TSourceObject >
void onOrthogonalAllocation ()
 
- Public Member Functions inherited from smacc2::ISmaccClient
 ISmaccClient ()
 
virtual ~ISmaccClient ()
 
virtual void onInitialize ()
 
virtual std::string getName () const
 
template<typename TComponent >
TComponent * getComponent ()
 
template<typename TComponent >
TComponent * getComponent (std::string name)
 
template<typename TComponent >
TComponent * getComponent (int index)
 
virtual smacc2::introspection::TypeInfo::Ptr getType ()
 
ISmaccStateMachinegetStateMachine ()
 
template<typename TSmaccSignal , typename T >
void connectSignal (TSmaccSignal &signal, void(T::*callback)(), T *object)
 
template<typename SmaccClientType >
void requiresClient (SmaccClientType *&storage)
 
void getComponents (std::vector< std::shared_ptr< ISmaccComponent > > &components)
 
const std::vector< std::shared_ptr< ISmaccComponent > > & iterateComponents () const
 
template<typename EventType >
void postEvent (const EventType &ev)
 
template<typename EventType >
void postEvent ()
 

Protected Member Functions

void timerCallback ()
 
void timerCallback ()
 
- Protected Member Functions inherited from smacc2::ISmaccClient
template<typename TOrthogonal , typename TSourceObject >
void onOrthogonalAllocation ()
 
template<typename SmaccComponentType , typename TOrthogonal , typename TClient , typename... TArgs>
SmaccComponentType * createComponent (TArgs... targs)
 
template<typename SmaccComponentType , typename TOrthogonal , typename TClient , typename... TArgs>
SmaccComponentType * createNamedComponent (std::string name, TArgs... targs)
 
rclcpp::Node::SharedPtr getNode ()
 
rclcpp::Logger getLogger ()
 

Protected Attributes

rclcpp::TimerBase::SharedPtr timer_
 
rclcpp::Duration duration_
 
bool oneshot_
 
std::function< void()> postTimerEvent_
 
smacc2::SmaccSignal< void()> onTimerTick_
 
- Protected Attributes inherited from smacc2::ISmaccClient
std::map< ComponentKey, std::shared_ptr< smacc2::ISmaccComponent > > components_
 

Detailed Description

Definition at line 39 of file cl_ros_timer.hpp.

Constructor & Destructor Documentation

◆ ClRosTimer() [1/2]

cl_ros_timer::ClRosTimer::ClRosTimer ( rclcpp::Duration  duration,
bool  oneshot = false 
)

Definition at line 19 of file timer_client.cpp.

20: duration_(duration), oneshot_(oneshot)
21{
22}
rclcpp::Duration duration_

◆ ~ClRosTimer() [1/2]

cl_ros_timer::ClRosTimer::~ClRosTimer ( )
virtual

Definition at line 24 of file timer_client.cpp.

24{ timer_->cancel(); }
rclcpp::TimerBase::SharedPtr timer_

References timer_.

◆ ClRosTimer() [2/2]

cl_ros_timer::ClRosTimer::ClRosTimer ( rclcpp::Duration  duration,
bool  oneshot = false 
)

◆ ~ClRosTimer() [2/2]

virtual cl_ros_timer::ClRosTimer::~ClRosTimer ( )
virtual

Member Function Documentation

◆ initialize()

virtual void cl_ros_timer::ClRosTimer::initialize ( )
virtual

◆ onInitialize()

void cl_ros_timer::ClRosTimer::onInitialize ( )
overridevirtual

Reimplemented from smacc2::ISmaccClient.

Definition at line 26 of file timer_client.cpp.

27{
28 auto clock = this->getNode()->get_clock();
29
30 timer_ = rclcpp::create_timer(
31 this->getNode(), clock, duration_, std::bind(&ClRosTimer::timerCallback, this));
32}
rclcpp::Node::SharedPtr getNode()
Definition: client.cpp:60

References duration_, smacc2::ISmaccClient::getNode(), timer_, and timerCallback().

Here is the call graph for this function:

◆ onOrthogonalAllocation() [1/2]

template<typename TOrthogonal , typename TSourceObject >
void cl_ros_timer::ClRosTimer::onOrthogonalAllocation ( )
inline

Definition at line 55 of file cl_ros_timer.hpp.

56 {
57 this->postTimerEvent_ = [=]() { this->postEvent<EvTimer<TSourceObject, TOrthogonal>>(); };
58 }
std::function< void()> postTimerEvent_

References postTimerEvent_.

◆ onOrthogonalAllocation() [2/2]

template<typename TOrthogonal , typename TSourceObject >
void cl_ros_timer::ClRosTimer::onOrthogonalAllocation ( )
inline

Definition at line 55 of file cl_ros_timer.hpp.

56 {
57 this->postTimerEvent_ = [this]() { this->postEvent<EvTimer<TSourceObject, TOrthogonal>>(); };
58 }

References postTimerEvent_.

◆ onTimerTick() [1/2]

template<typename T >
boost::signals2::connection cl_ros_timer::ClRosTimer::onTimerTick ( void(T::*)()  callback,
T *  object 
)
inline

Definition at line 49 of file cl_ros_timer.hpp.

50 {
51 return this->getStateMachine()->createSignalConnection(onTimerTick_, callback, object);
52 }
smacc2::SmaccSignal< void()> onTimerTick_
ISmaccStateMachine * getStateMachine()
boost::signals2::connection createSignalConnection(TSmaccSignal &signal, TMemberFunctionPrototype callback, TSmaccObjectType *object)

References smacc2::ISmaccStateMachine::createSignalConnection(), smacc2::ISmaccClient::getStateMachine(), and onTimerTick_.

Referenced by cl_ros_timer::CbTimer::onEntry(), cl_ros_timer::CbTimerCountdownLoop::onEntry(), and cl_ros_timer::CbTimerCountdownOnce::onEntry().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ onTimerTick() [2/2]

template<typename T >
boost::signals2::connection cl_ros_timer::ClRosTimer::onTimerTick ( void(T::*)()  callback,
T *  object 
)
inline

Definition at line 49 of file cl_ros_timer.hpp.

50 {
51 return this->getStateMachine()->createSignalConnection(onTimerTick_, callback, object);
52 }

References smacc2::ISmaccStateMachine::createSignalConnection(), smacc2::ISmaccClient::getStateMachine(), and onTimerTick_.

Here is the call graph for this function:

◆ timerCallback() [1/2]

void cl_ros_timer::ClRosTimer::timerCallback ( )
protected

Definition at line 34 of file timer_client.cpp.

35{
36 if (!onTimerTick_.empty())
37 {
38 this->onTimerTick_();
39 }
41
42 if (oneshot_)
43 {
44 this->timer_->cancel();
45 }
46}

References oneshot_, onTimerTick_, postTimerEvent_, and timer_.

Referenced by onInitialize().

Here is the caller graph for this function:

◆ timerCallback() [2/2]

void cl_ros_timer::ClRosTimer::timerCallback ( )
protected

Member Data Documentation

◆ duration_

rclcpp::Duration cl_ros_timer::ClRosTimer::duration_
protected

Definition at line 62 of file cl_ros_timer.hpp.

Referenced by onInitialize().

◆ oneshot_

bool cl_ros_timer::ClRosTimer::oneshot_
protected

Definition at line 63 of file cl_ros_timer.hpp.

Referenced by timerCallback().

◆ onTimerTick_

smacc2::SmaccSignal< void()> cl_ros_timer::ClRosTimer::onTimerTick_
protected

Definition at line 67 of file cl_ros_timer.hpp.

Referenced by onTimerTick(), and timerCallback().

◆ postTimerEvent_

std::function< void()> cl_ros_timer::ClRosTimer::postTimerEvent_
protected

Definition at line 66 of file cl_ros_timer.hpp.

Referenced by onOrthogonalAllocation(), and timerCallback().

◆ timer_

rclcpp::TimerBase::SharedPtr cl_ros_timer::ClRosTimer::timer_
protected

Definition at line 61 of file cl_ros_timer.hpp.

Referenced by onInitialize(), timerCallback(), and ~ClRosTimer().


The documentation for this class was generated from the following files: