From 3436d08d4ab2b53b9e992fe92e54f97d2d494787 Mon Sep 17 00:00:00 2001
From: tfarcraw <123211521@163.com>
Date: Sun, 8 Nov 2026 21:48:12 +0800
Subject: [PATCH] =?UTF-8?q?=E8=B0=83=E6=95=B4=E6=93=8D=E4=BD=9C=E5=91=98?=
=?UTF-8?q?=E4=B8=BB=E7=95=8C=E9=9D=A2=E5=B9=B6=E6=96=B0=E5=A2=9E=E8=BF=90?=
=?UTF-8?q?=E8=A1=8C=E8=AE=BE=E7=BD=AE=E9=A1=B5?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.../RuntimeSettings/RuntimeSettings.axaml | 70 +++++++++++++++++++
.../RuntimeSettings/RuntimeSettings.axaml.cs | 15 ++++
.../VVMs/SopPage/SopPage.axaml | 53 +-------------
.../VVMs/SopPage/SopPageViewModel.cs | 11 ++-
tests/Avalonia.Smoke/Program.cs | 23 +++++-
5 files changed, 119 insertions(+), 53 deletions(-)
create mode 100644 src/SopHelper.Avalonia/VVMs/RuntimeSettings/RuntimeSettings.axaml
create mode 100644 src/SopHelper.Avalonia/VVMs/RuntimeSettings/RuntimeSettings.axaml.cs
diff --git a/src/SopHelper.Avalonia/VVMs/RuntimeSettings/RuntimeSettings.axaml b/src/SopHelper.Avalonia/VVMs/RuntimeSettings/RuntimeSettings.axaml
new file mode 100644
index 0000000..fd2a55e
--- /dev/null
+++ b/src/SopHelper.Avalonia/VVMs/RuntimeSettings/RuntimeSettings.axaml
@@ -0,0 +1,70 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/src/SopHelper.Avalonia/VVMs/RuntimeSettings/RuntimeSettings.axaml.cs b/src/SopHelper.Avalonia/VVMs/RuntimeSettings/RuntimeSettings.axaml.cs
new file mode 100644
index 0000000..4fca3fb
--- /dev/null
+++ b/src/SopHelper.Avalonia/VVMs/RuntimeSettings/RuntimeSettings.axaml.cs
@@ -0,0 +1,15 @@
+using Avalonia.Controls;
+using SopHelper.Core.Prism;
+using SopHelper.VVMs.SopPage;
+
+namespace SopHelper.VVMs.RuntimeSettings;
+
+[NavigationPage(ViewName = nameof(RuntimeSettings), DisplayName = "运行设置", Index = 2)]
+public partial class RuntimeSettings : UserControl
+{
+ public RuntimeSettings(SopPageViewModel model)
+ {
+ InitializeComponent();
+ DataContext = model;
+ }
+}
diff --git a/src/SopHelper.Avalonia/VVMs/SopPage/SopPage.axaml b/src/SopHelper.Avalonia/VVMs/SopPage/SopPage.axaml
index a411ffb..cff3937 100644
--- a/src/SopHelper.Avalonia/VVMs/SopPage/SopPage.axaml
+++ b/src/SopHelper.Avalonia/VVMs/SopPage/SopPage.axaml
@@ -58,57 +58,8 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
diff --git a/src/SopHelper.Avalonia/VVMs/SopPage/SopPageViewModel.cs b/src/SopHelper.Avalonia/VVMs/SopPage/SopPageViewModel.cs
index b20619f..563ad53 100644
--- a/src/SopHelper.Avalonia/VVMs/SopPage/SopPageViewModel.cs
+++ b/src/SopHelper.Avalonia/VVMs/SopPage/SopPageViewModel.cs
@@ -59,6 +59,7 @@ public class SopPageViewModel : ViewModelBase
private CameraInfo? _selectedCamera;
private CameraInfo? _lastUsedCamera;
private string? _selectedRecipe;
+ private string _activeRecipe = "未应用配方";
private ImageSource? _frame;
private string _statusText = "就绪";
private string _fpsText = "—";
@@ -115,7 +116,7 @@ public class SopPageViewModel : ViewModelBase
EditRecipeCommand = new DelegateCommand(EditRecipe, CanEditRecipe);
NewRecipeCommand = new DelegateCommand(NewRecipe, () => !IsRunning && !_isCameraBusy);
- StatusText = "选择相机和配方,点开始";
+ StatusText = "就绪,请确认运行设置后开始";
LoadLastCamera();
_ = RefreshCamerasAsync();
}
@@ -160,6 +161,13 @@ public class SopPageViewModel : ViewModelBase
}
}
+ /// 已成功应用的配方,与设置页尚未应用的选择分开。
+ public string ActiveRecipe
+ {
+ get => _activeRecipe;
+ private set => SetProperty(ref _activeRecipe, value);
+ }
+
/// 画面
public ImageSource? Frame
{
@@ -619,6 +627,7 @@ public class SopPageViewModel : ViewModelBase
};
_pipeline.LoadModels(options);
+ ActiveRecipe = SelectedRecipe;
Log("info", $"推理设备:手部={_pipeline.HandBackend},YOLO={_pipeline.YoloBackend}");
StepCards.Clear();
diff --git a/tests/Avalonia.Smoke/Program.cs b/tests/Avalonia.Smoke/Program.cs
index 2ab21ff..3bf61d9 100644
--- a/tests/Avalonia.Smoke/Program.cs
+++ b/tests/Avalonia.Smoke/Program.cs
@@ -57,16 +57,34 @@ internal static class Smoke
await Task.Delay(150);
var app=(App)Application.Current!;var window=lifetime.MainWindow!;
var navigation=app.Container.Resolve();
- Check(navigation.Pages.Count==2,"Both original navigation pages registered");
+ Check(navigation.Pages.Count==3&&navigation.Pages[2].DisplayName=="运行设置","Runtime settings navigation page registered");
Check(navigation.Pages[0].DisplayName=="SOP 辅助"&&navigation.Pages[1].DisplayName=="零件标注与训练","Original navigation labels retained");
window.WindowState=WindowState.Normal;window.Width=1180;window.Height=820;
await Task.Delay(150);
var sop=app.Container.Resolve();
+ var sopView=window.GetVisualDescendants().OfType().Single();
+ Check(!sopView.GetVisualDescendants().Any(c=>c is ComboBox or Slider),"Operator page contains no camera, recipe or parameter editors");
+ Check(sop.ActiveRecipe=="未应用配方","No recipe is reported active before applying");
+ navigation.SelectedIndex=2;await Task.Delay(100);
+ var settings=window.GetVisualDescendants().OfType().Single();
+ Check(ReferenceEquals(settings.DataContext,sop),"Settings and operator page share runtime state");
+ Check(settings.GetVisualDescendants().OfType().Count()==2&&settings.GetVisualDescendants().OfType().Count()==2,"Camera, recipe, threshold and stride editors are on settings page");
sop.ApplyRecipeCommand.Execute();
+ Check(sop.ActiveRecipe==sop.SelectedRecipe,"Applied recipe is shown as current");
+ var applied=sop.ActiveRecipe;var selected=sop.SelectedRecipe;
+ sop.SelectedRecipe="pending.yaml";
+ Check(sop.ActiveRecipe==applied,"Unapplied recipe selection does not change current recipe");
+ sop.SelectedRecipe=selected;
+ Save(window,"runtime-settings");
+ navigation.SelectedIndex=0;await Task.Delay(100);
+ Check(window.GetVisualDescendants().OfType().Single().GetVisualDescendants().OfType().Any(t=>t.Text==applied),"Operator page displays the applied recipe");
Check(sop.StepCards.Count==4&&sop.Rois.Count==3,"Original SOP recipe creates four steps and three ROIs");
sop.StartStopCommand.Execute();
for(var i=0;i<100&&!sop.IsRunning;i++)await Task.Delay(20);
Check(sop.IsRunning,"Original start command connects the shared camera/pipeline");
+ navigation.SelectedIndex=2;await Task.Delay(80);
+ Check(settings.GetVisualDescendants().Where(c=>c is ComboBox or Slider).Cast().All(c=>!c.IsEnabled),"Runtime settings cannot be edited during acquisition");
+ navigation.SelectedIndex=0;await Task.Delay(80);
await Task.Run(()=>{Camera.Emit();Camera.Emit();});
await Task.Delay(150);
Check(sop.Frame is not null&&sop.FrameWidth==640&&sop.FrameHeight==480,"Camera buffer renders through the shared Avalonia bitmap adapter");
@@ -74,6 +92,9 @@ internal static class Smoke
Save(window,"sop");
sop.StartStopCommand.Execute();for(var i=0;i<100&&sop.IsRunning;i++)await Task.Delay(20);
Check(!sop.IsRunning&&!Camera.IsConnected,"Stop command releases acquisition");
+ navigation.SelectedIndex=2;await Task.Delay(80);
+ Check(settings.GetVisualDescendants().Where(c=>c is ComboBox or Slider).Cast().All(c=>c.IsEnabled),"Runtime settings become editable after stopping");
+ navigation.SelectedIndex=0;await Task.Delay(80);
Check(window.GetVisualDescendants().OfType().Any(),"SOP page navigates");
sop.EditRecipeCommand.Execute();await Task.Delay(150);
var modal=lifetime.Windows.OfType().Single();