From 9705cd4e02716f8f4d0c0cbc39ba5b31aaf45ed3 Mon Sep 17 00:00:00 2001 From: Don Gagne Date: Sat, 5 Mar 2016 16:47:37 -0800 Subject: [PATCH] Speech changes, plus clearTrajectory --- src/Vehicle/Vehicle.cc | 25 ++++++++++++++++++++----- src/Vehicle/Vehicle.h | 3 +++ 2 files changed, 23 insertions(+), 5 deletions(-) diff --git a/src/Vehicle/Vehicle.cc b/src/Vehicle/Vehicle.cc index e0032af26c..e1ac7d11a8 100644 --- a/src/Vehicle/Vehicle.cc +++ b/src/Vehicle/Vehicle.cc @@ -141,6 +141,7 @@ Vehicle::Vehicle(LinkInterface* link, connect(this, &Vehicle::_sendMessageOnThread, this, &Vehicle::_sendMessage, Qt::QueuedConnection); connect(this, &Vehicle::_sendMessageOnLinkOnThread, this, &Vehicle::_sendMessageOnLink, Qt::QueuedConnection); connect(this, &Vehicle::flightModeChanged, this, &Vehicle::_announceflightModeChanged); + connect(this, &Vehicle::armedChanged, this, &Vehicle::_announceArmedChanged); _uas = new UAS(_mavlink, this, _firmwarePluginManager); @@ -224,6 +225,9 @@ Vehicle::Vehicle(LinkInterface* link, _batteryFactGroup.setVehicle(this); _windFactGroup.setVehicle(this); _vibrationFactGroup.setVehicle(this); + + _announceArmedChanged(armed()); + _announceflightModeChanged(flightMode()); } // Disconnected Vehicle @@ -467,7 +471,7 @@ void Vehicle::_handleSysStatus(mavlink_message_t& message) if (sysStatus.battery_remaining > 0 && sysStatus.battery_remaining < _batteryFactGroup.percentRemainingAnnounce()->rawValue().toInt()) { if (!_lowBatteryAnnounceTimer.isValid() || _lowBatteryAnnounceTimer.elapsed() > _lowBatteryAnnounceRepeatMSecs) { _lowBatteryAnnounceTimer.restart(); - _say(QString("Low battery on %1: %2 percent remaining").arg(_vehicleIdSpeech()).arg(sysStatus.battery_remaining)); + _say(QString("%1 low battery: %2 percent remaining").arg(_vehicleIdSpeech()).arg(sysStatus.battery_remaining)); } } } @@ -1288,7 +1292,7 @@ void Vehicle::_connectionLostTimeout(void) _connectionLost = true; _heardFrom = false; emit connectionLostChanged(true); - _say(QString("communication lost to %1").arg(_vehicleIdSpeech())); + _say(QString("%1 communication lost").arg(_vehicleIdSpeech())); if (_autoDisconnect) { disconnectInactiveVehicle(); } @@ -1301,7 +1305,7 @@ void Vehicle::_connectionActive(void) if (_connectionLost) { _connectionLost = false; emit connectionLostChanged(false); - _say(QString("communication regained to %1").arg(_vehicleIdSpeech())); + _say(QString("% 1 communication regained").arg(_vehicleIdSpeech())); } } @@ -1344,15 +1348,26 @@ QString Vehicle::_vehicleIdSpeech(void) if (qgcApp()->toolbox()->multiVehicleManager()->vehicles()->count() > 1) { return QString("vehicle %1").arg(id()); } else { - return QStringLiteral("vehicle"); + return QString(); } } void Vehicle::_announceflightModeChanged(const QString& flightMode) { - _say(QString("%1 is now in %2 flight mode").arg(_vehicleIdSpeech()).arg(flightMode)); + _say(QString("%1 %2 flight mode").arg(_vehicleIdSpeech()).arg(flightMode)); +} + +void Vehicle::_announceArmedChanged(bool armed) +{ + _say(QString("%1 %2").arg(_vehicleIdSpeech()).arg(armed ? QStringLiteral("armed") : QStringLiteral("disarmed"))); } +void Vehicle::clearTrajectoryPoints(void) +{ + _mapTrajectoryList.clearAndDeleteContents(); +} + + const char* VehicleGPSFactGroup::_hdopFactName = "hdop"; const char* VehicleGPSFactGroup::_vdopFactName = "vdop"; const char* VehicleGPSFactGroup::_courseOverGroundFactName = "courseOverGround"; diff --git a/src/Vehicle/Vehicle.h b/src/Vehicle/Vehicle.h index 9c871841f7..fa22cd4dc5 100644 --- a/src/Vehicle/Vehicle.h +++ b/src/Vehicle/Vehicle.h @@ -318,6 +318,8 @@ public: Q_INVOKABLE void virtualTabletJoystickValue(double roll, double pitch, double yaw, double thrust); Q_INVOKABLE void disconnectInactiveVehicle(void); + Q_INVOKABLE void clearTrajectoryPoints(void); + // Property accessors QGeoCoordinate coordinate(void) { return _coordinate; } @@ -524,6 +526,7 @@ private slots: void _parametersReady(bool parametersReady); void _remoteControlRSSIChanged(uint8_t rssi); void _announceflightModeChanged(const QString& flightMode); + void _announceArmedChanged(bool armed); void _handleTextMessage (int newCount); void _handletextMessageReceived (UASMessage* message); -- GitLab