30 lines
708 B
C
30 lines
708 B
C
|
|
#pragma once
|
|||
|
|
#include <chrono>
|
|||
|
|
#include <cmath>
|
|||
|
|
#include <limits>
|
|||
|
|
#include <string>
|
|||
|
|
#include <tuple>
|
|||
|
|
class HoldTime {
|
|||
|
|
public:
|
|||
|
|
HoldTime(double time);
|
|||
|
|
~HoldTime();
|
|||
|
|
/**
|
|||
|
|
* @brief
|
|||
|
|
* @param exp_str My Param doc
|
|||
|
|
* @return std::tuple<bool, double, std::string, std::string>
|
|||
|
|
* 是否存在,时间,tagi,变量名
|
|||
|
|
*/
|
|||
|
|
static std::tuple<bool, double, std::string, std::string> find_hold(
|
|||
|
|
std::string exp_str);
|
|||
|
|
|
|||
|
|
public:
|
|||
|
|
void update_value(double tag_value);
|
|||
|
|
inline operator bool(void) const { return value; }
|
|||
|
|
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;
|
|||
|
|
};
|