终端一体化运控平台
Não pode escolher mais do que 25 tópicos Os tópicos devem começar com uma letra ou um número, podem incluir traços ('-') e podem ter até 35 caracteres.
 
 
 

108 linhas
3.9 KiB

  1. using BPASmartClient.Model.咖啡机.Enum;
  2. using System;
  3. using System.Collections.Generic;
  4. using System.Linq;
  5. using System.Text;
  6. using System.Threading.Tasks;
  7. namespace BPASmartClient.KLMCoffee.Protocal
  8. {
  9. public class SystemStatusModel :BitValue
  10. {
  11. /// <summary>
  12. /// 系统状态
  13. /// </summary>
  14. public K95SysTemStatus temStatus { get; set; }
  15. /// <summary>
  16. /// 饮品类型
  17. /// </summary>
  18. public DrinkType drinkType { get; set; }
  19. /// <summary>
  20. /// 制作状态
  21. /// </summary>
  22. public MakeStatus makeStatus { get; set; }
  23. /// <summary>
  24. /// 当前任务
  25. /// </summary>
  26. public TaskIndex taskIndex { get; set; }
  27. /// <summary>
  28. /// 当前进度 10%
  29. /// </summary>
  30. public int progress { get; set; }
  31. /// <summary>
  32. /// 故障信息
  33. /// </summary>
  34. public FaultMessage faultMessage { get; set; }
  35. /// <summary>
  36. /// 保养信息
  37. /// </summary>
  38. public UpkeepMessage upkeepMessage { get; set; }
  39. public SystemStatusModel(string cmd)
  40. {
  41. // 去掉字符串首尾处的空格
  42. if (string.IsNullOrEmpty(cmd) || cmd.Length < 32)
  43. return;
  44. string str = cmd.Trim().Replace(@"\","").Replace("r","").Replace(@"R","").Replace(@"n","").Replace(@"N","");
  45. int length = str.Length;
  46. str = str.Substring(5,length - 7);
  47. try
  48. {
  49. string systemStatus = str.Substring(0,4);//系统状态
  50. string makeSta = str.Substring(4,4);//制作状态
  51. string makeProgress = str.Substring(8,4);//制作进度
  52. string makeProgress1 = str.Substring(12,4);//制作进度
  53. byte ErrorH = (byte)Convert.ToInt32(str.Substring(16,2),16);//故障信息
  54. byte ErrorL = (byte)Convert.ToInt32(str.Substring(18,2),16);//故障信息
  55. byte InFormation = (byte)Convert.ToInt32(str.Substring(20,1),16);//保养信息
  56. System.Array values = System.Enum.GetValues(typeof(K95SysTemStatus));
  57. string[] nameList = System.Enum.GetNames(typeof(K95SysTemStatus));
  58. string[] sds = Enum.GetNames(typeof(K95SysTemStatus));
  59. foreach (var item in Enum.GetNames(typeof(K95SysTemStatus)))
  60. {
  61. if (systemStatus.Substring(0,1) == ((K95SysTemStatus)Enum.Parse(typeof(K95SysTemStatus),item)).GetString())
  62. temStatus = ((K95SysTemStatus)Enum.Parse(typeof(K95SysTemStatus),item));
  63. }
  64. foreach (var item in Enum.GetNames(typeof(DrinkType)))
  65. {
  66. if ("0" + makeSta.Substring(0,1) == ((DrinkType)Enum.Parse(typeof(DrinkType),item)).GetString())
  67. drinkType = ((DrinkType)Enum.Parse(typeof(DrinkType),item));
  68. }
  69. foreach (var item in Enum.GetNames(typeof(MakeStatus)))
  70. {
  71. if (makeSta.Substring(1,1) == ((MakeStatus)Enum.Parse(typeof(MakeStatus),item)).GetString())
  72. makeStatus = ((MakeStatus)Enum.Parse(typeof(MakeStatus),item));
  73. }
  74. foreach (var item in Enum.GetNames(typeof(TaskIndex)))
  75. {
  76. if (makeSta.Substring(2,1) == ((TaskIndex)Enum.Parse(typeof(TaskIndex),item)).GetString())
  77. taskIndex = ((TaskIndex)Enum.Parse(typeof(TaskIndex),item));
  78. }
  79. if (makeProgress1 != "0000")
  80. progress = Convert.ToInt32(makeProgress,16) / Convert.ToInt32(makeProgress1,16);
  81. faultMessage = new FaultMessage(ErrorL,ErrorH);
  82. upkeepMessage = new UpkeepMessage(InFormation);
  83. }
  84. catch (Exception ex)
  85. {
  86. }
  87. }
  88. }
  89. }