FPDErrorWarningProcess.cpp 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119
  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\\CareRayDRDetector\\ErrorInfo.xml";
  9. m_ErrRes.setFileName(strPath.c_str());
  10. strPath = strAppPath + "\\OEMDrivers\\Detector\\CareRay\\CareRayDRDetector\\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. //ÏÈÇå³ýÔ­ÓÐ̽²âÆ÷µÄERROR
  43. FINFO("Clear All Error");
  44. if (0 == m_ErrList.size())
  45. {
  46. 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. }
  56. }
  57. }
  58. bool FPDErrorWarning::IsErrorExist(std::string code)
  59. {
  60. return m_ErrList.isExist(code);
  61. }
  62. int FPDErrorWarning::GetExistErrorNum()
  63. {
  64. return m_ErrList.size();
  65. }
  66. void FPDErrorWarning::OnError(std::string strErrCode, std::string strErr)
  67. {
  68. if (IsErrorExist(strErrCode))
  69. {
  70. FINFO("Same Error,Omit");
  71. return;
  72. }
  73. DeviceError stErr;
  74. if (!m_ErrRes.getDeviceError(strErrCode, stErr))
  75. {
  76. FERROR("Get Error Code:{$}", strErrCode);
  77. }
  78. m_ErrList.add(stErr);
  79. std::string strDesc = stErr.getDescription() + strErr;
  80. stErr.setDescription(strDesc);
  81. AddErrMsg(stErr.getCode(), stErr.getDescription());
  82. }
  83. void FPDErrorWarning::OnWarn(std::string strWarnCode, std::string strWarn)
  84. {
  85. DeviceError stWar;
  86. if (!m_WarnRes.getDeviceWarn(strWarnCode, stWar))
  87. {
  88. FINFO("Get Warn Code:{$}", strWarnCode);
  89. }
  90. std::string strDesc = stWar.getDescription() + strWarn;
  91. stWar.setDescription(strDesc);
  92. AddWarnMsg(stWar.getCode(), stWar.getDescription());
  93. }