Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(diagnostic_converter): remove unit and blank in the value #3151

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 16 additions & 2 deletions evaluator/diagnostic_converter/src/converter_node.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@

namespace
{
std::string removeInvalidTopicString(std::string input_string)
std::string removeInvalidTopicString(const std::string & input_string)
{
std::regex pattern{R"([a-zA-Z0-9/_]+)"};

Expand All @@ -29,6 +29,20 @@ std::string removeInvalidTopicString(std::string input_string)
}
return result;
}

std::string removeUnitString(const std::string & input_string)
{
for (size_t i = 0; i < input_string.size(); ++i) {
if (input_string.at(i) == '[') {
if (i != 0 && input_string.at(i - 1) == ' ') {
// Blank is also removed
return std::string{input_string.begin(), input_string.begin() + i - 1};
}
return std::string{input_string.begin(), input_string.begin() + i};
}
}
return input_string;
}
} // namespace

namespace diagnostic_converter
Expand Down Expand Up @@ -68,7 +82,7 @@ UserDefinedValue DiagnosticConverter::createUserDefinedValue(const KeyValue & ke
{
UserDefinedValue param_msg;
param_msg.type.data = UserDefinedValueType::DOUBLE;
param_msg.value = key_value.value;
param_msg.value = removeUnitString(key_value.value);
return param_msg;
}

Expand Down