ProtocolInterface.h 2.37 KB
Newer Older
1 2 3 4 5 6 7 8
/****************************************************************************
 *
 *   (c) 2009-2016 QGROUNDCONTROL PROJECT <http://www.qgroundcontrol.org>
 *
 * QGroundControl is licensed according to the terms in the file
 * COPYING.md in the root of the source code directory.
 *
 ****************************************************************************/
lm's avatar
lm committed
9 10


pixhawk's avatar
pixhawk committed
11 12 13 14 15 16 17 18 19 20 21 22 23
/**
 * @file
 *   @brief Interface class for protocols
 *
 *   @author Lorenz Meier <mavteam@student.ethz.ch>
 *
 */

#ifndef _PROTOCOLINTERFACE_H_
#define _PROTOCOLINTERFACE_H_

#include <QThread>
#include <QString>
24
#include <QByteArray>
pixhawk's avatar
pixhawk committed
25 26 27 28 29 30 31
#include "LinkInterface.h"

/**
 * @brief Interface for all protocols.
 *
 * This class defines the interface for
 * communication packets transported by the LinkManager.
32
 *
pixhawk's avatar
pixhawk committed
33
 * @see LinkManager.
34
 *
pixhawk's avatar
pixhawk committed
35
 **/
Lorenz Meier's avatar
Lorenz Meier committed
36
class ProtocolInterface : public QThread
pixhawk's avatar
pixhawk committed
37
{
lm's avatar
lm committed
38
    Q_OBJECT
pixhawk's avatar
pixhawk committed
39
public:
40
    virtual ~ProtocolInterface () {}
lm's avatar
lm committed
41
    virtual QString getName() = 0;
42 43 44 45 46
    /**
     * Retrieve a total of all successfully parsed packets for the specified link.
     * @param link The link to return metadata about.
     * @returns -1 if this is not available for this protocol, # of packets otherwise.
     */
47
    virtual qint32 getReceivedPacketCount(const LinkInterface *link) const = 0;
48 49 50 51 52
    /**
     * Retrieve a total of all parsing errors for the specified link.
     * @param link The link to return metadata about.
     * @returns -1 if this is not available for this protocol, # of errors otherwise.
     */
53
    virtual qint32 getParsingErrorCount(const LinkInterface *link) const = 0;
54 55 56 57 58
    /**
     * Retrieve a total of all dropped packets for the specified link.
     * @param link The link to return metadata about.
     * @returns -1 if this is not available for this protocol, # of packets otherwise.
     */
59 60 61 62 63 64 65
    virtual qint32 getDroppedPacketCount(const LinkInterface *link) const = 0;
    /**
     * Reset the received, error, and dropped counts for the given link. Useful for
     * when reconnecting a link.
     * @param link The link to reset metadata for.
     */
    virtual void resetMetadataForLink(const LinkInterface *link) = 0;
lm's avatar
lm committed
66

pixhawk's avatar
pixhawk committed
67
public slots:
68
    virtual void receiveBytes(LinkInterface *link, QByteArray b) = 0;
69
    virtual void linkStatusChanged(bool connected) = 0;
lm's avatar
lm committed
70 71

signals:
pixhawk's avatar
pixhawk committed
72 73
    /** @brief Update the packet loss from one system */
    void receiveLossChanged(int uasId, float loss);
lm's avatar
lm committed
74

pixhawk's avatar
pixhawk committed
75 76 77
};

#endif // _PROTOCOLINTERFACE_H_