Browse Source

完善算法

肖奇伟 4 days ago
parent
commit
083579ceb6

+ 28 - 41
SCADA_DAQ/Customer/Machines/SortMachine.cs

@@ -192,10 +192,17 @@ namespace SCADA_DAQ.Customer.Machines
         /// <summary>
         /// 吸盘2中心点坐标
         /// </summary>
-        public Point Cup3Center = new Point((int)CustomerEnv.SortingMacConfigValue.Cup2OriginOffset.X,
+        public Point Cup2Center = new Point((int)CustomerEnv.SortingMacConfigValue.Cup2OriginOffset.X,
                                     (int)CustomerEnv.SortingMacConfigValue.Cup2OriginOffset.Y);
 
 
+        /// <summary>
+        /// 吸盘3中心点坐标
+        /// </summary>
+        public Point Cup3Center = new Point((int)CustomerEnv.SortingMacConfigValue.Cup3OriginOffset.X,
+                                    (int)CustomerEnv.SortingMacConfigValue.Cup3OriginOffset.Y);
+
+
         /// <summary>
         /// 旋转1后新坐标
         /// </summary>
@@ -251,15 +258,12 @@ namespace SCADA_DAQ.Customer.Machines
                     end = true;
                     if (CurrentCycDoc != null)
                     {
-
                         ExistSmallBoard(CurrentCycDoc);
-
                     }
                     else
                     {
                         MessageBox.Show($"参数页面中的'单机运行时cyc文件'为空!");
                     }
-
                 }
                 else
                 {
@@ -326,26 +330,27 @@ namespace SCADA_DAQ.Customer.Machines
                     //var Cup3Center = new Point(135, -155);
                     //修改后
 
-
                     if ((CurrentLabel.ActualLength > 550 && CurrentLabel.ActualWidth > 200) ||
-                        (CurrentLabel.ActualWidth > 550 && CurrentLabel.ActualLength > 200)
-                        )
+                        (CurrentLabel.ActualWidth > 550 && CurrentLabel.ActualLength > 200))
                     {
                         BoardInfo.CupIndex = 2;
                         if (CurrentLabel.ActualWidth > CurrentLabel.ActualLength)
                         {
                             BoardInfo.Rotation = -90;
                             BoardInfo.ReleaseY = CurrentLabel.ActualLength / 2 - 150;
-                            //releaseY = CurrentLabel.ActualLength / 2 - 140;
 
-                        }
+                            var cup2NewCenter = new Point(Cup2Center.Y * -1, (double)Cup2Center.X);  //旋转后的坐标
+                            BoardInfo.CupCenter = new Point(BoardInfo.CupCenter.X - cup2NewCenter.X, BoardInfo.CupCenter.Y - cup2NewCenter.Y);
+                            //releaseY = CurrentLabel.ActualLength / 2 - 140;
+                            CupNewCenter = cup2NewCenter;
+                           }
                         else
                         {
                             BoardInfo.ReleaseY = CurrentLabel.ActualWidth / 2 - 150;
-                            //BoardInfo.ReleaseY = CurrentLabel.ActualWidth / 2 - 140;
-
+                            var cup2NewCenter = new Point(Cup1Center.X, Cup1Center.Y);  //旋转后的坐标
+                            BoardInfo.CupCenter = new Point(BoardInfo.CupCenter.X - cup2NewCenter.X, BoardInfo.CupCenter.Y - cup2NewCenter.Y);
+                            CupNewCenter = cup2NewCenter;
                         }
-                        CupNewCenter = new Point(0, 0);
                     }
                     else
                     {
@@ -369,7 +374,6 @@ namespace SCADA_DAQ.Customer.Machines
                                     BoardInfo.CupCenter = new Point(BoardInfo.CupCenter.X - cup1NewCenter.X, BoardInfo.CupCenter.Y - cup1NewCenter.Y);
                                     BoardInfo.ReleaseY = CurrentLabel.ActualWidth / 2 - 30;
                                     CupNewCenter = cup1NewCenter;
-                                    //BoardInfo.ReleaseY = CurrentLabel.ActualWidth / 2 - 170;
                                 }
                             }
                             else
@@ -377,18 +381,12 @@ namespace SCADA_DAQ.Customer.Machines
                                 BoardInfo.Rotation = 90;
                                 var cup1NewCenter = new Point(Cup1Center.Y, -1 * (double)Cup1Center.X);  //旋转后的坐标
                                 CupNewCenter = cup1NewCenter;
-                                //cup3NewCenter.Offset(100, 32.5);   //补偿夹具尺寸
                                 BoardInfo.CupCenter = new Point(BoardInfo.CupCenter.X - cup1NewCenter.X, BoardInfo.CupCenter.Y - cup1NewCenter.Y);
-                                //BoardInfo.ReleaseY = CurrentLabel.ActualWidth / 2;
                                 BoardInfo.ReleaseY = CurrentLabel.ActualLength / 2 - 180;
-                                //BoardInfo.ReleaseY = CurrentLabel.ActualWidth / 2 - 20;
-
-
                             }
                         }
                         else if (BoardInfo.CupIndex == 3)
                         {
-
                             if (CenterX <= 600)
                             {
                                 if (CurrentLabel.ActualLength < CurrentLabel.ActualWidth)
@@ -397,14 +395,10 @@ namespace SCADA_DAQ.Customer.Machines
                                     var cup3NewCenter = new Point(Cup3Center.Y * -1, (double)Cup3Center.X);  //旋转后的坐标
                                     BoardInfo.CupCenter = new Point(BoardInfo.CupCenter.X - cup3NewCenter.X, BoardInfo.CupCenter.Y - cup3NewCenter.Y);
                                     CupNewCenter = cup3NewCenter;
-
                                 }
                                 //BoardInfo.ReleaseY = CurrentLabel.ActualWidth / 2;
                                 BoardInfo.ReleaseY = CurrentLabel.ActualLength / 2 - 180;
-
                                 //BoardInfo.ReleaseY = CurrentLabel.ActualWidth / 2 - 20;
-
-
                             }
                             else
                             {
@@ -413,9 +407,7 @@ namespace SCADA_DAQ.Customer.Machines
                                 //BoardInfo.ReleaseY = CurrentLabel.ActualWidth / 2 + 500;
                                 BoardInfo.ReleaseY = CurrentLabel.ActualWidth / 2 - 180;
                                 CupNewCenter = cup3NewCenter;
-
                                 //BoardInfo.ReleaseY = CurrentLabel.ActualWidth / 2 - 20;
-
                             }
                         }
                         else
@@ -469,7 +461,7 @@ namespace SCADA_DAQ.Customer.Machines
                                 var labels = JsonHelper.JsonDeserialize<CameraModels>(_strContent);  //获取标签位置
                                 var codes = labels.ID.Split(',');
                                 var labelModels = new List<LabelModel>();
-                                var minCount =Math.Min( Math.Min(labels.X.Count, labels.R.Count),codes.Length);
+                                var minCount = Math.Min(Math.Min(labels.X.Count, labels.R.Count), codes.Length);
                                 for (int i = 0; i < minCount; i++)
                                 {
                                     labelModels.Add(new LabelModel { X = labels.X[i], Y = labels.Y[i], R = labels.R[i], CodeID = codes[i] });
@@ -495,7 +487,7 @@ namespace SCADA_DAQ.Customer.Machines
                                             }
                                         }
                                     }
-                                    
+
                                 }
 
                             }
@@ -529,12 +521,7 @@ namespace SCADA_DAQ.Customer.Machines
                                     GetListenReg(Tag_Reset).SetBit();
                                 }
                             }
-
-
-
-
                         }
-
                     }
                 }
                 else
@@ -608,14 +595,14 @@ namespace SCADA_DAQ.Customer.Machines
                             //都放在输送辊中心点,无需偏移
                             BoardInfo.ReleaseY = 0;
                             GetListenReg(Tag_CaptureX).WriteObject(null,
-                            moveX + (float)xOffset,  //D1512
-                            moveY + (float)yOffset,  //D1514
-                            (float)rotation,     //D1516
-                            (short)1, // D1518
-                            (short)BoardInfo.CupIndex,  // D1519.
-                            (float)18.0,      // D1520 //厚度
-                            (float)470 + releaseXOffset,       // D1522 放板位置X
-                            (float)BoardInfo.ReleaseY,  // D1524 放板位置Y
+                            moveX + (float)xOffset,         //D1512
+                            moveY + (float)yOffset,         //D1514
+                            (float)rotation,                //D1516
+                            (short)1,                       // D1518
+                            (short)BoardInfo.CupIndex,      // D1519.
+                            (float)18.0,                    // D1520 //厚度
+                            (float)470 + releaseXOffset,    // D1522 放板位置X
+                            (float)BoardInfo.ReleaseY,      // D1524 放板位置Y
                             (float)releaseRotation          //放板角度
                             );
 
@@ -722,7 +709,7 @@ namespace SCADA_DAQ.Customer.Machines
                 {
                     t.Status = Models.TaskStatus.Finished;
                 }
-                
+
 
                 GetListenReg(Tag_SmallBoardManualConfirm).SetBit();
             }

+ 22 - 3
SCADA_DAQ/Customer/Models/SortingModel/SortingMacSettingModel.cs

@@ -277,12 +277,11 @@ namespace SCADA_DAQ.Customer.Models.SortingModel
         }
         private CenterPoint _Cup1OriginOffset = new CenterPoint();
 
-
         /// <summary>
-        /// 吸盘3坐标偏移
+        /// 吸盘2坐标偏移
         /// </summary>
         /// 
-        [AutoViewProperty("吸盘3中心点坐标", Icon = "ImageFilterCenterFocus")]
+        [AutoViewProperty("吸盘2中心点坐标", Icon = "ImageFilterCenterFocus")]
         public CenterPoint Cup2OriginOffset
         {
             get { return _Cup2OriginOffset; }
@@ -298,6 +297,26 @@ namespace SCADA_DAQ.Customer.Models.SortingModel
         private CenterPoint _Cup2OriginOffset = new CenterPoint();
 
 
+        /// <summary>
+        /// 吸盘3坐标偏移
+        /// </summary>
+        /// 
+        [AutoViewProperty("吸盘3中心点坐标", Icon = "ImageFilterCenterFocus")]
+        public CenterPoint Cup3OriginOffset
+        {
+            get { return _Cup3OriginOffset; }
+            set
+            {
+                if (value != _Cup3OriginOffset)
+                {
+                    _Cup3OriginOffset = value;
+                    OnPropertyChanged(nameof(Cup3OriginOffset));
+                }
+            }
+        }
+        private CenterPoint _Cup3OriginOffset = new CenterPoint();
+
+
     }
 
     /// <summary>

+ 13 - 5
SCADA_DAQ/Customer/Views/Menu/UctFrmSorting/UctFrmSortingMain.xaml.cs

@@ -32,8 +32,11 @@ namespace SCADA_DAQ.Customer.Views.Menu.UctFrmSorting
     public partial class UctFrmSortingMain : BaseUctFrm
     {
         SortMachine plc;
-        UctCup cup;  //吸盘
-        Point cupOrig = new Point(-165, -255);
+        //UctCup cup;  //吸盘
+        //Point cupOrig = new Point(-165, -255);
+
+        UctCupNew cup;  //吸盘
+        Point cupOrig = new Point(-170, -254);
 
         /// <summary>
         /// 
@@ -198,9 +201,14 @@ namespace SCADA_DAQ.Customer.Views.Menu.UctFrmSorting
                 index++;
             }
 
-            cup = new UctCup() { Height = 510, Width = 330 };
-            Canvas.SetLeft(cup, -165);
-            Canvas.SetTop(cup, -255);
+            //cup = new UctCup() { Height = 510, Width = 330 };
+            //Canvas.SetLeft(cup, -165);
+            //Canvas.SetTop(cup, -255);
+
+            cup = new UctCupNew() { Height = 508, Width = 340 };
+            Canvas.SetLeft(cup, -170);
+            Canvas.SetTop(cup, -254);
+
             Board.Children.Add(cup);
 
             cup.CupStatus = 0;

+ 77 - 0
SCADA_DAQ/Customer/Views/Uct/UcrSorting/UctCupNew.xaml

@@ -0,0 +1,77 @@
+<UserControl x:Class="SCADA_DAQ.Customer.Views.Uct.UctCupNew"
+             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
+             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
+             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
+             xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
+             xmlns:local="clr-namespace:SCADA_DAQ.Customer.Views.Uct"
+             mc:Ignorable="d" 
+             x:Name="this"
+             d:DesignHeight="558.8" d:DesignWidth="742.4" FontSize="35">
+    <Canvas Height="510" Width="340" Background="#1F000000" RenderTransformOrigin="0.5,0.5">
+
+        <Label Width="130" Height="510"  HorizontalContentAlignment="Center" VerticalContentAlignment="Center" Canvas.Left="209" Content="2" RenderTransformOrigin="0.5,0.5" >
+            <Label.RenderTransform>
+                <TransformGroup>
+                    <ScaleTransform ScaleY="-1"/>
+                    <SkewTransform/>
+                    <RotateTransform />
+                    <TranslateTransform/>
+                </TransformGroup>
+            </Label.RenderTransform>
+            <Label.Style>
+                <Style TargetType="Label">
+                    <Setter Property="Background" Value="#1F000000"/>
+                    <Style.Triggers>
+                        <DataTrigger Binding="{Binding CupStatus,ElementName=this}" Value="2">
+                            <Setter Property="Background" Value="Lime"/>
+                        </DataTrigger>
+                    </Style.Triggers>
+                </Style>
+            </Label.Style>
+        </Label>
+
+        <Label Width="65" Height="200" HorizontalContentAlignment="Center" VerticalContentAlignment="Center" BorderThickness="1" Content="3" VerticalAlignment="Top" RenderTransformOrigin="0.5,0.5">
+            <Label.RenderTransform>
+                <TransformGroup>
+                    <ScaleTransform ScaleY="-1"/>
+                    <SkewTransform/>
+                    <RotateTransform/>
+                    <TranslateTransform/>
+                </TransformGroup>
+            </Label.RenderTransform>
+            <Label.Style>
+                <Style TargetType="Label">
+                    <Setter Property="Background" Value="#1F000000"/>
+                    <Style.Triggers>
+                        <DataTrigger Binding="{Binding CupStatus,ElementName=this}" Value="3">
+                            <Setter Property="Background" Value="Lime"/>
+                        </DataTrigger>
+                    </Style.Triggers>
+                </Style>
+            </Label.Style>
+
+        </Label>
+
+        
+        <Label Width="65" Height="200" HorizontalContentAlignment="Center" VerticalContentAlignment="Center" Content="1" RenderTransformOrigin="0.5,0.5" Canvas.Bottom="0" HorizontalAlignment="Center" VerticalAlignment="Bottom">
+            <Label.RenderTransform>
+                <TransformGroup>
+                    <ScaleTransform ScaleY="-1"/>
+                    <SkewTransform/>
+                    <RotateTransform/>
+                    <TranslateTransform/>
+                </TransformGroup>
+            </Label.RenderTransform>
+            <Label.Style>
+                <Style TargetType="Label">
+                    <Setter Property="Background" Value="#1F000000"/>
+                    <Style.Triggers>
+                        <DataTrigger Binding="{Binding CupStatus,ElementName=this}" Value="1">
+                            <Setter Property="Background" Value="Lime"/>
+                        </DataTrigger>
+                    </Style.Triggers>
+                </Style>
+            </Label.Style>
+        </Label>
+    </Canvas>
+</UserControl>

+ 51 - 0
SCADA_DAQ/Customer/Views/Uct/UcrSorting/UctCupNew.xaml.cs

@@ -0,0 +1,51 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using System.Windows;
+using System.Windows.Controls;
+using System.Windows.Data;
+using System.Windows.Documents;
+using System.Windows.Input;
+using System.Windows.Media;
+using System.Windows.Media.Imaging;
+using System.Windows.Navigation;
+using System.Windows.Shapes;
+
+namespace SCADA_DAQ.Customer.Views.Uct
+{
+    /// <summary>
+    /// UctCup.xaml 的交互逻辑
+    /// </summary>
+    public partial class UctCupNew : UserControl
+    {
+        /// <summary>
+        /// 
+        /// </summary>
+        public UctCupNew()
+        {
+            InitializeComponent();
+        }
+
+        /// <summary>
+        /// 
+        /// </summary>
+        public int CupStatus
+        {
+            get { return (int)GetValue(CupStatusProperty); }
+            set { SetValue(CupStatusProperty, value); }
+        }
+        /// <summary>
+        /// 
+        /// </summary>
+        // Using a DependencyProperty as the backing store for CupStatus.  This enables animation, styling, binding, etc...
+        public static readonly DependencyProperty CupStatusProperty =
+            DependencyProperty.Register("CupStatus", typeof(int), typeof(UctCupNew), new PropertyMetadata(0));
+
+
+
+
+
+    }
+}

+ 3 - 0
SCADA_DAQ/SCADA_DAQ.csproj

@@ -234,6 +234,9 @@
   </ItemGroup>
 
   <ItemGroup>
+    <Compile Update="Customer\Views\Uct\UcrSorting\UctCupNew.xaml.cs">
+      <SubType>Code</SubType>
+    </Compile>
     <Compile Update="Customer\Views\Uct\UctPackageSorting\UctCylinderOn.xaml.cs">
       <SubType>Code</SubType>
     </Compile>

+ 3 - 0
SCADA_DAQ/SCADA_DAQ.csproj.user

@@ -115,6 +115,9 @@
     <Page Update="Customer\UctFrmParameterSet.xaml">
       <SubType>Designer</SubType>
     </Page>
+    <Page Update="Customer\Views\Uct\UcrSorting\UctCupNew.xaml">
+      <SubType>Designer</SubType>
+    </Page>
     <Page Update="Customer\Views\Uct\UctGantry\UctGantryCurentPosition.xaml">
       <SubType>Designer</SubType>
     </Page>