ros2_canopen master
C++ ROS CANopen Library
Loading...
Searching...
No Matches
mode_forward_helper.hpp
Go to the documentation of this file.
1// Copyright 2023 Christoph Hellmann Santos
2// Copyright 2014-2022 Authors of ros_canopen
3//
4// This program is free software: you can redistribute it and/or modify
5// it under the terms of the GNU General Public License as published by
6// the Free Software Foundation, either version 3 of the License, or
7// (at your option) any later version.
8//
9// This program is distributed in the hope that it will be useful,
10// but WITHOUT ANY WARRANTY; without even the implied warranty of
11// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12// GNU General Public License for more details.
13//
14// You should have received a copy of the GNU General Public License
15// along with this program. If not, see <https://www.gnu.org/licenses/>.
16//
17
18#ifndef MODE_FORWARD_HELPER_HPP
19#define MODE_FORWARD_HELPER_HPP
20
21#include <cstdint>
22#include <memory>
25
26namespace ros2_canopen
27{
28
29template <uint16_t ID, typename TYPE, uint16_t OBJ, uint8_t SUB, uint16_t CW_MASK>
31{
32 std::shared_ptr<LelyDriverBridge> driver;
33
34public:
35 ModeForwardHelper(std::shared_ptr<LelyDriverBridge> driver) : ModeTargetHelper<TYPE>(ID)
36 {
37 this->driver = driver;
38 }
39 virtual bool read(const uint16_t & sw) { return true; }
40 virtual bool write(Mode::OpModeAccesser & cw)
41 {
42 if (this->hasTarget())
43 {
44 cw = cw.get() | CW_MASK;
45
46 driver->universal_set_value<TYPE>(OBJ, SUB, this->getTarget());
47 return true;
48 }
49 else
50 {
51 cw = cw.get() & ~CW_MASK;
52 return false;
53 }
54 }
55};
56} // namespace ros2_canopen
57
58#endif // MODE_FORWARD_HELPER_HPP
Definition mode_forward_helper.hpp:31
virtual bool read(const uint16_t &sw)
Definition mode_forward_helper.hpp:39
ModeForwardHelper(std::shared_ptr< LelyDriverBridge > driver)
Definition mode_forward_helper.hpp:35
virtual bool write(Mode::OpModeAccesser &cw)
Definition mode_forward_helper.hpp:40
Definition mode_target_helper.hpp:37
bool hasTarget()
Definition mode_target_helper.hpp:43
TYPE getTarget()
Definition mode_target_helper.hpp:44
Definition word_accessor.hpp:27
bool get(uint8_t bit) const
Definition word_accessor.hpp:44
Definition configuration_manager.hpp:28