diff --git a/RoboGlue.pro.user b/RoboGlue.pro.user index 427bf8b..bd5c3ac 100644 --- a/RoboGlue.pro.user +++ b/RoboGlue.pro.user @@ -1,6 +1,6 @@ - + EnvironmentId diff --git a/com/mqtt_callback.cpp b/com/mqtt_callback.cpp index 7a20cab..7b8e0f2 100644 --- a/com/mqtt_callback.cpp +++ b/com/mqtt_callback.cpp @@ -31,17 +31,20 @@ void mqtt_callback::message_arrived(mqtt::const_message_ptr msg) { intMsg[mem_->comSettings.TS]); if (!intMsg[mem_->comSettings.NODE].compare(mem_->comSettings.nodeNames["relay"])){ mem_->commonStatus.relayRunning = true; - mem_->commonStatus.relayLast = fabs(mem_->commonStatus.relayLast - std::stod(intMsg[mem_->comSettings.TS])); + mem_->commonStatus.relayLast = std::stod(intMsg[mem_->comSettings.TS]); + log_->trace("HB RELAY time: [{}]", mem_->commonStatus.relayLast); } else if (!intMsg[mem_->comSettings.NODE].compare(mem_->comSettings.nodeNames["follower"])) { mem_->commonStatus.followerRunning = true; - mem_->commonStatus.followerLast = fabs(mem_->commonStatus.followerLast - std::stod(intMsg[mem_->comSettings.TS])); + mem_->commonStatus.followerLast = std::stod(intMsg[mem_->comSettings.TS]); + log_->trace("HB FOLLOWER time: [{}]", mem_->commonStatus.followerLast); } else if (!intMsg[mem_->comSettings.NODE].compare(mem_->comSettings.nodeNames["recorder"])) { mem_->commonStatus.recorderRunning = true; - mem_->commonStatus.recorderLast = fabs(mem_->commonStatus.recorderLast - std::stod(intMsg[mem_->comSettings.TS])); + mem_->commonStatus.recorderLast = std::stod(intMsg[mem_->comSettings.TS]); + log_->trace("HB RECORDER time: [{}]", mem_->commonStatus.recorderLast); } else { log_->error("Node {} unknown", intMsg[mem_->comSettings.NODE].c_str()); } - emit mem_->commonStatusChange(); + //emit mem_->commonStatusChange(); } } else if (msg->get_topic() == mem_->comSettings.subMap.find("state")->second){ log_->debug("MQTT: State Message: {}", msg->get_payload().c_str()); diff --git a/com/roboglue_com.cpp b/com/roboglue_com.cpp index 4ab4a1e..7b28096 100644 --- a/com/roboglue_com.cpp +++ b/com/roboglue_com.cpp @@ -6,7 +6,7 @@ RoboGlue_COM::RoboGlue_COM (RoboGlue_SHARED *mem): m(mem) { liblog = spdlog::stdout_logger_mt("URcom_liblog"); modlog = spdlog::stdout_logger_mt("RoboGlue_comlog"); liblog->set_level(spdlog::level::warn); - modlog->set_level(spdlog::level::info); + modlog->set_level(spdlog::level::trace); ///////// INITIALIZE TCP SERVER /////////// server = new QTcpServer(this); diff --git a/gui/roboglue_gui.cpp b/gui/roboglue_gui.cpp index 5fa5b15..177a47e 100644 --- a/gui/roboglue_gui.cpp +++ b/gui/roboglue_gui.cpp @@ -92,13 +92,13 @@ void RoboGlue_GUI::disableLockAxes(){ void RoboGlue_GUI::on_commonStatusChange() { modlog->trace("on_commonStatusChange Received"); // TODO: aggiungere e interpretare le flag per capire se i nodi ros sono tutti vivi dall'heartbeat - this->ui->lbl_relay->setText(QString().fromStdString(std::to_string(m->commonStatus.relayLast))); - this->ui->lbl_follower->setText(QString().fromStdString(std::to_string(m->commonStatus.followerLast))); - this->ui->lbl_recorder->setText(QString().fromStdString(std::to_string(m->commonStatus.recorderLast))); + this->ui->lbl_relay->setText(QString().fromStdString(std::to_string(m->commonStatus.relayTime))); + this->ui->lbl_follower->setText(QString().fromStdString(std::to_string(m->commonStatus.followerTime))); + this->ui->lbl_recorder->setText(QString().fromStdString(std::to_string(m->commonStatus.recorderTime))); - if(m->commonStatus.relayLast > m->comSettings.deadTime || - m->commonStatus.followerLast > m->comSettings.deadTime || - m->commonStatus.recorderLast > m->comSettings.deadTime) { + if(m->commonStatus.relayTime > m->comSettings.deadTime || + m->commonStatus.followerTime > m->comSettings.deadTime || + m->commonStatus.recorderTime > 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; }"); diff --git a/shared/roboglue_shared.cpp b/shared/roboglue_shared.cpp index b0e6a10..14fe524 100644 --- a/shared/roboglue_shared.cpp +++ b/shared/roboglue_shared.cpp @@ -15,6 +15,10 @@ RoboGlue_SHARED::~RoboGlue_SHARED(){ } void RoboGlue_SHARED::on_statusTimer(void){ + double curTime = static_cast(std::time(NULL)); + commonStatus.relayTime = fabs(commonStatus.relayLast - curTime); + commonStatus.followerTime = fabs(commonStatus.followerLast - curTime); + commonStatus.recorderTime = fabs(commonStatus.recorderLast - curTime); emit this->commonStatusChange(); } //////////////////////////////////////////////////////////////// diff --git a/shared/roboglue_shared.h b/shared/roboglue_shared.h index 9ca7649..cbaa133 100644 --- a/shared/roboglue_shared.h +++ b/shared/roboglue_shared.h @@ -59,6 +59,9 @@ public: double relayLast = 0.0; double followerLast = 0.0; double recorderLast = 0.0; + double relayTime = 0.0; + double followerTime = 0.0; + double recorderTime = 0.0; } commonStatus; /////////// PERMANENT SETTINGS VARIABLES /////////