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 (2.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 May 22 11:32:44 2025
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
50bool RemoteControlBoard_ParamsParser::getParamValue(const std::string& paramName, std::string& paramValue) const
51{
52 if (paramName =="remote")
53 {
54 paramValue = m_remote;
55 return true;
56 }
57 if (paramName =="local")
58 {
59 paramValue = m_local;
60 return true;
61 }
62 if (paramName =="writeStrict")
63 {
64 paramValue = m_writeStrict;
65 return true;
66 }
67 if (paramName =="carrier")
68 {
69 paramValue = m_carrier;
70 return true;
71 }
72 if (paramName =="timeout")
73 {
74 paramValue = std::to_string(m_timeout);
75 return true;
76 }
77 if (paramName =="local_qos::enable")
78 {
79 if (m_local_qos_enable==true) paramValue = "true";
80 else paramValue = "false";
81 return true;
82 }
83 if (paramName =="local_qos::thread_priority")
84 {
85 paramValue = std::to_string(m_local_qos_thread_priority);
86 return true;
87 }
88 if (paramName =="local_qos::thread_policy")
89 {
90 paramValue = std::to_string(m_local_qos_thread_policy);
91 return true;
92 }
93 if (paramName =="local_qos::packet_priority")
94 {
95 paramValue = m_local_qos_packet_priority;
96 return true;
97 }
98 if (paramName =="remote_qos::enable")
99 {
100 if (m_remote_qos_enable==true) paramValue = "true";
101 else paramValue = "false";
102 return true;
103 }
104 if (paramName =="remote_qos::thread_priority")
105 {
106 paramValue = std::to_string(m_remote_qos_thread_priority);
107 return true;
108 }
109 if (paramName =="remote_qos::thread_policy")
110 {
111 paramValue = std::to_string(m_remote_qos_thread_policy);
112 return true;
113 }
114 if (paramName =="remote_qos::packet_priority")
115 {
116 paramValue = m_remote_qos_packet_priority;
117 return true;
118 }
119 if (paramName =="ignoreProtocolCheck")
120 {
121 if (m_ignoreProtocolCheck==true) paramValue = "true";
122 else paramValue = "false";
123 return true;
124 }
125 if (paramName =="diagnostic")
126 {
127 if (m_diagnostic==true) paramValue = "true";
128 else paramValue = "false";
129 return true;
130 }
131
132 yError() <<"parameter '" << paramName << "' was not found";
133 return false;
134
135}
136
137
139{
140 //This is a sub-optimal solution.
141 //Ideally getConfiguration() should return all parameters but it is currently
142 //returning only user provided parameters (excluding default values)
143 //This behaviour will be fixed in the near future.
144 std::string s_cfg = m_provided_configuration;
145 return s_cfg;
146}
147
149{
150 //Check for --help option
151 if (config.check("help"))
152 {
153 yCInfo(RemoteControlBoardParamsCOMPONENT) << getDocumentationOfDeviceParams();
154 }
155
158 //Parser of parameter remote
159 {
160 if (config.check("remote"))
161 {
162 m_remote = config.find("remote").asString();
163 yCInfo(RemoteControlBoardParamsCOMPONENT) << "Parameter 'remote' using value:" << m_remote;
164 }
165 else
166 {
167 yCError(RemoteControlBoardParamsCOMPONENT) << "Mandatory parameter 'remote' not found!";
168 yCError(RemoteControlBoardParamsCOMPONENT) << "Description of the parameter: Prefix of the port to which to connect.";
169 return false;
170 }
171 prop_check.unput("remote");
172 }
173
174 //Parser of parameter local
175 {
176 if (config.check("local"))
177 {
178 m_local = config.find("local").asString();
179 yCInfo(RemoteControlBoardParamsCOMPONENT) << "Parameter 'local' using value:" << m_local;
180 }
181 else
182 {
183 yCError(RemoteControlBoardParamsCOMPONENT) << "Mandatory parameter 'local' not found!";
184 yCError(RemoteControlBoardParamsCOMPONENT) << "Description of the parameter: Port prefix of the port opened by this device.";
185 return false;
186 }
187 prop_check.unput("local");
188 }
189
190 //Parser of parameter writeStrict
191 {
192 if (config.check("writeStrict"))
193 {
194 m_writeStrict = config.find("writeStrict").asString();
195 yCInfo(RemoteControlBoardParamsCOMPONENT) << "Parameter 'writeStrict' using value:" << m_writeStrict;
196 }
197 else
198 {
199 yCInfo(RemoteControlBoardParamsCOMPONENT) << "Parameter 'writeStrict' using DEFAULT value:" << m_writeStrict;
200 }
201 prop_check.unput("writeStrict");
202 }
203
204 //Parser of parameter carrier
205 {
206 if (config.check("carrier"))
207 {
208 m_carrier = config.find("carrier").asString();
209 yCInfo(RemoteControlBoardParamsCOMPONENT) << "Parameter 'carrier' using value:" << m_carrier;
210 }
211 else
212 {
213 yCInfo(RemoteControlBoardParamsCOMPONENT) << "Parameter 'carrier' using DEFAULT value:" << m_carrier;
214 }
215 prop_check.unput("carrier");
216 }
217
218 //Parser of parameter timeout
219 {
220 if (config.check("timeout"))
221 {
222 m_timeout = config.find("timeout").asFloat32();
223 yCInfo(RemoteControlBoardParamsCOMPONENT) << "Parameter 'timeout' using value:" << m_timeout;
224 }
225 else
226 {
227 yCInfo(RemoteControlBoardParamsCOMPONENT) << "Parameter 'timeout' using DEFAULT value:" << m_timeout;
228 }
229 prop_check.unput("timeout");
230 }
231
232 //Parser of parameter local_qos::enable
233 {
234 yarp::os::Bottle sectionp;
235 sectionp = config.findGroup("local_qos");
236 if (sectionp.check("enable"))
237 {
238 m_local_qos_enable = sectionp.find("enable").asBool();
239 yCInfo(RemoteControlBoardParamsCOMPONENT) << "Parameter 'local_qos::enable' using value:" << m_local_qos_enable;
240 }
241 else
242 {
243 yCInfo(RemoteControlBoardParamsCOMPONENT) << "Parameter 'local_qos::enable' using DEFAULT value:" << m_local_qos_enable;
244 }
245 prop_check.unput("local_qos::enable");
246 }
247
248 //Parser of parameter local_qos::thread_priority
249 {
250 yarp::os::Bottle sectionp;
251 sectionp = config.findGroup("local_qos");
252 if (sectionp.check("thread_priority"))
253 {
254 m_local_qos_thread_priority = sectionp.find("thread_priority").asInt64();
255 yCInfo(RemoteControlBoardParamsCOMPONENT) << "Parameter 'local_qos::thread_priority' using value:" << m_local_qos_thread_priority;
256 }
257 else
258 {
259 yCInfo(RemoteControlBoardParamsCOMPONENT) << "Parameter 'local_qos::thread_priority' using DEFAULT value:" << m_local_qos_thread_priority;
260 }
261 prop_check.unput("local_qos::thread_priority");
262 }
263
264 //Parser of parameter local_qos::thread_policy
265 {
266 yarp::os::Bottle sectionp;
267 sectionp = config.findGroup("local_qos");
268 if (sectionp.check("thread_policy"))
269 {
270 m_local_qos_thread_policy = sectionp.find("thread_policy").asInt64();
271 yCInfo(RemoteControlBoardParamsCOMPONENT) << "Parameter 'local_qos::thread_policy' using value:" << m_local_qos_thread_policy;
272 }
273 else
274 {
275 yCInfo(RemoteControlBoardParamsCOMPONENT) << "Parameter 'local_qos::thread_policy' using DEFAULT value:" << m_local_qos_thread_policy;
276 }
277 prop_check.unput("local_qos::thread_policy");
278 }
279
280 //Parser of parameter local_qos::packet_priority
281 {
282 yarp::os::Bottle sectionp;
283 sectionp = config.findGroup("local_qos");
284 if (sectionp.check("packet_priority"))
285 {
286 m_local_qos_packet_priority = sectionp.find("packet_priority").asString();
287 yCInfo(RemoteControlBoardParamsCOMPONENT) << "Parameter 'local_qos::packet_priority' using value:" << m_local_qos_packet_priority;
288 }
289 else
290 {
291 yCInfo(RemoteControlBoardParamsCOMPONENT) << "Parameter 'local_qos::packet_priority' using DEFAULT value:" << m_local_qos_packet_priority;
292 }
293 prop_check.unput("local_qos::packet_priority");
294 }
295
296 //Parser of parameter remote_qos::enable
297 {
298 yarp::os::Bottle sectionp;
299 sectionp = config.findGroup("remote_qos");
300 if (sectionp.check("enable"))
301 {
302 m_remote_qos_enable = sectionp.find("enable").asBool();
303 yCInfo(RemoteControlBoardParamsCOMPONENT) << "Parameter 'remote_qos::enable' using value:" << m_remote_qos_enable;
304 }
305 else
306 {
307 yCInfo(RemoteControlBoardParamsCOMPONENT) << "Parameter 'remote_qos::enable' using DEFAULT value:" << m_remote_qos_enable;
308 }
309 prop_check.unput("remote_qos::enable");
310 }
311
312 //Parser of parameter remote_qos::thread_priority
313 {
314 yarp::os::Bottle sectionp;
315 sectionp = config.findGroup("remote_qos");
316 if (sectionp.check("thread_priority"))
317 {
318 m_remote_qos_thread_priority = sectionp.find("thread_priority").asInt64();
319 yCInfo(RemoteControlBoardParamsCOMPONENT) << "Parameter 'remote_qos::thread_priority' using value:" << m_remote_qos_thread_priority;
320 }
321 else
322 {
323 yCInfo(RemoteControlBoardParamsCOMPONENT) << "Parameter 'remote_qos::thread_priority' using DEFAULT value:" << m_remote_qos_thread_priority;
324 }
325 prop_check.unput("remote_qos::thread_priority");
326 }
327
328 //Parser of parameter remote_qos::thread_policy
329 {
330 yarp::os::Bottle sectionp;
331 sectionp = config.findGroup("remote_qos");
332 if (sectionp.check("thread_policy"))
333 {
334 m_remote_qos_thread_policy = sectionp.find("thread_policy").asInt64();
335 yCInfo(RemoteControlBoardParamsCOMPONENT) << "Parameter 'remote_qos::thread_policy' using value:" << m_remote_qos_thread_policy;
336 }
337 else
338 {
339 yCInfo(RemoteControlBoardParamsCOMPONENT) << "Parameter 'remote_qos::thread_policy' using DEFAULT value:" << m_remote_qos_thread_policy;
340 }
341 prop_check.unput("remote_qos::thread_policy");
342 }
343
344 //Parser of parameter remote_qos::packet_priority
345 {
346 yarp::os::Bottle sectionp;
347 sectionp = config.findGroup("remote_qos");
348 if (sectionp.check("packet_priority"))
349 {
350 m_remote_qos_packet_priority = sectionp.find("packet_priority").asString();
351 yCInfo(RemoteControlBoardParamsCOMPONENT) << "Parameter 'remote_qos::packet_priority' using value:" << m_remote_qos_packet_priority;
352 }
353 else
354 {
355 yCInfo(RemoteControlBoardParamsCOMPONENT) << "Parameter 'remote_qos::packet_priority' using DEFAULT value:" << m_remote_qos_packet_priority;
356 }
357 prop_check.unput("remote_qos::packet_priority");
358 }
359
360 //Parser of parameter ignoreProtocolCheck
361 {
362 if (config.check("ignoreProtocolCheck"))
363 {
364 m_ignoreProtocolCheck = config.find("ignoreProtocolCheck").asBool();
365 yCInfo(RemoteControlBoardParamsCOMPONENT) << "Parameter 'ignoreProtocolCheck' using value:" << m_ignoreProtocolCheck;
366 }
367 else
368 {
369 yCInfo(RemoteControlBoardParamsCOMPONENT) << "Parameter 'ignoreProtocolCheck' using DEFAULT value:" << m_ignoreProtocolCheck;
370 }
371 prop_check.unput("ignoreProtocolCheck");
372 }
373
374 //Parser of parameter diagnostic
375 {
376 if (config.check("diagnostic"))
377 {
378 m_diagnostic = config.find("diagnostic").asBool();
379 yCInfo(RemoteControlBoardParamsCOMPONENT) << "Parameter 'diagnostic' using value:" << m_diagnostic;
380 }
381 else
382 {
383 yCInfo(RemoteControlBoardParamsCOMPONENT) << "Parameter 'diagnostic' using DEFAULT value:" << m_diagnostic;
384 }
385 prop_check.unput("diagnostic");
386 }
387
388 /*
389 //This code check if the user set some parameter which are not check by the parser
390 //If the parser is set in strict mode, this will generate an error
391 if (prop_check.size() > 0)
392 {
393 bool extra_params_found = false;
394 for (auto it=prop_check.begin(); it!=prop_check.end(); it++)
395 {
396 if (m_parser_is_strict)
397 {
398 yCError(RemoteControlBoardParamsCOMPONENT) << "User asking for parameter: "<<it->name <<" which is unknown to this parser!";
399 extra_params_found = true;
400 }
401 else
402 {
403 yCWarning(RemoteControlBoardParamsCOMPONENT) << "User asking for parameter: "<< it->name <<" which is unknown to this parser!";
404 }
405 }
406
407 if (m_parser_is_strict && extra_params_found)
408 {
409 return false;
410 }
411 }
412 */
413 return true;
414}
415
416
418{
419 std::string doc;
420 doc = doc + std::string("\n=============================================\n");
421 doc = doc + std::string("This is the help for device: RemoteControlBoard\n");
422 doc = doc + std::string("\n");
423 doc = doc + std::string("This is the list of the parameters accepted by the device:\n");
424 doc = doc + std::string("'remote': Prefix of the port to which to connect.\n");
425 doc = doc + std::string("'local': Port prefix of the port opened by this device.\n");
426 doc = doc + std::string("'writeStrict': It can be 'on' or 'off'\n");
427 doc = doc + std::string("'carrier': carrier used for streaming robot state\n");
428 doc = doc + std::string("'timeout': timeout for the input port which receives the streamed robot state\n");
429 doc = doc + std::string("'local_qos::enable': Enable the usage of local Qos\n");
430 doc = doc + std::string("'local_qos::thread_priority': Local Qos. See https://yarp.it/latest/channelprioritization.html\n");
431 doc = doc + std::string("'local_qos::thread_policy': Local Qos. See https://yarp.it/latest/channelprioritization.html\n");
432 doc = doc + std::string("'local_qos::packet_priority': Local Qos. See https://yarp.it/latest/channelprioritization.html\n");
433 doc = doc + std::string("'remote_qos::enable': Enable the usage of remote Qos\n");
434 doc = doc + std::string("'remote_qos::thread_priority': Remote Qos. See https://yarp.it/latest/channelprioritization.html\n");
435 doc = doc + std::string("'remote_qos::thread_policy': Remote Qos. See https://yarp.it/latest/channelprioritization.html.\n");
436 doc = doc + std::string("'remote_qos::packet_priority': Remote Qos. See https://yarp.it/latest/channelprioritization.html.\n");
437 doc = doc + std::string("'ignoreProtocolCheck': For development purpose only\n");
438 doc = doc + std::string("'diagnostic': For development purpose only\n");
439 doc = doc + std::string("\n");
440 doc = doc + std::string("Here are some examples of invocation command with yarpdev, with all params:\n");
441 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";
442 doc = doc + std::string("Using only mandatory params:\n");
443 doc = doc + " yarpdev --device remote_controlboard --remote <mandatory_value> --local <mandatory_value>\n";
444 doc = doc + std::string("=============================================\n\n"); return doc;
445}
#define yError(...)
Definition Log.h:361
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.
std::string getConfiguration() const override
Return the configuration of the device.
bool parseParams(const yarp::os::Searchable &config) override
Parse the DeviceDriver parameters.
bool getParamValue(const std::string &paramName, std::string &paramValue) const override
Return the value (represented as a string) of the requested parameter.
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,...)