|
|
@@ -1,6 +1,7 @@
|
|
|
using Cognex.VisionPro;
|
|
|
using Cognex.VisionPro.ToolBlock;
|
|
|
using MaterialDesignThemes.Wpf;
|
|
|
+using Newtonsoft.Json;
|
|
|
using OxyPlot;
|
|
|
using Prism.Commands;
|
|
|
using Prism.Events;
|
|
|
@@ -1390,14 +1391,13 @@ namespace TeamAAS_VP.ViewModels.Product
|
|
|
public void OnDialogClosed()
|
|
|
{
|
|
|
_cts?.Cancel();
|
|
|
+ SaveConfig();
|
|
|
}
|
|
|
|
|
|
public void OnDialogOpened(IDialogParameters parameters)
|
|
|
{
|
|
|
SelectProduct = parameters.GetValue<ProductModel>("SelectProduct");
|
|
|
Robot = parameters.GetValue<IRobot>("Robot");
|
|
|
- //Camera = _cameraService.GetCamera(SelectProcedure.CameraId);
|
|
|
- //VisionTool = parameters.GetValue<CogToolBlock>("ToolBlock");
|
|
|
ProcedureModels = new ObservableCollection<ProcedureModel>();
|
|
|
foreach (var item in SelectProduct.CameraProcedures)
|
|
|
{
|
|
|
@@ -1406,10 +1406,142 @@ namespace TeamAAS_VP.ViewModels.Product
|
|
|
ProcedureModels.Add(item1);
|
|
|
}
|
|
|
}
|
|
|
- //VisionTool.Run();
|
|
|
- //TestResult = CreateResultDataTable(VisionTool.Outputs);
|
|
|
+ LoadConfig();
|
|
|
}
|
|
|
#endregion
|
|
|
+
|
|
|
+ /// <summary>
|
|
|
+ /// 加载配置
|
|
|
+ /// </summary>
|
|
|
+ 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))
|
|
|
+ {
|
|
|
+ try
|
|
|
+ {
|
|
|
+ string json = System.IO.File.ReadAllText(configPath);
|
|
|
+ var ConfigModel = JsonConvert.DeserializeObject<VisionDynamicAccuracyAnalyzerConfigModel>(json);
|
|
|
+ //加载点位A、B
|
|
|
+ PointA = ConfigModel.PointA;
|
|
|
+ PointB = ConfigModel.PointB;
|
|
|
+ //加载选中视觉流程
|
|
|
+ var procedure = ProcedureModels.FirstOrDefault(p => p.Id == ConfigModel.SelectProcedureId);
|
|
|
+ if (procedure != null)
|
|
|
+ {
|
|
|
+ SelectProcedure = procedure;
|
|
|
+ }
|
|
|
+ MoveSpeed = ConfigModel.RobotMoveSpeed;
|
|
|
+ RepeatCount = ConfigModel.TestCount;
|
|
|
+ }
|
|
|
+ catch (Exception ex)
|
|
|
+ {
|
|
|
+ LogHelper.WriteLogError("加载视觉动态精度分析仪配置时出错", ex);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ /// <summary>
|
|
|
+ /// 保存配置
|
|
|
+ /// </summary>
|
|
|
+ private void SaveConfig()
|
|
|
+ {
|
|
|
+ try
|
|
|
+ {
|
|
|
+ //配置文件路径:FilePath.ProductsPath//productName//VisionDynamicAccuracyAnalyzerConfig.json
|
|
|
+ string configPath = System.IO.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
|
|
|
+ };
|
|
|
+ //如果配置文件夹不存在则创建
|
|
|
+ var configDir = System.IO.Path.GetDirectoryName(configPath);
|
|
|
+ if (!Directory.Exists(configDir))
|
|
|
+ {
|
|
|
+ Directory.CreateDirectory(configDir);
|
|
|
+ }
|
|
|
+
|
|
|
+ string json = JsonConvert.SerializeObject(ConfigModel, Formatting.Indented);
|
|
|
+ System.IO.File.WriteAllText(configPath, json);
|
|
|
+ }
|
|
|
+ catch (Exception ex)
|
|
|
+ {
|
|
|
+ LogHelper.WriteLogError("保存视觉动态精度分析仪配置时出错", ex);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ //配置参数模型
|
|
|
+ public class VisionDynamicAccuracyAnalyzerConfigModel : BindableBase
|
|
|
+ {
|
|
|
+ private int _RobotMoveSpeed = 100;
|
|
|
+ /// <summary>
|
|
|
+ /// 机器人移动速度
|
|
|
+ /// </summary>
|
|
|
+ public int RobotMoveSpeed
|
|
|
+ {
|
|
|
+ get { return _RobotMoveSpeed; }
|
|
|
+ set { SetProperty(ref _RobotMoveSpeed, value); }
|
|
|
+ }
|
|
|
+ private int _TestCount = 10;
|
|
|
+ /// <summary>
|
|
|
+ /// 测试次数
|
|
|
+ /// </summary>
|
|
|
+ public int TestCount
|
|
|
+ {
|
|
|
+ get { return _TestCount; }
|
|
|
+ set { SetProperty(ref _TestCount, value); }
|
|
|
+ }
|
|
|
+
|
|
|
+ //点位A
|
|
|
+ private RPoint _PointA;
|
|
|
+ /// <summary>
|
|
|
+ /// 点位A
|
|
|
+ /// </summary>
|
|
|
+ public RPoint PointA
|
|
|
+ {
|
|
|
+ get { return _PointA; }
|
|
|
+ set { SetProperty(ref _PointA, value); }
|
|
|
+ }
|
|
|
+
|
|
|
+ //点位B
|
|
|
+ private RPoint _PointB;
|
|
|
+ /// <summary>
|
|
|
+ /// 点位B
|
|
|
+ /// </summary>
|
|
|
+ public RPoint PointB
|
|
|
+ {
|
|
|
+ get { return _PointB; }
|
|
|
+ set { SetProperty(ref _PointB, value); }
|
|
|
+ }
|
|
|
+
|
|
|
+ private Guid _SelectProcedureId;
|
|
|
+ /// <summary>
|
|
|
+ /// 选中的视觉流程ID
|
|
|
+ /// </summary>
|
|
|
+ public Guid SelectProcedureId
|
|
|
+ {
|
|
|
+ get { return _SelectProcedureId; }
|
|
|
+ set { SetProperty(ref _SelectProcedureId, value); }
|
|
|
+ }
|
|
|
+
|
|
|
+ private string _SelectProcedureName;
|
|
|
+ /// <summary>
|
|
|
+ /// 选中的视觉流程Name
|
|
|
+ /// </summary>
|
|
|
+ public string SelectProcedureName
|
|
|
+ {
|
|
|
+ get { return _SelectProcedureName; }
|
|
|
+ set { SetProperty(ref _SelectProcedureName, value); }
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
}
|
|
|
|
|
|
public class DynamicTestResult : BindableBase
|