Skip to content
Snippets Groups Projects
Commit 0b7961c7 authored by Peter Albrecht's avatar Peter Albrecht
Browse files

Implemented execution fetch

parent e31be4fe
No related branches found
No related tags found
1 merge request!406Refactor skill memory GUI
......@@ -9,14 +9,62 @@ namespace armarx::skills::gui
void
SkillManagerWrapper::fetchUpdates()
{
fetchSkills();
fetchExecutions();
// if any of the updates was successful, we trigger a fetch from the gui
bool successful = fetchSkills() || fetchExecutions();
if (successful)
emit updateAvailable();
}
void
bool
SkillManagerWrapper::fetchExecutions()
{
ARMARX_ERROR << "Function not implemented!";
static std::map<skills::SkillStatus, std::string> ExecutionStatus2String = {
// Main states
{skills::SkillStatus::Constructing, "Constructing"},
{skills::SkillStatus::Initializing, "Initializing"},
{skills::SkillStatus::Preparing, "Preparing"},
{skills::SkillStatus::Running, "Running"},
// Terminating
{skills::SkillStatus::Aborted, "Aborted"},
{skills::SkillStatus::Failed, "Failed"},
{skills::SkillStatus::Succeeded, "Succeeded"}};
if (!memory)
{
// check if null
return false;
}
try
{
std::scoped_lock l(mutex_memory);
auto currentManagerStatuses = memory->getSkillExecutionStatuses();
// iterate over raw data and convert to common types
for (const auto& [k, v] : currentManagerStatuses)
{
auto executionId = skills::SkillExecutionID::FromIce(k);
auto statusUpdate = skills::SkillStatusUpdate::FromIce(v);
// update maps
snapshot.statuses[executionId] = statusUpdate;
}
return true;
}
catch (Ice::Exception const& e)
{
ARMARX_WARNING
<< "Unhandled Ice exception encountered while updating executions. Exception was: "
<< e;
return false;
}
catch (...)
{
ARMARX_WARNING << "Unknown exception encountered while updating executions.";
return false;
}
}
void
......@@ -46,12 +94,12 @@ namespace armarx::skills::gui
}
}
void
bool
SkillManagerWrapper::fetchSkills()
{
if (!memory)
{
return;
return false;
}
try
......@@ -76,18 +124,19 @@ namespace armarx::skills::gui
auto& providedSkillsMap = snapshot.skills[providerId]; // create new if not existent
providedSkillsMap.insert({skillId, description});
}
return true;
}
catch (Ice::Exception const& e)
{
ARMARX_WARNING
<< "Unhandled Ice exception encountered while updating skills. Exception was: "
<< e;
return;
return false;
}
catch (...)
{
ARMARX_WARNING << "Unknown exception encountered while updating skills.";
return;
return false;
}
}
......
......@@ -14,7 +14,7 @@ namespace armarx::skills::gui
{
class SkillManagerWrapper : public QObject
{
Q_OBJECT
public:
SkillManagerWrapper(skills::manager::dti::SkillManagerInterfacePrx& _memory,
QObject* parent = nullptr) :
......@@ -77,6 +77,11 @@ namespace armarx::skills::gui
*/
const Snapshot getLatestUpdate();
signals:
/**
* @brief Is emitted, after an update was successfully fetched from memory.
*/
void updateAvailable();
public slots:
/**
......@@ -105,13 +110,15 @@ namespace armarx::skills::gui
/**
* @brief Updates the skills map in the snapshot.
* @return true, if successful
*/
void fetchSkills();
bool fetchSkills();
/**
* @brief Updates the executions map in the snapshot.
* @return true, if successful
*/
void fetchExecutions();
bool fetchExecutions();
/**
* @brief Modifies the given map to match the search.
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment