Browse Source

change oxford movesemtopoint function.

cxs 3 years ago
parent
commit
e88c6bf320

+ 1 - 1
Bin/x64/Debug/Config/SysData/OTSStage.stg

@@ -1,5 +1,5 @@
 <?xml version="1.0" encoding="UTF-8"?>
-<XMLData Modify="true" PathName=".\Config\SysData\OTSStage.stg" WorkingStageId="1">
+<XMLData Modify="true" PathName=".\Config\SysData\OTSStage.stg" WorkingStageId="3">
   <Collection RegName="Stagelist">
     <Member strName="圆形九圆孔50mm">
       <Member RegName="boundary" PolygonPoint="" rectDomian="0,0,50000,0" shape="0" />

+ 83 - 17
OTSCPP/OTSControl/Oxford/OxfordWrapper/OxfordControllerWrapper.cpp

@@ -28,8 +28,8 @@ const long g_nMicrocopeConnectTimeOutMilliSeconds = 2000;
 const long g_nSinglePointCollectDelay = 3000;
 const long g_nSingleFeatureCollectDelay = 5000;
 const long g_nXrayControllerConnectTimeOutMilliSeconds = 10000;
-const long g_nImageTimeOutMilliSeconds = 30000;
-const long g_nStageTimeOutMilliSeconds = 30000;
+const long g_nImageTimeOutMilliSeconds = 20000;
+const long g_nStageTimeOutMilliSeconds = 10000;
 
 
 
@@ -317,6 +317,21 @@ void OxfordControllerWrapper::ControllerThreadFunction()
 			}
 
 			break;
+		case OxfordControllerCommand::SET_POSITIONXY:
+		{
+			if (SetPositionXYToController(_oxfordControllerData.m_dPositionX, _oxfordControllerData.m_dPositionY))
+			{
+				_oxfordControllerData.m_nState = OxfordControllerState::SUCCEEDED;
+			}
+			else
+			{
+				_oxfordControllerData.m_nState = OxfordControllerState::FAILED;
+			}
+
+			m_endControllerEvent->Set();
+		}
+
+		break;
 		case OxfordControllerCommand::STOP_ACQUISITION:
 		{
 			auto edsController = CreateEdsSpectrumController();
@@ -469,26 +484,38 @@ bool OxfordControllerWrapper::SetPositionXY(const double a_dPosX, const double a
 	_oxfordControllerData.m_dPositionX = a_dPosX;
 	_oxfordControllerData.m_dPositionY = a_dPosY;
 	m_bIsStageUpdated = false;
-
-	if (SetPositionXYToController(_oxfordControllerData.m_dPositionX, _oxfordControllerData.m_dPositionY))
-	{
-		_oxfordControllerData.m_nState = OxfordControllerState::SUCCEEDED;
-	}
-	else
-	{
-		_oxfordControllerData.m_nState = OxfordControllerState::FAILED;
-	}
-	double waitTime=0;
-	while (!m_bIsStageUpdated)//m_bIsStageUpdated will be set by the callback event.
+	m_startControllerEvent->Set();
+	long nCollectedTime = 0;
+	while (true)
 	{
-		Sleep(100);
-		waitTime += 0.1;
-		if (waitTime > 10)//prevent the m_bIsStageUpdated won't be set ,we will wait only 10s.
+		if (m_bIsStageUpdated)
+		{
+			if (m_endControllerEvent->WaitOne(0, true))
+			{
+				m_endControllerEvent->Reset();
+				break;
+			}
+		}
+
+
+		Application::DoEvents();
+		Thread::Sleep(g_nOxfordControllerEventSleepTimerInt);
+
+
+		long nCollectedTimeLimit = g_nStageTimeOutMilliSeconds;
+		nCollectedTime += g_nOxfordControllerEventSleepTimerInt;
+		if (nCollectedTime > nCollectedTimeLimit)
 		{
+
+
+			_oxfordControllerData.m_nState = OxfordControllerState::FAILED;
+
+
+			m_endControllerEvent->Reset();
+
 			break;
 		}
 	}
-	
 
 	if (_oxfordControllerData.m_nState == OxfordControllerState::SUCCEEDED)
 	{
@@ -500,6 +527,45 @@ bool OxfordControllerWrapper::SetPositionXY(const double a_dPosX, const double a
 		return false;
 	}
 
+
+	//---------------------------------------------------new method
+
+	//_oxfordControllerData.m_nCommand = OxfordControllerCommand::SET_POSITIONXY;
+
+	//_oxfordControllerData.m_dPositionX = a_dPosX;
+	//_oxfordControllerData.m_dPositionY = a_dPosY;
+	//m_bIsStageUpdated = false;
+
+	//if (SetPositionXYToController(_oxfordControllerData.m_dPositionX, _oxfordControllerData.m_dPositionY))
+	//{
+	//	_oxfordControllerData.m_nState = OxfordControllerState::SUCCEEDED;
+	//}
+	//else
+	//{
+	//	_oxfordControllerData.m_nState = OxfordControllerState::FAILED;
+	//}
+	//double waitTime=0;
+	//while (!m_bIsStageUpdated)//m_bIsStageUpdated will be set by the callback event.
+	//{
+	//	Sleep(100);
+	//	waitTime += 0.1;
+	//	if (waitTime > 10)//prevent the m_bIsStageUpdated won't be set ,we will wait only 10s.
+	//	{
+	//		break;
+	//	}
+	//}
+	//
+
+	//if (_oxfordControllerData.m_nState == OxfordControllerState::SUCCEEDED)
+	//{
+	//	return true;
+	//}
+	//else
+	//{
+
+	//	return false;
+	//}
+
 	
 }
 

+ 5 - 0
OTSCPP/OTSControl/Oxford/OxfordWrapper/OxfordControllerWrapper.h

@@ -182,6 +182,10 @@ public:
 	bool CollectImage(int a);
 
 	bool QuantifySpectrum(unsigned char* cResult);
+	bool IsStageUpdate()
+	{
+		return m_bIsStageUpdated;
+	}
 protected:
 
 	bool GetPositionXYFromController(double& a_dPosX, double& a_dPosY);
@@ -221,6 +225,7 @@ protected:
 	void OnMicroscopeStageUpdated(Object^ /*sender*/, OINA::Extender::MicroscopeControl::StageEventArgs^ /*e*/)
 	{
 		m_bIsStageUpdated = true;
+		LogTrace(__FILE__, __LINE__, _T("StageUpdated!"));
 	}
 	bool m_bIsStageUpdated;
 	bool m_bIsColumnUpdated;