feat: Service Registry + Bridge 解耦架构 + 全工程代码清理
## 架构升级:Service Registry + Bridge 模式 - 新增 PluginSDK/IPluginServices.h:10 个纯虚服务接口(IDataProvider/ILinkProvider/...) - 新增 MavLinkServiceBridge:单 QObject 实现全部服务,隔离 MavLinkNode 依赖 - 升级 PluginManifest:支持 plugin.json 的 provides/consumes 声明式依赖 - 实现 ExtensionHost::autoWire():元对象自省自动连接信号槽 - 集成到 AppController:initModules() 中创建桥接器并注册到 ServiceRegistry - CockpitPlugin 演示服务发现:initialize() 中通过 PluginContext 查找服务 ## 代码清理 - Plugins/opmap:~280 行死代码(waypointsetting 100行注释块/tilematrix 54行/等27个文件) - Plugins/MavLinkNode:~200 行 GBK 乱码注释翻译为 UTF-8 + 12 行注释死代码 - Plugins/ToolsUI:~222 行死代码(ECU.cpp 82行/INS.cpp 113行/Parse/ToolsUI 等) - StatusUI/Setting/MissionUI:~65 行注释死代码 - Cockpit/leftladder.cpp:10 处 GBK 乱码翻译为中文 - 清理头文件注释掉的 #include(19 处)、空 if-else 分支、注释变量声明 ## 编译验证 - [100%] Built target GCS 零错误 - 运行时 timeout 3s 正常退出,无崩溃
This commit is contained in:
@@ -0,0 +1,272 @@
|
||||
#ifndef Cockpit_H
|
||||
#define Cockpit_H
|
||||
|
||||
#include <QWidget>
|
||||
#include <QMouseEvent>
|
||||
#include "QTimer"
|
||||
#include "QDebug"
|
||||
#include "QPainterPath"
|
||||
|
||||
|
||||
#ifdef QtCockpit
|
||||
#include <cockpitglobal.h>
|
||||
class COCKPITSHARED_EXPORT Cockpit: public QWidget {
|
||||
#else
|
||||
class Cockpit: public QWidget
|
||||
{
|
||||
#endif
|
||||
|
||||
Q_OBJECT
|
||||
public:
|
||||
enum ErrorCode {MaxValueError=1,MinValueError,ThresholdError,TargetError,PrecisionError,ColorError,UnitsEmpty,OutOfRange};
|
||||
|
||||
explicit Cockpit(QWidget *parent = nullptr);
|
||||
~Cockpit();
|
||||
|
||||
|
||||
typedef struct {
|
||||
QColor CentreLineColor;
|
||||
QColor ForeColor;
|
||||
QColor CornerColor;
|
||||
|
||||
QColor GroundColor;//大地颜色
|
||||
QColor SkyColor;//天空颜色
|
||||
|
||||
QColor LedColor;
|
||||
|
||||
QColor CurrentColor;
|
||||
QColor TargetColor;
|
||||
QColor StatusColor;
|
||||
|
||||
QColor NormalColor;
|
||||
QColor NoticeColor;
|
||||
QColor WarningColor;
|
||||
|
||||
QColor WColor;
|
||||
|
||||
}_color;
|
||||
|
||||
typedef struct {
|
||||
|
||||
QString GPS;
|
||||
QString MODE;
|
||||
QString STATE;
|
||||
QString ARM;
|
||||
|
||||
quint8 svn = 0;
|
||||
|
||||
qreal ax = 0;
|
||||
qreal ay = 0;
|
||||
qreal az = 0;
|
||||
|
||||
qreal gx = 0;
|
||||
qreal gy = 0;
|
||||
qreal gz = 0;
|
||||
|
||||
qreal roll = 0;
|
||||
qreal pitch = 0;
|
||||
qreal yaw = 0;
|
||||
|
||||
qreal altitude = 0;
|
||||
qreal altitude_t = 0;
|
||||
qreal height = 0;
|
||||
|
||||
qreal speed = 0;
|
||||
qreal airspeed=0;
|
||||
qreal airspeed_t=0;
|
||||
qreal verticalspeed = 0;
|
||||
qreal verticalspeed_t = 0;
|
||||
|
||||
qreal horizontalspeed = 0;
|
||||
|
||||
qreal AOA = 0;
|
||||
qreal OL = 0;
|
||||
|
||||
|
||||
qreal wp_dist = 0;
|
||||
qreal alt_err = 0;
|
||||
qreal xtrack = 0;
|
||||
|
||||
|
||||
quint8 AirspeedFlag = 0;
|
||||
quint8 AltitudeFlag = 0;
|
||||
|
||||
|
||||
uint32_t rc_byte = 0;
|
||||
uint32_t rtcm_byte = 0;
|
||||
|
||||
bool isSendRTCM = false;
|
||||
|
||||
|
||||
bool isUpdate;
|
||||
|
||||
}_state;
|
||||
|
||||
typedef struct {
|
||||
qreal voltage[10];
|
||||
qreal current[10];
|
||||
}_battery;
|
||||
|
||||
|
||||
|
||||
typedef struct{
|
||||
|
||||
qreal pitch = 0;
|
||||
qreal roll = 0;
|
||||
qreal yaw = 0;
|
||||
|
||||
qreal height = 0;
|
||||
|
||||
qreal airspeed_maximun = 0;
|
||||
qreal airspeed = 0;
|
||||
qreal airspeed_minimun = 0;
|
||||
|
||||
qreal heading = 0;//航线方向
|
||||
qreal position = 0;//侧偏距
|
||||
qreal altitude = 0;//海拔
|
||||
|
||||
qreal verticalspeed = 0;//纵向速度
|
||||
|
||||
bool isUpdate = false;
|
||||
|
||||
}_target;
|
||||
|
||||
|
||||
_target m_Target;
|
||||
_state m_State;
|
||||
_color m_Color;
|
||||
|
||||
Q_SIGNALS:
|
||||
void errorSignal(int);
|
||||
|
||||
void showMessage(const QString &message,int TimeOut = 0);
|
||||
|
||||
|
||||
void changeRTCMstate(bool);
|
||||
|
||||
|
||||
public Q_SLOTS:
|
||||
|
||||
bool NormalSize()
|
||||
{
|
||||
return isNormalSize;
|
||||
}
|
||||
|
||||
void setNormalSize(bool flag)
|
||||
{
|
||||
isNormalSize = flag;
|
||||
}
|
||||
|
||||
//void setUseOpenGL(const bool &value);
|
||||
|
||||
|
||||
|
||||
|
||||
void setPitch(qreal Pitch);
|
||||
void setRoll(qreal Roll);
|
||||
void setYaw(qreal Yaw);
|
||||
void setAttitude(qreal Pitch,qreal Roll,qreal Yaw);
|
||||
void setAttitudeSpeed(qreal PitchSpeed,qreal RollSpeed,qreal YawSpeed);
|
||||
|
||||
void setPitchTarget(qreal Pitch);
|
||||
void setRollTarget(qreal Roll);
|
||||
void setYawTarget(qreal Yaw);
|
||||
void setAttitudeTarget(qreal Pitch,qreal Roll,qreal Yaw);
|
||||
|
||||
void setAltitude(qreal Altitude);
|
||||
void setHeight(double Altitude);
|
||||
void setAltitudeTarget(double Altitude);
|
||||
|
||||
void setSpeed(double speed,uint8_t flag);
|
||||
void setAirSpeed(qreal speed,uint8_t flag);
|
||||
void setAirSpeedTarget(double speed,uint8_t flag);
|
||||
void setAirSpeedFlag(quint8 flag);
|
||||
|
||||
quint8 AirSpeedFlag(void)
|
||||
{
|
||||
return m_State.AirspeedFlag;
|
||||
}
|
||||
|
||||
quint8 AltitudeFlag(void)
|
||||
{
|
||||
return m_State.AltitudeFlag;
|
||||
}
|
||||
|
||||
void setVerticalSpeed(double speed);
|
||||
void setVerticalSpeedTarget(double speed);
|
||||
|
||||
void setLed(QColor LED);
|
||||
|
||||
void setGPS(QString str);
|
||||
void setMode(QString str);
|
||||
void setState(QString str);
|
||||
void setARM(QString str);
|
||||
|
||||
void setSVN(qreal value);
|
||||
|
||||
void setAOA(qreal Value);
|
||||
void setOL(qreal Value);
|
||||
void setXTrack(double value);
|
||||
void setWP_dist(double value);
|
||||
void setAlt_err(double value);
|
||||
|
||||
void setRCByte(uint32_t byte);
|
||||
void setRTCMByte(uint32_t byte);
|
||||
void setRTCMState(bool flag);
|
||||
|
||||
protected:
|
||||
|
||||
void mouseMoveEvent(QMouseEvent *e);
|
||||
void mouseReleaseEvent(QMouseEvent *e);
|
||||
void mousePressEvent(QMouseEvent *e);
|
||||
void mouseDoubleClickEvent(QMouseEvent *e);
|
||||
void wheelEvent(QWheelEvent *e);
|
||||
//void resizeEvent(QResizeEvent *);
|
||||
|
||||
//void hideEvent(QHideEvent *);
|
||||
//void showEvent(QShowEvent *);
|
||||
|
||||
void paintEvent(QPaintEvent *);
|
||||
|
||||
void drawLed(QPainter *painter);
|
||||
|
||||
void drawPitch(QPainter *painter);
|
||||
void drawRoll(QPainter *painter);
|
||||
void drawRollScale(QPainter *painter);
|
||||
|
||||
void drawVRate(QPainter *painter);
|
||||
|
||||
void drawYawScale(QPainter *painter);
|
||||
void drawLeftScale(QPainter *painter);
|
||||
void drawRightScale(QPainter *painter);
|
||||
|
||||
void drawTopStatuts(QPainter *painter);
|
||||
|
||||
void drawRC_RTCM(QPainter *painter);
|
||||
private slots:
|
||||
|
||||
void UpdateTimeout(void);
|
||||
|
||||
|
||||
|
||||
private:
|
||||
bool isNormalSize = true;
|
||||
|
||||
QTimer *UpdateTimer = nullptr;
|
||||
|
||||
qreal Scale = 2100;//默认很大
|
||||
qreal H_pos = 44.7059;
|
||||
qreal V_pos = 43.8235;
|
||||
|
||||
QPoint lastPoint;
|
||||
bool isPress = false;
|
||||
|
||||
//uint8_t speedSelect = 0;
|
||||
|
||||
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
#endif // ALTITUDEPANEL_H
|
||||
@@ -0,0 +1,30 @@
|
||||
#ifndef COCKPITMANAGER_H
|
||||
#define COCKPITMANAGER_H
|
||||
|
||||
#include <QObject>
|
||||
#include <QHash>
|
||||
#include "ICockpitPlugin.h"
|
||||
|
||||
class CockpitManager : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit CockpitManager(QObject *parent = nullptr);
|
||||
|
||||
void registerCockpit(ICockpitPlugin *plugin);
|
||||
void setCurrentCockpit(const QString &name);
|
||||
ICockpitPlugin *currentCockpit() const { return m_current; }
|
||||
ICockpitPlugin *cockpit(const QString &name) const;
|
||||
QStringList cockpitNames() const;
|
||||
|
||||
QWidget *currentWidget() const;
|
||||
|
||||
signals:
|
||||
void cockpitChanged(const QString &name);
|
||||
|
||||
private:
|
||||
QHash<QString, ICockpitPlugin*> m_cockpits;
|
||||
ICockpitPlugin *m_current = nullptr;
|
||||
};
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,57 @@
|
||||
#ifndef LEFTLADDER_H
|
||||
#define LEFTLADDER_H
|
||||
|
||||
#include <QObject>
|
||||
#include "QWidget"
|
||||
#include <QMouseEvent>
|
||||
#include "QDebug"
|
||||
|
||||
#include <QPainter>
|
||||
#include <QtCore/qmath.h>
|
||||
#include "QThread"
|
||||
#include "QDebug"
|
||||
#include "QPicture"
|
||||
|
||||
|
||||
#ifdef QtCockpit
|
||||
#include <Cockpitglobal.h>
|
||||
class COCKPITSHARED_EXPORT LeftLadder: public QWidget{
|
||||
#else
|
||||
class LeftLadder: public QWidget
|
||||
{
|
||||
#endif
|
||||
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit LeftLadder(QWidget *parent = 0);
|
||||
|
||||
|
||||
public slots:
|
||||
void setAirSpeed(float speed);
|
||||
|
||||
|
||||
protected:
|
||||
|
||||
|
||||
void mouseReleaseEvent(QMouseEvent *e);
|
||||
void mousePressEvent(QMouseEvent *e);
|
||||
void mouseDoubleClickEvent(QMouseEvent *e);
|
||||
void wheelEvent(QWheelEvent *e);
|
||||
|
||||
void paintEvent(QPaintEvent *);
|
||||
|
||||
|
||||
void drawLeftScale(QPainter *painter);
|
||||
|
||||
|
||||
|
||||
private:
|
||||
|
||||
float airspeed;
|
||||
|
||||
|
||||
QColor m_CentreLineColor;
|
||||
|
||||
};
|
||||
|
||||
#endif // LEFTLADDER_H
|
||||
Reference in New Issue
Block a user