更新20260522
This commit is contained in:
@@ -9,9 +9,10 @@ namespace ConeCalorimeter.ViewModels;
|
||||
|
||||
public sealed class ConeRadiationSettingsViewModel : PageViewModel
|
||||
{
|
||||
private const ushort CurrentHeatFluxRegister = 32;
|
||||
private const ushort CurrentHeatFluxRegister = 410;
|
||||
private const ushort TargetTemperatureRegister = 400;
|
||||
private const ushort HeatTransferRegister = 418;
|
||||
private const double TargetTemperatureScale = 10;
|
||||
private const double CurrentHeatFluxMinimum = 0;
|
||||
private const double CurrentHeatFluxMaximum = 1000;
|
||||
private const double HeatTransferInputMinimum = 0;
|
||||
@@ -193,7 +194,7 @@ public sealed class ConeRadiationSettingsViewModel : PageViewModel
|
||||
|
||||
if (CanRefreshConeParameters())
|
||||
{
|
||||
TargetTemperatureText = ReadInt16Text(TargetTemperatureRegister);
|
||||
TargetTemperatureText = ReadScaledInt16Text(TargetTemperatureRegister, TargetTemperatureScale, "0.#");
|
||||
if (TryReadRangedFloatText(
|
||||
"ConeHeatTransfer",
|
||||
HeatTransferRegister,
|
||||
@@ -258,25 +259,34 @@ public sealed class ConeRadiationSettingsViewModel : PageViewModel
|
||||
return true;
|
||||
}
|
||||
|
||||
private string ReadInt16Text(ushort registerAddress)
|
||||
private string ReadScaledInt16Text(ushort registerAddress, double scale, string format)
|
||||
{
|
||||
return _tcpDeviceConnectionService.TryReadInt16(registerAddress, out var value)
|
||||
? value.ToString(CultureInfo.InvariantCulture)
|
||||
return _tcpDeviceConnectionService.TryReadInt16(registerAddress, out var rawValue)
|
||||
? (rawValue / scale).ToString(format, CultureInfo.InvariantCulture)
|
||||
: string.Empty;
|
||||
}
|
||||
|
||||
private bool WriteTargetTemperature()
|
||||
{
|
||||
if (!short.TryParse(TargetTemperatureText, NumberStyles.Integer, CultureInfo.InvariantCulture, out var value))
|
||||
if (!double.TryParse(TargetTemperatureText, NumberStyles.Float, CultureInfo.InvariantCulture, out var value)
|
||||
|| !double.IsFinite(value))
|
||||
{
|
||||
LastAction = "辐射温度输入无效";
|
||||
Debug.WriteLine($"Invalid cone radiation target temperature: {TargetTemperatureText}");
|
||||
return false;
|
||||
}
|
||||
|
||||
if (_tcpDeviceConnectionService.TryWriteInt16(TargetTemperatureRegister, value))
|
||||
var scaledValue = Math.Round(value * TargetTemperatureScale, MidpointRounding.AwayFromZero);
|
||||
if (scaledValue is < short.MinValue or > short.MaxValue)
|
||||
{
|
||||
TargetTemperatureText = value.ToString(CultureInfo.InvariantCulture);
|
||||
LastAction = "辐射温度输入超出范围";
|
||||
Debug.WriteLine($"Cone radiation target temperature out of range: {TargetTemperatureText}");
|
||||
return false;
|
||||
}
|
||||
|
||||
if (_tcpDeviceConnectionService.TryWriteInt16(TargetTemperatureRegister, (short)scaledValue))
|
||||
{
|
||||
TargetTemperatureText = value.ToString("0.#", CultureInfo.InvariantCulture);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@@ -142,7 +142,7 @@ public sealed class MainViewModel : ObservableObject
|
||||
+ "3.温度恒定后,打开隔热板;\n"
|
||||
+ " 打开风机;\n\n"
|
||||
+ "4.风速恒定后,点击测试;\n\n"
|
||||
+ "5.试样点燃后,点击【点火关】;\n\n"
|
||||
+ "5.点火时点击【点火开】,试样点燃后点击【点火关】;\n\n"
|
||||
+ "6.试样完全燃烧后,点击【停止】; 实验结束");
|
||||
}
|
||||
|
||||
|
||||
@@ -15,8 +15,8 @@ namespace ConeCalorimeter.ViewModels;
|
||||
public sealed class TestPageViewModel : PageViewModel
|
||||
{
|
||||
private const string ResetAction = "复位";
|
||||
private const ushort ResetCoil = 80;
|
||||
private const ushort ResetCompleteCoil = 82;
|
||||
private const ushort ResetCoil = 88;
|
||||
private const ushort ResetCompleteCoil = 89;
|
||||
|
||||
private readonly IExperimentDataService _experimentDataService;
|
||||
private readonly ITcpDeviceConnectionService _tcpDeviceConnectionService;
|
||||
@@ -81,6 +81,7 @@ public sealed class TestPageViewModel : PageViewModel
|
||||
new DeviceActionViewModel("测试结束", ExecuteDeviceActionCommand),
|
||||
new DeviceActionViewModel("风机开", ExecuteDeviceActionCommand),
|
||||
new DeviceActionViewModel("风机关", ExecuteDeviceActionCommand),
|
||||
new DeviceActionViewModel("点火开", ExecuteDeviceActionCommand),
|
||||
new DeviceActionViewModel("点火关", ExecuteDeviceActionCommand),
|
||||
_resetAction
|
||||
];
|
||||
@@ -387,8 +388,12 @@ public sealed class TestPageViewModel : PageViewModel
|
||||
case "测试结束":
|
||||
coilAddress = 67;
|
||||
return true;
|
||||
case "点火开":
|
||||
coilAddress = 53;
|
||||
return true;
|
||||
case "点火关":
|
||||
coilAddress = 53;
|
||||
value = false;
|
||||
return true;
|
||||
case "风机开":
|
||||
coilAddress = 54;
|
||||
|
||||
@@ -206,7 +206,7 @@
|
||||
<ItemsControl ItemsSource="{Binding DeviceActions}">
|
||||
<ItemsControl.ItemsPanel>
|
||||
<ItemsPanelTemplate>
|
||||
<UniformGrid Columns="2" Rows="5" />
|
||||
<UniformGrid Columns="3" Rows="4" />
|
||||
</ItemsPanelTemplate>
|
||||
</ItemsControl.ItemsPanel>
|
||||
<ItemsControl.ItemTemplate>
|
||||
|
||||
Reference in New Issue
Block a user