YARP
Yet Another Robot Platform
 
Loading...
Searching...
No Matches
MultipleAnalogSensorsClient_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:42 2025
12
13
15#include <yarp/os/LogStream.h>
16#include <yarp/os/Value.h>
17
18namespace {
19 YARP_LOG_COMPONENT(MultipleAnalogSensorsClientParamsCOMPONENT, "yarp.device.MultipleAnalogSensorsClient")
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("timeout");
34 params.push_back("externalConnection");
35 params.push_back("carrier");
36 return params;
37}
38
39
40bool MultipleAnalogSensorsClient_ParamsParser::getParamValue(const std::string& paramName, std::string& paramValue) const
41{
42 if (paramName =="remote")
43 {
44 paramValue = m_remote;
45 return true;
46 }
47 if (paramName =="local")
48 {
49 paramValue = m_local;
50 return true;
51 }
52 if (paramName =="timeout")
53 {
54 paramValue = std::to_string(m_timeout);
55 return true;
56 }
57 if (paramName =="externalConnection")
58 {
59 if (m_externalConnection==true) paramValue = "true";
60 else paramValue = "false";
61 return true;
62 }
63 if (paramName =="carrier")
64 {
65 paramValue = m_carrier;
66 return true;
67 }
68
69 yError() <<"parameter '" << paramName << "' was not found";
70 return false;
71
72}
73
74
76{
77 //This is a sub-optimal solution.
78 //Ideally getConfiguration() should return all parameters but it is currently
79 //returning only user provided parameters (excluding default values)
80 //This behaviour will be fixed in the near future.
81 std::string s_cfg = m_provided_configuration;
82 return s_cfg;
83}
84
86{
87 //Check for --help option
88 if (config.check("help"))
89 {
90 yCInfo(MultipleAnalogSensorsClientParamsCOMPONENT) << getDocumentationOfDeviceParams();
91 }
92
95 //Parser of parameter remote
96 {
97 if (config.check("remote"))
98 {
99 m_remote = config.find("remote").asString();
100 yCInfo(MultipleAnalogSensorsClientParamsCOMPONENT) << "Parameter 'remote' using value:" << m_remote;
101 }
102 else
103 {
104 yCError(MultipleAnalogSensorsClientParamsCOMPONENT) << "Mandatory parameter 'remote' not found!";
105 yCError(MultipleAnalogSensorsClientParamsCOMPONENT) << "Description of the parameter: Prefix of the ports to which to connect, opened by MultipleAnalogSensorsServer device.";
106 return false;
107 }
108 prop_check.unput("remote");
109 }
110
111 //Parser of parameter local
112 {
113 if (config.check("local"))
114 {
115 m_local = config.find("local").asString();
116 yCInfo(MultipleAnalogSensorsClientParamsCOMPONENT) << "Parameter 'local' using value:" << m_local;
117 }
118 else
119 {
120 yCError(MultipleAnalogSensorsClientParamsCOMPONENT) << "Mandatory parameter 'local' not found!";
121 yCError(MultipleAnalogSensorsClientParamsCOMPONENT) << "Description of the parameter: Port prefix of the ports opened by this device.";
122 return false;
123 }
124 prop_check.unput("local");
125 }
126
127 //Parser of parameter timeout
128 {
129 if (config.check("timeout"))
130 {
131 m_timeout = config.find("timeout").asFloat64();
132 yCInfo(MultipleAnalogSensorsClientParamsCOMPONENT) << "Parameter 'timeout' using value:" << m_timeout;
133 }
134 else
135 {
136 yCInfo(MultipleAnalogSensorsClientParamsCOMPONENT) << "Parameter 'timeout' using DEFAULT value:" << m_timeout;
137 }
138 prop_check.unput("timeout");
139 }
140
141 //Parser of parameter externalConnection
142 {
143 if (config.check("externalConnection"))
144 {
145 m_externalConnection = config.find("externalConnection").asBool();
146 yCInfo(MultipleAnalogSensorsClientParamsCOMPONENT) << "Parameter 'externalConnection' using value:" << m_externalConnection;
147 }
148 else
149 {
150 yCInfo(MultipleAnalogSensorsClientParamsCOMPONENT) << "Parameter 'externalConnection' using DEFAULT value:" << m_externalConnection;
151 }
152 prop_check.unput("externalConnection");
153 }
154
155 //Parser of parameter carrier
156 {
157 if (config.check("carrier"))
158 {
159 m_carrier = config.find("carrier").asString();
160 yCInfo(MultipleAnalogSensorsClientParamsCOMPONENT) << "Parameter 'carrier' using value:" << m_carrier;
161 }
162 else
163 {
164 yCInfo(MultipleAnalogSensorsClientParamsCOMPONENT) << "Parameter 'carrier' using DEFAULT value:" << m_carrier;
165 }
166 prop_check.unput("carrier");
167 }
168
169 /*
170 //This code check if the user set some parameter which are not check by the parser
171 //If the parser is set in strict mode, this will generate an error
172 if (prop_check.size() > 0)
173 {
174 bool extra_params_found = false;
175 for (auto it=prop_check.begin(); it!=prop_check.end(); it++)
176 {
177 if (m_parser_is_strict)
178 {
179 yCError(MultipleAnalogSensorsClientParamsCOMPONENT) << "User asking for parameter: "<<it->name <<" which is unknown to this parser!";
180 extra_params_found = true;
181 }
182 else
183 {
184 yCWarning(MultipleAnalogSensorsClientParamsCOMPONENT) << "User asking for parameter: "<< it->name <<" which is unknown to this parser!";
185 }
186 }
187
188 if (m_parser_is_strict && extra_params_found)
189 {
190 return false;
191 }
192 }
193 */
194 return true;
195}
196
197
199{
200 std::string doc;
201 doc = doc + std::string("\n=============================================\n");
202 doc = doc + std::string("This is the help for device: MultipleAnalogSensorsClient\n");
203 doc = doc + std::string("\n");
204 doc = doc + std::string("This is the list of the parameters accepted by the device:\n");
205 doc = doc + std::string("'remote': Prefix of the ports to which to connect, opened by MultipleAnalogSensorsServer device.\n");
206 doc = doc + std::string("'local': Port prefix of the ports opened by this device.\n");
207 doc = doc + std::string("'timeout': Timeout after which the device reports an error if no measurement was received.\n");
208 doc = doc + std::string("'externalConnection': If set to true, the connection to the rpc port of the MAS server is skipped and it is possible to connect to the data source externally after being opened\n");
209 doc = doc + std::string("'carrier': The carier used for the connection with the server.\n");
210 doc = doc + std::string("\n");
211 doc = doc + std::string("Here are some examples of invocation command with yarpdev, with all params:\n");
212 doc = doc + " yarpdev --device multipleanalogsensorsclient --remote <mandatory_value> --local <mandatory_value> --timeout 0.02 --externalConnection false --carrier tcp\n";
213 doc = doc + std::string("Using only mandatory params:\n");
214 doc = doc + " yarpdev --device multipleanalogsensorsclient --remote <mandatory_value> --local <mandatory_value>\n";
215 doc = doc + std::string("=============================================\n\n"); return doc;
216}
#define yError(...)
Definition Log.h:361
std::string getDocumentationOfDeviceParams() const override
Get the documentation of the DeviceDriver's parameters.
bool getParamValue(const std::string &paramName, std::string &paramValue) const override
Return the value (represented as a string) of the requested parameter.
std::vector< std::string > getListOfParams() const override
Return a list of all params used by the device.
std::string getConfiguration() const override
Return the configuration of the device.
bool parseParams(const yarp::os::Searchable &config) override
Parse the DeviceDriver parameters.
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.
#define yCInfo(component,...)
#define yCError(component,...)
#define YARP_LOG_COMPONENT(name,...)