#include "stdafx.h" #include "OTSSEMBruker.h" namespace OTSController { // constructor COTSSEMBruker::COTSSEMBruker() : m_bConnected(FALSE) { } // destructor COTSSEMBruker::~COTSSEMBruker() { } // check if connected // return true if setup success BOOL COTSSEMBruker::IsConnected() { return m_bConnected; } // connect client dll BOOL COTSSEMBruker::Connect() { // doing nothing if m_pBrukerImplPtr is not nullptr if (!m_pBrukerImplPtr) { // get bruker initialize controller m_pBrukerImplPtr = COTSBrukerImpl::GetInstance(); } // make sure m_pBrukerImplPtr is OK if (m_pBrukerImplPtr) { // initialize the bruker controller as a SEM controller LogTrace(__FILE__, __LINE__, _T("Init BrukerImpl...")); if (m_pBrukerImplPtr->Init(CONTROL_TYPE::BRUKER_SEM)) { // check connection if (!m_pBrukerImplPtr->CheckConnection(m_bConnected)) { LogErrorTrace(__FILE__, __LINE__, _T("COTSSEMBruker::Connect: failed to call CheckConnection.")); m_pBrukerImplPtr.reset(); m_bConnected = FALSE; return FALSE; } } // connection is ok? if (!m_bConnected) { // connection LogErrorTrace(__FILE__, __LINE__, _T("COTSSEMBruker::Connect(): connecting failed.")); m_pBrukerImplPtr.reset(); return FALSE; } } // ok, return TRUE return TRUE; } BOOL COTSSEMBruker::Disconnect() { if (m_bConnected) { m_pBrukerImplPtr->DisConnect(); m_bConnected = false; return true; } else { return true; } } // set beam blank BOOL COTSSEMBruker::SetBeamBlank(long a_nBeamBlank) { // m_pBrukerImplPtr check ASSERT(m_pBrukerImplPtr); if (!m_pBrukerImplPtr) { LogErrorTrace(__FILE__, __LINE__, _T("COTSSEMBruker::SetBeamBlank: m_pBrukerImplPtr is invalid.")); return FALSE; } // turn Bean off if a_nBeamBlank > 0 if (a_nBeamBlank > 0) { if (!m_pBrukerImplPtr->SwitchSEMOff(FALSE, FALSE, TRUE)) { // failed to call SwitchSEMOff method LogErrorTrace(__FILE__, __LINE__, _T("COTSSEMBruker::SetBeamBlank : failed to call SwitchSEMOff method.")); return FALSE; } } // ok, return TRUE return TRUE; } // set beam blank BOOL COTSSEMBruker::SetBeamCurrent(BOOL a_nBeamCurrent) { // m_pBrukerImplPtr check ASSERT(m_pBrukerImplPtr); if (!m_pBrukerImplPtr) { LogErrorTrace(__FILE__, __LINE__, _T("COTSSEMBruker::SetBeamBlank: m_pBrukerImplPtr is invalid.")); return FALSE; } // turn Bean off if a_nBeamBlank > 0 if (a_nBeamCurrent ) { if (!m_pBrukerImplPtr->SwitchSEMOff(FALSE,TRUE , FALSE)) { // failed to call SwitchSEMOff method LogErrorTrace(__FILE__, __LINE__, _T("COTSSEMBruker::SetBeamBlank : failed to call SwitchSEMOff method.")); return FALSE; } } // ok, return TRUE return TRUE; } // brightness BOOL COTSSEMBruker::GetBrightness(double& a_dBrightness) { // m_pBrukerImplPtr check ASSERT(m_pBrukerImplPtr); if (!m_pBrukerImplPtr) { LogErrorTrace(__FILE__, __LINE__, _T("COTSSEMBruker::GetBrightness: m_pBrukerImplPtr is invalid.")); return FALSE; } // get brightness and contrast double dBrightness, dContrast; if (!m_pBrukerImplPtr->GetSEMBCData(dBrightness, dContrast)) { // failed to call GetSEMBCData method LogErrorTrace(__FILE__, __LINE__, _T("COTSSEMBruker::GetBrightness: failed to call GetSEMBCData method.")); return FALSE; } a_dBrightness = dBrightness; // ok, return TRUE return TRUE; } BOOL COTSSEMBruker::SetBrightness(double a_dBrightness) { // m_pBrukerImplPtr check ASSERT(m_pBrukerImplPtr); if (!m_pBrukerImplPtr) { LogErrorTrace(__FILE__, __LINE__, _T("COTSSEMBruker::SetBrightness: m_pBrukerImplPtr is invalid.")); return FALSE; } // get current brightness and contrast double dBrightness, dContrast; if (!m_pBrukerImplPtr->GetSEMBCData(dBrightness, dContrast)) { // failed to call GetSEMBCData method LogErrorTrace(__FILE__, __LINE__, _T("COTSSEMBruker::SetBrightness: failed to call GetSEMBCData method.")); return FALSE; } // set brightness and contrast dBrightness = a_dBrightness; if (!m_pBrukerImplPtr->SetSEMBCData(dBrightness, dContrast)) { // failed to call GetSEMBCData method LogErrorTrace(__FILE__, __LINE__, _T("COTSSEMBruker::SetBrightness: failed to call SetSEMBCData method.")); return FALSE; } // ok, return TRUE return TRUE; } // contrast BOOL COTSSEMBruker::GetContrast(double& a_dContrast) { // m_pBrukerImplPtr check ASSERT(m_pBrukerImplPtr); if (!m_pBrukerImplPtr) { LogErrorTrace(__FILE__, __LINE__, _T("COTSSEMBruker::GetContrast: m_pBrukerImplPtr is invalid.")); return FALSE; } // get brightness and contrast double dBrightness, dContrast; if (!m_pBrukerImplPtr->GetSEMBCData(dBrightness, dContrast)) { // failed to call GetSEMBCData method LogErrorTrace(__FILE__, __LINE__, _T("COTSSEMBruker::GetContrast: failed to call GetSEMBCData method.")); return FALSE; } a_dContrast = dContrast; // ok, return TRUE return TRUE; } BOOL COTSSEMBruker::SetContrast(double a_dContrast) { // m_pBrukerImplPtr check ASSERT(m_pBrukerImplPtr); if (!m_pBrukerImplPtr) { LogErrorTrace(__FILE__, __LINE__, _T("COTSSEMBruker::SetContrast: m_pBrukerImplPtr is invalid.")); return FALSE; } // get current brightness and contrast double dBrightness, dContrast; if (!m_pBrukerImplPtr->GetSEMBCData(dBrightness, dContrast)) { // failed to call GetSEMBCData method LogErrorTrace(__FILE__, __LINE__, _T("COTSSEMBruker::SetContrast: failed to call GetSEMBCData method.")); return FALSE; } // set brightness and contrast dContrast = a_dContrast; if (!m_pBrukerImplPtr->SetSEMBCData(dBrightness, dContrast)) { // failed to call SetSEMBCData method LogErrorTrace(__FILE__, __LINE__, _T("COTSSEMBruker::SetContrast: failed to call SetSEMBCData method.")); return FALSE; } // ok, return TRUE return TRUE; } // working distance BOOL COTSSEMBruker::GetWorkingDistance(double& a_dWorkingDistance) { // m_pBrukerImplPtr check ASSERT(m_pBrukerImplPtr); if (!m_pBrukerImplPtr) { LogErrorTrace(__FILE__, __LINE__, _T("COTSSEMBruker::GetWorkingDistance: m_pBrukerImplPtr is invalid.")); return FALSE; } // get mag, KV and working distance double dMagnification, dHighVoltage, dWorkingDistance; if (!m_pBrukerImplPtr->GetSEMData(dMagnification, dHighVoltage, dWorkingDistance)) { // failed to call GetSEMData method LogErrorTrace(__FILE__, __LINE__, _T("COTSSEMBruker::GetWorkingDistance: failed to call SetSEMData method.")); return FALSE; } a_dWorkingDistance = dWorkingDistance; // ok, return TRUE return TRUE; } BOOL COTSSEMBruker::SetWorkingDistance(double a_dWorkingDistance) { // m_pBrukerImplPtr check ASSERT(m_pBrukerImplPtr); if (!m_pBrukerImplPtr) { LogErrorTrace(__FILE__, __LINE__, _T("COTSSEMBruker::SetWorkingDistance: m_pBrukerImplPtr is invalid.")); return FALSE; } // get current mag, KV and working distance double dMagnification, dHighVoltage, dWorkingDistance; if (!m_pBrukerImplPtr->GetSEMData(dMagnification, dHighVoltage, dWorkingDistance)) { // failed to call GetSEMData method LogErrorTrace(__FILE__, __LINE__, _T("COTSSEMBruker::SetWorkingDistance: failed to call GetSEMData method.")); return FALSE; } // set mag, KV and working distance dWorkingDistance = a_dWorkingDistance; if (!m_pBrukerImplPtr->SetSEMData(dMagnification, dHighVoltage, dWorkingDistance)) { // failed to call SetSEMData method LogErrorTrace(__FILE__, __LINE__, _T("COTSSEMBruker::SetWorkingDistance: failed to call SetSEMData method.")); return FALSE; } // ok, return TRUE return TRUE; } // high tension (KV) BOOL COTSSEMBruker::GetHighTension(double& a_dKV) { // m_pBrukerImplPtr check ASSERT(m_pBrukerImplPtr); if (!m_pBrukerImplPtr) { LogErrorTrace(__FILE__, __LINE__, _T("COTSSEMBruker::GetHighTension: m_pBrukerImplPtr is invalid.")); return FALSE; } // get mag, KV and working distance double dMagnification, dHighVoltage, dWorkingDistance; if (!m_pBrukerImplPtr->GetSEMData(dMagnification, dHighVoltage, dWorkingDistance)) { // failed to call GetSEMData method LogErrorTrace(__FILE__, __LINE__, _T("COTSSEMBruker::GetHighTension: failed to call SetSEMData method.")); return FALSE; } a_dKV = dHighVoltage; // ok, return TRUE return TRUE; } BOOL COTSSEMBruker::SetHighTension(double a_dKV) { // m_pBrukerImplPtr check ASSERT(m_pBrukerImplPtr); if (!m_pBrukerImplPtr) { LogErrorTrace(__FILE__, __LINE__, _T("COTSSEMBruker::SetHighTension: m_pBrukerImplPtr is invalid.")); return FALSE; } // get current mag, KV and working distance double dMagnification, dHighVoltage, dWorkingDistance; if (!m_pBrukerImplPtr->GetSEMData(dMagnification, dHighVoltage, dWorkingDistance)) { // failed to call GetSEMData method LogErrorTrace(__FILE__, __LINE__, _T("COTSSEMBruker::SetHighTension: failed to call GetSEMData method.")); return FALSE; } // set mag, KV and working distance dHighVoltage = a_dKV; if (!m_pBrukerImplPtr->SetSEMData(dMagnification, dHighVoltage, dWorkingDistance)) { // failed to call SetSEMData method LogErrorTrace(__FILE__, __LINE__, _T("COTSSEMBruker::SetHighTension: failed to call SetSEMData method.")); return FALSE; } // ok, return TRUE return TRUE; } // magnification BOOL COTSSEMBruker::GetMagnification(double& a_dMagnification) { // m_pBrukerImplPtr check ASSERT(m_pBrukerImplPtr); if (!m_pBrukerImplPtr) { LogErrorTrace(__FILE__, __LINE__, _T("COTSSEMBruker::GetMagnification: m_pBrukerImplPtr is invalid.")); return FALSE; } // get mag, KV and working distance double dMagnification, dHighVoltage, dWorkingDistance; if (!m_pBrukerImplPtr->GetSEMData(dMagnification, dHighVoltage, dWorkingDistance)) { // failed to call GetSEMData method LogErrorTrace(__FILE__, __LINE__, _T("COTSSEMBruker::GetMagnification: failed to call SetSEMData method.")); return FALSE; } a_dMagnification = dMagnification; // ok, return TRUE return TRUE; } BOOL COTSSEMBruker::SetMagnification(double a_dMagnification) { // m_pBrukerImplPtr check ASSERT(m_pBrukerImplPtr); if (!m_pBrukerImplPtr) { LogErrorTrace(__FILE__, __LINE__, _T("COTSSEMBruker::SetMagnification: m_pBrukerImplPtr is invalid.")); return FALSE; } // get current mag, KV and working distance double dMagnification, dHighVoltage, dWorkingDistance; if (!m_pBrukerImplPtr->GetSEMData(dMagnification, dHighVoltage, dWorkingDistance)) { // failed to call GetSEMData method LogErrorTrace(__FILE__, __LINE__, _T("COTSSEMBruker::SetMagnification: failed to call GetSEMData method.")); return FALSE; } // set mag, KV and working distance dMagnification = a_dMagnification; if (!m_pBrukerImplPtr->SetSEMData(dMagnification, dHighVoltage, dWorkingDistance)) { // failed to call SetSEMData method LogErrorTrace(__FILE__, __LINE__, _T("COTSSEMBruker::SetMagnification: failed to call SetSEMData method.")); return FALSE; } // ok, return TRUE return TRUE; } // scan field size BOOL COTSSEMBruker::GetScanFieldSize(double& a_dScanFieldSizeX, double& a_dScanFieldSizeY) { // get magnification double dMag = 0; if (!GetMagnification(dMag)) { // failed to call GetMagnification method LogErrorTrace(__FILE__, __LINE__, _T("COTSSEMBruker::GetScanFieldSize: failed to call GetMagnification method.")); return FALSE; } // calculate scan field size double dScanFieldSizeX, dScanFieldSizeY; if (!MagToScanFieldSize(dMag, dScanFieldSizeX, dScanFieldSizeY)) { // failed to call MagToScanFieldSize method LogErrorTrace(__FILE__, __LINE__, _T("COTSSEMBruker::GetScanFieldSize: failed to call MagToScanFieldSize method.")); return FALSE; } // calculate scan field size and set output values a_dScanFieldSizeX = dScanFieldSizeX; a_dScanFieldSizeY = dScanFieldSizeY; // ok, return TRUE return TRUE; } BOOL COTSSEMBruker::SetScanFieldSizeX(double a_dScanFieldSizeX) { // calculate magnification double dMag = 0; if (!ScanFieldSizeToMag(dMag, a_dScanFieldSizeX)) { // failed to call ScanFieldSizeToMag method LogErrorTrace(__FILE__, __LINE__, _T("COTSSEMBruker::SetScanFieldSizeX: filed to call ScanFieldSizeToMag method.")); return FALSE; } // set magnification if(!SetMagnification(dMag)) { // failed to call ScanFieldSizeToMag method LogErrorTrace(__FILE__, __LINE__, _T("COTSSEMBruker::SetScanFieldSizeX: filed to call SetMagnification method.")); return FALSE; } // ok, return TRUE return TRUE; } // high tension off // note: a_bHTValue is FALSE will turn HT off BOOL COTSSEMBruker::SetHTOnOff(BOOL a_bHTValue) { // m_pBrukerImplPtr check ASSERT(m_pBrukerImplPtr); if (!m_pBrukerImplPtr) { LogErrorTrace(__FILE__, __LINE__, _T("COTSSEMBruker::SetHTOnOff: m_pBrukerImplPtr is invalid.")); return FALSE; } // turn HT off if a_bHTValue is FALSE if (!a_bHTValue) { if (!m_pBrukerImplPtr->SwitchSEMOff(TRUE, FALSE, FALSE)) { // failed to call SwitchSEMOff method LogErrorTrace(__FILE__, __LINE__, _T("COTSSEMBruker::SetHTOnOff : failed to call SwitchSEMOff method.")); return FALSE; } } // ok, return TRUE return TRUE; } // position BOOL COTSSEMBruker::GetPositionXY(double& a_dPositionX, double& a_dPositionY, double& a_dPositionR) { // m_pBrukerImplPtr check ASSERT(m_pBrukerImplPtr); if (!m_pBrukerImplPtr) { LogErrorTrace(__FILE__, __LINE__, _T("COTSSEMBruker::GetPositionXY: m_pBrukerImplPtr is invalid.")); return FALSE; } // get position double dPositionX, dPositionY, dPositionZ, dTilt, dRotation; if (!m_pBrukerImplPtr->GetSEMStageData(dPositionX, dPositionY, dPositionZ, dTilt, dRotation)) { // failed to call GetSEMStageData method LogErrorTrace(__FILE__, __LINE__, _T("COTSSEMBruker::GetPositionXY : failed to call GetSEMStageData method.")); return FALSE; } // need to convert dPositionX, dPositionY from SEM position to OTS position // set output values a_dPositionX = dPositionX; a_dPositionY = dPositionY; a_dPositionR = dRotation; // ok, return TRUE return TRUE; } BOOL COTSSEMBruker::SetPositionXY(double a_dPositionX, double a_dPositionY, double a_dPositionR) { // m_pBrukerImplPtr check ASSERT(m_pBrukerImplPtr); if (!m_pBrukerImplPtr) { LogErrorTrace(__FILE__, __LINE__, _T("COTSSEMBruker::SetPositionXY: m_pBrukerImplPtr is invalid.")); return FALSE; } // get position double dPositionX, dPositionY, dPositionZ, dTilt, dRotation; if (!m_pBrukerImplPtr->GetSEMStageData(dPositionX, dPositionY, dPositionZ, dTilt, dRotation)) { // failed to call GetSEMStageData method LogErrorTrace(__FILE__, __LINE__, _T("COTSSEMBruker::SetPositionXY : failed to call GetSEMStageData method.")); return FALSE; } // need to convert a_dPositionX, a_dPositionY from OTS position to SEM position // set position dPositionX = a_dPositionX; dPositionY = a_dPositionY; dRotation = a_dPositionR; LogTrace(__FILE__, __LINE__, _T("COTSSEMBruker::Start to SetPositionXY ")); if (!m_pBrukerImplPtr->SetSEMStageData(dPositionX, dPositionY, dPositionZ, dTilt, dRotation)) { // failed to call SetSEMStageData method LogErrorTrace(__FILE__, __LINE__, _T("COTSSEMBruker::SetPositionXY : failed to call SetSEMStageData method.")); return FALSE; } LogTrace(__FILE__, __LINE__, _T("COTSSEMBruker::Finished SetPositionXY ")); // ok, return TRUE return TRUE; } BOOL COTSSEMBruker::SetPositionXY(double a_dPositionX, double a_dPositionY) { // m_pBrukerImplPtr check ASSERT(m_pBrukerImplPtr); if (!m_pBrukerImplPtr) { LogErrorTrace(__FILE__, __LINE__, _T("COTSSEMBruker::SetPositionXY: m_pBrukerImplPtr is invalid.")); return FALSE; } // get position double dPositionX, dPositionY, dPositionZ, dTilt, dRotation; if (!m_pBrukerImplPtr->GetSEMStageData(dPositionX, dPositionY, dPositionZ, dTilt, dRotation)) { // failed to call GetSEMStageData method LogErrorTrace(__FILE__, __LINE__, _T("COTSSEMBruker::SetPositionXY : failed to call GetSEMStageData method.")); return FALSE; } // need to convert a_dPositionX, a_dPositionY from OTS position to SEM position // set position dPositionX = a_dPositionX; dPositionY = a_dPositionY; //dRotation = a_dPositionR; LogTrace(__FILE__, __LINE__, _T("COTSSEMBruker::Start to SetPositionXY ")); if (!m_pBrukerImplPtr->SetSEMStageData(dPositionX, dPositionY, dPositionZ, dTilt, dRotation)) { // failed to call SetSEMStageData method LogErrorTrace(__FILE__, __LINE__, _T("COTSSEMBruker::SetPositionXY : failed to call SetSEMStageData method.")); return FALSE; } LogTrace(__FILE__, __LINE__, _T("COTSSEMBruker::Finished SetPositionXY ")); // ok, return TRUE return TRUE; } // spot size BOOL COTSSEMBruker::GetSpotSize(double& a_dSpotSize) { // m_pBrukerImplPtr check ASSERT(m_pBrukerImplPtr); if (!m_pBrukerImplPtr) { LogErrorTrace(__FILE__, __LINE__, _T("COTSSEMBruker::GetSpotSize: m_pBrukerImplPtr is invalid.")); return FALSE; } // get spot size double dSpotSize; if (!m_pBrukerImplPtr->GetSEMSpotSize(dSpotSize)) { // failed to call GetSEMSpotSize method LogErrorTrace(__FILE__, __LINE__, _T("COTSSEMBruker::GetSpotSize : failed to call GetSEMSpotSize method.")); return FALSE; } a_dSpotSize = dSpotSize; // ok, return TRUE return TRUE; } BOOL COTSSEMBruker::SetSpotSize(double a_dSpotSize) { // m_pBrukerImplPtr check ASSERT(m_pBrukerImplPtr); if (!m_pBrukerImplPtr) { LogErrorTrace(__FILE__, __LINE__, _T("COTSSEMBruker::SetSpotSize: m_pBrukerImplPtr is invalid.")); return FALSE; } // set spot size if (!m_pBrukerImplPtr->SetSEMSpotSize(a_dSpotSize)) { // failed to call GetSEMSpotSize method LogErrorTrace(__FILE__, __LINE__, _T("COTSSEMBruker::SetSpotSize : failed to call SetSEMSpotSize method.")); return FALSE; } // ok, return TRUE return TRUE; } // external mode BOOL COTSSEMBruker::SetScanExternal(BOOL a_bExternalOn) { // m_pBrukerImplPtr check ASSERT(m_pBrukerImplPtr); if (!m_pBrukerImplPtr) { LogErrorTrace(__FILE__, __LINE__, _T("COTSSEMBruker::SetScanExternal: m_pBrukerImplPtr is invalid.")); return FALSE; } if (a_bExternalOn) { // turn external on if (!m_pBrukerImplPtr->SetSEMExternalOn()) { // failed to call GetSEMSpotSize method LogErrorTrace(__FILE__, __LINE__, _T("COTSSEMBruker::SetScanExternal: failed to call SetSEMExternalOn method.")); return FALSE; } } else { // turn external off if (!m_pBrukerImplPtr->SetSEMExternalOff()) { // failed to call SetSEMExternalOff method LogErrorTrace(__FILE__, __LINE__, _T("COTSSEMBruker::SetScanExternal: failed to call SetSEMExternalOff method.")); return FALSE; } } // ok, return TRUE return TRUE; } }