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 内部变量 /// /// 定时器 /// private PeriodicJob _period; #endregion #region 属性 #endregion /// /// 构造函数 /// /// /// public TotalReservoirDevice() : base("Reservoir", "Reservoir", "Reservoir", "Reservoir") { _period = new PeriodicJob(500, OnTimer, "Reservoir.OnTimer", true, true); } /// /// 初始化 /// /// public bool Initialize() { return true; } /// /// 定时器 /// /// private bool OnTimer() { List reservoirs = ReservoirItemManager.Instance.InstalledModules; foreach (string module in reservoirs) { ReservoirItem reservoirItem = ReservoirItemManager.Instance.GetReservoirItem(module); ReservoirEntity reservoirEntity = Singleton.Instance.GetModule(module); if (reservoirEntity != null) { if (reservoirItem.SubType == "DM") { DMReservoirDevice reservoirDevice = DEVICE.GetDevice(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); } } }