|
@@ -102,12 +102,18 @@ namespace Extender
|
|
|
public short type;
|
|
|
}
|
|
|
|
|
|
- public struct PointXrayParam
|
|
|
+ public class PointXrayParam
|
|
|
{
|
|
|
+ public PointXrayParam()
|
|
|
+ {
|
|
|
+
|
|
|
+ this.XrayData = new long[2000];
|
|
|
+ this.listElement=new Dictionary<string, double> ();
|
|
|
+ }
|
|
|
public double dMilliSecondsTime;
|
|
|
- public int x;
|
|
|
- public int y;
|
|
|
- public long[] XrayData;
|
|
|
+ public double x;
|
|
|
+ public double y;
|
|
|
+ public long[] XrayData ;
|
|
|
public Dictionary<string, double> listElement;
|
|
|
|
|
|
}
|
|
@@ -233,19 +239,16 @@ namespace Extender
|
|
|
PointXrayParam p = currentCommand.pointXrayPrm;
|
|
|
|
|
|
log.Info("线程:开始采集单点xray");
|
|
|
- if (myExtender == null)
|
|
|
- {
|
|
|
- myExtender = new Extender();
|
|
|
- log.Info("renew the myExtender");
|
|
|
- }
|
|
|
- if (myExtender.XrayPointCollectiong(p.dMilliSecondsTime, p.x, p.y, out p.XrayData,out p.listElement))
|
|
|
+
|
|
|
+ if (myExtender.XrayPointCollecting(p.dMilliSecondsTime, p.x, p.y, out p.XrayData,out p.listElement))
|
|
|
{
|
|
|
- log.Info("线程:采集单点xray成功");
|
|
|
+
|
|
|
currentCommand.pointXrayPrm = p;
|
|
|
currentCommand.returnType = true;
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
+ log.Error("线程:采集单点xray失败");
|
|
|
currentCommand.returnType = false;
|
|
|
}
|
|
|
endEvent.Set();
|
|
@@ -254,7 +257,7 @@ namespace Extender
|
|
|
case OxfordCommand.XrayAreaCollectiong:
|
|
|
{
|
|
|
AreaXrayParam p = currentCommand.areaXrayPrm;
|
|
|
- if (myExtender.XrayAreaCollectiong(p.dMilliSecondsTime, p.a_listChord,out p.XrayData, out p.a_listElement))
|
|
|
+ if (myExtender.XrayAreaCollectiong( p.dMilliSecondsTime, p.a_listChord,out p.XrayData, out p.a_listElement))
|
|
|
{
|
|
|
currentCommand.areaXrayPrm = p;
|
|
|
currentCommand.returnType = true;
|
|
@@ -433,7 +436,6 @@ namespace Extender
|
|
|
|
|
|
public bool SetImageAcquistionSetting(double a_dDwellTime, int a_nImageType, double a_dImageScanSize)
|
|
|
{
|
|
|
- log.Info("进入wrapper");
|
|
|
return myExtender.SetImageAcquistionSetting(a_dDwellTime, a_nImageType, a_dImageScanSize);
|
|
|
}
|
|
|
|
|
@@ -487,7 +489,7 @@ namespace Extender
|
|
|
return myExtender.SetWorkingDistance(set);
|
|
|
}
|
|
|
|
|
|
- public bool XrayAreaCollectiong(double dMilliSecondsTime, List<Segment> a_listChord, out long[] XrayData, out Dictionary<string, double> a_listElement)
|
|
|
+ public bool XrayAreaCollectiong( double dMilliSecondsTime, List<Segment> a_listChord, out long[] XrayData, out Dictionary<string, double> a_listElement)
|
|
|
{
|
|
|
var p = new AreaXrayParam();
|
|
|
p = currentCommand.areaXrayPrm;
|
|
@@ -517,10 +519,10 @@ namespace Extender
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- public bool XrayPointCollectiong(double dMilliSecondsTime, int x, int y, out long[] XrayData, out Dictionary<string, double> a_listElement)
|
|
|
+ public bool XrayPointCollecting(double dMilliSecondsTime, double x, double y, out long[] XrayData, out Dictionary<string, double> a_listElement)
|
|
|
{
|
|
|
var p = new PointXrayParam();
|
|
|
- log.Info("进入 xrayPointCollecting");
|
|
|
+
|
|
|
p.dMilliSecondsTime = dMilliSecondsTime;
|
|
|
p.x = x;
|
|
|
p.y = y;
|
|
@@ -584,7 +586,7 @@ namespace Extender
|
|
|
}
|
|
|
public class Extender : IExtenderControl
|
|
|
{
|
|
|
-
|
|
|
+
|
|
|
|
|
|
//构造函数
|
|
|
public Extender()
|
|
@@ -1256,8 +1258,8 @@ namespace Extender
|
|
|
//a_dImageScanSize : 图像分辨率,图像的高
|
|
|
public bool SetImageAcquistionSetting(double a_dDwellTime, int a_nImageType, double a_dImageScanSize)
|
|
|
{
|
|
|
- NLog.Logger log = NLog.LogManager.GetCurrentClassLogger();
|
|
|
- log.Info("进入setImageAcquisition");
|
|
|
+
|
|
|
+
|
|
|
IImageSettings imageSettings = imageAcquisitionSettings.ImageSettings;
|
|
|
IImageCapabilities imageCapabilities = imageAcquisitionSettings.ImageCapabilities;
|
|
|
IImageScanSettings scanSettings = imageAcquisitionSettings.ScanSettings;
|
|
@@ -1289,7 +1291,7 @@ namespace Extender
|
|
|
|
|
|
var pixelSize = 1d / a_dImageScanSize;
|
|
|
|
|
|
- log.Info("开始createFullFieldRegion");
|
|
|
+
|
|
|
scanSettings.AcquisitionRegion.CreateFullFieldRegion(pixelSize);
|
|
|
|
|
|
return true;
|
|
@@ -1305,12 +1307,12 @@ namespace Extender
|
|
|
{
|
|
|
int lastingTime = 0;
|
|
|
NLog.Logger log = NLog.LogManager.GetCurrentClassLogger();
|
|
|
- log.Info("拍图开始");
|
|
|
+
|
|
|
|
|
|
//imageAcquisitionController.BeginMultipleAcquisition();
|
|
|
IEnumerable<IElectronImage> images = imageAcquisitionController.StartAcquisition(imageAcquisitionSettings);
|
|
|
|
|
|
- log.Info("startAcquisition 完成");
|
|
|
+ log.Info("拍图开始 startAcquisition 完成");
|
|
|
images.ToList().ForEach(i =>
|
|
|
{
|
|
|
i.Label = string.Format(@"Code example image - {0:HH:mm:ss} - {1}", DateTime.Now, i.InputSource.ToString());
|
|
@@ -1348,7 +1350,7 @@ namespace Extender
|
|
|
|
|
|
Thread.Sleep(100);
|
|
|
lastingTime += 100;
|
|
|
- if (lastingTime > EDSColletionTimeOut*3)
|
|
|
+ if (lastingTime > EDSColletionTimeOut*6)
|
|
|
{
|
|
|
return false;
|
|
|
}
|
|
@@ -1477,7 +1479,7 @@ namespace Extender
|
|
|
private int XRayChannelLength = 2000;
|
|
|
private long[] m_XrayData = null;
|
|
|
private bool m_bXrayDone = false;
|
|
|
- private int EDSColletionTimeOut=60000;
|
|
|
+ private int EDSColletionTimeOut=10000;
|
|
|
/// <summary>
|
|
|
/// List of EdSpectrum objects
|
|
|
/// </summary>
|
|
@@ -1502,40 +1504,41 @@ namespace Extender
|
|
|
//EdSpectrumAcquisitionController.ExperimentStarted -= this.OnEdSpectrumExperimentStarted;
|
|
|
}
|
|
|
|
|
|
- void SetXrayAcquisitionParam(double a_dMilliSecondsTime)
|
|
|
+ void SetXrayAcquisitionParam(ref double a_dMilliSecondsTime)
|
|
|
{
|
|
|
EdSpectrumSettings.EdSettings.AcquisitionMode = EdAcquireMode.LiveTime; // RealTime or LiveTime
|
|
|
|
|
|
- if (a_dMilliSecondsTime < 200)
|
|
|
+ if (a_dMilliSecondsTime < 5000)
|
|
|
{
|
|
|
- a_dMilliSecondsTime = 200;
|
|
|
+ a_dMilliSecondsTime = 5000;
|
|
|
}
|
|
|
|
|
|
EdSpectrumSettings.EdSettings.AcquisitionTime = TimeSpan.FromMilliseconds(a_dMilliSecondsTime);
|
|
|
|
|
|
- EdSpectrumSettings.EdSettings.ProcessTime = 1;
|
|
|
+ EdSpectrumSettings.EdSettings.ProcessTime = 4;
|
|
|
EdSpectrumSettings.EdSettings.EnergyRange = 20;
|
|
|
EdSpectrumSettings.EdSettings.NumberOfChannels = 4096;
|
|
|
|
|
|
EdSpectrumSettings.ScanSettings.AcquisitionRegion.CreateFullFieldRegion(1.0 / 1024.0);
|
|
|
}
|
|
|
|
|
|
- void SetPointAcquistionRegion(int a_nX, int a_nY)
|
|
|
+ void SetPointAcquistionRegion(double a_nX, double a_nY)
|
|
|
{
|
|
|
- Chord chord = new Chord(a_nX, a_nY, 1);
|
|
|
- List < Chord > chords = new List < Chord> ();
|
|
|
- chords.Add(chord);
|
|
|
+ //Chord chord = new Chord(a_nX, a_nY, 1);
|
|
|
+ //List < Chord > chords = new List < Chord> ();
|
|
|
+ //chords.Add(chord);
|
|
|
|
|
|
- ChordList chordsList = null;
|
|
|
- if (m_nImageWidth != 0)
|
|
|
- {
|
|
|
- chordsList = new ChordList(chords, 1 / (double)m_nImageWidth);
|
|
|
- }
|
|
|
- else
|
|
|
- {
|
|
|
- chordsList = new ChordList(chords, 1 / 1024.0);
|
|
|
- }
|
|
|
- EdSpectrumSettings.ScanSettings.AcquisitionRegion.CreateChordListRegion(chordsList);
|
|
|
+ //ChordList chordsList = null;
|
|
|
+ //if (m_nImageWidth != 0)
|
|
|
+ //{
|
|
|
+ // chordsList = new ChordList(chords, 1 / (double)m_nImageWidth);
|
|
|
+ //}
|
|
|
+ //else
|
|
|
+ //{
|
|
|
+ // chordsList = new ChordList(chords, 1 / 1024.0);
|
|
|
+ //}
|
|
|
+ //EdSpectrumSettings.ScanSettings.AcquisitionRegion.CreateChordListRegion(chordsList);
|
|
|
+ EdSpectrumSettings.ScanSettings.AcquisitionRegion.CreatePointRegion(new System.Windows.Point(a_nX, a_nY));
|
|
|
}
|
|
|
|
|
|
void SetAreaAcquistionRegion(List<Chord> a_nChords)
|
|
@@ -1589,20 +1592,20 @@ namespace Extender
|
|
|
|
|
|
IEdSpectrumAcquisitionController edSpectrumAcquisitionController = sender as IEdSpectrumAcquisitionController;
|
|
|
|
|
|
- //if (edSpectrumAcquisitionController != null)
|
|
|
- //{
|
|
|
- // // This only used for multiple acquisition:
|
|
|
- // // If this is the last experiment, call EndMultipleAcquisition on the Acquisition
|
|
|
- // // controller, to re-enable external scan switching
|
|
|
- // edSpectrumAcquisitionController.EndMultipleAcquisition();
|
|
|
- //}
|
|
|
|
|
|
+
|
|
|
+ NLog.Logger log = NLog.LogManager.GetCurrentClassLogger();
|
|
|
IEdSpectrum edSpectrum = e.Value;
|
|
|
|
|
|
if (!ReadXrayData(edSpectrum, out m_XrayData, XRayChannelLength))
|
|
|
{
|
|
|
MessageBox.Show("Xray采集完成,获取图像像素失败!");
|
|
|
}
|
|
|
+ long nXraycount = 0;
|
|
|
+ for (int i = 0; i < 2000; i++)
|
|
|
+ {
|
|
|
+ nXraycount += m_XrayData[i];
|
|
|
+ }
|
|
|
|
|
|
//Quantify processing
|
|
|
|
|
@@ -1614,6 +1617,7 @@ namespace Extender
|
|
|
IEnumerable < ISEMQuantResult > Results = quantStatus.Results;
|
|
|
|
|
|
//Get element result for single point
|
|
|
+ //quantStatus.Results.
|
|
|
var ie = Results.GetEnumerator();
|
|
|
|
|
|
listElement = new Dictionary<string, double>();
|
|
@@ -1626,19 +1630,22 @@ namespace Extender
|
|
|
{
|
|
|
listElement.Add(ElementProperties.GetElementSymbol(result.AtomicNumber), result.WeightPercent );
|
|
|
}
|
|
|
+
|
|
|
}
|
|
|
|
|
|
if (m_XrayData != null && m_XrayData.Length == XRayChannelLength)
|
|
|
{
|
|
|
- NLog.Logger log = NLog.LogManager.GetCurrentClassLogger();
|
|
|
+
|
|
|
log.Info("xray 采集结束事件,采集成功 当前线程" + Thread.CurrentThread.ManagedThreadId.ToString());
|
|
|
+ log.Info("计数率为:" + nXraycount.ToString());
|
|
|
+ if (nXraycount < 5000)
|
|
|
+ {
|
|
|
+ log.Warn("计数率低于5000!");
|
|
|
+ }
|
|
|
m_bXrayDone = true;
|
|
|
|
|
|
}
|
|
|
- else
|
|
|
- {
|
|
|
-
|
|
|
- }
|
|
|
+
|
|
|
|
|
|
}
|
|
|
|
|
@@ -1702,7 +1709,7 @@ namespace Extender
|
|
|
|
|
|
//点扫描
|
|
|
//X-ray
|
|
|
- public Boolean XrayPointCollectiong(double dMilliSecondsTime, int x, int y, out long[] XrayData, out Dictionary<string, double> a_listElement)
|
|
|
+ public Boolean XrayPointCollecting(double dMilliSecondsTime, double x, double y, out long[] XrayData, out Dictionary<string, double> a_listElement)
|
|
|
{
|
|
|
|
|
|
XrayParamInit();
|
|
@@ -1710,33 +1717,22 @@ namespace Extender
|
|
|
XrayData = new long[XRayChannelLength];
|
|
|
a_listElement = new Dictionary<string, double>();
|
|
|
|
|
|
- SetXrayAcquisitionParam(dMilliSecondsTime);
|
|
|
+ SetXrayAcquisitionParam(ref dMilliSecondsTime);
|
|
|
|
|
|
SetPointAcquistionRegion(x, y);
|
|
|
-
|
|
|
+ NLog.Logger log = NLog.LogManager.GetCurrentClassLogger();
|
|
|
+ log.Info("开始XrayStartAcquisition:t="+dMilliSecondsTime.ToString()+"pos="+"("+x.ToString()+","+y.ToString()+")");
|
|
|
|
|
|
|
|
|
- // IEdSpectrumSettings.EdCapabilities will validate settings and hardware availability.
|
|
|
if (EdSpectrumAcquisitionController.IsEdHardwareReady(EdSpectrumSettings))
|
|
|
{
|
|
|
|
|
|
-
|
|
|
-
|
|
|
- // This only used for multiple acquisition:
|
|
|
- // if this is the first acquisition, call BeginMultipleAcquisition
|
|
|
- // on the IEdSpectrumAcquisitionController to suppress external scan switching
|
|
|
-
|
|
|
- //if (m_bXrayDone)
|
|
|
- //{
|
|
|
- // EdSpectrumAcquisitionController.BeginMultipleAcquisition();
|
|
|
- //}
|
|
|
-
|
|
|
// Start spectrum acquisition
|
|
|
try
|
|
|
{
|
|
|
+ m_bXrayDone = false;
|
|
|
int lastingTime = 0;
|
|
|
- NLog.Logger log = NLog.LogManager.GetCurrentClassLogger();
|
|
|
- log.Info("开始XrayStartAcquisition");
|
|
|
+
|
|
|
IEdSpectrum edSpectrum = EdSpectrumAcquisitionController.StartAcquisition(EdSpectrumSettings);
|
|
|
edSpectrum.Label = string.Format(@"Point({0},{1})",x,y);
|
|
|
|
|
@@ -1754,9 +1750,10 @@ namespace Extender
|
|
|
|
|
|
Thread.Sleep(100);
|
|
|
lastingTime += 100;
|
|
|
- if (lastingTime > EDSColletionTimeOut)
|
|
|
+ if (lastingTime > EDSColletionTimeOut*3)
|
|
|
{
|
|
|
//EdSpectrumAcquisitionController.EndMultipleAcquisition();
|
|
|
+ log.Warn("XrayStartAcquisition 超时!");
|
|
|
return false;
|
|
|
}
|
|
|
}
|
|
@@ -1782,14 +1779,14 @@ namespace Extender
|
|
|
return true;
|
|
|
}
|
|
|
//面扫描
|
|
|
- public Boolean XrayAreaCollectiong(double dMilliSecondsTime, List<Segment> a_listChord, out long[] XrayData, out Dictionary<string, double> a_listElement)
|
|
|
+ public Boolean XrayAreaCollectiong( double dMilliSecondsTime, List<Segment> a_listChord, out long[] XrayData, out Dictionary<string, double> a_listElement)
|
|
|
{
|
|
|
XrayParamInit();
|
|
|
|
|
|
XrayData = new long[XRayChannelLength];
|
|
|
a_listElement = new Dictionary<string, double>();
|
|
|
|
|
|
- SetXrayAcquisitionParam(dMilliSecondsTime);
|
|
|
+ SetXrayAcquisitionParam(ref dMilliSecondsTime);
|
|
|
List<Chord> Chords = new List<Chord>();
|
|
|
|
|
|
foreach (Segment seg in a_listChord)
|
|
@@ -1827,7 +1824,7 @@ namespace Extender
|
|
|
Thread.Sleep(100);
|
|
|
Application.DoEvents();
|
|
|
lastingTime += 100;
|
|
|
- if (lastingTime > EDSColletionTimeOut)
|
|
|
+ if (lastingTime > EDSColletionTimeOut*3)
|
|
|
{
|
|
|
//EdSpectrumAcquisitionController.EndMultipleAcquisition();
|
|
|
return false;
|