Corretta gestione Heartbeat

This commit is contained in:
2019-11-05 16:47:55 +01:00
parent 64a4b9b122
commit bf368d6ac6
6 changed files with 22 additions and 12 deletions

View File

@@ -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());