OTSScanBrucker.cpp 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192
  1. #include "stdafx.h"
  2. #include "OTSScanBrucker.h"
  3. #include "SEMCommonConst.h"
  4. namespace OTSController {
  5. // constructor
  6. COTSScanBrucker::COTSScanBrucker()
  7. : m_pBrukerImpl(nullptr)
  8. {
  9. Init();
  10. }
  11. // destructor
  12. COTSScanBrucker::~COTSScanBrucker(void)
  13. {
  14. }
  15. // initialization
  16. BOOL COTSScanBrucker::Init()
  17. {
  18. // create bruker initialize controller
  19. if (!m_pBrukerImpl)
  20. {
  21. // get bruker controller
  22. m_pBrukerImpl = COTSBrukerImpl::GetInstance();
  23. }
  24. // initialize bruker scanner controller
  25. ASSERT(m_pBrukerImpl);
  26. if (!m_pBrukerImpl)
  27. {
  28. // failed to create bruker controller
  29. LogErrorTrace(__FILE__, __LINE__, _T("COTSScanBrucker::Init: failed to create bruker controller."));
  30. return FALSE;
  31. }
  32. // initialize bruker controller (as scanner)
  33. if (!m_pBrukerImpl->Init(CONTROL_TYPE::BRUKER_SCAN))
  34. {
  35. // failed to call bruker controller init method
  36. LogErrorTrace(__FILE__, __LINE__, _T("COTSScanBrucker::Init: failed to failed to call bruker controller init method."));
  37. return FALSE;
  38. }
  39. // ok, return TRUE
  40. return TRUE;
  41. }
  42. // acquire BSE image
  43. CBSEImgPtr COTSScanBrucker::AcquireBSEImage()
  44. {
  45. // BSE image
  46. CBSEImgPtr poBSEImgPtr = nullptr;
  47. // check bruker controller
  48. ASSERT(m_pBrukerImpl);
  49. if (!m_pBrukerImpl)
  50. {
  51. // invalid m_pBrukerImpl
  52. LogErrorTrace(__FILE__, __LINE__, _T("COTSScanBrucker::AcquireBSEImage: invalid m_pBrukerImpl."));
  53. return poBSEImgPtr;
  54. }
  55. // acquire BSE image
  56. poBSEImgPtr = m_pBrukerImpl->AcquireImage();
  57. // check acquired image
  58. ASSERT(poBSEImgPtr);
  59. if (!poBSEImgPtr)
  60. {
  61. // failed to load simulation image
  62. LogErrorTrace(__FILE__, __LINE__, _T("COTSScanBrucker::AcquireBSEImage: failed to acquire image"));
  63. }
  64. // return acquired image, nullptr if acquire image failed
  65. return poBSEImgPtr;
  66. }
  67. // move beam to point
  68. BOOL COTSScanBrucker::MoveBeamTo(CPoint& a_beamPos)
  69. {
  70. // check bruker controller
  71. ASSERT(m_pBrukerImpl);
  72. if (!m_pBrukerImpl)
  73. {
  74. // invalid m_pBrukerImpl
  75. LogErrorTrace(__FILE__, __LINE__, _T("COTSScanBrucker::MoveBeamTo: invalid m_pBrukerImpl."));
  76. return FALSE;
  77. }
  78. // move beam to point
  79. if (!m_pBrukerImpl->ImageSetPoint(a_beamPos))
  80. {
  81. // failed to call ImageSetPoint method
  82. LogErrorTrace(__FILE__, __LINE__, _T("COTSScanBrucker::MoveBeamTo: failed to call ImageSetPoint method."));
  83. return FALSE;
  84. }
  85. // ok, return TRUE
  86. return TRUE;
  87. }
  88. // set image size
  89. BOOL COTSScanBrucker::SetImageSize(long a_nImageSizeX,long a_Height)
  90. {
  91. // check bruker controller
  92. ASSERT(m_pBrukerImpl);
  93. if (!m_pBrukerImpl)
  94. {
  95. // invalid m_pBrukerImpl
  96. LogErrorTrace(__FILE__, __LINE__, _T("COTSScanBrucker::SetImageSize: invalid m_pBrukerImpl."));
  97. return FALSE;
  98. }
  99. // call ImageGetConfiguration to get the existing dimensions, dwell time and enabled channels
  100. DWORD nWidth = 0;
  101. DWORD nHeight = 0;
  102. DWORD nAverage;
  103. BYTE bCh1;
  104. BYTE bCh2;
  105. if (!m_pBrukerImpl->ImageGetConfiguration(nWidth, nHeight, nAverage, bCh1, bCh2))
  106. {
  107. // failed to call ImageGetConfiguration method
  108. LogErrorTrace(__FILE__, __LINE__, _T("COTSScanBrucker::SetImageSize: failed to call ImageGetConfiguration method."));
  109. return FALSE;
  110. }
  111. // set image size
  112. nWidth = a_nImageSizeX;
  113. nHeight = a_Height;
  114. if (!m_pBrukerImpl->ImageSetConfiguration(nWidth, nHeight, nAverage, bCh1, bCh2))
  115. {
  116. // failed to call ImageGetConfiguration method
  117. LogErrorTrace(__FILE__, __LINE__, _T("COTSScanBrucker::SetImageSize: failed to call ImageSetConfiguration method."));
  118. return FALSE;
  119. }
  120. // ok, return TRUE
  121. return TRUE;
  122. }
  123. // set dwell time
  124. BOOL COTSScanBrucker::SetDwellTime(long a_nDwellTime)
  125. {
  126. // check bruker controller
  127. ASSERT(m_pBrukerImpl);
  128. if (!m_pBrukerImpl)
  129. {
  130. // invalid m_pBrukerImpl
  131. LogErrorTrace(__FILE__, __LINE__, _T("COTSScanBrucker::SetDwellTime: invalid m_pBrukerImpl."));
  132. return FALSE;
  133. }
  134. // call ImageGetConfiguration to get the existing dimensions, dwell time and enabled channels
  135. DWORD nWidth = 0;
  136. DWORD nHeight = 0;
  137. DWORD nAverage;
  138. BYTE bCh1;
  139. BYTE bCh2;
  140. if (!m_pBrukerImpl->ImageGetConfiguration(nWidth, nHeight, nAverage, bCh1, bCh2))
  141. {
  142. // failed to call ImageGetConfiguration method
  143. LogErrorTrace(__FILE__, __LINE__, _T("COTSScanBrucker::SetDwellTime: failed to call ImageGetConfiguration method."));
  144. return FALSE;
  145. }
  146. // set dwell time
  147. nAverage = (DWORD)a_nDwellTime;
  148. if(!m_pBrukerImpl->ImageSetConfiguration(nWidth, nHeight, nAverage, bCh1, bCh2))
  149. {
  150. // failed to call ImageSetConfiguration method
  151. LogErrorTrace(__FILE__, __LINE__, _T("COTSScanBrucker::SetDwellTime: failed to call ImageSetConfiguration method."));
  152. return FALSE;
  153. }
  154. return TRUE;
  155. }
  156. }