EventTask.cs 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101
  1. using Aitex.Sorter.Common;
  2. using Efem;
  3. using Efem.Protocol;
  4. using System;
  5. namespace EFEM.RT.Tasks
  6. {
  7. public class SetEventTask : CheckImp, ITask
  8. {
  9. public SetEventTask()
  10. {
  11. HasInfoMessage = false;
  12. }
  13. public bool Execute(out string result, params string[] args)
  14. {
  15. string device = DeviceName.System;
  16. EfemEventType type;
  17. if (!Enum.TryParse(args[0], out type))
  18. {
  19. result = PARAM_NG;
  20. return false;
  21. }
  22. EfemEventValue value;
  23. if (!Enum.TryParse(args[1], out value))
  24. {
  25. result = PARAM_NG;
  26. return false;
  27. }
  28. if (!Check<NoReadyPolicy>(device, out result))
  29. {
  30. return false;
  31. }
  32. if (!Check<MaintenancePolicy>(device, out result))
  33. {
  34. return false;
  35. }
  36. SystemServerModule entity = (SystemServerModule)GetEntity(device);
  37. entity.SetEvent(type, value);
  38. return true;
  39. }
  40. public bool? Monitor(out string result, params string[] args)
  41. {
  42. result = string.Empty;
  43. return true;
  44. }
  45. }
  46. public class QueryEventTask : CheckImp, ITask
  47. {
  48. public QueryEventTask()
  49. {
  50. }
  51. public bool Execute(out string result, params string[] args)
  52. {
  53. string device = DeviceName.System;
  54. EfemEventType type;
  55. if (!Enum.TryParse(args[0], out type))
  56. {
  57. result = PARAM_NG;
  58. return false;
  59. }
  60. EfemEventValue value;
  61. if (!Enum.TryParse(args[1], out value))
  62. {
  63. result = PARAM_NG;
  64. return false;
  65. }
  66. if (!Check<NoReadyPolicy>(device, out result))
  67. {
  68. return false;
  69. }
  70. return true;
  71. }
  72. public bool? Monitor(out string result, params string[] args)
  73. {
  74. result = "ON";
  75. EfemEventType type;
  76. Enum.TryParse(args[0], out type);
  77. SystemServerModule entity = (SystemServerModule)GetEntity(DeviceName.System);
  78. if (entity.IsEventEnabled(type))
  79. result = string.Format("ON");
  80. else
  81. result = string.Format("OFF");
  82. return true;
  83. }
  84. }
  85. }