eis/eqpm/eqpm_alg.h

109 lines
2.9 KiB
C
Raw Normal View History

#pragma once
/**
* @file eqpm_alg.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 <eqpm/EqpmRecord.h>
#include <eqpm/utility.h>
#include <log4cplus/LOG.h>
#include <chrono>
#include <map>
// #include <mutex>///<弃用
#include <string>
using std::map;
using std::string;
/**
* @brief
*/
struct EqpRule {
int rule_type =
0; ///< 设备保养规则类型0-无1-重量(吨)2-长度(千米)3-时间(天)
double data = 0;
TimePoint repair_date; ///<上次检修时间
TimePoint repair_plan; ///<计划检修时间
};
class EqpmAlg {
public:
EqpmAlg();
~EqpmAlg();
private:
std::unique_ptr<LOG> logger_; ///< 本地logger
map<string, EqpRule> map_rules_; ///<设备-保养规则
double weight_slope_; ///<日产重量
double length_slope_; ///<日产长度
EqpRule rule_; ///<计算时更新的数据
TimePoint EqpmShm_stime_; ///<累计的开始时间从shm获取初始化后不变
TimePoint stime_; ///<更新shm累计数据的开始时间
TimePoint etime_; ///<更新shm累计数据的结束时间
EqpmShm::EqpmRecord eqpm_record_; ///<最新查询的日重量,日长度
TimePoint init_time_;
private:
// std::mutex local_mutext{}; ///<共享锁 弃用
public:
int init();
bool update_data();
bool select_eqpm_data(TimePoint stime);
/**
* @brief
*
* @return true
* @return false
*/
void update_repair();
/**
* @brief shm累计数据的map下标
* @param time My Param doc
* @return int
*/
int get_index(TimePoint time);
/**
* @brief mq的json
* @param mq mq消息的json
* @return int
*/
int update_repair(std::string mq);
/**
* @brief
* @param eqpid My Param doc
* @param rule_type My Param doc
* @param repair_date My Param doc
* @param interval My Param doc
* @return int
*/
int update_rule_data(std::string eqpid, int rule_type, TimePoint repair_date,
double interval);
/**
* @brief db2 T_EQP_REPAIR
* @param eqpid My Param doc
* @return int
*/
int update_db2(std::string eqpid);
/**
* @brief ()
* @param date My Param doc
*/
void update_slope(TimePoint date);
/**
* @brief
* @return int
*/
int select_repair();
/**
* @brief
* @param eqpid My Param doc
* @return int
*/
int select_eqp_data(std::string eqpid);
};