DIOS.Dev.MechanicalMoudle.cpp 8.1 KB

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