refactor: AlgBase 从 ExpModule 迁移到 ExpressionEngine
This commit is contained in:
parent
f10da49f65
commit
96ca4d02bb
@ -85,8 +85,7 @@ int AlgBase::init() {
|
||||
ms = 20;
|
||||
}
|
||||
this->delay_time_ = milliseconds(ms);
|
||||
exp_mpdule_ptr_ =
|
||||
std::make_unique<ExpModule>(mm_vars, m_tags, is_exp_alg_);
|
||||
expr_engine_ = std::make_unique<ExpressionEngine>(mm_vars, m_tags);
|
||||
if (this->prr_ == 1) {
|
||||
string exp_str = "";
|
||||
|
||||
@ -98,10 +97,8 @@ int AlgBase::init() {
|
||||
logger_->Info() << "tmp_exp:" << tmp_exp << std::endl;
|
||||
exp_str = get_macro_replaced_exp(tmp_exp);
|
||||
logger_->Info() << "exp_str:" << exp_str << std::endl;
|
||||
exp_mpdule_ptr_->add_exp("pre_result", exp_str);
|
||||
logger_->Info() << "pre_result:"
|
||||
<< exp_mpdule_ptr_->get_exp_str("pre_result")
|
||||
<< std::endl;
|
||||
expr_engine_->registerExpression("pre_result", exp_str);
|
||||
logger_->Info() << "pre_result:" << exp_str << std::endl;
|
||||
}
|
||||
logger_->Debug() << "ruleid:" << this->rule_id_
|
||||
<< ",rulename:" << this->rule_name_
|
||||
@ -199,7 +196,7 @@ void AlgBase::exec_mon_call() {
|
||||
if (alarm.alarmed) {
|
||||
logger_->Debug() << alarm.content << endl;
|
||||
alarm_poster_.alarm(alarm, &last_alarm_time_);
|
||||
exp_mpdule_ptr_->fun_reset();
|
||||
expr_engine_->forceResetFunVars();
|
||||
} else {
|
||||
if (get_save_data_cycled()) {
|
||||
this->save_rule_norm_data();
|
||||
@ -371,8 +368,12 @@ bool AlgBase::update_map_rule() {
|
||||
|
||||
bool AlgBase::get_prr() {
|
||||
if (this->prr_ == 1) {
|
||||
exp_mpdule_ptr_->update();
|
||||
bool prr_result = (bool)exp_mpdule_ptr_->get_value("pre_result");
|
||||
// 刷新共享内存变量
|
||||
this->refresh_now_time();
|
||||
mix_cc::time_range_t dummy_range;
|
||||
expr_engine_->refreshFromMemory(this->now_time_, dummy_range);
|
||||
|
||||
bool prr_result = expr_engine_->evaluateBool("pre_result");
|
||||
this->now_prr_ = prr_result;
|
||||
return prr_result;
|
||||
}
|
||||
|
||||
@ -18,7 +18,7 @@
|
||||
#include <eqpalg/define/error_code.h>
|
||||
#include <eqpalg/define/public.h>
|
||||
#include <eqpalg/gb_logger.h>
|
||||
#include <eqpalg/utility/ExpModule.h>
|
||||
#include <eqpalg/utility/expression_engine.h>
|
||||
#include <eqpalg/utility/VarsCache.hpp>
|
||||
#include <eqpalg/utility/XorShift128Plus.hpp>
|
||||
#include <eqpalg/utility/alarm_poster.h>
|
||||
@ -100,7 +100,7 @@ protected:
|
||||
std::vector<ErrorCodeType> error_code_list_;
|
||||
|
||||
int prr_ = PRR::None;
|
||||
std::unique_ptr<ExpModule> exp_mpdule_ptr_;
|
||||
std::unique_ptr<ExpressionEngine> expr_engine_;
|
||||
|
||||
DataInfo data_info_;
|
||||
|
||||
@ -108,8 +108,6 @@ protected:
|
||||
|
||||
bool now_prr_ = false;
|
||||
|
||||
bool is_exp_alg_ = false;
|
||||
|
||||
int task_seq = 0;
|
||||
TimeDur save_interval_ms_ = 5000ms;
|
||||
TimeDur rule_state_update_interval_ms_ = 500ms;
|
||||
|
||||
Loading…
Reference in New Issue
Block a user