123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215 |
- using Bruker.API;
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- namespace OTSMeasureApp.ServiceCenter.BrukerCSharp
- {
- public class COTSBrukerImpl
- {
- // constructor
- COTSBrukerImpl()
- { }
- // destructor
- ~COTSBrukerImpl()
- { }
- // initialization
- bool Init( bool a_b32Bite = true)
- {
-
- }
- bool DisConnect()
- { }
- // check connection
- bool CheckConnection(bool a_bConnected);
- 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 GetScanMode(long& a_nScanMode);
- // set scan mode
- BOOL SetScanMode(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 by timeB
- BOOL CollectSpectrum(DWORD a_nMilliSeconds, long* a_pCounts, DWORD a_nBufferSize);
- // 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);
- // collect x-ray
- BOOL CollectXRayPoints(std::vector<CPosXray*>& a_vXPoints, DWORD a_nACTimeMS);
- BOOL CollectXRayPoints(CPosXrayList& a_listXrayPois, DWORD a_nACTimeMS);
- BOOL CollectXRayPointsByFeatures(std::vector<CPosXray*>& a_vXPoints, std::vector<BrukerFeature>& a_vFeatures, DWORD a_nACTimeMS);
- BOOL ReadXRayPoints(std::vector<CPosXray*>& a_vXPoints, const DWORD a_nACTimeMS);
- 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);
- BOOL CollectOneXRayPoint(const CPoint& a_oPoi, DWORD a_nLifeTimeMilliSeconds, long* a_pnCounts, DWORD a_nBufferSize, bool a_bSetHeadStruc = FALSE);
- // spectrum measurement
- BOOL StartSpectrumMeasurement();
- BOOL IsSpectrumMeterRunning(BOOL& a_bRunning);
- BOOL StopSpectrumMeasure(void);
- BOOL ReadSpectrum(long* a_pnCounts, DWORD a_nBufferSize);
- // 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);
- BOOL QuantifyPosXrayPointsOnLine(std::vector<CPosXrayPtr>& a_vXRayParts);//delay quantifying so the next field's stage moving and BSE aquisition can be executed in the same time.
- BOOL QuantifyPosXrayPointOnLine(CPosXrayPtr a_vXRayPart);//delay quantifying
- RTSpectrumHeaderRec* GetSectrumHeader();
- // 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 SetXRayPoints(CPosXrayList& a_listXrayPois/*, const DWORD a_nACTimeMS*/);
- BOOL GetXRayByFeatures(CPosXrayList& a_vXPoints, std::vector<BrukerFeature> a_vFeatures, SHORT a_nACTimeMS);
- BOOL SetXRayPointsByFeature(CPosXrayList& a_vXPoints, const DWORD a_nACTimeMS);
- protected:
- // close client
- BOOL CloseClient(void);//there's no need to call from out ,the single instance destruction method will call it automatically.
- 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 StartPointListMeasurement(DWORD a_nSegmentCount, BrukerDll::PSegmentList a_poSegment, DWORD m_nMilliseconds);
- BOOL StartFeatureListMeasurement(DWORD a_nFeatureCount, BrukerDll::PFeatureDataList a_poFeature, SHORT** a_pwdPixelTimes);
- BOOL CheckDetectorState(long a_nDetectorId, BOOL& a_bState, uint32_t& a_nMaxEnergy);
- /// set SPU (used for send command to multi-detector system) value
- BOOL SetSPU(void);
- // open client
- BOOL OpenClient(void);
- BOOL OpenClient(char*, char*, char*, BYTE, BYTE, uint32_t&);
- // query server
- BOOL QueryBrukerServers(void);
- //// instance termination
- //void FinishedInstance(void); // this is to delete it
- CString GetQuantificationSpectrumPathName();
- //Get Load Dll Name
- BOOL GetLoadDllName(CString& csDllName);
- // spectrum header
- TRTSpectrumHeaderRec m_pSpectrumHead;
- //
- //std::shared_ptr<OTSBrukerClientDll> m_pBrukerDllHandle;
- 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;
- BOOL m_bDoQuantification; // if do x-ray quantification
- BOOL m_bShowQuantificationSpectrum;
- int m_expectCount;
- }
- }
|