-
Notifications
You must be signed in to change notification settings - Fork 3.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
20 changed files
with
908 additions
and
1,192 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,44 +7,43 @@ | |
* | ||
****************************************************************************/ | ||
|
||
|
||
/// @file | ||
/// @author Don Gagne <[email protected]> | ||
|
||
#include "AutoPilotPlugin.h" | ||
#include "QGCApplication.h" | ||
#include "FirmwarePlugin.h" | ||
#include "QGCApplication.h" | ||
#include "QGCLoggingCategory.h" | ||
#include "Vehicle.h" | ||
#include "VehicleComponent.h" | ||
|
||
#include <QtCore/QCoreApplication> | ||
|
||
AutoPilotPlugin::AutoPilotPlugin(Vehicle* vehicle, QObject* parent) | ||
QGC_LOGGING_CATEGORY(AutoPilotPluginLog, "qgc.autopilotplugin.autopilotplugin"); | ||
|
||
AutoPilotPlugin::AutoPilotPlugin(Vehicle *vehicle, QObject *parent) | ||
: QObject(parent) | ||
, _vehicle(vehicle) | ||
, _firmwarePlugin(vehicle->firmwarePlugin()) | ||
, _setupComplete(false) | ||
{ | ||
|
||
// qCDebug(AutoPilotPluginLog) << Q_FUNC_INFO << this; | ||
} | ||
|
||
AutoPilotPlugin::~AutoPilotPlugin() | ||
{ | ||
|
||
// qCDebug(AutoPilotPluginLog) << Q_FUNC_INFO << this; | ||
} | ||
|
||
void AutoPilotPlugin::_recalcSetupComplete(void) | ||
void AutoPilotPlugin::_recalcSetupComplete() | ||
{ | ||
bool newSetupComplete = true; | ||
|
||
for(const QVariant& componentVariant: vehicleComponents()) { | ||
VehicleComponent* component = qobject_cast<VehicleComponent*>(qvariant_cast<QObject *>(componentVariant)); | ||
for (const QVariant &componentVariant : vehicleComponents()) { | ||
const VehicleComponent *const component = qobject_cast<const VehicleComponent*>(qvariant_cast<const QObject*>(componentVariant)); | ||
if (component) { | ||
if (!component->setupComplete()) { | ||
newSetupComplete = false; | ||
break; | ||
} | ||
} else { | ||
qWarning() << "AutoPilotPlugin::_recalcSetupComplete Incorrectly typed VehicleComponent"; | ||
qCWarning(AutoPilotPluginLog) << "Incorrectly typed VehicleComponent"; | ||
} | ||
} | ||
|
||
|
@@ -54,22 +53,17 @@ void AutoPilotPlugin::_recalcSetupComplete(void) | |
} | ||
} | ||
|
||
bool AutoPilotPlugin::setupComplete(void) const | ||
{ | ||
return _setupComplete; | ||
} | ||
|
||
void AutoPilotPlugin::parametersReadyPreChecks(void) | ||
void AutoPilotPlugin::parametersReadyPreChecks() | ||
{ | ||
_recalcSetupComplete(); | ||
|
||
// Connect signals in order to keep setupComplete up to date | ||
for(QVariant componentVariant: vehicleComponents()) { | ||
VehicleComponent* component = qobject_cast<VehicleComponent*>(qvariant_cast<QObject *>(componentVariant)); | ||
for (QVariant componentVariant : vehicleComponents()) { | ||
VehicleComponent *const component = qobject_cast<VehicleComponent*>(qvariant_cast<QObject*>(componentVariant)); | ||
if (component) { | ||
connect(component, &VehicleComponent::setupCompleteChanged, this, &AutoPilotPlugin::_recalcSetupComplete); | ||
(void) connect(component, &VehicleComponent::setupCompleteChanged, this, &AutoPilotPlugin::_recalcSetupComplete); | ||
} else { | ||
qWarning() << "AutoPilotPlugin::_recalcSetupComplete Incorrectly typed VehicleComponent"; | ||
qCWarning(AutoPilotPluginLog) << "Incorrectly typed VehicleComponent"; | ||
} | ||
} | ||
|
||
|
@@ -82,12 +76,12 @@ void AutoPilotPlugin::parametersReadyPreChecks(void) | |
} | ||
} | ||
|
||
VehicleComponent* AutoPilotPlugin::findKnownVehicleComponent(KnownVehicleComponent knownVehicleComponent) | ||
VehicleComponent *AutoPilotPlugin::findKnownVehicleComponent(KnownVehicleComponent knownVehicleComponent) | ||
{ | ||
if (knownVehicleComponent != UnknownVehicleComponent) { | ||
for(const QVariant& componentVariant: vehicleComponents()) { | ||
VehicleComponent* component = qobject_cast<VehicleComponent*>(qvariant_cast<QObject *>(componentVariant)); | ||
if (component && component->KnownVehicleComponent() == knownVehicleComponent) { | ||
for (const QVariant &componentVariant: vehicleComponents()) { | ||
VehicleComponent *const component = qobject_cast<VehicleComponent*>(qvariant_cast<QObject *>(componentVariant)); | ||
if (component && (component->KnownVehicleComponent() == knownVehicleComponent)) { | ||
return component; | ||
} | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.