123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337 |
- #include "stdafx.h"
- #include "FPDErrorWarningProcess.h"
- extern Log4CPP::Logger* //mLog::gLogger;
- #if 1
- 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\\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)
- {
- //mLog::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);
- //mLog::Info("DelErrMsg {$}", code.c_str());
- m_MSGUnit->DelErrorMessage(code.c_str(), level, "");
- }
- void FPDErrorWarning::AddWarnMsg(std::string code, std::string info)
- {
- //mLog::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);
- //mLog::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()
- {
- //mLog::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()
- {
- //mLog::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
- //mLog::Info("Clear All Error");
- if (0 == m_ErrList.size())//fixbug 9834 切换工作位时清除错误,会将发生器的错误无故清除
- {
- //mLog::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
- {
- //mLog::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();
- // //mLog::Warn("IsErrorExist have {$} num: {$}", code.c_str(), nSize);
- // for (int i = 0; i < nSize; i++)
- // {
- // DeviceError stError;
- // stError = m_ErrList.item(i);
- //
- // {
- // //mLog::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))
- {
- //mLog::Info("Same Error,Omit");
- return;
- }
- DeviceError stErr;
- if (!m_ErrRes.getDeviceError(strErrCode, stErr))
- {
- if (!m_XCUErrRes.getDeviceError(strErrCode, stErr))
- {
- //mLog::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))
- {
- //mLog::Info("Same warn {$}", strWarnCode.c_str());
- return;
- }
- if (!m_WarnRes.getDeviceWarn(strWarnCode, stWar))
- {
- if (!m_XCUWarnRes.getDeviceWarn(strWarnCode, stWar))
- {
- //mLog::Info(("Get Warn Resouse Fault! WarnCode:{$}"), strWarnCode);
- stWar.setCode(strWarnCode);
- stWar.setName(strWarnCode);
- stWar.setDescription(strWarn);
- }
- //mLog::Info("XCU need this Warn");
- }
- //endif
- //mLog::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
- {
- //mLog::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();
- //mLog::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();
- //mLog::Info("XCU need this Warn {$}, BackCommand {$}", strWarnCode.c_str(), strBackCommand.c_str());
- return true;
- }
- return false;
- }
- #endif
|