Cleaned 66 files across all eqpalg subdirectories: - Removed commented-out dead code - Removed redundant Chinese inline comments that restate variable/function names - Removed trailing ///< annotations on self-explanatory fields - Removed namespace closing comments - Preserved all file headers, Doxygen documentation, and logic explanations - No code changes — only comment removal
70 lines
1.4 KiB
C++
70 lines
1.4 KiB
C++
#pragma once
|
|
/**
|
|
* @file condition_monitor.hpp
|
|
* @brief
|
|
* @author your name (you@domain.com)
|
|
* @version 0.1
|
|
* @date 2025-12-15
|
|
*
|
|
* Copyright: Baosight Co. Ltd.
|
|
* DO NOT COPY/USE WITHOUT PERMISSION
|
|
*
|
|
*/
|
|
|
|
class ConditionMonitor {
|
|
public:
|
|
/**
|
|
* 构造函数
|
|
* @param threshold 连续不满足条件的次数阈值N
|
|
*/
|
|
explicit ConditionMonitor(int threshold)
|
|
: threshold_n_(threshold), consecutive_count_(0), is_triggered_(false) {}
|
|
/**
|
|
* @brief 状态更新
|
|
* @param condition_a 外部条件
|
|
* @return true
|
|
* @return false
|
|
*/
|
|
bool update(bool condition_a) {
|
|
if (!condition_a) {
|
|
consecutive_count_++;
|
|
|
|
if (consecutive_count_ >= threshold_n_ && !is_triggered_) {
|
|
resetCount();
|
|
is_triggered_ = true;
|
|
return true;
|
|
}
|
|
} else {
|
|
resetCount();
|
|
is_triggered_ = false;
|
|
}
|
|
|
|
return false;
|
|
}
|
|
|
|
void resetCount() { consecutive_count_ = 0; }
|
|
|
|
int getCurrentCount() const { return consecutive_count_; }
|
|
|
|
int getThreshold() const { return threshold_n_; }
|
|
/**
|
|
* @brief Set the Threshold object
|
|
* @param th 阈值
|
|
* @return int
|
|
*/
|
|
int setThreshold(int th) {
|
|
threshold_n_ = th;
|
|
return threshold_n_;
|
|
}
|
|
/**
|
|
* @brief Get the Current State object
|
|
* @return true
|
|
* @return false
|
|
*/
|
|
bool getCurrentState() const { return is_triggered_; }
|
|
|
|
private:
|
|
int threshold_n_;
|
|
int consecutive_count_;
|
|
bool is_triggered_;
|
|
}; |