mirror of
https://gitee.com/mirrors_PX4/PX4-Autopilot.git
synced 2026-10-16 04:03:34 +08:00
ParamServer - automatic case conversion for parameter names
This commit is contained in:
@@ -79,22 +79,48 @@ class UAVCAN_EXPORT ParamServer
|
||||
void (ParamServer::*)(const protocol::param::ExecuteOpcode::Request&,
|
||||
protocol::param::ExecuteOpcode::Response&)> ExecuteOpcodeCallback;
|
||||
|
||||
public:
|
||||
/**
|
||||
* This class can automatically enforce that parameter names are not case-sensitive, by means of
|
||||
* automatic conversion to either upper or lower case whenever a parameter name is received.
|
||||
* For instance, if the lower-case conversion is enabled, then a UAVCAN request for a parameter
|
||||
* named "Foo" will be passed to the application as "foo". Similarly, when the application reports
|
||||
* that it has a parameter named "FOO", the class will convert the name to "foo".
|
||||
*/
|
||||
enum ParamNameCaseConversion
|
||||
{
|
||||
ParamNameCaseConversionDisabled, ///< Do not convert parameter names. The case will remain intact.
|
||||
ParamNameCaseConversionToLower, ///< Convert parameter names to lower case.
|
||||
ParamNameCaseConversionToUpper ///< Convert parameter names to upper case.
|
||||
};
|
||||
|
||||
private:
|
||||
ServiceServer<protocol::param::GetSet, GetSetCallback> get_set_srv_;
|
||||
ServiceServer<protocol::param::ExecuteOpcode, ExecuteOpcodeCallback> save_erase_srv_;
|
||||
IParamManager* manager_;
|
||||
const ParamNameCaseConversion param_name_case_conversion_mode_;
|
||||
|
||||
static bool isValueNonEmpty(const protocol::param::Value& value);
|
||||
|
||||
void convertParamNameCase(IParamManager::ParamName& name) const;
|
||||
|
||||
void handleGetSet(const protocol::param::GetSet::Request& request, protocol::param::GetSet::Response& response);
|
||||
|
||||
void handleExecuteOpcode(const protocol::param::ExecuteOpcode::Request& request,
|
||||
protocol::param::ExecuteOpcode::Response& response);
|
||||
|
||||
public:
|
||||
explicit ParamServer(INode& node)
|
||||
/**
|
||||
* @param param_name_case_conversion Specifies the parameter name conversion mode. Lower case is default,
|
||||
* which means that an external request for a parameter named "Foo" will
|
||||
* be relayed to the application as "foo".
|
||||
*/
|
||||
explicit ParamServer(INode& node,
|
||||
ParamNameCaseConversion param_name_case_conversion = ParamNameCaseConversionToLower)
|
||||
: get_set_srv_(node)
|
||||
, save_erase_srv_(node)
|
||||
, manager_(NULL)
|
||||
, param_name_case_conversion_mode_(param_name_case_conversion)
|
||||
{ }
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user