MAVLinkDecoder.h 1.73 KB
Newer Older
lm's avatar
lm committed
1 2 3 4 5 6
#ifndef MAVLINKDECODER_H
#define MAVLINKDECODER_H

#include <QObject>
#include "MAVLinkProtocol.h"

7
class MAVLinkDecoder : public QThread
lm's avatar
lm committed
8 9 10 11 12
{
    Q_OBJECT
public:
    MAVLinkDecoder(MAVLinkProtocol* protocol, QObject *parent = 0);

13 14
    void run();

lm's avatar
lm committed
15 16
signals:
    void textMessageReceived(int uasid, int componentid, int severity, const QString& text);
17
    void valueChanged(const int uasId, const QString& name, const QString& unit, const QVariant& value, const quint64 msec);
lm's avatar
lm committed
18 19 20 21 22 23 24

public slots:
    /** @brief Receive one message from the protocol and decode it */
    void receiveMessage(LinkInterface* link,mavlink_message_t message);
protected:
    /** @brief Emit the value of one message field */
    void emitFieldValue(mavlink_message_t* msg, int fieldid, quint64 time);
pixhawk's avatar
pixhawk committed
25 26
    /** @brief Shift a timestamp in Unix time if necessary */
    quint64 getUnixTimeFromMs(int systemID, quint64 time);
lm's avatar
lm committed
27

28 29 30 31 32 33 34 35 36 37
    static const size_t cMessageIds = 256;

    mavlink_message_t receivedMessages[cMessageIds];        ///< Available / known messages
    QMap<uint16_t, bool> messageFilter;                     ///< Message/field names not to emit
    QMap<uint16_t, bool> textMessageFilter;                 ///< Message/field names not to emit in text mode
    int componentID[cMessageIds];                           ///< Multi component detection
    bool componentMulti[cMessageIds];                       ///< Multi components detected
    quint64 onboardTimeOffset[cMessageIds];                 ///< Offset of onboard time from Unix epoch (of the receiving GCS)
    qint64 onboardToGCSUnixTimeOffsetAndDelay[cMessageIds]; ///< Offset of onboard time and GCS Unix time
    quint64 firstOnboardTime[cMessageIds];                  ///< First seen onboard time
lm's avatar
lm committed
38 39 40
};

#endif // MAVLINKDECODER_H