FPDErrorWarningProcess.cpp 5.7 KB

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