徐孝锋 8 сар өмнө
parent
commit
419d3f5b03

+ 1 - 0
TeamAAS-VM/Core/Management.cs

@@ -1535,6 +1535,7 @@ namespace TeamAAS_VP.Core
                             lockResult.ScrewdriverGetDataSucceed = isSucced;
                             lockResult.Number = positionIndex;
                             lockResult.LockPassed = ScrewDriver.Success;
+                            lockResult.ProductName = currentProduct.Name;
                             lockResult.ProductNumber = _productService.CurrentProductCode;
                             lockResult.LockTurns = (float)ScrewDriver.Truns;
                             lockResult.LockTorque = (float)ScrewDriver.TorqueValue;

+ 10 - 0
TeamAAS-VM/Models/LockResult.cs

@@ -11,6 +11,16 @@ namespace TeamAAS_VP.Models
         [SugarColumn(IsPrimaryKey = true, IsIdentity = true)]
         public int Id { get; set; }
 
+        private string _ProductName;
+        /// <summary>
+        /// 产品名称
+        /// </summary>
+        public string ProductName
+        {
+            get { return _ProductName; }
+            set { SetProperty(ref _ProductName, value); }
+        }
+
         private int __Number;
         /// <summary>
         /// 螺丝编号

+ 2 - 2
TeamAAS-VM/Resources/Languages/Lang.Designer.cs

@@ -5965,7 +5965,7 @@ namespace TeamAAS_VP.Resources.Languages {
         }
         
         /// <summary>
-        ///   查找类似 螺丝编号: 的本地化字符串。
+        ///   查找类似 螺丝编号 的本地化字符串。
         /// </summary>
         public static string 螺丝编号 {
             get {
@@ -7153,7 +7153,7 @@ namespace TeamAAS_VP.Resources.Languages {
         }
         
         /// <summary>
-        ///   查找类似 锁付结果 的本地化字符串。
+        ///   查找类似 锁付结果 的本地化字符串。
         /// </summary>
         public static string 锁付结果 {
             get {

+ 2 - 2
TeamAAS-VM/Resources/Languages/Lang.en.resx

@@ -2326,7 +2326,7 @@
     <value>Automatic Shooting</value>
   </data>
   <data name="螺丝编号" xml:space="preserve">
-    <value>Screw Number:</value>
+    <value>Screw Number</value>
   </data>
   <data name="开始" xml:space="preserve">
     <value>Start:</value>
@@ -2404,7 +2404,7 @@
     <value>Next Page</value>
   </data>
   <data name="锁付结果" xml:space="preserve">
-    <value>Fastening Result:</value>
+    <value>Fastening Result</value>
   </data>
   <data name="程序号" xml:space="preserve">
     <value>Program number</value>

+ 2 - 2
TeamAAS-VM/Resources/Languages/Lang.ja-JP.resx

@@ -2326,7 +2326,7 @@
     <value>自動撮影</value>
   </data>
   <data name="螺丝编号" xml:space="preserve">
-    <value>ネジ番号:</value>
+    <value>ネジ番号</value>
   </data>
   <data name="开始" xml:space="preserve">
     <value>開始:</value>
@@ -2404,7 +2404,7 @@
     <value>次ページ</value>
   </data>
   <data name="锁付结果" xml:space="preserve">
-    <value>締付け結果:</value>
+    <value>締付け結果</value>
   </data>
   <data name="程序号" xml:space="preserve">
     <value>プログラム番号</value>

+ 2 - 2
TeamAAS-VM/Resources/Languages/Lang.resx

@@ -2418,7 +2418,7 @@
     <value>自动拍照</value>
   </data>
   <data name="螺丝编号" xml:space="preserve">
-    <value>螺丝编号:</value>
+    <value>螺丝编号</value>
   </data>
   <data name="开始" xml:space="preserve">
     <value>开始:</value>
@@ -2496,7 +2496,7 @@
     <value>下一页</value>
   </data>
   <data name="锁付结果" xml:space="preserve">
-    <value>锁付结果</value>
+    <value>锁付结果</value>
   </data>
   <data name="程序号" xml:space="preserve">
     <value>程序号</value>

+ 2 - 2
TeamAAS-VM/Resources/Languages/Lang.zh-TW.resx

@@ -2326,7 +2326,7 @@
     <value>自動拍照</value>
   </data>
   <data name="螺丝编号" xml:space="preserve">
-    <value>螺絲編號:</value>
+    <value>螺絲編號</value>
   </data>
   <data name="开始" xml:space="preserve">
     <value>開始:</value>
@@ -2404,7 +2404,7 @@
     <value>下一頁</value>
   </data>
   <data name="锁付结果" xml:space="preserve">
-    <value>鎖付結果:</value>
+    <value>鎖付結果</value>
   </data>
   <data name="程序号" xml:space="preserve">
     <value>程式號</value>

+ 66 - 4
TeamAAS-VM/ViewModels/Home/TorqueCheckViewModel.cs

@@ -7,8 +7,10 @@ using Prism.Mvvm;
 using Prism.Services.Dialogs;
 using System;
 using System.Collections.Generic;
+using System.IO;
 using System.Linq;
 using System.Text;
+using System.Threading;
 using System.Threading.Tasks;
 using System.Windows;
 using TeamAAS_VP.Core;
@@ -27,6 +29,7 @@ namespace TeamAAS_VP.ViewModels.Home
         IEventAggregator _eventAggregator;
         IConfigService _configService;
         IContainerProvider _container;
+        IRobotService _robotService;
 
         #region 属性
         private Management _management;
@@ -166,11 +169,12 @@ namespace TeamAAS_VP.ViewModels.Home
         #endregion
 
         #region 方法
-        public TorqueCheckViewModel(IEventAggregator ea, IConfigService configService, IContainerProvider container)
+        public TorqueCheckViewModel(IEventAggregator ea, IConfigService configService, IContainerProvider container, IRobotService robotService)
         {
             _eventAggregator = ea;
             _configService = configService;
             _container = container;
+            _robotService = robotService;
             management = _container.Resolve<Management>();
         }
 
@@ -314,14 +318,57 @@ namespace TeamAAS_VP.ViewModels.Home
         }
 
         void ExecuteWorkCommand()
+        {
+            try
+            {
+                MoveRobot();
+                Thread.Sleep(500);
+                DisplayResult();
+            }
+            catch (Exception ex)
+            {
+                LogHelper.WriteLogError("执行点检时出错!", ex);
+            }
+        }
+        public async void MoveRobot()
+        {
+            if (!File.Exists(FilePath.TorqueCheckPath))
+            {
+                MessageBox.Show("还未示教,请先示教");
+                return;
+            }
+            var res = FileHelper.ReadJsonFile<TorqueTest>(FilePath.TorqueCheckPath);
+
+            var point = new RPoint()
+            {
+                X = (float)res.Xpoint,
+                Y = (float)res.Ypoint,
+                Z = (float)res.Zpoint,
+            };
+            if (Robot == null || !Robot.IsConnected) return;
+            try
+            {
+                //确认要执行该点位的该运动指令吗
+                if (MessageBox.Show($"确认要进行点检吗?", "执行点位", MessageBoxButton.YesNo, MessageBoxImage.Question) != MessageBoxResult.Yes)
+                {
+                    return;
+                }
+                await Robot.JumpAsync(point, 0);
+            }
+            catch (Exception ex)
+            {
+                LogHelper.WriteLogError("执行点检移动时出错!", ex);
+            }
+        }
+        public void DisplayResult()
         {
             try
             {
                 TValue = management.SignalValue;
                 double tvalue = double.Parse(TValue.Split(' ')[0]);
-                PValue = $"{management.Value} N·m";
+                PValue = $"{management.Value} N.m";
                 double pvalue = management.Value;
-                SubValue = $"{Math.Abs(tvalue - pvalue)} N·m";
+                SubValue = $"{Math.Abs(tvalue - pvalue)} N.m";
                 double sub = Math.Abs(tvalue - pvalue);
 
                 var res = FileHelper.ReadJsonFile<TorqueTest>(FilePath.TorqueCheckPath);
@@ -354,7 +401,7 @@ namespace TeamAAS_VP.ViewModels.Home
             }
             catch (Exception ex)
             {
-                LogHelper.WriteLogError("执行点检时出错!", ex);
+                LogHelper.WriteLogError("执行点检显示时出错!", ex);
             }
         }
         #endregion
@@ -391,6 +438,21 @@ namespace TeamAAS_VP.ViewModels.Home
             {
                 MessageBox.Show("还未示教,请先示教");
             }
+
+            if (Robot == null)
+            {
+                Robot = _robotService.GetRobotByNumber(1);
+            }
+
+            if (Robot != null && Robot.IsConnected)
+            {
+                this.Distance = _configService.GetRobotStepDistance(Robot.Id);
+                Robot.EnterDebugMode = true;
+            }
+            else if (Robot != null)
+            {
+                Robot.EnterDebugMode = true;
+            }
         }
     }
 }

+ 19 - 0
TeamAAS-VM/ViewModels/HomeViewModel.cs

@@ -5,6 +5,7 @@ using OxyPlot;
 using OxyPlot.Axes;
 using OxyPlot.Legends;
 using OxyPlot.Series;
+using OxyPlot.Wpf;
 using Prism.Commands;
 using Prism.Events;
 using Prism.Ioc;
@@ -14,6 +15,7 @@ using Prism.Services.Dialogs;
 using System;
 using System.Collections.Generic;
 using System.Collections.ObjectModel;
+using System.IO;
 using System.Linq;
 using System.Threading.Tasks;
 using System.Windows;
@@ -493,7 +495,24 @@ namespace TeamAAS_VP.ViewModels
             }));
 
         }
+        private void SaveAsPng(PlotModel LockCurvePlotModel)
+        {
+            string savePath = $"E:\\Data\\螺丝锁付曲线图\\{DateTime.Now:yyyyMMdd_HHmmss}.png";
 
+            Application.Current.Dispatcher.Invoke(() =>
+            {
+                try
+                {
+                    var exporter = new PngExporter { Width = 1200, Height = 800 };
+                    exporter.ExportToFile(LockCurvePlotModel, savePath);
+                    //SaveStatus = $"已保存到:{savePath}";
+                }
+                catch (Exception ex)
+                {
+                    //SaveStatus = $"保存失败:{ex.Message}";
+                }
+            });
+        }
 
         void ExecuteSetAlarmValueCommand()
         {

+ 3 - 1
TeamAAS-VM/Views/Home/TorqueCheck.xaml

@@ -32,6 +32,8 @@
 
     <UserControl.Resources>
         <convert:JogConverter x:Key="JogConverter" />
+        <convert:MultiParameterConverter x:Key="MultiParameterConverter" />
+        <convert:RobotConverter x:Key="RobotConverter" />
     </UserControl.Resources>
 
     <prism:Dialog.WindowStyle>
@@ -252,7 +254,7 @@
                                 HorizontalAlignment="Center"
                                 materialDesign:ButtonAssist.CornerRadius="10"
                                 Style="{StaticResource MaterialDesignRaisedDarkButton}"
-                                Command="{Binding DataContext.TechPointCommand}" />
+                                Command="{Binding TechPointCommand}" />
                     </Grid>
                 </Grid>
             </materialDesign:DrawerHost.LeftDrawerContent>

+ 5 - 1
TeamAAS-VM/Views/HomeView.xaml

@@ -90,6 +90,10 @@
                                                     Binding="{Binding Number}"
                                                     Width="auto"
                                                     IsReadOnly="True" />
+                                <DataGridTextColumn Header="{lex:Loc 产品名称}"
+                                                    Binding="{Binding ProductName}"
+                                                    Width="auto"
+                                                    IsReadOnly="True" />
                                 <DataGridTextColumn Header="{lex:Loc 产品编号}"
                                                     Binding="{Binding ProductNumber}"
                                                     Width="auto"
@@ -461,7 +465,7 @@
                             <DataTemplate>
                                 <Border BorderThickness="0"
                                         HorizontalAlignment="Left">
-                                    <Label MaxWidth="300"
+                                    <Label MaxWidth="600"
                                            BorderThickness="0"
                                            Background="Transparent"
                                            Margin="0"

+ 7 - 4
TeamAAS-VM/Views/Statistics/LockResultRecoredQuery.xaml

@@ -78,19 +78,22 @@
                                     Width="60" />
                 <DataGridTextColumn Header="{lex:Loc 时间}"
                                     Binding="{Binding Timestamp, StringFormat=yyyy-MM-dd HH:mm:ss}"
-                                    Width="160" />
+                                    Width="auto" />
+                <DataGridTextColumn Header="{lex:Loc 产品名称}"
+                                    Binding="{Binding ProductName}"
+                                    Width="auto" />
                 <DataGridTextColumn Header="{lex:Loc 产品编号}"
                                     Binding="{Binding ProductNumber}"
                                     Width="150" />
                 <DataGridTextColumn Header="{lex:Loc 螺丝编号}"
                                     Binding="{Binding Number}"
-                                    Width="80" />
+                                    Width="auto" />
                 <DataGridTextColumn Header="{lex:Loc 电批程序号}"
                                     Binding="{Binding ScrewdriverProgramNumber}"
-                                    Width="110" />
+                                    Width="auto" />
                 <DataGridTextColumn Header="{lex:Loc 锁付圈数}"
                                     Binding="{Binding LockTurns}"
-                                    Width="90" />
+                                    Width="100" />
                 <DataGridTextColumn Header="{lex:Loc 锁付扭矩}"
                                     Binding="{Binding LockTorque}"
                                     Width="90" />