From fbdd84ca12f55a39aa695e6536973877eb35541b Mon Sep 17 00:00:00 2001 From: hm-thinkbook14p Date: Tue, 16 May 2023 16:49:15 +0800 Subject: [PATCH] =?UTF-8?q?=E5=B9=B3=E5=9D=87=E9=A9=AC=E8=B5=AB=E6=95=B0?= =?UTF-8?q?=E6=94=B9=E4=B8=BA100s=E5=86=85=E7=9A=84=E6=80=BB=E4=B8=AA?= =?UTF-8?q?=E6=95=B0=EF=BC=8C=E7=BB=8F=E6=B5=8B=E9=87=8F=E5=A4=A7=E6=A6=82?= =?UTF-8?q?100s=E5=86=85=E6=9C=89360=E4=B8=AA=E6=95=B0=E6=8D=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- App/ToolsUI/PowerSystem/PowerSystem.cpp | 15 ++++++++++----- App/ToolsUI/PowerSystem/PowerSystem.h | 1 + 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/App/ToolsUI/PowerSystem/PowerSystem.cpp b/App/ToolsUI/PowerSystem/PowerSystem.cpp index 4c66d54..7d81826 100644 --- a/App/ToolsUI/PowerSystem/PowerSystem.cpp +++ b/App/ToolsUI/PowerSystem/PowerSystem.cpp @@ -152,6 +152,9 @@ PowerSystem::PowerSystem(QWidget *parent) : ScopeMa->setGeometry(0,0,ui->frame_Ma->width(),ui->frame_Ma->height()); + averageMa.clear(); + averageTime.clear(); + //设置开车时间 connect(&timer, &QTimer::timeout, this, [=]() @@ -454,17 +457,19 @@ void PowerSystem::setMa(QVariant Ma) } - MaMap.insert(QDateTime::currentMSecsSinceEpoch(),Ma.toDouble()); - - averageMa.append(Ma.toDouble()); + averageTime.append(QDateTime::currentMSecsSinceEpoch()); - - while(averageMa.size() > 100) + while(averageTime.back() - averageTime.first() > (100 * 1000)) { + averageTime.removeFirst(); averageMa.removeFirst(); } + //qDebug() << "size of time:" << averageTime.size() << averageMa.size() << averageTime.back() << averageTime.first(); + + + ScopeMa->setSerieData(tr("马赫"),Ma); diff --git a/App/ToolsUI/PowerSystem/PowerSystem.h b/App/ToolsUI/PowerSystem/PowerSystem.h index f89889b..a59a4fa 100644 --- a/App/ToolsUI/PowerSystem/PowerSystem.h +++ b/App/ToolsUI/PowerSystem/PowerSystem.h @@ -102,6 +102,7 @@ private: QVector averageMa; + QVector averageTime; QMap MaMap;