Go to the documentation of this file.
28 #include <SimoxUtility/algorithm/string.h>
36 #include <RobotAPI/components/armem/server/ExampleMemory/aron/ExampleData.aron.generated.h>
45 defs->topic(debugObserver);
49 p.core._defaultSegmentsStr = simox::alg::join(p.core.defaultCoreSegments,
", ");
50 defs->optional(p.core._defaultSegmentsStr,
"core.DefaultSegments",
51 "Core segments to add on start up (just as example).");
52 defs->optional(p.core.addOnUsage,
"core.AddOnUsage",
53 "If enabled, core segments are added when required by a new provider segment."
54 "This will usually be off for most memory servers.");
56 defs->optional(p.enableRemoteGui,
"p.enableRemoteGui",
57 "If true, the memory cotent is shown in the remote gui."
58 "Can be very slow for high-frequency updates!");
65 return "ExampleMemory";
79 {
return this->predictLatest(request); });
83 p.core.defaultCoreSegments =
simox::alg::split(p.core._defaultSegmentsStr,
",", trim);
84 p.core._defaultSegmentsStr.clear();
86 for (
const std::string& name : p.core.defaultCoreSegments)
89 c.setMaxHistorySize(100);
95 if (p.enableRemoteGui)
117 armem::data::AddSegmentsResult result = ReadWritePluginUser::addSegments(
input, p.core.addOnUsage);
126 armem::data::CommitResult result = ReadWritePluginUser::commit(
commit);
139 armem::actions::GetActionsOutputSeq
141 const armem::actions::GetActionsInputSeq&
input)
143 using namespace armem::actions;
144 Action greeting{
"hi",
"Say hello to " +
input[0].id.entityName};
145 Action
failure{
"fail",
"Fail dramatically"};
146 Action nothing{
"null",
"Do nothing, but deeply nested"};
148 SubMenu one{
"one",
"One", { nothing } };
149 SubMenu two{
"two",
"Two", { one } };
150 SubMenu three{
"three",
"Three", { two } };
151 SubMenu four{
"four",
"Four", { three } };
157 SubMenu{
"mut",
"Mutate", {
158 Action{
"copy",
"Copy latest instance"}
162 return {{ menu.toIce() }};
166 const armem::actions::ExecuteActionInputSeq&
input)
168 using namespace armem::actions;
170 ExecuteActionOutputSeq output;
171 for (
const auto& [
id, path] :
input)
174 if (path == ActionPath{
"hi"})
177 output.emplace_back(
true,
"");
179 else if (path == ActionPath{
"fail"})
182 output.emplace_back(
false,
"Why would you do that to him?");
184 else if (not path.empty() and path.front() ==
"four" and path.back() ==
"null")
187 ARMARX_INFO <<
"Nested action (path: " << path <<
")";
188 output.emplace_back(
true,
"");
190 else if (path == ActionPath{
"mut",
"copy"})
193 if (instance !=
nullptr)
201 update.instancesData = { instance->data() };
205 this->
commit(armarx::toIce<armem::data::Commit>(newCommit));
209 output.emplace_back(
true,
"");
213 output.emplace_back(
false,
"Couldn't duplicate " +
memoryID.
str());
233 if (queryResult.success)
235 auto readMemory = fromIce<armem::wm::Memory>(queryResult.memory);
236 auto*
latest = readMemory.findLatestSnapshot(memID);
239 auto instance = memID.hasInstanceIndex()
240 ?
latest->getInstance(memID)
241 :
latest->getInstance(
latest->getInstanceIndices().at(0));
249 "Could not find entity referenced by MemoryID '" + memID.str() +
"'.";
256 "Could not find entity referenced by MemoryID '" + memID.str() +
"'.";
280 if (tab.rebuild.exchange(
false))
const auto * findLatestInstance(int instanceIndex=0) const
Find the latest entity instance.
armem::MemoryID snapshotID
virtual armem::query::data::Result query(const armem::query::data::Input &input, const Ice::Current &=Ice::emptyCurrent) override
std::string providerSegmentName
A bundle of updates to be sent to the memory.
void RemoteGui_update() override
QueryInput buildQueryInput() const
GroupBox makeGroupBox(const armem::wm::Memory &memory) const
std::string str(bool escapeDelimiters=true) const
Get a string representation of this memory ID.
void setMemoryName(const std::string &memoryName)
void latestEntitySnapshot(const MemoryID &entityID)
server::wm::Memory & workingMemory()
armem::data::CommitResult commit(const armem::data::Commit &commit, const Ice::Current &=Ice::emptyCurrent) override
void onInitComponent() override
Pure virtual hook for the subclass.
void onDisconnectComponent() override
Hook for subclass.
MemoryID withProviderSegmentName(const std::string &name) const
aron::data::DictPtr prediction
void onConnectComponent() override
Pure virtual hook for the subclass.
ReaderT::InputType & input
armarx::PropertyDefinitionsPtr createPropertyDefinitions() override
An update of an entity for a specific point in time.
CoreSegmentT & addCoreSegment(const std::string &name, aron::type::ObjectPtr coreSegmentType=nullptr, const std::vector< PredictionEngine > &predictionEngines={})
Add an empty core segment with the given name, type and prediction engines.
armem::data::AddSegmentsResult addSegments(const armem::data::AddSegmentsInput &input, const Ice::Current &) override
void createRemoteGuiTab()
void addPredictor(const PredictionEngine &engine, Predictor &&predictor)
bool update(mongocxx::collection &coll, const nlohmann::json &query, const nlohmann::json &update)
void RemoteGui_startRunningTask()
std::function< void(query::SnapshotSelector &)> latest()
MemoryID getCoreSegmentID() const
std::string getConfigIdentifier()
Retrieve config identifier for this component as set in constructor.
MemoryID withEntityName(const std::string &name) const
void onExitComponent() override
Hook for subclass.
Default component property definition container.
armem::actions::GetActionsOutputSeq getActions(const armem::actions::GetActionsInputSeq &input) override
void RemoteGui_createTab(std::string const &name, RemoteGui::Client::Widget const &rootWidget, RemoteGui::Client::Tab *tab)
std::string getDefaultName() const override
The query::Builder class provides a fluent-style specification of hierarchical queries.
std::string getName() const
Retrieve name of object.
armem::actions::ExecuteActionOutputSeq executeActions(const armem::actions::ExecuteActionInputSeq &input) override
Utility for memory Remote Guis.
armem::MemoryID snapshotID
This file offers overloads of toIce() and fromIce() functions for STL container types.
std::vector< std::string > split(const std::string &source, const std::string &splitBy, bool trimElements=false, bool removeEmptyElements=false)