|  | @@ -858,154 +858,163 @@ namespace OTSController {
 | 
	
		
			
				|  |  |  	}
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |  	
 | 
	
		
			
				|  |  | -	BOOL COTSBrukerImpl::CollectXRayPoints(CPosXrayList& a_listXrayPois, DWORD a_nACTimeMS)
 | 
	
		
			
				|  |  | -	{
 | 
	
		
			
				|  |  | -
 | 
	
		
			
				|  |  | -		// do nothing if points list is empty
 | 
	
		
			
				|  |  | -		if (a_listXrayPois.empty())
 | 
	
		
			
				|  |  | -		{
 | 
	
		
			
				|  |  | -			// points list is empty
 | 
	
		
			
				|  |  | -			LogTrace(__FILE__, __LINE__, _T("COTSBrukerImpl::CollectXRayPoints: poits list is empty."));
 | 
	
		
			
				|  |  | -			return TRUE;
 | 
	
		
			
				|  |  | -		}
 | 
	
		
			
				|  |  | +	//BOOL COTSBrukerImpl::CollectXRayPoints(CPosXrayList& a_listXrayPois, DWORD a_nACTimeMS)
 | 
	
		
			
				|  |  | +	//{
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | -		// turn SEM to external
 | 
	
		
			
				|  |  | -		if (!SetSEMExternalOn())
 | 
	
		
			
				|  |  | -		{
 | 
	
		
			
				|  |  | -			// failed to call SetSEMExternalOn method
 | 
	
		
			
				|  |  | -			LogTrace(__FILE__, __LINE__, _T("COTSBrukerImpl::CollectXRayPoints: failed to call SetSEMExternalOn method."));
 | 
	
		
			
				|  |  | -			return FALSE;
 | 
	
		
			
				|  |  | -		}
 | 
	
		
			
				|  |  | +	//	// do nothing if points list is empty
 | 
	
		
			
				|  |  | +	//	if (a_listXrayPois.empty())
 | 
	
		
			
				|  |  | +	//	{
 | 
	
		
			
				|  |  | +	//		// points list is empty
 | 
	
		
			
				|  |  | +	//		LogTrace(__FILE__, __LINE__, _T("COTSBrukerImpl::CollectXRayPoints: poits list is empty."));
 | 
	
		
			
				|  |  | +	//		return TRUE;
 | 
	
		
			
				|  |  | +	//	}
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | -		// create array of BrukerSegment
 | 
	
		
			
				|  |  | -		long nCollectCount = (long)a_listXrayPois.size();
 | 
	
		
			
				|  |  | +	//	// turn SEM to external
 | 
	
		
			
				|  |  | +	//	if (!SetSEMExternalOn())
 | 
	
		
			
				|  |  | +	//	{
 | 
	
		
			
				|  |  | +	//		// failed to call SetSEMExternalOn method
 | 
	
		
			
				|  |  | +	//		LogTrace(__FILE__, __LINE__, _T("COTSBrukerImpl::CollectXRayPoints: failed to call SetSEMExternalOn method."));
 | 
	
		
			
				|  |  | +	//		return FALSE;
 | 
	
		
			
				|  |  | +	//	}
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | -		boost::scoped_array<BrukerDll::TSegment> segmentArray(new BrukerDll::TSegment[nCollectCount]);
 | 
	
		
			
				|  |  | +	//	// create array of BrukerSegment
 | 
	
		
			
				|  |  | +	//	long nCollectCount = (long)a_listXrayPois.size();
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | -		for (int i = 0; i < nCollectCount; ++i)
 | 
	
		
			
				|  |  | -		{
 | 
	
		
			
				|  |  | -			CPoint poi = a_listXrayPois[i]->GetPosition();
 | 
	
		
			
				|  |  | -			segmentArray[i].Y = poi.y;
 | 
	
		
			
				|  |  | -			segmentArray[i].XStart = poi.x;
 | 
	
		
			
				|  |  | -			segmentArray[i].XCount = 1;
 | 
	
		
			
				|  |  | -		}
 | 
	
		
			
				|  |  | +	//	boost::scoped_array<BrukerDll::TSegment> segmentArray(new BrukerDll::TSegment[nCollectCount]);
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | -		// ask bruker to collect a set of x ray data
 | 
	
		
			
				|  |  | -		if (!StartPointListMeasurement(nCollectCount, segmentArray.get(), a_nACTimeMS))
 | 
	
		
			
				|  |  | -		{
 | 
	
		
			
				|  |  | -			// failed to call StartPointListMeasurement method
 | 
	
		
			
				|  |  | -			LogTrace(__FILE__, __LINE__, _T("COTSBrukerImpl::CollectXRayPoints: failed to call StartPointListMeasurement method."));
 | 
	
		
			
				|  |  | -			return FALSE;
 | 
	
		
			
				|  |  | -		}
 | 
	
		
			
				|  |  | +	//	for (int i = 0; i < nCollectCount; ++i)
 | 
	
		
			
				|  |  | +	//	{
 | 
	
		
			
				|  |  | +	//		CPoint poi = a_listXrayPois[i]->GetPosition();
 | 
	
		
			
				|  |  | +	//		segmentArray[i].Y = poi.y;
 | 
	
		
			
				|  |  | +	//		segmentArray[i].XStart = poi.x;
 | 
	
		
			
				|  |  | +	//		segmentArray[i].XCount = 1;
 | 
	
		
			
				|  |  | +	//	}
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | -		// get the specs for a_listXrayPois
 | 
	
		
			
				|  |  | -		if (!ReadXRayPoints(a_listXrayPois, a_nACTimeMS))
 | 
	
		
			
				|  |  | -		{
 | 
	
		
			
				|  |  | -			// failed to call ReadXRayPoints method
 | 
	
		
			
				|  |  | -			LogTrace(__FILE__, __LINE__, _T("COTSBrukerImpl::CollectXRayPoints: failed to call ReadXRayPoints method."));
 | 
	
		
			
				|  |  | -			return FALSE;
 | 
	
		
			
				|  |  | -		}
 | 
	
		
			
				|  |  | -		
 | 
	
		
			
				|  |  | -		return TRUE;
 | 
	
		
			
				|  |  | -	}
 | 
	
		
			
				|  |  | +	//	// ask bruker to collect a set of x ray data
 | 
	
		
			
				|  |  | +	//	//if (!StartPointListMeasurement(nCollectCount, segmentArray, a_nACTimeMS))
 | 
	
		
			
				|  |  | +	//	//{
 | 
	
		
			
				|  |  | +	//	//	// failed to call StartPointListMeasurement method
 | 
	
		
			
				|  |  | +	//	//	LogTrace(__FILE__, __LINE__, _T("COTSBrukerImpl::CollectXRayPoints: failed to call StartPointListMeasurement method."));
 | 
	
		
			
				|  |  | +	//	//	return FALSE;
 | 
	
		
			
				|  |  | +	//	//}
 | 
	
		
			
				|  |  | +	//	if (BrukerDll::StartPointListMeasurement(m_nClientID, m_nSPU, nCollectCount, segmentArray, a_nACTimeMS) != 0)
 | 
	
		
			
				|  |  | +	//	{
 | 
	
		
			
				|  |  | +	//		LogErrorTrace(__FILE__, __LINE__, _T("COTSBrukerImpl::StartFeatureListMeasurement:Call StartFeatureListMeasurement failed: client id is %d"), m_nClientID);
 | 
	
		
			
				|  |  | +	//		return FALSE;
 | 
	
		
			
				|  |  | +	//	}
 | 
	
		
			
				|  |  | +	//	// get the specs for a_listXrayPois
 | 
	
		
			
				|  |  | +	//	if (!ReadXRayPoints(a_listXrayPois, a_nACTimeMS))
 | 
	
		
			
				|  |  | +	//	{
 | 
	
		
			
				|  |  | +	//		// failed to call ReadXRayPoints method
 | 
	
		
			
				|  |  | +	//		LogTrace(__FILE__, __LINE__, _T("COTSBrukerImpl::CollectXRayPoints: failed to call ReadXRayPoints method."));
 | 
	
		
			
				|  |  | +	//		return FALSE;
 | 
	
		
			
				|  |  | +	//	}
 | 
	
		
			
				|  |  | +	//	
 | 
	
		
			
				|  |  | +	//	return TRUE;
 | 
	
		
			
				|  |  | +	//}
 | 
	
		
			
				|  |  |  	// collect x ray points (area scan)
 | 
	
		
			
				|  |  | -	BOOL COTSBrukerImpl::CollectXRayPointsByFeatures(std::vector<CPosXray*>& a_vXPoints, std::vector<BrukerFeature>& a_vFeatures, DWORD a_nACTimeMS)
 | 
	
		
			
				|  |  | -	{
 | 
	
		
			
				|  |  | +	//BOOL COTSBrukerImpl::CollectXRayPointsByFeatures(std::vector<CPosXray*>& a_vXPoints, std::vector<BrukerFeature>& a_vFeatures, DWORD a_nACTimeMS)
 | 
	
		
			
				|  |  | +	//{
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | -		// do nothing if points list is empty
 | 
	
		
			
				|  |  | -		if (a_vXPoints.empty())
 | 
	
		
			
				|  |  | -		{
 | 
	
		
			
				|  |  | -			// points list is empty
 | 
	
		
			
				|  |  | -			LogTrace(__FILE__, __LINE__, _T("COTSBrukerImpl::CollectXRayPointsByFeatures: poits list is empty."));
 | 
	
		
			
				|  |  | -			return TRUE;
 | 
	
		
			
				|  |  | -		}
 | 
	
		
			
				|  |  | +	//	// do nothing if points list is empty
 | 
	
		
			
				|  |  | +	//	if (a_vXPoints.empty())
 | 
	
		
			
				|  |  | +	//	{
 | 
	
		
			
				|  |  | +	//		// points list is empty
 | 
	
		
			
				|  |  | +	//		LogTrace(__FILE__, __LINE__, _T("COTSBrukerImpl::CollectXRayPointsByFeatures: poits list is empty."));
 | 
	
		
			
				|  |  | +	//		return TRUE;
 | 
	
		
			
				|  |  | +	//	}
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | -		// lists size check
 | 
	
		
			
				|  |  | -		if (a_vXPoints.size() != a_vFeatures.size())
 | 
	
		
			
				|  |  | -		{
 | 
	
		
			
				|  |  | -			LogErrorTrace(__FILE__, __LINE__, _T("COTSBrukerImpl::CollectXRayPointsByFeatures:Feature size(%d) doesn't match xray point size(%d)"), a_vFeatures.size(), a_vXPoints.size());
 | 
	
		
			
				|  |  | -			return FALSE;
 | 
	
		
			
				|  |  | -		}
 | 
	
		
			
				|  |  | +	//	// lists size check
 | 
	
		
			
				|  |  | +	//	if (a_vXPoints.size() != a_vFeatures.size())
 | 
	
		
			
				|  |  | +	//	{
 | 
	
		
			
				|  |  | +	//		LogErrorTrace(__FILE__, __LINE__, _T("COTSBrukerImpl::CollectXRayPointsByFeatures:Feature size(%d) doesn't match xray point size(%d)"), a_vFeatures.size(), a_vXPoints.size());
 | 
	
		
			
				|  |  | +	//		return FALSE;
 | 
	
		
			
				|  |  | +	//	}
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | -		// set SEM to external
 | 
	
		
			
				|  |  | -		if (!SetSEMExternalOn())
 | 
	
		
			
				|  |  | -		{
 | 
	
		
			
				|  |  | -			// failed to call SetSEMExternalOn method
 | 
	
		
			
				|  |  | -			LogTrace(__FILE__, __LINE__, _T("COTSBrukerImpl::CollectXRayPointsByFeatures: failed to call SetSEMExternalOn method."));
 | 
	
		
			
				|  |  | -			return FALSE;
 | 
	
		
			
				|  |  | -		}
 | 
	
		
			
				|  |  | +	//	// set SEM to external
 | 
	
		
			
				|  |  | +	//	if (!SetSEMExternalOn())
 | 
	
		
			
				|  |  | +	//	{
 | 
	
		
			
				|  |  | +	//		// failed to call SetSEMExternalOn method
 | 
	
		
			
				|  |  | +	//		LogTrace(__FILE__, __LINE__, _T("COTSBrukerImpl::CollectXRayPointsByFeatures: failed to call SetSEMExternalOn method."));
 | 
	
		
			
				|  |  | +	//		return FALSE;
 | 
	
		
			
				|  |  | +	//	}
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | -		// create array of BrukerSegment
 | 
	
		
			
				|  |  | -		long nCollectCount = (long)a_vXPoints.size();
 | 
	
		
			
				|  |  | -		long nTotalPixelCount = 0;
 | 
	
		
			
				|  |  | +	//	// create array of BrukerSegment
 | 
	
		
			
				|  |  | +	//	long nCollectCount = (long)a_vXPoints.size();
 | 
	
		
			
				|  |  | +	//	long nTotalPixelCount = 0;
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | -		boost::scoped_array<SHORT*> pixelTimes(new SHORT*[nCollectCount]);
 | 
	
		
			
				|  |  | -		boost::scoped_array<BrukerDll::TFeatureData> features(new BrukerDll::TFeatureData[nCollectCount]);
 | 
	
		
			
				|  |  | +	//	SHORT* pixelTimes=new SHORT[nCollectCount];
 | 
	
		
			
				|  |  | +	//	BrukerDll::TFeatureData* features=new BrukerDll::TFeatureData[nCollectCount];
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | -		std::vector<BrukerDll::TSegment> extraSegments;
 | 
	
		
			
				|  |  | -		for (size_t i = 0; i < a_vXPoints.size(); i++)
 | 
	
		
			
				|  |  | -		{
 | 
	
		
			
				|  |  | -			features[i].SegmentCount = (long)a_vFeatures[i].SegmentCount;
 | 
	
		
			
				|  |  | -			if (features[i].SegmentCount > 0)
 | 
	
		
			
				|  |  | -			{
 | 
	
		
			
				|  |  | -				int segCount = features[i].SegmentCount;
 | 
	
		
			
				|  |  | -				auto ofeature = a_vFeatures[i];
 | 
	
		
			
				|  |  | -				features.get()->Segments = new BrukerDll::TSegment[segCount];
 | 
	
		
			
				|  |  | -					for (int j = 0; j < segCount; j++)
 | 
	
		
			
				|  |  | -					{
 | 
	
		
			
				|  |  | -						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;
 | 
	
		
			
				|  |  | -
 | 
	
		
			
				|  |  | -				// calculate pixel time
 | 
	
		
			
				|  |  | -				int nPixelCount = 0;
 | 
	
		
			
				|  |  | -				for (int j = 0; j < features[i].SegmentCount; j++)
 | 
	
		
			
				|  |  | -				{
 | 
	
		
			
				|  |  | -					nPixelCount += features[i].Segments[j].XCount;
 | 
	
		
			
				|  |  | -				}
 | 
	
		
			
				|  |  | -				SHORT pt= (SHORT)(a_nACTimeMS * 1000 / nPixelCount);
 | 
	
		
			
				|  |  | -				pixelTimes[i] = &pt;
 | 
	
		
			
				|  |  | -				nTotalPixelCount += nPixelCount;
 | 
	
		
			
				|  |  | -			}
 | 
	
		
			
				|  |  | -			else
 | 
	
		
			
				|  |  | -			{
 | 
	
		
			
				|  |  | -				// will generate according to the x-ray position
 | 
	
		
			
				|  |  | -				// this shouldn't happen
 | 
	
		
			
				|  |  | -				extraSegments.push_back(BrukerDll::TSegment());
 | 
	
		
			
				|  |  | -				extraSegments[extraSegments.size() - 1].XStart = a_vXPoints[i]->GetPosition().x;
 | 
	
		
			
				|  |  | -				extraSegments[extraSegments.size() - 1].Y = a_vXPoints[i]->GetPosition().y;
 | 
	
		
			
				|  |  | -				features[i].SegmentCount = 1;
 | 
	
		
			
				|  |  | -				features[i].Segments = &extraSegments[extraSegments.size() - 1];
 | 
	
		
			
				|  |  | -				SHORT pt = (SHORT)(a_nACTimeMS * 1000);
 | 
	
		
			
				|  |  | -				pixelTimes[i] = &pt;
 | 
	
		
			
				|  |  | -			}
 | 
	
		
			
				|  |  | -		}
 | 
	
		
			
				|  |  | +	//	std::vector<BrukerDll::TSegment> extraSegments;
 | 
	
		
			
				|  |  | +	//	for (size_t i = 0; i < a_vXPoints.size(); i++)
 | 
	
		
			
				|  |  | +	//	{
 | 
	
		
			
				|  |  | +	//		features[i].SegmentCount = (long)a_vFeatures[i].SegmentCount;
 | 
	
		
			
				|  |  | +	//		if (features[i].SegmentCount > 0)
 | 
	
		
			
				|  |  | +	//		{
 | 
	
		
			
				|  |  | +	//			int segCount = features[i].SegmentCount;
 | 
	
		
			
				|  |  | +	//			auto ofeature = a_vFeatures[i];
 | 
	
		
			
				|  |  | +	//			features->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[i].Segments = &a_vFeatures[i].pSegment;
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +	//			// calculate pixel time
 | 
	
		
			
				|  |  | +	//			int nPixelCount = 0;
 | 
	
		
			
				|  |  | +	//			for (int j = 0; j < features[i].SegmentCount; j++)
 | 
	
		
			
				|  |  | +	//			{
 | 
	
		
			
				|  |  | +	//				nPixelCount += features[i].Segments[j].XCount;
 | 
	
		
			
				|  |  | +	//			}
 | 
	
		
			
				|  |  | +	//			//SHORT pt= (SHORT)(a_nACTimeMS * 1000 / nPixelCount);
 | 
	
		
			
				|  |  | +	//			pixelTimes[i] = (SHORT)(a_nACTimeMS * 1000 / nPixelCount);
 | 
	
		
			
				|  |  | +	//			nTotalPixelCount += nPixelCount;
 | 
	
		
			
				|  |  | +	//		}
 | 
	
		
			
				|  |  | +	//		else
 | 
	
		
			
				|  |  | +	//		{
 | 
	
		
			
				|  |  | +	//			// will generate according to the x-ray position
 | 
	
		
			
				|  |  | +	//			// this shouldn't happen
 | 
	
		
			
				|  |  | +	//			extraSegments.push_back(BrukerDll::TSegment());
 | 
	
		
			
				|  |  | +	//			extraSegments[extraSegments.size() - 1].XStart = a_vXPoints[i]->GetPosition().x;
 | 
	
		
			
				|  |  | +	//			extraSegments[extraSegments.size() - 1].Y = a_vXPoints[i]->GetPosition().y;
 | 
	
		
			
				|  |  | +	//			features[i].SegmentCount = 1;
 | 
	
		
			
				|  |  | +	//			features[i].Segments = &extraSegments[extraSegments.size() - 1];
 | 
	
		
			
				|  |  | +	//			//SHORT pt = (SHORT)(a_nACTimeMS * 1000);
 | 
	
		
			
				|  |  | +	//			pixelTimes[i] = (SHORT)(a_nACTimeMS * 1000);
 | 
	
		
			
				|  |  | +	//		}
 | 
	
		
			
				|  |  | +	//	}
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | -		// ask bruker to collect a set of x-ray data
 | 
	
		
			
				|  |  | +	//	// ask bruker to collect a set of x-ray data
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | -		if (!StartFeatureListMeasurement(nCollectCount, features.get(), pixelTimes.get()))
 | 
	
		
			
				|  |  | -		{
 | 
	
		
			
				|  |  | -			// failed to call StartFeatureListMeasurement method
 | 
	
		
			
				|  |  | -			LogErrorTrace(__FILE__, __LINE__, _T("COTSBrukerImpl::CollectXRayPointsByFeatures: failed to call StartFeatureListMeasurement method."));
 | 
	
		
			
				|  |  | -			return FALSE;
 | 
	
		
			
				|  |  | -		}
 | 
	
		
			
				|  |  | +	//	//if (!StartFeatureListMeasurement(nCollectCount, features.get(), pixelTimes.get()))
 | 
	
		
			
				|  |  | +	//	//{
 | 
	
		
			
				|  |  | +	//	//	// failed to call StartFeatureListMeasurement method
 | 
	
		
			
				|  |  | +	//	//	LogErrorTrace(__FILE__, __LINE__, _T("COTSBrukerImpl::CollectXRayPointsByFeatures: failed to call StartFeatureListMeasurement method."));
 | 
	
		
			
				|  |  | +	//	//	return FALSE;
 | 
	
		
			
				|  |  | +	//	//}
 | 
	
		
			
				|  |  | +	//	if (BrukerDll::StartFeatureListMeasurement(m_nClientID, m_nSPU, nCollectCount, features, &pixelTimes) != 0)
 | 
	
		
			
				|  |  | +	//	{
 | 
	
		
			
				|  |  | +	//		LogErrorTrace(__FILE__, __LINE__, _T("COTSBrukerImpl::StartFeatureListMeasurement:Call StartFeatureListMeasurement failed: client id is %d"), m_nClientID);
 | 
	
		
			
				|  |  | +	//		return FALSE;
 | 
	
		
			
				|  |  | +	//	}
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | -		// get the specs for a_vXPoints
 | 
	
		
			
				|  |  | -		if (!ReadXRayPointsByFeature(a_vXPoints, a_nACTimeMS))
 | 
	
		
			
				|  |  | -		{
 | 
	
		
			
				|  |  | -			// failed to call ReadXRayPointsByFeature method
 | 
	
		
			
				|  |  | -			LogErrorTrace(__FILE__, __LINE__, _T("COTSBrukerImpl::CollectXRayPointsByFeatures: failed to call ReadXRayPointsByFeature method."));
 | 
	
		
			
				|  |  | -			return FALSE;
 | 
	
		
			
				|  |  | -		}
 | 
	
		
			
				|  |  | +	//	// get the specs for a_vXPoints
 | 
	
		
			
				|  |  | +	//	if (!ReadXRayPointsByFeature(a_vXPoints, a_nACTimeMS))
 | 
	
		
			
				|  |  | +	//	{
 | 
	
		
			
				|  |  | +	//		// failed to call ReadXRayPointsByFeature method
 | 
	
		
			
				|  |  | +	//		LogErrorTrace(__FILE__, __LINE__, _T("COTSBrukerImpl::CollectXRayPointsByFeatures: failed to call ReadXRayPointsByFeature method."));
 | 
	
		
			
				|  |  | +	//		return FALSE;
 | 
	
		
			
				|  |  | +	//	}
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | -		return TRUE;
 | 
	
		
			
				|  |  | -	}
 | 
	
		
			
				|  |  | +	//	return TRUE;
 | 
	
		
			
				|  |  | +	//}
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |  	
 | 
	
		
			
				|  |  |  
 | 
	
	
		
			
				|  | @@ -2332,60 +2341,7 @@ BOOL COTSBrukerImpl::GetFeatureListSpectrum(long a_nIndex, long* a_pnSpec)
 | 
	
		
			
				|  |  |  }
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | -// call StartPointListMeasurement
 | 
	
		
			
				|  |  | -// return true if success
 | 
	
		
			
				|  |  | -BOOL COTSBrukerImpl::StartPointListMeasurement(
 | 
	
		
			
				|  |  | -	DWORD a_nSegmentCount,
 | 
	
		
			
				|  |  | -	BrukerDll::PSegmentList a_poSegment,
 | 
	
		
			
				|  |  | -	DWORD m_nMilliseconds)
 | 
	
		
			
				|  |  | -{
 | 
	
		
			
				|  |  | -
 | 
	
		
			
				|  |  | -	ASSERT(a_poSegment);
 | 
	
		
			
				|  |  | -	if (!a_poSegment)
 | 
	
		
			
				|  |  | -	{
 | 
	
		
			
				|  |  | -		LogErrorTrace(__FILE__, __LINE__, _T("COTSBrukerImpl::StartPointListMeasurement:a_poSegment failed, return"));
 | 
	
		
			
				|  |  | -		return FALSE;
 | 
	
		
			
				|  |  | -	}
 | 
	
		
			
				|  |  | -
 | 
	
		
			
				|  |  | -
 | 
	
		
			
				|  |  | -	if (BrukerDll::StartPointListMeasurement(m_nClientID, m_nSPU, a_nSegmentCount, a_poSegment, m_nMilliseconds) != 0)
 | 
	
		
			
				|  |  | -	{
 | 
	
		
			
				|  |  | -		LogErrorTrace(__FILE__, __LINE__, _T("COTSBrukerImpl::StartPointListMeasurement£ºCall StartPointListMeasurement failed: client id is %d(%d, %d, %d)"), m_nClientID, m_nSPU, a_nSegmentCount, m_nMilliseconds);
 | 
	
		
			
				|  |  | -		return FALSE;
 | 
	
		
			
				|  |  | -	}
 | 
	
		
			
				|  |  | -	return TRUE;
 | 
	
		
			
				|  |  | -}
 | 
	
		
			
				|  |  | -
 | 
	
		
			
				|  |  | -	// call StartFeatureListMeasurement
 | 
	
		
			
				|  |  | -	// return true if success
 | 
	
		
			
				|  |  | -BOOL COTSBrukerImpl::StartFeatureListMeasurement(
 | 
	
		
			
				|  |  | -	DWORD a_nFeatureCount,
 | 
	
		
			
				|  |  | -	BrukerDll::PFeatureDataList a_poFeature,
 | 
	
		
			
				|  |  | -	SHORT** a_pwdPixelTimes)
 | 
	
		
			
				|  |  | -{
 | 
	
		
			
				|  |  | -	
 | 
	
		
			
				|  |  | -
 | 
	
		
			
				|  |  | -	ASSERT(a_poFeature);
 | 
	
		
			
				|  |  | -	if (!a_poFeature)
 | 
	
		
			
				|  |  | -	{
 | 
	
		
			
				|  |  | -		LogErrorTrace(__FILE__, __LINE__, _T("COTSBrukerImpl::StartFeatureListMeasurement:a_poFeature failed, return"));
 | 
	
		
			
				|  |  | -		return FALSE;
 | 
	
		
			
				|  |  | -	}
 | 
	
		
			
				|  |  | -
 | 
	
		
			
				|  |  | -	if (!a_pwdPixelTimes)
 | 
	
		
			
				|  |  | -	{
 | 
	
		
			
				|  |  | -		LogErrorTrace(__FILE__, __LINE__, _T("COTSBrukerImpl::StartFeatureListMeasurement:a_pwdPixelTimes failed, return"));
 | 
	
		
			
				|  |  | -		return FALSE;
 | 
	
		
			
				|  |  | -	}
 | 
	
		
			
				|  |  | -	
 | 
	
		
			
				|  |  | -	if (BrukerDll::StartFeatureListMeasurement(m_nClientID, m_nSPU, a_nFeatureCount, a_poFeature, a_pwdPixelTimes) != 0)
 | 
	
		
			
				|  |  | -	{
 | 
	
		
			
				|  |  | -		LogErrorTrace(__FILE__, __LINE__, _T("COTSBrukerImpl::StartFeatureListMeasurement:Call StartFeatureListMeasurement failed: client id is %d"), m_nClientID);
 | 
	
		
			
				|  |  | -		return FALSE;
 | 
	
		
			
				|  |  | -	}
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | -	return TRUE;
 | 
	
		
			
				|  |  | -}
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |  
 | 
	
	
		
			
				|  | @@ -2424,11 +2380,10 @@ BOOL COTSBrukerImpl::GetXRayByPoints(CPosXrayList& a_listXrayPois, DWORD a_nACTi
 | 
	
		
			
				|  |  |  			segmentArray[i].XCount = 1;
 | 
	
		
			
				|  |  |  		}
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | -		// ask Bruker to collect a set of x ray data
 | 
	
		
			
				|  |  | -		if (!StartPointListMeasurement(nCollectCount, segmentArray.get(), a_nACTimeMS))
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +		if (BrukerDll::StartPointListMeasurement(m_nClientID, m_nSPU, nCollectCount, segmentArray.get(), a_nACTimeMS) != 0)
 | 
	
		
			
				|  |  |  		{
 | 
	
		
			
				|  |  | -			// failed to call StartPointListMeasurement method
 | 
	
		
			
				|  |  | -			LogTrace(__FILE__, __LINE__, _T("COTSBrukerImpl::CollectXRayPoints: failed to call StartPointListMeasurement method."));
 | 
	
		
			
				|  |  | +			LogErrorTrace(__FILE__, __LINE__, _T("COTSBrukerImpl::StartPointListMeasurement£ºCall StartPointListMeasurement failed: client id is %d(%d, %d, %d)"), m_nClientID, m_nSPU, nCollectCount, a_nACTimeMS);
 | 
	
		
			
				|  |  |  			return FALSE;
 | 
	
		
			
				|  |  |  		}
 | 
	
		
			
				|  |  |  
 | 
	
	
		
			
				|  | @@ -2541,7 +2496,7 @@ BOOL COTSBrukerImpl::GetXRayByFeatures(CPosXrayList& a_vXPoints, std::vector<Bru
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |  	SHORT* pixelTimes(new SHORT[nCollectCount]);
 | 
	
		
			
				|  |  |  	BrukerDll::PFeatureDataList features = new BrukerDll::TFeatureData[nCollectCount];
 | 
	
		
			
				|  |  | -	std::vector<BrukerDll::TSegment> extraSegments;
 | 
	
		
			
				|  |  | +	
 | 
	
		
			
				|  |  |  	/*boost::scoped_array<SHORT*> pixelTimes(new SHORT *[nCollectCount]);
 | 
	
		
			
				|  |  |  	boost::scoped_array<BrukerDll::TFeatureData> features(new BrukerDll::TFeatureData[nCollectCount]);
 | 
	
		
			
				|  |  |  	std::vector<BrukerDll::TSegment> extraSegments;*/
 | 
	
	
		
			
				|  | @@ -2553,13 +2508,13 @@ BOOL COTSBrukerImpl::GetXRayByFeatures(CPosXrayList& a_vXPoints, std::vector<Bru
 | 
	
		
			
				|  |  |  		if (ofeature.SegmentCount > 0)
 | 
	
		
			
				|  |  |  		{
 | 
	
		
			
				|  |  |  			int segCount = features[i].SegmentCount;
 | 
	
		
			
				|  |  | -			auto ofeature = a_vFeatures[i];
 | 
	
		
			
				|  |  | -			features->Segments = new BrukerDll::TSegment[segCount];
 | 
	
		
			
				|  |  | +			//auto ofeature = a_vFeatures[i];
 | 
	
		
			
				|  |  | +			features[i].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[i].Segments[j].XStart = ofeature.pSegment[j].XStart;
 | 
	
		
			
				|  |  | +				features[i].Segments[j].XCount = ofeature.pSegment[j].XCount;
 | 
	
		
			
				|  |  | +				features[i].Segments[j].Y = ofeature.pSegment[j].Y;
 | 
	
		
			
				|  |  |  			}
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |  			// calculate pixel time
 | 
	
	
		
			
				|  | @@ -2570,7 +2525,7 @@ BOOL COTSBrukerImpl::GetXRayByFeatures(CPosXrayList& a_vXPoints, std::vector<Bru
 | 
	
		
			
				|  |  |  			{
 | 
	
		
			
				|  |  |  				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;
 | 
	
		
			
				|  |  |  		}
 | 
	
	
		
			
				|  | @@ -2579,25 +2534,26 @@ BOOL COTSBrukerImpl::GetXRayByFeatures(CPosXrayList& a_vXPoints, std::vector<Bru
 | 
	
		
			
				|  |  |  			// will generate according to the x-ray position
 | 
	
		
			
				|  |  |  			// this shouldn't happen
 | 
	
		
			
				|  |  |  			
 | 
	
		
			
				|  |  | -			BrukerDll::PFeatureDataList features = new BrukerDll::TFeatureData[nCollectCount];
 | 
	
		
			
				|  |  | -			extraSegments.push_back(BrukerDll::TSegment());
 | 
	
		
			
				|  |  | -			extraSegments[extraSegments.size() - 1].XStart = a_vXPoints[i]->GetPosition().x;
 | 
	
		
			
				|  |  | -			extraSegments[extraSegments.size() - 1].Y = a_vXPoints[i]->GetPosition().y;
 | 
	
		
			
				|  |  | +			//BrukerDll::PFeatureDataList features = new BrukerDll::TFeatureData[nCollectCount];
 | 
	
		
			
				|  |  | +			BrukerDll::TSegment* extraSegments=new BrukerDll::TSegment[1];
 | 
	
		
			
				|  |  | +			//extraSegments.push_back(BrukerDll::TSegment());
 | 
	
		
			
				|  |  | +			extraSegments[0].XStart = a_vXPoints[i]->GetPosition().x;
 | 
	
		
			
				|  |  | +			extraSegments[0].Y = a_vXPoints[i]->GetPosition().y;
 | 
	
		
			
				|  |  | +			extraSegments[0].XCount = 1;
 | 
	
		
			
				|  |  |  			features[i].SegmentCount = 1;
 | 
	
		
			
				|  |  | -			features[i].Segments = &extraSegments[extraSegments.size() - 1];
 | 
	
		
			
				|  |  | -			pixelTimes[i] = (WORD)(a_nACTimeMS * 1000);
 | 
	
		
			
				|  |  | +			features[i].Segments = &extraSegments[0];
 | 
	
		
			
				|  |  | +			pixelTimes[i] = (SHORT)(a_nACTimeMS * 1000);
 | 
	
		
			
				|  |  |  			
 | 
	
		
			
				|  |  |  		}
 | 
	
		
			
				|  |  |  	}
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |  	// ask bruker to collect a set of x-ray data
 | 
	
		
			
				|  |  | -
 | 
	
		
			
				|  |  | -	if (!StartFeatureListMeasurement(nCollectCount, features, &pixelTimes))
 | 
	
		
			
				|  |  | +	if (BrukerDll::StartFeatureListMeasurement(m_nClientID, m_nSPU, nCollectCount, features, &pixelTimes) != 0)
 | 
	
		
			
				|  |  |  	{
 | 
	
		
			
				|  |  | -		// failed to call StartFeatureListMeasurement method
 | 
	
		
			
				|  |  | -		LogErrorTrace(__FILE__, __LINE__, _T("COTSBrukerImpl::CollectXRayPointsByFeatures: failed to call StartFeatureListMeasurement method."));
 | 
	
		
			
				|  |  | +		LogErrorTrace(__FILE__, __LINE__, _T("COTSBrukerImpl::StartFeatureListMeasurement:Call StartFeatureListMeasurement failed: client id is %d"), m_nClientID);
 | 
	
		
			
				|  |  |  		return FALSE;
 | 
	
		
			
				|  |  |  	}
 | 
	
		
			
				|  |  | +	
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |  	// get the specs for a_vXPoints
 | 
	
		
			
				|  |  |  	if (!SetXRayPointsByFeature(a_vXPoints, a_nACTimeMS))
 | 
	
	
		
			
				|  | @@ -2606,7 +2562,8 @@ BOOL COTSBrukerImpl::GetXRayByFeatures(CPosXrayList& a_vXPoints, std::vector<Bru
 | 
	
		
			
				|  |  |  		LogErrorTrace(__FILE__, __LINE__, _T("COTSBrukerImpl::CollectXRayPointsByFeatures: failed to call ReadXRayPointsByFeature method."));
 | 
	
		
			
				|  |  |  		return FALSE;
 | 
	
		
			
				|  |  |  	}
 | 
	
		
			
				|  |  | -	
 | 
	
		
			
				|  |  | +	delete[] pixelTimes;
 | 
	
		
			
				|  |  | +	delete[] features;
 | 
	
		
			
				|  |  |  	return TRUE;
 | 
	
		
			
				|  |  |  }
 | 
	
		
			
				|  |  |  
 |