CVB++ 15.0
decl_digital_io.hpp
1#pragma once
2
3#include <stdexcept>
4#include <bitset>
5
6#include "../../global.hpp"
7
8namespace Cvb
9{
10
11 CVB_BEGIN_INLINE_NS
12
13 namespace Driver
14 {
15
17
18 class DigitalIO
19 {
20 public:
21 explicit DigitalIO(const DevicePtr &device)
22 : parent_(device)
23 {
24 }
25
27
31 DevicePtr Parent() const noexcept
32 {
33 return parent_;
34 }
35
37
41 int InputCount() const;
42
44
48 int OutputCount() const;
49
51
56 bool ReadInputBit(int port) const;
57
59
64 std::bitset<32> ReadInputGroup(int group) const;
65
67
72 bool ReadOutputBit(int port) const;
73
75
80 std::bitset<32> ReadOutputGroup(int group) const;
81
83
88 void WriteOutputBit(int port, bool value);
89
91
99 void WriteOutputGroup(int group, std::bitset<32> value)
100 {
101#ifdef max
102# undef max
103#endif
105 }
106
108
117 void WriteOutputGroup(int group, std::bitset<32> value, std::bitset<32> mask);
118
119 private:
120 DevicePtr parent_;
121 };
122
123 } // namespace Driver
124
125 using Driver::DigitalIO;
126
127 CVB_END_INLINE_NS
128
129} // namespace Cvb
bool ReadInputBit(int port) const
Reads a single input port from the device.
Definition detail_digital_io.hpp:35
void WriteOutputBit(int port, bool value)
Write a single output port to the device.
Definition detail_digital_io.hpp:71
int InputCount() const
Gets the number of digital input ports of the device.
Definition detail_digital_io.hpp:17
int OutputCount() const
Gets the number of digital output ports of the device.
Definition detail_digital_io.hpp:26
void WriteOutputGroup(int group, std::bitset< 32 > value)
Writes the output group to the device.
Definition decl_digital_io.hpp:99
std::bitset< 32 > ReadInputGroup(int group) const
Reads a group of input ports from the device.
Definition detail_digital_io.hpp:44
bool ReadOutputBit(int port) const
Reads a single output port from the device.
Definition detail_digital_io.hpp:53
std::bitset< 32 > ReadOutputGroup(int group) const
Reads a group of output ports from the device.
Definition detail_digital_io.hpp:62
DevicePtr Parent() const noexcept
Gets the parent device of this interface.
Definition decl_digital_io.hpp:31
T max(T... args)
Namespace for driver or device related operations.
Definition decl_composite.hpp:28
Root namespace for the Image Manager interface.
Definition c_bayer_to_rgb.h:17
std::shared_ptr< Device > DevicePtr
Convenience shared pointer for Device.
Definition global.hpp:98