From c659aee65867d2728c843770d864fa9d0a9f041b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Patrick=20Jos=C3=A9=20Pereira?= Date: Sun, 29 Jul 2018 11:31:50 -0300 Subject: [PATCH 1/2] pingmessage: Add function_map variable MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This new variable will help us to create a better log from all function return the function name and the value on it. Right now this variable can't return pointer types. Signed-off-by: Patrick José Pereira --- src/protocol/templates/pingmessage.h.in | 5 +++++ src/protocol/templates/pingmessage_.h.in | 16 ++++++++++++++++ 2 files changed, 21 insertions(+) diff --git a/src/protocol/templates/pingmessage.h.in b/src/protocol/templates/pingmessage.h.in index 361e24a2..c7a78436 100644 --- a/src/protocol/templates/pingmessage.h.in +++ b/src/protocol/templates/pingmessage.h.in @@ -7,7 +7,9 @@ /// script found in this directory #ifdef QT_CORE_LIB +#include #include +#include #endif {% for message_type in messages %} @@ -62,6 +64,9 @@ public: protected: uint16_t _bufferLength; +#ifdef QT_CORE_LIB + const QMap > function_map; +#endif public: uint8_t* msgData; diff --git a/src/protocol/templates/pingmessage_.h.in b/src/protocol/templates/pingmessage_.h.in index 272d4795..c4b7bb2b 100644 --- a/src/protocol/templates/pingmessage_.h.in +++ b/src/protocol/templates/pingmessage_.h.in @@ -5,6 +5,12 @@ #include "pingmessage.h" +#ifdef QT_CORE_LIB +#include +#include +#include + +#endif {% set message_type = _actual_message_type %} {% for message in messages[message_type] %} {% set total_payload = calc_payload(messages[message_type][message].payload) %} @@ -24,6 +30,16 @@ public: msgData[7] = 0; } +#ifdef QT_CORE_LIB + const QMap > function_map { +{% for payload in messages[message_type][message].payload %} +{% if not is_vector(payload.type) %} + {"{{payload.name}}", [this]()->float{return this->{{payload.name}}();}}, +{% endif %} +{% endfor %} + }; +#endif + {% set byte = namespace(offset=0, func='') %} {% if messages[message_type][message].payload %} {% for payload in messages[message_type][message].payload %} From 991a70c77b027292db32d912d0cee9f93b1404f5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Patrick=20Jos=C3=A9=20Pereira?= Date: Sun, 29 Jul 2018 21:19:44 -0300 Subject: [PATCH 2/2] FileLink: Add getPackages function MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Patrick José Pereira --- src/link/filelink.cpp | 26 ++++++++++++++++++++++++++ src/link/filelink.h | 2 +- 2 files changed, 27 insertions(+), 1 deletion(-) diff --git a/src/link/filelink.cpp b/src/link/filelink.cpp index 9b8a0b9d..b5ecb218 100644 --- a/src/link/filelink.cpp +++ b/src/link/filelink.cpp @@ -96,6 +96,32 @@ bool FileLink::startConnection() { return ok; }; +QList FileLink::getPackages() +{ + bool ok = _file.open(QIODevice::ReadOnly); + if(!ok || _openModeFlag != QIODevice::ReadOnly) { + qCCritical(PING_PROTOCOL_FILELINK) << "It's not possible to get packages!"; + qCDebug(PING_PROTOCOL_FILELINK) << "Ok:" << ok; + qCDebug(PING_PROTOCOL_FILELINK) << "ReadWrite:" << ok; + return QList(); + } + + Pack pack; + QList output; + while(true) { + // Get data + _inout >> pack.time >> pack.data; + + // Check if we have a new package + if(pack.time.isEmpty()) { + qCDebug(PING_PROTOCOL_FILELINK) << "No more packages !"; + break; + } + output.append(pack.data); + } + return output; +} + bool FileLink::finishConnection() { _file.close(); diff --git a/src/link/filelink.h b/src/link/filelink.h index ff88dca2..b5921ed2 100644 --- a/src/link/filelink.h +++ b/src/link/filelink.h @@ -28,7 +28,7 @@ class FileLink : public AbstractLink void setPackageIndex(int index) { if(_logThread) _logThread->setPackageIndex(index); } QTime totalTime() final { return _logThread ? _logThread->totalTime() : QTime(); }; QTime elapsedTime() final { return _logThread ? _logThread->elapsedTime() : QTime(); }; - + QList getPackages(); private: struct Pack { QString time;