FPDErrorWarningProcess.cpp 5.5 KB

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