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.

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