OTSScanBrucker.cpp 4.6 KB

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