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)
case MAVLINK_MSG_ID_STATUSTEXT: case MAVLINK_MSG_ID_STATUSTEXT:
{ {
QByteArray b; 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()); mavlink_msg_statustext_get_text(&message, b.data());
//b.append('\0'); // Ensure NUL-termination
b[b.length()-1] = '\0';
QString text = QString(b); QString text = QString(b);
int severity = mavlink_msg_statustext_get_severity(&message); int severity = mavlink_msg_statustext_get_severity(&message);
//qDebug() << "RECEIVED STATUS:" << text;false
//emit statusTextReceived(severity, text);
if (text.startsWith("#audio:")) if (text.startsWith("#audio:"))
{ {

23
src/ui/DebugConsole.cc

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

4
src/ui/DebugConsole.h

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

61
src/ui/MainWindow.cc

@ -1725,43 +1725,17 @@ void MainWindow::UASCreated(UASInterface* uas)
break; 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); // QAction* uasAction = new QAction(icon, tr("Select %1 for control").arg(uas->getUASName()), ui.menuConnected_Systems);
// connect(uas, SIGNAL(systemRemoved()), uasAction, SLOT(deleteLater())); // connect(uas, SIGNAL(systemRemoved()), uasAction, SLOT(deleteLater()));
// connect(uasAction, SIGNAL(triggered()), uas, SLOT(setSelected())); // connect(uasAction, SIGNAL(triggered()), uas, SLOT(setSelected()));
connect(uas, SIGNAL(systemSpecsChanged(int)), this, SLOT(UASSpecsChanged(int)));
// ui.menuConnected_Systems->addAction(uasAction); // 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 connect(uas, SIGNAL(systemSpecsChanged(int)), this, SLOT(UASSpecsChanged(int)));
if (listDockWidget)
{
UASListWidget *listWidget = dynamic_cast<UASListWidget*>(listDockWidget->widget());
if (listWidget)
{
listWidget->addUAS(uas);
}
}
// HIL // HIL
showHILConfigurationWidget(uas); showHILConfigurationWidget(uas);
@ -1773,25 +1747,12 @@ void MainWindow::UASCreated(UASInterface* uas)
} }
linechartWidget->addSource(mavlinkDecoder);
// Line chart if (dataView->centralWidget() != linechartWidget)
//if (!linechartWidget) {
//{ dataView->setCentralWidget(linechartWidget);
linechartWidget->show();
// 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();
//}
// Load default custom widgets for this autopilot type // Load default custom widgets for this autopilot type
loadCustomWidgetsFromDefaults(uas->getSystemTypeName(), uas->getAutopilotTypeName()); loadCustomWidgetsFromDefaults(uas->getSystemTypeName(), uas->getAutopilotTypeName());

19
src/ui/uas/UASInfoWidget.cc

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

Loading…
Cancel
Save