diff --git a/App/Config/Config.cpp b/App/Config/Config.cpp index 3a22ed1..4eadb32 100644 --- a/App/Config/Config.cpp +++ b/App/Config/Config.cpp @@ -1,4 +1,4 @@ -#include "Config.h" +#include "Config.h" Config::Config(QObject *parent) : @@ -309,7 +309,7 @@ void Config::setTTS(QVariant value) setJsonObject("Sound",obj); } -void Config::get_ExportInfo(QVariant *state, QVariant *flag, QHostAddress *addr, QVariant *port) +void Config::get_ExportInfo(QVariant *state, QVariant *flag, QHostAddress *addr, QVariant *port, QString &id) { QJsonObject obj = getJsonObject("ExportInfo"); @@ -317,9 +317,10 @@ void Config::get_ExportInfo(QVariant *state, QVariant *flag, QHostAddress *addr, *flag = obj.value("flag").toInt(); *addr = obj.value("addr").toString(); *port = obj.value("port").toInt(); + id = obj.value("id").toString(); } -void Config::set_ExportInfo(QVariant state, QVariant flag, QHostAddress addr, QVariant port) +void Config::set_ExportInfo(QVariant state, QVariant flag, QHostAddress addr, QVariant port, QString id) { QJsonObject obj; @@ -327,6 +328,9 @@ void Config::set_ExportInfo(QVariant state, QVariant flag, QHostAddress addr, QV obj["flag"] = flag.toInt(); obj["addr"] = addr.toString(); obj["port"] = port.toInt(); + obj["id"] = id; + + qDebug() << "id: " << obj["id"].toString(); setJsonObject("ExportInfo",obj); } diff --git a/App/Config/Config.h b/App/Config/Config.h index 7634852..121c1ee 100644 --- a/App/Config/Config.h +++ b/App/Config/Config.h @@ -1,4 +1,4 @@ -#ifndef CONFIG_H +#ifndef CONFIG_H #define CONFIG_H #include @@ -44,8 +44,8 @@ public slots: void get_GCS_ID(QVariant *id); void set_GCS_ID(QVariant id); - void get_ExportInfo(QVariant *state, QVariant *flag, QHostAddress *addr, QVariant *port); - void set_ExportInfo(QVariant state, QVariant flag, QHostAddress addr, QVariant port); + void get_ExportInfo(QVariant *state, QVariant *flag, QHostAddress *addr, QVariant *port, QString &id); + void set_ExportInfo(QVariant state, QVariant flag, QHostAddress addr, QVariant port, QString id); void getBeep(QVariant *value); void setBeep(QVariant value); diff --git a/App/Setting/Index0/Global/GlobalSetting.cpp b/App/Setting/Index0/Global/GlobalSetting.cpp index 5adb3b4..f8673d3 100644 --- a/App/Setting/Index0/Global/GlobalSetting.cpp +++ b/App/Setting/Index0/Global/GlobalSetting.cpp @@ -1,4 +1,4 @@ -#include "GlobalSetting.h" +#include "GlobalSetting.h" #include "ui_GlobalSetting.h" GlobalSetting::GlobalSetting(QWidget *parent) : @@ -125,10 +125,12 @@ GlobalSetting::GlobalSetting(QWidget *parent) : QVariant flag; QHostAddress addr; QVariant port; + QString manufactorId; - cfg->get_ExportInfo(&state, &flag, &addr, &port); + cfg->get_ExportInfo(&state, &flag, &addr, &port, manufactorId); ui->comboBox_export_state->setCurrentIndex(ui->comboBox_export_state->findData(state)); + ui->lineEdit_identifying->setText(manufactorId); bool ss = false; ui->lineEdit_export_flag->setText(QString::number(flag.toUInt())); @@ -155,7 +157,6 @@ GlobalSetting::GlobalSetting(QWidget *parent) : } emit setMapTypes(bingmap.value(maptype.toString())); - } GlobalSetting::~GlobalSetting() @@ -632,11 +633,15 @@ void GlobalSetting::on_pushButton_setExport_clicked() port = ui->lineEdit_export_port->text().toInt(); emit setExportInfo(state,flag,addr,port); + bool ok; + quint16 id = ui->lineEdit_identifying->text().toUInt(&ok, 16); + emit ManufacturerID(id); + qDebug() << "lineEdit_identifying" << ui->lineEdit_identifying->text(); Config *cfg = new Config(); - cfg->set_ExportInfo(state, flag, addr, port); + cfg->set_ExportInfo(state, flag, addr, port, ui->lineEdit_identifying->text() ); cfg->deleteLater(); delete cfg; diff --git a/App/Setting/Index0/Global/GlobalSetting.h b/App/Setting/Index0/Global/GlobalSetting.h index 69ab1f9..418493e 100644 --- a/App/Setting/Index0/Global/GlobalSetting.h +++ b/App/Setting/Index0/Global/GlobalSetting.h @@ -1,4 +1,4 @@ -#ifndef GLOBALSETTING_H +#ifndef GLOBALSETTING_H #define GLOBALSETTING_H #include @@ -68,6 +68,7 @@ private slots: void on_pushButton_TTS_clicked(); signals: + void ManufacturerID(quint16 id); void showMessage(const QString &message,int TimeOut = 0); void setGCSID(int id); diff --git a/App/Setting/Index0/Global/GlobalSetting.ui b/App/Setting/Index0/Global/GlobalSetting.ui index 7a168f7..cdcd41f 100644 --- a/App/Setting/Index0/Global/GlobalSetting.ui +++ b/App/Setting/Index0/Global/GlobalSetting.ui @@ -129,54 +129,12 @@ 入网输出设置 - - - - 飞机编号 - - - - - - - 1 - - - - - - - IP地址 - - - - - - - 192.168.5.72 - - - - - - - 端口 - - - - - - - 10049 - - - - + - Qt::Horizontal + Qt::Orientation::Horizontal @@ -198,6 +156,65 @@ + + + + 端口 + + + + + + + 厂家标识 + + + + + + + 1 + + + + + + + 飞机编号 + + + + + + + 192.168.5.72 + + + + + + + IP地址 + + + + + + + 10049 + + + + + + + + + + 十六进制输入,0x开头输入 + + + @@ -668,7 +685,7 @@ - Qt::Horizontal + Qt::Orientation::Horizontal @@ -681,7 +698,7 @@ - Qt::Vertical + Qt::Orientation::Vertical diff --git a/App/mainwindow.cpp b/App/mainwindow.cpp index 814c1d5..1642c3b 100644 --- a/App/mainwindow.cpp +++ b/App/mainwindow.cpp @@ -1,4 +1,4 @@ -#include "mainwindow.h" +#include "mainwindow.h" #include "QPushButton" #include "QAction" @@ -637,6 +637,8 @@ MainWindow::MainWindow(QWidget *parent) dlink->mavlinknode->Status,&statusprocess::setHeartbeat,Qt::DirectConnection); //设置地面站ID + connect(setting->index0->globalsetting, &GlobalSetting::ManufacturerID, dlink->mavlinknode, &MavLinkNode::setManufacturerIdentification, Qt::DirectConnection); + setting->index0->globalsetting->getGCSID(); setting->index0->globalsetting->getServo(); setting->index0->globalsetting->getHeartBeat(); @@ -644,6 +646,7 @@ MainWindow::MainWindow(QWidget *parent) setting->index0->globalsetting->getTTS(); setting->index0->globalsetting->getExportInfo(); + } MainWindow::~MainWindow() diff --git a/MavLinkNode/mavlinknode.cpp b/MavLinkNode/mavlinknode.cpp index 4e156e2..90544b1 100644 --- a/MavLinkNode/mavlinknode.cpp +++ b/MavLinkNode/mavlinknode.cpp @@ -347,6 +347,11 @@ MavLinkNode::~MavLinkNode() qDebug() << "stop mavlink" << QThread::currentThreadId(); } +void MavLinkNode::setManufacturerIdentification(quint16 id) +{ + ManufacturerID = id; +} + void MavLinkNode::setGCSID(int id) { qDebug() << "set GCS ID" << id; @@ -1350,7 +1355,7 @@ void MavLinkNode::StatusParse(mavlink_message_t msg) - info.flag = 0x24a8; + info.flag = ManufacturerID; info.id = infoExportID;//1 //info.time = (int32_t)vehicle.ins1.time;//(second+min*60+hour*3600)*1000 info.time = (int32_t)(sec+min*60+hour*3600)*1000; @@ -1459,7 +1464,7 @@ void MavLinkNode::StatusParse(mavlink_message_t msg) //qDebug() << gpstimebase->currentMSecsSinceEpoch(); - info.flag = 0x24a8; + info.flag = ManufacturerID; info.id = infoExportID;//1 //info.time = (int32_t)vehicle.ins2.time; info.time = (int32_t)(sec+min*60+hour*3600)*1000; diff --git a/MavLinkNode/mavlinknode.h b/MavLinkNode/mavlinknode.h index c5c515f..f9e8bbc 100644 --- a/MavLinkNode/mavlinknode.h +++ b/MavLinkNode/mavlinknode.h @@ -87,7 +87,7 @@ public: typedef struct { - uint16_t flag;//0x24a8 + uint16_t flag;// uint16_t id;//1 int32_t time;//(second+min*60+hour*3600)*1000 int32_t lng;//*10000000 @@ -235,6 +235,11 @@ signals: void SendMessageToExport(quint8 ch, quint8 *data,quint16 len); public slots: + /** + * @brief 设置厂家标识 + */ + void setManufacturerIdentification(quint16 id); + //线程对外接口 void CreateCSV(void); void CloseCSV(void); @@ -361,6 +366,8 @@ protected: QPointer showInfoTimer = nullptr; QThread showInfoThread; + quint16 ManufacturerID; + private slots: void showInfoTimerTimeout(); }; diff --git a/dlink/dlink.cpp b/dlink/dlink.cpp index 6c8f00e..626aa2b 100644 --- a/dlink/dlink.cpp +++ b/dlink/dlink.cpp @@ -13,7 +13,7 @@ DLink::DLink(QObject *parent) : QObject(parent) //在当前线程运行 connect(mavlinknode,SIGNAL(SendMessageTo(quint8,quint8*,quint16)), - this,SLOT(SendMessageTo(quint8,quint8*,quint16)));//BlockingQueuedConnection);//信号和槽必须在不同的线程中,否则就产生死锁 + this,SLOT(SendMessageTo(quint8,quint8*,quint16)), Qt::BlockingQueuedConnection);//BlockingQueuedConnection);//信号和槽必须在不同的线程中,否则就产生死锁 connect(mavlinknode,SIGNAL(SendMessageToExport(quint8,quint8*,quint16)), this,SLOT(SendMessageToExport(quint8,quint8*,quint16)));//BlockingQueuedConnection);//信号和槽必须在不同的线程中,否则就产生死锁