wenxiangchao
4 天以前 559890c482f5973f06aafdfec9550fee5ba3c7f2
Plugin.IntegrationTest/MainWindow.xaml
@@ -116,6 +116,90 @@
                    <Border x:Name="canSimulatorHost" Grid.Row="1" Background="White" Margin="4"/>
                </Grid>
            </TabItem>
            <!-- Tab 5: 全自动测试 -->
            <TabItem Header="  全自动测试  " FontSize="13">
                <Grid Margin="8">
                    <Grid.RowDefinitions>
                        <RowDefinition Height="Auto"/>
                        <RowDefinition Height="Auto"/>
                        <RowDefinition Height="*"/>
                    </Grid.RowDefinitions>
                    <!-- 步骤信息区 -->
                    <Border Grid.Row="0" Background="#FFF3E0" CornerRadius="4" Padding="14,10" Margin="0,0,0,8">
                        <StackPanel>
                            <TextBlock Text="CAN 老化自动化步骤示例(方案 B + C)" FontSize="16" FontWeight="Bold" Foreground="#E65100" Margin="0,0,0,8"/>
                            <WrapPanel>
                                <TextBlock Text="发送设备:" FontWeight="SemiBold" VerticalAlignment="Center" Margin="0,0,6,6"/>
                                <ComboBox x:Name="autoTxDeviceCombo" Width="150" Height="28" Margin="0,0,16,6"/>
                                <TextBlock Text="目标设备:" FontWeight="SemiBold" VerticalAlignment="Center" Margin="0,0,6,6"/>
                                <ComboBox x:Name="autoRxDeviceCombo" Width="150" Height="28" Margin="0,0,16,6"/>
                                <TextBlock Text="循环次数:" FontWeight="SemiBold" VerticalAlignment="Center" Margin="0,0,6,6"/>
                                <TextBox x:Name="autoLoopCount" Width="60" Height="28" Text="5" VerticalContentAlignment="Center" Padding="4,0" Margin="0,0,16,6"/>
                                <TextBlock Text="帧间隔(ms):" FontWeight="SemiBold" VerticalAlignment="Center" Margin="0,0,6,6"/>
                                <TextBox x:Name="autoInterval" Width="70" Height="28" Text="300" VerticalContentAlignment="Center" Padding="4,0" Margin="0,0,16,6"/>
                            </WrapPanel>
                            <StackPanel Orientation="Horizontal" Margin="0,8,0,0">
                                <Button x:Name="autoRunBtn" Content="▶ 运行自动化步骤" Width="180" Height="36" Margin="0,0,10,0"
                                        Click="AutoRunBtn_Click" Background="#FF9800" Foreground="White"
                                        BorderThickness="0" Cursor="Hand" FontWeight="SemiBold" FontSize="13"/>
                                <Button x:Name="perDeviceBtn" Content="▶ 逐设备一次收发(CAN-001~004)" Width="250" Height="36" Margin="0,0,10,0"
                                        Click="PerDeviceCanTest_Click" Background="#3F51B5" Foreground="White"
                                        BorderThickness="0" Cursor="Hand" FontWeight="SemiBold" FontSize="13"/>
                                <Button x:Name="autoStopBtn" Content="■ 中止" Width="90" Height="36" Margin="0,0,10,0"
                                        Click="AutoStopBtn_Click" Background="#F44336" Foreground="White"
                                        BorderThickness="0" Cursor="Hand" FontWeight="SemiBold" IsEnabled="False"/>
                                <ProgressBar x:Name="autoProgress" Width="300" Height="18" Margin="0,0,10,0"/>
                                <TextBlock x:Name="autoProgressText" Text="就绪" VerticalAlignment="Center" Foreground="#666"/>
                            </StackPanel>
                        </StackPanel>
                    </Border>
                    <!-- 代码预览 -->
                    <Expander Grid.Row="1" Header="查看等价代码(方案 B + C 使用示例)" IsExpanded="False" Margin="0,0,0,8">
                        <Border Background="#263238" Padding="12" CornerRadius="4" MaxHeight="280">
                            <ScrollViewer VerticalScrollBarVisibility="Auto" HorizontalScrollBarVisibility="Auto">
                                <TextBlock FontFamily="Consolas" FontSize="12" Foreground="#ECEFF1">
<Run Foreground="#80CBC4">// 业务代码只看到类型化服务(方案 C)和作域(方案 B)</Run>
<Run>&#10;</Run><Run Foreground="#FFCC80">using </Run><Run Foreground="#C5E1A5">var </Run><Run>lease = </Run><Run Foreground="#FFCC80">await </Run><Run>auto.AcquireAsync(</Run><Run Foreground="#C5E1A5">"CAN-001"</Run><Run>, </Run><Run Foreground="#C5E1A5">"CAN_Aging"</Run><Run>, ct);</Run>
<Run>&#10;</Run><Run Foreground="#C5E1A5">await </Run><Run>canBus.SetAutoResponseAsync(lease, enabled:</Run><Run Foreground="#F48FB1">true</Run><Run>);</Run>
<Run>&#10;</Run><Run Foreground="#89DDFF">for </Run><Run>(</Run><Run Foreground="#C5E1A5">int </Run><Run>i = 0; i &lt; cycles; i++)</Run>
<Run>&#10;</Run><Run>{</Run>
<Run>&#10;</Run><Run>    </Run><Run Foreground="#C5E1A5">await </Run><Run>canBus.SendFrameAsync(lease, 0x100 + i, data);</Run>
<Run>&#10;</Run><Run>    </Run><Run Foreground="#C5E1A5">var </Run><Run>echo = </Run><Run Foreground="#C5E1A5">await </Run><Run>canBus.ReceiveFrameAsync(lease, ct);</Run>
<Run>&#10;</Run><Run>    Verify(echo != </Run><Run Foreground="#FF5370">null</Run><Run>);  </Run><Run Foreground="#546E7A">// 断言</Run>
<Run>&#10;</Run><Run>}</Run>
                                </TextBlock>
                            </ScrollViewer>
                        </Border>
                    </Expander>
                    <!-- 日志区 -->
                    <Border Grid.Row="2" BorderBrush="#DDD" BorderThickness="1" CornerRadius="4">
                        <Grid>
                            <Grid.RowDefinitions>
                                <RowDefinition Height="Auto"/>
                                <RowDefinition Height="*"/>
                            </Grid.RowDefinitions>
                            <DockPanel Grid.Row="0" Margin="10,6">
                                <TextBlock Text="自动化执行日志" FontWeight="Bold" FontSize="14"/>
                                <Button Content="清空" Padding="10,3" DockPanel.Dock="Right" Click="AutoClearLog_Click"
                                        Background="#9E9E9E" Foreground="White" BorderThickness="0" Cursor="Hand"/>
                            </DockPanel>
                            <TextBox Grid.Row="1" x:Name="autoLog"
                                     IsReadOnly="True" VerticalScrollBarVisibility="Auto" HorizontalScrollBarVisibility="Auto"
                                     FontFamily="Consolas" FontSize="12"
                                     Background="#1E1E1E" Foreground="#D4D4D4"
                                     BorderThickness="0" Padding="10" TextWrapping="NoWrap" AcceptsReturn="True"/>
                        </Grid>
                    </Border>
                </Grid>
            </TabItem>
        </TabControl>
        <!-- 底部结果栏 -->