OpalLink.h 1.4 KB
Newer Older
1 2
#ifndef OPALLINK_H
#define OPALLINK_H
Bryan Godbolt's avatar
Bryan Godbolt committed
3 4 5 6 7 8 9 10 11 12 13 14
/**
  Connection to OpalRT.  This class receives MAVLink packets as if it is a true link, but it
  interprets the packets internally, and calls the appropriate api functions.

  \author Bryan Godbolt <godbolt@ualberta.ca>
*/

#include <QMutex>

#include "LinkInterface.h"
#include "LinkManager.h"
#include "MG.h"
15

Bryan Godbolt's avatar
Bryan Godbolt committed
16 17 18
#include "errno.h"
#include "OpalApi.h"

19 20
class OpalLink : public LinkInterface
{
Bryan Godbolt's avatar
Bryan Godbolt committed
21 22 23 24 25 26 27 28 29 30 31 32 33 34
    Q_OBJECT
    /* Connection management */

    int getId();
    QString getName();
    bool isConnected();

    /* Connection characteristics */


    qint64 getNominalDataRate();
    bool isFullDuplex();
    int getLinkQuality();
    qint64 getTotalUpstream();
35
    qint64 getTotalDownstream();
Bryan Godbolt's avatar
Bryan Godbolt committed
36 37 38 39 40 41
    qint64 getCurrentUpstream();
    qint64 getMaxUpstream();
    qint64 getBitsSent();
    qint64 getBitsReceived();


Bryan Godbolt's avatar
Bryan Godbolt committed
42
    bool connect();
Bryan Godbolt's avatar
Bryan Godbolt committed
43 44


Bryan Godbolt's avatar
Bryan Godbolt committed
45
    bool disconnect();
Bryan Godbolt's avatar
Bryan Godbolt committed
46 47


Bryan Godbolt's avatar
Bryan Godbolt committed
48
    qint64 bytesAvailable();
Bryan Godbolt's avatar
Bryan Godbolt committed
49 50 51 52

public slots:


Bryan Godbolt's avatar
Bryan Godbolt committed
53
    void writeBytes(const char *bytes, qint64 length);
Bryan Godbolt's avatar
Bryan Godbolt committed
54 55


Bryan Godbolt's avatar
Bryan Godbolt committed
56
    void readBytes(char *bytes, qint64 maxLength);
Bryan Godbolt's avatar
Bryan Godbolt committed
57 58


59 60
public:
    OpalLink();
Bryan Godbolt's avatar
Bryan Godbolt committed
61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77

protected:
    QString name;
    int id;
    bool connectState;

    quint64 bitsSentTotal;
    quint64 bitsSentCurrent;
    quint64 bitsSentMax;
    quint64 bitsReceivedTotal;
    quint64 bitsReceivedCurrent;
    quint64 bitsReceivedMax;
    quint64 connectionStartTime;

    QMutex statisticsMutex;

    void setName(QString name);
78 79 80
};

#endif // OPALLINK_H