DIOS.Dev.MechanicalMoudle.cpp 7.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321
  1. #include "stdafx.h"
  2. #include "CCOS.Dev.MechanicalMoudle.hpp"
  3. #include "CCOSDICOMInfo.h"
  4. using namespace CCOS::Dev;
  5. using namespace CCOS::Dev::Detail::Mechanical;
  6. namespace nsMech = CCOS::Dev::Detail::Mechanical;
  7. nsMech::MechanicalDevice::MechanicalDevice(std::shared_ptr <CCOS::Dev::IOEventCenter> EventCenter) :super(EventCenter)
  8. {
  9. m_EventCenter = EventCenter;
  10. m_Grid = 0;
  11. m_Mammo_AE = 0;
  12. m_Mammo_FT = 0;
  13. m_Mammo_Thickness = 0;
  14. m_Mammo_CompPressureDEC = 0;
  15. m_Mammo_Depress = 0;
  16. m_Mammo_MechAngle = 0.0f;
  17. m_Mammo_MechHeight = 0.0f;
  18. m_Mammo_PressureValue = 0.0f;
  19. m_Mammo_AGD = 0.0f;
  20. m_Mammo_MAG = 0.0f;
  21. }
  22. nsMech::MechanicalDevice::~MechanicalDevice()
  23. {
  24. }
  25. void nsMech::MechanicalDevice::FireNotify(string key, unsigned int value)
  26. {
  27. char szInfo[64] = { 0 };
  28. sprintf_s(szInfo, "%d", value);
  29. std::string str = szInfo;
  30. m_EventCenter->OnNotify(1, key, str);//(int)ATTRACTION_SET 2
  31. }
  32. void nsMech::MechanicalDevice::FireNotify(string key, float value)
  33. {
  34. char szInfo[64] = { 0 };
  35. sprintf_s(szInfo, "%f", value);
  36. std::string str = szInfo;
  37. m_EventCenter->OnNotify(1, key, str);//(int)ATTRACTION_SET 2
  38. }
  39. void nsMech::MechanicalDevice::Register()
  40. {
  41. auto Disp = &Dispatch;
  42. Disp->Action.Push("SetGrid", this, &nsMech::MechanicalDevice::JSSetGrid);
  43. Disp->Action.Push("SetAutoTracking", this, &nsMech::MechanicalDevice::JSSetAutoTracking);
  44. Disp->Action.Push("GetTomoResults", this, &nsMech::MechanicalDevice::JSGetTomoResults);
  45. Disp->Get.Push("GRID", this, &nsMech::MechanicalDevice::JSGetGrid);
  46. Disp->Get.Push("AE", this, &nsMech::MechanicalDevice::JSGetMammo_AE);
  47. Disp->Get.Push("Filter", this, &nsMech::MechanicalDevice::JSGetMammo_FT);
  48. Disp->Get.Push("Thickness", this, &nsMech::MechanicalDevice::JSGetMammo_Thickness);
  49. Disp->Get.Push("CompPressureDEC", this, &nsMech::MechanicalDevice::JSGetMammo_CompPressureDEC);
  50. Disp->Get.Push("Depress", this, &nsMech::MechanicalDevice::JSGetMammo_Depress);
  51. Disp->Get.Push("MechanicalAngle", this, &nsMech::MechanicalDevice::JSGetMammo_MechAngle);
  52. Disp->Get.Push("MechanicalHeight", this, &nsMech::MechanicalDevice::JSGetMammo_MechHeight);
  53. Disp->Get.Push("CompPressure", this, &nsMech::MechanicalDevice::JSGetMammo_PressureValue);
  54. Disp->Get.Push("AGD", this, &nsMech::MechanicalDevice::JSGetMammo_AGD);
  55. Disp->Get.Push("MAG", this, &nsMech::MechanicalDevice::JSGetMammo_MAG);
  56. }
  57. bool nsMech::MechanicalDevice::Prepare()
  58. {
  59. Register();
  60. return true;
  61. }
  62. std::string nsMech::MechanicalDevice::GetGUID() const
  63. {
  64. return MechanicalUnitType;
  65. }
  66. RET_STATUS nsMech::MechanicalDevice::JSSetGrid(std::string in, std::string& out)
  67. {
  68. ResDataObject json;
  69. json.decode(in.c_str());
  70. unsigned int nValue = json[0];
  71. return SetGrid(nValue);
  72. }
  73. RET_STATUS nsMech::MechanicalDevice::JSSetAutoTracking(std::string in, std::string& out)
  74. {
  75. ResDataObject json;
  76. json.decode(in.c_str());
  77. unsigned int nValue = json[0];
  78. return SetAutoTracking(nValue);
  79. }
  80. RET_STATUS nsMech::MechanicalDevice::JSGetTomoResults(std::string in, std::string& out)
  81. {
  82. ResDataObject json;
  83. ResDataObject resultAngle;
  84. ResDataObject resultHeight;
  85. RET_STATUS ret = GetTomoResults(resultAngle, resultHeight);
  86. if(ret != RET_STATUS::RET_SUCCEED)
  87. {
  88. return RET_STATUS::RET_FAILED;
  89. }
  90. json.add("P0", resultAngle);
  91. json.add("P1", resultHeight);
  92. out = json.encode();
  93. return RET_STATUS::RET_SUCCEED;
  94. }
  95. RET_STATUS nsMech::MechanicalDevice::JSGetGrid(std::string& out)
  96. {
  97. char szInfo[64] = { 0 };
  98. sprintf_s(szInfo, "%d", m_Grid);
  99. out = szInfo;
  100. return RET_STATUS::RET_SUCCEED;
  101. }
  102. RET_STATUS nsMech::MechanicalDevice::JSGetMammo_AE(std::string& out)
  103. {
  104. char szInfo[64] = { 0 };
  105. sprintf_s(szInfo, "%d", m_Mammo_AE);
  106. out = szInfo;
  107. return RET_STATUS::RET_SUCCEED;
  108. }
  109. RET_STATUS nsMech::MechanicalDevice::JSGetMammo_FT(std::string& out)
  110. {
  111. char szInfo[64] = { 0 };
  112. sprintf_s(szInfo, "%d", m_Mammo_FT);
  113. out = szInfo;
  114. return RET_STATUS::RET_SUCCEED;
  115. }
  116. RET_STATUS nsMech::MechanicalDevice::JSGetMammo_Thickness(std::string& out)
  117. {
  118. char szInfo[64] = { 0 };
  119. sprintf_s(szInfo, "%d", m_Mammo_Thickness);
  120. out = szInfo;
  121. return RET_STATUS::RET_SUCCEED;
  122. }
  123. RET_STATUS nsMech::MechanicalDevice::JSGetMammo_CompPressureDEC(std::string& out)
  124. {
  125. char szInfo[64] = { 0 };
  126. sprintf_s(szInfo, "%d", m_Mammo_CompPressureDEC);
  127. out = szInfo;
  128. return RET_STATUS::RET_SUCCEED;
  129. }
  130. RET_STATUS nsMech::MechanicalDevice::JSGetMammo_Depress(std::string& out)
  131. {
  132. char szInfo[64] = { 0 };
  133. sprintf_s(szInfo, "%d", m_Mammo_Depress);
  134. out = szInfo;
  135. return RET_STATUS::RET_SUCCEED;
  136. }
  137. RET_STATUS nsMech::MechanicalDevice::JSGetMammo_MechAngle(std::string& out)
  138. {
  139. char szInfo[64] = { 0 };
  140. sprintf_s(szInfo, "%f", m_Mammo_MechAngle);
  141. out = szInfo;
  142. return RET_STATUS::RET_SUCCEED;
  143. }
  144. RET_STATUS nsMech::MechanicalDevice::JSGetMammo_MechHeight(std::string& out)
  145. {
  146. char szInfo[64] = { 0 };
  147. sprintf_s(szInfo, "%f", m_Mammo_MechHeight);
  148. out = szInfo;
  149. return RET_STATUS::RET_SUCCEED;
  150. }
  151. RET_STATUS nsMech::MechanicalDevice::JSGetMammo_PressureValue(std::string& out)
  152. {
  153. char szInfo[64] = { 0 };
  154. sprintf_s(szInfo, "%f", m_Mammo_PressureValue);
  155. out = szInfo;
  156. return RET_STATUS::RET_SUCCEED;
  157. }
  158. RET_STATUS nsMech::MechanicalDevice::JSGetMammo_AGD(std::string& out)
  159. {
  160. char szInfo[64] = { 0 };
  161. sprintf_s(szInfo, "%f", m_Mammo_AGD);
  162. out = szInfo;
  163. return RET_STATUS::RET_SUCCEED;
  164. }
  165. RET_STATUS nsMech::MechanicalDevice::JSGetMammo_MAG(std::string& out)
  166. {
  167. char szInfo[64] = { 0 };
  168. sprintf_s(szInfo, "%f", m_Mammo_MAG);
  169. out = szInfo;
  170. return RET_STATUS::RET_SUCCEED;
  171. }
  172. void MechanicalDevice::UpdateGrid(unsigned int Value)
  173. {
  174. m_Grid = Value;
  175. FireNotify("GRID", Value);
  176. }
  177. void MechanicalDevice::UpdateMammo_AE(unsigned int Value)
  178. {
  179. m_Mammo_AE = Value;
  180. FireNotify("AE", Value);
  181. }
  182. void MechanicalDevice::UpdateMammo_FT(unsigned int Value)
  183. {
  184. if (m_Mammo_FT != Value)
  185. {
  186. m_Mammo_FT = Value;
  187. FireNotify("Filter", Value);
  188. }
  189. }
  190. void MechanicalDevice::UpdateMammo_Thickness(unsigned int Value)
  191. {
  192. if (m_Mammo_Thickness != Value)
  193. {
  194. m_Mammo_Thickness = Value;
  195. FireNotify("Thickness", Value);
  196. }
  197. }
  198. void MechanicalDevice::UpdateMammo_CompPressureDEC(unsigned int Value)
  199. {
  200. m_Mammo_CompPressureDEC = Value;
  201. FireNotify("CompPressureDEC", Value);
  202. }
  203. void MechanicalDevice::UpdateMammo_Depress(unsigned int Value)
  204. {
  205. if (m_Mammo_Depress != Value)
  206. {
  207. m_Mammo_Depress = Value;
  208. FireNotify("Depress", Value);
  209. }
  210. }
  211. void MechanicalDevice::UpdateMammo_MechAngle(float Value)
  212. {
  213. m_Mammo_MechAngle = Value;
  214. FireNotify("MechanicalAngle", Value);
  215. }
  216. void MechanicalDevice::UpdateMammo_MechHeight(float Value)
  217. {
  218. m_Mammo_MechHeight = Value;
  219. FireNotify("MechanicalHeight", Value);
  220. }
  221. void MechanicalDevice::UpdateMammo_PressureValue(float Value)
  222. {
  223. if (m_Mammo_PressureValue != Value)
  224. {
  225. m_Mammo_PressureValue = Value;
  226. FireNotify("CompPressure", Value);
  227. }
  228. }
  229. void MechanicalDevice::UpdateMammo_AGD(float Value)
  230. {
  231. m_Mammo_AGD = Value;
  232. FireNotify("AGD", Value);
  233. }
  234. void MechanicalDevice::UpdateMammo_MAG(float Value)
  235. {
  236. m_Mammo_MAG = Value;
  237. FireNotify("MAG", Value);
  238. }
  239. RET_STATUS MechanicalDevice::SetGrid(unsigned int GridType)
  240. {
  241. return RET_STATUS::RET_SUCCEED;
  242. }
  243. RET_STATUS MechanicalDevice::SetAutoTracking(unsigned int nAutoTracking)
  244. {
  245. return RET_STATUS::RET_FAILED;
  246. }
  247. RET_STATUS MechanicalDevice::GetTomoResults(ResDataObject& resultAngle, ResDataObject& resultHeight)
  248. {
  249. return RET_STATUS::RET_SUCCEED;
  250. }
  251. unsigned int MechanicalDevice::GetMammo_FT()
  252. {
  253. return m_Mammo_FT;
  254. }
  255. unsigned int MechanicalDevice::GetMammo_Thickness()
  256. {
  257. return m_Mammo_Thickness;
  258. }
  259. unsigned int MechanicalDevice::GetMammo_PressureValue()
  260. {
  261. return m_Mammo_PressureValue;
  262. }