NJointControllersWidget.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 <QTreeWidgetItem>
36 #include <QCheckBox>
37 
41 #include <RobotAPI/interface/units/RobotUnit/RobotUnitInterface.h>
42 #include <RobotAPI/interface/units/RobotUnit/NJointController.h>
43 
44 #include "RobotUnitWidgetBase.h"
45 #include <RobotAPI/gui-plugins/RobotUnitPlugin/ui_NJointControllersWidget.h>
46 
47 namespace armarx
48 {
49  class NJointControllersWidget;
50  class NJointControllersWidgetEntry;
51  class NJointControllersWidgetRemoteFunction;
52 
53  class NJointControllersWidget : public RobotUnitWidgetTemplateBase<Ui::NJointControllersWidget>
54  {
55  Q_OBJECT
56  public:
57  explicit NJointControllersWidget(QWidget* parent = 0);
58  ~NJointControllersWidget() override;
59  void nJointControllerStatusChanged(const NJointControllerStatusSeq& allStatus);
60 
61  virtual void nJointControllerCreated(std::string name);
62  virtual void nJointControllerDeleted(std::string name);
63 
64  void loadSettings(QSettings* settings) override;
65  void saveSettings(QSettings* settings) override;
66 
67  protected:
68  void clearAll() override;
69  void doContentUpdate() override;
70  void getResetData() override;
71  bool addOneFromResetData() override;
72 
73  private:
74  void add(const NJointControllerDescriptionWithStatus& ds);
75 
76  std::map<std::string, NJointControllersWidgetEntry*> entries;
77  std::map<std::string, NJointControllerStatus> statusUpdates;
78  std::map<std::string, NJointControllerDescriptionWithStatus> controllersCreated;
79  std::set<std::string> controllersDeleted;
80  private slots:
81  void onPushButtonStopAll_clicked();
82  void onPushButtonRemoveAll_clicked();
83 
84  public:
85  static constexpr int idxName = 0;
86  static constexpr int idxClass = 1;
87  static constexpr int idxActive = 2;
88  static constexpr int idxRequested = 3;
89  static constexpr int idxError = 4;
90  static constexpr int idxInternal = 5;
91  static constexpr int idxCtrlDev = 6;
92  static constexpr int idxCtrlMode = 7;
93  static constexpr int idxActivate = 8;
94  static constexpr int idxDeactivate = 9;
95  static constexpr int idxDelete = 10;
96  };
97 
98  class NJointControllersWidgetEntry : public QObject
99  {
100  Q_OBJECT
101  public:
103 
105  NJointControllersWidget& parent,
106  QTreeWidget& treeWidget,
107  const NJointControllerDescription& desc
108  );
109 
110  void update(const NJointControllerStatus& status);
111 
112  bool matchName(const QString& name);
113  bool matchClass(const QString& name);
114  bool isActiveState(const QString& state);
115  bool isRequestedState(const QString& state);
116  bool isErrorState(const QString& state);
117  bool matchDevice(const QString& dev);
118  bool matchMode(const QString& mode);
119  void deleteContent();
120 
121  public slots:
122  void setVisible(bool vis);
123  private slots:
124  void activateController();
125  void deactivateController();
126  void deleteController();
127 
128  void hideDeviceList();
129 
130  void setDeviceListVisible(bool vis);
131  private:
132  const bool deletable;
133  QCheckBox* boxDev;
134  QCheckBox* boxMod;
135  QTreeWidgetItem* header;
136  NJointControllerInterfacePrx controller;
137  std::vector<QTreeWidgetItem*> devsToModes;
138 
139  };
140 
142  {
143  Q_OBJECT
144  public:
146  QTreeWidget& treeWidget,
147  QTreeWidgetItem& header,
148  const std::string& functionName,
149  const NJointControllerInterfacePrx& ctrl,
151  private slots:
152  void execFunction();
153  private:
154  QTreeWidgetItem* functionHeader;
155 
156  std::string functionName;
157  NJointControllerInterfacePrx ctrl;
158 
159  QCheckBox* execOnParamChange;
161 
162  std::map<std::string, VariantBasePtr> paramValues;
163 
164  public slots:
165  void valueChangedSlot(std::string name, VariantBasePtr value) override;
166  };
167 }
armarx::NJointControllersWidgetRemoteFunction::valueChangedSlot
void valueChangedSlot(std::string name, VariantBasePtr value) override
Definition: NJointControllersWidget.cpp:575
RobotUnitWidgetBase.h
algorithm.h
armarx::NJointControllersWidget::idxRequested
static constexpr int idxRequested
Definition: NJointControllersWidget.h:88
armarx::NJointControllersWidgetEntry::matchMode
bool matchMode(const QString &mode)
Definition: NJointControllersWidget.cpp:401
armarx::NJointControllersWidgetRemoteFunction
Definition: NJointControllersWidget.h:141
armarx::NJointControllersWidgetEntry::isRequestedState
bool isRequestedState(const QString &state)
Definition: NJointControllersWidget.cpp:379
armarx::NJointControllersWidgetRemoteFunction::NJointControllersWidgetRemoteFunction
NJointControllersWidgetRemoteFunction(QTreeWidget &treeWidget, QTreeWidgetItem &header, const std::string &functionName, const NJointControllerInterfacePrx &ctrl, const WidgetDescription::WidgetPtr &w)
Definition: NJointControllersWidget.cpp:474
armarx::NJointControllersWidgetEntry::matchName
bool matchName(const QString &name)
Definition: NJointControllersWidget.cpp:364
armarx::NJointControllersWidgetEntry::setVisible
void setVisible(bool vis)
Definition: NJointControllersWidget.cpp:422
armarx::NJointControllersWidget::idxName
static constexpr int idxName
Definition: NJointControllersWidget.h:85
armarx::NJointControllersWidget::~NJointControllersWidget
~NJointControllersWidget() override
Definition: NJointControllersWidget.cpp:85
VariantWidget.h
armarx::NJointControllersWidget::idxClass
static constexpr int idxClass
Definition: NJointControllersWidget.h:86
WidgetDescription.h
armarx::NJointControllersWidget::clearAll
void clearAll() override
Definition: NJointControllersWidget.cpp:191
armarx::NJointControllersWidget
Definition: NJointControllersWidget.h:53
armarx::WidgetDescription::ValueChangedListenerInterface
Definition: WidgetDescription.h:36
armarx::NJointControllersWidget::idxError
static constexpr int idxError
Definition: NJointControllersWidget.h:89
armarx::NJointControllersWidget::idxActive
static constexpr int idxActive
Definition: NJointControllersWidget.h:87
IceInternal::Handle
Definition: forward_declarations.h:8
armarx::NJointControllersWidget::NJointControllersWidget
NJointControllersWidget(QWidget *parent=0)
Definition: NJointControllersWidget.cpp:29
armarx::NJointControllersWidget::loadSettings
void loadSettings(QSettings *settings) override
Definition: NJointControllersWidget.cpp:175
armarx::NJointControllersWidget::idxCtrlMode
static constexpr int idxCtrlMode
Definition: NJointControllersWidget.h:92
armarx::status
status
Definition: FiniteStateMachine.h:259
armarx::NJointControllersWidgetEntry::isActiveState
bool isActiveState(const QString &state)
Definition: NJointControllersWidget.cpp:374
cxxopts::value
std::shared_ptr< Value > value()
Definition: cxxopts.hpp:926
armarx::NJointControllersWidgetEntry::matchDevice
bool matchDevice(const QString &dev)
Definition: NJointControllersWidget.cpp:389
controller
Definition: AddOperation.h:39
armarx::NJointControllersWidget::nJointControllerDeleted
virtual void nJointControllerDeleted(std::string name)
Definition: NJointControllersWidget.cpp:165
armarx::NJointControllersWidget::addOneFromResetData
bool addOneFromResetData() override
Definition: NJointControllersWidget.cpp:253
armarx::WidgetDescription::DescribedWidgetBase
Definition: WidgetDescription.h:45
armarx::NJointControllersWidget::idxCtrlDev
static constexpr int idxCtrlDev
Definition: NJointControllersWidget.h:91
armarx::NJointControllersWidget::idxDelete
static constexpr int idxDelete
Definition: NJointControllersWidget.h:95
armarx::RobotUnitWidgetTemplateBase
Definition: RobotUnitWidgetBase.h:93
armarx::NJointControllersWidget::saveSettings
void saveSettings(QSettings *settings) override
Definition: NJointControllersWidget.cpp:183
armarx::NJointControllersWidgetEntry::matchClass
bool matchClass(const QString &name)
Definition: NJointControllersWidget.cpp:369
armarx::NJointControllersWidgetEntry::NJointControllersWidgetEntry
NJointControllersWidgetEntry(NJointControllersWidget &parent, QTreeWidget &treeWidget, const NJointControllerDescription &desc)
Definition: NJointControllersWidget.cpp:264
armarx::NJointControllersWidgetEntry::isErrorState
bool isErrorState(const QString &state)
Definition: NJointControllersWidget.cpp:384
armarx::NJointControllersWidget::nJointControllerStatusChanged
void nJointControllerStatusChanged(const NJointControllerStatusSeq &allStatus)
Definition: NJointControllersWidget.cpp:90
armarx::NJointControllersWidgetEntry::update
void update(const NJointControllerStatus &status)
Definition: NJointControllersWidget.cpp:351
armarx::NJointControllersWidget::getResetData
void getResetData() override
Definition: NJointControllersWidget.cpp:241
armarx::NJointControllersWidget::doContentUpdate
void doContentUpdate() override
Definition: NJointControllersWidget.cpp:199
armarx::NJointControllersWidgetEntry
Definition: NJointControllersWidget.h:98
armarx::NJointControllersWidget::nJointControllerCreated
virtual void nJointControllerCreated(std::string name)
Definition: NJointControllersWidget.cpp:143
armarx::NJointControllersWidget::idxActivate
static constexpr int idxActivate
Definition: NJointControllersWidget.h:93
armarx
This file offers overloads of toIce() and fromIce() functions for STL container types.
Definition: ArmarXTimeserver.cpp:28
armarx::NJointControllersWidget::idxInternal
static constexpr int idxInternal
Definition: NJointControllersWidget.h:90
armarx::NJointControllersWidget::idxDeactivate
static constexpr int idxDeactivate
Definition: NJointControllersWidget.h:94
armarx::NJointControllersWidgetEntry::deleteContent
void deleteContent()
Definition: NJointControllersWidget.cpp:413