SkillDashboardWidgetController.cpp
Go to the documentation of this file.
2
3#include <cmath>
4#include <fstream>
5#include <iostream>
6#include <string>
7
8#include <IceUtil/Optional.h>
9
10#include <nlohmann/json.hpp>
11
12#include <QDateTime>
13#include <QDebug>
14#include <QHBoxLayout>
15#include <QLabel>
16#include <QLineEdit>
17#include <QMessageBox>
18#include <QPalette>
19#include <QPushButton>
20#include <QString>
21#include <QStringList>
22#include <QTimer>
23#include <QToolButton>
24#include <Qt>
25#include <QtConcurrent/QtConcurrent>
26#include <QtGlobal>
27#include <QtWidgets/QSlider>
28#include <QtWidgets/QTableWidgetItem>
29
38
42#include <RobotAPI/interface/components/SkillDashboardInterface.h>
43#include <RobotAPI/interface/skills/SkillManagerInterface.h>
44
45#include "EllipsisPushButton.h"
46
47namespace armarx
48{
53
55 DEFAULT_SETTINGS_PLUGIN_NAME("SkillDashboardGuiPlugin"),
56 DEFAULT_SETTINGS_CUSTOM_TEXT("custom text")
57 {
58 // init gui
59 ARMARX_INFO << "Setup UI";
60 ui.setupUi(getWidget());
61 this->shortcutLayout = new QVBoxLayout();
62 this->dialog = new SkillDashboardConfigWindow();
63 this->editModeAction = new QAction("Edit Mode", this);
64 this->editModeAction->setCheckable(true);
65 this->editModeAction->setToolTip("If toggled the shortcut config buttons and the reload, "
66 "add and export button will be shown.");
67
68 this->recoverButtons = new QToolButton();
69 QIcon iconRecover = getWidget()->style()->standardIcon(QStyle::SP_BrowserReload);
70 this->recoverButtons->setIcon(iconRecover);
71 this->recoverButtons->setToolTip("Recover all buttons");
72
73 this->errorMessageArea = new MessageWidget(true, getWidget());
74 ui.messageArea->layout()->addWidget(this->errorMessageArea);
75
76 ui.shortcutListWidget->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
77 ui.shortcutListWidget->setDragDropMode(QAbstractItemView::InternalMove);
78 ui.shortcutListWidget->setDefaultDropAction(Qt::MoveAction);
79 ui.shortcutListWidget->setSelectionMode(QAbstractItemView::SingleSelection);
80 ui.shortcutListWidget->setSizeAdjustPolicy(QAbstractScrollArea::AdjustToContents);
81 ui.shortcutListWidget->setStyleSheet(R"(
82 QListWidget {
83 background: transparent;
84 border: none;
85 }
86 QListWidget::item {
87 margin: 0px;
88 padding: 0px;
89 }
90)");
91
92 qRegisterMetaType<skills::core::dto::Execution::Status>(
93 "skills::core::dto::Execution::Status");
94
95 connect(this->editModeAction, SIGNAL(toggled(bool)), this, SLOT(editMode(bool)));
96 connect(this->recoverButtons,
97 &QToolButton::clicked,
98 this,
99 &SkillDashboardWidget::enableBlockedButtons);
100 connect(ui.addFromClipboardButton,
101 &QPushButton::clicked,
102 this,
103 &SkillDashboardWidget::addFromClipboard);
104 connect(ui.addButton,
105 &QPushButton::clicked,
106 this,
107 [this]() { openConfigWindow("", "", "", "", ""); });
108 connect(ui.reloadButton, &QPushButton::clicked, this, &SkillDashboardWidget::loadButtons);
109 connect(
110 this, &SkillDashboardWidget::loadButtonInit, this, &SkillDashboardWidget::loadButtons);
111 connect(ui.exportButton, &QPushButton::clicked, this, &SkillDashboardWidget::exportButtons);
112 connect(ui.importButton, &QPushButton::clicked, this, &SkillDashboardWidget::importButtons);
113
114 connect(this,
116 this,
117 &SkillDashboardWidget::activateButton);
118
119
120 connect(this->dialog,
122 this,
123 &SkillDashboardWidget::onShortcutNameChanged);
124 connect(ui.stopAllButton, &QPushButton::clicked, this, &SkillDashboardWidget::stopAll);
125 connect(this, &SkillDashboardWidget::loadPathInfo, this, &SkillDashboardWidget::loadPath);
126
127 this->editModeAction->toggle();
128
129 ARMARX_INFO << "Done: Setup UI";
130 }
131
132 void
134 {
136
137 usingProxy(skillDashboardProxyName);
138
139 if (not this->skillManagerOberserverName.empty())
140 {
141 usingProxy(this->skillManagerOberserverName);
142 }
143 else
144 {
145 ARMARX_IMPORTANT << "empty";
146 }
147 }
148
149 void
151 {
153 this->connected.store(true);
154 getProxy(this->dashboardPrx, skillDashboardProxyName);
155 getProxy(this->managerPrx, this->skillManagerOberserverName);
156 ARMARX_INFO << "Starting thread that queries the SkillsMemory if skills are running in the "
157 "dashboard.";
158 this->exampleTask = std::thread([&] { exampleThreadMethod(); });
159 emit loadButtonInit();
160 emit loadPathInfo();
161 }
162
163 void
164 SkillDashboardWidget::updateShortcutListHeight()
165 {
166 int rows = ui.shortcutListWidget->count();
167 if (rows == 0)
168 {
169 ui.shortcutListWidget->setMinimumHeight(0);
170 return;
171 }
172
173 int rowHeight = ui.shortcutListWidget->sizeHintForRow(0);
174 int frame = ui.shortcutListWidget->frameWidth() * 2;
175 ui.shortcutListWidget->setMinimumHeight(rows * rowHeight + frame);
176 }
177
178 std::string
179 errorStatustoString(skills::core::dto::Execution::Status s)
180 {
181 switch (s)
182 {
183 case skills::core::dto::Execution::Status::Failed:
184 return "Failed";
185 case skills::core::dto::Execution::Status::Succeeded:
186 return "Succeeded";
187 case skills::core::dto::Execution::Status::Aborted:
188 return "Aborted";
189 default:
190 return "Other";
191 }
192 return "Unknown";
193 }
194
195 void
196 SkillDashboardWidget::saveShortcutOrder()
197 {
198 std::vector<std::string> order;
199
200 for (int i = 0; i < ui.shortcutListWidget->count(); ++i)
201 {
202 QListWidgetItem* item = ui.shortcutListWidget->item(i);
203 QString name = item->data(Qt::UserRole).toString();
204 order.push_back(name.toStdString());
205 }
206
207 try
208 {
209 dashboardPrx->saveShortcutOrder(order);
210 }
211 catch (Ice::Exception const&)
212 {
213 ARMARX_WARNING << "Could not save shortcut order";
214 }
215 }
216
217 void
218 SkillDashboardWidget::loadPath()
219 {
220 std::vector<std::string> pathSegments;
221 try
222 {
223 pathSegments = dashboardPrx->getPathStructure();
224 }
225 catch (Ice::Exception const&)
226 {
227 ARMARX_WARNING << "Could not request path";
228 }
229 if (pathSegments.size() == 3)
230 {
231 ui.packageEdit->setText(QString::fromStdString(pathSegments[0]));
232 ui.folderEdit->setText(QString::fromStdString(pathSegments[1]));
233 ui.fileNameEdit->setText(QString::fromStdString(pathSegments[2]));
234 }
235 }
236
237 void
238 SkillDashboardWidget::activateButton(const std::string& name,
239 skills::core::dto::Execution::Status status)
240 {
241 auto* btn = this->shortcutButtons.at(name);
242 btn->setDisabled(false);
243 if (status != skills::core::dto::Execution::Status::Succeeded)
244 {
245 btn->finishProgress(true);
246 std::string text = "Shortcut '" + name + "' terminated with status '" +
248 QString timestamp = QDateTime::currentDateTime().toString("HH:mm:ss");
249 QString messageWithTimestamp =
250 QString("[%1] %2").arg(timestamp, QString::fromStdString(text));
251 this->errorMessageArea->newErrorMessage(messageWithTimestamp);
252 }
253 btn->finishProgress(false);
254 }
255
256 void
257 SkillDashboardWidget::addFromClipboard()
258 {
259 QClipboard* clipboard = QApplication::clipboard();
260 auto clipboardText = clipboard->text().toStdString();
261 nlohmann::json j;
262 try
263 {
264 j = nlohmann::json::parse(clipboardText);
265 }
266 catch (const nlohmann::json::parse_error& e)
267 {
268 ARMARX_ERROR << "JSON Parse Error: " << e.what() << "\n";
269 }
270
271 auto shortcutImport = j["shortcuts"][0];
272 auto skillArgs = shortcutImport["skill_args"].dump(2);
273 auto skillId = shortcutImport["skill_id"];
274 this->openConfigWindow("", skillId, skillArgs, "", "");
275 }
276
277 void
278 SkillDashboardWidget::stopAll()
279 {
280 QtConcurrent::run(
281 [this]
282 {
283 try
284 {
285 auto results = managerPrx->abortAllSkills();
286 for (auto& r : results)
287 ARMARX_IMPORTANT << r.success;
288 }
289 catch (Ice::Exception const&)
290 {
291 ARMARX_WARNING << "Could not send stop all request.";
292 }
293 });
294 this->enableBlockedButtons();
295 }
296
297 void
298 SkillDashboardWidget::exampleThreadMethod()
299 {
300 while (this->connected.load())
301 {
302 if (not this->runningSkills.empty())
303 {
304 for (auto it = this->runningSkills.cbegin(); it != this->runningSkills.cend();)
305 {
306 skills::core::dto::Execution::Status status =
307 skills::core::dto::Execution::Status::Succeeded;
308
309 try
310 {
311 IceUtil::Optional<skills::manager::dto::SkillStatusUpdate> update =
312 this->managerPrx->getSkillExecutionStatus(it->second);
313 if (update)
314 {
315 status = update->status;
316 }
317 }
318 catch (Ice::Exception const&)
319 {
320 ARMARX_WARNING << "Could not get skill status." << deactivateSpam(10);
321 }
322
323 if (status == skills::core::dto::Execution::Status::Succeeded ||
324 status == skills::core::dto::Execution::Status::Failed ||
325 status == skills::core::dto::Execution::Status::Aborted)
326 {
327 ARMARX_INFO << "Finished skill " << it->first;
328 emit skillFinished(it->first, status);
329 it = this->runningSkills.erase(it);
330 }
331 else
332 {
333 ++it;
334 }
335 }
336 ARMARX_INFO << deactivateSpam(10) << "Waiting for skills to finish..";
337 }
339 }
340 }
341
342 void
343 SkillDashboardWidget::onShortcutNameChanged()
344 {
345
346 if ((this->shortcutButtons.find(this->dialog->getShortcutName().toStdString()) !=
347 this->shortcutButtons.end()) and
348 (this->dialog->getShortcutName().toStdString() != this->currentShortcutName))
349 {
350 this->dialog->setInfoText(
351 "A shortcut with this name already exists! The old one will be overwritten.");
353 << "A shortcut with this name already exists! The old one will be overwritten!";
354 }
355 else
356 {
357 this->dialog->setInfoText("");
358 }
359 }
360
361 void
362 SkillDashboardWidget::openConfigWindow(const std::string& name,
363 const std::string& id,
364 const std::string& args,
365 const std::string& iconName,
366 const std::string& shortcutId)
367 {
368
369 this->dialog->setShortcutName(name);
370 this->dialog->setSkillId(id);
371 this->dialog->setIconName(iconName);
372 this->dialog->setSkillConfig(args);
373
374
375 if (this->dialog->exec() == QDialog::Accepted)
376 {
377 try
378 {
379 SkillShortcut newShortcut;
380 newShortcut.shortcutName = this->dialog->getShortcutName().toStdString();
381 newShortcut.skillId = this->dialog->getSkillId().toStdString();
382 newShortcut.skillArgs = this->dialog->getSkillConfig().toStdString();
383 newShortcut.iconName = this->dialog->getIconName().toStdString();
384 newShortcut.id = shortcutId;
385 this->dashboardPrx->addNewShortcut(newShortcut);
386 }
387 catch (Ice::Exception const&)
388 {
389 ARMARX_WARNING << "Could not send new Shortcut." << deactivateSpam(10);
390 }
391 loadButtons();
392 }
393 }
394
395 void
396 SkillDashboardWidget::exportButtons()
397 {
398 saveShortcutOrder();
399 std::string packageName = ui.packageEdit->text().toStdString();
400 std::string folderName = ui.folderEdit->text().toStdString();
401 if (ui.fileNameEdit->text().count(' ') == ui.fileNameEdit->text().length())
402 {
403 ARMARX_ERROR << "please enter a file name!";
404 return;
405 }
406 std::string fileName = ui.fileNameEdit->text().toStdString();
407 try
408 {
409 this->dashboardPrx->exportShortcuts(packageName, folderName, fileName);
410 }
411 catch (Ice::Exception const&)
412 {
413 ARMARX_WARNING << "Could not send export task." << deactivateSpam(10);
414 }
415
416 std::string coloredPath = "<span style='color:red;'>" + packageName + "/" + folderName +
417 "/" + fileName + "</span>";
418 std::string propertyPath = "Insert " + coloredPath +
419 " into the property 'ArmarX.SkillDashboard.ShortcutPath' of the "
420 "SkillDashboard component.";
421
422
423 ui.exportPath->setFullText(QString::fromStdString(propertyPath));
424 ui.exportPath->setTextInteractionFlags(Qt::TextSelectableByMouse);
425 }
426
427 void
428 SkillDashboardWidget::importButtons()
429 {
430 bool success = false;
431 std::string packageName = ui.packageEdit->text().toStdString();
432 std::string folderName = ui.folderEdit->text().toStdString();
433 if (ui.fileNameEdit->text().count(' ') == ui.fileNameEdit->text().length())
434 {
435 ARMARX_ERROR << "please enter a file name!";
436 return;
437 }
438 std::string fileName = ui.fileNameEdit->text().toStdString();
439 try
440 {
441 success = this->dashboardPrx->importShortcuts(packageName, folderName, fileName);
442 }
443 catch (Ice::Exception const&)
444 {
445 ARMARX_WARNING << "Could not send import task." << deactivateSpam(10);
446 }
447 if (success)
448 {
449 this->loadButtons();
450 }
451 }
452
453 void
454 SkillDashboardWidget::loadButtons()
455 {
456
457 this->saveShortcutOrder();
458 this->dashboardPrx->syncOrderedWithDefault();
459 this->shortcutButtons.clear();
460 this->configButtons.clear();
461 this->deleteButtons.clear();
462 ui.shortcutListWidget->clear();
463
464 std::vector<SkillShortcut> shortcuts;
465 try
466 {
467 shortcuts = this->dashboardPrx->getShortcuts();
468 }
469 catch (Ice::Exception const& e)
470 {
471 ARMARX_WARNING << "Could not fetch shortcuts. " << e.what() << deactivateSpam(10);
472 }
473
474
475 for (const auto& shortcut : shortcuts)
476 {
477 auto* mainButton =
478 new EllipsisPushButton(QString::fromStdString(shortcut.shortcutName));
479 mainButton->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Preferred);
480 mainButton->setToolTip(QString("Execute"));
481
482 QToolButton* editButton = new QToolButton();
483 editButton->setIcon(
484 getWidget()->style()->standardIcon(QStyle::SP_FileDialogContentsView));
485 editButton->setToolTip(QString("Edit"));
486
487 QToolButton* deleteButton = new QToolButton();
488 deleteButton->setIcon(getWidget()->style()->standardIcon(QStyle::SP_TrashIcon));
489 deleteButton->setToolTip(QString("Delete"));
490
491 QWidget* rowWidget = new QWidget();
492 QHBoxLayout* layout = new QHBoxLayout(rowWidget);
493 layout->setContentsMargins(0, 0, 0, 0);
494 layout->setSpacing(2);
495 layout->addWidget(mainButton);
496 layout->addWidget(editButton);
497 layout->addWidget(deleteButton);
498
499 QListWidgetItem* item = new QListWidgetItem(ui.shortcutListWidget);
500 item->setSizeHint(rowWidget->sizeHint());
501 item->setData(Qt::UserRole, QString::fromStdString(shortcut.shortcutName));
502 ui.shortcutListWidget->addItem(item);
503 ui.shortcutListWidget->setItemWidget(item, rowWidget);
504
505 this->shortcutButtons[shortcut.shortcutName] = mainButton;
506 this->configButtons[shortcut.shortcutName] = editButton;
507 this->deleteButtons[shortcut.shortcutName] = deleteButton;
508
509 connect(mainButton,
510 &QPushButton::clicked,
511 this,
512 [this, name = shortcut.shortcutName] { executeSkill(name); });
513 connect(editButton,
514 &QToolButton::clicked,
515 this,
516 [this, name = shortcut.shortcutName] { editShortcut(name); });
517 connect(deleteButton,
518 &QToolButton::clicked,
519 this,
520 [this, name = shortcut.shortcutName] { deleteShortcut(name); });
521 }
522 updateShortcutListHeight();
523 }
524
525 void
526 SkillDashboardWidget::executeSkill(const std::string& name)
527 {
528 ARMARX_INFO << "About to execute skill with shortcut name `" << name
529 << "` from skill dashboard.";
530
531 SkillShortcut shortcut;
532 try
533 {
534 shortcut = this->dashboardPrx->getShortcut(name);
535 }
536 catch (Ice::Exception const&)
537 {
538 ARMARX_WARNING << "Could not fetch shortcut." << deactivateSpam(10);
539 std::string text = "Shortcut '" + name + "': Could not fetch shortcut.";
540 QString timestamp = QDateTime::currentDateTime().toString("HH:mm:ss");
541 QString messageWithTimestamp =
542 QString("[%1] %2").arg(timestamp, QString::fromStdString(text));
543 this->errorMessageArea->newErrorMessage(messageWithTimestamp);
544 }
545
546 size_t pos = shortcut.skillId.find('/');
547 std::string provider = "";
548 std::string nameSkill = "";
549 nlohmann::json json = nlohmann::json::parse(shortcut.skillArgs);
552 aron::data::dto::DictPtr paramterDto = data->toAronDictDTO();
553
554 if (pos != std::string::npos)
555 {
556 provider = shortcut.skillId.substr(0, pos);
557 nameSkill = shortcut.skillId.substr(pos + 1);
558 skills::manager::dto::ProviderID providerId{.providerName = provider};
559
560 skills::manager::dto::SkillID skillId{.providerId = providerId, .skillName = nameSkill};
561
562 char hostname[HOST_NAME_MAX];
563 gethostname(hostname, HOST_NAME_MAX);
564
565 skills::manager::dto::SkillExecutionRequest request{
566 .skillId = skillId,
567 .executorName = "Skills.Dashboard GUI (hostname: " + std::string(hostname) + ")",
568 .parameters = paramterDto,
569 };
570
571
572 try
573 {
574 ARMARX_IMPORTANT << "Executing skill with shortcut name `" << shortcut.shortcutName
575 << "` from skill dashboard.";
576 armarx::core::time::Duration skillTimeout =
578
579 IceUtil::Optional<armarx::skills::manager::dto::SkillDescription> optDto =
580 managerPrx->getSkillDescription(skillId);
581
582 if (optDto)
583 {
584 const auto& dto = *optDto;
585 skillTimeout =
586 armarx::core::time::Duration::MicroSeconds(dto.timeout.microSeconds);
587 }
588 else
589 {
590 ARMARX_WARNING << "SkillDescription not found";
591 }
592 skills::manager::dto::SkillExecutionID executionId =
593 this->managerPrx->executeSkillAsync(request);
594 this->runningSkills[shortcut.shortcutName] = executionId;
595 auto* btn = this->shortcutButtons.at(shortcut.shortcutName);
596 btn->setDisabled(true);
597 btn->startTimeout(skillTimeout.toSeconds());
598 }
599 catch (Ice::Exception const&)
600 {
601 ARMARX_WARNING << "Could not send execute request." << deactivateSpam(10);
602 std::string text = "Shortcut '" + name + "': Could not send execute request.";
603 QString timestamp = QDateTime::currentDateTime().toString("HH:mm:ss");
604 QString messageWithTimestamp =
605 QString("[%1] %2").arg(timestamp, QString::fromStdString(text));
606 this->errorMessageArea->newErrorMessage(messageWithTimestamp);
607 }
608 }
609 else
610 {
611 ARMARX_IMPORTANT << "Invalid SkillID";
612 }
613 }
614
615 void
616 SkillDashboardWidget::editShortcut(const std::string& name)
617 {
618 this->currentShortcutName = name;
619
620 SkillShortcut shortcut;
621 try
622 {
623 shortcut = this->dashboardPrx->getShortcut(name);
624 }
625 catch (Ice::Exception const&)
626 {
627 ARMARX_WARNING << "Could not fetch shortcut." << deactivateSpam(10);
628 }
629 openConfigWindow(shortcut.shortcutName,
630 shortcut.skillId,
631 shortcut.skillArgs,
632 shortcut.iconName,
633 shortcut.id);
634 this->currentShortcutName = "not set";
635 }
636
637 void
638 SkillDashboardWidget::deleteShortcut(const std::string& name)
639 {
640 ARMARX_INFO << "delete shortcut: " << name;
641 try
642 {
643 this->dashboardPrx->deleteShortcut(name);
644 //this->shortcutButtons.erase(this->shortcutButtons.find(name));
645 }
646 catch (Ice::Exception const&)
647 {
648 ARMARX_WARNING << "Could not delete shortcut." << deactivateSpam(10);
649 }
650 loadButtons();
651 }
652
653 void
654 SkillDashboardWidget::clearLayout(QLayout* layout)
655 {
656 if (!layout)
657 return;
658
659 while (QLayoutItem* item = layout->takeAt(0))
660 {
661 if (QWidget* widget = item->widget())
662 {
663 widget->deleteLater();
664 }
665 else if (QLayout* subLayout = item->layout())
666 {
667 clearLayout(subLayout);
668 }
669 delete item;
670 }
671 }
672
673 QPointer<QWidget>
675 {
676 if (customToolbar)
677 {
678 if (parent != customToolbar->parent())
679 {
680 customToolbar->setParent(parent);
681 }
682
683 return customToolbar.data();
684 }
685
686 customToolbar = new QToolBar(parent);
687 customToolbar->setIconSize(QSize(16, 16));
688 customToolbar->addAction(editModeAction);
689 customToolbar->addWidget(this->recoverButtons);
690
691 return customToolbar.data();
692 }
693
694 void
695 SkillDashboardWidget::editMode(bool edit)
696 {
697 if (edit)
698 {
699 for (const auto& button : this->deleteButtons)
700 {
701 button.second->setVisible(true);
702 }
703 for (const auto& button : this->configButtons)
704 {
705 button.second->setVisible(true);
706 }
707 ui.addButton->setVisible(true);
708 ui.reloadButton->setVisible(true);
709 ui.exportButton->setVisible(true);
710 ui.importButton->setVisible(true);
711 ui.exportConfiguration->setVisible(true);
712 ui.addFromClipboardButton->setVisible(true);
713 ui.shortcutListWidget->setDragDropMode(QAbstractItemView::InternalMove);
714 }
715 else
716 {
717 for (const auto& button : this->deleteButtons)
718 {
719 button.second->setVisible(false);
720 }
721 for (const auto& button : this->configButtons)
722 {
723 button.second->setVisible(false);
724 }
725 ui.addButton->setVisible(false);
726 ui.reloadButton->setVisible(false);
727 ui.exportButton->setVisible(false);
728 ui.importButton->setVisible(false);
729 ui.exportConfiguration->setVisible(false);
730 ui.addFromClipboardButton->setVisible(false);
731 ui.shortcutListWidget->setDragDropMode(QAbstractItemView::NoDragDrop);
732 }
733 }
734
735 void
736 SkillDashboardWidget::enableBlockedButtons()
737 {
738 for (auto& shortCutB : this->shortcutButtons)
739 {
740 shortCutB.second->setDisabled(false);
741 }
742 }
743
744 void
746 {
747 this->connected.store(false);
748 ARMARX_INFO << "Stopping thread which queries skill memory ...";
749 this->exampleTask.join();
750 ARMARX_INFO << "Stopped!";
751 }
752
753 void
757
758 QPointer<QDialog>
760 {
762
763 if (not m_config_dialog)
764 {
765 m_config_dialog = new armarx::SimpleConfigDialog{parent};
766 m_config_dialog->addProxyFinder<SkillDashboardInterfacePrx>(
767 {"SkillDashboard", "Skill Dashboard", "*SkillDashboard"});
768 m_config_dialog->addProxyFinder<skills::manager::dti::SkillManagerInterfacePrx>(
769 "SkillMemory", "", "*SkillMemory");
770 }
771 return qobject_cast<QDialog*>(m_config_dialog);
772 }
773
774 void
776 {
778 this->skillDashboardProxyName =
779 settings
780 ->value("skillDashboardProxyName", QString::fromStdString(skillDashboardProxyName))
781 .toString()
782 .toStdString();
783 this->skillManagerOberserverName =
784 settings->value("SkillMemory", "SkillMemory").toString().toStdString();
785 }
786
787 void
789 {
791 settings->setValue("skillDashboardProxyName",
792 QString::fromStdString(skillDashboardProxyName));
793 settings->setValue("SkillMemory", QString::fromStdString(this->skillManagerOberserverName));
794 }
795
796 void
798 {
800 if (m_config_dialog)
801 {
802 this->skillDashboardProxyName = m_config_dialog->getProxyName("SkillDashboard");
803 this->skillManagerOberserverName = m_config_dialog->getProxyName("SkillMemory");
804 }
805 }
806
807
808} // namespace armarx
std::string timestamp()
uint8_t data[1]
SpamFilterDataPtr deactivateSpam(SpamFilterDataPtr const &spamFilter, float deactivationDurationSec, const std::string &identifier, bool deactivate)
Definition Logging.cpp:75
std::enable_if<!HasGetWidgetName< ArmarXWidgetType >::value >::type addWidget()
virtual QPointer< QWidget > getWidget()
getWidget returns a pointer to the a widget of this controller.
static Duration SecondsDouble(double seconds)
Constructs a duration in seconds.
Definition Duration.cpp:78
bool usingProxy(const std::string &name, const std::string &endpoints="")
Registers a proxy for retrieval after initialization and adds it to the dependency list.
Ice::ObjectPrx getProxy(long timeoutMs=0, bool waitForScheduler=true) const
Returns the proxy of this object (optionally it waits for the proxy)
A config-dialog containing one (or multiple) proxy finders.
void addProxyFinder(const std::vector< EntryData > &entryData)
void onInitComponent() override
Pure virtual hook for the subclass.
QPointer< QWidget > getCustomTitlebarWidget(QWidget *parent) override
getTitleToolbar returns a pointer to the a toolbar widget of this controller.
void onDisconnectComponent() override
Hook for subclass.
void loadSettings(QSettings *settings) override
Implement to load the settings that are part of the GUI configuration.
void saveSettings(QSettings *settings) override
Implement to save the settings as part of the GUI configuration.
void onConnectComponent() override
Pure virtual hook for the subclass.
void configured() override
This function must be implemented by the user, if he supplies a config dialog.
void skillFinished(const std::string &name, skills::core::dto::Execution::Status status)
void onExitComponent() override
Hook for subclass.
QPointer< QDialog > getConfigDialog(QWidget *parent) override
getConfigDialog returns a pointer to the a configuration widget of this controller.
static data::DictPtr ConvertFromNlohmannJSONObject(const nlohmann::json &, const armarx::aron::Path &p={})
static void WaitFor(const Duration &duration)
Wait for a certain duration on the virtual clock.
Definition Clock.cpp:99
static Duration MicroSeconds(std::int64_t microSeconds)
Constructs a duration in microseconds.
Definition Duration.cpp:24
static Duration Seconds(std::int64_t seconds)
Constructs a duration in seconds.
Definition Duration.cpp:72
std::int64_t toSeconds() const
Returns the amount of seconds.
Definition Duration.cpp:84
#define ARMARX_INFO
The normal logging level.
Definition Logging.h:179
#define ARMARX_IMPORTANT
The logging level for always important information, but expected behaviour (in contrast to ARMARX_WAR...
Definition Logging.h:188
#define ARMARX_ERROR
The logging level for unexpected behaviour, that must be fixed.
Definition Logging.h:194
#define ARMARX_WARNING
The logging level for unexpected behaviour, but not a serious problem.
Definition Logging.h:191
bool update(mongocxx::collection &coll, const nlohmann::json &query, const nlohmann::json &update)
Definition mongodb.cpp:68
::IceInternal::Handle< Dict > DictPtr
std::shared_ptr< Dict > DictPtr
Definition Dict.h:42
This file offers overloads of toIce() and fromIce() functions for STL container types.
std::string errorStatustoString(skills::core::dto::Execution::Status s)
#define ARMARX_TRACE
Definition trace.h:75