weight_scale.h 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. /**
  2. * weight_scale.h — 称重系统模块(fix20完整实现)
  3. * 从 plate_log2mqtt.cpp 完整迁移 F1-F12 功能
  4. * 包括:耀华仪表TCP通信、稳定读数检测、称重数据上报平台
  5. */
  6. #ifndef WEIGHT_SCALE_H
  7. #define WEIGHT_SCALE_H
  8. #include "common.h"
  9. #include <string>
  10. /**
  11. * 初始化称重系统(启动TCP客户端线程连接称重仪表)
  12. * @return true=初始化成功, false=未启用或失败
  13. */
  14. bool weight_scale_init();
  15. /**
  16. * 读取当前称重数据(阻塞等待稳定读数)
  17. * @param weight_kg 输出:重量(kg)
  18. * @param timeout_sec 超时秒数(实际使用g_weight_detection_time)
  19. * @return true=读取成功, false=超时或失败
  20. */
  21. bool weight_scale_read(double& weight_kg, int timeout_sec);
  22. /**
  23. * 关闭称重系统(停止TCP线程)
  24. */
  25. void weight_scale_close();
  26. /**
  27. * 提交称重+MQTT任务到异步队列(不阻塞主循环)
  28. * @param plate 车牌号
  29. * @param station_type 1=进站, 2=出站
  30. * @param tb_num 联单编号
  31. */
  32. void enqueue_weight_mqtt_task(const std::string& plate, int station_type,
  33. const std::string& tb_num);
  34. /**
  35. * 启动称重+MQTT异步worker线程
  36. */
  37. void start_weight_mqtt_worker();
  38. /**
  39. * 停止称重+MQTT异步worker线程
  40. */
  41. void stop_weight_mqtt_worker();
  42. /**
  43. * 手动重试称重上传(fix24-v9)
  44. * @param record_id 称重记录ID
  45. * @return true=重试成功, false=重试失败
  46. */
  47. bool weight_manual_retry(int record_id);
  48. #endif