feat: add AngleDisplay MVVM UserControl for advance monitoring

Refactors the old AngleDisplay code-behind into a clean MVVM implementation
with AngleDisplayViewModel (PSG/INJ/Manual encoder angles, zero references,
lock angle calculation with tolerance color coding) and a pure XAML view.
Wires LockAngleFaseReady and PsgModeFaseReady test phase events.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-04-11 15:16:15 +02:00
parent e343006f45
commit d34e81163a
5 changed files with 449 additions and 0 deletions

View File

@@ -0,0 +1,134 @@
<UserControl x:Class="HC_APTBS.Views.UserControls.AngleDisplayView"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d"
d:DesignHeight="200" d:DesignWidth="500">
<Border Margin="0,4">
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="Auto"/>
<RowDefinition Height="*"/>
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto"/>
<ColumnDefinition Width="100"/>
<ColumnDefinition Width="*"/>
</Grid.ColumnDefinitions>
<!-- Header -->
<TextBlock Grid.ColumnSpan="3" Text="ADVANCE MONITORING"
HorizontalAlignment="Center" FontSize="20"
FontWeight="Bold" FontStyle="Italic"
Foreground="DimGray" Margin="0,0,0,4"/>
<!-- ── Column 0: PSG + INJ encoder readouts ── -->
<StackPanel Grid.Row="1" Grid.Column="0">
<!-- PSG row -->
<StackPanel Orientation="Horizontal" Height="56" Margin="0,2">
<Button Content="0" Width="28" Height="28" FontWeight="Bold"
VerticalAlignment="Center" Margin="0,0,4,0"
Command="{Binding SetPsgZeroCommand}"
ToolTip="Set PSG zero reference"/>
<Border Style="{DynamicResource LcdBlue}" Padding="4,0" Width="170">
<DockPanel>
<TextBlock Text="PSG:" DockPanel.Dock="Left"
VerticalAlignment="Bottom" Margin="2,0,0,8"
FontSize="10" FontWeight="Bold"
Foreground="{Binding PsgAngleForeground}"/>
<TextBlock Text="{Binding PsgEncoderAngle}" DockPanel.Dock="Right"
VerticalAlignment="Top" HorizontalAlignment="Right"
Margin="0,6,4,0" FontSize="12"
Foreground="LightGray" FontFamily="Consolas"/>
<TextBlock Text="{Binding PsgRelativeAngle}"
HorizontalAlignment="Center" VerticalAlignment="Center"
FontSize="30" FontWeight="Bold" FontFamily="Consolas"
Foreground="{Binding PsgAngleForeground}"/>
</DockPanel>
</Border>
</StackPanel>
<!-- INJ row -->
<StackPanel Orientation="Horizontal" Height="56" Margin="0,2">
<Button Content="0" Width="28" Height="28" FontWeight="Bold"
VerticalAlignment="Center" Margin="0,0,4,0"
Command="{Binding SetInjZeroCommand}"
ToolTip="Set INJ zero reference"/>
<Border Style="{DynamicResource LcdBlue}" Padding="4,0" Width="170">
<DockPanel>
<TextBlock Text="INJ:" DockPanel.Dock="Left"
VerticalAlignment="Bottom" Margin="2,0,0,8"
FontSize="10" FontWeight="Bold"
Foreground="{Binding InjAngleForeground}"/>
<TextBlock Text="{Binding InjEncoderAngle}" DockPanel.Dock="Right"
VerticalAlignment="Top" HorizontalAlignment="Right"
Margin="0,6,4,0" FontSize="12"
Foreground="LightGray" FontFamily="Consolas"/>
<TextBlock Text="{Binding InjRelativeAngle}"
HorizontalAlignment="Center" VerticalAlignment="Center"
FontSize="30" FontWeight="Bold" FontFamily="Consolas"
Foreground="{Binding InjAngleForeground}"/>
</DockPanel>
</Border>
</StackPanel>
</StackPanel>
<!-- ── Column 1: Delta angle input ── -->
<StackPanel Grid.Row="1" Grid.Column="1" VerticalAlignment="Bottom"
Margin="8,0" Height="60">
<TextBlock Text="Δº" FontSize="16" FontWeight="Bold"
HorizontalAlignment="Center" Margin="0,0,0,2"/>
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto"/>
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="Auto"/>
</Grid.ColumnDefinitions>
<TextBlock Text="+" FontSize="14" VerticalAlignment="Center"
Margin="0,0,4,0"/>
<TextBox Grid.Column="1"
Text="{Binding LockAngleDeltaInput, UpdateSourceTrigger=PropertyChanged}"
FontSize="14" FontFamily="Consolas" Height="28"
VerticalContentAlignment="Center" HorizontalContentAlignment="Center"
Padding="4,2"/>
<TextBlock Grid.Column="2" Text="=" FontSize="14"
VerticalAlignment="Center" Margin="4,0,0,0"/>
</Grid>
</StackPanel>
<!-- ── Column 2: Manual (ABS) + Lock angle displays ── -->
<StackPanel Grid.Row="1" Grid.Column="2" Margin="4,0,0,0">
<!-- ABS (manual encoder) -->
<Border Style="{DynamicResource LcdBlue}" Height="56" Margin="0,2" Padding="4,0">
<DockPanel>
<TextBlock Text="ABS º:" DockPanel.Dock="Left"
VerticalAlignment="Bottom" Margin="4,0,0,8"
FontSize="10" FontWeight="Bold" Foreground="#FFEBEBFF"/>
<TextBlock Text="{Binding ManualAngleText}"
HorizontalAlignment="Center" VerticalAlignment="Center"
FontSize="32" FontWeight="Bold" FontFamily="Consolas"
Foreground="#FFEBEBFF"/>
</DockPanel>
</Border>
<!-- LOCK angle result -->
<Border Style="{DynamicResource LcdBlue}" Height="56" Margin="0,2" Padding="4,0">
<DockPanel>
<TextBlock Text="LOCK º:" DockPanel.Dock="Left"
VerticalAlignment="Bottom" Margin="4,0,0,8"
FontSize="10" FontWeight="Bold" Foreground="#FFEBEBFF"/>
<TextBlock Text="{Binding LockAngleDisplay}"
HorizontalAlignment="Center" VerticalAlignment="Center"
FontSize="32" FontWeight="Bold" FontFamily="Consolas"
Foreground="{Binding LockAngleForeground}"/>
</DockPanel>
</Border>
</StackPanel>
</Grid>
</Border>
</UserControl>

View File

@@ -0,0 +1,16 @@
using System.Windows.Controls;
namespace HC_APTBS.Views.UserControls
{
/// <summary>
/// Advance monitoring display for PSG, Injector, and Manual encoder angles.
/// All logic resides in <see cref="ViewModels.AngleDisplayViewModel"/>.
/// </summary>
public partial class AngleDisplayView : UserControl
{
public AngleDisplayView()
{
InitializeComponent();
}
}
}