EventTask.cs 2.3 KB

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