123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247 |
- #pragma once
- #include "OTSSingleton.h"
- #include "OTSBrukerImpl_const.h"
- #include "Bruker.API.Esprit.h"
- #include "otsdataconst.h"
- #include "Element.h"
- #include "BSEImg.h"
- #include "PosXray.h"
- #include "OTSFeature.h"
- using namespace OTSDATA;
- namespace OTSController {
- typedef enum class __declspec(dllexport) CONTROL_TYPE
- {
- BRUKER_SEM = 0, //电镜设备
- BRUKER_SCAN = 1, //图像扫描模块
- BRUKER_XRAY = 2 //X-RAY模块
- } CONTROL_TYPE;
-
- typedef enum class __declspec(dllexport) BRUKER_PARAM
- {
- BUF_LENGTH = 1024,
- MAX_SEGMENTS = 8192,
- MAX_PIXEL_MICROSECONDS = 32000,
- RT_SPECTRUM_BUFFER_SIZE = 64000, // SpectrumBufferSize
- RT_SPECTRUM_CHANNELS = 2000, // XANA_CHANNELS = 2000,
- RT_SPECTRUM_CHANNELS_LONG = 3000 // RT_SPECTRUM_CHANNELS_LONG = 3000,
- } BRUKER_PARAM;
- class COTSBrukerImpl : public Singleton<COTSBrukerImpl>
- {
- public:
- // constructor
- COTSBrukerImpl();
- // destructor
- ~COTSBrukerImpl();
-
- // initialization
- BOOL Init(CONTROL_TYPE a_nControlType, BOOL a_b32Bite = TRUE);
- BOOL Connect();
- /// set SPU (used for send command to multi-detector system) value
- BOOL SetSPU(void);
- // check connection
- //BOOL CheckConnection(BOOL& a_bConnected);
- BOOL DisConnect();
-
- void SetExpectCount(int expectCount);
- int GetExpectCount();
- // SEM functions
- // SEM Data (mag, KV and working distance)
- BOOL GetSEMData(double& a_dMagnification, double& a_dHighVoltage, double& a_dWorkingDistance);
- BOOL SetSEMData(double a_dMagnification, double a_dHighVoltage, double a_dWorkingDistance);
- // SEM BC Data (brightness and contrast)
- BOOL GetSEMBCData(double& a_dBrightness, double& a_dContrast);
- BOOL SetSEMBCData(double a_dBrightness, double a_dContrast);
- // Probe Current
- BOOL GetProbeCurrent(double&);
- BOOL SetProbeCurrent(double);
- // spot size
- BOOL GetSEMSpotSize(double& a_dSpotSize);
- BOOL SetSEMSpotSize(double a_dSpotSize);
- // stage data
- BOOL GetSEMStageData(double& a_nPositionX, double& a_nPositionY, double& a_nPositionZ, double& a_dTilt, double& a_dRotation);
- BOOL SetSEMStageData(double a_nPositionX, double a_nPositionY, double a_nPositionZ, double a_dTilt, double a_dRotation);
- // external on/off
- BOOL SetSEMExternalOn(void);
- BOOL SetSEMExternalOff(void);
- // get scan Mode
- BOOL GetExternalScanMode(long& a_nScanMode);
-
- // Switch SEM Off
- BOOL SwitchSEMOff(BOOL a_bHTValue, BOOL a_bBeamCurrent, BOOL a_bBeamBlank);
- // imaging functions
-
- // Get and set image config - dimensions, dwell time and enabled channels
- BOOL ImageGetConfiguration(DWORD& a_nWidth, DWORD& a_nHeight, DWORD& a_nAverage, BYTE& a_bCh1, BYTE& a_bCh2);
- BOOL ImageSetConfiguration(DWORD a_nWidth, DWORD a_nHeight, DWORD a_nAverage, BYTE a_bCh1, BYTE a_bCh2);
-
- // image collection, using the size and dwell time that was last set
- CBSEImgPtr AcquireImage();
-
- // set point
- BOOL ImageSetPoint(const CPoint& a_oPoint);
-
- // x-ray functions
-
- // live time
- float GetLiveTime(void);
- BOOL GetLiveRealTime(float& a_dLiveTime, float& a_dRealTime);
-
- // ---------collect spectrum data ,for testing
- BOOL CollectSpectrum(DWORD a_nMilliSeconds, long* a_pCounts, DWORD a_nBufferSize);
- BOOL CollectOneXRayPoint(const CPoint& a_oPoi, DWORD a_nLifeTimeMilliSeconds, long* a_pnCounts, DWORD a_nBufferSize, bool a_bSetHeadStruc = FALSE);
- //------------------
-
-
- BOOL StopSpectrumMeasure(void);
-
- // get quantification method name
- BOOL GetQuantificationMethods(std::vector<CString>& a_vMethods);
- BOOL QuantifyXrayPoint(CPosXray* a_pXRayPoint, CString a_strMethodName);
- BOOL QuantifySpectrumFile(LPCTSTR a_sFilePathName, CString a_strMethodName, CElementChemistriesList& a_vElementChemistry);
- // collect spectrum data by timeB and quantify
- BOOL QuantifySpectrumOut(DWORD a_nMilliSeconds, long* a_pCounts, DWORD a_nBufferSize, CElementChemistriesList& a_listElementChemistries);
- // quantify spectrum
- BOOL QuantifySpectrum(char* a_pcMethod, char* a_pcParams, char* a_pcResultBuffer, long a_nBufferSize);
-
- // if do x-ray quantification
- BOOL GetQuantificationFlag() { return m_bDoQuantification; }
- void SetQuantificationFlag(BOOL a_bDoQuantification) { m_bDoQuantification = a_bDoQuantification; }
- // m_bDoQuantification should be set first.
- BOOL GetXRayByPoints(CPosXrayList& a_listXrayPois, DWORD a_nACTimeMS);
-
- BOOL GetXRayByFeatures(CPosXrayList& a_vXPoints, std::vector<BrukerFeature> a_vFeatures, SHORT a_nACTimeMS);
-
- BOOL QuantifyPosXrayPointsOnLine(CPosXrayList& a_vXRayParts);//delay quantifying
-
- BOOL QuantifyPosXrayPointOnLine(CPosXrayPtr a_vXRayPart);//delay quantifying
- void SetQuantificationParam(BOOL ifAuto, CString knownElements);
- private:
- BOOL GetXRayByPointsOnHardwareLimit(CPosXrayList& a_listXrayPois, DWORD a_nACTimeMS);
- BOOL GetXRayByFeaturesOnHardwareLimit(CPosXrayList& a_vXPoints, std::vector<BrukerFeature> a_vFeatures, SHORT a_nACTimeMS);
- BOOL ReadSpectrum(long* a_pnCounts, DWORD a_nBufferSize);
- BOOL ReadXRayPoints(CPosXrayList& a_listXrayPois, const DWORD a_nACTimeMS);
- BOOL ReadXRayPointsByFeature(std::vector<CPosXray*>& a_vXPoints, const DWORD a_nACTimeMS);
- BOOL ReadXRayPointsByFeature(CPosXrayList& a_vXPoints, const DWORD a_nACTimeMS);
- // spectrum measurement
- BOOL StartSpectrumMeasurement();
- BOOL IsSpectrumMeasureRunning(BOOL& a_bRunning);
- BOOL SetXRayPointsByFeature(CPosXrayList& a_vXPoints, const DWORD a_nACTimeMS);
- // collect x-ray
-
- // close client
- BOOL CloseClient(void);//there's no need to call from out ,the single instance destruction method will call it automatically.
-
- RTSpectrumHeaderRec* GetSectrumHeader();
- BOOL GetSpectrum(long a_nBufferIndex, BrukerDll::PRTSpectrumHeaderRec a_poSpcHR, long a_nBufferSize);
- BOOL LoadSpectrum(char* a_sFilePathName);
- BOOL ReadSpectrum(void);
-
- BOOL PutSpectrum(char* m_pBuffer, long a_nBufferSize);
- BOOL CreateSpectrum(char* m_pParamBuffer, BrukerDll::PRTSpectrumHeaderRec a_poSpcHR, char* m_pResultBuffer, int32_t& a_nBufferSize);
- BOOL ShowSpectrum(long a_nBufferIndex, char* a_pSpectumName);
- BOOL GetSpectrometerParams(long a_nBufferIndex, char* a_pcBuffer, int32_t& a_nBufferSize);
- BOOL GetElementChemistryData(CElementChemistry& a_oElementChemistryData, CString a_strElementChemistry);
- BOOL CopySpectrum(long* a_pnCounts, DWORD a_nBufferSize);
- BOOL StartSpectrumLifeTimeMeasurement(DWORD a_nLifeTime);
- BOOL SpectrumLifeTimeMeasurement(DWORD a_nLifeTime);
- BOOL StartSpectrumRealTimeMeasurement(DWORD a_nRealTime);
- BOOL SpectrumRealTimeMeasurement(DWORD a_nRealTime);
- BOOL SpectrumCountsMeasurement(DWORD a_nCounts, int a_nTimeLimit = -1);
- BOOL ConvertSpectrum(RTSpectrumHeaderRec* a_poSpcHR, long* a_pnCounts, DWORD a_nBufferSize);
- BOOL GetPointListSpectrum(long a_nIndex, long* a_pnSpec);
- BOOL GetFeatureListSpectrum(long a_nIndex, long* a_pnSpec);
- BOOL CheckDetectorState(long a_nDetectorId, BOOL& a_bState, uint32_t& a_nMaxEnergy);
-
- // open client
- BOOL OpenClient(void);
-
-
- // query server
- BOOL QueryBrukerServers(void);
- CString GetQuantificationSpectrumPathName();
- //Get Load Dll Name
- BOOL GetLoadDllName(CString& csDllName);
- // spectrum header
- RTSpectrumHeaderRec* m_pSpectrumHead;
-
- std::shared_ptr<char> m_psServerName; // server name
- BOOL m_bInit; // initialize flag
- BOOL m_bSEMInst; // SEM instance
- BOOL m_bScannerInst; // scanner instance
- BOOL m_bXRAyControllerInst; // x ray instance
- std::shared_ptr<char> m_psRTSpectrumBuffer; // this is used to get spectrum from detector
- uint32_t m_nClientID;
- BOOL m_bSEMExternal;
- int m_nSPU;
- BOOL m_bConnected;
- DWORD nWidth = 0;
- DWORD nHeight = 0;
- BOOL m_bDoQuantification; // if do x-ray quantification
- BOOL m_bShowQuantificationSpectrum;
- int m_expectCount;
- BOOL m_ifAutoId=TRUE;
- CString m_knownElements;
- const int XrayQuantityLimitPerTime = 256;
- };
- }
|