recipe name filter

This commit is contained in:
meelstorm
2025-07-28 09:52:29 +02:00
parent 71d59df0cd
commit f80b275ad8
58 changed files with 4066 additions and 79 deletions

View File

@@ -37,12 +37,21 @@ public class ErrorsVM:IEventHandler<ImageProcessedEvent>, IEventHandler<SessionS
{
if(!@event.HasError)return;
string additionalInfo = string.Empty;
var errorShortName = _uiConfiguration.ErrorShortNames
.FirstOrDefault(x => x.FullName == @event.ErrorNames[0]);
if (errorShortName != null)
{
additionalInfo += " ,"+errorShortName.ShortName;
}
ErrorData errorData = new ErrorData
{
RecipeName = @event.RecipeName,
ImageOriginal = @event.ImageOriginal,
ImageAnalysis = @event.ImageAnalysis,
Title = @event.ErrorNames +" "+ DateTime.Now.ToString("T")
Title =DateTime.Now.ToString("G")+ additionalInfo
};
if (Errors.Count >= _uiConfiguration.MaxErrorCount)

View File

@@ -6,5 +6,5 @@ namespace VisionBuilder.UI.Common.ViewModel;
public class RecipeSelectionVM
{
public ObservableCollection<RecipeData> Recipes { get; set; }
public RecipeData SelectedRecipe { get; set; }
public RecipeData? SelectedRecipe { get; set; }
}

View File

@@ -1,6 +1,7 @@
using CommunityToolkit.Mvvm.ComponentModel;
using CommunityToolkit.Mvvm.Input;
using System.Collections.ObjectModel;
using System.ComponentModel;
using VisionBuilder.UI.Common.Commands;
using VisionBuilder.UI.Common.Commands.Interfaces;
using VisionBuilder.UI.Common.RecipeProcessing;
@@ -12,6 +13,8 @@ namespace VisionBuilder.UI.Common
{
public partial class SingleCameraVM : ObservableObject, IEventHandler<ImageProcessedEvent>
{
public SynchronizationContext? SynchronizationContext { get; set; }
private readonly IRecipeSelectionDialogService _recipeSelectionDialogService;
private readonly IRecognitionControl _recognitionControl;
@@ -29,21 +32,38 @@ namespace VisionBuilder.UI.Common
[NotifyCanExecuteChangedFor(nameof(StartCommand))]
[NotifyCanExecuteChangedFor(nameof(StopCommand))]
private bool _isRunning;
[ObservableProperty]
[NotifyPropertyChangedFor(nameof(CameraLabelAndStatus))]
private string _cameraLabel;
public string CameraLabelAndStatus=>
$"{CameraLabel}{(IsPaused ? "(PAUSED)" : "")}";
[ObservableProperty]
[NotifyPropertyChangedFor(nameof(CameraLabelAndStatus))]
private bool _isPaused;
public bool IsResumed => !IsPaused;
public bool CanStop => IsRunning;
public bool CanStart => !IsRunning && SelectedRecipe!=null;
public bool IsNotRunning => !IsRunning;
private bool _handlingEnabled = true;
public bool RecipeSelected => SelectedRecipe != null;
public bool RecipeNotSelected => SelectedRecipe == null;
[ObservableProperty]
[NotifyPropertyChangedFor(nameof(CanStop))]
[NotifyPropertyChangedFor(nameof(CanStart))]
[NotifyCanExecuteChangedFor(nameof(SelectRecipeCommand))]
[NotifyCanExecuteChangedFor(nameof(StartCommand))]
[NotifyCanExecuteChangedFor(nameof(StopCommand))]
[NotifyPropertyChangedFor(nameof(RecipeSelected))]
[NotifyPropertyChangedFor(nameof(RecipeNotSelected))]
private RecipeData? _selectedRecipe;
@@ -69,11 +89,24 @@ namespace VisionBuilder.UI.Common
[RelayCommand(CanExecute = nameof(IsNotRunning))]
public void SelectRecipe()
{
var vm = new RecipeSelectionVM();
vm.Recipes = new ObservableCollection<RecipeData>(_recognitionControl.GetRecipesData());
var vm = GetRecipeSelectionVm();
if (!_recipeSelectionDialogService.SelectRecipe(vm))return;
ProcessRecipeSelectionVm(vm);
}
public RecipeSelectionVM GetRecipeSelectionVm()
{
var vm= new RecipeSelectionVM();
vm.Recipes = new ObservableCollection<RecipeData>(_recognitionControl.GetRecipesData());
vm.SelectedRecipe = SelectedRecipe;
return vm;
}
public void ProcessRecipeSelectionVm(RecipeSelectionVM vm)
{
if(!SelectRecipeCommand.CanExecute(null))return;
SelectedRecipe = vm.SelectedRecipe;
_recognitionControl.SetRecipe(SelectedRecipe);
_recognitionControl.SetRecipe(SelectedRecipe!);
CurrentRecipeName = SelectedRecipe?.RecipeName ?? "Select recipe";
}
@@ -93,6 +126,22 @@ namespace VisionBuilder.UI.Common
IsRunning = false;
}
[RelayCommand(CanExecute = nameof(IsResumed))]
public void Pause()
{
_recognitionControl.Pause();
IsPaused = true;
}
[RelayCommand(CanExecute = nameof(IsPaused))]
public void Resume()
{
_recognitionControl.Resume();
IsPaused = false;
}
public void Handle(ImageProcessedEvent @event)
{

View File

@@ -17,10 +17,14 @@ public partial class StatisticsVM: ObservableObject,IEventHandler<ImageProcessed
[ObservableProperty] private int _good;
[ObservableProperty] private int _bad;
[ObservableProperty] private int _total;
[ObservableProperty]
[NotifyPropertyChangedFor(nameof(ErrorRate))]
private int _total;
[ObservableProperty] private string _statisticsDetails="";
public string ErrorRate => _bad/(float)_total * 100 + "%";
private readonly Dictionary<string, int> _errorTypes = new();
public void Handle(ImageProcessedEvent @event)