2 Commits d8d442ad4d ... be4b1f67e9

Author SHA1 Message Date
  陈子杰 be4b1f67e9 Merge branch '75豪德众益洋智能家居' of http://www.imaodou.com.cn:30030/c_jack/EICP3.0_69 into 75豪德众益洋智能家居 4 months ago
  陈子杰 62dabf0eb2 临时提交 4 months ago

+ 203 - 123
SCADA_DAQ/Customer/Machines/SortMachine.cs

@@ -100,6 +100,24 @@ namespace SCADA_DAQ.Customer.Machines
         public string AlarmStr { get => string.Join(",", AlarmCollection.Select(t => t.Desc).ToList()); }
 
 
+        /// <summary>
+        /// 解析文件的板件信息
+        /// </summary>
+        public SortingBoardLocation BoardInfo
+        {
+            get { return _BoardInfo; }
+            set
+            {
+                if (value != _BoardInfo)
+                {
+                    _BoardInfo = value;
+                    OnPropertyChanged(nameof(BoardInfo));
+                }
+            }
+        }
+        private SortingBoardLocation _BoardInfo;
+
+
         /// <summary>
         /// 
         /// </summary>
@@ -189,53 +207,114 @@ namespace SCADA_DAQ.Customer.Machines
                 {
                     //角度计算与下方抓板角度计算一致
                     //拍照时先把角度转成相对应角度,避免吸盘撞机
-                    var rotation = 0m;
-                    var cupIndex = 0;
-                    //CenterX = (double)CurrentLabel.CenterX + (double)CurrentLabel.ActualWidth / 2;
-                    //CenterY = (double)CurrentLabel.CenterY + (double)CurrentLabel.ActualLength / 2;
+                    //var cupIndex = 0;
+                    //var rotation = 0m;
+                    BoardInfo = new SortingBoardLocation();
                     CenterX = (double)CurrentLabel.CenterX;
                     CenterY = (double)CurrentLabel.CenterY;
+                    BoardInfo.CupCenter = new Point(CenterX, CenterY);
+                    //修改前
+                    //var cup1Center = new Point(-140, -155);
+                    //var cup3Center = new Point(135, -155);
+                    //修改后
+                    var cup1Center = new Point((int)CustomerEnv.SortingMacConfigValue.Cup1OriginOffset.X,
+                                                (int)CustomerEnv.SortingMacConfigValue.Cup1OriginOffset.Y);
+                    var cup3Center = new Point((int)CustomerEnv.SortingMacConfigValue.Cup2OriginOffset.X,
+                                                (int)CustomerEnv.SortingMacConfigValue.Cup2OriginOffset.Y);
+
                     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)
                         {
-                            rotation = -90;
+                            BoardInfo.Rotation = -90;
+                            BoardInfo.ReleaseY = CurrentLabel.ActualLength / 2 - 150;
+                            //releaseY = CurrentLabel.ActualLength / 2 - 140;
+
+                        }
+                        else
+                        {
+                            BoardInfo.ReleaseY = CurrentLabel.ActualWidth / 2 - 150;
+                            //BoardInfo.ReleaseY = CurrentLabel.ActualWidth / 2 - 140;
+
                         }
+
                     }
                     else
                     {
                         if ((CenterX > 600 && CurrentLabel.ActualLength > CurrentLabel.ActualWidth) ||   //靠近X轴且横着
                             (CenterX <= 600 && CurrentLabel.ActualLength < CurrentLabel.ActualWidth))
                         {
-                            cupIndex = 3;
+                            BoardInfo.CupIndex = 3;
                         }
                         else
                         {
-                            cupIndex = 1;
+                            BoardInfo.CupIndex = 1;
                         }
 
-                        if (cupIndex == 1)
+                        if (BoardInfo.CupIndex == 1)
                         {
-                            if (CenterX > 600)
+                            if (CenterX <= 600)
                             {
-                                rotation = -90;
+                                if (CurrentLabel.ActualLength >= CurrentLabel.ActualWidth)
+                                {
+                                    var cup1NewCenter = new Point(cup1Center.X, cup1Center.Y);  //旋转后的坐标
+                                    BoardInfo.CupCenter = new Point(BoardInfo.CupCenter.X - cup1NewCenter.X, BoardInfo.CupCenter.Y - cup1NewCenter.Y);
+                                    BoardInfo.ReleaseY = CurrentLabel.ActualWidth / 2 - 180;
+                                    //BoardInfo.ReleaseY = CurrentLabel.ActualWidth / 2 - 170;
+
+                                }
                             }
+                            else
+                            {
+                                BoardInfo.Rotation = 90;
+                                var cup1NewCenter = new Point(cup1Center.Y,-1 * (double)cup1Center.X);  //旋转后的坐标
+                                                                                                         //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.ActualWidth / 2 - 180;
+                                //BoardInfo.ReleaseY = CurrentLabel.ActualWidth / 2 - 20;
 
+
+                            }
                         }
-                        else if (cupIndex == 3)
+                        else if (BoardInfo.CupIndex == 3)
                         {
 
                             if (CenterX <= 600)
                             {
                                 if (CurrentLabel.ActualLength < CurrentLabel.ActualWidth)
                                 {
-                                    rotation = 90;
+                                    BoardInfo.Rotation = -90;
+                                    var cup3NewCenter = new Point(cup3Center.Y * -1,(double)cup3Center.X);  //旋转后的坐标
+                                    BoardInfo.CupCenter = new Point(BoardInfo.CupCenter.X - cup3NewCenter.X, BoardInfo.CupCenter.Y - cup3NewCenter.Y);
                                 }
+                                //BoardInfo.ReleaseY = CurrentLabel.ActualWidth / 2;
+                                BoardInfo.ReleaseY = CurrentLabel.ActualWidth / 2 - 180;
+                                //BoardInfo.ReleaseY = CurrentLabel.ActualWidth / 2 - 20;
+
+
+                            }
+                            else
+                            {
+                                var cup3NewCenter = new Point(cup3Center.X, (double)cup3Center.Y);  //旋转后的坐标
+                                BoardInfo.CupCenter = new Point(BoardInfo.CupCenter.X - cup3NewCenter.X, BoardInfo.CupCenter.Y - cup3NewCenter.Y);
+                                //BoardInfo.ReleaseY = CurrentLabel.ActualWidth / 2 + 500;
+                                BoardInfo.ReleaseY = CurrentLabel.ActualWidth / 2 - 30;
+                                //BoardInfo.ReleaseY = CurrentLabel.ActualWidth / 2 - 20;
+
                             }
                         }
+                        else
+                        {
+                            //BoardInfo.ReleaseY = CurrentLabel.ActualWidth / 2;
+                        }
+
                     }
-                    GetListenReg(Tag_PhotoAngle).WriteObject(null,(float)rotation);
+
+                    GetListenReg(Tag_PhotoAngle).WriteObject(null,(float)BoardInfo.Rotation);
                     GetListenReg(Tag_PhotographX).WriteObject(null,
                     (float)(CurrentLabel.X > originXOffset ? CurrentLabel.X - originXOffset : 0),
                     (float)(CurrentLabel.Y - cameraOriginy), (short)1);
@@ -322,143 +401,143 @@ namespace SCADA_DAQ.Customer.Machines
                 //var centerY = (double)CurrentLabel.CenterY + (double)CurrentLabel.ActualLength / 2;
 
                 //var cupCenter = new Point((double)CurrentLabel.X, (double)CurrentLabel.Y);
-                var cupCenter = new Point(CenterX, CenterY);
-                var cup1Center = new Point(-140, -155);
-                var cup3Center = new Point(135, -155);
-                var releaseY = 0m;
+                //var cupCenter = new Point(CenterX, CenterY);
+                //var cup1Center = new Point(-140, -155);
+                //var cup3Center = new Point(135, -155);
+                //var BoardInfo.RelaeaseY = 0m;
                 if (!isCancel)
                 {
                     if (_lbl.ID == CurrentLabel.ID)
                     {
                         Log.Info($"开始处理,{CurrentLabel.ID}");
-                        var cupIndex = 0;
-                        var rotation = 0m;
-                        if ((CurrentLabel.ActualLength > 550 && CurrentLabel.ActualWidth > 200) ||
-                            (CurrentLabel.ActualWidth > 550 && CurrentLabel.ActualLength > 200)
-                            )
-                        {
-                            cupIndex = 2;
-                            if (CurrentLabel.ActualWidth > CurrentLabel.ActualLength)
-                            {
-                                rotation = -90;
-                                releaseY = CurrentLabel.ActualLength / 2 - 150;
-                                //releaseY = CurrentLabel.ActualLength / 2 - 140;
-
-                            }
-                            else
-                            {
-                                releaseY = CurrentLabel.ActualWidth / 2 - 150;
-                                //releaseY = CurrentLabel.ActualWidth / 2 - 140;
-
-                            }
-
-                        }
-                        else
-                        {
-                            if ((CenterX > 600 && CurrentLabel.ActualLength > CurrentLabel.ActualWidth) ||   //靠近X轴且横着
-                                (CenterX <= 600 && CurrentLabel.ActualLength < CurrentLabel.ActualWidth))
-                            {
-                                cupIndex = 3;
-                            }
-                            else
-                            {
-                                cupIndex = 1;
-                            }
-
-                            if (cupIndex == 1)
-                            {
-                                if (CenterX <= 600)
-                                {
-                                    if (CurrentLabel.ActualLength >= CurrentLabel.ActualWidth)
-                                    {
-                                        var cup1NewCenter = new Point(cup1Center.X, cup1Center.Y);  //旋转后的坐标
-                                        cupCenter = new Point(cupCenter.X - cup1NewCenter.X, cupCenter.Y - cup1NewCenter.Y);
-                                        releaseY = CurrentLabel.ActualWidth / 2 - 180;
-                                        //releaseY = CurrentLabel.ActualWidth / 2 - 170;
-
-                                    }
-                                }
-                                else
-                                {
-                                    rotation = -90;
-                                    var cup3NewCenter = new Point(-1 * cup1Center.Y, (double)cup1Center.X);  //旋转后的坐标
-                                                                                                             //cup3NewCenter.Offset(100, 32.5);   //补偿夹具尺寸
-                                    cupCenter = new Point(cupCenter.X - cup3NewCenter.X, cupCenter.Y - cup3NewCenter.Y);
-                                    //releaseY = CurrentLabel.ActualWidth / 2;
-                                    releaseY = CurrentLabel.ActualWidth / 2 - 30;
-                                    //releaseY = CurrentLabel.ActualWidth / 2 - 20;
-
-
-                                }
-                            }
-                            else if (cupIndex == 3)
-                            {
-
-                                if (CenterX <= 600)
-                                {
-                                    if (CurrentLabel.ActualLength < CurrentLabel.ActualWidth)
-                                    {
-                                        rotation = 90;
-                                        var cup3NewCenter = new Point(cup3Center.Y, -1 * (double)cup3Center.X);  //旋转后的坐标
-                                        cupCenter = new Point(cupCenter.X - cup3NewCenter.X, cupCenter.Y - cup3NewCenter.Y);
-                                    }
-                                    //releaseY = CurrentLabel.ActualWidth / 2;
-                                    releaseY = CurrentLabel.ActualWidth / 2 - 30;
-                                    //releaseY = CurrentLabel.ActualWidth / 2 - 20;
-
-
-                                }
-                                else
-                                {
-                                    var cup3NewCenter = new Point(cup3Center.X, (double)cup3Center.Y);  //旋转后的坐标
-                                    cupCenter = new Point(cupCenter.X - cup3NewCenter.X, cupCenter.Y - cup3NewCenter.Y);
-                                    //releaseY = CurrentLabel.ActualWidth / 2 + 500;
-                                    releaseY = CurrentLabel.ActualWidth / 2 - 30;
-                                    //releaseY = CurrentLabel.ActualWidth / 2 - 20;
-
-                                }
-                            }
-                            else
-                            {
-                                //releaseY = CurrentLabel.ActualWidth / 2;
-
-                            }
-
-                        }
+                        //var cupIndex = 0;
+                        //var rotation = 0m;
+                        //if ((CurrentLabel.ActualLength > 550 && CurrentLabel.ActualWidth > 200) ||
+                        //    (CurrentLabel.ActualWidth > 550 && CurrentLabel.ActualLength > 200)
+                        //    )
+                        //{
+                        //    cupIndex = 2;
+                        //    if (CurrentLabel.ActualWidth > CurrentLabel.ActualLength)
+                        //    {
+                        //        rotation = -90;
+                        //        releaseY = CurrentLabel.ActualLength / 2 - 150;
+                        //        //releaseY = CurrentLabel.ActualLength / 2 - 140;
+
+                        //    }
+                        //    else
+                        //    {
+                        //        releaseY = CurrentLabel.ActualWidth / 2 - 150;
+                        //        //releaseY = CurrentLabel.ActualWidth / 2 - 140;
+
+                        //    }
+
+                        //}
+                        //else
+                        //{
+                        //    if ((CenterX > 600 && CurrentLabel.ActualLength > CurrentLabel.ActualWidth) ||   //靠近X轴且横着
+                        //        (CenterX <= 600 && CurrentLabel.ActualLength < CurrentLabel.ActualWidth))
+                        //    {
+                        //        cupIndex = 3;
+                        //    }
+                        //    else
+                        //    {
+                        //        cupIndex = 1;
+                        //    }
+
+                        //    if (cupIndex == 1)
+                        //    {
+                        //        if (CenterX <= 600)
+                        //        {
+                        //            if (CurrentLabel.ActualLength >= CurrentLabel.ActualWidth)
+                        //            {
+                        //                var cup1NewCenter = new Point(cup1Center.X, cup1Center.Y);  //旋转后的坐标
+                        //                cupCenter = new Point(cupCenter.X - cup1NewCenter.X, cupCenter.Y - cup1NewCenter.Y);
+                        //                releaseY = CurrentLabel.ActualWidth / 2 - 180;
+                        //                //releaseY = CurrentLabel.ActualWidth / 2 - 170;
+
+                        //            }
+                        //        }
+                        //        else
+                        //        {
+                        //            rotation = -90;
+                        //            var cup3NewCenter = new Point(-1 * cup1Center.Y, (double)cup1Center.X);  //旋转后的坐标
+                        //                                                                                     //cup3NewCenter.Offset(100, 32.5);   //补偿夹具尺寸
+                        //            cupCenter = new Point(cupCenter.X - cup3NewCenter.X, cupCenter.Y - cup3NewCenter.Y);
+                        //            //releaseY = CurrentLabel.ActualWidth / 2;
+                        //            releaseY = CurrentLabel.ActualWidth / 2 - 30;
+                        //            //releaseY = CurrentLabel.ActualWidth / 2 - 20;
+
+
+                        //        }
+                        //    }
+                        //    else if (cupIndex == 3)
+                        //    {
+
+                        //        if (CenterX <= 600)
+                        //        {
+                        //            if (CurrentLabel.ActualLength < CurrentLabel.ActualWidth)
+                        //            {
+                        //                rotation = 90;
+                        //                var cup3NewCenter = new Point(cup3Center.Y, -1 * (double)cup3Center.X);  //旋转后的坐标
+                        //                cupCenter = new Point(cupCenter.X - cup3NewCenter.X, cupCenter.Y - cup3NewCenter.Y);
+                        //            }
+                        //            //releaseY = CurrentLabel.ActualWidth / 2;
+                        //            releaseY = CurrentLabel.ActualWidth / 2 - 30;
+                        //            //releaseY = CurrentLabel.ActualWidth / 2 - 20;
+
+
+                        //        }
+                        //        else
+                        //        {
+                        //            var cup3NewCenter = new Point(cup3Center.X, (double)cup3Center.Y);  //旋转后的坐标
+                        //            cupCenter = new Point(cupCenter.X - cup3NewCenter.X, cupCenter.Y - cup3NewCenter.Y);
+                        //            //releaseY = CurrentLabel.ActualWidth / 2 + 500;
+                        //            releaseY = CurrentLabel.ActualWidth / 2 - 30;
+                        //            //releaseY = CurrentLabel.ActualWidth / 2 - 20;
+
+                        //        }
+                        //    }
+                        //    else
+                        //    {
+                        //        //releaseY = CurrentLabel.ActualWidth / 2;
+                        //    }
+
+                        //}
+                        var rotation = BoardInfo.Rotation;
                         var releaseRotation = rotation == -90 ? -90 : 90;
                         var releaseXOffset = 0f;
-                        if (cupIndex != 2)
+                        if (BoardInfo.CupIndex != 2)
                         {
-                            releaseXOffset = releaseRotation == 90 ? 155f : -155f;
+                            releaseXOffset = releaseRotation == 90 ? -155f : 155f;
 
                         }
-                        releaseY = Math.Max(10, releaseY);
+                        BoardInfo.ReleaseY = Math.Max(10, BoardInfo.ReleaseY);
                         rotation += _lbl.R;
 
-                        var moveX = (float)((double)_lbl.X + cupCenter.X);
+                        var moveX = (float)((double)_lbl.X + BoardInfo.CupCenter.X);
                         moveX = moveX > originXOffset ? moveX - originXOffset : 0;
-                        var moveY = (float)((double)_lbl.Y + cupCenter.Y);
-                        if (((double)_lbl.X + cupCenter.X) > 0 && ((double)_lbl.Y + cupCenter.Y) > 0)
+                        var moveY = (float)((double)_lbl.Y + BoardInfo.CupCenter.Y);
+                        if (moveX < GetListenReg(Tag_XMaxLimitPos).ScaleValue && moveY < 2800)
                         {
                             GetListenReg(Tag_CaptureX).WriteObject(null,
                             moveX,  //D1512
                             moveY,  //D1514
                             (float)rotation,     //D1516
                             (short)1, // D1518
-                            (short)cupIndex,  // D1519.
+                            (short)BoardInfo.CupIndex,  // D1519.
                             (float)18.0,      // D1520 //厚度
                             (float)470 + releaseXOffset,       // D1522 放板位置X
-                            (float)releaseY,  // D1524 放板位置Y
+                            (float)BoardInfo.ReleaseY,  // D1524 放板位置Y
                             (float)releaseRotation          //放板角度
                             );
 
-                            CupMove?.Invoke(this, new CupMoveEventArgs() { X = (double)_lbl.X + cupCenter.X, Y = (double)_lbl.Y + cupCenter.Y, R = (double)rotation, CupIndex = cupIndex });
+                            CupMove?.Invoke(this, new CupMoveEventArgs() { X = (double)_lbl.X + BoardInfo.CupCenter.X, Y = (double)_lbl.Y + BoardInfo.CupCenter.Y, R = (double)rotation, CupIndex = BoardInfo.CupIndex });
 
-                            Log.Info($"正在分拣:{CurrentLabel.ID},X:{moveX},Y:{moveY},角度:{rotation},吸盘:{cupIndex}");
+                            Log.Info($"正在分拣:{CurrentLabel.ID},X:{moveX},Y:{moveY},角度:{rotation},吸盘:{BoardInfo.CupIndex}");
                         }
                         else
                         {
-                            Log.Info("位置错误");
+                            Log.Warn($"位置错误,取料X坐标为{moveX},Y坐标为{moveY}");
                         }
                     }
                     else
@@ -501,6 +580,7 @@ namespace SCADA_DAQ.Customer.Machines
             OnPropertyChanged(nameof(AlarmStr));
         }
 
+
         private string CycFilePath(params int[] values)
         {
             var str = "";

+ 43 - 1
SCADA_DAQ/Customer/Machines/SortingDeliveryMachine.cs

@@ -1,4 +1,5 @@
-using SCADA_DAQ.Customer.Models.BackOfSortingDelivery;
+using SCADA.Drive;
+using SCADA_DAQ.Customer.Models.BackOfSortingDelivery;
 using System;
 using System.Collections.Generic;
 using System.Collections.ObjectModel;
@@ -6,6 +7,7 @@ using System.ComponentModel;
 using System.Linq;
 using System.Text;
 using System.Threading.Tasks;
+using System.Windows.Forms;
 
 namespace SCADA_DAQ.Customer.Machines
 {
@@ -32,9 +34,49 @@ namespace SCADA_DAQ.Customer.Machines
         private ObservableCollection<CodeInfoModel> _CodeQueue = new ObservableCollection<CodeInfoModel>();
 
 
+
+        /// <summary>
+        /// 异型或者余料队列
+        /// </summary>
+        public Queue<int> LeftLoversOrAbnormal
+        {
+            get { return _LeftLoversOrAbnormal; }
+            set
+            {
+                if (value != _LeftLoversOrAbnormal)
+                {
+                    _LeftLoversOrAbnormal = value;
+                    OnPropertyChanged(nameof(LeftLoversOrAbnormal));
+                }
+            }
+        }
+        private Queue<int> _LeftLoversOrAbnormal = new Queue<int>();
+
+
+
+
         public SortingDeliveryMachine(string machieID) : base(machieID)
         {
         }
 
+        protected override void RegReadValueChanged(object sender, RegReadValueChangedEventArgs e)
+        {
+            base.RegReadValueChanged(sender, e);
+            var reg = (RegInfo)sender;
+            if (reg.Comment.Variable == Tag_WriteLeftLoversOrAbnormal && reg.Value == 1)
+            {
+                reg.ResetBit();
+                if (LeftLoversOrAbnormal.Count > 0)
+                {
+                    var value = LeftLoversOrAbnormal.Dequeue();
+                    GetListenReg(Tag_IsLeftovers).WriteReg(value);
+                }
+                else
+                {
+                    log.Info("信号误触发!");
+                }
+            }
+        }
+
     }
 }

+ 123 - 0
SCADA_DAQ/Customer/Models/SortingModel/SortingBoardLocation.cs

@@ -0,0 +1,123 @@
+using SCADA.CommonLib;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using System.Windows;
+
+namespace SCADA_DAQ.Customer.Models.SortingModel
+{
+    public class SortingBoardLocation : ObservableObject
+    {
+
+        /// <summary>
+        /// 文件中板件X轴坐标
+        /// </summary>
+        public decimal CenterX
+        {
+            get { return _CenterX; }
+            set
+            {
+                if (value != _CenterX)
+                {
+                    _CenterX = value;
+                    OnPropertyChanged(nameof(CenterX));
+                }
+            }
+        }
+        private decimal _CenterX;
+
+
+        /// <summary>
+        /// 文件中板件Y轴坐标
+        /// </summary>
+        public decimal CenterY
+        {
+            get { return _CenterY; }
+            set
+            {
+                if (value != _CenterY)
+                {
+                    _CenterY = value;
+                    OnPropertyChanged(nameof(CenterY));
+                }
+            }
+        }
+        private decimal _CenterY;
+
+
+        /// <summary>
+        /// 旋转角度
+        /// </summary>
+        public decimal Rotation
+        {
+            get { return _Rotation; }
+            set
+            {
+                if (value != _Rotation)
+                {
+                    _Rotation = value;
+                    OnPropertyChanged(nameof(Rotation));
+                }
+            }
+        }
+        private decimal _Rotation;
+
+
+        /// <summary>
+        /// 使用的吸盘号
+        /// </summary>
+        public int CupIndex
+        {
+            get { return _CupIndex; }
+            set
+            {
+                if (value != _CupIndex)
+                {
+                    _CupIndex = value;
+                    OnPropertyChanged(nameof(CupIndex));
+                }
+            }
+        }
+        private int _CupIndex;
+
+
+        /// <summary>
+        /// 放板坐标
+        /// </summary>
+        public decimal ReleaseY
+        {
+            get { return _ReleaseY; }
+            set
+            {
+                if (value != _ReleaseY)
+                {
+                    _ReleaseY = value;
+                    OnPropertyChanged(nameof(ReleaseY));
+                }
+            }
+        }
+        private decimal _ReleaseY;
+
+
+        /// <summary>
+        /// 使用吸盘的坐标
+        /// </summary>
+        public Point CupCenter
+        {
+            get { return _CupCenter; }
+            set
+            {
+                if (value != _CupCenter)
+                {
+                    _CupCenter = value;
+                    OnPropertyChanged(nameof(CupCenter));
+                }
+            }
+        }
+        private Point _CupCenter;
+
+
+    }
+}

+ 88 - 0
SCADA_DAQ/Customer/Models/SortingModel/SortingMacSettingModel.cs

@@ -91,5 +91,93 @@ namespace SCADA_DAQ.Customer.Models.SortingModel
         private string _CycFolder;
 
 
+        /// <summary>
+        /// 吸盘1坐标偏移
+        /// </summary>
+        /// 
+        [AutoViewProperty("吸盘1中心点坐标", Icon = "ImageFilterCenterFocus")]
+        public CenterPoint Cup1OriginOffset
+        {
+            get { return _Cup1OriginOffset; }
+            set
+            {
+                if (value != _Cup1OriginOffset)
+                {
+                    _Cup1OriginOffset = value;
+                    OnPropertyChanged(nameof(Cup1OriginOffset));
+                }
+            }
+        }
+        private CenterPoint _Cup1OriginOffset = new CenterPoint();
+
+
+        /// <summary>
+        /// 吸盘3坐标偏移
+        /// </summary>
+        /// 
+        [AutoViewProperty("吸盘3中心点坐标", Icon = "ImageFilterCenterFocus")]
+        public CenterPoint Cup2OriginOffset
+        {
+            get { return _Cup2OriginOffset; }
+            set
+            {
+                if (value != _Cup2OriginOffset)
+                {
+                    _Cup2OriginOffset = value;
+                    OnPropertyChanged(nameof(Cup2OriginOffset));
+                }
+            }
+        }
+        private CenterPoint _Cup2OriginOffset = new CenterPoint();
+
+
+    }
+
+    /// <summary>
+    /// 中心点偏移
+    /// </summary>
+    public class CenterPoint :ObservableObject
+    {
+
+        /// <summary>
+        /// X
+        /// </summary>
+        /// 
+        [AutoViewProperty("中心点X坐标", Icon = "AlphaX")]
+        public decimal X
+        {
+            get { return _X; }
+            set
+            {
+                if (value != _X)
+                {
+                    _X = value;
+                    OnPropertyChanged(nameof(X));
+                }
+            }
+        }
+        private decimal _X;
+
+
+        /// <summary>
+        /// Y
+        /// </summary>
+        /// 
+        [AutoViewProperty("中心点Y坐标", Icon = "AlphaY")]
+        public decimal Y
+        {
+            get { return _Y; }
+            set
+            {
+                if (value != _Y)
+                {
+                    _Y = value;
+                    OnPropertyChanged(nameof(Y));
+                }
+            }
+        }
+        private decimal _Y;
+
+
     }
 }

+ 14 - 8
SCADA_DAQ/Customer/Service/ScannerService.cs

@@ -87,7 +87,7 @@ namespace SCADA_DAQ.Customer.Service
             BoardTasks = CSVHelper.CsvToObject<BoardTaskModel>("ATXY24031503-P1徐州老板家.csv", 0, true, ',', Encoding.Default);
             Sbr1.BarCodeReceived += Sbr1_BarCodeReceived;
             Env.Schedual.DateTimeChanged += Schedual_DateTimeChanged;
-            
+            var a = Math.Round(11.5);
             return base.Start();
         }
 
@@ -108,13 +108,15 @@ namespace SCADA_DAQ.Customer.Service
 
             var barcodeTask = BoardTasks.Where(t => t.BoardID == barcode).FirstOrDefault();
             var api = new WebApiHelper(_ScannerServiceConfig.Url);
-            if (barcode != "NoRead" || (barcodeTask != null && Math.Max(barcodeTask.Width,barcodeTask.Height) < 250))
+            if (barcode != "NoRead" &&  (barcodeTask != null && Math.Min(barcodeTask.Width,barcodeTask.Height) > 250))
             {
-                //先判断是否异型
+                //先判断是否异型 
                 if (barcodeTask.IsAbnormalShape)
                 {
                     Plc1.GetListenReg(SortingDeliveryMachine.Tag_CodeMatch).WriteReg(2);
-                    Plc1.GetListenReg(SortingDeliveryMachine.Tag_IsLeftovers).WriteReg(0);
+
+                    //Plc1.GetListenReg(SortingDeliveryMachine.Tag_IsLeftovers).WriteReg(0);
+                    Plc1.LeftLoversOrAbnormal.Enqueue(2);
                 }
                 else
                 {
@@ -149,16 +151,20 @@ namespace SCADA_DAQ.Customer.Service
                         //Log.Info($"{result.Data.success},{result.Data.code},{result.Data.message}");
                         Log.Info($"缓存仓:条码匹配失败");
                         Plc1.GetListenReg(SortingDeliveryMachine.Tag_CodeMatch).WriteReg(2);
-                        Plc1.GetListenReg(SortingDeliveryMachine.Tag_IsLeftovers).WriteReg(1);
+                        //Plc1.GetListenReg(SortingDeliveryMachine.Tag_IsLeftovers).WriteReg(1);
+                        Plc1.LeftLoversOrAbnormal.Enqueue(1);
+
 
                     }
-                }              
-              
+                }
+
             }
             else
             {
                 Plc1.GetListenReg(SortingDeliveryMachine.Tag_CodeMatch).WriteReg(2);
-                Plc1.GetListenReg(SortingDeliveryMachine.Tag_IsLeftovers).WriteReg(1);
+                //Plc1.GetListenReg(SortingDeliveryMachine.Tag_IsLeftovers).WriteReg(1);
+                Plc1.LeftLoversOrAbnormal.Enqueue(1);
+
                 Log.Info($"没有获取到条码或尺寸小于250");
             }
             

+ 4 - 0
SCADA_DAQ/Customer/Views/Menu/UctFrmBackOfSortingDelivery/UctFrmSortingDelivery.xaml

@@ -119,6 +119,10 @@
                         </Style>
                     </wpfcontrol:IconButton.Style>
                 </wpfcontrol:IconButton>
+                <wpfcontrol:IconButton ButtonKind="ResetButton" Width="200" Height="40" 
+                                       Margin="5" x:Name="ResetBtn" 
+                                       FontSize="20" FontWeight="Bold"
+                                       PreviewMouseDown="ResetBtn_PreviewMouseDown" PreviewMouseUp="ResetBtn_PreviewMouseUp"/>
             </StackPanel>
 
           

+ 23 - 0
SCADA_DAQ/Customer/Views/Menu/UctFrmBackOfSortingDelivery/UctFrmSortingDelivery.xaml.cs

@@ -21,6 +21,7 @@ using System.Windows.Media;
 using System.Windows.Media.Imaging;
 using System.Windows.Navigation;
 using System.Windows.Shapes;
+using static NPOI.HSSF.Util.HSSFColor;
 
 namespace SCADA_DAQ.Customer.Views.Menu.UctFrmBackOfSortingDelivery
 {
@@ -51,6 +52,7 @@ namespace SCADA_DAQ.Customer.Views.Menu.UctFrmBackOfSortingDelivery
             LeftoversRequest.DataContext = _PLC.GetListenReg(SortingDeliveryMachine.Tag_Y12);
             AllowLeftoversRequest.DataContext = _PLC.GetListenReg(SortingDeliveryMachine.Tag_X32);
             CodeInfo.BoardGrid.ItemsSource = _PLC.CodeQueue;
+            ResetBtn.DataContext = _PLC.GetListenReg(SortingDeliveryMachine.Tag_Reset);
             ForceBtn.DataContext = _PLC.GetListenReg(SortingDeliveryMachine.Tag_ForceToCache);
             Barcode.Icon = new Image()
             {
@@ -191,5 +193,26 @@ namespace SCADA_DAQ.Customer.Views.Menu.UctFrmBackOfSortingDelivery
                 }
             }
         }
+
+
+        private void ResetBtn_PreviewMouseDown(object sender, MouseButtonEventArgs e)
+        {
+            var btn = (IconButton)sender;
+            if (btn.DataContext is RegInfo reg)
+            {
+                reg.SetBit();
+            }
+            _PLC.LeftLoversOrAbnormal.Clear();
+        }
+
+        private void ResetBtn_PreviewMouseUp(object sender, MouseButtonEventArgs e)
+        {
+            var btn = (IconButton)sender;
+            if (btn.DataContext is RegInfo reg)
+            {
+                reg.ResetBit();
+            }
+
+        }
     }
 }

+ 13 - 5
SCADA_DAQ/Customer/Views/Uct/UcrSorting/UctCup.xaml

@@ -8,7 +8,15 @@
              x:Name="this"
              d:DesignHeight="558.8" d:DesignWidth="742.4" FontSize="35">
     <Canvas Height="510" Width="330" Background="#1F000000" RenderTransformOrigin="0.5,0.5">
-        <Label Width="65" Height="200" HorizontalContentAlignment="Center" VerticalContentAlignment="Center" BorderThickness="1" Content="1" RenderTransformOrigin="0.5,0.5">
+        <Canvas.RenderTransform>
+            <TransformGroup>
+                <ScaleTransform/>
+                <SkewTransform/>
+                <RotateTransform Angle="180"/>
+                <TranslateTransform />
+            </TransformGroup>
+            </Canvas.RenderTransform>
+            <Label Width="65" Height="200" HorizontalContentAlignment="Center" VerticalContentAlignment="Center" BorderThickness="1" Content="3" RenderTransformOrigin="0.5,0.5">
             <Label.RenderTransform>
                 <TransformGroup>
                     <ScaleTransform ScaleY="-1"/>
@@ -21,7 +29,7 @@
                 <Style TargetType="Label">
                     <Setter Property="Background" Value="#1F000000"/>
                     <Style.Triggers>
-                        <DataTrigger Binding="{Binding CupStatus,ElementName=this}" Value="1">
+                        <DataTrigger Binding="{Binding CupStatus,ElementName=this}" Value="3">
                             <Setter Property="Background" Value="Lime"/>
                         </DataTrigger>
                     </Style.Triggers>
@@ -35,7 +43,7 @@
                 <TransformGroup>
                     <ScaleTransform ScaleY="-1"/>
                     <SkewTransform/>
-                    <RotateTransform/>
+                    <RotateTransform />
                     <TranslateTransform/>
                 </TransformGroup>
             </Label.RenderTransform>
@@ -51,7 +59,7 @@
             </Label.Style>
         </Label>
 
-        <Label Width="65" Height="200" HorizontalContentAlignment="Center" VerticalContentAlignment="Center"  Canvas.Left="265" Content="3" RenderTransformOrigin="0.5,0.5">
+        <Label Width="65" Height="200" HorizontalContentAlignment="Center" VerticalContentAlignment="Center"  Canvas.Left="265" Content="1" RenderTransformOrigin="0.5,0.5">
             <Label.RenderTransform>
                 <TransformGroup>
                     <ScaleTransform ScaleY="-1"/>
@@ -64,7 +72,7 @@
                 <Style TargetType="Label">
                     <Setter Property="Background" Value="#1F000000"/>
                     <Style.Triggers>
-                        <DataTrigger Binding="{Binding CupStatus,ElementName=this}" Value="3">
+                        <DataTrigger Binding="{Binding CupStatus,ElementName=this}" Value="1">
                             <Setter Property="Background" Value="Lime"/>
                         </DataTrigger>
                     </Style.Triggers>

+ 2 - 2
SCADA_DAQ/Machines/EdgeMachine_封边机.cs

@@ -22,12 +22,12 @@ namespace SCADA_DAQ.Customer.Machines
 		/// </summary>
 		public const string @Tag_SlideOut="SlideOut";
 			
-		/// <summary>寄存器:D161【Height
+		/// <summary>寄存器:D161【Length
 		/// <para>单位:</para> 
 		/// <para>缩放:1 类型: Default</para> 
 		/// <para>备注:板长</para> 
 		/// </summary>
-		public const string @Tag_Length="Height";
+		public const string @Tag_Length="Length";
 			
 		/// <summary>寄存器:D162【Width】
 		/// <para>单位:</para> 

+ 9 - 2
SCADA_DAQ/Machines/LongMen1_龙门移载1.cs

@@ -323,12 +323,12 @@ namespace SCADA_DAQ.Customer.Machines
 		/// </summary>
 		public const string @Tag_RotationAngle="RotationAngle";
 			
-		/// <summary>寄存器:D125【Height
+		/// <summary>寄存器:D125【Length
 		/// <para>单位:</para> 
 		/// <para>缩放:1 类型: Default</para> 
 		/// <para>备注:贴边长度</para> 
 		/// </summary>
-		public const string @Tag_Length="Height";
+		public const string @Tag_Length="Length";
 			
 		/// <summary>寄存器:D126【WriteOK】
 		/// <para>单位:</para> 
@@ -505,6 +505,13 @@ namespace SCADA_DAQ.Customer.Machines
 		/// </summary>
 		public const string @Tag_D150="D150";
 			
+		/// <summary>寄存器:D171【BarCodeNoRead】
+		/// <para>单位:</para> 
+		/// <para>缩放:1 类型: Default</para> 
+		/// <para>备注:</para> 
+		/// </summary>
+		public const string @Tag_BarCodeNoRead="BarCodeNoRead";
+			
 		/// <summary>寄存器:M1014【XManualFwdBtn】
 		/// <para>单位:</para> 
 		/// <para>缩放:1 类型: Default</para> 

+ 2 - 2
SCADA_DAQ/Machines/LongMen2_龙门移载2.cs

@@ -288,12 +288,12 @@ namespace SCADA_DAQ.Customer.Machines
 		/// </summary>
 		public const string @Tag_RotationAngle="RotationAngle";
 			
-		/// <summary>寄存器:D135【Height
+		/// <summary>寄存器:D135【Length
 		/// <para>单位:</para> 
 		/// <para>缩放:1 类型: Default</para> 
 		/// <para>备注:贴边长度</para> 
 		/// </summary>
-		public const string @Tag_Length="Height";
+		public const string @Tag_Length="Length";
 			
 		/// <summary>寄存器:D136【WriteOK】
 		/// <para>单位:</para> 

+ 2 - 2
SCADA_DAQ/Machines/LongMen3_龙门移载3.cs

@@ -211,12 +211,12 @@ namespace SCADA_DAQ.Customer.Machines
 		/// </summary>
 		public const string @Tag_RotationAngle="RotationAngle";
 			
-		/// <summary>寄存器:D145【Height
+		/// <summary>寄存器:D145【Length
 		/// <para>单位:</para> 
 		/// <para>缩放:1 类型: Default</para> 
 		/// <para>备注:贴边长度</para> 
 		/// </summary>
-		public const string @Tag_Length="Height";
+		public const string @Tag_Length="Length";
 			
 		/// <summary>寄存器:D146【WriteOK】
 		/// <para>单位:</para> 

+ 2 - 2
SCADA_DAQ/Machines/LongMen4_龙门移载4.cs

@@ -197,12 +197,12 @@ namespace SCADA_DAQ.Customer.Machines
 		/// </summary>
 		public const string @Tag_RotationAngle="RotationAngle";
 			
-		/// <summary>寄存器:D155【Height
+		/// <summary>寄存器:D155【Length
 		/// <para>单位:</para> 
 		/// <para>缩放:1 类型: Default</para> 
 		/// <para>备注:贴边长度</para> 
 		/// </summary>
-		public const string @Tag_Length="Height";
+		public const string @Tag_Length="Length";
 			
 		/// <summary>寄存器:D156【WriteOK】
 		/// <para>单位:</para> 

+ 42 - 0
SCADA_DAQ/Machines/SortMachine_分拣机.cs

@@ -1204,6 +1204,48 @@ namespace SCADA_DAQ.Customer.Machines
 		/// <para>备注:吸盘复位</para> 
 		/// </summary>
 		public const string @Tag_CupReset="CupReset";
+			
+		/// <summary>寄存器:M1012【M1012】
+		/// <para>单位:</para> 
+		/// <para>缩放:1 类型: Default</para> 
+		/// <para>备注:X轴报警</para> 
+		/// </summary>
+		public const string @Tag_M1012="M1012";
+			
+		/// <summary>寄存器:M1013【M1013】
+		/// <para>单位:</para> 
+		/// <para>缩放:1 类型: Default</para> 
+		/// <para>备注:Y轴报警</para> 
+		/// </summary>
+		public const string @Tag_M1013="M1013";
+			
+		/// <summary>寄存器:M1014【M1014】
+		/// <para>单位:</para> 
+		/// <para>缩放:1 类型: Default</para> 
+		/// <para>备注:Y1轴报警</para> 
+		/// </summary>
+		public const string @Tag_M1014="M1014";
+			
+		/// <summary>寄存器:M1015【M1015】
+		/// <para>单位:</para> 
+		/// <para>缩放:1 类型: Default</para> 
+		/// <para>备注:Z轴报警</para> 
+		/// </summary>
+		public const string @Tag_M1015="M1015";
+			
+		/// <summary>寄存器:M1016【M1016】
+		/// <para>单位:</para> 
+		/// <para>缩放:1 类型: Default</para> 
+		/// <para>备注:旋转轴报警</para> 
+		/// </summary>
+		public const string @Tag_M1016="M1016";
+			
+		/// <summary>寄存器:M1017【M1017】
+		/// <para>单位:</para> 
+		/// <para>缩放:1 类型: Default</para> 
+		/// <para>备注:急停报警</para> 
+		/// </summary>
+		public const string @Tag_M1017="M1017";
 						
 	}
 }

+ 9 - 2
SCADA_DAQ/Machines/SortingDeliveryMachine_开料分拣输送.cs

@@ -855,12 +855,12 @@ namespace SCADA_DAQ.Customer.Machines
 		/// </summary>
 		public const string @Tag_M260="M260";
 			
-		/// <summary>寄存器:M261【M261
+		/// <summary>寄存器:M261【Reset
 		/// <para>单位:</para> 
 		/// <para>缩放:1 类型: Default</para> 
 		/// <para>备注:软件复位</para> 
 		/// </summary>
-		public const string @Tag_M261="M261";
+		public const string @Tag_Reset="Reset";
 			
 		/// <summary>寄存器:M600【M600】
 		/// <para>单位:</para> 
@@ -1428,6 +1428,13 @@ namespace SCADA_DAQ.Customer.Machines
 		/// <para>备注:强制进仓 =1</para> 
 		/// </summary>
 		public const string @Tag_ForceToCache="ForceToCache";
+			
+		/// <summary>寄存器:M190【WriteLeftLoversOrAbnormal】
+		/// <para>单位:</para> 
+		/// <para>缩放:1 类型: Default</para> 
+		/// <para>备注:</para> 
+		/// </summary>
+		public const string @Tag_WriteLeftLoversOrAbnormal="WriteLeftLoversOrAbnormal";
 						
 	}
 }