DebugRobotUnitDataStreamingWidgetController.cpp
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::DebugRobotUnitDataStreamingWidgetController
17  * \author Raphael Grimm ( raphael dot grimm at kit dot edu )
18  * \date 2021
19  * \copyright http://www.gnu.org/licenses/gpl-2.0.txt
20  * GNU General Public License
21  */
22 
24 
25 #include <string>
26 
27 namespace armarx
28 {
29 
30  void
32  {
34  settings->value("ru", "Armar6Unit").toString().toStdString());
35  }
36 
37  void
39  {
40  settings->setValue(
41  "ru", QString::fromStdString(getRobotUnitComponentPlugin().getRobotUnitName()));
42  }
43 
44  QPointer<QDialog>
46  {
47  if (!dialog)
48  {
49  dialog = new SimpleConfigDialog(parent);
50  dialog->addProxyFinder<RobotUnitInterfacePrx>("ru", "Robot Unit", "*Unit");
51  }
52  return qobject_cast<SimpleConfigDialog*>(dialog);
53  }
54 
55  void
57  {
58  getRobotUnitComponentPlugin().setRobotUnitName(dialog->get("ru"));
59  }
60 
62  {
63  widget.setupUi(getWidget());
64  startTimer(10);
65  }
66 
67  void
69  {
70  std::lock_guard f{mutex};
71  rec.clear();
72  }
73 
74  void
76  {
77  const std::size_t n = widget.spinBoxNumberOfStreams->value();
78  if (!getRobotUnit())
79  {
80  return;
81  }
82  if (rec.size() > n)
83  {
84  rec.resize(n);
85  }
86  std::lock_guard f{mutex};
87  RobotUnitDataStreaming::Config cfg;
88  if (widget.checkBoxStreamSens->isChecked())
89  {
90  cfg.loggingNames.emplace_back("sens");
91  }
92  if (widget.checkBoxStreamCtrl->isChecked())
93  {
94  cfg.loggingNames.emplace_back("ctrl");
95  }
96  while (rec.size() < n)
97  {
98  rec.emplace_back(getRobotUnitComponentPlugin().startDataStreaming(cfg));
99  ARMARX_INFO << rec.back()->getDataDescriptionString();
100  }
101  for (auto& r : rec)
102  {
103  r->getDataBuffer().clear();
104  }
105  }
106 } // namespace armarx
armarx::DebugRobotUnitDataStreamingWidgetController::loadSettings
void loadSettings(QSettings *settings) override
Implement to load the settings that are part of the GUI configuration.
Definition: DebugRobotUnitDataStreamingWidgetController.cpp:31
armarx::DebugRobotUnitDataStreamingWidgetController::DebugRobotUnitDataStreamingWidgetController
DebugRobotUnitDataStreamingWidgetController()
Definition: DebugRobotUnitDataStreamingWidgetController.cpp:61
armarx::plugins::RobotUnitComponentPlugin::setRobotUnitName
void setRobotUnitName(const std::string &name)
Definition: RobotUnitComponentPlugin.cpp:118
armarx::DebugRobotUnitDataStreamingWidgetController::saveSettings
void saveSettings(QSettings *settings) override
Implement to save the settings as part of the GUI configuration.
Definition: DebugRobotUnitDataStreamingWidgetController.cpp:38
armarx::DebugRobotUnitDataStreamingWidgetController::onDisconnectComponent
void onDisconnectComponent() override
Hook for subclass.
Definition: DebugRobotUnitDataStreamingWidgetController.cpp:68
armarx::DebugRobotUnitDataStreamingWidgetController::getConfigDialog
QPointer< QDialog > getConfigDialog(QWidget *parent) override
getConfigDialog returns a pointer to the a configuration widget of this controller.
Definition: DebugRobotUnitDataStreamingWidgetController.cpp:45
DebugRobotUnitDataStreamingWidgetController.h
armarx::DebugRobotUnitDataStreamingWidgetController::configured
void configured() override
This function must be implemented by the user, if he supplies a config dialog.
Definition: DebugRobotUnitDataStreamingWidgetController.cpp:56
armarx::DebugRobotUnitDataStreamingWidgetController::timerEvent
void timerEvent(QTimerEvent *event) override
Definition: DebugRobotUnitDataStreamingWidgetController.cpp:75
ARMARX_INFO
#define ARMARX_INFO
Definition: Logging.h:181
IceInternal::ProxyHandle<::IceProxy::armarx::RobotUnitInterface >
armarx::RobotUnitComponentPluginUser::getRobotUnitComponentPlugin
plugins::RobotUnitComponentPlugin & getRobotUnitComponentPlugin()
Definition: RobotUnitComponentPlugin.cpp:191
armarx::ArmarXWidgetController::getWidget
virtual QPointer< QWidget > getWidget()
getWidget returns a pointer to the a widget of this controller.
Definition: ArmarXWidgetController.cpp:54
armarx::RobotUnitComponentPluginUser::getRobotUnit
RobotUnitInterfacePrx getRobotUnit() const
Definition: RobotUnitComponentPlugin.cpp:185
armarx
This file offers overloads of toIce() and fromIce() functions for STL container types.
Definition: ArmarXTimeserver.cpp:27
armarx::SimpleConfigDialog
A config-dialog containing one (or multiple) proxy finders.
Definition: SimpleConfigDialog.h:84