Quellcode durchsuchen

fix alarmCondition 优化

jiangjy vor 20 Stunden
Ursprung
Commit
9e7b280302

+ 1 - 0
FrameworkLocal/Common/Common.csproj

@@ -558,6 +558,7 @@
     <Compile Include="SubstrateTrackings\CarrierInfo.cs" />
     <Compile Include="SubstrateTrackings\CarrierManager.cs" />
     <Compile Include="SubstrateTrackings\WaferManager.cs" />
+    <Compile Include="Tolerance\FilterChecker.cs" />
     <Compile Include="Tolerance\ToleranceChecker.cs" />
     <Compile Include="StylableWindow\ControlDoubleClickBehavior.cs" />
     <Compile Include="StylableWindow\ShowSystemMenuBehavior.cs" />

+ 74 - 0
FrameworkLocal/Common/Tolerance/FilterChecker.cs

@@ -0,0 +1,74 @@
+using Aitex.Core.Util;
+using DocumentFormat.OpenXml.Packaging;
+using MECF.Framework.Common.Event;
+using System;
+using System.Collections.Generic;
+using System.Diagnostics;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace MECF.Framework.Common.Tolerance
+{
+    /// <summary>
+    /// 搭配FR_TRIG 实现滤波功能
+    /// </summary>
+    public class FilterChecker
+    {
+        private FR_TRIG frTrig;
+        private Stopwatch stopwatch;
+        public double CheckInterval;
+        private bool stableOutput;
+
+
+        /// <summary>
+        /// 构造函数
+        /// </summary>
+        public FilterChecker()
+        {
+            frTrig = new FR_TRIG();
+            stopwatch = new Stopwatch();
+            stopwatch.Start();
+            stableOutput = false;
+        }
+        /// <summary>
+        /// 检测信号输入并管理计时器
+        /// </summary>
+        public void Monitor(bool signal)
+        {
+            frTrig.CLK = signal;
+
+            if (frTrig.Q)
+            {
+                stopwatch.Restart(); // 重启计时器在信号变化时
+            }
+
+            if (stopwatch.IsRunning && stopwatch.ElapsedMilliseconds >= CheckInterval * 1000 && frTrig.M)
+            {
+                stableOutput = true;
+                if (stopwatch.IsRunning)
+                    stopwatch.Stop();
+            }
+            else
+            {
+                stableOutput = false;
+            }
+        }
+
+        /// <summary>
+        /// 重置信号和计时器
+        /// </summary>
+        public void Restart()
+        {
+            frTrig.RST = true;
+            stopwatch.Reset();
+            stableOutput = false;
+        }
+
+        /// <summary>
+        /// 稳定的检测结果输出
+        /// </summary>
+        [System.Xml.Serialization.XmlIgnore]
+        public bool Trig { get => stableOutput; private set => stableOutput = value; }
+    }
+}

+ 158 - 93
FrameworkLocal/Common/Utilities/Trigger.cs

@@ -1,4 +1,5 @@
 using System;
+using System.Diagnostics;
 using System.IO;
 using System.Reflection;
 using System.Runtime.InteropServices;
@@ -6,44 +7,44 @@ using System.Xml.Serialization;
 
 namespace Aitex.Core.Util
 {
-	/// <summary>
-	/// 下降沿信号检测类
-	/// 
-	/// 设计目的:
-	/// 用于信号下降沿事件检测
-	/// 
-	/// 使用场合:
-	/// 系统输入数字信号,1->0跳变检测
-	/// </summary>
-	public class F_TRIG
-	{
-		/// <summary>
-		/// 构造函数
-		/// </summary>
-		public F_TRIG()
-		{
-			Q = false;
-			M = true;
-		}
-
-		/// <summary>
-		/// 检测信号输入
-		/// </summary>
-		public bool CLK
-		{
-			set
-			{
-				if (M != value && !value)
-					Q = true;
-				else
-					Q = false;
-				M = value;
-			}
-			get
-			{
-				return M;
-			}
-		}
+    /// <summary>
+    /// 下降沿信号检测类
+    /// 
+    /// 设计目的:
+    /// 用于信号下降沿事件检测
+    /// 
+    /// 使用场合:
+    /// 系统输入数字信号,1->0跳变检测
+    /// </summary>
+    public class F_TRIG
+    {
+        /// <summary>
+        /// 构造函数
+        /// </summary>
+        public F_TRIG()
+        {
+            Q = false;
+            M = true;
+        }
+
+        /// <summary>
+        /// 检测信号输入
+        /// </summary>
+        public bool CLK
+        {
+            set
+            {
+                if (M != value && !value)
+                    Q = true;
+                else
+                    Q = false;
+                M = value;
+            }
+            get
+            {
+                return M;
+            }
+        }
 
         //clear 
         public bool RST
@@ -54,57 +55,121 @@ namespace Aitex.Core.Util
                 M = true;
             }
         }
-		/// <summary>
-		/// 检测结果输出
-		/// </summary>
+        /// <summary>
+        /// 检测结果输出
+        /// </summary>
         [XmlIgnore]
         public bool Q { get; private set; }
 
-		/// <summary>
-		/// 记录上一次输入信号值
-		/// </summary>
+        /// <summary>
+        /// 记录上一次输入信号值
+        /// </summary>
         [XmlIgnore]
         public bool M { get; private set; }
-	}
-
-	/// <summary>
-	/// 上升沿信号检测类
-	/// 
-	/// 设计目的:
-	/// 用于信号上升沿事件检测
-	/// 
-	/// 使用场合:
-	/// 系统输入数字信号,0->1跳变检测
-	/// </summary>
-	public class R_TRIG
-	{
-		/// <summary>
-		/// 构造函数
-		/// </summary>
-		public R_TRIG()
-		{
-			Q = false;
-			M = false;
-		}
-
-		/// <summary>
-		/// 检测信号输入
-		/// </summary>
-		public bool CLK
-		{
-			set
-			{
-				if (M != value && value)
-					Q = true;
-				else
-					Q = false;
-				M = value;
-			}
-			get
-			{
-				return M;
-			}
-		}
+    }
+    /// <summary>
+    /// 实现滤波功能
+    /// </summary>
+    public class FR_TRIG
+    {
+        private bool lastValue;
+        private bool currentValue;
+        private bool output;
+
+        /// <summary>
+        /// 构造函数
+        /// </summary>
+        public FR_TRIG()
+        {
+            lastValue = false;
+            currentValue = false;
+            output = false;
+        }
+
+        /// <summary>
+        /// 检测信号输入
+        /// </summary>
+        public bool CLK
+        {
+            set
+            {
+                currentValue = value;
+                if (currentValue != lastValue)
+                {
+                    output = true; // 信号变化时立即输出 true
+                }
+                else
+                {
+                    output = false; // 信号不变时输出 false
+                }
+                lastValue = currentValue;
+            }
+            get
+            {
+                return currentValue;
+            }
+        }
+
+        public bool RST
+        {
+            set
+            {
+                currentValue = false;
+                lastValue = false;
+                output = false;
+            }
+        }
+
+        /// <summary>
+        /// 检测结果输出
+        /// </summary>
+        [System.Xml.Serialization.XmlIgnore]
+        public bool Q { get => output; private set => output = value; }
+
+        /// <summary>
+        /// 记录上一次输入信号值
+        /// </summary>
+        [System.Xml.Serialization.XmlIgnore]
+        public bool M { get => currentValue; private set => currentValue = value; }
+    }
+    /// <summary>
+    /// 上升沿信号检测类
+    /// 
+    /// 设计目的:
+    /// 用于信号上升沿事件检测
+    /// 
+    /// 使用场合:
+    /// 系统输入数字信号,0->1跳变检测
+    /// </summary>
+    public class R_TRIG
+    {
+        /// <summary>
+        /// 构造函数
+        /// </summary>
+        public R_TRIG()
+        {
+            Q = false;
+            M = false;
+        }
+
+        /// <summary>
+        /// 检测信号输入
+        /// </summary>
+        public bool CLK
+        {
+            set
+            {
+                if (M != value && value)
+                    Q = true;
+                else
+                    Q = false;
+                M = value;
+            }
+            get
+            {
+                return M;
+            }
+        }
 
         public bool RST
         {
@@ -114,18 +179,18 @@ namespace Aitex.Core.Util
                 M = false;
             }
         }
-		/// <summary>
-		/// 检测结果输出
-		/// </summary>
+        /// <summary>
+        /// 检测结果输出
+        /// </summary>
         [XmlIgnore]
         public bool Q { get; private set; }
 
-		/// <summary>
-		/// 记录上一次输入信号值
-		/// </summary>
+        /// <summary>
+        /// 记录上一次输入信号值
+        /// </summary>
         [XmlIgnore]
-		public bool M { get; private set; }
-	}
+        public bool M { get; private set; }
+    }
 
     /// <summary>
     /// 边沿信号检测类
@@ -145,7 +210,7 @@ namespace Aitex.Core.Util
         /// </summary>
         public RD_TRIG()
         {
-            R = false;    
+            R = false;
             T = false;
             M = false;
         }

BIN
Furnace/FurnaceRT/Config/VIDs/Equipment_VIDs_20250731.xlsx


+ 25 - 45
Furnace/FurnaceRT/Equipments/PMs/PMAlarmCondition.cs

@@ -16,6 +16,8 @@ using MECF.Framework.Common.CommonData.EnumData;
 using MECF.Framework.Common.Equipment;
 using MECF.Framework.Common.Event;
 using MECF.Framework.Common.OperationCenter;
+using MECF.Framework.Common.Tolerance;
+using MECF.Framework.RT.EquipmentLibrary.HardwareUnits.Robot;
 using System;
 using System.Collections;
 using System.Collections.Generic;
@@ -113,12 +115,7 @@ namespace FurnaceRT.Equipments.PMs
                 checker.ToleranceCheckerAlarm.RST = true;
                 checker?.DelayTimer.Restart();
             }
-            for (int i = 0; i < _hwILKChecker.Count; i++)
-            {
-                var checker = _hwILKChecker[i];
-                checker.ToleranceCheckerAlarm.RST = true;
-                checker?.DelayTimer?.Restart();
-            }
+
             for (int i = 0; i < _auxChecker.Count; i++)
             {
                 var checker = _auxChecker[i];
@@ -129,6 +126,12 @@ namespace FurnaceRT.Equipments.PMs
                 checker.ToleranceCheckerAlarm.RST = true;
                 checker?.DelayTimer.Restart();
             }
+
+            for (int i = 0; i < _hwILKChecker.Count; i++)
+            {
+                var checker = _hwILKChecker[i];
+                checker?.FilterCheckerAlarm?.Restart();
+            }
         }
         private void InitAlarmConditionChecker()
         {
@@ -266,7 +269,7 @@ namespace FurnaceRT.Equipments.PMs
                 var checker = new AlarmConditionChecker()
                 {
                     Name = item.Value.Name,
-                    ToleranceCheckerAlarm = new ToleranceChecker(),
+                    FilterCheckerAlarm = new FilterChecker(),
                     Parameter = new AlarmConditionAIParameter(),
                 };
 
@@ -638,55 +641,27 @@ namespace FurnaceRT.Equipments.PMs
 
         private void MonitorInterlockAlarmCondition()
         {
+            if (_alarmConditionDic == null || !_alarmConditionDic.ContainsKey(_currentAlarmConditionIndex) || _alarmConditionDic[_currentAlarmConditionIndex].InterlockParameterLst == null || HWILKAlarmDic == null)
+                return;
+
             foreach (var item in _hwILKChecker)
             {
                 if (item.DIParameter == null || item.DIParameter.IsEnable == false)
                     continue;
 
-                if (!_sensors.TryGetValue(item.Name, out var sensor))
+                if (!_sensors.TryGetValue(item.Name, out var sensorItem))
                     continue;
 
-                if (!sensor.Value)
+                if (!HWILKAlarmDic.TryGetValue(sensorItem, out var alarmItem))
                     continue;
 
-                //ProcessAlarmConditionErrorCommand(item.Command);
+                item.FilterCheckerAlarm.CheckInterval = 0.1;
 
+                item.FilterCheckerAlarm.Monitor(sensorItem.Value);
 
+                if (item.FilterCheckerAlarm.Trig)
+                    ProcessAlarmConditionErrorCommand(item.DIParameter.Command, () => alarmItem.Set());
             }
-
-            //if (_triggeredAlarmList == null || _triggeredAlarmList.Count == 0)
-            //    return;
-
-            //if (_hardwareInterlockAlarmConditionDic == null)
-            //    return;
-
-            //if (_alarmConditionDic == null || !_alarmConditionDic.ContainsKey(_currentAlarmConditionIndex) || _alarmConditionDic[_currentAlarmConditionIndex].InterlockParameterLst == null)
-            //    return;
-
-            //var newAlarm = _triggeredAlarmList[_triggeredAlarmList.Count - 1];
-            //var alarmConditionItemName = "";
-            //for (int i = _triggeredAlarmList.Count - 1; i >= 0; i--)
-            //{
-            //    var alarm = _triggeredAlarmList[i];
-            //    var interval = DateTime.Now - newAlarm.OccuringTime;
-            //    if (interval.TotalMilliseconds > 1000)//老的alarm
-            //        continue;
-            //    var paras = newAlarm.EventEnum.Split('.');
-            //    if (paras.Length < 2)
-            //        continue;
-            //    var ret = _hardwareInterlockAlarmConditionDic.TryGetValue(paras[1], out string name);
-            //    if (ret)
-            //    {
-            //        newAlarm = alarm;
-            //        alarmConditionItemName = name;
-            //        var alarmConditionItem = _alarmConditionDic[_currentAlarmConditionIndex].InterlockParameterLst.FirstOrDefault(x => x.Name == alarmConditionItemName);
-            //        if (alarmConditionItem == null)
-            //            continue;
-            //        if (alarmConditionItem.IsEnable)
-            //            ProcessAlarmConditionErrorCommand(alarmConditionItem.Command);
-            //        break;
-            //    }
-            //}
         }
         private void MonitorAPCAlarmCondition()
         {
@@ -985,7 +960,7 @@ namespace FurnaceRT.Equipments.PMs
                 }
             }
         }
-        private void ProcessAlarmConditionErrorCommand(string command)
+        private void ProcessAlarmConditionErrorCommand(string command, Action eventHandler = null)
         {
             var recipe = "";
             var recipeType = "";
@@ -1035,6 +1010,7 @@ namespace FurnaceRT.Equipments.PMs
                     LOG.Write($"Alarm condition: command={command}");
                     break;
                 case "Monitor":
+                    eventHandler?.Invoke();
                     LOG.Write($"Alarm condition: command={command}");
                     break;
                 case "Buzzer":
@@ -1220,6 +1196,10 @@ namespace FurnaceRT.Equipments.PMs
             public AlarmConditionAIParameter Parameter { get; set; }
             public AlarmConditionDIParameter DIParameter { get; set; }
             public Stopwatch DelayTimer { get; set; }//N秒过后才检测
+
+
+            public FilterChecker FilterCheckerAlarm { get; set; }
+
         }
         class AlarmConditionTableParameter
         {

+ 9 - 3
Furnace/FurnaceRT/Equipments/PMs/PMModuleAlarmDefine.cs

@@ -1,4 +1,5 @@
-using Aitex.Core.RT.Device.Unit;
+using Aitex.Core.RT.Device;
+using Aitex.Core.RT.Device.Unit;
 using Aitex.Core.RT.Event;
 using Aitex.Core.RT.IOCore;
 using Aitex.Core.RT.Log;
@@ -12,6 +13,7 @@ using MECF.Framework.UI.Client.CenterViews.Dialogs;
 using System;
 using System.Collections.Generic;
 using System.Linq;
+using System.Windows.Controls.Primitives;
 
 namespace FurnaceRT.Equipments.PMs
 {
@@ -319,7 +321,7 @@ namespace FurnaceRT.Equipments.PMs
         #endregion
 
         public Dictionary<int, Tuple<AlarmEventItem, AlarmEventItem>> AUXAlarmDic { get; set; }
-
+        public Dictionary<IDevice, AlarmEventItem> HWILKAlarmDic { get; set; } = new Dictionary<IDevice, AlarmEventItem>();
         #endregion
 
         private void InitAlarmEvent()
@@ -7564,6 +7566,7 @@ namespace FurnaceRT.Equipments.PMs
 
                 CreateAlarmEventByIoSensor(item.Value);
 
+
             }
 
         }
@@ -7578,11 +7581,14 @@ namespace FurnaceRT.Equipments.PMs
                     Description = $"{ioSensor.Display}",
                     Solution = "No information available. Press [Clear] to delete alarm message.",
                     Explaination = "No information available.",
-                    AutoRecovery = false,
+                    AutoRecovery = true,
                     Level = EventLevel.Alarm,
                     Action = EventAction.Clear,
                     Category = "TubeAlarm",
                 }, () => { return true; });
+
+                HWILKAlarmDic.Add(ioSensor, sensorAlarm);
+
             }
         }
         private void InitIoAlarmSignalAlarmEvent()

+ 28 - 7
Furnace/FurnaceRT/Equipments/PMs/PMModuleInterlock.cs

@@ -7,6 +7,7 @@ using Aitex.Core.RT.OperationCenter;
 using Aitex.Core.RT.SCCore;
 using Aitex.Core.Util;
 using MECF.Framework.Common.OperationCenter;
+using MECF.Framework.FA.Core.FAControl;
 using System;
 using System.Collections;
 using System.Diagnostics;
@@ -33,10 +34,10 @@ namespace FurnaceRT.Equipments.PMs
         private int _vac1PumpTimeS = 120;
         private int _vac2PumpTimeS = 120;
         private int _vac3PumpTimeS = 120;
-        private int _foolProofTime = 5;   
+        private int _foolProofTime = 5;
         private DeviceTimer _plcFoolProofTime = null;
         private RD_TRIG _trigPLCConnected = null;
-      
+
 
         private void InitInterlock()
         {
@@ -79,7 +80,7 @@ namespace FurnaceRT.Equipments.PMs
         //设置自定义的interlock action
         private bool UserDefineInterlockHandler(string name, object value)
         {
-            switch(name)
+            switch (name)
             {
                 case "PM1.Heater1":
                     //设置Heater的值
@@ -260,7 +261,7 @@ namespace FurnaceRT.Equipments.PMs
                 _trigPLCConnected.CLK = SensorPLCHeartBeatPC.Value;
                 if (_trigPLCConnected.T || _trigPLCConnected.R)
                 {
-                    _plcFoolProofTime.Start(_foolProofTime * 1000);    
+                    _plcFoolProofTime.Start(_foolProofTime * 1000);
                 }
                 if (_plcFoolProofTime.IsTimeout())
                 {
@@ -271,6 +272,26 @@ namespace FurnaceRT.Equipments.PMs
         }
         private void ProcessAlarmSignal()
         {
+            var alarms = EV.GetAlarmEvent();
+            if (alarms != null && alarms.Count > 0)
+            {
+                foreach (var device in HWILKAlarmDic)
+                {
+                    if (device.Key is IoSensor && !((IoSensor)device.Key).Value && device.Value.AutoRecovery)
+                    {
+                        var item = alarms.FirstOrDefault(x => x.EventEnum == device.Value.EventEnum);
+                        if (item != null)
+                        {
+                            alarms.Remove(item);
+                            EV.ClearAlarmEvent(item.EventEnum);
+                            Singleton<FAJobController>.Instance.ClearAlarm(item.EventEnum);
+
+                        }
+                    }
+                }
+            }
+
+
             bool isTrig = false;
             foreach (var signal in _alarmSignals)
             {
@@ -282,6 +303,7 @@ namespace FurnaceRT.Equipments.PMs
                         item.Reset();
                         _triggeredAlarmList.Remove(item);
                         EV.ClearAlarmEvent(item.EventEnum);
+                        Singleton<FAJobController>.Instance.ClearAlarm(item.EventEnum);
                     }
                     isTrig = true;
                     signal.AlarmRecovery?.Set();
@@ -291,7 +313,6 @@ namespace FurnaceRT.Equipments.PMs
             if (isTrig)
             {
                 int count = 0;
-                var alarms = EV.GetAlarmEvent();
                 foreach (var alarm in alarms)
                 {
                     if (alarm.Level == EventLevel.Alarm && alarm.Source == Name)
@@ -313,7 +334,7 @@ namespace FurnaceRT.Equipments.PMs
                     _vac1Timer.Stop();
             }
 
-            if(!ValveAV9.Status &&
+            if (!ValveAV9.Status &&
                 !ValveAV16.Status &&
                 !ValveAV20.Status &&
                 !ValveAV24.Status &&
@@ -326,7 +347,7 @@ namespace FurnaceRT.Equipments.PMs
             {
                 if (!_vac1Timer.IsRunning)
                     _vac1Timer.Restart();
-                if(_vac1Timer.ElapsedMilliseconds > _vac1PumpTimeS * 1000)
+                if (_vac1Timer.ElapsedMilliseconds > _vac1PumpTimeS * 1000)
                     _vac1 = true;
             }
             else