#include "stdafx.h" #include "OTSScanBrucker.h" #include "SEMCommonConst.h" namespace OTSController { // constructor COTSScanBrucker::COTSScanBrucker() : m_pBrukerImpl(nullptr) { m_pBrukerImpl = COTSBrukerImpl::GetInstance(); 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.")); } } // 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; } // 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; } // 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; } return TRUE; } }