Quellcode durchsuchen

add dm reservoir ca direplenin releated

chenzk vor 2 Tagen
Ursprung
Commit
263b4c3df5

+ 1 - 1
PunkHPX8_MainPages/Views/DMReservoirView.xaml

@@ -280,7 +280,7 @@
                     </Border>
                 </Grid>
             </GroupBox>
-            <Grid Grid.Row="2" Grid.Column="0" Grid.ColumnSpan="3" Grid.RowSpan="3" Margin="230,-50,0,0">
+            <Grid Grid.Row="2" Grid.Column="0" Grid.ColumnSpan="3" Grid.RowSpan="3" Margin="210,-50,0,0">
                 <userControls:DMReservoirUIControl
                     ModuleName="{Binding Module}"
                     ANIsolationValve="{Binding ReservoirData.AnIsolation}"

+ 1 - 0
PunkHPX8_RT/Config/System.sccfg

@@ -339,6 +339,7 @@
 		<config default="0.5" name="ANFlowStartLowLimit" nameView="ANFlowStartLowLimit" description="AN Flow StartLow Limit" max="20" min="0" paramter="" tag="" unit="L/min" type="Double"></config>
 	</configs>
 	<configs name="Reservoir" nameView="Reservoir">
+		<config default="0.5" name="LevelHysteresis" nameView="LevelHysteresis" description="level Hysteresis" max="2" min="0" paramter="" tag="" unit="" type="Double"></config>
 		<config default="5000" name="CADefaultPumpSpeed" nameView="CADefaultPumpSpeed" description="CA pump default speed" max="7200" min="0" paramter="" tag="" unit="" type="Double"></config>
 		<config default="7200" name="CAMaxPumpSpeed" nameView="CAMaxPumpSpeed" description="CA Max Pump Speed" max="10000" min="1" paramter="" tag="" unit="rpm" type="Double"></config>
 		<config default="3" name="ANDefaultPumpSpeed" nameView="ANDefaultPumpSpeed" description="AN pump default speed" max="5" min="0" paramter="" tag="" unit="" type="Double"></config>

+ 3 - 0
PunkHPX8_RT/Devices/DeviceManager.cs

@@ -76,6 +76,9 @@ namespace PunkHPX8_RT.Instances
             SafetyDevice safetyDevice = new SafetyDevice();
             AddCustomDevice(safetyDevice);
 
+            TotalReservoirDevice totalReservoirDevice = new TotalReservoirDevice();
+            AddCustomDevice(totalReservoirDevice);
+
             AddCustomModuleDevice(new SunWaySignalTower("System", "SignalTower"));
 
             return true;

+ 103 - 3
PunkHPX8_RT/Devices/Reservoir/DMReservoirDevice.cs

@@ -5,6 +5,8 @@ using Aitex.Core.Util;
 using MECF.Framework.Common.Beckhoff.ModuleIO;
 using MECF.Framework.Common.CommonData.Reservoir;
 using MECF.Framework.Common.Equipment;
+using MECF.Framework.Common.Persistent.Reservoirs;
+using MECF.Framework.Common.Persistent.Temperature;
 using MECF.Framework.Common.TwinCat;
 using System;
 using System.Collections.Generic;
@@ -26,6 +28,17 @@ namespace PunkHPX8_RT.Devices.Reservoir
         private double _anPumpSpeed = 5000;
         #endregion
 
+        #region 属性
+        /// <summary>
+        /// 检验阳极是否highlevel
+        /// </summary>
+        public bool IsANHighLevel { get { return _reservoirData.AnTowerHigh; } }
+        /// <summary>
+        /// 检验阳极是否lowlevel
+        /// </summary>
+        public bool IsANLowLevel { get { return _reservoirData.AnTowerLow; } }
+        #endregion
+
         #region Trigger
         /// <summary>
         /// low WaterLevel trigger
@@ -64,6 +77,8 @@ namespace PunkHPX8_RT.Devices.Reservoir
             OP.Subscribe($"{Module}.ANPumpEnable", AnPumpOnOperation);
             OP.Subscribe($"{Module}.ANPumpSpeed", ANPumpSpeedOperation);
             OP.Subscribe($"{Module}.ANPumpDisable", AnPumpOffOperation);
+            OP.Subscribe($"{Module}.ANIsolationOn", (cmd, para) => { return ANIsolationOn(); });
+            OP.Subscribe($"{Module}.ANIsolationOff", (cmd, para) => { return ANIsolationOff(); });
         }
 
         #region AnPump
@@ -145,6 +160,22 @@ namespace PunkHPX8_RT.Devices.Reservoir
             string ioName = BeckhoffModuleIOManager.Instance.GetIoNameByInnerModuleName($"{Module}.{AN_PUMP_ENABLE}");
             return BeckhoffIOManager.Instance.WriteIoValue(ioName, false);
         }
+        /// <summary>
+        /// ANIsolationOn
+        /// </summary>
+        /// <returns></returns>
+        public bool ANIsolationOn()
+        {
+            return WriteVariableValue(AN_ISOLATION, true);
+        }
+        /// <summary>
+        /// ANIsolationOff
+        /// </summary>
+        /// <returns></returns>
+        public bool ANIsolationOff()
+        {
+            return WriteVariableValue(AN_ISOLATION, false);
+        }
         #endregion
 
         /// <summary>
@@ -161,12 +192,81 @@ namespace PunkHPX8_RT.Devices.Reservoir
         {
             base.AutoDireplenMonitor();
         }
+
         /// <summary>
-        /// 阳极补水
+        /// 阳极DI Replen On
         /// </summary>
-        private void AnDireplenMonitor()
+        /// <param name="cmd"></param>
+        /// <param name="args"></param>
+        /// <returns></returns>
+        private bool ANDiReplenOnOperation(string cmd, object[] args)
         {
-            
+            return ANDiReplenOn();
         }
+        /// <summary>
+        /// 阳极DI Replen On
+        /// </summary>
+        /// <param name="showError"></param>
+        /// <returns></returns>
+        private bool ANDiReplenOn()
+        {
+            bool preCondition = CheckPreDiReplenCondition();
+            if (!preCondition)
+            {
+                return false;
+            }
+            if (IsANHighLevel)
+            {
+                LOG.WriteLog(eEvent.ERR_RESERVOIR, Module, $"ANHighLevel is activate,Can't do AN_DIReple");
+                return false;
+            }
+            if (IsANLowLevel)
+            {
+                LOG.WriteLog(eEvent.ERR_RESERVOIR, Module, $"ANLowLevel is activate,Can't do AN_DIReple");
+                return false;
+            }
+            if (ReservoirData.CaDiReplen)
+            {
+                LOG.WriteLog(eEvent.ERR_RESERVOIR, Module, "CADiReplen is on");
+                return false;
+            }
+            string ioName = BeckhoffModuleIOManager.Instance.GetIoNameByInnerModuleName($"{Module}.{AN_DI_REPLEN}");
+            return BeckhoffIOManager.Instance.WriteIoValue(ioName, true);
+        }
+
+        /// <summary>
+        /// 阳极DI Replen Off
+        /// </summary>
+        /// <param name="cmd"></param>
+        /// <param name="args"></param>
+        /// <returns></returns>
+        private bool ANDiReplenOff(string cmd, object[] args)
+        {
+            string ioName = BeckhoffModuleIOManager.Instance.GetIoNameByInnerModuleName($"{Module}.{AN_DI_REPLEN}");
+            bool result = BeckhoffIOManager.Instance.WriteIoValue(ioName, false);
+            if (result)
+            {
+                _persistentValue.IsDiReplenOn = false;
+                if (_currentDireplenOperation == DiReplenOperation.ManualANDiReplen || _currentDireplenOperation == DiReplenOperation.AutoANDiReplen)
+                {
+                    _currentDireplenOperation = DiReplenOperation.None;
+                    _persistentValue.LastTotalReplen = _persistentValue.TotalReplen;
+                    ReservoirsPersistentManager.Instance.UpdatePersistentValue(Module);
+                }
+            }
+            return result;
+        }
+        /// <summary>
+        /// 手动阳极注水
+        /// </summary>
+        /// <param name="cmd"></param>
+        /// <param name="args"></param>
+        /// <returns></returns>
+        private bool ManualANDiReplen(string cmd, object[] args)
+        {
+            return ManualDiReplen(ANDiReplenOnOperation, DiReplenOperation.ManualANDiReplen, args[0].ToString());
+        }
+
+
     }
 }

+ 64 - 138
PunkHPX8_RT/Devices/Reservoir/ReservoirDevice.cs

@@ -32,7 +32,8 @@ namespace PunkHPX8_RT.Devices.Reservoir
 {
     public class ReservoirDevice : BaseDevice, IDevice
     {
-        private enum ReservoirOperation
+
+        protected enum DiReplenOperation
         {
             None,
             ManualANDiReplen,
@@ -40,7 +41,7 @@ namespace PunkHPX8_RT.Devices.Reservoir
             AutoANDiReplen,
             AutoCADiReplen
         }
-        
+
         #region 常量
         protected const string AUTO = "Auto";
         protected const string MANUAL = "Manual";
@@ -73,20 +74,13 @@ namespace PunkHPX8_RT.Devices.Reservoir
         #endregion
 
         #region 内部变量
-        /// <summary>
-        /// Prewet 持久性数值对象
-        /// </summary>
-        private ReservoirsPersistentValue _persistentValue;
+
 
         /// <summary>
         /// 变量是否初始化字典
         /// </summary>
         private Dictionary<string, bool> _variableInitializeDic = new Dictionary<string, bool>();
         /// <summary>
-        /// 数据
-        /// </summary>
-        private ReservoirData _reservoirData = new ReservoirData();
-        /// <summary>
         /// 定时器
         /// </summary>
         private PeriodicJob _periodicJob;
@@ -128,10 +122,6 @@ namespace PunkHPX8_RT.Devices.Reservoir
         /// </summary>
         private ReservoirDiReplenHelper _direplenHelper;
         
-        /// <summary>
-        /// 当前操作
-        /// </summary>
-        private ReservoirOperation _currentOperation;
         #endregion
 
         #region Trigger
@@ -152,6 +142,14 @@ namespace PunkHPX8_RT.Devices.Reservoir
         /// 手动注水时间(秒)
         /// </summary>
         protected int _manualReplenSecond = 0;
+        /// <summary>
+        /// 数据
+        /// </summary>
+        protected ReservoirData _reservoirData = new ReservoirData();
+        /// <summary>
+        /// Prewet 持久性数值对象
+        /// </summary>
+        protected ReservoirsPersistentValue _persistentValue;
         #endregion
 
         #region 属性
@@ -181,17 +179,25 @@ namespace PunkHPX8_RT.Devices.Reservoir
         /// </summary>
         public bool IsCALowLevel { get { return CheckCALowLevelStatus(); } }
         /// <summary>
-        /// 检验阳极是否highlevel
+        /// 当前Recipe
         /// </summary>
-        public bool IsANHighLevel { get { return _reservoirData.AnTowerHigh; } }
+        public ResRecipe Recipe { get { return _resRecipe; } }
         /// <summary>
-        /// 检验阳极是否lowlevel
+        /// 阴极是否需要补水
         /// </summary>
-        public bool IsANLowLevel { get { return _reservoirData.AnTowerLow; } }
+        public bool CANeedDiReplen { get { return CheckCANeedDiReplen(); } }
         /// <summary>
-        /// 当前Recipe
+        /// 正在补水
         /// </summary>
-        public ResRecipe Recipe { get { return _resRecipe; } }
+        public bool IsDireplenOn { get { return _reservoirData.AnDiReplen || _reservoirData.CaDiReplen; } }
+        /// <summary>
+        /// 单次补水是否超时
+        /// </summary>
+        public bool IsDIReplenPerfillTimeOut { get { return _isDIReplenPerfillTimeOut; } }
+        /// <summary>
+        /// 累计补水是否超时
+        /// </summary>
+        public bool IsDIReplenMaxTimeOut { get { return _isDIReplenMaxTimeOut; } }
         #endregion
         /// <summary>
         /// 构造函数
@@ -228,11 +234,6 @@ namespace PunkHPX8_RT.Devices.Reservoir
             {
                 LOG.WriteLog(eEvent.ERR_RESERVOIR, Module.ToString(), "Persistent Value Object is not exist");
             }
-            _persistentValue = ReservoirsPersistentManager.Instance.GetReservoirsPersistentValue(Module);
-            if (_persistentValue == null)
-            {
-                LOG.WriteLog(eEvent.ERR_RESERVOIR, Module, "Persistent Value Object is not exist");
-            }
             if (!string.IsNullOrEmpty(_persistentValue.Recipe))
             {
                 _resRecipe = RecipeFileManager.Instance.LoadGenericityRecipe<ResRecipe>(_persistentValue.Recipe);
@@ -258,7 +259,7 @@ namespace PunkHPX8_RT.Devices.Reservoir
             DATA.Subscribe($"{Module}.IsCALowLevel", () => IsCALowLevel, SubscriptionAttribute.FLAG.IgnoreSaveDB);
 
             DATA.Subscribe($"{Module}.DIValveMaxOnTime", () => SC.GetValue<double>($"Reservoir.{Module}.DIValveMaxOnTime") * 60, SubscriptionAttribute.FLAG.IgnoreSaveDB);
-            DATA.Subscribe($"{Module}.IsManualCAReplen", () => { return _currentOperation == ReservoirOperation.ManualCADiReplen; }, SubscriptionAttribute.FLAG.IgnoreSaveDB);
+            DATA.Subscribe($"{Module}.IsManualCAReplen", () => { return _currentDireplenOperation == DiReplenOperation.ManualCADiReplen; }, SubscriptionAttribute.FLAG.IgnoreSaveDB);
             DATA.Subscribe($"{Module}.IsDIReplenPerfillTimeOut", () => _isDIReplenPerfillTimeOut, SubscriptionAttribute.FLAG.IgnoreSaveDB);
             DATA.Subscribe($"{Module}.IsDIReplenMaxTimeOut", () => _isDIReplenMaxTimeOut, SubscriptionAttribute.FLAG.IgnoreSaveDB);
         }
@@ -282,8 +283,7 @@ namespace PunkHPX8_RT.Devices.Reservoir
 
             OP.Subscribe($"{Module}.CAIsolationOn", (cmd, para) => { return CAIsolationOn(); });
             OP.Subscribe($"{Module}.CAIsolationOff", (cmd, para) => { return CAIsolationOff(); });
-            OP.Subscribe($"{Module}.ANIsolationOn", (cmd, para) => { return ANIsolationOn(); });
-            OP.Subscribe($"{Module}.ANIsolationOff", (cmd, para) => { return ANIsolationOff(); });
+   
             OP.Subscribe($"{Module}.SampleOutValveOn", (cmd, para) => { return SampleOutValveOn(); });
             OP.Subscribe($"{Module}.SampleOutValveOff", (cmd, para) => { return SampleOutValveOff(); });
             OP.Subscribe($"{Module}.DegasValveOn", (cmd, para) => { return DegasValveOn(); });
@@ -359,7 +359,7 @@ namespace PunkHPX8_RT.Devices.Reservoir
         /// <param name="variable"></param>
         /// <param name="value"></param>
         /// <returns></returns>
-        private bool WriteVariableValue(string variable, object value)
+        protected bool WriteVariableValue(string variable, object value)
         {
             string ioName = BeckhoffModuleIOManager.Instance.GetIoNameByInnerModuleName($"{Module}.{variable}");
             return IOModuleManager.Instance.WriteIoValue(ioName, value);
@@ -374,7 +374,7 @@ namespace PunkHPX8_RT.Devices.Reservoir
         {
             //CalculateCALevel();
             WaterLevelMonitor();
-            //DireplenMonitor();
+            DireplenMonitor();
             return true;
         }
         #region timer
@@ -507,20 +507,21 @@ namespace PunkHPX8_RT.Devices.Reservoir
             }
             if (_currentDireplenOperation == DiReplenOperation.ManualANDiReplen)
             {
-                bool result = _direplenHelper.MonitorManualDiReplenComplete(_manualReplenSecond, ANDiReplenOff, ref _isDIReplenMaxTimeOut);
-                if (result)
-                {
-                    _currentDireplenOperation = DiReplenOperation.None;
-                }
+                //bool result = _direplenHelper.MonitorManualDiReplenComplete(_manualReplenSecond, ANDiReplenOff, ref _isDIReplenMaxTimeOut);
+                //if (result)
+                //{
+                //    _currentDireplenOperation = DiReplenOperation.None;
+                //}
             }
             if (_currentDireplenOperation == DiReplenOperation.AutoCADiReplen)
             {
                 AutoDiReplenMonitor(CADiReplenOff, _reservoirData.CaLevel, _resRecipe.ReservoirCALevel, _resRecipe.DIReplenEnable,
                     _resRecipe.DIReplenTimeRate, _resRecipe.DIReplenCurrentRate);
             }
-            if (_currentDireplenOperation == DiReplenOperation.AutoANDiReplen) //阳极没有水位,自动补水监控逻辑待修正
+            //阳极没有水位,自动补水监控逻辑待修正
+            if (_currentDireplenOperation == DiReplenOperation.AutoANDiReplen) 
             {
-          
+                
             }
         }
         /// <summary>
@@ -532,6 +533,7 @@ namespace PunkHPX8_RT.Devices.Reservoir
         private void AutoDiReplenMonitor(Func<string, object[], bool> direplenOff, double level, double recipeLevel, bool replenEnable,
             int direplenTimeRate, int direplenCurrentRate)
         {
+            //判断是否注水超时(包括单次和累计)
             bool result = _direplenHelper.AutoDiReplenMonitorTimeOut(direplenOff, ref _isDIReplenMaxTimeOut, ref _isDIReplenPerfillTimeOut);
             if (result)
             {
@@ -666,6 +668,7 @@ namespace PunkHPX8_RT.Devices.Reservoir
         public void Monitor()
         {
         }
+
         #region CA Pump
         /// <summary>
         /// CA Pump调速
@@ -805,22 +808,8 @@ namespace PunkHPX8_RT.Devices.Reservoir
         }
         #endregion
         
-        /// <summary>
-        /// ANIsolationOn
-        /// </summary>
-        /// <returns></returns>
-        public bool ANIsolationOn()
-        {
-            return WriteVariableValue(AN_ISOLATION, true);
-        }
-        /// <summary>
-        /// ANIsolationOff
-        /// </summary>
-        /// <returns></returns>
-        public bool ANIsolationOff()
-        {
-            return WriteVariableValue(AN_ISOLATION, false);
-        }
+
+
         /// <summary>
         /// CAIsolationOn
         /// </summary>
@@ -1033,72 +1022,6 @@ namespace PunkHPX8_RT.Devices.Reservoir
         }
         #endregion
 
-        #region AN DiReplen
-        /// <summary>
-        /// 阳极DI Replen On
-        /// </summary>
-        /// <param name="cmd"></param>
-        /// <param name="args"></param>
-        /// <returns></returns>
-        private bool ANDiReplenOnOperation(string cmd, object[] args)
-        {
-            return ANDiReplenOn();
-        }
-        /// <summary>
-        /// 阳极DI Replen On
-        /// </summary>
-        /// <param name="showError"></param>
-        /// <returns></returns>
-        private bool ANDiReplenOn()
-        {
-            bool preCondition = CheckPreDiReplenCondition();
-            if (!preCondition)
-            {
-                return false;
-            }
-            if (IsANHighLevel)
-            {
-                LOG.WriteLog(eEvent.ERR_RESERVOIR, Module, $"ANHighLevel is activate,Can't do AN_DIReple");
-                return false;
-            }
-            if (IsANLowLevel)
-            {
-                LOG.WriteLog(eEvent.ERR_RESERVOIR, Module, $"ANLowLevel is activate,Can't do AN_DIReple");
-                return false;
-            }
-            if (ReservoirData.CaDiReplen)
-            {
-                LOG.WriteLog(eEvent.ERR_RESERVOIR, Module, "CADiReplen is on");
-                return false;
-            }
-            string ioName = BeckhoffModuleIOManager.Instance.GetIoNameByInnerModuleName($"{Module}.{AN_DI_REPLEN}");
-            return BeckhoffIOManager.Instance.WriteIoValue(ioName, true);
-        }
-
-        /// <summary>
-        /// 阳极DI Replen Off
-        /// </summary>
-        /// <param name="cmd"></param>
-        /// <param name="args"></param>
-        /// <returns></returns>
-        private bool ANDiReplenOff(string cmd, object[] args)
-        {
-            string ioName = BeckhoffModuleIOManager.Instance.GetIoNameByInnerModuleName($"{Module}.{AN_DI_REPLEN}");
-            bool result = BeckhoffIOManager.Instance.WriteIoValue(ioName, false);
-            if (result)
-            {
-                _persistentValue.IsDiReplenOn = false;
-                if (_currentDireplenOperation == DiReplenOperation.ManualANDiReplen || _currentDireplenOperation == DiReplenOperation.AutoANDiReplen)
-                {
-                    _currentDireplenOperation = DiReplenOperation.None;
-                    _persistentValue.LastTotalReplen = _persistentValue.TotalReplen;
-                    ReservoirsPersistentManager.Instance.UpdatePersistentValue(Module);
-                }
-            }
-            return result;
-        }
-
-        #endregion
 
         #region DiReplen Operation
         /// <summary>
@@ -1126,22 +1049,12 @@ namespace PunkHPX8_RT.Devices.Reservoir
             return ManualDiReplen(CADiReplenOnOperation, DiReplenOperation.ManualCADiReplen, args[0].ToString());
         }
         /// <summary>
-        /// 手动阳极注水
-        /// </summary>
-        /// <param name="cmd"></param>
-        /// <param name="args"></param>
-        /// <returns></returns>
-        private bool ManualANDiReplen(string cmd, object[] args)
-        {
-            return ManualDiReplen(ANDiReplenOnOperation, DiReplenOperation.ManualANDiReplen, args[0].ToString());
-        }
-        /// <summary>
         /// 手动注水
         /// </summary>
         /// <param name="direplenOn"></param>
         /// <param name="direplenOperation"></param>
         /// <returns></returns>
-        private bool ManualDiReplen(Func<string, object[], bool> direplenOn, DiReplenOperation direplenOperation, string timeLength)
+        protected bool ManualDiReplen(Func<string, object[], bool> direplenOn, DiReplenOperation direplenOperation, string timeLength)
         {
             if (_currentDireplenOperation != DiReplenOperation.None)
             {
@@ -1230,6 +1143,26 @@ namespace PunkHPX8_RT.Devices.Reservoir
         {
             return ReservoirData.CaWaterLevel < SC.GetValue<double>($"Reservoir.{Module}.CALowLevel") ? true : false;
         }
+        /// <summary>
+        /// 检验CA是否需要注水
+        /// </summary>
+        /// <returns></returns>
+        public bool CheckCANeedDiReplen()
+        {
+            if (IsAuto && _resRecipe != null)
+            {
+                if (_resRecipe.DIReplenEnable && _resRecipe.DIReplenTimeRate == 0 && _resRecipe.DIReplenCurrentRate == 0)
+                {
+                    double levelHysteresis = SC.GetValue<double>("Reservoir.LevelHysteresis");
+                    return _reservoirData.CaLevel < _resRecipe.ReservoirCALevel - levelHysteresis;
+                }
+                return false;
+            }
+            else
+            {
+                return false;
+            }
+        }
 
 
         public void Reset()
@@ -1239,14 +1172,7 @@ namespace PunkHPX8_RT.Devices.Reservoir
         public void Terminate()
         {
         }
-        protected enum DiReplenOperation
-        {
-            None,
-            ManualANDiReplen,
-            ManualCADiReplen,
-            AutoANDiReplen,
-            AutoCADiReplen
-        }
+        
 
     }
 }

+ 1 - 1
PunkHPX8_RT/Devices/Reservoir/ReservoirDiReplenHelper.cs

@@ -40,7 +40,7 @@ namespace PunkHPX8_RT.Devices.Reservoir
         /// </summary>
         public void MonitorPeriodTime(ref bool maxTimeout)
         {
-            double levelHysteresis = SC.GetValue<double>("Reservoir.LevelHysteresis");
+            //double levelHysteresis = SC.GetValue<double>("Reservoir.LevelHysteresis");
             double diValveMaxOnTimePeriod = SC.GetValue<double>($"Reservoir.{_module}.DIValveMaxOnTimePeriod");
             //没有在注水
             if (_persistentValue != null && !_persistentValue.IsDiReplenOn)

+ 93 - 0
PunkHPX8_RT/Devices/Reservoir/TotalReservoirDevice.cs

@@ -0,0 +1,93 @@
+using Aitex.Core.RT.Device;
+using Aitex.Core.Util;
+using MECF.Framework.Common.CommonData;
+using MECF.Framework.Common.ToolLayout;
+using MECF.Framework.Common.TwinCat;
+using PunkHPX8_RT.Modules;
+using PunkHPX8_RT.Modules.Reservoir;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Reflection;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace PunkHPX8_RT.Devices.Reservoir
+{
+    public class TotalReservoirDevice : BaseDevice, IDevice
+    {
+        #region 常量 
+      
+        #endregion
+        #region 内部变量
+       
+        /// <summary>
+        /// 定时器
+        /// </summary>
+        private PeriodicJob _period;
+        #endregion
+        #region 属性
+
+        #endregion
+        /// <summary>
+        /// 构造函数
+        /// </summary>
+        /// <param name="moduleName"></param>
+        /// <param name="name"></param>
+        public TotalReservoirDevice() : base("Reservoir", "Reservoir", "Reservoir", "Reservoir")
+        {
+            _period = new PeriodicJob(500, OnTimer, "Reservoir.OnTimer", true, true);
+        }
+        /// <summary>
+        /// 初始化
+        /// </summary>
+        /// <returns></returns>
+        public bool Initialize()
+        { 
+            return true;
+        }
+        /// <summary>
+        /// 定时器
+        /// </summary>
+        /// <returns></returns>
+        private bool OnTimer()
+        {
+            List<string> reservoirs = ReservoirItemManager.Instance.InstalledModules;
+            foreach (string module in reservoirs)
+            {
+                ReservoirItem reservoirItem = ReservoirItemManager.Instance.GetReservoirItem(module);
+                ReservoirEntity reservoirEntity = Singleton<RouteManager>.Instance.GetModule<ReservoirEntity>(module);
+                if (reservoirEntity != null)
+                {
+                    if (reservoirItem.SubType == "DM")
+                    {
+                        DMReservoirDevice reservoirDevice = DEVICE.GetDevice<DMReservoirDevice>(module);
+                        if (!reservoirEntity.IsInitialized || reservoirDevice.IsDIReplenMaxTimeOut
+                            || reservoirDevice.IsDireplenOn || reservoirDevice.IsDIReplenPerfillTimeOut)
+                        {
+                            continue;
+                        }
+                        if (reservoirDevice.CANeedDiReplen && !reservoirDevice.IsDireplenOn)
+                        {
+                            reservoirDevice.AutoCADiReplen();
+                        }
+                    }
+                }
+            }
+            return true;
+        }
+
+        public void Monitor()
+        {
+        }
+
+        public void Reset()
+        {
+        }
+
+        public void Terminate()
+        {
+            _period.Stop(false);
+        }
+    }
+}