116 lines
3.0 KiB
C
116 lines
3.0 KiB
C
|
|
/*********************************************************************
|
||
|
|
*
|
||
|
|
* 文 件: AlgorithmBase.h
|
||
|
|
*
|
||
|
|
* 版权所有: Shanghai Baosight Software Co., Ltd.
|
||
|
|
*
|
||
|
|
*********************************************************************/
|
||
|
|
|
||
|
|
#ifndef H_ALGORITHM_BASE_H
|
||
|
|
#define H_ALGORITHM_BASE_H
|
||
|
|
#include <eqpalg/AlgCommonDefine.h>
|
||
|
|
#include <glob/AutoTele.h>
|
||
|
|
#include <glob/BinaryTele.h>
|
||
|
|
#include <glob/MathExpression.h>
|
||
|
|
#include <iostream>
|
||
|
|
#include <json/json.h>
|
||
|
|
#include <log4cplus/LOG.h>
|
||
|
|
#include <zcus/IHDBTools.h>
|
||
|
|
#include <zcus/RuleAlarm.h>
|
||
|
|
#include <zlib/MemTable.hpp>
|
||
|
|
|
||
|
|
using namespace std;
|
||
|
|
|
||
|
|
/*********************************************************************
|
||
|
|
* 类 名: AlgorithmBase
|
||
|
|
* 版权所有: Shanghai Baosight Software Co., Ltd.
|
||
|
|
*********************************************************************/
|
||
|
|
class AlgorithmBase {
|
||
|
|
|
||
|
|
protected:
|
||
|
|
// BinaryTele *p_tele;
|
||
|
|
// BinaryTele *p_btel;
|
||
|
|
|
||
|
|
Json::Value m_json_alarm;
|
||
|
|
Json::Value m_json_param;
|
||
|
|
|
||
|
|
protected:
|
||
|
|
string m_ruleid;
|
||
|
|
long long m_time;
|
||
|
|
int m_ms;
|
||
|
|
long long m_btime;
|
||
|
|
|
||
|
|
int nRet;
|
||
|
|
string m_name;
|
||
|
|
vector<string> m_tags;
|
||
|
|
bool m_usable;
|
||
|
|
string m_msg;
|
||
|
|
|
||
|
|
protected:
|
||
|
|
IHDBTools *mp_ihdb;
|
||
|
|
HD3TimeRegion m_timeRegion;
|
||
|
|
// HD3Time m_timehd;
|
||
|
|
HD3Record *mp_hdRec;
|
||
|
|
HD3Record **mp_recordsQueried;
|
||
|
|
int m_tagcnt;
|
||
|
|
|
||
|
|
public:
|
||
|
|
// handling repeat alarm
|
||
|
|
time_t tPreAlarmTime;
|
||
|
|
|
||
|
|
public:
|
||
|
|
AlgorithmBase(const string &name, const Json::Value &rulejson,
|
||
|
|
const string &ruleid);
|
||
|
|
AlgorithmBase(const string &name, const Json::Value &rulejson,
|
||
|
|
const string &ruleid, IHDBTools *ihdbtool);
|
||
|
|
|
||
|
|
virtual ~AlgorithmBase();
|
||
|
|
|
||
|
|
virtual int ReInit(const string &name, const Json::Value &rulejson,
|
||
|
|
const string &ruleid);
|
||
|
|
|
||
|
|
int SetCycleTime(int ms);
|
||
|
|
// check is run cycle
|
||
|
|
bool IsCycled();
|
||
|
|
|
||
|
|
string GetName();
|
||
|
|
|
||
|
|
string GetRuleID();
|
||
|
|
|
||
|
|
void SetUsable(bool usable);
|
||
|
|
|
||
|
|
bool Usable();
|
||
|
|
|
||
|
|
bool Reduce(const string ruleid, int CS_ALARM_DIFF_DLTIME);
|
||
|
|
|
||
|
|
public:
|
||
|
|
// outjson 为计划返回的结果,正常情况为空
|
||
|
|
virtual int calculate(string &outjson) = 0;
|
||
|
|
|
||
|
|
protected:
|
||
|
|
// string AssemblyMsg(const string &level, const string &ruleid, const
|
||
|
|
// string &name, const string &group, const string &msg);
|
||
|
|
string AssemblyMsg(const string &level, const string &ruleid,
|
||
|
|
const string &name, const string &group, const string &msg,
|
||
|
|
HD3TimeRegion &timeRegion);
|
||
|
|
|
||
|
|
virtual int EquipProd(const string &ruleid, const string &name,
|
||
|
|
const string &msg, HD3TimeRegion &timeRegion);
|
||
|
|
|
||
|
|
short Proxy(int eventNo, const string &proxyName, const char *keyValue,
|
||
|
|
int length);
|
||
|
|
|
||
|
|
long long mstime(void);
|
||
|
|
long long ToMsTime(HD3Time *hd3time);
|
||
|
|
void SetHDTime(HD3Time *hd3time, long long mstime);
|
||
|
|
void SetHDTime(HD3Time *dist_hd3time, HD3Time *sou_hd3time);
|
||
|
|
void SetHDTime(HD3Time *hd3time, HD3Record *hdrcd);
|
||
|
|
void SetHDTime(HD3Record *hdrcd, HD3Time *hd3time);
|
||
|
|
|
||
|
|
virtual void AllotDB3Record();
|
||
|
|
virtual void FreeDB3Record();
|
||
|
|
virtual int QueryDB3Record();
|
||
|
|
};
|
||
|
|
|
||
|
|
#endif
|