From 5c7caa3259ab0827e9415975da52400a2b9ae42f Mon Sep 17 00:00:00 2001 From: Emanuele Date: Fri, 15 Nov 2019 14:49:45 +0100 Subject: [PATCH] Aggiunto nodo broadcaster a interfaccia e shared memory --- RoboGlue.pro.user | 2 +- gui/roboglue_gui.cpp | 6 +++++- shared/roboglue_shared.cpp | 3 +++ shared/roboglue_shared.h | 15 +++++++++------ 4 files changed, 18 insertions(+), 8 deletions(-) diff --git a/RoboGlue.pro.user b/RoboGlue.pro.user index 090363b..0d5c9f7 100644 --- a/RoboGlue.pro.user +++ b/RoboGlue.pro.user @@ -1,6 +1,6 @@ - + EnvironmentId diff --git a/gui/roboglue_gui.cpp b/gui/roboglue_gui.cpp index 514f21f..4c1c6ec 100644 --- a/gui/roboglue_gui.cpp +++ b/gui/roboglue_gui.cpp @@ -95,17 +95,21 @@ void RoboGlue_GUI::on_commonStatusChange() { this->ui->lbl_relay->setText(QString().fromStdString(this->m->comSettings.nodeNames.find("relay")->second+": "+std::to_string(static_cast(m->commonStatus.relayTime)))); this->ui->lbl_follower->setText(QString().fromStdString(this->m->comSettings.nodeNames.find("follower")->second+": "+std::to_string(static_cast(m->commonStatus.followerTime)))); this->ui->lbl_recorder->setText(QString().fromStdString(this->m->comSettings.nodeNames.find("recorder")->second+": "+std::to_string(static_cast(m->commonStatus.recorderTime)))); + this->ui->lbl_broadcaster->setText(QString().fromStdString(this->m->comSettings.nodeNames.find("broadcaster")->second+": "+std::to_string(static_cast(m->commonStatus.broadcasterTime)))); if(m->commonStatus.relayTime > m->comSettings.deadTime || m->commonStatus.followerTime > m->comSettings.deadTime || - m->commonStatus.recorderTime > m->comSettings.deadTime) { + m->commonStatus.recorderTime > m->comSettings.deadTime || + m->commonStatus.broadcasterTime > m->comSettings.deadTime) { this->ui->lbl_relay->setStyleSheet("QLabel { background-color : red; color : white; }"); this->ui->lbl_follower->setStyleSheet("QLabel { background-color : red; color : white; }"); this->ui->lbl_recorder->setStyleSheet("QLabel { background-color : red; color : white; }"); + this->ui->lbl_broadcaster->setStyleSheet("QLabel { background-color : red; color : white; }"); } else { this->ui->lbl_relay->setStyleSheet("QLabel { background-color : green; color : white; }"); this->ui->lbl_follower->setStyleSheet("QLabel { background-color : green; color : white; }"); this->ui->lbl_recorder->setStyleSheet("QLabel { background-color : green; color : white; }"); + this->ui->lbl_broadcaster->setStyleSheet("QLabel { background-color : green; color : white; }"); } } diff --git a/shared/roboglue_shared.cpp b/shared/roboglue_shared.cpp index 14fe524..a0d93ba 100644 --- a/shared/roboglue_shared.cpp +++ b/shared/roboglue_shared.cpp @@ -19,6 +19,7 @@ void RoboGlue_SHARED::on_statusTimer(void){ commonStatus.relayTime = fabs(commonStatus.relayLast - curTime); commonStatus.followerTime = fabs(commonStatus.followerLast - curTime); commonStatus.recorderTime = fabs(commonStatus.recorderLast - curTime); + commonStatus.broadcasterTime = fabs(commonStatus.broadcasterLast - curTime); emit this->commonStatusChange(); } //////////////////////////////////////////////////////////////// @@ -88,6 +89,7 @@ void RoboGlue_SHARED::restoreComSettings() { comSettings.nodeNames["relay"] = settings->value("relay").toString().toStdString(); comSettings.nodeNames["follower"] = settings->value("follower").toString().toStdString(); comSettings.nodeNames["recorder"] = settings->value("recorder").toString().toStdString(); + comSettings.nodeNames["broadcaster"] = settings->value("broadcaster").toString().toStdString(); settings->endGroup(); settings->endGroup(); settings->endGroup(); @@ -153,6 +155,7 @@ void RoboGlue_SHARED::saveComSettings() { settings->setValue("relay", QString().fromStdString(comSettings.nodeNames.find("relay")->second)); settings->setValue("follower", QString().fromStdString(comSettings.nodeNames.find("follower")->second)); settings->setValue("recorder", QString().fromStdString(comSettings.nodeNames.find("recorder")->second)); + settings->setValue("broadcaster", QString().fromStdString(comSettings.nodeNames.find("broadcaster")->second)); settings->endGroup(); settings->endGroup(); settings->endGroup(); diff --git a/shared/roboglue_shared.h b/shared/roboglue_shared.h index cca73e8..e1e86a4 100644 --- a/shared/roboglue_shared.h +++ b/shared/roboglue_shared.h @@ -30,6 +30,7 @@ #include #include #include +#include #include #include #include @@ -56,12 +57,14 @@ public: bool followerRunning = false; bool recorderRunning = false; // ROS node last seen - double relayLast = 0.0; - double followerLast = 0.0; - double recorderLast = 0.0; - double relayTime = 0.0; - double followerTime = 0.0; - double recorderTime = 0.0; + double relayLast = static_cast(time(NULL)); + double followerLast = static_cast(time(NULL)); + double recorderLast = static_cast(time(NULL)); + double broadcasterLast = static_cast(time(NULL)); + double relayTime = static_cast(time(NULL)); + double followerTime = static_cast(time(NULL)); + double recorderTime = static_cast(time(NULL)); + double broadcasterTime = static_cast(time(NULL)); } commonStatus; /////////// PERMANENT SETTINGS VARIABLES /////////