- config.toml 新增 [batch] 段(use_multi_process 默认 true、max_parallel_instances 默认 3) - SystemConfig.BatchConfig 模型 + ConfigManager 解析/回写 - ResolveMaxParallelInstances 完全由配置驱动(无硬编码默认值):配置缺失/无效明确报错; use_multi_process=false 时并发 1(串行);环境变量可临时覆盖 - 批处理页签新增"使用多进程并行执行"开关(默认开启,绑定配置并保存) - 部署目录 config.toml 手动追加 [batch] 段(default_config 是模板) 验证:2 项并行(配置并发 3)约 40s Completed,日志确认从 config 读取
351 lines
10 KiB
C#
351 lines
10 KiB
C#
|
||
using System.Collections.Generic;
|
||
|
||
namespace NavisworksTransport.Core.Config
|
||
{
|
||
/// <summary>
|
||
/// 系统配置根类
|
||
/// </summary>
|
||
public class SystemConfig
|
||
{
|
||
/// <summary>
|
||
/// 网格生成配置
|
||
/// </summary>
|
||
public GridGenerationConfig GridGeneration { get; set; }
|
||
|
||
/// <summary>
|
||
/// 路径规划配置
|
||
/// </summary>
|
||
public PathPlanningConfig PathPlanning { get; set; }
|
||
|
||
/// <summary>
|
||
/// 路径编辑配置
|
||
/// </summary>
|
||
public PathEditingConfig PathEditing { get; set; }
|
||
|
||
/// <summary>
|
||
/// 可视化配置
|
||
/// </summary>
|
||
public VisualizationConfig Visualization { get; set; }
|
||
|
||
/// <summary>
|
||
/// 动画配置
|
||
/// </summary>
|
||
public AnimationConfig Animation { get; set; }
|
||
|
||
/// <summary>
|
||
/// 物流属性配置
|
||
/// </summary>
|
||
public LogisticsConfig Logistics { get; set; }
|
||
|
||
/// <summary>
|
||
/// 坐标系配置
|
||
/// </summary>
|
||
public CoordinateSystemConfig CoordinateSystem { get; set; }
|
||
|
||
/// <summary>
|
||
/// 别名树配置
|
||
/// </summary>
|
||
public AliasTreeConfig AliasTree { get; set; }
|
||
|
||
/// <summary>
|
||
/// 批处理配置
|
||
/// </summary>
|
||
public BatchConfig Batch { get; set; } = new BatchConfig();
|
||
|
||
/// <summary>
|
||
/// 自定义类别列表
|
||
/// </summary>
|
||
public List<CustomCategoryConfigItem> CustomCategories { get; set; } = new List<CustomCategoryConfigItem>();
|
||
}
|
||
|
||
/// <summary>
|
||
/// 自定义类别配置项(极简版,只用名称作为标识)
|
||
/// </summary>
|
||
public class CustomCategoryConfigItem
|
||
{
|
||
/// <summary>
|
||
/// 类别名称(同时作为显示名称和唯一标识)
|
||
/// </summary>
|
||
public string Name { get; set; }
|
||
}
|
||
|
||
/// <summary>
|
||
/// 网格生成配置
|
||
/// </summary>
|
||
public class GridGenerationConfig
|
||
{
|
||
}
|
||
|
||
/// <summary>
|
||
/// 路径规划配置
|
||
/// </summary>
|
||
public class PathPlanningConfig
|
||
{
|
||
}
|
||
|
||
/// <summary>
|
||
/// 路径编辑配置
|
||
/// </summary>
|
||
public class PathEditingConfig
|
||
{
|
||
/// <summary>
|
||
/// 网格单元大小(米)
|
||
/// </summary>
|
||
public double CellSizeMeters { get; set; }
|
||
|
||
/// <summary>
|
||
/// 最大高度差(米)
|
||
/// </summary>
|
||
public double MaxHeightDiffMeters { get; set; }
|
||
|
||
/// <summary>
|
||
/// 物体长度(米)
|
||
/// </summary>
|
||
public double ObjectLengthMeters { get; set; }
|
||
|
||
/// <summary>
|
||
/// 物体宽度(米)
|
||
/// </summary>
|
||
public double ObjectWidthMeters { get; set; }
|
||
|
||
/// <summary>
|
||
/// 物体高度(米)
|
||
/// </summary>
|
||
public double ObjectHeightMeters { get; set; }
|
||
|
||
/// <summary>
|
||
/// 安全间隙(米)
|
||
/// </summary>
|
||
public double SafetyMarginMeters { get; set; }
|
||
|
||
/// <summary>
|
||
/// 路径默认转弯半径(米)
|
||
/// </summary>
|
||
public double DefaultPathTurnRadiusMeters { get; set; }
|
||
|
||
/// <summary>
|
||
/// 圆弧采样步长(米)
|
||
/// </summary>
|
||
public double ArcSamplingStepMeters { get; set; }
|
||
|
||
/// <summary>
|
||
/// 吊装路径自动视角距离(米)
|
||
/// </summary>
|
||
public double HoistingViewDistanceMeters { get; set; }
|
||
|
||
/// <summary>
|
||
/// 吊装路径自动视角仰角(度)
|
||
/// </summary>
|
||
public double HoistingViewElevationDegrees { get; set; }
|
||
|
||
/// <summary>
|
||
/// Rail 路径自动视角距离(米)
|
||
/// </summary>
|
||
public double RailViewDistanceMeters { get; set; }
|
||
|
||
/// <summary>
|
||
/// Rail 路径自动视角仰角(度)
|
||
/// </summary>
|
||
public double RailViewElevationDegrees { get; set; }
|
||
|
||
// === 模型单位接口(用于内部计算) ===
|
||
|
||
/// <summary>
|
||
/// 网格单元大小(模型单位)
|
||
/// </summary>
|
||
public double CellSize => CellSizeMeters * Utils.UnitsConverter.GetMetersToUnitsConversionFactor();
|
||
|
||
/// <summary>
|
||
/// 最大高度差(模型单位)
|
||
/// </summary>
|
||
public double MaxHeightDiff => MaxHeightDiffMeters * Utils.UnitsConverter.GetMetersToUnitsConversionFactor();
|
||
|
||
/// <summary>
|
||
/// 物体长度(模型单位)
|
||
/// </summary>
|
||
public double ObjectLength => ObjectLengthMeters * Utils.UnitsConverter.GetMetersToUnitsConversionFactor();
|
||
|
||
/// <summary>
|
||
/// 物体宽度(模型单位)
|
||
/// </summary>
|
||
public double ObjectWidth => ObjectWidthMeters * Utils.UnitsConverter.GetMetersToUnitsConversionFactor();
|
||
|
||
/// <summary>
|
||
/// 物体高度(模型单位)
|
||
/// </summary>
|
||
public double ObjectHeight => ObjectHeightMeters * Utils.UnitsConverter.GetMetersToUnitsConversionFactor();
|
||
|
||
/// <summary>
|
||
/// 安全间隙(模型单位)
|
||
/// </summary>
|
||
public double SafetyMargin => SafetyMarginMeters * Utils.UnitsConverter.GetMetersToUnitsConversionFactor();
|
||
|
||
/// <summary>
|
||
/// 路径默认转弯半径(模型单位)
|
||
/// </summary>
|
||
public double DefaultPathTurnRadius => DefaultPathTurnRadiusMeters * Utils.UnitsConverter.GetMetersToUnitsConversionFactor();
|
||
|
||
/// <summary>
|
||
/// 圆弧采样步长(模型单位)
|
||
/// </summary>
|
||
public double ArcSamplingStep => ArcSamplingStepMeters * Utils.UnitsConverter.GetMetersToUnitsConversionFactor();
|
||
|
||
/// <summary>
|
||
/// 吊装路径自动视角距离(模型单位)
|
||
/// </summary>
|
||
public double HoistingViewDistance => HoistingViewDistanceMeters * Utils.UnitsConverter.GetMetersToUnitsConversionFactor();
|
||
|
||
/// <summary>
|
||
/// Rail 路径自动视角距离(模型单位)
|
||
/// </summary>
|
||
public double RailViewDistance => RailViewDistanceMeters * Utils.UnitsConverter.GetMetersToUnitsConversionFactor();
|
||
}
|
||
|
||
/// <summary>
|
||
/// 可视化配置
|
||
/// </summary>
|
||
public class VisualizationConfig
|
||
{
|
||
/// <summary>
|
||
/// 地图边距比例
|
||
/// </summary>
|
||
public double MarginRatio { get; set; }
|
||
|
||
/// <summary>
|
||
/// 通行空间渲染透明度(0.0=完全透明,1.0=完全不透明)
|
||
/// 推荐值:0.3-0.6,根据实际模型场景调整
|
||
/// </summary>
|
||
public double PassageSpaceOpacity { get; set; }
|
||
}
|
||
|
||
/// <summary>
|
||
/// 动画配置
|
||
/// </summary>
|
||
public class AnimationConfig
|
||
{
|
||
/// <summary>
|
||
/// 动画帧率(帧/秒)
|
||
/// </summary>
|
||
public int FrameRate { get; set; }
|
||
|
||
/// <summary>
|
||
/// 动画持续时间(秒)
|
||
/// </summary>
|
||
public double DurationSeconds { get; set; }
|
||
|
||
/// <summary>
|
||
/// 检测容差(米)- 用于ClashDetective精确检测
|
||
/// </summary>
|
||
public double DetectionToleranceMeters { get; set; }
|
||
|
||
/// <summary>
|
||
/// 空间索引格子大小(米)- 用于动画碰撞检测的空间索引
|
||
/// </summary>
|
||
public double SpatialIndexCellSizeMeters { get; set; }
|
||
|
||
// === 模型单位接口(用于内部计算) ===
|
||
|
||
/// <summary>
|
||
/// 检测容差(模型单位)- 用于ClashDetective精确检测
|
||
/// </summary>
|
||
public double DetectionTolerance => DetectionToleranceMeters * Utils.UnitsConverter.GetMetersToUnitsConversionFactor();
|
||
|
||
/// <summary>
|
||
/// 空间索引格子大小(模型单位)- 用于动画碰撞检测的空间索引
|
||
/// </summary>
|
||
public double SpatialIndexCellSize => SpatialIndexCellSizeMeters * Utils.UnitsConverter.GetMetersToUnitsConversionFactor();
|
||
}
|
||
|
||
/// <summary>
|
||
/// 物流属性配置
|
||
/// </summary>
|
||
public class LogisticsConfig
|
||
{
|
||
/// <summary>
|
||
/// 可通行性
|
||
/// </summary>
|
||
public bool Traversable { get; set; }
|
||
|
||
/// <summary>
|
||
/// 优先级
|
||
/// </summary>
|
||
public int Priority { get; set; }
|
||
|
||
/// <summary>
|
||
/// 高度限制(米)
|
||
/// </summary>
|
||
public double HeightLimitMeters { get; set; }
|
||
|
||
/// <summary>
|
||
/// 速度限制(米/秒)
|
||
/// </summary>
|
||
public double SpeedLimitMetersPerSecond { get; set; }
|
||
|
||
/// <summary>
|
||
/// 宽度限制(米)
|
||
/// </summary>
|
||
public double WidthLimitMeters { get; set; }
|
||
|
||
// === 模型单位接口(用于内部计算) ===
|
||
|
||
/// <summary>
|
||
/// 高度限制(模型单位)
|
||
/// </summary>
|
||
public double HeightLimit => HeightLimitMeters * Utils.UnitsConverter.GetMetersToUnitsConversionFactor();
|
||
|
||
/// <summary>
|
||
/// 速度限制(模型单位/秒)
|
||
/// </summary>
|
||
public double SpeedLimit => SpeedLimitMetersPerSecond * Utils.UnitsConverter.GetMetersToUnitsConversionFactor();
|
||
|
||
/// <summary>
|
||
/// 宽度限制(模型单位)
|
||
/// </summary>
|
||
public double WidthLimit => WidthLimitMeters * Utils.UnitsConverter.GetMetersToUnitsConversionFactor();
|
||
}
|
||
|
||
/// <summary>
|
||
/// 坐标系配置
|
||
/// </summary>
|
||
public class CoordinateSystemConfig
|
||
{
|
||
/// <summary>
|
||
/// 坐标系类型
|
||
/// 可选值: "AutoDetect", "ZUp", "YUp"
|
||
/// AutoDetect: 基于 Document.UpVector 自动检测
|
||
/// ZUp: 强制使用 Z-Up 坐标系
|
||
/// YUp: 强制使用 Y-Up 坐标系
|
||
/// </summary>
|
||
public string Type { get; set; } = "AutoDetect";
|
||
|
||
}
|
||
|
||
/// <summary>
|
||
/// 别名树配置
|
||
/// </summary>
|
||
public class AliasTreeConfig
|
||
{
|
||
/// <summary>
|
||
/// 别名树完整展示的最大层级深度(0 = 仅根节点,默认 2)
|
||
/// </summary>
|
||
public int MaxFullDisplayDepth { get; set; } = 2;
|
||
}
|
||
|
||
/// <summary>
|
||
/// 批处理配置
|
||
/// </summary>
|
||
public class BatchConfig
|
||
{
|
||
/// <summary>
|
||
/// 是否启用多进程并行批处理(默认开启;关闭时并发数视为 1,串行执行)
|
||
/// </summary>
|
||
public bool UseMultiProcess { get; set; } = true;
|
||
|
||
/// <summary>
|
||
/// 并发副 Navisworks 实例数(默认 3,范围 1-20)
|
||
/// </summary>
|
||
public int MaxParallelInstances { get; set; } = 3;
|
||
}
|
||
}
|