FPDErrorWarningProcess.cpp 5.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221
  1. #include "FPDErrorWarningProcess.h"
  2. #include "LogLocalHelper.h"
  3. #include "Log4CPP.h"
  4. //extern Log4CPP::Logger* mLog::gLogger;
  5. FPDErrorWarning::FPDErrorWarning(std::shared_ptr <CCOS::Dev::IOEventCenter> EventCenter, std::string DevInstance, std::string strAppPath)
  6. {
  7. m_MSGUnit.reset(new nDetail::MSGUnit(EventCenter, DevInstance));
  8. m_EventCenter = EventCenter;
  9. std::string strPath = strAppPath + "\\OEMDrivers\\Detector\\Demo\\ErrorInfo.xml";
  10. m_ErrRes.setFileName(strPath.c_str());
  11. strPath = strAppPath + "\\OEMDrivers\\Detector\\Demo\\WarnInfo.xml";
  12. m_WarnRes.setFileName(strPath);
  13. }
  14. FPDErrorWarning::~FPDErrorWarning()
  15. {
  16. }
  17. void FPDErrorWarning::AddErrMsg(std::string code, std::string info)
  18. {
  19. FINFO( "AddErrMsg {$}: {$}", code.c_str(), info.c_str());
  20. int level = 1;
  21. m_MSGUnit->AddErrorMessage(code.c_str(), level, info.c_str());
  22. }
  23. void FPDErrorWarning::DelErrMsg(std::string code)
  24. {
  25. int level = 1;
  26. FINFO( "DelErrMsg {$}", code.c_str());
  27. m_MSGUnit->DelErrorMessage(code.c_str(), level, "");
  28. }
  29. void FPDErrorWarning::AddWarnMsg(std::string code, std::string info)
  30. {
  31. FINFO( "AddWarnMsg {$}: {$}", code.c_str(), info.c_str());
  32. int level = 1;
  33. m_MSGUnit->AddWarnMessage(code.c_str(), level, info.c_str());
  34. }
  35. void FPDErrorWarning::DelWarnMsg(std::string code)
  36. {
  37. int level = 1;
  38. FINFO( "DelWarnMsg {$}", code.c_str());
  39. m_MSGUnit->DelWarnMessage(code.c_str(), level, "");
  40. }
  41. void FPDErrorWarning::SendError( DeviceError obErr)
  42. {
  43. //ResDataObject obxmllist;
  44. //obxmllist.add("Code", obErr.getCode().c_str());
  45. //obxmllist.add("Name", obErr.getDescription().c_str());
  46. //obxmllist.add("Description", obErr.getDescription().c_str());
  47. //obxmllist.add("Solution", obErr.getSolution().c_str());
  48. //obxmllist.add("NotifyType", obErr.getNotifyType().c_str());
  49. //obxmllist.add("Interlock", obErr.getInterlock().c_str());
  50. //obxmllist.add("BackCommand", obErr.getBackCommand().c_str());
  51. //obxmllist.add("SerialNumber", m_stDeviceConfig.strPanelSerial.c_str());
  52. //std::string strErr = obxmllist.encode();
  53. //SendCmd(BUSID_HWMgr, BUSCMD_HW_ERROR, nIndex, Parameter_A, CMDID_ERR, String_C, wcsErr);
  54. //if (m_bConnect2XCU)
  55. //{
  56. // ResDataObject request, response;
  57. // request.add("P0", obErr.getCode().c_str());
  58. // m_pXCUClient->Action("SendFPDError", request, response, g_nXCUtimeout);
  59. //}
  60. }
  61. void FPDErrorWarning::SendAllError()
  62. {
  63. FINFO( "Send All Error");
  64. for (int i = 0; i < m_ErrList.size(); i++)
  65. {
  66. DeviceError stError;
  67. stError = m_ErrList.item(i);
  68. SendError( stError);
  69. }
  70. }
  71. void FPDErrorWarning::ClearAllError()
  72. {
  73. //先清除原有探测器的ERROR
  74. FINFO( "Clear All Error");
  75. if (0 == m_ErrList.size())//fixbug 9834 切换工作位时清除错误,会将发生器的错误无故清除
  76. {
  77. FINFO( "There is no error in list. Omit Clear All Error");
  78. return;
  79. }
  80. for (int i = 0; i < m_ErrList.size(); i++)
  81. {
  82. DeviceError stError;
  83. stError = m_ErrList.item(i);
  84. if (ERR_FPD_MAX_NUMBER == stError.getCode() || ERR_FPD_SN_NOT_LIST == stError.getCode())
  85. {
  86. OnErrorX(stError.getCode());
  87. }
  88. }
  89. }
  90. void FPDErrorWarning::SendErrorX( std::string strErrorCode)
  91. {
  92. DelErrMsg(strErrorCode);
  93. }
  94. bool FPDErrorWarning::OnErrorX(std::string strErr)
  95. {
  96. if (IsErrorExist(strErr))
  97. {
  98. m_ErrList.remove(strErr);
  99. SendErrorX( strErr);
  100. return true;
  101. }
  102. else
  103. {
  104. FERROR("have no error {$}", strErr.c_str());
  105. }
  106. return false;
  107. }
  108. void FPDErrorWarning::SendWarn( DeviceError stWar)
  109. {
  110. //ResDataObject obxmllist;
  111. //obxmllist.add("Code", stWar.getCode().c_str());
  112. //obxmllist.add("Name", stWar.getDescription().c_str());
  113. //obxmllist.add("Description", stWar.getDescription().c_str());
  114. //obxmllist.add("Solution", stWar.getSolution().c_str());
  115. //obxmllist.add("NotifyType", stWar.getNotifyType().c_str());
  116. //obxmllist.add("Interlock", stWar.getInterlock().c_str());
  117. //obxmllist.add("BackCommand", stWar.getBackCommand().c_str());
  118. //obxmllist.add("SerialNumber", m_stDeviceConfig.strPanelSerial.c_str());
  119. //std::string strWar = obxmllist.encode();
  120. //SendCmd(BUSID_HWMgr, BUSCMD_HW_ERROR, nIndex, Parameter_A, CMDID_WAR, String_C, wcsWar);
  121. //if (m_bConnect2XCU)
  122. //{
  123. // ResDataObject request, response;
  124. // request.add("P0", stWar.getCode().c_str());
  125. // m_pXCUClient->Action("SendFPDWarn", request, response, g_nXCUtimeout);
  126. //}
  127. }
  128. bool FPDErrorWarning::IsErrorExist(std::string code)
  129. {
  130. return m_ErrList.isExist(code);
  131. }
  132. int FPDErrorWarning::GetExistErrorNum()
  133. {
  134. return m_ErrList.size();
  135. }
  136. void FPDErrorWarning::OnError(std::string strErrCode, std::string strErr)
  137. {
  138. if (IsErrorExist(strErrCode))
  139. {
  140. FINFO( "Same Error,Omit");
  141. return;
  142. }
  143. std::string strLog;
  144. DeviceError stErr;
  145. bool bXcu = false;
  146. if (!m_ErrRes.getDeviceError(strErrCode, stErr))
  147. {
  148. if (!m_XCUErrRes.getDeviceError(strErrCode, stErr))
  149. {
  150. FINFO( "Get Error Resouse Fault! ErrorCode:{$}", strErrCode);
  151. stErr.setCode(strErrCode);
  152. stErr.setName(strErrCode);
  153. }
  154. else
  155. {
  156. bXcu = true;
  157. }
  158. }
  159. m_ErrList.add(stErr);
  160. std::string strDesc = stErr.getDescription() + strErr;
  161. stErr.setDescription(strDesc);
  162. AddErrMsg(stErr.getCode(), stErr.getDescription());
  163. }
  164. void FPDErrorWarning::OnWarn(std::string strWarnCode, std::string strWarn)
  165. {
  166. std::string strLog;
  167. DeviceError stWar;
  168. bool bXcu = false;
  169. if (!m_WarnRes.getDeviceWarn(strWarnCode, stWar))
  170. {
  171. if (!m_XCUWarnRes.getDeviceWarn(strWarnCode, stWar))
  172. {
  173. FINFO( ("Get Warn Resouse Fault! WarnCode:{$}"), strWarnCode);
  174. stWar.setCode(strWarnCode);
  175. stWar.setName(strWarnCode);
  176. stWar.setDescription(strWarn);
  177. }
  178. bXcu = true;
  179. }
  180. std::string strDesc = stWar.getDescription() + strWarn;
  181. stWar.setDescription(strDesc);
  182. AddWarnMsg(stWar.getCode(), stWar.getDescription());
  183. }