|
@@ -48,9 +48,6 @@ void OxfordControllerWrapper::CloseClient(void)
|
|
|
{
|
|
|
if (_controllerThread && _controllerThread->IsAlive)
|
|
|
{
|
|
|
- m_startControllerEvent->Set();
|
|
|
-
|
|
|
- m_endControllerEvent->WaitOne(g_nOxfordControllerEventWaitTimerInt);
|
|
|
}
|
|
|
|
|
|
_controllerThread->Abort();
|
|
@@ -61,8 +58,6 @@ OxfordControllerWrapper::~OxfordControllerWrapper(void)
|
|
|
{
|
|
|
if (_controllerThread && _controllerThread->IsAlive)
|
|
|
{
|
|
|
-
|
|
|
- m_endControllerEvent->WaitOne(g_nOxfordControllerEventWaitTimerInt);
|
|
|
}
|
|
|
|
|
|
_controllerThread->Abort();
|
|
@@ -72,12 +67,9 @@ OxfordControllerWrapper::!OxfordControllerWrapper(void)
|
|
|
{
|
|
|
if (_controllerThread && _controllerThread->IsAlive)
|
|
|
{
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
- m_endControllerEvent->WaitOne(g_nOxfordControllerEventWaitTimerInt);
|
|
|
+
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
_controllerThread->Abort();
|
|
|
}
|
|
|
|
|
@@ -191,13 +183,13 @@ void OxfordControllerWrapper::ControllerThreadFunction()
|
|
|
if (edsController && _oxfordControllerData.m_pSpectrumData)
|
|
|
{
|
|
|
edsController->BeginMultipleAcquisition();
|
|
|
- //OutputDebugString(_T("BeginMultipleAcquisition...(single point)"));
|
|
|
+
|
|
|
|
|
|
if (m_bBeamPositionSet)
|
|
|
{
|
|
|
m_bBeamPositionSet = false;
|
|
|
bRet = true;
|
|
|
- //OutputDebugString(_T("Beam position already set."));
|
|
|
+
|
|
|
|
|
|
Point pos(_oxfordControllerData.m_dBeamPositionX * _oxfordControllerData.m_dPixelSize, _oxfordControllerData.m_dBeamPositionY * _oxfordControllerData.m_dPixelSize);
|
|
|
auto edsSettings = GetEdsSpectrumSettings();
|
|
@@ -206,7 +198,7 @@ void OxfordControllerWrapper::ControllerThreadFunction()
|
|
|
else
|
|
|
{
|
|
|
bRet = SetCurrentBeamPosition();
|
|
|
- //OutputDebugString(_T("Set current Beam position to collect xray."));
|
|
|
+
|
|
|
}
|
|
|
|
|
|
if (bRet)
|
|
@@ -359,7 +351,17 @@ void OxfordControllerWrapper::ControllerThreadFunction()
|
|
|
|
|
|
bool OxfordControllerWrapper::IsConnected()
|
|
|
{
|
|
|
- return true;
|
|
|
+ if (IsMicroscopeColumnConnected()
|
|
|
+ && IsMicroscopeStageConnected())
|
|
|
+ {
|
|
|
+ return true;
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
}
|
|
|
|
|
|
bool OxfordControllerWrapper::IsMicroscopeColumnConnected()
|
|
@@ -398,7 +400,6 @@ bool OxfordControllerWrapper::GetPositionXY(double& a_dPosX, double& a_dPosY)
|
|
|
{
|
|
|
_oxfordControllerData.m_nCommand = OxfordControllerCommand::GET_POSITIONXY;
|
|
|
|
|
|
- //m_startControllerEvent->Set();
|
|
|
|
|
|
double dX, dY;
|
|
|
|
|
@@ -468,7 +469,6 @@ bool OxfordControllerWrapper::SetPositionXY(const double a_dPosX, const double a
|
|
|
_oxfordControllerData.m_dPositionX = a_dPosX;
|
|
|
_oxfordControllerData.m_dPositionY = a_dPosY;
|
|
|
m_bIsStageUpdated = false;
|
|
|
- //m_startControllerEvent->Set();
|
|
|
|
|
|
if (SetPositionXYToController(_oxfordControllerData.m_dPositionX, _oxfordControllerData.m_dPositionY))
|
|
|
{
|
|
@@ -478,7 +478,16 @@ bool OxfordControllerWrapper::SetPositionXY(const double a_dPosX, const double a
|
|
|
{
|
|
|
_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)
|
|
@@ -1664,7 +1673,7 @@ bool OxfordControllerWrapper::StartImageCollecting()
|
|
|
catch (Exception^ /*ex*/)
|
|
|
{
|
|
|
CString sMessage(_T("StartImageCollecting: Start Acquisition failed"));
|
|
|
- //OutputDebugString(sMessage);
|
|
|
+
|
|
|
LogErrorTrace(__FILE__,__LINE__,sMessage);
|
|
|
}
|
|
|
|
|
@@ -1807,7 +1816,7 @@ bool OxfordControllerWrapper::StopImageCollecting()
|
|
|
CString sMessage = ex->Message;
|
|
|
CString sErrorMessage;
|
|
|
sErrorMessage.Format(_T("StopImageCollecting: Stop Acquisition caught(%s)"), sMessage);
|
|
|
- //OutputDebugString(sErrorMessage);
|
|
|
+
|
|
|
LogErrorTrace(__FILE__, __LINE__, sErrorMessage);
|
|
|
}
|
|
|
|
|
@@ -1824,13 +1833,13 @@ IMicroscopeController^ OxfordControllerWrapper::CreateMicroscopeController()
|
|
|
|
|
|
try
|
|
|
{
|
|
|
+ LogTrace(__FILE__, __LINE__, _T("CreateMicroscopeControl..."));
|
|
|
_microscopeController = AcquireFactory::CreateMicroscopeControl();
|
|
|
}
|
|
|
catch(Exception^ ex)
|
|
|
{
|
|
|
CString sErrorMessage = ex->Message;
|
|
|
- AfxMessageBox(_T("oxford eds cann't work,you can change work mode to offline in the sysMgrApp to run offline mode!\nerror:")+ sErrorMessage);
|
|
|
- //OutputDebugString(sErrorMessage);
|
|
|
+ AfxMessageBox(_T("oxford eds cann't work,you can change work mode to offline in the sysMgrApp to run offline mode!\nerror:")+ sErrorMessage);
|
|
|
LogErrorTrace(__FILE__, __LINE__, sErrorMessage);
|
|
|
exit(0);
|
|
|
}
|
|
@@ -1845,7 +1854,7 @@ IMicroscopeController^ OxfordControllerWrapper::CreateMicroscopeController()
|
|
|
|
|
|
m_bIsStageUpdated = false;
|
|
|
|
|
|
- auto nStart = GetTickCount64();
|
|
|
+ /*auto nStart = GetTickCount64();
|
|
|
auto nEnd = nStart;
|
|
|
do
|
|
|
{
|
|
@@ -1857,15 +1866,17 @@ IMicroscopeController^ OxfordControllerWrapper::CreateMicroscopeController()
|
|
|
}
|
|
|
|
|
|
nEnd = GetTickCount64();
|
|
|
- } while (nEnd >= nStart && nEnd <= (nStart + g_nMicrocopeConnectTimeOutMilliSeconds));
|
|
|
-
|
|
|
+ } while (nEnd >= nStart && nEnd <= (nStart + g_nMicrocopeConnectTimeOutMilliSeconds));*/
|
|
|
+ Sleep(g_nMicrocopeConnectTimeOutMilliSeconds);
|
|
|
return _microscopeController;
|
|
|
}
|
|
|
|
|
|
IEdSpectrumAcquisitionController^ OxfordControllerWrapper::CreateEdsSpectrumController()
|
|
|
{
|
|
|
+
|
|
|
if (_edSpectrumController == nullptr)
|
|
|
{
|
|
|
+ LogTrace(__FILE__, __LINE__, _T("CreateEdSpectrumServer..."));
|
|
|
_edSpectrumController = AcquireFactory::CreateEdSpectrumServer();
|
|
|
|
|
|
_edSpectrumController->ExperimentFinished += gcnew EventHandler<OINA::Extender::Acquisition::AcquisitionFinishedEventArgs<OINA::Extender::Data::Ed::IEdSpectrum^>^>(this, &OxfordControllerWrapper::OnXrayAcquisitionFinished);
|
|
@@ -1895,8 +1906,7 @@ IEdSpectrumSettings^ OxfordControllerWrapper::GetEdsSpectrumSettings()
|
|
|
|
|
|
if (_edsSpectrumSettings == nullptr)
|
|
|
{
|
|
|
- CString sMessage(_T("Create EDS Spectrum setting failed."));
|
|
|
- //OutputDebugString(sMessage);
|
|
|
+ CString sMessage(_T("Create EDS Spectrum setting failed."));
|
|
|
LogErrorTrace(__FILE__, __LINE__, sMessage);
|
|
|
ASSERT(FALSE);
|
|
|
}
|
|
@@ -1917,6 +1927,7 @@ IImageAcquisitionController^ OxfordControllerWrapper::CreateImageAcqusitionContr
|
|
|
{
|
|
|
if (_imageAcqusitionController == nullptr)
|
|
|
{
|
|
|
+ LogTrace(__FILE__, __LINE__, _T("CreateImageAcqusitionController..."));
|
|
|
try
|
|
|
{
|
|
|
_imageAcqusitionController = AcquireFactory::CreateImageServer();
|
|
@@ -1940,10 +1951,9 @@ IImageAcquisitionController^ OxfordControllerWrapper::CreateImageAcqusitionContr
|
|
|
{
|
|
|
CString sMessage = ex->Message;
|
|
|
CString sErrorMessage;
|
|
|
- // sErrorMessage.Format(_T("CreateImageAcqusitionController: create controller caught(%s)"), sMessage);
|
|
|
- //OutputDebugString(sErrorMessage);
|
|
|
+
|
|
|
LogErrorTrace(__FILE__, __LINE__, sErrorMessage);
|
|
|
- //LogMessage(sErrorMessage);
|
|
|
+
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -2013,6 +2023,7 @@ IEdChordListAcquisitionController^ OxfordControllerWrapper::CreateChordlistContr
|
|
|
{
|
|
|
if (_edsChordListController == nullptr)
|
|
|
{
|
|
|
+ LogTrace(__FILE__, __LINE__, _T("CreateEdChordListServer..."));
|
|
|
_edsChordListController = AcquireFactory::CreateEdChordListServer();
|
|
|
|
|
|
_edsChordListController->PixelProcessed += gcnew EventHandler<OINA::Extender::EventArgs<OINA::Extender::Processing::Quant::IPixelSEMQuantStatus^>^>(this, &OxfordControllerWrapper::OnController_PixelProcessed);
|