|
@@ -936,6 +936,7 @@ namespace TeamAAS_VP.Core
|
|
|
nodeValues.Add(addressConfig.Out_FixedCameraPickNum.Address, (Int16)systemConfiguration.FixedCameraPickNum);
|
|
nodeValues.Add(addressConfig.Out_FixedCameraPickNum.Address, (Int16)systemConfiguration.FixedCameraPickNum);
|
|
|
nodeValues.Add(addressConfig.Out_FixedCameraPutNum.Address, (Int16)systemConfiguration.FixedCameraPutNum);
|
|
nodeValues.Add(addressConfig.Out_FixedCameraPutNum.Address, (Int16)systemConfiguration.FixedCameraPutNum);
|
|
|
nodeValues.Add(addressConfig.Out_FixedCameracheckNum.Address, (Int16)systemConfiguration.FixedCameracheckNum);
|
|
nodeValues.Add(addressConfig.Out_FixedCameracheckNum.Address, (Int16)systemConfiguration.FixedCameracheckNum);
|
|
|
|
|
+ nodeValues.Add(addressConfig.Out_ScrewTeachNum.Address, (Int16)systemConfiguration.ScrewTeachNum);
|
|
|
|
|
|
|
|
var res = await plc.WriteNodesAsync(nodeValues);
|
|
var res = await plc.WriteNodesAsync(nodeValues);
|
|
|
}
|
|
}
|
|
@@ -963,6 +964,8 @@ namespace TeamAAS_VP.Core
|
|
|
addressConfig.In_WorkDone.Address,
|
|
addressConfig.In_WorkDone.Address,
|
|
|
addressConfig.In_MesCheck.Address,
|
|
addressConfig.In_MesCheck.Address,
|
|
|
addressConfig.In_RequestPosition.Address,
|
|
addressConfig.In_RequestPosition.Address,
|
|
|
|
|
+ addressConfig.In_ScrewTeachExe.Address,
|
|
|
|
|
+ addressConfig.In_PickINC.Address,
|
|
|
};
|
|
};
|
|
|
|
|
|
|
|
//订阅PLC地址变化
|
|
//订阅PLC地址变化
|
|
@@ -1086,7 +1089,7 @@ namespace TeamAAS_VP.Core
|
|
|
if (robot == null)
|
|
if (robot == null)
|
|
|
{
|
|
{
|
|
|
SendTaskMessage($"未找到机器人,无法执行上相机锁附/组装拍照视觉任务", MessageLevel.Alarm);
|
|
SendTaskMessage($"未找到机器人,无法执行上相机锁附/组装拍照视觉任务", MessageLevel.Alarm);
|
|
|
- await plc.WriteNodeAsync(addressConfig.Out_UpCameraPutStatus.Address, (Int16)2);
|
|
|
|
|
|
|
+ await plc.WriteNodeAsync(addressConfig.Out_DownCameraStatus.Address, (Int16)2);
|
|
|
return;
|
|
return;
|
|
|
|
|
|
|
|
}
|
|
}
|
|
@@ -1118,6 +1121,64 @@ namespace TeamAAS_VP.Core
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
+ // 触发下相机拍照披头
|
|
|
|
|
+ if (addressConfig.In_ScrewTeachExe.Address.Contains(tuple.nodeId))
|
|
|
|
|
+ {
|
|
|
|
|
+ if (tuple.value is bool state)
|
|
|
|
|
+ {
|
|
|
|
|
+ if (state)
|
|
|
|
|
+ {
|
|
|
|
|
+ SendTaskMessage($"触发下相机拍照...", MessageLevel.Debug);
|
|
|
|
|
+ //相机的编号
|
|
|
|
|
+ Int16 cameraIndex = plc.ReadNode<Int16>(addressConfig.In_DowmCameraNum.Address);
|
|
|
|
|
+ SendTaskMessage($"编号:{cameraIndex}", MessageLevel.Info);
|
|
|
|
|
+
|
|
|
|
|
+ // 获取流程
|
|
|
|
|
+ var process = _productService.GetCurrentProductProcedureModelById(currentProduct.FixedUpCamera1ProcedureId);
|
|
|
|
|
+ if (process == null)
|
|
|
|
|
+ {
|
|
|
|
|
+ SendTaskMessage($"固定向上相机1视觉流程,流程ID:{currentProduct.FixedUpCamera1ProcedureId}", MessageLevel.Alarm);
|
|
|
|
|
+ await plc.WriteNodeAsync(addressConfig.Out_ScrewTeachOk.Address, (Int16)2);
|
|
|
|
|
+ return;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ // 获取机器人当前坐标
|
|
|
|
|
+ var robot = _robotService.GetAllRobots().FirstOrDefault();
|
|
|
|
|
+ if (robot == null)
|
|
|
|
|
+ {
|
|
|
|
|
+ SendTaskMessage($"未找到机器人,无法执行上相机锁附/组装拍照视觉任务", MessageLevel.Alarm);
|
|
|
|
|
+ await plc.WriteNodeAsync(addressConfig.Out_ScrewTeachOk.Address, (Int16)2);
|
|
|
|
|
+ return;
|
|
|
|
|
+
|
|
|
|
|
+ }
|
|
|
|
|
+ var currentPosition = robot.GetRobotPos();
|
|
|
|
|
+
|
|
|
|
|
+ // 执行视觉任务
|
|
|
|
|
+ var _cts = new CancellationTokenSource();
|
|
|
|
|
+ var visionResult = await _remoteCommandService.ExecutePhotoGetSinglePoint(process, null, null, _cts.Token);
|
|
|
|
|
+ if (visionResult.IsSucceed)
|
|
|
|
|
+ {
|
|
|
|
|
+ //披头偏差
|
|
|
|
|
+ float offsetX = (float)(visionResult.X - currentPosition.X);
|
|
|
|
|
+ float offsetY = (float)(visionResult.Y - currentPosition.Y);
|
|
|
|
|
+
|
|
|
|
|
+ DowmCameraResults[cameraIndex] = new PointF(offsetX, offsetY);
|
|
|
|
|
+ await plc.WriteNodeAsync(addressConfig.Out_ScrewTeachOk.Address, (Int16)1);
|
|
|
|
|
+ return;
|
|
|
|
|
+ }
|
|
|
|
|
+ else
|
|
|
|
|
+ {
|
|
|
|
|
+ await plc.WriteNodeAsync(addressConfig.Out_ScrewTeachOk.Address, (Int16)2);
|
|
|
|
|
+ return;
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ else
|
|
|
|
|
+ {
|
|
|
|
|
+ SendTaskMessage($"触发下相机拍照信号已关闭", MessageLevel.Alarm);
|
|
|
|
|
+ await plc.WriteNodeAsync(addressConfig.Out_ScrewTeachOk.Address, (Int16)0);
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
// 触发上相机取料拍照
|
|
// 触发上相机取料拍照
|
|
|
else if (addressConfig.In_UpCameraPickExe.Address.Contains(tuple.nodeId))
|
|
else if (addressConfig.In_UpCameraPickExe.Address.Contains(tuple.nodeId))
|
|
|
{
|
|
{
|
|
@@ -1430,6 +1491,19 @@ namespace TeamAAS_VP.Core
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
+ // 螺丝供料器螺丝递减
|
|
|
|
|
+ else if (addressConfig.In_PickINC.Address.Contains(tuple.nodeId))
|
|
|
|
|
+ {
|
|
|
|
|
+ if (tuple.value is bool state)
|
|
|
|
|
+ {
|
|
|
|
|
+ if (state)
|
|
|
|
|
+ {
|
|
|
|
|
+ SendTaskMessage($"螺丝供料器...", MessageLevel.Info);
|
|
|
|
|
+ await plc.WriteNodeAsync(addressConfig.In_PickINC.Address, false);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|
|
|
catch (Exception ex)
|
|
catch (Exception ex)
|
|
|
{
|
|
{
|