10#include <Ice/Exception.h>
19#include <RobotAPI/interface/armem/actions.h>
20#include <RobotAPI/interface/armem/memory.h>
21#include <RobotAPI/interface/armem/mns/MemoryNameSystemInterface.h>
35 _statusLabel->clear();
36 _statusLabel->setContextMenuPolicy(Qt::CustomContextMenu);
38 &QLabel::customContextMenuRequested,
39 [
this](
const QPoint& pos)
41 QMenu menu(_statusLabel);
42 menu.addAction(
"Copy to clipboard",
44 { QApplication::clipboard()->setText(_statusLabel->text()); });
45 menu.addAction(
"Clear status", [
this]() { _statusLabel->clear(); });
46 menu.exec(_statusLabel->mapToGlobal(pos));
49 _model = std::make_shared<armem::gui::model::MemoryViewerModel>();
51 _diskIOController = std::make_unique<armem::gui::controller::DiskIOController>(
55 _periodicUpdateController = std::make_unique<armem::gui::controller::PeriodicUpdateController>(
59 connect(_periodicUpdateController
60 ->memoryGroupBoxController()
61 ->memoryGroupBoxView()
66 connect(_periodicUpdateController
67 ->memoryGroupBoxController()
68 ->instanceGroupBoxController()
69 ->instanceGroupBoxView()
85 if (_mnsName.size() > 0)
89 if (_debugObserverName.size() > 0)
94 _model->setInitialized(
true);
101 if (not _mnsName.empty())
103 armem::mns::MemoryNameSystemInterfacePrx mnsProxy;
105 _model->setMns(std::make_unique<client::MemoryNameSystem>(mnsProxy));
107 const bool update =
true;
109 _model->setMemoryReaders(_model->mns().getAllReaders(update));
110 _model->setMemoryWriters(_model->mns().getAllWriters(update));
113 if (not _debugObserverName.empty())
116 component.getProxy(observer, _debugObserverName,
false,
"",
false);
117 _model->setDebugObserver(observer);
120 emit _periodicUpdateController->startPeriodicTimerSignal();
121 _periodicUpdateController->startAutoUpdateTimerIfEnabled();
123 _model->setConnected(
true);
130 emit _periodicUpdateController->stopAutoUpdateTimerSignal();
131 emit _periodicUpdateController->stopPeriodicTimerSignal();
133 _model->setConnected(
false);
145 auto showMenu = [menu, pos]()
158 mns::dto::MemoryServerInterfaces prx;
161 prx = _model->mns().resolveServer(memoryID);
165 _statusLabel->setText(
166 QString::fromStdString(e.
makeMsg(memoryID,
"Could not resolve memory server.")));
173 std::stringstream ss;
174 ss <<
"Memory server " << memoryID <<
" does not support actions or is offline.";
175 _statusLabel->setText(QString::fromStdString(ss.str()));
180 actions::GetActionsOutputSeq result;
185 catch (
const Ice::LocalException& e)
187 std::stringstream ss;
188 ss <<
"Could not get actions for " << memoryID <<
".";
189 _statusLabel->setText(QString::fromStdString(ss.str()));
194 if (result.size() == 0)
202 [
this, prx](
const MemoryID& memoryID,
const actions::ActionPath& path)
204 actions::data::ExecuteActionOutputSeq result;
207 result = prx.actions->executeActions(
210 catch (
const Ice::LocalException& e)
212 std::stringstream ss;
213 ss <<
"Failed to execute action: " << e.what();
214 _statusLabel->setText(QString::fromStdString(ss.str()));
217 for (
const auto& [
success, errorMessage] : result)
221 std::stringstream ss;
222 ss <<
"Failed to execute action: " << errorMessage;
223 _statusLabel->setText(QString::fromStdString(ss.str()));
232 actionsMenu->exec(pos);
236 menu->addMenu(actionsMenu);
241 const static std::string CONFIG_KEY_MEMORY =
"MemoryViewer.MemoryNameSystem";
242 const static std::string CONFIG_KEY_DEBUG_OBSERVER =
"MemoryViewer.DebugObserverName";
247 _mnsName = settings->value(QString::fromStdString(CONFIG_KEY_MEMORY),
"MemoryNameSystem")
251 settings->value(QString::fromStdString(CONFIG_KEY_DEBUG_OBSERVER),
"DebugObserver")
259 settings->setValue(QString::fromStdString(CONFIG_KEY_MEMORY),
260 QString::fromStdString(_mnsName));
261 settings->setValue(QString::fromStdString(CONFIG_KEY_DEBUG_OBSERVER),
262 QString::fromStdString(_debugObserverName));
268 dialog->
addProxyFinder<armarx::armem::mns::MemoryNameSystemInterfacePrx>(
269 {CONFIG_KEY_MEMORY,
"MemoryNameSystem",
"MemoryNameSystem"});
271 {CONFIG_KEY_DEBUG_OBSERVER,
"Debug Observer",
"DebugObserver"});
278 if (_mnsName.empty())
280 _mnsName =
"MemoryNameSystem";
283 _debugObserverName = dialog->
getProxyName(CONFIG_KEY_DEBUG_OBSERVER);
void setTag(const LogTag &tag)
The ManagedIceObject is the base class for all ArmarX objects.
A config-dialog containing one (or multiple) proxy finders.
void addProxyFinder(const std::vector< EntryData > &entryData)
std::string getProxyName(const std::string &entryName) const
Indicates that a query to the Memory Name System failed.
static std::string makeMsg(const MemoryID &memoryID, const std::string &errorMessage="")
void readConfigDialog(SimpleConfigDialog *dialog)
void setLogTag(const std::string &tag)
void showActionsMenu(const MemoryID &memoryID, QWidget *parent, const QPoint &pos, QMenu *menu)
void saveSettings(QSettings *settings)
void loadSettings(QSettings *settings)
void writeConfigDialog(SimpleConfigDialog *dialog)
MemoryViewer(MemoryViewerUIContext &uiContext)
void actionsMenuRequested(const MemoryID &memoryID, QWidget *parent, const QPoint &pos, QMenu *menu)
virtual void onDisconnect()
#define ARMARX_WARNING
The logging level for unexpected behaviour, but not a serious problem.
::IceInternal::ProxyHandle<::IceProxy::armarx::DebugObserverInterface > DebugObserverInterfacePrx
void toIce(std::map< IceKeyT, IceValueT > &iceMap, const boost::container::flat_map< CppKeyT, CppValueT > &cppMap)