Browse Source

开料分拣添加连线选择,滚线最小比例调整

陈子杰 3 months ago
parent
commit
3ba17ab68a

+ 59 - 48
SCADA_DAQ/Customer/Machines/SortMachine.cs

@@ -74,22 +74,22 @@ namespace SCADA_DAQ.Customer.Machines
         private double CenterX {  get; set; }   
         private double CenterY { get; set; }    
 
-        /// <summary>
-        /// 文件选择
-        /// </summary>
-        public FileSelectModel File
-        {
-            get { return _FilePath; }
-            set
-            {
-                if (value != _FilePath)
-                {
-                    _FilePath = value;
-                    OnPropertyChanged(nameof(File));
-                }
-            }
-        }
-        private FileSelectModel _FilePath = new FileSelectModel();
+        ///// <summary>
+        ///// 文件选择
+        ///// </summary>
+        //public FileSelectModel File
+        //{
+        //    get { return _FilePath; }
+        //    set
+        //    {
+        //        if (value != _FilePath)
+        //        {
+        //            _FilePath = value;
+        //            OnPropertyChanged(nameof(File));
+        //        }
+        //    }
+        //}
+        //private FileSelectModel _FilePath = new FileSelectModel();
 
 
         /// <summary>
@@ -187,56 +187,69 @@ namespace SCADA_DAQ.Customer.Machines
                 //Labels = new ObservableCollection<LabelModel>(_Lbls);
                 var errorCount = 0;
                 var end = false;
-                if (BaseDevice.Simulated)
+                if (BaseDevice.Simulated || !CustomerEnv.SortingMacConfigValue.IsConnectToCuttingMac)
                 {
                     end = true;
-                    _Lbls = GetLabes(File.FilePath);
-                    Labels = new ObservableCollection<LabelModel>(_Lbls);
-                }
-                while (!end)
-                {
-                    if (CuttingMac.isConnected())
+                    if (CustomerEnv.SortingMacConfigValue.CycFilePath != null)
                     {
-                        var ncName = new int[40];
-                        CuttingMac.READ_plc_register(7200, 7240, out ncName);
-                        var path = CycFilePath(ncName);
-                        if (path != null)
-                        {
-                            _Lbls = GetLabes(path);
-                            Labels = new ObservableCollection<LabelModel>(_Lbls);
-                        }
-                        else
-                        {
-                            
-                            MessageBox.Show($"文件不存在");
-                            GetListenReg(Tag_Reset).SetBit();
-
-                        }
-                        end = true;
+                        _Lbls = GetLabes(CustomerEnv.SortingMacConfigValue.CycFilePath);
+                        Labels = new ObservableCollection<LabelModel>(_Lbls);
                     }
                     else
                     {
-                        errorCount++;
-                        if (errorCount > 3)
+                        MessageBox.Show($"参数页面中的'单机运行时cyc文件'为空!");
+                    }
+                    
+                }
+                else
+                {
+                    while (!end)
+                    {
+                        if (CuttingMac.isConnected())
                         {
-                            if (MessageBox.Show("开料机连接失败,请检查网络连接!是否重新连接?", "获取开料机加工文件", MessageBoxButton.YesNo) == MessageBoxResult.Yes)
+                            var ncName = new int[40];
+                            CuttingMac.READ_plc_register(7200, 7240, out ncName);
+                            var path = CycFilePath(ncName);
+                            if (path != null)
                             {
-                                errorCount = 0;
+                                _Lbls = GetLabes(path);
+                                Labels = new ObservableCollection<LabelModel>(_Lbls);
                             }
                             else
                             {
+
+                                MessageBox.Show($"文件不存在");
                                 GetListenReg(Tag_Reset).SetBit();
-                                end = true;
+
                             }
+                            end = true;
+                        }
+                        else
+                        {
+                            errorCount++;
+                            if (errorCount > 3)
+                            {
+                                if (MessageBox.Show("开料机连接失败,请检查网络连接!是否重新连接?", "获取开料机加工文件", MessageBoxButton.YesNo) == MessageBoxResult.Yes)
+                                {
+                                    errorCount = 0;
+                                }
+                                else
+                                {
+                                    GetListenReg(Tag_Reset).SetBit();
+                                    end = true;
+                                }
 
+                            }
                         }
                     }
                 }
+                
                 reg.ResetBit(); 
                 NewBoardArrived?.Invoke(this, EventArgs.Empty);
             }
             else if (reg.Comment.Variable == Tag_RequestNext && reg.Value == 1 && reg.OldValue == 0)
             {
+                GetListenReg(Tag_AAutoSpeed).WriteReg(CustomerEnv.SortingMacConfigValue.AxisAAutoHighSpeed);
                 CurrentLabel = _Lbls.FirstOrDefault(t => t.Status == Models.TaskStatus.None);
                 if (CurrentLabel != null)
                 {
@@ -299,7 +312,6 @@ namespace SCADA_DAQ.Customer.Machines
                                     BoardInfo.CupCenter = new Point(BoardInfo.CupCenter.X - cup1NewCenter.X, BoardInfo.CupCenter.Y - cup1NewCenter.Y);
                                     BoardInfo.ReleaseY = CurrentLabel.ActualWidth / 2 - 180;
                                     //BoardInfo.ReleaseY = CurrentLabel.ActualWidth / 2 - 170;
-
                                 }
                             }
                             else
@@ -309,7 +321,7 @@ namespace SCADA_DAQ.Customer.Machines
                                                                                                          //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.ActualLength / 2 - 180;
                                 //BoardInfo.ReleaseY = CurrentLabel.ActualWidth / 2 - 20;
 
 
@@ -327,7 +339,7 @@ namespace SCADA_DAQ.Customer.Machines
                                     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.ActualLength / 2 - 180;
                                 //BoardInfo.ReleaseY = CurrentLabel.ActualWidth / 2 - 20;
 
 
@@ -372,7 +384,6 @@ namespace SCADA_DAQ.Customer.Machines
                 //var _lbl = new LabelModel() { ID = CurrentLabel.ID };
                 var _lbl = new LabelModel();
                 var isCancel = false;
-                GetListenReg(Tag_AAutoSpeed).WriteReg(CustomerEnv.SortingMacConfigValue.AxisAAutoHighSpeed);
                 if (GetListenReg(Tag_CameraEnable).Value == 0)
                 {
                     _barcodeReader = MachineServer.GetInstance().GetMachine<SampleBarcodeReader>("BarcodeReader4");

+ 20 - 0
SCADA_DAQ/Customer/Models/BackOfSortingDelivery/SettingModel.cs

@@ -72,5 +72,25 @@ namespace SCADA_DAQ.Customer.Models.BackOfSortingDelivery
         private decimal _MinProportion;
 
 
+        /// <summary>
+        /// 板材大于200是否启用最小比例限制
+        /// </summary>
+        /// 
+        [AutoViewProperty(">200mm启用比例限制", Icon = "PlaylistMinus")]
+
+        public bool IsMinProportionEnable
+        {
+            get { return _IsMinProportionEnable; }
+            set
+            {
+                if (value != _IsMinProportionEnable)
+                {
+                    _IsMinProportionEnable = value;
+                    OnPropertyChanged(nameof(IsMinProportionEnable));
+                }
+            }
+        }
+        private bool _IsMinProportionEnable;
+
     }
 }

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

@@ -130,6 +130,51 @@ namespace SCADA_DAQ.Customer.Models.SortingModel
         private int _AxisAAutoLowSpeed;
 
 
+        /// <summary>
+        /// 是否与开料机连线
+        /// </summary>
+        /// 
+        [AutoViewProperty("是否与开料机连线", Icon = "Connection")]
+
+        public bool IsConnectToCuttingMac
+        {
+            get { return _IsConnectToCuttingMac; }
+            set
+            {
+                if (value != _IsConnectToCuttingMac)
+                {
+                    _IsConnectToCuttingMac = value;
+                    OnPropertyChanged(nameof(IsConnectToCuttingMac));
+                }
+            }
+        }
+        private bool _IsConnectToCuttingMac;
+
+
+
+        /// <summary>
+        /// 单机运行时cyc文件选择
+        /// </summary>
+        /// 
+        [AutoViewProperty("单机运行时cyc文件", Icon = "FileDocumentMultiple", StringType = StringType.IsFilePath)]
+        public string CycFilePath
+        {
+            get { return _CycFilePath; }
+            set
+            {
+                if (value != _CycFilePath)
+                {
+                    _CycFilePath = value;
+                    OnPropertyChanged(nameof(CycFilePath));
+                }
+            }
+        }
+        private string _CycFilePath;
+
+
+
+
+
         /// <summary>
         /// 吸盘1坐标偏移
         /// </summary>

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

@@ -113,10 +113,15 @@ namespace SCADA_DAQ.Customer.Service
             var api = new WebApiHelper(_ScannerServiceConfig.Url);
             if (barcode != "NoRead" && barcodeTask != null)
             {
+                var MinProportion = Math.Min(barcodeTask.Width, barcodeTask.Height) / Math.Max(barcodeTask.Width, barcodeTask.Height);
+                var minSize = Math.Min(barcodeTask.Width, barcodeTask.Height);
                 //先判断是否异型 
-                if (barcodeTask.IsAbnormalShape || 
-                    Math.Min(barcodeTask.Width, barcodeTask.Height) < SortingEnv.SortingWorkReportSettingValue.MinSize
-                    || Math.Min(barcodeTask.Width, barcodeTask.Height) / Math.Max(barcodeTask.Width, barcodeTask.Height) < SortingEnv.SortingWorkReportSettingValue.MinProportion)
+                //大于200启用限制时判断最小比例
+                //
+                if (barcodeTask.IsAbnormalShape ||
+                    minSize < SortingEnv.SortingWorkReportSettingValue.MinSize
+                    || (MinProportion < SortingEnv.SortingWorkReportSettingValue.MinProportion && SortingEnv.SortingWorkReportSettingValue.IsMinProportionEnable
+                        || (MinProportion < SortingEnv.SortingWorkReportSettingValue.MinProportion && minSize < 200 && !SortingEnv.SortingWorkReportSettingValue.IsMinProportionEnable)))
                 {
                     Plc1.GetListenReg(SortingDeliveryMachine.Tag_CodeMatch).WriteReg(2);
 

+ 2 - 1
SCADA_DAQ/Customer/UctFrmAnimation.xaml

@@ -14,7 +14,8 @@
             <RowDefinition/>
             <RowDefinition/>
         </Grid.RowDefinitions>
-        <uctpackagesorting:UctBoardInfo x:Name="board" Width="500" Height="100"/>
+        <!--<uctpackagesorting:UctBoardInfo x:Name="board" Width="500" Height="100"/>-->
+        <Rectangle x:Name="Test" Width="400" Height="50" Fill="Red"/>
         <Button Content="开始" HorizontalAlignment="Right" VerticalAlignment="Bottom" Click="Button_Click" />
     </Grid>
 </wpfcontrol:BaseUctFrm>

+ 59 - 26
SCADA_DAQ/Customer/UctFrmAnimation.xaml.cs

@@ -3,6 +3,7 @@ using System;
 using System.Collections.Generic;
 using System.Linq;
 using System.Text;
+using System.Threading;
 using System.Threading.Tasks;
 using System.Windows;
 using System.Windows.Controls;
@@ -24,42 +25,74 @@ namespace SCADA_DAQ.Customer
     [UctMenu("动画",Icon ="看板")]
     public partial class UctFrmAnimation : BaseUctFrm
     {
+        public Task task { get; set; }
+        CancellationTokenSource cts = new CancellationTokenSource();
+
         public UctFrmAnimation()
         {
             InitializeComponent();
+            CancellationToken token = cts.Token;
+            task = Task.Run(() =>
+            {
+                while (true)
+                {
+                    token.ThrowIfCancellationRequested();
+
+                    Dispatcher.Invoke(() =>
+                    {
+                        Test.Opacity = Test.Opacity == 1 ? 0 : 1;
+                    });
+                    Thread.Sleep(1000);
+
+                }
+            }, token);
         }
 
         private void Button_Click(object sender, RoutedEventArgs e)
         {
+            cts.Cancel();
+            try
+            {
+                task.Wait();
+            }
+            catch (Exception)
+            {
 
-            var storyboard = new Storyboard();
-            Int32Animation int32Animation = new Int32Animation();
-            //trans.Children.Add(int32Animation);
-            //board.RenderTransform =
-            int32Animation.From = 0;
-            int32Animation.To = 1;
-            int32Animation.By = 1;
-            int32Animation.Duration = new TimeSpan(0, 0, 2);
-            int32Animation.AutoReverse = true;
-            int32Animation.RepeatBehavior = RepeatBehavior.Forever;
-            board.BeginAnimation(Grid.RowProperty, int32Animation);
+                throw;
+            }
+
+
+            //动画
+            //var storyboard = new Storyboard();
+            //Int32Animation int32Animation = new Int32Animation();
+            ////trans.Children.Add(int32Animation);
+            ////board.RenderTransform =
+            //int32Animation.From = 0;
+            //int32Animation.To = 1;
+            //int32Animation.By = 1;
+            //int32Animation.Duration = new TimeSpan(0, 0, 2);
+            //int32Animation.AutoReverse = true;
+            //int32Animation.RepeatBehavior = RepeatBehavior.Forever;
+            //board.BeginAnimation(Grid.RowProperty, int32Animation);
+
+            //TransformGroup trans = new TransformGroup();
+            //var rotation = new RotateTransform();
+            //board.RenderTransformOrigin = new Point(0.5, 0.5);
+            //trans.Children.Add(rotation);
+            //board.RenderTransform = trans;
+            //var boardRotation = new DoubleAnimation()
+            //{
+            //    From = 0,
+            //    To = 360,
+            //    By = 1,
+            //    Duration = new TimeSpan(0, 0, 2),
+            //    AutoReverse = true,
+            //    RepeatBehavior = RepeatBehavior.Forever,
+            //};
+            //rotation.BeginAnimation(RotateTransform.AngleProperty, boardRotation);
 
-            TransformGroup trans = new TransformGroup();
-            var rotation = new RotateTransform();
-            board.RenderTransformOrigin = new Point(0.5, 0.5);
-            trans.Children.Add(rotation);
-            board.RenderTransform = trans;
-            var boardRotation = new DoubleAnimation()
-            {
-                From = 0,
-                To = 360,
-                By = 1,
-                Duration = new TimeSpan(0, 0, 2),
-                AutoReverse = true,
-                RepeatBehavior = RepeatBehavior.Forever,
-            };
-            rotation.BeginAnimation(RotateTransform.AngleProperty, boardRotation);
 
+            //故事板
             //Storyboard.SetTarget(int32Animation, board);
             //Storyboard.SetTarget(boardRotation, board);
 

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

@@ -210,13 +210,8 @@ namespace SCADA_DAQ.Customer.Views.Menu.UctFrmSorting
         {
             if (plc.BaseDevice.Simulated)
             {
-                ShowChildWindow(new AutoView(plc.File), "选择模拟的加工文件", () =>
-                {
-                    Dispatcher.Invoke(() =>
-                    {
-                        Btn_Sim.IsEnabled = false;
+                    Btn_Sim.IsEnabled = false;
 
-                    });
                     //plc.Labels = new ObservableCollection<LabelModel>(plc.GetLabes(plc.File.FilePath));
                     Task.Run(async () =>
                     {
@@ -246,14 +241,11 @@ namespace SCADA_DAQ.Customer.Views.Menu.UctFrmSorting
                             Btn_Sim.IsEnabled = true;
                         });
                     });
-
-                    return true;
-                });
-                //if (string.IsNullOrEmpty(plc.File.FilePath))
-                //{
-                //    MessageBox.Show(Application.Current.MainWindow, "没有选择有效的NC文件");
-                //    return;
-                //}
+                if (string.IsNullOrEmpty(CustomerEnv.SortingMacConfigValue.CycFilePath))
+                {
+                    MessageBox.Show(Application.Current.MainWindow, "没有选择有效的cyc文件");
+                    return;
+                }
             }
             else
             {