GotoTask.cs 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125
  1. using Aitex.Core.RT.Device;
  2. using Aitex.Core.RT.Event;
  3. using Aitex.Core.Util;
  4. using Aitex.Sorter.Common;
  5. using Aitex.Sorter.RT.EFEMs.Servers;
  6. using MECF.Framework.Common.Equipment;
  7. using MECF.Framework.RT.EquipmentLibrary.HardwareUnits.Robot;
  8. namespace Aitex.Sorter.RT.EFEMs.Tasks
  9. {
  10. public class GotoTask : RobotImp, ITask
  11. {
  12. public GotoTask()
  13. {
  14. }
  15. public bool Execute(out string result, params string[] args)
  16. {
  17. string device = DeviceName.Robot;
  18. IServerModule entity = GetEntity(device);
  19. ModuleName target = ModuleName.System;
  20. int slot = 1;
  21. if (!ParseMoveTarget(args[0], out target, out slot))
  22. {
  23. result = PARAM_NG;
  24. return false;
  25. }
  26. Hand arm = Hand.Blade2;
  27. if (!ParseMoveArm(args[1], out arm))
  28. {
  29. result = PARAM_NG;
  30. return false;
  31. }
  32. //for goto, only assign lower arm
  33. if (arm == Hand.Both)
  34. arm = Hand.Blade1;
  35. MovePosition pos = MovePosition.UP;
  36. if (!ParseMovePosition(args[2], out pos))
  37. {
  38. result = PARAM_NG;
  39. return false;
  40. }
  41. var isPick = true;
  42. isPick = pos == MovePosition.DOWN;
  43. if (!Check<NoReadyPolicy>(device, out result))
  44. {
  45. return false;
  46. }
  47. if (!Check<NoInitCompletedPolicy>(device, out result))
  48. {
  49. return false;
  50. }
  51. if (!Check<NoOriginCompletedPolicy>(device, out result))
  52. {
  53. return false;
  54. }
  55. if (!Check<VacPolicy>(device, out result))
  56. {
  57. return false;
  58. }
  59. if (!Check<EMSPolicy>(device, out result))
  60. {
  61. return false;
  62. }
  63. if (!Check<ErrorPolicy>(device, out result))
  64. {
  65. return false;
  66. }
  67. if (!Check<BusyPolicy>(device, out result))
  68. {
  69. return false;
  70. }
  71. if (!Check<HoldPolicy>(device, out result))
  72. {
  73. return false;
  74. }
  75. if (!Check<RemovePolicy>(device, out result))
  76. {
  77. return false;
  78. }
  79. if (!Check<MaintenancePolicy>(device, out result))
  80. {
  81. return false;
  82. }
  83. if (!Check<LinkPolicy>(device, out result))
  84. {
  85. return false;
  86. }
  87. if (!Check<PowerDownPolicy>(device, out result))
  88. {
  89. return false;
  90. }
  91. _token = Singleton<EfemEntity>.Instance.EfemDevice.Invoke("Goto", target.ToString(), slot - 1, arm);
  92. return true;
  93. }
  94. public bool? Monitor(out string result, params string[] args)
  95. {
  96. result = string.Empty;
  97. if (Singleton<EfemEntity>.Instance.EfemDevice.CheckIsError(ModuleName.Robot))
  98. {
  99. result = "ERROR";
  100. return false;
  101. }
  102. if (Singleton<EfemEntity>.Instance.EfemDevice.CheckIsIdle(ModuleName.Robot)
  103. && Singleton<EfemEntity>.Instance.EfemDevice.CheckIsIdle(ModuleName.System)
  104. && Singleton<EfemEntity>.Instance.EfemDevice.CheckAcked(_token))
  105. return true;
  106. return null;
  107. }
  108. }
  109. }