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
113 lines
2.6 KiB
C++
113 lines
2.6 KiB
C++
#pragma once
|
|
/**
|
|
* @file ExpModule.h
|
|
* @brief 表达式模块
|
|
* @author your name (you@domain.com)
|
|
* @version 0.1
|
|
* @date 2025-08-20
|
|
*
|
|
* Copyright: Baosight Co. Ltd.
|
|
* DO NOT COPY/USE WITHOUT PERMISSION
|
|
*
|
|
*/
|
|
#include "mix_cc/ihyper_db.h"
|
|
#include "mix_cc/json.h"
|
|
#include "mix_cc/matheval/matheval.hpp"
|
|
#include <chrono>
|
|
#include <eqpalg/utility/StatExp.hpp>
|
|
#include <log4cplus/LOG.h>
|
|
#include <map>
|
|
#include <memory>
|
|
#include <string>
|
|
#include <vector>
|
|
using std::map;
|
|
using std::string;
|
|
using std::vector;
|
|
using MExp = mix_cc::matheval::Expression;
|
|
using namespace std::chrono;
|
|
using std::chrono::system_clock;
|
|
using TimePoint = system_clock::time_point;
|
|
using TimeDur = milliseconds;
|
|
|
|
class ExpModule {
|
|
public:
|
|
ExpModule(std::map<std::string, double> &vars_ref, vector<string> &m_tags,
|
|
bool &is_exp_alg_ref);
|
|
~ExpModule();
|
|
ExpModule() = delete;
|
|
ExpModule &operator=(const ExpModule &) = delete;
|
|
|
|
/**
|
|
* @brief 添加表达式
|
|
* @param exp_name 表达式名称
|
|
* @param exp_str 表达式字符串
|
|
* @return int
|
|
*/
|
|
int add_exp(string exp_name, string exp_str);
|
|
/**
|
|
* @brief 更新数据,更新表达式的值
|
|
* @return int
|
|
*/
|
|
int update();
|
|
|
|
void fun_reset();
|
|
|
|
/**
|
|
* @brief 更新数据,更新表达式的值 通过指定数据
|
|
* @param queried_data 指定数据项
|
|
* @return int
|
|
*/
|
|
int update(Eigen::Matrix<double, Eigen::Dynamic, Eigen::Dynamic> queried_data,
|
|
std::vector<TimePoint> queried_time, int row = 0);
|
|
/**
|
|
* @brief 获取表达式的值
|
|
* @param exp_name 表达式名称
|
|
* @return double
|
|
*/
|
|
double get_value(string exp_name);
|
|
/**
|
|
* @brief
|
|
*/
|
|
void print_value();
|
|
|
|
/**
|
|
* @brief Get the exp str object
|
|
* @param exp_name My Param doc
|
|
* @return string
|
|
*/
|
|
string get_exp_str(string exp_name);
|
|
|
|
private:
|
|
/**
|
|
* @brief 表达式变量,表达式初始化
|
|
*/
|
|
void init();
|
|
|
|
/**
|
|
* @brief 更新数据 共享内存
|
|
*/
|
|
void refresh_exp_vars_mem();
|
|
|
|
/**
|
|
* @brief 更新数据 指定数据
|
|
* @param queried_data
|
|
*/
|
|
void refresh_exp_ihd_mem(
|
|
Eigen::Matrix<double, Eigen::Dynamic, Eigen::Dynamic> queried_data,
|
|
std::vector<TimePoint> queried_time, int row);
|
|
|
|
private:
|
|
map<string, double> &mm_vars;
|
|
map<string, double> exp_result_;
|
|
map<string, std::unique_ptr<MExp>> exp_ptr_;
|
|
map<string, string> exp_str_;
|
|
vector<string> &m_tags;
|
|
std::unique_ptr<LOG> logger_;
|
|
TimePoint now_time_;
|
|
/**
|
|
* @brief 自定义带状态函数
|
|
*/
|
|
StatExp::FunVars fun_vars_;
|
|
bool &is_exp_alg_;
|
|
};
|