27 #include <SimoxUtility/algorithm/string/string_tools.h>
33 LONGTERM_SNAPSHOT_PREFIX(
"Snapshot_")
68 workingMemoryPrx = getProxy<memoryx::WorkingMemoryInterfacePrx>(
"WorkingMemory");
69 longtermMemoryPrx = getProxy<memoryx::LongtermMemoryInterfacePrx>(
"LongtermMemory");
81 void SnapshotControlWidgetController::connectSlots()
83 connect(widget.loadSnapshotButton, SIGNAL(clicked()),
this, SLOT(
loadSnapshot()));
84 connect(widget.removeSnapshotButton, SIGNAL(clicked()),
this, SLOT(
removeSnapshot()));
85 connect(widget.saveSnapshotButton, SIGNAL(clicked()),
this, SLOT(
saveSnapshot()));
86 connect(widget.snapshotName, SIGNAL(textChanged(QString)),
this, SLOT(snapshotNameChanged(QString)));
87 widget.loadSnapshotButton->setEnabled(
false);
88 widget.removeSnapshotButton->setEnabled(
false);
89 widget.saveSnapshotButton->setEnabled(
false);
93 void SnapshotControlWidgetController::snapshotNameChanged(
const QString& snapshotName)
95 widget.saveSnapshotButton->setEnabled(!snapshotName.isEmpty());
101 NameList snapshotNames = longtermMemoryPrx->getSnapshotNames();
102 widget.availableSnapshotsList->clear();
104 for (
auto snapshotName : snapshotNames)
106 widget.availableSnapshotsList->addItem(QString::fromStdString(snapshotName));
109 if (!snapshotNames.empty())
111 widget.loadSnapshotButton->setEnabled(
true);
112 widget.removeSnapshotButton->setEnabled(
true);
120 const std::string snapshotName = widget.availableSnapshotsList->currentText().toStdString();
122 if (snapshotName.empty())
129 ARMARX_INFO <<
"Loading Snapshot with Name: " << snapshotName;
130 longtermMemoryPrx->loadWorkingMemorySnapshot(snapshotName, workingMemoryPrx);
131 ARMARX_INFO <<
"Snapshot succcessfully loaded: " << snapshotName;
133 catch (
const armarx::LocalException& e)
135 ARMARX_ERROR <<
"SnapshotName could not be loaded: " << snapshotName;
144 const std::string snapshotName = widget.availableSnapshotsList->currentText().toStdString();
146 if (snapshotName.empty())
153 ARMARX_INFO <<
"Removing Snapshot with Name: " << snapshotName;
154 longtermMemoryPrx->removeWorkingMemorySnapshot(snapshotName);
155 ARMARX_INFO <<
"Snapshot succcessfully removed: " << snapshotName;
157 catch (
const armarx::LocalException& e)
159 ARMARX_ERROR <<
"SnapshotName could not be removed: " << snapshotName;
168 std::string snapshotName = widget.snapshotName->text().toStdString();
170 if (snapshotName.empty())
177 snapshotName = std::string(LONGTERM_SNAPSHOT_PREFIX) + snapshotName;
178 ARMARX_WARNING <<
"Snapshot name must start with <" << LONGTERM_SNAPSHOT_PREFIX <<
">. Changing to " << snapshotName;
181 ARMARX_LOG <<
"Saving snapshot: " << snapshotName;
182 longtermMemoryPrx->saveWorkingMemorySnapshot(snapshotName, workingMemoryPrx);