|
|
@@ -291,6 +291,7 @@ namespace TeamAAS_VP.Core
|
|
|
}
|
|
|
}
|
|
|
await WriteSystemParameterToPlcAsync(_configService.GetSystemConfiguration());
|
|
|
+ RegisterPlcMonitorAddress();
|
|
|
if (sb.Length == 0)
|
|
|
{
|
|
|
return (true, "");
|
|
|
@@ -857,7 +858,9 @@ namespace TeamAAS_VP.Core
|
|
|
var res = await plc.WriteNodesAsync(nodeValues);
|
|
|
}
|
|
|
|
|
|
- //注册需要监控的PLC地址
|
|
|
+ /// <summary>
|
|
|
+ /// 注册需要监控的PLC地址
|
|
|
+ /// </summary>
|
|
|
public void RegisterPlcMonitorAddress()
|
|
|
{
|
|
|
var addressConfig = _configService.GetPlcAddresses();
|
|
|
@@ -876,19 +879,79 @@ namespace TeamAAS_VP.Core
|
|
|
addressConfig.In_FixedCameracheckExe.Address,
|
|
|
addressConfig.In_WorkStart.Address,
|
|
|
addressConfig.In_WorkDone.Address,
|
|
|
+ addressConfig.In_MesCheck.Address,
|
|
|
+ addressConfig.In_RequestPosition.Address,
|
|
|
};
|
|
|
|
|
|
//订阅PLC地址变化
|
|
|
plc.SubscribeNodes("AutoSensor", monitorNodeIds, PlcCommandTrigger);
|
|
|
}
|
|
|
|
|
|
+ /// <summary>
|
|
|
+ /// 写入点位信息给PLC
|
|
|
+ /// </summary>
|
|
|
+ /// <returns></returns>
|
|
|
+ public async Task WritePositionToPlcAsync()
|
|
|
+ {
|
|
|
+ var addressConfig = _configService.GetPlcAddresses();
|
|
|
+ var plc = _plcService.GetPlcByNumber(addressConfig.PlcNo) as OpcUaClientPLC;
|
|
|
+ if (plc == null || !plc.IsConnected) return;
|
|
|
+ var current= _productService.GetCurrentProduct();
|
|
|
+ if (current == null) return;
|
|
|
+ if (current.PickCameraPoints!=null && current.PickCameraPoints.Count>0)
|
|
|
+ {
|
|
|
+ foreach (var item in current.PickCameraPoints)
|
|
|
+ {
|
|
|
+ await item.WriteToPlcAddress(addressConfig.Out_PickCamera,plc);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (current.PickPoints != null && current.PickPoints.Count > 0)
|
|
|
+ {
|
|
|
+ foreach (var item in current.PickPoints)
|
|
|
+ {
|
|
|
+ await item.WriteToPlcAddress(addressConfig.Out_Pick, plc);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (current.SecPosCameraPoints != null && current.SecPosCameraPoints.Count > 0)
|
|
|
+ {
|
|
|
+ foreach (var item in current.SecPosCameraPoints)
|
|
|
+ {
|
|
|
+ await item.WriteToPlcAddress(addressConfig.Out_SecPosCamera, plc);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (current.ScrewCameraPoints != null && current.ScrewCameraPoints.Count > 0)
|
|
|
+ {
|
|
|
+ foreach (var item in current.ScrewCameraPoints)
|
|
|
+ {
|
|
|
+ await item.WriteToPlcAddress(addressConfig.Out_ScrewCamera, plc);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (current.ScrewPoints != null && current.ScrewPoints.Count > 0)
|
|
|
+ {
|
|
|
+ foreach (var item in current.ScrewPoints)
|
|
|
+ {
|
|
|
+ await item.WriteToPlcAddress(addressConfig.Out_Screw, plc);
|
|
|
+ }
|
|
|
+ await plc.WriteNodeAsync(addressConfig.Out_WorkNum.Address, (Int16)current.ScrewPoints.Count);
|
|
|
+ }
|
|
|
+ if (current.CheckCameraPoints != null && current.CheckCameraPoints.Count > 0)
|
|
|
+ {
|
|
|
+ foreach (var item in current.CheckCameraPoints)
|
|
|
+ {
|
|
|
+ await item.WriteToPlcAddress(addressConfig.Out_CheckCamera, plc);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
/// <summary>
|
|
|
/// PLC命令触发时
|
|
|
/// </summary>
|
|
|
/// <param name="tuple"></param>
|
|
|
- private void PlcCommandTrigger((string key, string nodeId, object value) tuple)
|
|
|
+ private async void PlcCommandTrigger((string key, string nodeId, object value) tuple)
|
|
|
{
|
|
|
var addressConfig = _configService.GetPlcAddresses();
|
|
|
+ var plc = _plcService.GetPlcByNumber(addressConfig.PlcNo) as OpcUaClientPLC;
|
|
|
+ if (plc == null || !plc.IsConnected) return;
|
|
|
// 触发下相机拍照
|
|
|
if (tuple.nodeId.Contains(addressConfig.In_DowmCameraExe.Address))
|
|
|
{
|
|
|
@@ -896,11 +959,11 @@ namespace TeamAAS_VP.Core
|
|
|
{
|
|
|
if (state)
|
|
|
{
|
|
|
-
|
|
|
+ await plc.WriteNodeAsync(addressConfig.Out_DownCameraStatus.Address, (Int16)1);
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
-
|
|
|
+ await plc.WriteNodeAsync(addressConfig.Out_DownCameraStatus.Address, (Int16)0);
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
@@ -911,11 +974,11 @@ namespace TeamAAS_VP.Core
|
|
|
{
|
|
|
if (state)
|
|
|
{
|
|
|
-
|
|
|
+ await plc.WriteNodeAsync(addressConfig.Out_UpCameraPickStatus.Address, (Int16)1);
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
-
|
|
|
+ await plc.WriteNodeAsync(addressConfig.Out_UpCameraPickStatus.Address, (Int16)0);
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
@@ -926,11 +989,11 @@ namespace TeamAAS_VP.Core
|
|
|
{
|
|
|
if (state)
|
|
|
{
|
|
|
-
|
|
|
+ await plc.WriteNodeAsync(addressConfig.Out_UpCameraPutStatus.Address, (Int16)1);
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
-
|
|
|
+ await plc.WriteNodeAsync(addressConfig.Out_UpCameraPutStatus.Address, (Int16)0);
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
@@ -941,11 +1004,11 @@ namespace TeamAAS_VP.Core
|
|
|
{
|
|
|
if (state)
|
|
|
{
|
|
|
-
|
|
|
+ await plc.WriteNodeAsync(addressConfig.Out_UPCameracheckStatus.Address, (Int16)1);
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
-
|
|
|
+ await plc.WriteNodeAsync(addressConfig.Out_UPCameracheckStatus.Address, (Int16)0);
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
@@ -956,11 +1019,11 @@ namespace TeamAAS_VP.Core
|
|
|
{
|
|
|
if (state)
|
|
|
{
|
|
|
-
|
|
|
+ await plc.WriteNodeAsync(addressConfig.Out_FixedCameraPickStatus.Address, (Int16)1);
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
-
|
|
|
+ await plc.WriteNodeAsync(addressConfig.Out_FixedCameraPickStatus.Address, (Int16)0);
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
@@ -971,11 +1034,11 @@ namespace TeamAAS_VP.Core
|
|
|
{
|
|
|
if (state)
|
|
|
{
|
|
|
-
|
|
|
+ await plc.WriteNodeAsync(addressConfig.Out_FixedCameraPutStatus.Address, (Int16)1);
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
-
|
|
|
+ await plc.WriteNodeAsync(addressConfig.Out_FixedCameraPutStatus.Address, (Int16)0);
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
@@ -986,11 +1049,11 @@ namespace TeamAAS_VP.Core
|
|
|
{
|
|
|
if (state)
|
|
|
{
|
|
|
-
|
|
|
+ await plc.WriteNodeAsync(addressConfig.Out_FixedCameracheckStatus.Address, (Int16)1);
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
-
|
|
|
+ await plc.WriteNodeAsync(addressConfig.Out_FixedCameracheckStatus.Address, (Int16)0);
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
@@ -1024,6 +1087,36 @@ namespace TeamAAS_VP.Core
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
+ // 多相机坐标合并
|
|
|
+ else if (tuple.nodeId.Contains(addressConfig.In_RequestPosition.Address))
|
|
|
+ {
|
|
|
+ if (tuple.value is Int16 state)
|
|
|
+ {
|
|
|
+ if (state == 1)
|
|
|
+ {
|
|
|
+ await plc.WriteNodeAsync(addressConfig.Out_CameraDone.Address, (Int16)1);
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ await plc.WriteNodeAsync(addressConfig.Out_CameraDone.Address, (Int16)0);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ // 过站检查
|
|
|
+ else if (tuple.nodeId.Contains(addressConfig.In_MesCheck.Address))
|
|
|
+ {
|
|
|
+ if (tuple.value is Int16 state)
|
|
|
+ {
|
|
|
+ if (state==1)
|
|
|
+ {
|
|
|
+ await plc.WriteNodeAsync(addressConfig.Out_MesStatus.Address, (Int16)1);
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ await plc.WriteNodeAsync(addressConfig.Out_MesStatus.Address, (Int16)0);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
#endregion
|