2016-10-31 22:59:08 +01:00
|
|
|
#ifndef FITPARSER_H
|
|
|
|
#define FITPARSER_H
|
|
|
|
|
|
|
|
#include "parser.h"
|
|
|
|
|
|
|
|
class FITParser : public Parser
|
|
|
|
{
|
|
|
|
public:
|
2017-07-27 19:47:46 +02:00
|
|
|
FITParser();
|
2016-10-31 22:59:08 +01:00
|
|
|
|
2017-07-27 19:47:46 +02:00
|
|
|
bool parse(QFile *file, QList<TrackData> &tracks, QList<RouteData> &routes,
|
|
|
|
QList<Waypoint> &waypoints);
|
2016-10-31 22:59:08 +01:00
|
|
|
QString errorString() const {return _errorString;}
|
|
|
|
int errorLine() const {return 0;}
|
|
|
|
|
|
|
|
private:
|
2017-08-10 08:58:21 +02:00
|
|
|
struct FileHeader {
|
2016-11-03 07:37:17 +01:00
|
|
|
quint8 headerSize;
|
|
|
|
quint8 protocolVersion;
|
|
|
|
quint16 profileVersion;
|
|
|
|
quint32 dataSize;
|
2016-10-31 22:59:08 +01:00
|
|
|
quint32 magic;
|
2017-08-10 08:58:21 +02:00
|
|
|
};
|
2016-10-31 22:59:08 +01:00
|
|
|
|
2017-08-10 08:58:21 +02:00
|
|
|
struct Field {
|
2016-10-31 22:59:08 +01:00
|
|
|
quint8 id;
|
|
|
|
quint8 size;
|
|
|
|
quint8 type;
|
2017-08-10 08:58:21 +02:00
|
|
|
};
|
2016-10-31 22:59:08 +01:00
|
|
|
|
2017-08-10 08:58:21 +02:00
|
|
|
struct MessageDefinition {
|
2016-10-31 22:59:08 +01:00
|
|
|
quint8 endian;
|
2016-11-03 07:37:17 +01:00
|
|
|
quint16 globalId;
|
|
|
|
quint8 numFields;
|
2016-10-31 22:59:08 +01:00
|
|
|
Field *fields;
|
2016-11-03 08:02:28 +01:00
|
|
|
quint8 numDevFields;
|
|
|
|
Field *devFields;
|
2017-08-10 08:58:21 +02:00
|
|
|
};
|
2016-10-31 22:59:08 +01:00
|
|
|
|
|
|
|
|
2016-11-02 17:33:54 +01:00
|
|
|
void warning(const char *text) const;
|
|
|
|
void clearDefinitions();
|
|
|
|
|
2016-10-31 22:59:08 +01:00
|
|
|
bool readData(char *data, size_t size);
|
|
|
|
template<class T> bool readValue(T &val);
|
|
|
|
bool skipValue(size_t size);
|
|
|
|
|
|
|
|
bool parseHeader();
|
2017-07-27 19:47:46 +02:00
|
|
|
bool parseRecord(TrackData &track);
|
2016-10-31 22:59:08 +01:00
|
|
|
bool parseDefinitionMessage(quint8 header);
|
2017-07-27 19:47:46 +02:00
|
|
|
bool parseCompressedMessage(TrackData &track, quint8 header);
|
|
|
|
bool parseDataMessage(TrackData &track, quint8 header);
|
|
|
|
bool parseData(TrackData &track, MessageDefinition *def, quint8 offset);
|
2016-10-31 22:59:08 +01:00
|
|
|
bool readField(Field *f, quint32 &val);
|
|
|
|
|
|
|
|
QIODevice *_device;
|
|
|
|
QString _errorString;
|
|
|
|
|
|
|
|
quint32 _len;
|
|
|
|
quint8 _endian;
|
|
|
|
quint32 _timestamp;
|
|
|
|
MessageDefinition _defs[16];
|
|
|
|
};
|
|
|
|
|
|
|
|
#endif // FITPARSER_H
|