FPDErrorWarningProcess.cpp 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130
  1. #include "stdafx.h"
  2. #include "FPDErrorWarningProcess.h"
  3. extern Log4CPP::Logger* //mLog::gLogger;
  4. FPDErrorWarning::FPDErrorWarning(std::shared_ptr <CCOS::Dev::IOEventCenter> EventCenter, std::string DevInstance, std::string strAppPath)
  5. {
  6. m_MSGUnit.reset(new nDetail::MSGUnit(EventCenter, DevInstance));
  7. m_EventCenter = EventCenter;
  8. std::string strPath = strAppPath + "\\OEMDrivers\\Detector\\PZMedical\\PZMedicalDMDetector\\ErrorInfo.xml";
  9. m_ErrRes.setFileName(strPath.c_str());
  10. strPath = strAppPath + "\\OEMDrivers\\Detector\\PZMedical\\PZMedicalDMDetector\\WarnInfo.xml";
  11. m_WarnRes.setFileName(strPath);
  12. }
  13. FPDErrorWarning::~FPDErrorWarning()
  14. {
  15. }
  16. void FPDErrorWarning::AddErrMsg(std::string code, std::string info)
  17. {
  18. //mLog::FINFO("AddErrMsg {$}: {$}", code.c_str(), info.c_str());
  19. int level = 1;
  20. m_MSGUnit->AddErrorMessage(code.c_str(), level, info.c_str());
  21. }
  22. void FPDErrorWarning::DelErrMsg(std::string code)
  23. {
  24. int level = 1;
  25. //mLog::FINFO("DelErrMsg {$}", code.c_str());
  26. m_MSGUnit->DelErrorMessage(code.c_str(), level, "");
  27. }
  28. void FPDErrorWarning::AddWarnMsg(std::string code, std::string info)
  29. {
  30. //mLog::FINFO("AddWarnMsg {$}: {$}", code.c_str(), info.c_str());
  31. int level = 1;
  32. m_MSGUnit->AddWarnMessage(code.c_str(), level, info.c_str());
  33. }
  34. void FPDErrorWarning::DelWarnMsg(std::string code)
  35. {
  36. int level = 1;
  37. //mLog::FINFO("DelWarnMsg {$}", code.c_str());
  38. m_MSGUnit->DelWarnMessage(code.c_str(), level, "");
  39. }
  40. void FPDErrorWarning::ClearAllError()
  41. {
  42. //先清除原有探测器的ERROR
  43. //mLog::FINFO("Clear All Error");
  44. if (0 == m_ErrList.size())//fixbug 9834 切换工作位时清除错误,会将发生器的错误无故清除
  45. {
  46. //mLog::FINFO("There is no error in list. Omit Clear All Error");
  47. return;
  48. }
  49. for (int i = 0; i < m_ErrList.size(); i++)
  50. {
  51. DeviceError stError;
  52. stError = m_ErrList.item(i);
  53. if (ERR_FPD_MAX_NUMBER == stError.getCode() || ERR_FPD_SN_NOT_LIST == stError.getCode())
  54. {
  55. OnError(stError.getCode());
  56. }
  57. }
  58. }
  59. bool FPDErrorWarning::IsErrorExist(std::string code)
  60. {
  61. return m_ErrList.isExist(code);
  62. }
  63. int FPDErrorWarning::GetExistErrorNum()
  64. {
  65. return m_ErrList.size();
  66. }
  67. void FPDErrorWarning::OnError(std::string strErrCode, std::string strErr)
  68. {
  69. if (IsErrorExist(strErrCode))
  70. {
  71. //mLog::FINFO("Same Error,Omit");
  72. return;
  73. }
  74. std::string strLog;
  75. DeviceError stErr;
  76. bool bXcu = false;
  77. if (!m_ErrRes.getDeviceError(strErrCode, stErr))
  78. {
  79. //mLog::FINFO("Get Error Resouse Fault! ErrorCode:{$}", strErrCode);
  80. stErr.setCode(strErrCode);
  81. stErr.setName(strErrCode);
  82. }
  83. m_ErrList.add(stErr);
  84. std::string strDesc = stErr.getDescription() + strErr;
  85. stErr.setDescription(strDesc);
  86. AddErrMsg(stErr.getCode(), stErr.getDescription());
  87. }
  88. void FPDErrorWarning::OnWarn(std::string strWarnCode, std::string strWarn)
  89. {
  90. std::string strLog;
  91. DeviceError stWar;
  92. bool bXcu = false;
  93. if (!m_WarnRes.getDeviceWarn(strWarnCode, stWar))
  94. {
  95. //mLog::FINFO(("Get Warn Resouse Fault! WarnCode:{$}"), strWarnCode);
  96. stWar.setCode(strWarnCode);
  97. stWar.setName(strWarnCode);
  98. stWar.setDescription(strWarn);
  99. }
  100. std::string strDesc = stWar.getDescription() + strWarn;
  101. stWar.setDescription(strDesc);
  102. AddWarnMsg(stWar.getCode(), stWar.getDescription());
  103. }