将零件标注与训练移入配方编辑并固定当前配方
This commit is contained in:
parent
c34be54f18
commit
10f499cf10
@ -9,9 +9,9 @@
|
||||
|---|---|
|
||||
| 主窗口 Logo、左侧导航 | 原布局迁移到 `VVMs/MainWindow` |
|
||||
| SOP 参数、相机、配方、步骤、违规、日志 | `VVMs/SopPage`,保留原命令和 ViewModel 逻辑 |
|
||||
| 表单式配方编辑器 | `VVMs/RecipeEditor`,保留步骤/区域/全局设置/检测模型四个标签页 |
|
||||
| 表单式配方编辑器 | `VVMs/RecipeEditor`,包含步骤、区域、全局设置、零件列表、检测模型、SOP流程视频、零件标注与训练七个标签页 |
|
||||
| ROI 图像画框、坐标微调、相机取图 | Avalonia `RegionCanvas`,仍保存原图像素坐标 |
|
||||
| 零件标注、复核、SAM2、导出、YOLO 训练 | `Training`,保留原项目格式与 worker 协议 |
|
||||
| 零件标注、复核、SAM2、导出、YOLO 训练 | `Training` 嵌入配方编辑窗口,固定当前配方;每个编辑窗口独立持有模型和 worker,关闭时取消任务 |
|
||||
| 相机预览、录像、退出清理 | `Training/CameraWindow`,保留相机互斥与关闭等待流程 |
|
||||
| SOP、检测器、左右手稳定器、录像器、训练数据与 worker 客户端 | `SopHelper.CrossPlatform.Engine` 独立保存全部共享引擎源码,不引用归档仓库 |
|
||||
|
||||
@ -68,7 +68,7 @@ CUDA 12 与 CUDA 13 的 cuDNN 9 DLL 名称相同,不能仅凭文件名混用
|
||||
dotnet run --project tests/Avalonia.Smoke -c Release
|
||||
```
|
||||
|
||||
测试覆盖实际共享壳与 Prism 导航、SOP 启停和原生推理、相机缓冲显示、配方对话框及四个标签页、
|
||||
测试覆盖实际共享壳与 Prism 导航、SOP 启停和原生推理、相机缓冲显示、配方对话框及七个标签页、
|
||||
打开编辑器不改配方字段、标注保存与切页保留、Python 环境检查、BGR 颜色和缓冲所有权、
|
||||
实际鼠标正反向画框与留白坐标映射。渲染图与报告在 `artifacts/avalonia-smoke/`。
|
||||
测试使用假相机,避免枚举或占用现场硬件。也可对发布包执行 `--check-runtime` 验证模型与 SOP 引擎。
|
||||
|
||||
@ -44,7 +44,7 @@ Windows Python 环境使用 `tools/Setup-Python.ps1 -Sam2`;Linux 环境和部
|
||||
## 操作流程
|
||||
|
||||
1. 接好 UVC 或海康相机,选择设备和配方,应用后开始检测。
|
||||
2. 配方编辑器包含步骤、区域、全局设置、零件列表、检测模型、SOP流程视频六个标签页;区域坐标使用原图像素。
|
||||
2. 配方编辑器包含步骤、区域、全局设置、零件列表、检测模型、SOP流程视频、零件标注与训练七个标签页;区域坐标使用原图像素。
|
||||
- 零件名称只在“零件列表”维护,随配方保存到 `sop.parts`。标注类别、步骤目标类别、必留物品和完成必需物品均从该列表选择。
|
||||
- 旧配方首次编辑时汇总已有训练类别、模型配置、步骤和标注项目名称;保存后列表成为唯一来源。重名、空名以及删除仍被步骤或标注项目引用的名称会阻止保存。
|
||||
- 检测模型的类别表只读;维护零件列表不会更改已训练模型的类别映射。模型输出类别仍以训练版本为准。
|
||||
@ -52,13 +52,14 @@ Windows Python 环境使用 `tools/Setup-Python.ps1 -Sam2`;Linux 环境和部
|
||||
- 支持暂停、继续和停止保存;暂停时间不计入视频,累计有效录像最长 5 分钟,到时自动保存并弹窗。关闭编辑窗口也会停止并保存录像。
|
||||
- 同页可播放已保存视频,支持暂停、继续、停止及播完重播,拖动进度条可前后跳转,并保持原来的播放或暂停状态。播放不需要连接相机;开始播放时关闭相机预览,重新开启预览或关闭窗口时释放播放器。
|
||||
- 每份配方保留一段标准视频;“重新录制”先弹窗确认,确认后删除旧视频并重新开始,取消会保留原视频。录制中发起重新录制时会先暂停,取消后恢复原先的录制状态。
|
||||
3. 零件标注与训练包含相机录像、视频导入、画框、SAM2 传播、复核、数据集导出、YOLO 训练和 ONNX 导出。
|
||||
3. 在“运行设置 → 编辑配方 → 零件标注与训练”中进行相机录像、视频导入、画框、SAM2 传播、复核、数据集导出、YOLO 训练和 ONNX 导出。侧栏只保留 SOP 辅助和运行设置。
|
||||
- 每段相机录像最长 5 分钟,达到上限后自动停止、保存文件并弹窗提示保存位置;相机预览继续运行,可再次开始录像。
|
||||
- 在标注页选择所属配方及已有零件类别,每个视频录入一个零件;录像和导入原视频保存在 `recipes/配方名/recordings`,标注数据保存在同配方的 `parts`。
|
||||
- 所属配方固定为当前编辑的配方,在标注页选择已有零件类别,每个视频录入一个零件;新配方先保存后再标注或训练。录像和导入原视频保存在 `recipes/配方名/recordings`,标注数据保存在同配方的 `parts`。
|
||||
- 点击“训练并更新配方模型”,自动累计导出该配方所有已加入视频的复核数据,并使用上一版配方模型开始新训练;首次使用 `yolo11n.pt`。无需手选权重。
|
||||
- 同名零件的多个视频共用类别,训练导出按零件列表顺序分配类别编号,并拒绝列表以外的项目类别。每个视频均需完成足够的训练段和末尾验证段复核。
|
||||
- 训练成功后自动将 `配方名.pt` 和 `配方名.onnx` 发布到同配方的 `models/训练版本/`;训练曲线和日志保存在 `runs`,数据集保存在 `datasets`。`latest-model.json` 指向最新完整版本,重新应用配方即可加载。
|
||||
- “保存参数”写入所选配方的 `training-settings.json`,切换配方时恢复各自参数。打开外部标注项目会将其复制到所属配方目录。
|
||||
- “保存参数”写入当前配方的 `training-settings.json`,打开其他配方的编辑窗口会恢复各自参数。无配方归属的外部标注项目会复制到当前配方;属于其他配方的项目需在对应编辑窗口打开。
|
||||
- 切换配方编辑标签页会保留标注状态;关闭编辑窗口会取消本窗口的训练任务、释放录像相机并保留已保存的标注。
|
||||
4. 模型、相机和 Python 依赖的实际状态以日志和诊断结果为准。
|
||||
|
||||
模型文件:`palm_detection_full_Nx3x192x192_post.onnx`、`hand_landmark_sparse_Nx3x224x224.onnx`;
|
||||
|
||||
@ -20,7 +20,6 @@ public partial class App : PrismApplication
|
||||
{
|
||||
private ICameraService? _camera;
|
||||
private DetectionPipeline? _pipeline;
|
||||
private Engine.Training.WorkerClient? _worker;
|
||||
public App() { }
|
||||
public App(ICameraService camera) { _camera=camera; }
|
||||
public override void Initialize() { AvaloniaXamlLoader.Load(this); base.Initialize(); }
|
||||
@ -38,8 +37,6 @@ public partial class App : PrismApplication
|
||||
containerRegistry.RegisterInstance(_pipeline);
|
||||
containerRegistry.RegisterSingleton<SopEngine>();
|
||||
containerRegistry.RegisterSingleton<SopPageViewModel>();
|
||||
_worker=new Engine.Training.WorkerClient();containerRegistry.RegisterInstance(_worker);
|
||||
containerRegistry.RegisterSingleton<Training.MainViewModel>();
|
||||
containerRegistry.RegisterDialog<RecipeEditor,RecipeEditorViewModel>("RecipeEditorDialog");
|
||||
containerRegistry.RegisterDialogWindow<RecipeDialogWindow>();
|
||||
}
|
||||
@ -56,7 +53,6 @@ public partial class App : PrismApplication
|
||||
window.Opened+=(_,_)=> { if(navigation.Pages.Count>0) navigation.SelectedIndex=0; };
|
||||
window.Closed+=(_,_)=>
|
||||
{
|
||||
_worker?.Dispose();
|
||||
try{_camera?.Dispose();}catch(Exception ex){Log(ex,"Exit.Camera");}
|
||||
try{_pipeline?.Dispose();}catch(Exception ex){Log(ex,"Exit.Pipeline");}
|
||||
};
|
||||
|
||||
@ -75,11 +75,18 @@ public sealed class MainViewModel : BindableBase
|
||||
private static string PythonPath => DesktopPlatform.PythonPath;
|
||||
public ObservableCollection<string> Recipes { get; } = [];
|
||||
private string _recipeName = "";
|
||||
private bool _recipeLocked;
|
||||
public void BindRecipe(string name)
|
||||
{
|
||||
RecipeName = name;
|
||||
_recipeLocked = true;
|
||||
}
|
||||
public string RecipeName
|
||||
{
|
||||
get => _recipeName;
|
||||
set
|
||||
{
|
||||
if (_recipeLocked && value != _recipeName) throw new InvalidOperationException("标注与训练固定使用当前编辑的配方,请打开其他配方的编辑窗口再操作");
|
||||
if (!SetProperty(ref _recipeName, value)) return;
|
||||
LoadSettings();
|
||||
if (_project is not null && _project.RecipeName != value)
|
||||
@ -258,6 +265,8 @@ public sealed class MainViewModel : BindableBase
|
||||
public void Load(string path, int index = 0)
|
||||
{
|
||||
var incoming = TrainingProject.Load(path);
|
||||
if (_recipeLocked && !string.IsNullOrWhiteSpace(incoming.RecipeName) && incoming.RecipeName != RecipeName)
|
||||
throw new InvalidOperationException("该标注项目属于其他配方,请在对应配方的编辑窗口中打开");
|
||||
var name = string.IsNullOrWhiteSpace(incoming.RecipeName) ? RecipeName : incoming.RecipeName;
|
||||
path = DesktopPlatform.Recipes.ImportProject(name, path);
|
||||
_project = TrainingProject.Load(path);
|
||||
|
||||
@ -5,34 +5,34 @@
|
||||
<UserControl.Resources>
|
||||
</UserControl.Resources>
|
||||
<ScrollViewer Margin="12" HorizontalScrollBarVisibility="Auto" VerticalScrollBarVisibility="Auto">
|
||||
<Grid Width="{Binding Viewport.Width, RelativeSource={RelativeSource AncestorType=ScrollViewer}}" Height="{Binding Viewport.Height, RelativeSource={RelativeSource AncestorType=ScrollViewer}}" MinWidth="1080" MinHeight="720">
|
||||
<Grid Width="{Binding Viewport.Width, RelativeSource={RelativeSource AncestorType=ScrollViewer}}" Height="{Binding Viewport.Height, RelativeSource={RelativeSource AncestorType=ScrollViewer}}" MinWidth="960" MinHeight="540">
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="Auto" />
|
||||
<RowDefinition Height="*" />
|
||||
<RowDefinition Height="176" />
|
||||
<RowDefinition Height="130" />
|
||||
<RowDefinition Height="Auto" />
|
||||
</Grid.RowDefinitions>
|
||||
<DockPanel Margin="0,0,0,14">
|
||||
<StackPanel DockPanel.Dock="Left" Margin="0,0,28,0">
|
||||
<TextBlock Text="零件标注与训练" FontSize="23" FontWeight="Bold" Foreground="{StaticResource Accent}" />
|
||||
<TextBlock Text="{Binding RecipeFolder}" Foreground="{StaticResource Dim}" TextTrimming="CharacterEllipsis" MaxWidth="360" ToolTip.Tip="{Binding RecipeFolder}" />
|
||||
</StackPanel>
|
||||
<StackPanel Orientation="Horizontal" HorizontalAlignment="Right" VerticalAlignment="Center">
|
||||
<StackPanel Margin="0,0,0,10" Spacing="8">
|
||||
<Grid ColumnDefinitions="*,Auto">
|
||||
<TextBlock Text="零件标注与训练" FontSize="18" FontWeight="Bold" Foreground="{StaticResource Accent}" />
|
||||
<TextBlock Grid.Column="1" Text="{Binding RecipeName}" Foreground="{StaticResource Dim}" TextTrimming="CharacterEllipsis" MaxWidth="360" ToolTip.Tip="{Binding RecipeFolder}" />
|
||||
</Grid>
|
||||
<WrapPanel>
|
||||
<Button Content="相机与录像" Click="OpenCameraClicked" />
|
||||
<Button Content="导入视频" Command="{Binding ImportCommand}" />
|
||||
<Button Content="打开项目" Command="{Binding OpenCommand}" />
|
||||
<Button Content="保存参数" Command="{Binding SaveParametersCommand}" ToolTip.Tip="保存标注、训练和设置参数,下次打开时自动恢复" />
|
||||
<Button Content="配方文件夹" Command="{Binding RevealCommand}" />
|
||||
<Button Content="取消任务" Command="{Binding CancelCommand}" IsEnabled="{Binding IsBusy}" />
|
||||
</StackPanel>
|
||||
</DockPanel>
|
||||
</WrapPanel>
|
||||
</StackPanel>
|
||||
<Grid Grid.Row="1">
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="220" />
|
||||
<ColumnDefinition Width="180" />
|
||||
<ColumnDefinition Width="12" />
|
||||
<ColumnDefinition Width="*" />
|
||||
<ColumnDefinition Width="12" />
|
||||
<ColumnDefinition Width="330" />
|
||||
<ColumnDefinition Width="300" />
|
||||
</Grid.ColumnDefinitions>
|
||||
<DockPanel>
|
||||
<StackPanel DockPanel.Dock="Top" Margin="0,0,0,10">
|
||||
@ -74,8 +74,8 @@
|
||||
<ScrollViewer VerticalScrollBarVisibility="Auto">
|
||||
<StackPanel>
|
||||
<TextBlock Text="所属配方" />
|
||||
<ComboBox ItemsSource="{Binding Recipes}" SelectedItem="{Binding RecipeName, Mode=TwoWay, Converter={StaticResource SelectionConverter}}" HorizontalAlignment="Stretch" />
|
||||
<TextBlock Text="每个视频标注一个零件;请先在运行设置的“配方编辑 → 零件列表”中维护零件。" Classes="Hint" />
|
||||
<TextBlock Text="{Binding RecipeName}" FontWeight="Bold" />
|
||||
<TextBlock Text="每个视频标注一个零件;零件名称在本窗口的“零件列表”中维护,修改后请先保存配方。" Classes="Hint" />
|
||||
<TextBlock Text="零件类别名称" Margin="0,12,0,0" />
|
||||
<ComboBox x:Name="TrainingPartPicker" ItemsSource="{Binding PartNames}" SelectedItem="{Binding Label, Mode=TwoWay, Converter={StaticResource SelectionConverter}}" HorizontalAlignment="Stretch" />
|
||||
<TextBlock Text="抽帧间隔(原视频帧数)" />
|
||||
|
||||
@ -2,13 +2,11 @@ using Avalonia.Controls;
|
||||
using Avalonia.Input;
|
||||
using Avalonia.Interactivity;
|
||||
using Avalonia.Threading;
|
||||
using SopHelper.Core.Prism;
|
||||
using SopHelper.Engine.Camera;
|
||||
using SopHelper.VVMs.SopPage;
|
||||
|
||||
namespace SopHelper.Training;
|
||||
|
||||
[NavigationPage(ViewName=nameof(TrainingPage),DisplayName="零件标注与训练",Index=1)]
|
||||
public partial class TrainingPage : UserControl
|
||||
{
|
||||
private readonly MainViewModel _model;
|
||||
@ -16,20 +14,26 @@ public partial class TrainingPage : UserControl
|
||||
private CameraWindow? _cameraWindow;
|
||||
private Window? _host;
|
||||
private bool _closing,_closedSafely;
|
||||
public TrainingPage(MainViewModel model,SopPageViewModel? sop)
|
||||
private readonly Func<CameraInfo?> _selectedCameraProvider;
|
||||
private readonly Func<bool> _canOpenCamera;
|
||||
public MainViewModel Model => _model;
|
||||
public TrainingPage(MainViewModel model,SopPageViewModel? sop, bool embedded = false, Func<CameraInfo?>? selectedCameraProvider = null, Func<bool>? canOpenCamera = null)
|
||||
{
|
||||
InitializeComponent();_model=model;_sop=sop;DataContext=model;
|
||||
_selectedCameraProvider=selectedCameraProvider??(()=>_sop?.SelectedCamera);
|
||||
_canOpenCamera=canOpenCamera??(()=>true);
|
||||
Canvas.BoxDrawn+=model.DrawBox;
|
||||
model.ReadApiKey=()=>ApiKey.Text??"";
|
||||
AttachedToVisualTree+=(_,_)=>
|
||||
{
|
||||
if (!model.IsBusy && sop != null)
|
||||
if (!embedded && !model.IsBusy && sop != null)
|
||||
{
|
||||
foreach (var recipe in sop.Recipes.Select(System.IO.Path.GetFileNameWithoutExtension).OfType<string>())
|
||||
if (!model.Recipes.Contains(recipe)) model.Recipes.Add(recipe);
|
||||
if (string.IsNullOrWhiteSpace(model.RecipeName)) model.RecipeName = System.IO.Path.GetFileNameWithoutExtension(sop.SelectedRecipe) ?? "";
|
||||
model.RefreshPartNames();
|
||||
}
|
||||
if(!model.IsBusy)model.RefreshPartNames();
|
||||
if(embedded)return;
|
||||
if(_host!=null || TopLevel.GetTopLevel(this) is not Window host)return;
|
||||
_host=host;host.Closing+=HostClosing;
|
||||
};
|
||||
@ -44,16 +48,19 @@ public partial class TrainingPage : UserControl
|
||||
}
|
||||
private async void OpenCameraClicked(object? sender,RoutedEventArgs e)
|
||||
{
|
||||
if(_sop is { CanSelectCamera:false } || _sop is { IsConnected:true })
|
||||
{_model.Status="请先停止 SOP 采集并等待相机操作完成,再打开录像";return;}
|
||||
if(!_canOpenCamera() || _sop is { CanSelectCamera:false } || _sop is { IsConnected:true })
|
||||
{_model.Status="请先停止其他相机预览或 SOP 采集,再打开零件录像";return;}
|
||||
if(TopLevel.GetTopLevel(this) is not Window owner)return;
|
||||
if(string.IsNullOrWhiteSpace(_model.RecipeName)){_model.Status="请先选择配方,再打开录像";return;}
|
||||
_cameraWindow=new CameraWindow(new CameraViewModel(new CameraService(),_model.Root,_model.RecipeName,selectedCameraProvider:()=>_sop?.SelectedCamera));
|
||||
_cameraWindow=new CameraWindow(new CameraViewModel(new CameraService(),_model.Root,_model.RecipeName,selectedCameraProvider:_selectedCameraProvider));
|
||||
try { await _cameraWindow.ShowDialog(owner); }
|
||||
finally { _model.VideoImportDirectory=_cameraWindow.Model.SaveDirectory;_cameraWindow=null; }
|
||||
}
|
||||
public async Task ShutdownAsync()
|
||||
{await _model.StopAsync();if(_cameraWindow!=null)await _cameraWindow.Model.ShutdownAsync();}
|
||||
{
|
||||
await _model.StopAsync();
|
||||
if(_cameraWindow is { } cameraWindow){await cameraWindow.Model.ShutdownAsync();cameraWindow.Close();}
|
||||
}
|
||||
private async void HostClosing(object? sender,WindowClosingEventArgs e)
|
||||
{
|
||||
if(_closedSafely)return;e.Cancel=true;if(_closing)return;_closing=true;_host!.IsEnabled=false;
|
||||
|
||||
@ -7,7 +7,7 @@ public sealed class RecipeDialogWindow : Window,IDialogWindow
|
||||
public IDialogResult Result {get;set;}=new DialogResult();
|
||||
public RecipeDialogWindow()
|
||||
{
|
||||
Width=1040;Height=760;MinWidth=1040;MinHeight=760;
|
||||
Width=1180;Height=880;MinWidth=1040;MinHeight=800;
|
||||
WindowStartupLocation=WindowStartupLocation.CenterOwner;
|
||||
HorizontalContentAlignment=Avalonia.Layout.HorizontalAlignment.Stretch;
|
||||
VerticalContentAlignment=Avalonia.Layout.VerticalAlignment.Stretch;
|
||||
|
||||
@ -474,6 +474,12 @@
|
||||
</Grid>
|
||||
</Grid>
|
||||
</TabItem>
|
||||
<TabItem Header="零件标注与训练">
|
||||
<Grid RowDefinitions="Auto,*">
|
||||
<TextBlock Text="标注和训练固定使用当前配方。新配方请先保存;修改零件列表后,请保存配方再开始训练。" TextWrapping="Wrap" Margin="10,8,10,0" />
|
||||
<ContentControl Grid.Row="1" Content="{Binding TrainingView}" IsVisible="{Binding HasSopRecording}" HorizontalContentAlignment="Stretch" VerticalContentAlignment="Stretch" />
|
||||
</Grid>
|
||||
</TabItem>
|
||||
</TabControl>
|
||||
<Grid Grid.Row="2" Margin="0,10,0,0">
|
||||
<Grid.ColumnDefinitions>
|
||||
|
||||
@ -23,7 +23,7 @@ public partial class RecipeEditor : UserControl
|
||||
if (_host is not null) _host.Closing -= Closing;
|
||||
_host = null;
|
||||
UnbindRecording();
|
||||
if (_model is not null) { _model.PropertyChanged -= ModelChanged; _ = _model.ShutdownSopRecordingAsync(); }
|
||||
if (_model is not null) { _model.PropertyChanged -= ModelChanged; _ = _model.ShutdownAsync(); }
|
||||
};
|
||||
}
|
||||
private void BindModel()
|
||||
@ -79,7 +79,7 @@ public partial class RecipeEditor : UserControl
|
||||
if (_closedSafely || _model?.SopRecording is null) return;
|
||||
if (_closing) { e.Cancel = true; return; }
|
||||
_closing = true; _dialog?.Close(false);
|
||||
var shutdown = _model.ShutdownSopRecordingAsync();
|
||||
var shutdown = _model.ShutdownAsync();
|
||||
// The Close command already awaited shutdown. Let Prism finish that close in one pass.
|
||||
if (shutdown.IsCompleted) { _closedSafely = true; return; }
|
||||
e.Cancel = true;
|
||||
|
||||
@ -37,6 +37,11 @@ public class RecipeEditorViewModel : BindableBase, IDialogAware
|
||||
private ICameraService? _camera;
|
||||
private CameraInfo? _cameraInfo;
|
||||
private Func<CameraInfo?>? _selectedCameraProvider;
|
||||
private Func<bool> _canUseCamera = () => true;
|
||||
private WorkerClient? _trainingWorker;
|
||||
private SopHelper.Training.TrainingPage? _trainingView;
|
||||
private Task? _shutdown;
|
||||
public SopHelper.Training.TrainingPage? TrainingView { get => _trainingView; private set => SetProperty(ref _trainingView, value); }
|
||||
private SopHelper.Training.CameraViewModel? _sopRecording;
|
||||
public SopHelper.Training.CameraViewModel? SopRecording { get => _sopRecording; private set => SetProperty(ref _sopRecording, value); }
|
||||
public bool HasSopRecording => SopRecording is not null;
|
||||
@ -102,7 +107,7 @@ public class RecipeEditorViewModel : BindableBase, IDialogAware
|
||||
CloseCommand = new DelegateCommand(async () =>
|
||||
{
|
||||
_closingDialog = true; CloseCommand.RaiseCanExecuteChanged();
|
||||
await ShutdownSopRecordingAsync(); RequestClose.Invoke(ButtonResult.Cancel);
|
||||
await ShutdownAsync(); RequestClose.Invoke(ButtonResult.Cancel);
|
||||
}, () => !IsCapturing && !_closingDialog);
|
||||
CaptureImageCommand = new DelegateCommand(async () => await CaptureImageAsync(),
|
||||
() => !IsCapturing && _camera is not null && _cameraInfo is not null);
|
||||
@ -121,6 +126,7 @@ public class RecipeEditorViewModel : BindableBase, IDialogAware
|
||||
_camera = parameters.GetValue<ICameraService>("cameraService");
|
||||
_cameraInfo = parameters.GetValue<CameraInfo>("cameraInfo");
|
||||
_selectedCameraProvider = parameters.GetValue<Func<CameraInfo?>>("selectedCameraProvider") ?? (() => _cameraInfo);
|
||||
_canUseCamera = parameters.GetValue<Func<bool>>("canUseCamera") ?? (() => true);
|
||||
PreviewImage = parameters.GetValue<BitmapSource>("preview");
|
||||
CaptureImageCommand.RaiseCanExecuteChanged();
|
||||
if (PreviewImage is not null) DescribeImage("最近一帧");
|
||||
@ -137,7 +143,7 @@ public class RecipeEditorViewModel : BindableBase, IDialogAware
|
||||
foreach (var name in partNames)
|
||||
Recipe.Parts.Items.Add(new TextItem { Text = name, RemoveCommand = Recipe.Parts.RemoveCommand });
|
||||
Recipe.Changed += RefreshWarnings;
|
||||
InitializeSopRecording();
|
||||
InitializeRecipeTools();
|
||||
|
||||
RefreshWarnings();
|
||||
}
|
||||
@ -148,22 +154,38 @@ public class RecipeEditorViewModel : BindableBase, IDialogAware
|
||||
/// <inheritdoc />
|
||||
public void OnDialogClosed()
|
||||
{
|
||||
_ = ShutdownSopRecordingAsync();
|
||||
_ = ShutdownAsync();
|
||||
Recipe.Changed -= RefreshWarnings;
|
||||
foreach (var node in _observedStepNodes) node.PropertyChanged -= StepChanged;
|
||||
_observedStepNodes.Clear();
|
||||
_onSaved = null;
|
||||
}
|
||||
|
||||
private void InitializeSopRecording()
|
||||
private void InitializeRecipeTools()
|
||||
{
|
||||
if (SopRecording is not null || string.IsNullOrEmpty(_path) || !File.Exists(_path)) return;
|
||||
// Use a separate camera service so SOP capture cannot dispose the operator page's service.
|
||||
var recipeDirectory = Path.GetDirectoryName(_path)!;
|
||||
var root = Path.GetDirectoryName(Path.GetDirectoryName(recipeDirectory)!)!;
|
||||
SopRecording = new SopHelper.Training.CameraViewModel(new CameraService(), root, Path.GetFileNameWithoutExtension(_path), sopStandard: true, selectedCameraProvider: _selectedCameraProvider);
|
||||
_trainingWorker = new WorkerClient();
|
||||
var training = new SopHelper.Training.MainViewModel(_trainingWorker);
|
||||
training.BindRecipe(Path.GetFileNameWithoutExtension(_path));
|
||||
TrainingView = new SopHelper.Training.TrainingPage(training, null, embedded: true,
|
||||
selectedCameraProvider: _selectedCameraProvider,
|
||||
canOpenCamera: () => _canUseCamera() && !IsCapturing && SopRecording?.IsPreviewing != true);
|
||||
RaisePropertyChanged(nameof(HasSopRecording));
|
||||
}
|
||||
public Task ShutdownAsync() => _shutdown ??= ShutdownCoreAsync();
|
||||
private async Task ShutdownCoreAsync()
|
||||
{
|
||||
try
|
||||
{
|
||||
if (TrainingView is not null) { TrainingView.IsEnabled = false; await TrainingView.ShutdownAsync(); }
|
||||
}
|
||||
catch (Exception error) { SaveStatus = "关闭训练任务时出错:" + error.Message; }
|
||||
finally { _trainingWorker?.Dispose(); await ShutdownSopRecordingAsync(); }
|
||||
}
|
||||
public async Task ShutdownSopRecordingAsync()
|
||||
{
|
||||
if (SopRecording is null) return;
|
||||
@ -317,7 +339,8 @@ public class RecipeEditorViewModel : BindableBase, IDialogAware
|
||||
_path = path;
|
||||
_isNew = false;
|
||||
Recipe.MarkSaved(Path.GetFileNameWithoutExtension(path));
|
||||
InitializeSopRecording();
|
||||
InitializeRecipeTools();
|
||||
TrainingView?.Model.RefreshPartNames();
|
||||
RaisePropertyChanged(nameof(FileNameText));
|
||||
RaisePropertyChanged(nameof(Title));
|
||||
|
||||
|
||||
@ -4,7 +4,7 @@ using SopHelper.VVMs.SopPage;
|
||||
|
||||
namespace SopHelper.VVMs.RuntimeSettings;
|
||||
|
||||
[NavigationPage(ViewName = nameof(RuntimeSettings), DisplayName = "运行设置", Index = 2)]
|
||||
[NavigationPage(ViewName = nameof(RuntimeSettings), DisplayName = "运行设置", Index = 1)]
|
||||
public partial class RuntimeSettings : UserControl
|
||||
{
|
||||
public RuntimeSettings(SopPageViewModel model)
|
||||
|
||||
@ -465,6 +465,7 @@ public class SopPageViewModel : ViewModelBase
|
||||
_dispatcher.BeginInvoke(() => RefreshRecipes(fileName))));
|
||||
parameters.Add("cameraService", _camera);
|
||||
parameters.Add("selectedCameraProvider", new Func<CameraInfo?>(() => SelectedCamera));
|
||||
parameters.Add("canUseCamera", new Func<bool>(() => CanSelectCamera && !IsConnected));
|
||||
if (SelectedCamera is not null) parameters.Add("cameraInfo", SelectedCamera);
|
||||
if (Frame is BitmapSource image)
|
||||
{
|
||||
|
||||
@ -67,8 +67,8 @@ internal static class Smoke
|
||||
var app=(App)Application.Current!;var window=lifetime.MainWindow!;
|
||||
CheckCameraPreferences(app);
|
||||
var navigation=app.Container.Resolve<NavigationModel>();
|
||||
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");
|
||||
Check(navigation.Pages.Count==2&&navigation.Pages[1].DisplayName=="运行设置","Sidebar contains operator and runtime settings pages only");
|
||||
Check(navigation.Pages[0].DisplayName=="SOP 辅助"&&!navigation.Pages.Any(p=>p.DisplayName=="零件标注与训练"),"Training no longer has a standalone sidebar entry");
|
||||
window.WindowState=WindowState.Normal;window.Width=1180;window.Height=820;
|
||||
await Task.Delay(150);
|
||||
var sop=app.Container.Resolve<SopPageViewModel>();
|
||||
@ -76,7 +76,7 @@ internal static class Smoke
|
||||
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");
|
||||
Check(!string.IsNullOrWhiteSpace(sop.SelectedRecipe)&&sopView.GetVisualDescendants().OfType<TextBlock>().Any(t=>t.Text==sop.SelectedRecipe),"Operator page displays the selected recipe before applying or starting");
|
||||
navigation.SelectedIndex=2;await Task.Delay(100);
|
||||
navigation.SelectedIndex=1;await Task.Delay(100);
|
||||
var settings=window.GetVisualDescendants().OfType<SopHelper.VVMs.RuntimeSettings.RuntimeSettings>().Single();
|
||||
Check(ReferenceEquals(settings.DataContext,sop),"Settings and operator page share runtime state");
|
||||
Check(settings.GetVisualDescendants().OfType<ComboBox>().Count()==2&&settings.GetVisualDescendants().OfType<Slider>().Count()==2,"Camera, recipe, threshold and stride editors are on settings page");
|
||||
@ -92,7 +92,7 @@ internal static class Smoke
|
||||
Check(window.GetVisualDescendants().OfType<SopPage>().Single().GetVisualDescendants().OfType<TextBlock>().Any(t=>t.Text=="pending.yaml"),"Operator page updates to the selected recipe without applying or starting");
|
||||
sop.SelectedRecipe=selected;await Task.Delay(80);
|
||||
Check(window.GetVisualDescendants().OfType<SopPage>().Single().GetVisualDescendants().OfType<TextBlock>().Any(t=>t.Text==selected),"Recipe selection changes notify the operator page immediately");
|
||||
navigation.SelectedIndex=2;await Task.Delay(80);
|
||||
navigation.SelectedIndex=1;await Task.Delay(80);
|
||||
Save(window,"runtime-settings");
|
||||
navigation.SelectedIndex=0;await Task.Delay(100);
|
||||
Check(window.GetVisualDescendants().OfType<SopPage>().Single().GetVisualDescendants().OfType<TextBlock>().Any(t=>t.Text==applied),"Operator page displays the applied recipe");
|
||||
@ -100,7 +100,7 @@ internal static class Smoke
|
||||
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);
|
||||
navigation.SelectedIndex=1;await Task.Delay(80);
|
||||
Check(settings.GetVisualDescendants().Where(c=>c is ComboBox or Slider).Cast<Control>().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();});
|
||||
@ -110,13 +110,13 @@ 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);
|
||||
navigation.SelectedIndex=1;await Task.Delay(80);
|
||||
Check(settings.GetVisualDescendants().Where(c=>c is ComboBox or Slider).Cast<Control>().All(c=>c.IsEnabled),"Runtime settings become editable after stopping");
|
||||
navigation.SelectedIndex=0;await Task.Delay(80);
|
||||
Check(window.GetVisualDescendants().OfType<SopPage>().Any(),"SOP page navigates");
|
||||
sop.EditRecipeCommand.Execute();await Task.Delay(150);
|
||||
var modal=lifetime.Windows.OfType<RecipeDialogWindow>().Single();
|
||||
Check(modal.Width==1040&&modal.Height==760&&modal.DataContext is RecipeEditorViewModel,"Original edit command opens the sized Prism recipe dialog");
|
||||
Check(modal.Width==1180&&modal.Height==880&&modal.DataContext is RecipeEditorViewModel,"Edit command opens a recipe dialog sized for embedded annotation and training");
|
||||
Check(ReferenceEquals(((RecipeEditorViewModel)modal.DataContext!).SopRecording!.SelectedCamera,sop.SelectedCamera),"SOP recording inherits the runtime settings camera");
|
||||
((RecipeEditorViewModel)modal.DataContext!).CloseCommand.Execute();
|
||||
for(var i=0;i<100&&lifetime.Windows.Contains(modal);i++)await Task.Delay(20);
|
||||
@ -125,11 +125,15 @@ internal static class Smoke
|
||||
var titlebarModal=lifetime.Windows.OfType<RecipeDialogWindow>().Single();titlebarModal.Close();
|
||||
for(var i=0;i<100&&lifetime.Windows.Contains(titlebarModal);i++)await Task.Delay(20);
|
||||
Check(!lifetime.Windows.Contains(titlebarModal),"Titlebar close awaits SOP camera shutdown and closes the Prism dialog");
|
||||
navigation.SelectedIndex=1;await Task.Delay(150);Save(window,"training");
|
||||
Check(window.GetVisualDescendants().OfType<TrainingPage>().Any(),"Training page navigates");
|
||||
var trainer=app.Container.Resolve<SopHelper.Training.MainViewModel>();
|
||||
Check(trainer.Recipes.Contains(Path.GetFileNameWithoutExtension(sop.SelectedRecipe)!) && trainer.RecipeName==Path.GetFileNameWithoutExtension(sop.SelectedRecipe),"Training offers the current SOP recipe automatically");
|
||||
var trainingView=window.GetVisualDescendants().OfType<TrainingPage>().Single();
|
||||
sop.EditRecipeCommand.Execute();await Task.Delay(150);
|
||||
var trainingDialog=lifetime.Windows.OfType<RecipeDialogWindow>().Single();
|
||||
var trainingEditorVm=(RecipeEditorViewModel)trainingDialog.DataContext!;
|
||||
var outerTabs=trainingDialog.GetVisualDescendants().OfType<TabControl>().First();outerTabs.SelectedIndex=6;await Task.Delay(100);
|
||||
var trainingView=trainingDialog.GetVisualDescendants().OfType<TrainingPage>().Single();
|
||||
var trainer=trainingView.Model;
|
||||
Save(trainingDialog,"training");
|
||||
Check(ReferenceEquals(trainingView,trainingEditorVm.TrainingView)&&trainer.RecipeName==Path.GetFileNameWithoutExtension(sop.SelectedRecipe),"Training is embedded in the current recipe editor");
|
||||
Check(!trainingView.GetVisualDescendants().OfType<ComboBox>().Any(c=>ReferenceEquals(c.ItemsSource,trainer.Recipes)),"Embedded training has no recipe selector");
|
||||
var saveParameters=trainingView.GetVisualDescendants().OfType<Button>().Single(b=>b.Content?.ToString()=="保存参数");
|
||||
Check(ReferenceEquals(saveParameters.Command,trainer.SaveParametersCommand)&&trainer.Project is null&&saveParameters.Command!.CanExecute(null),"Save parameters is available without an annotation project");
|
||||
trainer.ExtractStride=3;trainer.MaxFrames=420;trainer.ExportEvery=2;trainer.ImageSize=960;trainer.Epochs=12;trainer.Batch=2;
|
||||
@ -141,10 +145,10 @@ internal static class Smoke
|
||||
var savedRecipe=trainer.RecipeName;
|
||||
restoredTrainer.RecipeName=savedRecipe;
|
||||
Check(restoredTrainer.ImageSize==960,"Reopening the same recipe restores its saved training parameters");
|
||||
trainer.RecipeName="另一配方";
|
||||
Check(trainer.ImageSize==640&&trainer.ExtractStride==1,"New recipes have independent default parameters");
|
||||
trainer.ImageSize=320;trainer.SaveParametersCommand.Execute();trainer.RecipeName=savedRecipe;
|
||||
Check(trainer.ImageSize==960&&trainer.ExtractStride==3,"Switching recipes restores each recipe's own parameters");
|
||||
restoredTrainer.RecipeName="另一配方";
|
||||
Check(restoredTrainer.ImageSize==640&&restoredTrainer.ExtractStride==1,"New recipes have independent default parameters");
|
||||
restoredTrainer.ImageSize=320;restoredTrainer.SaveParametersCommand.Execute();restoredTrainer.RecipeName=savedRecipe;
|
||||
Check(restoredTrainer.ImageSize==960&&restoredTrainer.ExtractStride==3,"Switching recipes restores each recipe's own parameters");
|
||||
var recipeId="onnx-smoke-"+Guid.NewGuid().ToString("N");
|
||||
var storage=new RecipeWorkspace(trainer.Root);
|
||||
var createEditor=new RecipeEditorViewModel();
|
||||
@ -195,7 +199,7 @@ internal static class Smoke
|
||||
var trainingTabs=trainingView.GetVisualDescendants().OfType<TabControl>().Single();
|
||||
trainingTabs.SelectedIndex=1;await Task.Delay(80);
|
||||
Check(trainingView.GetVisualDescendants().OfType<Button>().Any(b=>b.Content?.ToString()=="训练并更新配方模型"),"Recipe model update action is visible on the training tab");
|
||||
Save(window,"training-recipe-model");
|
||||
Save(trainingDialog,"training-recipe-model");
|
||||
trainingTabs.SelectedIndex=0;
|
||||
var temporary=Path.Combine(Path.GetTempPath(),"sophelper-avalonia-project-"+Guid.NewGuid().ToString("N"));Directory.CreateDirectory(temporary);
|
||||
using(var trainingFrame=new Mat(480,640,MatType.CV_8UC3,new Scalar(30,60,90)))Cv2.ImWrite(Path.Combine(temporary,"frame.png"),trainingFrame);
|
||||
@ -203,16 +207,22 @@ internal static class Smoke
|
||||
Frames=[new FrameAnnotation {Index=0,Image="frame.png",Status="unlabeled"}] };
|
||||
project.Save();trainer.Load(project.FilePath);trainer.DrawBox([10,20,100,200]);trainer.ApproveCommand.Execute();
|
||||
Check(TrainingProject.Load(trainer.Project!.FilePath).Frames[0].Status=="reviewed"&&RecipeWorkspace.IsWithin(trainer.Project.FilePath,storage.DirectoryFor(savedRecipe)),"Opened annotation projects are copied into their recipe and review saves there");
|
||||
navigation.SelectedIndex=0;navigation.SelectedIndex=1;await Task.Delay(80);
|
||||
Check(ReferenceEquals(trainer,app.Container.Resolve<SopHelper.Training.MainViewModel>())&&trainer.SelectedFrame?.Box is { Length:4 },"Navigation preserves the training project and annotation state");
|
||||
trainer.RecipeName="另一配方";
|
||||
Check(trainer.Project is null&&trainer.Frames.Count==0,"Switching recipes clears the previous recipe's annotation project");
|
||||
trainer.RecipeName=savedRecipe;trainer.Load(project.FilePath);
|
||||
await CheckTrainingLayout(window,trainingView,trainer);
|
||||
Save(window,"training-project");
|
||||
outerTabs.SelectedIndex=0;outerTabs.SelectedIndex=6;await Task.Delay(80);
|
||||
Check(ReferenceEquals(trainer,trainingEditorVm.TrainingView!.Model)&&trainer.SelectedFrame?.Box is { Length:4 },"Switching editor tabs preserves annotation state");
|
||||
try{trainer.RecipeName="另一配方";throw new Exception("Locked recipe accepted a switch");}catch(InvalidOperationException){}
|
||||
Check(trainer.RecipeName==savedRecipe&&trainer.Project is not null,"Embedded training cannot switch away from the edited recipe");
|
||||
var foreign=new TrainingProject{FilePath=Path.Combine(temporary,"foreign.json"),Name="其他零件",RecipeName="另一配方",Width=100,Height=100,Frames=[new FrameAnnotation{Index=0,Image="frame.png"}]};foreign.Save();
|
||||
try{trainer.Load(foreign.FilePath);throw new Exception("Foreign recipe project was accepted");}catch(InvalidOperationException){}
|
||||
Check(trainer.SelectedFrame?.Box is {Length:4},"Opening another recipe's project is rejected without altering current annotations");
|
||||
await CheckTrainingLayout(trainingDialog,trainingView,trainer);
|
||||
Save(trainingDialog,"training-project");
|
||||
trainer.DoctorCommand.Execute();
|
||||
for(var i=0;i<300&&trainer.IsBusy;i++)await Task.Delay(100);
|
||||
Check(!trainer.IsBusy&&trainer.Progress==100&&trainer.Logs.Contains("Python ")&&trainer.Logs.Contains("PyTorch"),"Training worker command completes using the repository Python runtime");
|
||||
trainer.DoctorCommand.Execute();Check(trainer.IsBusy,"A training worker operation is running before editor close");
|
||||
trainingEditorVm.CloseCommand.Execute();
|
||||
for(var i=0;i<200&&lifetime.Windows.Contains(trainingDialog);i++)await Task.Delay(20);
|
||||
Check(!lifetime.Windows.Contains(trainingDialog)&&!trainer.IsBusy&&File.Exists(trainer.Project!.FilePath),"Closing the editor cancels its worker and preserves saved annotations");
|
||||
var editorVm=new RecipeEditorViewModel();
|
||||
editorVm.OnDialogOpened(new DialogParameters { {"directory",storage.RecipesDirectory},
|
||||
{"config",SopHelper.Engine.Sop.SopConfigLoader.Load(storage.ConfigPath("demo"))},
|
||||
@ -221,7 +231,7 @@ internal static class Smoke
|
||||
var recipeBefore=SopHelper.Engine.Sop.SopConfigLoader.ToYaml(editorVm.Recipe.ToConfig());
|
||||
var dialog=new Window { Width=1180,Height=820,Content=editor };dialog.Show();await Task.Delay(100);
|
||||
var tabs=editor.GetVisualDescendants().OfType<TabControl>().First();
|
||||
Check(tabs.ItemCount==6,"Recipe tabs include the central parts catalog and SOP recording");
|
||||
Check(tabs.ItemCount==7,"Recipe tabs include parts, SOP recording and annotation/training");
|
||||
for(var i=0;i<tabs.ItemCount;i++){tabs.SelectedIndex=i;await Task.Delay(80);Save(dialog,"recipe-"+i);}
|
||||
Check(editorVm.Recipe.Steps.Count>0,"Original recipe ViewModel loads steps");
|
||||
Check(editorVm.Recipe.Steps[0].Detection?.Method=="hand_in_region","Recipe bindings preserve selected condition method");
|
||||
@ -293,10 +303,10 @@ internal static class Smoke
|
||||
for(var tab=0;tab<tabs.ItemCount;tab++)
|
||||
{
|
||||
tabs.SelectedIndex=tab;await Task.Delay(60);window.UpdateLayout();
|
||||
var expected=Math.Max(1080,scroll.Viewport.Width);
|
||||
var expected=Math.Max(960,scroll.Viewport.Width);
|
||||
Check(Math.Abs(layout.Bounds.Width-expected)<1,
|
||||
$"Training layout stays within viewport/minimum width with long logs and status ({size}, tab {tab}); actual={layout.Bounds.Width}, expected={expected}");
|
||||
Check(canvas.Bounds.Width>100&&canvas.Bounds.Width<=expected-574,
|
||||
Check(canvas.Bounds.Width>100&&canvas.Bounds.Width<=expected-504,
|
||||
"Annotation canvas stays within the center column after resizing and tab changes");
|
||||
}
|
||||
}
|
||||
|
||||
@ -24,6 +24,8 @@ internal static class Program
|
||||
public static void Main()
|
||||
{
|
||||
var root = Path.Combine(Path.GetTempPath(), "recording-limit-smoke-" + Guid.NewGuid().ToString("N"));
|
||||
var previousRoot = Environment.GetEnvironmentVariable("SOPHELPER_WORKSPACE_ROOT");
|
||||
Environment.SetEnvironmentVariable("SOPHELPER_WORKSPACE_ROOT", root);
|
||||
try
|
||||
{
|
||||
AppBuilder.Configure<Application>().UseSkia().UseHeadless(new AvaloniaHeadlessPlatformOptions { UseHeadlessDrawing = false }).SetupWithoutStarting();
|
||||
@ -83,6 +85,7 @@ internal static class Program
|
||||
}
|
||||
finally
|
||||
{
|
||||
Environment.SetEnvironmentVariable("SOPHELPER_WORKSPACE_ROOT", previousRoot);
|
||||
if (Path.GetFileName(root).StartsWith("recording-limit-smoke-") && Directory.Exists(root)) Directory.Delete(root, true);
|
||||
}
|
||||
}
|
||||
@ -103,7 +106,7 @@ internal static class Program
|
||||
var editor = new RecipeEditor { DataContext = vm };
|
||||
var window = new Window { Content = editor, Width = 1040, Height = 760 }; window.Show(); window.UpdateLayout();
|
||||
var tabs = editor.GetVisualDescendants().OfType<TabControl>().Single(); tabs.SelectedIndex = 5; window.UpdateLayout();
|
||||
Check(tabs.ItemCount == 6 && ((TabItem)tabs.Items[5]!).Header?.ToString() == "SOP流程视频", "Recipe editor contains the SOP recording page");
|
||||
Check(tabs.ItemCount == 7 && ((TabItem)tabs.Items[5]!).Header?.ToString() == "SOP流程视频", "Recipe editor contains the SOP recording page");
|
||||
var previewButton = editor.GetVisualDescendants().OfType<Button>().Single(b => ReferenceEquals(b.Command, model.PreviewCommand));
|
||||
var videoButtons = ((StackPanel)previewButton.Parent!).Children.OfType<Button>().ToArray();
|
||||
Check(ReferenceEquals(videoButtons[0].Command, model.PreviewCommand) && ReferenceEquals(videoButtons[1].Command, model.RecordCommand) && ReferenceEquals(videoButtons[^1].Command, model.RevealCommand), "Preview precedes recording and saved location is last");
|
||||
@ -203,8 +206,9 @@ internal static class Program
|
||||
Pump(other.ShutdownAsync());
|
||||
var fresh = new RecipeEditorViewModel(); var newConfig = new SopConfig(); newConfig.Sop.Name = "新配方";
|
||||
fresh.OnDialogOpened(new DialogParameters { { "directory", store.RecipesDirectory }, { "config", newConfig }, { "new", true } });
|
||||
Check(!fresh.HasSopRecording, "Unsaved recipes cannot record into an ambiguous directory");
|
||||
Check(!fresh.HasSopRecording && fresh.TrainingView is null, "Unsaved recipes cannot record or train into an ambiguous directory");
|
||||
fresh.SaveCommand.Execute(); Check(fresh.HasSopRecording, "Saving a new recipe enables its SOP recording page");
|
||||
Check(fresh.TrainingView?.Model.RecipeName == "新配方", "Saving a new recipe creates training bound to that recipe");
|
||||
Pump(fresh.ShutdownSopRecordingAsync()); fresh.OnDialogClosed();
|
||||
}
|
||||
private static Window FindSopDialog(RecipeEditor editor)
|
||||
|
||||
Loading…
Reference in New Issue
Block a user