Browse Source

ComponentInformation: add actuators

QGC4.4
Beat Küng 3 years ago committed by Daniel Agar
parent
commit
4b661bed26
  1. 2
      qgroundcontrol.pro
  2. 2
      src/Vehicle/CMakeLists.txt
  3. 25
      src/Vehicle/CompInfoActuators.cc
  4. 31
      src/Vehicle/CompInfoActuators.h
  5. 16
      src/Vehicle/ComponentInformationManager.cc
  6. 1
      src/Vehicle/ComponentInformationManager.h

2
qgroundcontrol.pro

@ -697,6 +697,7 @@ HEADERS += \ @@ -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 += \ @@ -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 \

2
src/Vehicle/CMakeLists.txt

@ -22,6 +22,8 @@ add_library(Vehicle @@ -22,6 +22,8 @@ add_library(Vehicle
Autotune.h
CompInfo.cc
CompInfo.h
CompInfoActuators.cc
CompInfoActuators.h
CompInfoEvents.cc
CompInfoEvents.h
CompInfoParam.cc

25
src/Vehicle/CompInfoActuators.cc

@ -0,0 +1,25 @@ @@ -0,0 +1,25 @@
/****************************************************************************
*
* (c) 2020 QGROUNDCONTROL PROJECT <http://www.qgroundcontrol.org>
*
* 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);
}
}

31
src/Vehicle/CompInfoActuators.h

@ -0,0 +1,31 @@ @@ -0,0 +1,31 @@
/****************************************************************************
*
* (c) 2020 QGROUNDCONTROL PROJECT <http://www.qgroundcontrol.org>
*
* 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 <QObject>
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:
};

16
src/Vehicle/ComponentInformationManager.cc

@ -15,6 +15,7 @@ @@ -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 @@ -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) @@ -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 @@ -136,6 +139,18 @@ void ComponentInformationManager::_stateRequestCompInfoEvents(StateMachine* stat
}
}
void ComponentInformationManager::_stateRequestCompInfoActuators(StateMachine* stateMachine)
{
ComponentInformationManager* compMgr = static_cast<ComponentInformationManager*>(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<ComponentInformationManager*>(stateMachine);
@ -208,6 +223,7 @@ QString RequestMetaDataTypeStateMachine::typeToString(void) @@ -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";

1
src/Vehicle/ComponentInformationManager.h

@ -111,6 +111,7 @@ private: @@ -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;

Loading…
Cancel
Save