FPDErrorWarningProcess.cpp 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123
  1. #include "stdafx.h"
  2. #include "FPDErrorWarningProcess.h"
  3. extern Log4CPP::Logger* 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\\CareRay\\CareRayRFDetector\\ErrorInfo.xml";
  9. m_ErrRes.setFileName(strPath);
  10. strPath = strAppPath + "\\OEMDrivers\\Detector\\CareRay\\CareRayRFDetector\\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. 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. 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. 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. FINFO("DelWarnMsg {$}", code.c_str());
  38. m_MSGUnit->DelWarnMessage(code.c_str(), level, "");
  39. }
  40. void FPDErrorWarning::ClearAllError()
  41. {
  42. FINFO("Clear All Error");
  43. if (0 == m_ErrList.size())//fixbug 9834 切换工作位时清除错误,会将发生器的错误无故清除
  44. {
  45. FINFO( "There is no error in list. Omit Clear All Error");
  46. return;
  47. }
  48. for (int i = 0; i < m_ErrList.size(); i++)
  49. {
  50. DeviceError stError;
  51. stError = m_ErrList.item(i);
  52. if (ERR_FPD_MAX_NUMBER == stError.getCode() || ERR_FPD_SN_NOT_LIST == stError.getCode())
  53. {
  54. OnError(stError.getCode());
  55. }
  56. }
  57. }
  58. void FPDErrorWarning::OnError(std::string strErrCode, std::string strErr)
  59. {
  60. if (IsErrorExist(strErrCode))
  61. {
  62. FINFO( "Same Error,Omit");
  63. return;
  64. }
  65. std::string strLog;
  66. DeviceError stErr;
  67. if (!m_ErrRes.getDeviceError(strErrCode, stErr))
  68. {
  69. FINFO("Get Error Resource Fail! ErrorCode:{$}", strErrCode);
  70. stErr.setCode(strErrCode);
  71. stErr.setName(strErrCode);
  72. }
  73. m_ErrList.add(stErr);
  74. std::string strDesc = stErr.getDescription() + strErr;
  75. stErr.setDescription(strDesc);
  76. AddErrMsg(stErr.getCode(), stErr.getDescription());
  77. }
  78. void FPDErrorWarning::OnWarn(std::string strWarnCode, std::string strWarn)
  79. {
  80. std::string strLog;
  81. DeviceError stWar;
  82. if (!m_WarnRes.getDeviceWarn(strWarnCode, stWar))
  83. {
  84. FINFO(("Get Warn Resouse Fault! WarnCode:{$}"), strWarnCode);
  85. stWar.setCode(strWarnCode);
  86. stWar.setName(strWarnCode);
  87. stWar.setDescription(strWarn);
  88. }
  89. std::string strDesc = stWar.getDescription() + strWarn;
  90. stWar.setDescription(strDesc);
  91. AddWarnMsg(stWar.getCode(), stWar.getDescription());
  92. }
  93. bool FPDErrorWarning::IsErrorExist(std::string code)
  94. {
  95. return m_ErrList.isExist(code);
  96. }
  97. int FPDErrorWarning::GetExistErrorNum()
  98. {
  99. return m_ErrList.size();
  100. }