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.

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