123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615 |
- #include "stdafx.h"
- #include "OTSControlFunExport.h"
- namespace OTSCLRINTERFACE
- {
- COTSHardwareMgrPtr g_ControllerMgrPtr = nullptr;
- CSemBasePtr g_SemBasePtr = nullptr;
- COTSSimuControlClr::COTSSimuControlClr()
- {
- g_ControllerMgrPtr = COTSHardwareMgrPtr(new COTSHardwareMgr);
- g_SemBasePtr = g_ControllerMgrPtr->GetSemControllerMgrPtr();
- }
- COTSSimuControlClr::~COTSSimuControlClr()
- {
- this->!COTSSimuControlClr();
- }
- COTSSimuControlClr::!COTSSimuControlClr()
- {
-
- }
-
- bool COTSSimuControlClr::Connect()
- {
-
- if (nullptr == g_SemBasePtr)
- {
- return false;
- }
- return g_SemBasePtr->Connect();
- }
- //bool COTSSimuControlClr::Disconnect()
- //{
- // if (nullptr == g_SemBasePtr)
- // {
- // return false;
- // }
- // return g_SemBasePtr->Disconnect();
- //}
- bool COTSSimuControlClr::SetWorkingDistance(double a_dWorkingDistance)
- {
- return g_SemBasePtr->SetWorkingDistance(a_dWorkingDistance);
- }
- bool COTSSimuControlClr::GetWorkingDistance(double% a_dWorkingDistance)
- {
- double WDistance;
- bool bRev = g_SemBasePtr->GetWorkingDistance(WDistance);
- a_dWorkingDistance = WDistance;
- return bRev;
- }
- bool COTSSimuControlClr::SetMagnification(double a_dMag)
- {
- return g_SemBasePtr->SetMagnification(a_dMag);
- }
- bool COTSSimuControlClr::GetMagnification(double% a_dMag)
- {
- double dMag;
- bool bRev = g_SemBasePtr->GetMagnification(dMag);
- a_dMag = dMag;
- return bRev;
- }
- bool COTSControlFunExport::CollectSpectrum(unsigned long a_nMilliseconds, Point a_oPoint, array<unsigned long>^% a_XrayData)
- {
- CPoint pt;
- pt.x = a_oPoint.X;
- pt.y = a_oPoint.Y;
- bool bRet = m_pEDS->CollectSpectrum(a_nMilliseconds, pt);
- DWORD* xrd;
- xrd = m_pEDS->GetXRayData();
- for (int i = 0; i < (int)EDSConst::XANA_CHANNELS; i++)
- {
- a_XrayData[i] = xrd[i];
- }
- return bRet;
- }
- bool COTSControlFunExport::CollectSpectrum(unsigned long a_nMilliseconds, array<unsigned long>^% a_XrayData, unsigned long a_nBufferSize)
- {
- long* aData = new long[a_nBufferSize];
- memset(aData, 0, a_nBufferSize);
- bool bRet = m_pEDS->CollectSpectrum(a_nMilliseconds, aData, a_nBufferSize);
- for (int i = a_nBufferSize; i < (int)a_nBufferSize; i++)
- {
- a_XrayData[i] = aData[i];
- }
- delete[] aData;
- return bRet;
- }
- bool COTSControlFunExport::CollectSpectrum(unsigned long a_nMilliseconds, array<unsigned long>^% a_XrayData)
- {
- bool bRet = m_pEDS->CollectSpectrum(a_nMilliseconds);
- DWORD* xrd;
- xrd = m_pEDS->GetXRayData();
- for (int i = 0; i < (int)EDSConst::XANA_CHANNELS; i++)
- {
- a_XrayData[i] = xrd[i];
- }
- return bRet;
- }
-
- bool COTSControlFunExport::GetXRayByPoints(unsigned long a_nMilliseconds, array<Point>^ points, array<array<unsigned long>^>^% a_XrayData, array<String^>^% a_strEleResult, bool bQuant)
- {
- std::vector<CPosXrayPtr> listXRayPoints;
- for (int i = 0; i < points->Length; i++)
- {
- CPosXrayPtr pXRayPoint = CPosXrayPtr(new CPosXray());
- pXRayPoint->SetPosition(CPoint(points[i].X, points[i].Y));
- listXRayPoints.push_back(pXRayPoint);
- }
- // set get quantify info flag
- if (bQuant)
- {
- m_pEDS->SetQuantification(TRUE);
- }
- else
- {
- m_pEDS->SetQuantification(FALSE);
- }
- bool bRet = m_pEDS->GetXRayByPoints(listXRayPoints, a_nMilliseconds);
- DWORD* xrd;
- for (int i = 0; i < points->Length; i++)
- {
- xrd = listXRayPoints[i]->GetXrayData();
- for (int j = 0; j < (int)EDSConst::XANA_CHANNELS; j++)
- {
- a_XrayData[i][j] = xrd[j];
- }
-
- }
- if (bQuant)
- {
- for (int i = 0; i < points->Length; i++)
- {
- CElementChemistriesList& listElement = listXRayPoints[i]->GetElementQuantifyData();
- int nElementNum = (int)listElement.size();
- CString strElementResult = _T("");
- for (auto pElement : listElement)
- {
- CString strResult;
- CString strName = pElement->GetName();
- double dPercent = pElement->GetPercentage();
- strResult.Format(_T("%s: %f\n"), strName, dPercent);
- strElementResult += strResult;
- }
- a_strEleResult[i] = gcnew String(strElementResult);
- }
- }
- return bRet;
- }
- bool COTSControlFunExport::GetXRayByPoints(unsigned long a_nMilliseconds, array<Point>^ points, array<COTSParticleClr^>^ parts, bool bQuant)
- {
- std::vector<CPosXrayPtr> listXRayPoints;
- for (int i = 0; i < points->Length; i++)
- {
- CPosXrayPtr pXRayPoint = parts[i]->GetXray()->GetPosXrayPtr();
- pXRayPoint->SetPosition(CPoint(points[i].X, points[i].Y));
- listXRayPoints.push_back(pXRayPoint);
- }
- // set get quantify info flag
- if (bQuant)
- {
- m_pEDS->SetQuantification(TRUE);
- }
- else
- {
- m_pEDS->SetQuantification(FALSE);
- }
- bool bRet = m_pEDS->GetXRayByPoints(listXRayPoints, a_nMilliseconds);
- //DWORD* xrd;
- for (int i = 0; i < points->Length; i++)
- {
- auto part = parts[i]->GetOTSParticlePtr();
- part->SetXrayInfo(listXRayPoints[i]);
- }
-
- return bRet;
- }
- bool COTSControlFunExport::GetXRayByFeatures(unsigned long a_nMilliseconds, array<COTSFeatureClr^>^ features, array<array<unsigned long>^>^% a_XrayData, array<String^>^% a_strEleResult, bool bQuant)
- {
- std::vector<CPosXrayPtr> listXRayPoints;
- long xraynum = features->Length;
- for (int i = 0; i < xraynum; i++)
- {
- CPosXrayPtr pXRayPoint = CPosXrayPtr(new CPosXray());
- listXRayPoints.push_back(pXRayPoint);
- }
-
- std::vector<BrukerFeature>listFeatures;
- for (int i = 0; i < xraynum; i++)
- {
- auto feature = features[i]->GetOTSFeaturePtr();
- auto otsSegs = feature->GetSegmentsList();
- //auto otsSegs = feature->GetSegmentsList();
- //std::vector<BrukerSegment*> listSegment;
- BrukerSegment* segArray = new BrukerSegment[otsSegs.size()];
- for (int j = 0; j < otsSegs.size(); j++)
- {
- auto seg = otsSegs[j];
- //BrukerSegment* oSegment=new BrukerSegment();
- BrukerSegment* oSegment = &segArray[j];
- oSegment->XCount = seg->GetLength();
- oSegment->XStart = seg->GetStart();
- oSegment->Y = seg->GetHeight();
- //listSegment.push_back(oSegment);
- }
- BrukerFeature oFeature;
- oFeature.SegmentCount = otsSegs.size();
- oFeature.pSegment = segArray;
- listFeatures.push_back(oFeature);
- }
- // set get quantify info flag
- if (bQuant)
- {
- m_pEDS->SetQuantification(TRUE);
- }
- else
- {
- m_pEDS->SetQuantification(FALSE);
- }
- bool bRet = m_pEDS->GetXRayByFeatures(listXRayPoints, listFeatures, a_nMilliseconds);
- DWORD* xrd;
- for (int i = 0; i < xraynum; i++)
- {
- xrd = listXRayPoints[i]->GetXrayData();
- for (int j = 0; j < (int)EDSConst::XANA_CHANNELS; j++)
- {
- a_XrayData[i][j] = xrd[j];
- }
-
- }
- if (bQuant)
- {
- for (int i = 0; i < features->Length; i++)
- {
- CElementChemistriesList& listElement = listXRayPoints[i]->GetElementQuantifyData();
- int nElementNum = (int)listElement.size();
- CString strElementResult = _T("");
- for (auto pElement : listElement)
- {
- CString strResult;
- CString strName = pElement->GetName();
- double dPercent = pElement->GetPercentage();
- strResult.Format(_T("%s: %f\n"), strName, dPercent);
- strElementResult += strResult;
- }
- a_strEleResult[i] = gcnew String(strElementResult);
- }
- }
- return bRet;
- }
- bool COTSControlFunExport::GetXRayByFeatures(unsigned long a_nMilliseconds, array<COTSParticleClr^>^ parts, bool bQuant)
- {
- std::vector<CPosXrayPtr> listXRayPoints;
- long xraynum = parts->Length;
- for (int i = 0; i < xraynum; i++)
- {
- //CPosXrayPtr pXRayPoint = CPosXrayPtr(new CPosXray());
- CPosXrayPtr pXRayPoint = parts[i]->GetXray()->GetPosXrayPtr();
- listXRayPoints.push_back(pXRayPoint);
- }
-
- //std::vector<std::vector<BrukerSegment>>listFeatures;
- std::vector<BrukerFeature>listFeatures;
- for (int i = 0; i < xraynum; i++)
- {
- auto feature = parts[i]->GetOTSParticlePtr()->GetFeature();
- auto otsSegs = feature->GetSegmentsList();
- //std::vector<BrukerSegment*> listSegment;
- BrukerSegment* segArray = new BrukerSegment[otsSegs.size()];
- for (int j = 0; j < otsSegs.size(); j++)
- {
- auto seg = otsSegs[j];
- //BrukerSegment* oSegment=new BrukerSegment();
- BrukerSegment* oSegment = &segArray[j];
- oSegment->XCount = seg->GetLength();
- oSegment->XStart = seg->GetStart();
- oSegment->Y = seg->GetHeight();
- //listSegment.push_back(oSegment);
- }
- BrukerFeature oFeature;
- oFeature.SegmentCount = otsSegs.size();
- oFeature.pSegment = segArray;
- listFeatures.push_back(oFeature);
- }
- // set get quantify info flag
- if (bQuant)
- {
- m_pEDS->SetQuantification(TRUE);
- }
- else
- {
- m_pEDS->SetQuantification(FALSE);
- }
- bool bRet = m_pEDS->GetXRayByFeatures(listXRayPoints, listFeatures, a_nMilliseconds);
- //DWORD* xrd;
- for (int i = 0; i < xraynum; i++)
- {
- auto part = parts[i]->GetOTSParticlePtr();
- part->SetXrayInfo(listXRayPoints[i]);
- }
-
- return bRet;
- }
- bool COTSControlFunExport::GetXRayBySinglePoint(unsigned long a_nMilliseconds, Point point, array<unsigned long>^% a_XrayData, String^% a_strEleResult, bool bQuant)
- {
- std::vector<CPosXrayPtr> listXRayPoints;
- CPosXrayPtr pXRayPoint = CPosXrayPtr(new CPosXray());
- pXRayPoint->SetPosition(CPoint(point.X, point.Y));
- listXRayPoints.push_back(pXRayPoint);
- // set get quantify info flag
- if (bQuant)
- {
- m_pEDS->SetQuantification(TRUE);
- }
- else
- {
- m_pEDS->SetQuantification(FALSE);
- }
- bool bRet = m_pEDS->GetXRayByPoints(listXRayPoints, a_nMilliseconds);
- DWORD* xrd;
- xrd = listXRayPoints[0]->GetXrayData();
- for (int j = 0; j < (int)EDSConst::XANA_CHANNELS; j++)
- {
- a_XrayData[j] = xrd[j];
- }
- if (bQuant)
- {
- CElementChemistriesList& listElement = listXRayPoints[0]->GetElementQuantifyData();
- int nElementNum = (int)listElement.size();
- CString strElementResult = _T("");
- for (auto pElement : listElement)
- {
- CString strResult;
- CString strName = pElement->GetName();
- double dPercent = pElement->GetPercentage();
- strResult.Format(_T("%s: %f\n"), strName, dPercent);
- strElementResult += strResult;
- }
- a_strEleResult = gcnew String(strElementResult);
- }
- return bRet;
- }
- bool COTSControlFunExport::GetXRayBySingleFeature(unsigned long a_nMilliseconds, COTSFeatureClr^ feature, array<unsigned long>^% a_XrayData, String^% a_strEleResult, bool bQuant)
- {
- std::vector<CPosXrayPtr> listXRayPoints;
- CPosXrayPtr pXRayPoint = CPosXrayPtr(new CPosXray());
- listXRayPoints.push_back(pXRayPoint);
- std::vector<BrukerSegment> listSegment;
- std::vector<BrukerFeature>listFeatures;
- auto otsSegs = feature->GetSegmentsList();
- for (int j = 0; j < otsSegs->Count; j++)
- {
- auto seg = otsSegs[j];
- BrukerSegment oSegment;
- oSegment.XCount = seg->GetLength();
- oSegment.XStart = seg->GetStart();
- oSegment.Y = seg->GetHeight();
- listSegment.push_back(oSegment);
- }
- BrukerFeature ofeature;
- ofeature.SegmentCount = listSegment.size();
- ofeature.pSegment = &listSegment[0];
- listFeatures.push_back(ofeature);
- bool bRet = FALSE;
- // set get quantify info flag
- if (bQuant)
- {
- m_pEDS->SetQuantification(TRUE);
- }
- else
- {
- m_pEDS->SetQuantification(FALSE);
- }
- bRet = m_pEDS->GetXRayByFeatures(listXRayPoints, listFeatures, a_nMilliseconds);
- DWORD* xrd;
- pXRayPoint = listXRayPoints[0];
- xrd = pXRayPoint->GetXrayData();
- for (int i = 0; i < (int)EDSConst::XANA_CHANNELS; i++)
- {
- a_XrayData[i] = xrd[i];
- }
- if (bQuant)
- {
- CElementChemistriesList& listElement = listXRayPoints[0]->GetElementQuantifyData();
- int nElementNum = (int)listElement.size();
- CString strElementResult = _T("");
- for (auto pElement : listElement)
- {
- CString strResult;
- CString strName = pElement->GetName();
- double dPercent = pElement->GetPercentage();
- strResult.Format(_T("%s: %f\n"), strName, dPercent);
- strElementResult += strResult;
- }
- a_strEleResult = gcnew String(strElementResult);
- }
- return bRet;
- }
- bool COTSControlFunExport::GetXRayElements(unsigned long a_nMilliseconds, array<unsigned long>^% a_XrayData, int^% a_nElementNum, String^% a_strResult)
- {
- std::vector<CPosXrayPtr> listXRayPoints;
- CPosXrayPtr pXRayPoint = CPosXrayPtr(new CPosXray());
- pXRayPoint->SetPosition(CPoint(10, 10));
- listXRayPoints.push_back(pXRayPoint);
- CPosXrayPtr pXRayPoint1 = CPosXrayPtr(new CPosXray());
- pXRayPoint1->SetPosition(CPoint(20, 20));
- listXRayPoints.push_back(pXRayPoint1);
- // set get quantify info flag
- m_pEDS->SetQuantification(TRUE);
- bool bRet = m_pEDS->GetXRayByPoints(listXRayPoints, a_nMilliseconds);
- //bool bRet = m_LpEDSBase->GetXRayByFeaturesFromMultiPoint(listXRayPoints, listFeatures, a_nMilliseconds);
- DWORD* xrd;
- pXRayPoint = listXRayPoints[1];
- xrd = pXRayPoint->GetXrayData();
- // element quantify data
- CElementChemistriesList& listElement = listXRayPoints[1]->GetElementQuantifyData();
- int nElementNum = (int)listElement.size();
- CString strElementResult = _T("");
- for (auto pElement : listElement)
- {
- CString strResult;
- CString strName = pElement->GetName();
- double dPercent = pElement->GetPercentage();
- strResult.Format(_T("%s: %f\n"), strName, dPercent);
- strElementResult += strResult;
- }
- for (int i = 0; i < (int)EDSConst::XANA_CHANNELS; i++)
- {
- a_XrayData[i] = xrd[i];
- }
- a_nElementNum = nElementNum;
- a_strResult = gcnew String(strElementResult);
- return bRet;
- }
- bool COTSControlFunExport::GetXRayAndElements(unsigned long a_nMilliseconds, int a_BSEX, int a_BSEY, array<unsigned long>^% a_XrayData, int^% a_nElementNum, String^% a_strResult)
- {
- std::vector<CPosXrayPtr> listXRayPoints;
- CPosXrayPtr pXRayPoint = CPosXrayPtr(new CPosXray());
- pXRayPoint->SetPosition(CPoint(a_BSEX, a_BSEY));
- listXRayPoints.push_back(pXRayPoint);
- CPosXrayPtr pXRayPoint1 = CPosXrayPtr(new CPosXray());
- pXRayPoint1->SetPosition(CPoint(a_BSEX, a_BSEY));
- listXRayPoints.push_back(pXRayPoint1);
- // set get quantify info flag
- m_pEDS->SetQuantification(FALSE);
- bool bRet = m_pEDS->GetXRayByPoints(listXRayPoints, a_nMilliseconds);
- //bool bRet = m_LpEDSBase->GetXRayByFeaturesFromMultiPoint(listXRayPoints, listFeatures, a_nMilliseconds);
- std::vector<CPosXrayPtr> listXRayPointsTemp;
- CPosXrayPtr pXRayPointTemp = CPosXrayPtr(new CPosXray());
- listXRayPointsTemp.push_back(pXRayPointTemp);
- for (int i = 0; i < 2; i++)
- {
- listXRayPointsTemp[0] = listXRayPoints[i];
- m_pEDS->SetQuantification(TRUE);
- bool bRet = m_pEDS->GetXRayByPoints(listXRayPointsTemp, a_nMilliseconds);
- listXRayPoints[i] = listXRayPointsTemp[0];
- }
- DWORD* xrd;
- pXRayPoint = listXRayPoints[1];
- xrd = pXRayPoint->GetXrayData();
- // element quantify data
- CElementChemistriesList& listElement = listXRayPoints[1]->GetElementQuantifyData();
- int nElementNum = (int)listElement.size();
- CString strElementResult = _T("");
- for (auto pElement : listElement)
- {
- CString strResult;
- CString strName = pElement->GetName();
- double dPercent = pElement->GetPercentage();
- strResult.Format(_T("%s: %f\n"), strName, dPercent);
- strElementResult += strResult;
- }
- for (int i = 0; i < (int)EDSConst::XANA_CHANNELS; i++)
- {
- a_XrayData[i] = xrd[i];
- }
- a_nElementNum = nElementNum;
- a_strResult = gcnew String(strElementResult);
- return bRet;
- }
- int COTSControlFunExport::AcquireBSEImage(int a_nMatrixIndex, int nReads, int nDwell, array<System::Byte>^% a_ImgData)
- {
- int bRet = 0;
- CSize sz;
- int height, width;
- CBSEImgPtr pbseImg = nullptr;
- pbseImg = m_pScan->AcquireBSEImage(a_nMatrixIndex, nReads, nDwell);
- sz = pbseImg->GetImageSize();
- height = sz.cx;
- width = sz.cy;
- bRet = height * width;
- BYTE* lpData = pbseImg->GetImageDataPointer();
- for (int i = 0; i < bRet; i++)
- {
- a_ImgData[i] = lpData[i];
- }
- return bRet;
- // return 0;
- }
- //void COTSControlFunExport::InitDevPoint()
- //{
- //
- //
- //
- //
- //}
- }
|