diff --git a/qgroundcontrol.pro b/qgroundcontrol.pro index de732e1..359ba6b 100644 --- a/qgroundcontrol.pro +++ b/qgroundcontrol.pro @@ -697,6 +697,7 @@ HEADERS += \ src/Vehicle/Actuators/Mixer.h \ src/Vehicle/Actuators/MotorAssignment.h \ src/Vehicle/CompInfo.h \ + src/Vehicle/CompInfoActuators.h \ src/Vehicle/CompInfoEvents.h \ src/Vehicle/CompInfoParam.h \ src/Vehicle/CompInfoGeneral.h \ @@ -947,6 +948,7 @@ SOURCES += \ src/Vehicle/Actuators/Mixer.cc \ src/Vehicle/Actuators/MotorAssignment.cc \ src/Vehicle/CompInfo.cc \ + src/Vehicle/CompInfoActuators.cc \ src/Vehicle/CompInfoEvents.cc \ src/Vehicle/CompInfoParam.cc \ src/Vehicle/CompInfoGeneral.cc \ diff --git a/src/Vehicle/CMakeLists.txt b/src/Vehicle/CMakeLists.txt index ee16cf5..e137e7f 100644 --- a/src/Vehicle/CMakeLists.txt +++ b/src/Vehicle/CMakeLists.txt @@ -22,6 +22,8 @@ add_library(Vehicle Autotune.h CompInfo.cc CompInfo.h + CompInfoActuators.cc + CompInfoActuators.h CompInfoEvents.cc CompInfoEvents.h CompInfoParam.cc diff --git a/src/Vehicle/CompInfoActuators.cc b/src/Vehicle/CompInfoActuators.cc new file mode 100644 index 0000000..82d083e --- /dev/null +++ b/src/Vehicle/CompInfoActuators.cc @@ -0,0 +1,25 @@ +/**************************************************************************** + * + * (c) 2020 QGROUNDCONTROL PROJECT + * + * QGroundControl is licensed according to the terms in the file + * COPYING.md in the root of the source code directory. + * + ****************************************************************************/ + +#include "CompInfoActuators.h" +#include "Vehicle.h" + +CompInfoActuators::CompInfoActuators(uint8_t compId, Vehicle* vehicle, QObject* parent) + : CompInfo(COMP_METADATA_TYPE_ACTUATORS, compId, vehicle, parent) +{ + +} + +void CompInfoActuators::setJson(const QString& metadataJsonFileName, const QString& translationJsonFileName) +{ + if (!metadataJsonFileName.isEmpty()) { + vehicle->setActuatorsMetadata(compId, metadataJsonFileName, translationJsonFileName); + } +} + diff --git a/src/Vehicle/CompInfoActuators.h b/src/Vehicle/CompInfoActuators.h new file mode 100644 index 0000000..3f3f1b8 --- /dev/null +++ b/src/Vehicle/CompInfoActuators.h @@ -0,0 +1,31 @@ +/**************************************************************************** + * + * (c) 2020 QGROUNDCONTROL PROJECT + * + * QGroundControl is licensed according to the terms in the file + * COPYING.md in the root of the source code directory. + * + ****************************************************************************/ + +#pragma once + +#include "CompInfo.h" + +#include + +class FactMetaData; +class Vehicle; +class FirmwarePlugin; + +class CompInfoActuators : public CompInfo +{ + Q_OBJECT + +public: + CompInfoActuators(uint8_t compId, Vehicle* vehicle, QObject* parent = nullptr); + + // Overrides from CompInfo + void setJson(const QString& metadataJsonFileName, const QString& translationJsonFileName) override; + +private: +}; diff --git a/src/Vehicle/ComponentInformationManager.cc b/src/Vehicle/ComponentInformationManager.cc index f5384aa..08141f3 100644 --- a/src/Vehicle/ComponentInformationManager.cc +++ b/src/Vehicle/ComponentInformationManager.cc @@ -15,6 +15,7 @@ #include "CompInfoGeneral.h" #include "CompInfoParam.h" #include "CompInfoEvents.h" +#include "CompInfoActuators.h" #include "QGCFileDownload.h" #include "QGCApplication.h" @@ -29,6 +30,7 @@ const ComponentInformationManager::StateFn ComponentInformationManager::_rgState ComponentInformationManager::_stateRequestCompInfoGeneralComplete, ComponentInformationManager::_stateRequestCompInfoParam, ComponentInformationManager::_stateRequestCompInfoEvents, + ComponentInformationManager::_stateRequestCompInfoActuators, ComponentInformationManager::_stateRequestAllCompInfoComplete }; @@ -52,6 +54,7 @@ ComponentInformationManager::ComponentInformationManager(Vehicle* vehicle) _compInfoMap[MAV_COMP_ID_AUTOPILOT1][COMP_METADATA_TYPE_GENERAL] = new CompInfoGeneral (MAV_COMP_ID_AUTOPILOT1, vehicle, this); _compInfoMap[MAV_COMP_ID_AUTOPILOT1][COMP_METADATA_TYPE_PARAMETER] = new CompInfoParam (MAV_COMP_ID_AUTOPILOT1, vehicle, this); _compInfoMap[MAV_COMP_ID_AUTOPILOT1][COMP_METADATA_TYPE_EVENTS] = new CompInfoEvents (MAV_COMP_ID_AUTOPILOT1, vehicle, this); + _compInfoMap[MAV_COMP_ID_AUTOPILOT1][COMP_METADATA_TYPE_ACTUATORS] = new CompInfoActuators (MAV_COMP_ID_AUTOPILOT1, vehicle, this); } int ComponentInformationManager::stateCount(void) const @@ -136,6 +139,18 @@ void ComponentInformationManager::_stateRequestCompInfoEvents(StateMachine* stat } } +void ComponentInformationManager::_stateRequestCompInfoActuators(StateMachine* stateMachine) +{ + ComponentInformationManager* compMgr = static_cast(stateMachine); + + if (compMgr->_isCompTypeSupported(COMP_METADATA_TYPE_ACTUATORS)) { + compMgr->_requestTypeStateMachine.request(compMgr->_compInfoMap[MAV_COMP_ID_AUTOPILOT1][COMP_METADATA_TYPE_ACTUATORS]); + } else { + qCDebug(ComponentInformationManagerLog) << "_stateRequestCompInfoActuators skipping, not supported"; + compMgr->advance(); + } +} + void ComponentInformationManager::_stateRequestAllCompInfoComplete(StateMachine* stateMachine) { ComponentInformationManager* compMgr = static_cast(stateMachine); @@ -208,6 +223,7 @@ QString RequestMetaDataTypeStateMachine::typeToString(void) case COMP_METADATA_TYPE_COMMANDS: return "COMP_METADATA_TYPE_COMMANDS"; case COMP_METADATA_TYPE_PERIPHERALS: return "COMP_METADATA_TYPE_PERIPHERALS"; case COMP_METADATA_TYPE_EVENTS: return "COMP_METADATA_TYPE_EVENTS"; + case COMP_METADATA_TYPE_ACTUATORS: return "COMP_METADATA_TYPE_ACTUATORS"; default: break; } return "Unknown"; diff --git a/src/Vehicle/ComponentInformationManager.h b/src/Vehicle/ComponentInformationManager.h index cf88cc6..30170ba 100644 --- a/src/Vehicle/ComponentInformationManager.h +++ b/src/Vehicle/ComponentInformationManager.h @@ -111,6 +111,7 @@ private: static void _stateRequestCompInfoGeneralComplete(StateMachine* stateMachine); static void _stateRequestCompInfoParam (StateMachine* stateMachine); static void _stateRequestCompInfoEvents (StateMachine* stateMachine); + static void _stateRequestCompInfoActuators (StateMachine* stateMachine); static void _stateRequestAllCompInfoComplete (StateMachine* stateMachine); Vehicle* _vehicle = nullptr;