XiaomiMqttClient_PassStationLog.cs 6.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148
  1. using Newtonsoft.Json;
  2. using System;
  3. using System.Collections.Generic;
  4. namespace MainForm.ClassFile.XiaomiAPI
  5. {
  6. /// <summary>
  7. /// 小米 MqttClient类 - API拓展方法
  8. /// 过站明细
  9. /// 过站明细指的是与该产品的加⼯/检测相关的数据,其包括:
  10. /// ◦ 产品加⼯过程中的⼯艺参数(实际值)
  11. /// ◦ 具体测试项的明细(如果有),针对检测装备
  12. /// ◦ 治具信息,如载具、保压治具等
  13. /// ◦ 物料信息
  14. /// ◦ 软件版本
  15. ///
  16. /// • 加⼯站:需要上报⽣产过程所有关键⼯艺参数,除此之外,有的加⼯站会对结果进⾏检查,需要提供检测明细数据,检测规则,以及判断结果
  17. /// • 测试站:详细的测试结果,需要提供检测明细数据,检测规则,以及判断结果
  18. /// </summary>
  19. public partial class XiaomiMqttClient_Extend : XiaomiMqttClient
  20. {
  21. /// <summary>
  22. /// 过站明细- 事件Id
  23. /// </summary>
  24. private static string PassStationLogId { get; set; } = "pass_details_log/passing_station_log";
  25. /// <summary>
  26. /// 过站明细- 事件方法
  27. /// </summary>
  28. /// <param name="msg">事件数据;Json</param>
  29. /// <param name="dataId">自定义事件Id;如:guid</param>
  30. /// <returns></returns>
  31. public static int Write_PassStationLog(List<PassStationLogRequest> request, string dataId = "")
  32. {
  33. int result = 0;
  34. string msg = JsonConvert.SerializeObject(request);
  35. byte[] bytes = ToUTF8(msg);
  36. // 发送
  37. if (string.IsNullOrEmpty(dataId))
  38. result = Write(PassStationLogId, bytes);
  39. else
  40. result = WriteWithDataId(PassStationLogId, bytes, dataId);
  41. return result;
  42. }
  43. /// <summary>
  44. /// 过站明细- 参数
  45. /// ◦ function_name是对test_item进⾏分类聚合,同⼀类的test_item对应同⼀个function_name名称。
  46. /// ◦ test_item可以是装备作业过程中的检测项、算法参数、⼯艺参数等
  47. /// ◦ result_val可以是检测值/算法的输出值/⼯艺参数值
  48. /// ◦ description填写对应test_item的中⽂描述,⽤于描述这条数据的含义
  49. /// </summary>
  50. public class PassStationLogRequest
  51. {
  52. /// <summary>
  53. /// 过站唯⼀标识(36位)
  54. /// string[1,64]
  55. /// 要确保唯⼀性,每次过站时⽣成的ID必须唯⼀。
  56. /// • 对于同⼀次过站⽽⾔,过站明细中的pass_station_id字段值与过站结果中的pass_station_id字段值是⼀样的。
  57. /// • 与mes中的过站明细uuid字段uuidInspection要求⼀致(这两个值需确保是⼀致的,以MES为主,如果关闭MES⽣产,则此项传空字符串)
  58. /// </summary>
  59. public string pass_station_id { get; set; } = string.Empty;
  60. /// <summary>
  61. /// 产品SN
  62. /// string[1,64]
  63. /// </summary>
  64. public string sn { get; set; } = string.Empty;
  65. /// <summary>
  66. /// 槽位
  67. /// string[1,64]
  68. /// </summary>
  69. public string slot { get; set; } = string.Empty;
  70. /// <summary>
  71. /// 测试项序号
  72. /// string[1,32]
  73. /// ⽰例:1,2,递增
  74. /// </summary>
  75. public string test_item_num { get; set; } = string.Empty;
  76. /// <summary>
  77. /// 功能名称
  78. /// string[1,64]
  79. /// ⼤类(可以是检测⼤类或加⼯项⼤类),枚举值如下:
  80. /// • Machine_加⼯模块,加⼯相关的⼯艺参
  81. /// • Test_测试模块,检测项相关
  82. /// • Fixture_Process,治具信息
  83. /// • Material_Process,物料信息
  84. /// • Tool_Process,软件版本信息
  85. /// • File_Process,⽂件相关信息
  86. ///
  87. /// 命名要求(英文):
  88. /// ◦ 加⼯类命名要求:Machine_加⼯模块
  89. /// ◦ 检测类命名要求:Test_测试模块
  90. /// 例如:Machine_Attach、Test_Acc
  91. /// </summary>
  92. public string function_name { get; set; } = string.Empty;
  93. /// <summary>
  94. /// 测试项
  95. /// string[1,32]
  96. /// key(⼩类,可以是检测项名称或⼯艺参数名称);英文
  97. /// </summary>
  98. public string test_item { get; set; } = string.Empty;
  99. /// <summary>
  100. /// 测试值/输出值
  101. /// string[1,32]
  102. /// value(和测试项对应的值,可以是检测值/算法的输出值/⼯艺参数值)
  103. /// </summary>
  104. public string result_val { get; set; } = string.Empty;
  105. /// <summary>
  106. /// 上限值
  107. /// string[1,32]
  108. /// </summary>
  109. public string hi_limit { get; set; } = string.Empty;
  110. /// <summary>
  111. /// 下限值
  112. /// string[1,32]
  113. /// </summary>
  114. public string low_limit { get; set; } = string.Empty;
  115. /// <summary>
  116. /// 测试状态
  117. /// string[1,32]
  118. /// PASS/FAIL
  119. /// </summary>
  120. public string status { get; set; } = "PASS";
  121. /// <summary>
  122. /// 单项测试时间
  123. /// string[1,32]
  124. /// 格式:0.000000
  125. /// </summary>
  126. public string test_time { get; set; } = string.Empty;
  127. /// <summary>
  128. /// 错误码
  129. /// string[1,32]
  130. /// </summary>
  131. public string error_code { get; set; } = string.Empty;
  132. /// <summary>
  133. /// 描述
  134. /// string[1,32]
  135. /// 中⽂描述或说明备注信息
  136. /// </summary>
  137. public string project_code { get; set; } = string.Empty;
  138. }
  139. }
  140. }