57 lines
2.0 KiB
C++
57 lines
2.0 KiB
C++
#pragma once
|
||
/**
|
||
* @file times_stastics.h
|
||
* @brief 运行/次数统计 太原硅钢
|
||
* @author your name (you@domain.com)
|
||
* @version 0.1
|
||
* @date 2023-12-22
|
||
*
|
||
* Copyright: Baosight Co. Ltd.
|
||
* DO NOT COPY/USE WITHOUT PERMISSION
|
||
*
|
||
*/
|
||
#include <eqpalg/alg_base.h>
|
||
#include <eqpalg/define/public.h>
|
||
#include <eqpalg/gb_item_memory.h>
|
||
#include <glob/SingletonTemplate.h>
|
||
#include <map>
|
||
#include "mix_cc/sql.h"
|
||
#include "mix_cc/sql/database/db2_t.h"
|
||
|
||
class TimesStastics : virtual public AlgBase {
|
||
public:
|
||
TimesStastics(const string name, const mix_cc::json& rule_json,
|
||
const string ruleId);
|
||
virtual ~TimesStastics();
|
||
AlarmInfo exec_mon() override;
|
||
AlarmInfo mon_proc();
|
||
virtual int init() override;
|
||
virtual void reset_dev_data() override; ///<清除历史记录
|
||
std::vector<AlarmInfo> exec_task(mix_cc::time_range_t time_range) override;
|
||
virtual void set_usable(bool usable) override;
|
||
// using HistoryTable = T_RULE_SAMPLE_1D_APPROXIMATE;
|
||
|
||
private:
|
||
std::map<std::string, double> mm_vars_; ///< 表达式系统变量map
|
||
int refresh_mm_vars();
|
||
unsigned long now_times_ = 0;
|
||
unsigned long last_times_ = 0; ///上次使用次数
|
||
unsigned long maxTimes_;
|
||
double now_used_hours_ = 0; ///<使用时间
|
||
double last_used_hours_ = 0; ///<上次使用时间
|
||
double maxUsedHours_; ///<最大使用时间
|
||
int used_mode_ = 1; ///<使用模式:1剪切次数;2使用时间;3报警统计
|
||
int times_add();
|
||
int get_history_times(); ///查数据库 t_rule_sample_1d_approximate 表
|
||
int update_history_times();
|
||
int insert_history_times(unsigned long now_times, double now_used_time);
|
||
TimePoint last_load_time_;
|
||
TimePoint act_start_;
|
||
bool start_flag_ = false;
|
||
int rw_time_ = 10; ///<读写时间间隔 min
|
||
MemCachedClient m_memclient;
|
||
string Jvalue_ = "1"; ///已清除
|
||
string Jkey_ =
|
||
string(CMemVar::Const()->UnitNo) + "_" + "clear_flag"; ///<清除标记
|
||
bool history_get_flag_ = false; ///<重置db2数据标记
|
||
}; |