ros2_canopen  master
C++ ROS CANopen Library
command.hpp
Go to the documentation of this file.
1 #ifndef CANOPEN_402_DRIVER_COMMAND_HPP
2 #define CANOPEN_402_DRIVER_COMMAND_HPP
3 
4 #include <boost/container/flat_map.hpp>
5 #include <cstdint>
6 #include <utility>
7 #include "state.hpp"
8 
9 namespace ros2_canopen
10 {
12 {
13  struct Op
14  {
15  uint16_t to_set_;
16  uint16_t to_reset_;
17  Op(uint16_t to_set, uint16_t to_reset) : to_set_(to_set), to_reset_(to_reset) {}
18  void operator()(uint16_t & val) const { val = (val & ~to_reset_) | to_set_; }
19  };
20  class TransitionTable
21  {
22  boost::container::flat_map<std::pair<State402::InternalState, State402::InternalState>, Op>
23  transitions_;
24  void add(const State402::InternalState & from, const State402::InternalState & to, Op op)
25  {
26  transitions_.insert(std::make_pair(std::make_pair(from, to), op));
27  }
28 
29  public:
30  TransitionTable();
31  const Op & get(const State402::InternalState & from, const State402::InternalState & to) const
32  {
33  return transitions_.at(std::make_pair(from, to));
34  }
35  };
36  static const TransitionTable transitions_;
37  static State402::InternalState nextStateForEnabling(State402::InternalState state);
38  Command402();
39 
40 public:
42  {
51  CW_Halt = 8,
53  // CW_Reserved1=10,
59  };
60  static bool setTransition(
61  uint16_t & cw, const State402::InternalState & from, const State402::InternalState & to,
63 };
64 } // namespace ros2_canopen
65 
66 #endif // CANOPEN_402_DRIVER_COMMAND_HPP
Definition: command.hpp:12
ControlWord
Definition: command.hpp:42
@ CW_Quick_Stop
Definition: command.hpp:45
@ CW_Operation_mode_specific3
Definition: command.hpp:52
@ CW_Switch_On
Definition: command.hpp:43
@ CW_Manufacturer_specific1
Definition: command.hpp:55
@ CW_Operation_mode_specific1
Definition: command.hpp:48
@ CW_Manufacturer_specific2
Definition: command.hpp:56
@ CW_Manufacturer_specific0
Definition: command.hpp:54
@ CW_Operation_mode_specific0
Definition: command.hpp:47
@ CW_Operation_mode_specific2
Definition: command.hpp:49
@ CW_Manufacturer_specific4
Definition: command.hpp:58
@ CW_Enable_Operation
Definition: command.hpp:46
@ CW_Fault_Reset
Definition: command.hpp:50
@ CW_Enable_Voltage
Definition: command.hpp:44
@ CW_Manufacturer_specific3
Definition: command.hpp:57
@ CW_Halt
Definition: command.hpp:51
static bool setTransition(uint16_t &cw, const State402::InternalState &from, const State402::InternalState &to, State402::InternalState *next)
InternalState
Definition: state.hpp:33
Definition: configuration_manager.hpp:28