14#include "ui_batchqosconfdialog.h"
26 ui->treeWidgetCons->header()->resizeSection(0, 120);
27 ui->treeWidgetCons->header()->resizeSection(3, 120);
28 ui->treeWidgetCons->header()->resizeSection(4, 120);
29 ui->treeWidgetCons->header()->resizeSection(5, 150);
32 connect(ui->pushButtonBatchQosUpdate,
SIGNAL(
clicked()),
this,
SLOT(updateQos()));
33 connect(ui->pushButtonBatchQosConfigure,
SIGNAL(
clicked()),
this,
SLOT(configureQos()));
34 ui->pushButtonBatchQosUpdate->setEnabled(
false);
35 ui->pushButtonBatchQosConfigure->setEnabled(
false);
45void BatchQosConfDialog::openCons()
49 QString filename = QFileDialog::getOpenFileName(
nullptr,
"Load connections list",
52 if (filename.size() == 0) {
57 file.open(filename.toStdString().c_str());
58 if (!file.is_open()) {
59 QMessageBox::critical(
nullptr, QObject::tr(
"Error"), QObject::tr(
"Cannot open the file for loading"));
63 ui->treeWidgetCons->clear();
65 unsigned int count = 0;
69 if(sample.size() == 3) {
72 QTreeWidgetItem*
item;
75 prop.append(
"Unknown");
76 prop.append(sample.get(0).asString().c_str());
77 prop.append(sample.get(1).asString().c_str());
78 prop.append(sample.get(2).asString().c_str());
79 item =
new QTreeWidgetItem( ui->treeWidgetCons, prop);
82 yWarning() <<
"Wrong connection data at line" << count;
87 if(ui->treeWidgetCons->topLevelItemCount() > 0) {
88 ui->pushButtonBatchQosUpdate->setEnabled(
true);
89 ui->pushButtonBatchQosConfigure->setEnabled(
true);
94 messageBox.critical(
nullptr,
"Error",
"Could not load any connections! \n Please check the file format.");
100void BatchQosConfDialog::updateQos()
102 for(
int i=0; i < ui->treeWidgetCons->topLevelItemCount(); ++i ){
103 QTreeWidgetItem *
item = ui->treeWidgetCons->topLevelItem(i);
109 switch(
fromStyle.getPacketPriorityAsLevel()) {
111 b.setColor(Qt::black);
115 b.setColor(
QColor(255,215,0));
119 b.setColor(
QColor(255,140,0));
127 b.setColor(Qt::black);
131 b.setColor(Qt::black);
134 item->setForeground( 0 , b);
136 qosStr +=
", " + QString::number(
fromStyle.getThreadPolicy()) +
", " + QString::number(
fromStyle.getThreadPriority());
140 qosStr +=
", " + QString::number(
toStyle.getThreadPolicy()) +
", " + QString::number(
toStyle.getThreadPriority());
143 yWarning() <<
"Cannot retrieve Qos property of" <<
item->text(0).toUtf8().constData() <<
"->" <<
item->text(0).toUtf8().constData();
146 ui->treeWidgetCons->update();
149void BatchQosConfDialog::configureQos() {
153 if (
dialog.exec() != QDialog::Accepted) {
157 for(
int i=0; i < ui->treeWidgetCons->topLevelItemCount(); ++i ){
158 QTreeWidgetItem *
item = ui->treeWidgetCons->topLevelItem(i);
159 std::string from =
item->text(1).toUtf8().constData();
160 std::string to =
item->text(2).toUtf8().constData();
162 yWarning()<<
"Cannot set Qos property of connection"<<from<<
"->"<<to;
int SIGNAL(int pid, int signum)
BatchQosConfDialog(QWidget *parent=0)
A simple collection of objects that can be described and transmitted in a portable way.
A mini-server for performing network communication in the background.
void close() override
Stop port activity.
static bool getConnectionQos(const std::string &src, const std::string &dest, QosStyle &srcStyle, QosStyle &destStyle, bool quiet=true)
Gets the Qos preferences of a connection.
static bool setConnectionQos(const std::string &src, const std::string &dest, const QosStyle &srcStyle, const QosStyle &destStyle, bool quiet=true)
Adjust the Qos preferences of a connection.
Preferences for the port's Quality of Service.
static std::string packetPrioToString(yarp::os::QosStyle::PacketPriorityLevel level)
An interface to the operating system, including Port based communication.