Files
ASTM-D7896-19TransientHot-W…/Models/AppConfig.cs

77 lines
2.6 KiB
C#
Raw Normal View History

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;
public ushort StartCommand { get; set; } = 40010;
public ushort ResetCommand { get; set; } = 40011;
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;
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;
2026-05-15 20:39:11 +08:00
public CalibrationCoefficients CalibrationCoefficients { get; set; } = new();
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-04-18 19:00:34 +08:00
}