70 lines
1.7 KiB
C
70 lines
1.7 KiB
C
|
|
#pragma once
|
|||
|
|
/**
|
|||
|
|
* @file exp_times.h
|
|||
|
|
* @brief 持续时间统计,出现次数统计
|
|||
|
|
* exp_type_ 6/7
|
|||
|
|
* 6——累计时间
|
|||
|
|
* 7——出现次数
|
|||
|
|
* @author your name (you@domain.com)
|
|||
|
|
* @version 0.1
|
|||
|
|
* @date 2023-12-15
|
|||
|
|
*
|
|||
|
|
* Copyright: Baosight Co. Ltd.
|
|||
|
|
* DO NOT COPY/USE WITHOUT PERMISSION
|
|||
|
|
*
|
|||
|
|
*/
|
|||
|
|
#include <eqpalg/algs/exp_base.h>
|
|||
|
|
class ExpTimes : public ExpBase {
|
|||
|
|
public:
|
|||
|
|
ExpTimes(const string& name, const mix_cc::json& rule_json,
|
|||
|
|
const string& ruleId, size_t exp_type);
|
|||
|
|
|
|||
|
|
~ExpTimes() override;
|
|||
|
|
virtual AlarmInfo mon_proc() override;
|
|||
|
|
virtual int init() override;
|
|||
|
|
/**
|
|||
|
|
* @brief 重写 清除历史记录
|
|||
|
|
*/
|
|||
|
|
virtual void reset_dev_data() override;
|
|||
|
|
|
|||
|
|
protected:
|
|||
|
|
double max_time_ = 0; ///<最大累积的运行时间
|
|||
|
|
int64_t max_times_ = 0; ///<最大出现次数
|
|||
|
|
int rw_time_ = 10; ///<读写时间间隔 min
|
|||
|
|
int wait_flag_ = 0; ///<首次读取db2 等待1次运行
|
|||
|
|
|
|||
|
|
protected:
|
|||
|
|
/**
|
|||
|
|
* @brief 保持时间/出现次数 更新
|
|||
|
|
* @return int
|
|||
|
|
*/
|
|||
|
|
int update_times();
|
|||
|
|
/**
|
|||
|
|
* @brief 检查是否报警
|
|||
|
|
* @return true
|
|||
|
|
* @return false
|
|||
|
|
*/
|
|||
|
|
bool check_alarm();
|
|||
|
|
/**
|
|||
|
|
* @brief 载入报警阈值
|
|||
|
|
* @return int
|
|||
|
|
*/
|
|||
|
|
int reload_params();
|
|||
|
|
/**
|
|||
|
|
* @brief 查数据库 t_rule_sample_1d_approximate 表
|
|||
|
|
* @return int
|
|||
|
|
*/
|
|||
|
|
int get_history_times();
|
|||
|
|
/**
|
|||
|
|
* @brief 更新数据库 t_rule_sample_1d_approximate 表
|
|||
|
|
* @return int
|
|||
|
|
*/
|
|||
|
|
int update_history_times();
|
|||
|
|
/**
|
|||
|
|
* @brief 插入数据库t_rule_sample_1d_approximate 表
|
|||
|
|
* @param now_times My Param doc
|
|||
|
|
* @param now_used_time My Param doc
|
|||
|
|
* @return int
|
|||
|
|
*/
|
|||
|
|
int insert_history_times(int64_t now_times, double now_used_time);
|
|||
|
|
};
|