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 <ArmarXGui/gui-plugins/SystemStateMonitorPlugin/ui_SystemStateMonitorWidget.h>
29 #include "ArmarXManagerModel.h"
31 
32 #include <QTimer>
33 #include <QWidget>
34 
39 
42 
43 #include <mutex>
44 
45 namespace Ui
46 {
47  class SystemStateMonitorWidget;
48 }
49 
50 namespace armarx
51 {
52 
53  class SystemStateMonitorFilterModel;
54  /**
55  \page ArmarXGui-GuiPlugins-SystemStateMonitor SystemStateMonitor
56  \brief The SystemStateMonitor allows you to inspect the properties of the running ArmarX components.
57 
58  \image html SystemStateMonitor.png
59  To inspect a component, press the button at the bottom with the wrench symbol.
60  Select any component you wish to inspect from the appearing list.
61  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.
62 
63  \see SystemStateMonitorWidget
64  \see SystemStateMonitorPlugin
65  */
66 
67  /**
68  \class SystemStateMonitorWidget
69  \brief The SystemStateMonitor allows you to inspect the properties of the running ArmarX components.
70  \see SystemStateMonitorPlugin
71  */
74  public ArmarXComponentWidgetControllerTemplate<SystemStateMonitorWidget>
75  {
76  Q_OBJECT
77 
78  public:
79 
80  explicit SystemStateMonitorWidget();
81  ~SystemStateMonitorWidget() override;
82 
83  /**
84  * View setup
85  */
86  void setupView();
87 
88  /**
89  * Model setup
90  */
91  void setupModel();
92 
93  /**
94  * Load stored manager models
95  */
96  void loadSettings(QSettings* settings) override;
97 
98  /**
99  * Saves the manager models
100  */
101  void saveSettings(QSettings* settings) override;
102 
103  /**
104  * Returns the Widget name displayed in the ArmarXGui to create an
105  * instance of this.
106  */
107  static QString GetWidgetName()
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 
126  void retrieveManagerObjectsState(ArmarXManagerItem* item);
127 
128  bool retrieveManagerObjectsState(ArmarXManagerInterfacePrx prx, ArmarXManagerItem::ObjectMap& objectStates);
129  bool retrieveManagerData(ArmarXManagerInterfacePrx prx, ArmarXManagerItem::ManagerData& managerData);
130 
131  signals:
132 
133  void updateManagerStatesSignal(const ArmarXManagerItem::ManagerDataMap&);
134  public slots:
135  void updateManagerObjectsState();
136  /**
137  * Updates the states of the managers stated in the monitored list
138  */
139  void updateManagerStates(const ArmarXManagerItem::ManagerDataMap& managerData);
140 
141  /**
142  * Accept config changes
143  */
144  void acceptConfig();
145 
146  /**
147  * Retrieves the online managers
148  */
149  void retrieveOnlineManagers();
150 
151  /**
152  * Opens the config dialog
153  */
154  void openManagerRepositoryDialog();
155  void addArmarXManagers(QStringList managerNames);
156 
157  private slots:
158  /**
159  * Prefills the widgets view with all currently existing components
160  */
161  void prefillView();
162  void addArmarXManagerEntries(ManagerPrxMap managers);
163  void expandFilterSelection(QString filterStr);
164  void delayedFilterExpansion();
165  void on_btnProblematicOnly_toggled(bool checked);
166 
167  private:
168 
169  void fillLegendLayout(QHBoxLayout* layout, ArmarXManagerModel& model) const;
170 
171  private:
172 
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 
209  // ArmarXWidgetController interface
210  public:
211  static QIcon GetWidgetIcon()
212  {
213  return QIcon(":icons/activity_monitor.png");
214  }
215  };
216 
218  {
219  public:
220  SystemStateMonitorFilterModel(QObject* parent) :
221  InfixFilterModel(parent) {}
222 
223  // QSortFilterProxyModel interface
224  bool getHideResolvedComponents() const;
225  void setHideResolvedComponents(bool value);
226 
227  protected:
228  bool filterAcceptsRow(int source_row, const QModelIndex& source_parent) const override
229  {
230  if (!InfixFilterModel::filterAcceptsRow(source_row, source_parent))
231  {
232  return false;
233  }
234  QModelIndex index0 = sourceModel()->index(source_row, 0, source_parent);
236  {
237  auto variant = index0.data((int)ArmarXManagerModel::UserDataRoles::ComponentStarted);
238  if (
239  variant.isValid())
240  {
241  // ARMARX_INFO << "Checking entry: " << index0.data().toString() << " val: " << variant.toBool() << " param: " << hideResolvedComponents;
242  if (variant.toBool())
243  {
244  ARMARX_VERBOSE << "Hiding entry: " << index0.data().toString();
245  return false;
246  }
247  }
248  else
249  {
250  return false;
251  }
252  }
253 
254 
255  return true;
256  }
258 
259  };
260 
261 }
262 
ARMARX_VERBOSE
#define ARMARX_VERBOSE
Definition: Logging.h:180
armarx::SystemStateMonitorFilterModel::filterAcceptsRow
bool filterAcceptsRow(int source_row, const QModelIndex &source_parent) const override
Definition: SystemStateMonitorWidget.h:228
armarx::SystemStateMonitorWidget::GetWidgetIcon
static QIcon GetWidgetIcon()
Definition: SystemStateMonitorWidget.h:211
ArmarXManagerRepositoryDialog.h
ArmarXManagerModel.h
armarx::ArmarXManagerModel
Definition: ArmarXManagerModel.h:47
armarx::ArmarXManagerRepositoryDialog
Definition: ArmarXManagerRepositoryDialog.h:46
PeriodicTask.h
InfixFilterModel.h
armarx::ArmarXComponentWidgetControllerTemplate
Definition: ArmarXComponentWidgetController.h:69
armarx::SystemStateMonitorWidget
The SystemStateMonitor allows you to inspect the properties of the running ArmarX components.
Definition: SystemStateMonitorWidget.h:72
armarx::SystemStateMonitorWidget::GetWidgetName
static QString GetWidgetName()
Returns the Widget name displayed in the ArmarXGui to create an instance of this.
Definition: SystemStateMonitorWidget.h:107
ArmarXGuiPlugin.h
armarx::SystemStateMonitorFilterModel::setHideResolvedComponents
void setHideResolvedComponents(bool value)
Definition: SystemStateMonitorWidget.cpp:576
cxxopts::value
std::shared_ptr< Value > value()
Definition: cxxopts.hpp:926
ArmarXComponentWidgetController.h
ARMARXCOMPONENT_IMPORT_EXPORT
#define ARMARXCOMPONENT_IMPORT_EXPORT
Definition: ImportExportComponent.h:38
Ui
ArmarX Headers.
Definition: ArmarXMainWindow.h:58
armarx::ArmarXManagerModel::UserDataRoles::ComponentStarted
@ ComponentStarted
armarx::SystemStateMonitorFilterModel::SystemStateMonitorFilterModel
SystemStateMonitorFilterModel(QObject *parent)
Definition: SystemStateMonitorWidget.h:220
armarx::ArmarXManagerItem::ManagerDataMap
std::map< QString, ManagerData > ManagerDataMap
Definition: ArmarXManagerItem.h:56
Component.h
armarx::SystemStateMonitorFilterModel::getHideResolvedComponents
bool getHideResolvedComponents() const
Definition: SystemStateMonitorWidget.cpp:571
armarx::ArmarXManagerItem::ObjectMap
QMap< QString, ManagedIceObjectItem > ObjectMap
Definition: ArmarXManagerItem.h:44
armarx::SystemStateMonitorFilterModel
Definition: SystemStateMonitorWidget.h:217
IceUtil::Handle
Definition: forward_declarations.h:29
armarx::ManagerPrxMap
std::map< QString, ArmarXManagerInterfacePrx > ManagerPrxMap
Definition: ArmarXManagerModel.h:46
armarx::SystemStateMonitorFilterModel::hideResolvedComponents
bool hideResolvedComponents
Definition: SystemStateMonitorWidget.h:257
armarx::ArmarXManagerItem::ManagerData
Definition: ArmarXManagerItem.h:46
armarx::InfixFilterModel
This proxy model reimplements the filterAcceptsRow function with a new behavior: All elements that fi...
Definition: InfixFilterModel.h:41
armarx::InfixFilterModel::filterAcceptsRow
bool filterAcceptsRow(int source_row, const QModelIndex &source_parent) const override
Definition: InfixFilterModel.cpp:109
armarx::ArmarXManagerItem
Definition: ArmarXManagerItem.h:41
armarx
This file offers overloads of toIce() and fromIce() functions for STL container types.
Definition: ArmarXTimeserver.cpp:28
ImportExportComponent.h