Browse Source

完善逻辑

陈子杰 3 months ago
parent
commit
bd471894ec

+ 366 - 0
SCADA_DAQ.DAL/DBSchema.cs

@@ -1935,6 +1935,85 @@ public static class T_Col_Name
                 /// </summary>
                  public const string @Remark_Str=nameof(@Remark_Str);
                     
+             }
+             /// <summary> 
+             /// App_Hold_SortingLabels
+             /// </summary>
+             public class App_Hold_SortingLabels
+             {
+             	/// <summary>
+                /// 
+                /// </summary>
+                 public const string @ID=nameof(@ID);
+                    /// <summary>
+                /// 
+                /// </summary>
+                 public const string @LabelName_Str=nameof(@LabelName_Str);
+                    /// <summary>
+                /// 
+                /// </summary>
+                 public const string @X_Dec=nameof(@X_Dec);
+                    /// <summary>
+                /// 
+                /// </summary>
+                 public const string @Y_Dec=nameof(@Y_Dec);
+                    /// <summary>
+                /// 
+                /// </summary>
+                 public const string @R_Dec=nameof(@R_Dec);
+                    /// <summary>
+                /// 
+                /// </summary>
+                 public const string @CodeID_Str=nameof(@CodeID_Str);
+                    /// <summary>
+                /// 
+                /// </summary>
+                 public const string @PositionX_Dec=nameof(@PositionX_Dec);
+                    /// <summary>
+                /// 
+                /// </summary>
+                 public const string @PositionY_Dec=nameof(@PositionY_Dec);
+                    /// <summary>
+                /// 
+                /// </summary>
+                 public const string @ActualLength_Dec=nameof(@ActualLength_Dec);
+                    /// <summary>
+                /// 
+                /// </summary>
+                 public const string @ActualWidth_Dec=nameof(@ActualWidth_Dec);
+                    /// <summary>
+                /// 
+                /// </summary>
+                 public const string @Waste_Dec=nameof(@Waste_Dec);
+                    /// <summary>
+                /// 
+                /// </summary>
+                 public const string @Accurate_Dec=nameof(@Accurate_Dec);
+                    /// <summary>
+                /// 
+                /// </summary>
+                 public const string @Status_Int=nameof(@Status_Int);
+                    /// <summary>
+                /// 
+                /// </summary>
+                 public const string @CreateUser_Str=nameof(@CreateUser_Str);
+                    /// <summary>
+                /// 
+                /// </summary>
+                 public const string @CreateTime_Dt=nameof(@CreateTime_Dt);
+                    /// <summary>
+                /// 
+                /// </summary>
+                 public const string @ModifyTime_Dt=nameof(@ModifyTime_Dt);
+                    /// <summary>
+                /// 
+                /// </summary>
+                 public const string @ModifyUser_Str=nameof(@ModifyUser_Str);
+                    /// <summary>
+                /// 
+                /// </summary>
+                 public const string @Remark_Str=nameof(@Remark_Str);
+                    
              }
              
                           }
@@ -9049,6 +9128,283 @@ namespace DBModel
                 }
             }
             
+             }
+             /// <summary> 
+             /// 
+             /// </summary>
+             public class App_Hold_SortingLabels:ObservableObject
+             {
+             	  private System.Int64 _ID;
+                /// <summary>
+                /// 
+                /// </summary>
+                 public System.Int64 ID
+                {
+                get {return _ID;}
+                set{
+                    if(value!=(_ID))
+                    {
+                        _ID=value;
+                        OnPropertyChanged(nameof( ID));
+                    }
+                }
+            }
+              private System.String _LabelName_Str;
+                /// <summary>
+                /// 
+                /// </summary>
+                 public System.String LabelName_Str
+                {
+                get {return _LabelName_Str;}
+                set{
+                    if(value!=(_LabelName_Str))
+                    {
+                        _LabelName_Str=value;
+                        OnPropertyChanged(nameof( LabelName_Str));
+                    }
+                }
+            }
+              private System.Decimal _X_Dec;
+                /// <summary>
+                /// 
+                /// </summary>
+                 public System.Decimal X_Dec
+                {
+                get {return _X_Dec;}
+                set{
+                    if(value!=(_X_Dec))
+                    {
+                        _X_Dec=value;
+                        OnPropertyChanged(nameof( X_Dec));
+                    }
+                }
+            }
+              private System.Decimal _Y_Dec;
+                /// <summary>
+                /// 
+                /// </summary>
+                 public System.Decimal Y_Dec
+                {
+                get {return _Y_Dec;}
+                set{
+                    if(value!=(_Y_Dec))
+                    {
+                        _Y_Dec=value;
+                        OnPropertyChanged(nameof( Y_Dec));
+                    }
+                }
+            }
+              private System.Decimal _R_Dec;
+                /// <summary>
+                /// 
+                /// </summary>
+                 public System.Decimal R_Dec
+                {
+                get {return _R_Dec;}
+                set{
+                    if(value!=(_R_Dec))
+                    {
+                        _R_Dec=value;
+                        OnPropertyChanged(nameof( R_Dec));
+                    }
+                }
+            }
+              private System.String _CodeID_Str;
+                /// <summary>
+                /// 
+                /// </summary>
+                 public System.String CodeID_Str
+                {
+                get {return _CodeID_Str;}
+                set{
+                    if(value!=(_CodeID_Str))
+                    {
+                        _CodeID_Str=value;
+                        OnPropertyChanged(nameof( CodeID_Str));
+                    }
+                }
+            }
+              private System.Decimal _PositionX_Dec;
+                /// <summary>
+                /// 
+                /// </summary>
+                 public System.Decimal PositionX_Dec
+                {
+                get {return _PositionX_Dec;}
+                set{
+                    if(value!=(_PositionX_Dec))
+                    {
+                        _PositionX_Dec=value;
+                        OnPropertyChanged(nameof( PositionX_Dec));
+                    }
+                }
+            }
+              private System.Decimal _PositionY_Dec;
+                /// <summary>
+                /// 
+                /// </summary>
+                 public System.Decimal PositionY_Dec
+                {
+                get {return _PositionY_Dec;}
+                set{
+                    if(value!=(_PositionY_Dec))
+                    {
+                        _PositionY_Dec=value;
+                        OnPropertyChanged(nameof( PositionY_Dec));
+                    }
+                }
+            }
+              private System.Decimal _ActualLength_Dec;
+                /// <summary>
+                /// 
+                /// </summary>
+                 public System.Decimal ActualLength_Dec
+                {
+                get {return _ActualLength_Dec;}
+                set{
+                    if(value!=(_ActualLength_Dec))
+                    {
+                        _ActualLength_Dec=value;
+                        OnPropertyChanged(nameof( ActualLength_Dec));
+                    }
+                }
+            }
+              private System.Decimal _ActualWidth_Dec;
+                /// <summary>
+                /// 
+                /// </summary>
+                 public System.Decimal ActualWidth_Dec
+                {
+                get {return _ActualWidth_Dec;}
+                set{
+                    if(value!=(_ActualWidth_Dec))
+                    {
+                        _ActualWidth_Dec=value;
+                        OnPropertyChanged(nameof( ActualWidth_Dec));
+                    }
+                }
+            }
+              private System.Decimal _Waste_Dec;
+                /// <summary>
+                /// 
+                /// </summary>
+                 public System.Decimal Waste_Dec
+                {
+                get {return _Waste_Dec;}
+                set{
+                    if(value!=(_Waste_Dec))
+                    {
+                        _Waste_Dec=value;
+                        OnPropertyChanged(nameof( Waste_Dec));
+                    }
+                }
+            }
+              private System.Decimal _Accurate_Dec;
+                /// <summary>
+                /// 
+                /// </summary>
+                 public System.Decimal Accurate_Dec
+                {
+                get {return _Accurate_Dec;}
+                set{
+                    if(value!=(_Accurate_Dec))
+                    {
+                        _Accurate_Dec=value;
+                        OnPropertyChanged(nameof( Accurate_Dec));
+                    }
+                }
+            }
+              private System.Int32 _Status_Int;
+                /// <summary>
+                /// 
+                /// </summary>
+                 public System.Int32 Status_Int
+                {
+                get {return _Status_Int;}
+                set{
+                    if(value!=(_Status_Int))
+                    {
+                        _Status_Int=value;
+                        OnPropertyChanged(nameof( Status_Int));
+                    }
+                }
+            }
+              private System.String _CreateUser_Str;
+                /// <summary>
+                /// 
+                /// </summary>
+                 public System.String CreateUser_Str
+                {
+                get {return _CreateUser_Str;}
+                set{
+                    if(value!=(_CreateUser_Str))
+                    {
+                        _CreateUser_Str=value;
+                        OnPropertyChanged(nameof( CreateUser_Str));
+                    }
+                }
+            }
+              private System.DateTime _CreateTime_Dt;
+                /// <summary>
+                /// 
+                /// </summary>
+                 public System.DateTime CreateTime_Dt
+                {
+                get {return _CreateTime_Dt;}
+                set{
+                    if(value!=(_CreateTime_Dt))
+                    {
+                        _CreateTime_Dt=value;
+                        OnPropertyChanged(nameof( CreateTime_Dt));
+                    }
+                }
+            }
+              private System.DateTime _ModifyTime_Dt;
+                /// <summary>
+                /// 
+                /// </summary>
+                 public System.DateTime ModifyTime_Dt
+                {
+                get {return _ModifyTime_Dt;}
+                set{
+                    if(value!=(_ModifyTime_Dt))
+                    {
+                        _ModifyTime_Dt=value;
+                        OnPropertyChanged(nameof( ModifyTime_Dt));
+                    }
+                }
+            }
+              private System.String _ModifyUser_Str;
+                /// <summary>
+                /// 
+                /// </summary>
+                 public System.String ModifyUser_Str
+                {
+                get {return _ModifyUser_Str;}
+                set{
+                    if(value!=(_ModifyUser_Str))
+                    {
+                        _ModifyUser_Str=value;
+                        OnPropertyChanged(nameof( ModifyUser_Str));
+                    }
+                }
+            }
+              private System.String _Remark_Str;
+                /// <summary>
+                /// 
+                /// </summary>
+                 public System.String Remark_Str
+                {
+                get {return _Remark_Str;}
+                set{
+                    if(value!=(_Remark_Str))
+                    {
+                        _Remark_Str=value;
+                        OnPropertyChanged(nameof( Remark_Str));
+                    }
+                }
+            }
+            
              }
              /// <summary> 
              /// 
@@ -11118,6 +11474,10 @@ public BaseTable App_Hold_BoardInfo{get;private set;}
  /// <summary> 
  ///  
  /// </summary> 
+public BaseTable App_Hold_SortingLabels{get;private set;}
+ /// <summary> 
+ ///  
+ /// </summary> 
 public BaseTable V_Sys_F_UserRole{get;private set;}
  /// <summary> 
  ///  
@@ -11178,6 +11538,7 @@ Sys_Menu_Info=CreateTable("ID","Sys_Menu_Info");
 App_Onduty=CreateTable("ID","App_Onduty");
 App_LocalNodeManage=CreateTable("ID","App_LocalNodeManage");
 App_Hold_BoardInfo=CreateTable("ID","App_Hold_BoardInfo");
+App_Hold_SortingLabels=CreateTable("ID","App_Hold_SortingLabels");
 V_Sys_F_UserRole=CreateTable("ID","V_Sys_F_UserRole");
 V_User_D_UserInfo=CreateTable("ID","V_User_D_UserInfo");
 V_Base_AlarmLog=CreateTable("ID","V_Base_AlarmLog");
@@ -11326,6 +11687,10 @@ public BaseTable App_Hold_BoardInfo{get;private set;}
  /// <summary> 
  ///  
  /// </summary> 
+public BaseTable App_Hold_SortingLabels{get;private set;}
+ /// <summary> 
+ ///  
+ /// </summary> 
 public BaseTable V_Sys_F_UserRole{get;private set;}
  /// <summary> 
  ///  
@@ -11392,6 +11757,7 @@ Sys_Menu_Info=innerDb.CreateTable("ID","Sys_Menu_Info");
 App_Onduty=innerDb.CreateTable("ID","App_Onduty");
 App_LocalNodeManage=innerDb.CreateTable("ID","App_LocalNodeManage");
 App_Hold_BoardInfo=innerDb.CreateTable("ID","App_Hold_BoardInfo");
+App_Hold_SortingLabels=innerDb.CreateTable("ID","App_Hold_SortingLabels");
 V_Sys_F_UserRole=innerDb.CreateTable("ID","V_Sys_F_UserRole");
 V_User_D_UserInfo=innerDb.CreateTable("ID","V_User_D_UserInfo");
 V_Base_AlarmLog=innerDb.CreateTable("ID","V_Base_AlarmLog");

+ 1 - 0
SCADA_DAQ/Customer/CustomerEnv.cs

@@ -42,5 +42,6 @@ namespace SCADA_DAQ.Customer
             });
 
         public static SortingMacSettingModel SortingMacConfigValue { get => _SortingConfig.Value; }
+
     }
 }

+ 196 - 56
SCADA_DAQ/Customer/Machines/SortMachine.cs

@@ -1,4 +1,6 @@
 
+using DBNames;
+using LiveCharts.Defaults;
 using Microsoft.DwayneNeed.Shapes;
 using Mysqlx.Session;
 using Newtonsoft.Json;
@@ -7,6 +9,8 @@ using NPOI.SS.Formula.Functions;
 using NPOI.XWPF.UserModel;
 using Opc.Ua;
 using SCADA.BarcodeReader;
+using SCADA.CommonLib;
+using SCADA.CommonLib.Data.DIL;
 using SCADA.CommonLib.Helper;
 using SCADA.Drive;
 using SCADA_DAQ.Customer.Models;
@@ -25,6 +29,7 @@ using System.Threading;
 using System.Threading.Tasks;
 using System.Windows;
 using System.Windows.Ink;
+using System.Windows.Shapes;
 using System.Xml.Linq;
 
 namespace SCADA_DAQ.Customer.Machines
@@ -52,6 +57,26 @@ namespace SCADA_DAQ.Customer.Machines
 
             //}
             CuttingMac = new SyntecRemoteCNC(CustomerEnv.SortingMacConfigValue.CuttingMacIP);
+            _Lbls = Env.DAL.App_Hold_SortingLabels.GetData<LabelModel>().ToList();           
+            Labels = new ObservableCollection<LabelModel>(_Lbls);
+            CurrentCycDoc = CustomerEnv.SortingMacConfigValue.CurrentFileName;
+            //var str = "{ \"X\" : [],\"Y\":[],\"R\":[],\"ID\":\"\"}";
+            //var labels = JsonHelper.JsonDeserialize<CameraModels>(str);
+            //var codes = labels.ID.Split(',');
+            //var labelModels = new List<LabelModel>();
+            //for (int i = 0; i < codes.Count(); i++)
+            //{
+            //    labelModels.Add(new LabelModel { X = labels.X[i], Y = labels.Y[i], R = labels.R[i], CodeID = codes[i] });
+            //}
+            //var model = labelModels.Where(x => x.CodeID == "5151").FirstOrDefault();
+            //if (model != null)
+            //{
+
+            //}
+            //else
+            //{
+
+            //}
             //var str = CycFilePath(6378049);
         }
 
@@ -72,8 +97,8 @@ namespace SCADA_DAQ.Customer.Machines
         }
         private ObservableCollection<LabelModel> _Labels;
         private List<LabelModel> _Lbls;
-        private double CenterX {  get; set; }   
-        private double CenterY { get; set; }    
+        private double CenterX { get; set; }
+        private double CenterY { get; set; }
 
         ///// <summary>
         ///// 文件选择
@@ -213,8 +238,8 @@ namespace SCADA_DAQ.Customer.Machines
 
             var reg = (RegInfo)sender;
 
-            
-            
+
+
             if (reg.Comment.Variable == Tag_StartSort && reg.Value == 1)
             {
                 //_Lbls = GetLabes(File.FilePath);
@@ -226,16 +251,16 @@ namespace SCADA_DAQ.Customer.Machines
                     end = true;
                     if (CustomerEnv.SortingMacConfigValue.CycFilePath != null)
                     {
-                        _Lbls = GetLabes(CustomerEnv.SortingMacConfigValue.CycFilePath);
-                        Labels = new ObservableCollection<LabelModel>(_Lbls);
-                        ExistSmallBoard();
+
+
+                        ExistSmallBoard(CustomerEnv.SortingMacConfigValue.CycFilePath);
 
                     }
                     else
                     {
                         MessageBox.Show($"参数页面中的'单机运行时cyc文件'为空!");
                     }
-                    
+
                 }
                 else
                 {
@@ -246,12 +271,10 @@ namespace SCADA_DAQ.Customer.Machines
                             var ncName = new int[41];
                             CuttingMac.READ_plc_register(7200, 7240, out ncName);
                             var path = CycFilePath(ncName);
-                            CuttingMac.WRITE_plc_register(7200, 7240, new int[41]);
                             if (File.Exists(path))
                             {
-                                _Lbls = GetLabes(path);
-                                Labels = new ObservableCollection<LabelModel>(_Lbls);
-                                ExistSmallBoard();
+                                CuttingMac.WRITE_plc_register(7200, 7240, new int[41]);
+                                ExistSmallBoard(path);
                             }
                             else
                             {
@@ -281,8 +304,8 @@ namespace SCADA_DAQ.Customer.Machines
                         }
                     }
                 }
-                
-                reg.ResetBit(); 
+
+                reg.ResetBit();
                 NewBoardArrived?.Invoke(this, EventArgs.Empty);
             }
             else if (reg.Comment.Variable == Tag_RequestNext && reg.Value == 1 && reg.OldValue == 0)
@@ -303,7 +326,7 @@ namespace SCADA_DAQ.Customer.Machines
                     //var Cup1Center = new Point(-140, -155);
                     //var Cup3Center = new Point(135, -155);
                     //修改后
-                    
+
 
                     if ((CurrentLabel.ActualLength > 550 && CurrentLabel.ActualWidth > 200) ||
                         (CurrentLabel.ActualWidth > 550 && CurrentLabel.ActualLength > 200)
@@ -353,7 +376,7 @@ namespace SCADA_DAQ.Customer.Machines
                             else
                             {
                                 BoardInfo.Rotation = 90;
-                                var cup1NewCenter = new Point(Cup1Center.Y,-1 * (double)Cup1Center.X);  //旋转后的坐标
+                                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);
@@ -372,7 +395,7 @@ namespace SCADA_DAQ.Customer.Machines
                                 if (CurrentLabel.ActualLength < CurrentLabel.ActualWidth)
                                 {
                                     BoardInfo.Rotation = -90;
-                                    var cup3NewCenter = new Point(Cup3Center.Y * -1,(double)Cup3Center.X);  //旋转后的坐标
+                                    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;
 
@@ -403,11 +426,11 @@ namespace SCADA_DAQ.Customer.Machines
 
                     }
 
-                    GetListenReg(Tag_PhotoAngle).WriteObject(null,(float)BoardInfo.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);
-                    if (CurrentLabel == _Lbls.Where(t=>t.Status == Models.TaskStatus.None).Last())
+                    if (CurrentLabel == _Lbls.Where(t => t.Status == Models.TaskStatus.None).Last())
                     {
                         System.Threading.Thread.Sleep(1000);
                         GetListenReg(Tag_SortFinish).SetBit();
@@ -415,18 +438,19 @@ namespace SCADA_DAQ.Customer.Machines
 
                     }
                     CurrentLabel.Status = Models.TaskStatus.Excuting;
-
+                    Env.DAL.App_Hold_SortingLabels.Update($"{T_Col_Name.App_Hold_SortingLabels.CodeID_Str} = '{CurrentLabel.CodeID}'",
+                        new UpdateItem(T_Col_Name.App_Hold_SortingLabels.Status_Int, (int)Models.TaskStatus.Excuting));
                 }
                 else
                 {
-                    MessageBox.Show("板件已经分拣完成!!!"); 
+                    MessageBox.Show("板件已经分拣完成!!!");
                 }
 
                 reg.ResetBit();
             }
             else if (reg.Comment.Variable == Tag_CameraMoveOK && reg.Value == 1 && reg.OldValue == 0)
-            { 
-                //var _lbl = new LabelModel() { ID = CurrentLabel.ID };
+            {
+                //var _lbl = new LabelModel() { CodeID = CurrentLabel.CodeID };
                 var _lbl = new LabelModel();
                 var isCancel = false;
                 if (GetListenReg(Tag_CameraEnable).Value == 0)
@@ -441,11 +465,38 @@ namespace SCADA_DAQ.Customer.Machines
                            new SCADA.Comm.ResponseInfo(SCADA.Comm.ResponseType.EndFlag) { EndFlags = new byte[] { 0x0A } });
                             if (_strContent != null)
                             {
-                                _lbl = JsonHelper.JsonDeserialize<LabelModel>(_strContent);  //获取标签位置
-                                log.Info($"相机计算的偏差值为:X={_lbl.X},Y={_lbl.Y},R={_lbl.R}");
-                                _lbl.X += CustomerEnv.SortingMacConfigValue.XCameraOffset;
+                                //var labels = new List<LabelModel>();
+
+                                var labels = JsonHelper.JsonDeserialize<CameraModels>(_strContent);  //获取标签位置
+                                var codes = labels.ID.Split(',');
+                                var labelModels = new List<LabelModel>();
+                                for (int i = 0; i < codes.Count(); i++)
+                                {
+                                    labelModels.Add(new LabelModel { X = labels.X[i], Y = labels.Y[i], R = labels.R[i], CodeID = codes[i] });
+                                }
+                                _lbl = labelModels.Where(t => t.CodeID == CurrentLabel.CodeID).FirstOrDefault();
+                                if (_lbl != null)
+                                {
+                                    log.Info($"相机计算的偏差值为:X={_lbl.X},Y={_lbl.Y},R={_lbl.R}");
+                                    _lbl.X += CustomerEnv.SortingMacConfigValue.XCameraOffset;
+                                }
+                                else
+                                {
+                                    _lbl = new LabelModel { CodeID = CurrentLabel.CodeID };
+
+                                    if (!CustomerEnv.SortingMacConfigValue.IsCameraFailForceRun)
+                                    {
+                                        if (MessageBox.Show($"相机数据中没有识别到数据 \n 是否继续?", "相机数据", MessageBoxButton.YesNo) == MessageBoxResult.No)
+                                        {
+                                            isCancel = true;
+                                            CurrentLabel.Status = Models.TaskStatus.None;
+                                            GetListenReg(Tag_Reset).SetBit();
+                                        }
+                                    }
+                                }
+
                             }
-                            else 
+                            else
                             {
                                 if (MessageBox.Show("连接相机失败,是否继续执行?", "相机数据", MessageBoxButton.YesNo) == MessageBoxResult.No)
                                 {
@@ -455,7 +506,7 @@ namespace SCADA_DAQ.Customer.Machines
                                 }
                                 else
                                 {
-                                    _lbl.ID = CurrentLabel.ID;
+                                    _lbl.CodeID = CurrentLabel.CodeID;
 
                                 }
                             }
@@ -463,42 +514,39 @@ namespace SCADA_DAQ.Customer.Machines
                         }
                         catch (Exception ex)
                         {
+                            //var path = ((JsonReaderException)ex).Path;
+                            _lbl.CodeID = CurrentLabel.CodeID;
 
-                            if (ex.Source == "Newtonsoft.Json")
+                            if (!CustomerEnv.SortingMacConfigValue.IsCameraFailForceRun)
                             {
-                                var path = ((JsonReaderException)ex).Path;
-                                _lbl.ID = CurrentLabel.ID;
-
-                                if (!CustomerEnv.SortingMacConfigValue.IsCameraFailForceRun)
+                                if (MessageBox.Show($"相机数据中没有识别到数据 \n 是否继续?", "相机数据", MessageBoxButton.YesNo) == MessageBoxResult.No)
                                 {
-                                    if (MessageBox.Show($"相机数据中属性“{path}”数据错误 \n 是否继续?", "相机数据", MessageBoxButton.YesNo) == MessageBoxResult.No)
-                                    {
-                                        isCancel = true;
-                                        CurrentLabel.Status = Models.TaskStatus.None;
-                                        GetListenReg(Tag_Reset).SetBit();
-                                    }
+                                    isCancel = true;
+                                    CurrentLabel.Status = Models.TaskStatus.None;
+                                    GetListenReg(Tag_Reset).SetBit();
                                 }
-                                
                             }
 
 
+
+
                         }
 
                     }
                 }
                 else
                 {
-                    _lbl.ID = CurrentLabel.ID;
+                    _lbl.CodeID = CurrentLabel.CodeID;
                 }
                 if (!isCancel)
                 {
-                    if (_lbl.ID == CurrentLabel.ID)
+                    if (_lbl.CodeID == CurrentLabel.CodeID)
                     {
-                        Log.Info($"开始处理,{CurrentLabel.ID}");
-                        
+                        Log.Info($"开始处理,{CurrentLabel.CodeID}");
+
                         var rotation = BoardInfo.Rotation;
-                        var releaseRotation = rotation  == 0 ? -90  : rotation;
-                        
+                        var releaseRotation = rotation == 0 ? -90 : rotation;
+
                         var releaseXOffset = 0f;
                         if (BoardInfo.CupIndex != 2)
                         {
@@ -510,7 +558,15 @@ namespace SCADA_DAQ.Customer.Machines
                         //    releaseRotation = -90;
                         //}
                         BoardInfo.ReleaseY = Math.Max(10, BoardInfo.ReleaseY);
-                        rotation += _lbl.R;
+                        if (CurrentLabel.R == 90)
+                        {
+                            rotation += Math.Abs(_lbl.R) - CurrentLabel.R;
+                        }
+                        else
+                        {
+                            rotation += _lbl.R - CurrentLabel.R;
+
+                        }
 
                         var moveX = (float)((double)_lbl.X + BoardInfo.CupCenter.X);
                         moveX = moveX > originXOffset ? moveX - originXOffset : 0;
@@ -532,7 +588,7 @@ namespace SCADA_DAQ.Customer.Machines
                             xOffset = CupNewCenter.X - (CupNewCenter.X * Math.Cos(angle) - CupNewCenter.Y * Math.Sin(angle));
                             yOffset = CupNewCenter.Y - (CupNewCenter.X * Math.Sin(angle) + CupNewCenter.Y * Math.Cos(angle));
                         }
-                        
+
 
                         //var xoffset = Math.Sin(a) * (double)CurrentLabel.ActualLength;
                         //var yoffset = Math.Sin(angle) * (double)CurrentLabel.ActualWidth;
@@ -559,10 +615,10 @@ namespace SCADA_DAQ.Customer.Machines
                             (float)BoardInfo.ReleaseY,  // D1524 放板位置Y
                             (float)releaseRotation          //放板角度
                             );
-                            
+
                             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},吸盘:{BoardInfo.CupIndex}");
+                            Log.Info($"正在分拣:{CurrentLabel.CodeID},X:{moveX},Y:{moveY},角度:{rotation},吸盘:{BoardInfo.CupIndex}");
                         }
                         else
                         {
@@ -571,7 +627,7 @@ namespace SCADA_DAQ.Customer.Machines
                     }
                     else
                     {
-                        Log.Error($"拍照获取的ID与需求ID不一致,被拍照的ID:{_lbl.ID},需求的板材ID:{CurrentLabel.ID}");
+                        Log.Error($"拍照获取的ID与需求ID不一致,被拍照的ID:{_lbl.CodeID},需求的板材ID:{CurrentLabel.CodeID}");
                     }
                 }
                 else
@@ -628,8 +684,8 @@ namespace SCADA_DAQ.Customer.Machines
             for (int i = 0; i < values.Count(); i++)
             {
                 code[0 + i * 4] = (byte)(values[i] >> 0);
-                code[1+ i * 4] = (byte)(values[i] >> 8);
-                code[2+ i * 4] = (byte)(values[i] >> 16);
+                code[1 + i * 4] = (byte)(values[i] >> 8);
+                code[2 + i * 4] = (byte)(values[i] >> 16);
                 code[3 + i * 4] = (byte)(values[i] >> 24);
             }
             for (int i = 0; i < code.Count(); i++)
@@ -642,14 +698,19 @@ namespace SCADA_DAQ.Customer.Machines
             }
             log.Info($"开料机解析的加工文件为{str}");
             //return str;
-            var fileName ="Label_"+str.Replace(".nc",".cyc");
+            var fileName = "Label_" + str.Replace(".nc", ".cyc");
             CurrentCycDoc = fileName;
+            CustomerEnv.SortingMacConfigValue.CurrentFileName = fileName;
             var filePath = new DirectoryInfo(CustomerEnv.SortingMacConfigValue.CycFolder).GetFiles().Where(t => t.Name.Contains(fileName)).FirstOrDefault();
             return CustomerEnv.SortingMacConfigValue.CycFolder + $@"\{fileName}";
         }
 
-        public void ExistSmallBoard()
+        public void ExistSmallBoard(string path)
         {
+            _Lbls = GetLabes(path);
+            Labels = new ObservableCollection<LabelModel>(_Lbls);
+            Env.DAL.App_Hold_SortingLabels.Delete("1=1");
+
             var smallBoard = Labels.Where(t => Math.Min(t.ActualWidth, t.ActualLength) <= 80 ||
                                                                 Math.Max(t.ActualWidth, t.ActualLength) <= 250).ToList();
             if (smallBoard != null && smallBoard.Count > 0)
@@ -658,6 +719,8 @@ namespace SCADA_DAQ.Customer.Machines
                 {
                     t.Status = Models.TaskStatus.Finished;
                 }
+                
+
                 GetListenReg(Tag_SmallBoardManualConfirm).SetBit();
             }
             else
@@ -665,6 +728,7 @@ namespace SCADA_DAQ.Customer.Machines
                 GetListenReg(Tag_SmallBoardManualConfirm).ResetBit();
 
             }
+            Env.DAL.Insert(_Lbls);
         }
 
         /// <summary>
@@ -694,6 +758,82 @@ namespace SCADA_DAQ.Customer.Machines
 
         }
 
-        
+
+    }
+
+    public class CameraModels : ObservableObject
+    {
+
+        /// <summary>
+        /// X集合
+        /// </summary>
+        public List<decimal> X
+        {
+            get { return _X; }
+            set
+            {
+                if (value != _X)
+                {
+                    _X = value;
+                    OnPropertyChanged(nameof(X));
+                }
+            }
+        }
+        private List<decimal> _X;
+
+
+        /// <summary>
+        /// Y集合
+        /// </summary>
+        public List<decimal> Y
+        {
+            get { return _Y; }
+            set
+            {
+                if (value != _Y)
+                {
+                    _Y = value;
+                    OnPropertyChanged(nameof(Y));
+                }
+            }
+        }
+        private List<decimal> _Y;
+
+
+        /// <summary>
+        /// R集合
+        /// </summary>
+        public List<decimal> R
+        {
+            get { return _R; }
+            set
+            {
+                if (value != _R)
+                {
+                    _R = value;
+                    OnPropertyChanged(nameof(R));
+                }
+            }
+        }
+        private List<decimal> _R;
+
+
+        /// <summary>
+        /// ID集合
+        /// </summary>
+        public string ID
+        {
+            get { return _ID; }
+            set
+            {
+                if (value != _ID)
+                {
+                    _ID = value;
+                    OnPropertyChanged(nameof(ID));
+                }
+            }
+        }
+        private string _ID;
+
     }
 }

+ 35 - 7
SCADA_DAQ/Customer/Models/LabelModel.cs

@@ -1,4 +1,5 @@
-using Newtonsoft.Json;
+using DBNames;
+using Newtonsoft.Json;
 using SCADA.CommonLib;
 using System;
 using System.Collections.Generic;
@@ -12,6 +13,8 @@ namespace SCADA_DAQ.Customer.Models
     /// <summary>
     /// 
     /// </summary>
+    /// 
+    [Table(nameof(DBModel.App_Hold_SortingLabels))]
     public class LabelModel : ObservableObject
     {
 
@@ -19,6 +22,7 @@ namespace SCADA_DAQ.Customer.Models
         /// 标签图片
         /// </summary>
         [AutoViewProperty("标签图片")]
+        [Column(T_Col_Name.App_Hold_SortingLabels.LabelName_Str)]
         public string LabelName
         {
             get { return _LabelName; }
@@ -38,6 +42,8 @@ namespace SCADA_DAQ.Customer.Models
         /// 标签X坐标
         /// </summary>
         [AutoViewProperty("标签X坐标")]
+        [Column(T_Col_Name.App_Hold_SortingLabels.X_Dec)]
+
         public decimal X
         {
             get { return _X; }
@@ -58,6 +64,8 @@ namespace SCADA_DAQ.Customer.Models
         /// 标签Y坐标
         /// </summary>
         [AutoViewProperty("标签Y坐标")]
+        [Column(T_Col_Name.App_Hold_SortingLabels.Y_Dec)]
+
         public decimal Y
         {
             get { return _Y; }
@@ -78,6 +86,8 @@ namespace SCADA_DAQ.Customer.Models
         /// 标签是否旋转90度
         /// </summary>
         [AutoViewProperty("标签是否旋转90度")]
+        [Column(T_Col_Name.App_Hold_SortingLabels.R_Dec)]
+
         public decimal R
         {
             get { return _R; }
@@ -98,20 +108,23 @@ namespace SCADA_DAQ.Customer.Models
         /// 板材ID
         /// </summary>
         [AutoViewProperty("板材ID")]
+        [JsonProperty("ID")]
 
-        public string ID
+        [Column(T_Col_Name.App_Hold_SortingLabels.CodeID_Str)]
+
+        public string CodeID
         {
-            get { return _ID; }
+            get { return _CodeID; }
             set
             {
-                if (value != _ID)
+                if (value != _CodeID)
                 {
-                    _ID = value;
-                    OnPropertyChanged(nameof(ID));
+                    _CodeID = value;
+                    OnPropertyChanged(nameof(CodeID));
                 }
             }
         }
-        private string _ID;
+        private string _CodeID;
 
 
 
@@ -121,6 +134,7 @@ namespace SCADA_DAQ.Customer.Models
         /// </summary>
         [AutoViewProperty("板材X坐标")]
         [JsonIgnore]
+
         public decimal PositionX
         {
             get { return _PositionX; }
@@ -162,6 +176,8 @@ namespace SCADA_DAQ.Customer.Models
         /// 板材中心位置X
         /// </summary>
         [JsonProperty("PositionX")]
+        [Column(T_Col_Name.App_Hold_SortingLabels.PositionX_Dec)]
+
         public decimal CenterX
         {
             get { return _CenterX; }
@@ -187,6 +203,8 @@ namespace SCADA_DAQ.Customer.Models
         /// 板材中心位置Y
         /// </summary>
         [JsonProperty("PositionY")]
+        [Column(T_Col_Name.App_Hold_SortingLabels.PositionY_Dec)]
+
         public decimal CenterY
         {
             get { return _CenterY; }
@@ -211,6 +229,8 @@ namespace SCADA_DAQ.Customer.Models
         ///  板材开料长度, Y方向长度
         /// </summary>
         [AutoViewProperty("开料长度(Y)")]
+        [Column(T_Col_Name.App_Hold_SortingLabels.ActualLength_Dec)]
+
         public decimal ActualLength
         {
             get { return _ActualLength; }
@@ -232,6 +252,8 @@ namespace SCADA_DAQ.Customer.Models
         /// 板材开料宽度, X方向长度
         /// </summary>
         [AutoViewProperty("开料宽度(X)")]
+        [Column(T_Col_Name.App_Hold_SortingLabels.ActualWidth_Dec)]
+
         public decimal ActualWidth
         {
             get { return _ActualWidth; }
@@ -253,6 +275,8 @@ namespace SCADA_DAQ.Customer.Models
         /// 是否余料
         /// </summary>
         [AutoViewProperty("是否余料")]
+        [Column(T_Col_Name.App_Hold_SortingLabels.Waste_Dec)]
+
         public int Waste
         {
             get { return _Waste; }
@@ -274,6 +298,8 @@ namespace SCADA_DAQ.Customer.Models
         /// 是否异形
         /// </summary>
         [AutoViewProperty("是否异形")]
+        [Column(T_Col_Name.App_Hold_SortingLabels.Accurate_Dec)]
+
         public int Accurate
         {
             get { return _Accurate; }
@@ -293,6 +319,8 @@ namespace SCADA_DAQ.Customer.Models
         /// 
         /// </summary>
         [AutoViewProperty("任务状态")]
+        [Column(T_Col_Name.App_Hold_SortingLabels.Status_Int)]
+
         public TaskStatus Status
         {
             get { return _Status; }

+ 1 - 1
SCADA_DAQ/Customer/Models/ProcessData.cs

@@ -39,7 +39,7 @@ namespace SCADA_DAQ.Customer.Models
         /// <summary>
         /// 
         /// </summary>
-        [ForeignKey("ID")]
+        [ForeignKey("CodeID")]
         [SCADA.CommonLib.Column(T_Col_Name.App_Demo_ProcessData.ReportId)]
         public int ReportId
         {

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

@@ -195,6 +195,25 @@ namespace SCADA_DAQ.Customer.Models.SortingModel
 
 
 
+        /// <summary>
+        /// 当前加工文件
+        /// </summary>
+        /// 
+
+        public string CurrentFileName
+        {
+            get { return _CurrentFileName; }
+            set
+            {
+                if (value != _CurrentFileName)
+                {
+                    _CurrentFileName = value;
+                    OnPropertyChanged(nameof(CurrentFileName));
+                }
+            }
+        }
+        private string _CurrentFileName;
+
 
 
         /// <summary>

+ 3 - 2
SCADA_DAQ/Customer/Service/ScannerService.cs

@@ -122,13 +122,14 @@ namespace SCADA_DAQ.Customer.Service
                 if (barcodeTask.IsAbnormalShape ||
                     minSize < SortingEnv.SortingWorkReportSettingValue.MinSize
                     || (MinProportion < SortingEnv.SortingWorkReportSettingValue.MinProportion && SortingEnv.SortingWorkReportSettingValue.IsMinProportionEnable
-                        || (MinProportion < SortingEnv.SortingWorkReportSettingValue.MinProportion && minSize < 200 && !SortingEnv.SortingWorkReportSettingValue.IsMinProportionEnable)))
+                        || (MinProportion < SortingEnv.SortingWorkReportSettingValue.MinProportion && minSize < 200 && !SortingEnv.SortingWorkReportSettingValue.IsMinProportionEnable))
+                         || Math.Max(barcodeTask.Width, barcodeTask.Height) > 2620)
                 {
                     Plc1.GetListenReg(SortingDeliveryMachine.Tag_CodeMatch).WriteReg(2);
 
                     //Plc1.GetListenReg(SortingDeliveryMachine.Tag_IsLeftovers).WriteReg(0);
                     Plc1.LeftLoversOrAbnormal.Enqueue(2);
-                    Log.Info("板件异型或尺寸或比例太小!");
+                    Log.Info("板件异型或尺寸或比例太小或尺寸超出2620mm!");
 
                 }
                 else

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

@@ -56,7 +56,7 @@ namespace SCADA_DAQ.Customer.Views.Menu.UctFrmBackOfSortingDelivery
             ForceBtn.DataContext = _PLC.GetListenReg(SortingDeliveryMachine.Tag_ForceToCache);
             Barcode.Icon = new Image()
             {
-                Source = SCADA.CommonCtrl.WpfHelper.VisualHelper.ImageToImageSource(@"./Content/Img/Code.png")
+                Source = SCADA.CommonCtrl.WpfHelper.VisualHelper.ImageToImageSource(@"./Content/Img/CodeID.png")
             };
             HeteromorphosisDelivery.IconGrid.Visibility = Visibility.Collapsed;
             HeteromorphosisDelivery.Delivery.Left.DataContext = _PLC.GetListenReg(SortingDeliveryMachine.Tag_HeteromorphosisRollerState);

+ 6 - 6
SCADA_DAQ/Customer/Views/Menu/UctFrmSorting/UctFrmSortingMain.xaml

@@ -74,7 +74,7 @@
                             <Style TargetType="wpfcontrol:IconButton">
                                 <Setter Property="ButtonStyle" Value="Info"/>
                                 <Setter Property="Width" Value="200"/>
-                                <Setter Property="Height" Value="40"/>
+                                <Setter Property="Height" Value="50"/>
                                 <Setter Property="Margin" Value="5"/>
                                 <Setter Property="FontSize" Value="24"/>
                                 <Setter Property="FontWeight" Value="Bold"/>
@@ -110,17 +110,17 @@
 
                             <wpfcontrol:IconButton Title="废料清除" ButtonKind="ClearButton" Click="IconButton_Click" x:Name="ClearBtn">
                             </wpfcontrol:IconButton>
-                            <wpfcontrol:IconButton Title="重新启动" ButtonKind="ReloadButton" Click="IconButton_Click" x:Name="RestartBtn">
-                            </wpfcontrol:IconButton>
-                            <wpfcontrol:IconButton Title="一键送料" ButtonKind="RigthButton" Click="FeedBtn_Click"  x:Name="FeedBtn">
+                            <wpfcontrol:IconButton Title="重新启动" ButtonKind="ReloadButton" Click="RestartBtn_Click" x:Name="RestartBtn">
                             </wpfcontrol:IconButton>
+                            <!--<wpfcontrol:IconButton Title="一键送料" ButtonKind="RigthButton" Click="FeedBtn_Click"  x:Name="FeedBtn">
+                            </wpfcontrol:IconButton>-->
                             <wpfcontrol:IconButton ButtonKind="PauseButton" x:Name="PauseBtn" Click="PauseBtn_Click">
                                 <wpfcontrol:IconButton.Style>
                                     <Style TargetType="wpfcontrol:IconButton">
                                         <Setter Property="Title" Value="系统暂停"/>
                                         <Setter Property="ButtonStyle" Value="Info"/>
                                         <Setter Property="Width" Value="200"/>
-                                        <Setter Property="Height" Value="40"/>
+                                        <Setter Property="Height" Value="50"/>
                                         <Setter Property="Margin" Value="5"/>
                                         <Setter Property="FontSize" Value="24"/>
                                         <Setter Property="FontWeight" Value="Bold"/>
@@ -141,7 +141,7 @@
                                         <Setter Property="Title" Value="视觉已启用"/>
                                         <Setter Property="ButtonStyle" Value="Info"/>
                                         <Setter Property="Width" Value="200"/>
-                                        <Setter Property="Height" Value="40"/>
+                                        <Setter Property="Height" Value="50"/>
                                         <Setter Property="Margin" Value="5"/>
                                         <Setter Property="FontSize" Value="24"/>
                                         <Setter Property="FontWeight" Value="Bold"/>

+ 51 - 35
SCADA_DAQ/Customer/Views/Menu/UctFrmSorting/UctFrmSortingMain.xaml.cs

@@ -1,6 +1,8 @@
-using SCADA.CommonCtrl.SCADAUI;
+using DBNames;
+using SCADA.CommonCtrl.SCADAUI;
 using SCADA.CommonCtrl.WpfControl;
 using SCADA.CommonLib;
+using SCADA.CommonLib.Data.DIL;
 using SCADA.Drive;
 using SCADA_DAQ.Customer.Machines;
 using SCADA_DAQ.Customer.Models;
@@ -53,7 +55,7 @@ namespace SCADA_DAQ.Customer.Views.Menu.UctFrmSorting
             ClearBtn.DataContext = plc.GetListenReg(SortMachine.Tag_ScrapsClear);
             ResetBtn.DataContext = plc.GetListenReg(SortMachine.Tag_Reset);
             PauseBtn.DataContext = plc.GetListenReg(SortMachine.Tag_Pause);
-            RestartBtn.DataContext = plc.GetListenReg(SortMachine.Tag_PhotographOK);
+            //RestartBtn.DataContext = plc.GetListenReg(SortMachine.Tag_PhotographOK);
             CupResetBtn.DataContext = plc.GetListenReg(SortMachine.Tag_CupReset);
             AlarmRoller.DataContext = plc;
             //PathSelect.Content = new AutoView(plc.File) { FontSize = 22, MaxTitleWidth = 100, ContentWidth = 1000 };
@@ -82,6 +84,7 @@ namespace SCADA_DAQ.Customer.Views.Menu.UctFrmSorting
             UpdateStartFlagShow(plc.GetListenReg(SortMachine.Tag_RunStateFlag));
             ShowFlag.DataContext = plc.GetListenReg(SortMachine.Tag_RunStateFlag);
             CameraBtn.DataContext = plc.GetListenReg(SortMachine.Tag_CameraEnable);
+            BuildBoardItems();
             plc.BaseDevice.RegReadValueChanged += BaseDevice_RegReadValueChanged;
         }
 
@@ -142,13 +145,13 @@ namespace SCADA_DAQ.Customer.Views.Menu.UctFrmSorting
 
                     ClearBtn.IsEnabled = true;
                     RestartBtn.IsEnabled = true;
-                    FeedBtn.IsEnabled = true;
+               
                 }
                 else
                 {
                     ClearBtn.IsEnabled = false;
                     RestartBtn.IsEnabled = false;
-                    FeedBtn.IsEnabled = false;
+               
                 }
             });
         }
@@ -160,6 +163,9 @@ namespace SCADA_DAQ.Customer.Views.Menu.UctFrmSorting
             if (excutingBoard != null)
             {
                 excutingBoard.Status = Models.TaskStatus.Finished;
+                Env.DAL.App_Hold_SortingLabels.Update($"{T_Col_Name.App_Hold_SortingLabels.CodeID_Str} = '{excutingBoard.CodeID}'",
+                      new UpdateItem(T_Col_Name.App_Hold_SortingLabels.Status_Int, (int)Models.TaskStatus.Finished));
+
             }
         }
 
@@ -167,29 +173,34 @@ namespace SCADA_DAQ.Customer.Views.Menu.UctFrmSorting
         {
             Dispatcher.Invoke(new Action(() =>
             {
-                Board.Children.Clear();
-                var index = 1;
-                foreach (var item in plc.Labels)
-                {
-                    var subBoard = new UctBoardView() { Width = (double)item.ActualWidth, Height = (double)item.ActualLength, BoardId = item.ID, BoardIndex = index };
-                    Canvas.SetLeft(subBoard, (double)item.PositionX);
-                    Canvas.SetTop(subBoard, (double)item.PositionY);
 
-                    Board.Children.Add(subBoard);
+                BuildBoardItems();
+            }));
+        }
 
-                    subBoard.DataContext = item;
-                    subBoard.SetBinding(UctBoardView.StatusProperty, new Binding(nameof(LabelModel.Status)));
-                    index++;
-                }
+        public void BuildBoardItems()
+        {
+            Board.Children.Clear();
+            var index = 1;
+            foreach (var item in plc.Labels)
+            {
+                var subBoard = new UctBoardView() { Width = (double)item.ActualWidth, Height = (double)item.ActualLength, BoardId = item.CodeID, BoardIndex = index };
+                Canvas.SetLeft(subBoard, (double)item.PositionX);
+                Canvas.SetTop(subBoard, (double)item.PositionY);
 
-                cup = new UctCup() { Height = 510, Width = 330 };
-                Canvas.SetLeft(cup, -165);
-                Canvas.SetTop(cup, -255);
-                Board.Children.Add(cup);
+                Board.Children.Add(subBoard);
 
-                cup.CupStatus = 0;
+                subBoard.DataContext = item;
+                subBoard.SetBinding(UctBoardView.StatusProperty, new Binding(nameof(LabelModel.Status)));
+                index++;
+            }
 
-            }));
+            cup = new UctCup() { Height = 510, Width = 330 };
+            Canvas.SetLeft(cup, -165);
+            Canvas.SetTop(cup, -255);
+            Board.Children.Add(cup);
+
+            cup.CupStatus = 0;
         }
 
         /// <summary>
@@ -260,17 +271,17 @@ namespace SCADA_DAQ.Customer.Views.Menu.UctFrmSorting
             var btn = (IconButton)sender;
             if (btn.DataContext is RegInfo reg)
             {
-                if (reg == plc.GetListenReg(SortMachine.Tag_PhotographOK))
-                {
-                    plc.GetListenReg(SortMachine.Tag_RequestNext).WriteReg(1);
-                    Task.Run(() =>
-                    {
-                        Thread.Sleep(500);
-                        reg.WriteReg(1);
-
-                    });
-                }
-                else if (reg == plc.GetListenReg(SortMachine.Tag_ManualStart))
+                //if (reg == plc.GetListenReg(SortMachine.Tag_PhotographOK))
+                //{
+                //    plc.GetListenReg(SortMachine.Tag_RequestNext).WriteReg(1);
+                //    Task.Run(() =>
+                //    {
+                //        Thread.Sleep(500);
+                //        reg.WriteReg(1);
+
+                //    });
+                //}
+                if (reg == plc.GetListenReg(SortMachine.Tag_ManualStart))
                 {
                     plc.GetListenReg(SortMachine.Tag_SingleModeSort).WriteReg(CustomerEnv.SortingMacConfigValue.IsConnectToCuttingMac == false ? 1 : 0);
                     reg.WriteReg(1);
@@ -306,9 +317,14 @@ namespace SCADA_DAQ.Customer.Views.Menu.UctFrmSorting
 
         }
 
-        private void FeedBtn_Click(object sender, RoutedEventArgs e)
+        private void RestartBtn_Click(object sender, RoutedEventArgs e)
         {
-            plc.GetListenReg(SortMachine.Tag_StartSort).SetBit();
+            //plc.GetListenReg(SortMachine.Tag_StartSort).SetBit();
+            if (plc.Labels.Where(t => Math.Min(t.ActualWidth, t.ActualLength) <= 80 ||
+                                                                Math.Max(t.ActualWidth, t.ActualLength) <= 250).FirstOrDefault() != null)
+            {
+                plc.GetListenReg(SortMachine.Tag_SmallBoardManualConfirm).SetBit();
+            }
             plc.GetListenReg(SortMachine.Tag_FeedBtn).SetBit();
             Task.Run(() =>
             {