更新102
This commit is contained in:
@@ -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()
|
||||
|
||||
@@ -239,15 +239,25 @@
|
||||
<ColumnDefinition Width="150" />
|
||||
<ColumnDefinition Width="16" />
|
||||
<ColumnDefinition Width="76" />
|
||||
<ColumnDefinition Width="12" />
|
||||
<ColumnDefinition Width="120" />
|
||||
<ColumnDefinition Width="*" />
|
||||
</Grid.ColumnDefinitions>
|
||||
<TextBox Text="{Binding HeatTransferText, UpdateSourceTrigger=PropertyChanged}"
|
||||
Grid.Column="1"
|
||||
Style="{StaticResource ValueInputBoxStyle}" />
|
||||
Style="{StaticResource ValueInputBoxStyle}"
|
||||
GotKeyboardFocus="ConeParameterTextBox_GotKeyboardFocus"
|
||||
LostKeyboardFocus="ConeParameterTextBox_LostKeyboardFocus" />
|
||||
<TextBlock Grid.Column="3"
|
||||
Text="KW/M*k"
|
||||
FontSize="18"
|
||||
VerticalAlignment="Center" />
|
||||
<Button Grid.Column="5"
|
||||
Content="保存"
|
||||
Command="{Binding SaveParametersCommand}"
|
||||
Height="42"
|
||||
Style="{StaticResource InstrumentButtonStyle}"
|
||||
VerticalAlignment="Center" />
|
||||
</Grid>
|
||||
</StackPanel>
|
||||
|
||||
@@ -256,13 +266,25 @@
|
||||
Orientation="Horizontal"
|
||||
HorizontalAlignment="Center"
|
||||
Margin="0,14,0,0">
|
||||
<Button Content="开始升温"
|
||||
<Button Content="{Binding StartHeatingButtonText}"
|
||||
Command="{Binding ActionCommand}"
|
||||
CommandParameter="开始升温"
|
||||
Width="140"
|
||||
Height="42"
|
||||
Margin="0,0,10,0"
|
||||
Style="{StaticResource InstrumentPrimaryButtonStyle}" />
|
||||
Margin="0,0,10,0">
|
||||
<Button.Style>
|
||||
<Style TargetType="Button"
|
||||
BasedOn="{StaticResource InstrumentPrimaryButtonStyle}">
|
||||
<Style.Triggers>
|
||||
<DataTrigger Binding="{Binding HeatingActive}" Value="True">
|
||||
<Setter Property="Background" Value="#FDE8D0" />
|
||||
<Setter Property="BorderBrush" Value="#C86F12" />
|
||||
<Setter Property="Foreground" Value="#5C2D00" />
|
||||
</DataTrigger>
|
||||
</Style.Triggers>
|
||||
</Style>
|
||||
</Button.Style>
|
||||
</Button>
|
||||
<Button Content="停止升温"
|
||||
Command="{Binding ActionCommand}"
|
||||
CommandParameter="停止升温"
|
||||
@@ -277,46 +299,12 @@
|
||||
<Grid Grid.Row="2"
|
||||
Margin="24,12,24,16">
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="Auto" />
|
||||
<ColumnDefinition Width="150" />
|
||||
<ColumnDefinition Width="34" />
|
||||
<ColumnDefinition Width="Auto" />
|
||||
<ColumnDefinition Width="150" />
|
||||
<ColumnDefinition Width="24" />
|
||||
<ColumnDefinition Width="150" />
|
||||
<ColumnDefinition Width="16" />
|
||||
<ColumnDefinition Width="*" />
|
||||
<ColumnDefinition Width="150" />
|
||||
<ColumnDefinition Width="*" />
|
||||
</Grid.ColumnDefinitions>
|
||||
|
||||
<TextBlock Text="斜率:"
|
||||
FontSize="24"
|
||||
FontWeight="SemiBold"
|
||||
VerticalAlignment="Center" />
|
||||
<TextBox Grid.Column="1"
|
||||
Text="{Binding SlopeText, UpdateSourceTrigger=PropertyChanged}"
|
||||
Style="{StaticResource ValueInputBoxStyle}"
|
||||
GotKeyboardFocus="ConeParameterTextBox_GotKeyboardFocus"
|
||||
LostKeyboardFocus="ConeParameterTextBox_LostKeyboardFocus"
|
||||
VerticalAlignment="Center" />
|
||||
<TextBlock Grid.Column="3"
|
||||
Text="截距:"
|
||||
FontSize="24"
|
||||
FontWeight="SemiBold"
|
||||
VerticalAlignment="Center" />
|
||||
<TextBox Grid.Column="4"
|
||||
Text="{Binding InterceptText, UpdateSourceTrigger=PropertyChanged}"
|
||||
Style="{StaticResource ValueInputBoxStyle}"
|
||||
GotKeyboardFocus="ConeParameterTextBox_GotKeyboardFocus"
|
||||
LostKeyboardFocus="ConeParameterTextBox_LostKeyboardFocus"
|
||||
VerticalAlignment="Center" />
|
||||
<Button Grid.Column="6"
|
||||
Content="保存参数"
|
||||
Command="{Binding SaveParametersCommand}"
|
||||
Height="42"
|
||||
Style="{StaticResource InstrumentButtonStyle}"
|
||||
VerticalAlignment="Center" />
|
||||
<Button Grid.Column="8"
|
||||
<Button Grid.Column="1"
|
||||
Content="{Binding CirculatingWaterButtonText}"
|
||||
Command="{Binding ActionCommand}"
|
||||
CommandParameter="循环水"
|
||||
|
||||
Reference in New Issue
Block a user