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

#include <cb_timer_countdown_once.hpp>

Inheritance diagram for cl_ros2_timer::CbTimerCountdownOnce:
Inheritance graph
Collaboration diagram for cl_ros2_timer::CbTimerCountdownOnce:
Collaboration graph

Public Member Functions

 CbTimerCountdownOnce (rclcpp::Duration targetDuration)
 
template<typename T , std::enable_if_t< std::is_integral< T >::value, int > = 0>
 CbTimerCountdownOnce (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 targetDuration_
 
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_once.hpp.

Constructor & Destructor Documentation

◆ CbTimerCountdownOnce() [1/2]

cl_ros2_timer::CbTimerCountdownOnce::CbTimerCountdownOnce ( rclcpp::Duration targetDuration)
inline

Definition at line 25 of file cb_timer_countdown_once.hpp.

25: targetDuration_(targetDuration) {}

◆ CbTimerCountdownOnce() [2/2]

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

Definition at line 29 of file cb_timer_countdown_once.hpp.

30 {
31 static_assert(
32 !std::is_integral<T>::value,
33 "\n\nCbTimerCountdownOnce no longer accepts a tick count.\n"
34 "Pass a chrono duration literal instead:\n"
35 " configure_orthogonal<OrTimer, CbTimerCountdownOnce>(5s); // 5 seconds\n"
36 " configure_orthogonal<OrTimer, CbTimerCountdownOnce>(500ms); // 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::CbTimerCountdownOnce::onEntry ( )
inlineoverridevirtual

Reimplemented from smacc2::ISmaccClientBehavior.

Definition at line 40 of file cb_timer_countdown_once.hpp.

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

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

Here is the call graph for this function:

◆ onExit()

void cl_ros2_timer::CbTimerCountdownOnce::onExit ( )
inlineoverridevirtual

Reimplemented from smacc2::ISmaccClientBehavior.

Definition at line 54 of file cb_timer_countdown_once.hpp.

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

References wallTimer_.

◆ onStateOrthogonalAllocation()

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

Definition at line 64 of file cb_timer_countdown_once.hpp.

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

Here is the call graph for this function:

◆ onTimerTick()

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

Definition at line 71 of file cb_timer_countdown_once.hpp.

72 {
73 return this->getStateMachine()->createSignalConnection(onTimerTick_, callback, object);
74 }
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

◆ onTimerTick_

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

Definition at line 81 of file cb_timer_countdown_once.hpp.

Referenced by onTimerTick().

◆ postCountDownEvent_

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

Definition at line 80 of file cb_timer_countdown_once.hpp.

Referenced by onStateOrthogonalAllocation().

◆ targetDuration_

rclcpp::Duration cl_ros2_timer::CbTimerCountdownOnce::targetDuration_
private

Definition at line 77 of file cb_timer_countdown_once.hpp.

Referenced by onEntry().

◆ wallTimer_

rclcpp::TimerBase::SharedPtr cl_ros2_timer::CbTimerCountdownOnce::wallTimer_
private

Definition at line 78 of file cb_timer_countdown_once.hpp.

Referenced by onEntry(), and onExit().


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