InertiaSDK

Loading...
Searching...
No Matches
RemoteIOCommands.h
1#pragma once
2
3#include "data/command/InertiaCommand.h"
4
5 namespace inertia
6{
7
9 enum RemoteIOCommands : uint8_t {
10 RemoteIOport = 1, // set port I/O pin directions
11 RemoteIOset = 2, // set state of I/O pins
12 RemoteIOget = 3, // get state of I/O pins
13 RemoteIOgetADC = 4, // get ADC value of a pin
14 RemoteIOLast
15};
16
17
19 enum RemoteIOsetting {
20 RemoteIOsettingKeep = 0, // no change
21 RemoteIOsettingInput, // set to input
22 RemoteIOsettingOutput, // set to output
23 RemoteIOsettingADC // assign to ADC
24};
25
26
27 struct INERTIA_API RemoteIOCommand
28 : InertiaCommand
29{
30 protected:
31 RemoteIOCommand();
32 RemoteIOCommand(const uint8_t* packet, const unsigned max_size);
33 RemoteIOCommand(std::wstring const& argString);
34
35 public:
36 InertiaCommandGroups GetGroup() const override;
37 static std::wstring GetName(RemoteIOCommands const command);
38
39 static InertiaCommandPtr Parse(const uint8_t* in, unsigned const packetSize);
40 static InertiaCommandPtr Parse(std::wstring const& argString);
41};
42
43
44 struct INERTIA_API RemoteIOportRequest
45 : RemoteIOCommand
46{
47 std::vector<RemoteIOsetting> setting; // max 8
48
49 RemoteIOportRequest();
50 RemoteIOportRequest(const uint8_t* packet, const unsigned max_size);
51 RemoteIOportRequest(std::wstring const& argString);
52
53 void GetBytes(std::vector<uint8_t>& out) const override;
54 const std::wstring ToString() const override;
55
56#ifdef WITH_BOOST_PROGRAM_OPTIONS
57 static const po::options_description GetOptionDescription();
58#endif
59
60 uint8_t GetType() const override;
61 bool IsResponse() const override;
62};
63
64
65 struct INERTIA_API RemoteIOportResponse
66 : RemoteIOCommand
67 , BoolValue
68{
69 RemoteIOportResponse(const uint8_t* packet, const unsigned max_size);
70 RemoteIOportResponse(std::wstring const& argString);
71
72 void GetBytes(std::vector<uint8_t>& out) const override;
73 const std::wstring ToString() const override;
74
75#ifdef WITH_BOOST_PROGRAM_OPTIONS
76 static const po::options_description GetOptionDescription();
77#endif
78
79 uint8_t GetType() const override;
80 bool IsResponse() const override;
81};
82
83
84 struct INERTIA_API RemoteIOsetRequest
85 : RemoteIOCommand
86{
87 uint8_t setting;
88
89 RemoteIOsetRequest();
90 RemoteIOsetRequest(const uint8_t* packet, const unsigned max_size);
91 RemoteIOsetRequest(std::wstring const& argString);
92
93 void GetBytes(std::vector<uint8_t>& out) const override;
94 const std::wstring ToString() const override;
95
96#ifdef WITH_BOOST_PROGRAM_OPTIONS
97 static const po::options_description GetOptionDescription();
98#endif
99
100 uint8_t GetType() const override;
101 bool IsResponse() const override;
102};
103
104
105 struct INERTIA_API RemoteIOsetResponse
106 : RemoteIOCommand
107 , BoolValue
108{
109 RemoteIOsetResponse(const uint8_t* packet, const unsigned max_size);
110 RemoteIOsetResponse(std::wstring const& argString);
111
112 void GetBytes(std::vector<uint8_t>& out) const override;
113 const std::wstring ToString() const override;
114
115#ifdef WITH_BOOST_PROGRAM_OPTIONS
116 static const po::options_description GetOptionDescription();
117#endif
118
119 uint8_t GetType() const override;
120 bool IsResponse() const override;
121};
122
123
124 struct INERTIA_API RemoteIOgetRequest
125 : RemoteIOCommand
126{
127 RemoteIOgetRequest();
128 RemoteIOgetRequest(const uint8_t* packet, const unsigned max_size);
129 RemoteIOgetRequest(std::wstring const& argString);
130
131 void GetBytes(std::vector<uint8_t>& out) const override;
132 const std::wstring ToString() const override;
133
134#ifdef WITH_BOOST_PROGRAM_OPTIONS
135 static const po::options_description GetOptionDescription();
136#endif
137
138 uint8_t GetType() const override;
139 bool IsResponse() const override;
140};
141
142
143 struct INERTIA_API RemoteIOgetResponse
144 : RemoteIOCommand
145{
146 uint8_t setting;
147
148 RemoteIOgetResponse(const uint8_t* packet, const unsigned max_size);
149 RemoteIOgetResponse(std::wstring const& argString);
150
151 void GetBytes(std::vector<uint8_t>& out) const override;
152 const std::wstring ToString() const override;
153
154#ifdef WITH_BOOST_PROGRAM_OPTIONS
155 static const po::options_description GetOptionDescription();
156#endif
157
158 uint8_t GetType() const override;
159 bool IsResponse() const override;
160};
161
162
163 struct INERTIA_API RemoteIOgetADCRequest
164 : RemoteIOCommand
165{
166 RemoteIOgetADCRequest();
167 RemoteIOgetADCRequest(const uint8_t* packet, const unsigned max_size);
168 RemoteIOgetADCRequest(std::wstring const& argString);
169
170 void GetBytes(std::vector<uint8_t>& out) const override;
171 const std::wstring ToString() const override;
172
173#ifdef WITH_BOOST_PROGRAM_OPTIONS
174 static const po::options_description GetOptionDescription();
175#endif
176
177 uint8_t GetType() const override;
178 bool IsResponse() const override;
179};
180
181
182 struct INERTIA_API RemoteIOgetADCResponse
183 : RemoteIOCommand
184{
185 int16_t value;
186
187 RemoteIOgetADCResponse(const uint8_t* packet, const unsigned max_size);
188 RemoteIOgetADCResponse(std::wstring const& argString);
189
190 void GetBytes(std::vector<uint8_t>& out) const override;
191 const std::wstring ToString() const override;
192
193#ifdef WITH_BOOST_PROGRAM_OPTIONS
194 static const po::options_description GetOptionDescription();
195#endif
196
197 uint8_t GetType() const override;
198 bool IsResponse() const override;
199};
200
201}
inertia
Definition FlashCommands.h:6
inertia::RemoteIOCommands
RemoteIOCommands
Definition RemoteIOCommands.h:9
inertia::RemoteIOsetting
RemoteIOsetting
Definition RemoteIOCommands.h:19
inertia::InertiaCommandPtr
std::shared_ptr< InertiaCommand > InertiaCommandPtr
Pointer to an InertiaCommand.
Definition platform.h:52
inertia::InertiaCommandGroups
InertiaCommandGroups
Definition InertiaCommand.h:7