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.

446 lines
18 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 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 5
  4. #define HEART_OVERTIME (30 * 1000)
  5. #pragma pack(1)
  6. /**
  7. * @brief 12bit from,1bit emergency
  8. * H L
  9. * [1] [4bit] [8bit] [8bit] [4bit/4bit]
  10. * , from to frameNum/frameId
  11. */
  12. // 数值越大优先级越低
  13. typedef enum {
  14. kpriority_emergency_report = 7,
  15. kpriority_cmd = 8,
  16. kpriority_receipt = 9,
  17. kpriority_report = 10,
  18. } priority_t;
  19. typedef struct {
  20. uint8_t frameNumAndFrameId;
  21. uint8_t to;
  22. uint8_t from;
  23. uint8_t pad;
  24. } zcanid_t;
  25. typedef struct {
  26. uint8_t ptype;
  27. uint8_t index;
  28. uint16_t function_id;
  29. uint8_t params[];
  30. } zcanbus_packet_t;
  31. #pragma pack()
  32. typedef enum {
  33. kcmd,
  34. kreceipt,
  35. kerror_receipt,
  36. kreport,
  37. } packet_type_t;
  38. typedef enum {
  39. kMainBoard = 0, // 主机
  40. kBoardType_LiquidCtrl = 2, // 液路板
  41. kBoardType_PowerControl = 3, // 电源板
  42. kBoardType_PowerControlMiniBoard = 4, // 电源控制Mini板,用于拉杆箱箱消毒机
  43. kBoardType_ExtBallValveCtrl = 5, // 外部球阀控制板
  44. kBoardType_H2O2Sensor = 6, // H2O2传感器板
  45. } BoardType_t;
  46. typedef enum {
  47. kFixBoardId_MainBoard = 1, // 主机
  48. kFixBoardId_LiquidCtrl = 2, // 液路板
  49. kFixBoardId_PowerControl = 3, // 电源板
  50. kFixBoardId_PowerControlMiniBoard = 4, // 电源控制Mini板,用于拉杆箱箱消毒机
  51. kFixBoardId_ExtBallValveCtrl = 5, // 外部球阀控制板
  52. kFixBoardId_H2O2SensorStart = 100, // H2O2传感器板
  53. } FixBoardId_t;
  54. static inline const char *BoardTypeToString(uint32_t type) {
  55. switch (type) {
  56. case kMainBoard:
  57. return "MainBoard";
  58. case kBoardType_LiquidCtrl:
  59. return "LiquidCtrl";
  60. case kBoardType_PowerControl:
  61. return "PowerControl";
  62. case kBoardType_PowerControlMiniBoard:
  63. return "PowerControlMiniBoard";
  64. case kBoardType_ExtBallValveCtrl:
  65. return "ExtBallValveCtrl";
  66. case kBoardType_H2O2Sensor:
  67. return "H2O2Sensor";
  68. default:
  69. return "unkown";
  70. }
  71. }
  72. typedef enum {
  73. klarge_space_disinfection_machine = 1, // 大空间消毒机
  74. ksmall_space_disinfection_machine = 2, // 小空间消毒机
  75. kpipe_disinfection_machine = 3, // 管道式消毒机
  76. kdraw_bar_disinfection_box = 4, // 手持拉杆箱消毒机
  77. } ProjectID_t;
  78. static inline const char *ProjectIDToString(uint32_t id) {
  79. switch (id) {
  80. case klarge_space_disinfection_machine:
  81. return "large_space_disinfection_machine";
  82. case ksmall_space_disinfection_machine:
  83. return "small_space_disinfection_machine";
  84. case kpipe_disinfection_machine:
  85. return "pipe_disinfection_machine";
  86. case kdraw_bar_disinfection_box:
  87. return "draw_bar_disinfection_box";
  88. default:
  89. return "unkown";
  90. }
  91. }
  92. typedef enum {
  93. kerr_noerror = 0,
  94. kerr_overtime = 1,
  95. kerr_invalid_param = 2,
  96. kerr_invalid_param_num = 3,
  97. kerr_subdevice_offline = 4,
  98. // 驱动器错误
  99. kerr_motor_reset_error = 100,
  100. kerr_motor_subdevice_offline = 101,
  101. kerr_motor_driver_error = 102,
  102. kerr_motor_undervoltage_error = 103,
  103. kerr_motor_unkown_error = 104,
  104. kerr_AirBlowerError = 200, // 空压机异常
  105. kerr_HeaterError = 201, // 加热片异常
  106. kerr_BlowerError = 202, // 鼓风机异常
  107. kerr_ProportionalValveError = 203, // 气密性测试专用空压机异常
  108. } ErrorCode_t;
  109. static inline const char *ErrorCodeToString(uint32_t code) {
  110. switch (code) {
  111. case kerr_noerror:
  112. return "noerror";
  113. case kerr_overtime:
  114. return "overtime";
  115. case kerr_invalid_param:
  116. return "invalid_param";
  117. case kerr_invalid_param_num:
  118. return "invalid_param_num";
  119. case kerr_subdevice_offline:
  120. return "subdevice_offline";
  121. case kerr_motor_reset_error:
  122. return "motor_reset_error";
  123. case kerr_motor_subdevice_offline:
  124. return "motor_subdevice_offline";
  125. case kerr_motor_driver_error:
  126. return "motor_driver_error";
  127. case kerr_motor_undervoltage_error:
  128. return "motor_undervoltage_error";
  129. case kerr_AirBlowerError:
  130. return "AirBlowerError";
  131. case kerr_HeaterError:
  132. return "HeaterError";
  133. case kerr_BlowerError:
  134. return "BlowerError";
  135. case kerr_ProportionalValveError:
  136. return "ProportionalValveError";
  137. default:
  138. return "unkown";
  139. }
  140. }
  141. typedef enum {
  142. /***********************************************************************************************************************
  143. * *
  144. ***********************************************************************************************************************/
  145. kcmd_read_board_info = 1, // cmd:no, ack:ack_read_board_info_data_t
  146. kcmd_force_report = 2, // cmd:no, ack:none
  147. kcmd_read_sysinfo = 3, // cmd:no, ack:ack_sysinfo_t
  148. kcmd_read_taskinfo = 4, // cmd:taskoff, ack:ask_taskinfo_t
  149. kcmd_heart_ping = 5, // cmd:pingindex, ack:ask_taskinfo_t
  150. kcmd_clear_reset_flag = 6, // cmd:taskoff, ack:ask_taskinfo_t
  151. kreport_heatpacket_pong = 50, // cmd:no ack:no report:heatpacket_t
  152. kreport_exception_error = 51, // report:error_code,subid
  153. /***********************************************************************************************************************
  154. * *
  155. ***********************************************************************************************************************/
  156. /**
  157. * (id,)
  158. *
  159. *
  160. * TMC参数
  161. * TMC参数
  162. * ihold,irun,idelay
  163. *
  164. */
  165. kcmd_pump_rotate = 100, // cmd: index rpm ack:none
  166. kcmd_pump_stop = 101, // cmd: index rpm ack:none
  167. kcmd_pump_set_ihold_irun_idelay = 102, // cmd: index irun,ihold,idelay ack:none
  168. kcmd_pump_set_acc = 104, // cmd: index acc ack:none
  169. kcmd_pump_ping = 105, // cmd: index, ack:none
  170. kcmd_pump_set_subic_reg = 110, // cmd: index,val ack:none
  171. kcmd_pump_get_subic_reg = 111, // cmd: index, ack:val
  172. /***********************************************************************************************************************
  173. * MINI真空泵 *
  174. ***********************************************************************************************************************/
  175. /**
  176. * @brief Spray liquid mini air compressor
  177. * /
  178. */
  179. kcmd_sl_mini_ac_ctrl = 200, // cmd: power(0-100)
  180. /***********************************************************************************************************************
  181. * MINI真空泵 *
  182. ***********************************************************************************************************************/
  183. /**
  184. * @brief air Tightness Test AirCompressor
  185. * /
  186. *
  187. */
  188. kcmd_atta_mini_air_compressor_ctrl = 300, // cmd: power(0-100)
  189. /***********************************************************************************************************************
  190. * *
  191. ***********************************************************************************************************************/
  192. kcmd_pressure_sensor_bus_read_data = 400, // cmd:subid ack:pressure(0.1pa)
  193. #if 0
  194. kcmd_pressure_sensor_bus_set_report_period_ms = 401, // cmd:period
  195. kreport_pressure_data = 450, // report:subid pressure(0.1pa)
  196. #endif
  197. /***********************************************************************************************************************
  198. * MINI_PWM风机控制 *
  199. ***********************************************************************************************************************/
  200. /**
  201. * @brief
  202. * /
  203. *
  204. *
  205. */
  206. kcmd_mini_pwm_blower_ctrl = 500, // cmd: speed(0-100)
  207. kcmd_mini_pwm_blower_read_fbcount = 501, // cmd: valve_state
  208. /***********************************************************************************************************************
  209. * *
  210. ***********************************************************************************************************************/
  211. /**
  212. * @brief
  213. * /
  214. *
  215. *
  216. *
  217. *
  218. *
  219. */
  220. kcmd_heater_ctrl = 600, // cmd: power(0-100)
  221. kcmd_heater_ctrl_safe_valve = 601, // cmd: valve_state
  222. kcmd_heater_read_electric_current = 602, // report:electric_current(ma)
  223. kcmd_heater_read_temperature_data = 603, // report:temperature(0.01)
  224. /***********************************************************************************************************************
  225. * H2O2传感器数值上报 *
  226. ***********************************************************************************************************************/
  227. kreport_h2o2_sensor_data = 750, // report:subid h2o2_sensor_data
  228. #if 0
  229. /***********************************************************************************************************************
  230. * *
  231. ***********************************************************************************************************************/
  232. kcmd_triple_warning_light_ctl = 200, // cmd: r,g,b,warning
  233. /***********************************************************************************************************************
  234. * H2O2传感器数值上报 *
  235. ***********************************************************************************************************************/
  236. kreport_h2o2_data = 400, // report:subid h2o2_sensor_data
  237. /***********************************************************************************************************************
  238. * *
  239. ***********************************************************************************************************************/
  240. /**
  241. * @brief
  242. * /
  243. *
  244. *
  245. *
  246. *
  247. *
  248. */
  249. kcmd_heater_ctrl = 500, // cmd: power(0-100)
  250. kcmd_heater_ctrl_safe_valve = 501, // cmd: valve_state
  251. kreport_heater_temperature_data = 550, // report:temperature(0.01)
  252. kreport_heater_electric_current = 551, // report:electric_current(ma)
  253. /***********************************************************************************************************************
  254. * *
  255. ***********************************************************************************************************************/
  256. /**
  257. * @brief
  258. * /
  259. *
  260. *
  261. */
  262. kcmd_blower_ctrl = 600, // cmd: power(0-100)
  263. kcmd_blower_ctrl_safe_valve = 601, // cmd: valve_state
  264. kreport_blower_electric_current = 651, // report:electric_current(ma)
  265. /***********************************************************************************************************************
  266. * *
  267. ***********************************************************************************************************************/
  268. /**
  269. * @brief airCompressor
  270. * /
  271. *
  272. *
  273. *
  274. */
  275. kcmd_airCompressor_ctrl = 700, // cmd: power(0-100)
  276. kcmd_airCompressor_ctrl_safe_valve = 701, // cmd: valve_state
  277. kreport_airCompressor_electric_current = 751, // report:electric_current(ma)
  278. /***********************************************************************************************************************
  279. * *
  280. ***********************************************************************************************************************/
  281. /**
  282. * @brief
  283. * /
  284. */
  285. kcmd_electromagnetic_valve_ctrl = 900, // cmd: valve_state
  286. /***********************************************************************************************************************
  287. * *
  288. ***********************************************************************************************************************/
  289. /**
  290. * @brief
  291. * /
  292. */
  293. kcmd_ball_valve_ctrl = 1000, // cmd: valve_state
  294. /***********************************************************************************************************************
  295. * *
  296. ***********************************************************************************************************************/
  297. /**
  298. * @brief
  299. * /
  300. *
  301. */
  302. kcmd_proportional_valve_ctrl = 1100, // cmd: subid valve_state(0->100)
  303. kreport_proportional_valve_value = 1150, // cmd: subid valve_state(0->100)
  304. /***********************************************************************************************************************
  305. * *
  306. ***********************************************************************************************************************/
  307. kreport_evaporation_bin_water_sensor = 1200, // report:state //蒸发仓水浸
  308. kreport_device_bottom_water_sensor = 1201, // report:state //设备底部水浸
  309. #endif
  310. } cmd_t;
  311. #pragma pack(1)
  312. /***********************************************************************************************************************
  313. * ACK *
  314. ***********************************************************************************************************************/
  315. typedef struct {
  316. uint16_t boardType;
  317. uint16_t projectId;
  318. uint16_t protcol_version;
  319. uint16_t software_version;
  320. uint16_t hardware_version;
  321. } ack_read_board_info_data_t;
  322. typedef struct {
  323. uint8_t taskName[8];
  324. uint16_t stackRemindSize;
  325. uint16_t priority;
  326. uint8_t state;
  327. } ask_taskinfo_t;
  328. typedef struct {
  329. uint32_t total_heap_size;
  330. uint32_t free_heap_size;
  331. uint16_t taskNum;
  332. uint16_t sysHasRun;
  333. } ack_sysinfo_t;
  334. /***********************************************************************************************************************
  335. * Report *
  336. ***********************************************************************************************************************/
  337. typedef struct {
  338. uint16_t heartIndex;
  339. uint8_t boardType;
  340. uint8_t flag; // 0:reset_flag
  341. } report_heatpacket_data_t;
  342. typedef struct {
  343. uint16_t subid;
  344. uint32_t ecode;
  345. } report_exeception_data_t;
  346. typedef struct {
  347. uint8_t sensorDataNum;
  348. struct {
  349. uint8_t subid;
  350. int16_t pressureVal;
  351. } data[];
  352. } report_pressure_data_t;
  353. typedef struct {
  354. uint16_t subid;
  355. uint16_t h2o2; // ppm
  356. uint16_t humid; // %RH * 100
  357. uint16_t temp; // °C * 100
  358. uint16_t saturation; // %RS * 100
  359. } report_h2o2_data_t;
  360. typedef struct {
  361. uint16_t temperature; // 0.01
  362. } report_heater_temperature_data_t;
  363. typedef struct {
  364. uint16_t electric_current; // ma
  365. } report_heater_electric_current_data_t;
  366. typedef struct {
  367. uint16_t electric_current; // ma
  368. } report_blower_electric_current_data_t;
  369. typedef struct {
  370. uint16_t electric_current; // ma
  371. } report_airCompressor_electric_current_data_t;
  372. typedef struct {
  373. uint16_t subid; // 0->100
  374. uint16_t valve_state; // 0->100
  375. } report_proportional_valve_value_data_t;
  376. typedef struct {
  377. uint16_t state;
  378. } report_evaporation_bin_water_sensor_data_t;
  379. typedef struct {
  380. uint16_t state;
  381. } report_device_bottom_water_sensor_data_t;
  382. #pragma pack()