Commit b1fc82ac authored by Bryant's avatar Bryant

Removing UASes now returns the UI to an almost pristine state. This was done...

Removing UASes now returns the UI to an almost pristine state. This was done by altering the activeUASSet signal so that it can emit a NULL UAS. Crashes may still exist in autopilot-specific code.
parent d91453a3
...@@ -310,38 +310,23 @@ void UASManager::removeUAS(UASInterface* uas) ...@@ -310,38 +310,23 @@ void UASManager::removeUAS(UASInterface* uas)
{ {
int listindex = systems.indexOf(uas); int listindex = systems.indexOf(uas);
// If this is the active UAS, select a new one. // Remove this system from local data store.
systems.removeAt(listindex);
// If this is the active UAS, select a new one if one exists otherwise
// indicate that there are no active UASes.
if (uas == activeUAS) if (uas == activeUAS)
{ {
if (systems.count() > 1) if (systems.count())
{ {
// We only set a new UAS if more than one is present setActiveUAS(systems.first());
if (listindex != 0)
{
// The system to be removed is not at position 1
// set position one as new active system
setActiveUAS(systems.first());
}
else
{
// The system to be removed is at position 1,
// select the next system
setActiveUAS(systems.at(1));
}
} }
else else
{ {
// TODO send a null pointer if no UAS is present any more setActiveUAS(NULL);
// This has to be properly tested however, since it might
// crash code parts not handling null pointers correctly.
activeUAS = NULL;
// XXX Not emitting the null pointer yet
} }
} }
// Finally delete a local reference to this UAS
systems.removeAt(listindex);
// Notify other UI elements that a UAS is being deleted before finally deleting it. // Notify other UI elements that a UAS is being deleted before finally deleting it.
qDebug() << "Deleting UAS object: " << uas->getUASName(); qDebug() << "Deleting UAS object: " << uas->getUASName();
emit UASDeleted(uas); emit UASDeleted(uas);
...@@ -449,21 +434,24 @@ UASInterface* UASManager::getUASForId(int id) ...@@ -449,21 +434,24 @@ UASInterface* UASManager::getUASForId(int id)
void UASManager::setActiveUAS(UASInterface* uas) void UASManager::setActiveUAS(UASInterface* uas)
{ {
if (uas != NULL) { // Signal components that the last UAS is no longer active.
activeUASMutex.lock(); activeUASMutex.lock();
if (activeUAS != NULL) { if (activeUAS != NULL) {
emit activeUASStatusChanged(activeUAS, false); emit activeUASStatusChanged(activeUAS, false);
emit activeUASStatusChanged(activeUAS->getUASID(), false); emit activeUASStatusChanged(activeUAS->getUASID(), false);
} }
activeUAS = uas; activeUAS = uas;
activeUASMutex.unlock(); activeUASMutex.unlock();
// And signal that a new UAS is.
emit activeUASSet(activeUAS);
if (activeUAS)
{
activeUAS->setSelected(); activeUAS->setSelected();
emit activeUASSet(uas); emit activeUASSet(activeUAS->getUASID());
emit activeUASSet(uas->getUASID()); emit activeUASSetListIndex(systems.indexOf(activeUAS));
emit activeUASSetListIndex(systems.indexOf(uas)); emit activeUASStatusChanged(activeUAS, true);
emit activeUASStatusChanged(uas, true); emit activeUASStatusChanged(activeUAS->getUASID(), true);
emit activeUASStatusChanged(uas->getUASID(), true);
} }
} }
...@@ -151,12 +151,12 @@ public slots: ...@@ -151,12 +151,12 @@ public slots:
**/ **/
void addUAS(UASInterface* UAS); void addUAS(UASInterface* UAS);
/** @brief Remove a system from the list. Also triggers the UAS to kill itself. */ /** @brief Remove a system from the list. If this is the active UAS, it switches to another one calling setActiveUAS. Also triggers the UAS to kill itself. */
void removeUAS(UASInterface* uas); void removeUAS(UASInterface* uas);
/** /**
* @brief Set a UAS as currently selected * @brief Set a UAS as currently selected. NULL is a valid value for when no other valid UAS's are available.
* *
* @param UAS Unmanned Air System to set * @param UAS Unmanned Air System to set
**/ **/
......
...@@ -177,12 +177,11 @@ HSIDisplay::HSIDisplay(QWidget *parent) : ...@@ -177,12 +177,11 @@ HSIDisplay::HSIDisplay(QWidget *parent) :
setStatusTip(tr("View from top in body frame. Scroll with mouse wheel to change the horizontal field of view of the widget.")); setStatusTip(tr("View from top in body frame. Scroll with mouse wheel to change the horizontal field of view of the widget."));
connect(&statusClearTimer, SIGNAL(timeout()), this, SLOT(clearStatusMessage())); connect(&statusClearTimer, SIGNAL(timeout()), this, SLOT(clearStatusMessage()));
statusClearTimer.start(3000);
setActiveUAS(UASManager::instance()->getActiveUAS()); setActiveUAS(UASManager::instance()->getActiveUAS());
// Listen for the removal of the active UAS. connect(UASManager::instance(), SIGNAL(activeUASSet(UASInterface*)),
setActiveUAS(UASManager::instance()->getActiveUAS()); this, SLOT(setActiveUAS(UASInterface*)));
setFocusPolicy(Qt::StrongFocus); setFocusPolicy(Qt::StrongFocus);
} }
...@@ -236,7 +235,7 @@ void HSIDisplay::paintEvent(QPaintEvent * event) ...@@ -236,7 +235,7 @@ void HSIDisplay::paintEvent(QPaintEvent * event)
void HSIDisplay::renderOverlay() void HSIDisplay::renderOverlay()
{ {
if (!isVisible()) return; if (!isVisible() || !uas) return;
#if (QGC_EVENTLOOP_DEBUG) #if (QGC_EVENTLOOP_DEBUG)
qDebug() << "EVENTLOOP:" << __FILE__ << __LINE__; qDebug() << "EVENTLOOP:" << __FILE__ << __LINE__;
#endif #endif
...@@ -911,9 +910,6 @@ void HSIDisplay::setMetricWidth(double width) ...@@ -911,9 +910,6 @@ void HSIDisplay::setMetricWidth(double width)
*/ */
void HSIDisplay::setActiveUAS(UASInterface* uas) void HSIDisplay::setActiveUAS(UASInterface* uas)
{ {
if (!uas)
return;
if (this->uas != NULL) { if (this->uas != NULL) {
disconnect(this->uas, SIGNAL(gpsSatelliteStatusChanged(int,int,float,float,float,bool)), this, SLOT(updateSatellite(int,int,float,float,float,bool))); disconnect(this->uas, SIGNAL(gpsSatelliteStatusChanged(int,int,float,float,float,bool)), this, SLOT(updateSatellite(int,int,float,float,float,bool)));
disconnect(this->uas, SIGNAL(localPositionChanged(UASInterface*,double,double,double,quint64)), this, SLOT(updateLocalPosition(UASInterface*,double,double,double,quint64))); disconnect(this->uas, SIGNAL(localPositionChanged(UASInterface*,double,double,double,quint64)), this, SLOT(updateLocalPosition(UASInterface*,double,double,double,quint64)));
...@@ -946,47 +942,49 @@ void HSIDisplay::setActiveUAS(UASInterface* uas) ...@@ -946,47 +942,49 @@ void HSIDisplay::setActiveUAS(UASInterface* uas)
disconnect(this->uas, SIGNAL(actuatorStatusChanged(bool,bool,bool)), this, SLOT(updateActuatorStatus(bool,bool,bool))); disconnect(this->uas, SIGNAL(actuatorStatusChanged(bool,bool,bool)), this, SLOT(updateActuatorStatus(bool,bool,bool)));
} }
connect(uas, SIGNAL(gpsSatelliteStatusChanged(int,int,float,float,float,bool)), this, SLOT(updateSatellite(int,int,float,float,float,bool))); if (uas)
connect(uas, SIGNAL(localPositionChanged(UASInterface*,double,double,double,quint64)), this, SLOT(updateLocalPosition(UASInterface*,double,double,double,quint64))); {
connect(uas, SIGNAL(globalPositionChanged(UASInterface*,double,double,double,quint64)), this, SLOT(updateGlobalPosition(UASInterface*,double,double,double,quint64))); connect(uas, SIGNAL(gpsSatelliteStatusChanged(int,int,float,float,float,bool)), this, SLOT(updateSatellite(int,int,float,float,float,bool)));
connect(uas, SIGNAL(attitudeThrustSetPointChanged(UASInterface*,double,double,double,double,quint64)), this, SLOT(updateAttitudeSetpoints(UASInterface*,double,double,double,double,quint64))); connect(uas, SIGNAL(localPositionChanged(UASInterface*,double,double,double,quint64)), this, SLOT(updateLocalPosition(UASInterface*,double,double,double,quint64)));
connect(uas, SIGNAL(positionSetPointsChanged(int,float,float,float,float,quint64)), this, SLOT(updatePositionSetpoints(int,float,float,float,float,quint64))); connect(uas, SIGNAL(globalPositionChanged(UASInterface*,double,double,double,quint64)), this, SLOT(updateGlobalPosition(UASInterface*,double,double,double,quint64)));
connect(uas, SIGNAL(userPositionSetPointsChanged(int,float,float,float,float)), this, SLOT(updateUserPositionSetpoints(int,float,float,float,float))); connect(uas, SIGNAL(attitudeThrustSetPointChanged(UASInterface*,double,double,double,double,quint64)), this, SLOT(updateAttitudeSetpoints(UASInterface*,double,double,double,double,quint64)));
connect(uas, SIGNAL(speedChanged(UASInterface*,double,double,double,quint64)), this, SLOT(updateSpeed(UASInterface*,double,double,double,quint64))); connect(uas, SIGNAL(positionSetPointsChanged(int,float,float,float,float,quint64)), this, SLOT(updatePositionSetpoints(int,float,float,float,float,quint64)));
connect(uas, SIGNAL(attitudeChanged(UASInterface*,double,double,double,quint64)), this, SLOT(updateAttitude(UASInterface*,double,double,double,quint64))); connect(uas, SIGNAL(userPositionSetPointsChanged(int,float,float,float,float)), this, SLOT(updateUserPositionSetpoints(int,float,float,float,float)));
connect(uas, SIGNAL(speedChanged(UASInterface*,double,double,double,quint64)), this, SLOT(updateSpeed(UASInterface*,double,double,double,quint64)));
connect(uas, SIGNAL(attitudeControlEnabled(bool)), this, SLOT(updateAttitudeControllerEnabled(bool))); connect(uas, SIGNAL(attitudeChanged(UASInterface*,double,double,double,quint64)), this, SLOT(updateAttitude(UASInterface*,double,double,double,quint64)));
connect(uas, SIGNAL(positionXYControlEnabled(bool)), this, SLOT(updatePositionXYControllerEnabled(bool)));
connect(uas, SIGNAL(positionZControlEnabled(bool)), this, SLOT(updatePositionZControllerEnabled(bool))); connect(uas, SIGNAL(attitudeControlEnabled(bool)), this, SLOT(updateAttitudeControllerEnabled(bool)));
connect(uas, SIGNAL(positionYawControlEnabled(bool)), this, SLOT(updatePositionYawControllerEnabled(bool))); connect(uas, SIGNAL(positionXYControlEnabled(bool)), this, SLOT(updatePositionXYControllerEnabled(bool)));
connect(uas, SIGNAL(positionZControlEnabled(bool)), this, SLOT(updatePositionZControllerEnabled(bool)));
connect(uas, SIGNAL(localizationChanged(UASInterface*,int)), this, SLOT(updateLocalization(UASInterface*,int))); connect(uas, SIGNAL(positionYawControlEnabled(bool)), this, SLOT(updatePositionYawControllerEnabled(bool)));
connect(uas, SIGNAL(visionLocalizationChanged(UASInterface*,int)), this, SLOT(updateVisionLocalization(UASInterface*,int)));
connect(uas, SIGNAL(gpsLocalizationChanged(UASInterface*,int)), this, SLOT(updateGpsLocalization(UASInterface*,int))); connect(uas, SIGNAL(localizationChanged(UASInterface*,int)), this, SLOT(updateLocalization(UASInterface*,int)));
connect(uas, SIGNAL(irUltraSoundLocalizationChanged(UASInterface*,int)), this, SLOT(updateInfraredUltrasoundLocalization(UASInterface*,int))); connect(uas, SIGNAL(visionLocalizationChanged(UASInterface*,int)), this, SLOT(updateVisionLocalization(UASInterface*,int)));
connect(uas, SIGNAL(objectDetected(uint,int,int,QString,int,float,float)), this, SLOT(updateObjectPosition(uint,int,int,QString,int,float,float))); connect(uas, SIGNAL(gpsLocalizationChanged(UASInterface*,int)), this, SLOT(updateGpsLocalization(UASInterface*,int)));
connect(uas, SIGNAL(irUltraSoundLocalizationChanged(UASInterface*,int)), this, SLOT(updateInfraredUltrasoundLocalization(UASInterface*,int)));
connect(uas, SIGNAL(gyroStatusChanged(bool,bool,bool)), this, SLOT(updateGyroStatus(bool,bool,bool))); connect(uas, SIGNAL(objectDetected(uint,int,int,QString,int,float,float)), this, SLOT(updateObjectPosition(uint,int,int,QString,int,float,float)));
connect(uas, SIGNAL(accelStatusChanged(bool,bool,bool)), this, SLOT(updateAccelStatus(bool,bool,bool)));
connect(uas, SIGNAL(magSensorStatusChanged(bool,bool,bool)), this, SLOT(updateMagSensorStatus(bool,bool,bool))); connect(uas, SIGNAL(gyroStatusChanged(bool,bool,bool)), this, SLOT(updateGyroStatus(bool,bool,bool)));
connect(uas, SIGNAL(baroStatusChanged(bool,bool,bool)), this, SLOT(updateBaroStatus(bool,bool,bool))); connect(uas, SIGNAL(accelStatusChanged(bool,bool,bool)), this, SLOT(updateAccelStatus(bool,bool,bool)));
connect(uas, SIGNAL(airspeedStatusChanged(bool,bool,bool)), this, SLOT(updateAirspeedStatus(bool,bool,bool))); connect(uas, SIGNAL(magSensorStatusChanged(bool,bool,bool)), this, SLOT(updateMagSensorStatus(bool,bool,bool)));
connect(uas, SIGNAL(opticalFlowStatusChanged(bool,bool,bool)), this, SLOT(updateOpticalFlowStatus(bool,bool,bool))); connect(uas, SIGNAL(baroStatusChanged(bool,bool,bool)), this, SLOT(updateBaroStatus(bool,bool,bool)));
connect(uas, SIGNAL(laserStatusChanged(bool,bool,bool)), this, SLOT(updateLaserStatus(bool,bool,bool))); connect(uas, SIGNAL(airspeedStatusChanged(bool,bool,bool)), this, SLOT(updateAirspeedStatus(bool,bool,bool)));
connect(uas, SIGNAL(groundTruthSensorStatusChanged(bool,bool,bool)), this, SLOT(updateGroundTruthSensorStatus(bool,bool,bool))); connect(uas, SIGNAL(opticalFlowStatusChanged(bool,bool,bool)), this, SLOT(updateOpticalFlowStatus(bool,bool,bool)));
connect(uas, SIGNAL(actuatorStatusChanged(bool,bool,bool)), this, SLOT(updateActuatorStatus(bool,bool,bool))); connect(uas, SIGNAL(laserStatusChanged(bool,bool,bool)), this, SLOT(updateLaserStatus(bool,bool,bool)));
connect(uas, SIGNAL(groundTruthSensorStatusChanged(bool,bool,bool)), this, SLOT(updateGroundTruthSensorStatus(bool,bool,bool)));
connect(uas, SIGNAL(actuatorStatusChanged(bool,bool,bool)), this, SLOT(updateActuatorStatus(bool,bool,bool)));
statusClearTimer.start(3000);
}
else
{
statusClearTimer.stop();
}
this->uas = uas; this->uas = uas;
resetMAVState(); resetMAVState();
} }
void HSIDisplay::removeUAS(UASInterface* uas)
{
this->uas = NULL;
resetMAVState();
}
void HSIDisplay::updateSpeed(UASInterface* uas, double vx, double vy, double vz, quint64 time) void HSIDisplay::updateSpeed(UASInterface* uas, double vx, double vy, double vz, quint64 time)
{ {
Q_UNUSED(uas); Q_UNUSED(uas);
...@@ -1091,7 +1089,7 @@ void HSIDisplay::updateAttitude(UASInterface* uas, double roll, double pitch, do ...@@ -1091,7 +1089,7 @@ void HSIDisplay::updateAttitude(UASInterface* uas, double roll, double pitch, do
void HSIDisplay::updateUserPositionSetpoints(int uasid, float xDesired, float yDesired, float zDesired, float yawDesired) void HSIDisplay::updateUserPositionSetpoints(int uasid, float xDesired, float yDesired, float zDesired, float yawDesired)
{ {
Q_UNUSED(uasid); Q_UNUSED(uasid);
uiXSetCoordinate = xDesired; uiXSetCoordinate = xDesired;
uiYSetCoordinate = yDesired; uiYSetCoordinate = yDesired;
uiZSetCoordinate = zDesired; uiZSetCoordinate = zDesired;
......
...@@ -52,7 +52,6 @@ public: ...@@ -52,7 +52,6 @@ public:
public slots: public slots:
void setActiveUAS(UASInterface* uas); void setActiveUAS(UASInterface* uas);
void removeUAS(UASInterface* uas);
/** @brief Set the width in meters this widget shows from top */ /** @brief Set the width in meters this widget shows from top */
void setMetricWidth(double width); void setMetricWidth(double width);
void updateSatellite(int uasid, int satid, float azimuth, float direction, float snr, bool used); void updateSatellite(int uasid, int satid, float azimuth, float direction, float snr, bool used);
......
...@@ -319,10 +319,10 @@ void HUD::setActiveUAS(UASInterface* uas) ...@@ -319,10 +319,10 @@ void HUD::setActiveUAS(UASInterface* uas)
connect(u, SIGNAL(imageStarted(quint64)), this, SLOT(startImage(quint64))); connect(u, SIGNAL(imageStarted(quint64)), this, SLOT(startImage(quint64)));
connect(u, SIGNAL(imageReady(UASInterface*)), this, SLOT(copyImage())); connect(u, SIGNAL(imageReady(UASInterface*)), this, SLOT(copyImage()));
} }
// Set new UAS
this->uas = uas;
} }
// Set new UAS
this->uas = uas;
} }
//void HUD::updateAttitudeThrustSetPoint(UASInterface* uas, double rollDesired, double pitchDesired, double yawDesired, double thrustDesired, quint64 msec) //void HUD::updateAttitudeThrustSetPoint(UASInterface* uas, double rollDesired, double pitchDesired, double yawDesired, double thrustDesired, quint64 msec)
......
...@@ -166,7 +166,6 @@ void QGCToolBar::createUI() ...@@ -166,7 +166,6 @@ void QGCToolBar::createUI()
// Configure the toolbar for the current default UAS // Configure the toolbar for the current default UAS
setActiveUAS(UASManager::instance()->getActiveUAS()); setActiveUAS(UASManager::instance()->getActiveUAS());
connect(UASManager::instance(), SIGNAL(activeUASSet(UASInterface*)), this, SLOT(setActiveUAS(UASInterface*))); connect(UASManager::instance(), SIGNAL(activeUASSet(UASInterface*)), this, SLOT(setActiveUAS(UASInterface*)));
connect(UASManager::instance(), SIGNAL(UASDeleted(UASInterface*)), this, SLOT(removeUAS(UASInterface*)));
if (LinkManager::instance()->getLinks().count() > 2) if (LinkManager::instance()->getLinks().count() > 2)
addLink(LinkManager::instance()->getLinks().last()); addLink(LinkManager::instance()->getLinks().last());
...@@ -288,8 +287,8 @@ void QGCToolBar::advancedActivityTriggered(QAction* action) ...@@ -288,8 +287,8 @@ void QGCToolBar::advancedActivityTriggered(QAction* action)
void QGCToolBar::setActiveUAS(UASInterface* active) void QGCToolBar::setActiveUAS(UASInterface* active)
{ {
// Do nothing if system is the same or NULL // Do nothing if system is the same
if ((active == NULL) || mav == active) return; if (mav == active) return;
// If switching UASes, disconnect the only one. // If switching UASes, disconnect the only one.
if (mav) if (mav)
...@@ -317,54 +316,43 @@ void QGCToolBar::setActiveUAS(UASInterface* active) ...@@ -317,54 +316,43 @@ void QGCToolBar::setActiveUAS(UASInterface* active)
// Connect new system // Connect new system
mav = active; mav = active;
connect(active, SIGNAL(statusChanged(UASInterface*,QString,QString)), this, SLOT(updateState(UASInterface*, QString,QString))); if (mav)
connect(active, SIGNAL(modeChanged(int,QString,QString)), this, SLOT(updateMode(int,QString,QString)));
connect(active, SIGNAL(nameChanged(QString)), this, SLOT(updateName(QString)));
connect(active, SIGNAL(systemTypeSet(UASInterface*,uint)), this, SLOT(setSystemType(UASInterface*,uint)));
connect(active, SIGNAL(textMessageReceived(int,int,int,QString)), this, SLOT(receiveTextMessage(int,int,int,QString)));
connect(active, SIGNAL(batteryChanged(UASInterface*,double,double,int)), this, SLOT(updateBatteryRemaining(UASInterface*,double,double,int)));
connect(active, SIGNAL(armingChanged(bool)), this, SLOT(updateArmingState(bool)));
connect(active, SIGNAL(heartbeatTimeout(bool, unsigned int)), this, SLOT(heartbeatTimeout(bool,unsigned int)));
connect(active, SIGNAL(globalPositionChanged(UASInterface*,double,double,double,quint64)), this, SLOT(globalPositionChanged(UASInterface*,double,double,double,quint64)));
if (active->getWaypointManager())
{ {
connect(active->getWaypointManager(), SIGNAL(currentWaypointChanged(quint16)), this, SLOT(updateCurrentWaypoint(quint16))); connect(mav, SIGNAL(statusChanged(UASInterface*,QString,QString)), this, SLOT(updateState(UASInterface*, QString,QString)));
connect(active->getWaypointManager(), SIGNAL(waypointDistanceChanged(double)), this, SLOT(updateWaypointDistance(double))); connect(mav, SIGNAL(modeChanged(int,QString,QString)), this, SLOT(updateMode(int,QString,QString)));
} connect(mav, SIGNAL(nameChanged(QString)), this, SLOT(updateName(QString)));
connect(mav, SIGNAL(systemTypeSet(UASInterface*,uint)), this, SLOT(setSystemType(UASInterface*,uint)));
// Update all values once connect(mav, SIGNAL(textMessageReceived(int,int,int,QString)), this, SLOT(receiveTextMessage(int,int,int,QString)));
systemName = mav->getUASName(); connect(mav, SIGNAL(batteryChanged(UASInterface*,double,double,int)), this, SLOT(updateBatteryRemaining(UASInterface*,double,double,int)));
systemArmed = mav->isArmed(); connect(mav, SIGNAL(armingChanged(bool)), this, SLOT(updateArmingState(bool)));
toolBarNameLabel->setText(mav->getUASName()); connect(mav, SIGNAL(heartbeatTimeout(bool, unsigned int)), this, SLOT(heartbeatTimeout(bool,unsigned int)));
toolBarNameLabel->setStyleSheet(QString("QLabel {color: %1;}").arg(mav->getColor().name())); connect(mav, SIGNAL(globalPositionChanged(UASInterface*,double,double,double,quint64)), this, SLOT(globalPositionChanged(UASInterface*,double,double,double,quint64)));
symbolLabel->setStyleSheet(QString("QWidget {background-color: %1;}").arg(mav->getColor().name())); if (mav->getWaypointManager())
toolBarModeLabel->setText(mav->getShortMode()); {
toolBarStateLabel->setText(mav->getShortState()); connect(mav->getWaypointManager(), SIGNAL(currentWaypointChanged(quint16)), this, SLOT(updateCurrentWaypoint(quint16)));
toolBarTimeoutLabel->setText(""); connect(mav->getWaypointManager(), SIGNAL(waypointDistanceChanged(double)), this, SLOT(updateWaypointDistance(double)));
toolBarDistLabel->setText(""); }
toolBarBatteryBar->setEnabled(true);
setSystemType(mav, mav->getSystemType());
}
/** // Update all values once
* @brief Handle removal of the UAS that is currently being displayed. systemName = mav->getUASName();
* Stop updating the UI periodically, reset the UI, and reset our stored UAS. systemArmed = mav->isArmed();
* @param uas The UAS to remove. toolBarNameLabel->setText(mav->getUASName());
*/ toolBarNameLabel->setStyleSheet(QString("QLabel {color: %1;}").arg(mav->getColor().name()));
void QGCToolBar::removeUAS(UASInterface* uas) symbolLabel->setStyleSheet(QString("QWidget {background-color: %1;}").arg(mav->getColor().name()));
{ toolBarModeLabel->setText(mav->getShortMode());
if (mav == uas) { toolBarStateLabel->setText(mav->getShortState());
toolBarTimeoutLabel->setText("");
toolBarDistLabel->setText("");
toolBarBatteryBar->setEnabled(true);
setSystemType(mav, mav->getSystemType());
}
else
{
updateViewTimer.stop(); updateViewTimer.stop();
resetToolbarUI(); resetToolbarUI();
mav = NULL;
} }
} }
void QGCToolBar::createCustomWidgets()
{
}
void QGCToolBar::updateArmingState(bool armed) void QGCToolBar::updateArmingState(bool armed)
{ {
systemArmed = armed; systemArmed = armed;
......
...@@ -46,8 +46,6 @@ public: ...@@ -46,8 +46,6 @@ public:
public slots: public slots:
/** @brief Set the system that is currently displayed by this widget */ /** @brief Set the system that is currently displayed by this widget */
void setActiveUAS(UASInterface* active); void setActiveUAS(UASInterface* active);
/** @brief Remove the provided UAS if it's currently active from the toolbar */
void removeUAS(UASInterface* uas);
/** @brief Set the link which is currently handled with connecting / disconnecting */ /** @brief Set the link which is currently handled with connecting / disconnecting */
void addLink(LinkInterface* link); void addLink(LinkInterface* link);
/** @brief Remove link which is currently handled */ /** @brief Remove link which is currently handled */
...@@ -86,7 +84,6 @@ public slots: ...@@ -86,7 +84,6 @@ public slots:
void advancedActivityTriggered(QAction* action); void advancedActivityTriggered(QAction* action);
protected: protected:
void createCustomWidgets();
void storeSettings(); void storeSettings();
void loadSettings(); void loadSettings();
void createUI(); void createUI();
......
This diff is collapsed.
...@@ -16,7 +16,7 @@ class QGCVehicleConfig; ...@@ -16,7 +16,7 @@ class QGCVehicleConfig;
class QGCVehicleConfig : public QWidget class QGCVehicleConfig : public QWidget
{ {
Q_OBJECT Q_OBJECT
public: public:
explicit QGCVehicleConfig(QWidget *parent = 0); explicit QGCVehicleConfig(QWidget *parent = 0);
~QGCVehicleConfig(); ~QGCVehicleConfig();
...@@ -175,12 +175,13 @@ protected: ...@@ -175,12 +175,13 @@ protected:
QList<QGCToolWidget*> toolWidgets; ///< Configurable widgets QList<QGCToolWidget*> toolWidgets; ///< Configurable widgets
bool calibrationEnabled; ///< calibration mode on / off bool calibrationEnabled; ///< calibration mode on / off
QMap<QString,QGCToolWidget*> *paramToWidgetMap; ///< Holds the current active MAV's parameter widgets. QMap<QString,QGCToolWidget*>* paramToWidgetMap; ///< Holds the current active MAV's parameter widgets.
QMap<QString,QGCToolWidget*> *libParamToWidgetMap; ///< Holds the library parameter widgets QList<QWidget*> additionalTabs; ///< Stores additional tabs loaded for this vehicle/autopilot configuration. Used for cleaning up.
QMap<QString,QMap<QString,QGCToolWidget*>*> systemTypeToParamMap; ///< Holds all loaded MAV specific parameter widgets, for every MAV. QMap<QString,QGCToolWidget*> libParamToWidgetMap; ///< Holds the library parameter widgets
QMap<QString,QMap<QString,QGCToolWidget*> > systemTypeToParamMap; ///< Holds all loaded MAV specific parameter widgets, for every MAV.
QMap<QGCToolWidget*,QGroupBox*> toolToBoxMap; ///< Easy method of figuring out which QGroupBox is tied to which ToolWidget. QMap<QGCToolWidget*,QGroupBox*> toolToBoxMap; ///< Easy method of figuring out which QGroupBox is tied to which ToolWidget.
QMap<QString,QString> paramTooltips; ///< Tooltips for the ? button next to a parameter. QMap<QString,QString> paramTooltips; ///< Tooltips for the ? button next to a parameter.
private: private:
Ui::QGCVehicleConfig *ui; Ui::QGCVehicleConfig *ui;
......
...@@ -35,7 +35,7 @@ ...@@ -35,7 +35,7 @@
</sizepolicy> </sizepolicy>
</property> </property>
<property name="currentIndex"> <property name="currentIndex">
<number>3</number> <number>0</number>
</property> </property>
<widget class="QWidget" name="rcTab"> <widget class="QWidget" name="rcTab">
<property name="sizePolicy"> <property name="sizePolicy">
...@@ -765,7 +765,7 @@ p, li { white-space: pre-wrap; } ...@@ -765,7 +765,7 @@ p, li { white-space: pre-wrap; }
<property name="widgetResizable"> <property name="widgetResizable">
<bool>true</bool> <bool>true</bool>
</property> </property>
<widget class="QWidget" name="scrollAreaWidgetContents_7"> <widget class="QWidget" name="sensorContents">
<property name="geometry"> <property name="geometry">
<rect> <rect>
<x>0</x> <x>0</x>
...@@ -849,7 +849,7 @@ p, li { white-space: pre-wrap; } ...@@ -849,7 +849,7 @@ p, li { white-space: pre-wrap; }
<property name="widgetResizable"> <property name="widgetResizable">
<bool>true</bool> <bool>true</bool>
</property> </property>
<widget class="QWidget" name="scrollAreaWidgetContents"> <widget class="QWidget" name="generalLeftContents">
<property name="geometry"> <property name="geometry">
<rect> <rect>
<x>0</x> <x>0</x>
...@@ -886,7 +886,7 @@ p, li { white-space: pre-wrap; } ...@@ -886,7 +886,7 @@ p, li { white-space: pre-wrap; }
<property name="widgetResizable"> <property name="widgetResizable">
<bool>true</bool> <bool>true</bool>
</property> </property>
<widget class="QWidget" name="scrollAreaWidgetContents_2"> <widget class="QWidget" name="generalRightContents">
<property name="geometry"> <property name="geometry">
<rect> <rect>
<x>0</x> <x>0</x>
...@@ -983,7 +983,7 @@ p, li { white-space: pre-wrap; } ...@@ -983,7 +983,7 @@ p, li { white-space: pre-wrap; }
<property name="widgetResizable"> <property name="widgetResizable">
<bool>true</bool> <bool>true</bool>
</property> </property>
<widget class="QWidget" name="scrollAreaWidgetContents_4"> <widget class="QWidget" name="advancedLeftContents">
<property name="geometry"> <property name="geometry">
<rect> <rect>
<x>0</x> <x>0</x>
...@@ -1036,7 +1036,7 @@ p, li { white-space: pre-wrap; } ...@@ -1036,7 +1036,7 @@ p, li { white-space: pre-wrap; }
<property name="widgetResizable"> <property name="widgetResizable">
<bool>true</bool> <bool>true</bool>
</property> </property>
<widget class="QWidget" name="scrollAreaWidgetContents_5"> <widget class="QWidget" name="advancedRightContents">
<property name="geometry"> <property name="geometry">
<rect> <rect>
<x>0</x> <x>0</x>
......
...@@ -302,7 +302,6 @@ void QGCMapWidget::addUAS(UASInterface* uas) ...@@ -302,7 +302,6 @@ void QGCMapWidget::addUAS(UASInterface* uas)
void QGCMapWidget::activeUASSet(UASInterface* uas) void QGCMapWidget::activeUASSet(UASInterface* uas)
{ {
// Only execute if proper UAS is set // Only execute if proper UAS is set
if (!uas) return;
this->uas = uas; this->uas = uas;
// Disconnect old MAV manager // Disconnect old MAV manager
...@@ -315,17 +314,26 @@ void QGCMapWidget::activeUASSet(UASInterface* uas) ...@@ -315,17 +314,26 @@ void QGCMapWidget::activeUASSet(UASInterface* uas)
disconnect(this, SIGNAL(waypointChanged(Waypoint*)), currWPManager, SLOT(notifyOfChangeEditable(Waypoint*))); disconnect(this, SIGNAL(waypointChanged(Waypoint*)), currWPManager, SLOT(notifyOfChangeEditable(Waypoint*)));
} }
currWPManager = uas->getWaypointManager(); // Attach the new waypoint manager if a new UAS was selected. Otherwise, indicate
// that no such manager exists.
if (uas)
{
currWPManager = uas->getWaypointManager();
updateSelectedSystem(uas->getUASID()); updateSelectedSystem(uas->getUASID());
followUAVID = uas->getUASID(); followUAVID = uas->getUASID();
updateWaypointList(uas->getUASID()); updateWaypointList(uas->getUASID());
// Connect the waypoint manager / data storage to the UI // Connect the waypoint manager / data storage to the UI
connect(currWPManager, SIGNAL(waypointEditableListChanged(int)), this, SLOT(updateWaypointList(int))); connect(currWPManager, SIGNAL(waypointEditableListChanged(int)), this, SLOT(updateWaypointList(int)));
connect(currWPManager, SIGNAL(waypointEditableChanged(int, Waypoint*)), this, SLOT(updateWaypoint(int,Waypoint*))); connect(currWPManager, SIGNAL(waypointEditableChanged(int, Waypoint*)), this, SLOT(updateWaypoint(int,Waypoint*)));
connect(this, SIGNAL(waypointCreated(Waypoint*)), currWPManager, SLOT(addWaypointEditable(Waypoint*))); connect(this, SIGNAL(waypointCreated(Waypoint*)), currWPManager, SLOT(addWaypointEditable(Waypoint*)));
connect(this, SIGNAL(waypointChanged(Waypoint*)), currWPManager, SLOT(notifyOfChangeEditable(Waypoint*))); connect(this, SIGNAL(waypointChanged(Waypoint*)), currWPManager, SLOT(notifyOfChangeEditable(Waypoint*)));
}
else
{
currWPManager = NULL;
}
} }
/** /**
......
...@@ -113,7 +113,10 @@ Pixhawk3DWidget::~Pixhawk3DWidget() ...@@ -113,7 +113,10 @@ Pixhawk3DWidget::~Pixhawk3DWidget()
void void
Pixhawk3DWidget::activeSystemChanged(UASInterface* uas) Pixhawk3DWidget::activeSystemChanged(UASInterface* uas)
{ {
mActiveSystemId = uas->getUASID(); if (uas)
{
mActiveSystemId = uas->getUASID();
}
mActiveUAS = uas; mActiveUAS = uas;
......
...@@ -70,7 +70,7 @@ UASControlWidget::UASControlWidget(QWidget *parent) : QWidget(parent), ...@@ -70,7 +70,7 @@ UASControlWidget::UASControlWidget(QWidget *parent) : QWidget(parent),
void UASControlWidget::setUAS(UASInterface* uas) void UASControlWidget::setUAS(UASInterface* uas)
{ {
if (this->uas != 0) if (this->uas)
{ {
UASInterface* oldUAS = UASManager::instance()->getUASForId(this->uas); UASInterface* oldUAS = UASManager::instance()->getUASForId(this->uas);
disconnect(ui.controlButton, SIGNAL(clicked()), oldUAS, SLOT(armSystem())); disconnect(ui.controlButton, SIGNAL(clicked()), oldUAS, SLOT(armSystem()));
...@@ -83,18 +83,25 @@ void UASControlWidget::setUAS(UASInterface* uas) ...@@ -83,18 +83,25 @@ void UASControlWidget::setUAS(UASInterface* uas)
} }
// Connect user interface controls // Connect user interface controls
connect(ui.controlButton, SIGNAL(clicked()), this, SLOT(cycleContextButton())); if (uas)
connect(ui.liftoffButton, SIGNAL(clicked()), uas, SLOT(launch())); {
connect(ui.landButton, SIGNAL(clicked()), uas, SLOT(home())); connect(ui.controlButton, SIGNAL(clicked()), this, SLOT(cycleContextButton()));
connect(ui.shutdownButton, SIGNAL(clicked()), uas, SLOT(shutdown())); connect(ui.liftoffButton, SIGNAL(clicked()), uas, SLOT(launch()));
//connect(ui.setHomeButton, SIGNAL(clicked()), uas, SLOT(setLocalOriginAtCurrentGPSPosition())); connect(ui.landButton, SIGNAL(clicked()), uas, SLOT(home()));
connect(uas, SIGNAL(modeChanged(int,QString,QString)), this, SLOT(updateMode(int,QString,QString))); connect(ui.shutdownButton, SIGNAL(clicked()), uas, SLOT(shutdown()));
connect(uas, SIGNAL(statusChanged(int)), this, SLOT(updateState(int))); //connect(ui.setHomeButton, SIGNAL(clicked()), uas, SLOT(setLocalOriginAtCurrentGPSPosition()));
connect(uas, SIGNAL(modeChanged(int,QString,QString)), this, SLOT(updateMode(int,QString,QString)));
ui.controlStatusLabel->setText(tr("Connected to ") + uas->getUASName()); connect(uas, SIGNAL(statusChanged(int)), this, SLOT(updateState(int)));
this->uas = uas->getUASID(); ui.controlStatusLabel->setText(tr("Connected to ") + uas->getUASName());
setBackgroundColor(uas->getColor());
this->uas = uas->getUASID();
setBackgroundColor(uas->getColor());
}
else
{
this->uas = -1;
}
} }
UASControlWidget::~UASControlWidget() UASControlWidget::~UASControlWidget()
......
...@@ -56,15 +56,21 @@ UASListWidget::UASListWidget(QWidget *parent) : QWidget(parent), ...@@ -56,15 +56,21 @@ UASListWidget::UASListWidget(QWidget *parent) : QWidget(parent),
m_ui->verticalLayout->addWidget(uWidget); m_ui->verticalLayout->addWidget(uWidget);
linkToBoxMapping = QMap<LinkInterface*, QGroupBox*>(); linkToBoxMapping = QMap<LinkInterface*, QGroupBox*>();
uasToBoxMapping = QMap<UASInterface*, QGroupBox*>();
uasViews = QMap<UASInterface*, UASView*>(); uasViews = QMap<UASInterface*, UASView*>();
this->setVisible(false); this->setVisible(false);
// Listen for when UASes are added or removed. This does not manage the UASView
// widgets that are displayed within this widget.
connect(UASManager::instance(), SIGNAL(UASCreated(UASInterface*)), connect(UASManager::instance(), SIGNAL(UASCreated(UASInterface*)),
this, SLOT(addUAS(UASInterface*))); this, SLOT(addUAS(UASInterface*)));
connect(UASManager::instance(), SIGNAL(UASDeleted(UASInterface*)),
this, SLOT(removeUAS(UASInterface*)));
// Get a list of all existing UAS // Get a list of all existing UAS
foreach (UASInterface* uas, UASManager::instance()->getUASList()) { foreach (UASInterface* uas, UASManager::instance()->getUASList())
{
addUAS(uas); addUAS(uas);
} }
} }
...@@ -94,7 +100,7 @@ void UASListWidget::addUAS(UASInterface* uas) ...@@ -94,7 +100,7 @@ void UASListWidget::addUAS(UASInterface* uas)
if (uasViews.isEmpty()) if (uasViews.isEmpty())
{ {
m_ui->verticalLayout->removeWidget(uWidget); m_ui->verticalLayout->removeWidget(uWidget);
delete uWidget; uWidget->deleteLater();
uWidget = NULL; uWidget = NULL;
} }
...@@ -125,6 +131,7 @@ void UASListWidget::addUAS(UASInterface* uas) ...@@ -125,6 +131,7 @@ void UASListWidget::addUAS(UASInterface* uas)
// And add the new UAS to the UASList // And add the new UAS to the UASList
UASView* newView = new UASView(uas, newBox); UASView* newView = new UASView(uas, newBox);
uasViews.insert(uas, newView); uasViews.insert(uas, newView);
uasToBoxMapping[uas] = newBox;
newBox->layout()->addWidget(newView); newBox->layout()->addWidget(newView);
// Watch for when this widget is destroyed so that we can clean up the // Watch for when this widget is destroyed so that we can clean up the
...@@ -149,30 +156,49 @@ void UASListWidget::activeUAS(UASInterface* uas) ...@@ -149,30 +156,49 @@ void UASListWidget::activeUAS(UASInterface* uas)
*/ */
void UASListWidget::removeUAS(UASInterface* uas) void UASListWidget::removeUAS(UASInterface* uas)
{ {
// Remove the UAS from our data structures and // Remove the UASView and check if its parent GroupBox has any other children,
// the global listing. // delete it if it doesn't.
QGroupBox* box = uasToBoxMapping[uas];
uasToBoxMapping.remove(uas);
uasViews.remove(uas); uasViews.remove(uas);
int otherViews = 0;
// Check all groupboxes for all links this uas had and check if they're empty. foreach (UASView* view, box->findChildren<UASView*>())
// Delete them if they are.
QListIterator<LinkInterface*> i = *uas->getLinks();
while (i.hasNext())
{ {
LinkInterface* link = i.next(); if (view->uas == uas)
{
view->deleteLater();
}
else
{
++otherViews;
}
}
if (otherViews == 0)
{
// Delete the groupbox.
QMap<LinkInterface*, QGroupBox*>::const_iterator i = linkToBoxMapping.constBegin();
while (i != linkToBoxMapping.constEnd()) {
if (i.value() == box)
{
linkToBoxMapping.remove(i.key());
}
++i;
}
box->deleteLater();
QGroupBox* box = linkToBoxMapping[link]; // And if no other QGroupBoxes are left, put the initial widget back.
if (box) int otherBoxes = 0;
foreach (const QGroupBox* otherBox, findChildren<QGroupBox*>())
{ {
// If this was the last UAS in the GroupBox, remove it and its corresponding link. if (otherBox != box)
int views = box->findChildren<UASView*>().size(); {
if (views == 0) { ++otherBoxes;
box->deleteLater();
linkToBoxMapping.remove(link);
} }
} }
if (otherBoxes == 0)
{
uWidget = new QGCUnconnectedInfoWidget(this);
m_ui->verticalLayout->addWidget(uWidget);
}
} }
// And if no QGroupBoxes are left, put the initial widget back.
uWidget = new QGCUnconnectedInfoWidget(this);
m_ui->verticalLayout->addWidget(uWidget);
} }
...@@ -33,6 +33,7 @@ This file is part of the QGROUNDCONTROL project ...@@ -33,6 +33,7 @@ This file is part of the QGROUNDCONTROL project
#include <QWidget> #include <QWidget>
#include <QMap> #include <QMap>
#include <QList>
#include <QVBoxLayout> #include <QVBoxLayout>
#include <QGroupBox> #include <QGroupBox>
#include "UASInterface.h" #include "UASInterface.h"
...@@ -54,9 +55,11 @@ public slots: ...@@ -54,9 +55,11 @@ public slots:
void removeUAS(UASInterface* uas); void removeUAS(UASInterface* uas);
protected: protected:
// Keep a mapping from UASes to their GroupBox. Useful for determining when groupboxes are empty.
QMap<UASInterface*, QGroupBox*> uasToBoxMapping;
// Keep a mapping from Links to GroupBoxes for adding new links. // Keep a mapping from Links to GroupBoxes for adding new links.
QMap<LinkInterface*, QGroupBox*> linkToBoxMapping; QMap<LinkInterface*, QGroupBox*> linkToBoxMapping;
// Tie each view to their UAS object. // Tie each view to their UAS object so they can be removed easily.
QMap<UASInterface*, UASView*> uasViews; QMap<UASInterface*, UASView*> uasViews;
QGCUnconnectedInfoWidget* uWidget; QGCUnconnectedInfoWidget* uWidget;
void changeEvent(QEvent *e); void changeEvent(QEvent *e);
......
...@@ -17,61 +17,61 @@ UASQuickView::UASQuickView(QWidget *parent) : ...@@ -17,61 +17,61 @@ UASQuickView::UASQuickView(QWidget *parent) :
{ {
QAction *action = new QAction("latitude",this); QAction *action = new QAction(tr("latitude"),this);
action->setCheckable(true); action->setCheckable(true);
action->setChecked(true); action->setChecked(true);
connect(action,SIGNAL(toggled(bool)),this,SLOT(actionTriggered(bool))); connect(action,SIGNAL(toggled(bool)),this,SLOT(actionTriggered(bool)));
this->addAction(action); this->addAction(action);
UASQuickViewItem *item = new UASQuickViewItem(this); UASQuickViewItem *item = new UASQuickViewItem(this);
item->setTitle("latitude"); item->setTitle(tr("latitude"));
this->layout()->addWidget(item); this->layout()->addWidget(item);
uasPropertyToLabelMap["latitude"] = item; uasPropertyToLabelMap["latitude"] = item;
} }
{ {
QAction *action = new QAction("longitude",this); QAction *action = new QAction(tr("longitude"),this);
action->setCheckable(true); action->setCheckable(true);
action->setChecked(true); action->setChecked(true);
connect(action,SIGNAL(toggled(bool)),this,SLOT(actionTriggered(bool))); connect(action,SIGNAL(toggled(bool)),this,SLOT(actionTriggered(bool)));
this->addAction(action); this->addAction(action);
UASQuickViewItem *item = new UASQuickViewItem(this); UASQuickViewItem *item = new UASQuickViewItem(this);
item->setTitle("longitude"); item->setTitle(tr("longitude"));
this->layout()->addWidget(item); this->layout()->addWidget(item);
uasPropertyToLabelMap["longitude"] = item; uasPropertyToLabelMap["longitude"] = item;
} }
{ {
QAction *action = new QAction("altitude",this); QAction *action = new QAction(tr("altitude"),this);
action->setCheckable(true); action->setCheckable(true);
action->setChecked(true); action->setChecked(true);
connect(action,SIGNAL(toggled(bool)),this,SLOT(actionTriggered(bool))); connect(action,SIGNAL(toggled(bool)),this,SLOT(actionTriggered(bool)));
this->addAction(action); this->addAction(action);
UASQuickViewItem *item = new UASQuickViewItem(this); UASQuickViewItem *item = new UASQuickViewItem(this);
item->setTitle("altitude"); item->setTitle(tr("altitude"));
this->layout()->addWidget(item); this->layout()->addWidget(item);
uasPropertyToLabelMap["altitude"] = item; uasPropertyToLabelMap["altitude"] = item;
} }
{ {
QAction *action = new QAction("satelliteCount",this); QAction *action = new QAction(tr("satelliteCount"),this);
action->setCheckable(true); action->setCheckable(true);
action->setChecked(true); action->setChecked(true);
connect(action,SIGNAL(toggled(bool)),this,SLOT(actionTriggered(bool))); connect(action,SIGNAL(toggled(bool)),this,SLOT(actionTriggered(bool)));
this->addAction(action); this->addAction(action);
UASQuickViewItem *item = new UASQuickViewItem(this); UASQuickViewItem *item = new UASQuickViewItem(this);
item->setTitle("satelliteCount"); item->setTitle(tr("satelliteCount"));
this->layout()->addWidget(item); this->layout()->addWidget(item);
uasPropertyToLabelMap["satelliteCount"] = item; uasPropertyToLabelMap["satelliteCount"] = item;
} }
{ {
QAction *action = new QAction("distToWaypoint",this); QAction *action = new QAction(tr("distToWaypoint"),this);
action->setCheckable(true); action->setCheckable(true);
action->setChecked(true); action->setChecked(true);
connect(action,SIGNAL(toggled(bool)),this,SLOT(actionTriggered(bool))); connect(action,SIGNAL(toggled(bool)),this,SLOT(actionTriggered(bool)));
this->addAction(action); this->addAction(action);
UASQuickViewItem *item = new UASQuickViewItem(this); UASQuickViewItem *item = new UASQuickViewItem(this);
item->setTitle("distToWaypoint"); item->setTitle(tr("distToWaypoint"));
this->layout()->addWidget(item); this->layout()->addWidget(item);
uasPropertyToLabelMap["distToWaypoint"] = item; uasPropertyToLabelMap["distToWaypoint"] = item;
} }
......
...@@ -43,48 +43,48 @@ This file is part of the PIXHAWK project ...@@ -43,48 +43,48 @@ This file is part of the PIXHAWK project
#include <QGCHilFlightGearConfiguration.h> #include <QGCHilFlightGearConfiguration.h>
UASView::UASView(UASInterface* uas, QWidget *parent) : UASView::UASView(UASInterface* uas, QWidget *parent) :
QWidget(parent), QWidget(parent),
startTime(0), uas(uas),
timeout(false), startTime(0),
iconIsRed(true), timeout(false),
disconnected(false), iconIsRed(true),
timeRemaining(0), disconnected(false),
chargeLevel(0), timeRemaining(0),
uas(uas), chargeLevel(0),
load(0), load(0),
state("UNKNOWN"), state("UNKNOWN"),
stateDesc(tr("Unknown state")), stateDesc(tr("Unknown state")),
mode("MAV_MODE_UNKNOWN"), mode("MAV_MODE_UNKNOWN"),
thrust(0), thrust(0),
isActive(false), isActive(false),
x(0), x(0),
y(0), y(0),
z(0), z(0),
totalSpeed(0), totalSpeed(0),
lat(0), lat(0),
lon(0), lon(0),
alt(0), alt(0),
groundDistance(0), groundDistance(0),
localFrame(false), localFrame(false),
globalFrameKnown(false), globalFrameKnown(false),
removeAction(new QAction("Delete this system", this)), removeAction(new QAction(tr("Delete this system"), this)),
renameAction(new QAction("Rename..", this)), renameAction(new QAction(tr("Rename.."), this)),
selectAction(new QAction("Control this system", this )), selectAction(new QAction(tr("Control this system"), this)),
hilAction(new QAction("HIL - Hardware in the Loop", this )), hilAction(new QAction(tr("HIL - Hardware in the Loop"), this)),
selectAirframeAction(new QAction("Choose Airframe", this)), selectAirframeAction(new QAction(tr("Choose Airframe"), this)),
setBatterySpecsAction(new QAction("Set Battery Options", this)), setBatterySpecsAction(new QAction(tr("Set Battery Options"), this)),
lowPowerModeEnabled(true), lowPowerModeEnabled(true),
generalUpdateCount(0), generalUpdateCount(0),
filterTime(0), filterTime(0),
m_ui(new Ui::UASView) m_ui(new Ui::UASView)
{ {
m_ui->setupUi(this);
// FIXME XXX // FIXME XXX
lowPowerModeEnabled = MainWindow::instance()->lowPowerModeEnabled(); lowPowerModeEnabled = MainWindow::instance()->lowPowerModeEnabled();
hilAction->setCheckable(true); hilAction->setCheckable(true);
m_ui->setupUi(this);
// Setup communication // Setup communication
//connect(uas, SIGNAL(valueChanged(int,QString,double,quint64)), this, SLOT(receiveValue(int,QString,double,quint64))); //connect(uas, SIGNAL(valueChanged(int,QString,double,quint64)), this, SLOT(receiveValue(int,QString,double,quint64)));
connect(uas, SIGNAL(batteryChanged(UASInterface*, double, double, int)), this, SLOT(updateBattery(UASInterface*, double, double, int))); connect(uas, SIGNAL(batteryChanged(UASInterface*, double, double, int)), this, SLOT(updateBattery(UASInterface*, double, double, int)));
...@@ -116,8 +116,8 @@ UASView::UASView(UASInterface* uas, QWidget *parent) : ...@@ -116,8 +116,8 @@ UASView::UASView(UASInterface* uas, QWidget *parent) :
connect(m_ui->killButton, SIGNAL(clicked()), uas, SLOT(emergencyKILL())); connect(m_ui->killButton, SIGNAL(clicked()), uas, SLOT(emergencyKILL()));
connect(m_ui->shutdownButton, SIGNAL(clicked()), uas, SLOT(shutdown())); connect(m_ui->shutdownButton, SIGNAL(clicked()), uas, SLOT(shutdown()));
// Allow to delete this widget // Allow deleting this widget
connect(removeAction, SIGNAL(triggered()), this, SLOT(prepareForDeletion())); connect(removeAction, SIGNAL(triggered()), this, SLOT(triggerUASDeletion()));
connect(renameAction, SIGNAL(triggered()), this, SLOT(rename())); connect(renameAction, SIGNAL(triggered()), this, SLOT(rename()));
connect(selectAction, SIGNAL(triggered()), uas, SLOT(setSelected())); connect(selectAction, SIGNAL(triggered()), uas, SLOT(setSelected()));
connect(hilAction, SIGNAL(triggered(bool)), this, SLOT(showHILUi())); connect(hilAction, SIGNAL(triggered(bool)), this, SLOT(showHILUi()));
...@@ -170,9 +170,6 @@ UASView::UASView(UASInterface* uas, QWidget *parent) : ...@@ -170,9 +170,6 @@ UASView::UASView(UASInterface* uas, QWidget *parent) :
UASView::~UASView() UASView::~UASView()
{ {
delete m_ui; delete m_ui;
delete removeAction;
delete renameAction;
delete selectAction;
} }
void UASView::heartbeatTimeout(bool timeout, unsigned int ms) void UASView::heartbeatTimeout(bool timeout, unsigned int ms)
...@@ -561,23 +558,14 @@ void UASView::showHILUi() ...@@ -561,23 +558,14 @@ void UASView::showHILUi()
MainWindow::instance()->showHILConfigurationWidget(uas); MainWindow::instance()->showHILConfigurationWidget(uas);
} }
/** void UASView::triggerUASDeletion()
* @brief Stop updating this UASView, queue it for deletion, and also tell the UASManager to delete the UAS.
*/
void UASView::prepareForDeletion()
{ {
refreshTimer->stop(); refreshTimer->stop();
UASManager::instance()->removeUAS(uas); UASManager::instance()->removeUAS(uas);
deleteLater();
} }
void UASView::refresh() void UASView::refresh()
{ {
//setUpdatesEnabled(false);
//setUpdatesEnabled(true);
//repaint();
//qDebug() << "UPDATING UAS WIDGET!" << uas->getUASName();
if (generalUpdateCount == 4) if (generalUpdateCount == 4)
{ {
#if (QGC_EVENTLOOP_DEBUG) #if (QGC_EVENTLOOP_DEBUG)
......
...@@ -49,6 +49,7 @@ class UASView : public QWidget ...@@ -49,6 +49,7 @@ class UASView : public QWidget
public: public:
UASView(UASInterface* uas, QWidget *parent = 0); UASView(UASInterface* uas, QWidget *parent = 0);
~UASView(); ~UASView();
UASInterface* uas;
public slots: public slots:
/** @brief Update the name of the system */ /** @brief Update the name of the system */
...@@ -65,8 +66,11 @@ public slots: ...@@ -65,8 +66,11 @@ public slots:
void updateLoad(UASInterface* uas, double load); void updateLoad(UASInterface* uas, double load);
//void receiveValue(int uasid, QString id, double value, quint64 time); //void receiveValue(int uasid, QString id, double value, quint64 time);
void showHILUi(); void showHILUi();
/** @brief Disables the widget from accessing the UAS object in preparation for being deleted */ /**
void prepareForDeletion(); * Request that the UASManager deletes this UAS. This doesn't delete this widget
* yet, it waits for the approprait uasDeleted signal.
*/
void triggerUASDeletion();
void refresh(); void refresh();
/** @brief Receive new waypoint information */ /** @brief Receive new waypoint information */
void setWaypoint(int uasId, int id, double x, double y, double z, double yaw, bool autocontinue, bool current); void setWaypoint(int uasId, int id, double x, double y, double z, double yaw, bool autocontinue, bool current);
...@@ -103,7 +107,6 @@ protected: ...@@ -103,7 +107,6 @@ protected:
bool disconnected; bool disconnected;
int timeRemaining; int timeRemaining;
float chargeLevel; float chargeLevel;
UASInterface* uas;
float load; float load;
QString state; QString state;
QString stateDesc; QString stateDesc;
......
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