XiaomiMqttClient_StationInputBegin.cs 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125
  1. using Newtonsoft.Json;
  2. namespace MainForm.ClassFile.XiaomiAPI
  3. {
  4. /// <summary>
  5. /// 小米 MqttClient类 - API拓展方法
  6. /// 节拍⽇志(OEE)
  7. /// • 节拍发⽣时上传
  8. /// 上料开始->上料结束->作业开始->作业结束->下料开始->下料结束
  9. /// </summary>
  10. public partial class XiaomiMqttClient_Extend : XiaomiMqttClient
  11. {
  12. /// <summary>
  13. /// 节拍⽇志(OEE)- 事件Id
  14. /// 上料开始->上料结束->作业开始->作业结束->下料开始->下料结束
  15. /// 上料开始:beat_log/business/OEE/station_input_begin
  16. /// 上料结束:beat_log/business/OEE/station_input_end
  17. /// 作业开始:beat_log/business/OEE/station_work_begin
  18. /// 作业结束:beat_log/business/OEE/station_work_end
  19. /// 下料开始:beat_log/business/OEE/station_output_begin
  20. /// 下料结束:beat_log/business/OEE/station_output_end
  21. /// </summary>
  22. private static string StationInputBeginId { get; set; } = "beat_log/business/OEE/{0}";
  23. /// <summary>
  24. /// 节拍⽇志(OEE)- 事件方法
  25. /// XiaomiDeviceState
  26. /// </summary>
  27. /// <param name="msg">事件数据;Json</param>
  28. /// <param name="dataId">自定义事件Id;如:guid</param>
  29. /// <returns></returns>
  30. public static int Write_StationInputBegin(StationInputBeginRequest request, string dataId = "")
  31. {
  32. int result = 0;
  33. string msg = JsonConvert.SerializeObject(request);
  34. byte[] bytes = ToUTF8(msg);
  35. request.action = string.Format(StationInputBeginId, request.action);
  36. // 发送
  37. if (string.IsNullOrEmpty(dataId))
  38. result = Write(request.action, bytes);
  39. else
  40. result = WriteWithDataId(request.action, bytes, dataId);
  41. return result;
  42. }
  43. /// <summary>
  44. /// 节拍⽇志(OEE)- 参数
  45. /// </summary>
  46. public class StationInputBeginRequest
  47. {
  48. /// <summary>
  49. /// 节拍动作(XiaomiDeviceOEE)
  50. /// string[1,64]
  51. /// 上料开始:beat_log/business/OEE/station_input_begin
  52. /// 上料结束:beat_log/business/OEE/station_input_end
  53. /// 作业开始:beat_log/business/OEE/station_work_begin
  54. /// 作业结束:beat_log/business/OEE/station_work_end
  55. /// 下料开始:beat_log/business/OEE/station_output_begin
  56. /// 下料结束:beat_log/business/OEE/station_output_end
  57. /// </summary>
  58. public string action { get; set; } = string.Empty;
  59. /// <summary>
  60. /// 节拍发⽣时间
  61. /// string[1,32]
  62. /// 时间,精确到毫秒。如:2022-06-01 14:27:57.283
  63. /// </summary>
  64. public string beat_tm { get; set; } = string.Empty;
  65. /// <summary>
  66. /// 该动作操作的⽬标对象(SN)
  67. /// string[1,64]
  68. /// </summary>
  69. public string action_subject { get; set; } = string.Empty;
  70. /// <summary>
  71. /// ⼤板SN/载具SN
  72. /// 若使用虚拟SN,虚拟SN格式为:SN-编号
  73. /// string[1,64]
  74. /// </summary>
  75. public string action_subject_parent { get; set; } = string.Empty;
  76. /// <summary>
  77. /// 该动作的位置信息(⼯位、槽位),如:F06-GSTPLA11_01-SLOT-01
  78. /// string[1,32]
  79. /// ⼯位
  80. /// </summary>
  81. public string action_location { get; set; } = string.Empty;
  82. /// <summary>
  83. /// 该动作的物料信息
  84. /// string[1,256]
  85. /// 若动作的位置信息有多级,则考虑使⽤"_"分隔,如:"⼯位号_槽位号"
  86. /// </summary>
  87. public string action_material { get; set; } = string.Empty;
  88. /// <summary>
  89. /// 额外信息
  90. /// ⽤于携带额外信息
  91. /// </summary>
  92. public string extra { get; set; } = string.Empty;
  93. /// <summary>
  94. /// 数据字典中定义的分类层级1
  95. /// string[1,64]
  96. /// </summary>
  97. public string class_level_1 { get; set; } = string.Empty;
  98. /// <summary>
  99. /// 数据字典中定义的分类层级2
  100. /// string[1,64]
  101. /// </summary>
  102. public string class_level_2 { get; set; } = string.Empty;
  103. /// <summary>
  104. /// 数据字典中定义的分类层级3
  105. /// string[1,64]
  106. /// </summary>
  107. public string class_level_3 { get; set; } = string.Empty;
  108. }
  109. }
  110. }