From 7d279fdc8ad8fb7666672486283d5d2457ff2e1f Mon Sep 17 00:00:00 2001 From: xcd <834800634@qq.com> Date: 星期二, 30 六月 2020 16:25:50 +0800 Subject: [PATCH] 更新主流程中ImageSet到IImageSet --- src/Bro.M071.Process/M071Process.cs | 53 +++++++++++++++++++++++++++++++++++++++-------------- 1 files changed, 39 insertions(+), 14 deletions(-) diff --git a/src/Bro.M071.Process/M071Process.cs b/src/Bro.M071.Process/M071Process.cs index 13fde83..1c79a4f 100644 --- a/src/Bro.M071.Process/M071Process.cs +++ b/src/Bro.M071.Process/M071Process.cs @@ -10,6 +10,7 @@ using System.IO; using System.Linq; using System.Text; +using System.Threading; using System.Threading.Tasks; namespace Bro.M071.Process @@ -138,8 +139,6 @@ //} #endregion - //Dictionary<string, ProductionMeasurement> MeasureDict = new Dictionary<string, ProductionMeasurement>(); - private string barCode = ""; public string BarCode { @@ -168,17 +167,7 @@ measurements.ForEach(m => { m.InitialKeyUnitMeasureChanged(); - //m.KeyUnitCollection.ForEach(k => k.InitialMeasureValueDictPropertyChanged()); }); - - //MeasureDict[BarCode] = new ProductionMeasurement() - //{ - // Barcode = BarCode, - // Measurements = measurements, - //}; - - //MeasureDict[BarCode].InitialMeasurementsPropertyChanged(); - //MeasureDict[BarCode].PropertyChanged += MeasureProduction_PropertyChanged; var pMeasure = new ProductionMeasurement() { @@ -191,6 +180,8 @@ Config.SnapshotPointCollection.Where(u => u.IsEnabled).ToList().ForEach(s => { + _pauseHandle.WaitHandle.WaitOne(); + IDevice device = DeviceCollection.FirstOrDefault(u => u.Id == s.MotionDevice); if (device == null) throw new ProcessException($"{s.Name}鎷嶇収鐐逛綅鏈缃繍鍔ㄨ澶�"); @@ -209,7 +200,7 @@ if (camera == null) return; - ImageSet imgSet = camera.Snapshot(s.CameraOp.OpConfig); + IImageSet imgSet = camera.Snapshot(s.CameraOp.OpConfig); if (imgSet == null) return; @@ -220,6 +211,39 @@ return new ProcessResponse(true); } + /// <summary> + /// 鏆傚仠鏍囧織 + /// WaitHandle 鏆傚仠鍙ユ焺 榛樿涓洪潪闃诲 鍙墽琛� + /// WaitResult 鏆傚仠鏍囧織 true 姝e父鎵ц false 鏆傚仠涓� + /// </summary> + ManualWaitConfirm _pauseHandle = new ManualWaitConfirm() + { + WaitHandle = new ManualResetEvent(true), + WaitResult = true, + }; + + [ProcessMethod("", "PauseJob", "鏆傚仠娴佺▼", InvokeType.TestInvoke)] + public ProcessResponse PauseJob(IOperationConfig opConfig, IDevice invokeDevice, IDevice sourceDevice) + { + if (_pauseHandle.WaitResult) + { + #region 鏉垮崱鏆傚仠鍔ㄤ綔 + #endregion + + _pauseHandle.WaitHandle.Reset(); + } + else + { + #region 鏉垮崱鎭㈠鍔ㄤ綔 + #endregion + + _pauseHandle.WaitHandle.Set(); + } + + _pauseHandle.WaitResult = !_pauseHandle.WaitResult; + return new ProcessResponse(_pauseHandle.WaitResult); + } + #region 绉佹湁鏂规硶 private void MeasureProduction_PropertyChanged(object sender, PropertyChangedEventArgs e) { if (sender is ProductionMeasurement pMeasure) @@ -284,7 +308,7 @@ } } - private async void RunImageHandle(CameraBase camera, IOperationConfig opConfig, ImageSet imgSet, string snapshotId, string snapshotName, List<MeasurementUint> measureList) + private async void RunImageHandle(CameraBase camera, IOperationConfig opConfig, IImageSet imgSet, string snapshotId, string snapshotName, List<MeasurementUint> measureList) { await Task.Run(() => { @@ -384,5 +408,6 @@ imgSet.HImage.Dispose(); }); } + #endregion } } -- Gitblit v1.8.0