From 559890c482f5973f06aafdfec9550fee5ba3c7f2 Mon Sep 17 00:00:00 2001
From: wenxiangchao <wenxiangchao@ihengxin.com.cn>
Date: 星期一, 09 十一月 2026 17:02:15 +0800
Subject: [PATCH] feat: CAN 模拟器 TCP 化 + 多设备并发调试 + 后台生命周期管理

---
 Plugin.DeviceDebug/DeviceDebug.xaml |  141 +++-------------------------------------------
 1 files changed, 10 insertions(+), 131 deletions(-)

diff --git a/Plugin.DeviceDebug/DeviceDebug.xaml b/Plugin.DeviceDebug/DeviceDebug.xaml
index 6de3a4b..b6e4d6f 100644
--- a/Plugin.DeviceDebug/DeviceDebug.xaml
+++ b/Plugin.DeviceDebug/DeviceDebug.xaml
@@ -5,12 +5,10 @@
              xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
              xmlns:hb="clr-namespace:HMI.Base;assembly=HMI.Base"
              xmlns:ui="clr-namespace:HMI.UI;assembly=HMI.UI"
-             xmlns:uic="clr-namespace:HMI.UI.Converter;assembly=HMI.UI"
              xmlns:pw="https://opensource.panuon.com/wpf"
              xmlns:pu="https://opensource.panuon.com/wpf-ui"
              xmlns:dp="clr-namespace:HMI.UI.DpUtil;assembly=HMI.UI"
              xmlns:local="clr-namespace:Plugin.DeviceDebug"
-             xmlns:panels="clr-namespace:Plugin.DeviceDebug.Panels"
              mc:Ignorable="d"
              Loaded="SimpleMaskControl_Loaded"
              d:DesignHeight="600" d:DesignWidth="1000">
@@ -25,153 +23,34 @@
                 <Setter Property="Padding" Value="8,4"/>
                 <Setter Property="VerticalAlignment" Value="Center"/>
             </Style>
-            <BooleanToVisibilityConverter x:Key="BoolToVis"/>
         </ResourceDictionary>
     </hb:SimpleMaskControl.Resources>
 
     <Grid dp:GridHelper.Space="8">
         <Grid.RowDefinitions>
             <RowDefinition Height="Auto"/>
-            <RowDefinition Height="Auto"/>
-            <RowDefinition Height="Auto"/>
             <RowDefinition Height="*"/>
         </Grid.RowDefinitions>
 
-        <!-- 椤堕儴鏍囬鏍� -->
+        <!-- 椤堕儴锛氭爣棰� + 璁惧閫夋嫨 + 鍔犲叆/鍏抽棴 -->
         <DockPanel Grid.Row="0">
             <StackPanel dp:StackPanelHelper.ChildSpace="10" DockPanel.Dock="Right" Orientation="Horizontal">
                 <ComboBox x:Name="deviceSelector" Width="240" 
                           ItemsSource="{Binding DeviceList}"
                           SelectedItem="{Binding SelectedDevice}"
-                          SelectionChanged="DeviceSelector_SelectionChanged"
                           VerticalContentAlignment="Center" Padding="6,4"/>
+                <Button x:Name="addDeviceBtn" Content="鍔犲叆璋冭瘯" Width="90" Height="28"
+                        Click="AddDeviceBtn_Click"
+                        Background="#4CAF50" Foreground="White" BorderThickness="0" Cursor="Hand" FontWeight="SemiBold"/>
+                <Button x:Name="closeTabBtn" Content="鍏抽棴褰撳墠椤�" Width="100" Height="28"
+                        Click="CloseTabBtn_Click"
+                        Background="#FF5722" Foreground="White" BorderThickness="0" Cursor="Hand"/>
                 <Button Style="{StaticResource RfhBtn}" x:Name="rfhBtn" Click="RfhBtn_Click"/>
             </StackPanel>
-            <TextBlock Style="{StaticResource TitleBox}" Text="纭欢璋冭瘯"/>
+            <TextBlock Style="{StaticResource TitleBox}" Text="纭欢璋冭瘯锛堝彲澶氳澶囧苟鍙戯級"/>
         </DockPanel>
 
-        <!-- 璁惧淇℃伅鏍� -->
-        <Border Grid.Row="1" BorderBrush="#CCCCCC" BorderThickness="1" Padding="10,6" Background="#F9F9F9"
-                Visibility="{Binding HasDevice, Converter={StaticResource BoolToVis}}">
-            <WrapPanel dp:StackPanelHelper.ChildSpace="20">
-                <StackPanel Orientation="Horizontal" dp:StackPanelHelper.ChildSpace="4">
-                    <TextBlock Text="璁惧ID:" FontWeight="Bold" Foreground="#555"/>
-                    <TextBlock Text="{Binding CurrentDeviceId}" Style="{StaticResource ListTableTextBlock}"/>
-                </StackPanel>
-                <StackPanel Orientation="Horizontal" dp:StackPanelHelper.ChildSpace="4">
-                    <TextBlock Text="鍨嬪彿:" FontWeight="Bold" Foreground="#555"/>
-                    <TextBlock Text="{Binding CurrentDeviceKind}" Style="{StaticResource ListTableTextBlock}"/>
-                </StackPanel>
-                <StackPanel Orientation="Horizontal" dp:StackPanelHelper.ChildSpace="4">
-                    <TextBlock Text="杩炴帴鐘舵��:" FontWeight="Bold" Foreground="#555"/>
-                    <TextBlock Text="{Binding ConnectionStateText}" Foreground="{Binding ConnectionBrush}"/>
-                </StackPanel>
-                <StackPanel Orientation="Horizontal" dp:StackPanelHelper.ChildSpace="4">
-                    <TextBlock Text="鐗堟湰:" FontWeight="Bold" Foreground="#555"/>
-                    <TextBlock Text="{Binding CurrentEffectiveVersion}" Style="{StaticResource ListTableTextBlock}"/>
-                </StackPanel>
-                <StackPanel Orientation="Horizontal" dp:StackPanelHelper.ChildSpace="4">
-                    <TextBlock Text="棰勭害鐘舵��:" FontWeight="Bold" Foreground="#555"/>
-                    <TextBlock Text="{Binding ReservationStatusText}" Style="{StaticResource ListTableTextBlock}"/>
-                </StackPanel>
-                <StackPanel Orientation="Horizontal" dp:StackPanelHelper.ChildSpace="4">
-                    <TextBlock Text="浼氳瘽鐘舵��:" FontWeight="Bold" Foreground="#555"/>
-                    <TextBlock Text="{Binding SessionStateText}" Foreground="{Binding SessionStateBrush}" FontWeight="Bold"/>
-                </StackPanel>
-            </WrapPanel>
-        </Border>
-
-        <!-- 鎿嶄綔鎸夐挳鏍� -->
-        <StackPanel Grid.Row="2" Orientation="Horizontal" dp:StackPanelHelper.ChildSpace="10"
-                    Visibility="{Binding HasDevice, Converter={StaticResource BoolToVis}}">
-            <Button x:Name="enterMaintenanceBtn" Content="杩涘叆缁存姢鎺у埗" Padding="14,6"
-                    IsEnabled="{Binding CanEnterMaintenance}"
-                    Click="EnterMaintenanceBtn_Click"
-                    Background="#2196F3" Foreground="White" BorderThickness="0" Cursor="Hand"/>
-            <Button x:Name="exitMaintenanceBtn" Content="閫�鍑虹淮鎶�" Padding="14,6"
-                    IsEnabled="{Binding CanExitMaintenance}"
-                    Click="ExitMaintenanceBtn_Click"
-                    Background="#FF5722" Foreground="White" BorderThickness="0" Cursor="Hand"/>
-        </StackPanel>
-
-        <!-- 涓讳綋鍖哄煙 -->
-        <Grid Grid.Row="3">
-            <Grid.ColumnDefinitions>
-                <ColumnDefinition Width="*"/>
-                <ColumnDefinition Width="350"/>
-            </Grid.ColumnDefinitions>
-
-            <!-- 宸︿晶闈㈡澘瀹瑰櫒 -->
-            <Border Grid.Column="0" BorderBrush="#DDDDDD" BorderThickness="1" Margin="0,0,8,0">
-                <ContentControl x:Name="panelContainer">
-                    <TextBlock Text="璇烽�夋嫨璁惧" HorizontalAlignment="Center" VerticalAlignment="Center"
-                               FontSize="16" Foreground="#999"/>
-                </ContentControl>
-            </Border>
-
-            <!-- 鍙充晶鎿嶄綔鏃ュ織 -->
-            <Border Grid.Column="1" BorderBrush="#DDDDDD" BorderThickness="1">
-                <Grid>
-                    <Grid.RowDefinitions>
-                        <RowDefinition Height="Auto"/>
-                        <RowDefinition Height="*"/>
-                    </Grid.RowDefinitions>
-                    <Border Grid.Row="0" Background="#F0F0F0" Padding="8,6">
-                        <TextBlock Text="鎿嶄綔鏃ュ織" FontWeight="Bold" FontSize="14"/>
-                    </Border>
-                    <ListView Grid.Row="1" x:Name="operationLogList"
-                              ItemsSource="{Binding OperationLogs}"
-                              Style="{StaticResource DefaultListTable}"
-                              VirtualizingPanel.IsVirtualizing="True"
-                              VirtualizingPanel.VirtualizationMode="Standard">
-                        <ListView.View>
-                            <GridView AllowsColumnReorder="False">
-                                <GridViewColumn Width="60" Header="绫诲瀷">
-                                    <GridViewColumn.CellTemplate>
-                                        <DataTemplate>
-                                            <Border Style="{StaticResource CellBorder}">
-                                                <TextBlock Style="{StaticResource ListTableTextBlock}" 
-                                                           Text="{Binding CommandType}"/>
-                                            </Border>
-                                        </DataTemplate>
-                                    </GridViewColumn.CellTemplate>
-                                </GridViewColumn>
-                                <GridViewColumn Width="120" Header="鍙傛暟">
-                                    <GridViewColumn.CellTemplate>
-                                        <DataTemplate>
-                                            <Border Style="{StaticResource CellBorder}">
-                                                <TextBlock Style="{StaticResource ListTableTextBlock}" 
-                                                           Text="{Binding Parameters}" TextTrimming="CharacterEllipsis"
-                                                           ToolTip="{Binding Parameters}"/>
-                                            </Border>
-                                        </DataTemplate>
-                                    </GridViewColumn.CellTemplate>
-                                </GridViewColumn>
-                                <GridViewColumn Width="60" Header="缁撴灉">
-                                    <GridViewColumn.CellTemplate>
-                                        <DataTemplate>
-                                            <Border Style="{StaticResource CellBorder}">
-                                                <TextBlock Style="{StaticResource ListTableTextBlock}" 
-                                                           Text="{Binding Outcome}"/>
-                                            </Border>
-                                        </DataTemplate>
-                                    </GridViewColumn.CellTemplate>
-                                </GridViewColumn>
-                                <GridViewColumn Width="100" Header="鏃堕棿">
-                                    <GridViewColumn.CellTemplate>
-                                        <DataTemplate>
-                                            <Border Style="{StaticResource CellBorder}">
-                                                <TextBlock Style="{StaticResource ListTableTextBlock}" 
-                                                           Text="{Binding Timestamp, StringFormat=HH:mm:ss}"/>
-                                            </Border>
-                                        </DataTemplate>
-                                    </GridViewColumn.CellTemplate>
-                                </GridViewColumn>
-                            </GridView>
-                        </ListView.View>
-                    </ListView>
-                </Grid>
-            </Border>
-        </Grid>
+        <!-- 澶氳澶囨爣绛惧尯 -->
+        <TabControl Grid.Row="1" x:Name="debugTabs" Background="White" BorderThickness="0"/>
     </Grid>
 </hb:SimpleMaskControl>

--
Gitblit v1.9.1