ParamServer - automatic case conversion for parameter names

This commit is contained in:
Pavel Kirienko
2015-03-21 00:12:06 +03:00
parent 241ae8a538
commit 80c2c175aa
3 changed files with 111 additions and 2 deletions
@@ -18,6 +18,22 @@ bool ParamServer::isValueNonEmpty(const protocol::param::Value& value)
!value.value_string.empty();
}
void ParamServer::convertParamNameCase(IParamManager::ParamName& name) const
{
if (param_name_case_conversion_mode_ == ParamNameCaseConversionToLower)
{
name.convertToLowerCaseASCII();
}
else if (param_name_case_conversion_mode_ == ParamNameCaseConversionToUpper)
{
name.convertToUpperCaseASCII();
}
else
{
; // Conversion is not needed
}
}
void ParamServer::handleGetSet(const protocol::param::GetSet::Request& in, protocol::param::GetSet::Response& out)
{
UAVCAN_ASSERT(manager_ != NULL);
@@ -33,6 +49,8 @@ void ParamServer::handleGetSet(const protocol::param::GetSet::Request& in, proto
out.name = in.name;
}
convertParamNameCase(out.name);
// Assign if needed, read back
if (isValueNonEmpty(in.value))
{