FPDErrorWarningProcess.cpp 8.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337
  1. #include "stdafx.h"
  2. #include "FPDErrorWarningProcess.h"
  3. extern Log4CPP::Logger* //mLog::gLogger;
  4. #if 1
  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\\SiemensTrixell\\PNLErrorInfor.xml";
  10. m_ErrRes.setFileName(strPath.c_str());
  11. strPath = strAppPath + "OEMDrivers\\Detector\\SiemensTrixell\\PNLWarnInfor.xml";
  12. m_WarnRes.setFileName(strPath);
  13. strPath = strAppPath + "OEMDrivers\\Detector\\SiemensTrixell\\XCUErrorInfor.xml";
  14. m_XCUErrRes.setFileName(strPath.c_str());
  15. strPath = strAppPath + "OEMDrivers\\Detector\\SiemensTrixell\\XCUWarnInfor.xml";
  16. m_XCUWarnRes.setFileName(strPath);
  17. m_ErrList.clear();
  18. }
  19. FPDErrorWarning::~FPDErrorWarning()
  20. {
  21. }
  22. int FPDErrorWarning::GetMessageLevel(const std::string& code)
  23. {
  24. int level = 1;
  25. if (code == ERR_FPD_TEMPHIGH_NOT_ACQ
  26. || code == ERR_FPD_TEMPLOW_NOT_ACQ
  27. || code == ERR_FPD_DOSE_HIGH
  28. || code == ERR_FPD_MAX_NUMBER
  29. || code == ERR_FPD_DOSE_OBJ
  30. || code == ERR_FPD_RESTART
  31. || code == ERR_FPD_DOSE_LOW
  32. || code == ERR_FPD_NOFPD
  33. || code == ERR_FPD_ACQ_FAILED
  34. || code == WAR_FPD_TEMPERATURE_HIGH
  35. || code == WAR_FPD_TEMPERTURE_LOW
  36. || code == WAR_FPD_BATTERY_LOW
  37. || code == WAR_FPD_EXCEED_CALB_TEMPER
  38. || code == WAR_FPD_EXCEED_CALB_TEMPER_HIGH
  39. || code == WAR_FPD_EXCEED_CALB_TEMPER_LOW)
  40. {
  41. level = 99;
  42. }
  43. else if (code == ERR_FPD_WIFI_LOW
  44. || code == ERR_FPD_DISCONNECT
  45. || code == ERR_FPD_BATTERY_LOW
  46. || code == ERR_FPD_POWEROFF
  47. || code == ERR_FPD_FATAL_ERROR
  48. || code == WAR_FPD_LOAD_CORRECT_FILE
  49. || code == WAR_FPD_WIFI_LOW)
  50. {
  51. level = 98;
  52. }
  53. return level;
  54. }
  55. void FPDErrorWarning::AddErrMsg(std::string code, std::string info)
  56. {
  57. //mLog::Info("AddErrMsg {$}: {$}", code.c_str(), info.c_str());
  58. //LogicDevice::AddErrorMessage(code.c_str(), level, info.c_str());
  59. int level = GetMessageLevel(code);
  60. m_MSGUnit->AddErrorMessage(code.c_str(), level, info.c_str());
  61. }
  62. void FPDErrorWarning::DelErrMsg(std::string code)
  63. {
  64. int level = GetMessageLevel(code);
  65. //mLog::Info("DelErrMsg {$}", code.c_str());
  66. m_MSGUnit->DelErrorMessage(code.c_str(), level, "");
  67. }
  68. void FPDErrorWarning::AddWarnMsg(std::string code, std::string info)
  69. {
  70. //mLog::Info("AddWarnMsg {$}: {$}", code.c_str(), info.c_str());
  71. //LogicDevice::AddErrorMessage(code.c_str(), level, info.c_str());
  72. int level = GetMessageLevel(code);
  73. m_MSGUnit->AddWarnMessage(code.c_str(), level, info.c_str());
  74. }
  75. void FPDErrorWarning::DelWarnMsg(std::string code)
  76. {
  77. int level = GetMessageLevel(code);
  78. //mLog::Info("DelWarnMsg {$}", code.c_str());
  79. m_MSGUnit->DelWarnMessage(code.c_str(), level, "");
  80. }
  81. void FPDErrorWarning::SendError( DeviceError obErr)
  82. {
  83. AddErrMsg(obErr.getCode(), obErr.getDescription());
  84. }
  85. void FPDErrorWarning::SendAllError()
  86. {
  87. //mLog::Info("Send All Error");
  88. for (int i = 0; i < m_ErrList.size(); i++)
  89. {
  90. DeviceError stError;
  91. stError = m_ErrList.item(i);
  92. SendError( stError);
  93. }
  94. }
  95. void FPDErrorWarning::SendAllWarn()
  96. {
  97. //mLog::Info("Send All Warn");
  98. for (int i = 0; i < m_WarnList.size(); i++)
  99. {
  100. auto stWar = m_WarnList.item(i);
  101. AddWarnMsg(stWar.getCode(), stWar.getDescription());
  102. }
  103. }
  104. void FPDErrorWarning::SyncErrorList()
  105. {
  106. SendAllError();
  107. SendAllWarn();
  108. }
  109. void FPDErrorWarning::ClearAllError()
  110. {
  111. //先清除原有探测器的ERROR
  112. //mLog::Info("Clear All Error");
  113. if (0 == m_ErrList.size())//fixbug 9834 切换工作位时清除错误,会将发生器的错误无故清除
  114. {
  115. //mLog::Info("There is no error in list. Omit Clear All Error");
  116. return;
  117. }
  118. //if (m_bConnect2XCU)
  119. //{
  120. // ResDataObject request, response;
  121. // request.add("P0", CAL_START);
  122. // m_pXCUClient->Action("SetFPDCalibrationStatus", request, response, g_nXCUtimeout);
  123. //}
  124. //SendCmd(BUSID_HWMgr, BUSCMD_HW_ERROR, m_nDeviceIndex, Parameter_A, CMDID_RES, String_C, STR_ZERODATA);
  125. for (int i = 0; i < m_ErrList.size(); i++)
  126. {
  127. DeviceError stError;
  128. stError = m_ErrList.item(i);
  129. //if (ERR_FPD_IMAGE_PENDING != stError.getCode())//if (ERR_FPD_MAX_NUMBER == stError.getCode() || ERR_FPD_SN_NOT_LIST == stError.getCode())
  130. {
  131. OnErrorX(stError.getCode());
  132. }
  133. }
  134. }
  135. void FPDErrorWarning::SendErrorX( std::string strErrorCode)
  136. {
  137. //SendCmd(BUSID_HWMgr, BUSCMD_HW_ERROR, nIndex, Parameter_A, CMDID_ERX, String_C, strErrorCode);
  138. DelErrMsg(strErrorCode);
  139. }
  140. bool FPDErrorWarning::OnErrorX(std::string strErr)
  141. {
  142. if (m_ErrListTemp.isExist(strErr)) //清除一下初始化时的临时ErrorList
  143. {
  144. //mLog::Info("Remove temp error");
  145. m_ErrListTemp.remove(strErr);
  146. }
  147. if (m_ErrList.isExist(strErr))
  148. {
  149. m_ErrList.remove(strErr);
  150. SendErrorX( strErr);
  151. return true;
  152. }
  153. return false;
  154. }
  155. void FPDErrorWarning::SendWarn( DeviceError stWar)
  156. {
  157. //ResDataObject obxmllist;
  158. //obxmllist.add("Code", stWar.getCode().c_str());
  159. //obxmllist.add("Name", stWar.getDescription().c_str());
  160. //obxmllist.add("Description", stWar.getDescription().c_str());
  161. //obxmllist.add("Solution", stWar.getSolution().c_str());
  162. //obxmllist.add("NotifyType", stWar.getNotifyType().c_str());
  163. //obxmllist.add("Interlock", stWar.getInterlock().c_str());
  164. //obxmllist.add("BackCommand", stWar.getBackCommand().c_str());
  165. //obxmllist.add("SerialNumber", m_stDeviceConfig.strPanelSerial.c_str());
  166. //std::string strWar = obxmllist.encode();
  167. //SendCmd(BUSID_HWMgr, BUSCMD_HW_ERROR, nIndex, Parameter_A, CMDID_WAR, String_C, wcsWar);
  168. //if (m_bConnect2XCU)
  169. //{
  170. // ResDataObject request, response;
  171. // request.add("P0", stWar.getCode().c_str());
  172. // m_pXCUClient->Action("SendFPDWarn", request, response, g_nXCUtimeout);
  173. //}
  174. }
  175. bool FPDErrorWarning::IsErrorExist(std::string code)
  176. {
  177. //if (m_ErrList.isExist(code))
  178. //{
  179. // int nSize = m_ErrList.size();
  180. // //mLog::Warn("IsErrorExist have {$} num: {$}", code.c_str(), nSize);
  181. // for (int i = 0; i < nSize; i++)
  182. // {
  183. // DeviceError stError;
  184. // stError = m_ErrList.item(i);
  185. //
  186. // {
  187. // //mLog::Warn("{$}",stError.getCode().c_str());
  188. // }
  189. // }
  190. //}
  191. return m_ErrList.isExist(code);
  192. }
  193. int FPDErrorWarning::GetExistErrorNum()
  194. {
  195. return m_ErrList.size();
  196. }
  197. void FPDErrorWarning::OnError(std::string strErrCode, std::string strErr)
  198. {
  199. if (IsErrorExist(strErrCode))
  200. {
  201. //mLog::Info("Same Error,Omit");
  202. return;
  203. }
  204. DeviceError stErr;
  205. if (!m_ErrRes.getDeviceError(strErrCode, stErr))
  206. {
  207. if (!m_XCUErrRes.getDeviceError(strErrCode, stErr))
  208. {
  209. //mLog::Info("Get Error Resouse Fault! ErrorCode:{$}", strErrCode);
  210. stErr.setCode(strErrCode);
  211. stErr.setName(strErrCode);
  212. }
  213. }
  214. m_ErrList.add(stErr);
  215. std::string strDesc = stErr.getDescription() + strErr;
  216. stErr.setDescription(strDesc);
  217. AddErrMsg(stErr.getCode(), stErr.getDescription());
  218. }
  219. void FPDErrorWarning::OnWarn(std::string strWarnCode, std::string strWarn)
  220. {
  221. std::string strLog;
  222. DeviceError stWar;
  223. if (m_WarnList.isExist(strWarnCode))
  224. {
  225. //mLog::Info("Same warn {$}", strWarnCode.c_str());
  226. return;
  227. }
  228. if (!m_WarnRes.getDeviceWarn(strWarnCode, stWar))
  229. {
  230. if (!m_XCUWarnRes.getDeviceWarn(strWarnCode, stWar))
  231. {
  232. //mLog::Info(("Get Warn Resouse Fault! WarnCode:{$}"), strWarnCode);
  233. stWar.setCode(strWarnCode);
  234. stWar.setName(strWarnCode);
  235. stWar.setDescription(strWarn);
  236. }
  237. //mLog::Info("XCU need this Warn");
  238. }
  239. //endif
  240. //mLog::Info(("Send Warn Code:{$}"), strWarnCode);
  241. std::string strDesc = stWar.getDescription() + strWarn;
  242. stWar.setDescription(strDesc);
  243. m_WarnList.add(stWar);
  244. AddWarnMsg(stWar.getCode(), stWar.getDescription());
  245. }
  246. void FPDErrorWarning::OnWarnX(std::string strWarnCode)
  247. {
  248. if (strWarnCode == "") //清除一下初始化时的临时ErrorList
  249. {
  250. //mLog::Info("OnWarnX have no code");
  251. return;
  252. }
  253. if (m_WarnList.isExist(strWarnCode))
  254. {
  255. m_WarnList.remove(strWarnCode);
  256. DelWarnMsg(strWarnCode);
  257. }
  258. }
  259. bool FPDErrorWarning::IsXCUneedError(std::string strErrCode, std::string & strBackCommand)
  260. {
  261. DeviceError stErr;
  262. if (m_XCUErrRes.getDeviceError(strErrCode, stErr))
  263. {
  264. strBackCommand = stErr.getBackCommand();
  265. //mLog::Info("XCU need this Error {$}, BackCommand {$}", strErrCode.c_str(), strBackCommand.c_str());
  266. return true;
  267. }
  268. return false;
  269. }
  270. bool FPDErrorWarning::IsXCUneedWarn(std::string strWarnCode, std::string & strBackCommand)
  271. {
  272. DeviceError stWar;
  273. if (m_XCUWarnRes.getDeviceWarn(strWarnCode, stWar))
  274. {
  275. strBackCommand = stWar.getBackCommand();
  276. //mLog::Info("XCU need this Warn {$}, BackCommand {$}", strWarnCode.c_str(), strBackCommand.c_str());
  277. return true;
  278. }
  279. return false;
  280. }
  281. #endif