领胜LDS 键盘AOI检测项目
wells.liu
2020-09-07 1491846b4736bc2e79604086acfd8544aa3ba384
Merge branch 'master' of http://gitblit.broconcentric.com:8088/r/M071
14个文件已修改
417 ■■■■■ 已修改文件
src/Bro.Common.Device/DeviceBase/HDevEngineTool.cs 8 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/Bro.Common.Model/GlobalVar.cs 10 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/Bro.Common.Model/Helper/SettingHelper.cs 9 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/Bro.Common.Model/Interface/IProcess.cs 4 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/Bro.Device.GTSCard/GTSCardDriver.cs 158 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/Bro.Device.HikCamera/HikCameraDriver.cs 9 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/Bro.M071.Process/M071Config.cs 10 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/Bro.M071.Process/M071Process.cs 142 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/Bro.M071.Process/UI/M071_MainForm.Designer.cs 27 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/Bro.M071.Process/UI/M071_MainForm.cs 12 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/Bro.M071.Process/UI/M071_MainForm.resx 3 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/Bro.Process/Bro.Process.csproj 10 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/Bro.Process/ProcessControl.cs 12 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/Bro.UI.Model.Winform/UI/CanvasImage.cs 3 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/Bro.Common.Device/DeviceBase/HDevEngineTool.cs
@@ -136,9 +136,15 @@
            catch (HDevEngineException ex)
            {
                IsSuccessful = false;
                errorMsg = $"HDevProgram {ex.ProcedureName} Run fail , Line number: {ex.LineNumber}, Halcon error number : {ex.HalconError},ex:{ex.Message}";
                return false;
            }
            catch (Exception ex)
            {
                IsSuccessful = false;
                //Trace.TraceInformation("HDevProgram {0} Run fail , Line number: {1}, Halcon error number : {2},ex:{3}", ex.ProcedureName, ex.LineNumber, ex.HalconError, ex.Message);
                //return;
                errorMsg = $"HDevProgram {ex.ProcedureName} Run fail , Line number: {ex.LineNumber}, Halcon error number : {ex.HalconError},ex:{ex.Message}";
                errorMsg = $"{ex.Message}";
                return false;
            }
        }
src/Bro.Common.Model/GlobalVar.cs
@@ -6,6 +6,8 @@
    {
        public static ContainerBuilder Builder { get; set; } = new ContainerBuilder();
        private static object containerLock = new object();
        private static IContainer container = null;
        public static IContainer Container
        {
@@ -13,7 +15,13 @@
            {
                if (container == null)
                {
                    container = Builder.Build();
                    lock (containerLock)
                    {
                        if (container == null)
                        {
                            container = Builder.Build();
                        }
                    }
                }
                return container;
src/Bro.Common.Model/Helper/SettingHelper.cs
@@ -76,9 +76,15 @@
            return codes;
        }
        public static List<string> AddNewProductionCode(string code)
        public static void AddNewProductionCode(string code)
        {
            var dataTemp = GetSettingData();
            if (!dataTemp.ContainsKey(PROPERTY_PRODUCTIONCODES))
            {
                dataTemp.Add(PROPERTY_PRODUCTIONCODES, new JArray());
            }
            if (dataTemp != null && dataTemp.ContainsKey(PROPERTY_PRODUCTIONCODES))
            {
                List<string> codes = GetProductionCodes();
@@ -96,7 +102,6 @@
                    writer.Close();
                }
            }
            return GetProductionCodes();
        }
        public static string GetConfigFilePath()
src/Bro.Common.Model/Interface/IProcess.cs
@@ -51,7 +51,7 @@
        //event Action<string, Bitmap, string> OnBitmapOutput;
        event Action<DeviceState> OnProcessStateChanged;
        event Action<string> OnAlarmUpdate;
        event Action<string> OnAlarmUpdate;
        Action<DateTime, int> OnUpdateResult { get; set; }
        Action<float> OnUpdateCT { get; set; }
@@ -59,7 +59,7 @@
        #region 数据库操作
        void SaveProcessConfig(IProcessConfig config);
        void CreateNewConfig(IProcessConfig config,string newProductionCode);
        void CreateNewConfig(IProcessConfig config, string newProductionCode);
        #endregion
    }
}
src/Bro.Device.GTSCard/GTSCardDriver.cs
@@ -443,7 +443,7 @@
                {
                    axisImmediatePauseHandleDict[optionPara.AxisIndex].WaitOne();
                    if (!axisPauseResumeFlag[optionPara.AxisIndex])
                    if (axisPauseResumeFlag.ContainsKey(optionPara.AxisIndex) && !axisPauseResumeFlag[optionPara.AxisIndex])
                        return true;
                    try
@@ -492,7 +492,7 @@
                        isSuccessAndStop = false;
                        LogAsync(DateTime.Now, $"轴{optionPara.AxisIndex}运动异常", ex.GetExceptionMessage());
                    }
                } while (axisImmediatePauseFlag[optionPara.AxisIndex]);
                } while (axisImmediatePauseFlag.ContainsKey(optionPara.AxisIndex) && axisImmediatePauseFlag[optionPara.AxisIndex]);
                return isSuccessAndStop;
            });
        }
@@ -891,19 +891,12 @@
                var goHomePara = IConfig.AxisSettings.FirstOrDefault(u => u.AxisIndex == movingOption.AxisIndex).GoHomePara;
                bool homeDirection = goHomePara.IsHomeDirPositive;
                bool isRightLimitReached = false;
            StartCapture:
                PositionReset(movingOption.AxisIndex, 1);
                ClearStatus(movingOption.AxisIndex, 1);
                short capture = 0;
                GTSCardAPI.TTrapPrm trapPrm;
                bool isStop = false;
                //搜索距离 阶段1
                // 启动Home捕获
                short sRtn = GTSCardAPI.GT_SetCaptureMode((short)IConfig.CardNum, (short)movingOption.AxisIndex, GTSCardAPI.CAPTURE_HOME);
                // 切换到点位运动模式
                sRtn = GTSCardAPI.GT_PrfTrap((short)IConfig.CardNum, (short)movingOption.AxisIndex);
                short sRtn = GTSCardAPI.GT_PrfTrap((short)IConfig.CardNum, (short)movingOption.AxisIndex);
                // 读取点位模式运动参数
                sRtn = GTSCardAPI.GT_GetTrapPrm((short)IConfig.CardNum, (short)movingOption.AxisIndex, out trapPrm);
                trapPrm.acc = movingOption.VelocityPara.Acc;
@@ -913,88 +906,99 @@
                // 设置点位模式目标速度,即回原点速度
                sRtn = GTSCardAPI.GT_SetVel((short)IConfig.CardNum, (short)movingOption.AxisIndex, goHomePara.HighVelocity);
                // 设置点位模式目标位置,即原点搜索距离
                sRtn = GTSCardAPI.GT_SetPos((short)IConfig.CardNum, (short)movingOption.AxisIndex, homeDirection ? 99999999 : -99999999);
                // 启动运动
                sRtn = GTSCardAPI.GT_Update((short)IConfig.CardNum, 1 << (movingOption.AxisIndex - 1));
                int repeatTime = goHomePara.GoHomeTimeOut * 1000;
                short capture;
                int pos;
                uint clk;//时钟参数
                do
                {
                    Thread.Sleep(IConfig.MonitorInterval);
                    // 读取捕获状态
                    GTSCardAPI.GT_GetCaptureStatus((short)IConfig.CardNum, (short)movingOption.AxisIndex, out capture, out pos, 1, out clk);
                    isStop = IsStop((short)movingOption.AxisIndex);
                    repeatTime -= IConfig.MonitorInterval;
                } while (!(isStop || capture == 1 || repeatTime <= 0));
                    PositionReset(movingOption.AxisIndex, 1);
                    ClearStatus(movingOption.AxisIndex, 1);
                if (repeatTime <= 0)
                {
                    MoveStop((short)movingOption.AxisIndex, 0);
                    throw new ProcessException($"运动轴{movingOption.AxisIndex} ,回原点超时异常");
                }
                    //搜索距离 阶段1
                    // 启动Home捕获
                    sRtn = GTSCardAPI.GT_SetCaptureMode((short)IConfig.CardNum, (short)movingOption.AxisIndex, GTSCardAPI.CAPTURE_HOME);
                if (isStop && capture != 1)
                {
                    ClearStatus((short)movingOption.AxisIndex, 1);
                    // 设置点位模式目标位置,即原点搜索距离
                    sRtn = GTSCardAPI.GT_SetPos((short)IConfig.CardNum, (short)movingOption.AxisIndex, homeDirection ? 99999999 : -99999999);
                    // 启动运动
                    sRtn = GTSCardAPI.GT_Update((short)IConfig.CardNum, 1 << (movingOption.AxisIndex - 1));
                    int repeatTime = goHomePara.GoHomeTimeOut * 1000;
                    bool isStop = false;
                    int pos;
                    uint clk;//时钟参数
                    do
                    {
                        Thread.Sleep(IConfig.MonitorInterval * 5);
                        // 读取捕获状态
                        GTSCardAPI.GT_GetCaptureStatus((short)IConfig.CardNum, (short)movingOption.AxisIndex, out capture, out pos, 1, out clk);
                        isStop = IsStop((short)movingOption.AxisIndex);
                        repeatTime -= IConfig.MonitorInterval * 5;
                    } while (!(isStop || capture == 1 || repeatTime <= 0));
                    if (repeatTime <= 0)
                    {
                        MoveStop((short)movingOption.AxisIndex, 0);
                        throw new ProcessException($"运动轴{movingOption.AxisIndex} ,回原点超时异常");
                    }
                    var axisStatus = AxisStatusList.FirstOrDefault(u => u.AxisIndex == movingOption.AxisIndex);
                    if (((axisStatus.AxisStatus & 0x20) != 0) || ((axisStatus.AxisStatus & 0x40) != 0))
                    if (isStop && capture != 1)
                    {
                        //movingOption.GoHomePara.HomeDir = (short)(movingOption.GoHomePara.HomeDir == 1 ? -1 : 1);
                        //正限位
                        if ((axisStatus.AxisStatus & 0x20) != 0 && !goHomePara.IsCaptureDirPositive)
                        if (((axisStatus.AxisStatus & 0x20) != 0) || ((axisStatus.AxisStatus & 0x40) != 0))
                        {
                            isRightLimitReached = true;
                            //movingOption.GoHomePara.HomeDir = (short)(movingOption.GoHomePara.HomeDir == 1 ? -1 : 1);
                            //正限位
                            if ((axisStatus.AxisStatus & 0x20) != 0 && !goHomePara.IsCaptureDirPositive)
                            {
                                isRightLimitReached = true;
                            }
                            //负限位
                            if ((axisStatus.AxisStatus & 0x40) != 0 && goHomePara.IsCaptureDirPositive)
                            {
                                isRightLimitReached = true;
                            }
                            homeDirection = !homeDirection;
                        }
                        ClearStatus(movingOption.AxisIndex, 1);
                    }
                        //负限位
                        if ((axisStatus.AxisStatus & 0x40) != 0 && goHomePara.IsCaptureDirPositive)
                    if (capture == 1)
                    {
                        if (!isRightLimitReached)
                        {
                            isRightLimitReached = true;
                            capture = 0;
                            ClearStatus(movingOption.AxisIndex, 1);
                            //GTSCardAPI.GT_SetCaptureMode((short)IConfig.CardNum, (short)movingOption.AxisIndex, GTSCardAPI.CAPTURE_HOME);
                            continue;
                        }
                        homeDirection = !homeDirection;
                        goto StartCapture;
                        //先stop
                        MoveStop((short)movingOption.AxisIndex, 0);
                        ClearStatus((short)movingOption.AxisIndex, 1);
                        //已经捕获到Home才可以回零 阶段2
                        // 运动到"捕获位置+偏移量"
                        sRtn = GTSCardAPI.GT_SetPos((short)IConfig.CardNum, (short)movingOption.AxisIndex, pos + goHomePara.HomeOffset);
                        // 在运动状态下更新目标位置
                        sRtn = GTSCardAPI.GT_Update((short)IConfig.CardNum, 1 << (movingOption.AxisIndex - 1));
                        isStop = false;
                        repeatTime = 1000;
                        do
                        {
                            Thread.Sleep(20);
                            isStop = IsStop((short)movingOption.AxisIndex);
                            repeatTime--;
                        } while (!isStop && repeatTime > 0);
                        PositionReset(movingOption.AxisIndex, 1);
                        return (sRtn == (short)GTSRetCode.GRCRunOK) && isStop;
                    }
                    throw new ProcessException($"运动轴{movingOption.AxisIndex} ,回原点超时异常");
                }
                if (capture == 1)
                {
                    if (!isRightLimitReached)
                    {
                        capture = 0;
                        goto StartCapture;
                    }
                    //先stop
                    MoveStop((short)movingOption.AxisIndex, 0);
                    ClearStatus((short)movingOption.AxisIndex, 1);
                    //已经捕获到Home才可以回零 阶段2
                    // 运动到"捕获位置+偏移量"
                    sRtn = GTSCardAPI.GT_SetPos((short)IConfig.CardNum, (short)movingOption.AxisIndex, pos + goHomePara.HomeOffset);
                    // 在运动状态下更新目标位置
                    sRtn = GTSCardAPI.GT_Update((short)IConfig.CardNum, 1 << (movingOption.AxisIndex - 1));
                    isStop = false;
                    repeatTime = 1000;
                    do
                    {
                        Thread.Sleep(20);
                        isStop = IsStop((short)movingOption.AxisIndex);
                        repeatTime--;
                    } while (!isStop && repeatTime > 0);
                    PositionReset(movingOption.AxisIndex, 1);
                    return (sRtn == (short)GTSRetCode.GRCRunOK) && isStop;
                }
                } while (!(capture == 1 && isRightLimitReached));
                return false;
            }
            catch (Exception ex)
src/Bro.Device.HikCamera/HikCameraDriver.cs
@@ -463,15 +463,14 @@
        {
            if (nMsgType == MyCamera.MV_EXCEPTION_DEV_DISCONNECT)
            {
                Thread.Sleep(1000);
                Stop();
                if (CurrentState != EnumHelper.DeviceState.DSClose)
                {
                    int reTryTimes = 3;
                    do
                    {
                        Thread.Sleep(1000);
                        Stop();
                        try
                        {
                            Start();
@@ -484,7 +483,7 @@
                            if (reTryTimes > 0)
                            {
                                //OnLog?.Invoke(DateTime.Now, this, "重新连接相机异常\r\n" + ex.GetExceptionMessage());
                                LogAsync(DateTime.Now, "重新连接异常", ex.GetExceptionMessage());
                                LogAsync(DateTime.Now, $"{this.Name}重新连接异常", ex.GetExceptionMessage());
                            }
                            else
                            {
src/Bro.M071.Process/M071Config.cs
@@ -75,6 +75,16 @@
        [Editor(typeof(ComplexCollectionEditor<MeasurementUnit>), typeof(UITypeEditor))]
        public List<MeasurementUnit> MeasurementUnitCollection { get; set; } = new List<MeasurementUnit>();
        [Category("检测设置")]
        [Description("平面补偿值")]
        [DisplayName("4.平面补偿值")]
        public double PlanCompensation { get; set; }
        [Category("检测设置")]
        [Description("数据精度设置")]
        [DisplayName("5.数据精度位数")]
        public int Precision { get; set; } = 3;
        //[Category("检测设置")]
        //[DisplayName("结果数据保存路径")]
        //[Description("检测结果数据保存路径")]
src/Bro.M071.Process/M071Process.cs
@@ -48,6 +48,9 @@
        public event Action OnFullResetDone;
        #endregion
        string _precision = "f3";
        public override void Open()
        {
            InitialSetting();
@@ -63,6 +66,11 @@
            Reset(null, null, null);
            FullReset(null);
            if (Config.Precision > 0)
            {
                _precision = "f" + Config.Precision;
            }
        }
        private void InitialMotionCardBaseAxisAlarm()
@@ -367,25 +375,36 @@
                                    }
                                    else
                                    {
                                        var array = m.KeyUnitCollection.SelectMany(u => u.MeasureValueDict.Values.ToList().ConvertAll(v => v ?? -999)).ToArray();
                                        _halconToolDict[toolKey].InputTupleDic["INPUT_Params"] = new HTuple(array);
                                        if (!_halconToolDict[toolKey].RunProcedure(out string error))
                                        //var array = m.KeyUnitCollection.SelectMany(u => u.MeasureValueDict.Values.ToList().ConvertAll(v => v ?? -999)).ToArray();
                                        var array = m.KeyUnitCollection.SelectMany(u => u.MeasureValueDict.Values.Select(v => v ?? -999)).ToArray();
                                        if (array == null || array.Length == 0)
                                        {
                                            LogAsync(DateTime.Now, $"{m.GetDisplayText()}{m.Spec.Code}算法异常,{error}", "");
                                            LogAsync(DateTime.Now, $"{m.GetDisplayText()}{m.Spec.Code}未能获取对应检测值", "");
                                            m.Spec.ActualValue = -999;
                                        }
                                        else
                                        {
                                            m.Spec.ActualValue = double.Parse(_halconToolDict[toolKey].GetResultTuple("OUTPUT_Result").D.ToString("f2"));
                                            LogAsync(DateTime.Now, $"{m.GetDisplayText()}数据{m.Spec.ActualValue},结果{(m.Spec.MeasureResult == null ? "TBD" : (m.Spec.MeasureResult == true ? "OK" : "NG"))}", "");
                                            _halconToolDict[toolKey].InputTupleDic["INPUT_Params"] = new HTuple(array);
                                            if (!_halconToolDict[toolKey].RunProcedure(out string error))
                                            {
                                                LogAsync(DateTime.Now, $"{m.GetDisplayText()}{m.Spec.Code}算法异常,{error}", "");
                                                m.Spec.ActualValue = -999;
                                            }
                                            else
                                            {
                                                m.Spec.ActualValue = double.Parse(_halconToolDict[toolKey].GetResultTuple("OUTPUT_Result").D.ToString(_precision));
                                                //LogAsync(DateTime.Now, $"{m.GetDisplayText()}数据{m.Spec.ActualValue},结果{(m.Spec.MeasureResult == null ? "TBD" : (m.Spec.MeasureResult == true ? "OK" : "NG"))}", "");
                                            }
                                        }
                                    }
                                }
                                LogAsync(DateTime.Now, $"{m.GetDisplayText()}检测结果", $"{((m.Spec.MeasureResult ?? false) ? "OK" : "NG")}");
                                //LogAsync(DateTime.Now, $"{m.GetDisplayText()}检测结果", $"{((m.Spec.MeasureResult ?? false) ? "OK" : "NG")}");
                                KeyIndicator indicator = new KeyIndicator(m.Id, m.DisplayLocation);
                                indicator.Text = (m.Spec.ActualValue == null || m.Spec.ActualValue == -999) ? "NA" : m.Spec.ActualValue.Value.ToString("f2");
                                indicator.Text = (m.Spec.ActualValue == null || m.Spec.ActualValue == -999) ? "NA" : m.Spec.ActualValue.Value.ToString(_precision);
                                indicator.ResultState = m.Spec.MeasureResult;
                                pMeasure.ElementList.Add(indicator);
                                //输出图形基元到界面 
@@ -517,7 +536,7 @@
                        measurementUnitResult.Keys = measurementUnit.KeyUnitCollection[0].KeyResultId + "~" + measurementUnit.KeyUnitCollection[measurementUnit.KeyUnitCollection.Count() - 1].KeyResultId;
                    }
                    measurementUnitResult.MeasurementType = measurementUnit.MeasureType;
                    measurementUnitResult.MeasurementValue = measurementUnit.Spec.ActualValue == null ? "NA" : measurementUnit.Spec.ActualValue.Value.ToString("f2");
                    measurementUnitResult.MeasurementValue = measurementUnit.Spec.ActualValue == null ? "NA" : measurementUnit.Spec.ActualValue.Value.ToString(_precision);
                    measurementUnitResult.MeasurementResult = measurementUnit.Spec.MeasureResult.Value ? "OK" : "NG";
                    measurementUnitResults.Add(measurementUnitResult);
@@ -533,7 +552,7 @@
                                keyUnitData.ProductionBarcode = productionMeasurementRecords.ProductionBarcode;
                                keyUnitData.Key = keyUnit.Key;
                                keyUnitData.MeasurementItem = keyValue.Key;
                                keyUnitData.ItemValue = keyValue.Value == null ? "NA" : keyValue.Value.Value.ToString("f2");
                                keyUnitData.ItemValue = keyValue.Value == null ? "NA" : keyValue.Value.Value.ToString(_precision);
                                keyUnitDatas.Add(keyUnitData);
                                MeasurementAndKeyDataRelation measurementAndKeyDataRelation = new MeasurementAndKeyDataRelation();
@@ -758,8 +777,12 @@
                        {
                            int slantStartCol = slantSheet.Dimension.Columns;
                            var barcodeCell = slantSheet.Cells[1, slantStartCol + 1, 1, slantStartCol + 2];
                            barcodeCell.Merge = true;
                            //var barcodeCell = slantSheet.Cells[1, slantStartCol + 1, 1, slantStartCol + 2];
                            //barcodeCell.Merge = true;
                            //barcodeCell.Value = exportData.ProductionMeasurementRecord.ProductionBarcode;
                            //SetTitleCell(barcodeCell);
                            var barcodeCell = slantSheet.Cells[1, slantStartCol + 1];
                            barcodeCell.Value = exportData.ProductionMeasurementRecord.ProductionBarcode;
                            SetTitleCell(barcodeCell);
@@ -767,9 +790,9 @@
                            valueCell.Value = "Value";
                            SetTitleCell(valueCell);
                            var resultCell = slantSheet.Cells[2, slantStartCol + 2];
                            resultCell.Value = "Result";
                            SetTitleCell(resultCell);
                            //var resultCell = slantSheet.Cells[2, slantStartCol + 2];
                            //resultCell.Value = "Result";
                            //SetTitleCell(resultCell);
                            slantMeasures.ForEach(m =>
                            {
@@ -781,15 +804,15 @@
                                }
                                var cellValue = slantSheet.Cells[rowIndex + 1 + 2, slantStartCol + 1];
                                var cellResult = slantSheet.Cells[rowIndex + 1 + 2, slantStartCol + 2];
                                //var cellResult = slantSheet.Cells[rowIndex + 1 + 2, slantStartCol + 2];
                                cellValue.Value = m.MeasurementValue;
                                cellResult.Value = m.MeasurementResult;
                                //cellResult.Value = m.MeasurementResult;
                                if (m.MeasurementResult != "OK")
                                {
                                    SetNGCell(cellValue);
                                    SetNGCell(cellResult);
                                    //SetNGCell(cellResult);
                                }
                            });
                        }
@@ -804,7 +827,7 @@
                                int allRowNums = alignmentSheet.Dimension.Rows;
                                int aligneStartCol = alignmentSheet.Dimension.Columns;
                                for (int i = 3; i <= allRowNums; i++)
                                for (int i = 3; i <= alignmentSheet.Dimension.End.Row; i++)
                                {
                                    string keys = alignmentSheet.Cells[i, 1].Value.ToString();
                                    string position = alignmentSheet.Cells[i, 2].Value.ToString();
@@ -812,8 +835,12 @@
                                    keysList.Add($"{keys}_{position}");
                                }
                                var barcodeCell = alignmentSheet.Cells[1, aligneStartCol + 1, 1, aligneStartCol + 2];
                                barcodeCell.Merge = true;
                                //var barcodeCell = alignmentSheet.Cells[1, aligneStartCol + 1, 1, aligneStartCol + 2];
                                //barcodeCell.Merge = true;
                                //barcodeCell.Value = exportData.ProductionMeasurementRecord.ProductionBarcode;
                                //SetTitleCell(barcodeCell);
                                var barcodeCell = alignmentSheet.Cells[1, aligneStartCol + 1];
                                barcodeCell.Value = exportData.ProductionMeasurementRecord.ProductionBarcode;
                                SetTitleCell(barcodeCell);
@@ -821,9 +848,9 @@
                                valueCell.Value = "Value";
                                SetTitleCell(valueCell);
                                var resultCell = alignmentSheet.Cells[2, aligneStartCol + 2];
                                resultCell.Value = "Result";
                                SetTitleCell(resultCell);
                                //var resultCell = alignmentSheet.Cells[2, aligneStartCol + 2];
                                //resultCell.Value = "Result";
                                //SetTitleCell(resultCell);
                                alignmentMeasures.ForEach(a =>
                                {
@@ -835,15 +862,15 @@
                                    }
                                    var cellValue = alignmentSheet.Cells[rowIndex + 1 + 2, aligneStartCol + 1];
                                    var cellResult = alignmentSheet.Cells[rowIndex + 1 + 2, aligneStartCol + 2];
                                    //var cellResult = alignmentSheet.Cells[rowIndex + 1 + 2, aligneStartCol + 2];
                                    cellValue.Value = a.MeasurementValue;
                                    cellResult.Value = a.MeasurementResult;
                                    //cellResult.Value = a.MeasurementResult;
                                    if (a.MeasurementResult != "OK")
                                    {
                                        SetNGCell(cellValue);
                                        SetNGCell(cellResult);
                                        //SetNGCell(cellResult);
                                    }
                                });
                            }
@@ -867,8 +894,12 @@
                                    keysList.Add($"{keys}_{position}");
                                }
                                var barcodeCell = rowAlignmentSheet.Cells[1, aligneStartCol + 1, 1, aligneStartCol + 2];
                                barcodeCell.Merge = true;
                                //var barcodeCell = rowAlignmentSheet.Cells[1, aligneStartCol + 1, 1, aligneStartCol + 2];
                                //barcodeCell.Merge = true;
                                //barcodeCell.Value = exportData.ProductionMeasurementRecord.ProductionBarcode;
                                //SetTitleCell(barcodeCell);
                                var barcodeCell = rowAlignmentSheet.Cells[1, aligneStartCol + 1];
                                barcodeCell.Value = exportData.ProductionMeasurementRecord.ProductionBarcode;
                                SetTitleCell(barcodeCell);
@@ -876,9 +907,9 @@
                                valueCell.Value = "Value";
                                SetTitleCell(valueCell);
                                var resultCell = rowAlignmentSheet.Cells[2, aligneStartCol + 2];
                                resultCell.Value = "Result";
                                SetTitleCell(resultCell);
                                //var resultCell = rowAlignmentSheet.Cells[2, aligneStartCol + 2];
                                //resultCell.Value = "Result";
                                //SetTitleCell(resultCell);
                                rowAlignmentMeasures.ForEach(a =>
                                {
@@ -890,15 +921,15 @@
                                    }
                                    var cellValue = rowAlignmentSheet.Cells[rowIndex + 1 + 2, aligneStartCol + 1];
                                    var cellResult = rowAlignmentSheet.Cells[rowIndex + 1 + 2, aligneStartCol + 2];
                                    //var cellResult = rowAlignmentSheet.Cells[rowIndex + 1 + 2, aligneStartCol + 2];
                                    cellValue.Value = a.MeasurementValue;
                                    cellResult.Value = a.MeasurementResult;
                                    //cellResult.Value = a.MeasurementResult;
                                    if (a.MeasurementResult != "OK")
                                    {
                                        SetNGCell(cellValue);
                                        SetNGCell(cellResult);
                                        //SetNGCell(cellResult);
                                    }
                                });
                            }
@@ -913,10 +944,10 @@
        private void SetNGCell(ExcelRange cell)
        {
            cell.Style.Font.Color.SetColor(Color.White);
            cell.Style.Font.Color.SetColor(Color.Red);
            cell.Style.Font.Bold = true;
            cell.Style.Fill.PatternType = ExcelFillStyle.Solid;
            cell.Style.Fill.BackgroundColor.SetColor(Color.Red);
            //cell.Style.Fill.PatternType = ExcelFillStyle.Solid;
            //cell.Style.Fill.BackgroundColor.SetColor(Color.Red);
        }
        private void SetTitleCell(ExcelRange cell, bool isCenterAlign = true)
@@ -1035,7 +1066,9 @@
                 var keyBindCollection = measureList.SelectMany(u => u.KeyUnitCollection).Where(u => keys.Any(k => k.Key == u.Key)).ToList();
                 string toolKey = (opConfig as CameraOprerationConfigBase).AlgorithemPath;
                 HObject images = imgSet.HImage;
                 //HObject images = imgSet.HImage;
                 HObject images = new HObject();
                 LaserScanParam scanParam = JsonConvert.DeserializeObject<LaserScanParam>(imgSet.ImageData);
                 LogAsync(DateTime.Now, $"扫描参数:{imgSet.ImageData}", "");
@@ -1049,8 +1082,8 @@
                         return;
                     }
                     string fileName = Path.Combine(Config.ImageSaveFolder, "BeforeRun", $"{DateTime.Now.ToString("yyyyMMddHHmmssfff")}.tif");
                     imgSet.HImage.WriteImage("tiff", 0, fileName);
                     //string fileName = Path.Combine(Config.ImageSaveFolder, "BeforeRun", $"{DateTime.Now.ToString("yyyyMMddHHmmssfff")}.tif");
                     //imgSet.HImage.WriteImage("tiff", 0, fileName);
                     _halconToolDict[toolKey].InputImageDic["INPUT_Image"] = imgSet.HImage;
                     if (!_halconToolDict[toolKey].RunProcedure(out string error))
@@ -1083,22 +1116,22 @@
                          });
                 }
                 string dir = Path.Combine(Config.ImageSaveFolder, "Clips", $"{DateTime.Now.ToString("yyyyMMdd")}", $"{snapshotName}_{DateTime.Now.ToString("HHmmss")}");
                 if (!Directory.Exists(dir))
                 {
                     Directory.CreateDirectory(dir);
                 }
                 //string dir = Path.Combine(Config.ImageSaveFolder, "Clips", $"{DateTime.Now.ToString("yyyyMMdd")}", $"{snapshotName}_{DateTime.Now.ToString("HHmmss")}");
                 //if (!Directory.Exists(dir))
                 //{
                 //    Directory.CreateDirectory(dir);
                 //}
                 //Parallel.For(1, count.I + 1, (i) =>
                 for (int i = 1; i <= count.I; i++)
                 {
                     HOperatorSet.SelectObj(images, out HObject image, i);
                     string fileName = Path.Combine(dir, $"{i}.tif");
                     using (HImage temp = image.ConvertHObjectToHImage())
                     {
                         temp.WriteImage("tiff", 0, fileName);
                     }
                     //string fileName = Path.Combine(dir, $"{i}.tif");
                     //using (HImage temp = image.ConvertHObjectToHImage())
                     //{
                     //    temp.WriteImage("tiff", 0, fileName);
                     //}
                     keys.Where(u => u.ImageSeq == i).ToList().ForEach(k =>
                         {
@@ -1115,6 +1148,7 @@
                             {
                                 _halconToolDict[keyToolKey].InputImageDic["INPUT_Image"] = image;
                                 _halconToolDict[keyToolKey].InputTupleDic["INPUT_Resolution_X"] = scanParam.Resolution_X / 1000000.0;
                                 _halconToolDict[keyToolKey].InputTupleDic["INPUT_Resolution_Y"] = scanParam.Resolution_Y / 1000000.0;
                                 _halconToolDict[keyToolKey].InputTupleDic["INPUT_Resolution_Z"] = scanParam.Resolution_Z / 1000000.0;
                                 _halconToolDict[keyToolKey].InputTupleDic["INPUT_ImageId"] = $"{k.AliasName}_{DateTime.Now.ToString("HHmmssfff")}.tif";
                                 if (!_halconToolDict[keyToolKey].RunProcedure(out string error))
@@ -1130,8 +1164,9 @@
                                     }
                                     else
                                     {
                                         //results = results.Select(u => double.Parse(u.ToString("f2"))).ToList();
                                         LogAsync(DateTime.Now, $"{k.AliasName}原始数据", $"{string.Join(" ", results)}");
                                         //LogAsync(DateTime.Now, $"{k.AliasName}原始数据", $"{string.Join(" ", results)}");
                                         results = results.Select(u => u - Config.PlanCompensation).ToList();
                                         resultDict = k.KeyResultList.ToDictionary(u => u, u =>
                                              {
                                                  int index = k.KeyResultList.IndexOf(u);
@@ -1152,6 +1187,7 @@
                 }
                 //);
                 images.Dispose();
                 //if (count.I != 1)
                 //{
                 //    hImage?.Dispose();
src/Bro.M071.Process/UI/M071_MainForm.Designer.cs
@@ -33,6 +33,7 @@
            this.tsmiShowToolBar = new System.Windows.Forms.ToolStripMenuItem();
            this.tsmiShowStatusBar = new System.Windows.Forms.ToolStripMenuItem();
            this.tsmiShowEditor = new System.Windows.Forms.ToolStripMenuItem();
            this.tsmiRefreshLabels = new System.Windows.Forms.ToolStripMenuItem();
            this.btnReset = new System.Windows.Forms.Button();
            this.btnStartMeasure = new System.Windows.Forms.Button();
            this.lblCT = new System.Windows.Forms.Label();
@@ -48,7 +49,7 @@
            this.lvMeasures = new System.Windows.Forms.ListView();
            this.columnHeader1 = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader()));
            this.propGridKeyIndicator = new System.Windows.Forms.PropertyGrid();
            this.tsmiRefreshLabels = new System.Windows.Forms.ToolStripMenuItem();
            this.timer1 = new System.Windows.Forms.Timer(this.components);
            this.contextMenuStrip1.SuspendLayout();
            this.plImage.SuspendLayout();
            this.tscEditLocation.ContentPanel.SuspendLayout();
@@ -68,13 +69,13 @@
            this.tsmiShowEditor,
            this.tsmiRefreshLabels});
            this.contextMenuStrip1.Name = "contextMenuStrip1";
            this.contextMenuStrip1.Size = new System.Drawing.Size(181, 114);
            this.contextMenuStrip1.Size = new System.Drawing.Size(149, 92);
            // 
            // tsmiShowToolBar
            // 
            this.tsmiShowToolBar.CheckOnClick = true;
            this.tsmiShowToolBar.Name = "tsmiShowToolBar";
            this.tsmiShowToolBar.Size = new System.Drawing.Size(180, 22);
            this.tsmiShowToolBar.Size = new System.Drawing.Size(148, 22);
            this.tsmiShowToolBar.Text = "显示工具条";
            this.tsmiShowToolBar.CheckedChanged += new System.EventHandler(this.tsmiShowToolBar_CheckedChanged);
            // 
@@ -82,7 +83,7 @@
            // 
            this.tsmiShowStatusBar.CheckOnClick = true;
            this.tsmiShowStatusBar.Name = "tsmiShowStatusBar";
            this.tsmiShowStatusBar.Size = new System.Drawing.Size(180, 22);
            this.tsmiShowStatusBar.Size = new System.Drawing.Size(148, 22);
            this.tsmiShowStatusBar.Text = "显示状态栏";
            this.tsmiShowStatusBar.CheckedChanged += new System.EventHandler(this.tsmiShowStatusBar_CheckedChanged);
            // 
@@ -90,9 +91,16 @@
            // 
            this.tsmiShowEditor.CheckOnClick = true;
            this.tsmiShowEditor.Name = "tsmiShowEditor";
            this.tsmiShowEditor.Size = new System.Drawing.Size(180, 22);
            this.tsmiShowEditor.Size = new System.Drawing.Size(148, 22);
            this.tsmiShowEditor.Text = "编辑显示点位";
            this.tsmiShowEditor.CheckedChanged += new System.EventHandler(this.tsmiShowEditor_CheckedChanged);
            //
            // tsmiRefreshLabels
            //
            this.tsmiRefreshLabels.Name = "tsmiRefreshLabels";
            this.tsmiRefreshLabels.Size = new System.Drawing.Size(148, 22);
            this.tsmiRefreshLabels.Text = "刷新显示点位";
            this.tsmiRefreshLabels.Click += new System.EventHandler(this.tsmiRefreshLabels_Click);
            // 
            // btnReset
            // 
@@ -293,12 +301,10 @@
            this.propGridKeyIndicator.TabIndex = 0;
            this.propGridKeyIndicator.ToolbarVisible = false;
            // 
            // tsmiRefreshLabels
            // timer1
            // 
            this.tsmiRefreshLabels.Name = "tsmiRefreshLabels";
            this.tsmiRefreshLabels.Size = new System.Drawing.Size(180, 22);
            this.tsmiRefreshLabels.Text = "刷新显示点位";
            this.tsmiRefreshLabels.Click += new System.EventHandler(this.tsmiRefreshLabels_Click);
            this.timer1.Interval = 3000;
            this.timer1.Tick += new System.EventHandler(this.timer1_Tick);
            // 
            // M071_MainForm
            // 
@@ -353,5 +359,6 @@
        private System.Windows.Forms.Button btnReset;
        private System.Windows.Forms.ColumnHeader columnHeader1;
        private System.Windows.Forms.ToolStripMenuItem tsmiRefreshLabels;
        private System.Windows.Forms.Timer timer1;
    }
}
src/Bro.M071.Process/UI/M071_MainForm.cs
@@ -40,6 +40,8 @@
                   cvImage.SetScreenSize();
                   cvImage.OnElementChangedHandle -= CvImage_OnElementChangedHandle;
                   cvImage.OnElementChangedHandle += CvImage_OnElementChangedHandle;
                   timer1.Enabled = true;
               };
        }
@@ -284,6 +286,10 @@
            {
                _barcode += keyStr.ToUpper();
            }
            else if (keyStr.Length == 2 && keyStr.StartsWith("D"))
            {
                _barcode += keyStr.Substring(1).ToUpper();
            }
            if (e.KeyValue == 13)
            {
@@ -337,7 +343,7 @@
                            btnStartMeasure.BackColor = lblMachineState.BackColor = Color.Lime;
                            btnStartMeasure.ForeColor = lblMachineState.ForeColor = Color.Black;
                            lblMachineState.Text = "就绪";
                            btnStartMeasure.Text = "开始测量";
                            btnStartMeasure.Enabled = true;
                            break;
@@ -475,5 +481,9 @@
        }
        #endregion
        private void timer1_Tick(object sender, EventArgs e)
        {
            cvImage.Refresh();
        }
    }
}
src/Bro.M071.Process/UI/M071_MainForm.resx
@@ -120,4 +120,7 @@
  <metadata name="contextMenuStrip1.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
    <value>17, 17</value>
  </metadata>
  <metadata name="timer1.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
    <value>182, 17</value>
  </metadata>
</root>
src/Bro.Process/Bro.Process.csproj
@@ -128,9 +128,7 @@
  </ItemGroup>
  <ItemGroup>
    <None Include="packages.config" />
    <None Include="Setting.json">
      <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
    </None>
    <None Include="Setting.json" />
  </ItemGroup>
  <ItemGroup>
    <EmbeddedResource Include="Forms\Calibration\FrmCalibration_9P.resx">
@@ -170,9 +168,5 @@
    <Error Condition="!Exists('..\..\packages\PostSharp.6.2.7\build\PostSharp.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\..\packages\PostSharp.6.2.7\build\PostSharp.targets'))" />
  </Target>
  <Import Project="..\..\packages\PostSharp.6.2.7\build\PostSharp.targets" Condition="Exists('..\..\packages\PostSharp.6.2.7\build\PostSharp.targets')" />
  <ProjectExtensions>
    <VisualStudio>
      <UserProperties setting_1json__JsonSchema="https://batect.dev/configSchema.json" />
    </VisualStudio>
  </ProjectExtensions>
  <ProjectExtensions />
</Project>
src/Bro.Process/ProcessControl.cs
@@ -348,10 +348,16 @@
            {
                if (config == null)
                    throw new ProcessException("保存的配置信息不能为空");
                ProductionCode = newProductionCode;
                string newConfigPath = Path.Combine(Path.GetDirectoryName(_configPath), $"Config_{newProductionCode}.json");
                if (File.Exists(newConfigPath))
                {
                    throw new ProcessException($"{newProductionCode}配置文件已经存在");
                }
                //生成config.json
                string newConfig = JsonConvert.SerializeObject(config, new JsonSerializerSettings() { TypeNameHandling = TypeNameHandling.All });
                using (StreamWriter writer = new StreamWriter(_configPath, false, System.Text.Encoding.UTF8))
                using (StreamWriter writer = new StreamWriter(newConfigPath, false, System.Text.Encoding.UTF8))
                {
                    writer.Write(newConfig);
                    writer.Flush();
@@ -359,7 +365,7 @@
                }
                //添加到Setting.json
                SettingHelper.AddNewProductionCode(ProductionCode);
                SettingHelper.AddNewProductionCode(newProductionCode);
            }
            catch (Exception ex)
            {
src/Bro.UI.Model.Winform/UI/CanvasImage.cs
@@ -614,6 +614,9 @@
            if (map == null)
                return;
            MAP?.Dispose();
            MAP = null;
            MAP = map;
            //MAP = map;