Browse Source

开料分拣取消人工选择/完善日志

陈子杰 3 months ago
parent
commit
69c45cd062

+ 1 - 1
SCADA_DAQ.Service/Models/BoardTaskModel.cs

@@ -7,7 +7,7 @@ using System.Security.Permissions;
 using System.Text;
 using System.Threading.Tasks;
 
-namespace SCADA_DAQ.Customer.Models
+namespace SCADA_DAQ.Customer.Service.Models
 {
     /// <summary>
     /// 

+ 62 - 40
SCADA_DAQ/Customer/Machines/SortMachine.cs

@@ -139,6 +139,25 @@ namespace SCADA_DAQ.Customer.Machines
         }
         private LabelModel _CurrentLabel;
 
+
+        /// <summary>
+        /// 当前加工文件
+        /// </summary>
+        public string CurrentCycDoc
+        {
+            get { return _CurrentCycDoc; }
+            set
+            {
+                if (value != _CurrentCycDoc)
+                {
+                    _CurrentCycDoc = value;
+                    OnPropertyChanged(nameof(CurrentCycDoc));
+                }
+            }
+        }
+        private string _CurrentCycDoc;
+
+
         /// <summary>
         /// 
         /// </summary>
@@ -164,39 +183,39 @@ namespace SCADA_DAQ.Customer.Machines
             
             if (reg.Comment.Variable == Tag_StartSort && reg.Value == 1)
             {
-                _Lbls = GetLabes(File.FilePath);
-                Labels = new ObservableCollection<LabelModel>(_Lbls);
-                //var errorCount = 0;
-                //var end = false;
-                
-                //while (!end)
-                //{
-                //    if (CuttingMac.isConnected())
-                //    {
-                //        var ncName = new int[16];
-                //        CuttingMac.READ_plc_register(0, 16, out ncName);
-                //        _Lbls = GetLabes(CycFilePath(ncName));
-                //        Labels = new ObservableCollection<LabelModel>(_Lbls);
-                //        end = true;
-                //    }
-                //    else
-                //    {
-                //        errorCount++;
-                //        if (errorCount > 3)
-                //        {
-                //            if (MessageBox.Show("开料机连接失败,请检查网络连接!是否重新连接?", "获取开料机加工文件", MessageBoxButton.YesNo) == MessageBoxResult.Yes)
-                //            {
-                //                errorCount = 0;
-                //            }
-                //            else
-                //            {
-                //                GetListenReg(Tag_Reset).SetBit();
-                //                end = true;
-                //            }
-                            
-                //        }
-                //    }
-                //}
+                //_Lbls = GetLabes(File.FilePath);
+                //Labels = new ObservableCollection<LabelModel>(_Lbls);
+                var errorCount = 0;
+                var end = false;
+
+                while (!end)
+                {
+                    if (CuttingMac.isConnected())
+                    {
+                        var ncName = new int[40];
+                        CuttingMac.READ_plc_register(7200, 7240, out ncName);
+                        _Lbls = GetLabes(CycFilePath(ncName));
+                        Labels = new ObservableCollection<LabelModel>(_Lbls);
+                        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);
             }
@@ -587,10 +606,10 @@ namespace SCADA_DAQ.Customer.Machines
             var code = new byte[values.Count() * 4];
             for (int i = 0; i < values.Count(); i++)
             {
-                code[0 + i * 4] = (byte)(values[i] >> 24);
-                code[1+ i * 4] = (byte)(values[i] >> 16);
-                code[2+ i * 4] = (byte)(values[i] >> 8);
-                code[3 + i * 4] = (byte)(values[i] >> 0);
+                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[3 + i * 4] = (byte)(values[i] >> 24);
             }
             for (int i = 0; i < code.Count(); i++)
             {
@@ -600,9 +619,12 @@ namespace SCADA_DAQ.Customer.Machines
 
                 }
             }
-            return str;
-            //var fileName = new DirectoryInfo(CustomerEnv.SortingMacConfigValue.CycFolder).GetFiles().Where(t => t.Name.Contains("202407092125_01")).FirstOrDefault();
-            //return CustomerEnv.SortingMacConfigValue.CycFolder + $@"\{fileName}";
+            log.Info($"开料机解析的加工文件为{str}");
+            //return str;
+            var fileName ="Label_"+str.Replace(".nc",".cyc");
+            CurrentCycDoc = fileName;
+            var filePath = new DirectoryInfo(CustomerEnv.SortingMacConfigValue.CycFolder).GetFiles().Where(t => t.Name.Contains(fileName)).FirstOrDefault();
+            return CustomerEnv.SortingMacConfigValue.CycFolder + $@"\{fileName}";
         }
 
         /// <summary>

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

@@ -0,0 +1,76 @@
+using SCADA.CommonLib;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace SCADA_DAQ.Customer.Models.BackOfSortingDelivery
+{
+    public class SettingModel : ObservableObject
+    {
+
+        /// <summary>
+        /// Mes报工接口参数
+        /// </summary>
+        /// 
+        [AutoViewProperty("Mes报工参数", Icon = "PlaylistMinus")]
+
+        public MesModel MesSetting
+        {
+            get { return _MesSetting; }
+            set
+            {
+                if (value != _MesSetting)
+                {
+                    _MesSetting = value;
+                    OnPropertyChanged(nameof(MesSetting));
+                }
+            }
+        }
+        private MesModel _MesSetting = new MesModel();
+
+
+        /// <summary>
+        /// 最小板材尺寸-异型通道
+        /// </summary>
+        /// 
+        [AutoViewProperty("最小板材尺寸",Icon = "PlaylistMinus")]
+        public int MinSize
+        {
+            get { return _MinSize; }
+            set
+            {
+                if (value != _MinSize)
+                {
+                    _MinSize = value;
+                    OnPropertyChanged(nameof(MinSize));
+                }
+            }
+        }
+        private int _MinSize;
+
+
+        /// <summary>
+        /// 最小板材尺寸比例-异型通道
+        /// </summary>
+        /// 
+        [AutoViewProperty("最小板材尺寸比例", Icon = "PlaylistMinus")]
+
+        public decimal MinProportion
+        {
+            get { return _MinProportion; }
+            set
+            {
+                if (value != _MinProportion)
+                {
+                    _MinProportion = value;
+                    OnPropertyChanged(nameof(MinProportion));
+                }
+            }
+        }
+        private decimal _MinProportion;
+
+
+    }
+}

+ 5 - 5
SCADA_DAQ/Customer/Models/BoardTaskModel.cs

@@ -107,7 +107,7 @@ namespace SCADA_DAQ.Customer.Models
         /// 板件ID
         /// </summary>
         [AutoViewProperty("板件ID")]
-        [CsvLabel("板件ID")]
+        [CsvLabel("编码")]
         [Column(T_Col_Name.App_Hold_BoardInfo.BoardID_Str)]
 
         public string BoardID
@@ -160,17 +160,17 @@ namespace SCADA_DAQ.Customer.Models
 
         public decimal Height
         {
-            get { return _Length; }
+            get { return _Height; }
             set
             {
-                if (value != _Length)
+                if (value != _Height)
                 {
-                    _Length = value;
+                    _Height = value;
                     OnPropertyChanged(nameof(Height));
                 }
             }
         }
-        private decimal _Length;
+        private decimal _Height;
 
 
 

+ 10 - 4
SCADA_DAQ/Customer/Service/ScannerService.cs

@@ -70,6 +70,8 @@ namespace SCADA_DAQ.Customer.Service
         {
             if (IsRunning) { return false; }
             RpcService.GetInstance().Regiseter(this);   //将服务中方法注册到RPC服务器,可以给WebApi调用
+            var width = 66;
+            //var a = Math.Min(66m,100m) / Math.Max(66m,100m);
             //var a = Env.DAL.App_Hold_BoardInfo.GetData<BoardTaskModel>();
                                                         //try
                                                         //{
@@ -88,7 +90,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);
+            //var a = Math.Round(11.5);
             return base.Start();
         }
 
@@ -109,15 +111,19 @@ 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.Min(barcodeTask.Width,barcodeTask.Height) > 150))
+            if (barcode != "NoRead" && barcodeTask != null)
             {
                 //先判断是否异型 
-                if (barcodeTask.IsAbnormalShape)
+                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)
                 {
                     Plc1.GetListenReg(SortingDeliveryMachine.Tag_CodeMatch).WriteReg(2);
 
                     //Plc1.GetListenReg(SortingDeliveryMachine.Tag_IsLeftovers).WriteReg(0);
                     Plc1.LeftLoversOrAbnormal.Enqueue(2);
+                    Log.Info("板件异型或尺寸或比例太小!");
+
                 }
                 else
                 {
@@ -159,7 +165,7 @@ namespace SCADA_DAQ.Customer.Service
                 //Plc1.GetListenReg(SortingDeliveryMachine.Tag_IsLeftovers).WriteReg(1);
                 Plc1.LeftLoversOrAbnormal.Enqueue(1);
 
-                Log.Info($"没有获取到条码或尺寸小于150");
+                Log.Info($"没有获取到条码");
             }
             
             

+ 18 - 0
SCADA_DAQ/Customer/SortingEnv.cs

@@ -0,0 +1,18 @@
+using SCADA.CommonLib;
+using SCADA_DAQ.Customer.Models;
+using SCADA_DAQ.Customer.Models.BackOfSortingDelivery;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace SCADA_DAQ.Customer
+{
+    static class SortingEnv
+    {
+        public static SettingModel SortingWorkReportSettingValue { get => SortingWorkReportSetting.Value; }
+        public static AutoSaveParameterItem<SettingModel> SortingWorkReportSetting { get; set; } =
+            AutoSaveParameterItem.Create("SortingWorkReport", new SettingModel());
+    }
+}

+ 15 - 0
SCADA_DAQ/Customer/Views/Menu/UctFrmBackOfSortingDelivery/UctFrmSortingDeliverySetting.xaml

@@ -0,0 +1,15 @@
+<wpfcontrol:BaseUctFrm  xmlns:wpfcontrol="clr-namespace:SCADA.CommonCtrl.WpfControl;assembly=SCADA.CommonCtrl"
+                        x:Class="SCADA_DAQ.Customer.Views.Menu.UctFrmBackOfSortingDelivery.UctFrmSortingDeliverySetting"
+      xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
+      xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
+      xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
+      xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
+      xmlns:local="clr-namespace:SCADA_DAQ.Customer.Views.Menu.UctFrmBackOfSortingDelivery"
+      mc:Ignorable="d" 
+      d:DesignHeight="450" d:DesignWidth="800"
+      Title="UctFrmSortingDeliverySetting">
+
+    <Grid Margin="10">
+        <GroupBox Header="参数设置" x:Name="SettingGroup"/>
+    </Grid>
+</wpfcontrol:BaseUctFrm>

+ 33 - 0
SCADA_DAQ/Customer/Views/Menu/UctFrmBackOfSortingDelivery/UctFrmSortingDeliverySetting.xaml.cs

@@ -0,0 +1,33 @@
+using SCADA.CommonCtrl.WpfControl;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using System.Windows;
+using System.Windows.Controls;
+using System.Windows.Data;
+using System.Windows.Documents;
+using System.Windows.Input;
+using System.Windows.Media;
+using System.Windows.Media.Imaging;
+using System.Windows.Navigation;
+using System.Windows.Shapes;
+
+namespace SCADA_DAQ.Customer.Views.Menu.UctFrmBackOfSortingDelivery
+{
+    /// <summary>
+    /// UctFrmSortingDeliverySetting.xaml 的交互逻辑
+    /// </summary>
+    /// 
+    [UctMenu("开料输送线参数设置",Icon ="设置")]
+    public partial class UctFrmSortingDeliverySetting : BaseUctFrm
+    {
+        public UctFrmSortingDeliverySetting()
+        {
+            InitializeComponent();
+            ToolBar.Visibility = Visibility.Collapsed;
+            SettingGroup.Content = new AutoView(SortingEnv.SortingWorkReportSettingValue) { MaxTitleWidth = 160};
+        }
+    }
+}

+ 3 - 2
SCADA_DAQ/Customer/Views/Menu/UctFrmSorting/UctFrmSortingMain.xaml

@@ -23,7 +23,8 @@
                 <RowDefinition Height="auto"/>
                 <RowDefinition />
             </Grid.RowDefinitions>
-            <ContentControl x:Name="PathSelect" Margin="5"/>
+            <!--<ContentControl x:Name="PathSelect" Margin="5"/>-->
+            <TextBlock Text="{Binding CurrentCycDoc,StringFormat=当前加工文件为:{0}}" x:Name="DocName" FontWeight="Bold" Margin="5" FontSize="22"/>
             <wpfcontrol:SmartGrid x:Name="DG_Labels" AutoGenerateColumns="True" ShowRowTips="False" Grid.Row="1"></wpfcontrol:SmartGrid>
 
         </Grid>
@@ -167,7 +168,7 @@
                                         <Setter Property="Foreground" Value="Lime"/>
                                     </DataTrigger>
                                     <DataTrigger Binding="{Binding Value}" Value="3">
-                                        <Setter Property="Text" Value="废料清完"/>
+                                        <Setter Property="Text" Value="废料清完,等待开料机请求信号"/>
                                         <Setter Property="Foreground" Value="Lime"/>
                                     </DataTrigger>
                                     <DataTrigger Binding="{Binding Value}" Value="4">

+ 3 - 8
SCADA_DAQ/Customer/Views/Menu/UctFrmSorting/UctFrmSortingMain.xaml.cs

@@ -55,7 +55,8 @@ namespace SCADA_DAQ.Customer.Views.Menu.UctFrmSorting
             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 };
+            //PathSelect.Content = new AutoView(plc.File) { FontSize = 22, MaxTitleWidth = 100, ContentWidth = 1000 };
+            DocName.DataContext = plc;
             if (plc != null)
             {
                 plc.NewBoardArrived += Plc_NewBoardArrived;
@@ -255,12 +256,7 @@ namespace SCADA_DAQ.Customer.Views.Menu.UctFrmSorting
             var btn = (IconButton)sender;
             if (btn.DataContext is RegInfo reg)
             {
-                if (reg == plc.GetListenReg(SortMachine.Tag_ManualStart) && plc.File.FilePath == null)
-                {
-                    MessageBox.Show("未选择分拣文件!");
-
-                }
-                else if (reg == plc.GetListenReg(SortMachine.Tag_PhotographOK))
+                if (reg == plc.GetListenReg(SortMachine.Tag_PhotographOK))
                 {
                     plc.GetListenReg(SortMachine.Tag_RequestNext).WriteReg(1);
                     Task.Run(() =>
@@ -273,7 +269,6 @@ namespace SCADA_DAQ.Customer.Views.Menu.UctFrmSorting
                 else
                 {
                     reg.WriteReg(1);
-
                 }
             }
         }

+ 2 - 2
SCADA_DAQ/Customer/Views/Menu/UctFrmSorting/UctFrmSorttingSetting.xaml.cs

@@ -22,7 +22,7 @@ namespace SCADA_DAQ.Customer.Views.Menu.UctFrmSorting
     /// UctFrmSorttingSetting.xaml 的交互逻辑
     /// </summary>
     /// 
-    [UctMenu("开料分拣参数设置",Icon ="看板")]
+    [UctMenu("开料分拣参数设置",Icon ="设置")]
     public partial class UctFrmSorttingSetting : BaseUctFrm
     {
         public UctFrmSorttingSetting()
@@ -36,7 +36,7 @@ namespace SCADA_DAQ.Customer.Views.Menu.UctFrmSorting
             //int cyc;
             //int count;
             //cnc.READ_time(out time, out acctime, out cyc, out count);
-       
+        
             SysSetting.Content = new AutoView(CustomerEnv.SortingMacConfigValue) { MaxTitleWidth = 200 };
         }
     }

+ 2 - 8
SCADA_DAQ/SCADA_DAQ.csproj.user

@@ -8,7 +8,7 @@
     <Compile Update="Customer\Views\Menu\UctFrmBackOfSortingDelivery\UctFrmSortingDelivery.xaml.cs">
       <SubType>Code</SubType>
     </Compile>
-    <Compile Update="Customer\Views\Menu\UctFrmGantry\UctFrmGantryParameter.xaml.cs">
+    <Compile Update="Customer\Views\Menu\UctFrmBackOfSortingDelivery\UctFrmSortingDeliverySetting.xaml.cs">
       <SubType>Code</SubType>
     </Compile>
     <Compile Update="Customer\Views\Menu\UctFrmGantry\UctFrmGantryMain.xaml.cs">
@@ -56,9 +56,6 @@
     <Compile Update="Customer\Views\Uct\UctAlarmBar.xaml.cs">
       <SubType>Code</SubType>
     </Compile>
-    <Compile Update="Customer\Views\Uct\UctGantry\UctEdgeFigureControl.xaml.cs">
-      <SubType>Code</SubType>
-    </Compile>
     <Compile Update="Customer\Views\Uct\UctGantry\UctGantryControl.xaml.cs">
       <SubType>Code</SubType>
     </Compile>
@@ -94,7 +91,7 @@
     <Page Update="Customer\Views\Menu\UctFrmBackOfSortingDelivery\UctFrmSortingDelivery.xaml">
       <SubType>Designer</SubType>
     </Page>
-    <Page Update="Customer\Views\Menu\UctFrmGantry\UctFrmGantryParameter.xaml">
+    <Page Update="Customer\Views\Menu\UctFrmBackOfSortingDelivery\UctFrmSortingDeliverySetting.xaml">
       <SubType>Designer</SubType>
     </Page>
     <Page Update="Customer\Views\Menu\UctFrmGantry\UctFrmGantryMain.xaml">
@@ -142,9 +139,6 @@
     <Page Update="Customer\Views\Uct\UctAlarmBar.xaml">
       <SubType>Designer</SubType>
     </Page>
-    <Page Update="Customer\Views\Uct\UctGantry\UctEdgeFigureControl.xaml">
-      <SubType>Designer</SubType>
-    </Page>
     <Page Update="Customer\Views\Uct\UctGantry\UctGantryControl.xaml">
       <SubType>Designer</SubType>
     </Page>