SMACC2
Loading...
Searching...
No Matches
cl_modbus_tcp_relay::CbAllRelaysOn Class Reference

Client behavior to turn ON all relay channels simultaneously. More...

#include <cb_all_relays_on.hpp>

Inheritance diagram for cl_modbus_tcp_relay::CbAllRelaysOn:
Inheritance graph
Collaboration diagram for cl_modbus_tcp_relay::CbAllRelaysOn:
Collaboration graph

Public Member Functions

 CbAllRelaysOn ()
 
virtual ~CbAllRelaysOn ()
 
template<typename TOrthogonal , typename TSourceObject >
void onStateOrthogonalAllocation ()
 
virtual void onEntry () override
 
- Public Member Functions inherited from smacc2::SmaccAsyncClientBehavior
template<typename TOrthogonal , typename TSourceObject >
void onStateOrthogonalAllocation ()
 
virtual ~SmaccAsyncClientBehavior ()
 
template<typename TCallback , typename T >
smacc2::SmaccSignalConnection onSuccess (TCallback callback, T *object)
 
template<typename TCallback , typename T >
smacc2::SmaccSignalConnection onFinished (TCallback callback, T *object)
 
template<typename TCallback , typename T >
smacc2::SmaccSignalConnection onFailure (TCallback callback, T *object)
 
void requestForceFinish ()
 
void executeOnEntry () override
 
void executeOnExit () override
 
void waitOnEntryThread (bool requestFinish)
 
template<typename TCallbackMethod , typename T >
smacc2::SmaccSignalConnection onSuccess (TCallbackMethod callback, T *object)
 
template<typename TCallbackMethod , typename T >
smacc2::SmaccSignalConnection onFinished (TCallbackMethod callback, T *object)
 
template<typename TCallbackMethod , typename T >
smacc2::SmaccSignalConnection onFailure (TCallbackMethod callback, T *object)
 
- 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 onExit ()
 

Private Attributes

ClModbusTcpRelayclient_
 
CpModbusRelayrelayComponent_
 

Additional Inherited Members

- Protected Member Functions inherited from smacc2::SmaccAsyncClientBehavior
void postSuccessEvent ()
 
void postFailureEvent ()
 
virtual void dispose () override
 
bool isShutdownRequested ()
 onEntry is executed in a new thread. However the current state cannot be left until the onEntry thread finishes. This flag can be checked from the onEntry thread to force finishing the thread.
 
- 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 rclcpp::Node::SharedPtr getNode () const
 
virtual rclcpp::Logger getLogger () const
 

Detailed Description

Client behavior to turn ON all relay channels simultaneously.

Posts EvCbSuccess on successful write, EvCbFailure on error.

Definition at line 34 of file cb_all_relays_on.hpp.

Constructor & Destructor Documentation

◆ CbAllRelaysOn()

cl_modbus_tcp_relay::CbAllRelaysOn::CbAllRelaysOn ( )
inline

Definition at line 37 of file cb_all_relays_on.hpp.

37{}

◆ ~CbAllRelaysOn()

virtual cl_modbus_tcp_relay::CbAllRelaysOn::~CbAllRelaysOn ( )
inlinevirtual

Definition at line 39 of file cb_all_relays_on.hpp.

39{}

Member Function Documentation

◆ onEntry()

virtual void cl_modbus_tcp_relay::CbAllRelaysOn::onEntry ( )
inlineoverridevirtual

Reimplemented from smacc2::ISmaccClientBehavior.

Definition at line 50 of file cb_all_relays_on.hpp.

51 {
52 RCLCPP_INFO(getLogger(), "[CbAllRelaysOn] Turning ON all channels");
53
54 if (!relayComponent_)
55 {
56 RCLCPP_ERROR(getLogger(), "[CbAllRelaysOn] Relay component not available");
57 this->postFailureEvent();
58 return;
59 }
60
61 bool success = relayComponent_->writeAllCoils(true);
62
63 if (success)
64 {
65 RCLCPP_INFO(getLogger(), "[CbAllRelaysOn] All channels turned ON successfully");
66 this->postSuccessEvent();
67 }
68 else
69 {
70 RCLCPP_ERROR(getLogger(), "[CbAllRelaysOn] Failed to turn ON all channels");
71 this->postFailureEvent();
72 }
73 }
virtual rclcpp::Logger getLogger() const

References smacc2::ISmaccClientBehavior::getLogger(), smacc2::SmaccAsyncClientBehavior::postFailureEvent(), smacc2::SmaccAsyncClientBehavior::postSuccessEvent(), relayComponent_, and cl_modbus_tcp_relay::CpModbusRelay::writeAllCoils().

Here is the call graph for this function:

◆ onStateOrthogonalAllocation()

template<typename TOrthogonal , typename TSourceObject >
void cl_modbus_tcp_relay::CbAllRelaysOn::onStateOrthogonalAllocation ( )
inline

Member Data Documentation

◆ client_

ClModbusTcpRelay* cl_modbus_tcp_relay::CbAllRelaysOn::client_
private

Definition at line 76 of file cb_all_relays_on.hpp.

Referenced by onStateOrthogonalAllocation().

◆ relayComponent_

CpModbusRelay* cl_modbus_tcp_relay::CbAllRelaysOn::relayComponent_
private

Definition at line 77 of file cb_all_relays_on.hpp.

Referenced by onEntry(), and onStateOrthogonalAllocation().


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