diff --git a/ConeCalorimeter/ViewModels/ConeRadiationSettingsViewModel.cs b/ConeCalorimeter/ViewModels/ConeRadiationSettingsViewModel.cs
index d0fb753..b8305b6 100644
--- a/ConeCalorimeter/ViewModels/ConeRadiationSettingsViewModel.cs
+++ b/ConeCalorimeter/ViewModels/ConeRadiationSettingsViewModel.cs
@@ -10,11 +10,11 @@ public sealed class ConeRadiationSettingsViewModel : PageViewModel
{
private const ushort CurrentTemperatureRegister = 26;
private const ushort TargetTemperatureRegister = 400;
- private const ushort CurrentHeatFluxRegister = 32;
- private const ushort SlopeRegister = 420;
- private const ushort InterceptRegister = 422;
+ private const ushort CurrentHeatFluxRegister = 410;
+ private const ushort HeatTransferRegister = 418;
private const ushort AlarmCoil = 91;
private const ushort CirculatingWaterCoil = 49;
+ private const ushort HeatingCoil = 102;
private const string CirculatingWaterAction = "循环水";
private readonly Action _closeAction;
@@ -25,11 +25,10 @@ public sealed class ConeRadiationSettingsViewModel : PageViewModel
private string _currentHeatFluxText = "";
private string _targetTemperatureText = "";
private string _heatTransferText = "";
- private string _slopeText = "";
- private string _interceptText = "";
private string _lastAction = "待机";
private bool _alarmActive;
private bool _circulatingWaterActive;
+ private bool _heatingActive;
private bool _isEditingConeParameters;
public ConeRadiationSettingsViewModel(
@@ -86,18 +85,6 @@ public sealed class ConeRadiationSettingsViewModel : PageViewModel
set => SetProperty(ref _heatTransferText, value);
}
- public string SlopeText
- {
- get => _slopeText;
- set => SetProperty(ref _slopeText, value);
- }
-
- public string InterceptText
- {
- get => _interceptText;
- set => SetProperty(ref _interceptText, value);
- }
-
public string LastAction
{
get => _lastAction;
@@ -124,6 +111,20 @@ public sealed class ConeRadiationSettingsViewModel : PageViewModel
public string CirculatingWaterButtonText => CirculatingWaterActive ? "循环水:开启" : "循环水:关闭";
+ public bool HeatingActive
+ {
+ get => _heatingActive;
+ private set
+ {
+ if (SetProperty(ref _heatingActive, value))
+ {
+ OnPropertyChanged(nameof(StartHeatingButtonText));
+ }
+ }
+ }
+
+ public string StartHeatingButtonText => HeatingActive ? "加热中" : "开始升温";
+
public void BeginConeParameterEdit()
{
_isEditingConeParameters = true;
@@ -165,11 +166,11 @@ public sealed class ConeRadiationSettingsViewModel : PageViewModel
CurrentHeatFluxText = ReadFloatText(CurrentHeatFluxRegister);
if (!_isEditingConeParameters)
{
- SlopeText = ReadFloatText(SlopeRegister);
- InterceptText = ReadFloatText(InterceptRegister);
+ HeatTransferText = ReadFloatText(HeatTransferRegister);
}
AlarmActive = _tcpDeviceConnectionService.TryReadCoil(AlarmCoil, out var alarmActive) && alarmActive;
+ HeatingActive = _tcpDeviceConnectionService.TryReadCoil(HeatingCoil, out var heatingActive) && heatingActive;
if (_tcpDeviceConnectionService.TryReadCoil(CirculatingWaterCoil, out var circulatingWaterActive))
{
CirculatingWaterActive = circulatingWaterActive;
@@ -187,6 +188,7 @@ public sealed class ConeRadiationSettingsViewModel : PageViewModel
{
if (!short.TryParse(TargetTemperatureText, NumberStyles.Integer, CultureInfo.InvariantCulture, out var value))
{
+ LastAction = "辐射温度输入无效";
Debug.WriteLine($"Invalid cone radiation target temperature: {TargetTemperatureText}");
return;
}
@@ -200,31 +202,21 @@ public sealed class ConeRadiationSettingsViewModel : PageViewModel
private void SaveParameters()
{
- if (!float.TryParse(SlopeText, NumberStyles.Float, CultureInfo.InvariantCulture, out var slope))
+ if (!float.TryParse(HeatTransferText, NumberStyles.Float, CultureInfo.InvariantCulture, out var heatTransfer))
{
- LastAction = "斜率输入无效";
- Debug.WriteLine($"Invalid cone radiation slope: {SlopeText}");
+ LastAction = "热传递输入无效";
+ Debug.WriteLine($"Invalid cone radiation heat transfer: {HeatTransferText}");
return;
}
- if (!float.TryParse(InterceptText, NumberStyles.Float, CultureInfo.InvariantCulture, out var intercept))
+ if (_tcpDeviceConnectionService.TryWriteFloat(HeatTransferRegister, heatTransfer))
{
- LastAction = "截距输入无效";
- Debug.WriteLine($"Invalid cone radiation intercept: {InterceptText}");
+ LastAction = "热传递保存成功";
return;
}
- var slopeWritten = _tcpDeviceConnectionService.TryWriteFloat(SlopeRegister, slope);
- var interceptWritten = _tcpDeviceConnectionService.TryWriteFloat(InterceptRegister, intercept);
-
- if (slopeWritten && interceptWritten)
- {
- LastAction = "参数保存成功";
- return;
- }
-
- LastAction = "参数保存失败";
- Debug.WriteLine($"Cone radiation parameters write failed. Slope: {slopeWritten}, intercept: {interceptWritten}.");
+ LastAction = "热传递保存失败";
+ Debug.WriteLine("Cone radiation heat transfer write failed.");
}
private void ToggleCirculatingWater()
diff --git a/ConeCalorimeter/Views/ConeRadiationSettingsView.xaml b/ConeCalorimeter/Views/ConeRadiationSettingsView.xaml
index beadf27..6dfa538 100644
--- a/ConeCalorimeter/Views/ConeRadiationSettingsView.xaml
+++ b/ConeCalorimeter/Views/ConeRadiationSettingsView.xaml
@@ -239,15 +239,25 @@
+
+
+ Style="{StaticResource ValueInputBoxStyle}"
+ GotKeyboardFocus="ConeParameterTextBox_GotKeyboardFocus"
+ LostKeyboardFocus="ConeParameterTextBox_LostKeyboardFocus" />
+
@@ -256,13 +266,25 @@
Orientation="Horizontal"
HorizontalAlignment="Center"
Margin="0,14,0,0">
-
+ Margin="0,0,10,0">
+
+
+
+