123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254 |
- #include "stdafx.h"
- #include "FPDErrorWarningProcess.h"
- extern Log4CPP::Logger* gLogger;
- FPDErrorWarning::FPDErrorWarning(std::shared_ptr <CCOS::Dev::IOEventCenter> EventCenter, std::string DevInstance, std::string strAppPath)
- {
- m_MSGUnit.reset(new nDetail::MSGUnit(EventCenter, DevInstance));
- m_EventCenter = EventCenter;
- std::string strPath = "";
- strPath = strAppPath + "OEMDrivers\\Detector\\Conf\\PNLErrorInfor.xml";
- m_ErrRes.setFileName(strPath.c_str());
- strPath = strAppPath + "OEMDrivers\\Detector\\Conf\\PNLWarnInfor.xml";
- m_WarnRes.setFileName(strPath);
- m_WarnList.clear();
- m_ErrList.clear();
- }
- FPDErrorWarning::~FPDErrorWarning()
- {
- }
- int FPDErrorWarning::GetMessageLevel(const std::string& code)
- {
- int level = 1;
- if (code == ERR_FPD_TEMPHIGH_NOT_ACQ
- || code == ERR_FPD_TEMPLOW_NOT_ACQ
- || code == ERR_FPD_DOSE_HIGH
- || code == ERR_FPD_MAX_NUMBER
- || code == ERR_FPD_DOSE_OBJ
- || code == ERR_FPD_RESTART
- || code == ERR_FPD_DOSE_LOW
- || code == ERR_FPD_NOFPD
- || code == ERR_FPD_ACQ_FAILED
- || code == WAR_FPD_TEMPERATURE_HIGH
- || code == WAR_FPD_TEMPERTURE_LOW
- || code == WAR_FPD_BATTERY_LOW
- || code == WAR_FPD_EXCEED_CALB_TEMPER
- || code == WAR_FPD_EXCEED_CALB_TEMPER_HIGH
- || code == WAR_FPD_EXCEED_CALB_TEMPER_LOW)
- {
- level = 99;
- }
- else if (code == ERR_FPD_WIFI_LOW
- || code == ERR_FPD_DISCONNECT
- || code == ERR_FPD_BATTERY_LOW
- || code == ERR_FPD_POWEROFF
- || code == ERR_FPD_FATAL_ERROR
- || code == WAR_FPD_LOAD_CORRECT_FILE
- || code == WAR_FPD_WIFI_LOW)
- {
- level = 98;
- }
- return level;
- }
- void FPDErrorWarning::AddErrMsg(std::string code, std::string info)
- {
- Info("AddErrMsg {$}: {$}", code.c_str(), info.c_str());
- int level = GetMessageLevel(code);
- m_MSGUnit->AddErrorMessage(code.c_str(), level, info.c_str());
- }
- void FPDErrorWarning::DelErrMsg(std::string code)
- {
- int level = GetMessageLevel(code);
- Info("DelErrMsg {$}", code.c_str());
- m_MSGUnit->DelErrorMessage(code.c_str(), level, "");
- }
- void FPDErrorWarning::AddWarnMsg(std::string code, std::string info)
- {
- Info("AddWarnMsg {$}: {$}", code.c_str(), info.c_str());
- int level = GetMessageLevel(code);
- m_MSGUnit->AddWarnMessage(code.c_str(), level, info.c_str());
- }
- void FPDErrorWarning::DelWarnMsg(std::string code)
- {
- int level = GetMessageLevel(code);
- Info("DelWarnMsg {$}", code.c_str());
- m_MSGUnit->DelWarnMessage(code.c_str(), level, "");
- }
- void FPDErrorWarning::SendError( DeviceError obErr)
- {
- AddErrMsg(obErr.getCode(), obErr.getDescription());
- }
- void FPDErrorWarning::SendAllError()
- {
- Info("Send All Error");
- for (int i = 0; i < m_ErrList.size(); i++)
- {
- DeviceError stError;
- stError = m_ErrList.item(i);
- SendError( stError);
- }
- }
- void FPDErrorWarning::SendAllWarn()
- {
- Info("Send All Warn");
- for (int i = 0; i < m_WarnList.size(); i++)
- {
- auto stWar = m_WarnList.item(i);
- AddWarnMsg(stWar.getCode(), stWar.getDescription());
- }
- }
- void FPDErrorWarning::SyncErrorList()
- {
- SendAllError();
- SendAllWarn();
- }
- void FPDErrorWarning::ClearAllError()
- {
- //先清除原有探测器的ERROR
- Info("Clear All Error");
- if (0 == m_ErrList.size()) // 切换工作位时清除错误,会将发生器的错误无故清除
- {
- Info("There is no error in list. Omit Clear All Error");
- return;
- }
- for (int i = 0; i < m_ErrList.size(); i++)
- {
- DeviceError stError;
- stError = m_ErrList.item(i);
- OnErrorX(stError.getCode());
- }
- }
- void FPDErrorWarning::SendErrorX( std::string strErrorCode)
- {
- DelErrMsg(strErrorCode);
- }
- bool FPDErrorWarning::OnErrorX(std::string strErr)
- {
- if (m_ErrListTemp.isExist(strErr)) //清除一下初始化时的临时ErrorList
- {
- Info("Remove temp error");
- m_ErrListTemp.remove(strErr);
- }
- if (m_ErrList.isExist(strErr))
- {
- m_ErrList.remove(strErr);
- SendErrorX( strErr);
- return true;
- }
- return false;
- }
- void FPDErrorWarning::SendWarn( DeviceError stWar)
- {
-
- }
- bool FPDErrorWarning::IsErrorExist(std::string code)
- {
- return m_ErrList.isExist(code);
- }
- int FPDErrorWarning::GetExistErrorNum()
- {
- return m_ErrList.size();
- }
- void FPDErrorWarning::OnError(std::string strErrCode, std::string strErr)
- {
- if (IsErrorExist(strErrCode))
- {
- Info("Same Error,Omit");
- return;
- }
- DeviceError stErr;
- if (!m_ErrRes.getDeviceError(strErrCode, stErr))
- {
- Warn("Get Error Resouse Fault! ErrorCode:{$}", strErrCode);
- stErr.setCode(strErrCode);
- stErr.setName(strErrCode);
- }
- m_ErrList.add(stErr);
- std::string strDesc = stErr.getDescription() + strErr;
- stErr.setDescription(strDesc);
- AddErrMsg(stErr.getCode(), stErr.getDescription());
- }
- void FPDErrorWarning::OnWarn(std::string strWarnCode, std::string strWarn)
- {
- std::string strLog;
- DeviceError stWar;
- if (m_WarnList.isExist(strWarnCode))
- {
- Info("Same warn {$}", strWarnCode.c_str());
- return;
- }
- if (!m_WarnRes.getDeviceWarn(strWarnCode, stWar))
- {
- Warn(("Get Warn Resouse Fault! WarnCode:{$}"), strWarnCode);
- stWar.setCode(strWarnCode);
- stWar.setName(strWarnCode);
- stWar.setDescription(strWarn);
- }
- Info(("Send Warn Code:{$}"), strWarnCode);
- std::string strDesc = stWar.getDescription() + strWarn;
- stWar.setDescription(strDesc);
- m_WarnList.add(stWar);
- AddWarnMsg(stWar.getCode(), stWar.getDescription());
- }
- void FPDErrorWarning::OnWarnX(std::string strWarnCode)
- {
- if (strWarnCode == "") //清除一下初始化时的临时ErrorList
- {
- Info("OnWarnX have no code");
- return;
- }
- if (m_WarnList.isExist(strWarnCode))
- {
- m_WarnList.remove(strWarnCode);
- DelWarnMsg(strWarnCode);
- }
- }
|