Commit 6f920c2d authored by lm's avatar lm

Working on debug console auto hold feature, added param retransmission

parent a97c4405
...@@ -825,6 +825,8 @@ void MAVLinkSimulationLink::writeBytes(const char* data, qint64 size) ...@@ -825,6 +825,8 @@ void MAVLinkSimulationLink::writeBytes(const char* data, qint64 size)
// Iterate through all components / subsystems // Iterate through all components / subsystems
int j = 0; int j = 0;
for (i = onboardParams.begin(); i != onboardParams.end(); ++i) for (i = onboardParams.begin(); i != onboardParams.end(); ++i)
{
if (j != 5)
{ {
// Pack message and get size of encoded byte string // Pack message and get size of encoded byte string
mavlink_msg_param_value_pack(systemId, componentId, &msg, (int8_t*)i.key().toStdString().c_str(), i.value(), onboardParams.size(), j); mavlink_msg_param_value_pack(systemId, componentId, &msg, (int8_t*)i.key().toStdString().c_str(), i.value(), onboardParams.size(), j);
...@@ -833,6 +835,7 @@ void MAVLinkSimulationLink::writeBytes(const char* data, qint64 size) ...@@ -833,6 +835,7 @@ void MAVLinkSimulationLink::writeBytes(const char* data, qint64 size)
//add data into datastream //add data into datastream
memcpy(stream+streampointer,buffer, bufferlength); memcpy(stream+streampointer,buffer, bufferlength);
streampointer+=bufferlength; streampointer+=bufferlength;
}
j++; j++;
} }
...@@ -854,7 +857,7 @@ void MAVLinkSimulationLink::writeBytes(const char* data, qint64 size) ...@@ -854,7 +857,7 @@ void MAVLinkSimulationLink::writeBytes(const char* data, qint64 size)
onboardParams.insert(key, set.param_value); onboardParams.insert(key, set.param_value);
// Pack message and get size of encoded byte string // Pack message and get size of encoded byte string
mavlink_msg_param_value_pack(systemId, componentId, &msg, (int8_t*)key.toStdString().c_str(), set.param_value, onboardParams.size(), 0); mavlink_msg_param_value_pack(systemId, componentId, &msg, (int8_t*)key.toStdString().c_str(), set.param_value, onboardParams.size(), onboardParams.keys().indexOf(key));
// Allocate buffer with packet data // Allocate buffer with packet data
bufferlength = mavlink_msg_to_send_buffer(buffer, &msg); bufferlength = mavlink_msg_to_send_buffer(buffer, &msg);
//add data into datastream //add data into datastream
...@@ -863,15 +866,48 @@ void MAVLinkSimulationLink::writeBytes(const char* data, qint64 size) ...@@ -863,15 +866,48 @@ void MAVLinkSimulationLink::writeBytes(const char* data, qint64 size)
} }
} }
} }
case MAVLINK_MSG_ID_PARAM_REQUEST_READ:
{
qDebug() << "SIMULATION RECEIVED COMMAND TO SEND PARAMETER";
mavlink_param_request_read_t read;
mavlink_msg_param_request_read_decode(&msg, &read);
QByteArray bytes((char*)read.param_id, MAVLINK_MSG_PARAM_REQUEST_READ_FIELD_PARAM_ID_LEN);
QString key = QString(bytes);
if (onboardParams.contains(key))
{
float paramValue = onboardParams.value(key);
// Pack message and get size of encoded byte string
mavlink_msg_param_value_pack(systemId, componentId, &msg, (int8_t*)key.toStdString().c_str(), paramValue, onboardParams.size(), onboardParams.keys().indexOf(key));
// Allocate buffer with packet data
bufferlength = mavlink_msg_to_send_buffer(buffer, &msg);
//add data into datastream
memcpy(stream+streampointer,buffer, bufferlength);
streampointer+=bufferlength;
}
else if (read.param_index < onboardParams.size())
{
key = onboardParams.keys().at(read.param_index);
float paramValue = onboardParams.value(key);
// Pack message and get size of encoded byte string
mavlink_msg_param_value_pack(systemId, componentId, &msg, (int8_t*)key.toStdString().c_str(), paramValue, onboardParams.size(), onboardParams.keys().indexOf(key));
// Allocate buffer with packet data
bufferlength = mavlink_msg_to_send_buffer(buffer, &msg);
//add data into datastream
memcpy(stream+streampointer,buffer, bufferlength);
streampointer+=bufferlength;
}
}
break; break;
} }
} }
//unsigned char v=data[i]; unsigned char v=data[i];
//fprintf(stderr,"%02x ", v); fprintf(stderr,"%02x ", v);
} }
//fprintf(stderr,"\n"); fprintf(stderr,"\n");
readyBufferMutex.lock(); readyBufferMutex.lock();
for (int i = 0; i < streampointer; i++) for (int i = 0; i < streampointer; i++)
...@@ -903,22 +939,22 @@ void MAVLinkSimulationLink::readBytes() { ...@@ -903,22 +939,22 @@ void MAVLinkSimulationLink::readBytes() {
readyBufferMutex.unlock(); readyBufferMutex.unlock();
// if (len > 0) // if (len > 0)
// { // {
// qDebug() << "Simulation sent " << len << " bytes to groundstation: "; // qDebug() << "Simulation sent " << len << " bytes to groundstation: ";
//
// /* Increase write counter */ // /* Increase write counter */
// //bitsSentTotal += size * 8; // //bitsSentTotal += size * 8;
//
// //Output all bytes as hex digits // //Output all bytes as hex digits
// int i; // int i;
// for (i=0; i<len; i++) // for (i=0; i<len; i++)
// { // {
// unsigned int v=data[i]; // unsigned int v=data[i];
// fprintf(stderr,"%02x ", v); // fprintf(stderr,"%02x ", v);
// } // }
// fprintf(stderr,"\n"); // fprintf(stderr,"\n");
// } // }
} }
/** /**
......
...@@ -535,9 +535,8 @@ void UAS::receiveMessage(LinkInterface* link, mavlink_message_t message) ...@@ -535,9 +535,8 @@ void UAS::receiveMessage(LinkInterface* link, mavlink_message_t message)
emit valueChanged(uasId, "latitude", "deg", latitude, time); emit valueChanged(uasId, "latitude", "deg", latitude, time);
emit valueChanged(uasId, "longitude", "deg", longitude, time); emit valueChanged(uasId, "longitude", "deg", longitude, time);
emit valueChanged(uasId, "altitude", "m", altitude, time); emit valueChanged(uasId, "altitude", "m", altitude, time);
emit valueChanged(uasId, "gps x speed", "m/s", speedX, time); double totalSpeed = sqrt(speedX*speedX + speedY*speedY + speedZ*speedZ);
emit valueChanged(uasId, "gps y speed", "m/s", speedY, time); emit valueChanged(uasId, "gps speed", "m/s", totalSpeed, time);
emit valueChanged(uasId, "gps z speed", "m/s", speedZ, time);
emit globalPositionChanged(this, longitude, latitude, altitude, time); emit globalPositionChanged(this, longitude, latitude, altitude, time);
emit speedChanged(this, speedX, speedY, speedZ, time); emit speedChanged(this, speedX, speedY, speedZ, time);
// Set internal state // Set internal state
...@@ -565,12 +564,10 @@ void UAS::receiveMessage(LinkInterface* link, mavlink_message_t message) ...@@ -565,12 +564,10 @@ void UAS::receiveMessage(LinkInterface* link, mavlink_message_t message)
emit valueChanged(uasId, "latitude", "deg", latitude, time); emit valueChanged(uasId, "latitude", "deg", latitude, time);
emit valueChanged(uasId, "longitude", "deg", longitude, time); emit valueChanged(uasId, "longitude", "deg", longitude, time);
emit valueChanged(uasId, "altitude", "m", altitude, time); emit valueChanged(uasId, "altitude", "m", altitude, time);
emit valueChanged(uasId, "gps x speed", "m/s", speedX, time); double totalSpeed = sqrt(speedX*speedX + speedY*speedY + speedZ*speedZ);
emit valueChanged(uasId, "gps y speed", "m/s", speedY, time); emit valueChanged(uasId, "gps speed", "m/s", totalSpeed, time);
emit valueChanged(uasId, "gps z speed", "m/s", speedZ, time);
emit globalPositionChanged(this, longitude, latitude, altitude, time); emit globalPositionChanged(this, longitude, latitude, altitude, time);
emit speedChanged(this, speedX, speedY, speedZ, time); emit speedChanged(this, speedX, speedY, speedZ, time);
emit valueChanged(uasId, "gpsspeed", "m/s", sqrt(speedX*speedX+speedY*speedY+speedZ*speedZ), time);
// Set internal state // Set internal state
if (!positionLock) if (!positionLock)
{ {
...@@ -600,7 +597,7 @@ void UAS::receiveMessage(LinkInterface* link, mavlink_message_t message) ...@@ -600,7 +597,7 @@ void UAS::receiveMessage(LinkInterface* link, mavlink_message_t message)
if (pos.fix_type > 0) if (pos.fix_type > 0)
{ {
emit globalPositionChanged(this, pos.lon, pos.lat, pos.alt, time); emit globalPositionChanged(this, pos.lon, pos.lat, pos.alt, time);
emit valueChanged(uasId, "gpsspeed", "m/s", pos.v, time); emit valueChanged(uasId, "gps speed", "m/s", pos.v, time);
// Check for NaN // Check for NaN
int alt = pos.alt; int alt = pos.alt;
...@@ -1515,11 +1512,11 @@ void UAS::setParameter(const int component, const QString& id, const float value ...@@ -1515,11 +1512,11 @@ void UAS::setParameter(const int component, const QString& id, const float value
{ {
p.param_id[i] = id.toAscii()[i]; p.param_id[i] = id.toAscii()[i];
} }
// Null termination at end of string or end of buffer // // Null termination at end of string or end of buffer
else if ((int)i == id.length() || i == (sizeof(p.param_id) - 1)) // else if ((int)i == id.length() || i == (sizeof(p.param_id) - 1))
{ // {
p.param_id[i] = '\0'; // p.param_id[i] = '\0';
} // }
// Zero fill // Zero fill
else else
{ {
...@@ -1531,6 +1528,18 @@ void UAS::setParameter(const int component, const QString& id, const float value ...@@ -1531,6 +1528,18 @@ void UAS::setParameter(const int component, const QString& id, const float value
} }
} }
void UAS::requestParameter(int component, int parameter)
{
mavlink_message_t msg;
mavlink_param_request_read_t read;
read.param_index = parameter;
read.target_system = uasId;
read.target_component = component;
mavlink_msg_param_request_read_encode(mavlink->getSystemId(), mavlink->getComponentId(), &msg, &read);
sendMessage(msg);
qDebug() << __FILE__ << __LINE__ << "REQUESTING PARAM RETRANSMISSION FROM COMPONENT" << component << "FOR PARAM ID" << parameter;
}
void UAS::setSystemType(int systemType) void UAS::setSystemType(int systemType)
{ {
type = systemType; type = systemType;
......
...@@ -259,6 +259,9 @@ public slots: ...@@ -259,6 +259,9 @@ public slots:
/** @brief Request all parameters */ /** @brief Request all parameters */
void requestParameters(); void requestParameters();
/** @brief Request a single parameter by index */
void requestParameter(int component, int parameter);
/** @brief Set a system parameter */ /** @brief Set a system parameter */
void setParameter(const int component, const QString& id, const float value); void setParameter(const int component, const QString& id, const float value);
......
...@@ -226,6 +226,8 @@ public slots: ...@@ -226,6 +226,8 @@ public slots:
virtual void setLocalOriginAtCurrentGPSPosition() = 0; virtual void setLocalOriginAtCurrentGPSPosition() = 0;
/** @brief Request all onboard parameters of all components */ /** @brief Request all onboard parameters of all components */
virtual void requestParameters() = 0; virtual void requestParameters() = 0;
/** @brief Request one specific onboard parameter */
virtual void requestParameter(int component, int parameter) = 0;
/** @brief Write parameter to permanent storage */ /** @brief Write parameter to permanent storage */
virtual void writeParametersToStorage() = 0; virtual void writeParametersToStorage() = 0;
/** @brief Read parameter from permanent storage */ /** @brief Read parameter from permanent storage */
......
...@@ -85,10 +85,10 @@ DebugConsole::DebugConsole(QWidget *parent) : ...@@ -85,10 +85,10 @@ DebugConsole::DebugConsole(QWidget *parent) :
snapShotTimer.setInterval(snapShotInterval); snapShotTimer.setInterval(snapShotInterval);
snapShotTimer.start(); snapShotTimer.start();
// Set hex checkbox checked // // Set hex checkbox checked
m_ui->hexCheckBox->setChecked(!convertToAscii); // m_ui->hexCheckBox->setChecked(!convertToAscii);
m_ui->mavlinkCheckBox->setChecked(filterMAVLINK); // m_ui->mavlinkCheckBox->setChecked(filterMAVLINK);
m_ui->holdCheckBox->setChecked(autoHold); // m_ui->holdCheckBox->setChecked(autoHold);
// Get a list of all existing links // Get a list of all existing links
links = QList<LinkInterface*>(); links = QList<LinkInterface*>();
...@@ -120,8 +120,6 @@ DebugConsole::DebugConsole(QWidget *parent) : ...@@ -120,8 +120,6 @@ DebugConsole::DebugConsole(QWidget *parent) :
// Allow to send via return // Allow to send via return
connect(m_ui->sendText, SIGNAL(returnPressed()), this, SLOT(sendBytes())); connect(m_ui->sendText, SIGNAL(returnPressed()), this, SLOT(sendBytes()));
hold(false);
loadSettings(); loadSettings();
// Warn user about not activated hold // Warn user about not activated hold
...@@ -146,8 +144,8 @@ void DebugConsole::loadSettings() ...@@ -146,8 +144,8 @@ void DebugConsole::loadSettings()
m_ui->specialComboBox->setCurrentIndex(settings.value("SPECIAL_SYMBOL", m_ui->specialComboBox->currentIndex()).toInt()); 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()); 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()); hexModeEnabled(settings.value("HEX_MODE_ENABLED", m_ui->hexCheckBox->isChecked()).toBool());
MAVLINKfilterEnabled(settings.value("MAVLINK_FILTER_ENABLED", m_ui->mavlinkCheckBox->isChecked()).toBool()); MAVLINKfilterEnabled(settings.value("MAVLINK_FILTER_ENABLED", filterMAVLINK).toBool());
setAutoHold(settings.value("AUTO_HOLD_ENABLED", m_ui->holdCheckBox->isChecked()).toBool()); setAutoHold(settings.value("AUTO_HOLD_ENABLED", autoHold).toBool());
settings.endGroup(); settings.endGroup();
// Update visibility settings // Update visibility settings
...@@ -166,8 +164,8 @@ void DebugConsole::storeSettings() ...@@ -166,8 +164,8 @@ void DebugConsole::storeSettings()
settings.setValue("SPECIAL_SYMBOL", m_ui->specialComboBox->currentIndex()); settings.setValue("SPECIAL_SYMBOL", m_ui->specialComboBox->currentIndex());
settings.setValue("SPECIAL_SYMBOL_CHECKBOX_STATE", m_ui->specialCheckBox->isChecked()); settings.setValue("SPECIAL_SYMBOL_CHECKBOX_STATE", m_ui->specialCheckBox->isChecked());
settings.setValue("HEX_MODE_ENABLED", m_ui->hexCheckBox->isChecked()); settings.setValue("HEX_MODE_ENABLED", m_ui->hexCheckBox->isChecked());
settings.setValue("MAVLINK_FILTER_ENABLED", m_ui->mavlinkCheckBox->isChecked()); settings.setValue("MAVLINK_FILTER_ENABLED", filterMAVLINK);
settings.setValue("AUTO_HOLD_ENABLED", m_ui->holdCheckBox->isChecked()); settings.setValue("AUTO_HOLD_ENABLED", autoHold);
settings.endGroup(); settings.endGroup();
settings.sync(); settings.sync();
//qDebug() << "Storing settings!"; //qDebug() << "Storing settings!";
...@@ -242,8 +240,16 @@ void DebugConsole::setAutoHold(bool hold) ...@@ -242,8 +240,16 @@ void DebugConsole::setAutoHold(bool hold)
this->hold(false); this->hold(false);
m_ui->holdButton->setChecked(false); m_ui->holdButton->setChecked(false);
} }
// Set auto hold checkbox
if (m_ui->holdCheckBox->isChecked() != hold)
{
m_ui->holdCheckBox->setChecked(hold);
}
// Set new state // Set new state
autoHold = hold; autoHold = hold;
// FIXME REMOVE THIS HERE
storeSettings();
} }
/** /**
...@@ -699,6 +705,8 @@ void DebugConsole::hexModeEnabled(bool mode) ...@@ -699,6 +705,8 @@ void DebugConsole::hexModeEnabled(bool mode)
m_ui->sentText->clear(); m_ui->sentText->clear();
commandHistory.clear(); commandHistory.clear();
} }
// FIXME REMOVE THIS HERE
storeSettings();
} }
/** /**
...@@ -715,6 +723,8 @@ void DebugConsole::MAVLINKfilterEnabled(bool filter) ...@@ -715,6 +723,8 @@ void DebugConsole::MAVLINKfilterEnabled(bool filter)
m_ui->mavlinkCheckBox->setChecked(filter); m_ui->mavlinkCheckBox->setChecked(filter);
} }
} }
// FIXME REMOVE THIS HERE
storeSettings();
} }
/** /**
* @param hold Freeze the input and thus any scrolling * @param hold Freeze the input and thus any scrolling
......
...@@ -50,6 +50,9 @@ ...@@ -50,6 +50,9 @@
<property name="toolTip"> <property name="toolTip">
<string>Ignore MAVLINK protocol messages in display</string> <string>Ignore MAVLINK protocol messages in display</string>
</property> </property>
<property name="statusTip">
<string>Ignore MAVLINK protocol messages in display</string>
</property>
<property name="text"> <property name="text">
<string>Hide MAVLink</string> <string>Hide MAVLink</string>
</property> </property>
...@@ -58,7 +61,10 @@ ...@@ -58,7 +61,10 @@
<item> <item>
<widget class="QCheckBox" name="hexCheckBox"> <widget class="QCheckBox" name="hexCheckBox">
<property name="toolTip"> <property name="toolTip">
<string>Display and send bytes in HEX representation</string> <string>Display and enter bytes in HEX representation (e.g. 0xAA)</string>
</property>
<property name="statusTip">
<string>Display and enter bytes in HEX representation (e.g. 0xAA)</string>
</property> </property>
<property name="text"> <property name="text">
<string>HEX</string> <string>HEX</string>
......
...@@ -391,7 +391,7 @@ void MainWindow::buildCommonWidgets() ...@@ -391,7 +391,7 @@ void MainWindow::buildCommonWidgets()
if (!dataplotWidget) if (!dataplotWidget)
{ {
dataplotWidget = new QGCDataPlot2D(this); dataplotWidget = new QGCDataPlot2D(this);
addToCentralWidgetsMenu (dataplotWidget, "Data Plot", SLOT(showCentralWidget()),CENTRAL_DATA_PLOT); addToCentralWidgetsMenu (dataplotWidget, "Logfile Plot", SLOT(showCentralWidget()),CENTRAL_DATA_PLOT);
} }
} }
...@@ -431,27 +431,27 @@ void MainWindow::buildPxWidgets() ...@@ -431,27 +431,27 @@ void MainWindow::buildPxWidgets()
{ {
// Center widgets // Center widgets
linechartWidget = new Linecharts(this); linechartWidget = new Linecharts(this);
addToCentralWidgetsMenu(linechartWidget, "Line Plots", SLOT(showCentralWidget()), CENTRAL_LINECHART); addToCentralWidgetsMenu(linechartWidget, tr("Realtime Plot"), SLOT(showCentralWidget()), CENTRAL_LINECHART);
} }
if (!hudWidget) if (!hudWidget)
{ {
hudWidget = new HUD(320, 240, this); hudWidget = new HUD(320, 240, this);
addToCentralWidgetsMenu(hudWidget, "HUD", SLOT(showCentralWidget()), CENTRAL_HUD); addToCentralWidgetsMenu(hudWidget, tr("Head Up Display"), SLOT(showCentralWidget()), CENTRAL_HUD);
} }
if (!dataplotWidget) if (!dataplotWidget)
{ {
dataplotWidget = new QGCDataPlot2D(this); dataplotWidget = new QGCDataPlot2D(this);
addToCentralWidgetsMenu(dataplotWidget, "Data Plots", SLOT(showCentralWidget()), CENTRAL_DATA_PLOT); addToCentralWidgetsMenu(dataplotWidget, "Logfile Plot", SLOT(showCentralWidget()), CENTRAL_DATA_PLOT);
} }
#ifdef QGC_OSG_ENABLED #ifdef QGC_OSG_ENABLED
if (!_3DWidget) if (!_3DWidget)
{ {
_3DWidget = Q3DWidgetFactory::get("PIXHAWK"); _3DWidget = Q3DWidgetFactory::get("PIXHAWK");
addToCentralWidgetsMenu(_3DWidget, "Local 3D", SLOT(showCentralWidget()), CENTRAL_3D_LOCAL); addToCentralWidgetsMenu(_3DWidget, tr("Local 3D"), SLOT(showCentralWidget()), CENTRAL_3D_LOCAL);
} }
#endif #endif
...@@ -459,7 +459,7 @@ void MainWindow::buildPxWidgets() ...@@ -459,7 +459,7 @@ void MainWindow::buildPxWidgets()
if (!_3DMapWidget) if (!_3DMapWidget)
{ {
_3DMapWidget = Q3DWidgetFactory::get("MAP3D"); _3DMapWidget = Q3DWidgetFactory::get("MAP3D");
addToCentralWidgetsMenu(_3DMapWidget, "OSG Earth 3D", SLOT(showCentralWidget()), CENTRAL_OSGEARTH); addToCentralWidgetsMenu(_3DMapWidget, tr("OSG Earth 3D"), SLOT(showCentralWidget()), CENTRAL_OSGEARTH);
} }
#endif #endif
...@@ -467,7 +467,7 @@ void MainWindow::buildPxWidgets() ...@@ -467,7 +467,7 @@ void MainWindow::buildPxWidgets()
if (!gEarthWidget) if (!gEarthWidget)
{ {
gEarthWidget = new QGCGoogleEarthView(this); gEarthWidget = new QGCGoogleEarthView(this);
addToCentralWidgetsMenu(gEarthWidget, "Google Earth", SLOT(showCentralWidget()), CENTRAL_GOOGLE_EARTH); addToCentralWidgetsMenu(gEarthWidget, tr("Google Earth"), SLOT(showCentralWidget()), CENTRAL_GOOGLE_EARTH);
} }
#endif #endif
...@@ -503,7 +503,7 @@ void MainWindow::buildPxWidgets() ...@@ -503,7 +503,7 @@ void MainWindow::buildPxWidgets()
hsiDockWidget = new QDockWidget(tr("Horizontal Situation Indicator"), this); hsiDockWidget = new QDockWidget(tr("Horizontal Situation Indicator"), this);
hsiDockWidget->setWidget( new HSIDisplay(this) ); hsiDockWidget->setWidget( new HSIDisplay(this) );
hsiDockWidget->setObjectName("HORIZONTAL_SITUATION_INDICATOR_DOCK_WIDGET"); hsiDockWidget->setObjectName("HORIZONTAL_SITUATION_INDICATOR_DOCK_WIDGET");
addToToolsMenu (hsiDockWidget, tr("HSI"), SLOT(showToolWidget(bool)), MENU_HSI, Qt::BottomDockWidgetArea); addToToolsMenu (hsiDockWidget, tr("Horizontal Situation"), SLOT(showToolWidget(bool)), MENU_HSI, Qt::BottomDockWidgetArea);
} }
if (!headDown1DockWidget) if (!headDown1DockWidget)
...@@ -572,6 +572,7 @@ void MainWindow::buildSlugsWidgets() ...@@ -572,6 +572,7 @@ void MainWindow::buildSlugsWidgets()
{ {
// Center widgets // Center widgets
linechartWidget = new Linecharts(this); linechartWidget = new Linecharts(this);
addToCentralWidgetsMenu(linechartWidget, tr("Realtime Plot"), SLOT(showCentralWidget()), CENTRAL_LINECHART);
} }
if (!headUpDockWidget) if (!headUpDockWidget)
...@@ -580,7 +581,7 @@ void MainWindow::buildSlugsWidgets() ...@@ -580,7 +581,7 @@ void MainWindow::buildSlugsWidgets()
headUpDockWidget = new QDockWidget(tr("Control Indicator"), this); headUpDockWidget = new QDockWidget(tr("Control Indicator"), this);
headUpDockWidget->setWidget( new HUD(320, 240, this)); headUpDockWidget->setWidget( new HUD(320, 240, this));
headUpDockWidget->setObjectName("HEAD_UP_DISPLAY_DOCK_WIDGET"); headUpDockWidget->setObjectName("HEAD_UP_DISPLAY_DOCK_WIDGET");
addToToolsMenu (headUpDockWidget, tr("HUD"), SLOT(showToolWidget(bool)), MENU_HUD, Qt::LeftDockWidgetArea); addToToolsMenu (headUpDockWidget, tr("Head Up Display"), SLOT(showToolWidget(bool)), MENU_HUD, Qt::LeftDockWidgetArea);
} }
if (!rcViewDockWidget) if (!rcViewDockWidget)
......
...@@ -44,12 +44,6 @@ ParameterInterface::ParameterInterface(QWidget *parent) : ...@@ -44,12 +44,6 @@ ParameterInterface::ParameterInterface(QWidget *parent) :
m_ui(new Ui::parameterWidget) m_ui(new Ui::parameterWidget)
{ {
m_ui->setupUi(this); m_ui->setupUi(this);
// Make sure the combo box is empty
// because else indices get messed up
//m_ui->vehicleComboBox->clear();
// Setup UI connections
//connect(m_ui->vehicleComboBox, SIGNAL(activated(int)), this, SLOT(selectUAS(int)));
// Get current MAV list // Get current MAV list
QList<UASInterface*> systems = UASManager::instance()->getUASList(); QList<UASInterface*> systems = UASManager::instance()->getUASList();
...@@ -84,8 +78,6 @@ void ParameterInterface::selectUAS(int index) ...@@ -84,8 +78,6 @@ void ParameterInterface::selectUAS(int index)
*/ */
void ParameterInterface::addUAS(UASInterface* uas) void ParameterInterface::addUAS(UASInterface* uas)
{ {
//m_ui->vehicleComboBox->addItem(uas->getUASName());
QGCParamWidget* param = new QGCParamWidget(uas, this); QGCParamWidget* param = new QGCParamWidget(uas, this);
paramWidgets->insert(uas->getUASID(), param); paramWidgets->insert(uas->getUASID(), param);
m_ui->stackedWidget->addWidget(param); m_ui->stackedWidget->addWidget(param);
......
...@@ -30,6 +30,7 @@ This file is part of the QGROUNDCONTROL project ...@@ -30,6 +30,7 @@ This file is part of the QGROUNDCONTROL project
#include <QPushButton> #include <QPushButton>
#include <QFileDialog> #include <QFileDialog>
#include <QFile> #include <QFile>
#include <QList>
#include "QGCParamWidget.h" #include "QGCParamWidget.h"
#include "UASInterface.h" #include "UASInterface.h"
...@@ -127,6 +128,10 @@ QGCParamWidget::QGCParamWidget(UASInterface* uas, QWidget *parent) : ...@@ -127,6 +128,10 @@ QGCParamWidget::QGCParamWidget(UASInterface* uas, QWidget *parent) :
// New parameters from UAS // New parameters from UAS
connect(uas, SIGNAL(parameterChanged(int,int,int,int,QString,float)), this, SLOT(addParameter(int,int,int,int,QString,float))); connect(uas, SIGNAL(parameterChanged(int,int,int,int,QString,float)), this, SLOT(addParameter(int,int,int,int,QString,float)));
// Connect retransmission guard
connect(this, SIGNAL(requestParameter(int,int)), uas, SLOT(requestParameter(int,int)));
connect(&retransmissionTimer, SIGNAL(timeout()), this, SLOT(retransmissionGuardTick()));
} }
/** /**
...@@ -202,6 +207,7 @@ void QGCParamWidget::addParameter(int uas, int component, int paramCount, int pa ...@@ -202,6 +207,7 @@ void QGCParamWidget::addParameter(int uas, int component, int paramCount, int pa
transmissionMissingPackets.insert(component, new QList<int>()); transmissionMissingPackets.insert(component, new QList<int>());
} }
// Mark all parameters as missing
for (int i = 0; i < paramCount; ++i) for (int i = 0; i < paramCount; ++i)
{ {
if (!transmissionMissingPackets.value(component)->contains(i)) if (!transmissionMissingPackets.value(component)->contains(i))
...@@ -209,6 +215,11 @@ void QGCParamWidget::addParameter(int uas, int component, int paramCount, int pa ...@@ -209,6 +215,11 @@ void QGCParamWidget::addParameter(int uas, int component, int paramCount, int pa
transmissionMissingPackets.value(component)->append(i); transmissionMissingPackets.value(component)->append(i);
} }
} }
// Start retransmission guard
setRetransmissionGuardEnabled(true);
// Mark list size as known
transmissionListSizeKnown.insert(component, true); transmissionListSizeKnown.insert(component, true);
} }
} }
...@@ -532,6 +543,68 @@ void QGCParamWidget::loadParameters() ...@@ -532,6 +543,68 @@ void QGCParamWidget::loadParameters()
} }
/**
* Enabling the retransmission guard enables the parameter widget to track
* dropped parameters and to re-request them. This works for both individual
* parameter reads as well for whole list requests.
*
* @param enabled True if retransmission checking should be enabled, false else
*/
void QGCParamWidget::setRetransmissionGuardEnabled(bool enabled)
{
if (enabled)
{
retransmissionTimer.start(retransmissionTimeout);
}
else
{
retransmissionTimer.stop();
}
}
void QGCParamWidget::retransmissionGuardTick()
{
if (transmissionActive)
{
qDebug() << __FILE__ << __LINE__ << "RETRANSMISSION GUARD ACTIVE, CHECKING FOR DROPS..";
// Re-request at maximum five parameters at once
// to prevent link flooding
QMap<int, QMap<QString, float>*>::iterator i;
for (i = parameters.begin(); i != parameters.end(); ++i)
{
// Iterate through the parameters of the component
int component = i.key();
// Request five parameters from this component (at maximum)
QList<int> * paramList = transmissionMissingPackets.value(component, NULL);
if (paramList)
{
int count = 0;
int maxCount = 5;
foreach (int id, *paramList)
{
if (count < maxCount)
{
qDebug() << __FILE__ << __LINE__ << "RETRANSMISSION GUARD REQUESTS RETRANSMISSION OF PARAM #" << id << "FROM COMPONENT #" << component;
emit requestParameter(component, id);
statusLabel->setText(tr("Requ. retransmission of #%1").arg(id));
count++;
}
else
{
break;
}
}
}
}
}
else
{
qDebug() << __FILE__ << __LINE__ << "STOPPING RETRANSMISSION GUARD GRACEFULLY";
setRetransmissionGuardEnabled(false);
}
}
/** /**
* @param component the subsystem which has the parameter * @param component the subsystem which has the parameter
...@@ -541,7 +614,23 @@ void QGCParamWidget::loadParameters() ...@@ -541,7 +614,23 @@ void QGCParamWidget::loadParameters()
void QGCParamWidget::setParameter(int component, QString parameterName, float value) void QGCParamWidget::setParameter(int component, QString parameterName, float value)
{ {
emit parameterChanged(component, parameterName, value); emit parameterChanged(component, parameterName, value);
// // Wait for parameter to be written back
// // mark it therefore as missing
// if (!transmissionMissingPackets.contains(component))
// {
// transmissionMissingPackets.insert(component, new QList<int>());
// }
// for (int i = 0; i < paramCount; ++i)
// {
// if (!transmissionMissingPackets.value(component)->contains(i))
// {
// transmissionMissingPackets.value(component)->append(i);
// }
// }
// transmissionActive = true;
// transmissionStarted = QGC::groundTimeUsecs();
// setRetransmissionGuardEnabled(true);
} }
/** /**
......
...@@ -35,6 +35,7 @@ This file is part of the QGROUNDCONTROL project ...@@ -35,6 +35,7 @@ This file is part of the QGROUNDCONTROL project
#include <QTreeWidgetItem> #include <QTreeWidgetItem>
#include <QMap> #include <QMap>
#include <QLabel> #include <QLabel>
#include <QTimer>
#include "UASInterface.h" #include "UASInterface.h"
...@@ -51,6 +52,8 @@ public: ...@@ -51,6 +52,8 @@ public:
signals: signals:
/** @brief A parameter was changed in the widget, NOT onboard */ /** @brief A parameter was changed in the widget, NOT onboard */
void parameterChanged(int component, QString parametername, float value); void parameterChanged(int component, QString parametername, float value);
/** @brief Request a single parameter */
void requestParameter(int component, int parameter);
public slots: public slots:
/** @brief Add a component to the list */ /** @brief Add a component to the list */
void addComponent(int uas, int component, QString componentName); void addComponent(int uas, int component, QString componentName);
...@@ -77,6 +80,10 @@ public slots: ...@@ -77,6 +80,10 @@ public slots:
void saveParameters(); void saveParameters();
/** @brief Load parameters from a file */ /** @brief Load parameters from a file */
void loadParameters(); void loadParameters();
/** @brief Check for missing parameters */
void retransmissionGuardTick();
protected: protected:
UASInterface* mav; ///< The MAV this widget is controlling UASInterface* mav; ///< The MAV this widget is controlling
QTreeWidget* tree; ///< The parameter tree QTreeWidget* tree; ///< The parameter tree
...@@ -91,6 +98,11 @@ protected: ...@@ -91,6 +98,11 @@ protected:
QMap<int, bool> transmissionListSizeKnown; ///< List size initialized? QMap<int, bool> transmissionListSizeKnown; ///< List size initialized?
bool transmissionActive; ///< Missing packets, working on list? bool transmissionActive; ///< Missing packets, working on list?
quint64 transmissionStarted; ///< Timeout quint64 transmissionStarted; ///< Timeout
QTimer retransmissionTimer; ///< Timer handling parameter retransmission
const static int retransmissionTimeout = 100; ///< Retransmission request timeout, in milliseconds
/** @brief Activate / deactivate parameter retransmission */
void setRetransmissionGuardEnabled(bool enabled);
}; };
#endif // QGCPARAMWIDGET_H #endif // QGCPARAMWIDGET_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