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.

356 lines
13 KiB

1 year ago
  1. #pragma once
  2. #include <stdint.h>
  3. #define PROTOCOL_VERSION 1
  4. #define HEART_PACKET_PERIOD_MS (5 * 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. // 驱动器错误
  82. kerr_motorReset = 100,
  83. kerr_motorUnkownError = 101,
  84. kerr_AirBlowerError = 200, // 空压机异常
  85. kerr_HeaterError = 201, // 加热片异常
  86. kerr_BlowerError = 202, // 鼓风机异常
  87. kerr_ProportionalValveError = 203, // 气密性测试专用空压机异常
  88. } ErrorCode_t;
  89. static inline const char *ErrorCodeToString(uint32_t code) {
  90. switch (code) {
  91. case kerr_noerror:
  92. return "no error";
  93. case kerr_motorReset:
  94. return "motor reset";
  95. case kerr_motorUnkownError:
  96. return "motor unkown error";
  97. case kerr_AirBlowerError:
  98. return "air blower error";
  99. case kerr_HeaterError:
  100. return "heater error";
  101. case kerr_BlowerError:
  102. return "blower error";
  103. case kerr_ProportionalValveError:
  104. return "proportional valve error";
  105. default:
  106. return "unkown error";
  107. }
  108. }
  109. typedef enum {
  110. /***********************************************************************************************************************
  111. * *
  112. ***********************************************************************************************************************/
  113. kcmd_read_board_info = 1, // cmd:no, ack:read_board_info_ack_t
  114. kcmd_force_report = 2, // cmd:no, ack:read_board_info_ack_t
  115. kcmd_read_sysinfo = 3, // cmd:no, ack:read_board_info_ack_t
  116. kcmd_read_taskinfo = 4, // cmd:taskoff, ack:read_board_info_ack_t
  117. kreport_heatpacket = 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: rpm
  132. kcmd_pump_stop = 101, // cmd: rpm
  133. kcmd_pump_set_subic_reg = 102, // cmd: add,val
  134. kcmd_pump_get_subic_reg = 103, // cmd: add,ack:val
  135. kcmd_pump_set_irun_ihold = 104, // cmd: irun,ihold,idelay
  136. /***********************************************************************************************************************
  137. * *
  138. ***********************************************************************************************************************/
  139. kcmd_triple_warning_light_ctl = 200, // cmd: r,g,b,warning
  140. /***********************************************************************************************************************
  141. * *
  142. ***********************************************************************************************************************/
  143. kreport_pressure_data = 300, // report:subid pressure(0.1pa)
  144. /***********************************************************************************************************************
  145. * H2O2传感器数值上报 *
  146. ***********************************************************************************************************************/
  147. kreport_h2o2_data = 400, // report:subid h2o2_sensor_data
  148. /***********************************************************************************************************************
  149. * *
  150. ***********************************************************************************************************************/
  151. /**
  152. * @brief
  153. * /
  154. *
  155. *
  156. *
  157. *
  158. *
  159. */
  160. kcmd_heater_ctrl = 500, // cmd: power(0-100)
  161. kcmd_heater_ctrl_safe_valve = 501, // cmd: valve_state
  162. kreport_heater_temperature_data = 550, // report:temperature(0.01)
  163. kreport_heater_electric_current = 551, // report:electric_current(ma)
  164. /***********************************************************************************************************************
  165. * *
  166. ***********************************************************************************************************************/
  167. /**
  168. * @brief
  169. * /
  170. *
  171. *
  172. */
  173. kcmd_blower_ctrl = 600, // cmd: power(0-100)
  174. kcmd_blower_ctrl_safe_valve = 601, // cmd: valve_state
  175. kreport_blower_electric_current = 651, // report:electric_current(ma)
  176. /***********************************************************************************************************************
  177. * *
  178. ***********************************************************************************************************************/
  179. /**
  180. * @brief airCompressor
  181. * /
  182. *
  183. *
  184. *
  185. */
  186. kcmd_airCompressor_ctrl = 700, // cmd: power(0-100)
  187. kcmd_airCompressor_ctrl_safe_valve = 701, // cmd: valve_state
  188. kreport_airCompressor_electric_current = 751, // report:electric_current(ma)
  189. /***********************************************************************************************************************
  190. * *
  191. ***********************************************************************************************************************/
  192. /**
  193. * @brief air Tightness Test AirCompressor
  194. * /
  195. *
  196. *
  197. *
  198. */
  199. kcmd_ATTAirCompressor_ctrl = 800, // cmd: power(0-100)
  200. kcmd_ATTAirCompressor_ctrl_safe_valve = 801, // cmd: valve_state
  201. /***********************************************************************************************************************
  202. * *
  203. ***********************************************************************************************************************/
  204. /**
  205. * @brief
  206. * /
  207. */
  208. kcmd_electromagnetic_valve_ctrl = 900, // cmd: valve_state
  209. /***********************************************************************************************************************
  210. * *
  211. ***********************************************************************************************************************/
  212. /**
  213. * @brief
  214. * /
  215. */
  216. kcmd_ball_valve_ctrl = 1000, // cmd: valve_state
  217. /***********************************************************************************************************************
  218. * *
  219. ***********************************************************************************************************************/
  220. /**
  221. * @brief
  222. * /
  223. *
  224. */
  225. kcmd_proportional_valve_ctrl = 1100, // cmd: subid valve_state(0->100)
  226. kreport_proportional_valve_value = 1150, // cmd: subid valve_state(0->100)
  227. /***********************************************************************************************************************
  228. * *
  229. ***********************************************************************************************************************/
  230. kreport_evaporation_bin_water_sensor = 1200, // report:state //蒸发仓水浸
  231. kreport_device_bottom_water_sensor = 1201, // report:state //设备底部水浸
  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_task_info;
  250. typedef struct {
  251. uint16_t total_heap_size;
  252. uint16_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 boardType;
  261. } report_heatpacket_data_t;
  262. typedef struct {
  263. uint16_t subid;
  264. uint32_t ecode;
  265. } report_exeception_data_t;
  266. typedef struct {
  267. uint16_t subid;
  268. uint32_t pressure;
  269. } report_pressure_data_t;
  270. typedef struct {
  271. uint16_t subid;
  272. uint16_t h2o2; // ppm
  273. uint16_t humid; // %RH * 100
  274. uint16_t temp; // °C * 100
  275. uint16_t saturation; // %RS * 100
  276. } report_h2o2_data_t;
  277. typedef struct {
  278. uint16_t temperature; // 0.01
  279. } report_heater_temperature_data_t;
  280. typedef struct {
  281. uint16_t electric_current; // ma
  282. } report_heater_electric_current_data_t;
  283. typedef struct {
  284. uint16_t electric_current; // ma
  285. } report_blower_electric_current_data_t;
  286. typedef struct {
  287. uint16_t electric_current; // ma
  288. } report_airCompressor_electric_current_data_t;
  289. typedef struct {
  290. uint16_t subid; // 0->100
  291. uint16_t valve_state; // 0->100
  292. } report_proportional_valve_value_data_t;
  293. typedef struct {
  294. uint16_t state;
  295. } report_evaporation_bin_water_sensor_data_t;
  296. typedef struct {
  297. uint16_t state;
  298. } report_device_bottom_water_sensor_data_t;
  299. #pragma pack()
  300. }