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.

372 lines
16 KiB

1 year ago
  1. #pragma once
  2. #include <stdint.h>
  3. #include "zscanprotocol/zscanprotocol.hpp"
  4. #define PROTOCOL_VERSION 6
  5. #define HEART_OVERTIME (30 * 1000)
  6. typedef enum {
  7. klarge_space_disinfection_machine = 1, // 大空间消毒机
  8. ksmall_space_disinfection_machine = 2, // 小空间消毒机
  9. kpipe_disinfection_machine = 3, // 管道式消毒机
  10. kdraw_bar_disinfection_box = 4, // 手持拉杆箱消毒机
  11. kh2o2_ext_sensor = 5, // 外部H2O2传感器
  12. } ProjID_t;
  13. typedef enum {
  14. kBoardType_LiquidCtrl = 1, // 液路板
  15. kBoardType_PowerControl = 2, // 电源板
  16. kBoardType_PowerControlMiniBoard = 3, // 电源控制Mini板,用于拉杆箱箱消毒机
  17. kBoardType_ExtBallValveCtrl = 4, // 外部球阀控制板
  18. kBoardType_H2O2Sensor = 5, // H2O2传感器板
  19. } BoardType_t;
  20. typedef enum {
  21. kFixBoardId_MainBoard = 1, // 主机
  22. kFixBoardId_LiquidCtrl = 2, // 液路板
  23. kFixBoardId_PowerControl = 3, // 电源板
  24. kFixBoardId_ExtBallValveCtrl = 4, // 外部球阀控制板
  25. kFixBoardId_H2O2SensorStart = 100, // H2O2传感器板
  26. } BoardId_t;
  27. static inline const char *BoardTypeToString(uint32_t type) {
  28. switch (type) {
  29. case kBoardType_LiquidCtrl:
  30. return "LiquidCtrl";
  31. case kBoardType_PowerControl:
  32. return "PowerControl";
  33. case kBoardType_PowerControlMiniBoard:
  34. return "PowerControlMiniBoard";
  35. case kBoardType_ExtBallValveCtrl:
  36. return "ExtBallValveCtrl";
  37. case kBoardType_H2O2Sensor:
  38. return "H2O2Sensor";
  39. default:
  40. return "unkown";
  41. }
  42. }
  43. static inline const char *ProjectIDToString(uint32_t id) {
  44. switch (id) {
  45. case klarge_space_disinfection_machine:
  46. return "large_space_disinfection_machine";
  47. case ksmall_space_disinfection_machine:
  48. return "small_space_disinfection_machine";
  49. case kpipe_disinfection_machine:
  50. return "pipe_disinfection_machine";
  51. case kdraw_bar_disinfection_box:
  52. return "draw_bar_disinfection_box";
  53. case kh2o2_ext_sensor:
  54. return "h2o2_ext_sensor";
  55. default:
  56. return "unkown";
  57. }
  58. }
  59. typedef enum {
  60. kerr_noerror = 0,
  61. kerr_overtime = 1,
  62. kerr_invalid_param = 2,
  63. kerr_invalid_param_num = 3,
  64. kerr_subdevice_offline = 4,
  65. kerr_function_not_support = 5,
  66. // 驱动器错误
  67. kerr_motor_reset_error = 100,
  68. kerr_motor_subdevice_offline = 101,
  69. kerr_motor_driver_error = 102,
  70. kerr_motor_undervoltage_error = 103,
  71. kerr_motor_unkown_error = 104,
  72. kerr_AirBlowerError = 200, // 空压机异常
  73. kerr_HeaterError = 201, // 加热片异常
  74. kerr_BlowerError = 202, // 鼓风机异常
  75. kerr_ProportionalValveError = 203, // 气密性测试专用空压机异常
  76. } ErrorCode_t;
  77. static inline const char *ErrorCodeToString(uint32_t code) {
  78. switch (code) {
  79. case kerr_noerror:
  80. return "noerror";
  81. case kerr_overtime:
  82. return "overtime";
  83. case kerr_invalid_param:
  84. return "invalid_param";
  85. case kerr_invalid_param_num:
  86. return "invalid_param_num";
  87. case kerr_subdevice_offline:
  88. return "subdevice_offline";
  89. case kerr_function_not_support:
  90. return "function_not_support";
  91. case kerr_motor_reset_error:
  92. return "motor_reset_error";
  93. case kerr_motor_subdevice_offline:
  94. return "motor_subdevice_offline";
  95. case kerr_motor_driver_error:
  96. return "motor_driver_error";
  97. case kerr_motor_undervoltage_error:
  98. return "motor_undervoltage_error";
  99. case kerr_AirBlowerError:
  100. return "AirBlowerError";
  101. case kerr_HeaterError:
  102. return "HeaterError";
  103. case kerr_BlowerError:
  104. return "BlowerError";
  105. case kerr_ProportionalValveError:
  106. return "ProportionalValveError";
  107. default:
  108. return "unkown";
  109. }
  110. }
  111. typedef enum {
  112. /***********************************************************************************************************************
  113. * *
  114. ***********************************************************************************************************************/
  115. kfn_read_board_info = 1, // cmd:no, ack:ack_read_board_info_data_t
  116. kfn_force_report = 2, // cmd:no, ack:none //!delete
  117. kfn_read_sysinfo = 3, // cmd:no, ack:ack_sysinfo_t
  118. kfn_read_taskinfo = 4, // cmd:taskoff, ack:ask_taskinfo_t
  119. kfn_heart_ping = 5, // cmd:pingindex, ack:ask_taskinfo_t
  120. kfn_clear_reset_flag = 6, // cmd:taskoff, ack:ask_taskinfo_t
  121. kreport_heatpacket_pong = 50, // cmd:no ack:no report:heatpacket_t
  122. kreport_exception_error = 51, // report:error_code,subid
  123. /***********************************************************************************************************************
  124. * *
  125. ***********************************************************************************************************************/
  126. /**
  127. * (id,)
  128. *
  129. *
  130. * TMC参数
  131. * TMC参数
  132. * ihold,irun,idelay
  133. *
  134. */
  135. kfn_pump_rotate = 100, // cmd: index rpm ack:none
  136. kfn_pump_stop = 101, // cmd: index rpm ack:none
  137. kfn_pump_set_ihold_irun_idelay = 102, // cmd: index irun,ihold,idelay ack:none
  138. kfn_pump_set_acc = 104, // cmd: index acc ack:none
  139. kfn_pump_ping = 105, // cmd: index, ack:none
  140. kfn_pump_set_subic_reg = 110, // cmd: index,val ack:none
  141. kfn_pump_get_subic_reg = 111, // cmd: index, ack:val
  142. /***********************************************************************************************************************
  143. * MINI真空泵 *
  144. ***********************************************************************************************************************/
  145. /**
  146. * @brief Spray liquid mini air compressor
  147. * /
  148. */
  149. kfn_sl_mini_ac_ctrl = 200, // cmd: power(0-100)
  150. /***********************************************************************************************************************
  151. * MINI真空泵 *
  152. ***********************************************************************************************************************/
  153. /**
  154. * @brief air Tightness Test AirCompressor
  155. * /
  156. *
  157. */
  158. kfn_atta_mini_air_compressor_ctrl = 300, // cmd: power(0-100)
  159. /***********************************************************************************************************************
  160. * *
  161. ***********************************************************************************************************************/
  162. kfn_pressure_sensor_bus_read_data = 400, // cmd:subid ack:pressure(0.1pa)
  163. kfn_pressure_sensor_bus_set_report_period_ms = 401, // cmd:period
  164. kreport_pressure_data = 450, // report:subid pressure(0.1pa)
  165. /***********************************************************************************************************************
  166. * MINI_PWM风机控制 *
  167. ***********************************************************************************************************************/
  168. /**
  169. * @brief
  170. * /
  171. *
  172. *
  173. */
  174. kfn_mini_pwm_blower_ctrl = 500, // cmd: speed(0-100)
  175. kfn_mini_pwm_blower_read_fbcount = 501, // cmd: valve_state
  176. /***********************************************************************************************************************
  177. * *
  178. ***********************************************************************************************************************/
  179. /**
  180. * @brief
  181. * /
  182. *
  183. *
  184. *
  185. *
  186. *
  187. */
  188. kfn_heater_ctrl = 600, // cmd: power(0-100)
  189. kfn_heater_ctrl_safe_valve = 601, // cmd: valve_state
  190. kfn_heater_read_electric_current = 602, // report:electric_current(ma)
  191. kfn_heater_read_temperature_data = 603, // report:temperature(0.01)
  192. /***********************************************************************************************************************
  193. * H2O2传感器数值上报 *
  194. ***********************************************************************************************************************/
  195. kfn_h2o2_sensor_read_calibration_date = 700, // cmd:subid ack:year,month,day
  196. kfn_h2o2_sensor_read_sub_ic_errorcode = 701, // cmd:subid ack:errorcode
  197. kfn_h2o2_sensor_read_sub_ic_reg = 702, // cmd:subid,reg,num ack:errorcode
  198. kreport_h2o2_sensor_data = 750, // report:subid h2o2_sensor_data
  199. /***********************************************************************************************************************
  200. * *
  201. ***********************************************************************************************************************/
  202. kfn_triple_warning_light_ctl = 800, // cmd: r,g,b,warning
  203. /***********************************************************************************************************************
  204. * *
  205. ***********************************************************************************************************************/
  206. kfn_evaporation_bin_water_sensor_read_state = 900, // cmd: state
  207. kfn_device_bottom_water_sensor_read_state = 901, // cmd: state
  208. kreport_evaporation_bin_water_sensor = 950, // report:state //蒸发仓水浸 //report_evaporation_bin_water_sensor_data_t
  209. kreport_device_bottom_water_sensor = 951, // report:state //设备底部水浸 //report_device_bottom_water_sensor_data
  210. /***********************************************************************************************************************
  211. * *
  212. ***********************************************************************************************************************/
  213. kfn_blower_ctrl = 1000, // cmd: power(0-100)
  214. kfn_blower_ctrl_safe_valve = 1001, // cmd: valve_state
  215. kfn_blower_read_electric_current = 1002, // report:electric_current(ma)
  216. /***********************************************************************************************************************
  217. * *
  218. ***********************************************************************************************************************/
  219. kfn_air_compressor_ctrl = 1100, // cmd: power(0-100)
  220. kfn_air_compressor_ctrl_safe_valve = 1101, // cmd: valve_state
  221. kfn_air_compressor_read_electric_current = 1102, // report:electric_current(ma)
  222. #if 0
  223. /***********************************************************************************************************************
  224. * H2O2传感器数值上报 *
  225. ***********************************************************************************************************************/
  226. kreport_h2o2_data = 400, // report:subid h2o2_sensor_data
  227. /***********************************************************************************************************************
  228. * *
  229. ***********************************************************************************************************************/
  230. /**
  231. * @brief
  232. * /
  233. */
  234. kfn_electromagnetic_valve_ctrl = 900, // cmd: valve_state
  235. /***********************************************************************************************************************
  236. * *
  237. ***********************************************************************************************************************/
  238. /**
  239. * @brief
  240. * /
  241. */
  242. kfn_ball_valve_ctrl = 1000, // cmd: valve_state
  243. /***********************************************************************************************************************
  244. * *
  245. ***********************************************************************************************************************/
  246. /**
  247. * @brief
  248. * /
  249. *
  250. */
  251. kfn_proportional_valve_ctrl = 1100, // cmd: subid valve_state(0->100)
  252. kreport_proportional_valve_value = 1150, // cmd: subid valve_state(0->100)
  253. /***********************************************************************************************************************
  254. * *
  255. ***********************************************************************************************************************/
  256. kreport_evaporation_bin_water_sensor = 1200, // report:state //蒸发仓水浸
  257. kreport_device_bottom_water_sensor = 1201, // report:state //设备底部水浸
  258. #endif
  259. } cmd_t;
  260. #pragma pack(1)
  261. /***********************************************************************************************************************
  262. * ACK *
  263. ***********************************************************************************************************************/
  264. typedef struct {
  265. uint16_t boardType;
  266. uint16_t projectId;
  267. uint16_t protcol_version;
  268. uint16_t software_version;
  269. uint16_t hardware_version;
  270. } ack_read_board_info_data_t;
  271. typedef struct {
  272. uint8_t taskName[8];
  273. uint16_t stackRemindSize;
  274. uint16_t priority;
  275. uint8_t state;
  276. } ask_taskinfo_t;
  277. typedef struct {
  278. uint32_t total_heap_size;
  279. uint32_t free_heap_size;
  280. uint16_t taskNum;
  281. uint16_t sysHasRun;
  282. } ack_sysinfo_t;
  283. /***********************************************************************************************************************
  284. * Report *
  285. ***********************************************************************************************************************/
  286. typedef struct {
  287. uint16_t heartIndex;
  288. uint8_t boardType;
  289. uint8_t flag; // 0:reset_flag
  290. } report_heatpacket_data_t;
  291. typedef struct {
  292. uint32_t ecode;
  293. uint16_t subid;
  294. } report_exeception_data_t;
  295. #if 1
  296. typedef struct {
  297. uint8_t sensorDataNum;
  298. struct {
  299. uint8_t subid;
  300. int16_t pressureVal;
  301. } data[];
  302. } report_pressure_data_t;
  303. #endif
  304. typedef struct {
  305. uint8_t sensor_error; // 传感器异常
  306. uint16_t h2o2; // ppm * 10
  307. uint16_t humid; // %RH * 10
  308. uint16_t temp; // °C * 10
  309. uint16_t saturation; // %RS * 10
  310. } report_h2o2_data_t;
  311. typedef struct {
  312. uint16_t temperature; // 0.01
  313. } report_heater_temperature_data_t;
  314. typedef struct {
  315. uint16_t subid; // 0->100
  316. uint16_t valve_state; // 0->100
  317. } report_proportional_valve_value_data_t;
  318. typedef struct {
  319. uint16_t state;
  320. } report_water_sensor_state_t;
  321. #pragma pack()