123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289 |
- #include "stdafx.h"
- #include "OTSScanBrucker.h"
- #include "SEMCommonConst.h"
- namespace OTSController {
- // constructor
- COTSScanBrucker::COTSScanBrucker()
- : m_pBrukerImpl(nullptr)
- {
- }
- // destructor
- COTSScanBrucker::~COTSScanBrucker(void)
- {
- }
- // initialization
- BOOL COTSScanBrucker::Init()
- {
- // create bruker initialize controller
- if (!m_pBrukerImpl)
- {
- // get bruker controller
- m_pBrukerImpl = COTSBrukerImpl::GetInstance();
- }
- // initialize bruker scanner controller
- ASSERT(m_pBrukerImpl);
- if (!m_pBrukerImpl)
- {
- // failed to create bruker controller
- LogErrorTrace(__FILE__, __LINE__, _T("COTSScanBrucker::Init: failed to create bruker controller."));
- return FALSE;
- }
- // initialize bruker controller (as scanner)
- if (!m_pBrukerImpl->Init(CONTROL_TYPE::BRUKER_SCAN))
- {
- // failed to call bruker controller init method
- LogErrorTrace(__FILE__, __LINE__, _T("COTSScanBrucker::Init: failed to failed to call bruker controller init method."));
- return FALSE;
- }
- // ok, return TRUE
- return TRUE;
- }
- // get the size of matrix.
- CSize COTSScanBrucker::GetMatrixSize(int /*a_nMatrixIndex*/)
- {
- // check bruker controller
- ASSERT(m_pBrukerImpl);
- if (!m_pBrukerImpl)
- {
- // invalid m_pBrukerImpl
- LogErrorTrace(__FILE__, __LINE__, _T("COTSScanBrucker::GetMatrixSize: invalid m_pBrukerImpl."));
- return CSize(0);
- }
- // Just return the a size based on the image size that has previously been set.
- // This is an artifact the interface being based on the edax model, but not catering
- // to bruker that keeps state internally.
- // Return the size based on the height that was set - we stretch the image horizontally
- // but by the time we return it the image is square.
- DWORD nWidth = 0;
- DWORD nHeight = 0;
- DWORD nAverage;
- BYTE bCh1;
- BYTE bCh2;
- if (!m_pBrukerImpl->ImageGetConfiguration(nWidth, nHeight, nAverage, bCh1, bCh2))
- {
- // failed to call ImageGetConfiguration method
- LogErrorTrace(__FILE__, __LINE__, _T("COTSScanBrucker::GetMatrixSize: failed to call ImageGetConfiguration method"));
- return CSize(0);
- }
- // return
- return CSize(nWidth, nHeight);
- }
- // acquire BSE image
- CBSEImgPtr COTSScanBrucker::AcquireBSEImage()
- {
- // BSE image
- CBSEImgPtr poBSEImgPtr = nullptr;
- // check bruker controller
- ASSERT(m_pBrukerImpl);
- if (!m_pBrukerImpl)
- {
- // invalid m_pBrukerImpl
- LogErrorTrace(__FILE__, __LINE__, _T("COTSScanBrucker::AcquireBSEImage: invalid m_pBrukerImpl."));
- return poBSEImgPtr;
- }
- // acquire BSE image
- poBSEImgPtr = m_pBrukerImpl->AcquireImage();
- // check acquired image
- ASSERT(poBSEImgPtr);
- if (!poBSEImgPtr)
- {
- // failed to load simulation image
- LogErrorTrace(__FILE__, __LINE__, _T("COTSScanBrucker::AcquireBSEImage: failed to acquire image"));
- }
- // return acquired image, nullptr if acquire image failed
- return poBSEImgPtr;
- }
- // move beam to point
- BOOL COTSScanBrucker::MoveBeamTo(CPoint& a_beamPos)
- {
- // check bruker controller
- ASSERT(m_pBrukerImpl);
- if (!m_pBrukerImpl)
- {
- // invalid m_pBrukerImpl
- LogErrorTrace(__FILE__, __LINE__, _T("COTSScanBrucker::MoveBeamTo: invalid m_pBrukerImpl."));
- return FALSE;
- }
- // move beam to point
- if (!m_pBrukerImpl->ImageSetPoint(a_beamPos))
- {
- // failed to call ImageSetPoint method
- LogErrorTrace(__FILE__, __LINE__, _T("COTSScanBrucker::MoveBeamTo: failed to call ImageSetPoint method."));
- return FALSE;
- }
- // ok, return TRUE
- return TRUE;
- }
- // start scan table
- BOOL COTSScanBrucker::StartScanTable(int /*a_nMatrixIndex*/, unsigned int /*nP*/, int* /*px*/, int* /*py*/)
- {
- return TRUE;
- }
- // set image size
- BOOL COTSScanBrucker::SetImageSize(long a_nImageSizeX,long a_Height)
- {
- // check bruker controller
- ASSERT(m_pBrukerImpl);
- if (!m_pBrukerImpl)
- {
- // invalid m_pBrukerImpl
- LogErrorTrace(__FILE__, __LINE__, _T("COTSScanBrucker::SetImageSize: invalid m_pBrukerImpl."));
- return FALSE;
- }
- // call ImageGetConfiguration to get the existing dimensions, dwell time and enabled channels
- DWORD nWidth = 0;
- DWORD nHeight = 0;
- DWORD nAverage;
- BYTE bCh1;
- BYTE bCh2;
- if (!m_pBrukerImpl->ImageGetConfiguration(nWidth, nHeight, nAverage, bCh1, bCh2))
- {
- // failed to call ImageGetConfiguration method
- LogErrorTrace(__FILE__, __LINE__, _T("COTSScanBrucker::SetImageSize: failed to call ImageGetConfiguration method."));
- return FALSE;
- }
- // set image size
- nWidth = a_nImageSizeX;
- nHeight = a_Height;
- if (!m_pBrukerImpl->ImageSetConfiguration(nWidth, nHeight, nAverage, bCh1, bCh2))
- {
- // failed to call ImageGetConfiguration method
- LogErrorTrace(__FILE__, __LINE__, _T("COTSScanBrucker::SetImageSize: failed to call ImageSetConfiguration method."));
- return FALSE;
- }
- // ok, return TRUE
- return TRUE;
- }
- // set dwell time
- BOOL COTSScanBrucker::SetDwellTime(long a_nDwellTime)
- {
- // check bruker controller
- ASSERT(m_pBrukerImpl);
- if (!m_pBrukerImpl)
- {
- // invalid m_pBrukerImpl
- LogErrorTrace(__FILE__, __LINE__, _T("COTSScanBrucker::SetDwellTime: invalid m_pBrukerImpl."));
- return FALSE;
- }
- // call ImageGetConfiguration to get the existing dimensions, dwell time and enabled channels
- DWORD nWidth = 0;
- DWORD nHeight = 0;
- DWORD nAverage;
- BYTE bCh1;
- BYTE bCh2;
- if (!m_pBrukerImpl->ImageGetConfiguration(nWidth, nHeight, nAverage, bCh1, bCh2))
- {
- // failed to call ImageGetConfiguration method
- LogErrorTrace(__FILE__, __LINE__, _T("COTSScanBrucker::SetDwellTime: failed to call ImageGetConfiguration method."));
- return FALSE;
- }
- // set dwell time
- nAverage = (DWORD)a_nDwellTime;
- if(!m_pBrukerImpl->ImageSetConfiguration(nWidth, nHeight, nAverage, bCh1, bCh2))
- {
- // failed to call ImageSetConfiguration method
- LogErrorTrace(__FILE__, __LINE__, _T("COTSScanBrucker::SetDwellTime: failed to call ImageSetConfiguration method."));
- return FALSE;
- }
- // ok, return TRUE
- return TRUE;
- }
-
- // get dwell time by index
- long COTSScanBrucker::GetDwellTimeByIndex(const long a_nIndex)
- {
- // check index
- if (a_nIndex < DWELLTIME_BRUKER_ID_MIN || a_nIndex > DWELLTIME_BRUKER_ID_MAX)
- {
- // invalid index
- ASSERT(FALSE);
- LogInfoTrace(__FILE__, __LINE__, _T("COTSScanBrucker::GetDwellTimeByIndex: invalid index"));
- return -1;
- }
- // get dwell time by index
- long nDwellTime = DWELLTIME_BRUKER_VALUES[a_nIndex];
- return nDwellTime;
- }
- // set dwell time by index
- BOOL COTSScanBrucker::SetDwellTimeByIndex(const long a_nIndex)
- {
- // check index
- if (a_nIndex < DWELLTIME_BRUKER_ID_MIN || a_nIndex > DWELLTIME_BRUKER_ID_MIN)
- {
- // invalid index
- ASSERT(FALSE);
- LogInfoTrace(__FILE__, __LINE__, _T("COTSScanBrucker::SetDwellTimeByIndex: invalid index"));
- return FALSE;
- }
- // get dwell time
- long nDwellTime = DWELLTIME_BRUKER_VALUES[a_nIndex];
- if (!SetDwellTime(nDwellTime))
- {
- // failed to call SetDwellTime method
- LogErrorTrace(__FILE__, __LINE__, _T("COTSScanBrucker::SetDwellTimeByIndex: failed to call SetDwellTime method."));
- return FALSE;
- }
- // ok, return TRUE
- return TRUE;
- }
- // scan field size
- BOOL COTSScanBrucker::SetScanFieldSize(const int a_nWidth, const int a_nHeight)
- {
- m_nScanFieldSizeX = a_nWidth;
- m_nScanFieldSizeY = a_nHeight;
- return TRUE;
- }
- // set the SEM position
- BOOL COTSScanBrucker::SetEMPosition(const int a_nPosX, const int a_nPosY)
- {
- m_nCurrentBSEPositionX = a_nPosX;
- m_nCurrentBSEPositionY = a_nPosY;
- return TRUE;
- }
- }
|