@ -69,25 +69,37 @@ void MultiVehicleManager::setToolbox(QGCToolbox *toolbox)
QQmlEngine : : setObjectOwnership ( this , QQmlEngine : : CppOwnership ) ;
QQmlEngine : : setObjectOwnership ( this , QQmlEngine : : CppOwnership ) ;
qmlRegisterUncreatableType < MultiVehicleManager > ( " QGroundControl.MultiVehicleManager " , 1 , 0 , " MultiVehicleManager " , " Reference only " ) ;
qmlRegisterUncreatableType < MultiVehicleManager > ( " QGroundControl.MultiVehicleManager " , 1 , 0 , " MultiVehicleManager " , " Reference only " ) ;
connect ( _toolbox - > linkManager ( ) , & LinkManager : : linkActive , this , & MultiVehicleManager : : _linkActive ) ;
connect ( _mavlinkProtocol , & MAVLinkProtocol : : vehicleHeartbeatInfo , this , & MultiVehicleManager : : _vehicleHeartbeatInfo ) ;
}
}
void MultiVehicleManager : : _linkActive ( LinkInterface * link , int vehicleId , int vehicleFirmwareType , int vehicleType )
void MultiVehicleManager : : _vehicleHeartbeatInfo ( LinkInterface * link , int vehicleId , int vehicleMavlinkVersion , int vehicleFirmwareType , int vehicleType )
{
{
if ( ! getVehicleById ( vehicleId ) ) {
if ( _ignoreVehicleIds . contains ( vehicleId ) | | getVehicleById ( vehicleId ) ) {
qCDebug ( MultiVehicleManagerLog ) < < " Adding new vehicle linkName:vehicleId:vehicleFirmwareType:vehicleType "
return ;
}
qCDebug ( MultiVehicleManagerLog ( ) ) < < " Adding new vehicle link:vehicleId:vehicleMavlinkVersion:vehicleFirmwareType:vehicleType "
< < link - > getName ( )
< < link - > getName ( )
< < vehicleId
< < vehicleId
< < vehicleMavlinkVersion
< < vehicleFirmwareType
< < vehicleFirmwareType
< < vehicleType ;
< < vehicleType ;
Vehicle * vehicle = new Vehicle ( link , vehicleId , ( MAV_AUTOPILOT ) vehicleFirmwareType , ( MAV_TYPE ) vehicleType , _firmwarePluginManager , _autopilotPluginManager , _joystickManager ) ;
if ( vehicleId = = _mavlinkProtocol - > getSystemId ( ) ) {
_app - > showMessage ( QString ( " Warning: A vehicle is using the same system id as QGroundControl: %1 " ) . arg ( vehicleId ) ) ;
}
if ( ! vehicle ) {
QSettings settings ;
qWarning ( ) < < " New Vehicle allocation failed " ;
bool mavlinkVersionCheck = settings . value ( " VERSION_CHECK_ENABLED " , true ) . toBool ( ) ;
if ( mavlinkVersionCheck & & vehicleMavlinkVersion ! = MAVLINK_VERSION ) {
_ignoreVehicleIds + = vehicleId ;
_app - > showMessage ( QString ( " The MAVLink protocol version on vehicle #%1 and QGroundControl differ! "
" It is unsafe to use different MAVLink versions. "
" QGroundControl therefore refuses to connect to vehicle #%1, which sends MAVLink version %2 (QGroundControl uses version %3). " ) . arg ( vehicleId ) . arg ( vehicleMavlinkVersion ) . arg ( MAVLINK_VERSION ) ) ;
return ;
return ;
}
}
Vehicle * vehicle = new Vehicle ( link , vehicleId , ( MAV_AUTOPILOT ) vehicleFirmwareType , ( MAV_TYPE ) vehicleType , _firmwarePluginManager , _autopilotPluginManager , _joystickManager ) ;
connect ( vehicle , & Vehicle : : allLinksInactive , this , & MultiVehicleManager : : _deleteVehiclePhase1 ) ;
connect ( vehicle , & Vehicle : : allLinksInactive , this , & MultiVehicleManager : : _deleteVehiclePhase1 ) ;
connect ( vehicle - > autopilotPlugin ( ) , & AutoPilotPlugin : : parametersReadyChanged , this , & MultiVehicleManager : : _autopilotParametersReadyChanged ) ;
connect ( vehicle - > autopilotPlugin ( ) , & AutoPilotPlugin : : parametersReadyChanged , this , & MultiVehicleManager : : _autopilotParametersReadyChanged ) ;
@ -97,7 +109,6 @@ void MultiVehicleManager::_linkActive(LinkInterface* link, int vehicleId, int ve
setActiveVehicle ( vehicle ) ;
setActiveVehicle ( vehicle ) ;
}
}
}
/// This slot is connected to the Vehicle::allLinksDestroyed signal such that the Vehicle is deleted
/// This slot is connected to the Vehicle::allLinksDestroyed signal such that the Vehicle is deleted
/// and all other right things happen when the Vehicle goes away.
/// and all other right things happen when the Vehicle goes away.