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.

361 lines
14 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 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_OVERTIME (30 * 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. static inline const char *BoardTypeToString(uint32_t type) {
  41. switch (type) {
  42. case kMainBoard:
  43. return "MainBoard";
  44. case kBoardType_LiquidCtrl:
  45. return "LiquidCtrl";
  46. case kBoardType_PowerControl:
  47. return "PowerControl";
  48. case kBoardType_PowerControlMiniBoard:
  49. return "PowerControlMiniBoard";
  50. case kBoardType_ExtBallValveCtrl:
  51. return "ExtBallValveCtrl";
  52. case kBoardType_H2O2Sensor:
  53. return "H2O2Sensor";
  54. default:
  55. return "unkown";
  56. }
  57. }
  58. typedef enum {
  59. klarge_space_disinfection_machine = 1, // 大空间消毒机
  60. ksmall_space_disinfection_machine = 2, // 小空间消毒机
  61. kpipe_disinfection_machine = 3, // 管道式消毒机
  62. kdraw_bar_disinfection_box = 4, // 手持拉杆箱消毒机
  63. } ProjectID_t;
  64. static inline const char *ProjectIDToString(uint32_t id) {
  65. switch (id) {
  66. case klarge_space_disinfection_machine:
  67. return "large_space_disinfection_machine";
  68. case ksmall_space_disinfection_machine:
  69. return "small_space_disinfection_machine";
  70. case kpipe_disinfection_machine:
  71. return "pipe_disinfection_machine";
  72. case kdraw_bar_disinfection_box:
  73. return "draw_bar_disinfection_box";
  74. default:
  75. return "unkown";
  76. }
  77. }
  78. typedef enum {
  79. kerr_noerror = 0,
  80. kerr_overtime = 1,
  81. kerr_invalid_param = 2,
  82. kerr_invalid_param_num = 3,
  83. // 驱动器错误
  84. kerr_motor_reset_error = 100,
  85. kerr_motor_offline = 101,
  86. kerr_motor_error_status = 102,
  87. kerr_AirBlowerError = 200, // 空压机异常
  88. kerr_HeaterError = 201, // 加热片异常
  89. kerr_BlowerError = 202, // 鼓风机异常
  90. kerr_ProportionalValveError = 203, // 气密性测试专用空压机异常
  91. } ErrorCode_t;
  92. static inline const char *ErrorCodeToString(uint32_t code) {
  93. switch (code) {
  94. default:
  95. return "unkown error";
  96. }
  97. }
  98. typedef enum {
  99. /***********************************************************************************************************************
  100. * *
  101. ***********************************************************************************************************************/
  102. kcmd_read_board_info = 1, // cmd:no, ack:ack_read_board_info_data_t
  103. kcmd_force_report = 2, // cmd:no, ack:none
  104. kcmd_read_sysinfo = 3, // cmd:no, ack:ack_sysinfo_t
  105. kcmd_read_taskinfo = 4, // cmd:taskoff, ack:ask_taskinfo_t
  106. kcmd_heart_ping = 5, // cmd:taskoff, ack:ask_taskinfo_t
  107. kreport_heatpacket_pong = 50, // cmd:no ack:no report:heatpacket_t
  108. kreport_exception_error = 51, // report:error_code,subid
  109. /***********************************************************************************************************************
  110. * *
  111. ***********************************************************************************************************************/
  112. /**
  113. * (id,)
  114. *
  115. *
  116. * TMC参数
  117. * TMC参数
  118. * ihold,irun,idelay
  119. *
  120. */
  121. kcmd_pump_rotate = 100, // cmd: index rpm ack:none
  122. kcmd_pump_stop = 101, // cmd: index rpm ack:none
  123. kcmd_pump_set_ihold_irun_idelay = 102, // cmd: index irun,ihold,idelay ack:none
  124. kcmd_pump_set_acc = 104, // cmd: index acc ack:none
  125. kcmd_pump_set_subic_reg = 110, // cmd: index,val ack:none
  126. kcmd_pump_get_subic_reg = 111, // cmd: index, ack:val
  127. /***********************************************************************************************************************
  128. * MINI真空泵 *
  129. ***********************************************************************************************************************/
  130. /**
  131. * @brief Spray liquid mini air compressor
  132. * /
  133. */
  134. kcmd_sl_mini_ac_ctrl = 200, // cmd: power(0-100)
  135. /***********************************************************************************************************************
  136. * MINI真空泵 *
  137. ***********************************************************************************************************************/
  138. /**
  139. * @brief air Tightness Test AirCompressor
  140. * /
  141. *
  142. */
  143. kcmd_atta_mini_air_compressor_ctrl = 300, // cmd: power(0-100)
  144. /***********************************************************************************************************************
  145. * *
  146. ***********************************************************************************************************************/
  147. kcmd_read_pressure_data = 400, // cmd:subid ack:pressure(0.1pa)
  148. kcmd_set_pressure_data_report_period_ms = 401, // cmd:subid,period
  149. kreport_pressure_data = 450, // report:subid pressure(0.1pa)
  150. #if 0
  151. /***********************************************************************************************************************
  152. * *
  153. ***********************************************************************************************************************/
  154. kcmd_triple_warning_light_ctl = 200, // cmd: r,g,b,warning
  155. /***********************************************************************************************************************
  156. * H2O2传感器数值上报 *
  157. ***********************************************************************************************************************/
  158. kreport_h2o2_data = 400, // report:subid h2o2_sensor_data
  159. /***********************************************************************************************************************
  160. * *
  161. ***********************************************************************************************************************/
  162. /**
  163. * @brief
  164. * /
  165. *
  166. *
  167. *
  168. *
  169. *
  170. */
  171. kcmd_heater_ctrl = 500, // cmd: power(0-100)
  172. kcmd_heater_ctrl_safe_valve = 501, // cmd: valve_state
  173. kreport_heater_temperature_data = 550, // report:temperature(0.01)
  174. kreport_heater_electric_current = 551, // report:electric_current(ma)
  175. /***********************************************************************************************************************
  176. * *
  177. ***********************************************************************************************************************/
  178. /**
  179. * @brief
  180. * /
  181. *
  182. *
  183. */
  184. kcmd_blower_ctrl = 600, // cmd: power(0-100)
  185. kcmd_blower_ctrl_safe_valve = 601, // cmd: valve_state
  186. kreport_blower_electric_current = 651, // report:electric_current(ma)
  187. /***********************************************************************************************************************
  188. * *
  189. ***********************************************************************************************************************/
  190. /**
  191. * @brief airCompressor
  192. * /
  193. *
  194. *
  195. *
  196. */
  197. kcmd_airCompressor_ctrl = 700, // cmd: power(0-100)
  198. kcmd_airCompressor_ctrl_safe_valve = 701, // cmd: valve_state
  199. kreport_airCompressor_electric_current = 751, // report:electric_current(ma)
  200. /***********************************************************************************************************************
  201. * *
  202. ***********************************************************************************************************************/
  203. /**
  204. * @brief
  205. * /
  206. */
  207. kcmd_electromagnetic_valve_ctrl = 900, // cmd: valve_state
  208. /***********************************************************************************************************************
  209. * *
  210. ***********************************************************************************************************************/
  211. /**
  212. * @brief
  213. * /
  214. */
  215. kcmd_ball_valve_ctrl = 1000, // cmd: valve_state
  216. /***********************************************************************************************************************
  217. * *
  218. ***********************************************************************************************************************/
  219. /**
  220. * @brief
  221. * /
  222. *
  223. */
  224. kcmd_proportional_valve_ctrl = 1100, // cmd: subid valve_state(0->100)
  225. kreport_proportional_valve_value = 1150, // cmd: subid valve_state(0->100)
  226. /***********************************************************************************************************************
  227. * *
  228. ***********************************************************************************************************************/
  229. kreport_evaporation_bin_water_sensor = 1200, // report:state //蒸发仓水浸
  230. kreport_device_bottom_water_sensor = 1201, // report:state //设备底部水浸
  231. #endif
  232. } cmd_t;
  233. #pragma pack(1)
  234. /***********************************************************************************************************************
  235. * ACK *
  236. ***********************************************************************************************************************/
  237. typedef struct {
  238. uint16_t boardType;
  239. uint16_t projectId;
  240. uint16_t protcol_version;
  241. uint16_t software_version;
  242. uint16_t hardware_version;
  243. } ack_read_board_info_data_t;
  244. typedef struct {
  245. uint8_t taskName[8];
  246. uint16_t stackRemindSize;
  247. uint16_t priority;
  248. uint8_t state;
  249. } ask_taskinfo_t;
  250. typedef struct {
  251. uint32_t total_heap_size;
  252. uint32_t free_heap_size;
  253. uint16_t taskNum;
  254. uint16_t sysHasRun;
  255. } ack_sysinfo_t;
  256. /***********************************************************************************************************************
  257. * Report *
  258. ***********************************************************************************************************************/
  259. typedef struct {
  260. uint16_t heartIndex;
  261. uint16_t boardType;
  262. } report_heatpacket_data_t;
  263. typedef struct {
  264. uint16_t subid;
  265. uint32_t ecode;
  266. } report_exeception_data_t;
  267. typedef struct {
  268. uint16_t subid;
  269. uint32_t pressure;
  270. } report_pressure_data_t;
  271. typedef struct {
  272. uint16_t subid;
  273. uint16_t h2o2; // ppm
  274. uint16_t humid; // %RH * 100
  275. uint16_t temp; // °C * 100
  276. uint16_t saturation; // %RS * 100
  277. } report_h2o2_data_t;
  278. typedef struct {
  279. uint16_t temperature; // 0.01
  280. } report_heater_temperature_data_t;
  281. typedef struct {
  282. uint16_t electric_current; // ma
  283. } report_heater_electric_current_data_t;
  284. typedef struct {
  285. uint16_t electric_current; // ma
  286. } report_blower_electric_current_data_t;
  287. typedef struct {
  288. uint16_t electric_current; // ma
  289. } report_airCompressor_electric_current_data_t;
  290. typedef struct {
  291. uint16_t subid; // 0->100
  292. uint16_t valve_state; // 0->100
  293. } report_proportional_valve_value_data_t;
  294. typedef struct {
  295. uint16_t state;
  296. } report_evaporation_bin_water_sensor_data_t;
  297. typedef struct {
  298. uint16_t state;
  299. } report_device_bottom_water_sensor_data_t;
  300. #pragma pack()
  301. }