using Aitex.Core.RT.Device; using Aitex.Core.Util; using MECF.Framework.Common.Equipment; using MECF.Framework.Common.ToolLayout; using PunkHPX8_RT.Devices.AXIS; using PunkHPX8_RT.Devices.SRD; using PunkHPX8_RT.Devices.VpwCell; using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace PunkHPX8_RT.Devices.VpwMain { public class VpDeviceTimer : BaseDevice, IDevice { #region 常量 private const string VPW = "Vpw"; #endregion #region 内部变量 private PeriodicJob _periodicJob; private VpwMainDevice _vpwMainDevice; private VpwCellDevice[] _vpwCellDevices; #endregion /// /// 构造函数 /// public VpDeviceTimer() : base(VPW, VPW, VPW, VPW) { _periodicJob = new PeriodicJob(20, OnTimer, $"{VPW}.OnTimer", false); } /// /// 初始化 /// /// public bool Initialize() { if (ModuleHelper.IsInstalled(ModuleName.VPWMain1)) { _vpwMainDevice=DEVICE.GetDevice(ModuleName.VPWMain1.ToString()); } List installedCells = VpwCellItemManager.Instance.InstalledModules; _vpwCellDevices=new VpwCellDevice[installedCells.Count]; for (int i=0;i<_vpwCellDevices.Length;i++) { _vpwCellDevices[i] = DEVICE.GetDevice(installedCells[i]); } _periodicJob.Start(); return true; } public void Monitor() { } public void Reset() { } public void Terminate() { _periodicJob.Stop(); } /// /// 定时器执行 /// /// private bool OnTimer() { if (_vpwMainDevice != null) { _vpwMainDevice.OnTimer(); } foreach(var item in _vpwCellDevices) { item.OnTimer(); } return true; } } }