Commit 914f512f authored by Don Gagne's avatar Don Gagne Committed by GitHub

Merge pull request #3953 from DonLakeFlyer/RemoveStatusDetails

Remove Status Details widget
parents 2959a3a3 cae4903d
......@@ -245,7 +245,6 @@ FORMS += \
src/ui/QGCUASFileViewMulti.ui \
src/ui/uas/UASQuickView.ui \
src/ui/uas/UASQuickViewItemSelect.ui \
src/ui/UASInfo.ui \
}
HEADERS += \
......@@ -379,7 +378,6 @@ HEADERS += \
src/ui/QGCTabbedInfoView.h \
src/ui/QGCUASFileView.h \
src/ui/QGCUASFileViewMulti.h \
src/ui/uas/UASInfoWidget.h \
src/ui/uas/UASQuickView.h \
src/ui/uas/UASQuickViewGaugeItem.h \
src/ui/uas/UASQuickViewItem.h \
......@@ -525,7 +523,6 @@ SOURCES += \
src/ui/QGCTabbedInfoView.cpp \
src/ui/QGCUASFileView.cc \
src/ui/QGCUASFileViewMulti.cc \
src/ui/uas/UASInfoWidget.cc \
src/ui/uas/UASQuickView.cc \
src/ui/uas/UASQuickViewGaugeItem.cc \
src/ui/uas/UASQuickViewItem.cc \
......
......@@ -50,7 +50,6 @@
#include "QGCTabbedInfoView.h"
#include "CustomCommandWidget.h"
#include "QGCDockWidget.h"
#include "UASInfoWidget.h"
#include "HILDockWidget.h"
#include "LogDownload.h"
#include "AppMessages.h"
......@@ -72,7 +71,6 @@ enum DockWidgetTypes {
MAVLINK_INSPECTOR,
CUSTOM_COMMAND,
ONBOARD_FILES,
STATUS_DETAILS,
INFO_VIEW,
HIL_CONFIG,
ANALYZE,
......@@ -83,7 +81,6 @@ static const char *rgDockWidgetNames[] = {
"MAVLink Inspector",
"Custom Command",
"Onboard Files",
"Status Details",
"Info View",
"HIL Config",
"Analyze",
......@@ -358,9 +355,6 @@ bool MainWindow::_createInnerDockWidget(const QString& widgetName)
case LOG_DOWNLOAD:
widget = new LogDownload(widgetName, action, this);
break;
case STATUS_DETAILS:
widget = new UASInfoWidget(widgetName, action, this);
break;
case HIL_CONFIG:
widget = new HILDockWidget(widgetName, action, this);
break;
......
This diff is collapsed.
/****************************************************************************
*
* (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.
*
****************************************************************************/
/**
* @file
* @brief Implementation of class UASInfoWidget
*
* @author Lorenz Meier <mavteam@student.ethz.ch>
*
*/
#include <QtGlobal>
#include <QTimer>
#include <QDir>
#include <QDebug>
#include <float.h>
#include <cstdlib>
#include <cmath>
#include "UASInfoWidget.h"
#include "MultiVehicleManager.h"
#include "QGC.h"
#include "UAS.h"
#include "QGCApplication.h"
UASInfoWidget::UASInfoWidget(const QString& title, QAction* action, QWidget *parent, QString name)
: QGCDockWidget(title, action, parent)
, _activeUAS(NULL)
, _seqLossPercent(0)
, _seqLossTotal(0)
{
ui.setupUi(this);
this->name = name;
connect(qgcApp()->toolbox()->multiVehicleManager(), &MultiVehicleManager::activeVehicleChanged, this, &UASInfoWidget::_activeVehicleChanged);
_activeVehicleChanged(qgcApp()->toolbox()->multiVehicleManager()->activeVehicle());
startTime = QGC::groundTimeMilliseconds();
// Set default values
/** Set two voltage decimals and zero charge level decimals **/
this->voltageDecimals = 2;
this->loadDecimals = 2;
this->voltage = 0;
this->chargeLevel = 0;
this->load = 0;
receiveLoss = 0;
sendLoss = 0;
changed = true;
errors = QMap<QString, int>();
updateTimer = new QTimer(this);
connect(updateTimer, &QTimer::timeout, this, &UASInfoWidget::refresh);
updateTimer->start(updateInterval);
this->setVisible(false);
loadSettings();
connect(qgcApp()->toolbox()->mavlinkProtocol(), &MAVLinkProtocol::receiveLossPercentChanged, this, &UASInfoWidget::updateSeqLossPercent);
connect(qgcApp()->toolbox()->mavlinkProtocol(), &MAVLinkProtocol::receiveLossTotalChanged, this, &UASInfoWidget::updateSeqLossTotal);
}
UASInfoWidget::~UASInfoWidget()
{
}
void UASInfoWidget::showEvent(QShowEvent* event)
{
// React only to internal (pre-display)
// events
Q_UNUSED(event);
updateTimer->start(updateInterval);
}
void UASInfoWidget::hideEvent(QHideEvent* event)
{
// React only to internal (pre-display)
// events
Q_UNUSED(event);
updateTimer->stop();
}
void UASInfoWidget::_activeVehicleChanged(Vehicle* vehicle)
{
if (_activeUAS) {
disconnect(_activeUAS, &UASInterface::batteryChanged, this, &UASInfoWidget::updateBattery);
disconnect(_activeUAS, &UASInterface::dropRateChanged, this, &UASInfoWidget::updateReceiveLoss);
disconnect(static_cast<UAS*>(_activeUAS), &UAS::loadChanged, this, &UASInfoWidget::updateCPULoad);
disconnect(_activeUAS, &UASInterface::errCountChanged, this, &UASInfoWidget::updateErrorCount);
_activeUAS = NULL;
}
if (vehicle) {
_activeUAS = vehicle->uas();
connect(_activeUAS, &UASInterface::batteryChanged, this, &UASInfoWidget::updateBattery);
connect(_activeUAS, &UASInterface::dropRateChanged, this, &UASInfoWidget::updateReceiveLoss);
connect(static_cast<UAS*>(_activeUAS), &UAS::loadChanged, this, &UASInfoWidget::updateCPULoad);
connect(_activeUAS, &UASInterface::errCountChanged, this, &UASInfoWidget::updateErrorCount);
}
}
void UASInfoWidget::updateBattery(UASInterface* uas, double voltage, double current, double percent, int seconds)
{
Q_UNUSED(current)
setVoltage(uas, voltage);
setChargeLevel(uas, percent);
setTimeRemaining(uas, seconds);
}
void UASInfoWidget::updateErrorCount(int uasid, QString component, QString device, int count)
{
//qDebug() << __FILE__ << __LINE__ << _activeUAS->getUASID() << "=" << uasid;
if (_activeUAS->getUASID() == uasid) {
errors.remove(component + ":" + device);
errors.insert(component + ":" + device, count);
}
}
/**
*
*/
void UASInfoWidget::updateCPULoad(UASInterface* uas, double load)
{
if (_activeUAS == uas) {
this->load = load;
}
}
void UASInfoWidget::updateReceiveLoss(int uasId, float receiveLoss)
{
Q_UNUSED(uasId);
this->receiveLoss = this->receiveLoss * 0.8f + receiveLoss * 0.2f;
}
void UASInfoWidget::updateSeqLossPercent(int uasId, float seqLossPercent)
{
if (_activeUAS && _activeUAS->getUASID() == uasId) {
_seqLossPercent = _seqLossPercent * 0.8f + seqLossPercent * 0.2f;
} else {
_seqLossPercent = 0;
}
}
void UASInfoWidget::updateSeqLossTotal(int uasId, int seqLossTotal)
{
if (_activeUAS && _activeUAS->getUASID() == uasId) {
_seqLossTotal = seqLossTotal;
} else {
_seqLossTotal = 0;
}
}
/**
The send loss is typically calculated on the GCS based on packets
that were received scrambled from the MAV
*/
void UASInfoWidget::updateSendLoss(int uasId, float sendLoss)
{
Q_UNUSED(uasId);
this->sendLoss = this->sendLoss * 0.8f + sendLoss * 0.2f;
}
void UASInfoWidget::setVoltage(UASInterface* uas, double voltage)
{
Q_UNUSED(uas);
this->voltage = voltage;
}
void UASInfoWidget::setChargeLevel(UASInterface* uas, double chargeLevel)
{
if (_activeUAS == uas) {
this->chargeLevel = chargeLevel;
}
}
void UASInfoWidget::setTimeRemaining(UASInterface* uas, double seconds)
{
if (_activeUAS == uas) {
this->timeRemaining = seconds;
}
}
void UASInfoWidget::refresh()
{
ui.voltageLabel->setText(QString::number(this->voltage, 'f', voltageDecimals));
ui.batteryBar->setValue(qMax(0,qMin(static_cast<int>(this->chargeLevel), 100)));
ui.loadLabel->setText(QString::number(this->load, 'f', loadDecimals));
ui.loadBar->setValue(qMax(0, qMin(static_cast<int>(this->load), 100)));
ui.receiveLossBar->setValue(qMax(0, qMin(static_cast<int>(receiveLoss), 100)));
ui.receiveLossLabel->setText(QString::number(receiveLoss, 'f', 2));
ui.seqLossBar->setValue(qMax(0, qMin(static_cast<int>(_seqLossPercent), 100)));
ui.seqLossLabel->setText(QString::number(_seqLossPercent, 'f', 2));
ui.seqcntLossLabel->setText(QString::number(_seqLossTotal));
ui.sendLossBar->setValue(sendLoss);
ui.sendLossLabel->setText(QString::number(sendLoss, 'f', 2));
ui.label_5->setText(QString::number(this->load, 'f', loadDecimals));
ui.progressBar->setValue(qMax(0, qMin(static_cast<int>(this->load), 100)));
QString errorString;
QMapIterator<QString, int> i(errors);
while (i.hasNext()) {
i.next();
errorString += QString(i.key() + ": %1 ").arg(i.value());
// FIXME
errorString.replace("IMU:", "");
}
ui.errorLabel->setText(errorString);
}
/****************************************************************************
*
* (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.
*
****************************************************************************/
/**
* @file
* @brief Detail information of one MAV
*
* @author Lorenz Meier <mavteam@student.ethz.ch>
*
*/
#ifndef _UASINFOWIDGET_H_
#define _UASINFOWIDGET_H_
#include <QTimer>
#include <QMap>
#include "QGCDockWidget.h"
#include "UASInterface.h"
#include "ui_UASInfo.h"
#include "Vehicle.h"
/**
* @brief Info indicator for the currently active UAS
*
**/
class UASInfoWidget : public QGCDockWidget
{
Q_OBJECT
public:
UASInfoWidget(const QString& title, QAction* action, QWidget *parent = 0, QString name = "");
~UASInfoWidget();
public slots:
void updateBattery(UASInterface* uas, double voltage, double current, double percent, int seconds);
void updateCPULoad(UASInterface* uas, double load);
/**
* @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.
*/
void updateReceiveLoss(int uasId, float receiveLoss);
void updateSeqLossPercent(int uasId, float seqLoss);
void updateSeqLossTotal(int uasId, int seqLossTotal);
/**
* @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.
*/
void updateSendLoss(int uasId, float sendLoss);
/** @brief Update the error count */
void updateErrorCount(int uasid, QString component, QString device, int count);
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;
float receiveLoss;
float sendLoss;
bool changed;
QTimer* updateTimer;
QString name;
quint64 startTime;
QMap<QString, int> errors;
static const int updateInterval = 800; ///< Refresh interval in milliseconds
void showEvent(QShowEvent* event);
void hideEvent(QHideEvent* event);
private slots:
void _activeVehicleChanged(Vehicle* vehicle);
private:
Ui::uasInfo ui;
UASInterface* _activeUAS;
float _seqLossPercent;
int _seqLossTotal;
};
#endif // _UASINFOWIDGET_H_
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment