eis/eqpalg/utility/build_alarm_info.cc
Huamonarch 224c2c45c4 Remove irrelevant comments from eqpalg source files
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
2026-05-09 13:30:09 +08:00

56 lines
1.9 KiB
C++

#include "mix_cc/json.h"
#include "mix_cc/type/mix_time.h"
#include <cmath>
#include <eqpalg/utility/build_alarm_info.h>
namespace utility {
using std::string;
AlarmInfo build_alarm_info(const string &alarm_level, const string &ruleId,
const string &name, const string &group,
const std::string &alarm_content,
const mix_cc::time_range_t &time_range) {
AlarmInfo ret;
ret.content[0]["key"] = alarm_level;
ret.content[0]["result"] = alarm_content;
ret.content[0]["alarm_time"] =
mix_cc::mix_time_t(time_range.get_right()).to_milliseconds();
ret.alarmed = true;
ret.alarm_start_time = time_range.get_left();
ret.alarm_end_time = time_range.get_right();
ret.cfg_info.id = ruleId;
ret.cfg_info.name = name;
ret.cfg_info.group = group;
ret.cfg_info.descName = alarm_content;
ret.cfg_info.remark = alarm_content;
return ret;
}
AlarmInfo
build_alarm_info(const string &alarm_level, const string &ruleId,
const string &name, const string &group,
const std::string &alarm_content,
const std::vector<double> &value,
const std::vector<mix_cc::float_range_t> &desire_range,
const mix_cc::time_range_t &time_range) {
auto ret = build_alarm_info(alarm_level, ruleId, name, group, alarm_content,
time_range);
auto dr_array = mix_cc::json::array();
for (const auto &x : desire_range) {
dr_array.push_back(x.to_array());
}
ret.content[0]["value"] = value;
ret.content[0]["desire_range"] = dr_array;
return ret;
}
string get_msg_level(double limit_down, double limit_up, double value) {
if (value < limit_down) {
return value < limit_down - fabs(limit_down * 0.3) ? "ERROR" : "WARN";
} else {
return value > limit_up + fabs(limit_up * 0.3) ? "ERROR" : "WARN";
}
return "NULL";
}
}