You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

49 lines
2.6 KiB
C

2 months ago
// 全局配置:变量声明 + 配置加载接口
#ifndef CONFIG_H
#define CONFIG_H
#include <string>
#include <vector>
#include <utility>
#include <cstdint>
// ==================== 常量(编译期固定) ====================
const uint32_t OPEN_TIMEOUT_MS = 3000; // 连接超时(ms)
const uint16_t FRAME_TIMEOUT_MS = 2000; // 获取帧数据超时(ms)
const bool FILTER_ENABLE = true; // 多边形过滤开关
const bool SHIFT_Y_POSITIVE = true; // Y值上移使最小Y≥0
const int SLICE_IMG_SIZE = 800; // 截面图片最大像素尺寸
const double ORIGIN_TOL_MM = 0.5; // 原点无效点判定容差(mm)
// ==================== 运行时配置变量(load_config 加载) ====================
extern std::string Leida_IP; // 雷达IP
extern uint16_t Leida_PORT; // 雷达数据端口
extern int Collect_Duration_S; // exe模式/默认扫描时长(秒)
extern double Speed_Z; // Z轴速度(cm/s),0=时间(ms),>0=移动距离(mm)
extern bool Log_Flag; // 是否写日志文件
extern double Z_RANGE_MM; // Z截面区间长度(mm)
extern double Y_RANGE_MM; // Y截面区间长度(mm)
extern double Lidar_Hz; // 雷达帧率(Hz)
extern int Rect_Width_PX; // 截面矩形宽度(px)
extern double Rect_Length_Ratio; // 矩形长倍率
extern std::string Run_Mode; // exe=直接检测一次, tcp=服务端模式
extern uint16_t Tcp_Port; // TCP监听端口
extern double Floor_Height; // 地板高度(mm): 物品高度=Floor_Height-Y
extern double Count_Base_Tolerance; // 分层初始冗余(mm)
extern double Count_Additional_Tolerance_Per_Level; // 每层递增冗余(mm)
extern int Point_Dilate; // 画layer图每个点膨胀像素
extern std::string Z_Interpolate_Mode; // none/CopyTranslation/AngleBucketInterpolation
extern int Log_Retain_Days; // 日志(任务目录)保留天数, 超出自动删除
extern int Tuo_Wei; // 拖尾滤波 0关1弱2中3强
extern int Qian_Chong; // 前冲滤波 0关1弱2中3强
extern int Yuan_Duan; // 远端高反 0关1弱2强
extern bool Jin_Duan; // 近端高反识别
extern std::vector<std::pair<double, double>> Filter_Polygon; // 过滤多边形(mm)
extern int Filter_Poly_N; // 多边形顶点数
// 加载 JSON 格式配置文件(行首(忽略空白)以 // 开头的注释行会被剔除)
// path 不存在时打印错误并退出
void load_config(const std::string& path = "./config/config");
#endif // CONFIG_H