OTSSEMOxford.cpp 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316
  1. #include "stdafx.h"
  2. #include "OTSSEMOxford.h"
  3. #include "../OTSSemBase.h"
  4. #include "COTSUtilityDllFunExport.h"
  5. namespace OTSController {
  6. COTSSEMOxford::COTSSEMOxford(void)
  7. {
  8. }
  9. COTSSEMOxford::~COTSSEMOxford(void)
  10. {
  11. }
  12. BOOL COTSSEMOxford::IsConnected(void)
  13. {
  14. if (!m_oxfordImpl)
  15. {
  16. return FALSE;
  17. }
  18. return m_oxfordImpl->IsConnected();
  19. }
  20. BOOL COTSSEMOxford::Connect(void)
  21. {
  22. if (!m_oxfordImpl)
  23. {
  24. m_oxfordImpl = OxfordImpl::GetInstance();
  25. }
  26. return m_oxfordImpl->Connect();
  27. }
  28. // 0: beam off
  29. // 1: beam on
  30. // 2: beam blank
  31. BOOL COTSSEMOxford::GetBeamBlank(long& a_nBeamBlank)
  32. {
  33. ASSERT(m_oxfordImpl);
  34. if (!m_oxfordImpl)
  35. {
  36. return FALSE;
  37. }
  38. bool bBeamOn = false;
  39. if (!m_oxfordImpl->GetBeamOn(bBeamOn))
  40. {
  41. return FALSE;
  42. }
  43. if (!bBeamOn)
  44. {
  45. a_nBeamBlank = 0;
  46. return TRUE;
  47. }
  48. bool bBeamBlank = false;
  49. if (!m_oxfordImpl->GetBeamBlank(bBeamBlank))
  50. {
  51. return FALSE;
  52. }
  53. if (bBeamBlank)
  54. {
  55. a_nBeamBlank = 2;
  56. return TRUE;
  57. }
  58. a_nBeamBlank = 1;
  59. return TRUE;
  60. }
  61. BOOL COTSSEMOxford::SetBeamBlank(long a_nBeamBlank)
  62. {
  63. ASSERT(m_oxfordImpl);
  64. if (!m_oxfordImpl)
  65. {
  66. return FALSE;
  67. }
  68. /*if (a_nBeamBlank < 0 || a_nBeamBlank >= 3)
  69. {
  70. return FALSE;
  71. }
  72. if (a_nBeamBlank == 0)
  73. {
  74. return m_oxfordImpl->SetBeamOn(FALSE);
  75. }
  76. if (!m_oxfordImpl->SetBeamOn(TRUE))
  77. {
  78. return FALSE;
  79. }*/
  80. if (a_nBeamBlank == 0)
  81. {
  82. return m_oxfordImpl->SetBeamBlank(FALSE);
  83. }
  84. return TRUE;
  85. }
  86. BOOL COTSSEMOxford::SetBeamCurrent(BOOL a_nBeamCurrent)
  87. {
  88. ASSERT(m_oxfordImpl);
  89. if (!m_oxfordImpl)
  90. {
  91. return FALSE;
  92. }
  93. if (!a_nBeamCurrent)
  94. {
  95. return m_oxfordImpl->SetBeamOn(FALSE);
  96. }
  97. return TRUE;
  98. }
  99. BOOL COTSSEMOxford::GetPositionXY(double& a_dPositionX, double& a_dPositionY, double& /*a_dPositionR*/)
  100. {
  101. // controller checking
  102. ASSERT(m_oxfordImpl);
  103. if (!m_oxfordImpl)
  104. {
  105. return FALSE;
  106. }
  107. if (!m_oxfordImpl->GetPositionXY(a_dPositionX, a_dPositionY))
  108. {
  109. return FALSE;
  110. }
  111. return TRUE;
  112. }
  113. BOOL COTSSEMOxford::SetPositionXY(double a_dPositionX, double a_dPositionY, double /*a_dPositionR*/)
  114. {
  115. // controller checking
  116. ASSERT(m_oxfordImpl);
  117. if (!m_oxfordImpl)
  118. {
  119. return FALSE;
  120. }
  121. // set position
  122. if (!m_oxfordImpl->SetPositionXY(a_dPositionX, a_dPositionY))
  123. {
  124. // OK, return TRUE
  125. return TRUE;
  126. }
  127. LogTrace(__FILE__, __LINE__, _T("setpostionxy %f, %f"), a_dPositionX, a_dPositionY);
  128. return TRUE;
  129. }
  130. BOOL COTSSEMOxford::SetPositionXY(double a_dPositionX, double a_dPositionY)
  131. {
  132. // controller checking
  133. ASSERT(m_oxfordImpl);
  134. if (!m_oxfordImpl)
  135. {
  136. return FALSE;
  137. }
  138. // set position
  139. if (!m_oxfordImpl->SetPositionXY(a_dPositionX, a_dPositionY))
  140. {
  141. // OK, return TRUE
  142. return TRUE;
  143. }
  144. LogTrace(__FILE__, __LINE__, _T("setpostionxy %f, %f"), a_dPositionX, a_dPositionY);
  145. return TRUE;
  146. }
  147. BOOL COTSSEMOxford::GetWorkingDistance(double& a_dWorkingDistance)
  148. {
  149. ASSERT(m_oxfordImpl);
  150. if (!m_oxfordImpl)
  151. {
  152. return FALSE;
  153. }
  154. return m_oxfordImpl->GetWorkingDistance(a_dWorkingDistance);
  155. }
  156. BOOL COTSSEMOxford::SetWorkingDistance(double a_dWorkingDistance)
  157. {
  158. ASSERT(m_oxfordImpl);
  159. if (!m_oxfordImpl)
  160. {
  161. return FALSE;
  162. }
  163. return m_oxfordImpl->SetWorkingDistance(a_dWorkingDistance);
  164. }
  165. BOOL COTSSEMOxford::GetHighTension(double& a_dKV)
  166. {
  167. ASSERT(m_oxfordImpl);
  168. if (!m_oxfordImpl)
  169. {
  170. return FALSE;
  171. }
  172. return m_oxfordImpl->GetHighVoltage(a_dKV);
  173. }
  174. BOOL COTSSEMOxford::SetHighTension(double a_dKV)
  175. {
  176. ASSERT(m_oxfordImpl);
  177. if (!m_oxfordImpl)
  178. {
  179. return FALSE;
  180. }
  181. return m_oxfordImpl->SetHighVoltage(a_dKV);
  182. }
  183. BOOL COTSSEMOxford::GetMagnification(double& a_dMagnification)
  184. {
  185. ASSERT(m_oxfordImpl);
  186. if (!m_oxfordImpl)
  187. {
  188. return FALSE;
  189. }
  190. return m_oxfordImpl->GetMagnification(a_dMagnification);
  191. }
  192. BOOL COTSSEMOxford::SetMagnification(double a_dMagnification)
  193. {
  194. ASSERT(m_oxfordImpl);
  195. if (!m_oxfordImpl)
  196. {
  197. return FALSE;
  198. }
  199. return m_oxfordImpl->SetMagnification(a_dMagnification);
  200. }
  201. // get scan field size
  202. // param double& a_dScanFieldSizeX - output
  203. // double& a_dScanFieldSizeY - output
  204. // return TRUE if success
  205. BOOL COTSSEMOxford::GetScanFieldSize(double& a_dScanFieldSizeX, double& a_dScanFieldSizeY)
  206. {
  207. // set method succeed flag to FALSE as default
  208. BOOL bReturn = FALSE;
  209. // get screen matrix and magnification
  210. double fmag = 0;
  211. if (GetMagnification(fmag))
  212. {
  213. double fssizeX = 0;
  214. double fssizeY = 0;
  215. if (MagToScanFieldSize(fmag, fssizeX, fssizeY))
  216. {
  217. // calculate scan field size and set output values
  218. a_dScanFieldSizeX = fssizeX;
  219. a_dScanFieldSizeY = fssizeY;
  220. // set method succeed flag to TRUE
  221. bReturn = TRUE;
  222. }
  223. }
  224. // return method succeed flag
  225. return bReturn;
  226. }
  227. // Set scan field size
  228. // param double& a_dScanFieldSizeX
  229. // return TRUE if success
  230. BOOL COTSSEMOxford::SetScanFieldSizeX(double a_dScanFieldSizeX)
  231. {
  232. // set method succeed flag to FALSE as default
  233. BOOL bReturn = FALSE;
  234. double mag = 0;
  235. if (ScanFieldSizeToMag(mag, a_dScanFieldSizeX))
  236. {
  237. LogTrace(__FILE__, __LINE__,_T("Scan field size is %f, mag is %f"), a_dScanFieldSizeX, mag);
  238. // set magnification and method succeed flag
  239. bReturn = SetMagnification(mag);
  240. }
  241. // return method succeed flag
  242. return bReturn;
  243. }
  244. BOOL COTSSEMOxford::SetScanExternal(BOOL a_bExternal)
  245. {
  246. ASSERT(m_oxfordImpl);
  247. if (!m_oxfordImpl)
  248. {
  249. return FALSE;
  250. }
  251. return m_oxfordImpl->SetExternal(a_bExternal);
  252. }
  253. }