From b544d5cccd76735e034c8055918a50927b437474 Mon Sep 17 00:00:00 2001
From: wenxiangchao <wenxiangchao@ihengxin.com.cn>
Date: 星期二, 10 十一月 2026 08:29:04 +0800
Subject: [PATCH] fix: 维护模式重复进入失败与按钮灰死 + Broker 并发验证用例

---
 Plugin.DeviceDebug/Panels/CanDebugPanel.xaml |  219 +++---------------------------------------------------
 1 files changed, 14 insertions(+), 205 deletions(-)

diff --git a/Plugin.DeviceDebug/Panels/CanDebugPanel.xaml b/Plugin.DeviceDebug/Panels/CanDebugPanel.xaml
index 4ebbe7a..b97fe0a 100644
--- a/Plugin.DeviceDebug/Panels/CanDebugPanel.xaml
+++ b/Plugin.DeviceDebug/Panels/CanDebugPanel.xaml
@@ -3,218 +3,27 @@
              xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
              xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
              xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
-             xmlns:ui="clr-namespace:HMI.UI;assembly=HMI.UI"
-             xmlns:dp="clr-namespace:HMI.UI.DpUtil;assembly=HMI.UI"
              mc:Ignorable="d" 
-             d:DesignHeight="700" d:DesignWidth="700">
-    <UserControl.Resources>
-        <ResourceDictionary>
-            <ResourceDictionary.MergedDictionaries>
-                <ResourceDictionary Source="/HMI.UI;component/Style/PanuonListView.xaml"/>
-            </ResourceDictionary.MergedDictionaries>
-        </ResourceDictionary>
-    </UserControl.Resources>
-
-    <Grid dp:GridHelper.Space="10" Margin="10">
+             d:DesignHeight="720" d:DesignWidth="720">
+    <Grid Margin="6">
         <Grid.RowDefinitions>
-            <RowDefinition Height="Auto"/>
-            <RowDefinition Height="Auto"/>
             <RowDefinition Height="Auto"/>
             <RowDefinition Height="*"/>
         </Grid.RowDefinitions>
 
-        <!-- 鏍囬 -->
-        <Border Grid.Row="0" Background="#FF9800" CornerRadius="4" Padding="12,8">
-            <TextBlock Text="CAN 閫氳璋冭瘯闈㈡澘" FontSize="16" FontWeight="Bold" Foreground="White"/>
+        <!-- 閫氶亾宸ュ叿鏉� -->
+        <Border Grid.Row="0" Background="#F5F5F5" BorderBrush="#DDD" BorderThickness="0,0,0,1" Padding="6,4">
+            <StackPanel Orientation="Horizontal">
+                <Button x:Name="addChannelBtn" Content="+ 娣诲姞閫氶亾" Width="100" Height="26" Margin="0,0,6,0"
+                        Click="AddChannelBtn_Click"
+                        Background="#2196F3" Foreground="White" BorderThickness="0" Cursor="Hand" FontWeight="SemiBold"/>
+                <Button x:Name="closeChannelBtn" Content="鍏抽棴褰撳墠閫氶亾" Width="110" Height="26"
+                        Click="CloseChannelBtn_Click"
+                        Background="#9E9E9E" Foreground="White" BorderThickness="0" Cursor="Hand"/>
+            </StackPanel>
         </Border>
 
-        <!-- 妯℃嫙鍣ㄨ繛鎺ユ帶鍒跺尯 -->
-        <Border Grid.Row="1" BorderBrush="#DDD" BorderThickness="1" CornerRadius="4" Padding="12" Background="#FAFAFA">
-            <Grid dp:GridHelper.Space="8">
-                <Grid.RowDefinitions>
-                    <RowDefinition Height="Auto"/>
-                    <RowDefinition Height="Auto"/>
-                </Grid.RowDefinitions>
-                <Grid.ColumnDefinitions>
-                    <ColumnDefinition Width="80"/>
-                    <ColumnDefinition Width="150"/>
-                    <ColumnDefinition Width="80"/>
-                    <ColumnDefinition Width="100"/>
-                    <ColumnDefinition Width="*"/>
-                    <ColumnDefinition Width="Auto"/>
-                </Grid.ColumnDefinitions>
-
-                <!-- 绗竴琛岋細鎬荤嚎鍚嶇О鍜岃妭鐐圭紪鍙� -->
-                <TextBlock Grid.Row="0" Grid.Column="0" Text="鎬荤嚎鍚嶇О:" VerticalAlignment="Center" FontWeight="SemiBold"/>
-                <TextBox Grid.Row="0" Grid.Column="1" x:Name="busNameInput" 
-                         VerticalContentAlignment="Center" Padding="6,4" Text="CAN_BUS_1"/>
-
-                <TextBlock Grid.Row="0" Grid.Column="2" Text="鑺傜偣缂栧彿:" VerticalAlignment="Center" FontWeight="SemiBold" Margin="8,0,0,0"/>
-                <TextBox Grid.Row="0" Grid.Column="3" x:Name="nodeIndexInput" 
-                         VerticalContentAlignment="Center" Padding="6,4" Text="0"/>
-
-                <Button Grid.Row="0" Grid.Column="5" x:Name="connectBtn" Content="杩炴帴" Width="80" Height="30"
-                        Click="ConnectBtn_Click" 
-                        Background="#4CAF50" Foreground="White" BorderThickness="0" Cursor="Hand" FontWeight="SemiBold"/>
-
-                <!-- 绗簩琛岋細鐘舵�佹樉绀哄拰鎺у埗鎸夐挳 -->
-                <TextBlock Grid.Row="1" Grid.Column="0" Text="鐘舵��:" VerticalAlignment="Center" FontWeight="SemiBold"/>
-                <StackPanel Grid.Row="1" Grid.Column="1" Grid.ColumnSpan="2" Orientation="Horizontal" VerticalAlignment="Center">
-                    <Ellipse x:Name="statusIndicator" Width="12" Height="12" Fill="#9E9E9E" Margin="0,0,6,0"/>
-                    <TextBlock x:Name="statusText" Text="鏈繛鎺�" VerticalAlignment="Center"/>
-                </StackPanel>
-
-                <TextBlock Grid.Row="1" Grid.Column="3" Text="缁熻:" VerticalAlignment="Center" FontWeight="SemiBold" Margin="8,0,0,0"/>
-                <TextBlock Grid.Row="1" Grid.Column="4" x:Name="statsText" Text="TX: 0  RX: 0" 
-                           VerticalAlignment="Center" Foreground="#666"/>
-
-                <StackPanel Grid.Row="1" Grid.Column="5" Orientation="Horizontal">
-                    <ToggleButton x:Name="autoResponseToggleBtn" Content="鑷姩鍝嶅簲: 鍏�" Width="100" Height="28" Margin="0,0,4,0"
-                                  Click="AutoResponseToggleBtn_Click" IsEnabled="False" IsChecked="False"
-                                  Background="#9E9E9E" Foreground="White" BorderThickness="0" Cursor="Hand" FontWeight="SemiBold"/>
-                    <ToggleButton x:Name="maintenanceToggleBtn" Content="缁存姢妯″紡: 寮�" Width="100" Height="28" Margin="0,0,4,0"
-                                  Click="MaintenanceToggleBtn_Click" IsEnabled="False" IsChecked="True"
-                                  Background="#4CAF50" Foreground="White" BorderThickness="0" Cursor="Hand" FontWeight="SemiBold"/>
-                    <Button x:Name="disconnectBtn" Content="鏂紑" Width="60" Height="28" Margin="0,0,4,0"
-                            Click="DisconnectBtn_Click" IsEnabled="False"
-                            Background="#F44336" Foreground="White" BorderThickness="0" Cursor="Hand"/>
-                    <Button x:Name="promiscuousBtn" Content="娣锋潅妯″紡" Width="80" Height="28"
-                            Click="PromiscuousBtn_Click" IsEnabled="False"
-                            Background="#2196F3" Foreground="White" BorderThickness="0" Cursor="Hand"/>
-                </StackPanel>
-            </Grid>
-        </Border>
-
-        <!-- 鍙戦�佸尯 -->
-        <Border Grid.Row="2" BorderBrush="#DDD" BorderThickness="1" CornerRadius="4" Padding="12">
-            <Grid dp:GridHelper.Space="8">
-                <Grid.RowDefinitions>
-                    <RowDefinition Height="Auto"/>
-                    <RowDefinition Height="Auto"/>
-                </Grid.RowDefinitions>
-                <Grid.ColumnDefinitions>
-                    <ColumnDefinition Width="80"/>
-                    <ColumnDefinition Width="*"/>
-                    <ColumnDefinition Width="Auto"/>
-                </Grid.ColumnDefinitions>
-
-                <!-- 甯D -->
-                <TextBlock Grid.Row="0" Grid.Column="0" Text="甯� ID:" VerticalAlignment="Center" FontWeight="Bold"/>
-                <TextBox Grid.Row="0" Grid.Column="1" x:Name="frameIdInput"
-                         IsEnabled="{Binding IsMaintenanceMode, RelativeSource={RelativeSource AncestorType=UserControl}}"
-                         VerticalContentAlignment="Center" Padding="6,4" Text="0x100"/>
-
-                <!-- 鏁版嵁 -->
-                <TextBlock Grid.Row="1" Grid.Column="0" Text="鏁版嵁(Hex):" VerticalAlignment="Center" FontWeight="Bold"/>
-                <TextBox Grid.Row="1" Grid.Column="1" x:Name="dataInput"
-                         IsEnabled="{Binding IsMaintenanceMode, RelativeSource={RelativeSource AncestorType=UserControl}}"
-                         VerticalContentAlignment="Center" Padding="6,4" Text="00 00 00 00 00 00 00 00"/>
-
-                <!-- 鍙戦�佹寜閽� -->
-                <Button Grid.Row="1" Grid.Column="2" x:Name="sendBtn" Content="鍙戦��" Width="80" Height="30"
-                        IsEnabled="{Binding IsMaintenanceMode, RelativeSource={RelativeSource AncestorType=UserControl}}"
-                        Click="SendBtn_Click" 
-                        Background="#FF9800" Foreground="White" BorderThickness="0" Cursor="Hand" FontWeight="SemiBold"/>
-            </Grid>
-        </Border>
-
-        <!-- 鎺ユ敹鍖� -->
-        <Border Grid.Row="3" BorderBrush="#DDD" BorderThickness="1" CornerRadius="4">
-            <Grid>
-                <Grid.RowDefinitions>
-                    <RowDefinition Height="Auto"/>
-                    <RowDefinition Height="*"/>
-                </Grid.RowDefinitions>
-
-                <DockPanel Grid.Row="0" Margin="8,6">
-                    <Button x:Name="clearBtn" Content="娓呯┖" Padding="12,4" DockPanel.Dock="Right"
-                            Click="ClearBtn_Click"
-                            Background="#9E9E9E" Foreground="White" BorderThickness="0" Cursor="Hand"/>
-                    <TextBlock Text="鎺ユ敹璁板綍" FontWeight="Bold" FontSize="14" VerticalAlignment="Center"/>
-                </DockPanel>
-
-                <ListView Grid.Row="1" x:Name="receiveList"
-                          Style="{StaticResource DefaultListTable}"
-                          VirtualizingPanel.IsVirtualizing="True"
-                          VirtualizingPanel.VirtualizationMode="Standard">
-                    <ListView.View>
-                        <GridView AllowsColumnReorder="False">
-                            <GridViewColumn Width="90" Header="鏃堕棿">
-                                <GridViewColumn.CellTemplate>
-                                    <DataTemplate>
-                                        <Border Style="{StaticResource CellBorder}">
-                                            <TextBlock Style="{StaticResource ListTableTextBlock}" 
-                                                       Text="{Binding Timestamp, StringFormat=HH:mm:ss.fff}"/>
-                                        </Border>
-                                    </DataTemplate>
-                                </GridViewColumn.CellTemplate>
-                            </GridViewColumn>
-                            <GridViewColumn Width="80" Header="甯D">
-                                <GridViewColumn.CellTemplate>
-                                    <DataTemplate>
-                                        <Border Style="{StaticResource CellBorder}">
-                                            <TextBlock Style="{StaticResource ListTableTextBlock}" 
-                                                       Text="{Binding FrameId}"/>
-                                        </Border>
-                                    </DataTemplate>
-                                </GridViewColumn.CellTemplate>
-                            </GridViewColumn>
-                            <GridViewColumn Width="50" Header="DLC">
-                                <GridViewColumn.CellTemplate>
-                                    <DataTemplate>
-                                        <Border Style="{StaticResource CellBorder}">
-                                            <TextBlock Style="{StaticResource ListTableTextBlock}" 
-                                                       Text="{Binding Dlc}"/>
-                                        </Border>
-                                    </DataTemplate>
-                                </GridViewColumn.CellTemplate>
-                            </GridViewColumn>
-                            <GridViewColumn Width="200" Header="鏁版嵁">
-                                <GridViewColumn.CellTemplate>
-                                    <DataTemplate>
-                                        <Border Style="{StaticResource CellBorder}">
-                                            <TextBlock Style="{StaticResource ListTableTextBlock}" 
-                                                       Text="{Binding Data}" FontFamily="Consolas"/>
-                                        </Border>
-                                    </DataTemplate>
-                                </GridViewColumn.CellTemplate>
-                            </GridViewColumn>
-                            <GridViewColumn Width="50" Header="鏂瑰悜">
-                                <GridViewColumn.CellTemplate>
-                                    <DataTemplate>
-                                        <Border Style="{StaticResource CellBorder}">
-                                            <TextBlock Text="{Binding Direction}">
-                                                <TextBlock.Style>
-                                                    <Style TargetType="TextBlock" BasedOn="{StaticResource ListTableTextBlock}">
-                                                        <Style.Triggers>
-                                                            <DataTrigger Binding="{Binding Direction}" Value="TX">
-                                                                <Setter Property="Foreground" Value="#2196F3"/>
-                                                            </DataTrigger>
-                                                            <DataTrigger Binding="{Binding Direction}" Value="RX">
-                                                                <Setter Property="Foreground" Value="#4CAF50"/>
-                                                            </DataTrigger>
-                                                        </Style.Triggers>
-                                                    </Style>
-                                                </TextBlock.Style>
-                                            </TextBlock>
-                                        </Border>
-                                    </DataTemplate>
-                                </GridViewColumn.CellTemplate>
-                            </GridViewColumn>
-                            <GridViewColumn Width="100" Header="鏉ユ簮">
-                                <GridViewColumn.CellTemplate>
-                                    <DataTemplate>
-                                        <Border Style="{StaticResource CellBorder}">
-                                            <TextBlock Style="{StaticResource ListTableTextBlock}" 
-                                                       Text="{Binding Source}"/>
-                                        </Border>
-                                    </DataTemplate>
-                                </GridViewColumn.CellTemplate>
-                            </GridViewColumn>
-                        </GridView>
-                    </ListView.View>
-                </ListView>
-            </Grid>
-        </Border>
+        <!-- 澶氶�氶亾鏍囩椤� -->
+        <TabControl Grid.Row="1" x:Name="channelTabs" Background="White" BorderThickness="0"/>
     </Grid>
 </UserControl>

--
Gitblit v1.9.1