RoutineBase.cs 2.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. using Aitex.Core.RT.Log;
  2. using DocumentFormat.OpenXml.Wordprocessing;
  3. using MECF.Framework.Common.Equipment;
  4. using System;
  5. using System.Collections.Generic;
  6. using System.Diagnostics;
  7. using System.Linq;
  8. using System.Reflection;
  9. using System.Text;
  10. using System.Threading.Tasks;
  11. namespace MECF.Framework.Common.Routine
  12. {
  13. public class RoutineBase
  14. {
  15. private string _errmsg = "";
  16. public string Module { get; }
  17. public bool NullFun() => true;
  18. protected RoutineRunner Runner = new RoutineRunner();
  19. public string ErrorMsg { get { return string.IsNullOrEmpty(_errmsg) ? Runner.ErrorMsg : _errmsg; } set { _errmsg = value; } }
  20. public int ErrorStep { get; set; }
  21. /// <summary>
  22. /// 运行时长
  23. /// </summary>
  24. public long ElapsedMilliseconds { get { return Runner.ElapsedMS; } }
  25. protected readonly int _delay_1ms = 1;
  26. protected readonly int _delay_50ms = 50;
  27. protected readonly int _delay_1s = 1000;
  28. protected readonly int _delay_2s = 2000;
  29. protected readonly int _delay_3s = 3000;
  30. protected readonly int _delay_4s = 4000;
  31. protected readonly int _delay_5s = 5000;
  32. protected readonly int _delay_10s = 10000;
  33. protected readonly int _delay_20s = 20000;
  34. protected readonly int _delay_30s = 30000;
  35. protected readonly int _delay_60s = 60000;
  36. protected readonly int _delay_2m = 120000;
  37. protected readonly int _delay_3m = 180000;
  38. protected readonly int _delay_5m = 300000;
  39. /// <summary>
  40. /// 当前执行到循环哪一步
  41. /// </summary>
  42. public string CurrentStep
  43. {
  44. get { return Runner.CurrentStep.ToString(); }
  45. }
  46. public RoutineBase(string module)
  47. {
  48. Module = module;
  49. Runner.Reset();
  50. }
  51. public void Reset()
  52. {
  53. Runner.Reset();
  54. }
  55. /// <summary>
  56. /// 通知错误
  57. /// </summary>
  58. /// <param name="eEvent"></param>
  59. /// <param name="message"></param>
  60. /// <param name="isPostError"></param>
  61. public void NotifyError(eEvent eEvent, string message,int step)
  62. {
  63. LOG.WriteLog(eEvent, Module, message);
  64. _errmsg = message;
  65. ErrorStep = step;
  66. }
  67. }
  68. }