eis/eqpalg/utility/HoldTime.h

85 lines
2.4 KiB
C
Raw Normal View History

#pragma once
/**
* @file HoldTime.h
* @brief hold(n,T)
* ntag点序号()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>
* booltrue为存在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);
};