KWD hace 7 meses
padre
commit
093deb15e4
Se han modificado 2 ficheros con 72 adiciones y 3 borrados
  1. 68 3
      TeamAAS-VM/Services/TorqueService.cs
  2. 4 0
      TeamAAS-VM/Views/Home/TorqueCheck.xaml

+ 68 - 3
TeamAAS-VM/Services/TorqueService.cs

@@ -4,10 +4,12 @@ using Prism.Ioc;
 using Prism.Mvvm;
 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;
 using TeamAAS_VP.Core.PLCs;
 using TeamAAS_VP.Events;
@@ -20,6 +22,8 @@ namespace TeamAAS_VP.Services
 {
     public class TorqueService : BindableBase
     {
+
+
         IEventAggregator _eventAggregator;
         IConfigService _configService;
         IContainerProvider _container;
@@ -27,7 +31,68 @@ namespace TeamAAS_VP.Services
         IPlcService _plcService;
         private Management management;
 
+        /// <summary>
+        /// 扭矩日志月份目录
+        /// </summary>
+        private string TorqueParametrPath
+        {
+            get
+            {
+                // 示例:..//Log//LogTorque//2026-01
+                return $"..//Log//LogTorque//{DateTime.Now:yyyy-MM}";
+            }
+        }
+
+        /// <summary>
+        /// 当天扭矩 CSV 文件完整路径
+        /// </summary>
+        private string CurrentVariableCSV
+        {
+            get
+            {
+                // 示例:..//Log//LogTorque//2026-01//2026-01-22.csv
+                return $"..//Log//LogTorque//{DateTime.Now:yyyy-MM}//{DateTime.Now:yyyy-MM-dd}.csv";
+            }
+        }
+
 
+        public async void Save_Torque_Log(string fileName, string content)
+        {
+            try
+            {
+                if (!File.Exists(TorqueParametrPath))
+                {
+                    Directory.CreateDirectory(TorqueParametrPath);
+                }
+                bool Is_Exists = File.Exists(CurrentVariableCSV);
+                if (!Is_Exists)
+                {
+                    Directory.CreateDirectory(CurrentVariableCSV);
+                }
+
+                using (FileStream fs = new FileStream(CurrentVariableCSV, FileMode.Append, FileAccess.Write))
+                {
+                    using (StreamWriter sw = new StreamWriter(fs))
+                    {
+                        if (!Is_Exists)
+                        {
+                            //初始化文件,写入标题行
+                            sw.WriteLine("Time,...");
+                            sw.WriteLine("Time,...");
+                        }
+                        else
+                        {
+                            sw.WriteLine("Time,...");
+                        }
+                    }
+                }
+
+            }
+            catch (Exception)
+            {
+
+            }
+        }
 
         public TorqueService(IEventAggregator ea, IConfigService configService,
             IContainerProvider container, IRobotService robotService, IPlcService plcService)
@@ -120,7 +185,7 @@ namespace TeamAAS_VP.Services
             return !result.Contains(false);
         }
 
-        
+
         public async Task<bool> Safety_Position_Async(IRobot Robot, OpcUaClientPLC plc, PlcAddressConfig addressConfig, TorqueProduceModel PlcPoint)
         {
             List<bool> result = new List<bool>();
@@ -131,8 +196,8 @@ namespace TeamAAS_VP.Services
                 Z = PlcPoint.TorquePoints[3].Z_Position_Start,
             };
 
-            result.Add( await Robot.JumpAsync(point, 0));
-            
+            result.Add(await Robot.JumpAsync(point, 0));
+
             return !result.Contains(false);
         }
 

+ 4 - 0
TeamAAS-VM/Views/Home/TorqueCheck.xaml

@@ -50,6 +50,10 @@
     </Setter>-->
             <Setter Property="WindowStyle"
                     Value="SingleBorderWindow" />
+            <Setter Property="ResizeMode"
+                    Value="NoResize" />
+            <Setter Property="SizeToContent"
+                    Value="Manual" />
             <Setter Property="AllowDrop"
                     Value="True" />
             <Setter Property="BorderThickness"