DIOS.Dev.FPD2OtherDevice.cpp 7.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338
  1. // CCOS.Dev.FPD.DEMO.cpp : 定义 DLL 应用程序的导出函数。
  2. //
  3. #include "stdafx.h"
  4. #include <stdio.h>
  5. #include "CCOS.Dev.FPD2OtherDevice.hpp"
  6. #include "Logger.temp.h"
  7. using namespace CCOS::Dev;
  8. using namespace CCOS::Dev::Detail::Detector;
  9. namespace nsFPD = CCOS::Dev::Detail::Detector;
  10. // FPDCommunicateWithOtherDevice.cpp : 定义 DLL 应用程序的导出函数。
  11. //
  12. #include "stdafx.h"
  13. #include "common_api.h"
  14. // 这是已导出类的构造函数。
  15. // 有关类定义的信息,请参阅 FPDCommunicateWithOtherDevice.h
  16. CFPDCommunicateWithOtherDevice::CFPDCommunicateWithOtherDevice(void)
  17. {
  18. m_strPanelSN = "";
  19. m_nCAL = 0;
  20. m_nCAM = 0;
  21. m_nHWcrop = 0;
  22. m_nPanelRotate = 0;
  23. m_nCollimatorAlign = 0;
  24. m_fCollimatorWidth = 0.0f;
  25. m_fCollimatorLen = 0.0f;
  26. m_fAPRms = 0.0f;
  27. m_nWorkStation = 0;
  28. m_fLTEthreshold = 0.0;
  29. m_bLTEenable = new BaseJsonDataObject<bool>;
  30. m_bLTEenable->SetKey("LTEenable");
  31. *m_bLTEenable = false;
  32. m_bXrayStatus = new BaseJsonDataObject<bool>;
  33. m_bXrayStatus->SetKey("XrayStatus"); //0:No xray;1:Xray
  34. *m_bXrayStatus = false;
  35. //CreateLogger("FPD2Other");
  36. return;
  37. }
  38. CFPDCommunicateWithOtherDevice::~CFPDCommunicateWithOtherDevice(void)
  39. {
  40. //ReleaseLogger();
  41. return;
  42. }
  43. RET_STATUS CFPDCommunicateWithOtherDevice::GetPanelSN(string& strValue)
  44. {
  45. strValue = m_strPanelSN;
  46. return RET_STATUS::RET_SUCCEED;
  47. }
  48. RET_STATUS CFPDCommunicateWithOtherDevice::GetCAL(unsigned int& nValue)
  49. {
  50. nValue = m_nCAL;
  51. return RET_STATUS::RET_SUCCEED;
  52. }
  53. RET_STATUS CFPDCommunicateWithOtherDevice::GetCAM(unsigned int& nValue)
  54. {
  55. nValue = m_nCAM;
  56. return RET_STATUS::RET_SUCCEED;
  57. }
  58. RET_STATUS CFPDCommunicateWithOtherDevice::OnHWcrop(unsigned int nValue)
  59. {
  60. m_nHWcrop = nValue;
  61. return RET_STATUS::RET_SUCCEED;
  62. }
  63. RET_STATUS CFPDCommunicateWithOtherDevice::OnPANEL_ROTATE(unsigned int nValue)
  64. {
  65. m_nPanelRotate = nValue;
  66. return RET_STATUS::RET_SUCCEED;
  67. }
  68. RET_STATUS CFPDCommunicateWithOtherDevice::OnCollimatorAlign(unsigned int nValue)
  69. {
  70. m_nCollimatorAlign = nValue;
  71. return RET_STATUS::RET_SUCCEED;
  72. }
  73. RET_STATUS CFPDCommunicateWithOtherDevice::OnCollimatorWidth(float fValue)
  74. {
  75. m_fCollimatorWidth = fValue;
  76. return RET_STATUS::RET_SUCCEED;
  77. }
  78. RET_STATUS CFPDCommunicateWithOtherDevice::OnCollimatorLen(float fValue)
  79. {
  80. m_fCollimatorLen = fValue;
  81. return RET_STATUS::RET_SUCCEED;
  82. }
  83. RET_STATUS CFPDCommunicateWithOtherDevice::OnAPRms(float fValue)
  84. {
  85. m_fAPRms = fValue;
  86. PRINTA_INFO("Set APR ms %f, LTEthreshold %f", fValue,m_fLTEthreshold);
  87. //printf("CFPDCommunicateWithOtherDevice::OnAPRms: ms %f\n", fValue);
  88. if (m_fLTEthreshold > 0.1f)
  89. {
  90. bool bLTEenable = *m_bLTEenable;
  91. if (fValue > m_fLTEthreshold && !bLTEenable)
  92. {
  93. *m_bLTEenable = true;
  94. m_EventCenter->OnNotify((int)ATTRACTION_SET, m_bLTEenable->GetKey(), m_bLTEenable->GetVal());
  95. PRINTA_INFO("send notify LTE enable");
  96. printf("CFPDCommunicateWithOtherDevice::m_fLTEthreshold: %f ms, send notify LTE enable\n", m_fLTEthreshold);
  97. }
  98. if (fValue <= m_fLTEthreshold && bLTEenable)
  99. {
  100. *m_bLTEenable = false;
  101. m_EventCenter->OnNotify((int)ATTRACTION_SET, m_bLTEenable->GetKey(), m_bLTEenable->GetVal());
  102. printf("CFPDCommunicateWithOtherDevice::m_fLTEthreshold: %f ms, send notify LTE disable\n", m_fLTEthreshold);
  103. PRINTA_INFO("send notify LTE disable");
  104. }
  105. }
  106. return RET_STATUS::RET_SUCCEED;
  107. }
  108. RET_STATUS CFPDCommunicateWithOtherDevice::OnWorkStation(unsigned int nValue)
  109. {
  110. m_nWorkStation = nValue;
  111. return RET_STATUS::RET_SUCCEED;
  112. }
  113. RET_STATUS CFPDCommunicateWithOtherDevice::OnXrayStatus(bool bXRayStatus)
  114. {
  115. PRINTA_INFO("Get XrayStatus: %d", bXRayStatus);
  116. if (bXRayStatus)
  117. {
  118. *m_bXrayStatus = true;
  119. }
  120. else
  121. {
  122. *m_bXrayStatus = false;
  123. }
  124. m_EventCenter->OnNotify((int)ATTRACTION_SET, m_bXrayStatus->GetKey(), m_bXrayStatus->GetVal());
  125. return RET_STATUS::RET_SUCCEED;
  126. }
  127. void CFPDCommunicateWithOtherDevice::SetEventCenter(std::shared_ptr <CCOS::Dev::IOEventCenter> EventCenter)
  128. {
  129. m_EventCenter = EventCenter;
  130. }
  131. RET_STATUS CFPDCommunicateWithOtherDevice::JSSetPanelSN(std::string in, std::string& out)
  132. {
  133. ResDataObject json;
  134. json.decode(in.c_str());
  135. string strValue = json[0];
  136. m_strPanelSN = strValue;
  137. return RET_STATUS::RET_SUCCEED;
  138. }
  139. RET_STATUS CFPDCommunicateWithOtherDevice::JSSetLTEthreshold(std::string in, std::string& out)
  140. {
  141. PRINTA_INFO("SetLTEthreshold %s", in.c_str());
  142. ResDataObject json;
  143. json.decode(in.c_str());
  144. float fValue = json[0];
  145. m_fLTEthreshold = fValue;
  146. return RET_STATUS::RET_SUCCEED;
  147. }
  148. RET_STATUS CFPDCommunicateWithOtherDevice::JSSetFPDCalibrationStatus(std::string in, std::string& out)
  149. {
  150. ResDataObject json;
  151. json.decode(in.c_str());
  152. unsigned int nValue = json[0];
  153. m_nCAL = nValue;
  154. return RET_STATUS::RET_SUCCEED;
  155. }
  156. RET_STATUS CFPDCommunicateWithOtherDevice::JSSetCalibrationHSWStatus(std::string in, std::string& out)
  157. {
  158. ResDataObject json;
  159. json.decode(in.c_str());
  160. unsigned int nValue = json[0];
  161. m_nCAM = nValue;
  162. return RET_STATUS::RET_SUCCEED;
  163. }
  164. RET_STATUS CFPDCommunicateWithOtherDevice::JSSendFPDError(std::string in, std::string& out)
  165. {
  166. PRINTA_INFO("FPDError: %s", in.c_str());
  167. return RET_STATUS::RET_SUCCEED;
  168. }
  169. RET_STATUS CFPDCommunicateWithOtherDevice::JSClearFPDError(std::string in, std::string& out)
  170. {
  171. PRINTA_INFO("clearFPDError: %s", in.c_str());
  172. return RET_STATUS::RET_SUCCEED;
  173. }
  174. RET_STATUS CFPDCommunicateWithOtherDevice::JSSendFPDWarn(std::string in, std::string& out)
  175. {
  176. PRINTA_INFO("FPDWarn: %s", in.c_str());
  177. return RET_STATUS::RET_SUCCEED;
  178. }
  179. RET_STATUS CFPDCommunicateWithOtherDevice::JSGetIMGCropStatus(std::string& out)
  180. {
  181. char szFDinfo[MAX_STRING] = { 0 };
  182. sprintf_s(szFDinfo, "%d", m_nHWcrop);
  183. out = szFDinfo;
  184. PRINTA_INFO("GetIMGCropStatus: %s", out.c_str());
  185. return RET_STATUS::RET_SUCCEED;
  186. }
  187. RET_STATUS CFPDCommunicateWithOtherDevice::JSGetFPDRotate(std::string& out)
  188. {
  189. char szFDinfo[MAX_STRING] = { 0 };
  190. sprintf_s(szFDinfo, "%d", m_nPanelRotate);
  191. out = szFDinfo;
  192. PRINTA_INFO("GetFPDRotate: %s", out.c_str());
  193. return RET_STATUS::RET_SUCCEED;
  194. }
  195. RET_STATUS CFPDCommunicateWithOtherDevice::JSGetCollimatorAlign(std::string& out)
  196. {
  197. char szFDinfo[MAX_STRING] = { 0 };
  198. sprintf_s(szFDinfo, "%d", m_nCollimatorAlign);
  199. out = szFDinfo;
  200. PRINTA_INFO("GetCollimatorAlign: %s", out.c_str());
  201. return RET_STATUS::RET_SUCCEED;
  202. }
  203. RET_STATUS CFPDCommunicateWithOtherDevice::JSGetCollimatorWidth(std::string& out)
  204. {
  205. char szFDinfo[MAX_STRING] = { 0 };
  206. sprintf_s(szFDinfo, "%f", m_fCollimatorWidth);
  207. out = szFDinfo;
  208. PRINTA_INFO("GetCollimatorWidth: %s", out.c_str());
  209. return RET_STATUS::RET_SUCCEED;
  210. }
  211. RET_STATUS CFPDCommunicateWithOtherDevice::JSGetCollimatorLength(std::string& out)
  212. {
  213. char szFDinfo[MAX_STRING] = { 0 };
  214. sprintf_s(szFDinfo, "%f", m_fCollimatorLen);
  215. out = szFDinfo;
  216. PRINTA_INFO("GetCollimatorLength: %s", out.c_str());
  217. return RET_STATUS::RET_SUCCEED;
  218. }
  219. RET_STATUS CFPDCommunicateWithOtherDevice::JSGetAPRms(std::string& out)
  220. {
  221. char szFDinfo[MAX_STRING] = { 0 };
  222. sprintf_s(szFDinfo, "%f", m_fAPRms);
  223. out = szFDinfo;
  224. PRINTA_INFO("GetAPRms: %s", out.c_str());
  225. return RET_STATUS::RET_SUCCEED;
  226. }
  227. RET_STATUS CFPDCommunicateWithOtherDevice::JSGetWorkStation(std::string& out)
  228. {
  229. char szFDinfo[MAX_STRING] = { 0 };
  230. sprintf_s(szFDinfo, "%d", m_nWorkStation);
  231. out = szFDinfo;
  232. PRINTA_INFO("GetWorkStation: %s", out.c_str());
  233. return RET_STATUS::RET_SUCCEED;
  234. }
  235. RET_STATUS CFPDCommunicateWithOtherDevice::JSLTEenable(std::string& out)
  236. {
  237. char szFDinfo[MAX_STRING] = { 0 };
  238. bool bEnable = *m_bLTEenable;
  239. sprintf_s(szFDinfo, "%d", bEnable);
  240. out = szFDinfo;
  241. PRINTA_INFO("GetLTEenable: %s", out.c_str());
  242. return RET_STATUS::RET_SUCCEED;
  243. }
  244. RET_STATUS CFPDCommunicateWithOtherDevice::JSXrayStatus(std::string& out)
  245. {
  246. char szFDinfo[MAX_STRING] = { 0 };
  247. bool bXrayStatus = *m_bXrayStatus;
  248. sprintf_s(szFDinfo, "%d", bXrayStatus);
  249. out = szFDinfo;
  250. PRINTA_INFO("GetXrayStatus: %s", out.c_str());
  251. return RET_STATUS::RET_SUCCEED;
  252. }