Browse Source

Hotfix: Fixed widget / UAS initialization order which led to text messages (and other updates) being ignored if the widget was not open when the UAS was created

QGC4.4
Lorenz Meier 12 years ago
parent
commit
e6e7600761
  1. 7
      src/uas/UAS.cc
  2. 23
      src/ui/DebugConsole.cc
  3. 4
      src/ui/DebugConsole.h
  4. 61
      src/ui/MainWindow.cc
  5. 19
      src/ui/uas/UASInfoWidget.cc
  6. 5
      src/ui/uas/UASListWidget.cc

7
src/uas/UAS.cc

@ -1148,13 +1148,12 @@ void UAS::receiveMessage(LinkInterface* link, mavlink_message_t message) @@ -1148,13 +1148,12 @@ void UAS::receiveMessage(LinkInterface* link, mavlink_message_t message)
case MAVLINK_MSG_ID_STATUSTEXT:
{
QByteArray b;
b.resize(MAVLINK_MSG_STATUSTEXT_FIELD_TEXT_LEN);
b.resize(MAVLINK_MSG_STATUSTEXT_FIELD_TEXT_LEN+1);
mavlink_msg_statustext_get_text(&message, b.data());
//b.append('\0');
// Ensure NUL-termination
b[b.length()-1] = '\0';
QString text = QString(b);
int severity = mavlink_msg_statustext_get_severity(&message);
//qDebug() << "RECEIVED STATUS:" << text;false
//emit statusTextReceived(severity, text);
if (text.startsWith("#audio:"))
{

23
src/ui/DebugConsole.cc

@ -93,14 +93,23 @@ DebugConsole::DebugConsole(QWidget *parent) : @@ -93,14 +93,23 @@ DebugConsole::DebugConsole(QWidget *parent) :
// Update measurements the first time
updateTrafficMeasurements();
// First connect management slots, then make sure to add all existing objects
// Connect to link manager to get notified about new links
connect(LinkManager::instance(), SIGNAL(newLink(LinkInterface*)), this, SLOT(addLink(LinkInterface*)));
// Connect to UAS manager to get notified about new UAS
connect(UASManager::instance(), SIGNAL(UASCreated(UASInterface*)), this, SLOT(uasCreated(UASInterface*)));
// Get a list of all existing links
links = QList<LinkInterface*>();
foreach (LinkInterface* link, LinkManager::instance()->getLinks()) {
addLink(link);
}
// Connect to link manager to get notified about new links
connect(LinkManager::instance(), SIGNAL(newLink(LinkInterface*)), this, SLOT(addLink(LinkInterface*)));
// Get a list of all existing UAS
foreach (UASInterface* uas, UASManager::instance()->getUASList()) {
uasCreated(uas);
}
// Connect link combo box
connect(m_ui->linkComboBox, SIGNAL(currentIndexChanged(int)), this, SLOT(linkSelected(int)));
// Connect send button
@ -169,6 +178,12 @@ void DebugConsole::storeSettings() @@ -169,6 +178,12 @@ void DebugConsole::storeSettings()
//qDebug() << "Storing settings!";
}
void DebugConsole::uasCreated(UASInterface* uas)
{
connect(uas, SIGNAL(textMessageReceived(int,int,int,QString)),
this, SLOT(receiveTextMessage(int,int,int,QString)), Qt::UniqueConnection);
}
/**
* Add a link to the debug console output
*/
@ -183,8 +198,8 @@ void DebugConsole::addLink(LinkInterface* link) @@ -183,8 +198,8 @@ void DebugConsole::addLink(LinkInterface* link)
linkSelected(m_ui->linkComboBox->currentIndex());
// Register for name changes
connect(link, SIGNAL(nameChanged(QString)), this, SLOT(updateLinkName(QString)));
connect(link, SIGNAL(deleteLink(LinkInterface* const)), this, SLOT(removeLink(LinkInterface* const)));
connect(link, SIGNAL(nameChanged(QString)), this, SLOT(updateLinkName(QString)), Qt::UniqueConnection);
connect(link, SIGNAL(deleteLink(LinkInterface* const)), this, SLOT(removeLink(LinkInterface* const)), Qt::UniqueConnection);
}
void DebugConsole::removeLink(LinkInterface* const linkInterface)

4
src/ui/DebugConsole.h

@ -45,6 +45,8 @@ namespace Ui @@ -45,6 +45,8 @@ namespace Ui
class DebugConsole;
}
class UASInterface;
/**
* @brief Shows a debug console
*
@ -61,6 +63,8 @@ public: @@ -61,6 +63,8 @@ public:
public slots:
/** @brief Add a link to the list of monitored links */
void addLink(LinkInterface* link);
/** @brief Add a UAS to the list of monitored UAS */
void uasCreated(UASInterface* uas);
/** @brief Remove a link from the list */
void removeLink(LinkInterface* const link);
/** @brief Update a link name */

61
src/ui/MainWindow.cc

@ -1725,43 +1725,17 @@ void MainWindow::UASCreated(UASInterface* uas) @@ -1725,43 +1725,17 @@ void MainWindow::UASCreated(UASInterface* uas)
break;
}
// XXX The multi-UAS selection menu has been disabled for now,
// its redundant with right-clicking the UAS in the list.
// this code piece might be removed later if this is the final
// conclusion (May 2013)
// QAction* uasAction = new QAction(icon, tr("Select %1 for control").arg(uas->getUASName()), ui.menuConnected_Systems);
// connect(uas, SIGNAL(systemRemoved()), uasAction, SLOT(deleteLater()));
// connect(uasAction, SIGNAL(triggered()), uas, SLOT(setSelected()));
connect(uas, SIGNAL(systemSpecsChanged(int)), this, SLOT(UASSpecsChanged(int)));
// ui.menuConnected_Systems->addAction(uasAction);
// FIXME Should be not inside the mainwindow
if (debugConsoleDockWidget)
{
DebugConsole *debugConsole = dynamic_cast<DebugConsole*>(debugConsoleDockWidget->widget());
if (debugConsole)
{
connect(uas, SIGNAL(textMessageReceived(int,int,int,QString)),
debugConsole, SLOT(receiveTextMessage(int,int,int,QString)));
}
}
// Health / System status indicator
if (infoDockWidget)
{
UASInfoWidget *infoWidget = dynamic_cast<UASInfoWidget*>(infoDockWidget->widget());
if (infoWidget)
{
infoWidget->addUAS(uas);
}
}
// UAS List
if (listDockWidget)
{
UASListWidget *listWidget = dynamic_cast<UASListWidget*>(listDockWidget->widget());
if (listWidget)
{
listWidget->addUAS(uas);
}
}
connect(uas, SIGNAL(systemSpecsChanged(int)), this, SLOT(UASSpecsChanged(int)));
// HIL
showHILConfigurationWidget(uas);
@ -1773,25 +1747,12 @@ void MainWindow::UASCreated(UASInterface* uas) @@ -1773,25 +1747,12 @@ void MainWindow::UASCreated(UASInterface* uas)
}
// Line chart
//if (!linechartWidget)
//{
// Center widgets
//linechartWidget->addSystem(uas);
linechartWidget->addSource(mavlinkDecoder);
//addCentralWidget(linechartWidget, tr("Realtime Plot"));
if (dataView->centralWidget() != linechartWidget)
{
dataView->setCentralWidget(linechartWidget);
linechartWidget->show();
}
//dataView->setCentralWidget(linechartWidget);
//linechartWidget->show();
//}
linechartWidget->addSource(mavlinkDecoder);
if (dataView->centralWidget() != linechartWidget)
{
dataView->setCentralWidget(linechartWidget);
linechartWidget->show();
}
// Load default custom widgets for this autopilot type
loadCustomWidgetsFromDefaults(uas->getSystemTypeName(), uas->getAutopilotTypeName());

19
src/ui/uas/UASInfoWidget.cc

@ -34,7 +34,7 @@ This file is part of the PIXHAWK project @@ -34,7 +34,7 @@ This file is part of the PIXHAWK project
#include <float.h>
#include <UASInfoWidget.h>
#include <UASManager.h>
#include <MG.h>
#include <QGC.h>
#include <QTimer>
#include <QDir>
#include <cstdlib>
@ -46,20 +46,12 @@ UASInfoWidget::UASInfoWidget(QWidget *parent, QString name) : QWidget(parent) @@ -46,20 +46,12 @@ UASInfoWidget::UASInfoWidget(QWidget *parent, QString name) : QWidget(parent)
{
ui.setupUi(this);
this->name = name;
connect(UASManager::instance(), SIGNAL(activeUASSet(UASInterface*)), this, SLOT(setActiveUAS(UASInterface*)));
activeUAS = NULL;
//instruments = new QMap<QString, QProgressBar*>();
// Set default battery type
// setBattery(0, LIPOLY, 3);
startTime = MG::TIME::getGroundTimeNow();
// startVoltage = 0.0f;
connect(UASManager::instance(), SIGNAL(activeUASSet(UASInterface*)), this, SLOT(setActiveUAS(UASInterface*)));
setActiveUAS(UASManager::instance()->getActiveUAS());
// lastChargeLevel = 0.5f;
// lastRemainingTime = 1;
startTime = QGC::groundTimeMilliseconds();
// Set default values
/** Set two voltage decimals and zero charge level decimals **/
@ -117,7 +109,8 @@ void UASInfoWidget::addUAS(UASInterface* uas) @@ -117,7 +109,8 @@ void UASInfoWidget::addUAS(UASInterface* uas)
void UASInfoWidget::setActiveUAS(UASInterface* uas)
{
activeUAS = uas;
if (uas)
activeUAS = uas;
}
void UASInfoWidget::updateBattery(UASInterface* uas, double voltage, double percent, int seconds)

5
src/ui/uas/UASListWidget.cc

@ -67,6 +67,11 @@ UASListWidget::UASListWidget(QWidget *parent) : QWidget(parent), m_ui(new Ui::UA @@ -67,6 +67,11 @@ UASListWidget::UASListWidget(QWidget *parent) : QWidget(parent), m_ui(new Ui::UA
this->setVisible(false);
connect(UASManager::instance(),SIGNAL(UASCreated(UASInterface*)),this,SLOT(addUAS(UASInterface*)));
// Get a list of all existing UAS
foreach (UASInterface* uas, UASManager::instance()->getUASList()) {
addUAS(uas);
}
}
UASListWidget::~UASListWidget()

Loading…
Cancel
Save