using System.ComponentModel.DataAnnotations; namespace ASTM_D7896_Tester.Models; public class AppConfig { public PlcConnectionConfig PlcConnection { get; set; } = new(); public PlcRegisterAddresses PlcRegisterAddresses { get; set; } = new(); public TestParameters TestParameters { get; set; } = new(); public AppSettings AppSettings { get; set; } = new(); } public class PlcConnectionConfig { public string IpAddress { get; set; } = "127.0.0.1"; public int Port { get; set; } = 502; public int TimeoutMs { get; set; } = 5000; public byte SlaveId { get; set; } = 1; // 从站地址(默认1) } public class PlcRegisterAddresses { // 物理量寄存器 public ushort Temperature { get; set; } = 1376; public ushort Pressure { get; set; } = 1322; public ushort Resistance { get; set; } = 1422; // 计算结果寄存器(浮点数) public ushort ThermalConductivity { get; set; } = 40001; public ushort ThermalDiffusivity { get; set; } = 40003; public ushort StartCommand { get; set; } = 40010; public ushort ResetCommand { get; set; } = 40011; // 线圈地址(注意:Modbus 线圈地址通常从 0 开始,但用户给出的 M1300 等可能是实际地址) public ushort PressureCalibrationCoil { get; set; } = 1300; public ushort ResistanceZeroCoil { get; set; } = 1301; public ushort InletValveCoil { get; set; } = 5; public ushort OutletValveCoil { get; set; } = 6; } public class TestParameters { [Range(1, 100)] public int MeasurementCount { get; set; } = 10; [Range(5, 300)] public int IntervalSeconds { get; set; } = 30; public double PlatinumWireLength { get; set; } = 0.04; public double PlatinumWireDiameter { get; set; } = 0.00006; public string ReportOutputPath { get; set; } = "Reports\\"; public double DefaultSampleVolume { get; set; } = 40.0; public double DefaultPressure { get; set; } = 0.0; public bool UsePressure { get; set; } = false; public string ReferenceLiquid { get; set; } = "蒸馏水"; public double ReferenceConductivity { get; set; } = 0.606; public CalibrationCoefficients CalibrationCoefficients { get; set; } = new(); } public class AppSettings { public int WindowWidth { get; set; } = 1024; public int WindowHeight { get; set; } = 768; public string ThemeColor { get; set; } = "Blue"; } public class CalibrationCoefficients { public ushort PressureCoefficient { get; set; } public ushort PressureProtection { get; set; } public ushort TemperatureCoefficient { get; set; } public ushort ResistanceCoefficient { get; set; } }