UASInfoWidget.h 2.76 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.
 *
 ****************************************************************************/
9

10

pixhawk's avatar
pixhawk committed
11 12 13 14 15 16 17 18 19 20 21 22 23 24
/**
 * @file
 *   @brief Detail information of one MAV
 *
 *   @author Lorenz Meier <mavteam@student.ethz.ch>
 *
 */

#ifndef _UASINFOWIDGET_H_
#define _UASINFOWIDGET_H_

#include <QTimer>
#include <QMap>

25
#include "QGCDockWidget.h"
pixhawk's avatar
pixhawk committed
26 27
#include "UASInterface.h"
#include "ui_UASInfo.h"
28
#include "Vehicle.h"
pixhawk's avatar
pixhawk committed
29 30 31 32 33

/**
 * @brief Info indicator for the currently active UAS
 *
 **/
34
class UASInfoWidget : public QGCDockWidget
35
{
pixhawk's avatar
pixhawk committed
36 37
    Q_OBJECT
public:
38
    UASInfoWidget(const QString& title, QAction* action, QWidget *parent = 0, QString name = "");
pixhawk's avatar
pixhawk committed
39 40 41
    ~UASInfoWidget();

public slots:
dongfang's avatar
dongfang committed
42
    void updateBattery(UASInterface* uas, double voltage, double current, double percent, int seconds);
pixhawk's avatar
pixhawk committed
43
    void updateCPULoad(UASInterface* uas, double load);
44 45 46 47 48
    /**
     * @brief Set the loss rate of packets received by the MAV.
     * @param uasId UNUSED
     * @param receiveLoss A percentage value (0-100) of how many message the UAS has failed to receive.
     */
pixhawk's avatar
pixhawk committed
49
    void updateReceiveLoss(int uasId, float receiveLoss);
50

51 52 53
    void updateSeqLossPercent(int uasId, float seqLoss);
    void updateSeqLossTotal(int uasId, int seqLossTotal);

54 55 56 57 58
    /**
	 * @brief Set the loss rate of packets sent from the MAV 
	 * @param uasId UNUSED
	 * @param sendLoss A percentage value (0-100) of how many message QGC has failed to receive.
	 */
pixhawk's avatar
pixhawk committed
59
    void updateSendLoss(int uasId, float sendLoss);
60
	
61 62
    /** @brief Update the error count */
    void updateErrorCount(int uasid, QString component, QString device, int count);
pixhawk's avatar
pixhawk committed
63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83

    void setVoltage(UASInterface* uas, double voltage);
    void setChargeLevel(UASInterface* uas, double chargeLevel);
    void setTimeRemaining(UASInterface* uas, double seconds);

    void refresh();

protected:


    // Configuration variables
    int voltageDecimals;
    int loadDecimals;

    // State variables

    // Voltage
    double voltage;
    double chargeLevel;
    double timeRemaining;
    double load;
lm's avatar
lm committed
84 85
    float receiveLoss;
    float sendLoss;
86
    bool changed;
pixhawk's avatar
pixhawk committed
87 88 89
    QTimer* updateTimer;
    QString name;
    quint64 startTime;
90
    QMap<QString, int> errors;
91
    static const int updateInterval = 800; ///< Refresh interval in milliseconds
92 93 94

    void showEvent(QShowEvent* event);
    void hideEvent(QHideEvent* event);
95 96 97
    
private slots:
    void _activeVehicleChanged(Vehicle* vehicle);
pixhawk's avatar
pixhawk committed
98 99 100 101

private:
    Ui::uasInfo ui;

102 103 104
    UASInterface*   _activeUAS;
    float           _seqLossPercent;
    int             _seqLossTotal;
pixhawk's avatar
pixhawk committed
105 106 107
};

#endif // _UASINFOWIDGET_H_