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.

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