Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 26 additions & 0 deletions src/link/filelink.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,32 @@ bool FileLink::startConnection() {
return ok;
};

QList<QByteArray> 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<QByteArray>();
}

Pack pack;
QList<QByteArray> 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();
Expand Down
2 changes: 1 addition & 1 deletion src/link/filelink.h
Original file line number Diff line number Diff line change
Expand Up @@ -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<QByteArray> getPackages();
private:
struct Pack {
QString time;
Expand Down
5 changes: 5 additions & 0 deletions src/protocol/templates/pingmessage.h.in
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,9 @@
/// script found in this directory

#ifdef QT_CORE_LIB
#include <functional>
#include <QObject>
#include <QMap>

#endif
{% for message_type in messages %}
Expand Down Expand Up @@ -62,6 +64,9 @@ public:

protected:
uint16_t _bufferLength;
#ifdef QT_CORE_LIB
const QMap<QString, std::function<float()> > function_map;
#endif

public:
uint8_t* msgData;
Expand Down
16 changes: 16 additions & 0 deletions src/protocol/templates/pingmessage_.h.in
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,12 @@

#include "pingmessage.h"

#ifdef QT_CORE_LIB
#include <functional>
#include <QMap>
#include <QVariant>

#endif
{% set message_type = _actual_message_type %}
{% for message in messages[message_type] %}
{% set total_payload = calc_payload(messages[message_type][message].payload) %}
Expand All @@ -24,6 +30,16 @@ public:
msgData[7] = 0;
}

#ifdef QT_CORE_LIB
const QMap<QString, std::function<float()> > 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 %}
Expand Down