using System; namespace XP.Hardware.RaySource.Config { /// /// 射线源配置实体类 | X-Ray Source Configuration Entity /// 包含PVI通讯参数、硬件参数和操作超时配置 | Contains PVI communication parameters, hardware parameters, and operation timeout configuration /// public class RaySourceConfig { #region PVI通讯参数 | PVI Communication Parameters /// /// 射线源类型 | Ray source type /// 可选值: Comet225 | Available values: Comet225 /// public string SourceType { get; set; } = "Comet225"; /// /// PLC IP地址 | PLC IP Address /// public string PlcIpAddress { get; set; } = "192.168.12.10"; /// /// PLC端口号 | PLC Port Number /// public int PlcPort { get; set; } = 11159; /// /// 源站号 | Source Station Number /// public int StationNumber { get; set; } = 1; /// /// 源端口号 | Source Port Number /// public int PortNumber { get; set; } = 11; /// /// CPU名称 | CPU Name /// public string CpuName { get; set; } = "cpu"; /// /// 连接超时时间(毫秒)| Connection timeout (milliseconds) /// public int ConnectionTimeout { get; set; } = 5000; #endregion #region 硬件参数范围 | Hardware Parameter Ranges /// /// 最小电压(kV)| Minimum voltage (kV) /// public float MinVoltage { get; set; } = 20f; /// /// 最大电压(kV)| Maximum voltage (kV) /// public float MaxVoltage { get; set; } = 225f; /// /// 最小电流(μA)| Minimum current (μA) /// public float MinCurrent { get; set; } = 10f; /// /// 最大电流(μA)| Maximum current (μA) /// public float MaxCurrent { get; set; } = 1000f; #endregion #region 外部程序配置 | External Program Configuration /// /// 高级设置外部程序路径 | Advance settings external program path /// public string AdvanceExePath { get; set; } = @"C:\Program Files (x86)\Feinfocus\FXEControl_3.1.1.65\FXEControl.exe"; /// /// Host 进程可执行文件路径(可选) /// 为空时默认在主程序输出目录下查找 XP.Hardware.RaySource.Comet.Host.exe /// public string HostExePath { get; set; } #endregion #region 操作超时配置 | Operation Timeout Configuration /// /// 初始化超时时间(毫秒)| Initialization timeout (milliseconds) /// public int InitializationTimeout { get; set; } = 30000; /// /// 暖机超时时间(毫秒)| Warm-up timeout (milliseconds) /// public int WarmUpTimeout { get; set; } = 300000; // 5分钟 /// /// 启动超时时间(毫秒)| Startup timeout (milliseconds) /// public int StartUpTimeout { get; set; } = 180000; // 3分钟 /// /// 自动定心超时时间(毫秒)| Auto-center timeout (milliseconds) /// public int AutoCenterTimeout { get; set; } = 120000; // 2分钟 /// /// 灯丝调整超时时间(毫秒)| Filament adjust timeout (milliseconds) /// public int FilamentAdjustTimeout { get; set; } = 120000; // 2分钟 /// /// 一般操作超时时间(毫秒)| General operation timeout (milliseconds) /// public int GeneralOperationTimeout { get; set; } = 10000; #endregion #region 灯丝寿命配置 | Filament Lifetime Configuration /// /// 射线源序列号 | Ray source serial number /// 用于唯一标识设备,灯丝寿命管理依赖此字段匹配设备记录 /// Used to uniquely identify the device, filament lifetime management relies on this field to match device records /// public string SerialNumber { get; set; } = ""; /// /// 灯丝总寿命阈值(小时)| Filament total lifetime threshold (hours) /// 默认值为 1000 小时,超过阈值时系统将发出预警 /// Default value is 1000 hours, system will issue a warning when threshold is exceeded /// public int TotalLifeThreshold { get; set; } = 1000; #endregion /// /// 验证配置参数有效性 | Validate configuration parameters /// /// 验证结果 | Validation result public (bool IsValid, string ErrorMessage) Validate() { if (string.IsNullOrWhiteSpace(PlcIpAddress)) return (false, "PLC IP地址不能为空"); if (PlcPort <= 0 || PlcPort > 65535) return (false, "PLC端口号必须在1-65535之间"); if (MinVoltage >= MaxVoltage) return (false, "最小电压必须小于最大电压"); if (MinCurrent >= MaxCurrent) return (false, "最小电流必须小于最大电流"); if (ConnectionTimeout <= 0) return (false, "连接超时时间必须大于0"); return (true, null); } } }