YARP
Yet Another Robot Platform
 
Loading...
Searching...
No Matches
RemoteControlBoard_ParamsParser.cpp
Go to the documentation of this file.
1/*
2 * SPDX-FileCopyrightText: 2023-2023 Istituto Italiano di Tecnologia (IIT)
3 * SPDX-License-Identifier: LGPL-2.1-or-later
4 */
5
6
7// Generated by yarpDeviceParamParserGenerator (1.0)
8// This is an automatically generated file. Please do not edit it.
9// It will be re-generated if the cmake flag ALLOW_DEVICE_PARAM_PARSER_GERNERATION is ON.
10
11// Generated on: Thu Mar 7 17:59:48 2024
12
13
15#include <yarp/os/LogStream.h>
16#include <yarp/os/Value.h>
17
18namespace {
19 YARP_LOG_COMPONENT(RemoteControlBoardParamsCOMPONENT, "yarp.device.RemoteControlBoard")
20}
21
22
26
27
29{
30 std::vector<std::string> params;
31 params.push_back("remote");
32 params.push_back("local");
33 params.push_back("writeStrict");
34 params.push_back("carrier");
35 params.push_back("timeout");
36 params.push_back("local_qos::enable");
37 params.push_back("local_qos::thread_priority");
38 params.push_back("local_qos::thread_policy");
39 params.push_back("local_qos::packet_priority");
40 params.push_back("remote_qos::enable");
41 params.push_back("remote_qos::thread_priority");
42 params.push_back("remote_qos::thread_policy");
43 params.push_back("remote_qos::packet_priority");
44 params.push_back("ignoreProtocolCheck");
45 params.push_back("diagnostic");
46 return params;
47}
48
49
51{
52 //Check for --help option
53 if (config.check("help"))
54 {
55 yCInfo(RemoteControlBoardParamsCOMPONENT) << getDocumentationOfDeviceParams();
56 }
57
58 std::string config_string = config.toString();
59 yarp::os::Property prop_check(config_string.c_str());
60 //Parser of parameter remote
61 {
62 if (config.check("remote"))
63 {
64 m_remote = config.find("remote").asString();
65 yCInfo(RemoteControlBoardParamsCOMPONENT) << "Parameter 'remote' using value:" << m_remote;
66 }
67 else
68 {
69 yCError(RemoteControlBoardParamsCOMPONENT) << "Mandatory parameter 'remote' not found!";
70 yCError(RemoteControlBoardParamsCOMPONENT) << "Description of the parameter: Prefix of the port to which to connect.";
71 return false;
72 }
73 prop_check.unput("remote");
74 }
75
76 //Parser of parameter local
77 {
78 if (config.check("local"))
79 {
80 m_local = config.find("local").asString();
81 yCInfo(RemoteControlBoardParamsCOMPONENT) << "Parameter 'local' using value:" << m_local;
82 }
83 else
84 {
85 yCError(RemoteControlBoardParamsCOMPONENT) << "Mandatory parameter 'local' not found!";
86 yCError(RemoteControlBoardParamsCOMPONENT) << "Description of the parameter: Port prefix of the port opened by this device.";
87 return false;
88 }
89 prop_check.unput("local");
90 }
91
92 //Parser of parameter writeStrict
93 {
94 if (config.check("writeStrict"))
95 {
96 m_writeStrict = config.find("writeStrict").asString();
97 yCInfo(RemoteControlBoardParamsCOMPONENT) << "Parameter 'writeStrict' using value:" << m_writeStrict;
98 }
99 else
100 {
101 yCInfo(RemoteControlBoardParamsCOMPONENT) << "Parameter 'writeStrict' using DEFAULT value:" << m_writeStrict;
102 }
103 prop_check.unput("writeStrict");
104 }
105
106 //Parser of parameter carrier
107 {
108 if (config.check("carrier"))
109 {
110 m_carrier = config.find("carrier").asString();
111 yCInfo(RemoteControlBoardParamsCOMPONENT) << "Parameter 'carrier' using value:" << m_carrier;
112 }
113 else
114 {
115 yCInfo(RemoteControlBoardParamsCOMPONENT) << "Parameter 'carrier' using DEFAULT value:" << m_carrier;
116 }
117 prop_check.unput("carrier");
118 }
119
120 //Parser of parameter timeout
121 {
122 if (config.check("timeout"))
123 {
124 m_timeout = config.find("timeout").asFloat32();
125 yCInfo(RemoteControlBoardParamsCOMPONENT) << "Parameter 'timeout' using value:" << m_timeout;
126 }
127 else
128 {
129 yCInfo(RemoteControlBoardParamsCOMPONENT) << "Parameter 'timeout' using DEFAULT value:" << m_timeout;
130 }
131 prop_check.unput("timeout");
132 }
133
134 //Parser of parameter local_qos::enable
135 {
136 yarp::os::Bottle sectionp;
137 sectionp = config.findGroup("local_qos");
138 if (sectionp.check("enable"))
139 {
140 m_local_qos_enable = sectionp.find("enable").asBool();
141 yCInfo(RemoteControlBoardParamsCOMPONENT) << "Parameter 'local_qos::enable' using value:" << m_local_qos_enable;
142 }
143 else
144 {
145 yCInfo(RemoteControlBoardParamsCOMPONENT) << "Parameter 'local_qos::enable' using DEFAULT value:" << m_local_qos_enable;
146 }
147 prop_check.unput("local_qos::enable");
148 }
149
150 //Parser of parameter local_qos::thread_priority
151 {
152 yarp::os::Bottle sectionp;
153 sectionp = config.findGroup("local_qos");
154 if (sectionp.check("thread_priority"))
155 {
156 m_local_qos_thread_priority = sectionp.find("thread_priority").asInt64();
157 yCInfo(RemoteControlBoardParamsCOMPONENT) << "Parameter 'local_qos::thread_priority' using value:" << m_local_qos_thread_priority;
158 }
159 else
160 {
161 yCInfo(RemoteControlBoardParamsCOMPONENT) << "Parameter 'local_qos::thread_priority' using DEFAULT value:" << m_local_qos_thread_priority;
162 }
163 prop_check.unput("local_qos::thread_priority");
164 }
165
166 //Parser of parameter local_qos::thread_policy
167 {
168 yarp::os::Bottle sectionp;
169 sectionp = config.findGroup("local_qos");
170 if (sectionp.check("thread_policy"))
171 {
172 m_local_qos_thread_policy = sectionp.find("thread_policy").asInt64();
173 yCInfo(RemoteControlBoardParamsCOMPONENT) << "Parameter 'local_qos::thread_policy' using value:" << m_local_qos_thread_policy;
174 }
175 else
176 {
177 yCInfo(RemoteControlBoardParamsCOMPONENT) << "Parameter 'local_qos::thread_policy' using DEFAULT value:" << m_local_qos_thread_policy;
178 }
179 prop_check.unput("local_qos::thread_policy");
180 }
181
182 //Parser of parameter local_qos::packet_priority
183 {
184 yarp::os::Bottle sectionp;
185 sectionp = config.findGroup("local_qos");
186 if (sectionp.check("packet_priority"))
187 {
188 m_local_qos_packet_priority = sectionp.find("packet_priority").asString();
189 yCInfo(RemoteControlBoardParamsCOMPONENT) << "Parameter 'local_qos::packet_priority' using value:" << m_local_qos_packet_priority;
190 }
191 else
192 {
193 yCInfo(RemoteControlBoardParamsCOMPONENT) << "Parameter 'local_qos::packet_priority' using DEFAULT value:" << m_local_qos_packet_priority;
194 }
195 prop_check.unput("local_qos::packet_priority");
196 }
197
198 //Parser of parameter remote_qos::enable
199 {
200 yarp::os::Bottle sectionp;
201 sectionp = config.findGroup("remote_qos");
202 if (sectionp.check("enable"))
203 {
204 m_remote_qos_enable = sectionp.find("enable").asBool();
205 yCInfo(RemoteControlBoardParamsCOMPONENT) << "Parameter 'remote_qos::enable' using value:" << m_remote_qos_enable;
206 }
207 else
208 {
209 yCInfo(RemoteControlBoardParamsCOMPONENT) << "Parameter 'remote_qos::enable' using DEFAULT value:" << m_remote_qos_enable;
210 }
211 prop_check.unput("remote_qos::enable");
212 }
213
214 //Parser of parameter remote_qos::thread_priority
215 {
216 yarp::os::Bottle sectionp;
217 sectionp = config.findGroup("remote_qos");
218 if (sectionp.check("thread_priority"))
219 {
220 m_remote_qos_thread_priority = sectionp.find("thread_priority").asInt64();
221 yCInfo(RemoteControlBoardParamsCOMPONENT) << "Parameter 'remote_qos::thread_priority' using value:" << m_remote_qos_thread_priority;
222 }
223 else
224 {
225 yCInfo(RemoteControlBoardParamsCOMPONENT) << "Parameter 'remote_qos::thread_priority' using DEFAULT value:" << m_remote_qos_thread_priority;
226 }
227 prop_check.unput("remote_qos::thread_priority");
228 }
229
230 //Parser of parameter remote_qos::thread_policy
231 {
232 yarp::os::Bottle sectionp;
233 sectionp = config.findGroup("remote_qos");
234 if (sectionp.check("thread_policy"))
235 {
236 m_remote_qos_thread_policy = sectionp.find("thread_policy").asInt64();
237 yCInfo(RemoteControlBoardParamsCOMPONENT) << "Parameter 'remote_qos::thread_policy' using value:" << m_remote_qos_thread_policy;
238 }
239 else
240 {
241 yCInfo(RemoteControlBoardParamsCOMPONENT) << "Parameter 'remote_qos::thread_policy' using DEFAULT value:" << m_remote_qos_thread_policy;
242 }
243 prop_check.unput("remote_qos::thread_policy");
244 }
245
246 //Parser of parameter remote_qos::packet_priority
247 {
248 yarp::os::Bottle sectionp;
249 sectionp = config.findGroup("remote_qos");
250 if (sectionp.check("packet_priority"))
251 {
252 m_remote_qos_packet_priority = sectionp.find("packet_priority").asString();
253 yCInfo(RemoteControlBoardParamsCOMPONENT) << "Parameter 'remote_qos::packet_priority' using value:" << m_remote_qos_packet_priority;
254 }
255 else
256 {
257 yCInfo(RemoteControlBoardParamsCOMPONENT) << "Parameter 'remote_qos::packet_priority' using DEFAULT value:" << m_remote_qos_packet_priority;
258 }
259 prop_check.unput("remote_qos::packet_priority");
260 }
261
262 //Parser of parameter ignoreProtocolCheck
263 {
264 if (config.check("ignoreProtocolCheck"))
265 {
266 m_ignoreProtocolCheck = config.find("ignoreProtocolCheck").asBool();
267 yCInfo(RemoteControlBoardParamsCOMPONENT) << "Parameter 'ignoreProtocolCheck' using value:" << m_ignoreProtocolCheck;
268 }
269 else
270 {
271 yCInfo(RemoteControlBoardParamsCOMPONENT) << "Parameter 'ignoreProtocolCheck' using DEFAULT value:" << m_ignoreProtocolCheck;
272 }
273 prop_check.unput("ignoreProtocolCheck");
274 }
275
276 //Parser of parameter diagnostic
277 {
278 if (config.check("diagnostic"))
279 {
280 m_diagnostic = config.find("diagnostic").asBool();
281 yCInfo(RemoteControlBoardParamsCOMPONENT) << "Parameter 'diagnostic' using value:" << m_diagnostic;
282 }
283 else
284 {
285 yCInfo(RemoteControlBoardParamsCOMPONENT) << "Parameter 'diagnostic' using DEFAULT value:" << m_diagnostic;
286 }
287 prop_check.unput("diagnostic");
288 }
289
290 /*
291 //This code check if the user set some parameter which are not check by the parser
292 //If the parser is set in strict mode, this will generate an error
293 if (prop_check.size() > 0)
294 {
295 bool extra_params_found = false;
296 for (auto it=prop_check.begin(); it!=prop_check.end(); it++)
297 {
298 if (m_parser_is_strict)
299 {
300 yCError(RemoteControlBoardParamsCOMPONENT) << "User asking for parameter: "<<it->name <<" which is unknown to this parser!";
301 extra_params_found = true;
302 }
303 else
304 {
305 yCWarning(RemoteControlBoardParamsCOMPONENT) << "User asking for parameter: "<< it->name <<" which is unknown to this parser!";
306 }
307 }
308
309 if (m_parser_is_strict && extra_params_found)
310 {
311 return false;
312 }
313 }
314 */
315 return true;
316}
317
318
320{
321 std::string doc;
322 doc = doc + std::string("\n=============================================\n");
323 doc = doc + std::string("This is the help for device: RemoteControlBoard\n");
324 doc = doc + std::string("\n");
325 doc = doc + std::string("This is the list of the parameters accepted by the device:\n");
326 doc = doc + std::string("'remote': Prefix of the port to which to connect.\n");
327 doc = doc + std::string("'local': Port prefix of the port opened by this device.\n");
328 doc = doc + std::string("'writeStrict': It can be 'on' or 'off'\n");
329 doc = doc + std::string("'carrier': carrier used for streaming robot state\n");
330 doc = doc + std::string("'timeout': timeout for the input port which receives the streamed robot state\n");
331 doc = doc + std::string("'local_qos::enable': Enable the usage of local Qos\n");
332 doc = doc + std::string("'local_qos::thread_priority': Local Qos. See https://yarp.it/latest/channelprioritization.html\n");
333 doc = doc + std::string("'local_qos::thread_policy': Local Qos. See https://yarp.it/latest/channelprioritization.html\n");
334 doc = doc + std::string("'local_qos::packet_priority': Local Qos. See https://yarp.it/latest/channelprioritization.html\n");
335 doc = doc + std::string("'remote_qos::enable': Enable the usage of remote Qos\n");
336 doc = doc + std::string("'remote_qos::thread_priority': Remote Qos. See https://yarp.it/latest/channelprioritization.html\n");
337 doc = doc + std::string("'remote_qos::thread_policy': Remote Qos. See https://yarp.it/latest/channelprioritization.html.\n");
338 doc = doc + std::string("'remote_qos::packet_priority': Remote Qos. See https://yarp.it/latest/channelprioritization.html.\n");
339 doc = doc + std::string("'ignoreProtocolCheck': For development purpose only\n");
340 doc = doc + std::string("'diagnostic': For development purpose only\n");
341 doc = doc + std::string("\n");
342 doc = doc + std::string("Here are some examples of invocation command with yarpdev, with all params:\n");
343 doc = doc + " yarpdev --device remote_controlboard --remote <mandatory_value> --local <mandatory_value> --writeStrict <optional_value> --carrier udp --timeout 0.5 --local_qos::enable false --local_qos::thread_priority 0 --local_qos::thread_policy 0 --local_qos::packet_priority <optional_value> --remote_qos::enable false --remote_qos::thread_priority 0 --remote_qos::thread_policy 0 --remote_qos::packet_priority <optional_value> --ignoreProtocolCheck false --diagnostic false\n";
344 doc = doc + std::string("Using only mandatory params:\n");
345 doc = doc + " yarpdev --device remote_controlboard --remote <mandatory_value> --local <mandatory_value>\n";
346 doc = doc + std::string("=============================================\n\n"); return doc;
347}
std::vector< std::string > getListOfParams() const override
Return a list of all params used by the device.
std::string getDocumentationOfDeviceParams() const override
Get the documentation of the DeviceDriver's parameters.
bool parseParams(const yarp::os::Searchable &config) override
Parse the DeviceDriver parameters.
A simple collection of objects that can be described and transmitted in a portable way.
Definition Bottle.h:64
bool check(const std::string &key) const override
Check if there exists a property of the given name.
Definition Bottle.cpp:277
Value & find(const std::string &key) const override
Gets a value corresponding to a given keyword.
Definition Bottle.cpp:287
A class for storing options and configuration information.
Definition Property.h:33
void unput(const std::string &key)
Remove the association from the given key to a value, if present.
A base class for nested structures that can be searched.
Definition Searchable.h:31
virtual bool check(const std::string &key) const =0
Check if there exists a property of the given name.
virtual std::string toString() const =0
Return a standard text representation of the content of the object.
virtual Value & find(const std::string &key) const =0
Gets a value corresponding to a given keyword.
virtual Bottle & findGroup(const std::string &key) const =0
Gets a list corresponding to a given keyword.
virtual std::int64_t asInt64() const
Get 64-bit integer value.
Definition Value.cpp:210
virtual bool asBool() const
Get boolean value.
Definition Value.cpp:186
virtual std::string asString() const
Get string value.
Definition Value.cpp:234
#define yCInfo(component,...)
#define yCError(component,...)
#define YARP_LOG_COMPONENT(name,...)