|
@@ -121,17 +121,6 @@ namespace TeamAAS_VP.Core
|
|
|
set { SetProperty(ref _Renders, value); }
|
|
set { SetProperty(ref _Renders, value); }
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- private ProductModel _CurrentProduct;
|
|
|
|
|
-
|
|
|
|
|
- /// <summary>
|
|
|
|
|
- /// 当前产品
|
|
|
|
|
- /// </summary>
|
|
|
|
|
- public ProductModel CurrentProduct
|
|
|
|
|
- {
|
|
|
|
|
- get { return _CurrentProduct; }
|
|
|
|
|
- set { SetProperty(ref _CurrentProduct, value); }
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
public BgCommunicate BgCommunicate { get; private set; }
|
|
public BgCommunicate BgCommunicate { get; private set; }
|
|
|
|
|
|
|
|
public BgModbusTcpCommunicate BgModbusTcpCommunicate { get; private set; }
|
|
public BgModbusTcpCommunicate BgModbusTcpCommunicate { get; private set; }
|
|
@@ -828,7 +817,7 @@ namespace TeamAAS_VP.Core
|
|
|
/// </summary>
|
|
/// </summary>
|
|
|
/// <param name="plc"></param>
|
|
/// <param name="plc"></param>
|
|
|
/// <param name="isconnected"></param>
|
|
/// <param name="isconnected"></param>
|
|
|
- private void Management_PlcConnectChangedEvent(object sender, bool isconnected)
|
|
|
|
|
|
|
+ private async void Management_PlcConnectChangedEvent(object sender, bool isconnected)
|
|
|
{
|
|
{
|
|
|
IPlc plc = sender as IPlc;
|
|
IPlc plc = sender as IPlc;
|
|
|
var sta = Status.FirstOrDefault(s => s.ID == plc.Id);
|
|
var sta = Status.FirstOrDefault(s => s.ID == plc.Id);
|
|
@@ -842,6 +831,15 @@ namespace TeamAAS_VP.Core
|
|
|
sta.Message = $"{plc.Name}{Lang.已连接}";
|
|
sta.Message = $"{plc.Name}{Lang.已连接}";
|
|
|
sta.Background = new SolidColorBrush(Colors.Green);
|
|
sta.Background = new SolidColorBrush(Colors.Green);
|
|
|
}));
|
|
}));
|
|
|
|
|
+ try
|
|
|
|
|
+ {
|
|
|
|
|
+ await WriteSystemParameterToPlcAsync(_configService.GetSystemConfiguration());
|
|
|
|
|
+ await WritePositionToPlcAsync();
|
|
|
|
|
+ }
|
|
|
|
|
+ catch (Exception ex)
|
|
|
|
|
+ {
|
|
|
|
|
+ LogHelper.WriteLogError("PLC连接成功时,写入系统参数和点位信息时出错!", ex);
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|
|
|
else
|
|
else
|
|
|
{
|
|
{
|
|
@@ -1101,7 +1099,18 @@ namespace TeamAAS_VP.Core
|
|
|
/// 移动向下相机拍照结果
|
|
/// 移动向下相机拍照结果
|
|
|
/// </summary>
|
|
/// </summary>
|
|
|
OpenCvSharp.Point3f[] UpCameraPutResults = new OpenCvSharp.Point3f[10];
|
|
OpenCvSharp.Point3f[] UpCameraPutResults = new OpenCvSharp.Point3f[10];
|
|
|
-
|
|
|
|
|
|
|
+ /// <summary>
|
|
|
|
|
+ /// 取料移动相机拍照结果
|
|
|
|
|
+ /// </summary>
|
|
|
|
|
+ OpenCvSharp.Point3f UpCameraPickResult = new OpenCvSharp.Point3f();
|
|
|
|
|
+ /// <summary>
|
|
|
|
|
+ /// 最终组装位置
|
|
|
|
|
+ /// </summary>
|
|
|
|
|
+ OpenCvSharp.Point3f PlaceActualCoord = new OpenCvSharp.Point3f();
|
|
|
|
|
+ /// <summary>
|
|
|
|
|
+ /// 零件SN
|
|
|
|
|
+ /// </summary>
|
|
|
|
|
+ string PartSN = "";
|
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
/// <summary>
|
|
@@ -1209,7 +1218,7 @@ namespace TeamAAS_VP.Core
|
|
|
}
|
|
}
|
|
|
// 执行视觉任务
|
|
// 执行视觉任务
|
|
|
var _cts = new CancellationTokenSource();
|
|
var _cts = new CancellationTokenSource();
|
|
|
- var visionResult = await _remoteCommandService.ExecutePhotoGetSinglePoint(process, null, new double[] { currentPosition.X, currentPosition.Y, currentPosition.U }, _cts.Token);
|
|
|
|
|
|
|
+ var visionResult = await _remoteCommandService.ExecutePhotoGetSinglePoint(process, null, new double[] { currentPosition.X, currentPosition.Y, currentPosition.U }, _cts.Token, cameraIndex, null);
|
|
|
if (isDryMode)
|
|
if (isDryMode)
|
|
|
{
|
|
{
|
|
|
await plc.WriteNodeAsync(addressConfig.Out_DownCameraStatus.Address, (Int16)1);
|
|
await plc.WriteNodeAsync(addressConfig.Out_DownCameraStatus.Address, (Int16)1);
|
|
@@ -1257,8 +1266,8 @@ namespace TeamAAS_VP.Core
|
|
|
}
|
|
}
|
|
|
// 执行视觉任务
|
|
// 执行视觉任务
|
|
|
var _cts = new CancellationTokenSource();
|
|
var _cts = new CancellationTokenSource();
|
|
|
- var task1 = _remoteCommandService.ExecutePhotoGetSinglePoint(process1, null, new double[] { currentPosition.X, currentPosition.Y, currentPosition.U }, _cts.Token);
|
|
|
|
|
- var task2 = _remoteCommandService.ExecutePhotoGetSinglePoint(process2, null, new double[] { currentPosition.X, currentPosition.Y, currentPosition.U }, _cts.Token);
|
|
|
|
|
|
|
+ var task1 = _remoteCommandService.ExecutePhotoGetSinglePoint(process1, null, new double[] { currentPosition.X, currentPosition.Y, currentPosition.U }, _cts.Token, 1, null);
|
|
|
|
|
+ var task2 = _remoteCommandService.ExecutePhotoGetSinglePoint(process2, null, new double[] { currentPosition.X, currentPosition.Y, currentPosition.U }, _cts.Token, 2, null);
|
|
|
var visionResults = await Task.WhenAll(task1, task2);
|
|
var visionResults = await Task.WhenAll(task1, task2);
|
|
|
if (isDryMode)
|
|
if (isDryMode)
|
|
|
{
|
|
{
|
|
@@ -1353,8 +1362,8 @@ namespace TeamAAS_VP.Core
|
|
|
}
|
|
}
|
|
|
// 执行视觉任务
|
|
// 执行视觉任务
|
|
|
var _cts = new CancellationTokenSource();
|
|
var _cts = new CancellationTokenSource();
|
|
|
- var task1 = _remoteCommandService.ExecutePhotoGetSinglePoint(process1, null, new double[] { currentPosition.X, currentPosition.Y, currentPosition.U }, _cts.Token);
|
|
|
|
|
- var task2 = _remoteCommandService.ExecutePhotoGetSinglePoint(process2, null, new double[] { currentPosition.X, currentPosition.Y, currentPosition.U }, _cts.Token);
|
|
|
|
|
|
|
+ var task1 = _remoteCommandService.ExecutePhotoGetSinglePoint(process1, null, new double[] { currentPosition.X, currentPosition.Y, currentPosition.U }, _cts.Token, 1, null);
|
|
|
|
|
+ var task2 = _remoteCommandService.ExecutePhotoGetSinglePoint(process2, null, new double[] { currentPosition.X, currentPosition.Y, currentPosition.U }, _cts.Token, 2, null);
|
|
|
var visionResults = await Task.WhenAll(task1, task2);
|
|
var visionResults = await Task.WhenAll(task1, task2);
|
|
|
if (isDryMode)
|
|
if (isDryMode)
|
|
|
{
|
|
{
|
|
@@ -1505,7 +1514,7 @@ namespace TeamAAS_VP.Core
|
|
|
}
|
|
}
|
|
|
// 执行视觉任务
|
|
// 执行视觉任务
|
|
|
var _cts = new CancellationTokenSource();
|
|
var _cts = new CancellationTokenSource();
|
|
|
- var visionResult = await _remoteCommandService.ExecutePhotoGetSinglePoint(process, null, new double[] { currentPosition.X, currentPosition.Y, currentPosition.U }, _cts.Token);
|
|
|
|
|
|
|
+ var visionResult = await _remoteCommandService.ExecutePhotoGetSinglePoint(process, null, new double[] { currentPosition.X, currentPosition.Y, currentPosition.U }, _cts.Token, cameraIndex, null);
|
|
|
if (isDryMode)
|
|
if (isDryMode)
|
|
|
{
|
|
{
|
|
|
await plc.WriteNodeAsync(addressConfig.Out_UpCameraPickStatus.Address, (Int16)1);
|
|
await plc.WriteNodeAsync(addressConfig.Out_UpCameraPickStatus.Address, (Int16)1);
|
|
@@ -1546,8 +1555,8 @@ namespace TeamAAS_VP.Core
|
|
|
}
|
|
}
|
|
|
// 执行视觉任务
|
|
// 执行视觉任务
|
|
|
var _cts = new CancellationTokenSource();
|
|
var _cts = new CancellationTokenSource();
|
|
|
- var task1 = _remoteCommandService.ExecutePhotoGetSinglePoint(process1, null, new double[] { currentPosition.X, currentPosition.Y, currentPosition.U }, _cts.Token);
|
|
|
|
|
- var task2 = _remoteCommandService.ExecutePhotoGetSinglePoint(process2, null, new double[] { currentPosition.X, currentPosition.Y, currentPosition.U }, _cts.Token);
|
|
|
|
|
|
|
+ var task1 = _remoteCommandService.ExecutePhotoGetSinglePoint(process1, null, new double[] { currentPosition.X, currentPosition.Y, currentPosition.U }, _cts.Token, 1, null);
|
|
|
|
|
+ var task2 = _remoteCommandService.ExecutePhotoGetSinglePoint(process2, null, new double[] { currentPosition.X, currentPosition.Y, currentPosition.U }, _cts.Token, 2, null);
|
|
|
var visionResults = await Task.WhenAll(task1, task2);
|
|
var visionResults = await Task.WhenAll(task1, task2);
|
|
|
if (isDryMode)
|
|
if (isDryMode)
|
|
|
{
|
|
{
|
|
@@ -1633,7 +1642,7 @@ namespace TeamAAS_VP.Core
|
|
|
}
|
|
}
|
|
|
// 执行视觉任务
|
|
// 执行视觉任务
|
|
|
var _cts = new CancellationTokenSource();
|
|
var _cts = new CancellationTokenSource();
|
|
|
- var visionResult = await _remoteCommandService.ExecutePhotoGetSinglePoint(process, null, new double[] { currentPosition.X, currentPosition.Y, currentPosition.U }, _cts.Token);
|
|
|
|
|
|
|
+ var visionResult = await _remoteCommandService.ExecutePhotoGetSinglePoint(process, null, new double[] { currentPosition.X, currentPosition.Y, currentPosition.U }, _cts.Token, cameraIndex, null);
|
|
|
if (isDryMode)
|
|
if (isDryMode)
|
|
|
{
|
|
{
|
|
|
await plc.WriteNodeAsync(addressConfig.Out_UpCameraPutStatus.Address, (Int16)1);
|
|
await plc.WriteNodeAsync(addressConfig.Out_UpCameraPutStatus.Address, (Int16)1);
|
|
@@ -1672,8 +1681,8 @@ namespace TeamAAS_VP.Core
|
|
|
}
|
|
}
|
|
|
// 执行视觉任务
|
|
// 执行视觉任务
|
|
|
var _cts = new CancellationTokenSource();
|
|
var _cts = new CancellationTokenSource();
|
|
|
- var task1 = _remoteCommandService.ExecutePhotoGetSinglePoint(process1, null, new double[] { currentPosition.X, currentPosition.Y, currentPosition.U }, _cts.Token);
|
|
|
|
|
- var task2 = _remoteCommandService.ExecutePhotoGetSinglePoint(process2, null, new double[] { currentPosition.X, currentPosition.Y, currentPosition.U }, _cts.Token);
|
|
|
|
|
|
|
+ var task1 = _remoteCommandService.ExecutePhotoGetSinglePoint(process1, null, new double[] { currentPosition.X, currentPosition.Y, currentPosition.U }, _cts.Token, 1, null);
|
|
|
|
|
+ var task2 = _remoteCommandService.ExecutePhotoGetSinglePoint(process2, null, new double[] { currentPosition.X, currentPosition.Y, currentPosition.U }, _cts.Token, 2, null);
|
|
|
var visionResults = await Task.WhenAll(task1, task2);
|
|
var visionResults = await Task.WhenAll(task1, task2);
|
|
|
if (isDryMode)
|
|
if (isDryMode)
|
|
|
{
|
|
{
|
|
@@ -1721,7 +1730,7 @@ namespace TeamAAS_VP.Core
|
|
|
{
|
|
{
|
|
|
SendTaskMessage($"触发上相机检测拍照...", MessageLevel.Debug);
|
|
SendTaskMessage($"触发上相机检测拍照...", MessageLevel.Debug);
|
|
|
//相机的编号
|
|
//相机的编号
|
|
|
- //Int16 cameraIndex = plc.ReadNode<Int16>(addressConfig.Out_UPCameracheckNum.Address);
|
|
|
|
|
|
|
+ Int16 cameraIndex = plc.ReadNode<Int16>(addressConfig.Out_UPCameracheckNum.Address);
|
|
|
|
|
|
|
|
if (isDryMode)
|
|
if (isDryMode)
|
|
|
{
|
|
{
|
|
@@ -1729,6 +1738,37 @@ namespace TeamAAS_VP.Core
|
|
|
return;
|
|
return;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ //视觉流程ID
|
|
|
|
|
+ Guid procedureId = Guid.Empty;
|
|
|
|
|
+ //获取锁付拍照的点位
|
|
|
|
|
+ var pos = currentProduct.CheckCameraPoints.FirstOrDefault(p => p.Number == cameraIndex);
|
|
|
|
|
+ if (pos != null)
|
|
|
|
|
+ {
|
|
|
|
|
+ procedureId = pos.VisionProcessID;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ // 获取流程
|
|
|
|
|
+ var process = _productService.GetCurrentProductProcedureModelById(procedureId);
|
|
|
|
|
+ if (process == null)
|
|
|
|
|
+ {
|
|
|
|
|
+ SendTaskMessage(string.Format("未找到点位:{0}的视觉流程:{1}", cameraIndex, procedureId), MessageLevel.Alarm);
|
|
|
|
|
+ await plc.WriteNodeAsync(addressConfig.Out_UPCameracheckStatus.Address, (Int16)2);
|
|
|
|
|
+ return;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ // 执行视觉任务
|
|
|
|
|
+ var _cts = new CancellationTokenSource();
|
|
|
|
|
+ var visionResult = await _remoteCommandService.ExecutePhotoGetSinglePoint(process, null, null, _cts.Token, cameraIndex, null);
|
|
|
|
|
+ if (visionResult.IsSucceed)
|
|
|
|
|
+ {
|
|
|
|
|
+ await plc.WriteNodeAsync(addressConfig.Out_UPCameracheckStatus.Address, (Int16)1);
|
|
|
|
|
+ SendTaskMessage($"点位{cameraIndex}检测OK", MessageLevel.Debug);
|
|
|
|
|
+ }
|
|
|
|
|
+ else
|
|
|
|
|
+ {
|
|
|
|
|
+ await plc.WriteNodeAsync(addressConfig.Out_UPCameracheckStatus.Address, (Int16)2);
|
|
|
|
|
+ SendTaskMessage($"点位{cameraIndex}检测NG", MessageLevel.Error);
|
|
|
|
|
+ }
|
|
|
await plc.WriteNodeAsync(addressConfig.Out_UPCameracheckStatus.Address, (Int16)1);
|
|
await plc.WriteNodeAsync(addressConfig.Out_UPCameracheckStatus.Address, (Int16)1);
|
|
|
}
|
|
}
|
|
|
else
|
|
else
|
|
@@ -1758,11 +1798,66 @@ namespace TeamAAS_VP.Core
|
|
|
//相机的编号
|
|
//相机的编号
|
|
|
//Int16 cameraIndex = plc.ReadNode<Int16>(addressConfig.In_FixedCameraPickNum.Address);
|
|
//Int16 cameraIndex = plc.ReadNode<Int16>(addressConfig.In_FixedCameraPickNum.Address);
|
|
|
|
|
|
|
|
|
|
+ if (currentProduct.IndependentCamer1AuxProcedureId == Guid.Empty)
|
|
|
|
|
+ {
|
|
|
|
|
+ await plc.WriteNodeAsync(addressConfig.Out_FixedCameraPickStatus.Address, (Int16)2);
|
|
|
|
|
+ return;
|
|
|
|
|
+ }
|
|
|
|
|
+ if (currentProduct.IndependentCamer2AuxProcedureId == Guid.Empty)
|
|
|
|
|
+ {
|
|
|
|
|
+ await plc.WriteNodeAsync(addressConfig.Out_FixedCameraPickStatus.Address, (Int16)2);
|
|
|
|
|
+ return;
|
|
|
|
|
+ }
|
|
|
|
|
+ if (currentProduct.IndependentCamer3AuxProcedureId == Guid.Empty)
|
|
|
|
|
+ {
|
|
|
|
|
+ await plc.WriteNodeAsync(addressConfig.Out_FixedCameraPickStatus.Address, (Int16)2);
|
|
|
|
|
+ return;
|
|
|
|
|
+ }
|
|
|
|
|
+ if (currentProduct.IndependentCamer4AuxProcedureId == Guid.Empty)
|
|
|
|
|
+ {
|
|
|
|
|
+ await plc.WriteNodeAsync(addressConfig.Out_FixedCameraPickStatus.Address, (Int16)2);
|
|
|
|
|
+ return;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ //获取四个独立相机的流程id
|
|
|
|
|
+ var process1 = _productService.GetCurrentProductProcedureModelById(currentProduct.IndependentCamer1AuxProcedureId);
|
|
|
|
|
+ var process2 = _productService.GetCurrentProductProcedureModelById(currentProduct.IndependentCamer2AuxProcedureId);
|
|
|
|
|
+ var process3 = _productService.GetCurrentProductProcedureModelById(currentProduct.IndependentCamer3AuxProcedureId);
|
|
|
|
|
+ var process4 = _productService.GetCurrentProductProcedureModelById(currentProduct.IndependentCamer4AuxProcedureId);
|
|
|
|
|
+
|
|
|
|
|
+ // 执行视觉任务
|
|
|
|
|
+ var _cts = new CancellationTokenSource();
|
|
|
|
|
+ var task1 = _remoteCommandService.ExecutePhotoGetSinglePoint(process1, null, null, _cts.Token, 1, null);
|
|
|
|
|
+ var task2 = _remoteCommandService.ExecutePhotoGetSinglePoint(process2, null, null, _cts.Token, 2, null);
|
|
|
|
|
+ var task3 = _remoteCommandService.ExecutePhotoGetSinglePoint(process3, null, null, _cts.Token, 3, null);
|
|
|
|
|
+ var task4 = _remoteCommandService.ExecutePhotoGetSinglePoint(process4, null, null, _cts.Token, 4, null);
|
|
|
|
|
+
|
|
|
|
|
+ var visionResults = await Task.WhenAll(task1, task2, task3, task4);
|
|
|
if (isDryMode)
|
|
if (isDryMode)
|
|
|
{
|
|
{
|
|
|
await plc.WriteNodeAsync(addressConfig.Out_FixedCameraPickStatus.Address, (Int16)1);
|
|
await plc.WriteNodeAsync(addressConfig.Out_FixedCameraPickStatus.Address, (Int16)1);
|
|
|
return;
|
|
return;
|
|
|
}
|
|
}
|
|
|
|
|
+ if (visionResults[0].IsSucceed && visionResults[1].IsSucceed && visionResults[2].IsSucceed && visionResults[3].IsSucceed)
|
|
|
|
|
+ {
|
|
|
|
|
+
|
|
|
|
|
+ Vector<double> p1 = Vector<double>.Build.Dense(new double[] { visionResults[1].X, visionResults[1].Y });
|
|
|
|
|
+ Vector<double> p2 = Vector<double>.Build.Dense(new double[] { visionResults[2].X, visionResults[2].Y });
|
|
|
|
|
+ Vector<double> p3 = Vector<double>.Build.Dense(new double[] { visionResults[3].X, visionResults[3].Y });
|
|
|
|
|
+ Vector<double> p4 = Vector<double>.Build.Dense(new double[] { visionResults[0].X, visionResults[0].Y });
|
|
|
|
|
+
|
|
|
|
|
+ var center = RectangleCenterCalculator.CalculateByPCAWithKnownOrder(new List<Vector<double>> { p1, p2, p3, p4 });
|
|
|
|
|
+ UpCameraPutResults[1].X = (float)center.Center[0];
|
|
|
|
|
+ UpCameraPutResults[1].Y = (float)center.Center[1];
|
|
|
|
|
+ UpCameraPutResults[1].Z = (float)center.MajorAxisAngle;
|
|
|
|
|
+ SendTaskMessage($"LCD拍照结果:X={UpCameraPutResults[1].X},Y={UpCameraPutResults[1].Y},Angle={UpCameraPutResults[1].Z}", MessageLevel.Info);
|
|
|
|
|
+ }
|
|
|
|
|
+ else
|
|
|
|
|
+ {
|
|
|
|
|
+
|
|
|
|
|
+ await plc.WriteNodeAsync(addressConfig.Out_FixedCameraPickStatus.Address, (Int16)2);
|
|
|
|
|
+ return;
|
|
|
|
|
+ }
|
|
|
|
|
|
|
|
await plc.WriteNodeAsync(addressConfig.Out_FixedCameraPickStatus.Address, (Int16)1);
|
|
await plc.WriteNodeAsync(addressConfig.Out_FixedCameraPickStatus.Address, (Int16)1);
|
|
|
}
|
|
}
|
|
@@ -1821,10 +1916,10 @@ namespace TeamAAS_VP.Core
|
|
|
|
|
|
|
|
// 执行视觉任务
|
|
// 执行视觉任务
|
|
|
var _cts = new CancellationTokenSource();
|
|
var _cts = new CancellationTokenSource();
|
|
|
- var task1 = _remoteCommandService.ExecutePhotoGetSinglePoint(process1, null, null, _cts.Token);
|
|
|
|
|
- var task2 = _remoteCommandService.ExecutePhotoGetSinglePoint(process2, null, null, _cts.Token);
|
|
|
|
|
- var task3 = _remoteCommandService.ExecutePhotoGetSinglePoint(process3, null, null, _cts.Token);
|
|
|
|
|
- var task4 = _remoteCommandService.ExecutePhotoGetSinglePoint(process4, null, null, _cts.Token);
|
|
|
|
|
|
|
+ var task1 = _remoteCommandService.ExecutePhotoGetSinglePoint(process1, null, null, _cts.Token, 1, null);
|
|
|
|
|
+ var task2 = _remoteCommandService.ExecutePhotoGetSinglePoint(process2, null, null, _cts.Token, 2, null);
|
|
|
|
|
+ var task3 = _remoteCommandService.ExecutePhotoGetSinglePoint(process3, null, null, _cts.Token, 3, null);
|
|
|
|
|
+ var task4 = _remoteCommandService.ExecutePhotoGetSinglePoint(process4, null, null, _cts.Token, 4, null);
|
|
|
|
|
|
|
|
var visionResults = await Task.WhenAll(task1, task2, task3, task4);
|
|
var visionResults = await Task.WhenAll(task1, task2, task3, task4);
|
|
|
if (isDryMode)
|
|
if (isDryMode)
|
|
@@ -1881,39 +1976,39 @@ namespace TeamAAS_VP.Core
|
|
|
//相机的编号
|
|
//相机的编号
|
|
|
//Int16 cameraIndex = plc.ReadNode<Int16>(addressConfig.In_FixedCameracheckNum.Address);
|
|
//Int16 cameraIndex = plc.ReadNode<Int16>(addressConfig.In_FixedCameracheckNum.Address);
|
|
|
|
|
|
|
|
- if (currentProduct.IndependentCamer1AuxProcedureId == Guid.Empty)
|
|
|
|
|
|
|
+ if (currentProduct.IndependentCamer1CheckProcedureId == Guid.Empty)
|
|
|
{
|
|
{
|
|
|
await plc.WriteNodeAsync(addressConfig.Out_FixedCameracheckStatus.Address, (Int16)2);
|
|
await plc.WriteNodeAsync(addressConfig.Out_FixedCameracheckStatus.Address, (Int16)2);
|
|
|
return;
|
|
return;
|
|
|
}
|
|
}
|
|
|
- if (currentProduct.IndependentCamer2AuxProcedureId == Guid.Empty)
|
|
|
|
|
|
|
+ if (currentProduct.IndependentCamer2CheckProcedureId == Guid.Empty)
|
|
|
{
|
|
{
|
|
|
await plc.WriteNodeAsync(addressConfig.Out_FixedCameracheckStatus.Address, (Int16)2);
|
|
await plc.WriteNodeAsync(addressConfig.Out_FixedCameracheckStatus.Address, (Int16)2);
|
|
|
return;
|
|
return;
|
|
|
}
|
|
}
|
|
|
- if (currentProduct.IndependentCamer3AuxProcedureId == Guid.Empty)
|
|
|
|
|
|
|
+ if (currentProduct.IndependentCamer3CheckProcedureId == Guid.Empty)
|
|
|
{
|
|
{
|
|
|
await plc.WriteNodeAsync(addressConfig.Out_FixedCameracheckStatus.Address, (Int16)2);
|
|
await plc.WriteNodeAsync(addressConfig.Out_FixedCameracheckStatus.Address, (Int16)2);
|
|
|
return;
|
|
return;
|
|
|
}
|
|
}
|
|
|
- if (currentProduct.IndependentCamer4AuxProcedureId == Guid.Empty)
|
|
|
|
|
|
|
+ if (currentProduct.IndependentCamer4CheckProcedureId == Guid.Empty)
|
|
|
{
|
|
{
|
|
|
await plc.WriteNodeAsync(addressConfig.Out_FixedCameracheckStatus.Address, (Int16)2);
|
|
await plc.WriteNodeAsync(addressConfig.Out_FixedCameracheckStatus.Address, (Int16)2);
|
|
|
return;
|
|
return;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
//获取四个独立相机的流程id
|
|
//获取四个独立相机的流程id
|
|
|
- var process1 = _productService.GetCurrentProductProcedureModelById(currentProduct.IndependentCamer1AuxProcedureId);
|
|
|
|
|
- var process2 = _productService.GetCurrentProductProcedureModelById(currentProduct.IndependentCamer2AuxProcedureId);
|
|
|
|
|
- var process3 = _productService.GetCurrentProductProcedureModelById(currentProduct.IndependentCamer3AuxProcedureId);
|
|
|
|
|
- var process4 = _productService.GetCurrentProductProcedureModelById(currentProduct.IndependentCamer4AuxProcedureId);
|
|
|
|
|
|
|
+ var process1 = _productService.GetCurrentProductProcedureModelById(currentProduct.IndependentCamer1CheckProcedureId);
|
|
|
|
|
+ var process2 = _productService.GetCurrentProductProcedureModelById(currentProduct.IndependentCamer2CheckProcedureId);
|
|
|
|
|
+ var process3 = _productService.GetCurrentProductProcedureModelById(currentProduct.IndependentCamer3CheckProcedureId);
|
|
|
|
|
+ var process4 = _productService.GetCurrentProductProcedureModelById(currentProduct.IndependentCamer4CheckProcedureId);
|
|
|
|
|
|
|
|
// 执行视觉任务
|
|
// 执行视觉任务
|
|
|
var _cts = new CancellationTokenSource();
|
|
var _cts = new CancellationTokenSource();
|
|
|
- var task1 = _remoteCommandService.ExecutePhotoGetSinglePoint(process1, null, null, _cts.Token);
|
|
|
|
|
- var task2 = _remoteCommandService.ExecutePhotoGetSinglePoint(process2, null, null, _cts.Token);
|
|
|
|
|
- var task3 = _remoteCommandService.ExecutePhotoGetSinglePoint(process3, null, null, _cts.Token);
|
|
|
|
|
- var task4 = _remoteCommandService.ExecutePhotoGetSinglePoint(process4, null, null, _cts.Token);
|
|
|
|
|
|
|
+ var task1 = _remoteCommandService.ExecutePhotoGetSinglePoint(process1, null, null, _cts.Token, 1, null);
|
|
|
|
|
+ var task2 = _remoteCommandService.ExecutePhotoGetSinglePoint(process2, null, null, _cts.Token, 2, null);
|
|
|
|
|
+ var task3 = _remoteCommandService.ExecutePhotoGetSinglePoint(process3, null, null, _cts.Token, 3, null);
|
|
|
|
|
+ var task4 = _remoteCommandService.ExecutePhotoGetSinglePoint(process4, null, null, _cts.Token, 4, null);
|
|
|
|
|
|
|
|
var visionResults = await Task.WhenAll(task1, task2, task3, task4);
|
|
var visionResults = await Task.WhenAll(task1, task2, task3, task4);
|
|
|
if (isDryMode)
|
|
if (isDryMode)
|
|
@@ -1923,26 +2018,16 @@ namespace TeamAAS_VP.Core
|
|
|
}
|
|
}
|
|
|
if (visionResults[0].IsSucceed && visionResults[1].IsSucceed && visionResults[2].IsSucceed && visionResults[3].IsSucceed)
|
|
if (visionResults[0].IsSucceed && visionResults[1].IsSucceed && visionResults[2].IsSucceed && visionResults[3].IsSucceed)
|
|
|
{
|
|
{
|
|
|
-
|
|
|
|
|
- Vector<double> p1 = Vector<double>.Build.Dense(new double[] { visionResults[1].X, visionResults[1].Y });
|
|
|
|
|
- Vector<double> p2 = Vector<double>.Build.Dense(new double[] { visionResults[2].X, visionResults[2].Y });
|
|
|
|
|
- Vector<double> p3 = Vector<double>.Build.Dense(new double[] { visionResults[3].X, visionResults[3].Y });
|
|
|
|
|
- Vector<double> p4 = Vector<double>.Build.Dense(new double[] { visionResults[0].X, visionResults[0].Y });
|
|
|
|
|
-
|
|
|
|
|
- var center = RectangleCenterCalculator.CalculateByPCAWithKnownOrder(new List<Vector<double>> { p1, p2, p3, p4 });
|
|
|
|
|
- UpCameraPutResults[1].X = (float)center.Center[0];
|
|
|
|
|
- UpCameraPutResults[1].Y = (float)center.Center[1];
|
|
|
|
|
- UpCameraPutResults[1].Z = (float)center.MajorAxisAngle;
|
|
|
|
|
- SendTaskMessage($"LCD拍照结果:X={UpCameraPutResults[1].X},Y={UpCameraPutResults[1].Y},Angle={UpCameraPutResults[1].Z}", MessageLevel.Info);
|
|
|
|
|
|
|
+ SendTaskMessage($"固定相机检测OK", MessageLevel.Debug);
|
|
|
|
|
+ await plc.WriteNodeAsync(addressConfig.Out_FixedCameracheckStatus.Address, (Int16)1);
|
|
|
|
|
+ return;
|
|
|
}
|
|
}
|
|
|
else
|
|
else
|
|
|
{
|
|
{
|
|
|
-
|
|
|
|
|
|
|
+ SendTaskMessage($"固定相机检测NG", MessageLevel.Error);
|
|
|
await plc.WriteNodeAsync(addressConfig.Out_FixedCameracheckStatus.Address, (Int16)2);
|
|
await plc.WriteNodeAsync(addressConfig.Out_FixedCameracheckStatus.Address, (Int16)2);
|
|
|
return;
|
|
return;
|
|
|
}
|
|
}
|
|
|
-
|
|
|
|
|
- await plc.WriteNodeAsync(addressConfig.Out_FixedCameracheckStatus.Address, (Int16)1);
|
|
|
|
|
}
|
|
}
|
|
|
else
|
|
else
|
|
|
{
|
|
{
|
|
@@ -2005,7 +2090,7 @@ namespace TeamAAS_VP.Core
|
|
|
point.X_Position = (float)p0[0];
|
|
point.X_Position = (float)p0[0];
|
|
|
point.Y_Position = (float)p0[1];
|
|
point.Y_Position = (float)p0[1];
|
|
|
point.U_Position = (float)angle;
|
|
point.U_Position = (float)angle;
|
|
|
-
|
|
|
|
|
|
|
+ PlaceActualCoord = new OpenCvSharp.Point3f(point.X_Position, point.Y_Position, point.U_Position);
|
|
|
SendTaskMessage($"点:1,{point.X_Position:F3},{point.Y_Position:F4},{point.U_Position:F4}", MessageLevel.Info);
|
|
SendTaskMessage($"点:1,{point.X_Position:F3},{point.Y_Position:F4},{point.U_Position:F4}", MessageLevel.Info);
|
|
|
await point.WriteToPlcAddress(addressConfig.Out_Screw, plc);
|
|
await point.WriteToPlcAddress(addressConfig.Out_Screw, plc);
|
|
|
await plc.WriteNodeAsync(addressConfig.Out_WorkNum.Address, (Int16)1);
|
|
await plc.WriteNodeAsync(addressConfig.Out_WorkNum.Address, (Int16)1);
|
|
@@ -2095,16 +2180,40 @@ namespace TeamAAS_VP.Core
|
|
|
SendTaskMessage($"收到{i}上传本站数据请求...", MessageLevel.Debug);
|
|
SendTaskMessage($"收到{i}上传本站数据请求...", MessageLevel.Debug);
|
|
|
|
|
|
|
|
//这里缺少上传MES的本站数据结果及开始和结束时间,需要补充
|
|
//这里缺少上传MES的本站数据结果及开始和结束时间,需要补充
|
|
|
- if(i == 0)
|
|
|
|
|
|
|
+ double ct = DateTime.UtcNow.Subtract(_LastMesCheckTime[i]).TotalSeconds;
|
|
|
|
|
+ if (i == 0)
|
|
|
{
|
|
{
|
|
|
- CTtime = DateTime.UtcNow.Subtract(_LastMesCheckTime[i]).TotalSeconds;
|
|
|
|
|
|
|
+ CTtime = ct;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
//读取产品结果
|
|
//读取产品结果
|
|
|
Int16 resultIndex = plc.ReadNode<Int16>(string.Format(addressConfig.In_Result.Address,i));
|
|
Int16 resultIndex = plc.ReadNode<Int16>(string.Format(addressConfig.In_Result.Address,i));
|
|
|
|
|
+ //读取压力值
|
|
|
|
|
+ float pressure = plc.ReadNode<float>(string.Format(addressConfig.In_PressureValue.Address, i));
|
|
|
|
|
+ AssemblyRecord assemblyRecord = new AssemblyRecord();
|
|
|
|
|
+ assemblyRecord.ProductSN = code;
|
|
|
|
|
+ assemblyRecord.RecipeName = currentProduct.Name;
|
|
|
|
|
+ assemblyRecord.PartSN = PartSN;
|
|
|
|
|
+ assemblyRecord.AssemblyDurationSeconds = ct;
|
|
|
|
|
+ assemblyRecord.AssemblyPressure = pressure;
|
|
|
|
|
+ assemblyRecord.DeviceId = i;
|
|
|
|
|
+ assemblyRecord.DeviceName = $"";
|
|
|
|
|
+ assemblyRecord.OperatorName = _systemDatabaseService.GetCurrentUser().UserName;
|
|
|
|
|
+ assemblyRecord.Success = resultIndex == 1 ? true : false;
|
|
|
|
|
+ assemblyRecord.DownCameraCoord1 = "";
|
|
|
|
|
+ assemblyRecord.DownCameraCoord2 = "";
|
|
|
|
|
+ assemblyRecord.DownCameraCoord3 = "";
|
|
|
|
|
+ assemblyRecord.DownCameraCoord4 = "";
|
|
|
|
|
+ assemblyRecord.PickMoveCameraCoord = "";
|
|
|
|
|
+ assemblyRecord.PlaceMoveCameraCoord1 = "";
|
|
|
|
|
+ assemblyRecord.PlaceMoveCameraCoord2 = "";
|
|
|
|
|
+ assemblyRecord.PlaceMoveCameraCoord3 = "";
|
|
|
|
|
+ assemblyRecord.PlaceMoveCameraCoord4 = "";
|
|
|
|
|
+ assemblyRecord.PlaceActualCoord = "";
|
|
|
|
|
|
|
|
//目前只记录当前站
|
|
//目前只记录当前站
|
|
|
if (i == 0)
|
|
if (i == 0)
|
|
|
|
|
+ {
|
|
|
await _systemDatabaseService.RecordProductionAsync(new ProductionRecord()
|
|
await _systemDatabaseService.RecordProductionAsync(new ProductionRecord()
|
|
|
{
|
|
{
|
|
|
ProductName = currentProduct.Name,
|
|
ProductName = currentProduct.Name,
|
|
@@ -2113,8 +2222,19 @@ namespace TeamAAS_VP.Core
|
|
|
DeviceName = "",
|
|
DeviceName = "",
|
|
|
Category = resultIndex == 1 ? "OK" : "NG",
|
|
Category = resultIndex == 1 ? "OK" : "NG",
|
|
|
Quantity = 1,
|
|
Quantity = 1,
|
|
|
- Remark = $"TotalSeconds:{DateTime.UtcNow.Subtract(_LastMesCheckTime[i]).TotalSeconds.ToString("F2")}",
|
|
|
|
|
|
|
+ Remark = $"TotalSeconds:{ct.ToString("F2")}",
|
|
|
|
|
+ UserName = _systemDatabaseService.GetCurrentUser().UserName,
|
|
|
|
|
+ });
|
|
|
|
|
+ assemblyRecord.PlaceMoveCameraCoord1 = $"{UpCameraPutResults[0].X:F3},{UpCameraPutResults[0].Y:F3},{UpCameraPutResults[0].Z:F3}";
|
|
|
|
|
+ assemblyRecord.PlaceMoveCameraCoord2 = $"{UpCameraPutResults[1].X:F3},{UpCameraPutResults[1].Y:F3},{UpCameraPutResults[1].Z:F3}";
|
|
|
|
|
+ assemblyRecord.PlaceActualCoord = $"{PlaceActualCoord.X:F3},{PlaceActualCoord.Y:F3},{PlaceActualCoord.Z:F3}";
|
|
|
|
|
+ App.Current.Dispatcher.Invoke(() =>
|
|
|
|
|
+ {
|
|
|
|
|
+ _eventAggregator.GetEvent<AssemblyFinishNotification>().Publish(assemblyRecord);
|
|
|
});
|
|
});
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ await _systemDatabaseService.RecordAssemblyAsync(assemblyRecord);
|
|
|
|
|
|
|
|
(bool isSuccess, string response) = await _mesService.SubmitGetAsync(code, resultIndex == 1 ? true : false, _LastMesCheckTime[i], DateTime.UtcNow);
|
|
(bool isSuccess, string response) = await _mesService.SubmitGetAsync(code, resultIndex == 1 ? true : false, _LastMesCheckTime[i], DateTime.UtcNow);
|
|
|
//假设上传成功,这里缺少上传失败的处理
|
|
//假设上传成功,这里缺少上传失败的处理
|
|
@@ -2426,12 +2546,12 @@ namespace TeamAAS_VP.Core
|
|
|
{
|
|
{
|
|
|
try
|
|
try
|
|
|
{
|
|
{
|
|
|
- if (CurrentProduct == null) return;
|
|
|
|
|
//获取当前产品
|
|
//获取当前产品
|
|
|
var currentproduct = _productService.GetCurrentProduct();
|
|
var currentproduct = _productService.GetCurrentProduct();
|
|
|
- TotalQuantity = await _systemDatabaseService.GetOverallProductionAsync(CurrentProduct.Name);
|
|
|
|
|
- TotalQuantityToday = await _systemDatabaseService.GetTodayProductionAsync(CurrentProduct.Name);
|
|
|
|
|
- CurrentUPH = await _systemDatabaseService.GetLastHourProductionAsync(CurrentProduct.Name);
|
|
|
|
|
|
|
+ if (currentproduct == null) return;
|
|
|
|
|
+ TotalQuantity = await _systemDatabaseService.GetOverallProductionAsync(currentproduct.Name);
|
|
|
|
|
+ TotalQuantityToday = await _systemDatabaseService.GetTodayProductionAsync(currentproduct.Name);
|
|
|
|
|
+ CurrentUPH = await _systemDatabaseService.GetLastHourProductionAsync(currentproduct.Name);
|
|
|
}
|
|
}
|
|
|
catch (Exception)
|
|
catch (Exception)
|
|
|
{
|
|
{
|