1.0.6
This commit is contained in:
@@ -1,11 +1,22 @@
|
|||||||
using System.Xml;
|
using System.Xml;
|
||||||
using Hawkeye.VisionBuilder.Workflow;
|
using Hawkeye.VisionBuilder.Workflow;
|
||||||
|
|
||||||
WorkflowList workflowList = new WorkflowList();
|
var files = Directory.GetFiles(AppContext.BaseDirectory, "*.hrcp", SearchOption.TopDirectoryOnly);
|
||||||
var file = File.OpenRead("gold_b97.hrcp");
|
foreach (var file in files)
|
||||||
using (var br = new BinaryReader(file))
|
|
||||||
{
|
{
|
||||||
workflowList.Load(br,new OperationDiscoveryService(workflowList));
|
try
|
||||||
|
{
|
||||||
|
Console.WriteLine($"Converting {file}");
|
||||||
|
var f = File.OpenRead(file);
|
||||||
|
WorkflowList list = new WorkflowList();
|
||||||
|
list.Load(new BinaryReader(f),new OperationDiscoveryService(list));
|
||||||
|
list.SaveJSON(Path.GetFileNameWithoutExtension(file)+".jhrcp");
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
Console.WriteLine($"Error processing file {file}: {ex.Message}");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -59,10 +59,10 @@ namespace Hawkeye.VisionBuilder.UI.Sources.Hawkeye
|
|||||||
if (File.Exists(_settings?.SettingsFile))
|
if (File.Exists(_settings?.SettingsFile))
|
||||||
{
|
{
|
||||||
_cameraSettings = UICameraSettings.LoadSettingsLocal(_settings.SettingsFile).ToCameraSettings();
|
_cameraSettings = UICameraSettings.LoadSettingsLocal(_settings.SettingsFile).ToCameraSettings();
|
||||||
_client.ApplySettings(_cameraSettings);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
_client.ApplySettings(_cameraSettings);
|
||||||
}
|
}
|
||||||
|
|
||||||
public Task<Mat> GetImage(CancellationToken token)
|
public Task<Mat> GetImage(CancellationToken token)
|
||||||
@@ -98,6 +98,7 @@ namespace Hawkeye.VisionBuilder.UI.Sources.Hawkeye
|
|||||||
try
|
try
|
||||||
{
|
{
|
||||||
Log.Debug("Got image on {adapter}", _settings.Adapter);
|
Log.Debug("Got image on {adapter}", _settings.Adapter);
|
||||||
|
Log.Debug("Bytes: {bytes}", obj.Length);
|
||||||
//FlipLines(obj, _flipBuffer);
|
//FlipLines(obj, _flipBuffer);
|
||||||
|
|
||||||
var pinnedArray = GCHandle.Alloc(obj, GCHandleType.Pinned);
|
var pinnedArray = GCHandle.Alloc(obj, GCHandleType.Pinned);
|
||||||
@@ -113,10 +114,10 @@ namespace Hawkeye.VisionBuilder.UI.Sources.Hawkeye
|
|||||||
_cameraSettings.OffsetX;
|
_cameraSettings.OffsetX;
|
||||||
|
|
||||||
// crop the image with opencv
|
// crop the image with opencv
|
||||||
_lastImage = image[0, _cameraSettings.ImageSettings.Lines, xCrop,
|
//_lastImage = image[0, _cameraSettings.ImageSettings.Lines, xCrop,
|
||||||
xCrop + _cameraSettings.ImageWidth].Clone();
|
// xCrop + _cameraSettings.ImageWidth].Clone();
|
||||||
|
_lastImage = image;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
if (_cameraSettings.BayerFilter)
|
if (_cameraSettings.BayerFilter)
|
||||||
|
|||||||
@@ -13,22 +13,23 @@ public class CandyboxBarcodeReader : IVisionBuilderModule
|
|||||||
private readonly ILoadingService _loadingService;
|
private readonly ILoadingService _loadingService;
|
||||||
|
|
||||||
private readonly CandyboxBarcodeReaderSettings _settings;
|
private readonly CandyboxBarcodeReaderSettings _settings;
|
||||||
private readonly IRecognitionControl _recognitionControl;
|
private readonly SingleCameraVM _singleCameraVm;
|
||||||
private readonly VisionBuilderStatistics _statistics;
|
private readonly VisionBuilderStatistics _statistics;
|
||||||
private SerialPort _port;
|
private SerialPort _port;
|
||||||
public EReaderState _readerState = EReaderState.ReadingRecipe;
|
public EReaderState _readerState = EReaderState.ReadingRecipe;
|
||||||
private MaterialCancellableLoader? _loader;
|
private MaterialCancellableLoader? _loader;
|
||||||
|
|
||||||
public CandyboxBarcodeReader(CandyboxBarcodeReaderSettings settings, IRecognitionControl recognitionControl, VisionBuilderStatistics statistics)
|
public CandyboxBarcodeReader(CandyboxBarcodeReaderSettings settings, SingleCameraVM singleCameraVm, VisionBuilderStatistics statistics)
|
||||||
{
|
{
|
||||||
_settings = settings;
|
_settings = settings;
|
||||||
_recognitionControl = recognitionControl;
|
_singleCameraVm = singleCameraVm;
|
||||||
_statistics = statistics;
|
_statistics = statistics;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void _port_DataReceived(object sender, SerialDataReceivedEventArgs e)
|
private void _port_DataReceived(object sender, SerialDataReceivedEventArgs e)
|
||||||
{
|
{
|
||||||
Thread.Sleep(100);
|
Thread.Sleep(500);
|
||||||
|
if(_singleCameraVm.IsRunning)return;
|
||||||
if(_readerState == EReaderState.ReadingRecipe)
|
if(_readerState == EReaderState.ReadingRecipe)
|
||||||
ReadRecipe();
|
ReadRecipe();
|
||||||
if (_readerState == EReaderState.ReadingAUF)
|
if (_readerState == EReaderState.ReadingAUF)
|
||||||
@@ -37,14 +38,21 @@ public class CandyboxBarcodeReader : IVisionBuilderModule
|
|||||||
|
|
||||||
private void ReadRecipe()
|
private void ReadRecipe()
|
||||||
{
|
{
|
||||||
if (_recognitionControl.IsRunning) return;
|
if (_singleCameraVm.IsRunning) return;
|
||||||
|
|
||||||
byte[] buffer = new byte[_port.BytesToRead];
|
byte[] buffer = new byte[_port.BytesToRead];
|
||||||
_port.Read(buffer, 0, _port.BytesToRead);
|
_port.Read(buffer, 0, _port.BytesToRead);
|
||||||
var data = Encoding.ASCII.GetString(buffer).Trim();
|
var data = Encoding.ASCII.GetString(buffer).Trim();
|
||||||
var recipes = _recognitionControl.GetRecipesData();
|
if (string.IsNullOrEmpty(data))
|
||||||
|
{
|
||||||
|
Log.Warning("Received empty recipe");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
var vm = _singleCameraVm.GetRecipeSelectionVm();
|
||||||
|
var recipes = vm.Recipes;
|
||||||
|
|
||||||
string searchString = data;
|
string searchString = data;
|
||||||
|
Log.Information("Read Recipe: {Recipe}", data);
|
||||||
if (_settings.BarcodeRecipeMappings.Any(x => x.Barcode == searchString))
|
if (_settings.BarcodeRecipeMappings.Any(x => x.Barcode == searchString))
|
||||||
{
|
{
|
||||||
searchString = _settings.BarcodeRecipeMappings.First(x => x.Barcode == searchString).RecipeName;
|
searchString = _settings.BarcodeRecipeMappings.First(x => x.Barcode == searchString).RecipeName;
|
||||||
@@ -56,20 +64,29 @@ public class CandyboxBarcodeReader : IVisionBuilderModule
|
|||||||
Log.Warning("No matching recipe found for data: {Data}", data);
|
Log.Warning("No matching recipe found for data: {Data}", data);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
vm.SelectedRecipe = vm.Recipes.FirstOrDefault(r => r.RecipeName == existingRecipe.RecipeName);
|
||||||
_recognitionControl.SetRecipe(existingRecipe);
|
_singleCameraVm.SynchronizationContext!.Post((_) =>
|
||||||
|
{
|
||||||
|
_loader = new MaterialCancellableLoader();
|
||||||
|
_loader.StartLoading("Waiting for AUF...");
|
||||||
|
_loader.LoadingCancelled += CancelWaiting;
|
||||||
|
_singleCameraVm.ProcessRecipeSelectionVm(vm);
|
||||||
|
}, null);
|
||||||
|
Application.DoEvents();
|
||||||
_readerState = EReaderState.ReadingAUF;
|
_readerState = EReaderState.ReadingAUF;
|
||||||
_loader = new MaterialCancellableLoader();
|
|
||||||
_loader.StartLoading("Waiting for AUF...");
|
|
||||||
_loader.LoadingCancelled += CancelWaiting;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void CancelWaiting(object? sender, string e)
|
private void CancelWaiting(object? sender, string e)
|
||||||
{
|
{
|
||||||
|
_singleCameraVm.SynchronizationContext!.Post((_) =>
|
||||||
|
{
|
||||||
|
_loader.FinishLoading("Waiting for AUF...");
|
||||||
|
_loader.LoadingCancelled -= CancelWaiting;
|
||||||
|
_loader = null;
|
||||||
|
}, null);
|
||||||
_readerState = EReaderState.ReadingRecipe;
|
_readerState = EReaderState.ReadingRecipe;
|
||||||
_loader.Close();
|
|
||||||
_loader.LoadingCancelled -= CancelWaiting;
|
|
||||||
_loader = null;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void ReadAUF()
|
private void ReadAUF()
|
||||||
@@ -77,17 +94,22 @@ public class CandyboxBarcodeReader : IVisionBuilderModule
|
|||||||
byte[] buffer = new byte[_port.BytesToRead];
|
byte[] buffer = new byte[_port.BytesToRead];
|
||||||
_port.Read(buffer, 0, _port.BytesToRead);
|
_port.Read(buffer, 0, _port.BytesToRead);
|
||||||
var data = Encoding.ASCII.GetString(buffer).Trim();
|
var data = Encoding.ASCII.GetString(buffer).Trim();
|
||||||
|
if (string.IsNullOrEmpty(data))
|
||||||
|
{
|
||||||
|
Log.Warning("Received empty AUF");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
Log.Information("Read AUF: {AUF}", data);
|
||||||
if (_loader != null)
|
if (_loader != null)
|
||||||
{
|
{
|
||||||
_loader.Close();
|
CancelWaiting(this, string.Empty);
|
||||||
_loader.LoadingCancelled -= CancelWaiting;
|
|
||||||
_loader = null;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
_statistics.Metadata = data;
|
_statistics.Metadata = data;
|
||||||
_recognitionControl.Start();
|
_=_singleCameraVm.Start().ConfigureAwait(false);
|
||||||
_readerState = EReaderState.ReadingAUF;
|
Application.DoEvents();
|
||||||
|
_readerState = EReaderState.ReadingRecipe;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -94,7 +94,7 @@ public class CandyboxImageProcessingControl : BaseRecognitionControl
|
|||||||
swTotal.Stop();
|
swTotal.Stop();
|
||||||
|
|
||||||
var allErrors =
|
var allErrors =
|
||||||
res.ErrorPoints.Select(x => x.ToString())
|
res.ErrorPoints.Select(x => "Position "+x.ToString())
|
||||||
.Concat(
|
.Concat(
|
||||||
res.ErrorReason.Where(x=>x != EErrorReason.Good).Select(x=>x.ToString())
|
res.ErrorReason.Where(x=>x != EErrorReason.Good).Select(x=>x.ToString())
|
||||||
).ToArray();
|
).ToArray();
|
||||||
|
|||||||
@@ -3,6 +3,7 @@ using Inspectron.Settings;
|
|||||||
using Ninject;
|
using Ninject;
|
||||||
using System.Reflection;
|
using System.Reflection;
|
||||||
using CandyboxPlugin.Modules.Barcode;
|
using CandyboxPlugin.Modules.Barcode;
|
||||||
|
using Ninject.Planning.Bindings;
|
||||||
using VisionBuilder.UI.Common;
|
using VisionBuilder.UI.Common;
|
||||||
using VisionBuilder.UI.Common.Plugins;
|
using VisionBuilder.UI.Common.Plugins;
|
||||||
using VisionBuilder.UI.Common.Processing;
|
using VisionBuilder.UI.Common.Processing;
|
||||||
@@ -21,7 +22,13 @@ namespace CandyboxPlugin
|
|||||||
|
|
||||||
public void RegisterCameraModules(IKernel kernel, string cameraName)
|
public void RegisterCameraModules(IKernel kernel, string cameraName)
|
||||||
{
|
{
|
||||||
kernel.Bind<CandyboxRecognitionControlSettings, ISettings>().ToConstant(new CandyboxRecognitionControlSettings(cameraName));
|
|
||||||
|
// remove settings binding
|
||||||
|
var existingRecognitionControlSettings = kernel.GetBindings(typeof(BaseRecognitionControlSettings)).First();
|
||||||
|
var toRemove = kernel.GetBindings(typeof(ISettings)).First(x => x.ProviderCallback.Target == existingRecognitionControlSettings.ProviderCallback.Target);
|
||||||
|
kernel.RemoveBinding(toRemove);
|
||||||
|
|
||||||
|
kernel.Bind<CandyboxRecognitionControlSettings,BaseRecognitionControlSettings, ISettings>().ToConstant(new CandyboxRecognitionControlSettings(cameraName));
|
||||||
|
|
||||||
kernel.Rebind<IRecognitionControl>().To<CandyboxImageProcessingControl>().InSingletonScope();
|
kernel.Rebind<IRecognitionControl>().To<CandyboxImageProcessingControl>().InSingletonScope();
|
||||||
|
|
||||||
|
|||||||
@@ -477,6 +477,8 @@ namespace CandyboxPlugin.Recipe
|
|||||||
|
|
||||||
if(_learnedParameters.CandyParameters.Count==0)errorReason.Add(EErrorReason.NotLearned);
|
if(_learnedParameters.CandyParameters.Count==0)errorReason.Add(EErrorReason.NotLearned);
|
||||||
|
|
||||||
|
Thread.Sleep(50);
|
||||||
|
|
||||||
return new ProcessingResult(framedImage, final,
|
return new ProcessingResult(framedImage, final,
|
||||||
_learnedParameters.CandyParameters.Count == 0 || wasError, (int) sw.ElapsedMilliseconds,
|
_learnedParameters.CandyParameters.Count == 0 || wasError, (int) sw.ElapsedMilliseconds,
|
||||||
errorReason)
|
errorReason)
|
||||||
@@ -487,6 +489,7 @@ namespace CandyboxPlugin.Recipe
|
|||||||
}
|
}
|
||||||
catch(Exception ex)
|
catch(Exception ex)
|
||||||
{
|
{
|
||||||
|
Thread.Sleep(50);
|
||||||
return new ProcessingResult(image, image,
|
return new ProcessingResult(image, image,
|
||||||
true, (int)sw.ElapsedMilliseconds,
|
true, (int)sw.ElapsedMilliseconds,
|
||||||
new List<EErrorReason>() {EErrorReason.Unknown})
|
new List<EErrorReason>() {EErrorReason.Unknown})
|
||||||
|
|||||||
@@ -10,14 +10,15 @@ namespace PackstrasseBarcodeReader
|
|||||||
public class PackstrasseBarcodeReaderModule : IVisionBuilderModule
|
public class PackstrasseBarcodeReaderModule : IVisionBuilderModule
|
||||||
{
|
{
|
||||||
private readonly PackstrasseBarcodeReaderSettings _settings;
|
private readonly PackstrasseBarcodeReaderSettings _settings;
|
||||||
private readonly IRecognitionControl _recognitionControl;
|
private readonly SingleCameraVM _singleCameraVm;
|
||||||
private SerialPort _port;
|
private SerialPort _port;
|
||||||
|
|
||||||
|
|
||||||
public PackstrasseBarcodeReaderModule(PackstrasseBarcodeReaderSettings settings, IRecognitionControl recognitionControl)
|
public PackstrasseBarcodeReaderModule(PackstrasseBarcodeReaderSettings settings, SingleCameraVM singleCameraVm)
|
||||||
{
|
{
|
||||||
_settings = settings;
|
_settings = settings;
|
||||||
_recognitionControl = recognitionControl;
|
_singleCameraVm = singleCameraVm;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void _port_DataReceived(object sender, SerialDataReceivedEventArgs e)
|
private void _port_DataReceived(object sender, SerialDataReceivedEventArgs e)
|
||||||
@@ -26,7 +27,8 @@ namespace PackstrasseBarcodeReader
|
|||||||
byte[] buffer = new byte[_port.BytesToRead];
|
byte[] buffer = new byte[_port.BytesToRead];
|
||||||
_port.Read(buffer, 0, _port.BytesToRead);
|
_port.Read(buffer, 0, _port.BytesToRead);
|
||||||
var data = Encoding.ASCII.GetString(buffer).Trim();
|
var data = Encoding.ASCII.GetString(buffer).Trim();
|
||||||
var recipes = _recognitionControl.GetRecipesData();
|
var vm = _singleCameraVm.GetRecipeSelectionVm();
|
||||||
|
|
||||||
|
|
||||||
string searchString = data;
|
string searchString = data;
|
||||||
if (_settings.BarcodeRecipeMappings.Any(x=>x.Barcode==searchString))
|
if (_settings.BarcodeRecipeMappings.Any(x=>x.Barcode==searchString))
|
||||||
@@ -34,14 +36,17 @@ namespace PackstrasseBarcodeReader
|
|||||||
searchString = _settings.BarcodeRecipeMappings.First(x => x.Barcode == searchString).RecipeName;
|
searchString = _settings.BarcodeRecipeMappings.First(x => x.Barcode == searchString).RecipeName;
|
||||||
}
|
}
|
||||||
|
|
||||||
var existingRecipe=recipes.FirstOrDefault(x => x.RecipeName == searchString);
|
var existingRecipe= vm.Recipes.FirstOrDefault(x => x.RecipeName == searchString);
|
||||||
if (existingRecipe == null)
|
if (existingRecipe == null)
|
||||||
{
|
{
|
||||||
Log.Warning("No matching recipe found for data: {Data}", data);
|
Log.Warning("No matching recipe found for data: {Data}", data);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
vm.SelectedRecipe = vm.Recipes.FirstOrDefault(r => r.RecipeName == existingRecipe.RecipeName);
|
||||||
_recognitionControl.SetRecipe(existingRecipe);
|
_singleCameraVm.SynchronizationContext!.Post((_) =>
|
||||||
|
{
|
||||||
|
_singleCameraVm.ProcessRecipeSelectionVm(vm);
|
||||||
|
}, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -12,8 +12,8 @@ public abstract class BaseRecognitionControlSettings(string cameraName) : ISetti
|
|||||||
|
|
||||||
public virtual void RegisterSettings(InspectronSettings settings)
|
public virtual void RegisterSettings(InspectronSettings settings)
|
||||||
{
|
{
|
||||||
settings.RegisterSimple(this, () => this.MinimumProcessingTime, CameraName + "/Hawkeye recognition", "Minimum processing time (ms)");
|
settings.RegisterSimple(this, () => this.MinimumProcessingTime, CameraName + "/Recognition", "Minimum processing time (ms)");
|
||||||
settings.RegisterSimple(this, () => this.RecipeNameFilter, CameraName + "/Hawkeye recognition", nameof(RecipeNameFilter));
|
settings.RegisterSimple(this, () => this.RecipeNameFilter, CameraName + "/Recognition", nameof(RecipeNameFilter));
|
||||||
settings.RegisterSimple(this, () => this.ErrorsInSequenceAlarm, CameraName + "/Hawkeye recognition", nameof(ErrorsInSequenceAlarm));
|
settings.RegisterSimple(this, () => this.ErrorsInSequenceAlarm, CameraName + "/Recognition", nameof(ErrorsInSequenceAlarm));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -16,6 +16,10 @@ public class UIConfiguration: ISettings
|
|||||||
|
|
||||||
public bool ProtectSettingsWithPassword { get; set; }=false;
|
public bool ProtectSettingsWithPassword { get; set; }=false;
|
||||||
|
|
||||||
|
public bool ShowPauseButton { get; set; }=false;
|
||||||
|
|
||||||
|
public bool ShowTestModeButton { get; set; } = false;
|
||||||
|
|
||||||
public List<ErrorShortName> ErrorShortNames { get; set; } = new List<ErrorShortName>();
|
public List<ErrorShortName> ErrorShortNames { get; set; } = new List<ErrorShortName>();
|
||||||
|
|
||||||
public void RegisterSettings(InspectronSettings settings)
|
public void RegisterSettings(InspectronSettings settings)
|
||||||
@@ -24,6 +28,8 @@ public class UIConfiguration: ISettings
|
|||||||
settings.RegisterSimple(this, () => this.AdminPassword, "System", "Password");
|
settings.RegisterSimple(this, () => this.AdminPassword, "System", "Password");
|
||||||
settings.RegisterSimple(this, () => this.ProtectSettingsWithPassword, "System", nameof(ProtectSettingsWithPassword));
|
settings.RegisterSimple(this, () => this.ProtectSettingsWithPassword, "System", nameof(ProtectSettingsWithPassword));
|
||||||
settings.RegisterSimple(this, () => this.ErrorShortNames, "Errors", "Error short names");
|
settings.RegisterSimple(this, () => this.ErrorShortNames, "Errors", "Error short names");
|
||||||
|
settings.RegisterSimple(this, () => this.ShowPauseButton, "System", nameof(ShowPauseButton));
|
||||||
|
settings.RegisterSimple(this, () => this.ShowTestModeButton, "System", nameof(ShowTestModeButton));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -100,7 +100,7 @@ public partial class ErrorPreviewVM:ObservableObject
|
|||||||
[RelayCommand(CanExecute = nameof(LearnButtonVisible))]
|
[RelayCommand(CanExecute = nameof(LearnButtonVisible))]
|
||||||
public void Learn()
|
public void Learn()
|
||||||
{
|
{
|
||||||
if (string.IsNullOrEmpty(_uiConfiguration.AdminPassword))
|
if (!string.IsNullOrEmpty(_uiConfiguration.AdminPassword))
|
||||||
{
|
{
|
||||||
var passwordOk= _passwordInputService.GetPassword()==_uiConfiguration.AdminPassword;
|
var passwordOk= _passwordInputService.GetPassword()==_uiConfiguration.AdminPassword;
|
||||||
if (!passwordOk) return;
|
if (!passwordOk) return;
|
||||||
|
|||||||
@@ -15,7 +15,8 @@ namespace VisionBuilder.UI.Common
|
|||||||
public partial class SingleCameraVM : ObservableObject, IEventHandler<ImageProcessedEvent>
|
public partial class SingleCameraVM : ObservableObject, IEventHandler<ImageProcessedEvent>
|
||||||
{
|
{
|
||||||
public SynchronizationContext? SynchronizationContext { get; set; }
|
public SynchronizationContext? SynchronizationContext { get; set; }
|
||||||
|
|
||||||
|
private readonly UIConfiguration _uiConfiguration;
|
||||||
private readonly IRecipeSelectionDialogService _recipeSelectionDialogService;
|
private readonly IRecipeSelectionDialogService _recipeSelectionDialogService;
|
||||||
private readonly IRecognitionControl _recognitionControl;
|
private readonly IRecognitionControl _recognitionControl;
|
||||||
|
|
||||||
@@ -56,8 +57,10 @@ namespace VisionBuilder.UI.Common
|
|||||||
|
|
||||||
public bool CanStop => IsRunning;
|
public bool CanStop => IsRunning;
|
||||||
public bool CanStart => !IsRunning && SelectedRecipe!=null;
|
public bool CanStart => !IsRunning && SelectedRecipe!=null;
|
||||||
public bool CanPause => IsRunning && !IsPaused;
|
public bool CanPause => (IsRunning && !IsPaused)&&_uiConfiguration.ShowPauseButton;
|
||||||
public bool CanResume => IsRunning && IsPaused;
|
public bool CanResume => (IsRunning && IsPaused) && _uiConfiguration.ShowPauseButton;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
public bool IsNotRunning => !IsRunning;
|
public bool IsNotRunning => !IsRunning;
|
||||||
private bool _handlingEnabled = true;
|
private bool _handlingEnabled = true;
|
||||||
@@ -77,10 +80,12 @@ namespace VisionBuilder.UI.Common
|
|||||||
[NotifyPropertyChangedFor(nameof(RecipeSelected))]
|
[NotifyPropertyChangedFor(nameof(RecipeSelected))]
|
||||||
[NotifyPropertyChangedFor(nameof(RecipeNotSelected))]
|
[NotifyPropertyChangedFor(nameof(RecipeNotSelected))]
|
||||||
private RecipeData? _selectedRecipe;
|
private RecipeData? _selectedRecipe;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
public SingleCameraVM(CameraSettings cameraSettings, UIConfiguration uiConfiguration, IRecipeSelectionDialogService recipeSelectionDialogService, IRecognitionControl recognitionControl, IImagePreviewService imagePreviewService, ILearningTool learningTool, IPasswordInputService passwordInputService)
|
public SingleCameraVM(CameraSettings cameraSettings, UIConfiguration uiConfiguration, IRecipeSelectionDialogService recipeSelectionDialogService, IRecognitionControl recognitionControl, IImagePreviewService imagePreviewService, ILearningTool learningTool, IPasswordInputService passwordInputService)
|
||||||
{
|
{
|
||||||
|
_uiConfiguration = uiConfiguration;
|
||||||
_recipeSelectionDialogService = recipeSelectionDialogService;
|
_recipeSelectionDialogService = recipeSelectionDialogService;
|
||||||
|
|
||||||
_recognitionControl = recognitionControl;
|
_recognitionControl = recognitionControl;
|
||||||
@@ -94,6 +99,8 @@ namespace VisionBuilder.UI.Common
|
|||||||
|
|
||||||
recognitionControl.SessionStarted += StatisticsVm.Handle;
|
recognitionControl.SessionStarted += StatisticsVm.Handle;
|
||||||
recognitionControl.SessionStarted += ErrorsVm.Handle;
|
recognitionControl.SessionStarted += ErrorsVm.Handle;
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -8,7 +8,7 @@ public static class ModuleExtensions
|
|||||||
{
|
{
|
||||||
public static IChildKernel UseHawkeyeRecipes(this IChildKernel self, string cameraName)
|
public static IChildKernel UseHawkeyeRecipes(this IChildKernel self, string cameraName)
|
||||||
{
|
{
|
||||||
self.Bind<HawkeyeRecognitionSettings, ISettings>().ToConstant(new HawkeyeRecognitionSettings(cameraName));
|
self.Bind<HawkeyeRecognitionSettings,BaseRecognitionControlSettings ,ISettings>().ToConstant(new HawkeyeRecognitionSettings(cameraName));
|
||||||
self.Bind<IRecognitionControl>().To<HawkeyeRecognitionControl>().InSingletonScope();
|
self.Bind<IRecognitionControl>().To<HawkeyeRecognitionControl>().InSingletonScope();
|
||||||
return self;
|
return self;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -25,11 +25,14 @@ namespace VisionBuilder.UI.Statistics
|
|||||||
private string _currentRecipe;
|
private string _currentRecipe;
|
||||||
private string _fileName;
|
private string _fileName;
|
||||||
private string _directoryPath;
|
private string _directoryPath;
|
||||||
|
private int _total = 0;
|
||||||
|
|
||||||
private const string BY_EVENTS_FILE_NAME = "statistics_by_events.csv";
|
private const string BY_EVENTS_FILE_NAME = "statistics_by_events.csv";
|
||||||
private const string MONTHLY_FILE_NAME = "statistics_month.csv";
|
private const string MONTHLY_FILE_NAME = "statistics_month.csv";
|
||||||
private const string EMPTY_DATE = "";
|
private const string EMPTY_DATE = "";
|
||||||
private const string EMPTY_TIME = "";
|
private const string EMPTY_TIME = "";
|
||||||
|
private const string DATE_FORMAT = "dd.MM.yyyy";
|
||||||
|
private const string TIME_FORMAT = "HH:mm:ss";
|
||||||
public bool DoNotDeleteTempFiles { get; set; } = false;
|
public bool DoNotDeleteTempFiles { get; set; } = false;
|
||||||
|
|
||||||
public VisionBuilderStatistics(VisionBuilderStatisticsSettings settings, IRecognitionControl recognitionControl, ILoadingService loadingService)
|
public VisionBuilderStatistics(VisionBuilderStatisticsSettings settings, IRecognitionControl recognitionControl, ILoadingService loadingService)
|
||||||
@@ -51,7 +54,7 @@ namespace VisionBuilder.UI.Statistics
|
|||||||
_loadingService.StartLoading("Writing statistics for " + _settings.CameraName);
|
_loadingService.StartLoading("Writing statistics for " + _settings.CameraName);
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
_csvStatistics.WriteLine([_startTime.ToString("d"), _startTime.ToString("T"), endedAt.ToString("d"), endedAt.ToString("T"), "", "", ""]);
|
_csvStatistics.WriteLine([_startTime.ToString(DATE_FORMAT), _startTime.ToString(TIME_FORMAT), endedAt.ToString(DATE_FORMAT), endedAt.ToString(TIME_FORMAT), "", "", ""]);
|
||||||
_csvStatistics.Dispose();
|
_csvStatistics.Dispose();
|
||||||
_csvStatistics = null;
|
_csvStatistics = null;
|
||||||
|
|
||||||
@@ -67,19 +70,21 @@ namespace VisionBuilder.UI.Statistics
|
|||||||
private void _recognitionControl_ImageProcessed(ImageProcessedEvent obj)
|
private void _recognitionControl_ImageProcessed(ImageProcessedEvent obj)
|
||||||
{
|
{
|
||||||
var sw = Stopwatch.StartNew();
|
var sw = Stopwatch.StartNew();
|
||||||
|
_total++;
|
||||||
if (obj.HasError)
|
if (obj.HasError)
|
||||||
{
|
{
|
||||||
RecordBadImage(obj.ErrorNames[0]);
|
RecordBadImage(obj.ErrorNames[0]);
|
||||||
}
|
}
|
||||||
sw.Stop();
|
sw.Stop();
|
||||||
Console.WriteLine($"Recording statistics took {sw.ElapsedMilliseconds} ms");
|
Log.Debug($"Recording statistics took {sw.ElapsedMilliseconds} ms");
|
||||||
}
|
}
|
||||||
|
|
||||||
private void _recognitionControl_SessionStarted(SessionStartedEvent obj)
|
private void _recognitionControl_SessionStarted(SessionStartedEvent obj)
|
||||||
{
|
{
|
||||||
_startTime = obj.SessionStarted;
|
_startTime = obj.SessionStarted;
|
||||||
|
_total = 0;
|
||||||
_currentRecipe = obj.RecipeName;
|
_currentRecipe = obj.RecipeName;
|
||||||
_fileName = "tmp_"+Guid.NewGuid().ToString()+".csv";
|
_fileName = BY_EVENTS_FILE_NAME;
|
||||||
_directoryPath = PathSettingsUtils.ConvertVariables(_settings.PathTemplate, _startTime, _startTime,
|
_directoryPath = PathSettingsUtils.ConvertVariables(_settings.PathTemplate, _startTime, _startTime,
|
||||||
obj.RecipeName, cameraName: _settings.CameraName);
|
obj.RecipeName, cameraName: _settings.CameraName);
|
||||||
_filePath = Path.Combine(_directoryPath, _fileName);
|
_filePath = Path.Combine(_directoryPath, _fileName);
|
||||||
@@ -89,7 +94,7 @@ namespace VisionBuilder.UI.Statistics
|
|||||||
Directory.CreateDirectory(Path.GetDirectoryName(_filePath));
|
Directory.CreateDirectory(Path.GetDirectoryName(_filePath));
|
||||||
}
|
}
|
||||||
_csvStatistics = new CsvStatistics(_filePath, headers);
|
_csvStatistics = new CsvStatistics(_filePath, headers);
|
||||||
_csvStatistics.WriteLine([_startTime.ToString("d"), _startTime.ToString("T")]); // session started
|
_csvStatistics.WriteLine([_startTime.ToString(DATE_FORMAT), _startTime.ToString(TIME_FORMAT)]); // session started
|
||||||
_defects = new ConcurrentDictionary<string, int>();
|
_defects = new ConcurrentDictionary<string, int>();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -101,7 +106,7 @@ namespace VisionBuilder.UI.Statistics
|
|||||||
|
|
||||||
_csvStatistics.WriteLine(
|
_csvStatistics.WriteLine(
|
||||||
|
|
||||||
[_startTime.ToString("d"), _startTime.ToString("T"), EMPTY_DATE, EMPTY_TIME, DateTime.Now.ToString("T"), _currentRecipe, defectName, Metadata]
|
[_startTime.ToString(DATE_FORMAT), _startTime.ToString(TIME_FORMAT), EMPTY_DATE, EMPTY_TIME, DateTime.Now.ToString(TIME_FORMAT), _currentRecipe, defectName, Metadata]
|
||||||
|
|
||||||
);
|
);
|
||||||
|
|
||||||
@@ -119,16 +124,56 @@ namespace VisionBuilder.UI.Statistics
|
|||||||
var monthFilePath = Path.Combine(_directoryPath, MONTHLY_FILE_NAME);
|
var monthFilePath = Path.Combine(_directoryPath, MONTHLY_FILE_NAME);
|
||||||
|
|
||||||
var monthStatistics = new CsvStatistics(monthFilePath, [
|
var monthStatistics = new CsvStatistics(monthFilePath, [
|
||||||
"Date start","Time start","Date end", "Time end" ,"Product","Error type","Error count"
|
|
||||||
]);
|
]);
|
||||||
|
|
||||||
|
monthStatistics.WriteLine(
|
||||||
|
["Start", _startTime.ToString($"{DATE_FORMAT} {TIME_FORMAT}")]
|
||||||
|
);
|
||||||
|
monthStatistics.WriteLine([
|
||||||
|
_settings.MetadataColumnName, Metadata
|
||||||
|
]);
|
||||||
|
monthStatistics.WriteLine(
|
||||||
|
[_settings.ProductColumnName, _currentRecipe]
|
||||||
|
);
|
||||||
|
monthStatistics.WriteLine(
|
||||||
|
[_settings.ErrorColumnName, "Amount"]
|
||||||
|
);
|
||||||
|
|
||||||
foreach (var defect in _defects)
|
foreach (var defect in _defects)
|
||||||
{
|
{
|
||||||
monthStatistics.WriteLine(
|
monthStatistics.WriteLine(
|
||||||
[startDate.ToString("d"), startTime.ToString("T"), endDate.ToString("d"), endTime.ToString("T"), _currentRecipe, defect.Key, defect.Value.ToString()]
|
[defect.Key, defect.Value.ToString()]
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var totalDefects = 0;
|
||||||
|
foreach (var defect in _defects)
|
||||||
|
{
|
||||||
|
totalDefects += defect.Value;
|
||||||
|
}
|
||||||
|
|
||||||
|
monthStatistics.WriteLine([]);
|
||||||
|
monthStatistics.WriteLine(
|
||||||
|
["Total errors", totalDefects.ToString()]
|
||||||
|
);
|
||||||
|
monthStatistics.WriteLine(
|
||||||
|
["Total produced(including errors)", _total.ToString()]
|
||||||
|
);
|
||||||
|
|
||||||
|
var percentage = _total > 0 ? (double)totalDefects / _total * 100 : 0;
|
||||||
|
|
||||||
|
monthStatistics.WriteLine(
|
||||||
|
["Error rate", percentage.ToString("F2") + "%"]
|
||||||
|
);
|
||||||
|
|
||||||
|
monthStatistics.WriteLine(
|
||||||
|
[
|
||||||
|
"End", _endTime.ToString($"{DATE_FORMAT} {TIME_FORMAT}")
|
||||||
|
]);
|
||||||
|
|
||||||
|
monthStatistics.WriteLine([]);
|
||||||
|
monthStatistics.WriteLine([]);
|
||||||
monthStatistics.Dispose();
|
monthStatistics.Dispose();
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
7
VisionBuilder.UI.Windows.Test/Form1.Designer.cs
generated
7
VisionBuilder.UI.Windows.Test/Form1.Designer.cs
generated
@@ -135,14 +135,16 @@
|
|||||||
// flowLayoutPanel1
|
// flowLayoutPanel1
|
||||||
//
|
//
|
||||||
flowLayoutPanel1.Anchor = AnchorStyles.Bottom | AnchorStyles.Left;
|
flowLayoutPanel1.Anchor = AnchorStyles.Bottom | AnchorStyles.Left;
|
||||||
|
flowLayoutPanel1.AutoSize = true;
|
||||||
|
flowLayoutPanel1.AutoSizeMode = AutoSizeMode.GrowAndShrink;
|
||||||
flowLayoutPanel1.BackColor = Color.Transparent;
|
flowLayoutPanel1.BackColor = Color.Transparent;
|
||||||
flowLayoutPanel1.Controls.Add(btnTestMode);
|
flowLayoutPanel1.Controls.Add(btnTestMode);
|
||||||
flowLayoutPanel1.Controls.Add(btnSettings);
|
flowLayoutPanel1.Controls.Add(btnSettings);
|
||||||
flowLayoutPanel1.Controls.Add(btnMinimize);
|
flowLayoutPanel1.Controls.Add(btnMinimize);
|
||||||
flowLayoutPanel1.Controls.Add(btnExit);
|
flowLayoutPanel1.Controls.Add(btnExit);
|
||||||
flowLayoutPanel1.Location = new Point(664, 992);
|
flowLayoutPanel1.Location = new Point(664, 1002);
|
||||||
flowLayoutPanel1.Name = "flowLayoutPanel1";
|
flowLayoutPanel1.Name = "flowLayoutPanel1";
|
||||||
flowLayoutPanel1.Size = new Size(728, 80);
|
flowLayoutPanel1.Size = new Size(728, 70);
|
||||||
flowLayoutPanel1.TabIndex = 12;
|
flowLayoutPanel1.TabIndex = 12;
|
||||||
//
|
//
|
||||||
// lblVersion
|
// lblVersion
|
||||||
@@ -170,6 +172,7 @@
|
|||||||
Text = "Form1";
|
Text = "Form1";
|
||||||
flowLayoutPanel1.ResumeLayout(false);
|
flowLayoutPanel1.ResumeLayout(false);
|
||||||
ResumeLayout(false);
|
ResumeLayout(false);
|
||||||
|
PerformLayout();
|
||||||
}
|
}
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|||||||
@@ -29,6 +29,8 @@ namespace VisionBuilder.UI.Windows.Test
|
|||||||
Load += Form1_Load;
|
Load += Form1_Load;
|
||||||
_mainWindowVm.PropertyChanged += _mainWindowVm_PropertyChanged;
|
_mainWindowVm.PropertyChanged += _mainWindowVm_PropertyChanged;
|
||||||
lblVersion.Text = $"v{Application.ProductVersion.Split('+')[0]}";
|
lblVersion.Text = $"v{Application.ProductVersion.Split('+')[0]}";
|
||||||
|
if(!_uiConfiguration.ShowTestModeButton)
|
||||||
|
flowLayoutPanel1.Controls.Remove(btnTestMode);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -8,7 +8,7 @@
|
|||||||
<ImplicitUsings>enable</ImplicitUsings>
|
<ImplicitUsings>enable</ImplicitUsings>
|
||||||
<ApplicationIcon>Inspectron icon-512.ico</ApplicationIcon>
|
<ApplicationIcon>Inspectron icon-512.ico</ApplicationIcon>
|
||||||
<Deterministic>false</Deterministic>
|
<Deterministic>false</Deterministic>
|
||||||
<Version>1.0.5</Version>
|
<Version>1.0.6</Version>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -47,6 +47,7 @@ namespace VisionBuilder.UI.Windows.Components
|
|||||||
btnSelectRecipe.DataBindings.Add(nameof(btnSelectRecipe.Primary), _singleCameraVm, nameof(_singleCameraVm.RecipeNotSelected), true, DataSourceUpdateMode.OnPropertyChanged);
|
btnSelectRecipe.DataBindings.Add(nameof(btnSelectRecipe.Primary), _singleCameraVm, nameof(_singleCameraVm.RecipeNotSelected), true, DataSourceUpdateMode.OnPropertyChanged);
|
||||||
btnPause.DataBindings.Add(nameof(btnPause.Visible), _singleCameraVm, nameof(_singleCameraVm.CanPause), true, DataSourceUpdateMode.OnPropertyChanged);
|
btnPause.DataBindings.Add(nameof(btnPause.Visible), _singleCameraVm, nameof(_singleCameraVm.CanPause), true, DataSourceUpdateMode.OnPropertyChanged);
|
||||||
btnResume.DataBindings.Add(nameof(btnResume.Visible), _singleCameraVm, nameof(_singleCameraVm.CanResume), true, DataSourceUpdateMode.OnPropertyChanged);
|
btnResume.DataBindings.Add(nameof(btnResume.Visible), _singleCameraVm, nameof(_singleCameraVm.CanResume), true, DataSourceUpdateMode.OnPropertyChanged);
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user