SMACC2
Loading...
Searching...
No Matches
cb_all_relays_off.hpp
Go to the documentation of this file.
1// Copyright 2024 RobosoftAI Inc.
2//
3// Licensed under the Apache License, Version 2.0 (the "License");
4// you may not use this file except in compliance with the License.
5// You may obtain a copy of the License at
6//
7// http://www.apache.org/licenses/LICENSE-2.0
8//
9// Unless required by applicable law or agreed to in writing, software
10// distributed under the License is distributed on an "AS IS" BASIS,
11// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12// See the License for the specific language governing permissions and
13// limitations under the License.
14
15/*****************************************************************************************************************
16 *
17 * Authors: Pablo Inigo Blasco, Brett Aldrich
18 *
19 ******************************************************************************************************************/
20
21#pragma once
22
25
26namespace cl_modbus_tcp_relay
27{
28
35{
36public:
38
39 virtual ~CbAllRelaysOff() {}
40
41 template <typename TOrthogonal, typename TSourceObject>
49
50 virtual void onEntry() override
51 {
52 RCLCPP_INFO(getLogger(), "[CbAllRelaysOff] Turning OFF all channels");
53
54 if (!relayComponent_)
55 {
56 RCLCPP_ERROR(getLogger(), "[CbAllRelaysOff] Relay component not available");
57 this->postFailureEvent();
58 return;
59 }
60
61 bool success = relayComponent_->writeAllCoils(false);
62
63 if (success)
64 {
65 RCLCPP_INFO(getLogger(), "[CbAllRelaysOff] All channels turned OFF successfully");
66 this->postSuccessEvent();
67 }
68 else
69 {
70 RCLCPP_ERROR(getLogger(), "[CbAllRelaysOff] Failed to turn OFF all channels");
71 this->postFailureEvent();
72 }
73 }
74
75private:
78};
79
80} // namespace cl_modbus_tcp_relay
Client behavior to turn OFF all relay channels simultaneously.
SMACC2 Client for controlling Modbus TCP relays.
Component that handles Modbus coil read/write operations for 8-channel relay.
virtual rclcpp::Logger getLogger() const
void requiresClient(SmaccClientType *&storage)
void requiresComponent(SmaccComponentType *&storage, ComponentRequirement requirementType=ComponentRequirement::SOFT)