OTSSEMBruker.cpp 19 KB

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