Commit 6f367e79 authored by lm's avatar lm

Added persistence to debug console

parent 076e240a
...@@ -177,7 +177,7 @@ trailsVisible[id] = false; ...@@ -177,7 +177,7 @@ trailsVisible[id] = false;
} }
function hideTrail(id) function clearTrail(id)
{ {
trailsVisible[id] = false; trailsVisible[id] = false;
ge.getFeatures().removeChild(trailPlacemarks[id]); ge.getFeatures().removeChild(trailPlacemarks[id]);
...@@ -253,9 +253,9 @@ function setAircraftPositionAttitude(id, lat, lon, alt, roll, pitch, yaw) ...@@ -253,9 +253,9 @@ function setAircraftPositionAttitude(id, lat, lon, alt, roll, pitch, yaw)
// FIXME Currently invalid conversion from right-handed z-down to z-up frame // FIXME Currently invalid conversion from right-handed z-down to z-up frame
planeOrient.setRoll(((roll/M_PI))*180.0+180.0); planeOrient.setRoll(((roll/M_PI))*180.0+180.0);
planeOrient.setTilt(((pitch/M_PI))*180.0+180.0); planeOrient.setTilt(((pitch/M_PI))*180.0+180.0);
planeOrient.setHeading(((yaw/M_PI))*180.0-90.0); planeOrient.setHeading(((yaw/M_PI))*180.0-90.0+180.0);
currFollowHeading = ((yaw/M_PI))*180.0; currFollowHeading = ((yaw/M_PI))*180.0+180.0;
planeLoc.setLatitude(lastLat); planeLoc.setLatitude(lastLat);
planeLoc.setLongitude(lastLon); planeLoc.setLongitude(lastLon);
......
...@@ -23,6 +23,8 @@ This file is part of the QGROUNDCONTROL project ...@@ -23,6 +23,8 @@ This file is part of the QGROUNDCONTROL project
#include "QGC.h" #include "QGC.h"
#include <qmath.h>
namespace QGC { namespace QGC {
quint64 groundTimeUsecs() quint64 groundTimeUsecs()
...@@ -34,6 +36,25 @@ quint64 groundTimeUsecs() ...@@ -34,6 +36,25 @@ quint64 groundTimeUsecs()
return static_cast<quint64>(microseconds + (time.time().msec()*1000)); return static_cast<quint64>(microseconds + (time.time().msec()*1000));
} }
double limitAngleToPMPI(double angle)
{
if (angle < -M_PI)
{
while (angle < -M_PI)
{
angle += M_PI;
}
}
else if (angle > M_PI)
{
while (angle > M_PI)
{
angle -= M_PI;
}
}
return angle;
}
int applicationVersion() int applicationVersion()
{ {
return APPLICATIONVERSION; return APPLICATIONVERSION;
......
...@@ -18,6 +18,8 @@ namespace QGC ...@@ -18,6 +18,8 @@ namespace QGC
/** @brief Get the current ground time in microseconds */ /** @brief Get the current ground time in microseconds */
quint64 groundTimeUsecs(); quint64 groundTimeUsecs();
/** @brief Returns the angle limited to -pi - pi */
double limitAngleToPMPI(double angle);
int applicationVersion(); int applicationVersion();
const static int MAX_FLIGHT_TIME = 60 * 60 * 24 * 21; const static int MAX_FLIGHT_TIME = 60 * 60 * 24 * 21;
......
...@@ -77,10 +77,7 @@ MAVLinkProtocol::~MAVLinkProtocol() ...@@ -77,10 +77,7 @@ MAVLinkProtocol::~MAVLinkProtocol()
void MAVLinkProtocol::run() void MAVLinkProtocol::run()
{ {
forever exec();
{
QGC::SLEEP::msleep(5000);
}
} }
QString MAVLinkProtocol::getLogfileName() QString MAVLinkProtocol::getLogfileName()
......
...@@ -959,6 +959,7 @@ bool MAVLinkSimulationLink::connect() ...@@ -959,6 +959,7 @@ bool MAVLinkSimulationLink::connect()
MAVLinkSimulationMAV* mav1 = new MAVLinkSimulationMAV(this, 1, 47.376, 8.548); MAVLinkSimulationMAV* mav1 = new MAVLinkSimulationMAV(this, 1, 47.376, 8.548);
MAVLinkSimulationMAV* mav2 = new MAVLinkSimulationMAV(this, 2); MAVLinkSimulationMAV* mav2 = new MAVLinkSimulationMAV(this, 2);
Q_UNUSED(mav1); Q_UNUSED(mav1);
Q_UNUSED(mav2);
// timer->start(rate); // timer->start(rate);
return true; return true;
} }
......
...@@ -64,10 +64,11 @@ UDPLink::~UDPLink() ...@@ -64,10 +64,11 @@ UDPLink::~UDPLink()
**/ **/
void UDPLink::run() void UDPLink::run()
{ {
forever // forever
{ // {
QGC::SLEEP::msleep(5000); // QGC::SLEEP::msleep(5000);
} // }
exec();
} }
void UDPLink::setAddress(QString address) void UDPLink::setAddress(QString address)
......
...@@ -385,6 +385,11 @@ void UAS::receiveMessage(LinkInterface* link, mavlink_message_t message) ...@@ -385,6 +385,11 @@ void UAS::receiveMessage(LinkInterface* link, mavlink_message_t message)
roll = attitude.roll; roll = attitude.roll;
pitch = attitude.pitch; pitch = attitude.pitch;
yaw = attitude.yaw; yaw = attitude.yaw;
roll = QGC::limitAngleToPMPI(roll);
pitch = QGC::limitAngleToPMPI(pitch);
yaw = QGC::limitAngleToPMPI(yaw);
// emit valueChanged(uasId, "roll IMU", mavlink_msg_attitude_get_roll(&message), time); // emit valueChanged(uasId, "roll IMU", mavlink_msg_attitude_get_roll(&message), time);
// emit valueChanged(uasId, "pitch IMU", mavlink_msg_attitude_get_pitch(&message), time); // emit valueChanged(uasId, "pitch IMU", mavlink_msg_attitude_get_pitch(&message), time);
// emit valueChanged(uasId, "yaw IMU", mavlink_msg_attitude_get_yaw(&message), time); // emit valueChanged(uasId, "yaw IMU", mavlink_msg_attitude_get_yaw(&message), time);
......
...@@ -69,10 +69,11 @@ UASManager::~UASManager() ...@@ -69,10 +69,11 @@ UASManager::~UASManager()
void UASManager::run() void UASManager::run()
{ {
forever // forever
{ // {
QGC::SLEEP::msleep(5000); // QGC::SLEEP::msleep(5000);
} // }
exec();
} }
void UASManager::addUAS(UASInterface* uas) void UASManager::addUAS(UASInterface* uas)
......
...@@ -29,6 +29,7 @@ This file is part of the QGROUNDCONTROL project ...@@ -29,6 +29,7 @@ This file is part of the QGROUNDCONTROL project
* *
*/ */
#include <QPainter> #include <QPainter>
#include <QSettings>
#include "DebugConsole.h" #include "DebugConsole.h"
#include "ui_DebugConsole.h" #include "ui_DebugConsole.h"
...@@ -45,6 +46,7 @@ DebugConsole::DebugConsole(QWidget *parent) : ...@@ -45,6 +46,7 @@ DebugConsole::DebugConsole(QWidget *parent) :
holdOn(false), holdOn(false),
convertToAscii(true), convertToAscii(true),
filterMAVLINK(false), filterMAVLINK(false),
autoHold(true),
bytesToIgnore(0), bytesToIgnore(0),
lastByte(-1), lastByte(-1),
sentBytes(), sentBytes(),
...@@ -57,7 +59,6 @@ DebugConsole::DebugConsole(QWidget *parent) : ...@@ -57,7 +59,6 @@ DebugConsole::DebugConsole(QWidget *parent) :
dataRate(0.0f), dataRate(0.0f),
lowpassDataRate(0.0f), lowpassDataRate(0.0f),
dataRateThreshold(500), dataRateThreshold(500),
autoHold(true),
commandIndex(0), commandIndex(0),
m_ui(new Ui::DebugConsole) m_ui(new Ui::DebugConsole)
{ {
...@@ -121,14 +122,57 @@ DebugConsole::DebugConsole(QWidget *parent) : ...@@ -121,14 +122,57 @@ DebugConsole::DebugConsole(QWidget *parent) :
hold(false); hold(false);
this->setVisible(false); loadSettings();
// Warn user about not activated hold
if (!m_ui->holdCheckBox->isChecked())
{
m_ui->receiveText->appendHtml(QString("<font color=\"%1\">%2</font>\n").arg(QColor(Qt::red).name(), tr("WARNING: You have NOT enabled auto-hold (stops updating the console is huge amounts of serial data arrive). Updating the console consumes significant CPU load, so if you receive more than about 5 KB/s of serial data, make sure to enable auto-hold if not using the console.")));
}
} }
DebugConsole::~DebugConsole() DebugConsole::~DebugConsole()
{ {
storeSettings();
delete m_ui; delete m_ui;
} }
void DebugConsole::loadSettings()
{
// Load defaults from settings
QSettings settings;
settings.sync();
settings.beginGroup("QGC_DEBUG_CONSOLE");
m_ui->specialComboBox->setCurrentIndex(settings.value("SPECIAL_SYMBOL", m_ui->specialComboBox->currentIndex()).toInt());
m_ui->specialCheckBox->setChecked(settings.value("SPECIAL_SYMBOL_CHECKBOX_STATE", m_ui->specialCheckBox->isChecked()).toBool());
hexModeEnabled(settings.value("HEX_MODE_ENABLED", m_ui->hexCheckBox->isChecked()).toBool());
MAVLINKfilterEnabled(settings.value("MAVLINK_FILTER_ENABLED", m_ui->mavlinkCheckBox->isChecked()).toBool());
setAutoHold(settings.value("AUTO_HOLD_ENABLED", m_ui->holdCheckBox->isChecked()).toBool());
settings.endGroup();
// Update visibility settings
if (m_ui->specialCheckBox->isChecked())
{
m_ui->specialCheckBox->setVisible(true);
m_ui->addSymbolButton->setVisible(false);
}
}
void DebugConsole::storeSettings()
{
// Store settings
QSettings settings;
settings.beginGroup("QGC_DEBUG_CONSOLE");
settings.setValue("SPECIAL_SYMBOL", m_ui->specialComboBox->currentIndex());
settings.setValue("SPECIAL_SYMBOL_CHECKBOX_STATE", m_ui->specialCheckBox->isChecked());
settings.setValue("HEX_MODE_ENABLED", m_ui->hexCheckBox->isChecked());
settings.setValue("MAVLINK_FILTER_ENABLED", m_ui->mavlinkCheckBox->isChecked());
settings.setValue("AUTO_HOLD_ENABLED", m_ui->holdCheckBox->isChecked());
settings.endGroup();
settings.sync();
//qDebug() << "Storing settings!";
}
/** /**
* Add a link to the debug console output * Add a link to the debug console output
*/ */
...@@ -480,6 +524,12 @@ void DebugConsole::appendSpecialSymbol() ...@@ -480,6 +524,12 @@ void DebugConsole::appendSpecialSymbol()
void DebugConsole::sendBytes() void DebugConsole::sendBytes()
{ {
// FIXME This store settings should be removed
// once all threading issues have been resolved
// since its called in the destructor, which
// is absolutely sufficient
storeSettings();
// Store command history // Store command history
commandHistory.append(m_ui->sendText->text()); commandHistory.append(m_ui->sendText->text());
// Since text was just sent, we're at position commandHistory.length() // Since text was just sent, we're at position commandHistory.length()
...@@ -614,11 +664,18 @@ void DebugConsole::sendBytes() ...@@ -614,11 +664,18 @@ void DebugConsole::sendBytes()
*/ */
void DebugConsole::hexModeEnabled(bool mode) void DebugConsole::hexModeEnabled(bool mode)
{ {
convertToAscii = !mode; if (convertToAscii == mode)
m_ui->receiveText->clear(); {
m_ui->sendText->clear(); convertToAscii = !mode;
m_ui->sentText->clear(); if (m_ui->hexCheckBox->isChecked() != mode)
commandHistory.clear(); {
m_ui->hexCheckBox->setChecked(mode);
}
m_ui->receiveText->clear();
m_ui->sendText->clear();
m_ui->sentText->clear();
commandHistory.clear();
}
} }
/** /**
...@@ -626,14 +683,23 @@ void DebugConsole::hexModeEnabled(bool mode) ...@@ -626,14 +683,23 @@ void DebugConsole::hexModeEnabled(bool mode)
*/ */
void DebugConsole::MAVLINKfilterEnabled(bool filter) void DebugConsole::MAVLINKfilterEnabled(bool filter)
{ {
filterMAVLINK = filter; if (filterMAVLINK != filter)
bytesToIgnore = 0; {
filterMAVLINK = filter;
bytesToIgnore = 0;
if (m_ui->mavlinkCheckBox->isChecked() != filter)
{
m_ui->mavlinkCheckBox->setChecked(filter);
}
}
} }
/** /**
* @param hold Freeze the input and thus any scrolling * @param hold Freeze the input and thus any scrolling
*/ */
void DebugConsole::hold(bool hold) void DebugConsole::hold(bool hold)
{ {
if (holdOn != hold)
{
// Check if we need to append bytes from the hold buffer // Check if we need to append bytes from the hold buffer
if (this->holdOn && !hold) if (this->holdOn && !hold)
{ {
...@@ -654,6 +720,11 @@ void DebugConsole::hold(bool hold) ...@@ -654,6 +720,11 @@ void DebugConsole::hold(bool hold)
{ {
m_ui->receiveText->setTextInteractionFlags(Qt::NoTextInteraction); m_ui->receiveText->setTextInteractionFlags(Qt::NoTextInteraction);
} }
if (m_ui->holdCheckBox->isChecked() != hold)
{
m_ui->holdCheckBox->setChecked(hold);
}
}
} }
/** /**
......
...@@ -96,6 +96,8 @@ public slots: ...@@ -96,6 +96,8 @@ public slots:
void paintEvent(QPaintEvent *event); void paintEvent(QPaintEvent *event);
/** @brief Update traffic measurements */ /** @brief Update traffic measurements */
void updateTrafficMeasurements(); void updateTrafficMeasurements();
void loadSettings();
void storeSettings();
protected: protected:
void changeEvent(QEvent *e); void changeEvent(QEvent *e);
...@@ -109,14 +111,12 @@ protected: ...@@ -109,14 +111,12 @@ protected:
void cycleCommandHistory(bool up); void cycleCommandHistory(bool up);
QList<LinkInterface*> links; QList<LinkInterface*> links;
QStringList commandHistory;
QString currCommand;
int commandIndex;
LinkInterface* currLink; LinkInterface* currLink;
bool holdOn; ///< Hold current view, ignore new data bool holdOn; ///< Hold current view, ignore new data
bool convertToAscii; ///< Convert data to ASCII bool convertToAscii; ///< Convert data to ASCII
bool filterMAVLINK; ///< Set true to filter out MAVLink in output bool filterMAVLINK; ///< Set true to filter out MAVLink in output
bool autoHold; ///< Auto-hold mode sets view into hold if the data rate is too high
int bytesToIgnore; ///< Number of bytes to ignore int bytesToIgnore; ///< Number of bytes to ignore
char lastByte; ///< The last received byte char lastByte; ///< The last received byte
QList<QString> sentBytes; ///< Transmitted bytes, per transmission QList<QString> sentBytes; ///< Transmitted bytes, per transmission
...@@ -129,7 +129,9 @@ protected: ...@@ -129,7 +129,9 @@ protected:
float dataRate; ///< Current data rate float dataRate; ///< Current data rate
float lowpassDataRate; ///< Lowpass filtered data rate float lowpassDataRate; ///< Lowpass filtered data rate
float dataRateThreshold; ///< Threshold where to enable auto-hold float dataRateThreshold; ///< Threshold where to enable auto-hold
bool autoHold; ///< Auto-hold mode sets view into hold if the data rate is too high QStringList commandHistory;
QString currCommand;
int commandIndex;
private: private:
Ui::DebugConsole *m_ui; Ui::DebugConsole *m_ui;
......
...@@ -158,7 +158,7 @@ ...@@ -158,7 +158,7 @@
</widget> </widget>
</item> </item>
<item row="1" column="7"> <item row="1" column="7">
<widget class="QPushButton" name="clearWPButton"> <widget class="QPushButton" name="clearTrailsButton">
<property name="toolTip"> <property name="toolTip">
<string>Delete all waypoints</string> <string>Delete all waypoints</string>
</property> </property>
...@@ -169,7 +169,7 @@ ...@@ -169,7 +169,7 @@
<string>Delete all waypoints</string> <string>Delete all waypoints</string>
</property> </property>
<property name="text"> <property name="text">
<string>Clear WPs</string> <string>Clear Trails</string>
</property> </property>
</widget> </widget>
</item> </item>
......
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