123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269 |
- #pragma once
- // FileName: OTSEDSBase.h
- // Brief: EDS Base Class , x-Ray acquisition system
- // Author: Anna.Hao
- // Data: 6/30/2017
- #include "PosXray.h"
- #include "Element.h"
- #include "SEMCommonConst.h"
- #include "Bruker\OTSBrukerImpl_const.h"
- namespace OTSController
- {
-
- using namespace OTSDATA;
-
- const CString SIMULATION_SPECTRUM_FILENAME = _T("SimSpectrum.txt");
- #ifdef UNICODE
- #define isdigit_t iswdigit
- #else
- #define isdigit_t isdigit
- #endif
- // Class OTSController::COTSEDS define.
- class __declspec(dllexport) COTSEDSBase
- {
- public:
- COTSEDSBase(void);
- ~COTSEDSBase(void);
-
- // Get the name of EDS
- // Input: void
- // Output: CString, name of EDS
- CString GetName()
- {
- CString strR = EDSController::GetName((int)GetType());
- return strR;
- }
- // Get EDS type
- // virtual
- virtual EDSController::EDS_ID GetType() = 0;
- // Finished the instance.
- // virtual
- //virtual void FinishedInstance() = 0;
- // Initialization method
- // virtual
- virtual BOOL Init() = 0;
- // To show whether the detector can collect a set of x-Ray one go
- // virtual
- virtual BOOL IsSupportSetCollection() = 0;
- // Quantification
- virtual BOOL IsSupportQuantification() = 0;
- virtual BOOL GetQuantificationMethods(std::vector<CString>& a_vMethods) = 0;
- virtual BOOL QuantifyXrayPoint(CPosXray* a_pXRayPoint, LPCTSTR a_sMethodName) = 0;
- virtual BOOL QuantifySpectrumFile(LPCTSTR a_sFilePathName, LPCTSTR a_sMethodName, CElementChemistriesList& a_listElementChemistry) = 0;
- virtual BOOL QuantifySpectrumOut(DWORD a_nMilliseconds, long* a_pCounts, DWORD a_nBufferSize, CElementChemistriesList& a_listElementChemistry) = 0;
- // collect x ray points
- // virtual
- /* virtual BOOL CollectXRayPoints(std::vector<CPosXray*>& a_vXRayPoints, const DWORD a_nXRayAQTime) = 0;
- virtual BOOL CollectXRayPoints(std::vector<CPosXrayPtr>& a_vXRayPoints, const DWORD a_nXRayAQTime) = 0;
- virtual BOOL CollectXRayPointsByFeatures(std::vector<CPosXray*>& a_listXRayPoints,
- std::vector<std::vector<BrukerSegment>>& a_listFeatures,
- const DWORD a_nXRayAQTime) = 0;*/
-
- // collect spectrum data
- // virtual
- virtual BOOL CollectSpectrum(DWORD a_nMilliseconds) = 0;
- virtual BOOL CollectSpectrum(DWORD a_nMilliseconds, const CPoint& a_oPoint) = 0;
- virtual BOOL CollectSpectrum(DWORD a_nMilliseconds, long* a_pCounts, DWORD a_nBufferSize) = 0;
- virtual BOOL StopXrayAcquistion() = 0;
- // quantify spectrum
- // Get x-Ray data
- // virtual
- virtual DWORD* GetXRayData() = 0;
- // Set Amp Time Index for all detectors
- // virtual
- virtual BOOL SetAmpTimeIndex(long a_nIndex) = 0;
- // get live time
- // virtual
- virtual float GetLiveTime(void) = 0;
- // get max points limit
- // virtual
- virtual long GetMaxPointLimit(void) = 0;
- virtual BOOL GetXRayByPoints(std::vector<CPosXrayPtr>& a_vXRayPoints, const DWORD a_nXRayAQTime) = 0;
- virtual BOOL GetXRayByFeatures(std::vector<CPosXrayPtr>& a_listXRayPoints,
- std::vector<BrukerFeature>& a_listFeatures,
- const DWORD a_nXRayAQTime) = 0;
- BOOL GetXRayByFeaturesFromMultiPoint(std::vector<CPosXrayPtr>& a_listXRayPoints,
- std::vector<std::vector<BrukerSegment>>& a_listFeatures,
- const DWORD a_nXRayAQTime);
-
- // Quantification
- virtual void SetQuantification(BOOL a_bQuantification) = 0;
- virtual BOOL GetQuantification() = 0;
- virtual DWORD GetNumberOfChannels(void) = 0;
- BOOL CollectASpectrumFromTxtFile(DWORD* a_pCounts, DWORD a_nBufferSize);
- // get company system data path
- CString GetCompanySysDataPathName()
- {
- // get common data pathname string
- CString strCommonDataPathName = GetOSCommonDataPathName();
- if (strCommonDataPathName.IsEmpty())
- {
- // failed to get common data pathname string
- LogErrorTrace(__FILE__, __LINE__, _T("GetOTSPackSysDataPathName: failed to common data pathname string."));
- return _T("");
- }
- // company system data pathname
- // e.g. "c:\ProgramData\Config\"
- //CString strCmpSysDataPath = strCommonDataPathName + STR_COMPANYNAME + _T("\\") + STR_SYSTEM_DATA + _T("\\");
- CString strCmpSysDataPath = strCommonDataPathName + STR_COMPANYNAME + _T("\\") + STR_SIMULATE_DATA + _T("\\");
- // return company system data pathname
- return strCmpSysDataPath;
- }
- // get system common data folder pathname
- // return "" if failed
- CString GetOSCommonDataPathName()
- {
- CString strPathName= _T(".\\");
- /*if (strPathName.Right(1) != _T('.\\'))
- {
- strPathName +=
- }*/
- return strPathName;
- }
- // check if the file exists or not
- BOOL Exists(LPCTSTR a_sPath)
- {
- return ::PathFileExists(a_sPath) == TRUE;
- }
- std::vector<CString> LoadTextFileToCStingList(CString a_strPathName, int a_nLine /*= -1*/)
- {
- // string list
- std::vector<CString> listStr;
- // load
- try
- {
- // open the file
- CStdioFile file;
- file.Open(a_strPathName, CFile::modeRead | CFile::shareDenyWrite);
- // read the file
- CString strLine;
- int nLine = 0;
- while (file.ReadString(strLine) && nLine != a_nLine)
- {
- // get a line
- // remove comments
- int nCommentPos = strLine.Find(OTS_TEXT_FILE_COMMENT);
- if (nCommentPos != -1)
- {
- // remove comments
- strLine = strLine.Left(nCommentPos);
- }
- // process the line
- strLine.Trim();
- // jump over empty lines
- if (strLine.IsEmpty())
- {
- continue;
- }
- listStr.push_back(strLine);
- }
- file.Close();
- }
- catch (CFileException* pe)
- {
- pe->Delete();
- return listStr;
- }
- // return string list
- return listStr;
- }
- // Strings to int.
- BOOL StringToInt(LPCTSTR a_sValue, int& a_nValue)
- {
- if (!IsDigitString(a_sValue))
- {
- LogErrorTrace(__FILE__, __LINE__, _T("StringToInt: value string (%s) is not digit string."), a_sValue);
- return FALSE;
- }
- a_nValue = _ttoi(a_sValue);
- return TRUE;
- }
- // Determines whether is digit string.
- BOOL IsDigitString(LPCTSTR a_sValue)
- {
- CString strInt = a_sValue;
- strInt.Trim();
- if (strInt.IsEmpty())
- {
- LogErrorTrace(__FILE__, __LINE__, _T("IsDigitString: value string is an empty string."));
- return FALSE;
- }
- int nStart = 0;
- if (strInt[nStart] == _T('-'))
- {
- ++nStart;
- }
- // cycle through string and check each character if it is a digit
- for (; nStart < strInt.GetLength(); ++nStart)
- {
- if (!isdigit_t(strInt[nStart]))
- {
- LogErrorTrace(__FILE__, __LINE__, _T("IsDigitString: value string (%s) is not a digit string."), strInt);
- return FALSE;
- }
- }
- return TRUE;
- }
- protected:
- // x-Ray data
- DWORD m_nRayData[(long)EDSConst::XANA_CHANNELS];
- //amplify time list
- float m_list_ampTime[(long)EDSConst::MAX_AMPTIME_CONSTANTS];
- //amplify times
- long m_nTimeCounts;
- // do quantification
- BOOL m_bDoQuantification;
- };
- typedef std::shared_ptr<COTSEDSBase> COTSEDSBasePtr;
- } // namespace OTSController
|