Kaynağa Gözat

1.修改退rt报未处理异常
2.退出rt资源监控终止
3.修改plc重连

JET-YDB\JET-YANGDB 6 ay önce
ebeveyn
işleme
4582582fe3

+ 9 - 4
FrameworkLocal/Common/Log/LOG.cs

@@ -22,10 +22,15 @@ namespace Aitex.Core.RT.Log
 
         static string GetFormatStackFrameInfo(int traceLevel)
         {
-            StackFrame sf = new StackTrace(true).GetFrame(traceLevel+1);
-            string pathFile = sf.GetFileName();
-            string file = string.IsNullOrEmpty(pathFile) ? "" : pathFile.Substring(pathFile.LastIndexOf('\\') + 1);
-            return $"{file}\tLine {sf.GetFileLineNumber()}\t{sf.GetMethod().Name}()";
+            try
+            {
+                StackFrame sf = new StackTrace(true).GetFrame(traceLevel + 1);
+                string pathFile = sf.GetFileName();
+                string file = string.IsNullOrEmpty(pathFile) ? "" : pathFile.Substring(pathFile.LastIndexOf('\\') + 1);
+                return $"{file}\tLine {sf.GetFileLineNumber()}\t{sf.GetMethod().Name}()";
+            }
+            catch (Exception) { }
+            return string.Empty;
         }
 
         public static void Warning(string message, int traceLevel = 2, [CallerFilePath] string file = "",

+ 12 - 2
FrameworkLocal/Common/PLC/FinsPlc.cs

@@ -456,7 +456,8 @@ namespace MECF.Framework.Common.PLC
                     LOG.Write(ex, String.Format("Communication failed with PLC {0}:{1}", _ip, _port));
                     EV.PostMessage("System", EventEnum.DefaultWarning, String.Format("Communication failed with PLC {0}:{1}", _ip, _port));
                 }
-
+                _isOpened = false;
+                SetState(IoProviderStateEnum.Uninitialized);
                 return;
             }
 
@@ -474,7 +475,6 @@ namespace MECF.Framework.Common.PLC
                 if (_isOpened)
                 {
                     _isOpened = false;
-                    SetState(IoProviderStateEnum.Uninitialized);
                     msender.Close();
                 }
 
@@ -515,6 +515,8 @@ namespace MECF.Framework.Common.PLC
                 LOG.Error($"PLC ({_ip}) Read DI exception{detail}.", ex);
                 EV.PostMessage("System", EventEnum.DefaultWarning, "PLC Read DI exception");
                 Close();
+                if (State != IoProviderStateEnum.Closing)
+                    SetState(IoProviderStateEnum.Uninitialized);
             }
             return null;
         }
@@ -544,6 +546,8 @@ namespace MECF.Framework.Common.PLC
                 LOG.Error($"PLC ({_ip}) Read DO exception{detail}.", ex);
                 EV.PostMessage("System", EventEnum.DefaultWarning, "PLC Read DO exception");
                 Close();
+                if (State != IoProviderStateEnum.Closing)
+                    SetState(IoProviderStateEnum.Uninitialized);
             }
             return null;
         }
@@ -574,6 +578,8 @@ namespace MECF.Framework.Common.PLC
                 LOG.Error($"PLC ({_ip}) Read AI exception{detail}.", ex);
                 EV.PostMessage("System", EventEnum.DefaultWarning, "PLC Read AI exception");
                 Close();
+                if (State != IoProviderStateEnum.Closing)
+                    SetState(IoProviderStateEnum.Uninitialized);
             }
             return null;
         }
@@ -603,6 +609,8 @@ namespace MECF.Framework.Common.PLC
                 LOG.Error($"PLC ({_ip}) Write DO exception{detail}.", ex);
                 EV.PostMessage("System", EventEnum.DefaultWarning, "PLC Write DO exception");
                 Close();
+                if (State != IoProviderStateEnum.Closing)
+                    SetState(IoProviderStateEnum.Uninitialized);
                 return;
             }
         }
@@ -633,6 +641,8 @@ namespace MECF.Framework.Common.PLC
                 LOG.Error($"PLC ({_ip}) Write AO exception{detail}.", ex);
                 EV.PostMessage("System", EventEnum.DefaultWarning, "PLC Write AO exception");
                 Close();
+                if (State != IoProviderStateEnum.Closing)
+                    SetState(IoProviderStateEnum.Uninitialized);
                 return;
             }
         }

+ 1 - 0
Mars/EfemDualRT/Instances/ToolLoader.cs

@@ -105,6 +105,7 @@ namespace EfemDualRT.Instances
 
         public void Terminate()
         {
+            Singleton<ResourceMonitor>.Instance.Terminate();
             Singleton<EfemDualEquipment>.Instance.Terminate();
 
             DEVICE.Managers.ForEach(p=>p.Terminate());

+ 4 - 0
Mars/EfemDualRT/Resources/ResourceMonitor.cs

@@ -13,6 +13,7 @@ using System.Net.NetworkInformation;
 using System.Reflection;
 using System.ServiceModel.Channels;
 using System.Text;
+using System.Threading;
 using System.Timers;
 using System.Windows;
 
@@ -51,6 +52,7 @@ namespace EfemDualRT.Resources
         private PerformanceCounter _writeDisk;
         private PerformanceCounter _transferDisk;
         private PeriodicJob _thread;
+        private bool _isTerminate;
         public ResourceMonitor()
         {
 
@@ -102,6 +104,7 @@ namespace EfemDualRT.Resources
         {
             if (_thread != null)
             {
+                _isTerminate = true;
                 _thread.Stop();
                 _thread = null;
             }
@@ -129,6 +132,7 @@ namespace EfemDualRT.Resources
         {
             try
             {
+                if (_isTerminate) return true;
                 string rtmonoitor = process_use(processRTname);
                 string uimonoitor = process_use(processUIname);