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

Handle partial updates

parent 0b7961c7
No related branches found
No related tags found
1 merge request!406Refactor skill memory GUI
......@@ -18,6 +18,8 @@ namespace armarx::skills::gui
bool
SkillManagerWrapper::fetchExecutions()
{
bool partialUpdate = false;
static std::map<skills::SkillStatus, std::string> ExecutionStatus2String = {
// Main states
{skills::SkillStatus::Constructing, "Constructing"},
......@@ -50,6 +52,7 @@ namespace armarx::skills::gui
// update maps
snapshot.statuses[executionId] = statusUpdate;
partialUpdate = true;
}
return true;
}
......@@ -58,12 +61,12 @@ namespace armarx::skills::gui
ARMARX_WARNING
<< "Unhandled Ice exception encountered while updating executions. Exception was: "
<< e;
return false;
return partialUpdate;
}
catch (...)
{
ARMARX_WARNING << "Unknown exception encountered while updating executions.";
return false;
return partialUpdate;
}
}
......@@ -110,8 +113,16 @@ namespace armarx::skills::gui
this->filterSkillUpdate(managerSkills);
// completely recreate internal skills map
snapshot.skills.clear();
/*
* We create a new skills map and update the snapshot in one go.
* If an exception is thrown during the update (therefore it is incomplete),
* we discard the update.
*/
std::map<skills::ProviderID, std::map<skills::SkillID, skills::SkillDescription>>
_skills;
for (const auto& [sid, desc] : managerSkills)
{
auto description = skills::SkillDescription::FromIce(desc);
......@@ -121,9 +132,12 @@ namespace armarx::skills::gui
ARMARX_CHECK(skillId.isFullySpecified());
auto& providedSkillsMap = snapshot.skills[providerId]; // create new if not existent
auto& providedSkillsMap = _skills[providerId]; // create new if not existent
providedSkillsMap.insert({skillId, description});
}
// update the snapshot
snapshot.skills = _skills;
return true;
}
catch (Ice::Exception const& e)
......
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