#include AlarmInfo ExpWave::exec_mon() { AlarmInfo out_alarm; std::vector tmp_vec; this->refresh_now_time(); try { refresh_ihd_cache(); for (auto i = 0; i < queried_data_.rows(); i++) { refresh_exp_vars_ihd(i); auto tmp = cron_proc_sample(); if (tmp.has_value()) { tmp_vec.push_back((tmp.value()[0])); } } if (!tmp_vec.empty()) { auto tmp_data = Eigen::Map>{ tmp_vec.data(), static_cast(tmp_vec.size())}; auto frq_converted = data_process::fft_get(tmp_data, 20); auto dc_wave_factor = frq_converted(0, 1); frq_converted(0, 1) = 0; auto max_wave_factor = frq_converted.col(1).maxCoeff(); auto diff = abs(max_wave_factor - dc_wave_factor); // sample_stat_.cron_sampling_data(max_wave_factor); switch (this->test_mode_) { case stat_tools::TestMode::wave_test: if ( diff > dc_wave_factor * judge_diff_) { return utility::build_alarm_info( MsgLevel::ERROR, rule_id_, rule_name_, "EXPSMP", error_str_ + "波动性检测探测到异常,周期性波动振幅为" + std::to_string(max_wave_factor), query_time_range_); } break; case stat_tools::TestMode::wave_test_2: if (diff > judge_diff_) { return utility::build_alarm_info( MsgLevel::ERROR, rule_id_, rule_name_, "EXPSMP", error_str_ + "波动性检测探测到异常,周期性波动振幅为" + std::to_string(max_wave_factor), query_time_range_); } break; default: break; } } } catch (const std::exception& e) { std::throw_with_nested( mix_cc::Exception(-1, "calc_once error", BOOST_CURRENT_LOCATION)); } return out_alarm; } std::optional ExpWave::cron_proc_sample() { double result_value; try { act_triggered_ = static_cast(exp_act_->evaluate()); if (feedback_mode_) { feedback_triggered_ = static_cast(exp_feedback_->evaluate()); if (act_start_done() || act_not_hold()) { return std::nullopt; } if (act_done()) { result_value = exp_result_->evaluate(); this->log_action_info(result_value); if (result_value != 0 && !std::isnan(result_value)) { return std::make_optional(SamplePoint{result_value}); } } else if (act_timeout()) { this->get_timeout_alarm(); } } else if (act_triggered_) { result_value = exp_result_->evaluate(); if (result_value != 0 && !std::isnan(result_value)) { return std::make_optional(SamplePoint{result_value}); } } } catch (const std::exception& e) { std::throw_with_nested( mix_cc::Exception(-1, "calc_once error", BOOST_CURRENT_LOCATION)); } return std::nullopt; };