Browse Source

将保压上下限用于判断的值,移植到产品配方中

844184169 6 months ago
parent
commit
f6e2f6fa6d

+ 0 - 7
TeamAAS-VM/Core/FilePath.cs

@@ -62,13 +62,6 @@ namespace TeamAAS_VP.Core
         /// </summary>
         public static string BackgroundScriptPath = "..//Background Script";
 
-        /// <summary>
-        /// 保压参数存放路径
-        /// </summary>
-        public static string PressureParamterConfigPath = "..//Config//PressureParamterConfig.cfg";
-
-
-
         public static string ScanRS232ConfigPath = "..//Config//ScanRS232Config.cfg";
 
     }

+ 9 - 50
TeamAAS-VM/Core/Management.cs

@@ -1,62 +1,30 @@
-using Basler.Pylon;
-using Cognex.VisionPro;
-using Cognex.VisionPro.ToolBlock;
-using CSScripting;
-using MathNet.Numerics.Distributions;
-using MathNet.Numerics.LinearAlgebra;
-using MathNet.Numerics.RootFinding;
-using NPOI.SS.Formula.Functions;
-using NPOI.Util;
-using Opc.Ua;
-using OpenCvSharp;
-using OpenCvSharp.Flann;
+using MathNet.Numerics.LinearAlgebra;
 using Prism.Events;
 using Prism.Ioc;
 using Prism.Mvvm;
 using Prism.Regions;
-using Prism.Services.Dialogs;
 using System;
-using System.Collections;
 using System.Collections.Generic;
 using System.Collections.ObjectModel;
-using System.ComponentModel;
 using System.Drawing;
 using System.IO;
 using System.Linq;
 using System.Net.Sockets;
-using System.Reflection.Metadata;
-using System.Security.Cryptography;
 using System.Text;
 using System.Threading;
 using System.Threading.Tasks;
-using System.Windows;
-using System.Windows.Documents;
-using System.Windows.Interop;
 using System.Windows.Media;
-using System.Windows.Media.Media3D;
-using Team.FFFeederService;
 using Team.FFFeederService.Interfaces;
-using TeamAAS_VP;
 using TeamAAS_VP.Core.PLCs;
-using TeamAAS_VP.Core.Robots;
 using TeamAAS_VP.Core.ScrewDriver;
-using TeamAAS_VP.Data;
 using TeamAAS_VP.Enums;
 using TeamAAS_VP.Events;
 using TeamAAS_VP.Interfaces;
 using TeamAAS_VP.Models;
-using TeamAAS_VP.Models.Calibration;
-using TeamAAS_VP.Models.Feeder;
-using TeamAAS_VP.Models.Product;
 using TeamAAS_VP.Resources.Languages;
-using TeamAAS_VP.Services;
-using TeamAAS_VP.ViewModels.Home;
 using TouchSocket.Core;
 using TouchSocket.SerialPorts;
 using TouchSocket.Sockets;
-using static MaterialDesignThemes.Wpf.Theme.ToolBar;
-using static Org.BouncyCastle.Math.EC.ECCurve;
-using static System.Windows.Forms.AxHost;
 
 namespace TeamAAS_VP.Core
 {
@@ -1225,17 +1193,14 @@ namespace TeamAAS_VP.Core
             var addressConfig = _configService.GetPlcAddresses();
             var plc = _plcService.GetPlcByNumber(addressConfig.PlcNo) as OpcUaClientPLC;
             if (plc == null || !plc.IsConnected) return;
+            // 获取当前产品
+            var currentProduct = _productService.GetCurrentProduct();
+            if (currentProduct == null) return;
             try
             {
-                PressureModel models = new PressureModel();
-                if (!File.Exists(FilePath.PressureParamterConfigPath))
-                {
-                    FileHelper.WriteJsonFile(models, FilePath.PressureParamterConfigPath);
-                }
-                models = FileHelper.ReadJsonFile<PressureModel>(FilePath.PressureParamterConfigPath);
-                await plc.WriteNodeAsync(addressConfig.Down_Time.Address, models.PressureTime);
-                await plc.WriteNodeAsync(addressConfig.Down_WetOut_Num.Address, models.PressureNum);
-                await plc.WriteNodeAsync(addressConfig.Down_WetOut_Num_max.Address, models.PressureNumMax);
+                await plc.WriteNodeAsync(addressConfig.Down_Time.Address, currentProduct.GlobalParamEx.DownPressure.PressureTime);
+                await plc.WriteNodeAsync(addressConfig.Down_WetOut_Num.Address, currentProduct.GlobalParamEx.DownPressure.PressureNum);
+                await plc.WriteNodeAsync(addressConfig.Down_WetOut_Num_max.Address, currentProduct.GlobalParamEx.DownPressure.PressureNumMax);
             }
             catch (Exception)
             {
@@ -2589,11 +2554,6 @@ namespace TeamAAS_VP.Core
                                     assypress = currentPressure[i].ToString("F2");
                                     SendTaskMessage($"组装压力:{assypress}", MessageLevel.Debug);
 
-                                    var res = FileHelper.ReadJsonFile<PressureModel>(FilePath.PressureParamterConfigPath);
-                                    if (res.PressureUpLimit > 0)
-                                    {
-
-                                    }
                                     //cc-复检cc,assypress-组装站压力
                                     (bool isSuccess, string response) = await _mesService.SubmitGetAsync(i, ProductMainSN[i], comp, cc, assypress, resultIndex == 1 ? true : false, _LastMesCheckTime[i], serverTimeResult.Now);
                                     if (!stationConfig.EnableMES || isSuccess)
@@ -2618,7 +2578,6 @@ namespace TeamAAS_VP.Core
                                         if (!string.IsNullOrEmpty(stationConfig.SaveCsvPath))
                                         {
                                             bool assyPress = resultIndex == 1 ? true : false;
-                                            var pre = FileHelper.ReadJsonFile<PressureModel>(FilePath.PressureParamterConfigPath);
                                             DFC.Clear();
 
                                             foreach (var item in mes_cc)
@@ -2652,8 +2611,8 @@ namespace TeamAAS_VP.Core
                                                 PROCESS_START_TIME = _LastMesCheckTime[i].ToString(),
                                                 CTQ_NAME = "Assy_Pressure",
                                                 CTQ_VALUE = Math.Round(double.Parse(assypress), 3).ToString(),
-                                                CTQ_LSL = pre.PressureDownLimit.ToString("F3"),
-                                                CTQ_USL = pre.PressureUpLimit.ToString("F3"),
+                                                CTQ_LSL = currentProduct.GlobalParamEx.DownPressure.PressureDownLimit.ToString("F3"),
+                                                CTQ_USL = currentProduct.GlobalParamEx.DownPressure.PressureUpLimit.ToString("F3"),
                                                 PROCESS_END_TIME = serverTimeResult.Now.ToString(),
                                                 SUPPLIER_NAME = stationConfig.DataInfo.SUPPLIER_NAME,
                                                 COMMODITY_TYPE = stationConfig.DataInfo.COMMODITY_TYPE,

+ 17 - 0
TeamAAS-VM/Models/Product/ProductGlobalParamEx.cs

@@ -0,0 +1,17 @@
+using Prism.Mvvm;
+
+namespace TeamAAS_VP.Models.Product
+{
+    public class ProductGlobalParamEx : BindableBase
+    {
+        private PressureModel _DownPressure;
+        /// <summary>
+        /// 保压
+        /// </summary>
+        public PressureModel DownPressure
+        {
+            get { return _DownPressure; }
+            set { SetProperty(ref _DownPressure, value); }
+        }
+    }
+}

+ 15 - 4
TeamAAS-VM/Models/Product/ProductModel.cs

@@ -146,6 +146,16 @@ namespace TeamAAS_VP.Models
             set { SetProperty(ref _IsUserUpCamera, value); }
         }
 
+        private ProductGlobalParamEx _GlobalParamEx = new ProductGlobalParamEx();
+        /// <summary>
+        /// 全局参数扩展(保压/检测上下限)
+        /// </summary>
+        public ProductGlobalParamEx GlobalParamEx
+        {
+            get { return _GlobalParamEx; }
+            set { SetProperty(ref _GlobalParamEx, value); }
+        }
+
         private Guid _FixedUpCamera1ProcedureId;
         /// <summary>
         /// 固定向上相机1视觉流程ID
@@ -316,7 +326,7 @@ namespace TeamAAS_VP.Models
             set { SetProperty(ref _ScrewCameraPoints, value); }
         }
 
-        private PlcPoint _ScrewCameraLocalPos1= new PlcPoint();
+        private PlcPoint _ScrewCameraLocalPos1 = new PlcPoint();
         /// <summary>
         /// 锁付拍照点1对应的产品坐标系中的点位
         /// </summary>
@@ -442,7 +452,7 @@ namespace TeamAAS_VP.Models
             {
                 GlobalParamListCollection = new ObservableCollection<ProductGlobalParam>();
             }
-            globalParam.Number= GlobalParamListCollection.Count + 1;
+            globalParam.Number = GlobalParamListCollection.Count + 1;
             GlobalParamListCollection.Add(globalParam);
         }
 
@@ -462,7 +472,7 @@ namespace TeamAAS_VP.Models
                 gp.Number = number;
                 number++;
             }
-            GlobalParamListCollection=new ObservableCollection<ProductGlobalParam>(sortedList);
+            GlobalParamListCollection = new ObservableCollection<ProductGlobalParam>(sortedList);
         }
 
         public ProductModel Clone()
@@ -482,6 +492,7 @@ namespace TeamAAS_VP.Models
                 Accels = this.Accels,
                 Power = this.Power,
                 IsUserUpCamera = this.IsUserUpCamera,
+                GlobalParamEx = this.GlobalParamEx,
                 GlobalParamListCollection = new ObservableCollection<ProductGlobalParam>(this.GlobalParamListCollection.Select(gp => gp.Copy())),
                 PickCameraPoints = this.PickCameraPoints,
                 PickPoints = this.PickPoints,
@@ -493,7 +504,7 @@ namespace TeamAAS_VP.Models
                 PressurePlacePoints = this.PressurePlacePoints,
                 IsLoad = this.IsLoad,
                 IsCreate = this.IsCreate,
-                 ScrewCameraLocalPos1 = this.ScrewCameraLocalPos1,
+                ScrewCameraLocalPos1 = this.ScrewCameraLocalPos1,
                 ScrewCameraLocalPos2 = this.ScrewCameraLocalPos2
             };
         }

+ 1 - 0
TeamAAS-VM/TeamAAS-VP.csproj

@@ -547,6 +547,7 @@
     <Compile Include="Models\Feeder\ScrewFeederInfo.cs" />
     <Compile Include="Models\PhotoCaptureRecord.cs" />
     <Compile Include="Models\ProductWithMes.cs" />
+    <Compile Include="Models\Product\ProductGlobalParamEx.cs" />
     <Compile Include="Models\ScanRs232ConfigModel.cs" />
     <Compile Include="Models\PressureModel.cs" />
     <Compile Include="Models\ScrewFeederBatchRecord.cs" />

+ 4 - 24
TeamAAS-VM/ViewModels/SettingViewModel.cs

@@ -56,15 +56,6 @@ namespace TeamAAS_VP.ViewModels
         bool isFirstLoad = true;
 
         #region 属性
-
-        private PressureModel _DownPressureConfig = new PressureModel();
-
-        public PressureModel DownPressureConfig
-        {
-            get { return _DownPressureConfig; }
-            set { SetProperty(ref _DownPressureConfig, value); }
-        }
-
         private Management _management;
 
         public Management management
@@ -1276,19 +1267,14 @@ namespace TeamAAS_VP.ViewModels
 
         private void OnLoad()
         {
-            if (!File.Exists(FilePath.ScanRS232ConfigPath))
-            {
-                var scan = new ScanRs232ConfigModel();
-                FileHelper.WriteJsonFile(scan, FilePath.ScanRS232ConfigPath);
-            }
-            this.ScanConfig = FileHelper.ReadJsonFile<ScanRs232ConfigModel>(FilePath.ScanRS232ConfigPath);
             try
             {
-                if (!File.Exists(FilePath.PressureParamterConfigPath))
+                if (!File.Exists(FilePath.ScanRS232ConfigPath))
                 {
-                    FileHelper.WriteJsonFile(DownPressureConfig, FilePath.PressureParamterConfigPath);
+                    var scan = new ScanRs232ConfigModel();
+                    FileHelper.WriteJsonFile(scan, FilePath.ScanRS232ConfigPath);
                 }
-                DownPressureConfig = FileHelper.ReadJsonFile<PressureModel>(FilePath.PressureParamterConfigPath);
+                this.ScanConfig = FileHelper.ReadJsonFile<ScanRs232ConfigModel>(FilePath.ScanRS232ConfigPath);
             }
             catch (Exception)
             {
@@ -1657,7 +1643,6 @@ namespace TeamAAS_VP.ViewModels
             {
                 try
                 {
-                    SavePressureConfig();
                     var sysConfig = _configService.GetSystemConfiguration();
                     sysConfig.WorkMode = WorkMode;
                     sysConfig.PickPointNum = PickPointNum;
@@ -1682,11 +1667,6 @@ namespace TeamAAS_VP.ViewModels
             }
         }
 
-        private void SavePressureConfig()
-        {
-            FileHelper.WriteJsonFile(DownPressureConfig, FilePath.PressureParamterConfigPath);
-        }
-
         /// <summary>
         /// 选择压力曲线保存路径
         /// </summary>

+ 94 - 0
TeamAAS-VM/Views/Product/ProductParams.xaml

@@ -78,6 +78,7 @@
 
             <Grid>
                 <Grid.ColumnDefinitions>
+                    <ColumnDefinition Width="auto" />
                     <ColumnDefinition Width="auto" />
                     <ColumnDefinition Width="*" />
                 </Grid.ColumnDefinitions>
@@ -107,11 +108,104 @@
                         </StackPanel>
                     </ScrollViewer>
                 </Expander>
+                <!--产品检测判断的上下限-->
                 <Grid Grid.Column="1"
                       IsEnabled="{Binding IsAllowEdit}"
                       Margin="10"
                       HorizontalAlignment="Center"
                       VerticalAlignment="Center">
+                    <ScrollViewer VerticalScrollBarVisibility="Auto"
+                                  HorizontalScrollBarVisibility="Disabled"
+                                  CanContentScroll="True">
+                        <StackPanel Orientation="Vertical"
+                                    Margin="0">
+                            <GroupBox Header="组装保压配置"
+                                      Margin="20,0"
+                                      Width="200">
+                                <Grid Margin="10">
+                                    <Grid.ColumnDefinitions>
+                                        <ColumnDefinition Width="auto" />
+                                        <ColumnDefinition Width="*" />
+                                        <ColumnDefinition Width="auto" />
+                                    </Grid.ColumnDefinitions>
+                                    <Grid.RowDefinitions>
+                                        <RowDefinition Height="Auto" />
+                                        <RowDefinition Height="Auto" />
+                                        <RowDefinition Height="Auto" />
+                                        <RowDefinition Height="Auto" />
+                                        <RowDefinition Height="Auto" />
+                                        <RowDefinition Height="Auto" />
+                                    </Grid.RowDefinitions>
+                                    <TextBlock Text="保压时间:"
+                                               Grid.Row="0"
+                                               Grid.Column="0"
+                                               HorizontalAlignment="Right" />
+                                    <TextBox Text="{Binding SelectProduct.GlobalParamEx.DownPressure.PressureTime,Mode=TwoWay}"
+                                             Grid.Row="0"
+                                             Grid.Column="1"
+                                             Margin="6,0" />
+                                    <TextBlock Text="s"
+                                               Grid.Row="0"
+                                               Grid.Column="2"
+                                               HorizontalAlignment="Right" />
+                                    <TextBlock Text="保压压力:"
+                                               Grid.Row="1"
+                                               Grid.Column="0"
+                                               HorizontalAlignment="Right" />
+                                    <TextBox Text="{Binding SelectProduct.GlobalParamEx.DownPressure.PressureNum,Mode=TwoWay}"
+                                             Grid.Row="1"
+                                             Grid.Column="1"
+                                             Margin="6,0" />
+                                    <TextBlock Text="kg"
+                                               Grid.Row="1"
+                                               Grid.Column="2"
+                                               HorizontalAlignment="Right" />
+                                    <TextBlock Text="保压最大值:"
+                                               Grid.Row="2"
+                                               Grid.Column="0"
+                                               HorizontalAlignment="Right" />
+                                    <TextBox Text="{Binding SelectProduct.GlobalParamEx.DownPressure.PressureNumMax,Mode=TwoWay}"
+                                             Grid.Row="2"
+                                             Grid.Column="1"
+                                             Margin="6,0" />
+                                    <TextBlock Text="kg"
+                                               Grid.Row="2"
+                                               Grid.Column="2"
+                                               HorizontalAlignment="Right" />
+                                    <TextBlock Text="保压上限:"
+                                               Grid.Row="4"
+                                               Grid.Column="0"
+                                               HorizontalAlignment="Right" />
+                                    <TextBox Text="{Binding SelectProduct.GlobalParamEx.DownPressure.PressureUpLimit,Mode=TwoWay}"
+                                             Grid.Row="4"
+                                             Grid.Column="1"
+                                             Margin="6,0" />
+                                    <TextBlock Text="kg"
+                                               Grid.Row="4"
+                                               Grid.Column="2"
+                                               HorizontalAlignment="Right" />
+                                    <TextBlock Text="保压下限:"
+                                               Grid.Row="5"
+                                               Grid.Column="0"
+                                               HorizontalAlignment="Right" />
+                                    <TextBox Text="{Binding SelectProduct.GlobalParamEx.DownPressure.PressureDownLimit,Mode=TwoWay}"
+                                             Grid.Row="5"
+                                             Grid.Column="1"
+                                             Margin="6,0" />
+                                    <TextBlock Text="kg"
+                                               Grid.Row="5"
+                                               Grid.Column="2"
+                                               HorizontalAlignment="Right" />
+                                </Grid>
+                            </GroupBox>
+                        </StackPanel>
+                    </ScrollViewer>
+                </Grid>
+                <Grid Grid.Column="2"
+                      IsEnabled="{Binding IsAllowEdit}"
+                      Margin="10"
+                      HorizontalAlignment="Center"
+                      VerticalAlignment="Center">
 
                     <Grid.RowDefinitions>
                         <RowDefinition Height="auto" />

+ 16 - 95
TeamAAS-VM/Views/SettingView.xaml

@@ -2898,103 +2898,24 @@
                                              Margin="6,0" />
 
                                     <!--<Button Grid.Row="5"
-                        Grid.Column="0"
-                        Grid.ColumnSpan="2"
-                        Margin="0,10,0,0"
-                        Style="{StaticResource MaterialDesignRaisedButton}"
-                        materialDesign:ButtonAssist.CornerRadius="10"
-                        MinWidth="120"
-                        Command="{Binding SaveScanConfigConfigCommand}">
-                    <StackPanel Orientation="Horizontal"
-                                HorizontalAlignment="Center">
-                        <materialDesign:PackIcon Kind="ContentSaveCheck"
-                                                 Margin="0,0,6,0" />
-                        <TextBlock VerticalAlignment="Center"
-                                   Text="保存扫码机配置" />
-                    </StackPanel>
-                </Button>-->
+                                            Grid.Column="0"
+                                            Grid.ColumnSpan="2"
+                                            Margin="0,10,0,0"
+                                            Style="{StaticResource MaterialDesignRaisedButton}"
+                                            materialDesign:ButtonAssist.CornerRadius="10"
+                                            MinWidth="120"
+                                            Command="{Binding SaveScanConfigConfigCommand}">
+                                        <StackPanel Orientation="Horizontal"
+                                                    HorizontalAlignment="Center">
+                                            <materialDesign:PackIcon Kind="ContentSaveCheck"
+                                                                     Margin="0,0,6,0" />
+                                            <TextBlock VerticalAlignment="Center"
+                                                       Text="保存扫码机配置" />
+                                        </StackPanel>
+                                    </Button>-->
                                 </Grid>
                             </GroupBox>
 
-                            <GroupBox Header="组装保压配置"
-                                      Margin="20,0"
-                                      Width="200">
-                                <Grid Margin="10">
-                                    <Grid.ColumnDefinitions>
-                                        <ColumnDefinition Width="auto" />
-                                        <ColumnDefinition Width="*" />
-                                        <ColumnDefinition Width="auto" />
-                                    </Grid.ColumnDefinitions>
-                                    <Grid.RowDefinitions>
-                                        <RowDefinition Height="Auto" />
-                                        <RowDefinition Height="Auto" />
-                                        <RowDefinition Height="Auto" />
-                                        <RowDefinition Height="Auto" />
-                                        <RowDefinition Height="Auto" />
-                                        <RowDefinition Height="Auto" />
-                                    </Grid.RowDefinitions>
-                                    <TextBlock Text="保压时间:"
-                                               Grid.Row="0"
-                                               Grid.Column="0"
-                                               HorizontalAlignment="Right" />
-                                    <TextBox Text="{Binding DownPressureConfig.PressureTime,Mode=TwoWay}"
-                                             Grid.Row="0"
-                                             Grid.Column="1"
-                                             Margin="6,0" />
-                                    <TextBlock Text="s"
-                                               Grid.Row="0"
-                                               Grid.Column="2"
-                                               HorizontalAlignment="Right" />
-                                    <TextBlock Text="保压压力:"
-                                               Grid.Row="1"
-                                               Grid.Column="0"
-                                               HorizontalAlignment="Right" />
-                                    <TextBox Text="{Binding DownPressureConfig.PressureNum,Mode=TwoWay}"
-                                             Grid.Row="1"
-                                             Grid.Column="1"
-                                             Margin="6,0" />
-                                    <TextBlock Text="kg"
-                                               Grid.Row="1"
-                                               Grid.Column="2"
-                                               HorizontalAlignment="Right" />
-                                    <TextBlock Text="保压最大值:"
-                                               Grid.Row="2"
-                                               Grid.Column="0"
-                                               HorizontalAlignment="Right" />
-                                    <TextBox Text="{Binding DownPressureConfig.PressureNumMax,Mode=TwoWay}"
-                                             Grid.Row="2"
-                                             Grid.Column="1"
-                                             Margin="6,0" />
-                                    <TextBlock Text="kg"
-                                               Grid.Row="2"
-                                               Grid.Column="2"
-                                               HorizontalAlignment="Right" />
-                                    <TextBlock Text="保压上限:"
-                                               Grid.Row="4"
-                                               Grid.Column="0"
-                                               HorizontalAlignment="Right" />
-                                    <TextBox Text="{Binding DownPressureConfig.PressureUpLimit,Mode=TwoWay}"
-                                             Grid.Row="4"
-                                             Grid.Column="1"
-                                             Margin="6,0" />
-                                    <TextBlock Text="kg"
-                                               Grid.Row="4"
-                                               Grid.Column="2"
-                                               HorizontalAlignment="Right" />
-                                    <TextBlock Text="保压下限:"
-                                               Grid.Row="5"
-                                               Grid.Column="0"
-                                               HorizontalAlignment="Right" />
-                                    <TextBox Text="{Binding DownPressureConfig.PressureDownLimit,Mode=TwoWay}"
-                                             Grid.Row="5"
-                                             Grid.Column="1"
-                                             Margin="6,0" />
-                                    <TextBlock Text="kg"
-                                               Grid.Row="5"
-                                               Grid.Column="2"
-                                               HorizontalAlignment="Right" />
-                                </Grid>
-                            </GroupBox>
                         </StackPanel>
 
                     </StackPanel>
@@ -3159,7 +3080,7 @@
                     </GroupBox>
                 </StackPanel>
             </TabItem>
-            
+
             <!--生产排班-->
             <TabItem>
                 <TabItem.Header>