ControlDevicesWidget.h
Go to the documentation of this file.
1 /*
2  * This file is part of ArmarX.
3  *
4  * ArmarX is free software; you can redistribute it and/or modify
5  * it under the terms of the GNU General Public License version 2 as
6  * published by the Free Software Foundation.
7  *
8  * ArmarX is distributed in the hope that it will be useful, but
9  * WITHOUT ANY WARRANTY; without even the implied warranty of
10  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11  * GNU General Public License for more details.
12  *
13  * You should have received a copy of the GNU General Public License
14  * along with this program. If not, see <http://www.gnu.org/licenses/>.
15  *
16  * \package RobotAPI::gui-plugins::RobotUnitPlugin
17  * \author Raphael Grimm ( raphael dot grimm at kit dot edu )
18  * \date 2017
19  * \copyright http://www.gnu.org/licenses/gpl-2.0.txt
20  * GNU General Public License
21  */
22 
23 #pragma once
24 
25 #include <mutex>
26 #include <atomic>
27 
28 #include <QWidget>
29 #include <QLabel>
30 #include <QLineEdit>
31 #include <QHBoxLayout>
32 #include <QFormLayout>
33 #include <QPushButton>
34 #include <QTreeWidget>
35 #include <QCheckBox>
36 #include <QComboBox>
37 #include <QTreeWidgetItem>
38 
41 #include <RobotAPI/interface/units/RobotUnit/RobotUnitInterface.h>
42 
43 #include "RobotUnitWidgetBase.h"
44 #include <RobotAPI/gui-plugins/RobotUnitPlugin/ui_ControlDevicesWidget.h>
45 
46 namespace armarx
47 {
48  class ControlDevicesWidgetEntry;
49 
50  class ControlDevicesWidget : public RobotUnitWidgetTemplateBase<Ui::ControlDevicesWidget>
51  {
52  public:
53  explicit ControlDevicesWidget(QWidget* parent = 0);
54  ~ControlDevicesWidget() override;
55  void controlDeviceStatusChanged(const ControlDeviceStatusSeq& allStatus);
56 
57  protected:
58  void clearAll() override;
59  void doContentUpdate() override;
60  void getResetData() override;
61  bool addOneFromResetData() override;
62  private:
63  void add(const ControlDeviceDescription& desc);
64  void update(const ControlDeviceStatus& status);
65 
66  std::map<std::string, ControlDevicesWidgetEntry*> entries;
67  std::map<std::string, ControlDeviceStatus> statusUpdates;
68  ControlDeviceDescriptionSeq resetData;
69 
70  public:
71  static constexpr int idxName = 0;
72  static constexpr int idxTags = 1;
73  static constexpr int idxMode = 2;
74  static constexpr int idxHWMode = 3;
75  static constexpr int idxAct = 4;
76  static constexpr int idxReq = 5;
77  static constexpr int idxType = 6;
78  static constexpr int idxVal = 7;
79  };
80 
81  class ControlDevicesWidgetEntry : QObject
82  {
83 
84  Q_OBJECT
85  public:
87  ControlDevicesWidget& parent,
88  QTreeWidget& treeWidget,
89  const ControlDeviceDescription& desc
90  );
91 
92 
93  void update(const ControlDeviceStatus& status);
94 
95  bool matchName(const QString& name);
96  bool matchTag(const QString& tag);
97  std::set<QTreeWidgetItem*> matchMode(const QString& mode);
98  std::set<QTreeWidgetItem*> isActiveState(const QString& state);
99  std::set<QTreeWidgetItem*> isRequestedState(const QString& state);
100  std::set<QTreeWidgetItem*> matchTargetType(const QString& type);
101 
102  public slots:
103  void setVisible(bool vis);
104  void setChildVis(bool vis, std::set<QTreeWidgetItem*> children);
105 
106  private slots:
107  void hideTagList(bool hide);
108 
109  private:
110  struct ControllerEntry
111  {
112  QTreeWidgetItem* child;
114  };
115  std::map<std::string, ControllerEntry> subEntries;
116  std::string activeMode;
117  std::string requestedMode;
118 
119  QTreeWidgetItem* header;
120 
121  std::vector<QTreeWidgetItem*> tags;
122  };
123 }
armarx::ControlDevicesWidget::idxHWMode
static constexpr int idxHWMode
Definition: ControlDevicesWidget.h:74
armarx::ControlDevicesWidget::idxType
static constexpr int idxType
Definition: ControlDevicesWidget.h:77
armarx::ControlDevicesWidgetEntry::matchName
bool matchName(const QString &name)
Definition: ControlDevicesWidget.cpp:239
RobotUnitWidgetBase.h
VariantWidget.h
armarx::ControlDevicesWidget::idxAct
static constexpr int idxAct
Definition: ControlDevicesWidget.h:75
WidgetDescription.h
armarx::ControlDevicesWidgetEntry::matchTargetType
std::set< QTreeWidgetItem * > matchTargetType(const QString &type)
Definition: ControlDevicesWidget.cpp:295
armarx::ControlDevicesWidget::idxTags
static constexpr int idxTags
Definition: ControlDevicesWidget.h:72
armarx::ControlDevicesWidgetEntry::matchTag
bool matchTag(const QString &tag)
Definition: ControlDevicesWidget.cpp:244
armarx::ControlDevicesWidget
Definition: ControlDevicesWidget.h:50
armarx::ControlDevicesWidgetEntry::ControlDevicesWidgetEntry
ControlDevicesWidgetEntry(ControlDevicesWidget &parent, QTreeWidget &treeWidget, const ControlDeviceDescription &desc)
Definition: ControlDevicesWidget.cpp:149
armarx::ControlDevicesWidget::idxVal
static constexpr int idxVal
Definition: ControlDevicesWidget.h:78
armarx::ControlDevicesWidget::controlDeviceStatusChanged
void controlDeviceStatusChanged(const ControlDeviceStatusSeq &allStatus)
Definition: ControlDevicesWidget.cpp:69
armarx::ControlDevicesWidgetEntry::matchMode
std::set< QTreeWidgetItem * > matchMode(const QString &mode)
Definition: ControlDevicesWidget.cpp:256
armarx::status
status
Definition: FiniteStateMachine.h:259
armarx::ControlDevicesWidgetEntry::isActiveState
std::set< QTreeWidgetItem * > isActiveState(const QString &state)
Definition: ControlDevicesWidget.cpp:269
cxxopts::value
std::shared_ptr< Value > value()
Definition: cxxopts.hpp:926
armarx::ControlDevicesWidgetEntry::setVisible
void setVisible(bool vis)
Definition: ControlDevicesWidget.cpp:308
armarx::ControlDevicesWidgetEntry::update
void update(const ControlDeviceStatus &status)
Definition: ControlDevicesWidget.cpp:184
armarx::ControlDevicesWidget::ControlDevicesWidget
ControlDevicesWidget(QWidget *parent=0)
Definition: ControlDevicesWidget.cpp:30
armarx::ControlDevicesWidget::idxMode
static constexpr int idxMode
Definition: ControlDevicesWidget.h:73
armarx::RobotUnitWidgetTemplateBase
Definition: RobotUnitWidgetBase.h:93
armarx::ControlDevicesWidgetEntry
Definition: ControlDevicesWidget.h:81
armarx::ControlDevicesWidget::doContentUpdate
void doContentUpdate() override
Definition: ControlDevicesWidget.cpp:96
armarx::ControlDevicesWidget::idxName
static constexpr int idxName
Definition: ControlDevicesWidget.h:71
armarx::ControlDevicesWidget::clearAll
void clearAll() override
Definition: ControlDevicesWidget.cpp:89
armarx::ControlDevicesWidget::~ControlDevicesWidget
~ControlDevicesWidget() override
Definition: ControlDevicesWidget.cpp:64
armarx::ControlDevicesWidget::addOneFromResetData
bool addOneFromResetData() override
Definition: ControlDevicesWidget.cpp:114
armarx::ControlDevicesWidgetEntry::isRequestedState
std::set< QTreeWidgetItem * > isRequestedState(const QString &state)
Definition: ControlDevicesWidget.cpp:282
armarx::ControlDevicesWidgetEntry::setChildVis
void setChildVis(bool vis, std::set< QTreeWidgetItem * > children)
Definition: ControlDevicesWidget.cpp:317
armarx::ControlDevicesWidget::getResetData
void getResetData() override
Definition: ControlDevicesWidget.cpp:105
armarx::ControlDevicesWidget::idxReq
static constexpr int idxReq
Definition: ControlDevicesWidget.h:76
armarx
This file offers overloads of toIce() and fromIce() functions for STL container types.
Definition: ArmarXTimeserver.cpp:28
armarx::VariantWidget
Definition: VariantWidget.h:38