OTSSEMBruker.cpp 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681
  1. #include "stdafx.h"
  2. #include "OTSSEMBruker.h"
  3. namespace OTSController {
  4. // constructor
  5. COTSSEMBruker::COTSSEMBruker()
  6. : m_bConnected(FALSE)
  7. {
  8. }
  9. // destructor
  10. COTSSEMBruker::~COTSSEMBruker()
  11. {
  12. }
  13. // check if connected
  14. // return true if setup success
  15. BOOL COTSSEMBruker::IsConnected()
  16. {
  17. return m_bConnected;
  18. }
  19. // connect client dll
  20. BOOL COTSSEMBruker::Connect()
  21. {
  22. // doing nothing if m_pBrukerImplPtr is not nullptr
  23. if (!m_pBrukerImplPtr)
  24. {
  25. // get bruker initialize controller
  26. m_pBrukerImplPtr = COTSBrukerImpl::GetInstance();
  27. }
  28. // make sure m_pBrukerImplPtr is OK
  29. if (m_pBrukerImplPtr)
  30. {
  31. // initialize the bruker controller as a SEM controller
  32. LogTrace(__FILE__, __LINE__, _T("Init BrukerImpl..."));
  33. if (m_pBrukerImplPtr->Init(CONTROL_TYPE::BRUKER_SEM))
  34. {
  35. // check connection
  36. if (!m_pBrukerImplPtr->CheckConnection(m_bConnected))
  37. {
  38. LogErrorTrace(__FILE__, __LINE__, _T("COTSSEMBruker::Connect: failed to call CheckConnection."));
  39. m_pBrukerImplPtr.reset();
  40. m_bConnected = FALSE;
  41. return FALSE;
  42. }
  43. }
  44. // connection is ok?
  45. if (!m_bConnected)
  46. {
  47. // connection
  48. LogErrorTrace(__FILE__, __LINE__, _T("COTSSEMBruker::Connect(): connecting failed."));
  49. m_pBrukerImplPtr.reset();
  50. return FALSE;
  51. }
  52. }
  53. // ok, return TRUE
  54. return TRUE;
  55. }
  56. BOOL COTSSEMBruker::Disconnect()
  57. {
  58. if (m_bConnected)
  59. {
  60. m_pBrukerImplPtr->DisConnect();
  61. m_bConnected = false;
  62. return true;
  63. }
  64. else
  65. {
  66. return true;
  67. }
  68. }
  69. // set beam blank
  70. BOOL COTSSEMBruker::SetBeamBlank(long a_nBeamBlank)
  71. {
  72. // m_pBrukerImplPtr check
  73. ASSERT(m_pBrukerImplPtr);
  74. if (!m_pBrukerImplPtr)
  75. {
  76. LogErrorTrace(__FILE__, __LINE__, _T("COTSSEMBruker::SetBeamBlank: m_pBrukerImplPtr is invalid."));
  77. return FALSE;
  78. }
  79. // turn Bean off if a_nBeamBlank > 0
  80. if (a_nBeamBlank > 0)
  81. {
  82. if (!m_pBrukerImplPtr->SwitchSEMOff(FALSE, FALSE, TRUE))
  83. {
  84. // failed to call SwitchSEMOff method
  85. LogErrorTrace(__FILE__, __LINE__, _T("COTSSEMBruker::SetBeamBlank : failed to call SwitchSEMOff method."));
  86. return FALSE;
  87. }
  88. }
  89. // ok, return TRUE
  90. return TRUE;
  91. }
  92. // set beam blank
  93. BOOL COTSSEMBruker::SetBeamCurrent(BOOL a_nBeamCurrent)
  94. {
  95. // m_pBrukerImplPtr check
  96. ASSERT(m_pBrukerImplPtr);
  97. if (!m_pBrukerImplPtr)
  98. {
  99. LogErrorTrace(__FILE__, __LINE__, _T("COTSSEMBruker::SetBeamBlank: m_pBrukerImplPtr is invalid."));
  100. return FALSE;
  101. }
  102. // turn Bean off if a_nBeamBlank > 0
  103. if (a_nBeamCurrent )
  104. {
  105. if (!m_pBrukerImplPtr->SwitchSEMOff(FALSE,TRUE , FALSE))
  106. {
  107. // failed to call SwitchSEMOff method
  108. LogErrorTrace(__FILE__, __LINE__, _T("COTSSEMBruker::SetBeamBlank : failed to call SwitchSEMOff method."));
  109. return FALSE;
  110. }
  111. }
  112. // ok, return TRUE
  113. return TRUE;
  114. }
  115. // brightness
  116. BOOL COTSSEMBruker::GetBrightness(double& a_dBrightness)
  117. {
  118. // m_pBrukerImplPtr check
  119. ASSERT(m_pBrukerImplPtr);
  120. if (!m_pBrukerImplPtr)
  121. {
  122. LogErrorTrace(__FILE__, __LINE__, _T("COTSSEMBruker::GetBrightness: m_pBrukerImplPtr is invalid."));
  123. return FALSE;
  124. }
  125. // get brightness and contrast
  126. double dBrightness, dContrast;
  127. if (!m_pBrukerImplPtr->GetSEMBCData(dBrightness, dContrast))
  128. {
  129. // failed to call GetSEMBCData method
  130. LogErrorTrace(__FILE__, __LINE__, _T("COTSSEMBruker::GetBrightness: failed to call GetSEMBCData method."));
  131. return FALSE;
  132. }
  133. a_dBrightness = dBrightness;
  134. // ok, return TRUE
  135. return TRUE;
  136. }
  137. BOOL COTSSEMBruker::SetBrightness(double a_dBrightness)
  138. {
  139. // m_pBrukerImplPtr check
  140. ASSERT(m_pBrukerImplPtr);
  141. if (!m_pBrukerImplPtr)
  142. {
  143. LogErrorTrace(__FILE__, __LINE__, _T("COTSSEMBruker::SetBrightness: m_pBrukerImplPtr is invalid."));
  144. return FALSE;
  145. }
  146. // get current brightness and contrast
  147. double dBrightness, dContrast;
  148. if (!m_pBrukerImplPtr->GetSEMBCData(dBrightness, dContrast))
  149. {
  150. // failed to call GetSEMBCData method
  151. LogErrorTrace(__FILE__, __LINE__, _T("COTSSEMBruker::SetBrightness: failed to call GetSEMBCData method."));
  152. return FALSE;
  153. }
  154. // set brightness and contrast
  155. dBrightness = a_dBrightness;
  156. if (!m_pBrukerImplPtr->SetSEMBCData(dBrightness, dContrast))
  157. {
  158. // failed to call GetSEMBCData method
  159. LogErrorTrace(__FILE__, __LINE__, _T("COTSSEMBruker::SetBrightness: failed to call SetSEMBCData method."));
  160. return FALSE;
  161. }
  162. // ok, return TRUE
  163. return TRUE;
  164. }
  165. // contrast
  166. BOOL COTSSEMBruker::GetContrast(double& a_dContrast)
  167. {
  168. // m_pBrukerImplPtr check
  169. ASSERT(m_pBrukerImplPtr);
  170. if (!m_pBrukerImplPtr)
  171. {
  172. LogErrorTrace(__FILE__, __LINE__, _T("COTSSEMBruker::GetContrast: m_pBrukerImplPtr is invalid."));
  173. return FALSE;
  174. }
  175. // get brightness and contrast
  176. double dBrightness, dContrast;
  177. if (!m_pBrukerImplPtr->GetSEMBCData(dBrightness, dContrast))
  178. {
  179. // failed to call GetSEMBCData method
  180. LogErrorTrace(__FILE__, __LINE__, _T("COTSSEMBruker::GetContrast: failed to call GetSEMBCData method."));
  181. return FALSE;
  182. }
  183. a_dContrast = dContrast;
  184. // ok, return TRUE
  185. return TRUE;
  186. }
  187. BOOL COTSSEMBruker::SetContrast(double a_dContrast)
  188. {
  189. // m_pBrukerImplPtr check
  190. ASSERT(m_pBrukerImplPtr);
  191. if (!m_pBrukerImplPtr)
  192. {
  193. LogErrorTrace(__FILE__, __LINE__, _T("COTSSEMBruker::SetContrast: m_pBrukerImplPtr is invalid."));
  194. return FALSE;
  195. }
  196. // get current brightness and contrast
  197. double dBrightness, dContrast;
  198. if (!m_pBrukerImplPtr->GetSEMBCData(dBrightness, dContrast))
  199. {
  200. // failed to call GetSEMBCData method
  201. LogErrorTrace(__FILE__, __LINE__, _T("COTSSEMBruker::SetContrast: failed to call GetSEMBCData method."));
  202. return FALSE;
  203. }
  204. // set brightness and contrast
  205. dContrast = a_dContrast;
  206. if (!m_pBrukerImplPtr->SetSEMBCData(dBrightness, dContrast))
  207. {
  208. // failed to call SetSEMBCData method
  209. LogErrorTrace(__FILE__, __LINE__, _T("COTSSEMBruker::SetContrast: failed to call SetSEMBCData method."));
  210. return FALSE;
  211. }
  212. // ok, return TRUE
  213. return TRUE;
  214. }
  215. // working distance
  216. BOOL COTSSEMBruker::GetWorkingDistance(double& a_dWorkingDistance)
  217. {
  218. // m_pBrukerImplPtr check
  219. ASSERT(m_pBrukerImplPtr);
  220. if (!m_pBrukerImplPtr)
  221. {
  222. LogErrorTrace(__FILE__, __LINE__, _T("COTSSEMBruker::GetWorkingDistance: m_pBrukerImplPtr is invalid."));
  223. return FALSE;
  224. }
  225. // get mag, KV and working distance
  226. double dMagnification, dHighVoltage, dWorkingDistance;
  227. if (!m_pBrukerImplPtr->GetSEMData(dMagnification, dHighVoltage, dWorkingDistance))
  228. {
  229. // failed to call GetSEMData method
  230. LogErrorTrace(__FILE__, __LINE__, _T("COTSSEMBruker::GetWorkingDistance: failed to call SetSEMData method."));
  231. return FALSE;
  232. }
  233. a_dWorkingDistance = dWorkingDistance;
  234. // ok, return TRUE
  235. return TRUE;
  236. }
  237. BOOL COTSSEMBruker::SetWorkingDistance(double a_dWorkingDistance)
  238. {
  239. // m_pBrukerImplPtr check
  240. ASSERT(m_pBrukerImplPtr);
  241. if (!m_pBrukerImplPtr)
  242. {
  243. LogErrorTrace(__FILE__, __LINE__, _T("COTSSEMBruker::SetWorkingDistance: m_pBrukerImplPtr is invalid."));
  244. return FALSE;
  245. }
  246. // get current mag, KV and working distance
  247. double dMagnification, dHighVoltage, dWorkingDistance;
  248. if (!m_pBrukerImplPtr->GetSEMData(dMagnification, dHighVoltage, dWorkingDistance))
  249. {
  250. // failed to call GetSEMData method
  251. LogErrorTrace(__FILE__, __LINE__, _T("COTSSEMBruker::SetWorkingDistance: failed to call GetSEMData method."));
  252. return FALSE;
  253. }
  254. // set mag, KV and working distance
  255. dWorkingDistance = a_dWorkingDistance;
  256. if (!m_pBrukerImplPtr->SetSEMData(dMagnification, dHighVoltage, dWorkingDistance))
  257. {
  258. // failed to call SetSEMData method
  259. LogErrorTrace(__FILE__, __LINE__, _T("COTSSEMBruker::SetWorkingDistance: failed to call SetSEMData method."));
  260. return FALSE;
  261. }
  262. // ok, return TRUE
  263. return TRUE;
  264. }
  265. // high tension (KV)
  266. BOOL COTSSEMBruker::GetHighTension(double& a_dKV)
  267. {
  268. // m_pBrukerImplPtr check
  269. ASSERT(m_pBrukerImplPtr);
  270. if (!m_pBrukerImplPtr)
  271. {
  272. LogErrorTrace(__FILE__, __LINE__, _T("COTSSEMBruker::GetHighTension: m_pBrukerImplPtr is invalid."));
  273. return FALSE;
  274. }
  275. // get mag, KV and working distance
  276. double dMagnification, dHighVoltage, dWorkingDistance;
  277. if (!m_pBrukerImplPtr->GetSEMData(dMagnification, dHighVoltage, dWorkingDistance))
  278. {
  279. // failed to call GetSEMData method
  280. LogErrorTrace(__FILE__, __LINE__, _T("COTSSEMBruker::GetHighTension: failed to call SetSEMData method."));
  281. return FALSE;
  282. }
  283. a_dKV = dHighVoltage;
  284. // ok, return TRUE
  285. return TRUE;
  286. }
  287. BOOL COTSSEMBruker::SetHighTension(double a_dKV)
  288. {
  289. // m_pBrukerImplPtr check
  290. ASSERT(m_pBrukerImplPtr);
  291. if (!m_pBrukerImplPtr)
  292. {
  293. LogErrorTrace(__FILE__, __LINE__, _T("COTSSEMBruker::SetHighTension: m_pBrukerImplPtr is invalid."));
  294. return FALSE;
  295. }
  296. // get current mag, KV and working distance
  297. double dMagnification, dHighVoltage, dWorkingDistance;
  298. if (!m_pBrukerImplPtr->GetSEMData(dMagnification, dHighVoltage, dWorkingDistance))
  299. {
  300. // failed to call GetSEMData method
  301. LogErrorTrace(__FILE__, __LINE__, _T("COTSSEMBruker::SetHighTension: failed to call GetSEMData method."));
  302. return FALSE;
  303. }
  304. // set mag, KV and working distance
  305. dHighVoltage = a_dKV;
  306. if (!m_pBrukerImplPtr->SetSEMData(dMagnification, dHighVoltage, dWorkingDistance))
  307. {
  308. // failed to call SetSEMData method
  309. LogErrorTrace(__FILE__, __LINE__, _T("COTSSEMBruker::SetHighTension: failed to call SetSEMData method."));
  310. return FALSE;
  311. }
  312. // ok, return TRUE
  313. return TRUE;
  314. }
  315. // magnification
  316. BOOL COTSSEMBruker::GetMagnification(double& a_dMagnification)
  317. {
  318. // m_pBrukerImplPtr check
  319. ASSERT(m_pBrukerImplPtr);
  320. if (!m_pBrukerImplPtr)
  321. {
  322. LogErrorTrace(__FILE__, __LINE__, _T("COTSSEMBruker::GetMagnification: m_pBrukerImplPtr is invalid."));
  323. return FALSE;
  324. }
  325. // get mag, KV and working distance
  326. double dMagnification, dHighVoltage, dWorkingDistance;
  327. if (!m_pBrukerImplPtr->GetSEMData(dMagnification, dHighVoltage, dWorkingDistance))
  328. {
  329. // failed to call GetSEMData method
  330. LogErrorTrace(__FILE__, __LINE__, _T("COTSSEMBruker::GetMagnification: failed to call SetSEMData method."));
  331. return FALSE;
  332. }
  333. a_dMagnification = dMagnification;
  334. // ok, return TRUE
  335. return TRUE;
  336. }
  337. BOOL COTSSEMBruker::SetMagnification(double a_dMagnification)
  338. {
  339. // m_pBrukerImplPtr check
  340. ASSERT(m_pBrukerImplPtr);
  341. if (!m_pBrukerImplPtr)
  342. {
  343. LogErrorTrace(__FILE__, __LINE__, _T("COTSSEMBruker::SetMagnification: m_pBrukerImplPtr is invalid."));
  344. return FALSE;
  345. }
  346. // get current mag, KV and working distance
  347. double dMagnification, dHighVoltage, dWorkingDistance;
  348. if (!m_pBrukerImplPtr->GetSEMData(dMagnification, dHighVoltage, dWorkingDistance))
  349. {
  350. // failed to call GetSEMData method
  351. LogErrorTrace(__FILE__, __LINE__, _T("COTSSEMBruker::SetMagnification: failed to call GetSEMData method."));
  352. return FALSE;
  353. }
  354. // set mag, KV and working distance
  355. dMagnification = a_dMagnification;
  356. if (!m_pBrukerImplPtr->SetSEMData(dMagnification, dHighVoltage, dWorkingDistance))
  357. {
  358. // failed to call SetSEMData method
  359. LogErrorTrace(__FILE__, __LINE__, _T("COTSSEMBruker::SetMagnification: failed to call SetSEMData method."));
  360. return FALSE;
  361. }
  362. // ok, return TRUE
  363. return TRUE;
  364. }
  365. // scan field size
  366. BOOL COTSSEMBruker::GetScanFieldSize(double& a_dScanFieldSizeX, double& a_dScanFieldSizeY)
  367. {
  368. // get magnification
  369. double dMag = 0;
  370. if (!GetMagnification(dMag))
  371. {
  372. // failed to call GetMagnification method
  373. LogErrorTrace(__FILE__, __LINE__, _T("COTSSEMBruker::GetScanFieldSize: failed to call GetMagnification method."));
  374. return FALSE;
  375. }
  376. // calculate scan field size
  377. double dScanFieldSizeX, dScanFieldSizeY;
  378. if (!MagToScanFieldSize(dMag, dScanFieldSizeX, dScanFieldSizeY))
  379. {
  380. // failed to call MagToScanFieldSize method
  381. LogErrorTrace(__FILE__, __LINE__, _T("COTSSEMBruker::GetScanFieldSize: failed to call MagToScanFieldSize method."));
  382. return FALSE;
  383. }
  384. // calculate scan field size and set output values
  385. a_dScanFieldSizeX = dScanFieldSizeX;
  386. a_dScanFieldSizeY = dScanFieldSizeY;
  387. // ok, return TRUE
  388. return TRUE;
  389. }
  390. BOOL COTSSEMBruker::SetScanFieldSizeX(double a_dScanFieldSizeX)
  391. {
  392. // calculate magnification
  393. double dMag = 0;
  394. if (!ScanFieldSizeToMag(dMag, a_dScanFieldSizeX))
  395. {
  396. // failed to call ScanFieldSizeToMag method
  397. LogErrorTrace(__FILE__, __LINE__, _T("COTSSEMBruker::SetScanFieldSizeX: filed to call ScanFieldSizeToMag method."));
  398. return FALSE;
  399. }
  400. // set magnification
  401. if(!SetMagnification(dMag))
  402. {
  403. // failed to call ScanFieldSizeToMag method
  404. LogErrorTrace(__FILE__, __LINE__, _T("COTSSEMBruker::SetScanFieldSizeX: filed to call SetMagnification method."));
  405. return FALSE;
  406. }
  407. // ok, return TRUE
  408. return TRUE;
  409. }
  410. // high tension off
  411. // note: a_bHTValue is FALSE will turn HT off
  412. BOOL COTSSEMBruker::SetHTOnOff(BOOL a_bHTValue)
  413. {
  414. // m_pBrukerImplPtr check
  415. ASSERT(m_pBrukerImplPtr);
  416. if (!m_pBrukerImplPtr)
  417. {
  418. LogErrorTrace(__FILE__, __LINE__, _T("COTSSEMBruker::SetHTOnOff: m_pBrukerImplPtr is invalid."));
  419. return FALSE;
  420. }
  421. // turn HT off if a_bHTValue is FALSE
  422. if (!a_bHTValue)
  423. {
  424. if (!m_pBrukerImplPtr->SwitchSEMOff(TRUE, FALSE, FALSE))
  425. {
  426. // failed to call SwitchSEMOff method
  427. LogErrorTrace(__FILE__, __LINE__, _T("COTSSEMBruker::SetHTOnOff : failed to call SwitchSEMOff method."));
  428. return FALSE;
  429. }
  430. }
  431. // ok, return TRUE
  432. return TRUE;
  433. }
  434. // position
  435. BOOL COTSSEMBruker::GetPositionXY(double& a_dPositionX, double& a_dPositionY, double& a_dPositionR)
  436. {
  437. // m_pBrukerImplPtr check
  438. ASSERT(m_pBrukerImplPtr);
  439. if (!m_pBrukerImplPtr)
  440. {
  441. LogErrorTrace(__FILE__, __LINE__, _T("COTSSEMBruker::GetPositionXY: m_pBrukerImplPtr is invalid."));
  442. return FALSE;
  443. }
  444. // get position
  445. double dPositionX, dPositionY, dPositionZ, dTilt, dRotation;
  446. if (!m_pBrukerImplPtr->GetSEMStageData(dPositionX, dPositionY, dPositionZ, dTilt, dRotation))
  447. {
  448. // failed to call GetSEMStageData method
  449. LogErrorTrace(__FILE__, __LINE__, _T("COTSSEMBruker::GetPositionXY : failed to call GetSEMStageData method."));
  450. return FALSE;
  451. }
  452. // need to convert dPositionX, dPositionY from SEM position to OTS position
  453. // set output values
  454. a_dPositionX = dPositionX;
  455. a_dPositionY = dPositionY;
  456. a_dPositionR = dRotation;
  457. // ok, return TRUE
  458. return TRUE;
  459. }
  460. BOOL COTSSEMBruker::SetPositionXY(double a_dPositionX, double a_dPositionY, double a_dPositionR)
  461. {
  462. // m_pBrukerImplPtr check
  463. ASSERT(m_pBrukerImplPtr);
  464. if (!m_pBrukerImplPtr)
  465. {
  466. LogErrorTrace(__FILE__, __LINE__, _T("COTSSEMBruker::SetPositionXY: m_pBrukerImplPtr is invalid."));
  467. return FALSE;
  468. }
  469. // get position
  470. double dPositionX, dPositionY, dPositionZ, dTilt, dRotation;
  471. if (!m_pBrukerImplPtr->GetSEMStageData(dPositionX, dPositionY, dPositionZ, dTilt, dRotation))
  472. {
  473. // failed to call GetSEMStageData method
  474. LogErrorTrace(__FILE__, __LINE__, _T("COTSSEMBruker::SetPositionXY : failed to call GetSEMStageData method."));
  475. return FALSE;
  476. }
  477. // need to convert a_dPositionX, a_dPositionY from OTS position to SEM position
  478. // set position
  479. dPositionX = a_dPositionX;
  480. dPositionY = a_dPositionY;
  481. dRotation = a_dPositionR;
  482. LogTrace(__FILE__, __LINE__, _T("COTSSEMBruker::Start to SetPositionXY "));
  483. if (!m_pBrukerImplPtr->SetSEMStageData(dPositionX, dPositionY, dPositionZ, dTilt, dRotation))
  484. {
  485. // failed to call SetSEMStageData method
  486. LogErrorTrace(__FILE__, __LINE__, _T("COTSSEMBruker::SetPositionXY : failed to call SetSEMStageData method."));
  487. return FALSE;
  488. }
  489. LogTrace(__FILE__, __LINE__, _T("COTSSEMBruker::Finished SetPositionXY "));
  490. // ok, return TRUE
  491. return TRUE;
  492. }
  493. BOOL COTSSEMBruker::SetPositionXY(double a_dPositionX, double a_dPositionY)
  494. {
  495. // m_pBrukerImplPtr check
  496. ASSERT(m_pBrukerImplPtr);
  497. if (!m_pBrukerImplPtr)
  498. {
  499. LogErrorTrace(__FILE__, __LINE__, _T("COTSSEMBruker::SetPositionXY: m_pBrukerImplPtr is invalid."));
  500. return FALSE;
  501. }
  502. // get position
  503. double dPositionX, dPositionY, dPositionZ, dTilt, dRotation;
  504. if (!m_pBrukerImplPtr->GetSEMStageData(dPositionX, dPositionY, dPositionZ, dTilt, dRotation))
  505. {
  506. // failed to call GetSEMStageData method
  507. LogErrorTrace(__FILE__, __LINE__, _T("COTSSEMBruker::SetPositionXY : failed to call GetSEMStageData method."));
  508. return FALSE;
  509. }
  510. // need to convert a_dPositionX, a_dPositionY from OTS position to SEM position
  511. // set position
  512. dPositionX = a_dPositionX;
  513. dPositionY = a_dPositionY;
  514. //dRotation = a_dPositionR;
  515. LogTrace(__FILE__, __LINE__, _T("COTSSEMBruker::Start to SetPositionXY "));
  516. if (!m_pBrukerImplPtr->SetSEMStageData(dPositionX, dPositionY, dPositionZ, dTilt, dRotation))
  517. {
  518. // failed to call SetSEMStageData method
  519. LogErrorTrace(__FILE__, __LINE__, _T("COTSSEMBruker::SetPositionXY : failed to call SetSEMStageData method."));
  520. return FALSE;
  521. }
  522. LogTrace(__FILE__, __LINE__, _T("COTSSEMBruker::Finished SetPositionXY "));
  523. // ok, return TRUE
  524. return TRUE;
  525. }
  526. // spot size
  527. BOOL COTSSEMBruker::GetSpotSize(double& a_dSpotSize)
  528. {
  529. // m_pBrukerImplPtr check
  530. ASSERT(m_pBrukerImplPtr);
  531. if (!m_pBrukerImplPtr)
  532. {
  533. LogErrorTrace(__FILE__, __LINE__, _T("COTSSEMBruker::GetSpotSize: m_pBrukerImplPtr is invalid."));
  534. return FALSE;
  535. }
  536. // get spot size
  537. double dSpotSize;
  538. if (!m_pBrukerImplPtr->GetSEMSpotSize(dSpotSize))
  539. {
  540. // failed to call GetSEMSpotSize method
  541. LogErrorTrace(__FILE__, __LINE__, _T("COTSSEMBruker::GetSpotSize : failed to call GetSEMSpotSize method."));
  542. return FALSE;
  543. }
  544. a_dSpotSize = dSpotSize;
  545. // ok, return TRUE
  546. return TRUE;
  547. }
  548. BOOL COTSSEMBruker::SetSpotSize(double a_dSpotSize)
  549. {
  550. // m_pBrukerImplPtr check
  551. ASSERT(m_pBrukerImplPtr);
  552. if (!m_pBrukerImplPtr)
  553. {
  554. LogErrorTrace(__FILE__, __LINE__, _T("COTSSEMBruker::SetSpotSize: m_pBrukerImplPtr is invalid."));
  555. return FALSE;
  556. }
  557. // set spot size
  558. if (!m_pBrukerImplPtr->SetSEMSpotSize(a_dSpotSize))
  559. {
  560. // failed to call GetSEMSpotSize method
  561. LogErrorTrace(__FILE__, __LINE__, _T("COTSSEMBruker::SetSpotSize : failed to call SetSEMSpotSize method."));
  562. return FALSE;
  563. }
  564. // ok, return TRUE
  565. return TRUE;
  566. }
  567. // external mode
  568. BOOL COTSSEMBruker::SetScanExternal(BOOL a_bExternalOn)
  569. {
  570. // m_pBrukerImplPtr check
  571. ASSERT(m_pBrukerImplPtr);
  572. if (!m_pBrukerImplPtr)
  573. {
  574. LogErrorTrace(__FILE__, __LINE__, _T("COTSSEMBruker::SetScanExternal: m_pBrukerImplPtr is invalid."));
  575. return FALSE;
  576. }
  577. if (a_bExternalOn)
  578. {
  579. // turn external on
  580. if (!m_pBrukerImplPtr->SetSEMExternalOn())
  581. {
  582. // failed to call GetSEMSpotSize method
  583. LogErrorTrace(__FILE__, __LINE__, _T("COTSSEMBruker::SetScanExternal: failed to call SetSEMExternalOn method."));
  584. return FALSE;
  585. }
  586. }
  587. else
  588. {
  589. // turn external off
  590. if (!m_pBrukerImplPtr->SetSEMExternalOff())
  591. {
  592. // failed to call SetSEMExternalOff method
  593. LogErrorTrace(__FILE__, __LINE__, _T("COTSSEMBruker::SetScanExternal: failed to call SetSEMExternalOff method."));
  594. return FALSE;
  595. }
  596. }
  597. // ok, return TRUE
  598. return TRUE;
  599. }
  600. }