eis/dsm/dsm_icei.cc

71 lines
2.7 KiB
C++
Raw Permalink Normal View History

#include <common/L2Event.h>
#include <dao/DbStandardDBAX.h>
#include <dsm/dsm_icei.h>
#include <dsm/utility.h>
#include <log4cplus/LOG.h>
#include <nlohmann/json.hpp>
#include <string>
#include <thread>
dsmICEI::dsmICEI() {
this->logger_ = std::make_unique<LOG>("dsm_icei");
dsm_alg_ = std::make_unique<DsmAlg>();
ruleid_norminfo_ =
std::make_unique<CMemMap<std::string, DataInfo>>("ZONE1", 5000);
}
dsmICEI::~dsmICEI() { logger_->Info() << "dsmICEI::~dsmICEI()" << endl; }
void baosight::dsmICEI::SendDataShort(::Ice::Int eventNo,
const ::Ice::ByteSeq &seq,
::Ice::Int length,
const Ice::Current &current) {
logger_->Info() << "event no:" << eventNo << endl; /* ALARM! */
string str(seq.begin(), seq.end());
logger_->Debug() << "seq str:" << str << std::endl;
// 根据电文号调用,执行分派任务操作
switch (eventNo) {
case 99999:
logger_->Debug() << "test" << std::endl;
dsm_alg_->dispose(eventNo, seq);
break;
default:
logger_->Error() << "wrong event No.!" << endl;
break;
}
}
void baosight::dsmICEI::SendDataLong(
::Ice::Int eventNo, const ::Ice::ByteSeq &seq, ::Ice::Int length,
const ::std::string &sender, const ::std::string &receiver,
const ::std::string &additional, const Ice::Current &current) {}
void baosight::dsmICEI::TimeNotify(::Ice::Int eventNo,
const ::Ice::ByteSeq &seq,
const Ice::Current &current) {
// logger_->Debug() << "Test" << std::endl;
string ruleid = "6eb79df5-9162-41ba-8e54-590689bee6a8";
string ruleid2 = "5db79df5-9162-41ba-8e54-590689bee6a8";
string ruleid3 = "5db79df5-9162-41ba-8e54-590689be6909";
string ruleid4 = "a7a8913d-c3a8-4531-8c44-01944d9a360d";
// if (ruleid_norminfo_ != nullptr) {
// nlohmann::json js1;
// logger_->Debug() << "Test2" << std::endl;
// UtilityTools::jsonReader("/users/dsc/code/dsm/json/norm_info.json", js1);
// string value_str = js1.dump();
// DataInfo data_info(js1);
// logger_->Debug() << "Test3" << data_info.invert2json() << std::endl;
// ruleid_norminfo_->insert(ruleid, &data_info);
// ruleid_norminfo_->insert(ruleid2, &data_info);
// ruleid_norminfo_->insert(ruleid3, &data_info);
// SingletonTemplate<DsmHandle>::GetInstance().insert(ruleid, &data_info);
// SingletonTemplate<DsmHandle>::GetInstance().insert(ruleid2, &data_info);
// SingletonTemplate<DsmHandle>::GetInstance().insert(ruleid3, &data_info);
// }
// logger_->Debug() << "Test4" << std::endl;
// dsm_alg_->dsm_handle(ruleid4);
// logger_->Debug() << "Test5" << std::endl;
dsm_alg_->timed_task();
}