Skip to content

Commit

Permalink
ComponentInformation: add actuators
Browse files Browse the repository at this point in the history
  • Loading branch information
bkueng committed Nov 3, 2021
1 parent 37f04cb commit ccf9224
Show file tree
Hide file tree
Showing 6 changed files with 75 additions and 0 deletions.
2 changes: 2 additions & 0 deletions qgroundcontrol.pro
Expand Up @@ -695,6 +695,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 \
Expand Down Expand Up @@ -942,6 +943,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 \
Expand Down
2 changes: 2 additions & 0 deletions src/Vehicle/CMakeLists.txt
Expand Up @@ -20,6 +20,8 @@ endif()
add_library(Vehicle
CompInfo.cc
CompInfo.h
CompInfoActuators.cc
CompInfoActuators.h
CompInfoEvents.cc
CompInfoEvents.h
CompInfoParam.cc
Expand Down
23 changes: 23 additions & 0 deletions src/Vehicle/CompInfoActuators.cc
@@ -0,0 +1,23 @@
/****************************************************************************
*
* (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)
{
vehicle->setActuatorsMetadata(compId, metadataJsonFileName, translationJsonFileName);
}

31 changes: 31 additions & 0 deletions src/Vehicle/CompInfoActuators.h
@@ -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 changes: 16 additions & 0 deletions src/Vehicle/ComponentInformationManager.cc
Expand Up @@ -15,6 +15,7 @@
#include "CompInfoGeneral.h"
#include "CompInfoParam.h"
#include "CompInfoEvents.h"
#include "CompInfoActuators.h"
#include "QGCFileDownload.h"
#include "QGCApplication.h"

Expand All @@ -29,6 +30,7 @@ const ComponentInformationManager::StateFn ComponentInformationManager::_rgState
ComponentInformationManager::_stateRequestCompInfoGeneralComplete,
ComponentInformationManager::_stateRequestCompInfoParam,
ComponentInformationManager::_stateRequestCompInfoEvents,
ComponentInformationManager::_stateRequestCompInfoActuators,
ComponentInformationManager::_stateRequestAllCompInfoComplete
};

Expand All @@ -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
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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";
Expand Down
1 change: 1 addition & 0 deletions src/Vehicle/ComponentInformationManager.h
Expand Up @@ -111,6 +111,7 @@ class ComponentInformationManager : public StateMachine
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;
Expand Down

0 comments on commit ccf9224

Please sign in to comment.