7#include "ui_applicationviewwidget.h"
17#include <QTreeWidgetItem>
29 modRunAction(nullptr),
30 modStopAction(nullptr),
31 modkillAction(nullptr),
32 modSeparator(nullptr),
33 modRefreshAction(nullptr),
34 modSelectAllAction(nullptr),
35 modAttachAction(nullptr),
36 modAssignAction(nullptr),
39 connConnectAction(nullptr),
40 connDisconnectAction(nullptr),
41 connSeparatorAction(nullptr),
42 connRefreshAction(nullptr),
43 connSelectAllAction(nullptr),
44 conn1SeparatorAction(nullptr),
45 connInspectAction(nullptr),
46 connYARPViewAction(nullptr),
47 connYARPReadAction(nullptr),
48 connYARPHearAction(nullptr),
49 connYARPScopeAction(nullptr),
50 resRefreshAction(nullptr),
51 resSelectAllAction(nullptr)
57 this->editingMode = editingMode;
64 prepareManagerFrom(lazy);
66 ui->moduleList->resizeColumnToContents(0);
67 ui->moduleList->resizeColumnToContents(1);
68 ui->moduleList->resizeColumnToContents(2);
69 ui->moduleList->resizeColumnToContents(3);
70 ui->moduleList->resizeColumnToContents(4);
71 ui->moduleList->resizeColumnToContents(5);
72 ui->moduleList->resizeColumnToContents(6);
73 ui->moduleList->resizeColumnToContents(7);
75 ui->resourcesList->resizeColumnToContents(0);
76 ui->resourcesList->resizeColumnToContents(1);
77 ui->resourcesList->resizeColumnToContents(2);
78 ui->resourcesList->resizeColumnToContents(3);
81 ui->connectionList->resizeColumnToContents(0);
82 ui->connectionList->resizeColumnToContents(1);
83 ui->connectionList->resizeColumnToContents(2);
84 ui->connectionList->resizeColumnToContents(3);
85 ui->connectionList->resizeColumnToContents(4);
86 ui->connectionList->resizeColumnToContents(5);
88 connect(ui->moduleList,
SIGNAL(itemSelectionChanged()),
this,SLOT(onModuleItemSelectionChanged()));
89 connect(ui->moduleList,
SIGNAL(itemDoubleClicked(QTreeWidgetItem*,
int)),
this,SLOT(onItemDoubleClicked(QTreeWidgetItem*,
int)));
91 connect(ui->resourcesList,
SIGNAL(itemSelectionChanged()),
this,SLOT(onResourceItemSelectionChanged()));
92 connect(ui->resourcesList,
SIGNAL(itemDoubleClicked(QTreeWidgetItem*,
int)),
this,SLOT(onItemDoubleClicked(QTreeWidgetItem*,
int)));
94 connect(ui->connectionList,
SIGNAL(itemSelectionChanged()),
this,SLOT(onConnectionItemSelectionChanged()));
95 connect(ui->connectionList,
SIGNAL(itemDoubleClicked(QTreeWidgetItem*,
int)),
this,SLOT(onItemDoubleClicked(QTreeWidgetItem*,
int)));
98 connect(
this,
SIGNAL(
selfConnect(
int)),
this,SLOT(onSelfConnect(
int)),Qt::QueuedConnection);
102 connect(
this,
SIGNAL(
selfStart(
int)),
this,SLOT(onSelfStart(
int)),Qt::QueuedConnection);
103 connect(
this,
SIGNAL(
selfStop(
int)),
this,SLOT(onSelfStop(
int)),Qt::QueuedConnection);
105 createModulesViewContextMenu();
106 createConnectionsViewContextMenu();
107 createResourcesViewContextMenu();
109 l =
new QGridLayout(ui->builderContainer);
110 ui->builderContainer->setLayout(l);
114 layout()->removeWidget(ui->mainSplietter);
115 delete ui->mainSplietter;
116 l = (QGridLayout*)layout();
124 builderWindowContainer =
new QMainWindow(
nullptr,Qt::Widget);
125 builderWindowContainer->setDockNestingEnabled(
true);
126 l->addWidget(builderWindowContainer);
128 builderWidget =
new QDockWidget(
"YARP Builder",builderWindowContainer);
129 builderWindowContainer->addDockWidget(Qt::TopDockWidgetArea,builderWidget);
131 builderWidget->setWidget(builder);
133 builderWidget->setFeatures(QDockWidget::NoDockWidgetFeatures);
134 connect(builderWidget,
SIGNAL(topLevelChanged(
bool)),
this,SLOT(onBuilderFloatChanged(
bool)));
173 connect(builder,
SIGNAL(refreshApplication()),
174 this,SLOT(onRefreshApplication()),Qt::DirectConnection);
175 connect(builder,
SIGNAL(setModuleSelected(QList<int>)),
this,SLOT(onModuleSelected(QList<int>)));
176 connect(builder,
SIGNAL(setConnectionSelected(QList<int>)),
this,SLOT(onConnectionSelected(QList<int>)));
237 builderWidget->setVisible(show);
242 return !ui->moduleList->selectedItems().isEmpty();
246 return !ui->connectionList->selectedItems().isEmpty();
251 return ui->moduleList;
256 return ui->connectionList;
261 return builderToolBar;
265void ApplicationViewWidget::createModulesViewContextMenu()
267 modRunAction =
new QAction(
"Run",
this);
268 modStopAction =
new QAction(
"Stop",
this);
269 modkillAction =
new QAction(
"Kill",
this);
270 modSeparator =
new QAction(
this);
271 modSeparator->setSeparator(
true);
272 modRefreshAction =
new QAction(
"Refresh Status",
this);
273 modSelectAllAction =
new QAction(
"Select All Modules",
this);
274 modAttachAction =
new QAction(
"Attach to stdout",
this);
275 modAssignAction =
new QAction(
"Assign Hosts",
this);
277 modRunAction->setIcon(QIcon(
":/play22.svg"));
278 modStopAction->setIcon(QIcon(
":/stop22.svg"));
279 modkillAction->setIcon(QIcon(
":/kill22.svg"));
280 modRefreshAction->setIcon(QIcon(
":/refresh22.svg"));
281 modSelectAllAction->setIcon(QIcon(
":/select-all22.svg"));
282 modAssignAction->setIcon(QIcon(
":/computer-available22.svg"));
285 ui->moduleList->addAction(modRunAction);
286 ui->moduleList->addAction(modStopAction);
287 ui->moduleList->addAction(modkillAction);
288 ui->moduleList->addAction(modSeparator);
289 ui->moduleList->addAction(modRefreshAction);
290 ui->moduleList->addAction(modSelectAllAction);
291 ui->moduleList->addAction(modAttachAction);
292 ui->moduleList->addAction(modAssignAction);
294 connect(modRunAction,
SIGNAL(triggered()),
this,SLOT(onRun()));
295 connect(modStopAction,
SIGNAL(triggered()),
this,SLOT(onStop()));
296 connect(modkillAction,
SIGNAL(triggered()),
this,SLOT(onKill()));
297 connect(modRefreshAction,
SIGNAL(triggered()),
this,SLOT(onRefresh()));
298 connect(modSelectAllAction,
SIGNAL(triggered()),
this,SLOT(selectAllModule()));
299 connect(modAttachAction,
SIGNAL(triggered()),
this,SLOT(onAttachStdout()));
300 connect(modAssignAction,
SIGNAL(triggered()),
this,SLOT(onAssignHost()));
302 onModuleItemSelectionChanged();
306void ApplicationViewWidget::createConnectionsViewContextMenu()
308 connContex =
new QMenu(ui->connectionList);
309 connSubMenu =
new QMenu(
"Inspect",connContex);
311 connConnectAction =
new QAction(
"Connect",connContex);
312 connDisconnectAction =
new QAction(
"Disconnect",connContex);
313 connSeparatorAction =
new QAction(connContex);
314 connSeparatorAction->setSeparator(
true);
315 connRefreshAction =
new QAction(
"Refresh Status",connContex);
316 connSelectAllAction =
new QAction(
"Select All Connections",connContex);
317 conn1SeparatorAction =
new QAction(connContex);
318 conn1SeparatorAction->setSeparator(connContex);
320 connYARPViewAction =
new QAction(
"yarpview",connSubMenu);
321 connYARPReadAction =
new QAction(
"yarpread",connSubMenu);
322 connYARPHearAction =
new QAction(
"yarphear",connSubMenu);
323 connYARPScopeAction =
new QAction(
"yarpscope",connSubMenu);
325 connSelectAllAction->setIcon(QIcon(
":/select-all22.svg"));
326 connRefreshAction->setIcon(QIcon(
":/refresh22.svg"));
327 connConnectAction->setIcon(QIcon(
":/connect22.svg"));
328 connDisconnectAction->setIcon(QIcon(
":/disconnect22.svg"));
330 connect(connConnectAction,
SIGNAL(triggered()),
this,SLOT(onConnect()));
331 connect(connDisconnectAction,
SIGNAL(triggered()),
this,SLOT(onDisconnect()));
332 connect(connRefreshAction,
SIGNAL(triggered()),
this,SLOT(onRefresh()));
333 connect(connSelectAllAction,
SIGNAL(triggered()),
this,SLOT(selectAllConnections()));
335 connect(connYARPViewAction,
SIGNAL(triggered()),
this,SLOT(onYARPView()));
336 connect(connYARPReadAction,
SIGNAL(triggered()),
this,SLOT(onYARPRead()));
337 connect(connYARPHearAction,
SIGNAL(triggered()),
this,SLOT(onYARPHear()));
338 connect(connYARPScopeAction,
SIGNAL(triggered()),
this,SLOT(onYARPScope()));
340 connContex->addAction(connConnectAction);
341 connContex->addAction(connDisconnectAction);
342 connContex->addAction(connSeparatorAction);
343 connContex->addAction(connRefreshAction);
344 connContex->addAction(connSelectAllAction);
345 connContex->addAction(conn1SeparatorAction);
346 connContex->addMenu(connSubMenu);
348 connSubMenu->addAction(connYARPViewAction);
349 connSubMenu->addAction(connYARPReadAction);
350 connSubMenu->addAction(connYARPHearAction);
351 connSubMenu->addAction(connYARPScopeAction);
354 ui->connectionList->setContextMenu(connContex);
356 onConnectionItemSelectionChanged();
361void ApplicationViewWidget::createResourcesViewContextMenu()
363 resRefreshAction =
new QAction(
"Refresh Status",
this);
364 resSelectAllAction =
new QAction(
"Select All Resources",
this);
366 resRefreshAction->setIcon(QIcon(
":/refresh22.svg"));
367 resSelectAllAction->setIcon(QIcon(
":/select-all22.svg"));
369 ui->resourcesList->addAction(resRefreshAction);
370 ui->resourcesList->addAction(resSelectAllAction);
372 connect(resRefreshAction,
SIGNAL(triggered()),
this,SLOT(onRefresh()));
373 connect(resSelectAllAction,
SIGNAL(triggered()),
this,SLOT(selectAllResources()));
377void ApplicationViewWidget::onConnectionItemSelectionChanged()
379 if (ui->connectionList->selectedItems().isEmpty()) {
380 connConnectAction->setEnabled(
false);
381 connDisconnectAction->setEnabled(
false);
382 connSeparatorAction->setEnabled(
false);
383 connRefreshAction->setEnabled(
false);
385 connConnectAction->setEnabled(
true);
386 connDisconnectAction->setEnabled(
true);
387 connSeparatorAction->setEnabled(
true);
388 connRefreshAction->setEnabled(
true);
391 if (ui->connectionList->hasFocus()) {
392 QList<int>selectedIds;
393 QList<QTreeWidgetItem*> selectedItems = ui->connectionList->selectedItems();
394 foreach(QTreeWidgetItem *it,selectedItems) {
395 QString
id = it->text(1);
396 selectedIds.append(
id.toInt());
404void ApplicationViewWidget::onModuleItemSelectionChanged()
407 if (ui->moduleList->selectedItems().isEmpty()) {
408 modRunAction->setEnabled(
false);
409 modStopAction->setEnabled(
false);
410 modkillAction->setEnabled(
false);
411 modAttachAction->setEnabled(
false);
412 modAssignAction->setEnabled(
false);
413 modRefreshAction->setEnabled(
false);
415 modRunAction->setEnabled(
true);
416 modStopAction->setEnabled(
true);
417 modkillAction->setEnabled(
true);
420 foreach (QTreeWidgetItem *it, ui->moduleList->selectedItems()) {
421 if (it->text(3) !=
"localhost") {
422 modAttachAction->setEnabled(
false);
428 modAttachAction->setEnabled(
true);
431 modAssignAction->setEnabled(
true);
432 modRefreshAction->setEnabled(
true);
436 if (ui->moduleList->hasFocus()) {
438 QList<int>selectedIds;
439 QList<QTreeWidgetItem*> selectedItems = ui->moduleList->selectedItems();
440 foreach(QTreeWidgetItem *it,selectedItems) {
441 if (it->data(0,Qt::UserRole).toInt() ==
APPLICATION) {
442 for(
int j=0;j<it->childCount();j++) {
443 QTreeWidgetItem *child = it->child(j);
444 child->setSelected(
true);
450 selectedItems = ui->moduleList->selectedItems();
451 foreach(QTreeWidgetItem *it,selectedItems) {
452 if (it->data(0,Qt::UserRole).toInt() ==
APPLICATION) {
455 QString
id = it->text(1);
456 selectedIds.append(
id.toInt());
467void ApplicationViewWidget::onResourceItemSelectionChanged()
469 if (ui->resourcesList->currentItem() ==
nullptr) {
470 resRefreshAction->setEnabled(
false);
472 resRefreshAction->setEnabled(
true);
483 updateApplicationWindow();
489void ApplicationViewWidget::onRefreshApplication()
496 updateApplicationWindow();
504void ApplicationViewWidget::onConnectionSelected(QList<int>
id)
506 disconnect(ui->connectionList,
SIGNAL(itemSelectionChanged()),
this,SLOT(onConnectionItemSelectionChanged()));
507 for(
int i=0;i<ui->connectionList->topLevelItemCount();i++) {
508 ui->connectionList->topLevelItem(i)->setSelected(
false);
510 for(
int i=0;i<ui->connectionList->topLevelItemCount();i++) {
511 for(
int j=0;j<
id.count();j++) {
512 if (ui->connectionList->topLevelItem(i)->text(1).toInt() ==
id.at(j)) {
513 ui->connectionList->topLevelItem(i)->setSelected(
true);
518 onConnectionItemSelectionChanged();
519 connect(ui->connectionList,
SIGNAL(itemSelectionChanged()),
this,SLOT(onConnectionItemSelectionChanged()));
522void ApplicationViewWidget::onModuleSelected(QList<int>
id)
524 disconnect(ui->moduleList,
SIGNAL(itemSelectionChanged()),
this,SLOT(onModuleItemSelectionChanged()));
525 for(
int i=0;i<ui->moduleList->topLevelItemCount();i++) {
526 ui->moduleList->topLevelItem(i)->setSelected(
false);
527 if (ui->moduleList->topLevelItem(i)->data(0,Qt::UserRole) ==
APPLICATION ) {
528 for(
int k=0;k<ui->moduleList->topLevelItem(i)->childCount();k++) {
529 ui->moduleList->topLevelItem(i)->child(k)->setSelected(
false);
534 for(
int i=0;i<ui->moduleList->topLevelItemCount();i++) {
535 if (ui->moduleList->topLevelItem(i)->data(0,Qt::UserRole) ==
APPLICATION ) {
536 for(
int k=0;k<ui->moduleList->topLevelItem(i)->childCount();k++) {
537 for(
int j=0;j<
id.count();j++) {
538 if (ui->moduleList->topLevelItem(i)->child(k)->text(1).toInt() ==
id.at(j)) {
539 ui->moduleList->topLevelItem(i)->child(k)->setSelected(
true);
547 for(
int j=0;j<
id.count();j++) {
548 if (ui->moduleList->topLevelItem(i)->text(1).toInt() ==
id.at(j)) {
549 ui->moduleList->topLevelItem(i)->setSelected(
true);
556 onModuleItemSelectionChanged();
557 connect(ui->moduleList,
SIGNAL(itemSelectionChanged()),
this,SLOT(onModuleItemSelectionChanged()));
561void ApplicationViewWidget::updateApplicationWindow()
563 ui->moduleList->clear();
564 ui->connectionList->clear();
565 ui->resourcesList->clear();
566 listOfResourceNames.clear();
568 disconnect(ui->moduleList,
SIGNAL(itemChanged(QTreeWidgetItem*,
int)),
this,SLOT(onModuleItemChanged(QTreeWidgetItem*,
int)));
576 for(moditr=modules.begin(); moditr<modules.end(); moditr++)
579 Module *mod = (*moditr)->getModule();
583 if (modLabel != appLabel) {
585 for(
int i=0; i < ui->moduleList->topLevelItemCount();i++) {
586 if (ui->moduleList->topLevelItem(i)->data(0,Qt::UserRole + 1).toString() == modLabel) {
596 appNode->setData(0,Qt::UserRole + 1,modLabel);
598 appNode->setExpanded(
true);
599 appNode->setIcon(0,QIcon(
":/run22.svg"));
602 QString
id = QString(
"%1").arg((*moditr)->getID());
603 QString command = QString(
"%1").arg((*moditr)->getCommand());
604 QString host = QString(
"%1").arg((*moditr)->getHost());
605 QString param = QString(
"%1").arg((*moditr)->getParam());
606 QString stdio = QString(
"%1").arg((*moditr)->getStdio());
607 QString workDir = QString(
"%1").arg((*moditr)->getWorkDir());
608 QString env = QString(
"%1").arg((*moditr)->getEnv());
617 l << command <<
id <<
"stopped" << host << param << stdio << workDir << env;
628 it->setIcon(0,QIcon(
":/close.svg"));
629 it->setForeground(2,QColor(
"#BF0303"));
630 ui->moduleList->addTopLevelItem(it);
634 for(cnnitr=connections.begin(); cnnitr<connections.end(); cnnitr++)
637 if ((*cnnitr).isPersistent()) {
640 if ((*cnnitr).isExternalFrom() || (*cnnitr).isExternalTo()) {
646 QString sId = QString(
"%1").arg(
id);
647 QString from = QString(
"%1").arg((*cnnitr).from());
648 QString to = QString(
"%1").arg((*cnnitr).to());
649 QString carrier = QString(
"%1").arg((*cnnitr).carrier());
650 QString status =
"disconnected";
653 if(carrier.isEmpty())
657 size_t pos = carrier.toStdString().find(
'+');
658 if(pos != std::string::npos)
660 modifier = carrier.mid(pos);
661 QStringList myStringList = carrier.split(
'+');
662 carrier = myStringList.first();
667 l <<
type << sId << status << from << to << carrier << modifier;
669 ui->moduleList->addTopLevelItem(it);
672 scanAvailableCarriers(carrier,
false);
674 auto* comboBox =
new QComboBox(
this);
675 comboBox->addItems(stringLst);
676 comboBox->setEditable(
true);
677 ui->connectionList->setItemWidget((QTreeWidgetItem *) it,5, comboBox);
679 it->setIcon(0,QIcon(
":/disconnect22.svg"));
680 it->setForeground(2,QColor(
"#BF0303"));
689 QString sId = QString(
"%1").arg(
id);
699 QString res = QString(
"%1").arg((*itrS)->getName());
700 if (std::find(listOfResourceNames.begin(),
701 listOfResourceNames.end(),
702 res.toStdString()) == listOfResourceNames.end())
704 listOfResourceNames.push_back(res.toStdString());
711 QString status =
"unknown";
715 l << res << sId <<
type << status ;
717 ui->moduleList->addTopLevelItem(it);
719 if (
type ==
"computer") {
720 it->setIcon(0,QIcon(
":/computer-unavailable22.svg"));
721 it->setForeground(3,QColor(
"#BF0303"));
723 it->setIcon(0,QIcon(
":/port-unavailable22.svg"));
724 it->setForeground(3,QColor(
"#BF0303"));
728 connect(ui->moduleList,
SIGNAL(itemChanged(QTreeWidgetItem*,
int)),
this,SLOT(onModuleItemChanged(QTreeWidgetItem*,
int)));
731void ApplicationViewWidget::onModuleItemChanged(QTreeWidgetItem *it,
int col)
733 Qt::ItemFlags tmp = it->flags();
734 if (!(tmp & Qt::ItemIsEditable)) {
740void ApplicationViewWidget::onItemDoubleClicked(QTreeWidgetItem *it,
int col)
742 Qt::ItemFlags tmp = it->flags();
743 if (isEditable(it, col)) {
744 it->setFlags(tmp | Qt::ItemIsEditable);
745 disconnect(ui->connectionList,
SIGNAL(itemChanged(QTreeWidgetItem*,
int)),
this,SLOT(onItemChanged(QTreeWidgetItem*,
int)));
746 connect(ui->connectionList,
SIGNAL(itemChanged(QTreeWidgetItem*,
int)),
this,SLOT(onItemChanged(QTreeWidgetItem*,
int)));
747 }
else if (tmp & Qt::ItemIsEditable) {
748 it->setFlags(tmp ^ Qt::ItemIsEditable);
749 disconnect(ui->connectionList,
SIGNAL(itemChanged(QTreeWidgetItem*,
int)),
this,SLOT(onItemChanged(QTreeWidgetItem*,
int)));
750 connect(ui->connectionList,
SIGNAL(itemChanged(QTreeWidgetItem*,
int)),
this,SLOT(onItemChanged(QTreeWidgetItem*,
int)));
755void ApplicationViewWidget::onItemChanged(QTreeWidgetItem *it,
int col)
760 ui->connectionList->blockSignals(
true);
762 updateConnectionItem(it);
764 it->setForeground(3,QColor(res ?
"#008C00" :
"#BF0303"));
771 updateConnectionItem(it);
772 bool res = safeManager.
existPortTo(it->text(1).toInt());
773 it->setForeground(3,QColor(res ?
"#008C00" :
"#BF0303"));
779 ui->connectionList->blockSignals(
false);
780 disconnect(ui->connectionList,
SIGNAL(itemChanged(QTreeWidgetItem*,
int)),
this,SLOT(onItemChanged(QTreeWidgetItem*,
int)));
794bool ApplicationViewWidget::isEditable(QTreeWidgetItem *it,
int col)
800 if (col == 4 || col == 5 || col == 6 || col == 7) {
801 if (it->text(2) ==
"stopped") {
806 if (it->text(2) ==
"stopped") {
813 if (col == 3 || col == 4 || col == 5 || col == 6) {
814 if (it->text(2) ==
"disconnected") {
831void ApplicationViewWidget::onCloseStdOut(
int id)
833 for(
int i=0;i<ui->moduleList->topLevelItemCount();i++) {
834 QTreeWidgetItem *it = ui->moduleList->topLevelItem(i);
836 closeNestedApplicationStdOut(it,
id);
838 if (it->text(1).toInt() ==
id) {
839 auto* stdouWin = qvariant_cast<StdoutWindow *>(it->data(0,Qt::UserRole));
840 if (stdouWin && stdouWin->getId() ==
id) {
842 it->setData(0,Qt::UserRole,QVariant::fromValue(NULL));
850void ApplicationViewWidget::closeNestedApplicationStdOut(QTreeWidgetItem *it,
int id)
852 for(
int j=0; j<it->childCount();j++) {
853 QTreeWidgetItem *ch = it->child(j);
855 closeNestedApplicationStdOut(it,
id);
857 if (ch->text(1).toInt() ==
id) {
858 auto* stdouWin = qvariant_cast<StdoutWindow *>(ch->data(0,Qt::UserRole));
859 if (stdouWin && stdouWin->getId() ==
id) {
861 ch->setData(0,Qt::UserRole,QVariant::fromValue(NULL));
869bool ApplicationViewWidget::areAllShutdown()
872 for(
int i=0;i<ui->moduleList->topLevelItemCount();i++) {
873 QTreeWidgetItem *it = ui->moduleList->topLevelItem(i);
875 ret = areAllNestedApplicationShutdown(it);
880 if (it->text(2) !=
"stopped") {
886 for(
int i=0;i<ui->connectionList->topLevelItemCount();i++) {
887 QTreeWidgetItem *it = ui->connectionList->topLevelItem(i);
888 if (it->text(2) !=
"disconnected") {
896bool ApplicationViewWidget::areAllNestedApplicationShutdown(QTreeWidgetItem *it)
899 for(
int j=0; j<it->childCount();j++) {
900 QTreeWidgetItem *ch = it->child(j);
902 ret = areAllNestedApplicationShutdown(ch);
907 if (ch->text(2) !=
"stopped") {
915void ApplicationViewWidget::onSelfSafeLoadBalance()
917 updateApplicationWindow();
921void ApplicationViewWidget::onAssignHost()
923 if (areAllShutdown() && !safeManager.
busy()) {
924 for(
int i=0;i<ui->moduleList->topLevelItemCount();i++) {
925 QTreeWidgetItem *it = ui->moduleList->topLevelItem(i);
927 assignHostNestedApplication(it);
929 if (it->isSelected()) {
931 it->setText(2,
"waiting");
944 logger->
addError(
"Running modules should be stopped before assigning hosts.");
949void ApplicationViewWidget::assignHostNestedApplication(QTreeWidgetItem *it)
951 for(
int j=0; j<it->childCount();j++) {
952 QTreeWidgetItem *ch = it->child(j);
954 assignHostNestedApplication(ch);
956 if (ch->isSelected()) {
958 ch->setText(2,
"waiting");
965void ApplicationViewWidget::onAttachStdout()
967 if (safeManager.
busy()) {
971 std::vector<int> MIDs;
972 for(
int i=0;i<ui->moduleList->topLevelItemCount();i++) {
973 QTreeWidgetItem *it = ui->moduleList->topLevelItem(i);
975 attachStdOutNestedApplication(it,&MIDs);
977 if (it->isSelected()) {
978 int id = it->text(1).toInt();
980 auto* stdouWin = qvariant_cast<StdoutWindow *>(it->data(0,Qt::UserRole));
981 if (stdouWin && stdouWin->getId() ==
id) {
986 MIDs.push_back(it->text(1).toInt());
988 QString name = QString(
"%1").arg(app->
getName());
989 QString strTitle = name +
":" + it->text(0) +
":" + it->text(1);
992 connect(stdOutWindow,
SIGNAL(closeStdOut(
int)),
this,SLOT(onCloseStdOut(
int)));
994 it->setData(0,Qt::UserRole,QVariant::fromValue(stdOutWindow));
995 stdOutWindow->show();
1006void ApplicationViewWidget::attachStdOutNestedApplication(QTreeWidgetItem *it,std::vector<int> *MIDs)
1008 for(
int j=0; j<it->childCount();j++) {
1009 QTreeWidgetItem *ch = it->child(j);
1011 attachStdOutNestedApplication(ch,MIDs);
1013 if (ch->isSelected()) {
1014 int id = ch->text(1).toInt();
1016 auto* stdouWin = qvariant_cast<StdoutWindow *>(ch->data(0,Qt::UserRole));
1017 if (stdouWin && stdouWin->getId() ==
id) {
1022 MIDs->push_back(ch->text(1).toInt());
1024 QString name = QString(
"%1").arg(app->
getName());
1025 QString strTitle = name +
":" + ch->text(0) +
":" + ch->text(1);
1028 connect(stdOutWindow,
SIGNAL(closeStdOut(
int)),
this,SLOT(onCloseStdOut(
int)));
1030 ch->setData(0,Qt::UserRole,QVariant::fromValue(stdOutWindow));
1031 stdOutWindow->show();
1039bool ApplicationViewWidget::onRun()
1041 selectAllConnections(
true);
1042 selectAllResources(
true);
1043 if (safeManager.
busy() ) {
1047 std::vector<int> MIDs;
1048 for(
int i=0;i<ui->moduleList->topLevelItemCount();i++) {
1049 QTreeWidgetItem *it = ui->moduleList->topLevelItem(i);
1052 runNestedApplication(it,&MIDs);
1055 if (it->isSelected()) {
1056 MIDs.push_back(it->text(1).toInt());
1058 it->text(4).toLatin1().data(),
1059 it->text(3).toLatin1().data(),
1060 it->text(5).toLatin1().data(),
1061 it->text(6).toLatin1().data(),
1062 it->text(7).toLatin1().data());
1064 it->setText(2,
"waiting");
1065 it->setIcon(0,QIcon(
":/refresh.svg"));
1066 it->setForeground(2,QColor(
"#000000"));
1075 std::vector<int> CIDs;
1081 std::vector<int> RIDs;
1093 safeManager.
safeRun(MIDs,CIDs,RIDs);
1095 selectAllModule(
false);
1096 selectAllConnections(
false);
1097 selectAllResources(
false);
1101void ApplicationViewWidget::runNestedApplication(QTreeWidgetItem *it,std::vector<int> *MIDs)
1103 for(
int j=0; j<it->childCount();j++) {
1104 QTreeWidgetItem *ch = it->child(j);
1107 runNestedApplication(ch,MIDs);
1109 if (ch->isSelected()) {
1110 MIDs->push_back(ch->text(1).toInt());
1112 ch->text(4).toLatin1().data(),
1113 ch->text(3).toLatin1().data(),
1114 ch->text(5).toLatin1().data(),
1115 ch->text(6).toLatin1().data(),
1116 ch->text(7).toLatin1().data());
1118 ch->setText(2,
"waiting");
1119 ch->setIcon(0,QIcon(
":/refresh.svg"));
1120 ch->setForeground(2,QColor(
"#000000"));
1130bool ApplicationViewWidget::onStop()
1132 selectAllConnections(
true);
1133 selectAllResources(
true);
1134 if (safeManager.
busy()) {
1138 std::vector<int> MIDs;
1139 for(
int i=0;i<ui->moduleList->topLevelItemCount();i++) {
1140 QTreeWidgetItem *it = ui->moduleList->topLevelItem(i);
1142 stopNestedApplication(it,&MIDs);
1145 if (it->isSelected()) {
1147 MIDs.push_back(it->text(1).toInt());
1149 it->text(4).toLatin1().data(),
1150 it->text(3).toLatin1().data(),
1151 it->text(5).toLatin1().data(),
1152 it->text(6).toLatin1().data(),
1153 it->text(7).toLatin1().data());
1155 it->setText(2,
"waiting");
1156 it->setIcon(0,QIcon(
":/refresh.svg"));
1157 it->setForeground(2,QColor(
"#000000"));
1164 std::vector<int> CIDs;
1170 std::vector<int> RIDs;
1182 safeManager.
safeStop(MIDs,CIDs,RIDs);
1184 selectAllModule(
false);
1185 selectAllConnections(
false);
1186 selectAllResources(
false);
1190void ApplicationViewWidget::stopNestedApplication(QTreeWidgetItem *it,std::vector<int> *MIDs)
1192 for(
int j=0; j<it->childCount();j++) {
1193 QTreeWidgetItem *ch = it->child(j);
1195 stopNestedApplication(ch,MIDs);
1197 if (ch->isSelected()) {
1198 MIDs->push_back(ch->text(1).toInt());
1200 ch->text(4).toLatin1().data(),
1201 ch->text(3).toLatin1().data(),
1202 ch->text(5).toLatin1().data(),
1203 ch->text(6).toLatin1().data(),
1204 ch->text(7).toLatin1().data());
1206 ch->setText(2,
"waiting");
1207 ch->setIcon(0,QIcon(
":/refresh.svg"));
1208 ch->setForeground(2,QColor(
"#000000"));
1218bool ApplicationViewWidget::onKill()
1220 selectAllConnections(
true);
1221 selectAllResources(
true);
1222 if (safeManager.
busy()) {
1226 if (QMessageBox::question(
this,
"Killing modules!",
"Are you sure?") != QMessageBox::Yes) {
1230 std::vector<int> MIDs;
1231 for(
int i=0;i<ui->moduleList->topLevelItemCount();i++) {
1232 QTreeWidgetItem *it = ui->moduleList->topLevelItem(i);
1234 killNestedApplication(it,&MIDs);
1236 if (it->isSelected()) {
1238 MIDs.push_back(it->text(1).toInt());
1240 it->text(4).toLatin1().data(),
1241 it->text(3).toLatin1().data(),
1242 it->text(5).toLatin1().data(),
1243 it->text(6).toLatin1().data(),
1244 it->text(7).toLatin1().data());
1246 it->setText(2,
"waiting");
1247 it->setIcon(0,QIcon(
":/refresh22.svg"));
1248 it->setForeground(2,QColor(
"#000000"));
1255 std::vector<int> CIDs;
1262 std::vector<int> RIDs;
1274 safeManager.
safeKill(MIDs, CIDs, RIDs);
1276 selectAllModule(
false);
1277 selectAllConnections(
false);
1278 selectAllResources(
false);
1282void ApplicationViewWidget::killNestedApplication(QTreeWidgetItem *it,std::vector<int> *MIDs)
1284 for(
int j=0; j<it->childCount();j++) {
1285 QTreeWidgetItem *ch = it->child(j);
1287 killNestedApplication(ch,MIDs);
1289 if (ch->isSelected()) {
1290 MIDs->push_back(ch->text(1).toInt());
1292 ch->text(4).toLatin1().data(),
1293 ch->text(3).toLatin1().data(),
1294 ch->text(5).toLatin1().data(),
1295 ch->text(6).toLatin1().data(),
1296 ch->text(7).toLatin1().data());
1298 ch->setText(2,
"waiting");
1299 ch->setIcon(0,QIcon(
":/refresh.svg"));
1300 ch->setForeground(2,QColor(
"#000000"));
1310bool ApplicationViewWidget::onConnect()
1312 if (safeManager.
busy()) {
1317 std::vector<int> CIDs;
1318 for(
int i=0;i<ui->connectionList->topLevelItemCount();i++)
1320 updateConnection(i,CIDs);
1326 selectAllConnections(
false);
1331bool ApplicationViewWidget::onDisconnect()
1333 if (safeManager.
busy()) {
1338 std::vector<int> CIDs;
1339 for(
int i=0;i<ui->connectionList->topLevelItemCount();i++)
1341 updateConnection(i, CIDs);
1347 selectAllConnections(
false);
1353bool ApplicationViewWidget::onRefresh()
1355 if (safeManager.
busy()) {
1359 std::vector<int> modulesIDs;
1360 std::vector<int> connectionsIDs;
1361 std::vector<int> resourcesIDs;
1363 for(
int i=0;i<ui->moduleList->topLevelItemCount();i++) {
1364 QTreeWidgetItem *it = ui->moduleList->topLevelItem(i);
1366 refreshNestedApplication(it,&modulesIDs);
1368 if (it->isSelected()) {
1369 modulesIDs.push_back(it->text(1).toInt());
1371 it->text(4).toLatin1().data(),
1372 it->text(3).toLatin1().data(),
1373 it->text(5).toLatin1().data(),
1374 it->text(6).toLatin1().data(),
1375 it->text(7).toLatin1().data());
1376 it->setText(2,
"waiting");
1377 it->setIcon(0,QIcon(
":/refresh22.svg"));
1378 it->setForeground(2,QColor(
"#000000"));
1384 for(
int i=0;i<ui->connectionList->topLevelItemCount();i++) {
1385 updateConnection(i,connectionsIDs);
1388 for(
int i=0;i<ui->resourcesList->topLevelItemCount();i++) {
1389 QTreeWidgetItem *it = ui->resourcesList->topLevelItem(i);
1390 if (it->isSelected()) {
1391 resourcesIDs.push_back(it->text(1).toInt());
1392 it->setText(3,
"waiting");
1393 it->setIcon(0,QIcon(
":/refresh22.svg"));
1394 it->setForeground(3,QColor(
"#000000"));
1402 selectAllConnections(
false);
1403 selectAllModule(
false);
1404 selectAllResources(
false);
1408void ApplicationViewWidget::refreshNestedApplication(QTreeWidgetItem *it,std::vector<int> *MIDs)
1410 for(
int j=0; j<it->childCount();j++) {
1411 QTreeWidgetItem *ch = it->child(j);
1414 refreshNestedApplication(ch,MIDs);
1416 if (ch->isSelected()) {
1417 MIDs->push_back(ch->text(1).toInt());
1418 ch->setText(2,
"waiting");
1419 ch->setIcon(0,QIcon(
":/refresh22.svg"));
1420 ch->setForeground(2,QColor(
"#000000"));
1428void ApplicationViewWidget::selectAllModule()
1430 selectAllModule(
true);
1434void ApplicationViewWidget::selectAllConnections()
1436 selectAllConnections(
true);
1440void ApplicationViewWidget::selectAllResources()
1442 selectAllResources(
true);
1448void ApplicationViewWidget::selectAllModule(
bool check)
1450 disconnect(ui->moduleList,
SIGNAL(itemSelectionChanged()),
this,SLOT(onModuleItemSelectionChanged()));
1451 for(
int i=0;i<ui->moduleList->topLevelItemCount();i++) {
1452 QTreeWidgetItem *it = ui->moduleList->topLevelItem(i);
1454 selectAllNestedApplicationModule(it,check);
1456 it->setSelected(check);
1459 if (ui->moduleList->selectedItems().isEmpty()) {
1460 modRunAction->setEnabled(
false);
1461 modStopAction->setEnabled(
false);
1462 modkillAction->setEnabled(
false);
1463 modAttachAction->setEnabled(
false);
1464 modAssignAction->setEnabled(
false);
1465 modRefreshAction->setEnabled(
false);
1467 modRunAction->setEnabled(
true);
1468 modStopAction->setEnabled(
true);
1469 modkillAction->setEnabled(
true);
1472 foreach (QTreeWidgetItem *it, ui->moduleList->selectedItems()) {
1473 if (it->text(3) !=
"localhost") {
1474 modAttachAction->setEnabled(
false);
1480 modAttachAction->setEnabled(
true);
1490 modAssignAction->setEnabled(
true);
1491 modRefreshAction->setEnabled(
true);
1496 QList<int>selectedIds;
1497 QList<QTreeWidgetItem*> selectedItems = ui->moduleList->selectedItems();
1498 foreach(QTreeWidgetItem *it,selectedItems) {
1499 if (it->data(0,Qt::UserRole).toInt() ==
APPLICATION) {
1500 for(
int j=0;j<it->childCount();j++) {
1501 QTreeWidgetItem *child = it->child(j);
1502 child->setSelected(
true);
1508 selectedItems = ui->moduleList->selectedItems();
1509 foreach(QTreeWidgetItem *it,selectedItems) {
1510 if (it->data(0,Qt::UserRole).toInt() ==
APPLICATION) {
1513 QString
id = it->text(1);
1514 selectedIds.append(
id.toInt());
1521 connect(ui->moduleList,
SIGNAL(itemSelectionChanged()),
this,SLOT(onModuleItemSelectionChanged()));
1524void ApplicationViewWidget::selectAllNestedApplicationModule(QTreeWidgetItem *it,
bool check)
1526 for(
int j=0;j<it->childCount();j++) {
1527 QTreeWidgetItem *ch = it->child(j);
1529 selectAllNestedApplicationModule(ch, check);
1531 ch->setSelected(check);
1536bool ApplicationViewWidget::scanAvailableCarriers(QString carrier,
bool isConnection){
1541 stringLst.push_back(carrier);
1542 for (
size_t i=0; i<lst.
size(); i++)
1544 if (lst.
get(i).
asString() == carrier.toStdString()) {
1547 stringLst.push_back(lst.
get(i).
asString().c_str());
1550 if (!res && isConnection)
1552 std::string msg =
"Unable to find '"+ carrier.toStdString() +
1553 "' among the available carriers in this machine, the connection could fail.";
1559void ApplicationViewWidget::updateConnection(
int index, std::vector<int>& CIDs)
1561 QTreeWidgetItem *it = ui->connectionList->topLevelItem(index);
1562 if (it->isSelected()) {
1563 updateConnectionItem(it);
1565 CIDs.push_back(it->text(1).toInt());
1567 it->setText(2,
"waiting");
1568 it->setIcon(0,QIcon(
":/refresh22.svg"));
1569 it->setForeground(2,QColor(
"#000000"));
1574void ApplicationViewWidget::updateConnectionItem(QTreeWidgetItem *it)
1576 auto* box = qobject_cast<QComboBox*>(ui->connectionList->itemWidget((QTreeWidgetItem *)it, 5));
1577 QString carrier, modifier;
1580 carrier = box->currentText();
1585 carrier=it->text(5);
1590 size_t pos = carrier.toStdString().find(
'+');
1591 if(pos != std::string::npos)
1593 modifier = carrier.mid(pos);
1594 QStringList myStringList = carrier.split(
'+');
1595 carrier = myStringList.first();
1596 box->setCurrentText(carrier);
1597 it->setText(6,modifier);
1601 scanAvailableCarriers(carrier);
1602 carrier = carrier + it->text(6);
1604 it->text(3).toLatin1().data(),
1605 it->text(4).toLatin1().data(),
1606 carrier.toLatin1().data());
1612void ApplicationViewWidget::selectAllConnections(
bool check)
1614 disconnect(ui->connectionList,
SIGNAL(itemSelectionChanged()),
this,SLOT(onConnectionItemSelectionChanged()));
1615 for(
int i=0;i<ui->connectionList->topLevelItemCount();i++) {
1616 QTreeWidgetItem *it = ui->connectionList->topLevelItem(i);
1617 it->setSelected(check);
1620 if (ui->connectionList->selectedItems().isEmpty()) {
1621 connConnectAction->setEnabled(
false);
1622 connDisconnectAction->setEnabled(
false);
1623 connSeparatorAction->setEnabled(
false);
1624 connRefreshAction->setEnabled(
false);
1626 connConnectAction->setEnabled(
true);
1627 connDisconnectAction->setEnabled(
true);
1628 connSeparatorAction->setEnabled(
true);
1629 connRefreshAction->setEnabled(
true);
1632 QList<int>selectedIds;
1633 QList<QTreeWidgetItem*> selectedItems = ui->connectionList->selectedItems();
1634 foreach(QTreeWidgetItem *it,selectedItems) {
1635 QString
id = it->text(1);
1636 selectedIds.append(
id.toInt());
1640 connect(ui->connectionList,
SIGNAL(itemSelectionChanged()),
this,SLOT(onConnectionItemSelectionChanged()));
1647void ApplicationViewWidget::selectAllResources(
bool check)
1649 for(
int i=0;i<ui->resourcesList->topLevelItemCount();i++) {
1650 QTreeWidgetItem *it = ui->resourcesList->topLevelItem(i);
1651 it->setSelected(check);
1659 selectAllConnections(
true);
1660 selectAllModule(
true);
1661 selectAllResources(
true);
1667 if (!onlySelected) {
1668 selectAllModule(
true);
1676 if (!onlySelected) {
1677 selectAllModule(
true);
1685 if (!onlySelected) {
1686 selectAllModule(
true);
1694 if (!onlySelected) {
1695 selectAllConnections(
true);
1703 if (!onlySelected) {
1704 selectAllConnections(
true);
1712 selectAllConnections(
true);
1713 selectAllModule(
true);
1714 selectAllResources(
true);
1720void ApplicationViewWidget::reportErrors()
1728 QString msg = QString(
"(%1) %2").arg(app->
getName()).arg(err);
1734 QString msg = QString(
"(%1) %2").arg(app->
getName()).arg(err);
1744 QString fileName = QFileDialog::getSaveFileName(
this,
"Export Graph",QApplication::applicationDirPath(),
"GraphViz format (*.dot)");
1746 if (!fileName.isEmpty()) {
1750 logger->
addError(
"Cannot export graph");
1759void ApplicationViewWidget::onYARPView()
1761 if (safeManager.
busy()) {
1766 for(
int i=0;i<ui->connectionList->topLevelItemCount();i++) {
1767 QTreeWidgetItem *it = ui->connectionList->topLevelItem(i);
1768 if (it->isSelected()) {
1769 QString from = it->text(3);
1770 QString to = QString(
"/inspect").arg(from);
1771 QString env = QString(
"YARP_PORT_PREFIX=%1").arg(to);
1772 to +=
"/yarpview/img:i";
1775 if (launcher.
init(
"yarpview",
nullptr,
nullptr,
nullptr,
nullptr, env.toLatin1().data()))
1777 if (!launcher.
start() && !launcher.
error().empty())
1780 msg = QString(
"Error while launching yarpview. %1").arg(launcher.
error().c_str());
1781 logger->
addError(msg.toLatin1().data());
1788 while(!timeout(base, 3.0)) {
1789 if (launcher.
exists(to.toLatin1().data())) {
1793 if (!launcher.
connect(from.toLatin1().data(), to.toLatin1().data(),
"udp")) {
1795 msg = QString(
"Cannot inspect '%1' : %2").arg(from).arg(launcher.
error().c_str());
1796 logger->
addError(msg.toLatin1().data());
1810void ApplicationViewWidget::onYARPHear()
1812 if (safeManager.
busy()) {
1817 for(
int i=0;i<ui->connectionList->topLevelItemCount();i++) {
1818 QTreeWidgetItem *it = ui->connectionList->topLevelItem(i);
1819 if (it->isSelected()) {
1820 QString from = it->text(3);
1821 QString to = QString(
"/inspect/hear%1").arg(from);
1824 QString cmd =
"cmd.exe";
1826 param = QString(
"/C yarphear --name %1").arg(to);
1829 QString cmd =
"xterm";
1831 param = QString(
"-hold -title %1 -e yarphear --nodevice --name %2").arg(from).arg(to);
1836 if (launcher.
init(cmd.toLatin1().data(), param.toLatin1().data(),
nullptr,
nullptr,
nullptr,
nullptr))
1838 if (!launcher.
start() && !launcher.
error().empty())
1841 msg = QString(
"Error while launching yarpread. %1").arg(launcher.
error().c_str());
1842 logger->
addError(msg.toLatin1().data());
1849 while(!timeout(base, 3.0)) {
1850 if (launcher.
exists(to.toLatin1().data())) {
1854 if (!launcher.
exists(to.toLatin1().data())) {
1856 msg = QString(
"Cannot inspect '%1' : %2. Did you build yarp with 'portaudio' module?").arg(from).arg(launcher.
error().c_str());
1857 logger->
addError(msg.toLatin1().data());
1860 }
else if (!launcher.
connect(from.toLatin1().data(), to.toLatin1().data(),
"udp")) {
1862 msg = QString(
"Cannot inspect '%1' : %2").arg(from).arg(launcher.
error().c_str());
1863 logger->
addError(msg.toLatin1().data());
1879void ApplicationViewWidget::onYARPRead()
1881 if (safeManager.
busy()) {
1886 for(
int i=0;i<ui->connectionList->topLevelItemCount();i++) {
1887 QTreeWidgetItem *it = ui->connectionList->topLevelItem(i);
1888 if (it->isSelected()) {
1889 QString from = it->text(3);
1890 QString to = QString(
"/inspect/read%1").arg(from);
1893 QString cmd =
"cmd.exe";
1895 param = QString(
"/C yarp read %1").arg(to);
1898 QString cmd =
"xterm";
1900 param = QString(
"-hold -title %1 -e yarp read %2").arg(from).arg(to);
1905 if (launcher.
init(cmd.toLatin1().data(), param.toLatin1().data(),
nullptr,
nullptr,
nullptr,
nullptr))
1907 if (!launcher.
start() && !launcher.
error().empty())
1910 msg = QString(
"Error while launching yarpread. %1").arg(launcher.
error().c_str());
1911 logger->
addError(msg.toLatin1().data());
1918 while(!timeout(base, 3.0)) {
1919 if (launcher.
exists(to.toLatin1().data())) {
1923 if (!launcher.
connect(from.toLatin1().data(), to.toLatin1().data(),
"udp")) {
1925 msg = QString(
"Cannot inspect '%1' : %2").arg(from).arg(launcher.
error().c_str());
1926 logger->
addError(msg.toLatin1().data());
1941void ApplicationViewWidget::onYARPScope()
1943 if (safeManager.
busy()) {
1950 if (dlg.exec() != QDialog::Accepted) {
1958 for(
int i=0;i<ui->connectionList->topLevelItemCount();i++) {
1959 QTreeWidgetItem *it = ui->connectionList->topLevelItem(i);
1960 if (it->isSelected()) {
1961 QString from = it->text(3);
1962 QString to = QString(
"/inspect").arg(from);
1963 QString env = QString(
"YARP_PORT_PREFIX=%1").arg(to);
1967 param = QString(
"--title %1:%2 --bgcolor white --color blue --graph_size 2 --index %2").arg(from).arg(strIndex);
1971 if (launcher.
init(
"yarpscope", param.toLatin1().data(),
nullptr,
nullptr,
nullptr, env.toLatin1().data())) {
1972 if (!launcher.
start() && !launcher.
error().empty()) {
1974 msg = QString(
"Error while launching yarpscope. %1").arg(launcher.
error().c_str());
1975 logger->
addError(msg.toLatin1().data());
1981 while (!timeout(base, 3.0)) {
1982 if (launcher.
exists(to.toLatin1().data())) {
1986 if (!launcher.
connect(from.toLatin1().data(), to.toLatin1().data(),
"udp")) {
1988 msg = QString(
"Cannot inspect '%1' : %2").arg(from).arg(launcher.
error().c_str());
1989 logger->
addError(msg.toLatin1().data());
2003bool ApplicationViewWidget::timeout(
double base,
double timeout)
2021 for(
int i=0; i< ui->moduleList->topLevelItemCount();i++) {
2022 if (ui->moduleList->topLevelItem(i)->text(2) ==
"running") {
2034void ApplicationViewWidget::onSelfConnect(
int which)
2037 if (!getConRowByID(which, &row))
2039 yError()<<
"ApplicationViewWidget: unable to find row with id:"<<which;
2043 QTreeWidgetItem *it = ui->connectionList->topLevelItem(row);
2045 it->setText(2,
"connected");
2046 it->setIcon(0,QIcon(
":/connect22.svg"));
2047 it->setForeground(2,QColor(
"#008C00"));
2048 QString from = it->text(3);
2049 QString to = it->text(4);
2050 auto* box = qobject_cast<QComboBox*>(ui->connectionList->itemWidget((QTreeWidgetItem *)it, 5));
2051 box->setEnabled(
false);
2063void ApplicationViewWidget::onSelfDisconnect(
int which)
2066 if (!getConRowByID(which, &row))
2068 yError()<<
"ApplicationViewWidget: unable to find row with id:"<<which;
2072 QTreeWidgetItem *it = ui->connectionList->topLevelItem(row);
2074 it->setText(2,
"disconnected");
2075 it->setIcon(0,QIcon(
":/disconnect22.svg"));
2076 it->setForeground(2,QColor(
"#BF0303"));
2077 QString from = it->text(3);
2078 QString to = it->text(4);
2079 auto* box = qobject_cast<QComboBox*>(ui->connectionList->itemWidget((QTreeWidgetItem *)it, 5));
2080 box->setEnabled(
true);
2086void ApplicationViewWidget::onSelfResAvailable(
int which)
2089 if (!getResRowByID(which, &row))
2091 yError()<<
"ApplicationViewWidget: unable to find row with id:"<<which;
2095 QTreeWidgetItem *it = ui->resourcesList->topLevelItem(row);
2097 it->setText(3,
"available");
2098 if (it->text(2) ==
"computer") {
2099 it->setIcon(0,QIcon(
":/computer-available22.svg"));
2100 it->setForeground(3,QColor(
"#008C00"));
2102 it->setIcon(0,QIcon(
":/port-available22.svg"));
2103 it->setForeground(3,QColor(
"#008C00"));
2115void ApplicationViewWidget::onSelfResUnavailable(
int which)
2118 if (!getResRowByID(which, &row))
2120 yError()<<
"ApplicationViewWidget: unable to find row with id:"<<which;
2124 QTreeWidgetItem *it = ui->resourcesList->topLevelItem(row);
2126 it->setText(3,
"unavailable");
2127 if (it->text(2) ==
"computer") {
2128 it->setIcon(0,QIcon(
":/computer-unavailable22.svg"));
2129 it->setForeground(3,QColor(
"#BF0303"));
2131 it->setIcon(0,QIcon(
":/port-unavailable22.svg"));
2132 it->setForeground(3,QColor(
"#BF0303"));
2138void ApplicationViewWidget::onSelfStart(
int which)
2140 QTreeWidgetItem *it = getModRowByID(which);
2142 it->setText(2,
"running");
2143 it->setIcon(0,QIcon(
":/apply.svg"));
2144 it->setForeground(2,QColor(
"#008C00"));
2154void ApplicationViewWidget::onSelfStop(
int which)
2156 QTreeWidgetItem *it = getModRowByID(which);
2158 it->setText(2,
"stopped");
2159 it->setIcon(0,QIcon(
":/close.svg"));
2160 it->setForeground(2,QColor(
"#BF0303"));
2187 QString s = QString(
"%1").arg(msg);
2188 for(
int j=0;j<ui->moduleList->topLevelItemCount();j++) {
2189 QTreeWidgetItem *it = ui->moduleList->topLevelItem(j);
2191 modStdOutNestedApplication(it,which,s);
2193 auto* stdouWin = qvariant_cast<StdoutWindow *>(it->data(0,Qt::UserRole));
2194 if (stdouWin && stdouWin->getId() == which) {
2195 stdouWin->addMessage(s);
2203void ApplicationViewWidget::modStdOutNestedApplication(QTreeWidgetItem *it,
int id,QString s)
2205 for(
int j=0; j<it->childCount();j++) {
2206 QTreeWidgetItem *ch = it->child(j);
2208 modStdOutNestedApplication(ch,
id,s);
2210 auto* stdouWin = qvariant_cast<StdoutWindow *>(ch->data(0,Qt::UserRole));
2211 if (stdouWin && stdouWin->getId() ==
id) {
2212 stdouWin->addMessage(s);
2258 if (getConRowByID(from, &row)) {
2259 ui->connectionList->topLevelItem(row)->setForeground(3,QColor(
"#008C00"));
2266 if (getConRowByID(to, &row)) {
2267 ui->connectionList->topLevelItem(row)->setForeground(4,QColor(
"#008C00"));
2281 if (getConRowByID(from, &row)) {
2282 ui->connectionList->topLevelItem(row)->setForeground(3,QColor(
"#BF0303"));
2289 if (getConRowByID(to, &row)) {
2290 ui->connectionList->topLevelItem(row)->setForeground(4,QColor(
"#BF0303"));
2314void ApplicationViewWidget::onDetachStdout()
2323bool ApplicationViewWidget::getConRowByID(
int id,
int *row)
2325 for(
int i=0;i< ui->connectionList->topLevelItemCount();i++) {
2326 QTreeWidgetItem *it = ui->connectionList->topLevelItem(i);
2328 if (it->text(1).toInt() ==
id) {
2340bool ApplicationViewWidget::getResRowByID(
int id,
int *row)
2342 for(
int i=0;i< ui->resourcesList->topLevelItemCount();i++) {
2343 QTreeWidgetItem *it = ui->resourcesList->topLevelItem(i);
2345 if (it->text(1).toInt() ==
id) {
2356QTreeWidgetItem* ApplicationViewWidget::getModRowByID(
int id, QTreeWidgetItem *parent)
2358 QTreeWidgetItem *
ret =
nullptr;
2360 for(
int i=0;i< ui->moduleList->topLevelItemCount();i++) {
2361 QTreeWidgetItem *it = ui->moduleList->topLevelItem(i);
2363 ret = getModRowByID(
id,it);
2369 if (it->text(1).toInt() ==
id) {
2374 for(
int i=0;i< parent->childCount();i++) {
2375 QTreeWidgetItem *it = parent->child(i);
2377 ret = getModRowByID(
id,it);
2383 if (it->text(1).toInt() ==
id) {
2394 safeManager.
close();
int SIGNAL(int pid, int signum)
void setSelectedConnections(QList< int >selectedIds)
void load(bool refresh=false)
void addModulesAction(QAction *)
void setFileName(QString filename)
void setInputPortAvailable(QString, bool)
void setConnectionConnected(bool, QString from, QString to)
void addAction(QAction *)
void setAppName(QString appName)
void setModuleRunning(bool, int id)
void setOutputPortAvailable(QString, bool)
void addConnectionsAction(QAction *)
void setSelectedModules(QList< int >selectedIds)
void safeConnect(std::vector< int > &CIDs)
void safeStop(std::vector< int > &MIDs, std::vector< int > &CIDs, std::vector< int > &RIDs)
void safeRun(std::vector< int > &MIDs, std::vector< int > &CIDs, std::vector< int > &RIDs)
void safeKill(std::vector< int > &MIDs, std::vector< int > &CIDs, std::vector< int > &RIDs)
void safeRefresh(std::vector< int > &MIDs, std::vector< int > &CIDs, std::vector< int > &RIDs)
void safeAttachStdout(std::vector< int > &MIDs)
bool prepare(yarp::manager::Manager *lazy, yarp::os::Property *config, ApplicationEvent *event=nullptr)
void safeDisconnect(std::vector< int > &CDs)
static BuilderWindow * getBuilder(Application *app, Manager *lazyManager, SafeManager *manager, bool editingMode)
Singleton class ErrorLogger.
const char * getLastError()
void addError(const char *szError)
void addWarning(const char *szWarning)
static ErrorLogger * Instance()
Singleton class ErrorLogger.
const char * getLastWarning()
void setWindowMode(WindowMode m)
Define if the application will be visible or not.
bool exists(const std::string &port) override
std::string error() override
bool connect(const std::string &from, const std::string &to, const std::string &carrier, bool persist=false) override
connection broker
ExecutablePContainer & getExecutables()
bool updateConnection(unsigned int id, const char *from, const char *to, const char *carrier)
CnnContainer & getConnections()
ResourcePContainer & getResources()
bool existPortFrom(unsigned int id)
bool existPortTo(unsigned int id)
bool updateExecutable(unsigned int id, const char *szparam, const char *szhost, const char *szstdio, const char *szworkdir, const char *szenv)
bool loadApplication(const char *szAppName)
bool exportDependencyGraph(const char *szFileName)
A simple collection of objects that can be described and transmitted in a portable way.
size_type size() const
Gets the number of elements in the bottle.
Value & get(size_type index) const
Reads a Value v from a certain part of the list.
static Bottle listCarriers()
A class for storing options and configuration information.
static double nowSystem()
static void delaySystem(double seconds)
virtual std::string asString() const
Get string value.
std::vector< Executable * >::iterator ExecutablePIterator
std::vector< GenericResource * >::iterator ResourcePIterator
enum yarp::manager::__NodeType NodeType
std::vector< Connection >::iterator CnnIterator
std::vector< Executable * > ExecutablePContainer
std::vector< Connection > CnnContainer