| | |
| | | /// <param name="disposing">如果应释放托管资源,为 true;否则为 false。</param> |
| | | protected override void Dispose(bool disposing) |
| | | { |
| | | this.isClosed = true; |
| | | if (disposing && (components != null)) |
| | | { |
| | | components.Dispose(); |
| | |
| | | |
| | | if (ProcessRunBll != null) |
| | | this.label1.Text = $"总数:{ProcessRunBll.total}"; |
| | | this.isClosed = false ; |
| | | var TaskPhotoContinue = Task.Factory.StartNew(() => |
| | | { |
| | | ThreadCircleRun(); |
| | | }); |
| | | } |
| | | |
| | | public void SetTitle(string title) |
| | |
| | | |
| | | if (isCircleRuning) |
| | | { |
| | | threadCircleRun = new Thread(ThreadCircleRun); |
| | | threadCircleRun.IsBackground = true; |
| | | threadCircleRun.Start(); |
| | | this.mAutoResetEvent.Set(); |
| | | } |
| | | else |
| | | { |
| | | isCircleRuning = false; |
| | | threadCircleRun.Abort(); |
| | | } |
| | | if (!isCircleRuning) |
| | | { |
| | | ProcessRunBll.LogInfo($"{ProcessRunBll.Name}关闭连续运行", LogInfoType.PASS); |
| | | return; |
| | | } |
| | | |
| | | ProcessRunBll.LogInfo($"{ProcessRunBll.Name}开启连续运行", LogInfoType.WARN); |
| | | } |
| | | catch { } |
| | | } |
| | | |
| | | Thread threadCircleRun = null; |
| | | private AutoResetEvent mAutoResetEvent = new AutoResetEvent(false); |
| | | bool isClosed = false; |
| | | |
| | | void ThreadCircleRun() |
| | | { |
| | | if (!isCircleRuning) |
| | | while (!isClosed) |
| | | { |
| | | ProcessRunBll.LogInfo($"{ProcessRunBll.Name}关闭连续运行", LogInfoType.PASS); |
| | | return; |
| | | } |
| | | |
| | | ProcessRunBll.LogInfo($"{ProcessRunBll.Name}开启连续运行", LogInfoType.WARN); |
| | | |
| | | while (isCircleRuning) |
| | | { |
| | | //this.BeginInvoke(new Action(() => |
| | | //{ |
| | | try |
| | | { |
| | | if (isCircleRuning == false) |
| | | { |
| | | this.mAutoResetEvent.WaitOne(); |
| | | } |
| | | |
| | | ProcessRunBll.LogInfo($"{ProcessRunBll.Name}开始运行", LogInfoType.WARN); |
| | | ClearObj(); |
| | | bool result = ProcessRunBll.Run(); |
| | |
| | | ShowHoImage(RecordImage); |
| | | } |
| | | catch { } |
| | | //})); |
| | | |
| | | Thread.Sleep(100); |
| | | Thread.Sleep(33); |
| | | } |
| | | } |
| | | |
| | |
| | | using LB_VisionProcesses.Processes.ScriptTool; |
| | | using OpenCvSharp; |
| | | using System.Collections.Concurrent; |
| | | using System.Windows.Media.Media3D; |
| | | |
| | | namespace LB_SmartVision.ProcessRun |
| | | { |
| | |
| | | if (dicContext.TryGetValue(ProcessName, out IProcess obj) |
| | | && obj is IProcess process) |
| | | { |
| | | process.InputImage = null; |
| | | //process.InputImage = null; |
| | | |
| | | if (process.InputImage != null) |
| | | { |
| | | if (process.InputImage is HObject) |
| | | ((HObject)process.InputImage).Dispose(); |
| | | else if (process.InputImage is Mat) |
| | | ((Mat)process.InputImage).Dispose(); |
| | | else if (process.InputImage is Bitmap) |
| | | ((Bitmap)process.InputImage).Dispose(); |
| | | |
| | | process.InputImage = null; |
| | | } |
| | | |
| | | if (process.OutputImage != null) |
| | | { |
| | | if (process.OutputImage is HObject) |
| | | ((HObject)process.OutputImage).Dispose(); |
| | | else if (process.OutputImage is Mat) |
| | | ((Mat)process.OutputImage).Dispose(); |
| | | else if (process.OutputImage is Bitmap) |
| | | ((Bitmap)process.OutputImage).Dispose(); |
| | | |
| | | process.OutputImage = null; |
| | | } |
| | | |
| | | if (process.Record != null) |
| | | { |
| | | process.Record.Dispose(); |
| | | process.Record = null; |
| | | } |
| | | UpdateInputs(process); |
| | | |
| | | // 不同节点跳过的方式不同 |
| | |
| | | Result = true; |
| | | bCompleted = false; |
| | | Msg = ""; |
| | | OutputImage = null; |
| | | if (OutputImage != null) |
| | | { |
| | | if (OutputImage is HObject) |
| | | ((HObject)OutputImage).Dispose(); |
| | | else if (OutputImage is Mat) |
| | | ((Mat)OutputImage).Dispose(); |
| | | else if (OutputImage is Bitmap) |
| | | ((Bitmap)OutputImage).Dispose(); |
| | | OutputImage = null; |
| | | } |
| | | |
| | | if (Record != null) |
| | | Record.Dispose(); |
| | |
| | | using Newtonsoft.Json; |
| | | using HalconDotNet; |
| | | using Newtonsoft.Json; |
| | | using Newtonsoft.Json.Serialization; |
| | | using OpenCvSharp; |
| | | using OpenCvSharp.Extensions; |
| | | using System; |
| | | using System.Collections.Concurrent; |
| | | using System.Diagnostics; |
| | | using System.Text; |
| | |
| | | Msg = ""; |
| | | if (OutputImage != null) |
| | | { |
| | | if (OutputImage is Bitmap) |
| | | { |
| | | if (OutputImage is HObject) |
| | | ((HObject)OutputImage).Dispose(); |
| | | else if (OutputImage is Mat) |
| | | ((Mat)OutputImage).Dispose(); |
| | | else if (OutputImage is Bitmap) |
| | | ((Bitmap)OutputImage).Dispose(); |
| | | } |
| | | |
| | | OutputImage = null; |
| | | } |
| | | if (Record != null) |
| | | { |
| | | Record.Dispose(); |
| | | Record = null; |
| | | } |
| | | } |
| | | |
| | | public override void Dispose() |
| | | { |
| | | if (InputImage != null) |
| | | { |
| | | if (InputImage is HObject) |
| | | ((HObject)InputImage).Dispose(); |
| | | else if (InputImage is Mat) |
| | | ((Mat)InputImage).Dispose(); |
| | | else if (InputImage is Bitmap) |
| | | ((Bitmap)InputImage).Dispose(); |
| | | |
| | | InputImage = null; |
| | | } |
| | | |
| | | if (OutputImage != null) |
| | | { |
| | | if (OutputImage is HObject) |
| | | ((HObject)OutputImage).Dispose(); |
| | | else if (OutputImage is Mat) |
| | | ((Mat)OutputImage).Dispose(); |
| | | else if (OutputImage is Bitmap) |
| | | ((Bitmap)OutputImage).Dispose(); |
| | | |
| | | OutputImage = null; |
| | | } |
| | | return; |
| | | } |
| | | |