IRoutine.cs 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. using Aitex.Core.RT.Event;
  2. using Aitex.Core.Util;
  3. using MECF.Framework.Common.Equipment;
  4. using MECF.Framework.Common.Routine;
  5. using System;
  6. using System.Collections.Generic;
  7. using System.Linq;
  8. using System.Text;
  9. namespace Aitex.Core.RT.Routine
  10. {
  11. public interface IRoutine
  12. {
  13. Result Start(params object[] objs);
  14. Result Monitor();
  15. void Abort();
  16. }
  17. public interface IStepRoutine
  18. {
  19. RState Start(params object[] objs);
  20. RState Monitor();
  21. void Abort();
  22. }
  23. public class ModuleRoutineBase
  24. {
  25. public string Module { get; set; }
  26. public string Name { get; set; }
  27. public bool NullFun() => true;
  28. protected RoutineRunner Runner = new RoutineRunner();
  29. protected DeviceTimer counter = new DeviceTimer();
  30. protected readonly int _delay_0s = 0;
  31. protected readonly int _delay_50ms = 50;
  32. protected readonly int _delay_1s = 1000;
  33. protected readonly int _delay_2s = 2000;
  34. protected readonly int _delay_3s = 3000;
  35. protected readonly int _delay_4s = 4000;
  36. protected readonly int _delay_5s = 5000;
  37. protected readonly int _delay_10s = 10000;
  38. protected readonly int _delay_20s = 20000;
  39. protected readonly int _delay_30s = 30000;
  40. protected readonly int _delay_60s = 60000;
  41. protected readonly int _delay_2m = 120000;
  42. protected readonly int _delay_3m = 180000;
  43. protected readonly int _delay_5m = 300000;
  44. public ModuleRoutineBase(string module)
  45. {
  46. Module = module;
  47. Runner.Reset();
  48. }
  49. protected void Notify(string message)
  50. {
  51. EV.PostInfoLog(Module, $"{Module} {Name}, {message}");
  52. }
  53. protected void Stop(string failReason)
  54. {
  55. EV.PostAlarmLog(Module, $"{Module} {Name} failed, {failReason}");
  56. }
  57. public void Reset()
  58. {
  59. counter.Start(60 * 60 * 100);
  60. Runner.Reset();
  61. }
  62. protected virtual bool DelayTime(int delayMS)
  63. {
  64. if (delayMS > 0) Notify($"Delay {delayMS/1000} seconds");
  65. return true;
  66. }
  67. }
  68. }