hot reload
This commit is contained in:
@@ -142,6 +142,7 @@ public abstract class BaseRecognitionControl: IRecognitionControl
|
||||
_cts?.Dispose();
|
||||
_cts = null;
|
||||
_loopTask = null;
|
||||
Cleanup();
|
||||
}
|
||||
|
||||
SessionEnded?.Invoke(new SessionEndedEvent
|
||||
@@ -241,4 +242,9 @@ public abstract class BaseRecognitionControl: IRecognitionControl
|
||||
public event Action<SessionStartedEvent> SessionStarted = delegate { };
|
||||
public event Action<SessionEndedEvent> SessionEnded = delegate { };
|
||||
public event Action<ErrorsInSequenceEvent> ErrorsInSequenceAlarm = delegate { };
|
||||
|
||||
public event Action RecipeFileChanged = delegate { };
|
||||
public virtual void HotReload() { }
|
||||
protected void RaiseRecipeFileChanged() => RecipeFileChanged?.Invoke();
|
||||
protected virtual void Cleanup() { }
|
||||
}
|
||||
@@ -17,4 +17,6 @@ public interface IRecognitionControl
|
||||
event Action<SessionEndedEvent> SessionEnded;
|
||||
event Action<ErrorsInSequenceEvent> ErrorsInSequenceAlarm;
|
||||
|
||||
void HotReload();
|
||||
event Action RecipeFileChanged;
|
||||
}
|
||||
@@ -32,9 +32,11 @@ namespace VisionBuilder.UI.Common
|
||||
[NotifyPropertyChangedFor(nameof(CanStop))]
|
||||
[NotifyPropertyChangedFor(nameof(CanPause))]
|
||||
[NotifyPropertyChangedFor(nameof(CanResume))]
|
||||
[NotifyPropertyChangedFor(nameof(CanHotReload))]
|
||||
[NotifyCanExecuteChangedFor(nameof(SelectRecipeCommand))]
|
||||
[NotifyCanExecuteChangedFor(nameof(StartCommand))]
|
||||
[NotifyCanExecuteChangedFor(nameof(StopCommand))]
|
||||
[NotifyCanExecuteChangedFor(nameof(HotReloadCommand))]
|
||||
private bool _isRunning;
|
||||
|
||||
[ObservableProperty]
|
||||
@@ -55,6 +57,13 @@ namespace VisionBuilder.UI.Common
|
||||
|
||||
public bool IsResumed => !IsPaused;
|
||||
|
||||
[ObservableProperty]
|
||||
[NotifyPropertyChangedFor(nameof(CanHotReload))]
|
||||
[NotifyCanExecuteChangedFor(nameof(HotReloadCommand))]
|
||||
private bool _isHotReloadAvailable;
|
||||
|
||||
public bool CanHotReload => IsRunning && IsHotReloadAvailable;
|
||||
|
||||
public bool CanStop => IsRunning;
|
||||
public bool CanStart => !IsRunning && SelectedRecipe!=null;
|
||||
public bool CanPause => (IsRunning && !IsPaused)&&_uiConfiguration.ShowPauseButton;
|
||||
@@ -100,6 +109,9 @@ namespace VisionBuilder.UI.Common
|
||||
recognitionControl.SessionStarted += StatisticsVm.Handle;
|
||||
recognitionControl.SessionStarted += ErrorsVm.Handle;
|
||||
|
||||
recognitionControl.RecipeFileChanged += () =>
|
||||
SynchronizationContext?.Post(_ => IsHotReloadAvailable = true, null);
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -153,7 +165,14 @@ namespace VisionBuilder.UI.Common
|
||||
});
|
||||
IsPaused = false;
|
||||
IsRunning = false;
|
||||
IsHotReloadAvailable = false;
|
||||
}
|
||||
|
||||
[RelayCommand(CanExecute = nameof(CanHotReload))]
|
||||
public void HotReload()
|
||||
{
|
||||
_recognitionControl.HotReload();
|
||||
IsHotReloadAvailable = false;
|
||||
}
|
||||
|
||||
[RelayCommand]
|
||||
|
||||
Reference in New Issue
Block a user