|
@@ -5,12 +5,8 @@
|
|
|
#include "BrukerSPXFileMgr.h"
|
|
|
#include "ControllerHelper.h"
|
|
|
#include <COTSUtilityDllFunExport.h>
|
|
|
-#include "CFindPeaks.h"
|
|
|
-
|
|
|
|
|
|
namespace OTSController {
|
|
|
-
|
|
|
-
|
|
|
|
|
|
unsigned int DEFAULT_MAX_WAIT_TIME_COLLECT_COUNTS = 5000;
|
|
|
|
|
@@ -866,8 +862,9 @@ namespace OTSController {
|
|
|
|
|
|
// create array of BrukerSegment
|
|
|
long nCollectCount = (long)a_vXPoints.size();
|
|
|
- //boost::scoped_array<BrukerSegment> segmentArray(new BrukerSegment[nCollectCount]);
|
|
|
- BrukerDll::PSegmentList segmentArray=new BrukerDll::TSegment[nCollectCount];
|
|
|
+
|
|
|
+ boost::scoped_array<BrukerDll::TSegment> segmentArray(new BrukerDll::TSegment[nCollectCount]);
|
|
|
+
|
|
|
for (int i = 0; i < nCollectCount; ++i)
|
|
|
{
|
|
|
CPoint poi = a_vXPoints[i]->GetPosition();
|
|
@@ -876,7 +873,7 @@ namespace OTSController {
|
|
|
}
|
|
|
|
|
|
// ask bruker to collect a set of x ray data
|
|
|
- if (!StartPointListMeasurement(nCollectCount, segmentArray, a_nACTimeMS))
|
|
|
+ if (!StartPointListMeasurement(nCollectCount, segmentArray.get(), a_nACTimeMS))
|
|
|
{
|
|
|
// failed to call StartPointListMeasurement method
|
|
|
LogTrace(__FILE__, __LINE__, _T("COTSBrukerImpl::CollectXRayPoints: failed to call StartPointListMeasurement method."));
|
|
@@ -890,7 +887,7 @@ namespace OTSController {
|
|
|
LogTrace(__FILE__, __LINE__, _T("COTSBrukerImpl::CollectXRayPoints: failed to call ReadXRayPoints method."));
|
|
|
return FALSE;
|
|
|
}
|
|
|
- delete segmentArray;
|
|
|
+ //delete segmentArray;
|
|
|
// ok return TRUE
|
|
|
return TRUE;
|
|
|
}
|
|
@@ -915,8 +912,9 @@ namespace OTSController {
|
|
|
|
|
|
// create array of BrukerSegment
|
|
|
long nCollectCount = (long)a_listXrayPois.size();
|
|
|
- //boost::scoped_array<BrukerSegment> segmentArray(new BrukerSegment[nCollectCount]);
|
|
|
- BrukerDll::PSegmentList segmentArray=new BrukerDll::TSegment[nCollectCount];
|
|
|
+
|
|
|
+ boost::scoped_array<BrukerDll::TSegment> segmentArray(new BrukerDll::TSegment[nCollectCount]);
|
|
|
+
|
|
|
for (int i = 0; i < nCollectCount; ++i)
|
|
|
{
|
|
|
CPoint poi = a_listXrayPois[i]->GetPosition();
|
|
@@ -926,7 +924,7 @@ namespace OTSController {
|
|
|
}
|
|
|
|
|
|
// ask bruker to collect a set of x ray data
|
|
|
- if (!StartPointListMeasurement(nCollectCount, segmentArray, a_nACTimeMS))
|
|
|
+ if (!StartPointListMeasurement(nCollectCount, segmentArray.get(), a_nACTimeMS))
|
|
|
{
|
|
|
// failed to call StartPointListMeasurement method
|
|
|
LogTrace(__FILE__, __LINE__, _T("COTSBrukerImpl::CollectXRayPoints: failed to call StartPointListMeasurement method."));
|
|
@@ -940,7 +938,7 @@ namespace OTSController {
|
|
|
LogTrace(__FILE__, __LINE__, _T("COTSBrukerImpl::CollectXRayPoints: failed to call ReadXRayPoints method."));
|
|
|
return FALSE;
|
|
|
}
|
|
|
- delete segmentArray;
|
|
|
+ //delete segmentArray;
|
|
|
// ok return TRUE
|
|
|
return TRUE;
|
|
|
}
|
|
@@ -975,11 +973,10 @@ namespace OTSController {
|
|
|
long nCollectCount = (long)a_vXPoints.size();
|
|
|
long nTotalPixelCount = 0;
|
|
|
|
|
|
- // add by Jieshi 23/08/2017
|
|
|
- /*boost::scoped_array<WORD> pixelTimes(new WORD[nCollectCount]);
|
|
|
- boost::scoped_array<BrukerFeature> features(new BrukerFeature[nCollectCount]);*/
|
|
|
- SHORT* pixelTimes(new SHORT[nCollectCount]);
|
|
|
- BrukerDll::TFeatureData* features(new BrukerDll::TFeatureData[nCollectCount]);
|
|
|
+
|
|
|
+ boost::scoped_array<SHORT*> pixelTimes(new SHORT*[nCollectCount]);
|
|
|
+ boost::scoped_array<BrukerDll::TFeatureData> features(new BrukerDll::TFeatureData[nCollectCount]);
|
|
|
+
|
|
|
|
|
|
std::vector<BrukerDll::TSegment> extraSegments;
|
|
|
for (size_t i = 0; i < a_vXPoints.size(); i++)
|
|
@@ -989,12 +986,12 @@ namespace OTSController {
|
|
|
{
|
|
|
int segCount = features[i].SegmentCount;
|
|
|
auto ofeature = a_vFeatures[i];
|
|
|
- features->Segments = new BrukerDll::TSegment[segCount];
|
|
|
+ features.get()->Segments = new BrukerDll::TSegment[segCount];
|
|
|
for (int j = 0; j < segCount; j++)
|
|
|
{
|
|
|
- features->Segments[j].XStart = ofeature.pSegment[j].XStart;
|
|
|
- features->Segments[j].XCount = ofeature.pSegment[j].XCount;
|
|
|
- features->Segments[j].Y = ofeature.pSegment[j].Y;
|
|
|
+ features.get()->Segments[j].XStart = ofeature.pSegment[j].XStart;
|
|
|
+ features.get()->Segments[j].XCount = ofeature.pSegment[j].XCount;
|
|
|
+ features.get()->Segments[j].Y = ofeature.pSegment[j].Y;
|
|
|
}
|
|
|
|
|
|
//features[i].Segments = &a_vFeatures[i].pSegment;
|
|
@@ -1006,7 +1003,7 @@ namespace OTSController {
|
|
|
nPixelCount += features[i].Segments[j].XCount;
|
|
|
}
|
|
|
|
|
|
- pixelTimes[i] = (WORD)(a_nACTimeMS * 1000 / nPixelCount);
|
|
|
+ *pixelTimes[i] = (SHORT)(a_nACTimeMS * 1000 / nPixelCount);
|
|
|
nTotalPixelCount += nPixelCount;
|
|
|
}
|
|
|
else
|
|
@@ -1019,12 +1016,13 @@ namespace OTSController {
|
|
|
features[i].SegmentCount = 1;
|
|
|
features[i].Segments = &extraSegments[extraSegments.size() - 1];
|
|
|
|
|
|
- pixelTimes[i] = (WORD)(a_nACTimeMS * 1000);
|
|
|
+ *pixelTimes[i] = (SHORT)(a_nACTimeMS * 1000);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
// ask bruker to collect a set of x-ray data
|
|
|
- if (!StartFeatureListMeasurement(nCollectCount, features, &pixelTimes))
|
|
|
+
|
|
|
+ if (!StartFeatureListMeasurement(nCollectCount, features.get(), pixelTimes.get()))
|
|
|
{
|
|
|
// failed to call StartFeatureListMeasurement method
|
|
|
LogErrorTrace(__FILE__, __LINE__, _T("COTSBrukerImpl::CollectXRayPointsByFeatures: failed to call StartFeatureListMeasurement method."));
|
|
@@ -1039,9 +1037,7 @@ namespace OTSController {
|
|
|
return FALSE;
|
|
|
}
|
|
|
|
|
|
- delete pixelTimes;
|
|
|
- delete features;
|
|
|
- // ok, return TRUE
|
|
|
+
|
|
|
return TRUE;
|
|
|
}
|
|
|
|
|
@@ -2543,7 +2539,9 @@ BOOL COTSBrukerImpl::GetXRayByPoints(CPosXraysList& a_listXrayPois, DWORD a_nACT
|
|
|
|
|
|
// create array of BrukerSegment
|
|
|
long nCollectCount = (long)a_listXrayPois.size();
|
|
|
- BrukerDll::PSegmentList segmentArray=new BrukerDll::TSegment[nCollectCount];
|
|
|
+
|
|
|
+ boost::scoped_array<BrukerDll::TSegment> segmentArray(new BrukerDll::TSegment[nCollectCount]);
|
|
|
+
|
|
|
for (int i = 0; i < nCollectCount; ++i)
|
|
|
{
|
|
|
CPoint poi = a_listXrayPois[i]->GetPosition();
|
|
@@ -2553,7 +2551,7 @@ BOOL COTSBrukerImpl::GetXRayByPoints(CPosXraysList& a_listXrayPois, DWORD a_nACT
|
|
|
}
|
|
|
|
|
|
// ask Bruker to collect a set of x ray data
|
|
|
- if (!StartPointListMeasurement(nCollectCount, segmentArray, a_nACTimeMS))
|
|
|
+ if (!StartPointListMeasurement(nCollectCount, segmentArray.get(), a_nACTimeMS))
|
|
|
{
|
|
|
// failed to call StartPointListMeasurement method
|
|
|
LogTrace(__FILE__, __LINE__, _T("COTSBrukerImpl::CollectXRayPoints: failed to call StartPointListMeasurement method."));
|
|
@@ -2567,7 +2565,7 @@ BOOL COTSBrukerImpl::GetXRayByPoints(CPosXraysList& a_listXrayPois, DWORD a_nACT
|
|
|
LogTrace(__FILE__, __LINE__, _T("COTSBrukerImpl::CollectXRayPoints: failed to call ReadXRayPoints method."));
|
|
|
return FALSE;
|
|
|
}
|
|
|
- delete[] segmentArray;
|
|
|
+ //delete[] segmentArray;
|
|
|
// ok return TRUE
|
|
|
return TRUE;
|
|
|
|
|
@@ -2600,38 +2598,11 @@ BOOL COTSBrukerImpl::SetXRayPoints(CPosXraysList& a_listXrayPois, const DWORD a_
|
|
|
// cleanup data storage
|
|
|
memset(nChannelData, 0, sizeof(DWORD) * (int)BRUKER_PARAM::RT_SPECTRUM_CHANNELS);
|
|
|
|
|
|
- // get spectrum data of a point
|
|
|
- bool success = GetPointListSpectrum(i, (long*)nChannelData);
|
|
|
- if (!success)
|
|
|
- {
|
|
|
- // error
|
|
|
- CPoint poi = a_listXrayPois[i]->GetPosition();
|
|
|
- LogErrorTrace(__FILE__, __LINE__, _T("COTSBrukerImpl::SetXRayPoints:Call GetPointListSpectrum failed : index = %d(x : %d, y : %d)"),
|
|
|
- i,
|
|
|
- poi.x,
|
|
|
- poi.y);
|
|
|
-
|
|
|
- return FALSE;
|
|
|
- }
|
|
|
-
|
|
|
- /*std::vector<double> peakList;
|
|
|
- std::vector<CString> eleList;
|
|
|
- for (size_t i = 0; i < a_listXrayPois[i]->GetElementQuantifyData().size(); i++)
|
|
|
- {
|
|
|
- eleList.push_back(a_listXrayPois[i]->GetElementQuantifyData()[i]->GetName());
|
|
|
- }
|
|
|
- bool isFilter = false;*/
|
|
|
- /*if (eleList.size() != 0)
|
|
|
+ if (m_bDoQuantification)
|
|
|
{
|
|
|
- isFilter = CPeak::FindPeaks(nChannelData, eleList);
|
|
|
- }*/
|
|
|
-
|
|
|
- //bool isFilter = true;
|
|
|
|
|
|
- if (m_bDoQuantification/* && isFilter*/)
|
|
|
- {
|
|
|
// quantify the spectrum
|
|
|
- char* pcMethod = "Oxides";//"Default";//"Automatic";//Oxides
|
|
|
+ char* pcMethod = "Default";//"Default";//"Automatic";
|
|
|
char* pcParams = "ResultType=quantification";
|
|
|
char cResult[10000];
|
|
|
memset(cResult, 0, 10000);
|
|
@@ -2641,13 +2612,22 @@ BOOL COTSBrukerImpl::SetXRayPoints(CPosXraysList& a_listXrayPois, const DWORD a_
|
|
|
LogErrorTrace(__FILE__, __LINE__, _T("COTSBrukerImpl::SetXRayPoints failed to call QuantifyPointListSpectrum method at index %d, error code %d"), i, -1);
|
|
|
//return FALSE;
|
|
|
}
|
|
|
- //LogErrorTrace(__FILE__, __LINE__, cResult);
|
|
|
CElementChemistriesList listElement = CElement::ExtractElementChemistrys(CControllerHelper::CharToString(cResult));
|
|
|
a_listXrayPois[i]->SetElementQuantifyData(listElement);
|
|
|
}
|
|
|
- else
|
|
|
+
|
|
|
+ // get spectrum data of a point
|
|
|
+ bool success = GetPointListSpectrum(i, (long*)nChannelData);
|
|
|
+ if (!success)
|
|
|
{
|
|
|
- a_listXrayPois[i]->GetElementQuantifyData().clear();
|
|
|
+ // error
|
|
|
+ CPoint poi = a_listXrayPois[i]->GetPosition();
|
|
|
+ LogErrorTrace(__FILE__, __LINE__, _T("COTSBrukerImpl::SetXRayPoints:Call GetPointListSpectrum failed : index = %d(x : %d, y : %d)"),
|
|
|
+ i,
|
|
|
+ poi.x,
|
|
|
+ poi.y);
|
|
|
+
|
|
|
+ return FALSE;
|
|
|
}
|
|
|
|
|
|
// set spectrum data for the x-ray point
|
|
@@ -2729,10 +2709,11 @@ BOOL COTSBrukerImpl::GetXRayByFeatures(CPosXraysList& a_vXPoints, std::vector<Br
|
|
|
long nCollectCount = (long)a_vXPoints.size();
|
|
|
long nTotalPixelCount = 0;
|
|
|
|
|
|
- // added by Jieshi 23/08/2017
|
|
|
- SHORT* pixelTimes(new SHORT[nCollectCount]);
|
|
|
- BrukerDll::PFeatureDataList features=new BrukerDll::TFeatureData[nCollectCount];
|
|
|
+
|
|
|
+ boost::scoped_array<SHORT*> pixelTimes(new SHORT*[nCollectCount]);
|
|
|
+ boost::scoped_array<BrukerDll::TFeatureData> features(new BrukerDll::TFeatureData[nCollectCount]);
|
|
|
std::vector<BrukerDll::TSegment> extraSegments;
|
|
|
+
|
|
|
for (size_t i = 0; i < nCollectCount; i++)
|
|
|
{
|
|
|
BrukerFeature ofeature = a_vFeatures[i];
|
|
@@ -2741,12 +2722,12 @@ BOOL COTSBrukerImpl::GetXRayByFeatures(CPosXraysList& a_vXPoints, std::vector<Br
|
|
|
{
|
|
|
int segCount = features[i].SegmentCount;
|
|
|
auto ofeature = a_vFeatures[i];
|
|
|
- features->Segments = new BrukerDll::TSegment[segCount];
|
|
|
+ features.get()->Segments = new BrukerDll::TSegment[segCount];
|
|
|
for (int j = 0; j < segCount; j++)
|
|
|
{
|
|
|
- features->Segments[j].XStart = ofeature.pSegment[j].XStart;
|
|
|
- features->Segments[j].XCount = ofeature.pSegment[j].XCount;
|
|
|
- features->Segments[j].Y = ofeature.pSegment[j].Y;
|
|
|
+ features.get()->Segments[j].XStart = ofeature.pSegment[j].XStart;
|
|
|
+ features.get()->Segments[j].XCount = ofeature.pSegment[j].XCount;
|
|
|
+ features.get()->Segments[j].Y = ofeature.pSegment[j].Y;
|
|
|
}
|
|
|
|
|
|
// calculate pixel time
|
|
@@ -2757,7 +2738,7 @@ BOOL COTSBrukerImpl::GetXRayByFeatures(CPosXraysList& a_vXPoints, std::vector<Br
|
|
|
{
|
|
|
nPixelCount += ofeature.pSegment[j].XCount;
|
|
|
}
|
|
|
- pixelTimes[i] = (WORD)(ceil((double)a_nACTimeMS * 1000.0 / (double)nPixelCount));
|
|
|
+ *pixelTimes[i] = (SHORT)(ceil((double)a_nACTimeMS * 1000.0 / (double)nPixelCount));
|
|
|
|
|
|
nTotalPixelCount += nPixelCount;
|
|
|
}
|
|
@@ -2765,7 +2746,7 @@ BOOL COTSBrukerImpl::GetXRayByFeatures(CPosXraysList& a_vXPoints, std::vector<Br
|
|
|
{
|
|
|
// will generate according to the x-ray position
|
|
|
// this shouldn't happen
|
|
|
- //BrukerFeature* features(new BrukerFeature[nCollectCount]);
|
|
|
+
|
|
|
BrukerDll::PFeatureDataList features = new BrukerDll::TFeatureData[nCollectCount];
|
|
|
extraSegments.push_back(BrukerDll::TSegment());
|
|
|
extraSegments[extraSegments.size() - 1].XStart = a_vXPoints[i]->GetPosition().x;
|
|
@@ -2773,13 +2754,14 @@ BOOL COTSBrukerImpl::GetXRayByFeatures(CPosXraysList& a_vXPoints, std::vector<Br
|
|
|
features[i].SegmentCount = 1;
|
|
|
features[i].Segments = &extraSegments[extraSegments.size() - 1];
|
|
|
|
|
|
- pixelTimes[i] = (WORD)(a_nACTimeMS * 1000);
|
|
|
+ *pixelTimes[i] = (SHORT)(a_nACTimeMS * 1000);
|
|
|
|
|
|
}
|
|
|
}
|
|
|
|
|
|
// ask bruker to collect a set of x-ray data
|
|
|
- if (!StartFeatureListMeasurement(nCollectCount, features, &pixelTimes))
|
|
|
+
|
|
|
+ if (!StartFeatureListMeasurement(nCollectCount, features.get(), pixelTimes.get()))
|
|
|
{
|
|
|
// failed to call StartFeatureListMeasurement method
|
|
|
LogErrorTrace(__FILE__, __LINE__, _T("COTSBrukerImpl::CollectXRayPointsByFeatures: failed to call StartFeatureListMeasurement method."));
|
|
@@ -2793,8 +2775,6 @@ BOOL COTSBrukerImpl::GetXRayByFeatures(CPosXraysList& a_vXPoints, std::vector<Br
|
|
|
LogErrorTrace(__FILE__, __LINE__, _T("COTSBrukerImpl::CollectXRayPointsByFeatures: failed to call ReadXRayPointsByFeature method."));
|
|
|
return FALSE;
|
|
|
}
|
|
|
- delete[] pixelTimes;
|
|
|
- delete[] features;
|
|
|
|
|
|
return TRUE;
|
|
|
}
|