压力监视等待初版
This commit is contained in:
@@ -0,0 +1,41 @@
|
|||||||
|
#include "PressureMonitor.h"
|
||||||
|
#include <cmath>
|
||||||
|
|
||||||
|
PressureMonitor::PressureMonitor()
|
||||||
|
: m_stableTickCount(0)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
bool PressureMonitor::tick(float realtimePressure, float calibratedPressure)
|
||||||
|
{
|
||||||
|
if (calibratedPressure <= 0.0f) {
|
||||||
|
m_stableTickCount = 0;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
float upperBound = calibratedPressure + 10.0f;
|
||||||
|
float lowerBound = calibratedPressure - 10.0f;
|
||||||
|
|
||||||
|
if (realtimePressure >= lowerBound && realtimePressure <= upperBound) {
|
||||||
|
m_stableTickCount++;
|
||||||
|
} else {
|
||||||
|
m_stableTickCount = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
return m_stableTickCount >= REQUIRED_STABLE_TICKS;
|
||||||
|
}
|
||||||
|
|
||||||
|
void PressureMonitor::reset()
|
||||||
|
{
|
||||||
|
m_stableTickCount = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool PressureMonitor::isCurrentlyInRange() const
|
||||||
|
{
|
||||||
|
return m_stableTickCount > 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
int PressureMonitor::stableTickCount() const
|
||||||
|
{
|
||||||
|
return m_stableTickCount;
|
||||||
|
}
|
||||||
@@ -0,0 +1,29 @@
|
|||||||
|
#ifndef PRESSUREMONITOR_H
|
||||||
|
#define PRESSUREMONITOR_H
|
||||||
|
|
||||||
|
class PressureMonitor
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
PressureMonitor();
|
||||||
|
|
||||||
|
// 每个100ms tick 调用一次
|
||||||
|
// realtimePressure: 实时压力 (sysPara->status.PRESSURE)
|
||||||
|
// calibratedPressure: 标定压力 (sysPara->para.pressure)
|
||||||
|
// 返回 true 表示压力已持续稳定 3 秒
|
||||||
|
bool tick(float realtimePressure, float calibratedPressure);
|
||||||
|
|
||||||
|
// 重置监测器状态
|
||||||
|
void reset();
|
||||||
|
|
||||||
|
// 当前压力是否在 ±10% 范围内
|
||||||
|
bool isCurrentlyInRange() const;
|
||||||
|
|
||||||
|
// 当前连续稳定的 tick 计数
|
||||||
|
int stableTickCount() const;
|
||||||
|
|
||||||
|
private:
|
||||||
|
int m_stableTickCount;
|
||||||
|
static const int REQUIRED_STABLE_TICKS = 30; // 3秒 / 100ms = 30 ticks
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // PRESSUREMONITOR_H
|
||||||
@@ -96,6 +96,7 @@ HEADERS += Public.h \
|
|||||||
# ParaSettingUI.h \
|
# ParaSettingUI.h \
|
||||||
DevOp.h \
|
DevOp.h \
|
||||||
posix_qextserialport.h \
|
posix_qextserialport.h \
|
||||||
|
PressureMonitor.h \
|
||||||
rfid/sm4.h \
|
rfid/sm4.h \
|
||||||
rfid/sm3.h \
|
rfid/sm3.h \
|
||||||
rfid/rfidfunction.h \
|
rfid/rfidfunction.h \
|
||||||
@@ -254,6 +255,7 @@ SOURCES +=\
|
|||||||
# ParaSettingUI.cpp \
|
# ParaSettingUI.cpp \
|
||||||
DevOp.cpp \
|
DevOp.cpp \
|
||||||
posix_qextserialport.cpp \
|
posix_qextserialport.cpp \
|
||||||
|
PressureMonitor.cpp \
|
||||||
rfid/sm4.cpp \
|
rfid/sm4.cpp \
|
||||||
rfid/sm3.cpp \
|
rfid/sm3.cpp \
|
||||||
rfid/rfidfunction.cpp \
|
rfid/rfidfunction.cpp \
|
||||||
@@ -395,4 +397,4 @@ if(contains(DEFINES,__2451WIFI__))
|
|||||||
#SOURCES += /home/student/newDisk/2451_linux/wpa_supplicant_hostapd/wpa_supplicant_hostapd-0.8/src/common/wpa_ctrl.c
|
#SOURCES += /home/student/newDisk/2451_linux/wpa_supplicant_hostapd/wpa_supplicant_hostapd-0.8/src/common/wpa_ctrl.c
|
||||||
#INCLUDEPATH += /home/student/newDisk/2451_linux/wpa_supplicant_hostapd/wpa_supplicant_hostapd-0.8/src
|
#INCLUDEPATH += /home/student/newDisk/2451_linux/wpa_supplicant_hostapd/wpa_supplicant_hostapd-0.8/src
|
||||||
#INCLUDEPATH += /home/student/newDisk/2451_linux/wpa_supplicant_hostapd/wpa_supplicant_hostapd-0.8/src/utils
|
#INCLUDEPATH += /home/student/newDisk/2451_linux/wpa_supplicant_hostapd/wpa_supplicant_hostapd-0.8/src/utils
|
||||||
}
|
}
|
||||||
+19
-13
@@ -129,6 +129,8 @@ void MainWidget::init()
|
|||||||
airPushTimer = new QTimer(this);
|
airPushTimer = new QTimer(this);
|
||||||
connect(airPushTimer, SIGNAL(timeout()), this, SLOT(airPushingProcess()));
|
connect(airPushTimer, SIGNAL(timeout()), this, SLOT(airPushingProcess()));
|
||||||
|
|
||||||
|
m_pressureMonitor = new PressureMonitor();
|
||||||
|
|
||||||
timerPowerOff = new QTimer(this);
|
timerPowerOff = new QTimer(this);
|
||||||
connect(timerPowerOff,SIGNAL(timeout()),this,SLOT(sendPowerOffCmd()));
|
connect(timerPowerOff,SIGNAL(timeout()),this,SLOT(sendPowerOffCmd()));
|
||||||
|
|
||||||
@@ -1221,18 +1223,6 @@ void MainWidget::airPushingProcess()
|
|||||||
sysPara->saveParaToFile();
|
sysPara->saveParaToFile();
|
||||||
}
|
}
|
||||||
|
|
||||||
// 延迟 半秒后才开回收槽,正式结束排气阶段
|
|
||||||
if(sysPara->status.airPushingOnTime >= sysPara->para.airPushDurationSec * 1000 + 500){
|
|
||||||
//qDebug()<< "start stop";
|
|
||||||
reclaimTanOpen();
|
|
||||||
sysPara->status.airPushingDone = 1;
|
|
||||||
sysPara->status.airPushing = 0;
|
|
||||||
sysPara->status.airPushingOnTime = 0;
|
|
||||||
airPushTimer->stop();
|
|
||||||
setRunStatus(tr("喷嘴开启中"));
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if(sysPara->status.airPushingOnTime >= sysPara->para.airPushDurationSec * 1000){
|
if(sysPara->status.airPushingOnTime >= sysPara->para.airPushDurationSec * 1000){
|
||||||
sysPara->devOp->controlViscosityPump(false);
|
sysPara->devOp->controlViscosityPump(false);
|
||||||
sysPara->devOp->controlCycleValve(false);
|
sysPara->devOp->controlCycleValve(false);
|
||||||
@@ -1240,6 +1230,21 @@ void MainWidget::airPushingProcess()
|
|||||||
if(!sysPara->devOp->isReclaimPumpOpen())
|
if(!sysPara->devOp->isReclaimPumpOpen())
|
||||||
sysPara->devOp->controlReclaimPump(true, false);
|
sysPara->devOp->controlReclaimPump(true, false);
|
||||||
|
|
||||||
|
// 切换回自动模式
|
||||||
|
sysPara->status.isPumpValveControledByHand = false;
|
||||||
|
|
||||||
|
setRunStatus(tr("等待压力稳定..."));
|
||||||
|
|
||||||
|
// 调用压力检测器,监测压力持续3秒波动范围不超过标定值的+-10%
|
||||||
|
if(m_pressureMonitor->tick((float)sysPara->status.PRESSURE, (float)sysPara->para.pressure)) {
|
||||||
|
reclaimTanOpen();
|
||||||
|
sysPara->status.airPushingDone = 1;
|
||||||
|
sysPara->status.airPushing = 0;
|
||||||
|
sysPara->status.airPushingOnTime = 0;
|
||||||
|
airPushTimer->stop();
|
||||||
|
m_pressureMonitor->reset();
|
||||||
|
setRunStatus(tr("喷嘴开启中"));
|
||||||
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1431,6 +1436,7 @@ void MainWidget::on_m_RightBtn_clicked()
|
|||||||
sysPara->status.airPushingOnTime = 0;
|
sysPara->status.airPushingOnTime = 0;
|
||||||
|
|
||||||
airPushTimer->start(100); // 100ms
|
airPushTimer->start(100); // 100ms
|
||||||
|
m_pressureMonitor->reset();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
@@ -2698,4 +2704,4 @@ void MainWidget::UpdateUIVersion(){
|
|||||||
QString Mac = QString::number(sysPara->status.machineMac);
|
QString Mac = QString::number(sysPara->status.machineMac);
|
||||||
LogInfo::setRunStatusText(QString("Mac:%1").arg(Mac));
|
LogInfo::setRunStatusText(QString("Mac:%1").arg(Mac));
|
||||||
LogInfo::showVerionInformation(Mac,VernonBach,fpgaVersion,STM32Ver);
|
LogInfo::showVerionInformation(Mac,VernonBach,fpgaVersion,STM32Ver);
|
||||||
}
|
}
|
||||||
@@ -30,6 +30,7 @@
|
|||||||
|
|
||||||
#include "setnumdlg.h"
|
#include "setnumdlg.h"
|
||||||
#include "PrintSetting.h"
|
#include "PrintSetting.h"
|
||||||
|
#include "PressureMonitor.h"
|
||||||
|
|
||||||
class MainWidget : public QWidget
|
class MainWidget : public QWidget
|
||||||
{
|
{
|
||||||
@@ -165,6 +166,8 @@ private:
|
|||||||
int r_ExpiryDay;
|
int r_ExpiryDay;
|
||||||
QTimer *airPushTimer;
|
QTimer *airPushTimer;
|
||||||
|
|
||||||
|
PressureMonitor *m_pressureMonitor = nullptr;
|
||||||
|
|
||||||
PicScene *pPicScene = nullptr;
|
PicScene *pPicScene = nullptr;
|
||||||
QGraphicsView *view;
|
QGraphicsView *view;
|
||||||
PrintSettingModel printSettingsModel;
|
PrintSettingModel printSettingsModel;
|
||||||
|
|||||||
Reference in New Issue
Block a user