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 
45 namespace Ui
46 {
47  class SystemStateMonitorWidget;
48 }
49 
50 namespace armarx
51 {
52 
53  class SystemStateMonitorFilterModel;
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();
80  ~SystemStateMonitorWidget() override;
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 
126  void retrieveManagerObjectsState(ArmarXManagerItem* item);
127 
128  bool retrieveManagerObjectsState(ArmarXManagerInterfacePrx prx,
129  ArmarXManagerItem::ObjectMap& objectStates);
130  bool retrieveManagerData(ArmarXManagerInterfacePrx prx,
131  ArmarXManagerItem::ManagerData& managerData);
132 
133  signals:
134 
135  void updateManagerStatesSignal(const ArmarXManagerItem::ManagerDataMap&);
136  public slots:
137  void updateManagerObjectsState();
138  /**
139  * Updates the states of the managers stated in the monitored list
140  */
141  void updateManagerStates(const ArmarXManagerItem::ManagerDataMap& managerData);
142 
143  /**
144  * Accept config changes
145  */
146  void acceptConfig();
147 
148  /**
149  * Retrieves the online managers
150  */
151  void retrieveOnlineManagers();
152 
153  /**
154  * Opens the config dialog
155  */
156  void openManagerRepositoryDialog();
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
ARMARX_VERBOSE
#define ARMARX_VERBOSE
Definition: Logging.h:187
armarx::SystemStateMonitorFilterModel::filterAcceptsRow
bool filterAcceptsRow(int source_row, const QModelIndex &source_parent) const override
Definition: SystemStateMonitorWidget.h:230
armarx::SystemStateMonitorWidget::GetWidgetIcon
static QIcon GetWidgetIcon()
Definition: SystemStateMonitorWidget.h:211
ArmarXManagerRepositoryDialog.h
ArmarXManagerModel.h
armarx::ArmarXManagerModel
Definition: ArmarXManagerModel.h:48
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:73
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:623
cxxopts::value
std::shared_ptr< Value > value()
Definition: cxxopts.hpp:855
ArmarXComponentWidgetController.h
ARMARXCOMPONENT_IMPORT_EXPORT
#define ARMARXCOMPONENT_IMPORT_EXPORT
Definition: ImportExportComponent.h:38
Ui
ArmarX Headers.
Definition: ArmarXMainWindow.h:54
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:57
Component.h
armarx::SystemStateMonitorFilterModel::getHideResolvedComponents
bool getHideResolvedComponents() const
Definition: SystemStateMonitorWidget.cpp:617
armarx::ArmarXManagerItem::ObjectMap
QMap< QString, ManagedIceObjectItem > ObjectMap
Definition: ArmarXManagerItem.h:44
armarx::SystemStateMonitorFilterModel
Definition: SystemStateMonitorWidget.h:217
IceUtil::Handle
Definition: forward_declarations.h:30
armarx::ManagerPrxMap
std::map< QString, ArmarXManagerInterfacePrx > ManagerPrxMap
Definition: ArmarXManagerModel.h:46
armarx::SystemStateMonitorFilterModel::hideResolvedComponents
bool hideResolvedComponents
Definition: SystemStateMonitorWidget.h:260
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:42
armarx::InfixFilterModel::filterAcceptsRow
bool filterAcceptsRow(int source_row, const QModelIndex &source_parent) const override
Definition: InfixFilterModel.cpp:117
armarx::ArmarXManagerItem
Definition: ArmarXManagerItem.h:41
armarx
This file offers overloads of toIce() and fromIce() functions for STL container types.
Definition: ArmarXTimeserver.cpp:27
ImportExportComponent.h