30 std::vector<std::string> params;
31 params.push_back(
"name");
32 params.push_back(
"period");
33 params.push_back(
"enable_shutdown");
34 params.push_back(
"enable_log");
35 params.push_back(
"quitPortName");
42 if (paramName ==
"name")
47 if (paramName ==
"period")
49 paramValue = std::to_string(
m_period);
52 if (paramName ==
"enable_shutdown")
55 else paramValue =
"false";
58 if (paramName ==
"enable_log")
61 else paramValue =
"false";
64 if (paramName ==
"quitPortName")
70 yError() <<
"parameter '" << paramName <<
"' was not found";
89 if (config.
check(
"help"))
98 if (config.
check(
"name"))
101 yCInfo(Battery_nws_yarpParamsCOMPONENT) <<
"Parameter 'name' using value:" <<
m_name;
105 yCError(Battery_nws_yarpParamsCOMPONENT) <<
"Mandatory parameter 'name' not found!";
106 yCError(Battery_nws_yarpParamsCOMPONENT) <<
"Description of the parameter: prefix of the ports opened by the device";
109 prop_check.
unput(
"name");
114 if (config.
check(
"period"))
117 yCInfo(Battery_nws_yarpParamsCOMPONENT) <<
"Parameter 'period' using value:" <<
m_period;
121 yCInfo(Battery_nws_yarpParamsCOMPONENT) <<
"Parameter 'period' using DEFAULT value:" <<
m_period;
123 prop_check.
unput(
"period");
128 if (config.
check(
"enable_shutdown"))
135 yCInfo(Battery_nws_yarpParamsCOMPONENT) <<
"Parameter 'enable_shutdown' using DEFAULT value:" <<
m_enable_shutdown;
137 prop_check.
unput(
"enable_shutdown");
142 if (config.
check(
"enable_log"))
145 yCInfo(Battery_nws_yarpParamsCOMPONENT) <<
"Parameter 'enable_log' using value:" <<
m_enable_log;
149 yCInfo(Battery_nws_yarpParamsCOMPONENT) <<
"Parameter 'enable_log' using DEFAULT value:" <<
m_enable_log;
151 prop_check.
unput(
"enable_log");
156 if (config.
check(
"quitPortName"))
159 yCInfo(Battery_nws_yarpParamsCOMPONENT) <<
"Parameter 'quitPortName' using value:" <<
m_quitPortName;
163 yCInfo(Battery_nws_yarpParamsCOMPONENT) <<
"Parameter 'quitPortName' using DEFAULT value:" <<
m_quitPortName;
165 prop_check.
unput(
"quitPortName");
200 doc = doc + std::string(
"\n=============================================\n");
201 doc = doc + std::string(
"This is the help for device: Battery_nws_yarp\n");
202 doc = doc + std::string(
"\n");
203 doc = doc + std::string(
"This is the list of the parameters accepted by the device:\n");
204 doc = doc + std::string(
"'name': prefix of the ports opened by the device\n");
205 doc = doc + std::string(
"'period': refresh period of the broadcasted values in seconds\n");
206 doc = doc + std::string(
"'enable_shutdown': if enabled, batteryWrapper will start a system shutdown when charge is below 5%\n");
207 doc = doc + std::string(
"'enable_log': if enabled, stores a log of battery usage on disk\n");
208 doc = doc + std::string(
"'quitPortName': if present, this yarp port will be opened and used to send a sthutdown command to other processes\n");
209 doc = doc + std::string(
"\n");
210 doc = doc + std::string(
"Here are some examples of invocation command with yarpdev, with all params:\n");
211 doc = doc +
" yarpdev --device battery_nws_yarp --name /robotName/battery1 --period 1.0 --enable_shutdown false --enable_log false --quitPortName <optional_value>\n";
212 doc = doc + std::string(
"Using only mandatory params:\n");
213 doc = doc +
" yarpdev --device battery_nws_yarp --name /robotName/battery1\n";
214 doc = doc + std::string(
"=============================================\n\n");
return doc;
Battery_nws_yarp_ParamsParser()
std::string m_provided_configuration
std::string getConfiguration() const override
Return the configuration of the device.
bool getParamValue(const std::string ¶mName, std::string ¶mValue) const override
Return the value (represented as a string) of the requested parameter.
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.
std::string m_quitPortName
std::vector< std::string > getListOfParams() const override
Return a list of all params used by the device.
A class for storing options and configuration information.
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.
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,...)