5#include <SimoxUtility/algorithm/string.h>
9#include <RobotAPI/libraries/armem_skills/aron/Skill.aron.generated.h>
29 defs->topic(p.skillEventTopic,
"SkillEventListener", prefix +
"tpc.pub.SkillEventListener");
42 armarx::skills::arondto::SkillStatusUpdate event;
49 auto aron =
event.toAron();
52 auto& entityUpdate = comm.
add();
55 entityUpdate.instancesData = {
aron};
56 entityUpdate.entityID = commitId;
64 if (p.skillEventTopic)
68 p.skillEventTopic->reportSkillEvent(
69 update.toProviderIce(), event.skillId.providerId.providerName);
71 catch (
const std::exception& e)
73 static std::atomic_flag warned = ATOMIC_FLAG_INIT;
74 if (!warned.test_and_set())
77 <<
"SkillEventListener"
79 <<
". Subsequent failures of this kind will be "
80 "silently ignored. The local memory commit "
87 static std::atomic_flag warned = ATOMIC_FLAG_INIT;
88 if (!warned.test_and_set())
91 "skill events will not be published. "
92 "This warning is only logged once. "
93 "The local memory commit still proceeds.";
100 std::map<skills::SkillExecutionID, skills::SkillStatusUpdate>
103 std::map<skills::SkillExecutionID, skills::SkillStatusUpdate> ret;
107 coreSegment->doLocked(
110 coreSegment->forEachInstance(
120 i.
dataAs<armarx::skills::arondto::SkillStatusUpdate>();
123 catch (
const std::exception& e)
126 "instance in SkillEvent segment: "
131 if (
auto it = ret.find(up.executionId); it != ret.end() && up < it->second)
137 ret[up.executionId] = up;
149 std::optional<skills::SkillStatusUpdate>
152 std::optional<skills::SkillStatusUpdate> ret = std::nullopt;
156 coreSegment->doLocked(
159 coreSegment->forEachInstance(
169 i.
dataAs<armarx::skills::arondto::SkillStatusUpdate>();
172 catch (
const std::exception& e)
175 "instance in SkillEvent segment: "
180 if (up.executionId ==
id)
182 if (!ret || (ret.has_value() && *ret < up))
194 const std::string& memoryName,
197 consolidated =
false;
198 std::size_t snapshotCount = 0;
202 coreSegment->doLockedExclusive(
205 coreSegment->forEachSnapshot(
213 slice.setName(memoryName);
219 coreSegment->clear();
222 return snapshotCount;
std::string providerSegmentName
AronDtoT dataAs() const
Get the data converted to a generated Aron DTO class.
Helps connecting a Memory server to the Ice interface.
A memory storing data on the hard drive and in mongodb (needs 'armarx memory start' to start the mong...
void directlyStore(const armem::wm::Memory &memory, bool simulatedVersion=false)
virtual void defineProperties(armarx::PropertyDefinitionsPtr defs, const std::string &prefix="") override
void setDefaultMaxHistorySize(int64_t maxHistorySize)
virtual void init() override
MemoryToIceAdapter & iceMemory
server::wm::CoreSegment * segmentPtr
Client-side working entity instance.
Client-side working memory entity snapshot.
Client-side working memory.
void addSkillUpdateEvent(const skills::SkillStatusUpdate &update)
std::size_t clearAndConsolidate(armem::server::ltm::Memory <m, const std::string &memoryName, bool &consolidated)
Clear all snapshots from the working memory of this core segment, consolidating them into ltm first i...
SkillEventCoreSegment(armem::server::MemoryToIceAdapter &iceMemory)
static constexpr const char * CoreSegmentName
std::map< skills::SkillExecutionID, skills::SkillStatusUpdate > getSkillStatusUpdates()
std::optional< skills::SkillStatusUpdate > getSkillStatusUpdate(const skills::SkillExecutionID &id)
void defineProperties(PropertyDefinitionsPtr defs, const std::string &prefix)
#define ARMARX_CHECK(expression)
Shortcut for ARMARX_CHECK_EXPRESSION.
#define ARMARX_WARNING
The logging level for unexpected behaviour, but not a serious problem.
void fromAron(const arondto::MemoryID &dto, MemoryID &bo)
Commit toCommit(const ContainerT &container)
void toAron(arondto::MemoryID &dto, const MemoryID &bo)
This file offers overloads of toIce() and fromIce() functions for STL container types.
IceUtil::Handle< class PropertyDefinitionContainer > PropertyDefinitionsPtr
PropertyDefinitions smart pointer type.
This file is part of ArmarX.
A bundle of updates to be sent to the memory.
float confidence
An optional confidence, may be used for things like decay.