SMACC2
Loading...
Searching...
No Matches
cl_ros2_timer::CbTimerCountdownLoop Class Reference

#include <cb_timer_countdown_loop.hpp>

Inheritance diagram for cl_ros2_timer::CbTimerCountdownLoop:
Inheritance graph
Collaboration diagram for cl_ros2_timer::CbTimerCountdownLoop:
Collaboration graph

Public Member Functions

 CbTimerCountdownLoop (rclcpp::Duration loopDuration)
 
template<typename T , std::enable_if_t< std::is_integral< T >::value, int > = 0>
 CbTimerCountdownLoop (T)
 
void onEntry () override
 
void onExit () override
 
template<typename TOrthogonal , typename TSourceObject >
void onStateOrthogonalAllocation ()
 
template<typename T >
smacc2::SmaccSignalConnection onTimerTick (void(T::*callback)(), T *object)
 
- Public Member Functions inherited from smacc2::SmaccClientBehavior
virtual ~SmaccClientBehavior ()
 
void onEntry () override
 
void onExit () override
 
- Public Member Functions inherited from smacc2::ISmaccClientBehavior
 ISmaccClientBehavior ()
 
virtual ~ISmaccClientBehavior ()
 
ISmaccStateMachinegetStateMachine ()
 
std::string getName () const
 
template<typename SmaccClientType >
void requiresClient (SmaccClientType *&storage)
 
template<typename SmaccComponentType >
void requiresComponent (SmaccComponentType *&storage, ComponentRequirement requirementType=ComponentRequirement::SOFT)
 
virtual void executeOnEntry ()
 
virtual void executeOnExit ()
 

Private Attributes

rclcpp::Duration loopDuration_
 
rclcpp::TimerBase::SharedPtr wallTimer_
 
std::function< void()> postCountDownEvent_
 
smacc2::SmaccSignal< void()> onTimerTick_
 

Additional Inherited Members

- Protected Member Functions inherited from smacc2::ISmaccClientBehavior
virtual void runtimeConfigure ()
 
template<typename EventType >
void postEvent (const EventType &ev)
 
template<typename EventType >
void postEvent ()
 
ISmaccStategetCurrentState ()
 
virtual void dispose ()
 
virtual rclcpp::Node::SharedPtr getNode () const
 
virtual rclcpp::Logger getLogger () const
 

Detailed Description

Definition at line 22 of file cb_timer_countdown_loop.hpp.

Constructor & Destructor Documentation

◆ CbTimerCountdownLoop() [1/2]

cl_ros2_timer::CbTimerCountdownLoop::CbTimerCountdownLoop ( rclcpp::Duration loopDuration)
inlineexplicit

Definition at line 25 of file cb_timer_countdown_loop.hpp.

25: loopDuration_(loopDuration) {}

◆ CbTimerCountdownLoop() [2/2]

template<typename T , std::enable_if_t< std::is_integral< T >::value, int > = 0>
cl_ros2_timer::CbTimerCountdownLoop::CbTimerCountdownLoop ( T )
inlineexplicit

Definition at line 29 of file cb_timer_countdown_loop.hpp.

30 {
31 static_assert(
32 !std::is_integral<T>::value,
33 "\n\nCbTimerCountdownLoop no longer accepts a tick count.\n"
34 "Pass a chrono duration literal instead:\n"
35 " configure_orthogonal<OrTimer, CbTimerCountdownLoop>(3s); // every 3 seconds\n"
36 " configure_orthogonal<OrTimer, CbTimerCountdownLoop>(500ms); // every 500 ms\n"
37 "Migration guide: https://smacc2.robosoft.ai/how-to/how-to-cl-ros2-timer.html\n");
38 }

Member Function Documentation

◆ onEntry()

void cl_ros2_timer::CbTimerCountdownLoop::onEntry ( )
inlineoverridevirtual

Reimplemented from smacc2::ISmaccClientBehavior.

Definition at line 40 of file cb_timer_countdown_loop.hpp.

41 {
42 auto node = this->getNode();
43 auto clock = node->get_clock();
44 wallTimer_ = rclcpp::create_timer(
45 node, clock, std::chrono::nanoseconds(loopDuration_.nanoseconds()),
46 [this]()
47 {
48 onTimerTick_();
49 postCountDownEvent_();
50 });
51 }
virtual rclcpp::Node::SharedPtr getNode() const

References smacc2::ISmaccClientBehavior::getNode(), loopDuration_, and wallTimer_.

Here is the call graph for this function:

◆ onExit()

void cl_ros2_timer::CbTimerCountdownLoop::onExit ( )
inlineoverridevirtual

Reimplemented from smacc2::ISmaccClientBehavior.

Definition at line 53 of file cb_timer_countdown_loop.hpp.

54 {
55 if (wallTimer_)
56 {
57 wallTimer_->cancel();
58 wallTimer_.reset();
59 }
60 }

References wallTimer_.

◆ onStateOrthogonalAllocation()

template<typename TOrthogonal , typename TSourceObject >
void cl_ros2_timer::CbTimerCountdownLoop::onStateOrthogonalAllocation ( )
inline

Definition at line 63 of file cb_timer_countdown_loop.hpp.

References postCountDownEvent_, and smacc2::ISmaccClientBehavior::postEvent().

Here is the call graph for this function:

◆ onTimerTick()

template<typename T >
smacc2::SmaccSignalConnection cl_ros2_timer::CbTimerCountdownLoop::onTimerTick ( void(T::* callback )(),
T * object )
inline

Definition at line 70 of file cb_timer_countdown_loop.hpp.

71 {
72 return this->getStateMachine()->createSignalConnection(onTimerTick_, callback, object);
73 }
smacc2::SmaccSignalConnection createSignalConnection(TSmaccSignal &signal, TMemberFunctionPrototype callback, TSmaccObjectType *object)

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

Here is the call graph for this function:

Member Data Documentation

◆ loopDuration_

rclcpp::Duration cl_ros2_timer::CbTimerCountdownLoop::loopDuration_
private

Definition at line 76 of file cb_timer_countdown_loop.hpp.

Referenced by onEntry().

◆ onTimerTick_

smacc2::SmaccSignal<void()> cl_ros2_timer::CbTimerCountdownLoop::onTimerTick_
private

Definition at line 80 of file cb_timer_countdown_loop.hpp.

Referenced by onTimerTick().

◆ postCountDownEvent_

std::function<void()> cl_ros2_timer::CbTimerCountdownLoop::postCountDownEvent_
private

Definition at line 79 of file cb_timer_countdown_loop.hpp.

Referenced by onStateOrthogonalAllocation().

◆ wallTimer_

rclcpp::TimerBase::SharedPtr cl_ros2_timer::CbTimerCountdownLoop::wallTimer_
private

Definition at line 77 of file cb_timer_countdown_loop.hpp.

Referenced by onEntry(), and onExit().


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