增加通讯协议
This commit is contained in:
+27
-6
@@ -5,9 +5,9 @@
|
||||
#include <QSettings>
|
||||
#include <QVector>
|
||||
#include "global.h"
|
||||
#include "uart.h"
|
||||
|
||||
class UdpCommunication;
|
||||
class MockVehicle;
|
||||
class CarCommunication;
|
||||
|
||||
// 故障历史记录
|
||||
struct FaultRecord {
|
||||
@@ -25,8 +25,8 @@ class AppContext : public QObject
|
||||
public:
|
||||
static AppContext* instance();
|
||||
|
||||
UdpCommunication* comm() const { return m_comm; }
|
||||
MockVehicle* vehicle() const { return m_vehicle; }
|
||||
CarCommunication* comm() const { return m_comm; }
|
||||
RcCommunication* rc() const { return m_rc; }
|
||||
|
||||
// 遥测数据快照(由通信层填充)
|
||||
Telemetry telemetry;
|
||||
@@ -68,17 +68,38 @@ public:
|
||||
// 模式切换(行车/机械臂,由面板机械旋钮或演示按钮触发)
|
||||
void setMode(Mode m);
|
||||
|
||||
// 遥控器:链路状态与“正在操作”判据(遥控器优先时界面按钮让位)
|
||||
bool rcDriving() const { return m_rcDriving; }
|
||||
|
||||
signals:
|
||||
void modeChanged(Mode m);
|
||||
void estopChanged(bool triggered);
|
||||
void commChanged(bool ok);
|
||||
void rcDrivingChanged(bool driving);
|
||||
|
||||
private slots:
|
||||
void onRcFrame(const RcFrame& f);
|
||||
void onRcLinkChanged(bool ok);
|
||||
|
||||
private:
|
||||
explicit AppContext(QObject* parent = nullptr);
|
||||
void seedFaultHistory();
|
||||
|
||||
void applyRcChassis(int gear, int steer, bool enabled);
|
||||
void applyRcArm(const RcFrame& f);
|
||||
void sendChassisCommand(); // 按当前档位/转向方向下发(两者可同时)
|
||||
void updateRcDriving();
|
||||
|
||||
QSettings* m_settings = nullptr;
|
||||
UdpCommunication* m_comm = nullptr;
|
||||
MockVehicle* m_vehicle = nullptr;
|
||||
CarCommunication* m_comm = nullptr;
|
||||
RcCommunication* m_rc = nullptr;
|
||||
|
||||
// 遥控器动作边沿状态:只在方向变化时下发,避免 100ms 刷屏
|
||||
int m_rcGearDir = 0; // -1=后 0=中 +1=前
|
||||
int m_rcSteerDir = 0; // -1=左 0=中 +1=右
|
||||
int m_rcAxisDir[6] = {0, 0, 0, 0, 0, 0}; // 顺序见 kArmAxes
|
||||
bool m_rcEstopPrev = false;
|
||||
bool m_rcDriving = false;
|
||||
};
|
||||
|
||||
// 便捷访问宏
|
||||
|
||||
Reference in New Issue
Block a user