|
@@ -4,10 +4,12 @@ using Prism.Ioc;
|
|
|
using Prism.Mvvm;
|
|
using Prism.Mvvm;
|
|
|
using System;
|
|
using System;
|
|
|
using System.Collections.Generic;
|
|
using System.Collections.Generic;
|
|
|
|
|
+using System.IO;
|
|
|
using System.Linq;
|
|
using System.Linq;
|
|
|
using System.Text;
|
|
using System.Text;
|
|
|
using System.Threading;
|
|
using System.Threading;
|
|
|
using System.Threading.Tasks;
|
|
using System.Threading.Tasks;
|
|
|
|
|
+using System.Windows;
|
|
|
using TeamAAS_VP.Core;
|
|
using TeamAAS_VP.Core;
|
|
|
using TeamAAS_VP.Core.PLCs;
|
|
using TeamAAS_VP.Core.PLCs;
|
|
|
using TeamAAS_VP.Events;
|
|
using TeamAAS_VP.Events;
|
|
@@ -20,6 +22,8 @@ namespace TeamAAS_VP.Services
|
|
|
{
|
|
{
|
|
|
public class TorqueService : BindableBase
|
|
public class TorqueService : BindableBase
|
|
|
{
|
|
{
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
IEventAggregator _eventAggregator;
|
|
IEventAggregator _eventAggregator;
|
|
|
IConfigService _configService;
|
|
IConfigService _configService;
|
|
|
IContainerProvider _container;
|
|
IContainerProvider _container;
|
|
@@ -27,7 +31,68 @@ namespace TeamAAS_VP.Services
|
|
|
IPlcService _plcService;
|
|
IPlcService _plcService;
|
|
|
private Management management;
|
|
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,
|
|
public TorqueService(IEventAggregator ea, IConfigService configService,
|
|
|
IContainerProvider container, IRobotService robotService, IPlcService plcService)
|
|
IContainerProvider container, IRobotService robotService, IPlcService plcService)
|
|
@@ -120,7 +185,7 @@ namespace TeamAAS_VP.Services
|
|
|
return !result.Contains(false);
|
|
return !result.Contains(false);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
-
|
|
|
|
|
|
|
+
|
|
|
public async Task<bool> Safety_Position_Async(IRobot Robot, OpcUaClientPLC plc, PlcAddressConfig addressConfig, TorqueProduceModel PlcPoint)
|
|
public async Task<bool> Safety_Position_Async(IRobot Robot, OpcUaClientPLC plc, PlcAddressConfig addressConfig, TorqueProduceModel PlcPoint)
|
|
|
{
|
|
{
|
|
|
List<bool> result = new List<bool>();
|
|
List<bool> result = new List<bool>();
|
|
@@ -131,8 +196,8 @@ namespace TeamAAS_VP.Services
|
|
|
Z = PlcPoint.TorquePoints[3].Z_Position_Start,
|
|
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);
|
|
return !result.Contains(false);
|
|
|
}
|
|
}
|
|
|
|
|
|