将Feature/XP.Common和Feature/XP.Hardware分支合并至Develop/XP.forHardwareAndCommon,完善XPapp注册和相关硬件类库通用类库功能。

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