瀏覽代碼

Enable Com debug log.

sangwq 1 年之前
父節點
當前提交
39dd3fa41f

+ 45 - 0
Venus/Framework/Common/Communications/AsyncSerialPort.cs

@@ -1,9 +1,14 @@
 using System;
+using System.Collections;
 using System.IO.Ports;
 using System.Text;
+using System.Diagnostics;
 using Aitex.Core.RT.Event;
 using Aitex.Core.RT.Log;
 using MECF.Framework.Common.Utilities;
+using Aitex.Core.RT.SCCore;
+using MECF.Framework.Common.SCCore;
+using Aitex.Core.Util;
 
 namespace MECF.Framework.Common.Communications
 {
@@ -30,6 +35,7 @@ namespace MECF.Framework.Common.Communications
         public bool EnableLog { get; set; }
 
         private bool _isAsciiMode;
+        private static BitArray _EnableLog;
 
         public AsyncSerialPort(string name, int baudRate, int dataBits, Parity parity = Parity.None, StopBits stopBits = StopBits.One, string newline = "\r", bool isAsciiMode=true)
         {
@@ -54,6 +60,8 @@ namespace MECF.Framework.Common.Communications
 
             _port.DataReceived += new SerialDataReceivedEventHandler(DataReceived);
             _port.ErrorReceived += new SerialErrorReceivedEventHandler(ErrorReceived);
+
+            EnableLog = GetEnableFlag(name);
         }
 
         public void Dispose()
@@ -254,6 +262,43 @@ namespace MECF.Framework.Common.Communications
             if (OnErrorHappened != null)
                 OnErrorHappened(reason);
         }
+
+        bool GetEnableFlag(string portName)
+        {
+            if (_EnableLog == null)
+            {
+                Process cur = Process.GetCurrentProcess();
+                if (cur.ProcessName != "Venus_RT")
+                    return false;
+
+                string[] strArray = SC.GetStringValue("System.COMLogFlag").Split(',');
+                int[] bitData = new int[8];
+                for (int i = 0; i < strArray.Length; i++)
+                {
+                    if (int.TryParse(strArray[i], System.Globalization.NumberStyles.HexNumber, null, out int Flag))
+                    {
+                        bitData[i] = Flag;
+                    }
+                    else
+                    {
+                        bitData[i] = 0;
+                        LOG.Write(eEvent.WARN_DEVICE_INFO, "System", $"Parse System.COMLogFlag failed: {strArray[i]}.");
+                    }
+                }
+
+                _EnableLog = new BitArray(bitData);
+            }
+
+            if (int.TryParse(portName.Substring(3), out int nCom))
+            {
+                if (_EnableLog.Length > nCom)
+                {
+                    return _EnableLog[nCom];
+                }
+            }
+
+            return false;
+        }
     }
 }
 

+ 0 - 6
Venus/Framework/Common/Communications/ConnectionBase.cs

@@ -144,12 +144,6 @@ namespace MECF.Framework.Common.Communications
             }
         }
 
-        public void EnableLog(bool enable)
-        {
-            _port.EnableLog = enable;
-        }
-
-
         private void ProceedTransactionMessage(MessageBase msg)
         {
             if (msg == null || msg.IsFormatError)

+ 1 - 0
Venus/Venus_RT/Config/System.sccfg

@@ -17,6 +17,7 @@
 		<config default="LLA,PMA" name="InstalledModules" description="安装的模块" max="" min="" paramter="" tag="" unit="" visible="false" type="String" />
 		<config default="2" name="MaxInternalWaferCount" nameView="Max Internal wafer count" description="系统可允许进入的wafer数" max="8" min="1" paramter="" tag="" unit="" visible="true" type="Integer" />
 		<config default="100" name="TurboN2FlowSetPoint" nameView="TurboN2SetPoint" description="" max="200" min="0" paramter="" tag="" unit="mtorr" type="Double" />
+		<config default="00000000,00000000,00000000,00000000,00000000,00000000,00000000,00000000" name="COMLogFlag" description="Flag for print COM data log" max="" min="" paramter="" tag="" unit="" visible="false" type="String" />
 
 		<!--FA-->
 		<configs name="FA" nameView="FA" visible="false">

+ 1 - 0
Venus/Venus_RT/Modules/RouteManager.cs

@@ -1,4 +1,5 @@
 using System;
+using System.Collections;
 using System.Collections.Generic;
 using System.Linq;
 using System.Text;