From 9746a8f6004ba2e589a303c7007dbd4245fd389f Mon Sep 17 00:00:00 2001 From: Justin Hammond Date: Thu, 7 Nov 2019 11:00:29 +0800 Subject: [PATCH] timestamps as SecondsSinceEpoc --- qt-openzwave/include/qt-openzwave/qtozw_pods.h | 4 ++-- qt-openzwave/source/qtozwmanager_p.cpp | 5 +++-- qt-ozwdaemon/mqttpublisher.cpp | 4 ++-- 3 files changed, 7 insertions(+), 6 deletions(-) diff --git a/qt-openzwave/include/qt-openzwave/qtozw_pods.h b/qt-openzwave/include/qt-openzwave/qtozw_pods.h index 7764749..725ffaf 100644 --- a/qt-openzwave/include/qt-openzwave/qtozw_pods.h +++ b/qt-openzwave/include/qt-openzwave/qtozw_pods.h @@ -52,8 +52,8 @@ struct NodeStatistics { quint32 receivedPackets; /**< Number of received Packets from the Node */ quint32 receivedDupPackets; /**< Number of Duplicate Packets received from the Node */ quint32 receivedUnsolicited; /**< Number of Unsolicited Packets received from the Node */ - QString lastSentTimeStamp; /**< TimeStamp of the Last time we sent a packet to the Node */ - QString lastReceivedTimeStamp; /**< Timestamp of the last time we received a packet from the Node */ + QDateTime lastSentTimeStamp; /**< TimeStamp of the Last time we sent a packet to the Node */ + QDateTime lastReceivedTimeStamp; /**< Timestamp of the last time we received a packet from the Node */ quint32 lastRequestRTT; /**< Last Round-Trip Time when we made a request to the Node */ quint32 averageRequestRTT; /**< Average Round-Trip Time when we make requests to a Node */ quint32 lastResponseRTT; /**< Last Round-Trip Time when we got a Response from a Node */ diff --git a/qt-openzwave/source/qtozwmanager_p.cpp b/qt-openzwave/source/qtozwmanager_p.cpp index cd0c894..716ee34 100644 --- a/qt-openzwave/source/qtozwmanager_p.cpp +++ b/qt-openzwave/source/qtozwmanager_p.cpp @@ -494,13 +494,14 @@ NodeStatistics QTOZWManager_Internal::GetNodeStatistics(quint8 const _node) { ns.receivedPackets = nd.m_receivedCnt; ns.lastFailedLinkTo = nd.m_lastFailedLinkTo; ns.averageRequestRTT = nd.m_averageRequestRTT; - ns.lastSentTimeStamp = nd.m_sentTS.c_str(); + /* 2019-11-06 21:11:02:549 */ + ns.lastSentTimeStamp = QDateTime::fromString(nd.m_sentTS.c_str(), "YYYY-MM-DD HH:mm:ss:zzz"); + ns.lastReceivedTimeStamp = QDateTime::fromString(nd.m_receivedTS.c_str(), "YYYY-MM-DD HH:mm:ss:zzz"); ns.averageResponseRTT = nd.m_averageResponseRTT; ns.lastFailedLinkFrom = nd.m_lastFailedLinkFrom; ns.receivedDupPackets = nd.m_receivedDups; ns.extendedTXSupported = nd.m_txStatusReportSupported; ns.receivedUnsolicited = nd.m_receivedUnsolicited; - ns.lastReceivedTimeStamp = nd.m_receivedTS.c_str(); return ns; } catch (OpenZWave::OZWException &e) { emit this->error(QTOZWManagerErrorCodes::OZWException); diff --git a/qt-ozwdaemon/mqttpublisher.cpp b/qt-ozwdaemon/mqttpublisher.cpp index 3b2185d..804c25c 100644 --- a/qt-ozwdaemon/mqttpublisher.cpp +++ b/qt-ozwdaemon/mqttpublisher.cpp @@ -315,8 +315,8 @@ void mqttpublisher::doStats() { nsjson["receivedPackets"] = static_cast(ns.receivedPackets); /**< Number of received Packets from the Node */ nsjson["receivedDupPackets"] = static_cast(ns.receivedDupPackets); /**< Number of Duplicate Packets received from the Node */ nsjson["receivedUnsolicited"] = static_cast(ns.receivedUnsolicited); /**< Number of Unsolicited Packets received from the Node */ - nsjson["lastSentTimeStamp"] = ns.lastSentTimeStamp; /**< TimeStamp of the Last time we sent a packet to the Node */ - nsjson["lastRecievedTimeStamp"] = ns.lastReceivedTimeStamp; /**< Timestamp of the last time we received a packet from the Node */ + nsjson["lastSentTimeStamp"] = ns.lastSentTimeStamp.toSecsSinceEpoch(); /**< TimeStamp of the Last time we sent a packet to the Node */ + nsjson["lastRecievedTimeStamp"] = ns.lastReceivedTimeStamp.toSecsSinceEpoch(); /**< Timestamp of the last time we received a packet from the Node */ nsjson["lastRequestRTT"] = static_cast(ns.lastRequestRTT); /**< Last Round-Trip Time when we made a request to the Node */ nsjson["averageRequestRTT"] = static_cast(ns.averageRequestRTT); /**< Average Round-Trip Time when we make requests to a Node */ nsjson["lastResponseRTT"] = static_cast(ns.lastResponseRTT); /**< Last Round-Trip Time when we got a Response from a Node */