Skip to content

Commit

Permalink
DUNE/Control/BasicRemoteOperation: Fix additional actions to be corre…
Browse files Browse the repository at this point in the history
…ctly read from the ini file, need to change to Action:Type format instead of Action=Type (= in ini has a meaning).
  • Loading branch information
paulosousadias committed Nov 14, 2023
1 parent 3210710 commit e5623c2
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 10 deletions.
26 changes: 17 additions & 9 deletions src/DUNE/Control/BasicRemoteOperation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ namespace DUNE

param("Additional Actions", m_additional_actions)
.defaultValue("")
.description("Actions to be added to Remote Actions List");
.description("Actions to be added to remote actions list (comma separated in the form Action:Type)");

m_actions.op = IMC::RemoteActionsRequest::OP_REPORT;

Expand Down Expand Up @@ -148,21 +148,24 @@ namespace DUNE
}

void
BasicRemoteOperation::onResourceInitialization(void)
BasicRemoteOperation::setupAdditionalActions(const std::vector<std::string>& additional_actions)
{
std::vector<std::vector<std::string>> lst;
Utils::String::splitMulti(m_additional_actions, ",", "=", lst);
std::vector<std::vector<std::string>>::iterator it;
for (it = lst.begin(); it != lst.end(); ++it)
for (unsigned int i = 0; i < additional_actions.size(); ++i)
{
if (it->size() != 2) continue;
if (Utils::String::ltrim(additional_actions[i]).size() < 3)
continue;

std::vector<std::string> parts;
Utils::String::split(additional_actions[i], ":", parts);

std::string action_name = it->at(0);
if (parts.size() != 2) continue;

std::string action_name = parts[0];
action_name = Utils::String::ltrim(action_name);
action_name = Utils::String::rtrim(action_name);
if (action_name.empty()) continue;

std::string type_lowercase = it->at(1);
std::string type_lowercase = parts[1];
type_lowercase = Utils::String::ltrim(type_lowercase);
type_lowercase = Utils::String::rtrim(type_lowercase);
Utils::String::toLowerCase(type_lowercase);
Expand All @@ -184,7 +187,12 @@ namespace DUNE
addActionHalfSlider(action_name);
}
}
}

void
BasicRemoteOperation::onResourceInitialization(void)
{
setupAdditionalActions(m_additional_actions);
setEntityState(IMC::EntityState::ESTA_NORMAL, Status::CODE_IDLE);
}

Expand Down
5 changes: 4 additions & 1 deletion src/DUNE/Control/BasicRemoteOperation.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,9 @@ namespace DUNE
(void)message;
}

void
setupAdditionalActions(const std::vector<std::string>& additional_actions);

virtual void
onConnectionTimeout(void)
{ }
Expand Down Expand Up @@ -159,7 +162,7 @@ namespace DUNE
//! Control loops last reference
uint32_t m_scope_ref;
//! Additional Remote Operation Actions
std::string m_additional_actions;
std::vector<std::string> m_additional_actions;

//! IMC ID of the teleoperation source
uint16_t m_teleop_src;
Expand Down

0 comments on commit e5623c2

Please sign in to comment.