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.

357 lines
13 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. #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. // 驱动器错误
  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:ack_read_board_info_data_t
  114. kcmd_force_report = 2, // cmd:no, ack:none
  115. kcmd_read_sysinfo = 3, // cmd:no, ack:ack_sysinfo_t
  116. kcmd_read_taskinfo = 4, // cmd:taskoff, ack:ask_taskinfo_t
  117. kcmd_heart_ping = 5, // cmd:taskoff, ack:ask_taskinfo_t
  118. kreport_heatpacket = 50, // cmd:no ack:no report:heatpacket_t
  119. kreport_exception_error = 51, // report:error_code,subid
  120. /***********************************************************************************************************************
  121. * *
  122. ***********************************************************************************************************************/
  123. /**
  124. * (id,)
  125. *
  126. *
  127. * TMC参数
  128. * TMC参数
  129. * ihold,irun,idelay
  130. *
  131. */
  132. kcmd_pump_rotate = 100, // cmd: rpm
  133. kcmd_pump_stop = 101, // cmd: rpm
  134. kcmd_pump_set_subic_reg = 102, // cmd: add,val
  135. kcmd_pump_get_subic_reg = 103, // cmd: add,ack:val
  136. kcmd_pump_set_irun_ihold = 104, // cmd: irun,ihold,idelay
  137. /***********************************************************************************************************************
  138. * *
  139. ***********************************************************************************************************************/
  140. kcmd_triple_warning_light_ctl = 200, // cmd: r,g,b,warning
  141. /***********************************************************************************************************************
  142. * *
  143. ***********************************************************************************************************************/
  144. kreport_pressure_data = 300, // report:subid pressure(0.1pa)
  145. /***********************************************************************************************************************
  146. * H2O2传感器数值上报 *
  147. ***********************************************************************************************************************/
  148. kreport_h2o2_data = 400, // report:subid h2o2_sensor_data
  149. /***********************************************************************************************************************
  150. * *
  151. ***********************************************************************************************************************/
  152. /**
  153. * @brief
  154. * /
  155. *
  156. *
  157. *
  158. *
  159. *
  160. */
  161. kcmd_heater_ctrl = 500, // cmd: power(0-100)
  162. kcmd_heater_ctrl_safe_valve = 501, // cmd: valve_state
  163. kreport_heater_temperature_data = 550, // report:temperature(0.01)
  164. kreport_heater_electric_current = 551, // report:electric_current(ma)
  165. /***********************************************************************************************************************
  166. * *
  167. ***********************************************************************************************************************/
  168. /**
  169. * @brief
  170. * /
  171. *
  172. *
  173. */
  174. kcmd_blower_ctrl = 600, // cmd: power(0-100)
  175. kcmd_blower_ctrl_safe_valve = 601, // cmd: valve_state
  176. kreport_blower_electric_current = 651, // report:electric_current(ma)
  177. /***********************************************************************************************************************
  178. * *
  179. ***********************************************************************************************************************/
  180. /**
  181. * @brief airCompressor
  182. * /
  183. *
  184. *
  185. *
  186. */
  187. kcmd_airCompressor_ctrl = 700, // cmd: power(0-100)
  188. kcmd_airCompressor_ctrl_safe_valve = 701, // cmd: valve_state
  189. kreport_airCompressor_electric_current = 751, // report:electric_current(ma)
  190. /***********************************************************************************************************************
  191. * *
  192. ***********************************************************************************************************************/
  193. /**
  194. * @brief air Tightness Test AirCompressor
  195. * /
  196. *
  197. *
  198. *
  199. */
  200. kcmd_ATTAirCompressor_ctrl = 800, // cmd: power(0-100)
  201. kcmd_ATTAirCompressor_ctrl_safe_valve = 801, // cmd: valve_state
  202. /***********************************************************************************************************************
  203. * *
  204. ***********************************************************************************************************************/
  205. /**
  206. * @brief
  207. * /
  208. */
  209. kcmd_electromagnetic_valve_ctrl = 900, // cmd: valve_state
  210. /***********************************************************************************************************************
  211. * *
  212. ***********************************************************************************************************************/
  213. /**
  214. * @brief
  215. * /
  216. */
  217. kcmd_ball_valve_ctrl = 1000, // cmd: valve_state
  218. /***********************************************************************************************************************
  219. * *
  220. ***********************************************************************************************************************/
  221. /**
  222. * @brief
  223. * /
  224. *
  225. */
  226. kcmd_proportional_valve_ctrl = 1100, // cmd: subid valve_state(0->100)
  227. kreport_proportional_valve_value = 1150, // cmd: subid valve_state(0->100)
  228. /***********************************************************************************************************************
  229. * *
  230. ***********************************************************************************************************************/
  231. kreport_evaporation_bin_water_sensor = 1200, // report:state //蒸发仓水浸
  232. kreport_device_bottom_water_sensor = 1201, // report:state //设备底部水浸
  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. uint16_t subid;
  270. uint32_t pressure;
  271. } report_pressure_data_t;
  272. typedef struct {
  273. uint16_t subid;
  274. uint16_t h2o2; // ppm
  275. uint16_t humid; // %RH * 100
  276. uint16_t temp; // °C * 100
  277. uint16_t saturation; // %RS * 100
  278. } report_h2o2_data_t;
  279. typedef struct {
  280. uint16_t temperature; // 0.01
  281. } report_heater_temperature_data_t;
  282. typedef struct {
  283. uint16_t electric_current; // ma
  284. } report_heater_electric_current_data_t;
  285. typedef struct {
  286. uint16_t electric_current; // ma
  287. } report_blower_electric_current_data_t;
  288. typedef struct {
  289. uint16_t electric_current; // ma
  290. } report_airCompressor_electric_current_data_t;
  291. typedef struct {
  292. uint16_t subid; // 0->100
  293. uint16_t valve_state; // 0->100
  294. } report_proportional_valve_value_data_t;
  295. typedef struct {
  296. uint16_t state;
  297. } report_evaporation_bin_water_sensor_data_t;
  298. typedef struct {
  299. uint16_t state;
  300. } report_device_bottom_water_sensor_data_t;
  301. #pragma pack()
  302. }