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.

365 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. #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. kerr_subdevice_offline = 4,
  84. // 驱动器错误
  85. kerr_motor_reset_error = 100,
  86. kerr_motor_offline = 101,
  87. kerr_motor_error_status = 102,
  88. kerr_AirBlowerError = 200, // 空压机异常
  89. kerr_HeaterError = 201, // 加热片异常
  90. kerr_BlowerError = 202, // 鼓风机异常
  91. kerr_ProportionalValveError = 203, // 气密性测试专用空压机异常
  92. } ErrorCode_t;
  93. static inline const char *ErrorCodeToString(uint32_t code) {
  94. switch (code) {
  95. default:
  96. return "unkown error";
  97. }
  98. }
  99. typedef enum {
  100. /***********************************************************************************************************************
  101. * *
  102. ***********************************************************************************************************************/
  103. kcmd_read_board_info = 1, // cmd:no, ack:ack_read_board_info_data_t
  104. kcmd_force_report = 2, // cmd:no, ack:none
  105. kcmd_read_sysinfo = 3, // cmd:no, ack:ack_sysinfo_t
  106. kcmd_read_taskinfo = 4, // cmd:taskoff, ack:ask_taskinfo_t
  107. kcmd_heart_ping = 5, // cmd:taskoff, ack:ask_taskinfo_t
  108. kreport_heatpacket_pong = 50, // cmd:no ack:no report:heatpacket_t
  109. kreport_exception_error = 51, // report:error_code,subid
  110. /***********************************************************************************************************************
  111. * *
  112. ***********************************************************************************************************************/
  113. /**
  114. * (id,)
  115. *
  116. *
  117. * TMC参数
  118. * TMC参数
  119. * ihold,irun,idelay
  120. *
  121. */
  122. kcmd_pump_rotate = 100, // cmd: index rpm ack:none
  123. kcmd_pump_stop = 101, // cmd: index rpm ack:none
  124. kcmd_pump_set_ihold_irun_idelay = 102, // cmd: index irun,ihold,idelay ack:none
  125. kcmd_pump_set_acc = 104, // cmd: index acc ack:none
  126. kcmd_pump_set_subic_reg = 110, // cmd: index,val ack:none
  127. kcmd_pump_get_subic_reg = 111, // cmd: index, ack:val
  128. /***********************************************************************************************************************
  129. * MINI真空泵 *
  130. ***********************************************************************************************************************/
  131. /**
  132. * @brief Spray liquid mini air compressor
  133. * /
  134. */
  135. kcmd_sl_mini_ac_ctrl = 200, // cmd: power(0-100)
  136. /***********************************************************************************************************************
  137. * MINI真空泵 *
  138. ***********************************************************************************************************************/
  139. /**
  140. * @brief air Tightness Test AirCompressor
  141. * /
  142. *
  143. */
  144. kcmd_atta_mini_air_compressor_ctrl = 300, // cmd: power(0-100)
  145. /***********************************************************************************************************************
  146. * *
  147. ***********************************************************************************************************************/
  148. kcmd_read_pressure_data = 400, // cmd:subid ack:pressure(0.1pa)
  149. kcmd_set_pressure_data_report_period_ms = 401, // cmd:subid,period
  150. kreport_pressure_data = 450, // report:subid pressure(0.1pa)
  151. #if 0
  152. /***********************************************************************************************************************
  153. * *
  154. ***********************************************************************************************************************/
  155. kcmd_triple_warning_light_ctl = 200, // cmd: r,g,b,warning
  156. /***********************************************************************************************************************
  157. * H2O2传感器数值上报 *
  158. ***********************************************************************************************************************/
  159. kreport_h2o2_data = 400, // report:subid h2o2_sensor_data
  160. /***********************************************************************************************************************
  161. * *
  162. ***********************************************************************************************************************/
  163. /**
  164. * @brief
  165. * /
  166. *
  167. *
  168. *
  169. *
  170. *
  171. */
  172. kcmd_heater_ctrl = 500, // cmd: power(0-100)
  173. kcmd_heater_ctrl_safe_valve = 501, // cmd: valve_state
  174. kreport_heater_temperature_data = 550, // report:temperature(0.01)
  175. kreport_heater_electric_current = 551, // report:electric_current(ma)
  176. /***********************************************************************************************************************
  177. * *
  178. ***********************************************************************************************************************/
  179. /**
  180. * @brief
  181. * /
  182. *
  183. *
  184. */
  185. kcmd_blower_ctrl = 600, // cmd: power(0-100)
  186. kcmd_blower_ctrl_safe_valve = 601, // cmd: valve_state
  187. kreport_blower_electric_current = 651, // report:electric_current(ma)
  188. /***********************************************************************************************************************
  189. * *
  190. ***********************************************************************************************************************/
  191. /**
  192. * @brief airCompressor
  193. * /
  194. *
  195. *
  196. *
  197. */
  198. kcmd_airCompressor_ctrl = 700, // cmd: power(0-100)
  199. kcmd_airCompressor_ctrl_safe_valve = 701, // cmd: valve_state
  200. kreport_airCompressor_electric_current = 751, // report:electric_current(ma)
  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. #endif
  233. } cmd_t;
  234. #pragma pack(1)
  235. /***********************************************************************************************************************
  236. * ACK *
  237. ***********************************************************************************************************************/
  238. typedef struct {
  239. uint16_t boardType;
  240. uint16_t projectId;
  241. uint16_t protcol_version;
  242. uint16_t software_version;
  243. uint16_t hardware_version;
  244. } ack_read_board_info_data_t;
  245. typedef struct {
  246. uint8_t taskName[8];
  247. uint16_t stackRemindSize;
  248. uint16_t priority;
  249. uint8_t state;
  250. } ask_taskinfo_t;
  251. typedef struct {
  252. uint32_t total_heap_size;
  253. uint32_t free_heap_size;
  254. uint16_t taskNum;
  255. uint16_t sysHasRun;
  256. } ack_sysinfo_t;
  257. /***********************************************************************************************************************
  258. * Report *
  259. ***********************************************************************************************************************/
  260. typedef struct {
  261. uint16_t heartIndex;
  262. uint16_t boardType;
  263. } report_heatpacket_data_t;
  264. typedef struct {
  265. uint16_t subid;
  266. uint32_t ecode;
  267. } report_exeception_data_t;
  268. typedef struct {
  269. uint8_t sensorDataNum;
  270. struct {
  271. uint8_t subid;
  272. int16_t pressureVal;
  273. } data[];
  274. } report_pressure_data_t;
  275. typedef struct {
  276. uint16_t subid;
  277. uint16_t h2o2; // ppm
  278. uint16_t humid; // %RH * 100
  279. uint16_t temp; // °C * 100
  280. uint16_t saturation; // %RS * 100
  281. } report_h2o2_data_t;
  282. typedef struct {
  283. uint16_t temperature; // 0.01
  284. } report_heater_temperature_data_t;
  285. typedef struct {
  286. uint16_t electric_current; // ma
  287. } report_heater_electric_current_data_t;
  288. typedef struct {
  289. uint16_t electric_current; // ma
  290. } report_blower_electric_current_data_t;
  291. typedef struct {
  292. uint16_t electric_current; // ma
  293. } report_airCompressor_electric_current_data_t;
  294. typedef struct {
  295. uint16_t subid; // 0->100
  296. uint16_t valve_state; // 0->100
  297. } report_proportional_valve_value_data_t;
  298. typedef struct {
  299. uint16_t state;
  300. } report_evaporation_bin_water_sensor_data_t;
  301. typedef struct {
  302. uint16_t state;
  303. } report_device_bottom_water_sensor_data_t;
  304. #pragma pack()
  305. }