61 lines
1.7 KiB
C
61 lines
1.7 KiB
C
|
|
#pragma once
|
|||
|
|
/**
|
|||
|
|
* @file dsm_alg.h
|
|||
|
|
* @brief 从 DsmMapConfig::TableName(ZONE10)共享文件 读取 start end tags
|
|||
|
|
* 查ihd获取数据,保存文件
|
|||
|
|
* @author your name (you@domain.com)
|
|||
|
|
* @version 0.1
|
|||
|
|
* @date 2025-10-10
|
|||
|
|
*
|
|||
|
|
* Copyright: Baosight Co. Ltd.
|
|||
|
|
* DO NOT COPY/USE WITHOUT PERMISSION
|
|||
|
|
*
|
|||
|
|
*/
|
|||
|
|
#include <common/Macro.h>
|
|||
|
|
#include <dsm/data_query.h>
|
|||
|
|
#include <dsm/public.h>
|
|||
|
|
#include <glob/SingletonTemplate.h>
|
|||
|
|
#include <log4cplus/LOG.h>
|
|||
|
|
#include <memory>
|
|||
|
|
#include <mix_cc/type/mix_time.h>
|
|||
|
|
#include <mix_cc/type/range.h>
|
|||
|
|
#include <nlohmann/json.hpp>
|
|||
|
|
#include <string>
|
|||
|
|
#include <vector>
|
|||
|
|
#include <zlib/MemMap.hpp>
|
|||
|
|
using json = nlohmann::json;
|
|||
|
|
using namespace baosight;
|
|||
|
|
class DsmAlg {
|
|||
|
|
private:
|
|||
|
|
const std::string RuleNormDataRootDir = "/dscdata/RuleNormData";
|
|||
|
|
const std::string RuleAlertDataRootDir = "/dscdata/RuleAlertData";
|
|||
|
|
std::unique_ptr<LOG> logger_;
|
|||
|
|
std::unique_ptr<CMemMap<std::string, DataInfo>> ruleid_norminfo_;
|
|||
|
|
DataQuery data_query_;
|
|||
|
|
std::vector<std::string> need_ruleid_;
|
|||
|
|
std::string get_root_dir(std::string data_type);
|
|||
|
|
|
|||
|
|
public:
|
|||
|
|
DsmAlg();
|
|||
|
|
~DsmAlg();
|
|||
|
|
/**
|
|||
|
|
* @brief 根据ruleid 保存指定规则的数据
|
|||
|
|
* 1.根据reluid 从共享内存读取 start end tags 保存数据的类型(正常,异常)
|
|||
|
|
* 2.根据 start end tags 查询ihd数据
|
|||
|
|
* 3.保存查询的数据(data,time)到指定路径
|
|||
|
|
* 正常:RuleNormDataRootDir/ruleid/yyyy-mm-dd.json
|
|||
|
|
* 报警:RuleAlertDataRootDir/ruleid/yyyy-mm-dd.json
|
|||
|
|
* @param ruleid 规则id
|
|||
|
|
*/
|
|||
|
|
void dsm_handle(std::string ruleid);
|
|||
|
|
|
|||
|
|
/**
|
|||
|
|
* @brief 定时保存数据
|
|||
|
|
* 1. 获取所有的ruleid
|
|||
|
|
* 2.遍历ruleid,检测共享内存是否有ruleid的key
|
|||
|
|
* 3.调用dsm_handle
|
|||
|
|
*/
|
|||
|
|
void timed_task();
|
|||
|
|
|
|||
|
|
void dispose(int event_no, const ::Ice::ByteSeq &);
|
|||
|
|
};
|