领胜LDS 键盘AOI检测项目
patrick.xu
2021-01-24 b5e7fa2db4ac36fdb7bf9fd330d12a72ade9d483
0124
5个文件已修改
131 ■■■■ 已修改文件
src/Bro.Device.GTSCard/GTSCardDriver.cs 11 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/Bro.Device.Gocator/GocatorDriver.cs 66 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/Bro.M071.Process/M071Models.cs 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/Bro.M071.Process/M071Process.cs 32 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/Bro.M071.Process/M071Process_MotionCard.cs 20 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/Bro.Device.GTSCard/GTSCardDriver.cs
@@ -400,10 +400,13 @@
        /// <returns></returns>
        private bool SetAxisParam(MovingOption optionPara)
        {
            List<short> resultCode = new List<short>() { 0 };
            List<short> resultCode = new List<short>();
            GTSCardAPI.TTrapPrm trapprm = new GTSCardAPI.TTrapPrm();
            short axisIndex = short.Parse(optionPara.AxisIndexStr);
            resultCode.Add(GTSCardAPI.GT_PrfTrap((short)IConfig.CardNum, axisIndex));
            if (optionPara.VelocityPara.Acc != 0 || optionPara.VelocityPara.Dec != 0)
            {
            resultCode.Add(GTSCardAPI.GT_GetTrapPrm((short)IConfig.CardNum, axisIndex, out trapprm));
            trapprm.smoothTime = 1;
@@ -418,6 +421,7 @@
            }
            resultCode.Add(GTSCardAPI.GT_SetTrapPrm((short)IConfig.CardNum, axisIndex, ref trapprm));
            }
            if (optionPara.VelocityPara.Velocity != 0)
            {
@@ -427,9 +431,10 @@
            var resultOK = resultCode.All(u => u == (short)GTSRetCode.GRCRunOK);
            if (!resultOK)
            {
                throw new ProcessException("轴" + optionPara.AxisIndex + "设置参数异常,错误码:" + string.Join(",", resultCode));
                //throw new ProcessException("轴" + optionPara.AxisIndex + "设置参数异常,错误码:" + string.Join(",", resultCode));
                LogAsync(DateTime.Now, $"轴{optionPara.AxisIndex}设置参数异常,错误码:{string.Join(",", resultCode)}", "");
            }
            return resultOK;
            return true;
        }
        TaskFactory taskFactory = new TaskFactory(TaskCreationOptions.LongRunning, TaskContinuationOptions.LongRunning);
src/Bro.Device.Gocator/GocatorDriver.cs
@@ -139,10 +139,12 @@
                                //imgSet.HImage.GenImage1("int4", (int)width, zoomHeight, zoomPtr);
                                imgSet.HImage.GenImage1(IIConfig.ByteNums == GocatorDataByteNums.Byte2 ? "uint2" : "int4", (int)width, zoomHeight, zoomPtr);
                                imgSet.HImage_2 = imgSet.HImage.Clone();
                                //imgSet.HImage_2 = imgSet.HImage.Clone();
                                //imgSet.HImage_2.GenImage1("uint2", (int)width, zoomHeight, zoomPtr);
                                //imgSet.HImage_2.GenImage1("int4", (int)width, zoomHeight, zoomPtr);
                                //imgSet.HImage_2.GenImage1(IIConfig.ByteNums == GocatorDataByteNums.Byte2 ? "uint2" : "int4", (int)width, zoomHeight, zoomPtr);
                                imgSet.HImage_2 = new HImage();
                                imgSet.HImage_2.GenImage1(IIConfig.ByteNums == GocatorDataByteNums.Byte2 ? "uint2" : "int4", (int)width, zoomHeight, zoomPtr);
                                LaserScanParam para = new LaserScanParam()
                                {
@@ -223,7 +225,32 @@
            {
                if (opConfig.IsOpenConnection)
                {
                    while (sensor.State != GoState.Ready)
                    {
                        Thread.Sleep(10);
                    }
                    do
                    {
                        try
                        {
                    system.Start();
                            if (sensor.State != GoState.Running)
                            {
                                Thread.Sleep(100);
                            }
                            else
                            {
                                break;
                            }
                        }
                        catch (Exception ex)
                        {
                            LogAsync(DateTime.Now, $"开启异常:{ex.GetExceptionMessage()}", "");
                        }
                    } while (true);
                    LogAsync(DateTime.Now, $"传感器启动成功", "");
                }
                if (!opConfig.IsSnapshotAction)
@@ -264,7 +291,9 @@
                catch (Exception ex)
                {
                    LogAsync(DateTime.Now, $"{Name}获取图像异常", ex.GetExceptionMessage());
                    return null;
                    imgSet.HImage = null;
                    dataSet = null;
                    //return imgSet;
                }
            }
@@ -272,11 +301,39 @@
            {
                if (!opConfig.IsOpenConnection)
                {
                    while (sensor.State == GoState.Busy)
                    {
                        Thread.Sleep(100);
                    }
                    do
                    {
                        try
                        {
                    system.Stop();
                            if (sensor.State != GoState.Ready)
                            {
                                Thread.Sleep(100);
                            }
                            else
                            {
                                break;
                            }
                        }
                        catch (Exception ex)
                        {
                            LogAsync(DateTime.Now, $"关闭异常:{ex.GetExceptionMessage()}", "");
                        }
                    } while (true);
                    sensor.Flush();
                    LogAsync(DateTime.Now, $"传感器关闭成功", "");
                }
            }
            if (dataSet != null)
            {
            HandleGoData(dataSet, imgSet);
            dataSet.Dispose();
@@ -284,6 +341,7 @@
            if (imgSet.HImage == null)
            {
                LogAsync(DateTime.Now, $"{Name}未能获取HImage图像", "");
                }
            }
            return imgSet;
@@ -384,6 +442,8 @@
        {
            base.Start();
            //system.Start();
            if (IIConfig.IsAsyncMode)
                system.Start();
        }
src/Bro.M071.Process/M071Models.cs
@@ -280,7 +280,7 @@
            Measurements?.ForEach(m => m?.Dispose());
            Measurements = null;
            ElementList = null;
            Barcode = null;
            //Barcode = null;
            GC.Collect();
        }
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,6 +248,8 @@
            BarCode = "";
            lock (productionLock)
            {
            var existedProduction = productionList.FirstOrDefault(u => u.Barcode == pMeasure.Barcode);
            if (existedProduction != null)
            {
@@ -256,6 +259,7 @@
            }
            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);
                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);
                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();
src/Bro.M071.Process/M071Process_MotionCard.cs
@@ -29,6 +29,7 @@
                if (machineState == value)
                    return;
                LogAsync(DateTime.Now, $"设备状态切换:{machineState.ToString()}->{value.ToString()}", "");
                machineState = value;
                Task.Run(() =>
@@ -249,15 +250,15 @@
            RaisedAlarm("");
            if (MachineState != MachineState.Pause)
            {
            //if (MachineState != MachineState.Pause)
            //{
                MachineState = MachineState.Ready;
            }
            else
            {
                LogAsync(DateTime.Now, "设备暂停中,无法复位", "");
                return new ProcessResponse(true);
            }
            //}
            //else
            //{
            //    LogAsync(DateTime.Now, "设备暂停中,无法复位", "");
            //    return new ProcessResponse(true);
            //}
            if (IsEmergencyStopped)
            {
@@ -301,8 +302,11 @@
            MachineState = MachineState.Resetting;
            MotionCardDefaultRun("FullReset", ref opConfig, ref invokeDevice);
            lock (productionLock)
            {
            productionList.ForEach(u => u.Dispose());
            productionList.Clear();
            }
            OnFullResetDone?.Invoke();