Browse Source

Revise simultaneous DIReplen bugs of multiple reservoirs;

niuyx 1 month ago
parent
commit
64268396a0

+ 42 - 25
CyberX8_RT/Devices/Reservoir/CompactMembranReservoirDevice.cs

@@ -272,6 +272,10 @@ namespace CyberX8_RT.Devices.Reservoir
         /// 累计补水超时
         /// </summary>
         private bool _diReplenMaxTimeOut;
+        /// <summary>
+        /// 是否有其他DIReplen的警告
+        /// </summary>
+        private bool _isOtherDIReplenWarnOn = false;
         #endregion
 
         #region 属性
@@ -829,33 +833,33 @@ namespace CyberX8_RT.Devices.Reservoir
         /// <returns></returns>
         private bool ANDiReplenOnOperation(string cmd, object[] args)
         {
-            return ANDiReplenOn(true);
+            return ANDiReplenOn();
         }
         /// <summary>
         /// 阳极DI Replen On
         /// </summary>
         /// <param name="showError"></param>
         /// <returns></returns>
-        public bool ANDiReplenOn(bool showError)
+        public bool ANDiReplenOn()
         {
             if (IsANHighLevel)
             {
-                LOG.WriteLog(eEvent.ERR_RESERVOIR, Module, $"ANHighLevel is activate,Can't do AN_DIReple");
+                LOG.WriteLog(eEvent.ERR_RESERVOIR, Module, $"ANHighLevel is activate, can't do AN_DIReplen");
                 return false;
             }
             if (IsANLowLevel)
             {
-                LOG.WriteLog(eEvent.ERR_RESERVOIR, Module, $"ANLowLevel is activate,Can't do AN_DIReple");
+                LOG.WriteLog(eEvent.ERR_RESERVOIR, Module, $"ANLowLevel is activate, can't do AN_DIReplen");
                 return false;
             }
-            bool preCondition = CheckPreDiReplenCondition(showError);
+            bool preCondition = CheckPreDiReplenCondition();
             if (!preCondition)
             {
                 return false;
             }
             if (ReservoirData.CADiReplen)
             {
-                LOG.WriteLog(eEvent.ERR_RESERVOIR, Module, "CADiReplen is on");
+                LOG.WriteLog(eEvent.ERR_RESERVOIR, Module, "CA_DIReplen is on");
                 return false;
             }
             string ioName = BeckhoffModuleIOManager.Instance.GetIoNameByInnerModuleName($"{Module}.{AN_DI_REPLEN}");
@@ -887,20 +891,20 @@ namespace CyberX8_RT.Devices.Reservoir
         /// 检验DiReplen前置条件
         /// </summary>
         /// <returns></returns>
-        public bool CheckPreDiReplenCondition(bool showError)
+        public bool CheckPreDiReplenCondition()
         {
-            if (!CheckFacilitiesDiReplenStatus() && showError)
-            {
-                LOG.WriteLog(eEvent.ERR_RESERVOIR, Module, "Facilities DiReplen is Off");
-                return false;
-            }
+            //if (!CheckFacilitiesDiReplenStatus())
+            //{
+            //    LOG.WriteLog(eEvent.ERR_RESERVOIR, Module, "Facilities DiReplen is Off");
+            //    return false;
+            //}
             SafetyDevice safetyDevice = DEVICE.GetDevice<SafetyDevice>("Safety");
             if (safetyDevice != null && safetyDevice.SafetyData.ReservoirHighLevel)
             {
                 LOG.WriteLog(eEvent.ERR_RESERVOIR, Module, $"Safety high is Activate");
                 return false;
             }
-            if (CheckOtherReservoirDiReplenStatus(showError))
+            if (CheckOtherReservoirDiReplenStatus())
             {
                 return false;
             }
@@ -923,7 +927,7 @@ namespace CyberX8_RT.Devices.Reservoir
         /// 检验是否其他Reservoir Direplen已经
         /// </summary>
         /// <returns></returns>
-        private bool CheckOtherReservoirDiReplenStatus(bool showError)
+        private bool CheckOtherReservoirDiReplenStatus()
         {
             List<string> reservoirs = ReservoirItemManager.Instance.InstalledModules;
             foreach (string item in reservoirs)
@@ -934,28 +938,41 @@ namespace CyberX8_RT.Devices.Reservoir
                     if (reservoirItem.SubType == STRATUS)
                     {
                         StandardHotReservoirDevice tmpDevice = DEVICE.GetDevice<StandardHotReservoirDevice>(item);
-                        if (tmpDevice.ReservoirData.DiReplen && showError)
+                        if (tmpDevice.ReservoirData.DiReplen)
                         {
-                            LOG.WriteLog(eEvent.ERR_RESERVOIR, Module, $"{item} direplen valve is on");
+                            if (!_isOtherDIReplenWarnOn)
+                            {
+                                _isOtherDIReplenWarnOn = true;
+                                LOG.WriteLog(eEvent.ERR_RESERVOIR, Module, $"{item} DIReplen is on");
+                            }
                             return true;
                         }
                     }
                     else
                     {
                         CompactMembranReservoirDevice tmpDevice = DEVICE.GetDevice<CompactMembranReservoirDevice>(item);
-                        if (tmpDevice.ReservoirData.ANDiReplen && showError)
+                        if (tmpDevice.ReservoirData.ANDiReplen)
                         {
-                            LOG.WriteLog(eEvent.ERR_RESERVOIR, Module, $"{item} ANDireplen valve is on");
+                            if (!_isOtherDIReplenWarnOn)
+                            {
+                                _isOtherDIReplenWarnOn = true;
+                                LOG.WriteLog(eEvent.ERR_RESERVOIR, Module, $"{item} AN_DIReplen is on");
+                            }
                             return true;
                         }
-                        if (tmpDevice.ReservoirData.CADiReplen && showError)
+                        if (tmpDevice.ReservoirData.CADiReplen)
                         {
-                            LOG.WriteLog(eEvent.ERR_RESERVOIR, Module, $"{item} CADireplen valve is on");
+                            if (!_isOtherDIReplenWarnOn)
+                            {
+                                _isOtherDIReplenWarnOn = true;
+                                LOG.WriteLog(eEvent.ERR_RESERVOIR, Module, $"{item} CA_DIReplen is on");
+                            }
                             return true;
                         }
                     }
                 }
             }
+            _isOtherDIReplenWarnOn = false;
             return false;
         }
         #endregion
@@ -1221,16 +1238,16 @@ namespace CyberX8_RT.Devices.Reservoir
         /// <returns></returns>
         private bool CADiReplenOnOperation(string cmd, object[] args)
         {
-            return CADiReplenOn(true);
+            return CADiReplenOn();
         }
         /// <summary>
         /// 阴极DI Replen On
         /// </summary>
         /// <param name="showError"></param>
         /// <returns></returns>
-        private bool CADiReplenOn(bool showError)
+        private bool CADiReplenOn()
         {
-            bool preCondition = CheckPreDiReplenCondition(showError);
+            bool preCondition = CheckPreDiReplenCondition();
             if (!preCondition)
             {
                 return false;
@@ -1599,7 +1616,7 @@ namespace CyberX8_RT.Devices.Reservoir
         /// 自动注水
         /// </summary>
         /// <returns></returns>
-        private bool AutoDireplen(Func<bool, bool> direplenOn, ReservoirOperation reservoirOperation)
+        private bool AutoDireplen(Func<bool> direplenOn, ReservoirOperation reservoirOperation)
         {
             if (_currentOperation != ReservoirOperation.None)
             {
@@ -1611,7 +1628,7 @@ namespace CyberX8_RT.Devices.Reservoir
                 LOG.WriteLog(eEvent.ERR_RESERVOIR, Module, $"recipe is null");
                 return false;
             }
-            bool result = direplenOn(false);
+            bool result = direplenOn();
             if (result)
             {
                 _currentOperation = reservoirOperation;

+ 35 - 18
CyberX8_RT/Devices/Reservoir/StandardHotReservoirDevice.cs

@@ -233,6 +233,10 @@ namespace CyberX8_RT.Devices.Reservoir
         /// 累计补水超时
         /// </summary>
         private bool _diReplenMaxTimeOut;
+        /// <summary>
+        /// 是否有其他DIReplen的警告
+        /// </summary>
+        private bool _isOtherDIReplenWarnOn = false;
         #endregion
 
         #region 属性
@@ -1320,13 +1324,13 @@ namespace CyberX8_RT.Devices.Reservoir
         /// <returns></returns>
         public bool DIReplenOnOperation(string cmd, object[] args)
         {
-            return DIReplenOn(true);
+            return DIReplenOn();
         }
         /// <summary>
         /// 自动注水
         /// </summary>
         /// <returns></returns>
-        public bool DIReplenOn(bool showError)
+        public bool DIReplenOn()
         {
             ReservoirEntity entity = Singleton<RouteManager>.Instance.GetModule<ReservoirEntity>(Module);
             if (ReservoirData.WaterLevel > SC.GetValue<double>($"Reservoir.{Module}.HighLevel"))
@@ -1345,7 +1349,7 @@ namespace CyberX8_RT.Devices.Reservoir
                 }
                 return false;
             }
-            bool preCondition = CheckPreDiReplenCondition(showError);
+            bool preCondition = CheckPreDiReplenCondition();
             if (!preCondition)
             {
                 return false;
@@ -1388,20 +1392,20 @@ namespace CyberX8_RT.Devices.Reservoir
         /// 检验DiReplen前置条件
         /// </summary>
         /// <returns></returns>
-        public bool CheckPreDiReplenCondition(bool showError)
+        public bool CheckPreDiReplenCondition()
         {
-            if (!CheckFacilitiesDiReplenStatus() && showError)
-            {
-                LOG.WriteLog(eEvent.ERR_RESERVOIR, Module, "Facilities DiReplen is Off");
-                return false;
-            }
+            //if (!CheckFacilitiesDiReplenStatus())
+            //{
+            //    LOG.WriteLog(eEvent.ERR_RESERVOIR, Module, "Facilities DiReplen is Off");
+            //    return false;
+            //}
             SafetyDevice safetyDevice = DEVICE.GetDevice<SafetyDevice>("Safety");
             if (safetyDevice != null && safetyDevice.SafetyData.ReservoirHighLevel)
             {
                 LOG.WriteLog(eEvent.ERR_RESERVOIR, Module, $"Safety high is Activate");
                 return false;
             }
-            if (CheckOtherReservoirDiReplenStatus(showError))
+            if (CheckOtherReservoirDiReplenStatus())
             {
                 return false;
             }
@@ -1424,7 +1428,7 @@ namespace CyberX8_RT.Devices.Reservoir
         /// 检验是否其他Reservoir Direplen已经
         /// </summary>
         /// <returns></returns>
-        private bool CheckOtherReservoirDiReplenStatus(bool showError)
+        private bool CheckOtherReservoirDiReplenStatus()
         {
             List<string> reservoirs = ReservoirItemManager.Instance.InstalledModules;
             foreach (string item in reservoirs)
@@ -1435,28 +1439,41 @@ namespace CyberX8_RT.Devices.Reservoir
                     if (reservoirItem.SubType == STRATUS)
                     {
                         StandardHotReservoirDevice tmpDevice = DEVICE.GetDevice<StandardHotReservoirDevice>(item);
-                        if (tmpDevice.ReservoirData.DiReplen && showError)
+                        if (tmpDevice.ReservoirData.DiReplen)
                         {
-                            LOG.WriteLog(eEvent.ERR_RESERVOIR, Module, $"{item} direplen valve is on");
+                            if (!_isOtherDIReplenWarnOn)
+                            {
+                                _isOtherDIReplenWarnOn = true;
+                                LOG.WriteLog(eEvent.WARN_RESERVOIR, Module, $"{item} DIReplen is on");
+                            }
                             return true;
                         }
                     }
                     else
                     {
                         CompactMembranReservoirDevice tmpDevice = DEVICE.GetDevice<CompactMembranReservoirDevice>(item);
-                        if (tmpDevice.ReservoirData.ANDiReplen && showError)
+                        if (tmpDevice.ReservoirData.ANDiReplen)
                         {
-                            LOG.WriteLog(eEvent.ERR_RESERVOIR, Module, $"{item} ANDireplen valve is on");
+                            if (!_isOtherDIReplenWarnOn)
+                            {
+                                _isOtherDIReplenWarnOn = true;
+                                LOG.WriteLog(eEvent.WARN_RESERVOIR, Module, $"{item} AN_DIReplen is on");
+                            }
                             return true;
                         }
-                        if (tmpDevice.ReservoirData.CADiReplen && showError)
+                        if (tmpDevice.ReservoirData.CADiReplen)
                         {
-                            LOG.WriteLog(eEvent.ERR_RESERVOIR, Module, $"{item} CADireplen valve is on");
+                            if (!_isOtherDIReplenWarnOn)
+                            {
+                                _isOtherDIReplenWarnOn = true;
+                                LOG.WriteLog(eEvent.WARN_RESERVOIR, Module, $"{item} CA_DIReplen is on");
+                            }
                             return true;
                         }
                     }
                 }
             }
+            _isOtherDIReplenWarnOn = false;
             return false;
         }
         /// <summary>
@@ -1546,7 +1563,7 @@ namespace CyberX8_RT.Devices.Reservoir
             {
                 return false;
             }
-            bool result = DIReplenOn(false);
+            bool result = DIReplenOn();
             if (result)
             {
                 LOG.WriteLog(eEvent.INFO_RESERVOIR, Module, $"{Module} CADIReplen State :True,  " +

+ 38 - 23
CyberX8_RT/Devices/Reservoir/TotalReservoirDevice.cs

@@ -1,25 +1,14 @@
 using Aitex.Core.RT.Device;
-using Aitex.Core.RT.OperationCenter;
+using Aitex.Core.RT.Log;
 using Aitex.Core.Util;
+using CyberX8_RT.Modules;
+using CyberX8_RT.Modules.Reservoir;
 using MECF.Framework.Common.CommonData;
-using MECF.Framework.Common.Device.PowerSupplier;
-using MECF.Framework.Common.Device.Rinse;
+using MECF.Framework.Common.IOCore;
+using MECF.Framework.Common.ToolLayout;
 using MECF.Framework.Common.TwinCat;
-using CyberX8_RT.Devices.Metal;
-using CyberX8_RT.Devices.PowerSupplier;
-using CyberX8_RT.Devices.PUF;
-using System;
 using System.Collections.Generic;
-using System.Diagnostics.PerformanceData;
-using System.Linq;
 using System.Reflection;
-using System.Text;
-using System.Threading.Tasks;
-using MECF.Framework.Common.ToolLayout;
-using CyberX8_RT.Modules.Reservoir;
-using CyberX8_RT.Modules;
-using CyberX8_RT.Devices.Reservoir;
-using MECF.Framework.Common.IOCore;
 
 namespace CyberX8_RT.Devices.Reservoir
 {
@@ -58,6 +47,15 @@ namespace CyberX8_RT.Devices.Reservoir
         /// 定时器
         /// </summary>
         private PeriodicJob _period;
+        /// <summary>
+        /// DiReplen Warning Dictionary
+        /// </summary>      
+        private Dictionary<string, bool> _diReplenWarnDic = new Dictionary<string, bool>() {
+            {"Reservoir1", false},
+            {"Reservoir2", false},
+            {"Reservoir3", false},
+            {"Reservoir4", false},
+        };
         #endregion
         #region 属性
         /// <summary>
@@ -192,16 +190,17 @@ namespace CyberX8_RT.Devices.Reservoir
                     if (reservoirItem.SubType == STRATUS)
                     {
                         StandardHotReservoirDevice reservoirDevice = DEVICE.GetDevice<StandardHotReservoirDevice>(module);
-                        if (!reservoirEntity.IsInitialized || reservoirDevice.DiReplenMaxTimeOut)
+                        if (!reservoirEntity.IsInitialized || reservoirDevice.DiReplenMaxTimeOut
+                            || reservoirDevice.IsDireplenOn || reservoirDevice.IsDiReplenInFault)
                         {
                             continue;
                         }
-                        if (reservoirDevice.IsDireplenOn || !reservoirDevice.TotalDIReplenOn)
-                        {
-                            break;
-                        }
-                        if (reservoirDevice.NeedAutoDireplen && !reservoirDevice.IsDireplenOn && !reservoirDevice.IsDiReplenInFault)
+                        if (reservoirDevice.NeedAutoDireplen)
                         {
+                            if (!CheckFacilityDiReplenOn(reservoirDevice.TotalDIReplenOn, module))
+                            {
+                                continue;
+                            }
                             reservoirDevice.AutoDireplen();
                         }
                     }
@@ -213,7 +212,23 @@ namespace CyberX8_RT.Devices.Reservoir
             }
             return true;
         }
-
+        private bool CheckFacilityDiReplenOn(bool diReplenOn, string module)
+        {
+            if (!diReplenOn)
+            {
+                if (!_diReplenWarnDic[module])
+                {
+                    _diReplenWarnDic[module] = true;
+                    LOG.WriteLog(eEvent.WARN_RESERVOIR, module, $"SystemFacility DIReplen is off, {module} can't do auto DIReplen");
+                }
+                return false;
+            }
+            else
+            {
+                _diReplenWarnDic[module] = false;
+                return true;
+            }
+        }
         public void Monitor()
         {
         }