204 lines
4.6 KiB
C++
204 lines
4.6 KiB
C++
#ifndef COMMANDUI_H
|
|
#define COMMANDUI_H
|
|
|
|
#include <QWidget>
|
|
#include "QFile"
|
|
#include "QDebug"
|
|
|
|
#include "QPushButton"
|
|
#include "CommandButton.h"
|
|
#include "DragButton.h"
|
|
|
|
#include "QJsonArray"
|
|
#include "QJsonDocument"
|
|
#include "QJsonObject"
|
|
#include "QJsonParseError"
|
|
|
|
#include "QDir"
|
|
#include "QFileDialog"
|
|
|
|
#include <QCommonStyle>
|
|
#include "QStyle"
|
|
|
|
#include "multiselector.h"
|
|
#include "Selector.h"
|
|
#include "Inputter.h"
|
|
#include "CharInputter.h"
|
|
#include "Confirm.h"
|
|
#include "CommandEditor.h"
|
|
|
|
#include "QMouseEvent"
|
|
|
|
#include "mavlink.h"
|
|
|
|
#include "QAction"
|
|
#include "QContextMenuEvent"
|
|
#include "QMenu"
|
|
#include <QStackedWidget>
|
|
|
|
#include "Config/Config.h"
|
|
|
|
#include "QDragEnterEvent"
|
|
#include "QDropEvent"
|
|
#include "QMimeData"
|
|
|
|
#include "QMessageBox"
|
|
namespace Ui {
|
|
class CommandUI;
|
|
}
|
|
|
|
class CommandUI : public QWidget
|
|
{
|
|
Q_OBJECT
|
|
|
|
public:
|
|
|
|
enum state{
|
|
success = 0,
|
|
failure,
|
|
twinkle,
|
|
};
|
|
|
|
explicit CommandUI(QWidget *parent = nullptr);
|
|
~CommandUI();
|
|
|
|
protected:
|
|
void wheelEvent(QWheelEvent *event);
|
|
void mousePressEvent(QMouseEvent *event);
|
|
void dragEnterEvent(QDragEnterEvent *event);
|
|
void dropEvent(QDropEvent *event);
|
|
void keyReleaseEvent(QKeyEvent *event);
|
|
|
|
void loadCommandJson(const QString& jsonFilename);
|
|
|
|
public slots:
|
|
void commandAccepted(bool flag,uint16_t command,uint8_t result);
|
|
|
|
void missionConfirm(int group,int seq);
|
|
|
|
void setCommandFile(QString File);
|
|
|
|
void addVehicles(int sysid, int compid);
|
|
|
|
void setCurrent(QVariant value);
|
|
void setPointCount(QList<int> nums);
|
|
|
|
|
|
void CurrentUAV(int id, int comp);
|
|
|
|
signals:
|
|
void Accepted(bool flag,uint16_t command,uint8_t result);
|
|
|
|
void showMessage(const QString &message,int TimeOut = 0);
|
|
void SetCurrentPoint(int seq);
|
|
void SetCurrentUAV(int seq);
|
|
|
|
void cmd_int(float param1, float param2, float param3, float param4, int x, int y, float z);
|
|
void cmd_long( float param1,float param2,float param3,float param4,float param5,float param6,float param7,uint16_t command,uint8_t confirmation);
|
|
|
|
|
|
void WriteParam(uint8_t m_sysid, uint8_t m_compid ,QVariant id,QVariant type,QVariant value);
|
|
|
|
/*
|
|
void searchallPoint(void);
|
|
void searchallUav(void);
|
|
*/
|
|
|
|
void say(QString str);
|
|
|
|
private slots:
|
|
void updateUI(void);
|
|
|
|
void on_commandClicked();
|
|
|
|
void DoubleClickTimeout();
|
|
|
|
void setSecondConfirm(QVariant value);
|
|
void setSecondValue(QVariant value);
|
|
void setParamValue(QVariant value);
|
|
|
|
|
|
|
|
void on_groupBox_Command_clicked();
|
|
|
|
void on_pushButton_setSeq_clicked();
|
|
|
|
void on_pushButton_setUAV_clicked();
|
|
|
|
private:
|
|
|
|
const char* _spacingJsonKey = "spacing";
|
|
const char* _WidthJsonKey = "Width";
|
|
const char* _HeightJsonKey = "Height";
|
|
const char* _versionJsonKey = "version";
|
|
const char* _commentJsonKey = "comment";
|
|
|
|
const char* _ButtonsJsonKey = "Buttons";
|
|
|
|
const char* _PageJsonKey = "Page";
|
|
const char* _TitleJsonKey = "Title";
|
|
const char* _CommandsJsonKey = "Commands";
|
|
|
|
|
|
const char* _dialogJsonKey = "Dialog";
|
|
const char* _TextJsonKey = "Text";
|
|
const char* _rowJsonKey = "row";
|
|
const char* _colunmJsonKey = "column";
|
|
|
|
const char* _typeJsonKey = "Type";
|
|
const char* _noticeJsonKey = "Notice";
|
|
const char* _param1JsonKey = "param1";
|
|
const char* _param2JsonKey = "param2";
|
|
const char* _param3JsonKey = "param3";
|
|
const char* _param4JsonKey = "param4";
|
|
const char* _param5JsonKey = "param5";
|
|
const char* _param6JsonKey = "param6";
|
|
const char* _param7JsonKey = "param7";
|
|
const char* _commandJsonKey = "command";
|
|
const char* _confirmJsonKey = "confirm";
|
|
|
|
QJsonArray CMD_infoArray;
|
|
|
|
int m_spacing = 5;
|
|
int m_width = 75;
|
|
int m_height = 30;
|
|
|
|
QString m_version = 0;
|
|
|
|
QWidget *m_parent;
|
|
|
|
bool floatflag = false;
|
|
|
|
Ui::CommandUI *ui;
|
|
|
|
QTimer *DoubleClickTimer = nullptr;
|
|
|
|
|
|
QString CommandFile = "./commands/Command.json";
|
|
|
|
QString m_name = 0;
|
|
|
|
QVariant m_Type = 0;//0 cmd 1 param
|
|
QVariant m_param1 = 0;
|
|
QVariant m_param2 = 0;
|
|
QVariant m_param3 = 0;
|
|
QVariant m_param4 = 0;
|
|
QVariant m_param5 = 0;
|
|
QVariant m_param6 = 0;
|
|
QVariant m_param7 = 0;
|
|
uint16_t m_command = 10;
|
|
uint8_t m_confirm = 10;
|
|
|
|
|
|
|
|
int m_currentSeq = 0;
|
|
|
|
int m_currentSys = 1;
|
|
int m_currentComp = 1;
|
|
|
|
bool isCofirmShow = false;
|
|
|
|
};
|
|
|
|
#endif // COMMANDUI_H
|