Du kan inte välja fler än 25 ämnen Ämnen måste starta med en bokstav eller siffra, kan innehålla bindestreck ('-') och vara max 35 tecken långa.

94 rader
2.7 KiB

  1. using Glorysoft.SECS.EQP.Common;
  2. using System;
  3. using System.Collections.Generic;
  4. using System.Linq;
  5. using System.Reflection;
  6. using System.Text;
  7. using System.Threading.Tasks;
  8. namespace ARI.EAP.HOST.Common
  9. {
  10. public static class EquipmentStatus
  11. {
  12. public static string S5F3 { get; set; } = "AlarmEnable";
  13. public static bool S1F1FuntionStatus { get; set; } = false;
  14. public static ushort SpoolingFlag { get; set; } = 0;
  15. public static Dictionary<string, IEventHandler> EventHandlers { get; set; }
  16. public static ushort commandCount { get; set; } = 0;
  17. public static bool initStatus { get; set; } = false;
  18. public static MESHeartBit mESHeartBit;
  19. public static SocketClient socketClient;
  20. public static S1F1HeartBit S1F1HeartBit;
  21. private static string _MQstate = ConnectState.disconnected;
  22. private static string _EqConnectState = ConnectState.disconnected;
  23. private static RunState _EapState = RunState.Stop;
  24. public static string MQstate
  25. {
  26. get { return _MQstate; }
  27. set
  28. {
  29. if (!_MQstate.Equals(value))
  30. {
  31. _MQstate = value;
  32. Global.MF.MQConnectStatusSet(value);
  33. PublishStatus();
  34. }
  35. }
  36. }
  37. public static string EqConnectState
  38. {
  39. get { return _EqConnectState; }
  40. set
  41. {
  42. if (!_EqConnectState.Equals(value))
  43. {
  44. _EqConnectState = value;
  45. Global.MF.ConnectStatusSet(value);
  46. PublishStatus();
  47. }
  48. }
  49. }
  50. public static RunState EapState
  51. {
  52. get { return _EapState; }
  53. set
  54. {
  55. if (!_EapState.Equals(value))
  56. {
  57. _EapState = value;
  58. PublishStatus();
  59. }
  60. }
  61. }
  62. static EquipmentStatus()
  63. {
  64. mESHeartBit = new MESHeartBit();
  65. socketClient = new SocketClient();
  66. S1F1HeartBit = new S1F1HeartBit();
  67. EventHandlers = new Dictionary<string, IEventHandler>();
  68. foreach (Type item in MethodBase.GetCurrentMethod().DeclaringType.Assembly.GetTypes())
  69. {
  70. if (item.IsClass && item.GetInterface(nameof(IEventHandler)) != null)
  71. {
  72. EventHandlers.Add(item.Name, Activator.CreateInstance(item) as IEventHandler);
  73. }
  74. }
  75. }
  76. static void PublishStatus() {
  77. Task.Run(() => mESHeartBit.Method());
  78. }
  79. }
  80. }