96 lines
3.4 KiB
C#
96 lines
3.4 KiB
C#
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; } = 4;
|
||
public ushort ResetCommand { get; set; } = 4;
|
||
|
||
// 线圈地址(注意: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.040; // 默认 5.6 cm
|
||
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 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)
|
||
|
||
|
||
|
||
//public double FitStartTime { get; set; } = 0.01; // 默认0.35秒,避开早期扰动
|
||
//public double FitEndTime { get; set; } = 0.1;
|
||
|
||
public double FitStartTime { get; set; } = 0.25; // 默认0.35秒,避开早期扰动
|
||
public double FitEndTime { get; set; } = 0.60;
|
||
|
||
|
||
|
||
}
|
||
|
||
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; }
|
||
public double ThermalConductivityCorrection { get; set; } = 47.305349f;//蒸馏水 比热率修正
|
||
public double ThermalDiffusivityCorrection { get; set; } = 0.3469589023611997;//导热率修正
|
||
} |