45 std::shared_ptr<armem::gui::model::MemoryViewerModel>
model)
47 _model = std::move(
model);
49 _instanceGroupBoxController = std::make_unique<InstanceGroupBoxController>(
56 client::Reader reader = _model->memoryReaders().at(entityID.memoryName);
59 std::stringstream sstream;
60 sstream <<
"Predictions are not available for memory '" << entityID.memoryName
62 _statusLabel->setText(QString::fromStdString(sstream.str()));
66 std::map<MemoryID, std::vector<PredictionEngine>> predictionEngines;
73 catch (
const Ice::LocalException& e)
75 std::stringstream sstream;
76 sstream <<
"Could not get prediction engines and type from memory: " << e.what();
77 _statusLabel->setText(QString::fromStdString(sstream.str()));
85 if (providerSegment !=
nullptr)
87 entityType = providerSegment->aronType();
99 connect(_memoryGroupBoxView->tree(),
101 _instanceGroupBoxController.get(),
104 connect(_memoryGroupBoxView->predictionWidget(),
109 connect(_memoryGroupBoxView->commitWidget(),
114 connect(_memoryGroupBoxView->ltmWidget(),
119 connect(_memoryGroupBoxView->ltmWidget(),
124 connect(_memoryGroupBoxView->ltmWidget(),
129 connect(_memoryGroupBoxView->queryWidget(),
132 &This::updateActiveMemories);
134 connect(_memoryGroupBoxView->queryWidget(),
137 &This::updateRecursionDepth);
139 connect(_memoryGroupBoxView->queryWidget(),
142 &This::updateDataMode);
144 connect(_memoryGroupBoxView->queryWidget(),
147 &This::updateDropRemovedMemories);
149 connect(_memoryGroupBoxView->queryWidget(),
152 &This::updateDropDisabledMemories);
154 connect(_memoryGroupBoxView->snapshotSelectorWidget(),
157 &This::updateSelector);
159 updateActiveMemories();
160 updateRecursionDepth(_memoryGroupBoxView->queryWidget()->queryLinkRecursionDepth());
162 updateDropRemovedMemories();
163 updateDropDisabledMemories();
171 const std::string& engineID)
174 std::stringstream errorStream;
175 auto showError = [
this, &errorStream]()
176 { _statusLabel->setText(QString::fromStdString(errorStream.str())); };
180 errorStream <<
"Could not convert " << entityID <<
" to valid entity ID.";
184 auto readers = _model->memoryReadersCopy();
185 if (readers.find(entityID.
memoryName) == readers.end())
187 errorStream <<
"Not connected to memory '" << entityID.
memoryName
188 <<
"', cannot make prediction.";
195 errorStream <<
"Predictions are not available for memory '" << entityID.
memoryName
206 result = reader.
predict({request}).at(0);
208 catch (
const Ice::LocalException& e)
210 errorStream <<
"Could not make prediction request: " << e.what();
217 errorStream <<
"Prediction failed: " << result.
errorMessage;
223 _instanceGroupBoxController->instanceGroupBoxView()->instanceView()->addDataView(
view);
233 const std::string memoryIDStr = _memoryGroupBoxView->commitWidget()->getMemoryID();
234 const std::string aronJSONStr = _memoryGroupBoxView->commitWidget()->getAronJSON();
236 ARMARX_INFO <<
"Committing to " << memoryIDStr <<
" the data: " << aronJSONStr;
243 <<
"' does not contain an entity.";
248 nlohmann::json json = nlohmann::json::parse(aronJSONStr);
255 auto writers = _model->memoryWritersCopy();
256 if (
const auto& it = writers.find(memId.
memoryName); it == writers.end())
259 <<
"' available for commit.";
264 auto& entityUpdate = comm.
add();
266 entityUpdate.confidence = 1.0;
267 entityUpdate.instancesData = {
aron};
268 entityUpdate.referencedTime = now;
269 it->second.commit(comm);
281 auto enabledMemories = _memoryGroupBoxView->ltmWidget()->getEnabledLTMMemories();
282 auto memoryReaders = _model->memoryReadersCopy();
283 for (
auto& [name, reader] : memoryReaders)
286 if (std::find(enabledMemories.begin(), enabledMemories.end(), name) ==
287 enabledMemories.end())
293 auto q_res = reader.query(_model->queryInput());
296 server::dto::DirectlyStoreInput input;
297 input.memory = q_res.toIce().memory;
298 reader.directlyStore(input);
302 std::string
status =
"Query of memory " + name +
" was unsuccessful.";
303 _statusLabel->setText(QString::fromStdString(
status));
315 auto enabledMemories = _memoryGroupBoxView->ltmWidget()->getEnabledLTMMemories();
316 auto memoryReaders = _model->memoryReadersCopy();
317 for (
auto& [name, reader] : memoryReaders)
320 if (std::find(enabledMemories.begin(), enabledMemories.end(), name) ==
321 enabledMemories.end())
325 reader.startRecording();
336 auto enabledMemories = _memoryGroupBoxView->ltmWidget()->getEnabledLTMMemories();
337 auto memoryReaders = _model->memoryReadersCopy();
338 for (
auto& [name, reader] : memoryReaders)
341 if (std::find(enabledMemories.begin(), enabledMemories.end(), name) ==
342 enabledMemories.end())
346 reader.stopRecording();
356 std::map<std::string, const armem::wm::Memory*> memoriesToUpdate;
358 auto checkboxStates = _model->activeMemoryStates();
359 auto memoryData = _model->memoryDataCopy();
360 for (
auto& [name,
data] : memoryData)
365 memoriesToUpdate[name] = &
data;
371 _memoryGroupBoxView->tree()->update(memoriesToUpdate);
375 if (_model->debugObserver())
379 _model->debugObserver()->setDebugDatafield(
382 new Variant(GuiUpdateMemoryTree.toMilliSecondsDouble()));
384 catch (
const Ice::Exception&)
392 MemoryGroupBoxController::updateActiveMemories()
398 MemoryGroupBoxController::updateRecursionDepth(
int value)
400 _model->setRecursionDepth(value);
404 MemoryGroupBoxController::updateDataMode()
410 MemoryGroupBoxController::updateDropRemovedMemories()
416 MemoryGroupBoxController::updateDropDisabledMemories()
422 MemoryGroupBoxController::updateSelector()
424 _model->setSelector(_memoryGroupBoxView->snapshotSelectorWidget()->selector());
427 armem::gui::view::MemoryGroupBoxView*
430 return _memoryGroupBoxView;
436 return _instanceGroupBoxController.get();
#define ARMARX_CHECK_NULL(ptr)
SpamFilterDataPtr deactivateSpam(float deactivationDurationSec=10.0f, const std::string &identifier="", bool deactivate=true) const
disables the logging for the current line for the given amount of seconds.
The Variant class is described here: Variants.
bool hasGap() const
Indicate whether this ID has a gap such as in 'Memory//MyProvider' (no core segment name).
bool hasEntityName() const
MemoryID withTimestamp(Time time) const
Reads data from a memory server.
std::map< MemoryID, std::vector< PredictionEngine > > getAvailablePredictionEngines() const
Get the list of prediction engines supported by the memory.
QueryResult queryMemoryIDs(const std::vector< MemoryID > &ids, armem::query::DataMode dataMode=armem::query::DataMode::WithData) const
Query a specific set of memory IDs.
std::vector< PredictionResult > predict(const std::vector< PredictionRequest > &requests) const
Get a prediction for the state of multiple entity instances in the future.
server::PredictingMemoryInterfacePrx predictionPrx
controlls InstanceGroupBoxView
void updateInstanceTree(const armem::MemoryID &selectedID)
InstanceGroupBoxController * instanceGroupBoxController() const
armem::gui::view::MemoryGroupBoxView * memoryGroupBoxView() const
void onMakePrediction(const MemoryID &entityID, const aron::type::ObjectPtr &entityType, const armarx::DateTime ×tamp, const std::string &engineID)
void onStartLTMRecording()
void onStopLTMRecording()
MemoryGroupBoxController(MemoryViewerUIContext &uiContext, std::shared_ptr< armem::gui::model::MemoryViewerModel > model)
QueryWidget * queryWidget() const
static data::DictPtr ConvertFromNlohmannJSONObject(const nlohmann::json &, const armarx::aron::Path &p={})
Represents a point in time.
#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.
#define ARMARX_VERBOSE
The logging level for verbose information.
#define TIMING_START(name)
Helper macro to do timing tests.
#define TIMING_END_STREAM(name, os)
Prints duration.
instance::AronDataView AronDataView
@ NoData
Just get the structure, but no ARON data.
std::vector< ValueT > accumulateEntriesContainingID(const std::map< MemoryID, ValueT > &idMap, const MemoryID &id)
Return all values of keys containing the given ID.
std::shared_ptr< Object > ObjectPtr
void replaceWidget(WidgetT *&old, QWidget *neu, QLayout *parentLayout)
A bundle of updates to be sent to the memory.
MemoryID entityID
The entity's ID.
armem::MemoryID snapshotID
PredictionSettings predictionSettings
aron::data::DictPtr prediction
std::string predictionEngineID
auto * findProviderSegment(const MemoryID &providerSegmentID)
Retrieve a provider segment.
wm::Memory memory
The slice of the memory that matched the query.
QLayout * memoryGroupBoxParentLayout
QGroupBox * memoryGroupBox