b
This commit is contained in:
@@ -10,6 +10,8 @@ CommandUI::CommandUI(QWidget *parent) :
|
||||
{
|
||||
ui->setupUi(this);
|
||||
|
||||
this->setAcceptDrops(true);
|
||||
|
||||
m_parent = parent;
|
||||
//检测文件夹,如果不存在,那么就新建一个,这里存着所有的qml文件
|
||||
QDir *Dir = new QDir;
|
||||
@@ -41,6 +43,15 @@ CommandUI::CommandUI(QWidget *parent) :
|
||||
connect(DoubleClickTimer,SIGNAL(timeout()),
|
||||
this,SLOT(DoubleClickTimeout()));
|
||||
|
||||
|
||||
ui->comboBox_seq->hide();
|
||||
ui->label_seq->hide();
|
||||
ui->pushButton_setSeq->hide();
|
||||
|
||||
ui->comboBox_uav->hide();
|
||||
ui->label_uav->hide();
|
||||
ui->pushButton_setUAV->hide();
|
||||
|
||||
}
|
||||
|
||||
CommandUI::~CommandUI()
|
||||
@@ -48,9 +59,54 @@ CommandUI::~CommandUI()
|
||||
delete ui;
|
||||
}
|
||||
|
||||
void CommandUI::wheelEvent(QWheelEvent *e)
|
||||
void CommandUI::wheelEvent(QWheelEvent *event)
|
||||
{
|
||||
int max = ui->tabWidget_Command->count();
|
||||
int current = ui->tabWidget_Command->currentIndex();
|
||||
|
||||
if(event->delta() < 0)
|
||||
{
|
||||
if(current < (max - 1))
|
||||
{
|
||||
current++;
|
||||
ui->tabWidget_Command->setCurrentIndex(current);
|
||||
}
|
||||
}
|
||||
else if(event->delta() > 0)
|
||||
{
|
||||
if(current > 0)
|
||||
{
|
||||
current--;
|
||||
ui->tabWidget_Command->setCurrentIndex(current);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void CommandUI::dragEnterEvent(QDragEnterEvent *event)
|
||||
{
|
||||
|
||||
if(!event->mimeData()->urls()[0].fileName().right(5).compare(tr(".json")))
|
||||
{
|
||||
event->acceptProposedAction();
|
||||
}
|
||||
else
|
||||
{
|
||||
event->ignore();
|
||||
}
|
||||
}
|
||||
|
||||
void CommandUI::dropEvent(QDropEvent *event)
|
||||
{
|
||||
const QMimeData *qm = event->mimeData();
|
||||
|
||||
QString fileName = qm->urls()[0].toLocalFile();
|
||||
|
||||
|
||||
|
||||
if(fileName.right(5) == ".json")
|
||||
{
|
||||
setCommandFile(fileName);
|
||||
}
|
||||
}
|
||||
|
||||
void CommandUI::keyPressEvent(QKeyEvent *event) //键盘按下事件
|
||||
@@ -635,11 +691,21 @@ void CommandUI::commandAccepted(bool flag,uint16_t command,uint8_t result)
|
||||
else
|
||||
{
|
||||
if(string.size() > 0)
|
||||
{
|
||||
|
||||
QVariant flag;
|
||||
Config *cfg = new Config();
|
||||
|
||||
cfg->getTTS(&flag);
|
||||
|
||||
if(flag.toBool())
|
||||
{
|
||||
QTextToSpeech *tts = new QTextToSpeech();
|
||||
tts->say(string);
|
||||
tts->deleteLater();
|
||||
|
||||
}
|
||||
|
||||
emit showMessage(string);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -38,7 +38,9 @@
|
||||
|
||||
#include "Config/Config.h"
|
||||
|
||||
|
||||
#include "QDragEnterEvent"
|
||||
#include "QDropEvent"
|
||||
#include "QMimeData"
|
||||
|
||||
#include "QMessageBox"
|
||||
namespace Ui {
|
||||
@@ -61,9 +63,10 @@ public:
|
||||
~CommandUI();
|
||||
|
||||
protected:
|
||||
void wheelEvent(QWheelEvent *e);
|
||||
void wheelEvent(QWheelEvent *event);
|
||||
void mousePressEvent(QMouseEvent *event);
|
||||
|
||||
void dragEnterEvent(QDragEnterEvent *event);
|
||||
void dropEvent(QDropEvent *event);
|
||||
void keyPressEvent(QKeyEvent *event);
|
||||
|
||||
void loadCommandJson(const QString& jsonFilename);
|
||||
|
||||
@@ -1,11 +1,9 @@
|
||||
#include "ThreadTemplet.h"
|
||||
|
||||
ThreadTemplet::ThreadTemplet(QObject *parent) : QObject(parent)
|
||||
ThreadTemplet::ThreadTemplet(QObject *parent) : QThread(parent)
|
||||
{
|
||||
running_flag = false;
|
||||
moveToThread(this);
|
||||
//connect(this, &ThreadTemplet::started, this, &ThreadTemplet::process);
|
||||
//setRunFrq(50);//default frq = 50
|
||||
|
||||
start();
|
||||
|
||||
@@ -40,6 +38,7 @@ void ThreadTemplet::process()//线程函数
|
||||
|
||||
void ThreadTemplet::run(void)
|
||||
{
|
||||
QThread::msleep(1000/running_frq);
|
||||
|
||||
exec();
|
||||
}
|
||||
|
||||
@@ -36,8 +36,6 @@ signals:
|
||||
public slots:
|
||||
//线程对外接口
|
||||
virtual void setRunFrq(uint32_t frq);
|
||||
virtual void start();
|
||||
virtual void stop();
|
||||
virtual void run();
|
||||
virtual bool isActive(void)
|
||||
{
|
||||
@@ -61,9 +59,5 @@ protected:
|
||||
bool running_flag = false;
|
||||
quint32 running_frq = 50;//50Hz
|
||||
|
||||
QThread *thread;
|
||||
|
||||
|
||||
|
||||
};
|
||||
#endif // THREADTEMPLET_H
|
||||
|
||||
@@ -428,7 +428,7 @@ void MavLinkNode::stop()
|
||||
{
|
||||
if(rtk->isActive())
|
||||
{
|
||||
rtk->stop();
|
||||
//rtk->stop();
|
||||
delete rtk;
|
||||
rtk = nullptr;
|
||||
}
|
||||
|
||||
@@ -152,6 +152,20 @@ void ParameterProcess::WriteCmd(uint8_t m_sysid, uint8_t m_compid ,const char *i
|
||||
}
|
||||
|
||||
|
||||
void ParameterProcess::WriteCmd2(uint8_t m_sysid, uint8_t m_compid ,QVariant id,QVariant type,QVariant value)
|
||||
{
|
||||
if(status.m_Mode == Nop_Mode)
|
||||
{
|
||||
|
||||
sysid = m_sysid;
|
||||
compid = m_compid;
|
||||
|
||||
float par = getvalue(value,gettype(type));
|
||||
|
||||
WriteCmd(sysid,compid,getid(id.toString()),gettype(type),par);
|
||||
}
|
||||
}
|
||||
|
||||
//这个函数类似中断,专门处理接收到的状态
|
||||
void ParameterProcess::Parse(mavlink_message_t msg)
|
||||
{
|
||||
@@ -453,7 +467,7 @@ void ParameterProcess::request_read(const char *id, int16_t index)//
|
||||
|
||||
//================================
|
||||
|
||||
QVariant ParameterProcess::set_value(mavlink_param_value_t param)
|
||||
QVariant ParameterProcess::setvalue(mavlink_param_value_t param)
|
||||
{
|
||||
QVariant value;
|
||||
|
||||
@@ -485,11 +499,19 @@ QVariant ParameterProcess::set_value(mavlink_param_value_t param)
|
||||
}break;
|
||||
case MAV_PARAM_TYPE_UINT64:
|
||||
{
|
||||
#ifdef unix
|
||||
//value = ((ulong *)¶m.param_value)[0];
|
||||
#else
|
||||
value = ((uint64_t *)¶m.param_value)[0];
|
||||
#endif
|
||||
}break;
|
||||
case MAV_PARAM_TYPE_INT64:
|
||||
{
|
||||
#ifdef unix
|
||||
//value = ((long *)¶m.param_value)[0];
|
||||
#else
|
||||
value = ((int64_t *)¶m.param_value)[0];
|
||||
#endif
|
||||
}break;
|
||||
case MAV_PARAM_TYPE_REAL32:
|
||||
{
|
||||
@@ -502,6 +524,7 @@ QVariant ParameterProcess::set_value(mavlink_param_value_t param)
|
||||
default:
|
||||
{
|
||||
value = ((float *)¶m.param_value)[0];
|
||||
//qDebug() << "Unsupported type " << param.param_type;
|
||||
}break;
|
||||
|
||||
}
|
||||
@@ -509,7 +532,7 @@ QVariant ParameterProcess::set_value(mavlink_param_value_t param)
|
||||
return value;
|
||||
}
|
||||
|
||||
float ParameterProcess::get_value(QVariant param,uint8_t type)
|
||||
float ParameterProcess::getvalue(QVariant param,uint8_t type)
|
||||
{
|
||||
float value;
|
||||
union {
|
||||
@@ -590,7 +613,7 @@ float ParameterProcess::get_value(QVariant param,uint8_t type)
|
||||
}
|
||||
|
||||
|
||||
QVariant ParameterProcess::set_type(mavlink_param_value_t param)
|
||||
QVariant ParameterProcess::settype(mavlink_param_value_t param)
|
||||
{
|
||||
QVariant value;
|
||||
|
||||
@@ -640,14 +663,15 @@ QVariant ParameterProcess::set_type(mavlink_param_value_t param)
|
||||
{
|
||||
value = "unknow";
|
||||
}break;
|
||||
|
||||
}
|
||||
|
||||
return value;
|
||||
}
|
||||
|
||||
uint8_t ParameterProcess::get_type(QVariant type)
|
||||
uint8_t ParameterProcess::gettype(QVariant type)
|
||||
{
|
||||
uint8_t value = 0;
|
||||
uint8_t value;
|
||||
|
||||
if(type.toString() == "uint8")
|
||||
{
|
||||
@@ -698,8 +722,8 @@ uint8_t ParameterProcess::get_type(QVariant type)
|
||||
}
|
||||
|
||||
|
||||
//使用QString
|
||||
QString ParameterProcess::set_id(char *id)
|
||||
//浣跨敤QString
|
||||
QString ParameterProcess::setid(char *id)//璁剧疆id,濡傛灉id灏忎簬16锛岄偅涔堣兘澶熸壘鍒°/0锛屽¦傛灉绛変簬鎴栬€呭ぇ浜庯紝閭d箞浼氭壘涓嶅埌锛屽洜姝や贡鐮
|
||||
{
|
||||
QString Name;
|
||||
|
||||
@@ -713,15 +737,7 @@ QString ParameterProcess::set_id(char *id)
|
||||
return Name;
|
||||
}
|
||||
|
||||
char * ParameterProcess::get_id(QVariant Name)
|
||||
char * ParameterProcess::getid(QString id)//寰楀埌id
|
||||
{
|
||||
QString str = Name.toString();
|
||||
|
||||
return str.toLatin1().data();
|
||||
return id.toLatin1().data();
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -81,7 +81,7 @@ 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);
|
||||
|
||||
|
||||
//线程对外接口
|
||||
@@ -95,12 +95,15 @@ public slots:
|
||||
|
||||
void Parse(mavlink_message_t msg);
|
||||
|
||||
QVariant set_value(mavlink_param_value_t param);
|
||||
float get_value(QVariant param,uint8_t type);
|
||||
QVariant set_type(mavlink_param_value_t param);
|
||||
uint8_t get_type(QVariant type);
|
||||
QString set_id(char *id);
|
||||
char *get_id(QVariant Name);
|
||||
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:
|
||||
//线程私有接口
|
||||
|
||||
@@ -11,7 +11,7 @@ rtkprocess::rtkprocess(QObject *parent) : ThreadTemplet(parent)
|
||||
|
||||
rtkprocess::~rtkprocess()
|
||||
{
|
||||
stop();
|
||||
//stop();
|
||||
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user