RobotUnitPluginWidgetController.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::RobotUnitPluginWidgetController
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 <chrono>
26#include <fstream>
27#include <map>
28#include <mutex>
29#include <string>
30
31#include <QGroupBox>
32#include <QPointer>
33#include <QPushButton>
34#include <QToolBar>
35#include <QTreeWidget>
36#include <QTreeWidgetItem>
37#include <QWidget>
38
40
44
45#include <RobotAPI/interface/units/RobotUnit/RobotUnitInterface.h>
48
53
54// C++ includes
55#include <memory>
56
57// ui_RobotUnitPluginWidget.h is included by the .cpp, not here: moc textually inlines every
58// #include it can resolve, and parsing the uic-generated header alongside this one
59// makes moc mis-qualify this class as Ui::armarx::*.
60namespace Ui
61{
62 class RobotUnitPluginWidget;
63}
64
65namespace armarx
66{
67 /**
68 \page RobotAPI-GuiPlugins-RobotUnitPlugin RobotUnitPlugin
69 \brief The RobotUnitPlugin allows visualizing ...
70
71 \image html RobotUnitPlugin.png
72 The user can
73
74 API Documentation \ref RobotUnitPluginWidgetController
75
76 \see RobotUnitPluginGuiPlugin
77 */
78
79 /**
80 * \class RobotUnitPluginWidgetController
81 * \brief RobotUnitPluginWidgetController brief one line description
82 *
83 * Detailed description
84 */
86 public ArmarXComponentWidgetControllerTemplate<RobotUnitPluginWidgetController>,
87 public RobotUnitListener
88 {
89 Q_OBJECT
90 public:
91 /// @brief Controller Constructor
93
94 // Defined in the .cpp, where Ui::RobotUnitPluginWidget is complete.
96
97 /// @see ArmarXWidgetController::loadSettings()
98 void loadSettings(QSettings* settings) override;
99
100 /// @see ArmarXWidgetController::saveSettings()
101 void saveSettings(QSettings* settings) override;
102
103 /// @brief Returns the Widget name displayed in the ArmarXGui to create an instance of this class.
104 static QString
106 {
107 return "RobotControl.RobotUnitGUI";
108 }
109
110 /// @see armarx::Component::onInitComponent()
111 void onInitComponent() override;
112
113 /// @see armarx::Component::onConnectComponent()
114 void onConnectComponent() override;
115
116 void onDisconnectComponent() override;
117 void onExitComponent() override;
118 /**
119 * @param parent The dialog's parent.
120 * @return The plugin's config dialog.
121 */
122 QPointer<QDialog> getConfigDialog(QWidget* parent) override;
123
124 /// @brief Callback called when the config dialog is closed.
125 void configured() override;
126
127 static QIcon
129 {
130 return QIcon(":/robotunitplugin/icons/robot_unit_icon.svg");
131 }
132
133 static QIcon
135 {
136 return QIcon(":/robotunitplugin/icons/robot_unit_icon.svg");
137 }
138
139 QPointer<QWidget> getCustomTitlebarWidget(QWidget* parent) override;
140
141 // RobotUnitListener interface
142 public:
143 void nJointControllerStatusChanged(const NJointControllerStatusSeq& status,
144 const Ice::Current&) override;
145 void controlDeviceStatusChanged(const ControlDeviceStatusSeq& status,
146 const Ice::Current&) override;
147 void sensorDeviceStatusChanged(const SensorDeviceStatusSeq& status,
148 const Ice::Current&) override;
149 void nJointControllerClassAdded(const std::string& name, const Ice::Current&) override;
150 void nJointControllerCreated(const std::string& name, const Ice::Current&) override;
151 void nJointControllerDeleted(const std::string& name, const Ice::Current&) override;
152
153 private slots:
154 void refreshNJointControllersClicked();
155 void refreshNJointControllerClassesClicked();
156 void refreshControlDevicesClicked();
157 void refreshSensorDevicesClicked();
158 void refreshLogging();
159
160 void startOnConnectTimer();
161 void stopOnConnectTimer();
162
163 //logging
164 void on_lineEditLoggingFilter_textChanged(const QString& arg1);
165 void on_pushButtonLoggingStop_clicked();
166 void on_pushButtonLoggingStart_clicked();
167 void on_treeWidgetLoggingNames_itemChanged(QTreeWidgetItem* item, int column);
168 void on_pushButtonLoggingMark1_clicked();
169 void on_pushButtonLoggingMark2_clicked();
170 void on_pushButtonLoggingMark3_clicked();
171
172 private:
173 void timerEvent(QTimerEvent*) override;
174 void updateToolBarActionCheckedState();
175
176 private:
177 /// @brief Widget Form
178 std::unique_ptr<Ui::RobotUnitPluginWidget> widget;
179 /// @brief The plugin's config dialog.
180 QPointer<SimpleConfigDialog> dialog;
181
182 std::string robotUnitProxyName;
183 std::recursive_mutex robotUnitPrxMutex;
184 RobotUnitInterfacePrx robotUnitPrx;
185 std::string listenerTopicName;
186
187 NJointControllerClassesWidget* nJointControllerClasses;
188 NJointControllersWidget* nJointControllers;
189 ControlDevicesWidget* controlDevices;
190 SensorDevicesWidget* sensorDevices;
191
192 QPointer<QToolBar> customToolbar;
193
194 QPointer<QAction> showCDevs;
195 QPointer<QAction> showSDevs;
196 QPointer<QAction> showNJoint;
197 QPointer<QAction> showNJointClasses;
198 QPointer<QAction> showLogging;
199
200 struct LoggingData
201 {
202 QTreeWidgetItem* top;
203 std::vector<QTreeWidgetItem*> allItems;
204 SimpleRemoteReferenceCounterBasePtr handle;
205 RobotUnitDataStreamingReceiverPtr streamingHandler;
206 std::ofstream logStream;
207 static void updateCheckStateUpward(QTreeWidgetItem* item, bool recurseParents);
208 static void updateCheckStateDownward(QTreeWidgetItem* item,
209 Qt::CheckState state,
210 bool recurseChildren);
211 void localLogging();
212 };
213
214 LoggingData loggingData;
215
216 int timerId = 0;
217 std::atomic_bool timerLastIterationRuWasRunning = false;
218 };
219} // namespace armarx
#define ARMARXCOMPONENT_IMPORT_EXPORT
static QString GetWidgetName()
Returns the Widget name displayed in the ArmarXGui to create an instance of this class.
ArmarX Headers.
This file offers overloads of toIce() and fromIce() functions for STL container types.
::IceInternal::ProxyHandle<::IceProxy::armarx::RobotUnitInterface > RobotUnitInterfacePrx
std::shared_ptr< class RobotUnitDataStreamingReceiver > RobotUnitDataStreamingReceiverPtr