KWD 7 months ago
parent
commit
e18652abf9

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

@@ -62,6 +62,13 @@ 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";
 
     }

+ 47 - 16
TeamAAS-VM/Core/Management.cs

@@ -1171,6 +1171,30 @@ namespace TeamAAS_VP.Core
             }
         }
 
+        public async Task WriteParameterToPlcAsync()
+        {
+            var addressConfig = _configService.GetPlcAddresses();
+            var plc = _plcService.GetPlcByNumber(addressConfig.PlcNo) as OpcUaClientPLC;
+            if (plc == null || !plc.IsConnected) 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);
+            }
+            catch (Exception)
+            {
+
+            }
+
+        }
+
         /// <summary>
         /// 固定向上相机拍照结果
         /// </summary>
@@ -1218,6 +1242,7 @@ namespace TeamAAS_VP.Core
         Int16[] _LastMesCheck = new Int16[10];
         DateTime[] _LastMesCheckTime = new DateTime[10];
         Dictionary<string, string> mes_cc = new Dictionary<string, string>();
+        double currentPressure = 0;//当前的压力
         /// <summary>
         /// PLC命令触发时
         /// </summary>
@@ -1836,7 +1861,7 @@ namespace TeamAAS_VP.Core
                             }
                             else
                             {
-                                mes_cc.Add("0","0");
+                                mes_cc.Add($"{cameraIndex}","0");
                                 await plc.WriteNodeAsync(addressConfig.Out_UPCameracheckStatus.Address, (Int16)2);
                                 SendTaskMessage($"点位{cameraIndex}检测NG", MessageLevel.Error);
                             }
@@ -2264,12 +2289,17 @@ namespace TeamAAS_VP.Core
                                     }
 
                                     await _systemDatabaseService.RecordAssemblyAsync(assemblyRecord);
-
                                     LogHelper.WriteLogMes($"【mes开始ADD】");
                                     SendTaskMessage($"mes开始ADD", MessageLevel.Info);
                                     string assypress= "";string cc = "";
                                     cc = string.Join(",", mes_cc.OrderBy(kv => kv.Key, StringComparer.Ordinal).Select(kv => kv.Value));
-                                    assypress = assemblyRecord.AssemblyPressure.ToString();
+                                    assypress = currentPressure.ToString("F2");
+                                    var res = FileHelper.ReadJsonFile<PressureModel>(FilePath.PressureParamterConfigPath);
+                                    if (res.PressureUpLimit>0)
+                                    {
+
+                                    }
+                                    //cc-复检cc,assypress-组装站压力
                                     (bool isSuccess, string response) = await _mesService.SubmitGetAsync(code, comp, cc,assypress, resultIndex == 1 ? true : false, _LastMesCheckTime[i], DateTime.UtcNow);
                                     if (isSuccess)
                                     {
@@ -2316,23 +2346,21 @@ namespace TeamAAS_VP.Core
                                 
                                 if (state == 1)
                                 {
-                                    //SendTaskMessage($"收到开始组装信号[{i}]...", MessageLevel.Debug);
                                     SendTaskMessage($"收到开始保压信号[{i}]...", MessageLevel.Debug);
                                     // 开始采集压力值
                                     StartPressureCollection(currentProduct.Name, code, i);
                                 }
                                 else
                                 {
-                                    //SendTaskMessage($"开始锁付信号[{i}]已关闭", MessageLevel.Alarm);
-                                    //// 关闭时的处理(如需)可放在这里
-                                    SendTaskMessage($"收到关闭保压信号[{i}]...", MessageLevel.Debug);
-                                    // 停止采集压力并保存
-                                    await StopAndSavePressureCollectionAsync(currentProduct.Name, code, i);
+                                    SendTaskMessage($"收到关闭开始保压信号[{i}]...", MessageLevel.Debug);
                                 }
                             }
                         }
-                        //停止组装
-                        /*else if (string.Format(addressConfig.In_WorkStart.Address, i).Contains(tuple.nodeId))
+                    }
+                    //开始/停止 组装/锁附
+                    for (int i = 0; i < 7; i++)
+                    {
+                        if (string.Format(addressConfig.In_WorkStart.Address, i).Contains(tuple.nodeId))
                         {
                             if (tuple.value is Int16 state)
                             {
@@ -2344,9 +2372,9 @@ namespace TeamAAS_VP.Core
                                 {
                                     return;
                                 }
-                                if (state == 1 || state == 2)
+                                if (state == 1)
                                 {
-                                    SendTaskMessage($"收到停止锁付信号[{i}]...", MessageLevel.Debug);
+                                    SendTaskMessage($"收到停止压力信号[{i}]...", MessageLevel.Debug);
                                     //获取当前锁付点
                                     //var screwPoint = currentProduct.ScrewPoints.FirstOrDefault(p => p.Number == positionIndex);
                                     ////获取当前的机器人点位
@@ -2354,7 +2382,10 @@ namespace TeamAAS_VP.Core
                                     //var currentPosition = robot.GetRobotPos();
                                     ////读取压力值
                                     //float pressure = plc.ReadNode<float>(addressConfig.In_PressureValue.Address);
-
+                                    //读取压力值
+                                    float pressure = plc.ReadNode<float>(string.Format(addressConfig.In_PressureValue.Address, i));
+                                    currentPressure = pressure;
+                                    SendTaskMessage($"[{i}]压力:{pressure}", MessageLevel.Info);
 
                                     //await Task.Delay(60);
                                     ////获取电批结果
@@ -2396,10 +2427,10 @@ namespace TeamAAS_VP.Core
                                 }
                                 else
                                 {
-                                    SendTaskMessage($"停止锁付信号[{i}]已关闭", MessageLevel.Alarm);
+                                    SendTaskMessage($"停止压力信号[{i}]已关闭", MessageLevel.Alarm);
                                 }
                             }
-                        }*/
+                        }
                     }
                 }
             }

+ 45 - 0
TeamAAS-VM/Models/PLC/PlcAddressConfig.cs

@@ -339,6 +339,36 @@ namespace TeamAAS_VP.Models.PLC
             get { return _Out_ScrewFeederIsChanged; }
             set { SetProperty(ref _Out_ScrewFeederIsChanged, value); }
         }
+        private PlcAddress _Down_Time;
+        /// <summary>
+        /// A_Camera Assy组装时间
+        /// </summary>
+        public PlcAddress Down_Time
+        {
+            get { return _Down_Time; }
+            set { SetProperty(ref _Down_Time, value); }
+        }
+
+        private PlcAddress _Down_WetOut_Num;
+        /// <summary>
+        /// A_Camera Assy组装压力
+        /// </summary>
+        public PlcAddress Down_WetOut_Num
+        {
+            get { return _Down_WetOut_Num; }
+            set { SetProperty(ref _Down_WetOut_Num, value); }
+        }
+
+        private PlcAddress _Down_WetOut_Num_max;
+        /// <summary>
+        /// A_Camera Assy组装压力最大值
+        /// </summary>
+        public PlcAddress Down_WetOut_Num_max
+        {
+            get { return _Down_WetOut_Num_max; }
+            set { SetProperty(ref _Down_WetOut_Num_max, value); }
+        }
+
         #endregion
 
         #region 从PLC读取的地址
@@ -1070,6 +1100,21 @@ namespace TeamAAS_VP.Models.PLC
             In_DryMode.DataType = "bool";
             In_DryMode.Description = "空跑模式";
 
+            Down_Time = Ensure(Down_Time);
+            Down_Time.Address = "ns=4;s=DB_other|Down_Time";
+            Down_Time.DataType = "int32";
+            Down_Time.Description = "A_Camera Assy时间";
+
+            Down_WetOut_Num = Ensure(Down_WetOut_Num);
+            Down_WetOut_Num.Address = "ns=4;s=DB_other|WetOut_Num";
+            Down_WetOut_Num.DataType = "float";
+            Down_WetOut_Num.Description = "A_Camera Assy压力";
+
+            Down_WetOut_Num_max = Ensure(Down_WetOut_Num_max);
+            Down_WetOut_Num_max.Address = "ns=4;s=DB_other|WetOut_MAX";
+            Down_WetOut_Num_max.DataType = "float";
+            Down_WetOut_Num_max.Description = "A_Camera Assy压力最大值";
+
             // 说明:若项目中 PlcAddress 的实际属性名或类型与此不同(例如使用枚举、不同字段名),
             // 请根据实际类型调整赋值。本方法主要提供合理的默认字符串地址、数据类型及描述,便于后续从配置覆盖。
         }

+ 53 - 0
TeamAAS-VM/Models/PressureModel.cs

@@ -0,0 +1,53 @@
+using Prism.Mvvm;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace TeamAAS_VP.Models
+{
+    public class PressureModel : BindableBase
+    {
+        private Int32 _PressureTime = 0;
+
+        public Int32 PressureTime
+        {
+            get { return _PressureTime; }
+            set { SetProperty(ref _PressureTime, value); }
+        }
+
+        private float _PressureNum = 0;
+
+        public float PressureNum
+        {
+            get { return _PressureNum; }
+            set { SetProperty(ref _PressureNum, value); }
+        }
+
+        private float _PressureNumMax = 0;
+
+        public float PressureNumMax
+        {
+            get { return _PressureNumMax; }
+            set { SetProperty(ref _PressureNumMax, value); }
+        }
+
+        private float _PressureUpLimit = 0;
+
+        public float PressureUpLimit
+        {
+            get { return _PressureUpLimit; }
+            set { SetProperty(ref _PressureUpLimit, value); }
+        }
+
+        private float _PressureDownLimit = 0;
+
+        public float PressureDownLimit
+        {
+            get { return _PressureDownLimit; }
+            set { SetProperty(ref _PressureDownLimit, value); }
+        }
+
+    }
+}

+ 3 - 2
TeamAAS-VM/Services/MesService.cs

@@ -123,7 +123,7 @@ namespace TeamAAS_VP.Services
                         // "SFC_OK" ´ú±íºÍ MES Á¬½Ó³É¹¦
                         if (text.Contains("SFC_OK"))
                         {
-                            if (text.Contains("unit_process_check=OK"))
+                            if (text.Contains("message=OK"))
                             {
                                 return (true, text);
                             }
@@ -199,7 +199,8 @@ namespace TeamAAS_VP.Services
                 }
             }
 
-            string res = isSuccess ? "PASS" : "FAIL";
+            //string res = isSuccess ? "PASS" : "FAIL";
+            string res = "PASS";
             string url = "";
             if (device.F == "PTL")
             {

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

@@ -541,7 +541,11 @@
     <Compile Include="Models\DeviceInfo.cs" />
     <Compile Include="Models\Feeder\ScrewFeederInfo.cs" />
     <Compile Include="Models\PhotoCaptureRecord.cs" />
+<<<<<<< HEAD
     <Compile Include="Models\ScanRs232ConfigModel.cs" />
+=======
+    <Compile Include="Models\PressureModel.cs" />
+>>>>>>> 24cf64d4a0ed8eeeacf0f6455ca76b15114dc235
     <Compile Include="Models\ScrewFeederBatchRecord.cs" />
     <Compile Include="Services\MesService.cs" />
     <Compile Include="ValueConverter\CountToColumnsConverter.cs" />

+ 2 - 1
TeamAAS-VM/ViewModels/HomeViewModel.cs

@@ -272,6 +272,7 @@ namespace TeamAAS_VP.ViewModels
                     var task = DialogHost.Show(waiting, "RootDialog", null, null, null);
                     _productService.LoadProduct(product.ID);
                     _productService.SetCurrentProduct(product.ID);
+                    await management.WriteParameterToPlcAsync();
                     await management.WritePositionToPlcAsync();
                     if (DialogHost.IsDialogOpen("RootDialog"))
                     {
@@ -335,7 +336,7 @@ namespace TeamAAS_VP.ViewModels
         {
             try
             {
-                if (MessageQueue.Count >= 20)
+                if (MessageQueue.Count >= 200)
                 {
                     MessageQueue.RemoveAt(0);// 从队列头部移除最早的消息
                 }

+ 1 - 0
TeamAAS-VM/ViewModels/MainWindowViewModel.cs

@@ -355,6 +355,7 @@ namespace TeamAAS_VP.ViewModels
                     }
                 }
                 _container.Resolve<ShowVisionRenderViewModel>().Renders = management.Renders;
+                await management.WriteParameterToPlcAsync();
                 await management.WritePositionToPlcAsync();
             }
             var homeviewmodel = _container.Resolve<HomeViewModel>();

+ 19 - 2
TeamAAS-VM/ViewModels/SettingViewModel.cs

@@ -57,6 +57,14 @@ namespace TeamAAS_VP.ViewModels
 
         #region 属性
 
+        private PressureModel _DownPressureConfig = new PressureModel();
+
+        public PressureModel DownPressureConfig
+        {
+            get { return _DownPressureConfig; }
+            set { SetProperty(ref _DownPressureConfig, value); }
+        }
+
         private Management _management;
 
         public Management management
@@ -1202,7 +1210,18 @@ namespace TeamAAS_VP.ViewModels
                 FileHelper.WriteJsonFile(scan, FilePath.ScanRS232ConfigPath);
             }
             this.ScanConfig = FileHelper.ReadJsonFile<ScanRs232ConfigModel>(FilePath.ScanRS232ConfigPath);
+            try
+            {
+                if (!File.Exists(FilePath.PressureParamterConfigPath))
+                {
+                    FileHelper.WriteJsonFile(DownPressureConfig, FilePath.PressureParamterConfigPath);
+                }
+                DownPressureConfig = FileHelper.ReadJsonFile<PressureModel>(FilePath.PressureParamterConfigPath);
+            }
+            catch (Exception)
+            {
 
+            }
         }
 
         private void OnPropertyChanged(object sender, PropertyChangedEventArgs e)
@@ -1552,8 +1571,6 @@ namespace TeamAAS_VP.ViewModels
             {
                 try
                 {
-                    FileHelper.WriteJsonFile(this.ScanConfig, FilePath.ScanRS232ConfigPath);
-                    ExecuteSaveCardReaderConfigCommand();
                     var sysConfig = _configService.GetSystemConfiguration();
                     sysConfig.WorkMode = WorkMode;
                     sysConfig.PickPointNum = PickPointNum;

+ 138 - 37
TeamAAS-VM/Views/SettingView.xaml

@@ -2642,14 +2642,15 @@ Grid.Row="1">
                             </StackPanel>
                         </Grid>
                         <!--刷卡参数配置-->
+                        <!--刷卡参数配置-->
                         <StackPanel Grid.Row="5"
-                Orientation="Horizontal">
-                            <GroupBox Grid.Row="5"
-                  Grid.ColumnSpan="2"
-                  Header="刷卡器配置"
-                  HorizontalAlignment="Left"
-                  MinWidth="170"
-                  Margin="0,12,20,0">
+                                    Margin="0,12,0,0"
+                                    Orientation="Horizontal">
+                            <!--刷卡参数配置-->
+                            <GroupBox Header="刷卡器配置"
+                                      Width="200"
+                                      Margin="0,0,20,0"
+                                      HorizontalAlignment="Left">
                                 <Grid Margin="10">
                                     <Grid.ColumnDefinitions>
                                         <ColumnDefinition Width="auto" />
@@ -2664,45 +2665,45 @@ Grid.Row="1">
                                         <RowDefinition Height="Auto" />
                                     </Grid.RowDefinitions>
                                     <TextBlock Text="PortName:"
-                           Grid.Row="0"
-                           Grid.Column="0"
-                           HorizontalAlignment="Right" />
+                                               Grid.Row="0"
+                                               Grid.Column="0"
+                                               HorizontalAlignment="Right" />
                                     <TextBox Text="{Binding CardReaderConfig.PortName,Mode=TwoWay}"
-                         Grid.Row="0"
-                         Grid.Column="1"
-                         Margin="6,0" />
+                                             Grid.Row="0"
+                                             Grid.Column="1"
+                                             Margin="6,0" />
                                     <TextBlock Text="BaudRate:"
-                           Grid.Row="1"
-                           Grid.Column="0"
-                           HorizontalAlignment="Right" />
+                                               Grid.Row="1"
+                                               Grid.Column="0"
+                                               HorizontalAlignment="Right" />
                                     <TextBox Text="{Binding CardReaderConfig.BaudRate,Mode=TwoWay}"
-                         Grid.Row="1"
-                         Grid.Column="1"
-                         Margin="6,0" />
+                                             Grid.Row="1"
+                                             Grid.Column="1"
+                                             Margin="6,0" />
                                     <TextBlock Text="Parity:"
-                           Grid.Row="2"
-                           Grid.Column="0"
-                           HorizontalAlignment="Right" />
+                                               Grid.Row="2"
+                                               Grid.Column="0"
+                                               HorizontalAlignment="Right" />
                                     <ComboBox Grid.Row="2"
-                          Grid.Column="1"
-                          SelectedItem="{Binding CardReaderConfig.Parity,Mode=TwoWay}"
-                          ItemsSource="{Binding Source={StaticResource Parity}}" />
+                                              Grid.Column="1"
+                                              SelectedItem="{Binding CardReaderConfig.Parity,Mode=TwoWay}"
+                                              ItemsSource="{Binding Source={StaticResource Parity}}" />
                                     <TextBlock Text="StopBits:"
-                           Grid.Row="3"
-                           Grid.Column="0"
-                           HorizontalAlignment="Right" />
+                                               Grid.Row="3"
+                                               Grid.Column="0"
+                                               HorizontalAlignment="Right" />
                                     <ComboBox Grid.Row="3"
-                          Grid.Column="1"
-                          SelectedItem="{Binding CardReaderConfig.StopBits,Mode=TwoWay}"
-                          ItemsSource="{Binding Source={StaticResource StopBits}}" />
+                                              Grid.Column="1"
+                                              SelectedItem="{Binding CardReaderConfig.StopBits,Mode=TwoWay}"
+                                              ItemsSource="{Binding Source={StaticResource StopBits}}" />
                                     <TextBlock Text="DataBits:"
-                           Grid.Row="4"
-                           Grid.Column="0"
-                           HorizontalAlignment="Right" />
+                                               Grid.Row="4"
+                                               Grid.Column="0"
+                                               HorizontalAlignment="Right" />
                                     <TextBox Text="{Binding CardReaderConfig.DataBits,Mode=TwoWay}"
-                         Grid.Row="4"
-                         Grid.Column="1"
-                         Margin="6,0" />
+                                             Grid.Row="4"
+                                             Grid.Column="1"
+                                             Margin="6,0" />
 
                                     <!--<Button Grid.Row="5"
                         Grid.Column="0"
@@ -2801,6 +2802,106 @@ Grid.Row="1">
                                 </Grid>
                             </GroupBox>
                         </StackPanel>
+                    </StackPanel>
+                                    <!--<Button Grid.Row="5"
+        Grid.Column="0"
+        Grid.ColumnSpan="2"
+        Margin="0,6"
+        Style="{StaticResource MaterialDesignRaisedButton}"
+        materialDesign:ButtonAssist.CornerRadius="10"
+        MinWidth="120"
+        Command="{Binding SaveCardReaderConfigCommand}">
+    <StackPanel Orientation="Horizontal"
+                HorizontalAlignment="Center">
+        <materialDesign:PackIcon Kind="ContentSaveCheck"
+                                 Margin="0,0,6,0" />
+        <TextBlock VerticalAlignment="Center"
+                   Text="保存刷卡器配置" />
+    </StackPanel>
+</Button>-->
+                                </Grid>
+                            </GroupBox>
+                            <GroupBox Header="A_Camera Assy配置"
+                                      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="ms"
+                                               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>
                 </ScrollViewer>
             </TabItem>