SystemStateMonitorWidget.h
Go to the documentation of this file.
1/*
2 * This file is part of ArmarX.
3 *
4 * Copyright (C) 2011-2016, High Performance Humanoid Technologies (H2T), Karlsruhe Institute of Technology (KIT), all rights reserved.
5 *
6 * ArmarX is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License version 2 as
8 * published by the Free Software Foundation.
9 *
10 * ArmarX is distributed in the hope that it will be useful, but
11 * WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program. If not, see <http://www.gnu.org/licenses/>.
17 *
18 * @package ArmarX::Gui
19 * @author Jan Issac ( jan.issac at gmail dot com )
20 * @date 2012
21 * @copyright http://www.gnu.org/licenses/gpl-2.0.txt
22 * GNU General Public License
23 */
24
25
26#pragma once
27
28#include <mutex>
29
30#include <QTimer>
31#include <QWidget>
32
36
37#include <ArmarXGui/gui-plugins/SystemStateMonitorPlugin/ui_SystemStateMonitorWidget.h>
41
42#include "ArmarXManagerModel.h"
44
45namespace Ui
46{
47 class SystemStateMonitorWidget;
48}
49
50namespace armarx
51{
52
54
55 /**
56 \page ArmarXGui-GuiPlugins-SystemStateMonitor SystemStateMonitor
57 \brief The SystemStateMonitor allows you to inspect the properties of the running ArmarX components.
58
59 \image html SystemStateMonitor.png
60 To inspect a component, press the button at the bottom with the wrench symbol.
61 Select any component you wish to inspect from the appearing list.
62 Every component that is waiting for dependencies or is currently starting is yellow. If it was successfully started, it will be green. The dependencies of components are shown in the subtree of each component. Available dependencies are green while missing dependencies are red.
63
64 \see SystemStateMonitorWidget
65 \see SystemStateMonitorPlugin
66 */
67
68 /**
69 \class SystemStateMonitorWidget
70 \brief The SystemStateMonitor allows you to inspect the properties of the running ArmarX components.
71 \see SystemStateMonitorPlugin
72 */
74 public ArmarXComponentWidgetControllerTemplate<SystemStateMonitorWidget>
75 {
76 Q_OBJECT
77
78 public:
79 explicit SystemStateMonitorWidget();
81
82 /**
83 * View setup
84 */
85 void setupView();
86
87 /**
88 * Model setup
89 */
90 void setupModel();
91
92 /**
93 * Load stored manager models
94 */
95 void loadSettings(QSettings* settings) override;
96
97 /**
98 * Saves the manager models
99 */
100 void saveSettings(QSettings* settings) override;
101
102 /**
103 * Returns the Widget name displayed in the ArmarXGui to create an
104 * instance of this.
105 */
106 static QString
108 {
109 return "Meta.SystemStateMonitor";
110 }
111
112 /**
113 * @see armarx::Component::onInitComponent()
114 */
115 void onInitComponent() override;
116
117 /**
118 * @see armarx::Component::onConnectComponent()
119 */
120 void onConnectComponent() override;
121
122 void onDisconnectComponent() override;
123
124 void onExitComponent() override;
125
127
128 bool retrieveManagerObjectsState(ArmarXManagerInterfacePrx prx,
129 ArmarXManagerItem::ObjectMap& objectStates);
130 bool retrieveManagerData(ArmarXManagerInterfacePrx prx,
131 ArmarXManagerItem::ManagerData& managerData);
132
133 signals:
134
136 public slots:
138 /**
139 * Updates the states of the managers stated in the monitored list
140 */
142
143 /**
144 * Accept config changes
145 */
146 void acceptConfig();
147
148 /**
149 * Retrieves the online managers
150 */
152
153 /**
154 * Opens the config dialog
155 */
157 void addArmarXManagers(QStringList managerNames);
158
159 private slots:
160 /**
161 * Prefills the widgets view with all currently existing components
162 */
163 void prefillView();
164 void addArmarXManagerEntries(ManagerPrxMap managers);
165 void expandFilterSelection(QString filterStr);
166 void delayedFilterExpansion();
167 void on_btnProblematicOnly_toggled(bool checked);
168
169 private:
170 void fillLegendLayout(QHBoxLayout* layout, ArmarXManagerModel& model) const;
171
172 private:
173 /**
174 * Active monitored managers model
175 */
176 ArmarXManagerModel* monitoredManagerModel;
177
178 /**
179 * Passive manager repository
180 */
181 ArmarXManagerModel* managerRepositoryModel;
182
183 std::mutex managerPrxMapMutex;
184 ManagerPrxMap currentManagerPrxMap;
185 QTimer filterExpansionTimer;
186 /**
187 * Main widget
188 */
189 Ui::SystemStateMonitorWidget ui;
190
191 /**
192 * Config dialog
193 */
194 ArmarXManagerRepositoryDialog* managerRepositoryDialog;
195 QPointer<InfixFilterModel> filterModel;
196
197 /**
198 * Monitored managers state update periodic task
199 */
201
202 /**
203 * Fetches the online managers
204 */
205 QStringList fetchOnlineManagers();
206
207
208 // ArmarXWidgetController interface
209 public:
210 static QIcon
212 {
213 return QIcon(":icons/activity_monitor.png");
214 }
215 };
216
218 {
219 public:
221 {
222 }
223
224 // QSortFilterProxyModel interface
225 bool getHideResolvedComponents() const;
226 void setHideResolvedComponents(bool value);
227
228 protected:
229 bool
230 filterAcceptsRow(int source_row, const QModelIndex& source_parent) const override
231 {
232 if (!InfixFilterModel::filterAcceptsRow(source_row, source_parent))
233 {
234 return false;
235 }
236 QModelIndex index0 = sourceModel()->index(source_row, 0, source_parent);
238 {
239 auto variant =
241 if (variant.isValid())
242 {
243 // ARMARX_INFO << "Checking entry: " << index0.data().toString() << " val: " << variant.toBool() << " param: " << hideResolvedComponents;
244 if (variant.toBool())
245 {
246 ARMARX_VERBOSE << "Hiding entry: " << index0.data().toString();
247 return false;
248 }
249 }
250 else
251 {
252 return false;
253 }
254 }
255
256
257 return true;
258 }
259
261 };
262
263} // namespace armarx
#define ARMARXCOMPONENT_IMPORT_EXPORT
std::map< QString, ManagerData > ManagerDataMap
QMap< QString, ManagedIceObjectItem > ObjectMap
bool filterAcceptsRow(int source_row, const QModelIndex &source_parent) const override
InfixFilterModel(QObject *parent=0)
IceUtil::Handle< PeriodicTask< T > > pointer_type
Shared pointer type for convenience.
bool filterAcceptsRow(int source_row, const QModelIndex &source_parent) const override
void updateManagerStatesSignal(const ArmarXManagerItem::ManagerDataMap &)
bool retrieveManagerData(ArmarXManagerInterfacePrx prx, ArmarXManagerItem::ManagerData &managerData)
void loadSettings(QSettings *settings) override
Load stored manager models.
void updateManagerStates(const ArmarXManagerItem::ManagerDataMap &managerData)
Updates the states of the managers stated in the monitored list.
void saveSettings(QSettings *settings) override
Saves the manager models.
void openManagerRepositoryDialog()
Opens the config dialog.
void retrieveManagerObjectsState(ArmarXManagerItem *item)
void addArmarXManagers(QStringList managerNames)
static QString GetWidgetName()
Returns the Widget name displayed in the ArmarXGui to create an instance of this.
void acceptConfig()
Accept config changes.
void retrieveOnlineManagers()
Retrieves the online managers.
#define ARMARX_VERBOSE
The logging level for verbose information.
Definition Logging.h:187
ArmarX Headers.
This file offers overloads of toIce() and fromIce() functions for STL container types.
std::map< QString, ArmarXManagerInterfacePrx > ManagerPrxMap