#include "stdafx.h" #include "FPDErrorWarningProcess.h" extern Log4CPP::Logger* gLogger; #if 1 FPDErrorWarning::FPDErrorWarning(std::shared_ptr EventCenter, std::string DevInstance, std::string strAppPath) { m_MSGUnit.reset(new nDetail::MSGUnit(EventCenter, DevInstance)); m_EventCenter = EventCenter; std::string strPath = strAppPath + "OEMDrivers\\Detector\\SiemensTrixell\\PNLErrorInfor.xml"; m_ErrRes.setFileName(strPath.c_str()); strPath = strAppPath + "OEMDrivers\\Detector\\SiemensTrixell\\PNLWarnInfor.xml"; m_WarnRes.setFileName(strPath); strPath = strAppPath + "OEMDrivers\\Detector\\SiemensTrixell\\XCUErrorInfor.xml"; m_XCUErrRes.setFileName(strPath.c_str()); strPath = strAppPath + "OEMDrivers\\Detector\\SiemensTrixell\\XCUWarnInfor.xml"; m_XCUWarnRes.setFileName(strPath); 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()); //LogicDevice::AddErrorMessage(code.c_str(), level, 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()); //LogicDevice::AddErrorMessage(code.c_str(), level, 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())//fixbug 9834 切换工作位时清除错误,会将发生器的错误无故清除 { Info("There is no error in list. Omit Clear All Error"); return; } //if (m_bConnect2XCU) //{ // ResDataObject request, response; // request.add("P0", CAL_START); // m_pXCUClient->Action("SetFPDCalibrationStatus", request, response, g_nXCUtimeout); //} //SendCmd(BUSID_HWMgr, BUSCMD_HW_ERROR, m_nDeviceIndex, Parameter_A, CMDID_RES, String_C, STR_ZERODATA); for (int i = 0; i < m_ErrList.size(); i++) { DeviceError stError; stError = m_ErrList.item(i); //if (ERR_FPD_IMAGE_PENDING != stError.getCode())//if (ERR_FPD_MAX_NUMBER == stError.getCode() || ERR_FPD_SN_NOT_LIST == stError.getCode()) { OnErrorX(stError.getCode()); } } } void FPDErrorWarning::SendErrorX( std::string strErrorCode) { //SendCmd(BUSID_HWMgr, BUSCMD_HW_ERROR, nIndex, Parameter_A, CMDID_ERX, String_C, 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) { //ResDataObject obxmllist; //obxmllist.add("Code", stWar.getCode().c_str()); //obxmllist.add("Name", stWar.getDescription().c_str()); //obxmllist.add("Description", stWar.getDescription().c_str()); //obxmllist.add("Solution", stWar.getSolution().c_str()); //obxmllist.add("NotifyType", stWar.getNotifyType().c_str()); //obxmllist.add("Interlock", stWar.getInterlock().c_str()); //obxmllist.add("BackCommand", stWar.getBackCommand().c_str()); //obxmllist.add("SerialNumber", m_stDeviceConfig.strPanelSerial.c_str()); //std::string strWar = obxmllist.encode(); //SendCmd(BUSID_HWMgr, BUSCMD_HW_ERROR, nIndex, Parameter_A, CMDID_WAR, String_C, wcsWar); //if (m_bConnect2XCU) //{ // ResDataObject request, response; // request.add("P0", stWar.getCode().c_str()); // m_pXCUClient->Action("SendFPDWarn", request, response, g_nXCUtimeout); //} } bool FPDErrorWarning::IsErrorExist(std::string code) { //if (m_ErrList.isExist(code)) //{ // int nSize = m_ErrList.size(); // Warn("IsErrorExist have {$} num: {$}", code.c_str(), nSize); // for (int i = 0; i < nSize; i++) // { // DeviceError stError; // stError = m_ErrList.item(i); // // { // Warn("{$}",stError.getCode().c_str()); // } // } //} 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)) { if (!m_XCUErrRes.getDeviceError(strErrCode, stErr)) { Info("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)) { if (!m_XCUWarnRes.getDeviceWarn(strWarnCode, stWar)) { Info(("Get Warn Resouse Fault! WarnCode:{$}"), strWarnCode); stWar.setCode(strWarnCode); stWar.setName(strWarnCode); stWar.setDescription(strWarn); } Info("XCU need this Warn"); } //endif 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); } } bool FPDErrorWarning::IsXCUneedError(std::string strErrCode, std::string & strBackCommand) { DeviceError stErr; if (m_XCUErrRes.getDeviceError(strErrCode, stErr)) { strBackCommand = stErr.getBackCommand(); Info("XCU need this Error {$}, BackCommand {$}", strErrCode.c_str(), strBackCommand.c_str()); return true; } return false; } bool FPDErrorWarning::IsXCUneedWarn(std::string strWarnCode, std::string & strBackCommand) { DeviceError stWar; if (m_XCUWarnRes.getDeviceWarn(strWarnCode, stWar)) { strBackCommand = stWar.getBackCommand(); Info("XCU need this Warn {$}, BackCommand {$}", strWarnCode.c_str(), strBackCommand.c_str()); return true; } return false; } #endif