HomeTask.cs 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157
  1. using Aitex.Core.RT.Device;
  2. using Aitex.Core.Util;
  3. using Aitex.Sorter.Common;
  4. using Efem;
  5. using MECF.Framework.Common.Equipment;
  6. using MECF.Framework.RT.EquipmentLibrary.HardwareUnits.LoadPorts.LoadPortBase;
  7. using MECF.Framework.RT.EquipmentLibrary.HardwareUnits.Robots.RobotBase;
  8. namespace EFEM.RT.Tasks
  9. {
  10. public class HomeTask : CheckImp, ITask
  11. {
  12. public HomeTask()
  13. {
  14. }
  15. public bool Execute(out string result, params string[] args)
  16. {
  17. result = string.Empty;
  18. string device = Args2Unit(args.Length > 0 ?args[0]:string.Empty);
  19. if (string.IsNullOrEmpty(device))
  20. {
  21. result = PARAM_NG;
  22. return false;
  23. }
  24. IServerModule entity = GetEntity(device);
  25. if (entity == null || !(entity is RobotServerModule || entity is LoadPortServerModule || entity is BufferServerModule))
  26. {
  27. result = PARAM_NG;
  28. return false;
  29. }
  30. if (!Check<NoReadyPolicy>(device, out result))
  31. {
  32. return false;
  33. }
  34. if (!Check<NoInitCompletedPolicy>(device, out result))
  35. {
  36. return false;
  37. }
  38. if (!Check<NoOriginCompletedPolicy>(device, out result))
  39. {
  40. return false;
  41. }
  42. if (!Check<VacPolicy>(device, out result))
  43. {
  44. return false;
  45. }
  46. if (!Check<AirPolicy>(device, out result))
  47. {
  48. return false;
  49. }
  50. if (!Check<EMSPolicy>(device, out result))
  51. {
  52. return false;
  53. }
  54. if (!Check<ErrorPolicy>(device, out result))
  55. {
  56. return false;
  57. }
  58. if (!Check<InitBusyPolicy>(device, out result))
  59. {
  60. return false;
  61. }
  62. if (!Check<HoldPolicy>(device, out result))
  63. {
  64. return false;
  65. }
  66. if (!Check<MaintenancePolicy>(device, out result))
  67. {
  68. return false;
  69. }
  70. if (!Check<LinkPolicy>(device, out result))
  71. {
  72. return false;
  73. }
  74. if (!Check<ArmExtendPolicy>(device, out result))
  75. {
  76. return false;
  77. }
  78. if (!Check<PowerDownPolicy>(device, out result))
  79. {
  80. return false;
  81. }
  82. entity.Initialized = false;
  83. if (!entity.Home(out result))
  84. {
  85. return false;
  86. }
  87. return true;
  88. }
  89. public bool? Monitor(out string result, params string[] args)
  90. {
  91. result = string.Empty;
  92. string device = Args2Unit(args.Length > 0 ?args[0]:string.Empty);
  93. IServerModule entity = GetEntity(device);
  94. if (entity.Error)
  95. {
  96. flag1 = ErrorCheckList1.VAC | ErrorCheckList1.AIR | ErrorCheckList1.STALL
  97. | ErrorCheckList1.LIMIT | ErrorCheckList1.SENSOR | ErrorCheckList1.POSITION | ErrorCheckList1.EMS
  98. | ErrorCheckList1.COMM | ErrorCheckList1.COMM2 | ErrorCheckList1.VACON | ErrorCheckList1.VACOFF
  99. | ErrorCheckList1.CLAMPON | ErrorCheckList1.CLAMPOF;
  100. flag2 = ErrorCheckList2.RRTWAF | ErrorCheckList2.CRSWAF | ErrorCheckList2.THICKWAF | ErrorCheckList2.THINWAF
  101. | ErrorCheckList2.DBLWAF | ErrorCheckList2.BAOWAF | ErrorCheckList2.COMMAND | ErrorCheckList2.PODNG
  102. | ErrorCheckList2.PODMISMATCH | ErrorCheckList2.VAC_S | ErrorCheckList2.CLAMP_S | ErrorCheckList2.SAFTY
  103. | ErrorCheckList2.LOCKNG | ErrorCheckList2.UNLOCKNG | ErrorCheckList2.L_KEY_LK | ErrorCheckList2.L_KEY_UL;
  104. flag3 = ErrorCheckList3.MAP_S | ErrorCheckList3.MAP_S1 | ErrorCheckList3.MAP_S2 | ErrorCheckList3.WAFLOST
  105. | ErrorCheckList3.ALIGNNG
  106. | ErrorCheckList3.DRIVER | ErrorCheckList3.DRPOWERDOWN | ErrorCheckList3.HARDWARE
  107. | ErrorCheckList3.INTERNAL | ErrorCheckList3.E84_TIMEOUTx | ErrorCheckList3.E84_CS_VALID | ErrorCheckList3.READFAIL;
  108. return CheckError(device, out result);
  109. }
  110. if (!entity.Busy)
  111. {
  112. if (ModuleHelper.IsLoadPort(ModuleHelper.Converter(device)))
  113. {
  114. var lp = DEVICE.GetDevice<LoadPortBaseDevice>(device);
  115. if (lp.IsHomed)
  116. {
  117. entity.Initialized = true;
  118. Singleton<EfemEntity>.Instance.SendSigStatEvent(ModuleHelper.Converter(device));
  119. return true;
  120. }
  121. else return null;
  122. }else if (ModuleHelper.IsRobot(ModuleHelper.Converter(device)))
  123. {
  124. RobotBaseDevice _device = DEVICE.GetDevice<RobotBaseDevice>(DeviceName.Robot);
  125. if (_device.IsReady())
  126. {
  127. entity.Initialized = true;
  128. return true;
  129. }
  130. else
  131. return null;
  132. }
  133. else
  134. {
  135. entity.Initialized = true;
  136. return true;
  137. }
  138. }
  139. return null;
  140. }
  141. }
  142. }