zty 3 роки тому
батько
коміт
ad767f9309

+ 16 - 33
OTSIncAMeasureApp/ServiceCenter/EDSController.cs

@@ -20,6 +20,7 @@ namespace OTSModelSharp.ServiceInterface
         public static APIClass ApiClass = null;
         private static bool isFEI = false;
         private int AnalyExpCount = 100000;
+        private string strResolution = "";
         public static EDSController GetEDSController()
         {
             if (FileHelper.GetXMLInformations("EDSName") == "FEI")
@@ -55,7 +56,7 @@ namespace OTSModelSharp.ServiceInterface
                     Rectangle rectangle = (Rectangle)a_listParticles[i].GetParticleRect();
                     Dictionary<string, double> eleItems = new Dictionary<string, double>();
                     uint[] spectrumItems = new uint[2000];
-                    if (!ApiClass.GetXRayByRect(rectangle, a_nXRayAQTime, AnalyExpCount, a_bElementInfo, ref eleItems, ref spectrumItems))
+                    if (!ApiClass.GetXRayByRect(rectangle, strResolution, a_nXRayAQTime, AnalyExpCount, a_bElementInfo, ref eleItems, ref spectrumItems))
                     {
                         return false;
                     }
@@ -99,7 +100,7 @@ namespace OTSModelSharp.ServiceInterface
                     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, a_nXRayAQTime, AnalyExpCount, a_bElementInfo, ref eleItems, ref spectrumItems))
+                    if (!ApiClass.GetXRayByPoint(point.X, point.Y, strResolution, a_nXRayAQTime, AnalyExpCount, a_bElementInfo, ref eleItems, ref spectrumItems))
                     {
                         return false;
                     }
@@ -146,18 +147,9 @@ namespace OTSModelSharp.ServiceInterface
         {
             if (isFEI)
             {
-                double x = 0;
-                double y = 0;
-                double z = 0;
-                double r = 0;
-                double t = 0;
                 Dictionary<string, double> eleItems = new Dictionary<string, double>();
-                if (!ApiClass.GetSemPositionXYZRT(ref x, ref y, ref z, ref r, ref t))
-                {
-                    return false;
-                }
 
-                return ApiClass.GetXRayByPoint((int)x, (int)y, a_nXRayAQTime, AnalyExpCount, false, ref eleItems, ref a_XrayData);
+                return ApiClass.AcquireSpectrum(false, ref eleItems, ref a_XrayData);
             }
             else
             {
@@ -184,8 +176,7 @@ namespace OTSModelSharp.ServiceInterface
                 {
                     return false;
                 }
-
-                return ApiClass.GetXRayByPoint((int)x, (int)y, a_nXRayAQTime, AnalyExpCount, a_bElementInfo, ref eleItems, ref a_XrayData);
+                return ApiClass.GetXRayByPoint((int)x, (int)y, strResolution, a_nXRayAQTime, AnalyExpCount, a_bElementInfo, ref eleItems, ref a_XrayData);
             }
             else
             {
@@ -209,8 +200,7 @@ namespace OTSModelSharp.ServiceInterface
                 rectangle.Height = Math.Abs(rectangle.Y - rectangle.X);
 
                 Dictionary<string, double> eleItems = new Dictionary<string, double>();
-
-                return ApiClass.GetXRayByRect(rectangle, a_nXRayAQTime, AnalyExpCount, a_bElementInfo, ref eleItems, ref a_XrayData);
+                return ApiClass.GetXRayByRect(rectangle, strResolution, a_nXRayAQTime, AnalyExpCount, a_bElementInfo, ref eleItems, ref a_XrayData);
             }
             else
             {
@@ -227,17 +217,8 @@ namespace OTSModelSharp.ServiceInterface
         {
             if (isFEI)
             {
-                double x = 0;
-                double y = 0;
-                double z = 0;
-                double r = 0;
-                double t = 0;
                 Dictionary<string, double> eleItems = new Dictionary<string, double>();
-                if (!ApiClass.GetSemPositionXYZRT(ref x, ref y, ref z, ref r, ref t))
-                {
-                    return false;
-                }
-                bool isTrue = ApiClass.GetXRayByPoint((int)x, (int)y, a_nXRayAQTime, AnalyExpCount, true, ref eleItems, ref a_XrayData);
+                bool isTrue = ApiClass.AcquireSpectrum(true, ref eleItems, ref a_XrayData);
                 a_nElementNum = eleItems.Count;
                 for (int i = 0; i < eleItems.Count; i++)
                 {
@@ -262,7 +243,7 @@ namespace OTSModelSharp.ServiceInterface
             if (isFEI)
             {
                 Dictionary<string, double> eleItems = new Dictionary<string, double>();
-                bool isTrue = ApiClass.GetXRayByPoint(dMouseImgX, dMouseImgY, a_nXRayAQTime, AnalyExpCount, true, ref eleItems, ref a_XrayData);
+                bool isTrue = ApiClass.GetXRayByPoint(dMouseImgX, dMouseImgY, strResolution, a_nXRayAQTime, AnalyExpCount, true, ref eleItems, ref a_XrayData);
                 a_nElementNum = eleItems.Count;
                 for (int i = 0; i < eleItems.Count; i++)
                 {
@@ -316,10 +297,15 @@ namespace OTSModelSharp.ServiceInterface
                 string FEIPORT = FileHelper.GetXMLInformations("FEIPORT");
                 if (FEIIP == "" || FEIPORT == "")
                 {
-                    MessageBox.Show("FEI电镜端口配置为空!");
+                    NLog.LogManager.GetCurrentClassLogger().Error("FEI电镜端口配置为空!");
                     return false;
                 }
 
+                if (ApiClass.isConnect())
+                {
+                    return true;
+                }
+
                 return ApiClass.Connect(FEIIP, FEIPORT);
             }
             else
@@ -358,12 +344,9 @@ namespace OTSModelSharp.ServiceInterface
         {
             if (isFEI)
             {
-                return ApiClass.SetResolution(ResolutionWidth, ResolutionHeight);
-            }
-            else
-            {
-                return true;
+                strResolution = ResolutionWidth + "x" + ResolutionHeight;
             }
+            return true;
         }
 
         public bool SetAnalyExpCount(int MaxCounts)

+ 6 - 1
OTSIncAMeasureApp/ServiceCenter/ScanController.cs

@@ -87,10 +87,15 @@ namespace OTSModelSharp.ServiceInterface
                 string FEIPORT = FileHelper.GetXMLInformations("FEIPORT");
                 if (FEIIP == "" || FEIPORT == "")
                 {
-                    MessageBox.Show("FEI电镜端口配置为空!");
+                    NLog.LogManager.GetCurrentClassLogger().Error("FEI电镜端口配置为空!");
                     return false;
                 }
 
+                if (ApiClass.isConnect())
+                {
+                    return true;
+                }
+
                 return ApiClass.Connect(FEIIP, FEIPORT);
             }
             else

+ 8 - 1
OTSIncAMeasureApp/ServiceCenter/SemController.cs

@@ -51,10 +51,15 @@ namespace OTSModelSharp.ServiceInterface
                 string FEIPORT = FileHelper.GetXMLInformations("FEIPORT");
                 if (FEIIP == "" || FEIPORT == "")
                 {
-                    MessageBox.Show("FEI电镜端口配置为空!");
+                    NLog.LogManager.GetCurrentClassLogger().Error("FEI电镜端口配置为空!");
                     return false;
                 }
 
+                if (ApiClass.isConnect())
+                {
+                    return true;
+                }
+
                 return ApiClass.Connect(FEIIP, FEIPORT);
             }
             else
@@ -227,6 +232,7 @@ namespace OTSModelSharp.ServiceInterface
                 {
                     return false;
                 }
+                NLog.LogManager.GetCurrentClassLogger().Warn("Set WorkingDistance:" + a_distance.ToString("F2"));
                 return hw.GetSemWorkingDistance(ref a_distance);
             }
         }
@@ -275,6 +281,7 @@ namespace OTSModelSharp.ServiceInterface
                 {
                     return false;
                 }
+                NLog.LogManager.GetCurrentClassLogger().Warn("Set Magnification:" + a_dMagnification.ToString("F2"));
                 hw.SetSemMagnification(a_dMagnification);
                 return true;
             }

+ 22 - 7
OTSSysMgrApp/ControllerSettingForm.cs

@@ -318,7 +318,7 @@ namespace OTSSysMgrApp
                         uint[] a_XrayData = new uint[2000];
                         uint a_Milliseconds = 0;
                         //采集时间
-                        a_Milliseconds = Convert.ToUInt32(120);
+                        a_Milliseconds = Convert.ToUInt32(tbCollectionTime.Text);
                         //采集XRay数据
                         m_EDSHardwareMgr.CollectSpectrum(a_Milliseconds, ref a_XrayData);
                         int[] XData = new int[2000];
@@ -887,16 +887,31 @@ namespace OTSSysMgrApp
                         //采集时间
                         a_Milliseconds = Convert.ToUInt32(tbCollectionTime.Text);
                         //采集XRay数据
-                        Point p = new Point(10, 10);
-                        string ele = "";
-                        m_EDSHardwareMgr.GetXRayBySinglePoint(a_Milliseconds,p, ref a_XrayData, ref ele, false);
+                        List<COTSParticleClr> cOTSParticleClrs = new List<COTSParticleClr>();
+                        for (int i = 0; i < 5; i++)
+                        {
+                            COTSParticleClr cOTSParticle = new COTSParticleClr();
+                            CPosXrayClr cPosXray = new CPosXrayClr();
+                            cOTSParticle.SetXray(cPosXray);
+                            cOTSParticle.SetXRayPos(new Point(100 + i, 100 + i));
+                            cOTSParticleClrs.Add(cOTSParticle);
+                        }
+
+                        m_EDSHardwareMgr.SetResolution(int.Parse(tbRWidth.Text), int.Parse(tbRHeight.Text));
+                        m_EDSHardwareMgr.GetXRayByPoints(cOTSParticleClrs, a_Milliseconds, false);
+
                         int[] XData = new int[2000];
                         uint nXrayCount = 0;
-                        for (int i = 1; i <= 2000; i++)
+                        for (int j = 0; j < 5; j++)
                         {
-                            XData[i - 1] = i;
-                            nXrayCount += a_XrayData[i - 1];
+                            a_XrayData = cOTSParticleClrs[j].GetXray().GetXrayData();
+                            for (int i = 1; i <= 2000; i++)
+                            {
+                                XData[i - 1] = i;
+                                nXrayCount += a_XrayData[i - 1];
+                            }
                         }
+
                         //绑定数据源
                         chartData(XData, a_XrayData);
                         //显示Xray计数

BIN
OpenDll/FEIAPI/FEIApiControl.dll