PufDeviceTimer.cs 2.1 KB

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