iCub-main
Loading...
Searching...
No Matches
FakeRawValuesPublisher_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: Fri Oct 4 16:28:45 2024
12
13
15#include <yarp/os/LogStream.h>
16#include <yarp/os/Value.h>
17
18namespace {
19 YARP_LOG_COMPONENT(FakeRawValuesPublisherParamsCOMPONENT, "yarp.device.FakeRawValuesPublisher")
20}
21
22
26
27
29{
30 std::vector<std::string> params;
31 params.push_back("name");
32 params.push_back("njomos");
33 params.push_back("threshold");
34 return params;
35}
36
37
38bool FakeRawValuesPublisher_ParamsParser::parseParams(const yarp::os::Searchable & config)
39{
40 //Check for --help option
41 if (config.check("help"))
42 {
43 yCInfo(FakeRawValuesPublisherParamsCOMPONENT) << getDocumentationOfDeviceParams();
44 }
45
46 std::string config_string = config.toString();
47 yarp::os::Property prop_check(config_string.c_str());
48 //Parser of parameter name
49 {
50 if (config.check("name"))
51 {
52 m_name = config.find("name").asString();
53 yCInfo(FakeRawValuesPublisherParamsCOMPONENT) << "Parameter 'name' using value:" << m_name;
54 }
55 else
56 {
57 yCError(FakeRawValuesPublisherParamsCOMPONENT) << "Mandatory parameter 'name' not found!";
58 yCError(FakeRawValuesPublisherParamsCOMPONENT) << "Description of the parameter: Name of the device";
59 return false;
60 }
61 prop_check.unput("name");
62 }
63
64 //Parser of parameter njomos
65 {
66 if (config.check("njomos"))
67 {
68 m_njomos = config.find("njomos").asInt64();
69 yCInfo(FakeRawValuesPublisherParamsCOMPONENT) << "Parameter 'njomos' using value:" << m_njomos;
70 }
71 else
72 {
73 yCError(FakeRawValuesPublisherParamsCOMPONENT) << "Mandatory parameter 'njomos' not found!";
74 yCError(FakeRawValuesPublisherParamsCOMPONENT) << "Description of the parameter: Number of joint or motors to be instantiated";
75 return false;
76 }
77 prop_check.unput("njomos");
78 }
79
80 //Parser of parameter threshold
81 {
82 if (config.check("threshold"))
83 {
84 m_threshold = config.find("threshold").asInt64();
85 yCInfo(FakeRawValuesPublisherParamsCOMPONENT) << "Parameter 'threshold' using value:" << m_threshold;
86 }
87 else
88 {
89 yCError(FakeRawValuesPublisherParamsCOMPONENT) << "Mandatory parameter 'threshold' not found!";
90 yCError(FakeRawValuesPublisherParamsCOMPONENT) << "Description of the parameter: Threshold used for defining the amplitude of the sawthooth curve that simulates periodic raw encoder data";
91 return false;
92 }
93 prop_check.unput("threshold");
94 }
95
96 /*
97 //This code check if the user set some parameter which are not check by the parser
98 //If the parser is set in strict mode, this will generate an error
99 if (prop_check.size() > 0)
100 {
101 bool extra_params_found = false;
102 for (auto it=prop_check.begin(); it!=prop_check.end(); it++)
103 {
104 if (m_parser_is_strict)
105 {
106 yCError(FakeRawValuesPublisherParamsCOMPONENT) << "User asking for parameter: "<<it->name <<" which is unknown to this parser!";
107 extra_params_found = true;
108 }
109 else
110 {
111 yCWarning(FakeRawValuesPublisherParamsCOMPONENT) << "User asking for parameter: "<< it->name <<" which is unknown to this parser!";
112 }
113 }
114
115 if (m_parser_is_strict && extra_params_found)
116 {
117 return false;
118 }
119 }
120 */
121 return true;
122}
123
124
126{
127 std::string doc;
128 doc = doc + std::string("\n=============================================\n");
129 doc = doc + std::string("This is the help for device: FakeRawValuesPublisher\n");
130 doc = doc + std::string("\n");
131 doc = doc + std::string("This is the list of the parameters accepted by the device:\n");
132 doc = doc + std::string("'name': Name of the device\n");
133 doc = doc + std::string("'njomos': Number of joint or motors to be instantiated\n");
134 doc = doc + std::string("'threshold': Threshold used for defining the amplitude of the sawthooth curve that simulates periodic raw encoder data\n");
135 doc = doc + std::string("\n");
136 doc = doc + std::string("Here are some examples of invocation command with yarpdev, with all params:\n");
137 doc = doc + " yarpdev --device fakeRawValuesPublisher --name <mandatory_value> --njomos <mandatory_value> --threshold <mandatory_value>\n";
138 doc = doc + std::string("Using only mandatory params:\n");
139 doc = doc + " yarpdev --device fakeRawValuesPublisher --name <mandatory_value> --njomos <mandatory_value> --threshold <mandatory_value>\n";
140 doc = doc + std::string("=============================================\n\n"); return doc;
141}
bool parseParams(const yarp::os::Searchable &config)