From 2b024562b5eb779137ed81ff17994c6abafc10e9 Mon Sep 17 00:00:00 2001 From: hm-thinkbook14p Date: Wed, 17 May 2023 16:27:12 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BD=BF=E7=94=A8GPS=E6=97=B6=E9=97=B4?= =?UTF-8?q?=E4=BD=9C=E4=B8=BA=E5=9F=BA=E5=87=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- App/ToolsUI/PowerSystem/PowerSystem.cpp | 5 ++--- App/ToolsUI/PowerSystem/PowerSystem.h | 8 ++++--- App/mainwindow.cpp | 12 ++++++++-- MavLinkNode/mavlinknode.cpp | 30 +++++++++++++++++++++++++ MavLinkNode/mavlinknode.h | 7 +++++- 5 files changed, 53 insertions(+), 9 deletions(-) diff --git a/App/ToolsUI/PowerSystem/PowerSystem.cpp b/App/ToolsUI/PowerSystem/PowerSystem.cpp index 7d81826..883453f 100644 --- a/App/ToolsUI/PowerSystem/PowerSystem.cpp +++ b/App/ToolsUI/PowerSystem/PowerSystem.cpp @@ -446,7 +446,7 @@ void PowerSystem::setFuel(QVariant press, QVariant value) -void PowerSystem::setMa(QVariant Ma) +void PowerSystem::setMa(qint64 time, QVariant Ma) { if(AMaTimer) { @@ -456,9 +456,8 @@ void PowerSystem::setMa(QVariant Ma) } } - averageMa.append(Ma.toDouble()); - averageTime.append(QDateTime::currentMSecsSinceEpoch()); + averageTime.append(time); while(averageTime.back() - averageTime.first() > (100 * 1000)) { diff --git a/App/ToolsUI/PowerSystem/PowerSystem.h b/App/ToolsUI/PowerSystem/PowerSystem.h index a59a4fa..6846f76 100644 --- a/App/ToolsUI/PowerSystem/PowerSystem.h +++ b/App/ToolsUI/PowerSystem/PowerSystem.h @@ -59,10 +59,7 @@ public: void setTurbineState(mavlink_turbinestate_t *t); void setCCMState(mavlink_ccmstate_t *t); - void setMa(QVariant Ma); - void setAlt(QVariant Alt); - void setFuel(QVariant press,QVariant value); void updateUI(); @@ -82,6 +79,11 @@ private slots: public slots: void setFloat(void); + void setMa(qint64 time, QVariant Ma); + void setAlt(QVariant Alt); + + void setFuel(QVariant press,QVariant value); + private: QTimer timer2; diff --git a/App/mainwindow.cpp b/App/mainwindow.cpp index 40996a1..814c1d5 100644 --- a/App/mainwindow.cpp +++ b/App/mainwindow.cpp @@ -1,4 +1,4 @@ -#include "mainwindow.h" +#include "mainwindow.h" #include "QPushButton" #include "QAction" @@ -275,6 +275,14 @@ MainWindow::MainWindow(QWidget *parent) + //dlink ----toolsui-power + + //toolsui->powersystem->setMa(vehicle.timebase,vehicle.emb_atom_com.mach); + + connect(dlink->mavlinknode,SIGNAL(setMa(qint64,QVariant)), + toolsui->powersystem,SLOT(setMa(qint64,QVariant))); + + //setting ----- map connect(setting->index0->globalsetting,SIGNAL(getMapTypes()), @@ -1545,7 +1553,7 @@ void MainWindow::updateUI()//事件驱动式更新数据 toolsui->powersystem->setTurbineState(&vehicle.turbinstate); toolsui->powersystem->setCCMState(&vehicle.ccmstate); - toolsui->powersystem->setMa(vehicle.emb_atom_com.mach); + //toolsui->powersystem->setMa(vehicle.timebase,vehicle.emb_atom_com.mach); toolsui->powersystem->setAlt(vehicle.gps_raw_int.alt * 10e-4); diff --git a/MavLinkNode/mavlinknode.cpp b/MavLinkNode/mavlinknode.cpp index ba4c7f7..fda03ac 100644 --- a/MavLinkNode/mavlinknode.cpp +++ b/MavLinkNode/mavlinknode.cpp @@ -1318,6 +1318,21 @@ void MavLinkNode::StatusParse(mavlink_message_t msg) gpsTimer.min = min; gpsTimer.sec = sec; + + if(!gpstimebase) + { + gpstimebase = new QDateTime(); + } + + gpstimebase->setDate(QDate(year,mon,day)); + gpstimebase->setTime(QTime(hour,min,sec)); + + vehicle.timebase = gpstimebase->currentMSecsSinceEpoch(); + + //qDebug() << gpstimebase->currentMSecsSinceEpoch(); + + + _showinfo info; info.flag = 0x24a8; @@ -1417,6 +1432,18 @@ void MavLinkNode::StatusParse(mavlink_message_t msg) gpsTimer.min = min; gpsTimer.sec = sec; + if(!gpstimebase) + { + gpstimebase = new QDateTime(); + } + + gpstimebase->setDate(QDate(year,mon,day)); + gpstimebase->setTime(QTime(hour,min,sec)); + + vehicle.timebase = gpstimebase->currentMSecsSinceEpoch(); + + //qDebug() << gpstimebase->currentMSecsSinceEpoch(); + _showinfo info; @@ -1812,6 +1839,9 @@ void MavLinkNode::StatusParse(mavlink_message_t msg) setFileData(emb_atom_com_file,csvdata); + + emit setMa(vehicle.timebase, vehicle.emb_atom_com.mach); + }break; case MAVLINK_MSG_ID_TurbineState: { mavlink_msg_turbinestate_decode(&msg,&vehicle.turbinstate); diff --git a/MavLinkNode/mavlinknode.h b/MavLinkNode/mavlinknode.h index 512d565..73f2c1e 100644 --- a/MavLinkNode/mavlinknode.h +++ b/MavLinkNode/mavlinknode.h @@ -52,6 +52,9 @@ public: int sysid = 0; /* ID of message sender system/aircraft */ int compid = 0; /* ID of the message sender component */ + qint64 timebase; + + mavlink_autopilot_version_t autopilot_version = {0}; mavlink_sys_status_t sys_status = {0}; mavlink_heartbeat_t heartbeat = {0}; @@ -172,6 +175,8 @@ public: int infoExportID = 1; signals: + void setMa(qint64 time, QVariant Ma); + void signal_autopilot_version(mavlink_autopilot_version_t); void signal_sys_status(mavlink_sys_status_t); void signal_heartbeat(mavlink_heartbeat_t); @@ -348,7 +353,7 @@ protected: bool use_ins1 = false; - + QDateTime *gpstimebase = nullptr; }; #endif // MAVLINKNODE_H