| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177 | 
							- using Aitex.Core.RT.Device;
 
- using Aitex.Core.RT.Log;
 
- using Aitex.Core.RT.SCCore;
 
- using MECF.Framework.Common.Alarm;
 
- using MECF.Framework.Common.Persistent.Reservoirs;
 
- using PunkHPX8_RT.Devices.Facilities;
 
- using System;
 
- namespace PunkHPX8_RT.Devices.Reservoir
 
- {
 
-     public class ReservoirDiReplenHelper
 
-     {
 
-         #region 内部变量
 
-         /// <summary>
 
-         /// 模块名称
 
-         /// </summary>
 
-         private string _module;
 
-         /// <summary>
 
-         /// 持久化对象
 
-         /// </summary>
 
-         private ReservoirsPersistentValue _persistentValue;
 
-         /// <summary>
 
-         /// 锁
 
-         /// </summary>
 
-         private object _locker = new object();
 
-         #endregion
 
-         /// <summary>
 
-         /// 构造函数
 
-         /// </summary>
 
-         /// <param name="module"></param>
 
-         /// <param name="persistentValue"></param>
 
-         /// <param name="resRecipe"></param>
 
-         public ReservoirDiReplenHelper(string module, ReservoirsPersistentValue persistentValue)
 
-         {
 
-             _module = module;
 
-             _persistentValue = persistentValue;
 
-         }
 
-         /// <summary>
 
-         /// 监控
 
-         /// </summary>
 
-         public void MonitorPeriodTime(ref bool maxTimeout)
 
-         {
 
-             //double levelHysteresis = SC.GetValue<double>("Reservoir.LevelHysteresis");
 
-             double diValveMaxOnTimePeriod = SC.GetValue<double>($"Reservoir.{_module}.DIValveMaxOnTimePeriod");
 
-             //没有在注水
 
-             if (_persistentValue != null && !_persistentValue.IsDiReplenOn)
 
-             {
 
-                 //超过时间
 
-                 if (DateTime.Now.Subtract(_persistentValue.PeriodStartTime).TotalMinutes >= diValveMaxOnTimePeriod * 60)
 
-                 {
 
-                     maxTimeout = false;
 
-                     _persistentValue.PeriodStartTime = DateTime.Now;
 
-                     _persistentValue.TotalReplen = 0;
 
-                     _persistentValue.LastTotalReplen = 0;
 
-                     ReservoirsPersistentManager.Instance.UpdatePersistentValue(_module);
 
-                 }
 
-             }
 
-         }
 
-         /// <summary>
 
-         /// 监控手动注水
 
-         /// </summary>
 
-         public bool MonitorManualDiReplenComplete(int replenSecond, Func<string, object[], bool> direplenOffAction, ref bool maxTimeout)
 
-         {
 
-             lock (_locker)
 
-             {
 
-                 _persistentValue.TotalReplen = _persistentValue.LastTotalReplen + (int)DateTime.Now.Subtract(_persistentValue.DiReplenTime).TotalSeconds;
 
-             }
 
-             //周期内累计补水超时
 
-             double diValveMaxOnTime = SC.GetValue<double>($"Reservoir.{_module}.DIValveMaxOnTime");
 
-             if (_persistentValue.TotalReplen >= diValveMaxOnTime * 60)
 
-             {
 
-                 bool result = direplenOffAction("", null);
 
-                 if (result)
 
-                 {
 
-                     maxTimeout = true;
 
-                     LOG.WriteLog(eEvent.WARN_RESERVOIR, _module, $"DiReplen time over conifg's DIValveMaxOnTime:{diValveMaxOnTime} min");
 
-                     _persistentValue.LastTotalReplen = _persistentValue.TotalReplen;
 
-                     _persistentValue.IsDiReplenOn = false;
 
-                     ReservoirsPersistentManager.Instance.UpdatePersistentValue(_module);
 
-                 }
 
-                 return result;
 
-             }
 
-             if (DateTime.Now.Subtract(_persistentValue.DiReplenTime).TotalSeconds >= replenSecond)
 
-             {
 
-                 bool result = direplenOffAction("", null);
 
-                 if (result)
 
-                 {
 
-                     _persistentValue.LastTotalReplen = _persistentValue.TotalReplen;
 
-                     _persistentValue.IsDiReplenOn = false;
 
-                     ReservoirsPersistentManager.Instance.UpdatePersistentValue(_module);
 
-                     LOG.WriteLog(eEvent.INFO_RESERVOIR, _module, "Manual DiReplen complete");
 
-                 }
 
-                 return result;
 
-             }
 
-             return false;
 
-         }
 
-         /// <summary>
 
-         /// 单次自动注水超时
 
-         /// </summary>
 
-         /// <returns></returns>
 
-         public bool AutoDiReplenMonitorTimeOut(Func<string, object[], bool> direplenOffAction, ref bool maxTimeOut, ref bool perfillTimeOut)
 
-         {
 
-             lock (_locker)
 
-             {
 
-                 _persistentValue.TotalReplen = _persistentValue.LastTotalReplen + (int)DateTime.Now.Subtract(_persistentValue.DiReplenTime).TotalSeconds;
 
-             }
 
-             //单次补水超时
 
-             double diValveMaxOnTimePerFill = SC.GetValue<double>($"Reservoir.{_module}.DIValveMaxOnTimePerFill");
 
-             if (DateTime.Now.Subtract(_persistentValue.DiReplenTime).TotalSeconds >= diValveMaxOnTimePerFill * 60)
 
-             {
 
-                 bool result = direplenOffAction("", null);
 
-                 if (result)
 
-                 {
 
-                     perfillTimeOut = true;
 
-                     LOG.WriteLog(eEvent.WARN_RESERVOIR, _module, $"DiReplen time over conifg's DIValveMaxOnTimePerFill:{diValveMaxOnTimePerFill} min");
 
-                     AlarmListManager.Instance.AddWarn(_module, $"", $"{_module} DiReplen time over config DIValveMaxOnTimePerFill:{diValveMaxOnTimePerFill} min");
 
-                     //补水超时关闭总的补水阀
 
-                     SystemFacilities systemFacilities = DEVICE.GetDevice<SystemFacilities>("System.Facilities");
 
-                     if (systemFacilities != null)
 
-                     {
 
-                         if (systemFacilities.DIReplenEnable) systemFacilities.DiReplenDisableOperation("DiReplenDisableOperation", null);
 
-                     }
 
-                     _persistentValue.LastTotalReplen = _persistentValue.TotalReplen;
 
-                     _persistentValue.IsDiReplenOn = false;
 
-                     ReservoirsPersistentManager.Instance.UpdatePersistentValue(_module);
 
-                 }
 
-                 return result;
 
-             }
 
-             //周期内累计补水超时
 
-             double diValveMaxOnTime = SC.GetValue<double>($"Reservoir.{_module}.DIValveMaxOnTime");
 
-             if (_persistentValue.TotalReplen >= diValveMaxOnTime * 60)
 
-             {
 
-                 bool result = direplenOffAction("", null);
 
-                 if (result)
 
-                 {
 
-                     maxTimeOut = true;
 
-                     AlarmListManager.Instance.AddWarn(_module, $"", $"{_module} DiReplen time over config DIValveMaxOnTime:{diValveMaxOnTime} min");
 
-                     LOG.WriteLog(eEvent.WARN_RESERVOIR, _module, $"DiReplen time over config DIValveMaxOnTime:{diValveMaxOnTime} min");
 
-                     _persistentValue.LastTotalReplen = _persistentValue.TotalReplen;
 
-                     _persistentValue.IsDiReplenOn = false;
 
-                     ReservoirsPersistentManager.Instance.UpdatePersistentValue(_module);
 
-                 }
 
-                 return result;
 
-             }
 
-             return false;
 
-         }
 
-         /// <summary>
 
-         /// 自动注水是否结束
 
-         /// </summary>
 
-         /// <param name="level"></param>
 
-         /// <param name="recipeLevel"></param>
 
-         /// <param name="direplenOffAction"></param>
 
-         /// <returns></returns>
 
-         public bool AutoDiReplenMonitorComplete(double level, double recipeLevel, bool replenEnable,
 
-             int direplenTimeRate, int direplenCurrentRate, Func<string, object[], bool> direplenOffAction)
 
-         {
 
-             double levelHysteresis = SC.GetValue<double>("Reservoir.LevelHysteresis");
 
-             //按液位补水
 
-             if (replenEnable && direplenTimeRate == 0 && direplenCurrentRate == 0 &&
 
-                 level >= recipeLevel)
 
-             {
 
-                 LOG.WriteLog(eEvent.INFO_RESERVOIR, _module, "Auto DiReplen complete");
 
-                 bool result = direplenOffAction("", null);
 
-                 if (result)
 
-                 {
 
-                     _persistentValue.LastTotalReplen = _persistentValue.TotalReplen;
 
-                     _persistentValue.IsDiReplenOn = false;
 
-                     ReservoirsPersistentManager.Instance.UpdatePersistentValue(_module);
 
-                     return result;
 
-                 }
 
-             }
 
-             return false;
 
-         }
 
-     }
 
- }
 
 
  |