领胜LDS 键盘AOI检测项目
patrick.xu
2021-01-24 b5e7fa2db4ac36fdb7bf9fd330d12a72ade9d483
src/Bro.M071.Process/M071Process.cs
@@ -193,6 +193,7 @@
        }
        #endregion
        object productionLock = new object();
        List<ProductionMeasurement> productionList = new List<ProductionMeasurement>();
        [ProcessMethod("", "StartJob", "开始扫描", InvokeType.TestInvoke)]
@@ -204,12 +205,12 @@
            }
            string hint = "";
            if (MachineState != MachineState.Ready)
            {
                hint = "机台未就绪,请勿开始测量";
                OnCheckHintUpload?.Invoke(hint, true);
                throw new ProcessException(hint, null, ExceptionLevel.Warning);
            }
            //if (MachineState != MachineState.Ready)
            //{
            //    hint = "机台未就绪,请勿开始测量";
            //    OnCheckHintUpload?.Invoke(hint, true);
            //    throw new ProcessException(hint, null, ExceptionLevel.Warning);
            //}
            if (string.IsNullOrWhiteSpace(BarCode))
            {
@@ -247,15 +248,18 @@
            BarCode = "";
            var existedProduction = productionList.FirstOrDefault(u => u.Barcode == pMeasure.Barcode);
            if (existedProduction != null)
            lock (productionLock)
            {
                productionList.Remove(existedProduction);
                existedProduction.Dispose();
                existedProduction = null;
            }
                var existedProduction = productionList.FirstOrDefault(u => u.Barcode == pMeasure.Barcode);
                if (existedProduction != null)
                {
                    productionList.Remove(existedProduction);
                    existedProduction.Dispose();
                    existedProduction = null;
                }
            productionList.Add(pMeasure);
                productionList.Add(pMeasure);
            }
            pMeasure.InitialMeasurementsPropertyChanged();
            pMeasure.PropertyChanged += MeasureProduction_PropertyChanged;
@@ -444,9 +448,13 @@
        {
            if (sender is ProductionMeasurement pMeasure)
            {
                var production = productionList.FirstOrDefault(u => u.Barcode == pMeasure.Barcode);
                if (production == null)
                    return;
                ProductionMeasurement production = null;
                lock (productionLock)
                {
                    production = productionList.FirstOrDefault(u => u.Barcode == pMeasure.Barcode);
                    if (production == null)
                        return;
                }
                lock (production)
                {
@@ -585,7 +593,10 @@
                SaveWholeImage(pMeasure);
                productionList.RemoveAll(p => p.Barcode == pMeasure.Barcode);
                lock (productionLock)
                {
                    productionList.RemoveAll(p => p.Barcode == pMeasure.Barcode);
                }
                pMeasure.Dispose();
                //LogAsync(DateTime.Now, $"{pMeasure.Barcode}产品信息释放完成", JsonConvert.SerializeObject(pMeasure));
            }
@@ -1195,6 +1206,13 @@
                var keys = Config.KeyUnitCollection.Where(u => u.IsEnabled && u.SnapshotPointId == snapshotId);
                var keyBindCollection = measureList.SelectMany(u => u.KeyUnitCollection).Where(u => keys.Any(k => k.Key == u.Key)).ToList();
                if (imgSet.HImage == null)
                {
                    LogAsync(DateTime.Now, $"{snapshotName}未获取扫描图像", "");
                    keyBindCollection.ForEach(k => k.FillKeyValues(null));
                    return;
                }
                string toolKey = (opConfig as CameraOprerationConfigBase).AlgorithemPath;
                HObject images = new HObject();