终端一体化运控平台
Du kannst nicht mehr als 25 Themen auswählen Themen müssen entweder mit einem Buchstaben oder einer Ziffer beginnen. Sie können Bindestriche („-“) enthalten und bis zu 35 Zeichen lang sein.

MorkIStatus.cs 4.1 KiB

vor 2 Jahren
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131
  1. using BPASmartClient.GSIceCream;
  2. using BPASmartClient.Helper;
  3. using BPASmartClient.Message;
  4. using BPASmartClient.Model.冰淇淋.Enum;
  5. using System;
  6. using System.Collections.Generic;
  7. using System.Linq;
  8. using System.Text;
  9. using System.Threading.Tasks;
  10. using static BPASmartClient.GSIceCream.MessageDefine;
  11. namespace BPASmartClient.GSIceCream
  12. {
  13. public class MorkIStatus : Singleton<MorkIStatus>
  14. {
  15. private DateTime lastRefreshTime = DateTime.MinValue;
  16. /// <summary>
  17. /// 是否在线
  18. /// </summary>
  19. public bool OnLine { get { return DateTime.Now.Subtract(lastRefreshTime).TotalSeconds <= 3; } }
  20. /// <summary>
  21. /// 预冷温度
  22. /// </summary>
  23. public short YLWD { get; set; }
  24. /// <summary>
  25. /// 回气温度
  26. /// </summary>
  27. public short HQWD { get; set; }
  28. /// <summary>
  29. /// 环境温度
  30. /// </summary>
  31. public short HJWD { get; set; }
  32. /// <summary>
  33. /// 电流
  34. /// </summary>
  35. public short DL { get; set; }
  36. /// <summary>
  37. /// 电压
  38. /// </summary>
  39. public short DY { get; set; }
  40. /// <summary>
  41. /// 当前模式
  42. /// </summary>
  43. public MORKI_MODE CurrentMode { get; set; }
  44. /// <summary>
  45. /// 故障
  46. /// </summary>
  47. public MORKI_FAULT Fault { get; set; }
  48. /// <summary>
  49. /// 成型比
  50. /// </summary>
  51. public byte CXB { get; set; }
  52. /// <summary>
  53. /// 成型比(门限)
  54. /// </summary>
  55. public byte CXB_Threshold { get; set; }
  56. /// <summary>
  57. /// 打料完成(完成为true,正在打料为false)
  58. /// </summary>
  59. public bool DLCompleted { get; set; }
  60. public bool CanDo
  61. {
  62. get
  63. {
  64. if (!OnLine)
  65. return false;
  66. if (Fault != MORKI_FAULT.未发生故障)
  67. return false;
  68. if (CXB < CXB_Threshold)
  69. return false;
  70. return true;
  71. }
  72. }
  73. private void ProcessHeart(ICMSG_Heart_UP heartUpMsg)
  74. {
  75. CurrentMode = heartUpMsg.MS;
  76. YLWD = BitConverter.ToInt16(new byte[] { heartUpMsg.YLWD_L, heartUpMsg.YLWD_H }, 0);
  77. HQWD = BitConverter.ToInt16(new byte[] { heartUpMsg.HQWD_L, heartUpMsg.HQWD_H }, 0);
  78. HJWD = BitConverter.ToInt16(new byte[] { heartUpMsg.HJWD_L, heartUpMsg.HJWD_H }, 0);
  79. DL = BitConverter.ToInt16(new byte[] { heartUpMsg.DL_L, heartUpMsg.DL_H }, 0);
  80. Fault = (MORKI_FAULT)BitConverter.ToInt16(new byte[] { heartUpMsg.GZ_L, heartUpMsg.GZ_H }, 0);
  81. CXB = heartUpMsg.CXB;
  82. DLCompleted = (heartUpMsg.DLTJ >> 4 & 1) == 1;
  83. if (RTrig.GetInstance("打料完成检测").Start(DLCompleted))
  84. {
  85. MessageLog.GetInstance.Show("打料完成");
  86. }
  87. if (RTrig.GetInstance("打料中检测").Start(!DLCompleted))
  88. {
  89. MessageLog.GetInstance.Show("打料中");
  90. }
  91. //MessageLog.GetInstance.Show(string.Format("当前模式为:{0}", CurrentMode));
  92. }
  93. private void ProcessModeUp(ICMSG_MODE_UP modeUpMsg)
  94. {
  95. MessageLog.GetInstance.Show(string.Format("模式返回为:{0}", modeUpMsg.Mode));
  96. }
  97. public void ProcessMsg(byte[] data)
  98. {
  99. lastRefreshTime = DateTime.Now;
  100. try
  101. {
  102. if (data.Length < 5)
  103. return;
  104. switch (data[2])
  105. {
  106. case (byte)IC_CMD.HEART:
  107. var msg = IcPack.ByteToStructure<ICMSG_Heart_UP>(data.ToArray());
  108. ProcessHeart(msg);
  109. break;
  110. case (byte)IC_CMD.MODE:
  111. var modeUp = IcPack.ByteToStructure<ICMSG_MODE_UP>(data.ToArray());
  112. ProcessModeUp(modeUp);
  113. break;
  114. }
  115. }
  116. catch (Exception ex)
  117. {
  118. }
  119. }
  120. }
  121. }