Explorar o código

add dm reservoir releated monitor

chenzk hai 21 horas
pai
achega
0e26d8e4cc

+ 0 - 3
Framework/Common/CommonData/Reservoir/ReservoirData.cs

@@ -35,8 +35,6 @@ namespace MECF.Framework.Common.CommonData.Reservoir
 
         public bool ReturnValveEnable { get { return _returnValveEnable; } set { _returnValveEnable = value;InvokePropertyChanged(nameof(ReturnValveEnable)); } }
 
-        public double ReturnValvePercent { get { return _returnValvePercent; } set { _returnValvePercent = value; InvokePropertyChanged(nameof(ReturnValvePercent)); } }
-
         public bool CaDiReplen { get { return _caDiReplen; } set { _caDiReplen = value;InvokePropertyChanged(nameof(CaDiReplen)); } }
 
         public bool AnDiReplen { get { return _anDiReplen; } set { _anDiReplen = value;InvokePropertyChanged(nameof(AnDiReplen)); } }
@@ -71,7 +69,6 @@ namespace MECF.Framework.Common.CommonData.Reservoir
         private double _caPumpSpeed;
         private double _returnValveOpening;
         private bool _returnValveEnable;
-        private double _returnValvePercent;
         private bool _caDiReplen;
         private bool _anDiReplen;
         private bool _sampleOut;

+ 30 - 11
PunkHPX8_MainPages/ViewModels/DMReservoirViewModel.cs

@@ -16,6 +16,7 @@ using System.Collections.ObjectModel;
 using System.Linq;
 using System.Text;
 using System.Threading.Tasks;
+using System.Windows;
 using System.Windows.Input;
 using System.Windows.Threading;
 
@@ -56,20 +57,10 @@ namespace PunkHPX8_MainPages.ViewModels
         private ReservoirData _reservoirData;
         private bool _isCAHighLevel;
         private bool _isCALowLevel;
+        private double _avgCaLevel;
 
         private ObservableCollection<RecipeNode> _recipeNodes;
         private string _currentRecipeFileName;
-  
-        private double _returnValveOpenPerccent;
-        private bool _isCADIReplenFault;
-        private bool _isANDIReplenFault;
-        private double _flowAdjustDelta;
-        private double _maxFlowDelta;
-        private bool _isFolwDeltaUnBlance = false;
-        private bool _isHighLevel;
-        private bool _isLowLevel;
-        private bool _isLeakDetected;
-        private bool _cdaOn;
 
 
         /// <summary>
@@ -218,6 +209,14 @@ namespace PunkHPX8_MainPages.ViewModels
             get { return _isCALowLevel; }
             set { SetProperty(ref _isCALowLevel, value); }
         }
+        /// <summary>
+        /// Ca Level采样周期内平均值
+        /// </summary>
+        public double AvgCALevel
+        {
+            get { return _avgCaLevel; }
+            set { SetProperty(ref _avgCaLevel, value); }
+        }
 
         /// <summary>
         /// 单次注水最大时长
@@ -290,6 +289,12 @@ namespace PunkHPX8_MainPages.ViewModels
         /// <param name="param"></param>
         private void CAPumpSpeedSetAction(object param)
         {
+            if (InputCAPumpSpeed>100 || InputCAPumpSpeed < 0)
+            {
+                MessageBox.Show($"Input CAPumpSpeed value in 0~100", "Error",
+                      MessageBoxButton.OK, MessageBoxImage.Error);
+                return;
+            }
             InvokeClient.Instance.Service.DoOperation($"{Module}.CAPumpSpeed",InputCAPumpSpeed);
         }
         /// <summary>
@@ -298,6 +303,12 @@ namespace PunkHPX8_MainPages.ViewModels
         /// <param name="param"></param>
         private void ANPumpSpeedSetAction(object param)
         {
+            if (InputANPumpSpeed > 100 || InputANPumpSpeed < 0)
+            {
+                MessageBox.Show($"Input ANPumpSpeed value in 0~100", "Error",
+                      MessageBoxButton.OK, MessageBoxImage.Error);
+                return;
+            }
             InvokeClient.Instance.Service.DoOperation($"{Module}.ANPumpSpeed", InputANPumpSpeed);
         }
         /// <summary>
@@ -306,6 +317,12 @@ namespace PunkHPX8_MainPages.ViewModels
         /// <param name="param"></param>
         private void ReturnFlowOpenPercentSetAction(object param)
         {
+            if (InputRetrunFlowOpenPercent > 100 || InputRetrunFlowOpenPercent < 0)
+            {
+                MessageBox.Show($"Input RetrunFlowOpenPercent value in 0~100", "Error",
+                      MessageBoxButton.OK, MessageBoxImage.Error);
+                return;
+            }
             InvokeClient.Instance.Service.DoOperation($"{Module}.ReturnValvePercent", InputRetrunFlowOpenPercent);
         }
         /// <summary>
@@ -343,6 +360,7 @@ namespace PunkHPX8_MainPages.ViewModels
             _rtDataKeys.Add($"{Module}.IsManualCAReplen");
             _rtDataKeys.Add($"{Module}.IsDIReplenPerfillTimeOut");
             _rtDataKeys.Add($"{Module}.IsDIReplenMaxTimeOut");
+            _rtDataKeys.Add($"{Module}.AvgCALevel");
             if (_timer == null)
             {
                 _timer = new DispatcherTimer();
@@ -386,6 +404,7 @@ namespace PunkHPX8_MainPages.ViewModels
                     _tcName = TemperatureControlData.Name;
                     IsCAHighLevel = CommonFunction.GetValue<bool>(_rtDataValueDic, $"{Module}.IsCAHighLevel");
                     IsCALowLevel = CommonFunction.GetValue<bool>(_rtDataValueDic, $"{Module}.IsCALowLevel");
+                    AvgCALevel = CommonFunction.GetValue<double>(_rtDataValueDic, $"{Module}.AvgCALevel");
 
 
                     DIValveMaxOnTime = CommonFunction.GetValue<double>(_rtDataValueDic, $"{Module}.DIValveMaxOnTime");

+ 1 - 1
PunkHPX8_MainPages/Views/DMReservoirView.xaml

@@ -296,7 +296,7 @@
                     IsANLevelLow="{Binding ReservoirData.AnTowerLow}"
                     ANFlow="{Binding ReservoirData.AnFlow}"
                     CAFlow="{Binding ReservoirData.CaFlow}"
-                    CALevel="{Binding ReservoirData.CaLevel}"
+                    CALevel="{Binding AvgCALevel}"
                     CALevelRaw="{Binding ReservoirData.CaWaterLevel}"
                     ReservoirTemperature ="{Binding TemperatureControlData.ReserviorTemperature}"
                     TCStatus ="{Binding TemperatureControlData.Status}"

+ 6 - 1
PunkHPX8_RT/Config/System.sccfg

@@ -347,6 +347,7 @@
 		<config default="30" name="CellFlowUpdatePeriod" nameView="CellFlowUpdatePeriod" description="Cell Flow Update Period" max="60" min="0" paramter="" tag="" unit="s" type="Integer"/>
 		<config default="50" name="ReturnOpenDefaultPercentage" nameView="ReturnOpenDefaultPercentage" description="Return Valve default percentage" max="100" min="0" paramter="" tag="" unit="" type="Integer"></config>
 		<config default="20" name="LevelAvgSamples" nameView="LevelAvgSamples" description="Level average sample" max="100" min="0" paramter="" tag="" unit="" type="Integer"></config>
+		<config default="2" name="DegasValveOpenIdlePeriod" nameView="DegasValveOpenIdlePeriod" description="Degas Valve Open Idle Period" max="60" min="0" paramter="" tag="" unit="Min" type="Integer"></config>
 		<configs name="Reservoir1" nameView="Reservoir1">
 			<config default="5.0" name="CAMainFlowFaultLow" nameView="CAMainFlowFaultLow" description="CA Main Flow Fault Low" max="30" min="0" paramter="" tag="" unit="" type="Double"></config>
 			<config default="1000" name="FlowFaultHoldOffTime" nameView="FlowFaultHoldOffTime" description="CA Flow Fault Hold Off Time" max="50000" min="0" paramter="" tag="" unit="ms" type="Integer"></config>
@@ -356,7 +357,11 @@
 			<config default="16" name="DIValveMaxOnTime" nameView="DIValveMaxOnTime" description="DI Valve Max Time in period " max="50" min="0" paramter="" tag="" unit="minute" type="Double" />
 			<config default="5" name="DIValveMaxOnTimePerFill" nameView="DIValveMaxOnTimePerFill" description="DI Valve Max Time per fill " max="50" min="0" paramter="" tag="" unit="minute" type="Double" />
 			<config default="24" name="DIValveMaxOnTimePeriod" nameView="DIValveMaxOnTimePeriod" description="DI Valve Max Time in period " max="48" min="0" paramter="" tag="" unit="hour" type="Double" />
-		
+			<config default="5" name="OverflowLevelDelta" nameView="OverflowLevelDelta" description="Overflow Level Delta" max="100" min="0" paramter="" tag="" unit="mm" type="Integer"/>
+			<config default="1000" name="OverflowLevelCheckTime" nameView="OverflowLevelCheckTime" description="Overflow Level Check Time" max="10000" min="0" paramter="" tag="" unit="ms" type="Integer"/>
+			<config default="2" name="RetrunOpenHoldStep" nameView="RetrunOpenHoldStep" description="Retrun Open Hold Step" max="100" min="0" paramter="" tag="" unit="" type="Integer"/>
+			<config default="10" name="RetrunOpenRampStep" nameView="RetrunOpenRampStep" description="Retrun Open Ramp Step" max="100" min="0" paramter="" tag="" unit="" type="Integer"/>
+			
 		</configs>
 		<configs name="Reservoir2" nameView="Reservoir2">
 			<config default="5.0" name="CAMainFlowFaultLow" nameView="CAMainFlowFaultLow" description="CA Main Flow Fault Low" max="30" min="0" paramter="" tag="" unit="" type="Double"></config>

+ 106 - 6
PunkHPX8_RT/Devices/Reservoir/ReservoirDevice.cs

@@ -6,7 +6,9 @@ using Aitex.Core.RT.RecipeCenter;
 using Aitex.Core.RT.SCCore;
 using Aitex.Core.Util;
 using MECF.Framework.Common.Alarm;
+using MECF.Framework.Common.Algorithm;
 using MECF.Framework.Common.Beckhoff.ModuleIO;
+using MECF.Framework.Common.CommonData.Prewet;
 using MECF.Framework.Common.CommonData.Reservoir;
 using MECF.Framework.Common.IOCore;
 using MECF.Framework.Common.Persistent.Reservoirs;
@@ -121,7 +123,27 @@ namespace PunkHPX8_RT.Devices.Reservoir
         /// 注水Helper
         /// </summary>
         private ReservoirDiReplenHelper _direplenHelper;
-        
+
+        /// <summary>
+        /// 上一时刻platingcell的overflow level
+        /// </summary>
+        private double _lastOverFlow;
+        /// <summary>
+        /// platingcell的overflow status
+        /// </summary>
+        private string _overFlowStatus = "Empty";
+        /// <summary>
+        /// 当前调节return valve的时间
+        /// </summary>
+        private DateTime _adjustReturnvalveStartTime = DateTime.Now;
+        /// <summary>
+        /// 首次发现ca flow 满足条件的时间,用于自动打开degas valve
+        /// </summary>
+        private DateTime _caFlowOKTime = DateTime.Now;
+        /// <summary>
+        /// ca flow 是否首次达到条件
+        /// </summary>
+        private bool _isFirstCaFlowOK = false;
         #endregion
 
         #region Trigger
@@ -198,6 +220,10 @@ namespace PunkHPX8_RT.Devices.Reservoir
         /// 累计补水是否超时
         /// </summary>
         public bool IsDIReplenMaxTimeOut { get { return _isDIReplenMaxTimeOut; } }
+        /// <summary>
+        /// 是否启动retrun valve自动调节开闭
+        /// </summary>
+        public bool IsStartAutoReturnValve { get; set; }
         #endregion
         /// <summary>
         /// 构造函数
@@ -257,6 +283,7 @@ namespace PunkHPX8_RT.Devices.Reservoir
             DATA.Subscribe($"{Module}.CurrentRecipe", () => _resRecipe, SubscriptionAttribute.FLAG.IgnoreSaveDB);
             DATA.Subscribe($"{Module}.IsCAHighLevel", () => IsCAHighLevel, SubscriptionAttribute.FLAG.IgnoreSaveDB);
             DATA.Subscribe($"{Module}.IsCALowLevel", () => IsCALowLevel, SubscriptionAttribute.FLAG.IgnoreSaveDB);
+            DATA.Subscribe($"{Module}.AvgCALevel", () => _avgCALevel, SubscriptionAttribute.FLAG.IgnoreSaveDB);
 
             DATA.Subscribe($"{Module}.DIValveMaxOnTime", () => SC.GetValue<double>($"Reservoir.{Module}.DIValveMaxOnTime") * 60, SubscriptionAttribute.FLAG.IgnoreSaveDB);
             DATA.Subscribe($"{Module}.IsManualCAReplen", () => { return _currentDireplenOperation == DiReplenOperation.ManualCADiReplen; }, SubscriptionAttribute.FLAG.IgnoreSaveDB);
@@ -372,13 +399,84 @@ namespace PunkHPX8_RT.Devices.Reservoir
         /// <returns></returns>
         protected virtual bool OnTimer()
         {
-            //CalculateCALevel();
+            CalculateCALevel();
+            AdjustPumpSpeed();
             WaterLevelMonitor();
             DireplenMonitor();
+            AutoOpenDegasValve();
             return true;
         }
         #region timer
         /// <summary>
+        /// safety和ca flow满足条件,自动打开degas valve
+        /// </summary>
+        public void AutoOpenDegasValve()
+        {
+            if(ReservoirData.CaFlow >= Recipe.CAFlowSetPoint) //缺了safety的条件,待补充
+            {
+                int degasValveOpenIdlePeriod = SC.GetValue<int>($"Reservoir.DegasValveOpenIdlePeriod");
+                if (!_isFirstCaFlowOK)
+                {
+                    _isFirstCaFlowOK = true;
+                    _caFlowOKTime = DateTime.Now;
+                }
+                else
+                {
+                    if(DateTime.Now.Subtract(_caFlowOKTime).TotalMinutes >= degasValveOpenIdlePeriod && !ReservoirData.DegasEnable)
+                    {
+                        DegasValveOn();
+                        _caFlowOKTime = DateTime.Now;//开启后重置一下检测到ca flow ok的时间
+                    }
+                }
+            }
+            else
+            {
+                _isFirstCaFlowOK = false;
+            }
+        }
+        /// <summary>
+        /// 自动调节retrun valve 开闭
+        /// </summary>
+        public void AdjustPumpSpeed()
+        {
+            ReservoirEntity reservoirEntity = Singleton<RouteManager>.Instance.GetModule<ReservoirEntity>(Module);
+            if (reservoirEntity != null) 
+            {
+                //retrun valve打开
+                if (ReservoirData.ReturnValveEnable && (!reservoirEntity.IsInit && !reservoirEntity.IsError))
+                {
+                    double overflow = new Random().NextDouble() * 6 + 10;//模拟platingcell的液位;
+                    int _overflowLevelDelta = SC.GetValue<int>($"Reservoir.{Module}.OverflowLevelDelta");
+                    int _overflowLevelCheckTime = SC.GetValue<int>($"Reservoir.{Module}.OverflowLevelCheckTime");
+                    int _retrunOpenHoldStep = SC.GetValue<int>($"Reservoir.{Module}.RetrunOpenHoldStep");
+                    int _retrunOpenRampStep = SC.GetValue<int>($"Reservoir.{Module}.RetrunOpenRampStep");
+                    int adjustNumber = "Full".Equals(_overFlowStatus) ? _retrunOpenHoldStep : _retrunOpenRampStep;//判断当前overflow状态
+                    if (overflow > _lastOverFlow)//液位升高的情况
+                    {
+                        if (overflow - _lastOverFlow > _overflowLevelDelta && DateTime.Now.Subtract(_adjustReturnvalveStartTime).TotalMilliseconds > _overflowLevelCheckTime)
+                        {
+                            double percent = ReservoirData.ReturnValveOpening - adjustNumber;
+                            percent = percent >= 0 ? percent : 0;
+                            ReturnValvePercent(percent);
+                            _lastOverFlow = overflow;
+                            _adjustReturnvalveStartTime = DateTime.Now;
+                        }
+                    }
+                    else
+                    {
+                        if (_lastOverFlow - overflow > _overflowLevelDelta && DateTime.Now.Subtract(_adjustReturnvalveStartTime).TotalMilliseconds > _overflowLevelCheckTime)
+                        {
+                            double percent = ReservoirData.ReturnValveOpening + adjustNumber;
+                            ReturnValvePercent(percent);
+                            _lastOverFlow = overflow;
+                            _adjustReturnvalveStartTime = DateTime.Now;
+                        }
+                    }
+                }
+            }
+            
+        }
+        /// <summary>
         /// 计算CA
         /// </summary>
         private void CalculateCALevel()
@@ -408,7 +506,6 @@ namespace PunkHPX8_RT.Devices.Reservoir
             {
         
                 ReservoirEntity reservoirEntity = Singleton<RouteManager>.Instance.GetModule<ReservoirEntity>(Module);
-
                 string reason = $"Current CAWaterlevel:{ReservoirData.CaWaterLevel} is lower than  CALowLevel Config:{SC.GetValue<double>($"Reservoir.{Module}.CALowLevel")}";
                 LOG.WriteLog(eEvent.ERR_RESERVOIR, Module, reason);
                 CALowLevelOperation();
@@ -437,6 +534,10 @@ namespace PunkHPX8_RT.Devices.Reservoir
             {
                 CAPumpOff("", null);
             }
+            if (_reservoirData.CaIsolation)// 不确定是否是关闭cell flow
+            {
+                CAIsolationOff();
+            }
             //禁用TC
             if (!string.IsNullOrEmpty(reservoirItem.TCID))
             {
@@ -446,9 +547,7 @@ namespace PunkHPX8_RT.Devices.Reservoir
                     temperatureController.DisableOperation("", null);
                 }
             }
-
             ReservoirEntity reservoirEntity = Singleton<RouteManager>.Instance.GetModule<ReservoirEntity>(Module);
-
             if (!reservoirEntity.IsError) reservoirEntity.PostMsg(ReservoirMsg.Error);
         }
         /// <summary>
@@ -781,7 +880,7 @@ namespace PunkHPX8_RT.Devices.Reservoir
         /// <returns></returns>
         private bool ReturnValveOn(string cmd, object[] args)
         {
-            double percent = SC.GetValue<double>("Reservoir.ReturnOpenDefaultPercentage");
+            double percent = SC.GetValue<int>("Reservoir.ReturnOpenDefaultPercentage");
             bool result = ReturnValvePercent(percent);
             if (result)
             {
@@ -1033,6 +1132,7 @@ namespace PunkHPX8_RT.Devices.Reservoir
         private bool ResetTotalTime(string cmd, object[] objs)
         {
             _isDIReplenMaxTimeOut = false;
+            _isDIReplenPerfillTimeOut = false;
             _persistentValue.TotalReplen = 0;
             _persistentValue.LastTotalReplen = 0;
             ReservoirsPersistentManager.Instance.UpdatePersistentValue(Module);

+ 2 - 1
PunkHPX8_Themes/UserControls/DMReservoirUIControl.xaml

@@ -263,7 +263,8 @@
         <Label Height="20" Width="100" FontSize="10"  FontWeight="Bold" Content="ReturnFlow Valve" Canvas.Left="605" Canvas.Top="351" />
         <Canvas Width="150" Height="100" Canvas.Left="727" Canvas.Top="528" HorizontalAlignment="Left" VerticalAlignment="Top">
             <userControls:TempControl TempValue="{Binding ElementName=self,Path=ReservoirTemperature}" Status="{Binding ElementName=self,Path=TCStatus}"
-                              DisableStatus="{Binding ElementName=self,Path=TCEnableStatus}">
+                              DisableStatus="{Binding ElementName=self,Path=TCEnableStatus}"
+                              MouseLeftButtonUp="JumpToTCAction">
             </userControls:TempControl>
         </Canvas>
         <Grid Canvas.Left="178" Canvas.Top="430" HorizontalAlignment="Center" VerticalAlignment="Top">

+ 6 - 0
PunkHPX8_Themes/UserControls/DMReservoirUIControl.xaml.cs

@@ -1,5 +1,6 @@
 using MECF.Framework.Common.OperationCenter;
 using OpenSEMI.ClientBase;
+using PunkHPX8_Core;
 using System;
 using System.Collections.Generic;
 using System.Linq;
@@ -398,6 +399,11 @@ namespace PunkHPX8_Themes.UserControls
         {
             InvokeClient.Instance.Service.DoOperation($"{ModuleName}.SampleOutValveOff");
         }
+
+        private void JumpToTCAction(object sender, MouseButtonEventArgs e)
+        {
+            GlobalEvents.OnSwitchFixedTabItem("HardWare", "TemperatureController", "TC1");
+        }
     }