HoldTask.cs 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  1. using Aitex.Core.RT.Device;
  2. using Aitex.Core.Util;
  3. using Aitex.Sorter.Common;
  4. using Aitex.Sorter.RT.EFEMs.Servers;
  5. using MECF.Framework.RT.EquipmentLibrary.HardwareUnits.Robot;
  6. namespace Aitex.Sorter.RT.EFEMs.Tasks
  7. {
  8. public class HoldTask : CheckImp, ITask
  9. {
  10. public HoldTask()
  11. {
  12. }
  13. public bool Execute(out string result, params string[] args)
  14. {
  15. string device = DeviceName.Robot;
  16. if (!Check<NoReadyPolicy>(device, out result))
  17. {
  18. return false;
  19. }
  20. if (!Check<NoInitCompletedPolicy>(device, out result))
  21. {
  22. return false;
  23. }
  24. if (!Check<NoOriginCompletedPolicy>(device, out result))
  25. {
  26. return false;
  27. }
  28. if (!Check<EMSPolicy>(device, out result))
  29. {
  30. return false;
  31. }
  32. if (!Check<ErrorPolicy>(device, out result))
  33. {
  34. return false;
  35. }
  36. if (!Check<NoMovingPolicy>(device, out result))
  37. {
  38. return false;
  39. }
  40. if (!Check<HoldPolicy>(device, out result))
  41. {
  42. return false;
  43. }
  44. if (!Check<MaintenancePolicy>(device, out result))
  45. {
  46. return false;
  47. }
  48. if (!Check<PowerDownPolicy>(device, out result))
  49. {
  50. return false;
  51. }
  52. Robot robot = DEVICE.GetDevice<Robot>(device);
  53. if (!robot.Busy)
  54. {
  55. result = "NOTINMOTION";
  56. return false;
  57. }
  58. if (!robot.Stop(false, out result))
  59. {
  60. return false;
  61. }
  62. Singleton<EfemEntity>.Instance.SetSystemHold();
  63. return true;
  64. }
  65. public bool? Monitor(out string result, params string[] args)
  66. {
  67. result = string.Empty;
  68. string device = DeviceName.Robot;
  69. Robot robot = DEVICE.GetDevice<Robot>(device);
  70. if (robot.Error)
  71. {
  72. return false;
  73. }
  74. if (!robot.Moving)
  75. {
  76. return true;
  77. }
  78. return null;
  79. }
  80. }
  81. }