123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187 |
- using FEIApiControl;
- using OTSCLRINTERFACE;
- using OTSModelSharp.ServiceCenter;
- using System;
- using System.Collections.Generic;
- using System.Drawing;
- using System.Linq;
- namespace OTSMeasureApp.ServiceCenter
- {
- class FEIEDSController : IEDSController
- {
- private APIClass ApiClass = null;
-
- private int AnalyExpCount = 100000;
- private string strResolution = "";
- private int width = 0;
- private int height = 0;
- /// <summary>
- /// fei面扫这个参数作用是达到这个数值后采集xray操作停止,而ots期望计数率是lowcount的判断标准,两者概念不同,所以此处用常数5000而非ots期望计数率
- /// </summary>
- const int maxCounts = 8000;
- public FEIEDSController(int MaxCounts,bool ifautoid,string knownelements)
- {
- ApiClass = FEISemController.GetApiClassInstance();
- ApiClass.SetQuantificationParam(ifautoid, knownelements);
- SetAnalyExpCount(MaxCounts);
- Connect();
- }
- public bool GetXRayByFeatures(List<COTSParticleClr> a_listParticles, double a_nXRayAQTime, bool a_bElementInfo)
- {
- for (int i = 0; i < a_listParticles.Count; i++)
- {
- Dictionary<string, double> eleItems = new Dictionary<string, double>();
- uint[] spectrumItems = new uint[2000];
- if (ApiClass.GetSupportPolygon())//判断DLL是否支持多边形面扫
- {
- List<Point> points = CImageHandler.FindContoursBySegment(width, height, a_listParticles[i].GetFeature().GetSegmentsList());
- if (!ApiClass.GetXRayByPolygon(points, strResolution, a_nXRayAQTime, maxCounts, a_bElementInfo, ref eleItems, ref spectrumItems))
- {
- return false;
- }
- }
- else
- {
- Rectangle rectangle = (Rectangle)a_listParticles[i].GetParticleRect();
- if (!ApiClass.GetXRayByRect(rectangle, strResolution, a_nXRayAQTime, maxCounts, a_bElementInfo, ref eleItems, ref spectrumItems))
- {
- return false;
- }
- }
- var xray = a_listParticles[i].GetXray();
- xray.SetXrayData(spectrumItems);
- a_listParticles[i].SetXray(xray);
- if (a_bElementInfo)
- {
- List<CElementChemistryClr> elementChemistryClrs = new List<CElementChemistryClr>();
- for (int j = 0; j < eleItems.Count; j++)
- {
- CElementChemistryClr chemistryClr = new CElementChemistryClr();
- chemistryClr.SetName(eleItems.ElementAt(j).Key);
- chemistryClr.SetPercentage(eleItems.ElementAt(j).Value);
- elementChemistryClrs.Add(chemistryClr);
- }
- a_listParticles[i].GetXray().SetElementQuantifyData(elementChemistryClrs);
- }
- }
- return true;
- }
- public bool GetXRayByParts(List<COTSParticleClr> a_listParticles, uint a_nXRayAQTime, bool a_bElementInfo)
- {
- for (int i = 0; i < a_listParticles.Count; i++)
- {
- Point point = (Point)a_listParticles[i].GetXRayPos();
- Dictionary<string, double> eleItems = new Dictionary<string, double>();
- uint[] spectrumItems = new uint[2000];
- if (!ApiClass.GetXRayByPoint(point.X, point.Y, strResolution, a_nXRayAQTime, AnalyExpCount, a_bElementInfo, ref eleItems, ref spectrumItems))
- {
- return false;
- }
-
- var xray = a_listParticles[i].GetXray();
- xray.SetXrayData(spectrumItems);
- a_listParticles[i].SetXray(xray);
- if (a_bElementInfo)
- {
- List<CElementChemistryClr> elementChemistryClrs = new List<CElementChemistryClr>();
- for (int j = 0; j < eleItems.Count; j++)
- {
- CElementChemistryClr chemistryClr = new CElementChemistryClr();
- chemistryClr.SetName(eleItems.ElementAt(j).Key);
- chemistryClr.SetPercentage(eleItems.ElementAt(j).Value);
- elementChemistryClrs.Add(chemistryClr);
- }
- a_listParticles[i].GetXray().SetElementQuantifyData(elementChemistryClrs);
- }
- }
- return true;
- }
- public bool CollectSpectrum(uint a_nXRayAQTime, ref uint[] a_XrayData)
- {
-
- Dictionary<string, double> eleItems = new Dictionary<string, double>();
- return ApiClass.AcquireSpectrum(false, ref eleItems, ref a_XrayData);
-
- }
- public bool Connect()
- {
- string FEIIP = FileHelper.GetXMLInformations("FEIIP");
- string FEIPORT = FileHelper.GetXMLInformations("FEIPORT");
- if (FEIIP == "" || FEIPORT == "")
- {
- NLog.LogManager.GetCurrentClassLogger().Error("FEI电镜端口配置为空!");
- return false;
- }
- if (ApiClass.isConnect())
- {
- return true;
- }
- return ApiClass.Connect(FEIIP, FEIPORT);
- }
-
- private bool SetAnalyExpCount(int MaxCounts)
- {
-
- AnalyExpCount = MaxCounts;
-
- return true;
- }
- public EDSTYPE GetEDSType()
- {
- return EDSTYPE.FEI;
- }
-
- public void SetFilterKeyEleNames(List<string> KeyNameList)
- {
- throw new NotImplementedException();
- }
- void IEDSController.SetResolution(int ResolutionWidth, int ResolutionHeight)
- {
- ApiClass.SetResolution(ResolutionWidth, ResolutionHeight);
- width = ResolutionWidth;
- height = ResolutionHeight;
- strResolution = ResolutionWidth.ToString() + "x" + ResolutionHeight.ToString();
- }
- public bool QuantifyXrayByPart(COTSParticleClr part)
- {
- return true;
- }
- public int GetExpectCount()
- {
- return AnalyExpCount;
- }
- public bool GetIfDelayQuantify()
- {
- return false;
- }
- public void SetQuantifiCationParam(bool IfAutoId, string knownElements)
- {
- ApiClass.SetQuantificationParam(IfAutoId, knownElements);
- }
- public bool GetXRayByExpandFeatures(List<COTSParticleClr> a_listParticles, double a_nXRayAQTime, bool a_bElementInfo)
- {
- throw new NotImplementedException();
- }
- }
- }
|