|
SMACC2
|
Component that handles Modbus coil read/write operations for 8-channel relay. More...
#include <cp_modbus_relay.hpp>


Public Member Functions | |
| CpModbusRelay () | |
| virtual | ~CpModbusRelay () |
| void | onInitialize () override |
| template<typename TOrthogonal , typename TClient > | |
| void | onStateOrthogonalAllocation () |
| Configure component for event posting during orthogonal allocation. | |
| bool | writeCoil (int channel, bool state) |
| bool | readCoil (int channel, bool &state) |
| bool | writeAllCoils (bool state) |
| bool | writeAllCoils (uint8_t mask) |
| bool | readAllCoils (uint8_t &states) |
| template<typename T > | |
| smacc2::SmaccSignalConnection | onWriteSuccess (void(T::*callback)(int, bool), T *object) |
| template<typename T > | |
| smacc2::SmaccSignalConnection | onWriteFailure (void(T::*callback)(int, const std::string &), T *object) |
| template<typename T > | |
| smacc2::SmaccSignalConnection | onReadComplete (void(T::*callback)(uint8_t), T *object) |
Public Member Functions inherited from smacc2::ISmaccComponent | |
| ISmaccComponent () | |
| virtual | ~ISmaccComponent () |
| virtual std::string | getName () const |
Public Attributes | |
| smacc2::SmaccSignal< void(int channel, bool state)> | onWriteSuccess_ |
| smacc2::SmaccSignal< void(int channel, const std::string &error)> | onWriteFailure_ |
| smacc2::SmaccSignal< void(uint8_t states)> | onReadComplete_ |
Static Public Attributes | |
| static constexpr int | NUM_CHANNELS = 8 |
| static constexpr int | COIL_BASE_ADDRESS = 0x0000 |
Private Member Functions | |
| int | channelToAddress (int channel) const |
| bool | isValidChannel (int channel) const |
Private Attributes | |
| CpModbusConnection * | connectionComponent_ |
| std::function< void()> | postWriteSuccessEvent_ |
| std::function< void()> | postWriteFailureEvent_ |
Additional Inherited Members | |
Protected Member Functions inherited from smacc2::ISmaccComponent | |
| template<typename TOrthogonal , typename TClient > | |
| void | onComponentInitialization () |
| template<typename EventType > | |
| void | postEvent (const EventType &ev) |
| template<typename EventType > | |
| void | postEvent () |
| template<typename TOrthogonal , typename TSourceObject > | |
| void | onStateOrthogonalAllocation () |
| template<typename TComponent > | |
| void | requiresComponent (TComponent *&requiredComponentStorage, ComponentRequirement requirementType=ComponentRequirement::SOFT) |
| template<typename TComponent > | |
| void | requiresComponent (std::string name, TComponent *&requiredComponentStorage, ComponentRequirement requirementType=ComponentRequirement::SOFT) |
| template<typename TClient > | |
| void | requiresClient (TClient *&requiredClientStorage) |
| template<typename SmaccComponentType , typename TOrthogonal , typename TClient , typename... TArgs> | |
| SmaccComponentType * | createSiblingComponent (TArgs... targs) |
| template<typename SmaccComponentType , typename TOrthogonal , typename TClient , typename... TArgs> | |
| SmaccComponentType * | createSiblingNamedComponent (std::string name, TArgs... targs) |
| rclcpp::Node::SharedPtr | getNode () |
| rclcpp::Logger | getLogger () const |
| ISmaccStateMachine * | getStateMachine () |
Protected Attributes inherited from smacc2::ISmaccComponent | |
| ISmaccStateMachine * | stateMachine_ |
| ISmaccClient * | owner_ |
Component that handles Modbus coil read/write operations for 8-channel relay.
Responsibilities:
Channel numbering: 1-8 (user-friendly) Coil addresses: 0x0000-0x0007 (0-indexed internally)
Definition at line 51 of file cp_modbus_relay.hpp.
| cl_modbus_tcp_relay::CpModbusRelay::CpModbusRelay | ( | ) |
Definition at line 26 of file cp_modbus_relay.cpp.
|
virtual |
Definition at line 28 of file cp_modbus_relay.cpp.
|
inlineprivate |
Definition at line 116 of file cp_modbus_relay.hpp.
References COIL_BASE_ADDRESS.
Referenced by readCoil(), and writeCoil().

|
inlineprivate |
Definition at line 119 of file cp_modbus_relay.hpp.
References NUM_CHANNELS.
Referenced by readCoil(), and writeCoil().

|
overridevirtual |
Reimplemented from smacc2::ISmaccComponent.
Definition at line 30 of file cp_modbus_relay.cpp.
References connectionComponent_, smacc2::ISmaccComponent::getLogger(), and smacc2::ISmaccComponent::requiresComponent().

|
inline |
Definition at line 104 of file cp_modbus_relay.hpp.
References smacc2::ISmaccStateMachine::createSignalConnection(), and smacc2::ISmaccComponent::getStateMachine().

|
inline |
Configure component for event posting during orthogonal allocation.
Definition at line 66 of file cp_modbus_relay.hpp.
References smacc2::ISmaccComponent::postEvent(), postWriteFailureEvent_, and postWriteSuccessEvent_.

|
inline |
Definition at line 97 of file cp_modbus_relay.hpp.
References smacc2::ISmaccStateMachine::createSignalConnection(), and smacc2::ISmaccComponent::getStateMachine().

|
inline |
Definition at line 91 of file cp_modbus_relay.hpp.
References smacc2::ISmaccStateMachine::createSignalConnection(), and smacc2::ISmaccComponent::getStateMachine().

| bool cl_modbus_tcp_relay::CpModbusRelay::readAllCoils | ( | uint8_t & | states | ) |
Definition at line 183 of file cp_modbus_relay.cpp.
References COIL_BASE_ADDRESS, connectionComponent_, cl_modbus_tcp_relay::CpModbusConnection::getContext(), smacc2::ISmaccComponent::getLogger(), cl_modbus_tcp_relay::CpModbusConnection::getMutex(), cl_modbus_tcp_relay::CpModbusConnection::isConnected(), NUM_CHANNELS, and onReadComplete_.
Referenced by cl_modbus_tcp_relay::CbRelayStatus::readAllChannels().


Definition at line 94 of file cp_modbus_relay.cpp.
References channelToAddress(), connectionComponent_, cl_modbus_tcp_relay::CpModbusConnection::getContext(), smacc2::ISmaccComponent::getLogger(), cl_modbus_tcp_relay::CpModbusConnection::getMutex(), cl_modbus_tcp_relay::CpModbusConnection::isConnected(), and isValidChannel().
Referenced by cl_modbus_tcp_relay::CbRelayStatus::readSingleChannel().


Definition at line 129 of file cp_modbus_relay.cpp.
References writeAllCoils().
Referenced by cl_modbus_tcp_relay::CbAllRelaysOff::onEntry(), cl_modbus_tcp_relay::CbAllRelaysOn::onEntry(), and writeAllCoils().


| bool cl_modbus_tcp_relay::CpModbusRelay::writeAllCoils | ( | uint8_t | mask | ) |
Definition at line 136 of file cp_modbus_relay.cpp.
References COIL_BASE_ADDRESS, connectionComponent_, cl_modbus_tcp_relay::CpModbusConnection::getContext(), smacc2::ISmaccComponent::getLogger(), cl_modbus_tcp_relay::CpModbusConnection::getMutex(), cl_modbus_tcp_relay::CpModbusConnection::isConnected(), NUM_CHANNELS, onWriteFailure_, onWriteSuccess_, postWriteFailureEvent_, and postWriteSuccessEvent_.

Definition at line 47 of file cp_modbus_relay.cpp.
References channelToAddress(), connectionComponent_, cl_modbus_tcp_relay::CpModbusConnection::getContext(), smacc2::ISmaccComponent::getLogger(), cl_modbus_tcp_relay::CpModbusConnection::getMutex(), cl_modbus_tcp_relay::CpModbusConnection::isConnected(), isValidChannel(), onWriteFailure_, onWriteSuccess_, postWriteFailureEvent_, and postWriteSuccessEvent_.
Referenced by cl_modbus_tcp_relay::CbRelayOff::onEntry(), and cl_modbus_tcp_relay::CbRelayOn::onEntry().


|
staticconstexpr |
Definition at line 55 of file cp_modbus_relay.hpp.
Referenced by channelToAddress(), readAllCoils(), and writeAllCoils().
|
private |
Definition at line 110 of file cp_modbus_relay.hpp.
Referenced by onInitialize(), readAllCoils(), readCoil(), writeAllCoils(), and writeCoil().
|
staticconstexpr |
Definition at line 54 of file cp_modbus_relay.hpp.
Referenced by isValidChannel(), readAllCoils(), and writeAllCoils().
| smacc2::SmaccSignal<void(uint8_t states)> cl_modbus_tcp_relay::CpModbusRelay::onReadComplete_ |
Definition at line 87 of file cp_modbus_relay.hpp.
Referenced by readAllCoils().
| smacc2::SmaccSignal<void(int channel, const std::string & error)> cl_modbus_tcp_relay::CpModbusRelay::onWriteFailure_ |
Definition at line 86 of file cp_modbus_relay.hpp.
Referenced by writeAllCoils(), and writeCoil().
| smacc2::SmaccSignal<void(int channel, bool state)> cl_modbus_tcp_relay::CpModbusRelay::onWriteSuccess_ |
Definition at line 85 of file cp_modbus_relay.hpp.
Referenced by writeAllCoils(), and writeCoil().
|
private |
Definition at line 113 of file cp_modbus_relay.hpp.
Referenced by onStateOrthogonalAllocation(), writeAllCoils(), and writeCoil().
|
private |
Definition at line 112 of file cp_modbus_relay.hpp.
Referenced by onStateOrthogonalAllocation(), writeAllCoils(), and writeCoil().