| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556 |
- /**
- * weight_scale.h — 称重系统模块(fix20完整实现)
- * 从 plate_log2mqtt.cpp 完整迁移 F1-F12 功能
- * 包括:耀华仪表TCP通信、稳定读数检测、称重数据上报平台
- */
- #ifndef WEIGHT_SCALE_H
- #define WEIGHT_SCALE_H
- #include "common.h"
- #include <string>
- /**
- * 初始化称重系统(启动TCP客户端线程连接称重仪表)
- * @return true=初始化成功, false=未启用或失败
- */
- bool weight_scale_init();
- /**
- * 读取当前称重数据(阻塞等待稳定读数)
- * @param weight_kg 输出:重量(kg)
- * @param timeout_sec 超时秒数(实际使用g_weight_detection_time)
- * @return true=读取成功, false=超时或失败
- */
- bool weight_scale_read(double& weight_kg, int timeout_sec);
- /**
- * 关闭称重系统(停止TCP线程)
- */
- void weight_scale_close();
- /**
- * 提交称重+MQTT任务到异步队列(不阻塞主循环)
- * @param plate 车牌号
- * @param station_type 1=进站, 2=出站
- * @param tb_num 联单编号
- */
- void enqueue_weight_mqtt_task(const std::string& plate, int station_type,
- const std::string& tb_num);
- /**
- * 启动称重+MQTT异步worker线程
- */
- void start_weight_mqtt_worker();
- /**
- * 停止称重+MQTT异步worker线程
- */
- void stop_weight_mqtt_worker();
- /**
- * 手动重试称重上传(fix24-v9)
- * @param record_id 称重记录ID
- * @return true=重试成功, false=重试失败
- */
- bool weight_manual_retry(int record_id);
- #endif
|