12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485 |
- 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
- /// <summary>
- /// 构造函数
- /// </summary>
- public VpDeviceTimer() : 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;
- }
- }
- }
|