2020-03-19 23:36:25 +08:00
|
|
|
#ifndef PARAMETERPROCESS_H
|
|
|
|
|
#define PARAMETERPROCESS_H
|
|
|
|
|
|
|
|
|
|
#include <QObject>
|
|
|
|
|
|
|
|
|
|
#include "QDebug"
|
|
|
|
|
#include "QThread"
|
|
|
|
|
#include "mavlink.h"
|
|
|
|
|
#include "QTimer"
|
|
|
|
|
#include "QTime"
|
2020-03-20 22:54:20 +08:00
|
|
|
|
|
|
|
|
#include "ParameterInspector/ParameterInspector.h"
|
|
|
|
|
|
2020-03-19 23:36:25 +08:00
|
|
|
#ifdef QtMavlinkNode
|
|
|
|
|
#include <mavlinknodeglobal.h>
|
|
|
|
|
class MAVLINKNODESHARED_EXPORT ParameterProcess : public QObject{
|
|
|
|
|
#else
|
|
|
|
|
class ParameterProcess : public QObject
|
|
|
|
|
{
|
|
|
|
|
#endif
|
|
|
|
|
Q_OBJECT
|
2020-03-20 18:03:25 +08:00
|
|
|
|
|
|
|
|
|
|
|
|
|
enum _modetype {
|
|
|
|
|
Nop_Mode = 0,
|
|
|
|
|
RecieveMode,
|
|
|
|
|
TransmitMode
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
enum _readtype {
|
|
|
|
|
All = 0,
|
|
|
|
|
One = 1
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
typedef struct {
|
|
|
|
|
//bool isWaitingforCount;
|
|
|
|
|
bool isWaitingforValue;
|
|
|
|
|
|
|
|
|
|
_readtype type;
|
|
|
|
|
|
|
|
|
|
}_recieve;
|
|
|
|
|
|
|
|
|
|
typedef struct {
|
|
|
|
|
uint32_t count;
|
|
|
|
|
//bool isWaiteforRequest;
|
|
|
|
|
bool isWaitingforValue;
|
|
|
|
|
}_transmit;
|
|
|
|
|
|
|
|
|
|
typedef struct
|
|
|
|
|
{
|
|
|
|
|
_recieve recieve;
|
|
|
|
|
_transmit transmit;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
_modetype m_Mode;
|
|
|
|
|
|
|
|
|
|
}_parameter_;
|
|
|
|
|
|
|
|
|
|
|
2020-03-19 23:36:25 +08:00
|
|
|
public:
|
|
|
|
|
explicit ParameterProcess(QObject *parent = nullptr);
|
|
|
|
|
|
2020-03-20 18:03:25 +08:00
|
|
|
_parameter_ status;
|
|
|
|
|
|
2020-03-20 22:54:20 +08:00
|
|
|
|
|
|
|
|
ParameterInspector *paramInspect;
|
|
|
|
|
|
2020-03-23 18:39:05 +08:00
|
|
|
|
|
|
|
|
|
|
|
|
|
public slots:
|
2020-03-20 18:03:25 +08:00
|
|
|
//读取和写入指令
|
|
|
|
|
void ReadCmd(uint8_t m_sysid, uint8_t m_compid, uint8_t type);
|
2020-03-23 18:39:05 +08:00
|
|
|
void WriteCmd(uint8_t m_sysid, uint8_t m_compid ,uint32_t count);
|
|
|
|
|
|
|
|
|
|
|
2020-03-19 23:36:25 +08:00
|
|
|
|
|
|
|
|
//线程对外接口
|
|
|
|
|
void setRunFrq(uint32_t frq);
|
|
|
|
|
void start();
|
|
|
|
|
void stop();
|
|
|
|
|
|
|
|
|
|
|
2020-04-03 09:39:31 +08:00
|
|
|
void Parse(mavlink_message_t msg);
|
2020-03-19 23:36:25 +08:00
|
|
|
|
|
|
|
|
private slots:
|
|
|
|
|
//线程私有接口
|
|
|
|
|
void SendMessage(mavlink_message_t msg);
|
|
|
|
|
|
|
|
|
|
void process();
|
|
|
|
|
|
2020-03-20 18:03:25 +08:00
|
|
|
//状态机
|
|
|
|
|
void ReadStateMachine(void);
|
|
|
|
|
void WriteStateMachine(void);
|
|
|
|
|
|
2020-03-19 23:36:25 +08:00
|
|
|
|
2020-03-20 18:03:25 +08:00
|
|
|
//所有的相关函数
|
|
|
|
|
void set(const char *id, uint8_t type, float value);
|
2020-03-19 23:36:25 +08:00
|
|
|
void value(float value);
|
|
|
|
|
void ext_ack(float value);
|
2020-03-20 18:03:25 +08:00
|
|
|
void ext_set(const char *id, uint8_t type, float value);
|
2020-03-19 23:36:25 +08:00
|
|
|
void ext_value(float value);
|
|
|
|
|
void request_list(void);
|
2020-03-20 18:03:25 +08:00
|
|
|
void request_read(const char *id, int16_t index);
|
2020-03-19 23:36:25 +08:00
|
|
|
|
|
|
|
|
signals:
|
|
|
|
|
void readError();
|
|
|
|
|
|
|
|
|
|
void SendMessageTo(quint8 ch, quint8 *data,quint16 len);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private:
|
2020-04-03 09:39:31 +08:00
|
|
|
//线程运行参数
|
2020-03-19 23:36:25 +08:00
|
|
|
bool running_flag = false;
|
|
|
|
|
quint32 running_frq = 200;//200Hz
|
|
|
|
|
QThread *thread = nullptr;
|
|
|
|
|
|
2020-04-03 09:39:31 +08:00
|
|
|
//目标id
|
2020-03-19 23:36:25 +08:00
|
|
|
uint8_t sysid;
|
|
|
|
|
uint8_t compid;
|
|
|
|
|
|
|
|
|
|
mavlink_param_set_t param_set;//
|
|
|
|
|
mavlink_param_union_t param_union;
|
|
|
|
|
mavlink_param_value_t param_value;//
|
|
|
|
|
mavlink_param_map_rc_t param_map;
|
|
|
|
|
mavlink_param_ext_ack_t param_ext_ack;
|
|
|
|
|
mavlink_param_ext_set_t param_ext_set;
|
|
|
|
|
mavlink_param_ext_value_t param_ext_value;
|
|
|
|
|
mavlink_param_request_list_t param_request_list;//
|
|
|
|
|
mavlink_param_request_read_t param_request_read;//
|
|
|
|
|
mavlink_param_union_double_t param_union_double;
|
|
|
|
|
mavlink_param_ext_request_list_t param_ext_request_list;
|
|
|
|
|
mavlink_param_ext_request_read_t param_ext_request_read;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
#endif // PARAMETERPROCESS_H
|