#pragma once #include "BSEImg.h" #include "OTSSemBase.h" #include "OTSScanBase.h" #include "OTSEDSBase.h" #include "Bruker/OTSBrukerImpl_const.h" #include #include #include using namespace System; using namespace System::Drawing; using namespace System::Collections::Generic; using namespace OTSController; namespace OTSCLRINTERFACE { public ref class COTSControlFunExport { public: static COTSControlFunExport^ GetControllerInstance(String^ deviceType) { if (theInstance == nullptr) { theInstance = gcnew COTSControlFunExport(deviceType); } return theInstance; } ~COTSControlFunExport() { } !COTSControlFunExport() { } //和电镜建立通讯连接 bool ConncetSem(); bool DisconnectSem(); bool IsConnected(); // 初始化 bool ScanInit() { bool bRet = m_pScan->Init(); return bRet; } //EDS初始化 //函数名称:bool EDSInit() //输入参数:无 //输出参数:类型:bool,true,设备申请成功 // false,设备申请失败 bool EDSInit() { bool bRet = m_pEDS->Init(); return bRet; } //获取当前电镜的ID号 int GetSemType() { int ID = 0; ID = (int)m_pSem->GetType(); return ID; } bool GetSemBeamBlank(long% a_nBeamBlank) { long lBBlank = 0; BOOL bRev = m_pSem->GetBeamBlank(lBBlank); a_nBeamBlank = lBBlank; return bRev; } bool SetSemBeamBlank(bool a_nBeamBlank) { BOOL bRev = m_pSem->SetBeamBlank(a_nBeamBlank); return bRev; } bool SetSemBeamCurrent(bool a_nBeamCurrent) { bool bRev = true; bRev = m_pSem->SetBeamBlank(a_nBeamCurrent); return bRev; } //获得亮度 bool GetSemBrightness(double% a_dBrightness) { double dBriness = 0; BOOL bRev = m_pSem->GetBrightness(dBriness); a_dBrightness = dBriness; return bRev; } //设置亮度 bool SetSemBrightness(double a_dBrightness) { BOOL bRev = m_pSem->SetBrightness(a_dBrightness); return bRev; } //获得对比度 bool GetSemContrast(double% a_dContrast) { double dContrast = 0; BOOL bRev = m_pSem->GetContrast(dContrast); a_dContrast = dContrast; return bRev; } //设置对比度 bool SetSemContrast(double a_dContrast) { BOOL bRev = m_pSem->SetContrast(a_dContrast); return bRev; } //获得Z轴的工作距离 bool GetSemWorkingDistance(double% a_dWorkingDistance) { double dWDistance = 0; BOOL bRev = m_pSem->GetWorkingDistance(dWDistance); a_dWorkingDistance = dWDistance; return bRev; } // 设置Z轴工作距离 bool SetSemWorkingDistance(double a_dWorkingDistance) { BOOL bRev = m_pSem->SetWorkingDistance(a_dWorkingDistance); return bRev; } // 获得电压值 bool GetSemHighTension(double% a_dKV) { double dDKV = 0; BOOL bRev = m_pSem->GetHighTension(dDKV); a_dKV = dDKV; return bRev; } // 设置电压值 bool SetSemHighTension(double a_dKV) { BOOL bRev = m_pSem->SetHighTension(a_dKV); return bRev; } //获得放大倍数 bool GetSemMagnification(double% a_dMagnification) { double dMagni = 0; BOOL bRev = m_pSem->GetMagnification(dMagni); a_dMagnification = dMagni; return bRev; } //设置放大倍数 bool SetSemMagnification(double a_dMagnification) { BOOL bRev = m_pSem->SetMagnification(a_dMagnification); return bRev; } //获得扫描区域尺寸 bool GetSemScanFieldSize(double% a_dScanFieldSizeX, double% a_dScanFieldSizeY) { double dFSizeX = 0; double dFSizeY = 0; BOOL bRev = m_pSem->GetScanFieldSize(dFSizeX, dFSizeY); a_dScanFieldSizeX = dFSizeX; a_dScanFieldSizeY = dFSizeY; return bRev; } //设置扫描区域尺寸 bool SetSemScanFieldSizeX(double a_dScanFieldSizeX) { BOOL bRev = m_pSem->SetScanFieldSizeX(a_dScanFieldSizeX); return bRev; } bool GetSemHTOnOff(bool% a_bHTValue) { BOOL bHTV = FALSE; BOOL bRev = m_pSem->GetHTOnOff(bHTV); a_bHTValue = bHTV; return bRev; } bool SetSemHTOnOff(bool a_bHTValue) { bool bRev = m_pSem->SetHTOnOff(a_bHTValue); return bRev; } //获得电镜位置 bool GetSemPositionXY(double% a_dPositionX, double% a_dPositionY, double% a_dPositionR) { double dPosX = 0; double dPosY = 0; double dPosR = 0; BOOL bRev = m_pSem->GetPositionXY(dPosX, dPosY, dPosR); a_dPositionX = dPosX; a_dPositionY = dPosY; a_dPositionR = dPosR; return bRev; } //设置电镜位置 bool SetSemPositionXY(double a_dPositionX, double a_dPositionY, double a_dPositionR) { BOOL bRev = m_pSem->SetPositionXY(a_dPositionX, a_dPositionY, a_dPositionR); return bRev; } bool SetSemPositionXY(double a_dPositionX, double a_dPositionY) { BOOL bRev = m_pSem->SetPositionXY(a_dPositionX, a_dPositionY); return bRev; } //获得焦点尺寸 bool GetSemSpotSize(double% a_dSpotSize) { double dPSize = 0; BOOL bRev = m_pSem->GetSpotSize(dPSize); a_dSpotSize = dPSize; return bRev; } //设置焦点尺寸 bool SetSemSpotSize(double a_dSpotSize) { BOOL bRev = m_pSem->SetSpotSize(a_dSpotSize); return bRev; } bool SetSemScanExternal(bool external) { bool bRev = false; try { bRev = m_pSem->SetScanExternal(external); } catch (const std::exception&) { bRev = false; } return bRev; } int GetSemExternalMode() { BOOL bRev = m_pSem->GetExternalMode(); return bRev; } //移动电镜到指定的位置 bool MoveSEMToPoint(double dPosX, double dPosY, double dRotation) { //double dRota = dRotation; CPoint cPos; cPos.x = (LONG)dPosX; cPos.y = (LONG)dPosY; bool bRev = m_pSem->MoveSEMToPoint(cPos, dRotation); return bRev; } //移动电镜到指定的位置 bool MoveSEMToPoint(double dPosX, double dPosY) { double dRotation; CPoint cPos; cPos.x = (LONG)dPosX; cPos.y = (LONG)dPosY; bool bRev = m_pSem->MoveSEMToPoint(cPos, dRotation); return bRev; } //获取EDS类型,Bruker是3. //函数名称:int EDSGetType() //输入参数:无 //输出参数:类型:int,设备ID标识 int EDSGetType() { int a_type=(int)m_pEDS->GetType(); return a_type; } bool CollectSpectrum(unsigned long a_nMilliseconds, Point a_oPoint, cli::array^% a_XrayData); bool CollectSpectrum(unsigned long a_nMilliseconds, cli::array^% a_XrayData, unsigned long a_nBufferSize); bool CollectSpectrum(unsigned long a_nMilliseconds, cli::array^% a_XrayData); bool GetXRayByPoints(unsigned long a_nMilliseconds, cli::array^% a_XrayData, bool bQuant); bool GetXRayByPoints(unsigned long a_nMilliseconds, cli::array^ points, cli::array^ parts, bool bQuant); bool QuantifyXrayByParts(cli::array^ parts); bool QuantifyXrayByPart(COTSParticleClr^ part); bool GetXRayBySinglePoint(unsigned long a_nMilliseconds, Point point, cli::array^% a_XrayData, String^% a_strEleResult, bool bQuant); bool GetXRayByFeatures(unsigned long a_nMilliseconds, cli::array^ feas,cli::array^>^% a_XrayData, cli::array^% a_strEleResult, bool bQuant); bool GetXRayByFeatures(unsigned long a_nMilliseconds, cli::array^ parts, bool bQuant); bool GetXRayBySingleFeature(unsigned long a_nMilliseconds, COTSFeatureClr^ feature, cli::array^% a_XrayData, String^% a_strEleResult, bool bQuant); // analysis elements bool GetXRayAndElements(unsigned long a_nMilliseconds, int a_BSEX, int a_BSEY, cli::array^% a_XrayData, int^% a_nElementNum, String^% a_strResult); /// get live time float GetLiveTime(void) { float fRet = m_pEDS->GetLiveTime(); return fRet; } /// get x-ray point collection limit long GetMaxPointLimit(void) { long lRet = m_pEDS->GetMaxPointLimit(); return lRet; } //获取图像数据14741238434 int AcquireBSEImage( cli::array^% a_ImgData); //获取图像数据14741238434 bool AcquireBSEImage( CBSEImgClr^% a_ImgData) { CBSEImgPtr pbseImg = nullptr; pbseImg = m_pScan->AcquireBSEImage(); if (pbseImg == nullptr) { return false; } a_ImgData = gcnew CBSEImgClr(pbseImg); return true; } int GetScanType() { int nRet = (int)ScanController::SCANNER_ID::BRUKER; return nRet; } // set Image Size bool SetImageSize(long nWidth,long nHeight) { bool bRet = m_pScan->SetImageSize(nWidth,nHeight); return bRet; } /// set dwell time bool SetDwellTime(long nDwellTime) { bool bRet = m_pScan->SetDwellTime(nDwellTime); return bRet; } bool MoveBeamTo(Point a_beamPos) { CPoint pt; pt.x = a_beamPos.X; pt.y = a_beamPos.Y; bool bRet = (bool)m_pScan->MoveBeamTo(pt); return bRet; } bool StopXrayAcquisition() { bool bRet = (bool)m_pEDS->StopXrayAcquistion(); return bRet; } void SetExpectCount(int expectcount); int GetExpectCount(); void SetQuantificationParam(bool ifauto, String^ knownelements) ; private: COTSControlFunExport(String^ deviceType) { m_DeviceType = deviceType; this->Init(); } //get the hardware object according to the configure file. bool Init(); int GetEDSControllerID(const CString& EDSControllerName); COTSSemBase* m_pSem; COTSScanBase* m_pScan; COTSEDSBase* m_pEDS; String^ m_DeviceType; static COTSControlFunExport^ theInstance=nullptr; }; }