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; 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 %}