306 lines
7.5 KiB
C++
306 lines
7.5 KiB
C++
#ifndef MAVLINKNODE_H
|
|
#define MAVLINKNODE_H
|
|
|
|
#include <QObject>
|
|
#include "QThread"
|
|
#include "QFile"
|
|
#include "QDebug"
|
|
|
|
#include "mavlink.h"
|
|
#include "replay.h"
|
|
#include "missionprocess.h"
|
|
#include "parameterprocess.h"
|
|
#include "commandprocess.h"
|
|
#include "statusprocess.h"
|
|
#include "Terminal.h"
|
|
#include "sbusparser.h"
|
|
//#include "QAxObject"
|
|
|
|
|
|
#ifdef QtMavlinkNode
|
|
#include <mavlinknodeglobal.h>
|
|
class MAVLINKNODESHARED_EXPORT MavLinkNode : public QObject {
|
|
#else
|
|
class MavLinkNode : public QObject
|
|
{
|
|
#endif
|
|
Q_OBJECT
|
|
|
|
typedef struct {
|
|
qint32 max_size;
|
|
quint8 select;
|
|
QByteArray buff[2];
|
|
}_buffdef;
|
|
|
|
public:
|
|
|
|
typedef struct {
|
|
int sysid; /* ID of message sender system/aircraft */
|
|
int compid; /* ID of the message sender component */
|
|
|
|
mavlink_autopilot_version_t autopilot_version;
|
|
mavlink_sys_status_t sys_status;
|
|
mavlink_heartbeat_t heartbeat;
|
|
mavlink_ping_t ping;
|
|
mavlink_attitude_t attitude;
|
|
mavlink_ins1_t ins1;
|
|
mavlink_ins2_t ins2;
|
|
mavlink_gps_raw_int_t gps_raw_int;
|
|
mavlink_global_position_int_t global_position_int;
|
|
mavlink_servo_output_raw_t servo_output_raw;
|
|
mavlink_rc_channels_raw_t rc_channels_raw;
|
|
mavlink_nav_controller_output_t nav_controller_output;
|
|
mavlink_airspeed_autocal_t airspeed_autocal;
|
|
mavlink_rpm_t rpm;
|
|
mavlink_scaled_pressure_t scaled_pressure;
|
|
mavlink_extended_sys_state_t extended_sys_state;
|
|
mavlink_battery_status_t battery_status;
|
|
mavlink_vibration_t vibration;
|
|
mavlink_enginestate_t enginestate;
|
|
mavlink_vfr_hud_t vfr_hud;
|
|
mavlink_aoa_ssa_t aoa_ssa;
|
|
mavlink_emb_atmo_com_t emb_atom_com;
|
|
mavlink_turbinestate_t turbinstate;
|
|
mavlink_bmustate_t bmustate;
|
|
mavlink_ccmstate_t ccmstate;
|
|
mavlink_serial_control_t serial_control;
|
|
|
|
}_vehicle;
|
|
|
|
|
|
|
|
|
|
explicit MavLinkNode(QObject *parent = nullptr);
|
|
~MavLinkNode();
|
|
|
|
_vehicle vehicle;
|
|
QHash<int,_vehicle> vehicleList;
|
|
|
|
Replay *replay = nullptr;
|
|
|
|
MissionProcess *Mission = nullptr;
|
|
ParameterProcess *Parameter = nullptr;
|
|
commandprocess *Commander = nullptr;
|
|
statusprocess *Status = nullptr;
|
|
terminal *Terminal = nullptr;
|
|
|
|
|
|
bool isCommunicationLost = false;
|
|
|
|
uint64_t rate_in = 0;
|
|
uint64_t count_in = 0;
|
|
|
|
uint64_t rate_out = 0;
|
|
uint64_t count_out = 0;
|
|
|
|
|
|
|
|
uint64_t bittotal = 0;
|
|
|
|
uint64_t parserSuccess = 0;
|
|
uint64_t parserFailure = 0;
|
|
|
|
|
|
uint64_t TotalFrame_1s = 0;
|
|
uint64_t LossFrame_1s = 0;
|
|
|
|
float rssi = 100;
|
|
|
|
uint16_t rcin[20];
|
|
int rcin_cnt = 0;
|
|
bool rcin_update = true;
|
|
|
|
bool remote_enabled;
|
|
|
|
QByteArray rtkrawdata;
|
|
|
|
|
|
QByteArray csvData;
|
|
|
|
QByteArray autopilot_version_csv;
|
|
QByteArray sys_status_csv;
|
|
QByteArray heartbeat_csv;
|
|
QByteArray ping_csv;
|
|
QByteArray attitude_csv;
|
|
QByteArray ins1_csv;
|
|
QByteArray ins2_csv;
|
|
QByteArray gps_raw_int_csv;
|
|
QByteArray global_position_int_csv;
|
|
QByteArray servo_output_raw_csv[10];
|
|
QByteArray rc_channels_raw_csv;
|
|
QByteArray nav_controller_output_csv;
|
|
QByteArray airspeed_autocal_csv;
|
|
QByteArray rpm_csv;
|
|
QByteArray scaled_pressure_csv;
|
|
QByteArray extended_sys_state_csv;
|
|
QByteArray battery_status_csv;
|
|
QByteArray vibration_csv;
|
|
QByteArray enginestate_csv;
|
|
QByteArray vfr_hud_csv;
|
|
QByteArray aoa_ssa_csv;
|
|
QByteArray emb_atom_com_csv;
|
|
QByteArray turbinstate_csv;
|
|
QByteArray bmustate_csv;
|
|
QByteArray ccmstate_csv;
|
|
QByteArray serial_control_csv;
|
|
|
|
|
|
QFile * autopilot_version_file = nullptr;
|
|
QFile * sys_status_file = nullptr;
|
|
QFile * heartbeat_file = nullptr;
|
|
QFile * ping_file = nullptr;
|
|
QFile * attitude_file = nullptr;
|
|
QFile * ins1_file = nullptr;
|
|
QFile * ins2_file = nullptr;
|
|
QFile * gps_raw_int_file = nullptr;
|
|
QFile * global_position_int_file = nullptr;
|
|
QFile * servo_output_raw_file = nullptr;
|
|
QFile * rc_channels_raw_file = nullptr;
|
|
QFile * nav_controller_output_file = nullptr;
|
|
QFile * airspeed_autocal_file = nullptr;
|
|
QFile * rpm_file = nullptr;
|
|
QFile * scaled_pressure_file = nullptr;
|
|
QFile * extended_sys_state_file = nullptr;
|
|
QFile * battery_status_file = nullptr;
|
|
QFile * vibration_file = nullptr;
|
|
QFile * enginestate_file = nullptr;
|
|
QFile * vfr_hud_file = nullptr;
|
|
QFile * aoa_ssa_file = nullptr;
|
|
QFile * emb_atom_com_file = nullptr;
|
|
QFile * turbinstate_file = nullptr;
|
|
QFile * bmustate_file = nullptr;
|
|
QFile * ccmstate_file = nullptr;
|
|
QFile * serial_control_file = nullptr;
|
|
|
|
|
|
signals:
|
|
|
|
void signal_servo_output_raw(mavlink_servo_output_raw_t *servo);
|
|
|
|
|
|
void new_remote_ctrl(QList<uint16_t>);
|
|
|
|
void updateDlink(float rssi,uint64_t byte);
|
|
void CommuniationLost(bool);
|
|
|
|
void showMessage(const QString &message,int TimeOut = 0);
|
|
|
|
void beep(int);
|
|
|
|
void addVehicles(int sysid,int compid);
|
|
|
|
void SendMessageTo(quint8 ch, quint8 *data,quint16 len);
|
|
void recievemsg(mavlink_message_t msg);
|
|
|
|
void state_updated();
|
|
void parameter_updated();
|
|
//void mission_updated();
|
|
|
|
void setCurrentID(int sysid,int compid);
|
|
|
|
|
|
|
|
void setAltitude(int sysid,int compid,double roll,double pitch,double yaw);
|
|
void setPos(int sysid,int compid,double x,double y,double z);
|
|
void setHeading(int sysid,int compid,double x,double y,double z);
|
|
|
|
public slots:
|
|
//线程对外接口
|
|
void setRunFrq(uint32_t frq);
|
|
void start();
|
|
void stop();
|
|
bool isActive(void)
|
|
{
|
|
return running_flag;
|
|
}
|
|
|
|
void CreateCSV(void);
|
|
|
|
//缓存对外接口
|
|
void readPendingDatagramsReplay(void);
|
|
void setbuff(quint32 src, QByteArray data);
|
|
|
|
void setCurrentSelected(int sysid,int compid);
|
|
|
|
void setLogfile(QString file);
|
|
|
|
void setGCSID(int id);
|
|
|
|
void update15Hz(void);
|
|
void readRemote(QByteArray datagram);
|
|
void readRTK(QByteArray datagram);
|
|
|
|
private slots:
|
|
//线程私有接口
|
|
void Send(mavlink_message_t msg);
|
|
void process();
|
|
|
|
//缓存私有接口
|
|
void initbuff(void);
|
|
QByteArray readbuff(quint32 src);
|
|
|
|
void TimerOut(void);
|
|
void LogTimerOut(void);
|
|
void timer_1s_Out(void);
|
|
//解析
|
|
void Mavlinkparse(quint32 src,QByteArray datagram);
|
|
|
|
void MAVLinkRcv_Handler(mavlink_message_t msg);
|
|
|
|
void StatusParse(mavlink_message_t msg);
|
|
void CommandParse(mavlink_message_t msg);
|
|
//
|
|
|
|
//check for new vehicle
|
|
void CheckVehicle(int sysid, int compid);
|
|
|
|
|
|
protected:
|
|
|
|
int Current_sysID = 0xF1;
|
|
int Current_CompID = MAV_COMP_ID_MISSIONPLANNER;
|
|
|
|
enum SourceType{
|
|
c_sock = 0,
|
|
s_port = 1
|
|
};
|
|
|
|
bool hasConneted = false;
|
|
int32_t CommucationOverCount = 5;
|
|
uint64_t CommucationOverTimer = 5000;
|
|
|
|
uint8_t GCS_System_ID = 0xFF;
|
|
|
|
bool running_flag = false;
|
|
quint32 running_frq = 200;//200Hz
|
|
|
|
QThread *thread;
|
|
|
|
|
|
QThread *Parameterthread;
|
|
|
|
SBusParser sbus;
|
|
|
|
QTimer *gdt_timer = nullptr;
|
|
QTimer *timer = nullptr;
|
|
|
|
|
|
QByteArray databuff;
|
|
|
|
_buffdef serial_buff;
|
|
_buffdef client_buff;
|
|
|
|
QString mavlogFileName;
|
|
QFile *mavLogFile = NULL;
|
|
|
|
QTimer *logTimer = nullptr;
|
|
|
|
|
|
|
|
QTimer *timer_1s = nullptr;
|
|
|
|
|
|
};
|
|
|
|
#endif // MAVLINKNODE_H
|