eis/eqpalg/utility/eqp_stat.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

154 lines
3.7 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 eqp_stat.h
* @brief 处理与页面交互的shm数据
* @author your name (you@domain.com)
* @version 0.1
* @date 2023-12-21
*
* Copyright: Baosight Co. Ltd.
* DO NOT COPY/USE WITHOUT PERMISSION
*
*/
#include <log4cplus/LOG.h>
#include <shm/RuleStatShm.h>
#include <memory>
#include <vector>
class EqpStat {
public:
EqpStat();
~EqpStat();
public:
/**
* @brief 静态数据维护
*/
void init();
/**
* @brief 更新指定key的动态数据
* @param ruleid 规则id
* @param rule_stat RuleStatShm::RuleStat数据 引用
* @return true
* @return false
*/
bool update_dynamic(std::string ruleid,
const RuleStatShm::RuleStat& rule_stat);
/**
* @brief 更新指定key的静态数据 弃用
* @param ruleid 规则id
* @param rule_stat RuleStatShm::RuleStat数据 引用
* @return true
* @return false
*/
/**
* @brief 更新指定key的 静态数据
* 内含当前变量 rule_stat_statstic_
* @param ruleid 规则id
* @param is_times 是否为运行时间/出现次数
* @return true
* @return false
*/
bool update_static(std::string ruleid, bool is_times);
/**
* @brief 更新所有 循环
* 内含当前变量 rule_stat_
* @return true
* @return false
*/
bool update_static();
/**
* @brief 更新指定key的所有数据
* @param ruleid My Param doc
* @param rule_stat My Param doc
* @return true
* @return false
*/
bool update_stat(std::string ruleid, const RuleStatShm::RuleStat& rule_stat);
/**
* @brief 添加数据到shm
* @param ruleid My Param doc
* @param rule_stat My Param doc
* @return true
* @return false
*/
bool add_stat_values(std::string ruleid, const double& rule_stat);
/**
* @brief 获取shm的数据
* @param ruleid 规则id
* @param rule_stat 接收的数据类
* @return true
* @return false
*/
bool get_stat_values(std::string ruleid, RuleStatShm::RuleStat& rule_stat);
/**
* @brief 删除指定key的数据
* @param ruleid My Param doc
* @return true
* @return false
*/
bool delete_stat(std::string ruleid);
/**
* @brief map 转 json 的 string
* @return std::string
*/
std::string get_stat_json();
/**
* @brief 从 cfg查询 所有规则从map中找到cfg不存在的
* @return std::vector<std::string>
*/
std::vector<std::string> stat_find_no_ruleid();
/**
* @brief map的size
* @return int
*/
int get_stat_size();
/**
* @brief 查T_RULE_CFG表
*/
void get_cfg_rules();
/**
* @brief Get the ruleid json object
* @return string {"ruleid":[xxx,xxx,……]}
*/
string get_ruleid_json();
private:
std::unique_ptr<LOG> logger_;
std::vector<string> cfg_rules_;
bool cfg_flag = false;
chrono::system_clock::time_point
last_update_static_time_;
/**
* @brief 运行时间
* @param ruleid My Param doc
* @return double
*/
double select_running_by_ruleid(string ruleid);
/**
* @brief 出现次数
* @param ruleid My Param doc
* @return unsigned long
*/
unsigned long select_times_by_ruleid(string ruleid);
/**
* @brief 报警次数
* @param ruleid My Param doc
* @return int
*/
int select_alarm_by_ruleid(string ruleid);
/**
* @brief 设备编码
* @param ruleid My Param doc
* @return std::string
*/
std::string select_dev_coder_by_ruleid(string ruleid);
/**
* @brief 最新报警时间
* @param ruleid My Param doc
* @return string
*/
string select_latest_alarm_by_ruleid(string ruleid);
};