forked from mavlink/qgroundcontrol
-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #4 from ethz-asl/feature/sensorpodStatus
Feature/sensorpod status
- Loading branch information
Showing
13 changed files
with
413 additions
and
15 deletions.
There are no files selected for viewing
Submodule v1.0
updated
from 5a8a44 to 8dfbf2
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,102 @@ | ||
#include "sensorpodstatus.h" | ||
#include "ui_sensorpodstatus.h" | ||
#include <qgraphicsscene.h> | ||
#include <QMessageBox> | ||
#include <QTimer> | ||
#include <math.h> | ||
#include <qdebug.h> | ||
#include "../uas/ASLUAV.h" | ||
#include "UASInterface.h" | ||
#include "UASManager.h" | ||
#include "QGCApplication.h" | ||
|
||
#define RESETTIMEMS 10000 | ||
|
||
SensorpodStatus::SensorpodStatus(QWidget *parent) : | ||
QWidget(parent), | ||
ui(new Ui::SensorpodStatus), | ||
m_scene(new QGraphicsScene(this)), | ||
m_UpdateReset(new QTimer (this)) | ||
{ | ||
ui->setupUi(this); | ||
connect(UASManager::instance(), SIGNAL(activeUASSet(UASInterface*)), this, SLOT(setActiveUAS(UASInterface*))); | ||
connect(ui->PowerCycleButton, SIGNAL(clicked()), this, SLOT(PowerCycleSensorpodCmd())); | ||
// connect(qgcApp(), SIGNAL(styleChanged(bool)), this, SLOT(styleChanged(bool))); | ||
m_UpdateReset->setInterval(RESETTIMEMS); | ||
m_UpdateReset->setSingleShot(false); | ||
connect(m_UpdateReset, SIGNAL(timeout()), this, SLOT(UpdateTimerTimeout())); | ||
if (UASManager::instance()->getActiveUAS()) | ||
{ | ||
setActiveUAS(UASManager::instance()->getActiveUAS()); | ||
} | ||
m_UpdateReset->start(); | ||
} | ||
|
||
SensorpodStatus::~SensorpodStatus() | ||
{ | ||
delete ui; | ||
delete m_scene; | ||
delete m_UpdateReset; | ||
} | ||
|
||
void SensorpodStatus::updateSensorpodStatus(uint8_t rate1, uint8_t rate2, uint8_t rate3, uint8_t rate4, uint8_t numRecordTopics, uint8_t cpuTemp, uint16_t freeSpace) | ||
{ | ||
m_UpdateReset->stop(); | ||
ui->topic1rate->setText(QString("%1 Hz").arg(rate1)); | ||
ui->topic2rate->setText(QString("%1 Hz").arg(rate2)); | ||
ui->topic3rate->setText(QString("%1 Hz").arg(rate3)); | ||
ui->topic4rate->setText(QString("%1 Hz").arg(rate4)); | ||
ui->numRecNodes->setText(QString("%1").arg(numRecordTopics)); | ||
ui->cpuTemp->setText(QString("%1 °C").arg(cpuTemp)); | ||
ui->freeDiskSpace->setText(QString("%1 GB").arg(freeSpace/100.0)); | ||
m_UpdateReset->start(RESETTIMEMS); | ||
} | ||
|
||
|
||
//void EnergyBudget::resizeEvent(QResizeEvent *event) | ||
//{ | ||
// QWidget::resizeEvent(event); | ||
// ui->overviewGraphicsView->fitInView(m_scene->sceneRect(), Qt::AspectRatioMode::KeepAspectRatio); | ||
//} | ||
|
||
void SensorpodStatus::setActiveUAS(UASInterface *uas) | ||
{ | ||
//disconnect any previous uas | ||
disconnect(this, SLOT(updateSensorpodStatus(uint8_t, uint8_t, uint8_t, uint8_t, uint8_t, uint8_t, uint16_t))); | ||
|
||
//connect the uas if asluas | ||
ASLUAV *asluas = dynamic_cast<ASLUAV*>(uas); | ||
if (asluas) | ||
{ | ||
connect(asluas, SIGNAL(SensorpodStatusChanged(uint8_t, uint8_t, uint8_t, uint8_t, uint8_t, uint8_t, uint16_t)), this, SLOT(updateSensorpodStatus(uint8_t, uint8_t, uint8_t, uint8_t, uint8_t, uint8_t, uint16_t))); | ||
} | ||
//else set to standard output | ||
else | ||
{ | ||
|
||
} | ||
} | ||
|
||
void SensorpodStatus::PowerCycleSensorpodCmd() | ||
{ | ||
QMessageBox::StandardButton reply; | ||
reply = QMessageBox::question(this, tr("Sensorpod reset"), tr("Sending command to perform power cycle of sensorpod. Use this with caution! Are you sure?"), QMessageBox::Yes | QMessageBox::No); | ||
|
||
if (reply == QMessageBox::Yes) { | ||
//Send the message via the currently active UAS | ||
ASLUAV *tempUAS = (ASLUAV*) UASManager::instance()->getActiveUAS();; | ||
if (tempUAS) tempUAS->SendCommandLongTarget(MAV_CMD_PAYLOAD_CONTROL, (uint8_t) 50, 1.0f); | ||
} | ||
|
||
} | ||
|
||
void SensorpodStatus::UpdateTimerTimeout() | ||
{ | ||
ui->topic1rate->setText(QString("--")); | ||
ui->topic2rate->setText(QString("--")); | ||
ui->topic3rate->setText(QString("--")); | ||
ui->topic4rate->setText(QString("--")); | ||
ui->numRecNodes->setText(QString("--")); | ||
ui->cpuTemp->setText(QString("--")); | ||
ui->freeDiskSpace->setText(QString("--")); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
#ifndef SENSORPODSTATUS_H | ||
#define SENSORPODSTATUS_H | ||
|
||
#include <QObject> | ||
#include <QWidget> | ||
#include <stdint.h> | ||
|
||
namespace Ui { | ||
class SensorpodStatus; | ||
} | ||
|
||
class QGraphicsScene; | ||
class UASInterface; | ||
class QTimer; | ||
class UASInterface; | ||
|
||
class SensorpodStatus : public QWidget | ||
{ | ||
Q_OBJECT | ||
|
||
public: | ||
explicit SensorpodStatus(QWidget *parent = 0); | ||
~SensorpodStatus(); | ||
|
||
protected: | ||
Ui::SensorpodStatus *ui; | ||
QGraphicsScene *m_scene; | ||
QTimer *m_UpdateReset; | ||
|
||
|
||
protected slots: | ||
void updateSensorpodStatus(uint8_t rate1, uint8_t rate2, uint8_t rate3, uint8_t rate4, uint8_t numRecordTopics, uint8_t cpuTemp, uint16_t freeSpace); | ||
void setActiveUAS(UASInterface *uas); | ||
void UpdateTimerTimeout(); | ||
|
||
void PowerCycleSensorpodCmd(); | ||
}; | ||
|
||
#endif // SENSORPODSTATUS_H |
Oops, something went wrong.