Skip to content

Commit

Permalink
initial commit to test the CI:
Browse files Browse the repository at this point in the history
- fixed capital letters of source files
- added parser to CMakeLists.txt
- added dummy param files as placeholders
  • Loading branch information
randaz81 committed Feb 9, 2024
1 parent 3e5d0a7 commit 6557f19
Show file tree
Hide file tree
Showing 137 changed files with 5,226 additions and 217 deletions.
7 changes: 5 additions & 2 deletions src/devices/fake/fakeAnalogSensor/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,14 @@ yarp_prepare_plugin(fakeAnalogSensor

if(ENABLE_fakeAnalogSensor)
yarp_add_plugin(yarp_fakeAnalogSensor)
generateDeviceParamsParser(FakeAnalogSensor)

target_sources(yarp_fakeAnalogSensor
PRIVATE
fakeAnalogSensor.cpp
fakeAnalogSensor.h
FakeAnalogSensor.cpp
FakeAnalogSensor.h
FakeAnalogSensor_ParamsParser.cpp
FakeAnalogSensor_ParamsParser.h
)

target_link_libraries(yarp_fakeAnalogSensor
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,98 @@
/*
* SPDX-FileCopyrightText: 2023-2023 Istituto Italiano di Tecnologia (IIT)
* SPDX-License-Identifier: LGPL-2.1-or-later
*/


// Generated by yarpDeviceParamParserGenerator (1.0)
// This is an automatically generated file. Please do not edit it.
// It will be re-generated if the cmake flag ALLOW_DEVICE_PARAM_PARSER_GERNERATION is ON.

// Generated on: Fri Feb 9 20:17:51 2024


#include "FakeAnalogSensor_ParamsParser.h"
#include <yarp/os/LogStream.h>
#include <yarp/os/Value.h>

namespace {
YARP_LOG_COMPONENT(FakeAnalogSensorParamsCOMPONENT, "yarp.device.FakeAnalogSensor")
}


std::vector<std::string> FakeAnalogSensor_ParamsParser::getListOfParams() const
{
std::vector<std::string> params;
params.push_back("period");
return params;
}


bool FakeAnalogSensor_ParamsParser::parseParams(const yarp::os::Searchable & config)
{
//Check for --help option
if (config.check("help"))
{
yCInfo(FakeAnalogSensorParamsCOMPONENT) << getDocumentationOfDeviceParams();
}

std::string config_string = config.toString();
yarp::os::Property prop_check(config_string.c_str());
//Parser of parameter period
{
if (config.check("period"))
{
m_period = config.find("period").asFloat64();
yCInfo(FakeAnalogSensorParamsCOMPONENT) << "Parameter 'period' using value:" << m_period;
}
else
{
yCInfo(FakeAnalogSensorParamsCOMPONENT) << "Parameter 'period' using DEFAULT value:" << m_period;
}
prop_check.unput("period");
}

/*
//This code check if the user set some parameter which are not check by the parser
//If the parser is set in strict mode, this will generate an error
if (prop_check.size() > 0)
{
bool extra_params_found = false;
for (auto it=prop_check.begin(); it!=prop_check.end(); it++)
{
if (m_parser_is_strict)
{
yCError(FakeAnalogSensorParamsCOMPONENT) << "User asking for parameter: "<<it->name <<" which is unknown to this parser!";
extra_params_found = true;
}
else
{
yCWarning(FakeAnalogSensorParamsCOMPONENT) << "User asking for parameter: "<< it->name <<" which is unknown to this parser!";
}
}
if (m_parser_is_strict && extra_params_found)
{
return false;
}
}
*/
return true;
}


std::string FakeAnalogSensor_ParamsParser::getDocumentationOfDeviceParams() const
{
std::string doc;
doc = doc + std::string("\n=============================================\n");
doc = doc + std::string("This is the help for device: FakeAnalogSensor\n");
doc = doc + std::string("\n");
doc = doc + std::string("This is the list of the parameters accepted by the device:\n");
doc = doc + std::string("'period': thread period\n");
doc = doc + std::string("\n");
doc = doc + std::string("Here are some examples of invocation command with yarpdev, with all params:\n");
doc = doc + " yarpdev --device FakeAnalogSensor --period 1.0\n";
doc = doc + std::string("Using only mandatory params:\n");
doc = doc + " yarpdev --device FakeAnalogSensor\n";
doc = doc + std::string("=============================================\n\n"); return doc;
}
64 changes: 64 additions & 0 deletions src/devices/fake/fakeAnalogSensor/FakeAnalogSensor_ParamsParser.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
/*
* SPDX-FileCopyrightText: 2023-2023 Istituto Italiano di Tecnologia (IIT)
* SPDX-License-Identifier: LGPL-2.1-or-later
*/


// Generated by yarpDeviceParamParserGenerator (1.0)
// This is an automatically generated file. Please do not edit it.
// It will be re-generated if the cmake flag ALLOW_DEVICE_PARAM_PARSER_GERNERATION is ON.

// Generated on: Fri Feb 9 20:17:51 2024


#ifndef FAKEANALOGSENSOR_PARAMSPARSER_H
#define FAKEANALOGSENSOR_PARAMSPARSER_H

#include <yarp/os/Searchable.h>
#include <yarp/dev/IDeviceDriverParams.h>
#include <string>
#include <cmath>

/**
* This class is the parameters parser for class FakeAnalogSensor.
*
* These are the used parameters:
* | Group name | Parameter name | Type | Units | Default Value | Required | Description | Notes |
* |:----------:|:--------------:|:------:|:-----:|:-------------:|:--------:|:-------------:|:----------------------:|
* | - | period | double | s | 1.0 | 0 | thread period | optional, default 1.0s |
*
* The device can be launched by yarpdev using one of the following examples:
* \code{.unparsed}
* yarpdev --device FakeAnalogSensor --period 1.0
* \endcode
*
* \code{.unparsed}
* yarpdev --device FakeAnalogSensor
* \endcode
*
*/

class FakeAnalogSensor_ParamsParser : public yarp::dev::IDeviceDriverParams
{
public:
FakeAnalogSensor_ParamsParser() = default;
~FakeAnalogSensor_ParamsParser() override = default;

public:
const std::string m_device_type = {"FakeAnalogSensor"};
bool m_parser_is_strict = false;
struct parser_version_type
{
int major = 1;
int minor = 0;
};
const parser_version_type m_parser_version;
double m_period = {1.0};

bool parseParams(const yarp::os::Searchable & config) override;
std::string getDeviceType() const override { return m_device_type; }
std::string getDocumentationOfDeviceParams() const override;
std::vector<std::string> getListOfParams() const override;
};

#endif
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
* | | period | double | s | 1.0 | No | thread period | optional, default 1.0s |
9 changes: 6 additions & 3 deletions src/devices/fake/fakeBattery/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8,21 +8,24 @@ endif()
yarp_prepare_plugin(fakeBattery
CATEGORY device
TYPE FakeBattery
INCLUDE fakeBattery.h
INCLUDE FakeBattery.h
EXTRA_CONFIG
WRAPPER=batteryWrapper
)

if(NOT SKIP_fakeBattery)
yarp_add_plugin(yarp_fakeBattery)
generateDeviceParamsParser(FakeBattery)

include(YarpChooseIDL)
yarp_choose_idl(IDL FakeBatteryService.thrift)

target_sources(yarp_fakeBattery
PRIVATE
fakeBattery.cpp
fakeBattery.h
FakeBattery.cpp
FakeBattery.h
FakeBattery_ParamsParser.cpp
FakeBattery_ParamsParser.h
${IDL_GEN_FILES}
)

Expand Down
File renamed without changes.
98 changes: 98 additions & 0 deletions src/devices/fake/fakeBattery/FakeBattery_ParamsParser.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,98 @@
/*
* SPDX-FileCopyrightText: 2023-2023 Istituto Italiano di Tecnologia (IIT)
* SPDX-License-Identifier: LGPL-2.1-or-later
*/


// Generated by yarpDeviceParamParserGenerator (1.0)
// This is an automatically generated file. Please do not edit it.
// It will be re-generated if the cmake flag ALLOW_DEVICE_PARAM_PARSER_GERNERATION is ON.

// Generated on: Fri Feb 9 20:17:51 2024


#include "FakeBattery_ParamsParser.h"
#include <yarp/os/LogStream.h>
#include <yarp/os/Value.h>

namespace {
YARP_LOG_COMPONENT(FakeBatteryParamsCOMPONENT, "yarp.device.FakeBattery")
}


std::vector<std::string> FakeBattery_ParamsParser::getListOfParams() const
{
std::vector<std::string> params;
params.push_back("period");
return params;
}


bool FakeBattery_ParamsParser::parseParams(const yarp::os::Searchable & config)
{
//Check for --help option
if (config.check("help"))
{
yCInfo(FakeBatteryParamsCOMPONENT) << getDocumentationOfDeviceParams();
}

std::string config_string = config.toString();
yarp::os::Property prop_check(config_string.c_str());
//Parser of parameter period
{
if (config.check("period"))
{
m_period = config.find("period").asFloat64();
yCInfo(FakeBatteryParamsCOMPONENT) << "Parameter 'period' using value:" << m_period;
}
else
{
yCInfo(FakeBatteryParamsCOMPONENT) << "Parameter 'period' using DEFAULT value:" << m_period;
}
prop_check.unput("period");
}

/*
//This code check if the user set some parameter which are not check by the parser
//If the parser is set in strict mode, this will generate an error
if (prop_check.size() > 0)
{
bool extra_params_found = false;
for (auto it=prop_check.begin(); it!=prop_check.end(); it++)
{
if (m_parser_is_strict)
{
yCError(FakeBatteryParamsCOMPONENT) << "User asking for parameter: "<<it->name <<" which is unknown to this parser!";
extra_params_found = true;
}
else
{
yCWarning(FakeBatteryParamsCOMPONENT) << "User asking for parameter: "<< it->name <<" which is unknown to this parser!";
}
}
if (m_parser_is_strict && extra_params_found)
{
return false;
}
}
*/
return true;
}


std::string FakeBattery_ParamsParser::getDocumentationOfDeviceParams() const
{
std::string doc;
doc = doc + std::string("\n=============================================\n");
doc = doc + std::string("This is the help for device: FakeBattery\n");
doc = doc + std::string("\n");
doc = doc + std::string("This is the list of the parameters accepted by the device:\n");
doc = doc + std::string("'period': thread period\n");
doc = doc + std::string("\n");
doc = doc + std::string("Here are some examples of invocation command with yarpdev, with all params:\n");
doc = doc + " yarpdev --device FakeBattery --period 1.0\n";
doc = doc + std::string("Using only mandatory params:\n");
doc = doc + " yarpdev --device FakeBattery\n";
doc = doc + std::string("=============================================\n\n"); return doc;
}
64 changes: 64 additions & 0 deletions src/devices/fake/fakeBattery/FakeBattery_ParamsParser.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
/*
* SPDX-FileCopyrightText: 2023-2023 Istituto Italiano di Tecnologia (IIT)
* SPDX-License-Identifier: LGPL-2.1-or-later
*/


// Generated by yarpDeviceParamParserGenerator (1.0)
// This is an automatically generated file. Please do not edit it.
// It will be re-generated if the cmake flag ALLOW_DEVICE_PARAM_PARSER_GERNERATION is ON.

// Generated on: Fri Feb 9 20:17:51 2024


#ifndef FAKEBATTERY_PARAMSPARSER_H
#define FAKEBATTERY_PARAMSPARSER_H

#include <yarp/os/Searchable.h>
#include <yarp/dev/IDeviceDriverParams.h>
#include <string>
#include <cmath>

/**
* This class is the parameters parser for class FakeBattery.
*
* These are the used parameters:
* | Group name | Parameter name | Type | Units | Default Value | Required | Description | Notes |
* |:----------:|:--------------:|:------:|:-----:|:-------------:|:--------:|:-------------:|:----------------------:|
* | - | period | double | s | 1.0 | 0 | thread period | optional, default 1.0s |
*
* The device can be launched by yarpdev using one of the following examples:
* \code{.unparsed}
* yarpdev --device FakeBattery --period 1.0
* \endcode
*
* \code{.unparsed}
* yarpdev --device FakeBattery
* \endcode
*
*/

class FakeBattery_ParamsParser : public yarp::dev::IDeviceDriverParams
{
public:
FakeBattery_ParamsParser() = default;
~FakeBattery_ParamsParser() override = default;

public:
const std::string m_device_type = {"FakeBattery"};
bool m_parser_is_strict = false;
struct parser_version_type
{
int major = 1;
int minor = 0;
};
const parser_version_type m_parser_version;
double m_period = {1.0};

bool parseParams(const yarp::os::Searchable & config) override;
std::string getDeviceType() const override { return m_device_type; }
std::string getDocumentationOfDeviceParams() const override;
std::vector<std::string> getListOfParams() const override;
};

#endif
1 change: 1 addition & 0 deletions src/devices/fake/fakeBattery/FakeBattery_params.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
* | | period | double | s | 1.0 | No | thread period | optional, default 1.0s |
3 changes: 3 additions & 0 deletions src/devices/fake/fakeChatBotDevice/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,14 @@ yarp_prepare_plugin(fakeChatBotDevice
if(NOT SKIP_fakeChatBotDevice)

yarp_add_plugin(yarp_fakeChatBotDevice)
generateDeviceParamsParser(FakeChatBotDevice)

target_sources(yarp_fakeChatBotDevice
PRIVATE
FakeChatBotDevice.cpp
FakeChatBotDevice.h
FakeChatBotDevice_ParamsParser.cpp
FakeChatBotDevice_ParamsParser.h
)

target_link_libraries(yarp_fakeChatBotDevice
Expand Down
Loading

0 comments on commit 6557f19

Please sign in to comment.