|
|
@@ -19,10 +19,12 @@ using System.Threading;
|
|
|
using System.Threading.Tasks;
|
|
|
using Team.FFFeederService.Interfaces;
|
|
|
using TeamAAS_VP.Core;
|
|
|
+using TeamAAS_VP.Core.PLCs;
|
|
|
using TeamAAS_VP.Enums;
|
|
|
using TeamAAS_VP.Interfaces;
|
|
|
using TeamAAS_VP.Models;
|
|
|
using TeamAAS_VP.Resources.Languages;
|
|
|
+using TeamAAS_VP.Services;
|
|
|
using static TeamAAS_VP.Core.StabilityAnalyzer;
|
|
|
|
|
|
namespace TeamAAS_VP.ViewModels.Product
|
|
|
@@ -39,10 +41,17 @@ namespace TeamAAS_VP.ViewModels.Product
|
|
|
ISystemDatabaseService _systemDatabaseService;
|
|
|
ICalibrationService _calibrationService;
|
|
|
IConfigService _configService;
|
|
|
+ IPlcService _plcService;
|
|
|
|
|
|
//测试过程中控制取消的CTS
|
|
|
CancellationTokenSource _cts;
|
|
|
|
|
|
+ string manualToWork = "ns=4;s=DB_DriveControl|CylCtrl[6].Cmd.ManuToWork";
|
|
|
+ string manualToHome = "ns=4;s=DB_DriveControl|CylCtrl[6].Cmd.ManuToHome";
|
|
|
+ string inWork = "ns=4;s=DB_DriveControl|CylCtrl[6].Status.InWork";
|
|
|
+ string inHome = "ns=4;s=DB_DriveControl|CylCtrl[6].Status.InHome";
|
|
|
+
|
|
|
+
|
|
|
#region 属性
|
|
|
|
|
|
private ProductModel _SelectProduct;
|
|
|
@@ -241,8 +250,7 @@ namespace TeamAAS_VP.ViewModels.Product
|
|
|
get { return _precisionResult; }
|
|
|
set { SetProperty(ref _precisionResult, value); }
|
|
|
}
|
|
|
-
|
|
|
- private int _ADelay = 300;
|
|
|
+ private int _ADelay = 3000;
|
|
|
/// <summary>
|
|
|
/// A点延时时间
|
|
|
/// </summary>
|
|
|
@@ -252,7 +260,7 @@ namespace TeamAAS_VP.ViewModels.Product
|
|
|
set { SetProperty(ref _ADelay, value); }
|
|
|
}
|
|
|
|
|
|
- private int _BDelay = 500;
|
|
|
+ private int _BDelay = 3000;
|
|
|
/// <summary>
|
|
|
/// B点延时时间
|
|
|
/// </summary>
|
|
|
@@ -272,12 +280,35 @@ namespace TeamAAS_VP.ViewModels.Product
|
|
|
set { SetProperty(ref _IsTakePhoto, value); }
|
|
|
}
|
|
|
|
|
|
- private int _ProIndex;
|
|
|
- public int ProIndex
|
|
|
+ private bool _IsCylCtrl = true;
|
|
|
+ /// <summary>
|
|
|
+ /// 是否启用气缸IsVertical
|
|
|
+ /// </summary>
|
|
|
+ public bool IsCylCtrl
|
|
|
{
|
|
|
- get { return _ProIndex; }
|
|
|
- set { SetProperty(ref _ProIndex, value); }
|
|
|
+ get { return _IsCylCtrl; }
|
|
|
+ set { SetProperty(ref _IsCylCtrl, value); }
|
|
|
}
|
|
|
+
|
|
|
+ private bool _IsVertical = true;
|
|
|
+ /// <summary>
|
|
|
+ /// 是否启用垂直精度检测
|
|
|
+ /// </summary>
|
|
|
+ public bool IsVertical
|
|
|
+ {
|
|
|
+ get { return _IsVertical; }
|
|
|
+ set { SetProperty(ref _IsVertical, value); }
|
|
|
+ }
|
|
|
+
|
|
|
+ private float _Distance;
|
|
|
+
|
|
|
+ public float Distance
|
|
|
+ {
|
|
|
+ get { return _Distance; }
|
|
|
+ set { SetProperty(ref _Distance, value); }
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
#endregion
|
|
|
|
|
|
#region 命令
|
|
|
@@ -324,7 +355,7 @@ namespace TeamAAS_VP.ViewModels.Product
|
|
|
|
|
|
private DelegateCommand _ProcedureSelectionChangedCommand;
|
|
|
public DelegateCommand ProcedureSelectionChangedCommand =>
|
|
|
- _ProcedureSelectionChangedCommand ?? (_ProcedureSelectionChangedCommand = new DelegateCommand(ExecuteProcedureSelectionChangedCommand, () => !IsRunning).ObservesProperty(() => IsRunning));
|
|
|
+ _ProcedureSelectionChangedCommand ?? (_ProcedureSelectionChangedCommand = new DelegateCommand(ExecuteProcedureSelectionChangedCommand, () => !IsRunning).ObservesProperty(() => IsRunning).ObservesProperty(() => SelectProcedure));
|
|
|
|
|
|
private DelegateCommand _SingleTestCommand;
|
|
|
public DelegateCommand SingleTestCommand =>
|
|
|
@@ -343,7 +374,7 @@ namespace TeamAAS_VP.ViewModels.Product
|
|
|
|
|
|
public VisionDynamicAccuracyAnalyzerViewModel(IRegionManager regionManager, IEventAggregator ea, IContainerProvider container, IDialogService dialogService,
|
|
|
IFeederService feederService, IRobotService robotService, ICameraService cameraService, ISystemDatabaseService systemDatabaseService, ICalibrationService calibrationService,
|
|
|
- IConfigService configService)
|
|
|
+ IConfigService configService, IPlcService plcService)
|
|
|
{
|
|
|
_regionManager = regionManager;
|
|
|
_eventAggregator = ea;
|
|
|
@@ -356,6 +387,7 @@ namespace TeamAAS_VP.ViewModels.Product
|
|
|
MessageQueue = new SnackbarMessageQueue(TimeSpan.FromSeconds(1));
|
|
|
_calibrationService = calibrationService;
|
|
|
_configService = configService;
|
|
|
+ _plcService = plcService;
|
|
|
}
|
|
|
|
|
|
#region 方法
|
|
|
@@ -389,62 +421,141 @@ namespace TeamAAS_VP.ViewModels.Product
|
|
|
/// </summary>
|
|
|
async void ExecuteSingleTestCommand()
|
|
|
{
|
|
|
- if (Robot == null || !Robot.IsConnected)
|
|
|
- {
|
|
|
- SendTaskMessage("机器人未连接,无法示教!");
|
|
|
- return;
|
|
|
- }
|
|
|
+ IsRunning = true;
|
|
|
+ _cts = new CancellationTokenSource();
|
|
|
+ CurrentProgress = 0;
|
|
|
+ SuccessCount = 0;
|
|
|
+ SuccessRate = 0;
|
|
|
+ FailCount = 0;
|
|
|
+ Message = "测试进行中...";
|
|
|
+ TestResults = new ObservableCollection<DynamicTestResult>();
|
|
|
|
|
|
- if (Camera == null || !Camera.IsConnected)
|
|
|
+ try
|
|
|
{
|
|
|
- SendTaskMessage("相机未连接,无法示教!");
|
|
|
- return;
|
|
|
- }
|
|
|
+ //弹窗提示是否进行连续测试
|
|
|
+ var result = System.Windows.MessageBox.Show("确定进行单次测试吗?", "提示", System.Windows.MessageBoxButton.YesNo, System.Windows.MessageBoxImage.Question);
|
|
|
+ if (result != System.Windows.MessageBoxResult.Yes)
|
|
|
+ {
|
|
|
+ return;
|
|
|
+ }
|
|
|
|
|
|
- //弹窗提示是否进行单次测试
|
|
|
- var result = System.Windows.MessageBox.Show("确定进行单次测试吗?", "提示", System.Windows.MessageBoxButton.YesNo, System.Windows.MessageBoxImage.Question);
|
|
|
- if (result != System.Windows.MessageBoxResult.Yes)
|
|
|
- {
|
|
|
- return;
|
|
|
- }
|
|
|
+ var addressConfig = _configService.GetPlcAddresses();
|
|
|
+ var plc = _plcService.GetPlcByNumber(addressConfig.PlcNo) as OpcUaClientPLC;
|
|
|
+
|
|
|
+ if (Robot == null || !Robot.IsConnected)
|
|
|
+ {
|
|
|
+ SendTaskMessage("机器人未连接,无法示教!");
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
+ if (IsTakePhoto)
|
|
|
+ {
|
|
|
+ if (Camera == null || !Camera.IsConnected)
|
|
|
+ {
|
|
|
+ SendTaskMessage("相机未连接,无法示教!");
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ }
|
|
|
|
|
|
- IsRunning = true;
|
|
|
- try
|
|
|
- {
|
|
|
- DateTime startTime = DateTime.Now;
|
|
|
//为机器人设置移动速度
|
|
|
await Robot.CalibParameAsync(new PickInfo(), MoveSpeed, 0, false, 0, 0);
|
|
|
|
|
|
- //移动机器人至A点
|
|
|
- bool isSuccess1 = await Robot.CalibMotionAsync(PointA, null);
|
|
|
- if (!isSuccess1)
|
|
|
+
|
|
|
+ if (_cts.Token.IsCancellationRequested)
|
|
|
{
|
|
|
- SendTaskMessage("机器人移动到A点失败!");
|
|
|
+ Message = "测试已取消!";
|
|
|
return;
|
|
|
}
|
|
|
- await Task.Delay(ADelay);
|
|
|
+ DateTime startTime = DateTime.Now;
|
|
|
|
|
|
- //移动机器人至B点
|
|
|
- isSuccess1 = await Robot.CalibMotionAsync(PointB, null);
|
|
|
- if (!isSuccess1)
|
|
|
+ if (!IsCylCtrl)
|
|
|
{
|
|
|
- SendTaskMessage("机器人移动到B点失败!");
|
|
|
- return;
|
|
|
+ //移动机器人至A点
|
|
|
+ bool isSuccess1 = await Robot.CalibMotionAsync(PointA, null);
|
|
|
+ if (!isSuccess1)
|
|
|
+ {
|
|
|
+ SendTaskMessage("机器人移动到A点失败!");
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ await Task.Delay(ADelay);
|
|
|
+ if (_cts.Token.IsCancellationRequested)
|
|
|
+ {
|
|
|
+ Message = "测试已取消!";
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
+ //移动机器人至B点
|
|
|
+ isSuccess1 = await Robot.CalibMotionAsync(PointB, null);
|
|
|
+ if (!isSuccess1)
|
|
|
+ {
|
|
|
+ SendTaskMessage("机器人移动到B点失败!");
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ await Task.Delay(BDelay);
|
|
|
+ if (_cts.Token.IsCancellationRequested)
|
|
|
+ {
|
|
|
+ Message = "测试已取消!";
|
|
|
+ return;
|
|
|
+ }
|
|
|
}
|
|
|
- await Task.Delay(BDelay);
|
|
|
+ else
|
|
|
+ {
|
|
|
+ //气缸升上去
|
|
|
+ await plc.WriteNodeAsync(manualToWork, true);
|
|
|
+ await Task.Delay(BDelay);
|
|
|
+ await plc.ReadNodeAsync<bool>(inWork);
|
|
|
|
|
|
+ if (_cts.Token.IsCancellationRequested)
|
|
|
+ {
|
|
|
+ Message = "测试已取消!";
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ }
|
|
|
if (IsTakePhoto)
|
|
|
{
|
|
|
//相机拍照并处理
|
|
|
(bool isSuccess, double pixelX, double pixelY, double angleU, double transformX, double transformY) = await ExecutePhotoEx(CurrentProgress);
|
|
|
- }
|
|
|
|
|
|
- CycleTime = DateTime.Now.Subtract(startTime).TotalSeconds;
|
|
|
+ CycleTime = DateTime.Now.Subtract(startTime).TotalSeconds;
|
|
|
+
|
|
|
+ if (isSuccess)
|
|
|
+ {
|
|
|
+ SuccessCount++;
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ FailCount++;
|
|
|
+ }
|
|
|
+ TestResults.Add(new DynamicTestResult(CurrentProgress, isSuccess, PointB, CycleTime, pixelX, pixelY, angleU, transformX, transformY));
|
|
|
+ OnTestResultAdded();
|
|
|
+
|
|
|
+ CurrentProgress++;
|
|
|
+ SuccessRate = (double)SuccessCount / CurrentProgress * 100;
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ CycleTime = DateTime.Now.Subtract(startTime).TotalSeconds;
|
|
|
+ SuccessCount++;
|
|
|
+ CurrentProgress++;
|
|
|
+ SuccessRate = (double)SuccessCount / CurrentProgress * 100;
|
|
|
+ }
|
|
|
+ if (IsCylCtrl)
|
|
|
+ {
|
|
|
+ await plc.WriteNodeAsync(manualToHome, true);
|
|
|
+ await Task.Delay(ADelay);
|
|
|
+ //inHome 气杆在底部 InWork在上面
|
|
|
+ await plc.ReadNodeAsync<bool>(inHome);
|
|
|
+ if (_cts.Token.IsCancellationRequested)
|
|
|
+ {
|
|
|
+ Message = "测试已取消!";
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ Message = "测试完成!";
|
|
|
}
|
|
|
catch (Exception ex)
|
|
|
{
|
|
|
- LogHelper.WriteLogError("机器人移动到A点失败!", ex);
|
|
|
- SendTaskMessage("机器人移动到A点失败!");
|
|
|
+ LogHelper.WriteLogError("视觉动态重复测试时出错!", ex);
|
|
|
}
|
|
|
finally
|
|
|
{
|
|
|
@@ -465,6 +576,8 @@ namespace TeamAAS_VP.ViewModels.Product
|
|
|
SuccessRate = 0;
|
|
|
FailCount = 0;
|
|
|
Message = "测试进行中...";
|
|
|
+ int up = 1;
|
|
|
+ int down = 0;
|
|
|
TestResults = new ObservableCollection<DynamicTestResult>();
|
|
|
|
|
|
try
|
|
|
@@ -476,16 +589,22 @@ namespace TeamAAS_VP.ViewModels.Product
|
|
|
return;
|
|
|
}
|
|
|
|
|
|
+ var addressConfig = _configService.GetPlcAddresses();
|
|
|
+ var plc = _plcService.GetPlcByNumber(addressConfig.PlcNo) as OpcUaClientPLC;
|
|
|
+
|
|
|
if (Robot == null || !Robot.IsConnected)
|
|
|
{
|
|
|
SendTaskMessage("机器人未连接,无法示教!");
|
|
|
return;
|
|
|
}
|
|
|
|
|
|
- if (Camera == null || !Camera.IsConnected)
|
|
|
+ if (IsTakePhoto)
|
|
|
{
|
|
|
- SendTaskMessage("相机未连接,无法示教!");
|
|
|
- return;
|
|
|
+ if (Camera == null || !Camera.IsConnected)
|
|
|
+ {
|
|
|
+ SendTaskMessage("相机未连接,无法示教!");
|
|
|
+ return;
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
//为机器人设置移动速度
|
|
|
@@ -500,34 +619,75 @@ namespace TeamAAS_VP.ViewModels.Product
|
|
|
}
|
|
|
DateTime startTime = DateTime.Now;
|
|
|
|
|
|
- //移动机器人至A点
|
|
|
- bool isSuccess1 = await Robot.CalibMotionAsync(PointA, null);
|
|
|
- if (!isSuccess1)
|
|
|
+ if (IsVertical)
|
|
|
{
|
|
|
- SendTaskMessage("机器人移动到A点失败!");
|
|
|
- return;
|
|
|
+ RPoint verticalPosition = PointB.Clone();
|
|
|
+ if (CurrentProgress > (RepeatCount / 2))
|
|
|
+ {
|
|
|
+ verticalPosition.Z += up++ * Distance;
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ verticalPosition.Z -= down++ * Distance;
|
|
|
+ }
|
|
|
+ //移动机器人至B点
|
|
|
+ bool isSuccess1 = await Robot.GoAsync(verticalPosition);
|
|
|
+ if (!isSuccess1)
|
|
|
+ {
|
|
|
+ SendTaskMessage("机器人移动到B点失败!");
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ await Task.Delay(BDelay);
|
|
|
+ if (_cts.Token.IsCancellationRequested)
|
|
|
+ {
|
|
|
+ Message = "测试已取消!";
|
|
|
+ break;
|
|
|
+ }
|
|
|
}
|
|
|
- await Task.Delay(ADelay);
|
|
|
- if (_cts.Token.IsCancellationRequested)
|
|
|
+ else if (!IsCylCtrl)
|
|
|
{
|
|
|
- Message = "测试已取消!";
|
|
|
- break;
|
|
|
- }
|
|
|
+ IsVertical = false;
|
|
|
+ //移动机器人至A点
|
|
|
+ bool isSuccess1 = await Robot.CalibMotionAsync(PointA, null);
|
|
|
+ if (!isSuccess1)
|
|
|
+ {
|
|
|
+ SendTaskMessage("机器人移动到A点失败!");
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ await Task.Delay(ADelay);
|
|
|
+ if (_cts.Token.IsCancellationRequested)
|
|
|
+ {
|
|
|
+ Message = "测试已取消!";
|
|
|
+ break;
|
|
|
+ }
|
|
|
|
|
|
- //移动机器人至B点
|
|
|
- isSuccess1 = await Robot.CalibMotionAsync(PointB, null);
|
|
|
- if (!isSuccess1)
|
|
|
- {
|
|
|
- SendTaskMessage("机器人移动到B点失败!");
|
|
|
- return;
|
|
|
+ //移动机器人至B点
|
|
|
+ isSuccess1 = await Robot.CalibMotionAsync(PointB, null);
|
|
|
+ if (!isSuccess1)
|
|
|
+ {
|
|
|
+ SendTaskMessage("机器人移动到B点失败!");
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ await Task.Delay(BDelay);
|
|
|
+ if (_cts.Token.IsCancellationRequested)
|
|
|
+ {
|
|
|
+ Message = "测试已取消!";
|
|
|
+ break;
|
|
|
+ }
|
|
|
}
|
|
|
- await Task.Delay(BDelay);
|
|
|
- if (_cts.Token.IsCancellationRequested)
|
|
|
+ else
|
|
|
{
|
|
|
- Message = "测试已取消!";
|
|
|
- break;
|
|
|
- }
|
|
|
+ //气缸升上去
|
|
|
+ await plc.WriteNodeAsync(manualToWork, true);
|
|
|
+ await Task.Delay(BDelay);
|
|
|
+ await plc.ReadNodeAsync<bool>(inWork);
|
|
|
|
|
|
+ if (_cts.Token.IsCancellationRequested)
|
|
|
+ {
|
|
|
+ Message = "测试已取消!";
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ }
|
|
|
if (IsTakePhoto)
|
|
|
{
|
|
|
//相机拍照并处理
|
|
|
@@ -556,6 +716,18 @@ namespace TeamAAS_VP.ViewModels.Product
|
|
|
CurrentProgress++;
|
|
|
SuccessRate = (double)SuccessCount / CurrentProgress * 100;
|
|
|
}
|
|
|
+ if (IsCylCtrl)
|
|
|
+ {
|
|
|
+ await plc.WriteNodeAsync(manualToHome, true);
|
|
|
+ await Task.Delay(ADelay);
|
|
|
+ //inHome 气杆在底部 InWork在上面
|
|
|
+ await plc.ReadNodeAsync<bool>(inHome);
|
|
|
+ if (_cts.Token.IsCancellationRequested)
|
|
|
+ {
|
|
|
+ Message = "测试已取消!";
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ }
|
|
|
SendTaskMessage($"测试进行中... {CurrentProgress}/{RepeatCount}");
|
|
|
}
|
|
|
if (CurrentProgress >= RepeatCount)
|
|
|
@@ -565,7 +737,7 @@ namespace TeamAAS_VP.ViewModels.Product
|
|
|
}
|
|
|
catch (Exception ex)
|
|
|
{
|
|
|
- LogHelper.WriteLogError("视觉静态重复测试时出错!", ex);
|
|
|
+ LogHelper.WriteLogError("视觉动态重复测试时出错!", ex);
|
|
|
}
|
|
|
finally
|
|
|
{
|
|
|
@@ -1124,15 +1296,15 @@ namespace TeamAAS_VP.ViewModels.Product
|
|
|
bool succed = Camera.SetExposureTime(SelectProcedure.ExposureTime);
|
|
|
if (!succed)
|
|
|
{
|
|
|
- SendTaskMessage(Lang.相机曝光设置失败);
|
|
|
+ SendTaskMessage("相机曝光设置失败");
|
|
|
}
|
|
|
succed = Camera.SetGain(SelectProcedure.Gain);
|
|
|
if (!succed)
|
|
|
{
|
|
|
- SendTaskMessage(Lang.相机增益设置失败);
|
|
|
+ SendTaskMessage("相机增益设置失败");
|
|
|
}
|
|
|
DateTime nowtime = DateTime.Now;
|
|
|
- LogHelper.WriteLogInfo(Lang.开始采集图像);
|
|
|
+ LogHelper.WriteLogInfo("开始采集图像");
|
|
|
var image = Camera.Grab();
|
|
|
if (image == null)
|
|
|
{
|
|
|
@@ -1165,7 +1337,7 @@ namespace TeamAAS_VP.ViewModels.Product
|
|
|
//}
|
|
|
Image = VisionTool.Inputs["InputImage"].Value as ICogImage;
|
|
|
// 3. 运行视觉工具
|
|
|
- LogHelper.WriteLogInfo(Lang.开始运行视觉工具);
|
|
|
+ LogHelper.WriteLogInfo("开始运行视觉工具");
|
|
|
VisionTool.Run(); //运行ToolBlock
|
|
|
|
|
|
if (VisionTool.RunStatus.Result == CogToolResultConstants.Accept)
|
|
|
@@ -1237,7 +1409,7 @@ namespace TeamAAS_VP.ViewModels.Product
|
|
|
catch (Exception ex)
|
|
|
{
|
|
|
SendTaskMessage(ex.Message);
|
|
|
- LogHelper.WriteLogError(Lang.执行相机取图并执行视觉工具组时出错, ex);
|
|
|
+ LogHelper.WriteLogError("执行相机取图并执行视觉工具组时出错", ex);
|
|
|
outputCollection = null;
|
|
|
return (false, 0d, 0d, 0d, 0d, 0d);
|
|
|
}
|
|
|
@@ -1502,24 +1674,33 @@ namespace TeamAAS_VP.ViewModels.Product
|
|
|
private void LoadConfig()
|
|
|
{
|
|
|
//配置文件路径:FilePath.ProductsPath//productName//VisionDynamicAccuracyAnalyzerConfig.json
|
|
|
- string configPath = System.IO.Path.Combine(FilePath.ProductsPath, SelectProduct.Name, "VisionDynamicAccuracyAnalyzerConfig.json");
|
|
|
- if (System.IO.File.Exists(configPath))
|
|
|
+ string configPath = Path.Combine(FilePath.ProductsPath, SelectProduct.Name, "VisionDynamicAccuracyAnalyzerConfig.json");
|
|
|
+ if (File.Exists(configPath))
|
|
|
{
|
|
|
try
|
|
|
{
|
|
|
- string json = System.IO.File.ReadAllText(configPath);
|
|
|
+ string json = File.ReadAllText(configPath);
|
|
|
var ConfigModel = JsonConvert.DeserializeObject<VisionDynamicAccuracyAnalyzerConfigModel>(json);
|
|
|
- //加载点位A、B
|
|
|
- PointA = ConfigModel.PointA;
|
|
|
- PointB = ConfigModel.PointB;
|
|
|
+ //加载点位界面参数
|
|
|
+ this.PointA = ConfigModel.PointA;
|
|
|
+ this.PointB = ConfigModel.PointB;
|
|
|
+ this.MoveSpeed = ConfigModel.RobotMoveSpeed;
|
|
|
+ this.RepeatCount = ConfigModel.TestCount;
|
|
|
+ this.ADelay = ConfigModel.ADelay;
|
|
|
+ this.BDelay = ConfigModel.BDelay;
|
|
|
+ this.IsCylCtrl = ConfigModel.IsCylCtrl;
|
|
|
+ this.IsTakePhoto = ConfigModel.IsTakePhoto;
|
|
|
+ this.IsVertical = ConfigModel.IsVertical;
|
|
|
+ this.Distance = ConfigModel.Distance;
|
|
|
+
|
|
|
//加载选中视觉流程
|
|
|
var procedure = ProcedureModels.FirstOrDefault(p => p.Id == ConfigModel.SelectProcedureId);
|
|
|
if (procedure != null)
|
|
|
{
|
|
|
- SelectProcedure = procedure;
|
|
|
+ this.SelectProcedure = procedure;
|
|
|
+ this.Camera = _cameraService.GetCamera(SelectProcedure.CameraId);
|
|
|
}
|
|
|
- MoveSpeed = ConfigModel.RobotMoveSpeed;
|
|
|
- RepeatCount = ConfigModel.TestCount;
|
|
|
+
|
|
|
}
|
|
|
catch (Exception ex)
|
|
|
{
|
|
|
@@ -1536,25 +1717,31 @@ namespace TeamAAS_VP.ViewModels.Product
|
|
|
try
|
|
|
{
|
|
|
//配置文件路径:FilePath.ProductsPath//productName//VisionDynamicAccuracyAnalyzerConfig.json
|
|
|
- string configPath = System.IO.Path.Combine(FilePath.ProductsPath, SelectProduct.Name, "VisionDynamicAccuracyAnalyzerConfig.json");
|
|
|
+ string configPath = Path.Combine(FilePath.ProductsPath, SelectProduct.Name, "VisionDynamicAccuracyAnalyzerConfig.json");
|
|
|
var ConfigModel = new VisionDynamicAccuracyAnalyzerConfigModel
|
|
|
{
|
|
|
- PointA = PointA,
|
|
|
- PointB = PointB,
|
|
|
- SelectProcedureId = SelectProcedure?.Id ?? Guid.Empty,
|
|
|
- SelectProcedureName = SelectProcedure?.Name ?? "",
|
|
|
- RobotMoveSpeed = MoveSpeed,
|
|
|
- TestCount = RepeatCount
|
|
|
+ PointA = this.PointA,
|
|
|
+ PointB = this.PointB,
|
|
|
+ SelectProcedureId = this.SelectProcedure?.Id ?? Guid.Empty,
|
|
|
+ SelectProcedureName = this.SelectProcedure?.Name ?? "",
|
|
|
+ RobotMoveSpeed = this.MoveSpeed,
|
|
|
+ TestCount = this.RepeatCount,
|
|
|
+ ADelay = this.ADelay,
|
|
|
+ BDelay = this.BDelay,
|
|
|
+ IsCylCtrl = this.IsCylCtrl,
|
|
|
+ IsTakePhoto = this.IsTakePhoto,
|
|
|
+ IsVertical = this.IsVertical,
|
|
|
+ Distance = this.Distance,
|
|
|
};
|
|
|
//如果配置文件夹不存在则创建
|
|
|
- var configDir = System.IO.Path.GetDirectoryName(configPath);
|
|
|
+ var configDir = Path.GetDirectoryName(configPath);
|
|
|
if (!Directory.Exists(configDir))
|
|
|
{
|
|
|
Directory.CreateDirectory(configDir);
|
|
|
}
|
|
|
|
|
|
string json = JsonConvert.SerializeObject(ConfigModel, Formatting.Indented);
|
|
|
- System.IO.File.WriteAllText(configPath, json);
|
|
|
+ File.WriteAllText(configPath, json);
|
|
|
}
|
|
|
catch (Exception ex)
|
|
|
{
|
|
|
@@ -1626,6 +1813,58 @@ namespace TeamAAS_VP.ViewModels.Product
|
|
|
set { SetProperty(ref _SelectProcedureName, value); }
|
|
|
}
|
|
|
|
|
|
+ private int _ADelay;
|
|
|
+
|
|
|
+ public int ADelay
|
|
|
+ {
|
|
|
+ get { return _ADelay; }
|
|
|
+ set { _ADelay = value; }
|
|
|
+ }
|
|
|
+
|
|
|
+ private int _BDelay;
|
|
|
+
|
|
|
+ public int BDelay
|
|
|
+ {
|
|
|
+ get { return _BDelay; }
|
|
|
+ set { _BDelay = value; }
|
|
|
+ }
|
|
|
+
|
|
|
+ private bool _IsCylCtrl;
|
|
|
+
|
|
|
+ public bool IsCylCtrl
|
|
|
+ {
|
|
|
+ get { return _IsCylCtrl; }
|
|
|
+ set { _IsCylCtrl = value; }
|
|
|
+ }
|
|
|
+
|
|
|
+ private bool _IsTakePhoto;
|
|
|
+
|
|
|
+ public bool IsTakePhoto
|
|
|
+ {
|
|
|
+ get { return _IsTakePhoto; }
|
|
|
+ set { _IsTakePhoto = value; }
|
|
|
+ }
|
|
|
+
|
|
|
+ private bool _IsVertical = true;
|
|
|
+ /// <summary>
|
|
|
+ /// 是否启用垂直精度检测
|
|
|
+ /// </summary>
|
|
|
+ public bool IsVertical
|
|
|
+ {
|
|
|
+ get { return _IsVertical; }
|
|
|
+ set { SetProperty(ref _IsVertical, value); }
|
|
|
+ }
|
|
|
+
|
|
|
+ private float _Distance;
|
|
|
+
|
|
|
+ public float Distance
|
|
|
+ {
|
|
|
+ get { return _Distance; }
|
|
|
+ set { SetProperty(ref _Distance, value); }
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
}
|
|
|
|
|
|
}
|