123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348 |
- #include "stdafx.h"
- #include "OTSEDSBrucker.h"
- namespace OTSController {
- // constructor
- COTSEDSBrucker::COTSEDSBrucker(void)
- {
- m_pBrukerImpl = COTSBrukerImpl::GetInstance();
- if (!m_pBrukerImpl->Init(CONTROL_TYPE::BRUKER_XRAY))
- {
- // failed to initialize bruker controller
- LogErrorTrace(__FILE__, __LINE__, _T("COTSEDSBrucker::Init: failed to initialize bruker controller."));
- //return FALSE;
- }
- }
- // destructor
- COTSEDSBrucker::~COTSEDSBrucker(void)
- {
- }
-
- // initialization
- BOOL COTSEDSBrucker::Init()
- {
-
- if (!m_pBrukerImpl->SetSPU())
- {
- return FALSE;
- }
- // ok, return TRUE
- return TRUE;
- }
-
- // collect spectrum at the given position (to controller buffer)
- BOOL COTSEDSBrucker::CollectSpectrum(DWORD a_nMilliseconds, const CPoint& a_oPoint)
- {
-
- // check bruker controller
- ASSERT(m_pBrukerImpl);
- if (!m_pBrukerImpl)
- {
- LogErrorTrace(__FILE__, __LINE__, _T("COTSEDSBrucker::CollectSpectrum: invalid m_pBrukerImpl."));
- return FALSE;
- }
- // collect spectrum data
- if (!m_pBrukerImpl->CollectOneXRayPoint(a_oPoint, a_nMilliseconds, (long*)m_nRayData, (DWORD)EDSConst::XANA_CHANNELS))
- {
- // failed to call bruker controller CollectOneXRayPoint method
- LogErrorTrace(__FILE__, __LINE__, _T("COTSEDSBrucker::CollectSpectrum: failed to call bruker controller CollectOneXRayPoint method."));
- return FALSE;
- }
- // ok, return TRUE
- return TRUE;
- }
- // collects spectrum (to controller buffer)
- BOOL COTSEDSBrucker::CollectSpectrum(DWORD a_nMilliseconds)
- {
-
- // check bruker controller
- ASSERT(m_pBrukerImpl);
- if (!m_pBrukerImpl)
- {
- LogErrorTrace(__FILE__, __LINE__, _T("COTSEDSBrucker::CollectSpectrum: invalid m_pBrukerImpl."));
- return FALSE;
- }
- // collect spectrum data
- if (!m_pBrukerImpl->CollectSpectrum(a_nMilliseconds, (long*)m_nRayData, (DWORD)EDSConst::XANA_CHANNELS))
- {
- // failed to call bruker controller CollectSpectrum method
- LogErrorTrace(__FILE__, __LINE__, _T("COTSEDSBrucker::CollectSpectrum: failed to call bruker controller CollectSpectrum method."));
- return FALSE;
- }
- // ok, return TRUE
- return TRUE;
- }
- // collects spectrum (to given buffer)
- BOOL COTSEDSBrucker::CollectSpectrum(DWORD a_nMilliseconds, long* a_pCounts, DWORD a_nBufferSize)
- {
- // input check
- ASSERT(a_pCounts);
- if (!a_pCounts)
- {
- // invalid input data buffer
- LogTrace(__FILE__, __LINE__, _T("COTSEDSBrucker::CollectSpectrum: invalid input data buffer."));
- return FALSE;
- }
-
- // check bruker controller
- ASSERT(m_pBrukerImpl);
- if (!m_pBrukerImpl)
- {
- LogErrorTrace(__FILE__, __LINE__, _T("COTSEDSBrucker::CollectSpectrum: invalid m_pBrukerImpl."));
- return FALSE;
- }
- // collect spectrum data
- if (!m_pBrukerImpl->CollectSpectrum(a_nMilliseconds, a_pCounts, a_nBufferSize))
- {
- // failed to call bruker controller CollectSpectrum method
- LogErrorTrace(__FILE__, __LINE__, _T("COTSEDSBrucker::CollectSpectrum: failed to call bruker controller CollectSpectrum method."));
- return FALSE;
- }
- // ok, return TRUE
- return TRUE;
- }
- BOOL COTSEDSBrucker::StopXrayAcquistion()
- {
- ASSERT(m_pBrukerImpl);
- if (!m_pBrukerImpl)
- {
- LogErrorTrace(__FILE__, __LINE__, _T(" invalid m_pBrukerImpl."));
- return FALSE;
- }
- return m_pBrukerImpl->StopSpectrumMeasure();
- }
- // get live time
- float COTSEDSBrucker::GetLiveTime()
- {
-
- // check bruker controller
- ASSERT(m_pBrukerImpl);
- if (!m_pBrukerImpl)
- {
- LogErrorTrace(__FILE__, __LINE__, _T("COTSEDSBrucker::CollectSpectrum: invalid m_pBrukerImpl."));
- return 0.0;
- }
- // get time value from the controller
- float fRet;
- fRet = m_pBrukerImpl->GetLiveTime();
- return fRet;
- }
- BOOL COTSEDSBrucker::GetQuantificationMethods(std::vector<CString>& a_vMethods)
- {
-
- // check bruker controller
- ASSERT(m_pBrukerImpl);
- if (!m_pBrukerImpl)
- {
- LogErrorTrace(__FILE__, __LINE__, _T("COTSEDSBrucker::GetQuantificationMethods: invalid m_pBrukerImpl."));
- return FALSE;
- }
- return m_pBrukerImpl->GetQuantificationMethods(a_vMethods);
- }
- BOOL COTSEDSBrucker::QuantifyXrayPoint(CPosXray* a_pXRayPoint, LPCTSTR a_sMethodName)
- {
-
- // check bruker controller
- ASSERT(m_pBrukerImpl);
- if (!m_pBrukerImpl)
- {
- LogErrorTrace(__FILE__, __LINE__, _T("COTSEDSBrucker::QuantifyXrayPoint: invalid m_pBrukerImpl."));
- return FALSE;
- }
- return m_pBrukerImpl->QuantifyXrayPoint(a_pXRayPoint, a_sMethodName);
- }
- BOOL COTSEDSBrucker::QuantifySpectrumFile(LPCTSTR a_sFilePathName, LPCTSTR a_sMethodName, CElementChemistriesList& a_listElementChemistry)
- {
-
- // check bruker controller
- ASSERT(m_pBrukerImpl);
- if (!m_pBrukerImpl)
- {
- LogErrorTrace(__FILE__, __LINE__, _T("COTSEDSBrucker::QuantifySpectrumFile: invalid m_pBrukerImpl."));
- return FALSE;
- }
- return m_pBrukerImpl->QuantifySpectrumFile(a_sFilePathName, a_sMethodName, a_listElementChemistry);
- }
- BOOL COTSEDSBrucker::QuantifySpectrumOut(DWORD a_nMilliseconds, long* a_pCounts, DWORD a_nBufferSize, CElementChemistriesList& a_listElementChemistry)
- {
-
- // check bruker controller
- ASSERT(m_pBrukerImpl);
- if (!m_pBrukerImpl)
- {
- LogErrorTrace(__FILE__, __LINE__, _T("COTSEDSBrucker::QuantifySpectrumOut: invalid m_pBrukerImpl."));
- return FALSE;
- }
- return m_pBrukerImpl->QuantifySpectrumOut(a_nMilliseconds, a_pCounts, a_nBufferSize, a_listElementChemistry);
- }
- BOOL COTSEDSBrucker::GetXRayByPoints(std::vector<CPosXrayPtr>& a_vXRayPoints, const DWORD a_nXRayAQTime)
- {
-
- // check Bruker controller
- ASSERT(m_pBrukerImpl);
- if (!m_pBrukerImpl)
- {
- LogErrorTrace(__FILE__, __LINE__, _T("COTSEDSBrucker::GetXRayByPoints: invalid m_pBrukerImpl."));
- return FALSE;
- }
-
- std::vector<CPosXrayPtr> listXRayPointsTemp;
-
- if (!m_pBrukerImpl->GetXRayByPoints(a_vXRayPoints, a_nXRayAQTime))
- {
- LogErrorTrace(__FILE__, __LINE__, _T("GetXRayByPoints: failed to get element."));
- }
-
- return TRUE;
- }
- BOOL COTSEDSBrucker::QuantifyXrays(std::vector<CPosXrayPtr>& a_vXRayParts)
- {
- m_pBrukerImpl->QuantifyPosXrayPointsOnLine(a_vXRayParts);
- return true;
- }
- BOOL COTSEDSBrucker::QuantifyXray(CPosXrayPtr& a_vXRayPart)
- {
- m_pBrukerImpl->QuantifyPosXrayPointOnLine(a_vXRayPart);
- return true;
- }
- BOOL COTSEDSBrucker::GetXRayByFeatures(std::vector<CPosXrayPtr>& a_listXRayPoints,
- std::vector<BrukerFeature>& a_listFeatures,
- const DWORD a_nXRayAQTime)
- {
-
- // check bruker controller
- ASSERT(m_pBrukerImpl);
- if (!m_pBrukerImpl)
- {
- LogErrorTrace(__FILE__, __LINE__, _T("COTSEDSBrucker::GetXRayByFeatures: invalid m_pBrukerImpl."));
- return FALSE;
- }
- // turn SEM to external
- if (!m_pBrukerImpl->SetSEMExternalOn())
- {
- // failed to call SetSEMExternalOn method
- LogTrace(__FILE__, __LINE__, _T("COTSBrukerImpl::GetXRayByPoints: failed to call SetSEMExternalOn method."));
- return FALSE;
- }
- if (!m_pBrukerImpl->GetXRayByFeatures(a_listXRayPoints, a_listFeatures, a_nXRayAQTime))
- {
- // failed to call bruker controller CollectXRayPointsByFeatures method.
- LogErrorTrace(__FILE__, __LINE__, _T("COTSEDSBrucker::CollectXRayPointsByFeatures: failed to call bruker controller CollectXRayPointsByFeatures method."));
- }
-
- if (!m_pBrukerImpl->SetSEMExternalOff())
- {
- // failed to call SetSEMExternalOn method
- LogTrace(__FILE__, __LINE__, _T("COTSBrukerImpl::GetXRayByPoints: failed to call SetSEMExternalOff method."));
- }
- // ok, return TRUE
- return TRUE;
- }
- // Quatification
- void COTSEDSBrucker::SetQuantification(BOOL a_bQuantification)
- {
-
- // check bruker controller
- ASSERT(m_pBrukerImpl);
- if (!m_pBrukerImpl)
- {
- LogErrorTrace(__FILE__, __LINE__, _T("COTSEDSBrucker::SetQuantification: invalid m_pBrukerImpl."));
- return;
- }
- // collect x-Ray points (area scan)
- m_pBrukerImpl->SetQuantificationFlag(a_bQuantification);
- }
- BOOL COTSEDSBrucker::GetQuantification()
- {
-
- // check bruker controller
- ASSERT(m_pBrukerImpl);
- if (!m_pBrukerImpl)
- {
- LogErrorTrace(__FILE__, __LINE__, _T("COTSEDSBrucker::GetQuantification: invalid m_pBrukerImpl."));
- return FALSE;
- }
- // collect x-Ray points (area scan)
- return m_pBrukerImpl->GetQuantificationFlag();
- }
- // Get number of channels
- DWORD COTSEDSBrucker::GetNumberOfChannels(void)
- {
- return (DWORD)2000;
- }
- // Get the x-Ray data
- DWORD* COTSEDSBrucker::GetXRayData()
- {
- return m_nRayData;
- }
- void COTSEDSBrucker::SetExpectCount(int expectcount)
- {
- m_pBrukerImpl->SetExpectCount(expectcount);
- }
- int COTSEDSBrucker::GetExpectCount()
- {
- return m_pBrukerImpl->GetExpectCount();
- }
- void COTSEDSBrucker::SetQuantificationParam(bool ifauto, CString knownelements)
- {
- m_pBrukerImpl->SetQuantificationParam(ifauto, knownelements);
- }
- }
|