eis/eqpalg/build_algorithm.cpp

190 lines
6.1 KiB
C++

// #include <eqpalg/algs/exp.h>
// #include <eqpalg/algs/exp_cpc.h>
// #include <eqpalg/algs/exp_sample.h>
// #include <eqpalg/algs/exp_sample_multi_dim.h>
// #include <eqpalg/algs/exp_sample_curve.h>
// #include <eqpalg/algs/exp_hs.h>
// #include <eqpalg/algs/dist_interval_alg.h>
// #include <eqpalg/algs/exp_material.h>
// #include <eqpalg/algs/exp_wave.h>
// #include <eqpalg/algs/sbreak_position.h>
// #include <eqpalg/algs/alarm_monitor.h>
// #include <eqpalg/algs/exp_cs.h>
// #include <eqpalg/algs/meter_bound.h>
// #include <eqpalg/algs/meter_static.h>
// #include <eqpalg/algs/table_static.h>
// #include <eqpalg/algs/times_stastics.h>
// #include <eqpalg/algs/times_stastics_cs.h>
#include <eqpalg/algs/roller2.h>
#include <eqpalg/algs/trend_slope2.h>
#include <eqpalg/build_algorithm.h>
// for default case
#include <eqpalg/algs/exp_base.h>
#include <eqpalg/algs/exp_bound.h>
#include <eqpalg/algs/exp_sample2D.h>
#include <eqpalg/algs/exp_times.h>
#include <eqpalg/algs/fault_code.h>
#include <eqpalg/algs/glitch_detection.h>
#include <eqpalg/algs/null.h>
#include <eqpalg/algs/roller3.h>
#include <eqpalg/algs/trend_slope3.h>
std::unique_ptr<AlgBase> build_algorithm(int algId, const string &ruleId,
const string &name,
const mix_cc::json &rule_json,
const double padding_low,
const double padding_up) {
LOG d("build_algorithm");
switch (algId) {
case 1:
case 2:
case 3:
case 4:
case 5:
return std::make_unique<ExpBase>(name, rule_json, ruleId, algId);
break;
case 6:
case 7:
return std::make_unique<ExpTimes>(name, rule_json, ruleId, algId);
break;
case 8:
return std::make_unique<TrendSlope2>(name, rule_json, ruleId);
break;
case 9:
return std::make_unique<Roller2>(name, rule_json, ruleId, -1);
break;
case 10:
case 11:
/*故障代码解析*/
return std::make_unique<FaultCode>(name, rule_json, ruleId, algId - 10);
break;
case 12:
case 13:
return std::make_unique<ExpSample2D>(name, rule_json, ruleId, algId);
break;
case 14:
return std::make_unique<TrendSlope3>(name, rule_json, ruleId);
break;
case 15:
return std::make_unique<GlitchDetection>(name, rule_json, ruleId);
break;
case 16:
case 18:
return std::make_unique<Roller3>(name, rule_json, ruleId, algId);
break;
case 17:
return std::make_unique<ExpBound>(name, rule_json, ruleId, algId);
break;
// case 18:
// return std::make_unique<Roller3>(name, rule_json, ruleId, -3);
// break;
// case 11:
// // return std::make_unique<Torque>(name, rule_json, ruleId);
// break;
// case 20:
// case 21:
// case 220:
// case 221:
// case 111:
// return std::make_unique<Exp>(name, rule_json, ruleId, 1);
// break;
// case 23:
// return std::make_unique<ExpMaterial>(name, rule_json, ruleId);
// break;
// case 22:
// case 25:
// case 27:
// case 28:
// return std::make_unique<ExpSample>(name, rule_json, ruleId, 1,
// padding_low, padding_up);
// break;
// case 30:
// // case 230:
// return std::make_unique<TrendSlope>(name, rule_json, ruleId);
// break;
// case 32:
// // return std::make_unique<ExpSampleCurve>(name, rule_json, ruleId);
// break;
// case 33: {
// int dim = 0;
// auto tag1 =
// rule_json.at("sample").at("tag_x1").at(1).get<std::string>(); if (tag1
// != "null" && !tag1.empty()) {
// dim++;
// }
// auto tag2 =
// rule_json.at("sample").at("tag_x2").at(1).get<std::string>(); if (tag2
// != "null" && !tag2.empty()) {
// dim++;
// }
// auto tag3 =
// rule_json.at("sample").at("tag_x3").at(1).get<std::string>(); if (tag3
// != "null" && !tag3.empty()) {
// dim++;
// }
// if (dim == 1) {
// return std::make_unique<ExpSampleMultiDim>(name, rule_json, ruleId,
// 1,
// padding_low, padding_up);
// }
// if (dim == 2) {
// return std::make_unique<ExpSampleMultiDim>(name, rule_json, ruleId,
// 2,
// padding_low, padding_up);
// }
// if (dim == 3) {
// return std::make_unique<ExpSampleMultiDim>(name, rule_json, ruleId,
// 3,
// padding_low, padding_up);
// }
// } break;
// case 34:
// return std::make_unique<ExpWave>(name, rule_json, ruleId, padding_low,
// padding_up);
// break;
// case 40:
// // return std::make_unique<ExpRunStatic>(name, rule_json, ruleId);
// break;
// case 50:
// return std::make_unique<ExpCpc>(name, rule_json, ruleId);
// break;
// case 61:
// // return std::make_unique<ExpSampleCurve>(name, rule_json, ruleId);
// break;
// case 71:
// return std::make_unique<DistInterval>(name, rule_json, ruleId, 1,
// padding_low, padding_up);
// break;
// // case 100:
// // return std::make_unique<SBreakPosition>(name, rule_json, ruleId);
// // break;
// case 113:
// return std::make_unique<TimesStastics>(name, rule_json, ruleId);
// break;
// case 112:
// return std::make_unique<TableStatic>(name, rule_json, ruleId);
// break;
// case 114:
// return std::make_unique<MeterStatic>(name, rule_json, ruleId);
// break;
// // case 120:
// // case 121:
// // return std::make_unique<ExpCS>(name, rule_json, ruleId, 1);
// // break;
// // case 122:
// // return std::make_unique<TimesStasticsCS>(name, rule_json, ruleId);
// // break;
// case 131:
// return std::make_unique<MeterBound>(name, rule_json, ruleId, 1);
// break;
// case 132:
// return std::make_unique<AlarmMonitor>(name, rule_json, ruleId, 1);
// break;
default:
d.Warn() << "undefined algorithm" << endl;
return std::make_unique<Null>(name, rule_json, ruleId);
}
d.Warn() << "out of control flow" << endl;
return std::make_unique<Null>(name, rule_json, ruleId);
}