844184169 6 месяцев назад
Родитель
Сommit
86a06a7556

+ 37 - 9
TeamAAS-VM/Core/Management.cs

@@ -1208,7 +1208,7 @@ namespace TeamAAS_VP.Core
             {
                 foreach (var item in current.PickPoints)
                 {
-                    await item.WriteToPlcAddress(addressConfig.Out_Pick, plc);
+                    await item.WriteToPlcAddress(addressConfig.Out_Pick, plc,item.Feeder);
                 }
             }
             if (current.SecPosCameraPoints != null && current.SecPosCameraPoints.Count > 0)
@@ -1267,6 +1267,8 @@ namespace TeamAAS_VP.Core
         Int16[] _LastMesCheck = new Int16[10];
         Int16 _LastPickINC = 0;
         DateTime[] _LastMesCheckTime = new DateTime[10];
+        string ProductMainSN = "";//产品主sn
+        string wo = "";
         /// <summary>
         /// PLC命令触发时
         /// </summary>
@@ -1582,9 +1584,19 @@ namespace TeamAAS_VP.Core
                                 return;
                             }
 
+                            // 获取机器人当前坐标
+                            var robot = _robotService.GetAllRobots().FirstOrDefault();
+                            if (robot == null)
+                            {
+                                SendTaskMessage("未找到机器人无法执行 上相机检测拍照视觉任务", MessageLevel.Alarm);
+                                await plc.WriteNodeAsync(addressConfig.Out_UpCameraPutStatus.Address, (Int16)2);
+                                return;
+                            }
+                            var currentPosition = robot.GetRobotPos();
+
                             // 执行视觉任务
                             var _cts = new CancellationTokenSource();
-                            var visionResult = await _remoteCommandService.ExecutePhotoGetSinglePoint(process, null, null, _cts.Token, cameraIndex, null);
+                            var visionResult = await _remoteCommandService.ExecutePhotoGetSinglePoint(process, null, new double[] { currentPosition.X, currentPosition.Y, currentPosition.U }, _cts.Token, cameraIndex, null);
                             if (visionResult.IsSucceed)
                             {
                                 await plc.WriteNodeAsync(addressConfig.Out_UPCameracheckStatus.Address, (Int16)1);
@@ -1876,7 +1888,7 @@ namespace TeamAAS_VP.Core
                                     SUPPLIER_NAME = cdata.SUPPLIER_NAME,
                                     COMMODITY_TYPE = cdata.COMMODITY_TYPE,
                                     REVISION = cdata.REVISION,
-                                    WO = cdata.WO,
+                                    WO = wo,
                                     MFG_LOT = cdata.MFG_LOT,
                                     MFG_ASSY_LINE = cdata.MFG_ASSY_LINE,
                                     PROCESS_OUTCOME = torqueRes ? "PASS" : "FAIL",
@@ -1897,7 +1909,7 @@ namespace TeamAAS_VP.Core
                                     SUPPLIER_NAME = cdata.SUPPLIER_NAME,
                                     COMMODITY_TYPE = cdata.COMMODITY_TYPE,
                                     REVISION = cdata.REVISION,
-                                    WO = cdata.WO,
+                                    WO = wo,
                                     MFG_LOT = cdata.MFG_LOT,
                                     MFG_ASSY_LINE = cdata.MFG_ASSY_LINE,
                                     PROCESS_OUTCOME = turnRes ? "PASS" : "FAIL",
@@ -1918,7 +1930,7 @@ namespace TeamAAS_VP.Core
                                     SUPPLIER_NAME = cdata.SUPPLIER_NAME,
                                     COMMODITY_TYPE = cdata.COMMODITY_TYPE,
                                     REVISION = cdata.REVISION,
-                                    WO = cdata.WO,
+                                    WO = wo,
                                     MFG_LOT = cdata.MFG_LOT,
                                     MFG_ASSY_LINE = cdata.MFG_ASSY_LINE,
                                     PROCESS_OUTCOME = pressureRes ? "PASS" : "FAIL",
@@ -2199,7 +2211,23 @@ namespace TeamAAS_VP.Core
                                         await plc.WriteNodeAsync(string.Format(addressConfig.Out_MesStatus.Address, i), (Int16)1);
 
                                         LogHelper.WriteLogMes($"询问mes成功");
-                                        SendTaskMessage($"询问mes成功", MessageLevel.Debug);
+                                        SendTaskMessage($"询问mes成功:{response}", MessageLevel.Debug);
+                                        if (response != "MES功能未启用!")
+                                        {
+                                            string[] item= response.Split('\n');
+                                            if (item[3].Contains("sn="))
+                                            {
+                                                ProductMainSN = item[3].Replace("sn=", "");
+                                                SendTaskMessage($"产品主sn:{ProductMainSN}", MessageLevel.Info);
+                                            }
+                                            if (item[5].Contains("wo="))
+                                            {
+                                                wo = item[5].Replace("wo=", "");
+                                                SendTaskMessage($"产品主wo:{wo}", MessageLevel.Info);
+                                            }
+                                        }
+                                        LogHelper.WriteLogMes($"询问mes成功");
+                                        SendTaskMessage($"询问mes成功:{response}", MessageLevel.Debug);
                                     }
                                     else
                                     {
@@ -2233,7 +2261,7 @@ namespace TeamAAS_VP.Core
                                         await _systemDatabaseService.RecordProductionAsync(new ProductionRecord()
                                         {
                                             ProductName = currentProduct.Name,
-                                            ProductCode = code,
+                                            ProductCode = ProductMainSN,
                                             DeviceId = i,
                                             DeviceName = "",
                                             Category = resultIndex == 1 ? "OK" : "NG",
@@ -2247,7 +2275,7 @@ namespace TeamAAS_VP.Core
                                     string torque = string.Join(",", torqueList);
                                     string pressure = string.Join(",", pressureList);
                                     string turn = string.Join(",", turnList);
-                                    (bool isSuccess, string response) = await _mesService.SubmitGetAsync(code, "", torque, pressure, turn, resultIndex == 1 ? true : false, _LastMesCheckTime[i], DateTime.UtcNow);
+                                    (bool isSuccess, string response) = await _mesService.SubmitGetAsync(ProductMainSN, "", torque, pressure, turn, resultIndex == 1 ? true : false, _LastMesCheckTime[i], DateTime.UtcNow);
                                     if (isSuccess)
                                     {
                                         LogHelper.WriteLogMes($"上传mes成功");
@@ -2260,7 +2288,7 @@ namespace TeamAAS_VP.Core
                                     }
                                     await plc.WriteNodeAsync(string.Format(addressConfig.Out_MesStatus.Address, i), (Int16)3);
 
-                                    WriteProductLog(lockResultsAll, code, CTtime);
+                                    WriteProductLog(lockResultsAll, ProductMainSN, CTtime);
 
                                     LogHelper.WriteLogMes($"【mes结束ADD】");
                                     SendTaskMessage($"mes结束ADD", MessageLevel.Info);

+ 27 - 0
TeamAAS-VM/Models/PLC/PlcPoint.cs

@@ -361,6 +361,33 @@ namespace TeamAAS_VP.Models.PLC
             return await pLC.WriteNodesAsync(nodeValues);
         }
 
+        /// <summary>
+        /// 将点位数据写入到PLC地址
+        /// </summary>
+        /// <param name="plcAddress"></param>
+        /// <param name="pLC"></param>
+        /// <returns></returns>
+        public async Task<bool> WriteToPlcAddress(PlcPointAddress plcAddress, OpcUaClientPLC pLC,int index)
+        {
+            Dictionary<string, object> nodeValues = new Dictionary<string, object>();
+            nodeValues.Add(string.Format(plcAddress.X_Position.Address, index), X_Position + X_Offset);
+            nodeValues.Add(string.Format(plcAddress.X_Velocity.Address, index), X_Velocity);
+            nodeValues.Add(string.Format(plcAddress.Y_Position.Address, index), Y_Position + Y_Offset);
+            nodeValues.Add(string.Format(plcAddress.Y_Velocity.Address, index), Y_Velocity);
+            nodeValues.Add(string.Format(plcAddress.Z_Position_Start.Address, index), Z_Position_Start + Z_Start_Offset);
+            nodeValues.Add(string.Format(plcAddress.Z_Velocity_Start.Address, index), Z_Velocity_Start);
+            nodeValues.Add(string.Format(plcAddress.Z_Position_Stop.Address, index), Z_Position_Stop + Z_Stop_Offset);
+            nodeValues.Add(string.Format(plcAddress.Z_Velocity_Stop.Address, index), Z_Velocity_Stop);
+            nodeValues.Add(string.Format(plcAddress.U_Position.Address, index), U_Position + U_Offset);
+            nodeValues.Add(string.Format(plcAddress.U_Velocity.Address, index), U_Velocity);
+            nodeValues.Add(string.Format(plcAddress.R_Position.Address, index), R_Position + R_Offset);
+            nodeValues.Add(string.Format(plcAddress.R_Velocity.Address, index), R_Velocity);
+            nodeValues.Add(string.Format(plcAddress.Torque.Address, index), Torque);
+            nodeValues.Add(string.Format(plcAddress.Feeder.Address, index), Feeder);
+            nodeValues.Add(string.Format(plcAddress.ScrewProNum.Address, index), ScrewProNum);
+            return await pLC.WriteNodesAsync(nodeValues);
+        }
+
         /// <summary>
         /// 将点位数据写入到PLC地址
         /// </summary>

+ 2 - 2
TeamAAS-VM/Services/MesService.cs

@@ -102,11 +102,11 @@ namespace TeamAAS_VP.Services
             string url = "";
             if (device.F == "PTL")
             {
-                url = $"{device.MesUrl}?c=QUERY_RECORD&line={device.Line}&station={device.Station}&fixtureid={device.FixtureId}&sn={sn}&comp={device.comp}:{comp}&p=unit_process_check,message,model";
+                url = $"{device.MesUrl}?c=QUERY_RECORD&line={device.Line}&station={device.Station}&fixtureid={device.FixtureId}&sn={sn}&comp={device.comp}:{comp}&p=unit_process_check,message,model,sn,wo";
             }
             else
             {
-                url = $"{device.MesUrl}?c=QUERY_RECORD&line={device.Line}&station={device.Station}&fixtureid={device.FixtureId}&sn={sn}&p=unit_process_check,message,model";
+                url = $"{device.MesUrl}?c=QUERY_RECORD&line={device.Line}&station={device.Station}&fixtureid={device.FixtureId}&sn={sn}&p=unit_process_check,message,model,sn,wo";
             }
             
             LogHelper.WriteLogMes($"¡¾Ñ¯ÎÊURL¡¿{url}");

+ 2 - 2
TeamAAS-VM/Views/SettingView.xaml

@@ -410,7 +410,7 @@
                                  Text="{Binding DataInfo.REVISION, Mode=TwoWay}"
                                  Margin="6" />
 
-                        <TextBlock Grid.Row="6"
+                        <!--<TextBlock Grid.Row="6"
                                    Grid.Column="0"
                                    Text="WO#:"
                                    HorizontalAlignment="Right"
@@ -418,7 +418,7 @@
                         <TextBox Grid.Row="6"
                                  Grid.Column="1"
                                  Text="{Binding DataInfo.WO, Mode=TwoWay}"
-                                 Margin="6" />
+                                 Margin="6" />-->
 
                         <TextBlock Grid.Row="7"
                                    Grid.Column="0"