12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394 |
- 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);
- }
- }
- }
|