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.

306 lines
12 KiB

1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
  1. #pragma once
  2. #include <stdint.h>
  3. #define PROTOCOL_VERSION 1
  4. #define HEART_PACKET_PERIOD_MS (5 * 1000)
  5. extern "C" {
  6. #pragma pack(1)
  7. /**
  8. * @brief 12bit from,1bit emergency
  9. * H L
  10. * [1] [4bit] [8bit] [8bit] [4bit/4bit]
  11. * , from to frameNum/frameId
  12. */
  13. typedef struct {
  14. uint8_t frameNumAndFrameId;
  15. uint8_t to;
  16. uint8_t from;
  17. uint8_t pad;
  18. } zcanid_t;
  19. typedef struct {
  20. uint8_t ptype;
  21. uint8_t index;
  22. uint16_t function_id;
  23. uint8_t params[];
  24. } zcanbus_packet_t;
  25. #pragma pack()
  26. typedef enum {
  27. kcmd,
  28. kreceipt,
  29. kerror_receipt,
  30. kreport,
  31. } packet_type_t;
  32. typedef enum {
  33. kMainBoard = 0, // 主机
  34. kBoardType_LiquidCtrl = 1, // 液路板
  35. kBoardType_PowerControl = 2, // 电源板
  36. kBoardType_PowerControlMiniBoard = 3, // 电源控制Mini板,用于拉杆箱箱消毒机
  37. kBoardType_ExtBallValveCtrl = 4, // 外部球阀控制板
  38. kBoardType_H2O2Sensor = 5, // H2O2传感器板
  39. } BoardType_t;
  40. typedef enum {
  41. klarge_space_disinfection_machine = 1, // 大空间消毒机
  42. ksmall_space_disinfection_machine = 2, // 小空间消毒机
  43. kpipe_disinfection_machine = 3, // 管道式消毒机
  44. kdraw_bar_disinfection_box = 4, // 手持拉杆箱消毒机
  45. } ProjectID_t;
  46. typedef enum {
  47. kerr_noerror = 0,
  48. kerr_overtime = 1,
  49. // 驱动器错误
  50. kerr_motorReset = 100,
  51. kerr_motorUnkownError = 101,
  52. kerr_AirBlowerError = 200, // 空压机异常
  53. kerr_HeaterError = 201, // 加热片异常
  54. kerr_BlowerError = 202, // 鼓风机异常
  55. kerr_ProportionalValveError = 203, // 气密性测试专用空压机异常
  56. } ErrorCode_t;
  57. static inline const char *ErrorCodeToString(uint32_t code) {
  58. switch (code) {
  59. case kerr_noerror:
  60. return "no error";
  61. case kerr_motorReset:
  62. return "motor reset";
  63. case kerr_motorUnkownError:
  64. return "motor unkown error";
  65. case kerr_AirBlowerError:
  66. return "air blower error";
  67. case kerr_HeaterError:
  68. return "heater error";
  69. case kerr_BlowerError:
  70. return "blower error";
  71. case kerr_ProportionalValveError:
  72. return "proportional valve error";
  73. default:
  74. return "unkown error";
  75. }
  76. }
  77. typedef enum {
  78. /***********************************************************************************************************************
  79. * *
  80. ***********************************************************************************************************************/
  81. kcmd_read_board_info = 1, // cmd:no, ack:read_board_info_ack_t
  82. kcmd_force_report = 2, // cmd:no, ack:read_board_info_ack_t
  83. kreport_heatpacket = 50, // cmd:no ack:no report:heatpacket_t
  84. kreport_exception_error = 51, // report:error_code,subid
  85. /***********************************************************************************************************************
  86. * *
  87. ***********************************************************************************************************************/
  88. /**
  89. * (id,)
  90. *
  91. *
  92. * TMC参数
  93. * TMC参数
  94. * ihold,irun,idelay
  95. *
  96. */
  97. kcmd_pump_rotate = 100, // cmd: rpm
  98. kcmd_pump_stop = 101, // cmd: rpm
  99. kcmd_pump_set_subic_reg = 102, // cmd: add,val
  100. kcmd_pump_get_subic_reg = 103, // cmd: add,ack:val
  101. kcmd_pump_set_irun_ihold = 104, // cmd: irun,ihold,idelay
  102. /***********************************************************************************************************************
  103. * *
  104. ***********************************************************************************************************************/
  105. kcmd_triple_warning_light_ctl = 200, // cmd: r,g,b,warning
  106. /***********************************************************************************************************************
  107. * *
  108. ***********************************************************************************************************************/
  109. kreport_pressure_data = 300, // report:subid pressure(0.1pa)
  110. /***********************************************************************************************************************
  111. * H2O2传感器数值上报 *
  112. ***********************************************************************************************************************/
  113. kreport_h2o2_data = 400, // report:subid h2o2_sensor_data
  114. /***********************************************************************************************************************
  115. * *
  116. ***********************************************************************************************************************/
  117. /**
  118. * @brief
  119. * /
  120. *
  121. *
  122. *
  123. *
  124. *
  125. */
  126. kcmd_heater_ctrl = 500, // cmd: power(0-100)
  127. kcmd_heater_ctrl_safe_valve = 501, // cmd: valve_state
  128. kreport_heater_temperature_data = 550, // report:temperature(0.01)
  129. kreport_heater_electric_current = 551, // report:electric_current(ma)
  130. /***********************************************************************************************************************
  131. * *
  132. ***********************************************************************************************************************/
  133. /**
  134. * @brief
  135. * /
  136. *
  137. *
  138. */
  139. kcmd_blower_ctrl = 600, // cmd: power(0-100)
  140. kcmd_blower_ctrl_safe_valve = 601, // cmd: valve_state
  141. kreport_blower_electric_current = 651, // report:electric_current(ma)
  142. /***********************************************************************************************************************
  143. * *
  144. ***********************************************************************************************************************/
  145. /**
  146. * @brief airCompressor
  147. * /
  148. *
  149. *
  150. *
  151. */
  152. kcmd_airCompressor_ctrl = 700, // cmd: power(0-100)
  153. kcmd_airCompressor_ctrl_safe_valve = 701, // cmd: valve_state
  154. kreport_airCompressor_electric_current = 751, // report:electric_current(ma)
  155. /***********************************************************************************************************************
  156. * *
  157. ***********************************************************************************************************************/
  158. /**
  159. * @brief air Tightness Test AirCompressor
  160. * /
  161. *
  162. *
  163. *
  164. */
  165. kcmd_ATTAirCompressor_ctrl = 800, // cmd: power(0-100)
  166. kcmd_ATTAirCompressor_ctrl_safe_valve = 801, // cmd: valve_state
  167. /***********************************************************************************************************************
  168. * *
  169. ***********************************************************************************************************************/
  170. /**
  171. * @brief
  172. * /
  173. */
  174. kcmd_electromagnetic_valve_ctrl = 900, // cmd: valve_state
  175. /***********************************************************************************************************************
  176. * *
  177. ***********************************************************************************************************************/
  178. /**
  179. * @brief
  180. * /
  181. */
  182. kcmd_ball_valve_ctrl = 1000, // cmd: valve_state
  183. /***********************************************************************************************************************
  184. * *
  185. ***********************************************************************************************************************/
  186. /**
  187. * @brief
  188. * /
  189. *
  190. */
  191. kcmd_proportional_valve_ctrl = 1100, // cmd: subid valve_state(0->100)
  192. kreport_proportional_valve_value = 1150, // cmd: subid valve_state(0->100)
  193. /***********************************************************************************************************************
  194. * *
  195. ***********************************************************************************************************************/
  196. kreport_evaporation_bin_water_sensor = 1200, // report:state //蒸发仓水浸
  197. kreport_device_bottom_water_sensor = 1201, // report:state //设备底部水浸
  198. } cmd_t;
  199. #pragma pack(1)
  200. /***********************************************************************************************************************
  201. * ACK *
  202. ***********************************************************************************************************************/
  203. typedef struct {
  204. uint16_t boardType;
  205. uint16_t projectId;
  206. uint16_t protcol_version;
  207. uint16_t software_version;
  208. uint16_t hardware_version;
  209. } ack_read_board_info_data_t;
  210. /***********************************************************************************************************************
  211. * Report *
  212. ***********************************************************************************************************************/
  213. typedef struct {
  214. uint16_t boardType;
  215. } report_heatpacket_data_t;
  216. typedef struct {
  217. uint16_t subid;
  218. uint32_t ecode;
  219. } report_exeception_data_t;
  220. typedef struct {
  221. uint16_t subid;
  222. uint32_t pressure;
  223. } report_pressure_data_t;
  224. typedef struct {
  225. uint16_t subid;
  226. uint16_t h2o2; // ppm
  227. uint16_t humid; // %RH * 100
  228. uint16_t temp; // °C * 100
  229. uint16_t saturation; // %RS * 100
  230. } report_h2o2_data_t;
  231. typedef struct {
  232. uint16_t temperature; // 0.01
  233. } report_heater_temperature_data_t;
  234. typedef struct {
  235. uint16_t electric_current; // ma
  236. } report_heater_electric_current_data_t;
  237. typedef struct {
  238. uint16_t electric_current; // ma
  239. } report_blower_electric_current_data_t;
  240. typedef struct {
  241. uint16_t electric_current; // ma
  242. } report_airCompressor_electric_current_data_t;
  243. typedef struct {
  244. uint16_t subid; // 0->100
  245. uint16_t valve_state; // 0->100
  246. } report_proportional_valve_value_data_t;
  247. typedef struct {
  248. uint16_t state;
  249. } report_evaporation_bin_water_sensor_data_t;
  250. typedef struct {
  251. uint16_t state;
  252. } report_device_bottom_water_sensor_data_t;
  253. #pragma pack()
  254. }