| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460 | #pragma once#include "BSEImg.h"#include "OTSSemBase.h"#include "OTSScanBase.h"#include "OTSEDSBase.h"#include "Bruker/OTSBrukerImpl_const.h"#include <OTSFeatureClr.h>#include <BSEImgClr.h>#include <OTSParticleClr.h>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<unsigned long>^% a_XrayData);		bool CollectSpectrum(unsigned long a_nMilliseconds, cli::array<unsigned long>^% a_XrayData, unsigned long a_nBufferSize);					bool CollectSpectrum(unsigned long a_nMilliseconds, cli::array<unsigned long>^% a_XrayData);		bool GetXRayByPoints(unsigned long a_nMilliseconds, cli::array<CPosXrayClr^>^% a_XrayData, bool bQuant);				bool GetXRayByPoints(unsigned long a_nMilliseconds, cli::array<Point>^ points, cli::array<COTSParticleClr^>^ parts,  bool bQuant);		bool QuantifyXrayByParts(cli::array<COTSParticleClr^>^ parts);		bool QuantifyXrayByPart(COTSParticleClr^ part);		bool GetXRayBySinglePoint(unsigned long a_nMilliseconds, Point point, cli::array<unsigned long>^% a_XrayData, String^% a_strEleResult, bool bQuant);						bool GetXRayByFeatures(unsigned long a_nMilliseconds, cli::array<COTSFeatureClr^>^ feas,cli::array<cli::array<unsigned long>^>^% a_XrayData, cli::array<String^>^% a_strEleResult, bool bQuant);		bool GetXRayByFeatures(unsigned long a_nMilliseconds, cli::array<COTSParticleClr^>^ parts, bool bQuant);		bool GetXRayBySingleFeature(unsigned long a_nMilliseconds, COTSFeatureClr^ feature, cli::array<unsigned long>^% a_XrayData, String^% a_strEleResult, bool bQuant);		// analysis elements		bool GetXRayAndElements(unsigned long a_nMilliseconds, int a_BSEX, int a_BSEY, cli::array<unsigned long>^% 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<System::Byte>^% 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;	};}
 |