MemoryViewer.h
Go to the documentation of this file.
1 #pragma once
2 
3 #include <future>
4 #include <string>
5 
6 #include <QObject>
7 
9 #include <ArmarXCore/interface/observers/ObserverInterface.h>
10 
11 #include <RobotAPI/interface/armem/actions.h>
12 #include <RobotAPI/interface/armem/mns/MemoryNameSystemInterface.h>
21 
22 
23 class QBoxLayout;
24 class QDialog;
25 class QGroupBox;
26 class QLabel;
27 class QLayout;
28 class QSettings;
29 class QTimer;
30 
31 namespace armarx
32 {
33  class ManagedIceObject;
34  class SimpleConfigDialog;
35 } // namespace armarx
36 
37 namespace armarx::armem::gui
38 {
39 
40  class MemoryViewer : public QObject, public armarx::Logging, public armarx::gui::LifecycleClient
41  {
42  Q_OBJECT
43  using This = MemoryViewer;
44 
45 
46  public:
47  MemoryViewer(QBoxLayout* updateWidgetLayout,
48  QGroupBox* memoryGroupBox,
49  QLayout* memoryGroupBoxParentLayout,
50  QGroupBox* instanceGroupBox,
51  QLayout* instanceGroupBoxParentLayout,
52  QBoxLayout* diskControlWidgetLayout,
53  QLabel* statusLabel);
54 
55  void setLogTag(const std::string& tag);
56 
57 
58  void loadSettings(QSettings* settings);
59  void saveSettings(QSettings* settings);
60 
63 
64 
65  public slots:
66 
67  void updateInstanceTree(const armem::MemoryID& selectedID);
68 
69  void resolveMemoryID(const MemoryID& id);
70 
71  void
72  showActionsMenu(const MemoryID& memoryID, QWidget* parent, const QPoint& pos, QMenu* menu);
73 
74  void makePrediction(const MemoryID& entityID,
75  const aron::type::ObjectPtr& entityType,
76  const armarx::DateTime& timestamp,
77  const std::string& engineID);
78 
79  // Disk Control
80  void storeOnDisk(QString directory);
81  void loadFromDisk(QString directory);
82 
83  void queryAndStoreInLTM();
84  void startLTMRecording();
85  void stopLTMRecording();
86 
87  void commit();
88 
89 
90  signals:
91 
92  void initialized();
93  void connected();
94  void disconnected();
95 
96  void memoryTreeUpdated();
97  void instanceTreeUpdated();
98 
99 
100  private slots:
101 
102  void startQueries();
103  void startPeriodicUpdateTimer();
104  void processQueryResults();
105 
106  void updateMemoryTree();
107  void updateListOfActiveMemories();
108 
109  void collapseAll();
110 
111 
112  signals:
113 
114  void memoryDataChanged();
115 
116 
117  private:
121 
122  const armem::wm::Memory* getSingleMemoryData(const std::string& memoryName);
123  void updateStatusLabel(int errorCount);
124 
125 
126  /// Start a query for each entry in `memoryReaders` which is not in `runningQueries`.
127  void startDueQueries();
128 
129  std::map<std::string, client::QueryResult> collectQueryResults();
130 
131  void applyQueryResults(const std::map<std::string, client::QueryResult>& results,
132  int* outErrorCount = nullptr);
133 
134 
135  public:
136  std::string mnsName;
138 
139  std::map<std::string, armem::client::Reader> memoryReaders;
140  std::map<std::string, armem::client::Writer> memoryWriters;
141 
142  std::map<std::string, armem::wm::Memory> memoryData;
143 
144  std::map<std::string, std::future<armem::query::data::Result>> runningQueries;
145 
146  /// Periodically triggers query result collection and updates the available memories
148 
149 
150  QLayout* updateWidgetLayout = nullptr;
152 
153  QLayout* diskControlLayout = nullptr;
155 
157 
159 
160  QLabel* statusLabel = nullptr;
161 
162 
163  std::string debugObserverName;
165 
166  // Queries.
167  armem::query::data::EntityQueryPtr entityQuery;
168 
169  // others
170  std::atomic_bool is_initialized = false;
171  std::atomic_bool is_connected = false;
172  };
173 
174 } // namespace armarx::armem::gui
armarx::armem::gui::disk::ControlWidget
Definition: ControlWidget.h:17
armarx::armem::gui::instance::GroupBox
Definition: GroupBox.h:15
armarx::armem::gui::MemoryViewer::updateWidget
armem::gui::PeriodicUpdateWidget * updateWidget
Definition: MemoryViewer.h:151
armarx::armem::gui::memory::GroupBox
Definition: GroupBox.h:18
Reader.h
armarx::gui::LifecycleClient::onDisconnect
virtual void onDisconnect()
Definition: lifecycle.cpp:84
Writer.h
armarx::ProxyType::component
@ component
armarx::armem::gui::MemoryViewer::updateInstanceTree
void updateInstanceTree(const armem::MemoryID &selectedID)
Definition: MemoryViewer.cpp:672
armarx::armem::gui::MemoryViewer::is_connected
std::atomic_bool is_connected
Definition: MemoryViewer.h:171
armarx::armem::gui::MemoryViewer::debugObserver
DebugObserverInterfacePrx debugObserver
Definition: MemoryViewer.h:164
armarx::armem::gui::MemoryViewer::startLTMRecording
void startLTMRecording()
Definition: MemoryViewer.cpp:330
armarx::armem::gui::MemoryViewer::readConfigDialog
void readConfigDialog(SimpleConfigDialog *dialog)
Definition: MemoryViewer.cpp:1054
armarx::armem::gui::MemoryViewer::connected
void connected()
armarx::armem::gui::MemoryViewer::diskControlLayout
QLayout * diskControlLayout
Definition: MemoryViewer.h:153
armarx::armem::gui::MemoryViewer::commit
void commit()
Definition: MemoryViewer.cpp:372
armarx::armem::gui::PeriodicUpdateWidget
Definition: PeriodicUpdateWidget.h:14
armarx::armem::gui::MemoryViewer::resolveMemoryID
void resolveMemoryID(const MemoryID &id)
Definition: MemoryViewer.cpp:722
armarx::armem::gui::MemoryViewer::runningQueries
std::map< std::string, std::future< armem::query::data::Result > > runningQueries
Definition: MemoryViewer.h:144
armarx::armem::gui::MemoryViewer::instanceTreeUpdated
void instanceTreeUpdated()
ControlWidget.h
armarx::armem::gui::MemoryViewer::writeConfigDialog
void writeConfigDialog(SimpleConfigDialog *dialog)
Definition: MemoryViewer.cpp:1045
armarx::gui::LifecycleClient::onInit
virtual void onInit()
Definition: lifecycle.cpp:76
armarx::armem::gui::MemoryViewer::storeOnDisk
void storeOnDisk(QString directory)
Definition: MemoryViewer.cpp:421
armarx::armem::gui::MemoryViewer::mnsName
std::string mnsName
Definition: MemoryViewer.h:136
armarx::armem::MemoryID
A memory ID.
Definition: MemoryID.h:47
armarx::gui::LifecycleClient
Definition: lifecycle.h:54
armarx::armem::wm::Memory
Client-side working memory.
Definition: memory_definitions.h:133
armarx::armem::gui::MemoryViewer::setLogTag
void setLogTag(const std::string &tag)
Definition: MemoryViewer.cpp:204
PeriodicUpdateWidget.h
armarx::armem::gui::MemoryViewer::statusLabel
QLabel * statusLabel
Definition: MemoryViewer.h:160
GroupBox.h
armarx::armem::gui::MemoryViewer::instanceGroup
armem::gui::InstanceGroupBox * instanceGroup
Definition: MemoryViewer.h:158
armarx::armem::gui::MemoryViewer::mns
armem::client::MemoryNameSystem mns
Definition: MemoryViewer.h:137
armarx::armem::gui::MemoryViewer::saveSettings
void saveSettings(QSettings *settings)
Definition: MemoryViewer.cpp:1036
armarx::armem::gui::MemoryViewer::memoryData
std::map< std::string, armem::wm::Memory > memoryData
Definition: MemoryViewer.h:142
armarx::armem::gui::MemoryViewer::makePrediction
void makePrediction(const MemoryID &entityID, const aron::type::ObjectPtr &entityType, const armarx::DateTime &timestamp, const std::string &engineID)
Definition: MemoryViewer.cpp:962
armarx::armem::gui::MemoryViewer::showActionsMenu
void showActionsMenu(const MemoryID &memoryID, QWidget *parent, const QPoint &pos, QMenu *menu)
Definition: MemoryViewer.cpp:859
armarx::core::time::DateTime
Represents a point in time.
Definition: DateTime.h:24
armarx::armem::gui::MemoryViewer::debugObserverName
std::string debugObserverName
Definition: MemoryViewer.h:163
armarx::armem::gui::MemoryViewer::disconnected
void disconnected()
armarx::gui::LifecycleClient::onConnect
virtual void onConnect()
Definition: lifecycle.cpp:80
armarx::ManagedIceObject
The ManagedIceObject is the base class for all ArmarX objects.
Definition: ManagedIceObject.h:163
armarx::Logging
Base Class for all Logging classes.
Definition: Logging.h:232
armarx::armem::gui::MemoryViewer::memoryGroup
armem::gui::MemoryGroupBox * memoryGroup
Definition: MemoryViewer.h:156
armarx::armem::gui::MemoryViewer
Definition: MemoryViewer.h:40
armarx::armem::gui::MemoryViewer::loadFromDisk
void loadFromDisk(QString directory)
Definition: MemoryViewer.cpp:434
armarx::armem::gui::MemoryViewer::periodicUpdateTimer
QTimer * periodicUpdateTimer
Periodically triggers query result collection and updates the available memories.
Definition: MemoryViewer.h:147
armarx::armem::gui::MemoryViewer::queryAndStoreInLTM
void queryAndStoreInLTM()
Definition: MemoryViewer.cpp:297
armarx::armem::laser_scans::constants::memoryName
const std::string memoryName
Definition: constants.h:28
armarx::armem::gui::MemoryViewer::MemoryViewer
MemoryViewer(QBoxLayout *updateWidgetLayout, QGroupBox *memoryGroupBox, QLayout *memoryGroupBoxParentLayout, QGroupBox *instanceGroupBox, QLayout *instanceGroupBoxParentLayout, QBoxLayout *diskControlWidgetLayout, QLabel *statusLabel)
Definition: MemoryViewer.cpp:41
armarx::armem::gui
Definition: ActionsMenuBuilder.cpp:6
armarx::armem::index::memoryID
const MemoryID memoryID
Definition: memory_ids.cpp:29
IceInternal::ProxyHandle<::IceProxy::armarx::DebugObserverInterface >
armarx::Logging::tag
LogTag tag
Definition: Logging.h:271
armarx::armem::gui::MemoryViewer::diskControl
armem::gui::disk::ControlWidget * diskControl
Definition: MemoryViewer.h:154
armarx::armem::client::MemoryNameSystem
The memory name system (MNS) client.
Definition: MemoryNameSystem.h:69
armarx::armem::gui::MemoryViewer::memoryReaders
std::map< std::string, armem::client::Reader > memoryReaders
Definition: MemoryViewer.h:139
armarx::armem::gui::MemoryViewer::entityQuery
armem::query::data::EntityQueryPtr entityQuery
Definition: MemoryViewer.h:167
GroupBox.h
MemoryNameSystem.h
lifecycle.h
armarx::aron::type::ObjectPtr
std::shared_ptr< Object > ObjectPtr
Definition: Object.h:36
Logging.h
armarx::armem::gui::MemoryViewer::loadSettings
void loadSettings(QSettings *settings)
Definition: MemoryViewer.cpp:1024
armarx::armem::gui::MemoryViewer::memoryWriters
std::map< std::string, armem::client::Writer > memoryWriters
Definition: MemoryViewer.h:140
armarx::armem::gui::MemoryViewer::initialized
void initialized()
armarx::armem::gui::MemoryViewer::is_initialized
std::atomic_bool is_initialized
Definition: MemoryViewer.h:170
armarx::armem::gui::MemoryViewer::memoryTreeUpdated
void memoryTreeUpdated()
armarx::armem::gui::MemoryViewer::memoryDataChanged
void memoryDataChanged()
armarx::armem::gui::MemoryViewer::updateWidgetLayout
QLayout * updateWidgetLayout
Definition: MemoryViewer.h:150
armarx::armem::gui::MemoryViewer::stopLTMRecording
void stopLTMRecording()
Definition: MemoryViewer.cpp:351
armarx
This file offers overloads of toIce() and fromIce() functions for STL container types.
Definition: ArmarXTimeserver.cpp:28
armarx::SimpleConfigDialog
A config-dialog containing one (or multiple) proxy finders.
Definition: SimpleConfigDialog.h:84