refactor: 非 ExpBase 算法适配 ExpressionEngine API
This commit is contained in:
parent
7c2fe7f7bb
commit
38d0942a6c
@ -78,7 +78,7 @@ AlarmInfo GlitchDetection::exec_mon() {
|
||||
data_index_ = 0;
|
||||
run_time_range_.set_left(this->now_time_);
|
||||
}
|
||||
data_[data_index_] = exp_mpdule_ptr_->get_value("dataX");
|
||||
data_[data_index_] = expr_engine_->evaluate("dataX");
|
||||
data_index_++;
|
||||
return out_alarm;
|
||||
}
|
||||
@ -117,7 +117,7 @@ int GlitchDetection::load_exp() {
|
||||
auto tmp_exp =
|
||||
rule_json_.at("function").at("dataX").at("value").get<std::string>();
|
||||
exp_str_ = get_macro_replaced_exp(tmp_exp);
|
||||
exp_mpdule_ptr_->add_exp("dataX", exp_str_);
|
||||
expr_engine_->registerExpression("dataX", exp_str_);
|
||||
/*数据长度*/
|
||||
auto tmp_data_size = rule_json_.at("function")
|
||||
.at("dataX")
|
||||
@ -137,8 +137,10 @@ int GlitchDetection::load_exp() {
|
||||
}
|
||||
bool GlitchDetection::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;
|
||||
logger_->Debug() << "ruleid:" << this->rule_id_
|
||||
<< ",rulename:" << this->rule_name_
|
||||
|
||||
@ -71,7 +71,7 @@ Roller3::~Roller3() {
|
||||
|
||||
AlarmInfo Roller3::mon_proc() {
|
||||
|
||||
if ((bool)exp_act_->evaluate() == false) {
|
||||
if (!expr_engine_->evaluateBool("act")) {
|
||||
logger_->Debug() << "前提条件不满足!" << std::endl;
|
||||
return AlarmInfo{};
|
||||
}
|
||||
@ -227,9 +227,7 @@ int Roller3::init_X_exp() {
|
||||
exp_str_ = get_macro_replaced_exp(tmp_exp);
|
||||
res += init_hold_exp_str(exp_str_);
|
||||
|
||||
auto fun_res = fun_vars_.add_exp_str(exp_str_, &mm_vars);
|
||||
res += fun_res.first ? 0 : -1;
|
||||
exp_str_ = fun_res.second;
|
||||
// ExpressionEngine::registerExpression() now handles FunVars processing internally.
|
||||
feedback_mode_ = false;
|
||||
auto messy_code = exp_messy_code_check(exp_str_);
|
||||
if (messy_code == -1) {
|
||||
@ -305,31 +303,19 @@ int Roller3::init_X_exp() {
|
||||
}
|
||||
}
|
||||
value_num_ = tag_seq_.size();
|
||||
if (exp_act_ == nullptr && exp_str_ != "") {
|
||||
try {
|
||||
exp_act_ =
|
||||
std::make_unique<mix_cc::matheval::Expression>(exp_str_, &mm_vars);
|
||||
logger_->Debug() << "exp_act:" << exp_str_ << "=" << exp_act_->evaluate()
|
||||
<< endl;
|
||||
} catch (const std::exception &e) {
|
||||
logger_->Error() << "exp_act:" << exp_str_ << "计算出错:" << e.what()
|
||||
<< ",location:" << BOOST_CURRENT_LOCATION << endl;
|
||||
if (exp_str_ != "") {
|
||||
int reg_ret = expr_engine_->registerExpression("act", exp_str_);
|
||||
if (reg_ret != 0) {
|
||||
this->error_code_list_.push_back(
|
||||
{ErrorType::CalError, ErrorLocation::ActExp});
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
if (exp_result_ == nullptr && tags_exp_ != "") {
|
||||
try {
|
||||
exp_result_ =
|
||||
std::make_unique<mix_cc::matheval::Expression>(tags_exp_, &mm_vars);
|
||||
logger_->Debug() << "tags_exp_:" << tags_exp_ << "="
|
||||
<< exp_result_->evaluate() << endl;
|
||||
} catch (const std::exception &e) {
|
||||
logger_->Error() << "tags_exp_:" << tags_exp_ << "计算出错:" << e.what()
|
||||
<< ",location:" << BOOST_CURRENT_LOCATION << endl;
|
||||
if (tags_exp_ != "") {
|
||||
int reg_ret = expr_engine_->registerExpression("result", tags_exp_);
|
||||
if (reg_ret != 0) {
|
||||
this->error_code_list_.push_back(
|
||||
{ErrorType::CalError, ErrorLocation::ActExp});
|
||||
{ErrorType::CalError, ErrorLocation::ResultExp});
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
@ -182,8 +182,8 @@ std::vector<AlarmInfo> TrendSlope2::exec_task(mix_cc::time_range_t time_range) {
|
||||
|
||||
bool TrendSlope2::get_prr2() {
|
||||
if (this->prr_ == 1) {
|
||||
exp_mpdule_ptr_->update(queried_data_, queried_time_);
|
||||
bool prr_result = (bool)exp_mpdule_ptr_->get_value("pre_result");
|
||||
expr_engine_->refreshFromIhdRow(0, queried_data_, queried_time_, now_time_, query_time_range_);
|
||||
bool prr_result = expr_engine_->evaluateBool("pre_result");
|
||||
this->now_prr_ = prr_result;
|
||||
logger_->Debug() << "ruleid:" << this->rule_id_
|
||||
<< ",rulename:" << this->rule_name_
|
||||
|
||||
@ -190,8 +190,8 @@ std::vector<AlarmInfo> TrendSlope3::exec_task(mix_cc::time_range_t time_range) {
|
||||
|
||||
bool TrendSlope3::get_prr2() {
|
||||
if (this->prr_ == 1) {
|
||||
exp_mpdule_ptr_->update(queried_data_, queried_time_);
|
||||
bool prr_result = (bool)exp_mpdule_ptr_->get_value("pre_result");
|
||||
expr_engine_->refreshFromIhdRow(0, queried_data_, queried_time_, now_time_, query_time_range_);
|
||||
bool prr_result = expr_engine_->evaluateBool("pre_result");
|
||||
this->now_prr_ = prr_result;
|
||||
logger_->Debug() << "ruleid:" << this->rule_id_
|
||||
<< ",rulename:" << this->rule_name_
|
||||
|
||||
Loading…
Reference in New Issue
Block a user