|
@@ -28,7 +28,7 @@ const long g_nMicrocopeConnectTimeOutMilliSeconds = 2000;
|
|
|
const long g_nSinglePointCollectDelay = 3000;
|
|
|
const long g_nSingleFeatureCollectDelay = 5000;
|
|
|
const long g_nXrayControllerConnectTimeOutMilliSeconds = 10000;
|
|
|
-const long g_nImageTimeOutMilliSeconds = 20000;
|
|
|
+const long g_nImageTimeOutMilliSeconds = 40000;
|
|
|
const long g_nStageTimeOutMilliSeconds = 15000;
|
|
|
|
|
|
|
|
@@ -89,6 +89,7 @@ bool OxfordControllerWrapper::Init()
|
|
|
_controllerThread = gcnew Thread(gcnew ThreadStart(this, &OxfordControllerWrapper::ControllerThreadFunction));
|
|
|
m_startControllerEvent->Reset();
|
|
|
m_endControllerEvent->Reset();
|
|
|
+
|
|
|
_controllerThread->Start();
|
|
|
|
|
|
return true;
|
|
@@ -1136,99 +1137,169 @@ bool OxfordControllerWrapper::StopXrayCollecting()
|
|
|
|
|
|
return !edsController->IsAcquiring;
|
|
|
}
|
|
|
-
|
|
|
-void OxfordControllerWrapper::OnXrayAcquisitionFinished(Object^ sender, OINA::Extender::Acquisition::AcquisitionFinishedEventArgs<OINA::Extender::Data::Ed::IEdSpectrum^>^ e)
|
|
|
+void OxfordControllerWrapper::XraySpectrumProcess(OINA::Extender::Data::Ed::IEdSpectrum^ spectrum)
|
|
|
{
|
|
|
- //Quantify processing
|
|
|
- IEdSpectrumProcessing^ EdSpectrumProcessing = ProcessingFactory::CreateSpectrumProcessing();
|
|
|
+ try
|
|
|
+ {
|
|
|
|
|
|
- // Use the autoIdSettings to define elements that are known or elements that you want to exclude. They also list elements that cannot be identified
|
|
|
- IAutoIdSettings^ autoIdSettings = ProcessingFactory::CreateAutoIdSettings();
|
|
|
- EdSpectrumProcessing->IdentifyElements(e->Value, autoIdSettings);
|
|
|
+ //Quantify processing
|
|
|
+ IEdSpectrumProcessing^ EdSpectrumProcessing = ProcessingFactory::CreateSpectrumProcessing();
|
|
|
|
|
|
- ISEMQuantSettings^ settings = ProcessingFactory::CreateSEMQuantSettings();
|
|
|
+ // Use the autoIdSettings to define elements that are known or elements that you want to exclude. They also list elements that cannot be identified
|
|
|
+ IAutoIdSettings^ autoIdSettings = ProcessingFactory::CreateAutoIdSettings();
|
|
|
+ EdSpectrumProcessing->IdentifyElements(spectrum, autoIdSettings);
|
|
|
|
|
|
- // While it is possible to choose other elements, Oxygen is the only supported element by stoichiometry.
|
|
|
- settings->CombinedElement = 8;
|
|
|
- settings->Normalised = true;
|
|
|
+ ISEMQuantSettings^ settings = ProcessingFactory::CreateSEMQuantSettings();
|
|
|
|
|
|
- ISEMQuantStatus^ quantStatus = EdSpectrumProcessing->SEMQuantifySpectrum(e->Value, settings);//(a_nChannelData, OIHelper::SEMQuantSettings);
|
|
|
+ // While it is possible to choose other elements, Oxygen is the only supported element by stoichiometry.
|
|
|
+ settings->CombinedElement = 8;
|
|
|
+ settings->Normalised = true;
|
|
|
|
|
|
- IEnumerable<ISEMQuantResult^>^ Results = quantStatus->Results;
|
|
|
+ ISEMQuantStatus^ quantStatus = EdSpectrumProcessing->SEMQuantifySpectrum(spectrum, settings);//(a_nChannelData, OIHelper::SEMQuantSettings);
|
|
|
|
|
|
- if (_oxfordControllerData.m_nCommand == OxfordControllerCommand::COLLECT_XRAYPOINT
|
|
|
- || _oxfordControllerData.m_nCommand == OxfordControllerCommand::COLLECT_CURRENTXRAYPOINT)
|
|
|
- {
|
|
|
- //Get element result for single point
|
|
|
- auto ie = Results->GetEnumerator();
|
|
|
-
|
|
|
- String^ Quant = gcnew String("");
|
|
|
+ IEnumerable<ISEMQuantResult^>^ Results = quantStatus->Results;
|
|
|
|
|
|
- while (ie->MoveNext())
|
|
|
+ if (_oxfordControllerData.m_nCommand == OxfordControllerCommand::COLLECT_XRAYPOINT
|
|
|
+ || _oxfordControllerData.m_nCommand == OxfordControllerCommand::COLLECT_CURRENTXRAYPOINT)
|
|
|
{
|
|
|
- ISEMQuantResult^ result = ie->Current;
|
|
|
+ //Get element result for single point
|
|
|
+ auto ie = Results->GetEnumerator();
|
|
|
+
|
|
|
+ String^ Quant = gcnew String("");
|
|
|
|
|
|
- if (result->WeightPercent != 0)
|
|
|
+ while (ie->MoveNext())
|
|
|
{
|
|
|
- Quant += "Quant=";
|
|
|
- Quant += ElementProperties::GetElementSymbol(result->AtomicNumber);
|
|
|
- Quant += ",";
|
|
|
- Quant += result->LineType.ToString();
|
|
|
- Quant += ",";
|
|
|
- Quant += result->WeightPercent.ToString();
|
|
|
+ ISEMQuantResult^ result = ie->Current;
|
|
|
+
|
|
|
+ if (result->WeightPercent != 0)
|
|
|
+ {
|
|
|
+ Quant += "Quant=";
|
|
|
+ Quant += ElementProperties::GetElementSymbol(result->AtomicNumber);
|
|
|
+ Quant += ",";
|
|
|
+ Quant += result->LineType.ToString();
|
|
|
+ Quant += ",";
|
|
|
+ Quant += result->WeightPercent.ToString();
|
|
|
+ }
|
|
|
}
|
|
|
- }
|
|
|
|
|
|
- _oxfordControllerData.m_sElementResult = Quant;
|
|
|
- ConvertSpectrumData(e->Value, _oxfordControllerData.m_pSpectrumData, _oxfordControllerData.m_nBufferSize);
|
|
|
+ _oxfordControllerData.m_sElementResult = Quant;
|
|
|
+ ConvertSpectrumData(spectrum, _oxfordControllerData.m_pSpectrumData, _oxfordControllerData.m_nBufferSize);
|
|
|
|
|
|
- _oxfordControllerData.m_nState = OxfordControllerState::SUCCEEDED;
|
|
|
+ _oxfordControllerData.m_nState = OxfordControllerState::SUCCEEDED;
|
|
|
+
|
|
|
+ auto edsController = CreateEdsSpectrumController();
|
|
|
+ if (edsController)
|
|
|
+ {
|
|
|
+ edsController->EndMultipleAcquisition();
|
|
|
+ m_endControllerEvent->Set();
|
|
|
|
|
|
- auto edsController = CreateEdsSpectrumController();
|
|
|
- if (edsController)
|
|
|
+ }
|
|
|
+ }
|
|
|
+ else
|
|
|
{
|
|
|
- edsController->EndMultipleAcquisition();
|
|
|
- m_endControllerEvent->Set();
|
|
|
-
|
|
|
+
|
|
|
+ //Get element result for single point
|
|
|
+ auto ie = Results->GetEnumerator();
|
|
|
+
|
|
|
+ String^ Quant = gcnew String("");
|
|
|
+ while (ie->MoveNext())
|
|
|
+ {
|
|
|
+ ISEMQuantResult^ result = ie->Current;
|
|
|
+
|
|
|
+ if (result->WeightPercent != 0)
|
|
|
+ {
|
|
|
+ Quant += "Quant=";
|
|
|
+ Quant += ElementProperties::GetElementSymbol(result->AtomicNumber);
|
|
|
+ Quant += ",";
|
|
|
+ Quant += result->LineType.ToString();
|
|
|
+ Quant += ",";
|
|
|
+ Quant += result->WeightPercent.ToString();
|
|
|
+ Quant += "\n";
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ CString msg = Quant;
|
|
|
+ unsigned char* dst = _oxfordControllerData.m_pXrayDataList[_oxfordControllerData.m_nCollectedXrayCounts].m_strElementResult;
|
|
|
+ for (int i = 0; i < msg.GetLength(); i++)
|
|
|
+ {
|
|
|
+ dst[i] = (unsigned char)msg.GetAt(i);
|
|
|
+ }
|
|
|
+
|
|
|
+ ConvertSpectrumData(spectrum, _oxfordControllerData.m_pXrayDataList[_oxfordControllerData.m_nCollectedXrayCounts].m_pXrayData, _oxfordControllerData.m_nBufferSize);
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ _oxfordControllerData.m_nCollectedXrayCounts++;
|
|
|
+ if (_oxfordControllerData.m_nCollectedXrayCounts == _oxfordControllerData.m_nXrayDataCount)
|
|
|
+ {
|
|
|
+ _oxfordControllerData.m_nState = OxfordControllerState::SUCCEEDED;
|
|
|
+
|
|
|
+ auto edsController = CreateEdsSpectrumController();
|
|
|
+ if (edsController)
|
|
|
+ {
|
|
|
+ edsController->EndMultipleAcquisition();
|
|
|
+ m_endControllerEvent->Set();
|
|
|
+
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
- else
|
|
|
+ catch (Exception^ ex)
|
|
|
{
|
|
|
+ CString sMessage(_T("OnXrayAcquisitionFinished failed") + ex->ToString());
|
|
|
|
|
|
- //Get element result for single point
|
|
|
- auto ie = Results->GetEnumerator();
|
|
|
+ LogErrorTrace(__FILE__, __LINE__, sMessage);
|
|
|
+ }
|
|
|
|
|
|
- String^ Quant = gcnew String("");
|
|
|
- while (ie->MoveNext())
|
|
|
- {
|
|
|
- ISEMQuantResult^ result = ie->Current;
|
|
|
-
|
|
|
- if (result->WeightPercent != 0)
|
|
|
- {
|
|
|
- Quant += "Quant=";
|
|
|
- Quant += ElementProperties::GetElementSymbol(result->AtomicNumber);
|
|
|
- Quant += ",";
|
|
|
- Quant += result->LineType.ToString();
|
|
|
- Quant += ",";
|
|
|
- Quant += result->WeightPercent.ToString();
|
|
|
- Quant += "\n";
|
|
|
- }
|
|
|
- }
|
|
|
+}
|
|
|
+void OxfordControllerWrapper::OnXrayAcquisitionFinished(Object^ sender, OINA::Extender::Acquisition::AcquisitionFinishedEventArgs<OINA::Extender::Data::Ed::IEdSpectrum^>^ e)
|
|
|
+{
|
|
|
+ try
|
|
|
+ {
|
|
|
|
|
|
- CString msg = Quant;
|
|
|
- unsigned char* dst = _oxfordControllerData.m_pXrayDataList[_oxfordControllerData.m_nCollectedXrayCounts].m_strElementResult;
|
|
|
- for (int i = 0; i < msg.GetLength(); i++)
|
|
|
- {
|
|
|
- dst[i] = (unsigned char) msg.GetAt(i);
|
|
|
- }
|
|
|
+ //Quantify processing
|
|
|
+ IEdSpectrumProcessing^ EdSpectrumProcessing = ProcessingFactory::CreateSpectrumProcessing();
|
|
|
|
|
|
- ConvertSpectrumData(e->Value, _oxfordControllerData.m_pXrayDataList[_oxfordControllerData.m_nCollectedXrayCounts].m_pXrayData, _oxfordControllerData.m_nBufferSize);
|
|
|
+ // Use the autoIdSettings to define elements that are known or elements that you want to exclude. They also list elements that cannot be identified
|
|
|
+ IAutoIdSettings^ autoIdSettings = ProcessingFactory::CreateAutoIdSettings();
|
|
|
+ EdSpectrumProcessing->IdentifyElements(e->Value, autoIdSettings);
|
|
|
|
|
|
+ ISEMQuantSettings^ settings = ProcessingFactory::CreateSEMQuantSettings();
|
|
|
|
|
|
+ // While it is possible to choose other elements, Oxygen is the only supported element by stoichiometry.
|
|
|
+ settings->CombinedElement = 8;
|
|
|
+ settings->Normalised = true;
|
|
|
|
|
|
- _oxfordControllerData.m_nCollectedXrayCounts++;
|
|
|
- if (_oxfordControllerData.m_nCollectedXrayCounts == _oxfordControllerData.m_nXrayDataCount)
|
|
|
+ ISEMQuantStatus^ quantStatus = EdSpectrumProcessing->SEMQuantifySpectrum(e->Value, settings);//(a_nChannelData, OIHelper::SEMQuantSettings);
|
|
|
+
|
|
|
+ IEnumerable<ISEMQuantResult^>^ Results = quantStatus->Results;
|
|
|
+
|
|
|
+ if (_oxfordControllerData.m_nCommand == OxfordControllerCommand::COLLECT_XRAYPOINT
|
|
|
+ || _oxfordControllerData.m_nCommand == OxfordControllerCommand::COLLECT_CURRENTXRAYPOINT)
|
|
|
{
|
|
|
+ //Get element result for single point
|
|
|
+ auto ie = Results->GetEnumerator();
|
|
|
+
|
|
|
+ String^ Quant = gcnew String("");
|
|
|
+
|
|
|
+ while (ie->MoveNext())
|
|
|
+ {
|
|
|
+ ISEMQuantResult^ result = ie->Current;
|
|
|
+
|
|
|
+ if (result->WeightPercent != 0)
|
|
|
+ {
|
|
|
+ Quant += "Quant=";
|
|
|
+ Quant += ElementProperties::GetElementSymbol(result->AtomicNumber);
|
|
|
+ Quant += ",";
|
|
|
+ Quant += result->LineType.ToString();
|
|
|
+ Quant += ",";
|
|
|
+ Quant += result->WeightPercent.ToString();
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ _oxfordControllerData.m_sElementResult = Quant;
|
|
|
+ ConvertSpectrumData(e->Value, _oxfordControllerData.m_pSpectrumData, _oxfordControllerData.m_nBufferSize);
|
|
|
+
|
|
|
_oxfordControllerData.m_nState = OxfordControllerState::SUCCEEDED;
|
|
|
|
|
|
auto edsController = CreateEdsSpectrumController();
|
|
@@ -1236,10 +1307,64 @@ void OxfordControllerWrapper::OnXrayAcquisitionFinished(Object^ sender, OINA::Ex
|
|
|
{
|
|
|
edsController->EndMultipleAcquisition();
|
|
|
m_endControllerEvent->Set();
|
|
|
-
|
|
|
+
|
|
|
+ }
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+
|
|
|
+ //Get element result for single point
|
|
|
+ auto ie = Results->GetEnumerator();
|
|
|
+
|
|
|
+ String^ Quant = gcnew String("");
|
|
|
+ while (ie->MoveNext())
|
|
|
+ {
|
|
|
+ ISEMQuantResult^ result = ie->Current;
|
|
|
+
|
|
|
+ if (result->WeightPercent != 0)
|
|
|
+ {
|
|
|
+ Quant += "Quant=";
|
|
|
+ Quant += ElementProperties::GetElementSymbol(result->AtomicNumber);
|
|
|
+ Quant += ",";
|
|
|
+ Quant += result->LineType.ToString();
|
|
|
+ Quant += ",";
|
|
|
+ Quant += result->WeightPercent.ToString();
|
|
|
+ Quant += "\n";
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ CString msg = Quant;
|
|
|
+ unsigned char* dst = _oxfordControllerData.m_pXrayDataList[_oxfordControllerData.m_nCollectedXrayCounts].m_strElementResult;
|
|
|
+ for (int i = 0; i < msg.GetLength(); i++)
|
|
|
+ {
|
|
|
+ dst[i] = (unsigned char)msg.GetAt(i);
|
|
|
+ }
|
|
|
+
|
|
|
+ ConvertSpectrumData(e->Value, _oxfordControllerData.m_pXrayDataList[_oxfordControllerData.m_nCollectedXrayCounts].m_pXrayData, _oxfordControllerData.m_nBufferSize);
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ _oxfordControllerData.m_nCollectedXrayCounts++;
|
|
|
+ if (_oxfordControllerData.m_nCollectedXrayCounts == _oxfordControllerData.m_nXrayDataCount)
|
|
|
+ {
|
|
|
+ _oxfordControllerData.m_nState = OxfordControllerState::SUCCEEDED;
|
|
|
+
|
|
|
+ auto edsController = CreateEdsSpectrumController();
|
|
|
+ if (edsController)
|
|
|
+ {
|
|
|
+ edsController->EndMultipleAcquisition();
|
|
|
+ m_endControllerEvent->Set();
|
|
|
+
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
- }
|
|
|
+ }
|
|
|
+ catch (Exception^ ex)
|
|
|
+ {
|
|
|
+ CString sMessage(_T("OnXrayAcquisitionFinished failed") + ex->ToString());
|
|
|
+
|
|
|
+ LogErrorTrace(__FILE__, __LINE__, sMessage);
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
void OxfordControllerWrapper::OnXrayChordlistFinished(Object^, OINA::Extender::Acquisition::AcquisitionFinishedEventArgs<OINA::Extender::Data::Ed::IEdMap^>^ e)
|
|
@@ -1723,9 +1848,32 @@ bool OxfordControllerWrapper::StartImageCollecting()
|
|
|
|
|
|
try
|
|
|
{
|
|
|
- auto image = imageAcqusitionController->StartAcquisition(imageAcqusitionSettings);
|
|
|
+ List<IElectronImage^>^ electronImageList = gcnew List<IElectronImage^>();
|
|
|
|
|
|
- return image != nullptr;
|
|
|
+ auto images = imageAcqusitionController->StartAcquisition(imageAcqusitionSettings);
|
|
|
+
|
|
|
+ /*for each (auto eleImage in images)
|
|
|
+ {
|
|
|
+ electronImageList->Add(eleImage);
|
|
|
+ }
|
|
|
+
|
|
|
+ if (electronImageList->Count == 0)
|
|
|
+ {
|
|
|
+ _oxfordControllerData.m_nState = OxfordControllerState::FAILED;
|
|
|
+ }
|
|
|
+ else if (!ReadImageData(electronImageList[0], _oxfordControllerData.m_pImageBits))
|
|
|
+ {
|
|
|
+ _oxfordControllerData.m_nState = OxfordControllerState::FAILED;
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ _oxfordControllerData.m_nState = OxfordControllerState::SUCCEEDED;
|
|
|
+ }
|
|
|
+
|
|
|
+ m_endControllerEvent->Set();*/
|
|
|
+
|
|
|
+
|
|
|
+ return images != nullptr;
|
|
|
}
|
|
|
catch (Exception^ /*ex*/)
|
|
|
{
|
|
@@ -1740,25 +1888,33 @@ bool OxfordControllerWrapper::StartImageCollecting()
|
|
|
void OxfordControllerWrapper::OnImageAcquisitionFinished(Object^ /*sender*/, OINA::Extender::Acquisition::AcquisitionFinishedEventArgs<array<OINA::Extender::Data::Image::IElectronImage^ >^ >^ e)
|
|
|
{
|
|
|
List<IElectronImage^>^ electronImageList = gcnew List<IElectronImage^>();
|
|
|
-
|
|
|
- for each (auto eleImage in e->Value)
|
|
|
+ try
|
|
|
{
|
|
|
- electronImageList->Add(eleImage);
|
|
|
- }
|
|
|
|
|
|
- if (electronImageList->Count == 0)
|
|
|
- {
|
|
|
- _oxfordControllerData.m_nState = OxfordControllerState::FAILED;
|
|
|
- }
|
|
|
- else if (!ReadImageData(electronImageList[0], _oxfordControllerData.m_pImageBits))
|
|
|
- {
|
|
|
- _oxfordControllerData.m_nState = OxfordControllerState::FAILED;
|
|
|
+ for each (auto eleImage in e->Value)
|
|
|
+ {
|
|
|
+ electronImageList->Add(eleImage);
|
|
|
+ }
|
|
|
+
|
|
|
+ if (electronImageList->Count == 0)
|
|
|
+ {
|
|
|
+ _oxfordControllerData.m_nState = OxfordControllerState::FAILED;
|
|
|
+ }
|
|
|
+ else if (!ReadImageData(electronImageList[0], _oxfordControllerData.m_pImageBits))
|
|
|
+ {
|
|
|
+ _oxfordControllerData.m_nState = OxfordControllerState::FAILED;
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ _oxfordControllerData.m_nState = OxfordControllerState::SUCCEEDED;
|
|
|
+ }
|
|
|
}
|
|
|
- else
|
|
|
+ catch (Exception^ ex)
|
|
|
{
|
|
|
- _oxfordControllerData.m_nState = OxfordControllerState::SUCCEEDED;
|
|
|
- }
|
|
|
+ CString sMessage(_T("OnImageAcquisitionFinished failed")+ex->ToString());
|
|
|
|
|
|
+ LogErrorTrace(__FILE__, __LINE__, sMessage);
|
|
|
+ }
|
|
|
m_endControllerEvent->Set();
|
|
|
}
|
|
|
|
|
@@ -1910,7 +2066,8 @@ IMicroscopeController^ OxfordControllerWrapper::CreateMicroscopeController()
|
|
|
}
|
|
|
|
|
|
_microscopeController->ColumnChange += gcnew EventHandler<OINA::Extender::MicroscopeControl::ColumnEventArgs^>(this, &OxfordControllerWrapper::OnMicroscopeColumnUpdated);
|
|
|
- _microscopeController->StageChange += gcnew EventHandler<OINA::Extender::MicroscopeControl::StageEventArgs^>(this, &OxfordControllerWrapper::OnMicroscopeStageUpdated);
|
|
|
+ //_microscopeController->StageChange += gcnew EventHandler<OINA::Extender::MicroscopeControl::StageEventArgs^>(this, &OxfordControllerWrapper::OnMicroscopeStageUpdated);
|
|
|
+ _microscopeController->ChangeCompleted += gcnew EventHandler<OINA::Extender::MicroscopeControl::CompletedEventArgs^>(this, &OxfordControllerWrapper::OnMicroscopeCompleted);
|
|
|
|
|
|
m_bIsStageUpdated = false;
|
|
|
|