QGCUASParamManager.h 2.82 KB
Newer Older
1 2 3 4 5 6
#ifndef QGCUASPARAMMANAGER_H
#define QGCUASPARAMMANAGER_H

#include <QWidget>
#include <QMap>
#include <QTimer>
7
#include <QVariant>
8 9 10 11 12 13 14 15 16

class UASInterface;

class QGCUASParamManager : public QWidget
{
    Q_OBJECT
public:
    QGCUASParamManager(UASInterface* uas, QWidget *parent = 0);

17 18 19
    QList<QString> getParameterNames(int component) const {
        return parameters.value(component)->keys();
    }
20
    QList<QVariant> getParameterValues(int component) const {
21 22
        return parameters.value(component)->values();
    }
23
    QVariant getParameterValue(int component, const QString& parameter) const {
24 25
        return parameters.value(component)->value(parameter);
    }
26

LM's avatar
LM committed
27 28 29 30 31 32 33
    virtual bool isParamMinKnown(const QString& param) = 0;
    virtual bool isParamMaxKnown(const QString& param) = 0;
    virtual bool isParamDefaultKnown(const QString& param) = 0;
    virtual double getParamMin(const QString& param) = 0;
    virtual double getParamMax(const QString& param) = 0;
    virtual double getParamDefault(const QString& param) = 0;

34 35 36
    /** @brief Request an update for the parameter list */
    void requestParameterListUpdate(int component = 0);
    /** @brief Request an update for this specific parameter */
37
    virtual void requestParameterUpdate(int component, const QString& parameter) = 0;
38

39
signals:
40 41
    void parameterChanged(int component, QString parameter, QVariant value);
    void parameterChanged(int component, int parameterIndex, QVariant value);
42 43 44
    void parameterListUpToDate(int component);

public slots:
45
    /** @brief Write one parameter to the MAV */
46
    virtual void setParameter(int component, QString parameterName, QVariant value) = 0;
47 48
    /** @brief Request list of parameters from MAV */
    virtual void requestParameterList() = 0;
49 50 51

protected:
    UASInterface* mav;   ///< The MAV this widget is controlling
52 53
    QMap<int, QMap<QString, QVariant>* > changedValues; ///< Changed values
    QMap<int, QMap<QString, QVariant>* > parameters; ///< All parameters
54 55
    QVector<bool> received; ///< Successfully received parameters
    QMap<int, QList<int>* > transmissionMissingPackets; ///< Missing packets
56
    QMap<int, QMap<QString, QVariant>* > transmissionMissingWriteAckPackets; ///< Missing write ACK packets
57 58 59 60 61 62 63 64 65 66 67 68
    bool transmissionListMode;       ///< Currently requesting list
    QMap<int, bool> transmissionListSizeKnown;  ///< List size initialized?
    bool transmissionActive;         ///< Missing packets, working on list?
    quint64 transmissionTimeout;     ///< Timeout
    QTimer retransmissionTimer;      ///< Timer handling parameter retransmission
    int retransmissionTimeout; ///< Retransmission request timeout, in milliseconds
    int rewriteTimeout; ///< Write request timeout, in milliseconds
    int retransmissionBurstRequestSize; ///< Number of packets requested for retransmission per burst

};

#endif // QGCUASPARAMMANAGER_H