OTSSEMBruker.cpp 19 KB

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