AuboCaps  0.6.0
modbus_io.h
Go to the documentation of this file.
1 #ifndef AUBO_SCOPE_MODBUS_IO_H
2 #define AUBO_SCOPE_MODBUS_IO_H
3 
5 
6 namespace arcs {
7 namespace aubo_scope {
8 ARCS_CLASS_FORWARD(ModbusIo);
9 
10 /**
11  *
12  * This interface provides support for MODBUS I/Os.
13  */
14 class ARCS_ABI_EXPORT ModbusIo : public Io
15 {
16 public:
17  ModbusIo(ModbusIo &f);
18  ModbusIo(ModbusIo &&f);
19  ~ModbusIo();
20 
21  /**
22  *
23  * @return Get the IP address for this MODBUS I/O.
24  */
25  std::string getIpAddress();
26 
27  /**
28  *
29  * @return the signal address for this MODBUS I/O.
30  */
31  std::string getSignalAddress();
32 
33  /**
34  *
35  * @param value Set MODBUS signal to an integer value. If the MODBUS signal
36  * is digital, then <code>false</code> is represented by 0 and
37  * <code>true</code> are represented by all numbers different from 0.
38  *
39  * @return <code>true</code> if the MODBUS signal was sent down to the
40  * controller, and <code>false</code> if the signal was not sent down, e.g.
41  * because the controller was not running. Notice that the MODBUS signal
42  * must support writes, consult the Aubo MODBUS protocol.
43  */
44  bool setValue(int value);
45 
46  /**
47  *
48  * @return the integer value of the MODBUS signal. If the MODBUS signal is
49  * digital then <code>false</code> is represented by 0 and
50  * <code>true}</code> is represented by the value 1.
51  */
52  int getValue();
53 
54 private:
55  friend class DataSwitch;
56  ModbusIo();
57  void *d_{ nullptr };
58 };
59 
61 {
62  ModbusIoFilter(Io::IoType type, bool is_input)
63  : type_(type), is_input_(is_input)
64  {
65  }
66  bool operator()(IoPtr io)
67  {
68  return std::dynamic_pointer_cast<ModbusIo>(io) != nullptr &&
69  io->getType() == type_ && io->isInput() == is_input_;
70  }
71 
72 private:
74  bool is_input_;
75 };
76 
77 } // namespace aubo_scope
78 } // namespace arcs
79 
80 #endif // MODBUSIO_H
ARCS_CLASS_FORWARD(GripForceCapability)
This is the base interface representing all types of I/Os available in AuboScope. ...
Definition: io.h:16
ModbusIoFilter(Io::IoType type, bool is_input)
Definition: modbus_io.h:62
This interface provides support for MODBUS I/Os.
Definition: modbus_io.h:14
#define ARCS_ABI_EXPORT
Definition: class_forward.h:16
IoType getType() const