Преглед изворни кода

修改拍照光源打开方式,增加kb复检,优化mes上传程序

zly пре 4 месеци
родитељ
комит
2e7a52e5ad

+ 351 - 274
TeamAAS-VM/Core/Management.cs

@@ -1273,7 +1273,8 @@ namespace TeamAAS_VP.Core
             {
                 foreach (var item in current.PickPoints)
                 {
-                    await item.WriteToPlcAddress(addressConfig.Out_Pick, plc, item.Feeder);
+                    //await item.WriteToPlcAddress(addressConfig.Out_Pick, plc, item.Feeder);
+                    await item.WriteToPlcAddress(addressConfig.Out_Pick, plc);
                 }
             }
             if (current.SecPosCameraPoints != null && current.SecPosCameraPoints.Count > 0)
@@ -1386,6 +1387,7 @@ namespace TeamAAS_VP.Core
         Int16[] _LastMesCheck = new Int16[10];
         Int16 _LastPickINC = 0;
         DateTime[] _LastMesCheckTime = new DateTime[10];
+        Dictionary<string, string> mes_cc = new Dictionary<string, string>();
         string[] ProductMainSN { get; set; } = new string[10];//产品主sn
         string[] model_num { get; set; } = new string[10];//产品model_num
         string[] wo { get; set; } = new string[10];//产品wo
@@ -1409,6 +1411,7 @@ namespace TeamAAS_VP.Core
                 }
 
                 var addressConfig = _configService.GetPlcAddresses();
+
                 var plc = _plcService.GetPlcByNumber(addressConfig.PlcNo) as OpcUaClientPLC;
                 if (plc == null || !plc.IsConnected) return;
                 // 获取当前产品
@@ -1471,7 +1474,7 @@ namespace TeamAAS_VP.Core
                             var _cts = new CancellationTokenSource();
                             ImageParameters imgPara = new ImageParameters();
                             imgPara.SNCode = productSn;
-                            var visionResult = await _remoteCommandService.ExecutePhotoGetSinglePoint(process, null, null, _cts.Token, cameraIndex, null, imgPara);
+                            var visionResult = await _remoteCommandService.ExecutePhotoGetSinglePoint(process, null, null, _cts.Token, cameraIndex, cameraIndex, null, imgPara);
                             if (visionResult.IsSucceed)
                             {
                                 //披头偏差
@@ -1540,7 +1543,7 @@ namespace TeamAAS_VP.Core
                             var _cts = new CancellationTokenSource();
                             ImageParameters imgPara = new ImageParameters();
                             imgPara.SNCode = productSn;
-                            var visionResult = await _remoteCommandService.ExecutePhotoGetSinglePoint(process, null, null, _cts.Token, cameraIndex, null, imgPara);
+                            var visionResult = await _remoteCommandService.ExecutePhotoGetSinglePoint(process, null, null, _cts.Token, cameraIndex, cameraIndex, null, imgPara);
                             if (visionResult.IsSucceed)
                             {
                                 //披头偏差
@@ -1627,6 +1630,7 @@ namespace TeamAAS_VP.Core
                                 }
                             }
 
+                            int num = plcPoints.Count;
                             //获取锁付拍照的点位
                             var pos = plcPoints[cameraIndex - 1];
                             if (pos != null)
@@ -1653,16 +1657,29 @@ namespace TeamAAS_VP.Core
 
                             }
                             var currentPosition = robot.GetRobotPos();
-
+                            var systemConfig = _configService.GetSystemConfiguration();
                             // 执行视觉任务
                             var _cts = new CancellationTokenSource();
                             ImageParameters imgPara = new ImageParameters();
                             imgPara.SNCode = productSn;
-                            var visionResult = await _remoteCommandService.ExecutePhotoGetSinglePoint(process, null, new double[] { currentPosition.X, currentPosition.Y, currentPosition.U }, _cts.Token, cameraIndex, null, imgPara);
+
+                            var visionResult = await _remoteCommandService.ExecutePhotoGetSinglePoint(process, null, new double[] { currentPosition.X, currentPosition.Y, currentPosition.U }, _cts.Token, cameraIndex, num, null, imgPara);
                             if (visionResult.IsSucceed)
                             {
                                 //是拍一个锁一个还是拍两个点锁所有
-                                var systemConfig = _configService.GetSystemConfiguration();
+
+
+                                if (systemConfig.IsBasePartOpenLightKB)
+                                {
+                                    if (mes_cc.ContainsKey(visionResult.distance.Split(',')[0]))
+                                    {
+                                        mes_cc[visionResult.distance.Split(',')[0]] = visionResult.distance.Split(',')[1];
+                                    }
+                                    else
+                                    {
+                                        mes_cc.Add(visionResult.distance.Split(',')[0], visionResult.distance.Split(',')[1]);
+                                    }
+                                }
                                 //拍1打1 
                                 if (systemConfig.WorkMode == 1)
                                 {
@@ -1681,12 +1698,31 @@ namespace TeamAAS_VP.Core
                             }
                             else
                             {
+                                if (systemConfig.IsBasePartOpenLightKB)
+                                {
+                                    if (mes_cc.ContainsKey(visionResult.distance.Split(',')[0]))
+                                    {
+                                        mes_cc[visionResult.distance.Split(',')[0]] = visionResult.distance.Split(',')[1];
+                                    }
+                                    else
+                                    {
+                                        if (mes_cc.ContainsKey(cameraIndex.ToString()))
+                                        {
+                                            mes_cc[cameraIndex.ToString()] = "0";
+                                        }
+                                        else
+                                        {
+                                            mes_cc.Add(cameraIndex.ToString(), "0");
+                                        }
+                                    }
+                                }
+
                                 if (!resultToMes.Contains($"Screw{cameraIndex}_Fail"))
                                 {
                                     resultToMes.Add($"Screw{cameraIndex}_Fail");
                                     SendTaskMessage($"Screw{cameraIndex}:拍照失败", MessageLevel.Error);
-                                }                         
-                                
+                                }
+
                                 await plc.WriteNodeAsync(addressConfig.Out_UpCameraPutStatus.Address, (Int16)2);
                             }
                         }
@@ -1727,6 +1763,7 @@ namespace TeamAAS_VP.Core
                                 }
                             }
 
+                            int num = plcPoints.Count;
                             //视觉流程ID
                             Guid procedureId = Guid.Empty;
                             //获取锁付拍照的点位
@@ -1757,9 +1794,14 @@ namespace TeamAAS_VP.Core
 
                             // 执行视觉任务
                             var _cts = new CancellationTokenSource();
-                            var visionResult = await _remoteCommandService.ExecutePhotoGetSinglePoint(process, null, new double[] { currentPosition.X, currentPosition.Y, currentPosition.U }, _cts.Token, cameraIndex, null, null);
+                            var visionResult = await _remoteCommandService.ExecutePhotoGetSinglePoint(process, null, new double[] { currentPosition.X, currentPosition.Y, currentPosition.U }, _cts.Token, cameraIndex, num, null, null);
                             if (visionResult.IsSucceed)
                             {
+
+                                //if ()
+                                //{
+
+                                //}
                                 await plc.WriteNodeAsync(addressConfig.Out_UPCameracheckStatus.Address, (Int16)1);
                                 SendTaskMessage($"点位{cameraIndex}检测OK", MessageLevel.Debug);
                             }
@@ -2436,19 +2478,12 @@ namespace TeamAAS_VP.Core
                                 //询问mes
                                 if (state == 1)
                                 {
-                                    if (_configService.GetDeviceInfo().EnableMES)
-                                    {
-                                        if (i == 0)
-                                        {
-                                            SendTaskMessage($"收到当前过站检查请求(当站是否生产)...", MessageLevel.Debug);
-                                        }
-                                        else
-                                        {
-                                            SendTaskMessage($"收到{i}过站检查请求(当站是否生产)...", MessageLevel.Debug);
-                                        }
 
-                                        //获取过站时间
-                                        _LastMesCheckTime[i] = (await _mesService.GetServerTimeAsync(i, code, 2)).Now;
+                                    SendTaskMessage($"收到{i}过站检查请求(当站是否生产)...", MessageLevel.Debug);
+                                    //获取过站时间
+                                    _LastMesCheckTime[i] = (await _mesService.GetServerTimeAsync(i, code, 2)).Now;
+                                    if (_configService.GetDeviceInfo().EnableMES)
+                                    {                                              
                                         LogHelper.WriteLogMes($"【mes开始QUERY】");
                                         SendTaskMessage($"mes开始QUERY", MessageLevel.Info);
                                         dataToMes.Clear();
@@ -2713,48 +2748,215 @@ namespace TeamAAS_VP.Core
                                 }
                                 // 上传本站数据
                                 else if (state == 2)
-                                {
-                                    if (_configService.GetDeviceInfo().EnableMES == true)
-                                    {
-                                        DFC.Clear();//CTQ数据集合
+                                {                                
+                                    DFC.Clear();//CTQ数据集合
 
-                                        //获取当前工位的配置
-                                        var stationConfig = _configService.GetDeviceInfo(i);
-                                        SendTaskMessage($"收到{i}:{stationConfig.DeviceName}上传本站数据请求...", MessageLevel.Debug);
-                                        //从服务器中获取当前时间
-                                        LogHelper.WriteLogMes($"【从服务器中获取当前时间】");
-                                        SendTaskMessage($"从服务器中获取当前时间", MessageLevel.Info);
-                                        var serverTimeResult = await _mesService.GetServerTimeAsync(i, ProductMainSN[i], 2);
+                                    //获取当前工位的配置
+                                    var stationConfig = _configService.GetDeviceInfo(i);
+                                    SendTaskMessage($"收到{i}:{stationConfig.DeviceName}上传本站数据请求...", MessageLevel.Debug);
+                                    //从服务器中获取当前时间
+                                    LogHelper.WriteLogMes($"【从服务器中获取当前时间】");
+                                    SendTaskMessage($"从服务器中获取当前时间", MessageLevel.Info);
+                                    var serverTimeResult = await _mesService.GetServerTimeAsync(i, ProductMainSN[i], 2);
 
-                                        //这里缺少上传MES的本站数据结果及开始和结束时间,需要补充
+                                    //这里缺少上传MES的本站数据结果及开始和结束时间,需要补充
 
-                                        if (i == 0)
-                                        {
-                                            CTtime = serverTimeResult.Now.Subtract(_LastMesCheckTime[i]).TotalSeconds;
-                                            _eventAggregator.GetEvent<DelaySaveImageNotification>().Publish(true);//通知界面延迟保存图片,等待MES查询结果返回,避免图片和数据不同步
-                                        }
+                                    if (i == 0)
+                                    {
+                                        CTtime = serverTimeResult.Now.Subtract(_LastMesCheckTime[i]).TotalSeconds;
+                                        _eventAggregator.GetEvent<DelaySaveImageNotification>().Publish(true);//通知界面延迟保存图片,等待MES查询结果返回,避免图片和数据不同步
+                                    }
 
-                                        //读取产品结果
-                                        Int16 resultIndex = plc.ReadNode<Int16>(string.Format(addressConfig.In_Result.Address, i));
+                                    //读取产品结果
+                                    Int16 resultIndex = plc.ReadNode<Int16>(string.Format(addressConfig.In_Result.Address, i));
 
-                                        //目前只记录当前站
-                                        if (i == 0)
-                                            await _systemDatabaseService.RecordProductionAsync(new ProductionRecord()
+                                    //目前只记录当前站
+                                    if (i == 0)
+                                        await _systemDatabaseService.RecordProductionAsync(new ProductionRecord()
+                                        {
+                                            ProductName = currentProduct.Name,
+                                            ProductCode = ProductMainSN[i],
+                                            DeviceId = i,
+                                            DeviceName = "",
+                                            Category = resultIndex == 1 ? "OK" : "NG",
+                                            Quantity = 1,
+                                            Remark = $"TotalSeconds:{serverTimeResult.Now.Subtract(_LastMesCheckTime[i]).TotalSeconds.ToString("F2")}",
+                                        });
+
+                                    LogHelper.WriteLogMes($"【mes开始ADD】");
+                                    SendTaskMessage($"mes开始ADD", MessageLevel.Info);
+
+                                    if (i == 0)
+                                    {
+                                        foreach (var lockResult in lockResultsAll)
+                                        {
+                                            bool torqueRes, turnRes, pressureRes;
+                                            if (lockResult.LockTorque >= lockResult.TargetTorqueLowerLimit && lockResult.LockTorque <= lockResult.TargetTorqueUpperLimit)
                                             {
-                                                ProductName = currentProduct.Name,
-                                                ProductCode = ProductMainSN[i],
-                                                DeviceId = i,
-                                                DeviceName = "",
-                                                Category = resultIndex == 1 ? "OK" : "NG",
-                                                Quantity = 1,
-                                                Remark = $"TotalSeconds:{serverTimeResult.Now.Subtract(_LastMesCheckTime[i]).TotalSeconds.ToString("F2")}",
-                                            });
+                                                torqueRes = true;
+                                            }
+                                            else torqueRes = false;
+                                            if (lockResult.Pressure >= stationConfig.DataInfo.CTQ_LSL_Pressure && lockResult.Pressure <= stationConfig.DataInfo.CTQ_USL_Pressure)
+                                            {
+                                                pressureRes = true;
+                                            }
+                                            else pressureRes = false;
+                                            if (lockResult.LockTurns >= lockResult.TargetTurnsLowerLimit && lockResult.LockTurns <= lockResult.TargetTurnsUpperLimit)
+                                            {
+                                                turnRes = true;
+                                            }
+                                            else turnRes = false;
 
-                                        LogHelper.WriteLogMes($"【mes开始ADD】");
-                                        SendTaskMessage($"mes开始ADD", MessageLevel.Info);
-                                        //上传mes
-                                        //这里现在上传的结果都是锁付站的,如果存在其他附属站的数据需要上传时,将不适用,要根据实际情况进行调整
-                                        //(bool isSuccess, string response) = await _mesService.SubmitGetAsync(ProductMainSN[i], "", dataToMes, resultIndex == 1 ? true : false, _LastMesCheckTime[i], serverTimeResult.Now);
+                                            string midValue = "NA", saveppid = "NA";
+                                            if (stationConfig.SaveCsvPPID) saveppid = ppid[i];
+                                            midValue = ((lockResult.TargetTorqueLowerLimit + lockResult.TargetTorqueUpperLimit) / 2).ToString("F3");
+                                            DFC.Add(new DataFormCtq
+                                            {
+                                                PPID = saveppid,
+                                                ScrewNum = lockResult.Number,
+                                                PROCESS_NAME = stationConfig.DataInfo.PROCESS_NAME,
+                                                PROCESS_START_TIME = _LastMesCheckTime[i].ToString("yyyy-MM-ddTHH:mm:ss.fffffff") + "+08:00",
+                                                CTQ_NAME = "Torque",
+                                                CTQ_VALUE = lockResult.LockTorque,
+                                                CTQ_LSL = lockResult.TargetTorqueLowerLimit,
+                                                CTQ_USL = lockResult.TargetTorqueUpperLimit,
+                                                PROCESS_END_TIME = serverTimeResult.Now.ToString("yyyy-MM-ddTHH:mm:ss.fffffff") + "+08:00",
+                                                SUPPLIER_NAME = stationConfig.DataInfo.SUPPLIER_NAME,
+                                                COMMODITY_TYPE = stationConfig.DataInfo.COMMODITY_TYPE,
+                                                REVISION = stationConfig.DataInfo.REVISION + "_" + revision[i],
+                                                WO = wo[i],
+                                                MFG_LOT = stationConfig.DataInfo.MFG_LOT,
+                                                MFG_ASSY_LINE = stationConfig.DataInfo.MFG_ASSY_LINE,
+                                                PROCESS_OUTCOME = torqueRes ? "PASS" : "FAIL",
+                                                PROCESS_MACHINE_ID = stationConfig.DataInfo.PROCESS_MACHINE_ID,
+                                                CTQ_UNIT_OF_MEASURE = "kgf.cm",
+                                                ERROR_MESSAGE = torqueRes ? "NA" : "Torque_Spec OOS",
+                                                PD_ATTR_01 = ProductMainSN[i],
+                                                PD_ATTR_02 = midValue,
+                                                PD_ATTR_03 = "NA",
+                                                PD_ATTR_04 = productSn,
+                                                PD_ATTR_05 = "NA",
+                                            });
+                                            midValue = ((lockResult.TargetTurnsLowerLimit + lockResult.TargetTurnsUpperLimit) / 2).ToString("F3");
+                                            DFC.Add(new DataFormCtq
+                                            {
+                                                PPID = saveppid,
+                                                ScrewNum = lockResult.Number,
+                                                PROCESS_NAME = stationConfig.DataInfo.PROCESS_NAME,
+                                                PROCESS_START_TIME = _LastMesCheckTime[i].ToString("yyyy-MM-ddTHH:mm:ss.fffffff") + "+08:00",
+                                                CTQ_NAME = "Turn",
+                                                CTQ_VALUE = lockResult.LockTurns,
+                                                CTQ_LSL = lockResult.TargetTurnsLowerLimit,
+                                                CTQ_USL = lockResult.TargetTurnsUpperLimit,
+                                                PROCESS_END_TIME = serverTimeResult.Now.ToString("yyyy-MM-ddTHH:mm:ss.fffffff") + "+08:00",
+                                                SUPPLIER_NAME = stationConfig.DataInfo.SUPPLIER_NAME,
+                                                COMMODITY_TYPE = stationConfig.DataInfo.COMMODITY_TYPE,
+                                                REVISION = stationConfig.DataInfo.REVISION + "_" + revision[i],
+                                                WO = wo[i],
+                                                MFG_LOT = stationConfig.DataInfo.MFG_LOT,
+                                                MFG_ASSY_LINE = stationConfig.DataInfo.MFG_ASSY_LINE,
+                                                PROCESS_OUTCOME = turnRes ? "PASS" : "FAIL",
+                                                PROCESS_MACHINE_ID = stationConfig.DataInfo.PROCESS_MACHINE_ID,
+                                                CTQ_UNIT_OF_MEASURE = "圈",
+                                                ERROR_MESSAGE = turnRes ? "NA" : "Turn_Spec OOS",
+                                                PD_ATTR_01 = ProductMainSN[i],
+                                                PD_ATTR_02 = midValue,
+                                                PD_ATTR_03 = "NA",
+                                                PD_ATTR_04 = productSn,
+                                                PD_ATTR_05 = "NA",
+                                            });
+                                            midValue = ((stationConfig.DataInfo.CTQ_LSL_Pressure + stationConfig.DataInfo.CTQ_USL_Pressure) / 2).ToString("F3");
+                                            DFC.Add(new DataFormCtq
+                                            {
+                                                PPID = saveppid,
+                                                ScrewNum = lockResult.Number,
+                                                PROCESS_NAME = stationConfig.DataInfo.PROCESS_NAME,
+                                                PROCESS_START_TIME = _LastMesCheckTime[i].ToString("yyyy-MM-ddTHH:mm:ss.fffffff") + "+08:00",
+                                                CTQ_NAME = "Pressure",
+                                                CTQ_VALUE = lockResult.Pressure,
+                                                CTQ_LSL = stationConfig.DataInfo.CTQ_LSL_Pressure,
+                                                CTQ_USL = stationConfig.DataInfo.CTQ_USL_Pressure,
+                                                PROCESS_END_TIME = serverTimeResult.Now.ToString("yyyy-MM-ddTHH:mm:ss.fffffff") + "+08:00",
+                                                SUPPLIER_NAME = stationConfig.DataInfo.SUPPLIER_NAME,
+                                                COMMODITY_TYPE = stationConfig.DataInfo.COMMODITY_TYPE,
+                                                REVISION = stationConfig.DataInfo.REVISION + "_" + revision[i],
+                                                WO = wo[i],
+                                                MFG_LOT = stationConfig.DataInfo.MFG_LOT,
+                                                MFG_ASSY_LINE = stationConfig.DataInfo.MFG_ASSY_LINE,
+                                                PROCESS_OUTCOME = pressureRes ? "PASS" : "FAIL",
+                                                PROCESS_MACHINE_ID = stationConfig.DataInfo.PROCESS_MACHINE_ID,
+                                                CTQ_UNIT_OF_MEASURE = "N",
+                                                ERROR_MESSAGE = pressureRes ? "NA" : "Pressure_Spec OOS",
+                                                PD_ATTR_01 = ProductMainSN[i],
+                                                PD_ATTR_02 = midValue,
+                                                PD_ATTR_03 = "NA",
+                                                PD_ATTR_04 = productSn,
+                                                PD_ATTR_05 = "NA",
+                                            });                                            
+                                        }
+                                        if (systemConfig.IsBasePartOpenLightKB)
+                                        {
+                                            string midValue = "999", saveppid = "NA";
+                                            double upvlalue = 0, doenvlaue = 0;
+                                            if (stationConfig.SaveCsvPPID) saveppid = ppid[i];
+                                            bool pressureRes=true;                                            
+                                            foreach (var item in mes_cc)
+                                            {
+                                                switch(item.Key)
+                                                {
+                                                    case "1":
+                                                        upvlalue = Convert.ToDouble(currentProduct.GlobalParamEx.CC1DownLimit.ToString("F3"));
+                                                        doenvlaue = Convert.ToDouble(currentProduct.GlobalParamEx.CC1UpLimit.ToString("F3"));
+                                                        midValue = ((currentProduct.GlobalParamEx.CC1DownLimit + currentProduct.GlobalParamEx.CC1UpLimit) / 2).ToString("F3");
+                                                        break;
+                                                    case "2":
+                                                        upvlalue = Convert.ToDouble(currentProduct.GlobalParamEx.CC2DownLimit.ToString("F3"));
+                                                        doenvlaue = Convert.ToDouble(currentProduct.GlobalParamEx.CC2UpLimit.ToString("F3"));
+                                                        midValue = ((currentProduct.GlobalParamEx.CC2DownLimit + currentProduct.GlobalParamEx.CC2UpLimit) / 2).ToString("F3");
+                                                        break;                                                   
+                                                }
+                                                if (doenvlaue<= currentProduct.GlobalParamEx.CC1DownLimit|| doenvlaue >= currentProduct.GlobalParamEx.CC1UpLimit)
+                                                {
+                                                    pressureRes = false;
+                                                }
+                                                if (doenvlaue <= currentProduct.GlobalParamEx.CC2DownLimit|| doenvlaue >= currentProduct.GlobalParamEx.CC2UpLimit)
+                                                {
+                                                    pressureRes = false;
+                                                }
+                                                dataToMes.Add($"CC{item.Key}", $"{item.Value}");
+                                                DFC.Add(new DataFormCtq
+                                                {
+                                                    PPID = saveppid,
+                                                    ScrewNum = 1,
+                                                    PROCESS_NAME = stationConfig.DataInfo.PROCESS_NAME,
+                                                    PROCESS_START_TIME = _LastMesCheckTime[i].ToString("yyyy-MM-ddTHH:mm:ss.fffffff") + "+08:00",
+                                                    CTQ_NAME = $"CC{item.Key}",
+                                                    CTQ_VALUE = Convert.ToDouble(item.Value.ToString()),
+                                                    CTQ_LSL = doenvlaue,
+                                                    CTQ_USL = upvlalue,
+                                                    PROCESS_END_TIME = serverTimeResult.Now.ToString("yyyy-MM-ddTHH:mm:ss.fffffff") + "+08:00",
+                                                    SUPPLIER_NAME = stationConfig.DataInfo.SUPPLIER_NAME,
+                                                    COMMODITY_TYPE = stationConfig.DataInfo.COMMODITY_TYPE,
+                                                    REVISION = stationConfig.DataInfo.REVISION + "_" + revision[i],
+                                                    WO = wo[i],
+                                                    MFG_LOT = stationConfig.DataInfo.MFG_LOT,
+                                                    MFG_ASSY_LINE = stationConfig.DataInfo.MFG_ASSY_LINE,
+                                                    PROCESS_OUTCOME = pressureRes ? "PASS" : "FAIL",
+                                                    PROCESS_MACHINE_ID = stationConfig.DataInfo.PROCESS_MACHINE_ID,
+                                                    CTQ_UNIT_OF_MEASURE = "mm",
+                                                    ERROR_MESSAGE = pressureRes ? "NA" : $"CC{item.Key} OOS",
+                                                    PD_ATTR_01 = ProductMainSN[i],
+                                                    PD_ATTR_02 = midValue,
+                                                    PD_ATTR_03 = "NA",
+                                                    PD_ATTR_04 = productSn,
+                                                    PD_ATTR_05 = "NA",
+                                                });
+                                            }
+                                        }
+                                    }
+                                    //上传mes
+                                    if (stationConfig.EnableMES)
+                                    {
                                         (bool isSuccess, string response) = await _mesService.SubmitGetExAsync(ProductMainSN[i], "", dataToMes, resultToMes, _LastMesCheckTime[i], serverTimeResult.Now);
                                         if (isSuccess)
                                         {
@@ -2766,257 +2968,132 @@ namespace TeamAAS_VP.Core
                                             LogHelper.WriteLogMes($"上传mes失败");
                                             SendTaskMessage($"上传mes失败", MessageLevel.Error);
                                         }
-                                        await plc.WriteNodeAsync(string.Format(addressConfig.Out_MesStatus.Address, i), (Int16)3);
+                                    }
+                                    else
+                                    {
+                                        LogHelper.WriteLogMes($"上传mes成功");
+                                        SendTaskMessage($"上传mes成功", MessageLevel.Debug);
+                                    }
+                                    await plc.WriteNodeAsync(string.Format(addressConfig.Out_MesStatus.Address, i), (Int16)3);
 
-                                        //是否保存当前的产品记录至CSV?
-                                        if (stationConfig.SaveCsv)
+                                    if (stationConfig.SaveCsv)
+                                    {
+                                        if (!string.IsNullOrEmpty(stationConfig.SaveCsvPath))
                                         {
-                                            //判断锁付路径字符串是否为空,如果不为空则保存,否则不保存
-                                            if (!string.IsNullOrEmpty(stationConfig.SaveCsvPath))
+                                            bool recordResult = false;
+                                            recordResult = RecordStationResult(i, DFC, ProductMainSN[i], serverTimeResult.Now.Subtract(_LastMesCheckTime[i]).TotalSeconds, _LastMesCheckTime[i], stationConfig.SaveCsvPath);
+                                            if (recordResult)
                                             {
-                                                bool recordResult = false;
-                                                if (i == 0)
+                                                SendTaskMessage($"{i}:{stationConfig.DeviceName}产品记录保存成功", MessageLevel.Debug);
+                                                //上传数据
+                                                try
                                                 {
-                                                    foreach (var lockResult in lockResultsAll)
+                                                    if (stationConfig.EnableMES)
                                                     {
-                                                        bool torqueRes, turnRes, pressureRes;
-                                                        if (lockResult.LockTorque >= lockResult.TargetTorqueLowerLimit && lockResult.LockTorque <= lockResult.TargetTorqueUpperLimit)
-                                                        {
-                                                            torqueRes = true;
-                                                        }
-                                                        else torqueRes = false;
-                                                        if (lockResult.Pressure >= stationConfig.DataInfo.CTQ_LSL_Pressure && lockResult.Pressure <= stationConfig.DataInfo.CTQ_USL_Pressure)
-                                                        {
-                                                            pressureRes = true;
-                                                        }
-                                                        else pressureRes = false;
-                                                        if (lockResult.LockTurns >= lockResult.TargetTurnsLowerLimit && lockResult.LockTurns <= lockResult.TargetTurnsUpperLimit)
-                                                        {
-                                                            turnRes = true;
-                                                        }
-                                                        else turnRes = false;
+                                                        DateTime dt = DateTime.Now;
+                                                        string filename = $"{ProductMainSN[i]}_{dt.ToString("yyyyMMddHHmmss")}";
+                                                        var device = _configService.GetDeviceInfo();
+                                                        var config = _configService.GetSystemConfiguration();
 
-                                                        string midValue = "NA", saveppid = "NA";
-                                                        if (stationConfig.SaveCsvPPID) saveppid = ppid[i];
-                                                        midValue = ((lockResult.TargetTorqueLowerLimit + lockResult.TargetTorqueUpperLimit) / 2).ToString("F3");
-                                                        DFC.Add(new DataFormCtq
-                                                        {
-                                                            PPID = saveppid,
-                                                            ScrewNum = lockResult.Number,
-                                                            PROCESS_NAME = stationConfig.DataInfo.PROCESS_NAME,
-                                                            PROCESS_START_TIME = _LastMesCheckTime[i].ToString("yyyy-MM-ddTHH:mm:ss.fffffff") + "+08:00",
-                                                            CTQ_NAME = "Torque",
-                                                            CTQ_VALUE = lockResult.LockTorque,
-                                                            CTQ_LSL = lockResult.TargetTorqueLowerLimit,
-                                                            CTQ_USL = lockResult.TargetTorqueUpperLimit,
-                                                            PROCESS_END_TIME = serverTimeResult.Now.ToString("yyyy-MM-ddTHH:mm:ss.fffffff") + "+08:00",
-                                                            SUPPLIER_NAME = stationConfig.DataInfo.SUPPLIER_NAME,
-                                                            COMMODITY_TYPE = stationConfig.DataInfo.COMMODITY_TYPE,
-                                                            REVISION = stationConfig.DataInfo.REVISION+"_"+ revision[i],
-                                                            WO = wo[i],
-                                                            MFG_LOT = stationConfig.DataInfo.MFG_LOT,
-                                                            MFG_ASSY_LINE = stationConfig.DataInfo.MFG_ASSY_LINE,
-                                                            PROCESS_OUTCOME = torqueRes ? "PASS" : "FAIL",
-                                                            PROCESS_MACHINE_ID = stationConfig.DataInfo.PROCESS_MACHINE_ID,
-                                                            CTQ_UNIT_OF_MEASURE = "kgf.cm",
-                                                            ERROR_MESSAGE = torqueRes ? "NA" : "Torque_Spec OOS",
-                                                            PD_ATTR_01 = ProductMainSN[i],
-                                                            PD_ATTR_02 = midValue,
-                                                            PD_ATTR_03 = "NA",
-                                                            PD_ATTR_04 = productSn,
-                                                            PD_ATTR_05 = "NA",
-                                                        });
-                                                        midValue = ((lockResult.TargetTurnsLowerLimit + lockResult.TargetTurnsUpperLimit) / 2).ToString("F3");
-                                                        DFC.Add(new DataFormCtq
-                                                        {
-                                                            PPID = saveppid,
-                                                            ScrewNum = lockResult.Number,
-                                                            PROCESS_NAME = stationConfig.DataInfo.PROCESS_NAME,
-                                                            PROCESS_START_TIME = _LastMesCheckTime[i].ToString("yyyy-MM-ddTHH:mm:ss.fffffff") + "+08:00",
-                                                            CTQ_NAME = "Turn",
-                                                            CTQ_VALUE = lockResult.LockTurns,
-                                                            CTQ_LSL = lockResult.TargetTurnsLowerLimit,
-                                                            CTQ_USL = lockResult.TargetTurnsUpperLimit,
-                                                            PROCESS_END_TIME = serverTimeResult.Now.ToString("yyyy-MM-ddTHH:mm:ss.fffffff") + "+08:00",
-                                                            SUPPLIER_NAME = stationConfig.DataInfo.SUPPLIER_NAME,
-                                                            COMMODITY_TYPE = stationConfig.DataInfo.COMMODITY_TYPE,
-                                                            REVISION = stationConfig.DataInfo.REVISION + "_" + revision[i],
-                                                            WO = wo[i],
-                                                            MFG_LOT = stationConfig.DataInfo.MFG_LOT,
-                                                            MFG_ASSY_LINE = stationConfig.DataInfo.MFG_ASSY_LINE,
-                                                            PROCESS_OUTCOME = turnRes ? "PASS" : "FAIL",
-                                                            PROCESS_MACHINE_ID = stationConfig.DataInfo.PROCESS_MACHINE_ID,
-                                                            CTQ_UNIT_OF_MEASURE = "圈",
-                                                            ERROR_MESSAGE = turnRes ? "NA" : "Turn_Spec OOS",
-                                                            PD_ATTR_01 = ProductMainSN[i],
-                                                            PD_ATTR_02 = midValue,
-                                                            PD_ATTR_03 = "NA",
-                                                            PD_ATTR_04 = productSn,
-                                                            PD_ATTR_05 = "NA",
-                                                        });
-                                                        midValue = ((stationConfig.DataInfo.CTQ_LSL_Pressure + stationConfig.DataInfo.CTQ_USL_Pressure) / 2).ToString("F3");
-                                                        DFC.Add(new DataFormCtq
-                                                        {
-                                                            PPID = saveppid,
-                                                            ScrewNum = lockResult.Number,
-                                                            PROCESS_NAME = stationConfig.DataInfo.PROCESS_NAME,
-                                                            PROCESS_START_TIME = _LastMesCheckTime[i].ToString("yyyy-MM-ddTHH:mm:ss.fffffff") + "+08:00",
-                                                            CTQ_NAME = "Pressure",
-                                                            CTQ_VALUE = lockResult.Pressure,
-                                                            CTQ_LSL = stationConfig.DataInfo.CTQ_LSL_Pressure,
-                                                            CTQ_USL = stationConfig.DataInfo.CTQ_USL_Pressure,
-                                                            PROCESS_END_TIME = serverTimeResult.Now.ToString("yyyy-MM-ddTHH:mm:ss.fffffff") + "+08:00",
-                                                            SUPPLIER_NAME = stationConfig.DataInfo.SUPPLIER_NAME,
-                                                            COMMODITY_TYPE = stationConfig.DataInfo.COMMODITY_TYPE,
-                                                            REVISION = stationConfig.DataInfo.REVISION + "_" + revision[i],
-                                                            WO = wo[i],
-                                                            MFG_LOT = stationConfig.DataInfo.MFG_LOT,
-                                                            MFG_ASSY_LINE = stationConfig.DataInfo.MFG_ASSY_LINE,
-                                                            PROCESS_OUTCOME = pressureRes ? "PASS" : "FAIL",
-                                                            PROCESS_MACHINE_ID = stationConfig.DataInfo.PROCESS_MACHINE_ID,
-                                                            CTQ_UNIT_OF_MEASURE = "N",
-                                                            ERROR_MESSAGE = pressureRes ? "NA" : "Pressure_Spec OOS",
-                                                            PD_ATTR_01 = ProductMainSN[i],
-                                                            PD_ATTR_02 = midValue,
-                                                            PD_ATTR_03 = "NA",
-                                                            PD_ATTR_04 = productSn,
-                                                            PD_ATTR_05 = "NA",
-                                                        });
-                                                    }
-                                                }
-                                                recordResult = RecordStationResult(i, DFC, ProductMainSN[i], serverTimeResult.Now.Subtract(_LastMesCheckTime[i]).TotalSeconds, _LastMesCheckTime[i], stationConfig.SaveCsvPath);
-                                                if (recordResult)
-                                                {
-                                                    SendTaskMessage($"{i}:{stationConfig.DeviceName}产品记录保存成功", MessageLevel.Debug);
-                                                    //上传数据
-                                                    try
-                                                    {
-                                                        if (stationConfig.EnableMES)
+                                                        (bool isSuc, string resp) = await _mesService.SendFtpFileAsync(ProductMainSN[i], filename);
+                                                        if (isSuc)
                                                         {
-                                                            DateTime dt = DateTime.Now;
-                                                            string filename = $"{ProductMainSN[i]}_{dt.ToString("yyyyMMddHHmmss")}";
-                                                            var device = _configService.GetDeviceInfo();
-                                                            var config = _configService.GetSystemConfiguration();
-
-                                                            (bool isSuc, string resp) = await _mesService.SendFtpFileAsync(ProductMainSN[i], filename);
-                                                            if (isSuc)
+                                                            LogHelper.WriteLogMes($"上传数据成功");
+                                                            SendTaskMessage($"上传数据成功", MessageLevel.Debug);
+                                                            string filePath = $"D:\\image\\Recored\\{dt.ToString("yyyy-MM")}\\{dt.ToString("MM-dd")}\\{currentProduct.Name}\\{ProductMainSN[i]}";
+                                                            //string source_csv2 = $"{stationConfig.SaveCsvPath}\\{dt.ToString("yyyy-MM")}\\{i}_{stationConfig.DeviceName}_{dt.ToString("yyyy-MM-dd")}";
+                                                            if (!Directory.Exists(filePath))
                                                             {
-                                                                LogHelper.WriteLogMes($"上传数据成功");
-                                                                SendTaskMessage($"上传数据成功", MessageLevel.Debug);
-                                                                string filePath = $"D:\\image\\Recored\\{dt.ToString("yyyy-MM")}\\{dt.ToString("MM-dd")}\\{currentProduct.Name}\\{ProductMainSN[i]}";
-                                                                //string source_csv2 = $"{stationConfig.SaveCsvPath}\\{dt.ToString("yyyy-MM")}\\{i}_{stationConfig.DeviceName}_{dt.ToString("yyyy-MM-dd")}";
-                                                                if (!Directory.Exists(filePath))
-                                                                {
-                                                                    Directory.CreateDirectory(filePath);
-                                                                }
-                                                                string csvfilename = $"{i}_{stationConfig.DeviceName}_{dt.ToString("yyyy-MM-dd")}";
-                                                                //复制csv
-                                                                string source_csv = $"{stationConfig.SaveCsvPath}\\{dt.ToString("yyyy-MM")}\\{i}_{stationConfig.DeviceName}_{dt.ToString("yyyy-MM-dd")}.csv";
-                                                                string target_csv = Path.Combine(filePath, Path.GetFileName(source_csv));
-                                                                File.Copy(source_csv, target_csv, true);
-                                                                //复制log
-                                                                string source_log = $"..\\Log\\LogInfo\\{dt.ToString("yyyy-MM")}\\{dt.ToString("yyyy-MM-dd")}.txt";
-                                                                string target_log = Path.Combine(filePath, Path.GetFileName(source_log));
-                                                                File.Copy(source_log, target_log, true);
-
-                                                                //判断是否保存锁付曲线
-                                                                if (systemConfig.IsSaveScrewCurve)
+                                                                Directory.CreateDirectory(filePath);
+                                                            }
+                                                            string csvfilename = $"{i}_{stationConfig.DeviceName}_{dt.ToString("yyyy-MM-dd")}";
+                                                            //复制csv
+                                                            string source_csv = $"{stationConfig.SaveCsvPath}\\{dt.ToString("yyyy-MM")}\\{i}_{stationConfig.DeviceName}_{dt.ToString("yyyy-MM-dd")}.csv";
+                                                            string target_csv = Path.Combine(filePath, Path.GetFileName(source_csv));
+                                                            File.Copy(source_csv, target_csv, true);
+                                                            //复制log
+                                                            string source_log = $"..\\Log\\LogInfo\\{dt.ToString("yyyy-MM")}\\{dt.ToString("yyyy-MM-dd")}.txt";
+                                                            string target_log = Path.Combine(filePath, Path.GetFileName(source_log));
+                                                            File.Copy(source_log, target_log, true);
+
+                                                            //判断是否保存锁付曲线
+                                                            if (systemConfig.IsSaveScrewCurve)
+                                                            {
+                                                                string target_Directory = filePath + "\\扭力曲线\\";
+                                                                string source_Torque_Image = config.ScrewCurvePath + $"\\{dt.ToString("yyyy-MM")}\\{dt.ToString("yyyy-MM-dd")}\\{currentProduct.Name}\\{ProductMainSN[i]}";
+                                                                try
                                                                 {
-                                                                    string target_Directory = filePath + "\\扭力曲线\\";
-                                                                    string source_Torque_Image = config.ScrewCurvePath + $"\\{dt.ToString("yyyy-MM")}\\{dt.ToString("yyyy-MM-dd")}\\{currentProduct.Name}\\{ProductMainSN[i]}";
-                                                                    try
-                                                                    {
-                                                                        var col = Directory.GetFiles(source_Torque_Image);
-                                                                        Directory.CreateDirectory(target_Directory);
-                                                                        foreach (var item in col)
-                                                                        {
-                                                                            string target_Torque = target_Directory + item.Replace(source_Torque_Image, "");
-                                                                            File.Copy(item, target_Torque, true);
-                                                                        }
-                                                                    }
-                                                                    //string target_Directory = Path.Combine(filePath, "扭力曲线");  待测试
-                                                                    //string source_Torque_Image = config.ScrewCurvePath + $"\\{dt.ToString("yyyy-MM")}\\{dt.ToString("yyyy-MM-dd")}\\{currentProduct.Name}\\{ProductMainSN[i]}";
-                                                                    //try
-                                                                    //{
-                                                                    //    var col = Directory.GetFiles(source_Torque_Image);
-                                                                    //    Directory.CreateDirectory(target_Directory);
-                                                                    //    foreach (var item in col)
-                                                                    //    {
-                                                                    //        string fileName = Path.GetFileName(item); // 获取文件名(带后缀)
-                                                                    //        string target_Torque = Path.Combine(target_Directory, fileName); // 拼路径(推荐)
-                                                                    //        File.Copy(item, target_Torque, true);
-                                                                    //    }
-                                                                    //}
-                                                                    catch (Exception)
+                                                                    var col = Directory.GetFiles(source_Torque_Image);
+                                                                    Directory.CreateDirectory(target_Directory);
+                                                                    foreach (var item in col)
                                                                     {
-                                                                        SendTaskMessage($"扭力曲线图读取失败", MessageLevel.Error);
+                                                                        string target_Torque = target_Directory + item.Replace(source_Torque_Image, "");
+                                                                        File.Copy(item, target_Torque, true);
                                                                     }
-                                                                }                                                                
-                                                                CompressionImage(filePath, filename, device.Station, device.FixtureId);
-                                                                //上传csv
-                                                                bool isAfter20 = dt.Hour >= 20;
-                                                                //判断是否是新的一天
-                                                                bool isNewDay = dt.Date != _lastCompressDate.Date;
-                                                                //当天还没执行过压缩
-                                                                if (isAfter20 && isNewDay && !_hasCompressedToday)
-                                                                {
-                                                                    // 执行压缩
-                                                                    CompressionSingleCsv(source_csv, csvfilename, device.Station, device.FixtureId);
-                                                                    _lastCompressDate = dt;
-                                                                    _hasCompressedToday = true;
-                                                                    LogHelper.WriteLogMes("csv上传数据成功");
-                                                                    SendTaskMessage($"csv上传数据成功", MessageLevel.Debug);
                                                                 }
-                                                                // 跨天后重置当天执行标记
-                                                                if (!isNewDay && _hasCompressedToday)
+                                                                catch (Exception)
                                                                 {
-                                                                    _hasCompressedToday = false;
+                                                                    SendTaskMessage($"扭力曲线图读取失败", MessageLevel.Error);
                                                                 }
-
                                                             }
-                                                            else
+                                                            CompressionImage(filePath, filename, device.Station, device.FixtureId);
+                                                            //上传csv
+                                                            bool isAfter20 = dt.Hour >= 20;
+                                                            //判断是否是新的一天
+                                                            bool isNewDay = dt.Date != _lastCompressDate.Date;
+                                                            //当天还没执行过压缩
+                                                            if (isAfter20 && isNewDay && !_hasCompressedToday)
                                                             {
-                                                                LogHelper.WriteLogMes($"上传数据失败");
-                                                                SendTaskMessage($"上传数据失败", MessageLevel.Error);
+                                                                // 执行压缩
+                                                                CompressionSingleCsv(source_csv, csvfilename, device.Station, device.FixtureId);
+                                                                _lastCompressDate = dt;
+                                                                _hasCompressedToday = true;
+                                                                LogHelper.WriteLogMes("csv上传数据成功");
+                                                                SendTaskMessage($"csv上传数据成功", MessageLevel.Debug);
                                                             }
+                                                            // 跨天后重置当天执行标记
+                                                            if (!isNewDay && _hasCompressedToday)
+                                                            {
+                                                                _hasCompressedToday = false;
+                                                            }
+
                                                         }
                                                         else
                                                         {
-                                                            LogHelper.WriteLogMes($"未启用mes");
-                                                            SendTaskMessage($"未启用mes", MessageLevel.Error);
+                                                            LogHelper.WriteLogMes($"上传数据失败");
+                                                            SendTaskMessage($"上传数据失败", MessageLevel.Error);
                                                         }
                                                     }
-                                                    catch (Exception ex)
+                                                    else
                                                     {
-                                                        SendTaskMessage($"上传数据时出错:{ex.Message}", MessageLevel.Error);
-                                                        LogHelper.WriteLogError($"上传数据时出错", ex);
+                                                        LogHelper.WriteLogMes($"未启用mes");
+                                                        SendTaskMessage($"未启用mes", MessageLevel.Error);
                                                     }
                                                 }
-                                                else
+                                                catch (Exception ex)
                                                 {
-                                                    SendTaskMessage($"{i}:{stationConfig.DeviceName}产品记录保存失败", MessageLevel.Error);
+                                                    SendTaskMessage($"上传数据时出错:{ex.Message}", MessageLevel.Error);
+                                                    LogHelper.WriteLogError($"上传数据时出错", ex);
                                                 }
                                             }
                                             else
                                             {
-                                                SendTaskMessage($"{i}:{stationConfig.DeviceName}工位未配置保存路径,无法保存产品记录", MessageLevel.Error);
+                                                SendTaskMessage($"{i}:{stationConfig.DeviceName}产品记录保存失败", MessageLevel.Error);
                                             }
                                         }
                                         else
                                         {
-                                            SendTaskMessage($"{i}:{stationConfig.DeviceName}工位未配置保存产品记录", MessageLevel.Debug);
+                                            SendTaskMessage($"{i}:{stationConfig.DeviceName}工位未配置保存路径,无法保存产品记录", MessageLevel.Error);
                                         }
-
-                                        WriteProductLog(lockResultsAll, ProductMainSN[i], CTtime);
-
-                                        LogHelper.WriteLogMes($"【mes结束ADD】");
-                                        SendTaskMessage($"mes结束ADD", MessageLevel.Info);
                                     }
                                     else
                                     {
-                                        await plc.WriteNodeAsync(addressConfig.Out_ScrewFeederIsChanged.Address, (Int16)1); //不发生改变
-                                        await plc.WriteNodeAsync(string.Format(addressConfig.Out_MesStatus.Address, i), (Int16)3);
+                                        SendTaskMessage($"{i}:{stationConfig.DeviceName}工位未配置保存产品记录", MessageLevel.Debug);
                                     }
+                                    WriteProductLog(lockResultsAll, ProductMainSN[i], CTtime);
+                                    mes_cc.Clear();
+                                    LogHelper.WriteLogMes($"【mes结束ADD】");
+                                    SendTaskMessage($"mes结束ADD", MessageLevel.Info);                                 
                                 }
                                 else
                                 {
@@ -3064,7 +3141,7 @@ namespace TeamAAS_VP.Core
                 for (int i = 0; i < 1; i++)
                 {
                     var stationConfig = _configService.GetDeviceInfo(i);
-                    if (!stationConfig.EnableMES ||  !stationConfig.SaveCsv)
+                    if (!stationConfig.EnableMES || !stationConfig.SaveCsv)
                     {
                         SendTaskMessage("当前MES功能/保存CSV功能未启用,请检查...", MessageLevel.Info);
                         mesStatus = false;
@@ -3121,7 +3198,7 @@ namespace TeamAAS_VP.Core
         /// <param name="positionIndex">锁付点编号</param>
         private void StartPressureCollection(string productName, string productCode, int positionIndex)
         {
-            
+
             try
             {
                 // cancel existing if any
@@ -3150,7 +3227,7 @@ namespace TeamAAS_VP.Core
                 if (plc == null || !plc.IsConnected) return;
                 Task.Run(async () =>
                 {
-                    
+
                     SendTaskMessage($"Pressure collection started for position {positionIndex}", MessageLevel.Debug);
                     while (!token.IsCancellationRequested)
                     {
@@ -3224,7 +3301,7 @@ namespace TeamAAS_VP.Core
                     SendTaskMessage("No pressure samples collected.", MessageLevel.Info);
                     return;
                 }
-                
+
                 // save to file under configured path
                 try
                 {
@@ -3250,7 +3327,7 @@ namespace TeamAAS_VP.Core
                     {
                         _eventAggregator.GetEvent<PressureFinishNotification>().Publish((true, snapshot.ToArray(), pngPath));
                     });
-                    
+
                     //判断是否保存锁付曲线
                     if (systemConfig.IsSaveScrewCurve)
                     {
@@ -3260,7 +3337,7 @@ namespace TeamAAS_VP.Core
                             sb.AppendLine("Timestamp,Value");
                             foreach (var s in snapshot)
                             {
-                                sb.AppendLine($"{s.Timestamp:O},{s.Value}");                                
+                                sb.AppendLine($"{s.Timestamp:O},{s.Value}");
                             }
 
                             File.WriteAllText(fullPath, sb.ToString());

+ 13 - 1
TeamAAS-VM/Interfaces/IRemoteCommandService.cs

@@ -259,7 +259,19 @@ namespace TeamAAS_VP.Interfaces
         /// <param name="positionIndex"></param>
         /// <param name="remark"></param>
         /// <returns></returns>
-        Task<(bool IsSucceed, double X, double Y, double U)> ExecutePhotoGetSinglePoint(ProcedureModel procedure, Dictionary<string, string> InputTerminal, double[] robotCoord, CancellationToken cancellationToken, int positionIndex, string remark, ImageParameters imgPara);
+        Task<(bool IsSucceed,string distance, double X, double Y, double U)> ExecutePhotoGetSinglePoint(ProcedureModel procedure, Dictionary<string, string> InputTerminal, double[] robotCoord, CancellationToken cancellationToken, int positionIndex,int num, string remark, ImageParameters imgPara);
+
+        /// <summary>
+        /// 执行相机拍照获取单个点位结果,KB复检
+        /// </summary>
+        /// <param name="procedure"></param>
+        /// <param name="InputTerminal"></param>
+        /// <param name="robotCoord"></param>
+        /// <param name="cancellationToken"></param>
+        /// <param name="positionIndex"></param>
+        /// <param name="remark"></param>
+        /// <returns></returns>
+       // Task<(bool IsSucceed, double X, double Y, double U)> ExecutePhotoGetSinglePoint(ProcedureModel procedure, Dictionary<string, string> InputTerminal, double[] robotCoord, CancellationToken cancellationToken, int positionIndex, int num, string remark, Dictionary<string, string> mes_cc, ImageParameters imgPara);
 
         /// <summary>
         /// 执行相机拍照获取单个点位结果,并且返回图像和图形

+ 9 - 0
TeamAAS-VM/Models/DataFormCtq.cs

@@ -45,7 +45,15 @@ namespace TeamAAS_VP.Models
         /// </summary>
         public double CTQ_VALUE { get => _CTQ_VALUE; set => SetProperty(ref _CTQ_VALUE, value); }
 
+
+        //private string _CTQ_VALUEKB;
+        ///// <summary>
+        ///// KB复检检测值
+        ///// </summary>
+        //public string CTQ_VALUEKB { get => _CTQ_VALUEKB; set => SetProperty(ref _CTQ_VALUEKB, value); }
+
         private double _CTQ_LSL;
+
         /// <summary>
         /// 下限
         /// </summary>
@@ -57,6 +65,7 @@ namespace TeamAAS_VP.Models
         /// </summary>
         public double CTQ_USL { get => _CTQ_USL; set => SetProperty(ref _CTQ_USL, value); }
 
+
         private string _PROCESS_END_TIME;
         /// <summary>
         /// 结束时间

+ 47 - 0
TeamAAS-VM/Models/Product/ProductGlobalParamEx.cs

@@ -0,0 +1,47 @@
+using Prism.Mvvm;
+
+namespace TeamAAS_VP.Models.Product
+{
+    public class ProductGlobalParamEx : BindableBase
+    {
+        private float _CC1UpLimit = 0;
+        /// <summary>
+        /// CC1上限
+        /// </summary>
+        public float CC1UpLimit
+        {
+            get { return _CC1UpLimit; }
+            set { SetProperty(ref _CC1UpLimit, value); }
+        }
+
+        private float _CC1DownLimit = 0;
+        /// <summary>
+        /// CC1下限
+        /// </summary>
+        public float CC1DownLimit
+        {
+            get { return _CC1DownLimit; }
+            set { SetProperty(ref _CC1DownLimit, value); }
+        }
+
+        private float _CC2UpLimit = 0;
+        /// <summary>
+        /// CC2上限
+        /// </summary>
+        public float CC2UpLimit
+        {
+            get { return _CC2UpLimit; }
+            set { SetProperty(ref _CC2UpLimit, value); }
+        }
+
+        private float _CC2DownLimit = 0;
+        /// <summary>
+        /// CC2下限
+        /// </summary>
+        public float CC2DownLimit
+        {
+            get { return _CC2DownLimit; }
+            set { SetProperty(ref _CC2DownLimit, value); }
+        }
+    }
+}

+ 9 - 1
TeamAAS-VM/Models/Product/ProductModel.cs

@@ -156,7 +156,15 @@ namespace TeamAAS_VP.Models
             get { return _FixedUpCamera1ProcedureId; }
             set { SetProperty(ref _FixedUpCamera1ProcedureId, value); }
         }
-
+        private ProductGlobalParamEx _GlobalParamEx = new ProductGlobalParamEx();
+        /// <summary>
+        /// 全局参数扩展(保压/检测上下限)
+        /// </summary>
+        public ProductGlobalParamEx GlobalParamEx
+        {
+            get { return _GlobalParamEx; }
+            set { SetProperty(ref _GlobalParamEx, value); }
+        }
         private Guid _FixedUpCamera2ProcedureId;
         /// <summary>
         /// 固定向上相机2视觉流程ID

+ 20 - 0
TeamAAS-VM/Models/SystemConfiguration.cs

@@ -237,6 +237,26 @@ namespace TeamAAS_VP.Models
             set { SetProperty(ref _IsBasePartCodeChooseScrew, value); }
         }
 
+        private bool _IsBasePartOpenLight = false;
+        /// <summary>
+        /// 是否启用最后一次拍照关闭光源
+        /// </summary>
+        public bool IsBasePartOpenLight
+        {
+            get { return _IsBasePartOpenLight; }
+            set { SetProperty(ref _IsBasePartOpenLight, value); }
+        }
+
+        private bool _IsBasePartOpenLightKB = false;
+        /// <summary>
+        /// 是否启用KB复检
+        /// </summary>
+        public bool IsBasePartOpenLightKB
+        {
+            get { return _IsBasePartOpenLightKB; }
+            set { SetProperty(ref _IsBasePartOpenLightKB, value); }
+        }
+
         private string _ChooseScrewModel = "***********abc123****";
         /// <summary>
         /// 螺丝型号判断,如******123**,*为忽略字符

+ 92 - 64
TeamAAS-VM/Services/RemoteCommandService.cs

@@ -1858,87 +1858,115 @@ namespace TeamAAS_VP.Services
         /// <param name="positionIndex"></param>
         /// <param name="remark"></param>
         /// <returns></returns>
-        public async Task<(bool IsSucceed, double X, double Y, double U)> ExecutePhotoGetSinglePoint(ProcedureModel procedure, Dictionary<string, string> InputTerminal, double[] robotCoord, CancellationToken cancellationToken, int positionIndex, string remark, ImageParameters imgPara)
+        public async Task<(bool IsSucceed, string distance, double X, double Y, double U)> ExecutePhotoGetSinglePoint(ProcedureModel procedure, Dictionary<string, string> InputTerminal, double[] robotCoord, CancellationToken cancellationToken, int positionIndex,int num, string remark, ImageParameters imgPara)
         {
+            var systemConfig = _configService.GetSystemConfiguration();
             DateTime nowtime = DateTime.Now;
-            await SetLightBeforePhoto(procedure);
-            try
+            string cc = "999";
+            if (systemConfig.IsBasePartOpenLight)
             {
-                //拍照失败时,需要多次拍照
-                for (int i = 0; i < procedure.FeederFailLimit; i++)
+                if (positionIndex == 0|| positionIndex==1)
                 {
-                    SendTaskMessage(Lang.开始执行视觉流程.Replace("{0}", $"{i + 1}").Replace("{1}", procedure.Name), MessageLevel.Info);
+                    await SetLightBeforePhoto(procedure);
+                }
+            }
+            else
+            {
+                await SetLightBeforePhoto(procedure);
+            }
 
-                    // 1. 执行相机拍照并运行视觉工具
-                    bool visionSucceed = ExecutePhoto(i + 1, procedure, InputTerminal, out CogToolBlockTerminalCollection outputCollection, imgPara);
-                    if (!visionSucceed)
+                try
+                {
+                    //拍照失败时,需要多次拍照
+                    for (int i = 0; i < procedure.FeederFailLimit; i++)
                     {
-                        SendTaskMessage(Lang.视觉任务执行失败, MessageLevel.Error);
-                        continue;
-                    }
+                        SendTaskMessage(Lang.开始执行视觉流程.Replace("{0}", $"{i + 1}").Replace("{1}", procedure.Name), MessageLevel.Info);
 
-                    if (!outputCollection.Contains("Found"))
-                    {
-                        SendTaskMessage(Lang.未找到视觉输出结果, MessageLevel.Error);
-                        await RecordPhotoCaptureAsync(procedure, robotCoord, false, new double[] { 0, 0, 0 }, new double[] { 0, 0, 0 }, string.Empty, positionIndex, remark);
-                        return (false, 0, 0, 0);
-                    }
+                        // 1. 执行相机拍照并运行视觉工具
+                        bool visionSucceed = ExecutePhoto(i + 1, procedure, InputTerminal, out CogToolBlockTerminalCollection outputCollection, imgPara);
+                        if (!visionSucceed)
+                        {
+                            SendTaskMessage(Lang.视觉任务执行失败, MessageLevel.Error);
+                            continue;
+                        }
 
-                    // 2. 获取视觉输出结果
-                    bool Found = (bool)(outputCollection["Found"].Value);
-                    if (!Found)
-                    {
-                        SendTaskMessage(Lang.拍照NG, MessageLevel.Debug);
-                        continue;
-                    }
+                        if (!outputCollection.Contains("Found"))
+                        {
+                            SendTaskMessage(Lang.未找到视觉输出结果, MessageLevel.Error);
+                            await RecordPhotoCaptureAsync(procedure, robotCoord, false, new double[] { 0, 0, 0 }, new double[] { 0, 0, 0 }, string.Empty, positionIndex, remark);
+                            return (false,cc, 0, 0, 0);
+                        }                       
+                        // 2. 获取视觉输出结果
+                        bool Found = (bool)(outputCollection["Found"].Value);
+                        if (!Found)
+                        {
+                            SendTaskMessage(Lang.拍照NG, MessageLevel.Debug);
+                            continue;
+                        }
+                        if (outputCollection.Contains("CC"))
+                        {
+                             cc = outputCollection["CC"].Value.ToString();
+                        }
+                        
 
-                    SendTaskMessage(Lang.拍照OK, MessageLevel.Debug);
+                        SendTaskMessage(Lang.拍照OK, MessageLevel.Debug);
 
-                    if (procedure.CalibrationId == Guid.Empty)
+                        if (procedure.CalibrationId == Guid.Empty)
+                        {
+                            //没有关联校准时,则执行检测任务
+                            await RecordPhotoCaptureAsync(procedure, robotCoord, true, new double[] { 0, 0, 0 }, new double[] { 0, 0, 0 }, string.Empty, positionIndex, remark);
+                            return (true,cc, 0, 0, 0);
+                        }
+
+                        // 3. 获取视觉输出结果
+                        LogHelper.WriteLogInfo(Lang.开始获取视觉输出结果);
+                        //获取相机校准
+                        var calib = _calibrationService.GetCalibration(procedure.CalibrationId);
+                        string points = (string)(outputCollection["Point"].Value);
+                        string[] strpoints = points.Split(';');
+                        //先将pos按照逗号进行分隔,拿到数组
+                        var posParts = strpoints[0].Split(',');
+                        double _pixel_x = double.Parse(posParts[0]);
+                        double _pixel_y = double.Parse(posParts[1]);
+                        double _pixel_u = double.Parse(posParts[2]);
+                        //转换点位-像素转换成机器人绝对坐标
+                        var calibResult = _calibrationService.ConvertPixelToPosition((_pixel_x, _pixel_y, _pixel_u), robotCoord, calib, RobotBrand.XYZ_Platform);
+                        if (!calibResult.IsSucceed)
+                        {
+                            await RecordPhotoCaptureAsync(procedure, robotCoord, false, new double[] { _pixel_x, _pixel_y, _pixel_u }, new double[] { 0, 0, 0 }, string.Empty, positionIndex, remark);
+                            return (false,cc, 0, 0, 0);
+                        }
+                        await RecordPhotoCaptureAsync(procedure, robotCoord, true, new double[] { _pixel_x, _pixel_y, _pixel_u }, new double[] { calibResult.X, calibResult.Y, calibResult.U }, string.Empty, positionIndex, remark);
+                        return (true,cc, calibResult.X, calibResult.Y, calibResult.U);
+                    }
+                    SendTaskMessage(Lang.多次拍照失败, MessageLevel.Alarm);
+                    await RecordPhotoCaptureAsync(procedure, robotCoord, false, new double[] { 0, 0, 0 }, new double[] { 0, 0, 0 }, string.Empty, positionIndex, remark);
+                    return (false, cc, 0, 0, 0);
+                }
+                catch (Exception ex)
+                {
+                    LogHelper.WriteLogError(Lang.执行相机取图并获取单点位时出错, ex);
+                    await RecordPhotoCaptureAsync(procedure, robotCoord, false, new double[] { 0, 0, 0 }, new double[] { 0, 0, 0 }, string.Empty, positionIndex, remark);
+                    return (false, cc, 0, 0, 0);
+                }
+                finally
+                {
+                    if (systemConfig.IsBasePartOpenLight)
                     {
-                        //没有关联校准时,则执行检测任务
-                        await RecordPhotoCaptureAsync(procedure, robotCoord, true, new double[] { 0, 0, 0 }, new double[] { 0, 0, 0 }, string.Empty, positionIndex, remark);
-                        return (true, 0, 0, 0);
+                        if (positionIndex == num)
+                        {
+                            await TurnOffLightAfterPhoto(procedure);
+                        }
                     }
-
-                    // 3. 获取视觉输出结果
-                    LogHelper.WriteLogInfo(Lang.开始获取视觉输出结果);
-                    //获取相机校准
-                    var calib = _calibrationService.GetCalibration(procedure.CalibrationId);
-                    string points = (string)(outputCollection["Point"].Value);
-                    string[] strpoints = points.Split(';');
-                    //先将pos按照逗号进行分隔,拿到数组
-                    var posParts = strpoints[0].Split(',');
-                    double _pixel_x = double.Parse(posParts[0]);
-                    double _pixel_y = double.Parse(posParts[1]);
-                    double _pixel_u = double.Parse(posParts[2]);
-                    //转换点位-像素转换成机器人绝对坐标
-                    var calibResult = _calibrationService.ConvertPixelToPosition((_pixel_x, _pixel_y, _pixel_u), robotCoord, calib, RobotBrand.XYZ_Platform);
-                    if (!calibResult.IsSucceed)
+                    else
                     {
-                        await RecordPhotoCaptureAsync(procedure, robotCoord, false, new double[] { _pixel_x, _pixel_y, _pixel_u }, new double[] { 0, 0, 0 }, string.Empty, positionIndex, remark);
-                        return (false, 0, 0, 0);
+                        await TurnOffLightAfterPhoto(procedure);
                     }
-                    await RecordPhotoCaptureAsync(procedure, robotCoord, true, new double[] { _pixel_x, _pixel_y, _pixel_u }, new double[] { calibResult.X, calibResult.Y, calibResult.U }, string.Empty, positionIndex, remark);
-                    return (true, calibResult.X, calibResult.Y, calibResult.U);
+                    
                 }
-                SendTaskMessage(Lang.多次拍照失败, MessageLevel.Alarm);
-                await RecordPhotoCaptureAsync(procedure, robotCoord, false, new double[] { 0, 0, 0 }, new double[] { 0, 0, 0 }, string.Empty, positionIndex, remark);
-                return (false, 0, 0, 0);
-            }
-            catch (Exception ex)
-            {
-                LogHelper.WriteLogError(Lang.执行相机取图并获取单点位时出错, ex);
-                await RecordPhotoCaptureAsync(procedure, robotCoord, false, new double[] { 0, 0, 0 }, new double[] { 0, 0, 0 }, string.Empty, positionIndex, remark);
-                return (false, 0, 0, 0);
-            }
-            finally
-            {
-                await TurnOffLightAfterPhoto(procedure);
-
-            }
         }
 
+
         /// <summary>
         /// 记录拍照结果数据至数据库
         /// </summary>

+ 1 - 0
TeamAAS-VM/TeamAAS-VP.csproj

@@ -557,6 +557,7 @@
     <Compile Include="Models\NozzleChangeRecord.cs" />
     <Compile Include="Models\NumberStatistics.cs" />
     <Compile Include="Models\ProductWithMes.cs" />
+    <Compile Include="Models\Product\ProductGlobalParamEx.cs" />
     <Compile Include="Models\ThrowRecord.cs" />
     <Compile Include="Models\Torque\PickDynamicTestResult.cs" />
     <Compile Include="Models\Torque\PickScrewAccuracyAnalyzerrConfigModel.cs" />

+ 24 - 0
TeamAAS-VM/ViewModels/SettingViewModel.cs

@@ -1521,6 +1521,8 @@ namespace TeamAAS_VP.ViewModels
                 ScrewCurvePath = sys.ScrewCurvePath;
                 IsBasePartCodeGetSN = sys.IsBasePartCodeGetSN;
                 IsBasePartCodeChooseScrew = sys.IsBasePartCodeChooseScrew;
+                IsBasePartOpenLight = sys.IsBasePartOpenLight;
+                IsBasePartOpenLightKB = sys.IsBasePartOpenLightKB;
                 ChooseScrewModel = sys.ChooseScrewModel;
             }
 
@@ -1602,6 +1604,26 @@ namespace TeamAAS_VP.ViewModels
             set { SetProperty(ref _IsBasePartCodeGetSN, value); }
         }
 
+        private bool _IsBasePartOpenLight;
+        /// <summary>
+        /// 是否启用最后一次拍照关闭光源
+        /// </summary>
+        public bool IsBasePartOpenLight
+        {
+            get { return _IsBasePartOpenLight; }
+            set { SetProperty(ref _IsBasePartOpenLight, value); }
+        }
+
+        private bool _IsBasePartOpenLightKB;
+        /// <summary>
+        /// 是否启用KB复检
+        /// </summary>
+        public bool IsBasePartOpenLightKB
+        {
+            get { return _IsBasePartOpenLightKB; }
+            set { SetProperty(ref _IsBasePartOpenLightKB, value); }
+        }
+
         private bool _IsBasePartCodeChooseScrew;
         /// <summary>
         /// 是否通过零件码判断螺丝型号
@@ -1793,6 +1815,8 @@ namespace TeamAAS_VP.ViewModels
                     sysConfig.ScrewCurvePath = ScrewCurvePath;
                     sysConfig.IsBasePartCodeGetSN = IsBasePartCodeGetSN;
                     sysConfig.IsBasePartCodeChooseScrew = IsBasePartCodeChooseScrew;
+                    sysConfig.IsBasePartOpenLightKB = IsBasePartOpenLightKB;
+                    sysConfig.IsBasePartOpenLight = IsBasePartOpenLight;
                     sysConfig.ChooseScrewModel = ChooseScrewModel;
 
                     _configService.SaveSystemConfiguration(sysConfig);

+ 95 - 6
TeamAAS-VM/Views/Product/ProductParams.xaml

@@ -78,6 +78,7 @@
 
             <Grid>
                 <Grid.ColumnDefinitions>
+                    <ColumnDefinition Width="auto" />
                     <ColumnDefinition Width="auto" />
                     <ColumnDefinition Width="*" />
                 </Grid.ColumnDefinitions>
@@ -112,6 +113,85 @@
                       Margin="10"
                       HorizontalAlignment="Center"
                       VerticalAlignment="Center">
+                    <ScrollViewer VerticalScrollBarVisibility="Auto"
+              HorizontalScrollBarVisibility="Disabled"
+              CanContentScroll="True">
+                        <StackPanel Orientation="Vertical"
+                Margin="0">
+                            <GroupBox Header="复检配置"
+                  Margin="5"
+                  Width="200">
+                                <Grid Margin="10">
+                                    <Grid.ColumnDefinitions>
+                                        <ColumnDefinition Width="auto" />
+                                        <ColumnDefinition Width="*" />
+                                        <ColumnDefinition Width="auto" />
+                                    </Grid.ColumnDefinitions>
+                                    <Grid.RowDefinitions>
+                                        <RowDefinition Height="Auto" />
+                                        <RowDefinition Height="Auto" />
+                                        <RowDefinition Height="Auto" />
+                                        <RowDefinition Height="Auto" />
+                                    </Grid.RowDefinitions>
+                                    <TextBlock Text="{lex:Loc CC1上限}"
+                           Grid.Row="0"
+                           Grid.Column="0"
+                           HorizontalAlignment="Right" />
+                                    <TextBox Text="{Binding SelectProduct.GlobalParamEx.CC1UpLimit,Mode=TwoWay}"
+                         Grid.Row="0"
+                         Grid.Column="1"
+                         Margin="6,0" />
+                                    <TextBlock Text="mm"
+                           Grid.Row="0"
+                           Grid.Column="2"
+                           HorizontalAlignment="Right" />
+                                    <TextBlock Text="{lex:Loc CC1下限}"
+                           Grid.Row="1"
+                           Grid.Column="0"
+                           HorizontalAlignment="Right" />
+                                    <TextBox Text="{Binding SelectProduct.GlobalParamEx.CC1DownLimit,Mode=TwoWay}"
+                         Grid.Row="1"
+                         Grid.Column="1"
+                         Margin="6,0" />
+                                    <TextBlock Text="mm"
+                           Grid.Row="1"
+                           Grid.Column="2"
+                           HorizontalAlignment="Right" />
+                                    <TextBlock Text="{lex:Loc CC2上限}"
+                           Grid.Row="2"
+                           Grid.Column="0"
+                           HorizontalAlignment="Right" />
+                                    <TextBox Text="{Binding SelectProduct.GlobalParamEx.CC2UpLimit,Mode=TwoWay}"
+                         Grid.Row="2"
+                         Grid.Column="1"
+                         Margin="6,0" />
+                                    <TextBlock Text="mm"
+                           Grid.Row="2"
+                           Grid.Column="2"
+                           HorizontalAlignment="Right" />
+                                    <TextBlock Text="{lex:Loc CC2下限}"
+                           Grid.Row="3"
+                           Grid.Column="0"
+                           HorizontalAlignment="Right" />
+                                    <TextBox Text="{Binding SelectProduct.GlobalParamEx.CC2DownLimit,Mode=TwoWay}"
+                         Grid.Row="3"
+                         Grid.Column="1"
+                         Margin="6,0" />
+                                    <TextBlock Text="mm"
+                           Grid.Row="3"
+                           Grid.Column="2"
+                           HorizontalAlignment="Right" />
+                                </Grid>
+                            </GroupBox>
+                        </StackPanel>
+                    </ScrollViewer>
+                </Grid>
+
+                <Grid Grid.Column="2"
+                      IsEnabled="{Binding IsAllowEdit}"
+                      Margin="10"
+                      HorizontalAlignment="Center"
+                      VerticalAlignment="Center">
 
                     <Grid.RowDefinitions>
                         <RowDefinition Height="auto" />
@@ -181,7 +261,8 @@
                                               Minimum="1"
                                               StringFormat="{}{0:N0} %"
                                               Value="{Binding SelectProduct.Speed,Mode=TwoWay}" />
-                    <!--PTP加减速度--><!--
+                    <!--PTP加减速度-->
+                    <!--
                     <TextBlock Grid.Row="1"
                                Grid.Column="0"
                                Text="{lex:Loc PTP加减速度,Converter={StaticResource StringFormatConverter},ConverterParameter='{}{0}: '}" />
@@ -193,7 +274,9 @@
                                               StringFormat="{}{0:N0} %"
                                               Value="{Binding SelectProduct.Accel,Mode=TwoWay}" />
 
-                    --><!--CP速度--><!--
+                    -->
+                    <!--CP速度-->
+                    <!--
                     <TextBlock Grid.Row="2"
                                Grid.Column="0"
                                Text="{lex:Loc CP速度,Converter={StaticResource StringFormatConverter},ConverterParameter='{}{0}: '}" />
@@ -204,7 +287,9 @@
                                               Minimum="1"
                                               StringFormat="{}{0:N0} mm/s"
                                               Value="{Binding SelectProduct.Speeds,Mode=TwoWay}" />
-                    --><!--CP加减速度--><!--
+                    -->
+                    <!--CP加减速度-->
+                    <!--
                     <TextBlock Grid.Row="3"
                                Grid.Column="0"
                                Text="{lex:Loc CP加减速度,Converter={StaticResource StringFormatConverter},ConverterParameter='{}{0}: '}" />
@@ -216,7 +301,9 @@
                                               StringFormat="{}{0:N0} mm/s²"
                                               Value="{Binding SelectProduct.Accels,Mode=TwoWay}" />
 
-                    --><!--功率--><!--
+                    -->
+                    <!--功率-->
+                    <!--
                     <TextBlock Grid.Row="4"
                                Grid.Column="0"
                                Text="{lex:Loc 功率,Converter={StaticResource StringFormatConverter},ConverterParameter='{}{0}: '}" />
@@ -225,7 +312,9 @@
                               Content="{lex:Loc 高功率}"
                               IsChecked="{Binding SelectProduct.Power}" />
 
-                    --><!--二次相机功能--><!--
+                    -->
+                    <!--二次相机功能-->
+                    <!--
                     <TextBlock Grid.Row="5"
                                Grid.Column="0"
                                Text="{lex:Loc 视觉引导模式,Converter={StaticResource StringFormatConverter},ConverterParameter='{}{0}: '}" />
@@ -350,7 +439,7 @@
                     </ComboBox>
                 </Grid>
             </Grid>
-            
+
         </materialDesign:DrawerHost>
 
 

+ 11 - 1
TeamAAS-VM/Views/SettingView.xaml

@@ -2713,7 +2713,17 @@
                                       HorizontalAlignment="Right"
                                       FontSize="{DynamicResource Font.Size.Body3}"
                                       Margin="0,0,6,0">是否通过零件码判断螺丝型号</CheckBox>
-                            <TextBox MinWidth="300"
+                            <CheckBox IsChecked="{Binding IsBasePartOpenLight,Mode=TwoWay}"
+                                    VerticalAlignment="Center"
+                                    HorizontalAlignment="Right"
+                                    FontSize="{DynamicResource Font.Size.Body3}"
+                                    Margin="0,0,6,0">是否启用最后一次拍照关闭光源</CheckBox>
+                            <CheckBox IsChecked="{Binding IsBasePartOpenLightKB,Mode=TwoWay}"
+                                      VerticalAlignment="Center"
+                                      HorizontalAlignment="Right"
+                                      FontSize="{DynamicResource Font.Size.Body3}"
+                                      Margin="0,0,6,0">是否启用KB复检</CheckBox>
+                            <TextBox MinWidth="280"
                                      Text="{Binding ChooseScrewModel,Mode=TwoWay}"
                                      ToolTip="螺丝型号判断,如******123**,*为忽略字符" />