فهرست منبع

增加锁付拍照点位,锁付点位,复检点位可选写入plc,需保证每个点位启用或关闭相同,默认为启用,版本更新到1.3.0.3

KWD 6 ماه پیش
والد
کامیت
c8075d6a59

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

@@ -22,6 +22,7 @@ using TeamAAS_VP.Enums;
 using TeamAAS_VP.Events;
 using TeamAAS_VP.Interfaces;
 using TeamAAS_VP.Models;
+using TeamAAS_VP.Models.PLC;
 using TeamAAS_VP.Models.Torque;
 using TeamAAS_VP.Resources.Languages;
 using TouchSocket.Core;
@@ -1224,24 +1225,40 @@ namespace TeamAAS_VP.Core
             }
             if (current.ScrewCameraPoints != null && current.ScrewCameraPoints.Count > 0)
             {
+                int index = 0;
                 foreach (var item in current.ScrewCameraPoints)
                 {
-                    await item.WriteToPlcAddress(addressConfig.Out_ScrewCamera, plc);
+                    //根据使用的点位进行排序
+                    if (item.IsUse)
+                    {
+                        index++;
+                        await item.WriteToPlcAddress(addressConfig.Out_ScrewCamera, plc, index);
+                    }
                 }
             }
             if (current.ScrewPoints != null && current.ScrewPoints.Count > 0)
             {
+                int index = 0;
                 foreach (var item in current.ScrewPoints)
                 {
-                    await item.WriteToPlcAddressEx(addressConfig.Out_Screw, plc);
+                    if (item.IsUse)
+                    {
+                        index++;
+                        await item.WriteToPlcAddressEx(addressConfig.Out_Screw, plc, index);
+                    }
                 }
-                await plc.WriteNodeAsync(addressConfig.Out_WorkNum.Address, (Int16)current.ScrewPoints.Count);
+                await plc.WriteNodeAsync(addressConfig.Out_WorkNum.Address, (Int16)index);
             }
             if (current.CheckCameraPoints != null && current.CheckCameraPoints.Count > 0)
             {
+                int index = 0;
                 foreach (var item in current.CheckCameraPoints)
                 {
-                    await item.WriteToPlcAddress(addressConfig.Out_CheckCamera, plc);
+                    if (item.IsUse)
+                    {
+                        index++;
+                        await item.WriteToPlcAddress(addressConfig.Out_CheckCamera, plc,index);
+                    }
                 }
             }
             if (current.QrCodePoints != null && current.QrCodePoints.Count > 0)
@@ -1499,8 +1516,17 @@ namespace TeamAAS_VP.Core
                             //视觉流程ID
                             Guid procedureId = currentProduct.MoveDownCameraLockPhotoProcedureId;
 
+                            List<PlcPoint> plcPoints = new List<PlcPoint>();
+                            foreach (var item in currentProduct.ScrewCameraPoints)
+                            {
+                                if (item.IsUse)
+                                {
+                                    plcPoints.Add(item);
+                                }
+                            }
+
                             //获取锁付拍照的点位
-                            var pos = currentProduct.ScrewCameraPoints.FirstOrDefault(p => p.Number == cameraIndex);
+                            var pos = plcPoints[cameraIndex-1];
                             if (pos != null)
                             {
                                 procedureId = pos.VisionProcessID;
@@ -1579,10 +1605,20 @@ namespace TeamAAS_VP.Core
                             Int16 cameraIndex = plc.ReadNode<Int16>(addressConfig.In_UPCameracheckNum.Address);
                             SendTaskMessage(string.Format(Lang.编号0, cameraIndex), MessageLevel.Info);
 
+                            //获取锁付拍照的点位
+                            List<PlcPoint> plcPoints = new List<PlcPoint>();
+                            foreach (var item in currentProduct.CheckCameraPoints)
+                            {
+                                if (item.IsUse)
+                                {
+                                    plcPoints.Add(item);
+                                }
+                            }
+
                             //视觉流程ID
                             Guid procedureId = Guid.Empty;
                             //获取锁付拍照的点位
-                            var pos = currentProduct.CheckCameraPoints.FirstOrDefault(p => p.Number == cameraIndex);
+                            var pos = plcPoints[cameraIndex-1];
                             if (pos != null)
                             {
                                 procedureId = pos.VisionProcessID;
@@ -1898,7 +1934,15 @@ namespace TeamAAS_VP.Core
                             //拍1打1 
                             if (systemConfig.WorkMode == 1)
                             {
-                                var point = currentProduct.ScrewPoints.FirstOrDefault(p => p.Number == positionIndex);
+                                List<PlcPoint> plcPoints = new List<PlcPoint>(); 
+                                foreach (var item in currentProduct.ScrewPoints)
+                                {
+                                    if (item.IsUse)
+                                    {
+                                        plcPoints.Add(item);
+                                    }
+                                }
+                                var point = plcPoints[positionIndex-1];
                                 if (point == null)
                                 {
                                     SendTaskMessage($"点:{positionIndex}不存在", MessageLevel.Info);
@@ -1909,7 +1953,7 @@ namespace TeamAAS_VP.Core
                                 point.X_Position = UpCameraPutResults[1].X + DowmCameraResults[1].X;
                                 point.Y_Position = UpCameraPutResults[1].Y + DowmCameraResults[1].Y;
                                 SendTaskMessage($"点:{positionIndex},{point.X_Position:F3},{point.Y_Position:F4}", MessageLevel.Info);
-                                await point.WriteToPlcAddress(addressConfig.Out_Screw, plc);
+                                await point.WriteToPlcAddress(addressConfig.Out_Screw, plc, positionIndex);
                             }
                             //拍1打所有
                             else if (systemConfig.WorkMode == 2)
@@ -3264,7 +3308,7 @@ namespace TeamAAS_VP.Core
         #endregion
 
         #region 压缩图片文件夹
-        public async void CompressionImage(string sourcePath, string zipname,string fixid)
+        public async void CompressionImage(string sourcePath, string zipname, string fixid)
         {
             string zipPath = "";
             try

+ 15 - 5
TeamAAS-VM/Models/PLC/PlcPoint.cs

@@ -203,6 +203,15 @@ namespace TeamAAS_VP.Models.PLC
             set { SetProperty(ref _VisionProcessID, value); }
         }
 
+        private bool _IsUse = true;
+
+        public bool IsUse
+        {
+            get { return _IsUse; }
+            set { SetProperty(ref _IsUse, value); }
+        }
+
+
         private string _VisionProcessName;
         /// <summary>
         /// 视觉流程名称
@@ -298,7 +307,7 @@ namespace TeamAAS_VP.Models.PLC
             Z_Stop_Offset = 0;
             U_Offset = 0;
             R_Offset = 0;
-
+            IsUse = true;
         }
 
         public PlcPoint Clone()
@@ -330,7 +339,8 @@ namespace TeamAAS_VP.Models.PLC
                 Z_Start_Offset = this.Z_Start_Offset,
                 Z_Stop_Offset = this.Z_Stop_Offset,
                 U_Offset = this.U_Offset,
-                R_Offset = this.R_Offset
+                R_Offset = this.R_Offset,
+                IsUse = this.IsUse,
             };
         }
 
@@ -394,7 +404,7 @@ namespace TeamAAS_VP.Models.PLC
         /// <param name="plcAddress"></param>
         /// <param name="pLC"></param>
         /// <returns></returns>
-        public async Task<bool> WriteToPlcAddressEx(PlcPointAddress plcAddress, OpcUaClientPLC pLC)
+        public async Task<bool> WriteToPlcAddressEx(PlcPointAddress plcAddress, OpcUaClientPLC pLC,int index)
         {
             Dictionary<string, object> nodeValues = new Dictionary<string, object>();
             //nodeValues.Add(string.Format(plcAddress.X_Position.Address, Number), X_Position);
@@ -410,8 +420,8 @@ namespace TeamAAS_VP.Models.PLC
             //nodeValues.Add(string.Format(plcAddress.R_Position.Address, Number), R_Position);
             //nodeValues.Add(string.Format(plcAddress.R_Velocity.Address, Number), R_Velocity);
             //nodeValues.Add(string.Format(plcAddress.Torque.Address, Number), Torque);
-            nodeValues.Add(string.Format(plcAddress.Feeder.Address, Number), Feeder);
-            nodeValues.Add(string.Format(plcAddress.ScrewProNum.Address, Number), ScrewProNum);
+            nodeValues.Add(string.Format(plcAddress.Feeder.Address, index), Feeder);
+            nodeValues.Add(string.Format(plcAddress.ScrewProNum.Address, index), ScrewProNum);
             return await pLC.WriteNodesAsync(nodeValues);
         }
     }

+ 0 - 15
TeamAAS-VM/Services/RemoteCommandService.cs

@@ -1870,21 +1870,6 @@ namespace TeamAAS_VP.Services
                         continue;
                     }
 
-                    //如果机器人坐标为空,则获取当前机器人坐标
-                    if (robotCoord == null)
-                    {
-                        var robot = _robotService.GetAllRobots().FirstOrDefault();
-                        if (robot != null)
-                        {
-                            var pos = await robot.GetRobotPosAsync();
-                            robotCoord = new double[] { pos.X, pos.Y, pos.Z };
-                        }
-                        else
-                        {
-                            robotCoord = new double[] { 0, 0, 0 };
-                        }
-                    }
-
                     if (!outputCollection.Contains("Found"))
                     {
                         SendTaskMessage(Lang.未找到视觉输出结果, MessageLevel.Error);

+ 5 - 2
TeamAAS-VM/Views/Home/ShowVisionRender.xaml.cs

@@ -520,8 +520,11 @@ namespace TeamAAS_VP.Views.Home
                                 formulaName = formulaName.Replace(c, '_');
 
                             string productSN = _productService.CurrentProductCode;
-                            foreach (char c in Path.GetInvalidFileNameChars())
-                                productSN = productSN.Replace(c, '_');
+                            if (string.IsNullOrEmpty(productSN))
+                            {
+                                foreach (char c in Path.GetInvalidFileNameChars())
+                                    productSN = productSN.Replace(c, '_');
+                            }                          
 
                             string resultStr = result ? "OK" : "NG";
                             Originalpath = $"{path}\\Original\\{now:yyyy-MM}\\{now:MM-dd}\\{formulaName}\\{productSN}\\{resultStr}\\{imgName}.bmp";

+ 13 - 0
TeamAAS-VM/Views/Product/PlcPointParams.xaml

@@ -1399,6 +1399,19 @@
                                         </DataGridTemplateColumn.CellTemplate>
                                     </DataGridTemplateColumn>
 
+                                    <DataGridTemplateColumn x:Name="colIsUse"
+                                                            Header="是否启用"
+                                                            MinWidth="60"
+                                                            Width="Auto">
+                                        <DataGridTemplateColumn.CellTemplate>
+                                            <DataTemplate>
+                                                <CheckBox IsChecked="{Binding IsUse,Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"
+                                                          HorizontalAlignment="Center"
+                                                          VerticalAlignment="Center" />
+                                            </DataTemplate>
+                                        </DataGridTemplateColumn.CellTemplate>
+                                    </DataGridTemplateColumn>
+
                                     <DataGridTextColumn Header="{lex:Loc 描述}"
                                                         MinWidth="100"
                                                         Width="200"

+ 5 - 1
TeamAAS-VM/Views/Product/PlcPointParams.xaml.cs

@@ -23,8 +23,9 @@ namespace TeamAAS_VP.Views.Product
             // initialize visibility
             try
             {
-                if (VM != null && colProcedure != null)
+                if (VM != null && colProcedure != null && colIsUse!=null)
                     colProcedure.Visibility = VM.SelectedIndex == 3 ? System.Windows.Visibility.Visible : System.Windows.Visibility.Collapsed;
+                    colIsUse.Visibility = VM.SelectedIndex == 3 ? System.Windows.Visibility.Visible : System.Windows.Visibility.Collapsed;
             }
             catch { }
             this.display.HorizontalScrollBar = false;
@@ -40,10 +41,13 @@ namespace TeamAAS_VP.Views.Product
                 try
                 {
                     var visible = VM.SelectedIndex == 3|| VM.SelectedIndex == 5 ? System.Windows.Visibility.Visible : System.Windows.Visibility.Collapsed;
+                    var Usevisible = VM.SelectedIndex == 3 || VM.SelectedIndex == 4 || VM.SelectedIndex == 5 ? System.Windows.Visibility.Visible : System.Windows.Visibility.Collapsed;
                     this.Dispatcher.BeginInvoke(new Action(() =>
                     {
                         if (colProcedure != null)
                             colProcedure.Visibility = visible;
+                        if (colIsUse != null)
+                            colIsUse.Visibility = Usevisible;
                     }));
                 }
                 catch { }