终端一体化运控平台
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

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