为压力检测器添加超时机制、更新翻译
This commit is contained in:
@@ -3,11 +3,15 @@
|
||||
|
||||
PressureMonitor::PressureMonitor()
|
||||
: m_stableTickCount(0)
|
||||
, m_totalTickCount(0)
|
||||
, m_timeout(false)
|
||||
{
|
||||
}
|
||||
|
||||
bool PressureMonitor::tick(float realtimePressure, float calibratedPressure)
|
||||
{
|
||||
m_totalTickCount++;
|
||||
|
||||
if (calibratedPressure <= 0.0f) {
|
||||
m_stableTickCount = 0;
|
||||
return false;
|
||||
@@ -22,12 +26,20 @@ bool PressureMonitor::tick(float realtimePressure, float calibratedPressure)
|
||||
m_stableTickCount = 0;
|
||||
}
|
||||
|
||||
// 5分钟超时兜底:无论压力是否稳定,都触发结束
|
||||
if (m_totalTickCount >= TIMEOUT_TICKS) {
|
||||
m_timeout = true;
|
||||
return true;
|
||||
}
|
||||
|
||||
return m_stableTickCount >= REQUIRED_STABLE_TICKS;
|
||||
}
|
||||
|
||||
void PressureMonitor::reset()
|
||||
{
|
||||
m_stableTickCount = 0;
|
||||
m_totalTickCount = 0;
|
||||
m_timeout = false;
|
||||
}
|
||||
|
||||
bool PressureMonitor::isCurrentlyInRange() const
|
||||
@@ -38,4 +50,9 @@ bool PressureMonitor::isCurrentlyInRange() const
|
||||
int PressureMonitor::stableTickCount() const
|
||||
{
|
||||
return m_stableTickCount;
|
||||
}
|
||||
|
||||
bool PressureMonitor::wasTimeout() const
|
||||
{
|
||||
return m_timeout;
|
||||
}
|
||||
Reference in New Issue
Block a user