PufChuckRoutine.cs 2.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  1. using Aitex.Core.RT.Device;
  2. using Aitex.Core.RT.Routine;
  3. using CyberX8_Core;
  4. using CyberX8_RT.Devices.PUF;
  5. using MECF.Framework.Common.Routine;
  6. using System;
  7. using System.Collections.Generic;
  8. using System.Linq;
  9. using System.Text;
  10. using System.Threading.Tasks;
  11. namespace CyberX8_RT.Modules.PUF
  12. {
  13. public class PufChuckRoutine : RoutineBase, IRoutine
  14. {
  15. private enum ChuckStep
  16. {
  17. Chuck,
  18. ChuckWait,
  19. End
  20. }
  21. #region 内部变量
  22. private PufVacuum _pufVacuum;
  23. private bool _chuck;
  24. #endregion
  25. /// <summary>
  26. /// 构造函数
  27. /// </summary>
  28. /// <param name="module"></param>
  29. public PufChuckRoutine(string module) : base(module)
  30. {
  31. _pufVacuum= DEVICE.GetDevice<PufVacuum>($"{Module}.Vacuum");
  32. }
  33. /// <summary>
  34. /// 中止
  35. /// </summary>
  36. public void Abort()
  37. {
  38. Runner.Stop("Manual abort");
  39. }
  40. /// <summary>
  41. /// 监控
  42. /// </summary>
  43. /// <returns></returns>
  44. public RState Monitor()
  45. {
  46. Runner.Run(ChuckStep.Chuck, Chuck, _delay_1ms)
  47. .Wait(ChuckStep.ChuckWait, CheckChuck, _delay_5s)
  48. .End(ChuckStep.End, NullFun, _delay_1ms);
  49. return Runner.Status;
  50. }
  51. /// <summary>
  52. /// chuck操作
  53. /// </summary>
  54. /// <returns></returns>
  55. private bool Chuck()
  56. {
  57. if (_chuck)
  58. {
  59. return _pufVacuum.ChuckOn();
  60. }
  61. else
  62. {
  63. return _pufVacuum.ChuckOff();
  64. }
  65. }
  66. /// <summary>
  67. /// 检验chuck
  68. /// </summary>
  69. /// <returns></returns>
  70. private bool CheckChuck()
  71. {
  72. if (_chuck)
  73. {
  74. return _pufVacuum.CheckChuckOut();
  75. }
  76. else
  77. {
  78. return _pufVacuum.CheckChuckIn();
  79. }
  80. }
  81. /// <summary>
  82. /// 启动
  83. /// </summary>
  84. /// <param name="objs"></param>
  85. /// <returns></returns>
  86. public RState Start(params object[] objs)
  87. {
  88. _chuck=(bool)objs[0];
  89. return Runner.Start(Module, "Chuck");
  90. }
  91. }
  92. }