Files
gcs-nf/MavLinkNode/parameterprocess.h
T
2021-11-13 20:06:59 +08:00

135 lines
2.9 KiB
C++
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
#ifndef PARAMETERPROCESS_H
#define PARAMETERPROCESS_H
#include <QObject>
#include "QDebug"
#include "QThread"
#include "mavlink.h"
#include "QTimer"
#include "QTime"
#include <QtEndian>
#include "ThreadTemplet.h"
#ifdef QtMavlinkNode
#include <mavlinknodeglobal.h>
class MAVLINKNODESHARED_EXPORT ParameterProcess : public ThreadTemplet{
#else
class ParameterProcess : public ThreadTemplet
{
#endif
Q_OBJECT
enum _modetype {
Nop_Mode = 0,
RecieveMode,
TransmitMode
};
enum _readtype {
All = 0,
One = 1
};
typedef struct {
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_;
public:
explicit ParameterProcess(QObject *parent = nullptr);
~ParameterProcess();
_parameter_ status;
public slots:
//读取和写入指令
void ReadCmd(uint8_t m_sysid, uint8_t m_compid, uint8_t type);
void WriteCmd(uint8_t m_sysid, uint8_t m_compid , const char *id, uint8_t type, float value);
void WriteCmd2(uint8_t m_sysid, uint8_t m_compid ,QVariant id,QVariant type,QVariant value);
//线程对外接口
void Parse(mavlink_message_t msg);
QVariant setvalue(mavlink_param_value_t param);
float getvalue(QVariant param,uint8_t type);
QVariant settype(mavlink_param_value_t param);
uint8_t gettype(QVariant type);
QString setid(char *id);
char * getid(QString id);
private slots:
//线程私有接口
void process();
//状态机
void ReadStateMachine(void);
void WriteStateMachine(void);
//所有的相关函数
void set(const char *id, uint8_t type, float value);
void value(float value);
void ext_ack(float value);
void ext_set(const char *id, uint8_t type, float value);
void ext_value(float value);
void request_list(void);
void request_read(const char *id, int16_t index);
signals:
void RecieveValue(mavlink_message_t msg);
private:
//超时时间(ms
int readTimeout = 3000;
int sendTimeout = 3000;
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