VpwCellDeviceTimer.cs 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  1. using Aitex.Core.RT.Device;
  2. using Aitex.Core.Util;
  3. using MECF.Framework.Common.Equipment;
  4. using PunkHPX8_RT.Devices.AXIS;
  5. using PunkHPX8_RT.Devices.SRD;
  6. using System;
  7. using System.Collections.Generic;
  8. using System.Linq;
  9. using System.Text;
  10. using System.Threading.Tasks;
  11. namespace PunkHPX8_RT.Devices.VpwCell
  12. {
  13. public class VpwCellDeviceTimer : BaseDevice, IDevice
  14. {
  15. #region 常量
  16. private const string VPW = "Vpw";
  17. #endregion
  18. #region 内部变量
  19. private PeriodicJob _periodicJob;
  20. private JetAxisBase _vpw1RotationAxis;
  21. private JetAxisBase _vpw2RotationAxis;
  22. #endregion
  23. /// <summary>
  24. /// 构造函数
  25. /// </summary>
  26. public VpwCellDeviceTimer() : base(VPW, VPW, VPW, VPW)
  27. {
  28. _periodicJob = new PeriodicJob(20, OnTimer, $"{VPW}.OnTimer", false);
  29. }
  30. /// <summary>
  31. /// 初始化
  32. /// </summary>
  33. /// <returns></returns>
  34. public bool Initialize()
  35. {
  36. _vpw1RotationAxis = DEVICE.GetDevice<JetAxisBase>($"{ModuleName.VpwCell1}.Rotation");
  37. _vpw1RotationAxis = DEVICE.GetDevice<JetAxisBase>($"{ModuleName.VpwCell2}.Rotation");
  38. _periodicJob.Start();
  39. return true;
  40. }
  41. public void Monitor()
  42. {
  43. }
  44. public void Reset()
  45. {
  46. }
  47. public void Terminate()
  48. {
  49. _periodicJob.Stop();
  50. }
  51. /// <summary>
  52. /// 定时器执行
  53. /// </summary>
  54. /// <returns></returns>
  55. private bool OnTimer()
  56. {
  57. if (_vpw1RotationAxis != null)
  58. {
  59. _vpw1RotationAxis.OnTimer();
  60. }
  61. if (_vpw2RotationAxis != null)
  62. {
  63. _vpw2RotationAxis.OnTimer();
  64. }
  65. return true;
  66. }
  67. }
  68. }