25#include <SimoxUtility/algorithm/string/string_tools.h>
38 properties(properties), services(services)
40 services.debugObserver.setDebugObserverBatchModeEnabled(
true);
89 template <
class ValueT>
107 Visitor visitor(services.debugObserver);
109 std::stringstream log;
112 std::map<MemoryID, std::vector<const MemoryValueID*>> valuesPerProviderSegment;
113 for (
const MemoryValueID& valueId : properties.plottedValues)
118 for (
const auto& [providerSegmentID, values] : valuesPerProviderSegment)
123 reader = getReader(providerSegmentID);
127 log <<
"\n" << e.what();
135 log <<
"Query to provider segment " << providerSegmentID
143 if (entity ==
nullptr)
145 log <<
"\nDid not find entity " << valueId->
entityID <<
" in provider segment "
146 << providerSegmentID <<
".";
158 if (instance ==
nullptr)
160 log <<
"\nEntity " << valueId->
entityID
161 <<
" has no latest instance (yet) in provider segment "
162 << providerSegmentID <<
".";
168 if (not valueVariant)
171 <<
" in entity instance " << instance->
id() <<
".";
182 services.debugObserver.sendDebugObserverBatch();
184 if (not log.str().empty())
187 <<
"Encountered issues while sending memory values to the debug observer "
194 MemoryToDebugObserver::makeChannelName(
const MemoryID& memoryID)
196 return simox::alg::replace_all(memoryID.
str(),
"/",
">");
200 MemoryToDebugObserver::makeDatafieldName(
const aron::Path& path)
210 MemoryToDebugObserver::getReader(
const MemoryID& memoryID)
212 auto it = memoryReaders.find(memoryID);
213 if (it != memoryReaders.end())
221 auto [it, _] = memoryReaders.emplace(memoryID, reader);
228namespace armarx::armem::client
234 j[
"entityID"] =
id.entityID.getItems();
235 j[
"aronPath"] =
id.aronPath.getPath();
242 id.aronPath = {j.at(
"aronPath").get<std::vector<std::string>>()};
SpamFilterDataPtr deactivateSpam(SpamFilterDataPtr const &spamFilter, float deactivationDurationSec, const std::string &identifier, bool deactivate)
Brief description of class DebugObserverHelper.
static MemoryID fromItems(const std::vector< std::string > &items)
Constructor memory ID from items as returned by getItems().
MemoryID getProviderSegmentID() const
std::string str(bool escapeDelimiters=true) const
Get a string representation of this memory ID.
auto * findLatestInstance(int instanceIndex=0)
const DataT & data() const
Reader getReader(const MemoryID &memoryID)
Get a reader to the given memory name.
Reads data from a memory server.
QueryResult getLatestSnapshotsIn(const MemoryID &id, armem::query::DataMode dataMode=armem::query::DataMode::WithData) const
Get the latest snapshots under the given memory ID.
void pollOnce()
Query values from the memory and send them to the debug observer.
MemoryToDebugObserver(const Properties &properties, const Services &services)
Constructor.
Visitor(armarx::DebugObserverHelper &debugObserver)
armarx::DebugObserverHelper & debugObserver
void visitAronVariant(const aron::data::LongPtr &v) override
void visitAronVariant(const aron::data::IntPtr &v) override
void visitAronVariant(const aron::data::DoublePtr &v) override
std::string datafieldName
void setDatafield(const ValueT &value)
void visitAronVariant(const aron::data::StringPtr &v) override
void visitAronVariant(const aron::data::FloatPtr &v) override
void visitAronVariant(const aron::data::BoolPtr &v) override
Indicates that a query to the Memory Name System failed.
std::string toString() const
std::string getDelimeter() const
std::string getRootIdentifier() const
#define ARMARX_CHECK_NOT_NULL(ptr)
This macro evaluates whether ptr is not null and if it turns out to be false it will throw an Express...
#define ARMARX_INFO
The normal logging level.
void from_json(const simox::json::json &j, MemoryValueID &id)
void to_json(simox::json::json &j, const MemoryValueID &id)
armem::wm::EntityInstance EntityInstance
std::shared_ptr< Bool > BoolPtr
std::shared_ptr< Float > FloatPtr
std::shared_ptr< Variant > VariantPtr
std::shared_ptr< Long > LongPtr
std::shared_ptr< Int > IntPtr
void visit(VisitorImplementation &v, typename VisitorImplementation::Input &o)
std::shared_ptr< Double > DoublePtr
std::shared_ptr< String > StringPtr
auto * findEntity(const MemoryID &entityID)
Find an entity.
wm::Memory memory
The slice of the memory that matched the query.
std::vector< MemoryValueID > plottedValues
MemoryNameSystem & memoryNameSystem
ID of an ARON value in the memory.