eis/eqpalg/algs/fault_code.h

67 lines
1.5 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 fault_code.h
* @brief 故障代码解析
*
* @author your name (you@domain.com)
* @version 0.1
* @date 2024-03-04
*
* Copyright: Baosight Co. Ltd.
* DO NOT COPY/USE WITHOUT PERMISSION
*
*/
#include <eqpalg/alg_base.h>
class FaultCode : public AlgBase {
public:
FaultCode(const string name, const mix_cc::json& rule_json,
const string ruleId,size_t code_type);
~FaultCode() override;
public:
int init() override;
/**
* @brief 执行函数
* @return AlarmInfo
*/
AlarmInfo exec_mon() override;
/**
* @brief 单次执行
* @param time_range My Param doc
* @return std::vector<AlarmInfo>
*/
std::vector<AlarmInfo> exec_task(mix_cc::time_range_t time_range) override;
protected:
/**
* @brief 取位函数
* 获取 value的第sub位
* @tparam T
* @param value 数据
* @param sub 第sub位
* @return T 0或1
*/
template <typename T>
T static gitbit(T value, T sub) {
return int(value) >> int(sub) & 1;
};
/**
* @brief
* @return true
* @return false
*/
int select_t_lov_fcode();
protected:
const size_t code_type_; ///< 故障代码解析类型0-整体解析1-按位解析
struct FaultCodeInfo {
bool is_usable = false;
std::string name;
std::string content;
};
std::map<int, FaultCodeInfo> map2fcode_; ///<故障代码对应表
std::string alarm_content_; ///<报警内容
bool is_valid_ = false; ///<配置参数是否合法
};