AuboCaps  0.6.0
digital_io.h
Go to the documentation of this file.
1 #ifndef AUBO_SCOPE_DIGITAL_IO_H
2 #define AUBO_SCOPE_DIGITAL_IO_H
3 
5 
6 namespace arcs {
7 namespace aubo_scope {
8 ARCS_CLASS_FORWARD(DigitalIo);
9 
10 /**
11  * This interface provides support for digital I/Os.
12  *
13  */
15 {
16 public:
17  DigitalIo(DigitalIo &f);
18  DigitalIo(DigitalIo &&f);
19  ~DigitalIo();
20 
21  /**
22  * Set digital I/O output signal. Note that the I/O must be an output I/O.
23  *
24  * @param high the digital value to be set.
25  * @return <code>true</code> if the digital signal was set,
26  * <code>false</code> if the signal was not set, e.g. because the controller
27  * was not running.
28  */
29  bool setValue(bool high);
30 
31  /**
32  *
33  * @return Returns the last reading of the I/O.
34  */
35  bool getValue();
36 
37 private:
38  friend class DataSwitch;
39  DigitalIo();
40  void *d_{ nullptr };
41 };
42 
44 {
45  DigitalIoFilter(Io::InterfaceType interface, bool is_input)
46  : interface_(interface), is_input_(is_input)
47  {
48  }
49  bool operator()(IoPtr io)
50  {
51  return std::dynamic_pointer_cast<DigitalIo>(io) != nullptr &&
52  io->getInterfaceType() == interface_ &&
53  io->isInput() == is_input_;
54  }
55 
56 private:
58  bool is_input_;
59 };
60 
62 {
63  bool operator()(IoPtr io) { return io && io->isInput(); }
64 };
65 
67 {
68  bool operator()(IoPtr io) { return io && !io->isInput(); }
69 };
70 
71 } // namespace aubo_scope
72 } // namespace arcs
73 
74 #endif // AUBO_SCOPE_DIGITAL_IO_H
ARCS_CLASS_FORWARD(GripForceCapability)
This is the base interface representing all types of I/Os available in AuboScope. ...
Definition: io.h:16
InterfaceType getInterfaceType() const
This interface provides support for digital I/Os.
Definition: digital_io.h:14
#define ARCS_ABI_EXPORT
Definition: class_forward.h:16
Io::InterfaceType interface_
Definition: digital_io.h:57
DigitalIoFilter(Io::InterfaceType interface, bool is_input)
Definition: digital_io.h:45