SMACC2
Loading...
Searching...
No Matches
smacc2::ISmaccUpdatable Class Referenceabstract

#include <smacc_updatable.hpp>

Inheritance diagram for smacc2::ISmaccUpdatable:
Inheritance graph
Collaboration diagram for smacc2::ISmaccUpdatable:
Collaboration graph

Public Member Functions

 ISmaccUpdatable ()
 
 ISmaccUpdatable (rclcpp::Duration duration)
 
virtual ~ISmaccUpdatable ()=default
 
 ISmaccUpdatable (const ISmaccUpdatable &)=delete
 
ISmaccUpdatable & operator= (const ISmaccUpdatable &)=delete
 
 ISmaccUpdatable (ISmaccUpdatable &&)=delete
 
ISmaccUpdatable & operator= (ISmaccUpdatable &&)=delete
 
void executeUpdate (rclcpp::Node::SharedPtr node)
 
void setUpdatePeriod (rclcpp::Duration duration)
 

Protected Member Functions

virtual void update ()=0
 

Private Attributes

std::optional< rclcpp::Duration > periodDuration_
 
std::optional< rclcpp::Time > lastUpdate_
 

Detailed Description

Definition at line 32 of file smacc_updatable.hpp.

Constructor & Destructor Documentation

◆ ISmaccUpdatable() [1/4]

smacc2::ISmaccUpdatable::ISmaccUpdatable ( )

Definition at line 25 of file smacc_updatable.cpp.

25{}

◆ ISmaccUpdatable() [2/4]

smacc2::ISmaccUpdatable::ISmaccUpdatable ( rclcpp::Duration duration)
explicit

Definition at line 27 of file smacc_updatable.cpp.

27: periodDuration_(duration) {}
std::optional< rclcpp::Duration > periodDuration_

◆ ~ISmaccUpdatable()

virtual smacc2::ISmaccUpdatable::~ISmaccUpdatable ( )
virtualdefault

◆ ISmaccUpdatable() [3/4]

smacc2::ISmaccUpdatable::ISmaccUpdatable ( const ISmaccUpdatable & )
delete

◆ ISmaccUpdatable() [4/4]

smacc2::ISmaccUpdatable::ISmaccUpdatable ( ISmaccUpdatable && )
delete

Member Function Documentation

◆ executeUpdate()

void smacc2::ISmaccUpdatable::executeUpdate ( rclcpp::Node::SharedPtr node)

Definition at line 31 of file smacc_updatable.cpp.

32{
33 bool triggerUpdateMethod = true;
35 {
36 auto now = node->get_clock()->now();
37
38 if (!lastUpdate_)
39 {
40 lastUpdate_ = now;
41 }
42
43 auto elapsed = now - *lastUpdate_;
44 triggerUpdateMethod = elapsed > *periodDuration_;
45 if (triggerUpdateMethod)
46 {
47 this->lastUpdate_ = now;
48 }
49 }
50
51 if (triggerUpdateMethod)
52 {
53 this->update();
54 }
55}
virtual void update()=0
std::optional< rclcpp::Time > lastUpdate_

References lastUpdate_, periodDuration_, and update().

Here is the call graph for this function:

◆ operator=() [1/2]

ISmaccUpdatable & smacc2::ISmaccUpdatable::operator= ( const ISmaccUpdatable & )
delete

◆ operator=() [2/2]

ISmaccUpdatable & smacc2::ISmaccUpdatable::operator= ( ISmaccUpdatable && )
delete

◆ setUpdatePeriod()

void smacc2::ISmaccUpdatable::setUpdatePeriod ( rclcpp::Duration duration)

Definition at line 29 of file smacc_updatable.cpp.

29{ periodDuration_ = duration; }

References periodDuration_.

Referenced by cl_modbus_tcp_relay::CpModbusConnection::onInitialize().

Here is the caller graph for this function:

◆ update()

Member Data Documentation

◆ lastUpdate_

std::optional<rclcpp::Time> smacc2::ISmaccUpdatable::lastUpdate_
private

Definition at line 54 of file smacc_updatable.hpp.

Referenced by executeUpdate().

◆ periodDuration_

std::optional<rclcpp::Duration> smacc2::ISmaccUpdatable::periodDuration_
private

Definition at line 53 of file smacc_updatable.hpp.

Referenced by executeUpdate(), and setUpdatePeriod().


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