2026-04-18 19:00:34 +08:00
|
|
|
|
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();
|
2026-05-15 20:39:11 +08:00
|
|
|
|
|
2026-04-18 19:00:34 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public class PlcConnectionConfig
|
|
|
|
|
|
{
|
|
|
|
|
|
public string IpAddress { get; set; } = "127.0.0.1";
|
|
|
|
|
|
public int Port { get; set; } = 502;
|
|
|
|
|
|
public int TimeoutMs { get; set; } = 5000;
|
2026-05-15 20:39:11 +08:00
|
|
|
|
|
|
|
|
|
|
public byte SlaveId { get; set; } = 1; // 从站地址(默认1)
|
2026-04-18 19:00:34 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public class PlcRegisterAddresses
|
|
|
|
|
|
{
|
2026-05-15 21:10:42 +08:00
|
|
|
|
// 物理量寄存器
|
|
|
|
|
|
public ushort Temperature { get; set; } = 1376;
|
|
|
|
|
|
public ushort Pressure { get; set; } = 1322;
|
|
|
|
|
|
public ushort Resistance { get; set; } = 1422;
|
|
|
|
|
|
|
|
|
|
|
|
// 计算结果寄存器(浮点数)
|
2026-05-15 20:39:11 +08:00
|
|
|
|
public ushort ThermalConductivity { get; set; } = 40001;
|
|
|
|
|
|
public ushort ThermalDiffusivity { get; set; } = 40003;
|
2026-05-20 13:49:45 +08:00
|
|
|
|
public ushort StartCommand { get; set; } = 4;
|
|
|
|
|
|
public ushort ResetCommand { get; set; } = 4;
|
2026-05-15 20:39:11 +08:00
|
|
|
|
|
2026-05-15 21:10:42 +08:00
|
|
|
|
// 线圈地址(注意: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;
|
2026-04-18 19:00:34 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public class TestParameters
|
|
|
|
|
|
{
|
|
|
|
|
|
[Range(1, 100)]
|
|
|
|
|
|
public int MeasurementCount { get; set; } = 10;
|
|
|
|
|
|
[Range(5, 300)]
|
|
|
|
|
|
public int IntervalSeconds { get; set; } = 30;
|
2026-05-29 18:35:36 +08:00
|
|
|
|
public double PlatinumWireLength { get; set; } = 0.056; // 默认 5.6 cm
|
2026-04-18 19:00:34 +08:00
|
|
|
|
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;
|
2026-05-15 20:39:11 +08:00
|
|
|
|
|
|
|
|
|
|
public CalibrationCoefficients CalibrationCoefficients { get; set; } = new();
|
2026-05-29 15:32:13 +08:00
|
|
|
|
|
2026-05-29 18:35:36 +08:00
|
|
|
|
// 可选:强制使用固定的物性值,便于测试和校准
|
|
|
|
|
|
public bool UseFixedAlpha { get; set; } = false;
|
|
|
|
|
|
public double FixedAlpha { get; set; } = 1.4e-7; // m^2/s
|
|
|
|
|
|
public bool UseFixedLambda { get; set; } = false;
|
|
|
|
|
|
public double FixedLambda { get; set; } = 0.606; // W/(m·K)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2026-06-01 19:25:57 +08:00
|
|
|
|
public double FitStartTime { get; set; } = 0.01; // 默认0.35秒,避开早期扰动
|
|
|
|
|
|
public double FitEndTime { get; set; } = 0.1;
|
2026-05-29 18:35:36 +08:00
|
|
|
|
|
|
|
|
|
|
|
2026-05-29 15:32:13 +08:00
|
|
|
|
|
2026-04-18 19:00:34 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public class AppSettings
|
|
|
|
|
|
{
|
|
|
|
|
|
public int WindowWidth { get; set; } = 1024;
|
|
|
|
|
|
public int WindowHeight { get; set; } = 768;
|
|
|
|
|
|
public string ThemeColor { get; set; } = "Blue";
|
2026-05-15 20:39:11 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public class CalibrationCoefficients
|
|
|
|
|
|
{
|
|
|
|
|
|
public ushort PressureCoefficient { get; set; }
|
|
|
|
|
|
public ushort PressureProtection { get; set; }
|
|
|
|
|
|
public ushort TemperatureCoefficient { get; set; }
|
|
|
|
|
|
public ushort ResistanceCoefficient { get; set; }
|
2026-05-29 15:32:13 +08:00
|
|
|
|
|
|
|
|
|
|
public double ThermalConductivityCorrection { get; set; } = 0.606;
|
|
|
|
|
|
public double ThermalDiffusivityCorrection { get; set; } = 19.9;
|
2026-04-18 19:00:34 +08:00
|
|
|
|
}
|