DIOS.Dev.COLLIMATORMould.cpp 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143
  1. // DIOS.Dev.FPDDeviceMould.cpp : 定义 DLL 应用程序的导出函数。
  2. //
  3. #include "stdafx.h"
  4. #include <assert.h>
  5. #include "DIOS.Dev.COLLIMATORMould.hpp"
  6. #include "EasyJSONEncoder.hpp"
  7. #include "ResDataObject.h"
  8. #include "DIOSDICOMInfo.h"
  9. namespace DIOS
  10. {
  11. namespace Dev
  12. {
  13. namespace COLLIMATOR
  14. {
  15. //-----------------------------------------------------------------------------
  16. // CollimatorUnit
  17. //-----------------------------------------------------------------------------
  18. CollimatorUnit::CollimatorUnit(ICollimatorControl* pCollimatorDevice)
  19. {
  20. m_pCollimatorDevice = pCollimatorDevice;
  21. }
  22. CollimatorUnit:: ~CollimatorUnit()
  23. {
  24. }
  25. int CollimatorUnit::SetCollimatorSize(std::string in, std::string & out)
  26. {
  27. ResDataObject json;
  28. json.decode(in.c_str());
  29. int xvalue = atoi(((string)json[0]).c_str());
  30. int yvalue = atoi(((string)json[1]).c_str());
  31. return ((ICollimatorControl *)m_pCollimatorDevice)->SetCollimatorSize(xvalue, yvalue);
  32. }
  33. int CollimatorUnit::SetCollimatorSID(std::string in, std::string & out)
  34. {
  35. ResDataObject json;
  36. json.decode(in.c_str());
  37. int value = atoi(((string)json[0]).c_str());
  38. return ((ICollimatorControl *)m_pCollimatorDevice)->SetCollimatorSID(value);
  39. }
  40. int CollimatorUnit::SetCollimatorFilter(std::string in, std::string & out)
  41. {
  42. ResDataObject json;
  43. json.decode(in.c_str());
  44. int value = atoi(((string)json[0]).c_str());
  45. return ((ICollimatorControl *)m_pCollimatorDevice)->SetCollimatorFilter(value);
  46. }
  47. int CollimatorUnit::SetCollimatorAngle(std::string in, std::string & out)
  48. {
  49. ResDataObject json;
  50. json.decode(in.c_str());
  51. int value = atoi(((string)json[0]).c_str());
  52. return ((ICollimatorControl *)m_pCollimatorDevice)->SetCollimatorAngle(value);
  53. }
  54. int CollimatorUnit::SetCollimatorMode(std::string in, std::string & out)
  55. {
  56. ResDataObject json;
  57. json.decode(in.c_str());
  58. int value = atoi(((string)json[0]).c_str());
  59. return ((ICollimatorControl *)m_pCollimatorDevice)->SetCollimatorMode(value);
  60. }
  61. int CollimatorUnit::SetTechParamsInfo(std::string in, std::string & out)
  62. {
  63. ResDataObject json;
  64. json.decode(in.c_str());
  65. TECHPARAM_INFO info;
  66. info.SetVal(json[0].encode());
  67. string strcollimatorwidth = info.m_CollimatorWidth;
  68. string strcollimatorheight = info.m_CollimatorHeight;
  69. string strcollimatorfilter = info.m_CollimatorFilter;
  70. string strSID = info.m_SID;
  71. DWORD Width = 0;
  72. DWORD Height = 0;
  73. DWORD dwFilter = 0;
  74. DWORD dwSID = 0;
  75. if (strcollimatorwidth.find("IN") != string::npos)
  76. {
  77. Width = (DWORD)(atof(strcollimatorwidth.substr(0, strcollimatorwidth.size() - 2).c_str())*2.54);
  78. }
  79. else
  80. {
  81. Width = (DWORD)(atoi(strcollimatorwidth.substr(0, strcollimatorwidth.size() - 2).c_str()));
  82. }
  83. if (strcollimatorheight.find("IN") != string::npos)
  84. {
  85. Height = (DWORD)(atof(strcollimatorheight.substr(0, strcollimatorheight.size() - 2).c_str())*2.54);
  86. }
  87. else
  88. {
  89. Height = (DWORD)(atoi(strcollimatorheight.substr(0, strcollimatorheight.size() - 2).c_str()));
  90. }
  91. if (Width != 0 && Height != 0)
  92. {
  93. return ((ICollimatorControl *)m_pCollimatorDevice)->SetCollimatorSize(Width, Height);
  94. }
  95. dwFilter = (DWORD)atoi(strcollimatorfilter.c_str());
  96. if (dwFilter >= 0)
  97. {
  98. return ((ICollimatorControl *)m_pCollimatorDevice)->SetCollimatorFilter(dwFilter);
  99. }
  100. dwSID = (DWORD)atoi(strSID.c_str());
  101. if (dwSID >= 0)
  102. {
  103. return ((ICollimatorControl *)m_pCollimatorDevice)->SetCollimatorSID(dwSID);
  104. }
  105. return 2;
  106. }
  107. //-----------------------------------------------------------------------------
  108. // ICollimatorControl
  109. //-----------------------------------------------------------------------------
  110. int ICollimatorControl::SetCollimatorSize(unsigned short xsize, unsigned short ysize)
  111. {
  112. return 1;
  113. }
  114. int ICollimatorControl::SetCollimatorSID(unsigned short sid)
  115. {
  116. return 1;
  117. }
  118. int ICollimatorControl::SetCollimatorFilter(unsigned short pParams)
  119. {
  120. return 1;
  121. }
  122. int ICollimatorControl::SetCollimatorAngle(unsigned short pParams)
  123. {
  124. return 1;
  125. }
  126. int ICollimatorControl::SetCollimatorMode(unsigned short pParams)
  127. {
  128. return 1;
  129. }
  130. }
  131. }
  132. }