1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586 |
- 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 VpwDeviceTimer : BaseDevice, IDevice
- {
- #region 常量
- private const string VPW = "Vpw";
- #endregion
- #region 内部变量
- private PeriodicJob _periodicJob;
- private VpwMainDevice _vpwMainDevice;
- private VpwCellDevice[] _vpwCellDevices;
- #endregion
- /// <summary>
- /// 构造函数
- /// </summary>
- public VpwDeviceTimer() : base(VPW, VPW, VPW, VPW)
- {
- _periodicJob = new PeriodicJob(20, OnTimer, $"{VPW}.OnTimer", false);
- }
- /// <summary>
- /// 初始化
- /// </summary>
- /// <returns></returns>
- public bool Initialize()
- {
- if (ModuleHelper.IsInstalled(ModuleName.VPWMain1))
- {
- _vpwMainDevice=DEVICE.GetDevice<VpwMainDevice>(ModuleName.VPWMain1.ToString());
- }
- List<string> installedCells = VpwCellItemManager.Instance.InstalledModules;
- _vpwCellDevices=new VpwCellDevice[installedCells.Count];
- for (int i=0;i<_vpwCellDevices.Length;i++)
- {
- _vpwCellDevices[i] = DEVICE.GetDevice<VpwCellDevice>(installedCells[i]);
- }
- _periodicJob.Start();
- return true;
- }
- public void Monitor()
- {
- }
- public void Reset()
- {
- }
- public void Terminate()
- {
- _periodicJob.Stop();
- }
- /// <summary>
- /// 定时器执行
- /// </summary>
- /// <returns></returns>
- private bool OnTimer()
- {
- if (_vpwMainDevice != null)
- {
- _vpwMainDevice.OnTimer();
- }
- foreach(var item in _vpwCellDevices)
- {
- item.OnTimer();
- }
- return true;
- }
- }
- }
|