|
|
@@ -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;
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
}
|