AuboStudio SDK 0.6.3

digital_io.h
浏览该文件的文档.
1 #ifndef AUBO_SCOPE_DIGITAL_IO_H
2 #define AUBO_SCOPE_DIGITAL_IO_H
3
4 #include <aubo_caps/domain/io/io.h>
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 */
14 class ARCS_ABI_EXPORT DigitalIo : public Io
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
43 struct DigitalIoFilter
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:
57 Io::InterfaceType interface_;
58 bool is_input_;
59 };
60
61 struct InputIoFilter
62 {
63 bool operator()(IoPtr io) { return io && io->isInput(); }
64 };
65
66 struct OutputIoFilter
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_ABI_EXPORT
#define ARCS_ABI_EXPORT
Definition: class_forward.h:16
arcs::aubo_scope::DigitalIo
This interface provides support for digital I/Os.
Definition: digital_io.h:15
arcs::aubo_scope::DigitalIo::DigitalIo
DigitalIo(DigitalIo &&f)
arcs::aubo_scope::DigitalIo::DigitalIo
DigitalIo()
arcs::aubo_scope::DigitalIo::getValue
bool getValue()
arcs::aubo_scope::DigitalIo::setValue
bool setValue(bool high)
Set digital I/O output signal.
arcs::aubo_scope::DigitalIo::DigitalIo
DigitalIo(DigitalIo &f)
arcs::aubo_scope::DigitalIo::~DigitalIo
~DigitalIo()
arcs::aubo_scope::Io
This is the base interface representing all types of I/Os available in AuboScope.
Definition: io.h:17
arcs::aubo_scope::Io::InterfaceType
InterfaceType
Definition: io.h:28
io.h
arcs::aubo_scope::ARCS_CLASS_FORWARD
ARCS_CLASS_FORWARD(GripForceCapability)
arcs
Definition: contribution_provider.h:7
arcs::aubo_scope::DigitalIoFilter
Definition: digital_io.h:44
arcs::aubo_scope::DigitalIoFilter::operator()
bool operator()(IoPtr io)
Definition: digital_io.h:49
arcs::aubo_scope::DigitalIoFilter::DigitalIoFilter
DigitalIoFilter(Io::InterfaceType interface, bool is_input)
Definition: digital_io.h:45
arcs::aubo_scope::DigitalIoFilter::interface_
Io::InterfaceType interface_
Definition: digital_io.h:57
arcs::aubo_scope::DigitalIoFilter::is_input_
bool is_input_
Definition: digital_io.h:58
arcs::aubo_scope::InputIoFilter
Definition: digital_io.h:62
arcs::aubo_scope::InputIoFilter::operator()
bool operator()(IoPtr io)
Definition: digital_io.h:63
arcs::aubo_scope::OutputIoFilter
Definition: digital_io.h:67
arcs::aubo_scope::OutputIoFilter::operator()
bool operator()(IoPtr io)
Definition: digital_io.h:68