eis/eqpalg/utility/HoldTime.h
Huamonarch 224c2c45c4 Remove irrelevant comments from eqpalg source files
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
2026-05-09 13:30:09 +08:00

85 lines
2.4 KiB
C++
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

#pragma once
/**
* @file HoldTime.h
* @brief hold(n,T)变量类
* n——tag点序号(整型)T——保持时间(浮点),单位分钟
* @author your name (you@domain.com)
* @version 0.1
* @date 2023-12-22
*
* Copyright: Baosight Co. Ltd.
* DO NOT COPY/USE WITHOUT PERMISSION
*
*/
#include <chrono>
#include <cmath>
#include <limits>
#include <string>
#include <tuple>
#include <vector>
class HoldTime {
public:
std::string tagi;
std::string var_name;
public:
/**
* @brief Construct a new Hold Time object
* @param time 保持的时间
* @param tagi 需要监控的变量tag
* @param var_name hold变量名
*/
HoldTime(double time, std::string tagi, std::string var_name);
~HoldTime();
/**
* @brief static函数 检测表达式是否存在hold变量
* @param exp_str 表达式
* @return std::tuple<bool, double, std::string, std::string>
* bool——true为存在false为不存在
*/
static std::tuple<bool, double, std::string, std::string> find_hold(
std::string exp_str);
/**
* @brief 寻找包含hold变量的所有的子串
* @param str 表达式
* @param sub_str 子串集合
* @return std::vector<std::string>
*/
static std::vector<std::string> find_substr(std::string str,
std::string sub_str);
public:
/**
* @brief 刷新hold类的保持属性
* @param tag_value 最新的tag值
* @return true
* @return false
*/
bool update_value(double tag_value);
/**
* @brief 重载bool运算符返回保持状态量
*/
inline operator bool(void) const { return value; }
/**
* @brief 获取返回状态量函数
* @return true
* @return false
*/
inline bool get_value(void) const { return value; }
private:
double last_value;
double hold_time;
bool value;
std::chrono::system_clock::time_point last_time;
private:
/**
* @brief static函数 从源字符串中查找子字符串
* @param str 查找的源字符串
* @param sub_str 查找的目标子字符串
* @return std::pair<std::string, std::string>
* <存在子字符串的部分,剩下的部分>
*/
static std::pair<std::string, std::string> find_str(std::string str,
std::string sub_str);
};