2.0.14
This commit is contained in:
@@ -30,6 +30,7 @@ namespace Inspectron.Camera.UEye
|
|||||||
_camera = new uEye.Camera();
|
_camera = new uEye.Camera();
|
||||||
cameraIdx = _settings.CameraId;
|
cameraIdx = _settings.CameraId;
|
||||||
System.AppDomain.CurrentDomain.ProcessExit += AppDomain_ProcessExit;
|
System.AppDomain.CurrentDomain.ProcessExit += AppDomain_ProcessExit;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void AppDomain_ProcessExit(object sender, EventArgs e)
|
private void AppDomain_ProcessExit(object sender, EventArgs e)
|
||||||
@@ -179,10 +180,10 @@ namespace Inspectron.Camera.UEye
|
|||||||
throw new Exception("failed to save Parameters");
|
throw new Exception("failed to save Parameters");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
public int LastAqTime { get; private set; }
|
||||||
private void onFrameEvent(object sender, EventArgs e)
|
private void onFrameEvent(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
@@ -191,13 +192,14 @@ namespace Inspectron.Camera.UEye
|
|||||||
int s32MemId;
|
int s32MemId;
|
||||||
int active = (int)camera.Memory.GetActive(out s32MemId);
|
int active = (int)camera.Memory.GetActive(out s32MemId);
|
||||||
int num1 = (int)camera.Memory.Lock(s32MemId);
|
int num1 = (int)camera.Memory.Lock(s32MemId);
|
||||||
|
var sw = System.Diagnostics.Stopwatch.StartNew();
|
||||||
var image = this.MemoryToImage(s32MemId);
|
var image = this.MemoryToImage(s32MemId);
|
||||||
int num2 = (int)camera.Memory.Unlock(s32MemId);
|
sw.Stop();
|
||||||
|
LastAqTime = (int)sw.ElapsedMilliseconds;
|
||||||
|
|
||||||
|
|
||||||
if (!_channel.Writer.TryWrite(image))
|
int num2 = (int)camera.Memory.Unlock(s32MemId);
|
||||||
{
|
_channel.Writer.TryWrite(image);
|
||||||
Log.Warning("Image channel is full, dropping image");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
catch (TaskCanceledException ex)
|
catch (TaskCanceledException ex)
|
||||||
{
|
{
|
||||||
@@ -206,9 +208,6 @@ namespace Inspectron.Camera.UEye
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
private Channel<Mat> _channel = Channel.CreateBounded<Mat>(new BoundedChannelOptions(1)
|
private Channel<Mat> _channel = Channel.CreateBounded<Mat>(new BoundedChannelOptions(1)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
using Inspectron.Camera.UEye;
|
using Inspectron.Camera.UEye;
|
||||||
|
|
||||||
IDSImageSource imageSource = new IDSImageSource();
|
IDSImageSource imageSource = new IDSImageSource(new IDSImageSourceSettings("camera"){CameraId = 1});
|
||||||
|
|
||||||
Console.WriteLine("Opening");
|
Console.WriteLine("Opening");
|
||||||
imageSource.InitializeModule();
|
imageSource.InitializeModule();
|
||||||
@@ -8,6 +8,10 @@ imageSource.InitializeModule();
|
|||||||
while (true)
|
while (true)
|
||||||
{
|
{
|
||||||
Console.WriteLine("Getting image");
|
Console.WriteLine("Getting image");
|
||||||
|
var sw = System.Diagnostics.Stopwatch.StartNew();
|
||||||
var image=imageSource.GetImage(CancellationToken.None).Result;
|
var image=imageSource.GetImage(CancellationToken.None).Result;
|
||||||
|
sw.Stop();
|
||||||
|
Console.WriteLine($"Got image in {sw.ElapsedMilliseconds} ms");
|
||||||
|
Console.WriteLine("Last acquisition time: " + imageSource.LastAqTime);
|
||||||
image.SaveImage("test.png");
|
image.SaveImage("test.png");
|
||||||
}
|
}
|
||||||
@@ -56,7 +56,31 @@ public class SiemensCameraModule: IVisionBuilderModule
|
|||||||
}, null);
|
}, null);
|
||||||
_statistics.Metadata = packet.Materialnummer.ToString();
|
_statistics.Metadata = packet.Materialnummer.ToString();
|
||||||
}
|
}
|
||||||
|
Log.Information("Selected recipe {Recipe} for material number {MaterialNumber}", recipe, packet.Materialnummer);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
//Log.Information("Lifebit: {Lifebit}, KameraStart: {KameraStart}", packet.Lifebit, packet.KameraStart);
|
||||||
|
//Log.Information("Camera running: {IsRunning}", _singleCameraVm.IsRunning);
|
||||||
|
//if (recipe != selectedRecipe?.RecipeName)
|
||||||
|
//{
|
||||||
|
// if (packet.KameraStart && !_singleCameraVm.IsRunning)
|
||||||
|
// {
|
||||||
|
// Log.Information("Starting camera based on PLC packet.");
|
||||||
|
// _singleCameraVm.SynchronizationContext!.Post((o) =>
|
||||||
|
// {
|
||||||
|
// _ = _singleCameraVm.Start();
|
||||||
|
// }, null);
|
||||||
|
// }
|
||||||
|
// if (!packet.KameraStart && _singleCameraVm.IsRunning)
|
||||||
|
// {
|
||||||
|
// Log.Information("Stopping camera based on PLC packet.");
|
||||||
|
// _singleCameraVm.SynchronizationContext!.Post((o) =>
|
||||||
|
// {
|
||||||
|
// _ = _singleCameraVm.Stop();
|
||||||
|
// }, null);
|
||||||
|
// }
|
||||||
|
//}
|
||||||
|
|
||||||
|
|
||||||
return packet;
|
return packet;
|
||||||
|
|
||||||
|
|||||||
@@ -149,7 +149,8 @@ public abstract class BaseRecognitionControl: IRecognitionControl
|
|||||||
SessionEnded = DateTime.Now
|
SessionEnded = DateTime.Now
|
||||||
});
|
});
|
||||||
_loadingService.StopLoading($"Stopping {_settings.CameraName}");
|
_loadingService.StopLoading($"Stopping {_settings.CameraName}");
|
||||||
IsPaused = false; // ensure paused is reset
|
// note: recipe can be stared paused
|
||||||
|
//IsPaused = false; // ensure paused is reset
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -157,6 +158,7 @@ public abstract class BaseRecognitionControl: IRecognitionControl
|
|||||||
{
|
{
|
||||||
lock (_lock)
|
lock (_lock)
|
||||||
{
|
{
|
||||||
|
Log.Information("Pausing recognition");
|
||||||
IsPaused = true;
|
IsPaused = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -165,6 +167,7 @@ public abstract class BaseRecognitionControl: IRecognitionControl
|
|||||||
{
|
{
|
||||||
lock (_lock)
|
lock (_lock)
|
||||||
{
|
{
|
||||||
|
Log.Information("Resuming recognition");
|
||||||
IsPaused = false;
|
IsPaused = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -156,14 +156,14 @@ namespace VisionBuilder.UI.Common
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
[RelayCommand(CanExecute = nameof(IsResumed))]
|
[RelayCommand]
|
||||||
public void Pause()
|
public void Pause()
|
||||||
{
|
{
|
||||||
_recognitionControl.Pause();
|
_recognitionControl.Pause();
|
||||||
IsPaused = true;
|
IsPaused = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
[RelayCommand(CanExecute = nameof(IsPaused))]
|
[RelayCommand]
|
||||||
public void Resume()
|
public void Resume()
|
||||||
{
|
{
|
||||||
_recognitionControl.Resume();
|
_recognitionControl.Resume();
|
||||||
|
|||||||
@@ -30,23 +30,42 @@ public class IOCommanderModule:IVisionBuilderModule
|
|||||||
{
|
{
|
||||||
_ioCommander = _factory.Create();
|
_ioCommander = _factory.Create();
|
||||||
_ioCommander.OnPinChanged += OnPinChanged;
|
_ioCommander.OnPinChanged += OnPinChanged;
|
||||||
|
BroadcastInitialPinStates();
|
||||||
}
|
}
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
{
|
{
|
||||||
Log.Warning("IOCommander did non load: {e}",e);
|
Log.Warning("IOCommander did non load: {e}",e);
|
||||||
_ioCommander= null;
|
_ioCommander= null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
if (_settings.ShowDebugView)_debugViewService.ShowDebugView();
|
if (_settings.ShowDebugView)_debugViewService.ShowDebugView();
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
private void BroadcastInitialPinStates()
|
||||||
|
{
|
||||||
|
if (_ioCommander == null) return;
|
||||||
|
Task.Run(async () =>
|
||||||
|
{
|
||||||
|
// Wait for the first poll cycle to populate PinState
|
||||||
|
for (int attempt = 0; attempt < 10 && _ioCommander?.PinState == null; attempt++)
|
||||||
|
{
|
||||||
|
await Task.Delay(200);
|
||||||
|
}
|
||||||
|
if (_ioCommander?.PinState == null) return;
|
||||||
|
for (int i = 0; i < _ioCommander.PinState.Length; i++)
|
||||||
|
{
|
||||||
|
OnPinChanged(i + 1, _ioCommander.PinState[i]);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
ConcurrentDictionary<int, bool> _pinStates = new ConcurrentDictionary<int, bool>();
|
ConcurrentDictionary<int, bool> _pinStates = new ConcurrentDictionary<int, bool>();
|
||||||
public event Action<int, bool>? OnPinChangedEvent = delegate { };
|
public event Action<int, bool>? OnPinChangedEvent = delegate { };
|
||||||
private void OnPinChanged(int arg1, bool arg2)
|
private void OnPinChanged(int arg1, bool arg2)
|
||||||
{
|
{
|
||||||
_pinStates.TryAdd(arg1, arg2);
|
_pinStates[arg1] = arg2;
|
||||||
_debugViewService.SetInputPinStatus(arg1, arg2);
|
_debugViewService.SetInputPinStatus(arg1, arg2);
|
||||||
OnPinChangedEvent?.Invoke(arg1, arg2);
|
OnPinChangedEvent?.Invoke(arg1, arg2);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -75,6 +75,7 @@ namespace VisionBuilder.UI.Recipes.HawkeyeRecipe
|
|||||||
|
|
||||||
protected override (Mat originalImage, Mat analysisImage,TimeSpan processingTime, TimeSpan acquisitionTime, string[] errorNames)? ProcessImage(CancellationToken token)
|
protected override (Mat originalImage, Mat analysisImage,TimeSpan processingTime, TimeSpan acquisitionTime, string[] errorNames)? ProcessImage(CancellationToken token)
|
||||||
{
|
{
|
||||||
|
|
||||||
var sw = Stopwatch.StartNew();
|
var sw = Stopwatch.StartNew();
|
||||||
_workflow.Context.CancellationToken = token;
|
_workflow.Context.CancellationToken = token;
|
||||||
_workflow.ImageSource = _imageSource;
|
_workflow.ImageSource = _imageSource;
|
||||||
@@ -105,7 +106,10 @@ namespace VisionBuilder.UI.Recipes.HawkeyeRecipe
|
|||||||
}
|
}
|
||||||
|
|
||||||
string[] errorNames = _workflow.Operations.Where(x => !x.Result).Select(x => x.Label).ToArray();
|
string[] errorNames = _workflow.Operations.Where(x => !x.Result).Select(x => x.Label).ToArray();
|
||||||
|
if (_recognitionConfiguration.AlwaysError)
|
||||||
|
{
|
||||||
|
errorNames = errorNames.Concat(new[] { "Forced error" }).ToArray();
|
||||||
|
}
|
||||||
return (originalImage, analysisImage, sw.Elapsed, cameraTime, errorNames);
|
return (originalImage, analysisImage, sw.Elapsed, cameraTime, errorNames);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -6,6 +6,11 @@ namespace VisionBuilder.UI.Recipes.HawkeyeRecipe;
|
|||||||
|
|
||||||
public class HawkeyeRecognitionSettings(string cameraName) : BaseRecognitionControlSettings(cameraName)
|
public class HawkeyeRecognitionSettings(string cameraName) : BaseRecognitionControlSettings(cameraName)
|
||||||
{
|
{
|
||||||
|
public bool AlwaysError { get; set; }
|
||||||
|
|
||||||
|
public override void RegisterSettings(InspectronSettings settings)
|
||||||
|
{
|
||||||
|
base.RegisterSettings(settings);
|
||||||
|
settings.RegisterSimple(this, () => AlwaysError, CameraName + "/" + "Recognition", nameof(AlwaysError));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@@ -8,7 +8,7 @@
|
|||||||
<Nullable>enable</Nullable>
|
<Nullable>enable</Nullable>
|
||||||
<ApplicationIcon>Inspectron icon-512.ico</ApplicationIcon>
|
<ApplicationIcon>Inspectron icon-512.ico</ApplicationIcon>
|
||||||
<Deterministic>false</Deterministic>
|
<Deterministic>false</Deterministic>
|
||||||
<Version>2.0.12</Version>
|
<Version>2.0.14</Version>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
|||||||
@@ -36,13 +36,10 @@ namespace VisionBuilder.UI.Windows.Test
|
|||||||
|
|
||||||
//AppDomain.CurrentDomain.FirstChanceException += (sender, e) =>
|
//AppDomain.CurrentDomain.FirstChanceException += (sender, e) =>
|
||||||
//{
|
//{
|
||||||
// if (e.Exception.Message.Contains("timed out"))
|
// File.AppendAllText("timeout_log.txt",
|
||||||
// {
|
// $"[{DateTime.Now:O}] {e.Exception.GetType().FullName}: {e.Exception.Message}\n" +
|
||||||
// File.AppendAllText("timeout_log.txt",
|
// $"{e.Exception.StackTrace}\n" +
|
||||||
// $"[{DateTime.Now:O}] {e.Exception.GetType().FullName}: {e.Exception.Message}\n" +
|
// $"--- Inner: {e.Exception.InnerException}\n\n");
|
||||||
// $"{e.Exception.StackTrace}\n" +
|
|
||||||
// $"--- Inner: {e.Exception.InnerException}\n\n");
|
|
||||||
// }
|
|
||||||
//};
|
//};
|
||||||
// To customize application configuration such as set high DPI settings or default font,
|
// To customize application configuration such as set high DPI settings or default font,
|
||||||
// see https://aka.ms/applicationconfiguration.
|
// see https://aka.ms/applicationconfiguration.
|
||||||
|
|||||||
@@ -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>2.0.13</Version>
|
<Version>2.0.14</Version>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user