123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221 |
- #include "FPDErrorWarningProcess.h"
- #include "LogLocalHelper.h"
- #include "Log4CPP.h"
- //extern Log4CPP::Logger* mLog::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 = strAppPath + "\\OEMDrivers\\Detector\\Demo\\ErrorInfo.xml";
- m_ErrRes.setFileName(strPath.c_str());
- strPath = strAppPath + "\\OEMDrivers\\Detector\\Demo\\WarnInfo.xml";
- m_WarnRes.setFileName(strPath);
- }
- FPDErrorWarning::~FPDErrorWarning()
- {
- }
- void FPDErrorWarning::AddErrMsg(std::string code, std::string info)
- {
- FINFO( "AddErrMsg {$}: {$}", code.c_str(), info.c_str());
- int level = 1;
- m_MSGUnit->AddErrorMessage(code.c_str(), level, info.c_str());
- }
- void FPDErrorWarning::DelErrMsg(std::string code)
- {
- int level = 1;
- FINFO( "DelErrMsg {$}", code.c_str());
- m_MSGUnit->DelErrorMessage(code.c_str(), level, "");
- }
- void FPDErrorWarning::AddWarnMsg(std::string code, std::string info)
- {
- FINFO( "AddWarnMsg {$}: {$}", code.c_str(), info.c_str());
- int level = 1;
- m_MSGUnit->AddWarnMessage(code.c_str(), level, info.c_str());
- }
- void FPDErrorWarning::DelWarnMsg(std::string code)
- {
- int level = 1;
- FINFO( "DelWarnMsg {$}", code.c_str());
- m_MSGUnit->DelWarnMessage(code.c_str(), level, "");
- }
- void FPDErrorWarning::SendError( DeviceError obErr)
- {
- //ResDataObject obxmllist;
- //obxmllist.add("Code", obErr.getCode().c_str());
- //obxmllist.add("Name", obErr.getDescription().c_str());
- //obxmllist.add("Description", obErr.getDescription().c_str());
- //obxmllist.add("Solution", obErr.getSolution().c_str());
- //obxmllist.add("NotifyType", obErr.getNotifyType().c_str());
- //obxmllist.add("Interlock", obErr.getInterlock().c_str());
- //obxmllist.add("BackCommand", obErr.getBackCommand().c_str());
- //obxmllist.add("SerialNumber", m_stDeviceConfig.strPanelSerial.c_str());
- //std::string strErr = obxmllist.encode();
- //SendCmd(BUSID_HWMgr, BUSCMD_HW_ERROR, nIndex, Parameter_A, CMDID_ERR, String_C, wcsErr);
- //if (m_bConnect2XCU)
- //{
- // ResDataObject request, response;
- // request.add("P0", obErr.getCode().c_str());
- // m_pXCUClient->Action("SendFPDError", request, response, g_nXCUtimeout);
- //}
- }
- void FPDErrorWarning::SendAllError()
- {
- FINFO( "Send All Error");
- for (int i = 0; i < m_ErrList.size(); i++)
- {
- DeviceError stError;
- stError = m_ErrList.item(i);
- SendError( stError);
- }
- }
- void FPDErrorWarning::ClearAllError()
- {
- //先清除原有探测器的ERROR
- FINFO( "Clear All Error");
- if (0 == m_ErrList.size())//fixbug 9834 切换工作位时清除错误,会将发生器的错误无故清除
- {
- FINFO( "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);
- if (ERR_FPD_MAX_NUMBER == stError.getCode() || ERR_FPD_SN_NOT_LIST == stError.getCode())
- {
- OnErrorX(stError.getCode());
- }
- }
- }
- void FPDErrorWarning::SendErrorX( std::string strErrorCode)
- {
- DelErrMsg(strErrorCode);
- }
- bool FPDErrorWarning::OnErrorX(std::string strErr)
- {
- if (IsErrorExist(strErr))
- {
- m_ErrList.remove(strErr);
- SendErrorX( strErr);
- return true;
- }
- else
- {
- FERROR("have no error {$}", strErr.c_str());
- }
- 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)
- {
- return m_ErrList.isExist(code);
- }
- int FPDErrorWarning::GetExistErrorNum()
- {
- return m_ErrList.size();
- }
- void FPDErrorWarning::OnError(std::string strErrCode, std::string strErr)
- {
- if (IsErrorExist(strErrCode))
- {
- FINFO( "Same Error,Omit");
- return;
- }
- std::string strLog;
- DeviceError stErr;
- bool bXcu = false;
- if (!m_ErrRes.getDeviceError(strErrCode, stErr))
- {
- if (!m_XCUErrRes.getDeviceError(strErrCode, stErr))
- {
- FINFO( "Get Error Resouse Fault! ErrorCode:{$}", strErrCode);
- stErr.setCode(strErrCode);
- stErr.setName(strErrCode);
- }
- else
- {
- bXcu = true;
- }
- }
- 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;
- bool bXcu = false;
- if (!m_WarnRes.getDeviceWarn(strWarnCode, stWar))
- {
- if (!m_XCUWarnRes.getDeviceWarn(strWarnCode, stWar))
- {
- FINFO( ("Get Warn Resouse Fault! WarnCode:{$}"), strWarnCode);
- stWar.setCode(strWarnCode);
- stWar.setName(strWarnCode);
- stWar.setDescription(strWarn);
- }
- bXcu = true;
- }
- std::string strDesc = stWar.getDescription() + strWarn;
- stWar.setDescription(strDesc);
- AddWarnMsg(stWar.getCode(), stWar.getDescription());
- }
|