10#include <RobotAPI/libraries/armem_task_outcome/aron/TaskOutcome.aron.generated.h>
28 if (not
query.providerName.empty())
40 std::vector<TaskOutcome>
45 const std::optional<TaskType>& taskTypeFilter,
46 const std::optional<TaskOutcomeType>& outcomeFilter)
const
49 std::vector<TaskOutcome> outcomes;
58 entitySnapshot.forEachInstance(
59 [&outcomes, &
timestamp, &maxAge, &taskTypeFilter, &outcomeFilter](
60 const auto& entityInstance)
65 timestamp - entityInstance.metadata().referencedTime;
72 ARMARX_CHECK(aronDto) <<
"Failed casting to TaskOutcome";
78 if (taskTypeFilter.has_value() &&
79 outcome.
taskType != taskTypeFilter.value())
83 if (outcomeFilter.has_value() &&
89 outcomes.push_back(outcome);
100 return "mem.task_outcome.";
106 return {.memoryName =
"TaskOutcome", .coreSegmentName =
"TaskOutcome"};
120 ARMARX_DEBUG <<
"[TaskOutcomeReader] result: " << qResult;
125 return {.outcomes = {},
133 if (
query.providerName.empty())
137 std::vector<TaskOutcome> allOutcomes;
139 coreSegment.forEachProviderSegment(
140 [
this, &allOutcomes, &
query](
const auto& providerSegment)
146 query.taskTypeFilter,
147 query.outcomeFilter);
149 outcomes.begin(), outcomes.end(), std::back_inserter(allOutcomes));
152 if (allOutcomes.empty())
154 return {.outcomes = {},
156 .errorMessage =
"No entities"};
164 if (not coreSegment.hasProviderSegment(
query.providerName))
167 <<
"` does not exist (yet).";
174 coreSegment.getProviderSegment(
query.providerName);
176 if (providerSegment.
empty())
179 return {.outcomes = {},
181 .errorMessage =
"No entities"};
192 query.taskTypeFilter,
193 query.outcomeFilter);
203 std::vector<TaskOutcome>
207 Query q{.providerName =
"",
208 .taskTypeFilter = taskType,
209 .outcomeFilter = std::nullopt,
217 return result.outcomes;
228 std::vector<TaskOutcome>
231 Query q{.providerName =
"",
232 .taskTypeFilter = std::nullopt,
241 return result.outcomes;
246 ARMARX_WARNING <<
"Failed to query task outcome failures from memory";
SpamFilterDataPtr deactivateSpam(SpamFilterDataPtr const &spamFilter, float deactivationDurationSec, const std::string &identifier, bool deactivate)
CoreSegmentT & getCoreSegment(const std::string &name)
bool forEachEntity(EntityFunctionT &&func)
QueryResult query(const QueryInput &input) const
Perform a query on the WM.
The query::Builder class provides a fluent-style specification of hierarchical queries.
CoreSegmentSelector & coreSegments()
Start specifying core segments.
CoreSegmentSelector & withName(const std::string &name) override
ProviderSegmentSelector & providerSegments()
Start specifying provider segments.
EntitySelector & all() override
SnapshotSelector & snapshots()
Start specifying entity snapshots.
ProviderSegmentSelector & withName(const std::string &name) override
EntitySelector & entities()
Start specifying entities.
ProviderSegmentSelector & all() override
SnapshotSelector & beforeOrAtTime(Time timestamp)
const armem::client::Reader & memoryReader() const
const Properties & properties() const
std::vector< TaskOutcome > queryByTaskType(TaskType taskType, const Duration &maxAge) const
Properties defaultProperties() const override
Result query(const Query &query) const
std::vector< TaskOutcome > queryFailures(const Duration &maxAge) const
std::string propertyPrefix() const override
::armarx::armem::client::query::Builder buildQuery(const Query &query) const
std::vector< TaskOutcome > asTaskOutcomes(const wm::ProviderSegment &providerSegment, const DateTime ×tamp, const Duration &maxAge, const std::optional< TaskType > &taskTypeFilter, const std::optional< TaskOutcomeType > &outcomeFilter) const
~TaskOutcomeReader() override
Represents a point in time.
bool isPositive() const
Tests whether the duration is positive (value in µs > 0).
#define ARMARX_CHECK(expression)
Shortcut for ARMARX_CHECK_EXPRESSION.
#define ARMARX_INFO
The normal logging level.
#define ARMARX_DEBUG
The logging level for output that is only interesting while debugging.
#define ARMARX_WARNING
The logging level for unexpected behaviour, but not a serious problem.
void fromAron(const armarx::task_outcome::arondto::TaskOutcomeType &dto, TaskOutcomeType &bo)
armarx::core::time::Duration Duration
std::optional< AronClass > tryCast(const wm::EntityInstance &item)
Tries to cast a armem::EntityInstance to AronClass.
std::string GetHandledExceptionString()
auto & getLatestSnapshot(int snapshotIndex=0)
Retrieve the latest entity snapshot.
wm::Memory memory
The slice of the memory that matched the query.
TaskOutcomeType outcomeType