Unverified Commit 66753e21 authored by Don Gagne's avatar Don Gagne Committed by GitHub

VehicleLinkManager: Major refactor on how QGC manages comm links (#9101)

New VehicleLinkManager implementation
parent affc9f96
......@@ -31,6 +31,7 @@ linux {
message("Linux clang")
QMAKE_CXXFLAGS += -Qunused-arguments -fcolor-diagnostics
} else {
#QMAKE_CXXFLAGS += -H # Handy for debugging why something is getting built when an include file is touched
QMAKE_CXXFLAGS_WARN_ON += -Werror \
-Wno-deprecated-copy \ # These come from mavlink headers
-Wno-unused-parameter \ # gst_plugins-good has these errors
......
......@@ -14,5 +14,6 @@
<file alias="PolygonMissingNode.kml">src/MissionManager/UnitTest/PolygonMissingNode.kml</file>
<file alias="PolygonBadXml.kml">src/MissionManager/UnitTest/PolygonBadXml.kml</file>
<file alias="PolygonBadCoordinatesNode.kml">src/MissionManager/UnitTest/PolygonBadCoordinatesNode.kml</file>
<file alias="MockLinkOptionsDlg.qml">src/comm/MockLinkOptionsDlg.qml</file>
</qresource>
</RCC>
......@@ -431,7 +431,6 @@ HEADERS += \
src/api/QGCOptions.h \
src/api/QGCSettings.h \
src/api/QmlComponentInfo.h \
src/comm/MavlinkMessagesTimer.h \
src/GPS/Drivers/src/base_station.h \
contains (DEFINES, QGC_ENABLE_PAIRING) {
......@@ -445,7 +444,6 @@ SOURCES += \
src/api/QGCOptions.cc \
src/api/QGCSettings.cc \
src/api/QmlComponentInfo.cc \
src/comm/MavlinkMessagesTimer.cc \
contains (DEFINES, QGC_ENABLE_PAIRING) {
SOURCES += \
......@@ -492,17 +490,16 @@ DebugBuild { PX4FirmwarePlugin { PX4FirmwarePluginFactory { APMFirmwarePlugin {
src/MissionManager/TransectStyleComplexItemTestBase.h \
src/MissionManager/VisualMissionItemTest.h \
src/qgcunittest/GeoTest.h \
src/qgcunittest/LinkManagerTest.h \
src/qgcunittest/MavlinkLogTest.h \
src/qgcunittest/MultiSignalSpy.h \
src/qgcunittest/TCPLinkTest.h \
src/qgcunittest/TCPLoopBackServer.h \
src/qgcunittest/MultiSignalSpyV2.h \
src/qgcunittest/UnitTest.h \
src/Vehicle/FTPManagerTest.h \
src/Vehicle/InitialConnectTest.h \
src/Vehicle/RequestMessageTest.h \
src/Vehicle/SendMavCommandWithHandlerTest.h \
src/Vehicle/SendMavCommandWithSignallingTest.h \
src/Vehicle/VehicleLinkManagerTest.h \
#src/qgcunittest/RadioConfigTest.h \
#src/AnalyzeView/LogDownloadTest.h \
#src/qgcunittest/FileDialogTest.h \
......@@ -540,11 +537,9 @@ DebugBuild { PX4FirmwarePlugin { PX4FirmwarePluginFactory { APMFirmwarePlugin {
src/MissionManager/TransectStyleComplexItemTestBase.cc \
src/MissionManager/VisualMissionItemTest.cc \
src/qgcunittest/GeoTest.cc \
src/qgcunittest/LinkManagerTest.cc \
src/qgcunittest/MavlinkLogTest.cc \
src/qgcunittest/MultiSignalSpy.cc \
src/qgcunittest/TCPLinkTest.cc \
src/qgcunittest/TCPLoopBackServer.cc \
src/qgcunittest/MultiSignalSpyV2.cc \
src/qgcunittest/UnitTest.cc \
src/qgcunittest/UnitTestList.cc \
src/Vehicle/FTPManagerTest.cc \
......@@ -552,6 +547,7 @@ DebugBuild { PX4FirmwarePlugin { PX4FirmwarePluginFactory { APMFirmwarePlugin {
src/Vehicle/RequestMessageTest.cc \
src/Vehicle/SendMavCommandWithHandlerTest.cc \
src/Vehicle/SendMavCommandWithSignallingTest.cc \
src/Vehicle/VehicleLinkManagerTest.cc \
#src/qgcunittest/RadioConfigTest.cc \
#src/AnalyzeView/LogDownloadTest.cc \
#src/qgcunittest/FileDialogTest.cc \
......@@ -705,6 +701,7 @@ HEADERS += \
src/Vehicle/VehicleDistanceSensorFactGroup.h \
src/Vehicle/VehicleEstimatorStatusFactGroup.h \
src/Vehicle/VehicleGPSFactGroup.h \
src/Vehicle/VehicleLinkManager.h \
src/Vehicle/VehicleSetpointFactGroup.h \
src/Vehicle/VehicleTemperatureFactGroup.h \
src/Vehicle/VehicleVibrationFactGroup.h \
......@@ -933,6 +930,7 @@ SOURCES += \
src/Vehicle/VehicleDistanceSensorFactGroup.cc \
src/Vehicle/VehicleEstimatorStatusFactGroup.cc \
src/Vehicle/VehicleGPSFactGroup.cc \
src/Vehicle/VehicleLinkManager.cc \
src/Vehicle/VehicleSetpointFactGroup.cc \
src/Vehicle/VehicleTemperatureFactGroup.cc \
src/Vehicle/VehicleVibrationFactGroup.cc \
......
......@@ -474,11 +474,11 @@ LogDownloadController::_requestLogData(uint16_t id, uint32_t offset, uint32_t co
mavlink_msg_log_request_data_pack_chan(
qgcApp()->toolbox()->mavlinkProtocol()->getSystemId(),
qgcApp()->toolbox()->mavlinkProtocol()->getComponentId(),
_vehicle->priorityLink()->mavlinkChannel(),
_vehicle->vehicleLinkManager()->primaryLink()->mavlinkChannel(),
&msg,
qgcApp()->toolbox()->multiVehicleManager()->activeVehicle()->id(), qgcApp()->toolbox()->multiVehicleManager()->activeVehicle()->defaultComponentId(),
id, offset, count);
_vehicle->sendMessageOnLinkThreadSafe(_vehicle->priorityLink(), msg);
_vehicle->sendMessageOnLinkThreadSafe(_vehicle->vehicleLinkManager()->primaryLink(), msg);
}
}
......@@ -502,13 +502,13 @@ LogDownloadController::_requestLogList(uint32_t start, uint32_t end)
mavlink_msg_log_request_list_pack_chan(
qgcApp()->toolbox()->mavlinkProtocol()->getSystemId(),
qgcApp()->toolbox()->mavlinkProtocol()->getComponentId(),
_vehicle->priorityLink()->mavlinkChannel(),
_vehicle->vehicleLinkManager()->primaryLink()->mavlinkChannel(),
&msg,
_vehicle->id(),
_vehicle->defaultComponentId(),
start,
end);
_vehicle->sendMessageOnLinkThreadSafe(_vehicle->priorityLink(), msg);
_vehicle->sendMessageOnLinkThreadSafe(_vehicle->vehicleLinkManager()->primaryLink(), msg);
//-- Wait 5 seconds before bitching about not getting anything
_timer.start(5000);
}
......@@ -646,7 +646,7 @@ LogDownloadController::_setDownloading(bool active)
{
if (_downloadingLogs != active) {
_downloadingLogs = active;
_vehicle->setConnectionLostEnabled(!active);
_vehicle->vehicleLinkManager()->setCommunicationLostEnabled(!active);
emit downloadingLogsChanged();
}
}
......@@ -657,7 +657,7 @@ LogDownloadController::_setListing(bool active)
{
if (_requestingLogEntries != active) {
_requestingLogEntries = active;
_vehicle->setConnectionLostEnabled(!active);
_vehicle->vehicleLinkManager()->setCommunicationLostEnabled(!active);
emit requestingListChanged();
}
}
......@@ -671,10 +671,10 @@ LogDownloadController::eraseAll(void)
mavlink_msg_log_erase_pack_chan(
qgcApp()->toolbox()->mavlinkProtocol()->getSystemId(),
qgcApp()->toolbox()->mavlinkProtocol()->getComponentId(),
_vehicle->priorityLink()->mavlinkChannel(),
_vehicle->vehicleLinkManager()->primaryLink()->mavlinkChannel(),
&msg,
qgcApp()->toolbox()->multiVehicleManager()->activeVehicle()->id(), qgcApp()->toolbox()->multiVehicleManager()->activeVehicle()->defaultComponentId());
_vehicle->sendMessageOnLinkThreadSafe(_vehicle->priorityLink(), msg);
_vehicle->sendMessageOnLinkThreadSafe(_vehicle->vehicleLinkManager()->primaryLink(), msg);
refresh();
}
}
......
......@@ -116,12 +116,12 @@ MavlinkConsoleController::_sendSerialData(QByteArray data, bool close)
uint8_t flags = SERIAL_CONTROL_FLAG_EXCLUSIVE | SERIAL_CONTROL_FLAG_RESPOND | SERIAL_CONTROL_FLAG_MULTI;
if (close) flags = 0;
auto protocol = qgcApp()->toolbox()->mavlinkProtocol();
auto priority_link = _vehicle->priorityLink();
auto link = _vehicle->vehicleLinkManager()->primaryLink();
mavlink_message_t msg;
mavlink_msg_serial_control_pack_chan(
protocol->getSystemId(),
protocol->getComponentId(),
priority_link->mavlinkChannel(),
link->mavlinkChannel(),
&msg,
SERIAL_CONTROL_DEV_SHELL,
flags,
......@@ -129,7 +129,7 @@ MavlinkConsoleController::_sendSerialData(QByteArray data, bool close)
0,
chunk.size(),
reinterpret_cast<uint8_t*>(chunk.data()));
_vehicle->sendMessageOnLinkThreadSafe(priority_link, msg);
_vehicle->sendMessageOnLinkThreadSafe(link, msg);
data.remove(0, chunk.size());
}
}
......
......@@ -198,6 +198,8 @@ QString APMAutoPilotPlugin::prerequisiteSetup(VehicleComponent* component) const
void APMAutoPilotPlugin::_checkForBadCubeBlack(void)
{
bool cubeBlackFound = false;
#if 0
// FIXME: Put back
for (const QVariant& varLink: _vehicle->links()) {
SerialLink* serialLink = varLink.value<SerialLink*>();
if (serialLink && QSerialPortInfo(*serialLink->_hackAccessToPort()).description().contains(QStringLiteral("CubeBlack"))) {
......@@ -205,6 +207,7 @@ void APMAutoPilotPlugin::_checkForBadCubeBlack(void)
}
}
#endif
if (!cubeBlackFound) {
return;
}
......
......@@ -150,7 +150,7 @@ void APMSensorsComponentController::_resetInternalState(void)
void APMSensorsComponentController::_stopCalibration(APMSensorsComponentController::StopCalibrationCode code)
{
_vehicle->setConnectionLostEnabled(true);
_vehicle->vehicleLinkManager()->setCommunicationLostEnabled(true);
disconnect(_vehicle, &Vehicle::textMessageReceived, this, &APMSensorsComponentController::_handleUASTextMessage);
......@@ -292,7 +292,7 @@ void APMSensorsComponentController::calibrateCompass(void)
void APMSensorsComponentController::calibrateAccel(void)
{
_calTypeInProgress = CalTypeAccel;
_vehicle->setConnectionLostEnabled(false);
_vehicle->vehicleLinkManager()->setCommunicationLostEnabled(false);
_startLogCalibration();
_vehicle->startCalibration(Vehicle::CalibrationAccel);
}
......@@ -300,7 +300,7 @@ void APMSensorsComponentController::calibrateAccel(void)
void APMSensorsComponentController::calibrateMotorInterference(void)
{
_calTypeInProgress = CalTypeCompassMot;
_vehicle->setConnectionLostEnabled(false);
_vehicle->vehicleLinkManager()->setCommunicationLostEnabled(false);
_startLogCalibration();
_appendStatusLog(tr("Raise the throttle slowly to between 50% ~ 75% (the props will spin!) for 5 ~ 10 seconds."));
_appendStatusLog(tr("Quickly bring the throttle back down to zero"));
......@@ -311,7 +311,7 @@ void APMSensorsComponentController::calibrateMotorInterference(void)
void APMSensorsComponentController::levelHorizon(void)
{
_calTypeInProgress = CalTypeLevelHorizon;
_vehicle->setConnectionLostEnabled(false);
_vehicle->vehicleLinkManager()->setCommunicationLostEnabled(false);
_startLogCalibration();
_appendStatusLog(tr("Hold the vehicle in its level flight position."));
_vehicle->startCalibration(Vehicle::CalibrationLevel);
......@@ -320,7 +320,7 @@ void APMSensorsComponentController::levelHorizon(void)
void APMSensorsComponentController::calibratePressure(void)
{
_calTypeInProgress = CalTypePressure;
_vehicle->setConnectionLostEnabled(false);
_vehicle->vehicleLinkManager()->setCommunicationLostEnabled(false);
_startLogCalibration();
_appendStatusLog(tr("Requesting pressure calibration..."));
_vehicle->startCalibration(Vehicle::CalibrationAPMPressureAirspeed);
......@@ -329,7 +329,7 @@ void APMSensorsComponentController::calibratePressure(void)
void APMSensorsComponentController::calibrateGyro(void)
{
_calTypeInProgress = CalTypeGyro;
_vehicle->setConnectionLostEnabled(false);
_vehicle->vehicleLinkManager()->setCommunicationLostEnabled(false);
_startLogCalibration();
_appendStatusLog(tr("Requesting gyro calibration..."));
_vehicle->startCalibration(Vehicle::CalibrationGyro);
......@@ -507,7 +507,7 @@ void APMSensorsComponentController::nextClicked(void)
mavlink_message_t msg;
mavlink_msg_command_ack_pack_chan(qgcApp()->toolbox()->mavlinkProtocol()->getSystemId(),
qgcApp()->toolbox()->mavlinkProtocol()->getComponentId(),
_vehicle->priorityLink()->mavlinkChannel(),
_vehicle->vehicleLinkManager()->primaryLink()->mavlinkChannel(),
&msg,
0, // command
1, // result
......@@ -516,7 +516,7 @@ void APMSensorsComponentController::nextClicked(void)
0, // target_system
0); // target_component
_vehicle->sendMessageOnLinkThreadSafe(_vehicle->priorityLink(), msg);
_vehicle->sendMessageOnLinkThreadSafe(_vehicle->vehicleLinkManager()->primaryLink(), msg);
if (_calTypeInProgress == CalTypeCompassMot) {
_stopCalibration(StopCalibrationSuccess);
......@@ -535,7 +535,7 @@ bool APMSensorsComponentController::accelSetupNeeded(void) const
bool APMSensorsComponentController::usingUDPLink(void)
{
return _vehicle->priorityLink()->getLinkConfiguration()->type() == LinkConfiguration::TypeUdp;
return _vehicle->vehicleLinkManager()->primaryLink()->linkConfiguration()->type() == LinkConfiguration::TypeUdp;
}
void APMSensorsComponentController::_handleCommandAck(mavlink_message_t& message)
......
......@@ -7,15 +7,12 @@
*
****************************************************************************/
/// @file
/// @author Don Gagne <don@thegagnes.com>
#include "AirframeComponentController.h"
#include "AirframeComponentAirframes.h"
#include "QGCMAVLink.h"
#include "MultiVehicleManager.h"
#include "QGCApplication.h"
#include "LinkManager.h"
#include <QVariant>
#include <QQmlProperty>
......
......@@ -65,7 +65,7 @@ SensorsComponentController::SensorsComponentController(void)
bool SensorsComponentController::usingUDPLink(void)
{
return _vehicle->priorityLink()->getLinkConfiguration()->type() == LinkConfiguration::TypeUdp;
return _vehicle->vehicleLinkManager()->primaryLink()->linkConfiguration()->type() == LinkConfiguration::TypeUdp;
}
/// Appends the specified text to the status log area in the ui
......
......@@ -1176,12 +1176,12 @@ QGCCameraControl::_requestAllParameters()
mavlink_msg_param_ext_request_list_pack_chan(
static_cast<uint8_t>(mavlink->getSystemId()),
static_cast<uint8_t>(mavlink->getComponentId()),
_vehicle->priorityLink()->mavlinkChannel(),
_vehicle->vehicleLinkManager()->primaryLink()->mavlinkChannel(),
&msg,
static_cast<uint8_t>(_vehicle->id()),
static_cast<uint8_t>(compID()),
0); // trimmed messages = false
_vehicle->sendMessageOnLinkThreadSafe(_vehicle->priorityLink(), msg);
_vehicle->sendMessageOnLinkThreadSafe(_vehicle->vehicleLinkManager()->primaryLink(), msg);
qCDebug(CameraControlVerboseLog) << "Request all parameters";
}
......
......@@ -188,10 +188,10 @@ QGCCameraParamIO::_sendParameter()
mavlink_msg_param_ext_set_encode_chan(
static_cast<uint8_t>(_pMavlink->getSystemId()),
static_cast<uint8_t>(_pMavlink->getComponentId()),
_vehicle->priorityLink()->mavlinkChannel(),
_vehicle->vehicleLinkManager()->primaryLink()->mavlinkChannel(),
&msg,
&p);
_vehicle->sendMessageOnLinkThreadSafe(_vehicle->priorityLink(), msg);
_vehicle->sendMessageOnLinkThreadSafe(_vehicle->vehicleLinkManager()->primaryLink(), msg);
_paramWriteTimer.start();
}
......@@ -358,13 +358,13 @@ QGCCameraParamIO::paramRequest(bool reset)
mavlink_msg_param_ext_request_read_pack_chan(
static_cast<uint8_t>(_pMavlink->getSystemId()),
static_cast<uint8_t>(_pMavlink->getComponentId()),
_vehicle->priorityLink()->mavlinkChannel(),
_vehicle->vehicleLinkManager()->primaryLink()->mavlinkChannel(),
&msg,
static_cast<uint8_t>(_vehicle->id()),
static_cast<uint8_t>(_control->compID()),
param_id,
-1,
0); // trimmed messages = false
_vehicle->sendMessageOnLinkThreadSafe(_vehicle->priorityLink(), msg);
_vehicle->sendMessageOnLinkThreadSafe(_vehicle->vehicleLinkManager()->primaryLink(), msg);
_paramRequestTimer.start();
}
......@@ -81,7 +81,7 @@ ParameterManager::ParameterManager(Vehicle* vehicle)
, _waitingForDefaultComponent (false)
, _saveRequired (false)
, _metaDataAddedToFacts (false)
, _logReplay (vehicle->priorityLink() && vehicle->priorityLink()->isLogReplay())
, _logReplay (vehicle->vehicleLinkManager()->primaryLink() && vehicle->vehicleLinkManager()->primaryLink()->isLogReplay())
, _parameterSetMajorVersion (-1)
, _prevWaitingReadParamIndexCount (0)
, _prevWaitingReadParamNameCount (0)
......@@ -477,7 +477,11 @@ void ParameterManager::_valueUpdated(const QVariant& value)
void ParameterManager::refreshAllParameters(uint8_t componentId)
{
if (_vehicle->highLatencyLink() || _logReplay) {
if (!_vehicle->vehicleLinkManager()->primaryLink()) {
return;
}
if (_vehicle->vehicleLinkManager()->primaryLink()->linkConfiguration()->isHighLatency() || _logReplay) {
// These links don't load params
_parametersReady = true;
_missingParameters = true;
......@@ -511,11 +515,11 @@ void ParameterManager::refreshAllParameters(uint8_t componentId)
mavlink_message_t msg;
mavlink_msg_param_request_list_pack_chan(mavlink->getSystemId(),
mavlink->getComponentId(),
_vehicle->priorityLink()->mavlinkChannel(),
_vehicle->vehicleLinkManager()->primaryLink()->mavlinkChannel(),
&msg,
_vehicle->id(),
componentId);
_vehicle->sendMessageOnLinkThreadSafe(_vehicle->priorityLink(), msg);
_vehicle->sendMessageOnLinkThreadSafe(_vehicle->vehicleLinkManager()->primaryLink(), msg);
QString what = (componentId == MAV_COMP_ID_ALL) ? "MAV_COMP_ID_ALL" : QString::number(componentId);
qCDebug(ParameterManagerLog) << _logVehiclePrefix(-1) << "Request to refresh all parameters for component ID:" << what;
......@@ -814,13 +818,13 @@ void ParameterManager::_readParameterRaw(int componentId, const QString& paramNa
strncpy(fixedParamName, paramName.toStdString().c_str(), sizeof(fixedParamName));
mavlink_msg_param_request_read_pack_chan(_mavlink->getSystemId(), // QGC system id
_mavlink->getComponentId(), // QGC component id
_vehicle->priorityLink()->mavlinkChannel(),
_vehicle->vehicleLinkManager()->primaryLink()->mavlinkChannel(),
&msg, // Pack into this mavlink_message_t
_vehicle->id(), // Target system id
componentId, // Target component id
fixedParamName, // Named parameter being requested
paramIndex); // Parameter index being requested, -1 for named
_vehicle->sendMessageOnLinkThreadSafe(_vehicle->priorityLink(), msg);
_vehicle->sendMessageOnLinkThreadSafe(_vehicle->vehicleLinkManager()->primaryLink(), msg);
}
void ParameterManager::_writeParameterRaw(int componentId, const QString& paramName, const QVariant& value)
......@@ -876,10 +880,10 @@ void ParameterManager::_writeParameterRaw(int componentId, const QString& paramN
mavlink_message_t msg;
mavlink_msg_param_set_encode_chan(_mavlink->getSystemId(),
_mavlink->getComponentId(),
_vehicle->priorityLink()->mavlinkChannel(),
_vehicle->vehicleLinkManager()->primaryLink()->mavlinkChannel(),
&msg,
&p);
_vehicle->sendMessageOnLinkThreadSafe(_vehicle->priorityLink(), msg);
_vehicle->sendMessageOnLinkThreadSafe(_vehicle->vehicleLinkManager()->primaryLink(), msg);
}
void ParameterManager::_writeLocalParamCache(int vehicleId, int componentId)
......@@ -975,10 +979,10 @@ void ParameterManager::_tryCacheHashLoad(int vehicleId, int componentId, QVarian
mavlink_message_t msg;
mavlink_msg_param_set_encode_chan(_mavlink->getSystemId(),
_mavlink->getComponentId(),
_vehicle->priorityLink()->mavlinkChannel(),
_vehicle->vehicleLinkManager()->primaryLink()->mavlinkChannel(),
&msg,
&p);
_vehicle->sendMessageOnLinkThreadSafe(_vehicle->priorityLink(), msg);
_vehicle->sendMessageOnLinkThreadSafe(_vehicle->vehicleLinkManager()->primaryLink(), msg);
// Give the user some feedback things loaded properly
QVariantAnimation *ani = new QVariantAnimation(this);
......
......@@ -970,11 +970,11 @@ void APMFirmwarePlugin::guidedModeChangeAltitude(Vehicle* vehicle, double altitu
mavlink_msg_set_position_target_local_ned_encode_chan(
static_cast<uint8_t>(mavlink->getSystemId()),
static_cast<uint8_t>(mavlink->getComponentId()),
vehicle->priorityLink()->mavlinkChannel(),
vehicle->vehicleLinkManager()->primaryLink()->mavlinkChannel(),
&msg,
&cmd);
vehicle->sendMessageOnLinkThreadSafe(vehicle->priorityLink(), msg);
vehicle->sendMessageOnLinkThreadSafe(vehicle->vehicleLinkManager()->primaryLink(), msg);
}
void APMFirmwarePlugin::guidedModeTakeoff(Vehicle* vehicle, double altitudeRel)
......@@ -1103,7 +1103,7 @@ void APMFirmwarePlugin::_handleRCChannels(Vehicle* vehicle, mavlink_message_t* m
mavlink_msg_rc_channels_encode_chan(
static_cast<uint8_t>(mavlink->getSystemId()),
static_cast<uint8_t>(mavlink->getComponentId()),
vehicle->priorityLink()->mavlinkChannel(),
vehicle->vehicleLinkManager()->primaryLink()->mavlinkChannel(),
message,
&channels);
}
......@@ -1120,7 +1120,7 @@ void APMFirmwarePlugin::_handleRCChannelsRaw(Vehicle* vehicle, mavlink_message_t
mavlink_msg_rc_channels_raw_encode_chan(
static_cast<uint8_t>(mavlink->getSystemId()),
static_cast<uint8_t>(mavlink->getComponentId()),
vehicle->priorityLink()->mavlinkChannel(),
vehicle->vehicleLinkManager()->primaryLink()->mavlinkChannel(),
message,
&channels);
}
......@@ -1165,8 +1165,8 @@ void APMFirmwarePlugin::_sendGCSMotionReport(Vehicle* vehicle, FollowMe::GCSMoti
mavlink_message_t message;
mavlink_msg_global_position_int_encode_chan(static_cast<uint8_t>(mavlinkProtocol->getSystemId()),
static_cast<uint8_t>(mavlinkProtocol->getComponentId()),
vehicle->priorityLink()->mavlinkChannel(),
vehicle->vehicleLinkManager()->primaryLink()->mavlinkChannel(),
&message,
&globalPositionInt);
vehicle->sendMessageOnLinkThreadSafe(vehicle->priorityLink(), message);
vehicle->sendMessageOnLinkThreadSafe(vehicle->vehicleLinkManager()->primaryLink(), message);
}
......@@ -1051,8 +1051,8 @@ void FirmwarePlugin::sendGCSMotionReport(Vehicle* vehicle, FollowMe::GCSMotionRe
mavlink_message_t message;
mavlink_msg_follow_target_encode_chan(static_cast<uint8_t>(mavlinkProtocol->getSystemId()),
static_cast<uint8_t>(mavlinkProtocol->getComponentId()),
vehicle->priorityLink()->mavlinkChannel(),
vehicle->vehicleLinkManager()->primaryLink()->mavlinkChannel(),
&message,
&follow_target);
vehicle->sendMessageOnLinkThreadSafe(vehicle->priorityLink(), message);
vehicle->sendMessageOnLinkThreadSafe(vehicle->vehicleLinkManager()->primaryLink(), message);
}
......@@ -29,7 +29,7 @@ Item {
property double _ar: QGroundControl.videoManager.aspectRatio
property bool _showGrid: QGroundControl.settingsManager.videoSettings.gridLines.rawValue > 0
property var _dynamicCameras: globals.activeVehicle ? globals.activeVehicle.cameraManager : null
property bool _connected: globals.activeVehicle ? !globals.activeVehicle.connectionLost : false
property bool _connected: globals.activeVehicle ? !globals.activeVehicle.communicationLost : false
property int _curCameraIndex: _dynamicCameras ? _dynamicCameras.currentCamera : 0
property bool _isCamera: _dynamicCameras ? _dynamicCameras.cameras.count > 0 : false
property var _camera: _isCamera ? _dynamicCameras.cameras.get(_curCameraIndex) : null
......
......@@ -85,7 +85,7 @@ Item {
QGCButton {
Layout.fillWidth: true
text: qsTr("Remove plan from vehicle")
visible: !_activeVehicle.connectionLost// && !_activeVehicle.apmFirmware // ArduPilot has a bug somewhere with mission clear
visible: !_activeVehicle.communicationLost// && !_activeVehicle.apmFirmware // ArduPilot has a bug somewhere with mission clear
onClicked: {
_planController.removeAllFromVehicle()
hideDialog()
......@@ -108,7 +108,7 @@ Item {
ColumnLayout {
Layout.fillWidth: true
spacing: ScreenTools.defaultFontPixelHeight
visible: !_activeVehicle.connectionLost && globals.guidedControllerFlyView.showResumeMission
visible: !_activeVehicle.communicationLost && globals.guidedControllerFlyView.showResumeMission
QGCButton {
Layout.fillWidth: true
......
......@@ -156,12 +156,12 @@ Item {
z: QGroundControl.zOrderTopMost + 1
width: parent.width - (_pipOverlay.width / 2)
height: Math.min(parent.height * 0.25, ScreenTools.defaultFontPixelWidth * 16)
visible: _virtualJoystickEnabled && !QGroundControl.videoManager.fullScreen && !(_activeVehicle ? _activeVehicle.highLatencyLink : false)
visible: _virtualJoystickEnabled && !QGroundControl.videoManager.fullScreen && !(_activeVehicle ? _activeVehicle.usingHighLatencyLink : false)
anchors.bottom: parent.bottom
anchors.bottomMargin: parentToolInsets.leftEdgeBottomInset + ScreenTools.defaultFontPixelHeight * 2
anchors.horizontalCenter: parent.horizontalCenter
source: "qrc:/qml/VirtualJoystick.qml"
active: _virtualJoystickEnabled && !(_activeVehicle ? _activeVehicle.highLatencyLink : false)
active: _virtualJoystickEnabled && !(_activeVehicle ? _activeVehicle.usingHighLatencyLink : false)
property bool autoCenterThrottle: QGroundControl.settingsManager.appSettings.virtualJoystickAutoCenterThrottle.rawValue
......
......@@ -32,13 +32,12 @@ Item {
property var _rallyPointController: masterController.rallyPointController
property var _guidedController: globals.guidedControllerFlyView
property var _missionLineViewComponent
property bool _isActiveVehicle: vehicle.active
property string fmode: vehicle.flightMode
// Add the mission item visuals to the map
Repeater {
model: _isActiveVehicle && largeMapView ? _missionController.visualItems : 0
model: largeMapView ? _missionController.visualItems : 0
delegate: MissionItemMapVisual {
map: _map
......
......@@ -69,9 +69,9 @@ void RTCMMavlink::sendMessageToVehicle(const mavlink_gps_rtcm_data_t& msg)
mavlink_message_t message;
mavlink_msg_gps_rtcm_data_encode_chan(mavlinkProtocol->getSystemId(),
mavlinkProtocol->getComponentId(),
vehicle->priorityLink()->mavlinkChannel(),
vehicle->vehicleLinkManager()->primaryLink()->mavlinkChannel(),
&message,
&msg);
vehicle->sendMessageOnLinkThreadSafe(vehicle->priorityLink(), message);
vehicle->sendMessageOnLinkThreadSafe(vehicle->vehicleLinkManager()->primaryLink(), message);
}
}
......@@ -18,18 +18,16 @@
QGC_LOGGING_CATEGORY(GeoFenceManagerLog, "GeoFenceManagerLog")
GeoFenceManager::GeoFenceManager(Vehicle* vehicle)
: _vehicle (vehicle)
, _planManager (vehicle, MAV_MISSION_TYPE_FENCE)
, _firstParamLoadComplete (false)
: PlanManager (vehicle, MAV_MISSION_TYPE_FENCE)
#if defined(QGC_AIRMAP_ENABLED)
, _airspaceManager (qgcApp()->toolbox()->airspaceManager())
, _airspaceManager (qgcApp()->toolbox()->airspaceManager())
#endif
{
connect(&_planManager, &PlanManager::inProgressChanged, this, &GeoFenceManager::inProgressChanged);
connect(&_planManager, &PlanManager::error, this, &GeoFenceManager::error);
connect(&_planManager, &PlanManager::removeAllComplete, this, &GeoFenceManager::removeAllComplete);
connect(&_planManager, &PlanManager::sendComplete, this, &GeoFenceManager::_sendComplete);
connect(&_planManager, &PlanManager::newMissionItemsAvailable, this, &GeoFenceManager::_planManagerLoadComplete);
connect(this, &PlanManager::inProgressChanged, this, &GeoFenceManager::inProgressChanged);
connect(this, &PlanManager::error, this, &GeoFenceManager::error);
connect(this, &PlanManager::removeAllComplete, this, &GeoFenceManager::removeAllComplete);
connect(this, &PlanManager::sendComplete, this, &GeoFenceManager::_sendComplete);
connect(this, &PlanManager::newMissionItemsAvailable, this, &GeoFenceManager::_planManagerLoadComplete);
}
GeoFenceManager::~GeoFenceManager()
......@@ -37,16 +35,6 @@ GeoFenceManager::~GeoFenceManager()
}
bool GeoFenceManager::inProgress(void) const
{
return _planManager.inProgress();
}
void GeoFenceManager::loadFromVehicle(void)
{
_planManager.loadFromVehicle();
}
void GeoFenceManager::sendToVehicle(const QGeoCoordinate& breachReturn,
QmlObjectListModel& polygons,
QmlObjectListModel& circles)
......@@ -117,7 +105,7 @@ void GeoFenceManager::sendToVehicle(const QGeoCoordinate& breachReturn,
}
// Plan manager takes control of MissionItems, so no need to delete
_planManager.writeMissionItems(fenceItems);
writeMissionItems(fenceItems);
}
void GeoFenceManager::removeAll(void)
......@@ -126,7 +114,7 @@ void GeoFenceManager::removeAll(void)
_circles.clear();
_breachReturnPoint = QGeoCoordinate();
_planManager.removeAll();
PlanManager::removeAll();
}
void GeoFenceManager::_sendComplete(bool error)
......@@ -156,7 +144,7 @@ void GeoFenceManager::_planManagerLoadComplete(bool removeAllRequested)
MAV_CMD expectedCommand = (MAV_CMD)0;
int expectedVertexCount = 0;
QGCFencePolygon nextPolygon(true /* inclusion */);
const QList<MissionItem*>& fenceItems = _planManager.missionItems();
const QList<MissionItem*>& fenceItems = missionItems();
for (int i=0; i<fenceItems.count(); i++) {
MissionItem* item = fenceItems[i];
......
......@@ -7,8 +7,7 @@
*
****************************************************************************/
#ifndef GeoFenceManager_H
#define GeoFenceManager_H
#pragma once
#include <QObject>
#include <QGeoCoordinate>
......@@ -22,16 +21,16 @@
#include "PlanManager.h"
#include "QGCFencePolygon.h"
#include "QGCFenceCircle.h"
#include "PlanManager.h"
class Vehicle;
class QmlObjectListModel;
class PlanManager;
Q_DECLARE_LOGGING_CATEGORY(GeoFenceManagerLog)
/// This is the base class for firmware specific geofence managers. A geofence manager is responsible
/// for communicating with the vehicle to set/get geofence settings.
class GeoFenceManager : public QObject
class GeoFenceManager : public PlanManager
{
Q_OBJECT
......@@ -39,29 +38,19 @@ public:
GeoFenceManager(Vehicle* vehicle);
~GeoFenceManager();
/// Returns true if GeoFence is supported by this vehicle
virtual bool supported(void) const;
/// Returns true if the manager is currently communicating with the vehicle
virtual bool inProgress(void) const;
/// Load the current settings from the vehicle
/// Signals loadComplete when done
virtual void loadFromVehicle(void);
bool supported(void) const;
/// Send the geofence settings to the vehicle
/// Signals sendComplete when done
virtual void sendToVehicle(const QGeoCoordinate& breachReturn, ///< Breach return point
QmlObjectListModel& polygons, ///< List of QGCFencePolygons
QmlObjectListModel& circles); ///< List of QGCFenceCircles
/// Signals sendComplete when done
void sendToVehicle(const QGeoCoordinate& breachReturn, ///< Breach return point