徐孝锋 8 meses atrás
pai
commit
45a2cd1a31
2 arquivos alterados com 263 adições e 243 exclusões
  1. 173 153
      TeamAAS-VM/Core/Management.cs
  2. 90 90
      TeamAAS-VM/Models/PLC/PlcAddressConfig.cs

+ 173 - 153
TeamAAS-VM/Core/Management.cs

@@ -1,5 +1,6 @@
 using Cognex.VisionPro;
 using Cognex.VisionPro.ToolBlock;
+using CSScripting;
 using MathNet.Numerics.LinearAlgebra;
 using MathNet.Numerics.RootFinding;
 using NPOI.SS.Formula.Functions;
@@ -50,6 +51,7 @@ using TouchSocket.Core;
 using TouchSocket.Sockets;
 using static MaterialDesignThemes.Wpf.Theme.ToolBar;
 using static Org.BouncyCastle.Math.EC.ECCurve;
+using static System.Windows.Forms.AxHost;
 
 namespace TeamAAS_VP.Core
 {
@@ -290,8 +292,15 @@ namespace TeamAAS_VP.Core
                     SendTaskMessage($"{item.Name}{Lang.断开连接}!", MessageLevel.Alarm);
                 }
             }
-            await WriteSystemParameterToPlcAsync(_configService.GetSystemConfiguration());
-            RegisterPlcMonitorAddress();
+            try
+            {
+                await WriteSystemParameterToPlcAsync(_configService.GetSystemConfiguration());
+                RegisterPlcMonitorAddress();
+            }
+            catch (Exception ex)
+            {
+                LogHelper.WriteLogError("为PLC写入系统参数和订阅变量时出错",ex);
+            }
             if (sb.Length == 0)
             {
                 return (true, "");
@@ -905,6 +914,7 @@ namespace TeamAAS_VP.Core
                     await item.WriteToPlcAddress(addressConfig.Out_PickCamera,plc);
                 }
             }
+            
             if (current.PickPoints != null && current.PickPoints.Count > 0)
             {
                 foreach (var item in current.PickPoints)
@@ -949,202 +959,209 @@ namespace TeamAAS_VP.Core
         /// <param name="tuple"></param>
         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))
+            try
             {
-                if (tuple.value is bool state)
+                var addressConfig = _configService.GetPlcAddresses();
+                var plc = _plcService.GetPlcByNumber(addressConfig.PlcNo) as OpcUaClientPLC;
+                if (plc == null || !plc.IsConnected) return;
+
+                // 触发下相机拍照
+                if (addressConfig.In_DowmCameraExe.Address.Contains(tuple.nodeId))
                 {
-                    if (state)
+                    if (tuple.value is bool state)
                     {
-                        SendTaskMessage($"触发下相机拍照...", MessageLevel.Debug);
-                        await plc.WriteNodeAsync(addressConfig.Out_DownCameraStatus.Address, (Int16)1);
-                    }
-                    else
-                    {
-                        SendTaskMessage($"触发下相机拍照信号已关闭", MessageLevel.Alarm);
-                        await plc.WriteNodeAsync(addressConfig.Out_DownCameraStatus.Address, (Int16)0);
+                        if (state)
+                        {
+                            SendTaskMessage($"触发下相机拍照...", MessageLevel.Debug);
+                            await plc.WriteNodeAsync(addressConfig.Out_DownCameraStatus.Address, (Int16)1);
+                        }
+                        else
+                        {
+                            SendTaskMessage($"触发下相机拍照信号已关闭", MessageLevel.Alarm);
+                            await plc.WriteNodeAsync(addressConfig.Out_DownCameraStatus.Address, (Int16)0);
+                        }
                     }
                 }
-            }
-            // 触发上相机取料拍照
-            else if (tuple.nodeId.Contains(addressConfig.In_UpCameraPickExe.Address))
-            {
-                if (tuple.value is bool state)
+                // 触发上相机取料拍照
+                else if (addressConfig.In_UpCameraPickExe.Address.Contains(tuple.nodeId))
                 {
-                    if (state)
-                    {
-                        SendTaskMessage($"触发上相机取料拍照...", MessageLevel.Debug);
-                        await plc.WriteNodeAsync(addressConfig.Out_UpCameraPickStatus.Address, (Int16)1);
-                    }
-                    else
+                    if (tuple.value is bool state)
                     {
-                        SendTaskMessage($"触发上相机取料拍照信号已关闭", MessageLevel.Alarm);
-                        await plc.WriteNodeAsync(addressConfig.Out_UpCameraPickStatus.Address, (Int16)0);
+                        if (state)
+                        {
+                            SendTaskMessage($"触发上相机取料拍照...", MessageLevel.Debug);
+                            await plc.WriteNodeAsync(addressConfig.Out_UpCameraPickStatus.Address, (Int16)1);
+                        }
+                        else
+                        {
+                            SendTaskMessage($"触发上相机取料拍照信号已关闭", MessageLevel.Alarm);
+                            await plc.WriteNodeAsync(addressConfig.Out_UpCameraPickStatus.Address, (Int16)0);
+                        }
                     }
                 }
-            }
-            // 上相机锁附/组装拍照
-            else if (tuple.nodeId.Contains(addressConfig.In_UpCameraPutExe.Address))
-            {
-                if (tuple.value is bool state)
+                // 上相机锁附/组装拍照
+                else if (addressConfig.In_UpCameraPutExe.Address.Contains(tuple.nodeId))
                 {
-                    if (state)
+                    if (tuple.value is bool state)
                     {
-                        SendTaskMessage($"触发上相机锁附/组装拍照...", MessageLevel.Debug);
-                        await plc.WriteNodeAsync(addressConfig.Out_UpCameraPutStatus.Address, (Int16)1);
-                    }
-                    else
-                    {
-                        SendTaskMessage($"触发上相机锁附/组装拍照信号已关闭", MessageLevel.Alarm);
-                        await plc.WriteNodeAsync(addressConfig.Out_UpCameraPutStatus.Address, (Int16)0);
+                        if (state)
+                        {
+                            SendTaskMessage($"触发上相机锁附/组装拍照...", MessageLevel.Debug);
+                            await plc.WriteNodeAsync(addressConfig.Out_UpCameraPutStatus.Address, (Int16)1);
+                        }
+                        else
+                        {
+                            SendTaskMessage($"触发上相机锁附/组装拍照信号已关闭", MessageLevel.Alarm);
+                            await plc.WriteNodeAsync(addressConfig.Out_UpCameraPutStatus.Address, (Int16)0);
+                        }
                     }
                 }
-            }
-            // 上相机检测拍照
-            else if (tuple.nodeId.Contains(addressConfig.In_UPCameracheckExe.Address))
-            {
-                if (tuple.value is bool state)
+                // 上相机检测拍照
+                else if (addressConfig.In_UPCameracheckExe.Address.Contains(tuple.nodeId))
                 {
-                    if (state)
-                    {
-                        SendTaskMessage($"触发上相机检测拍照...", MessageLevel.Debug);
-                        await plc.WriteNodeAsync(addressConfig.Out_UPCameracheckStatus.Address, (Int16)1);
-                    }
-                    else
+                    if (tuple.value is bool state)
                     {
-                        SendTaskMessage($"触发上相机检测拍照信号已关闭", MessageLevel.Alarm);
-                        await plc.WriteNodeAsync(addressConfig.Out_UPCameracheckStatus.Address, (Int16)0);
+                        if (state)
+                        {
+                            SendTaskMessage($"触发上相机检测拍照...", MessageLevel.Debug);
+                            await plc.WriteNodeAsync(addressConfig.Out_UPCameracheckStatus.Address, (Int16)1);
+                        }
+                        else
+                        {
+                            SendTaskMessage($"触发上相机检测拍照信号已关闭", MessageLevel.Alarm);
+                            await plc.WriteNodeAsync(addressConfig.Out_UPCameracheckStatus.Address, (Int16)0);
+                        }
                     }
                 }
-            }
-            // 固定相机取料拍照
-            else if (tuple.nodeId.Contains(addressConfig.In_FixedCameraPickExe.Address))
-            {
-                if (tuple.value is bool state)
+                // 固定相机取料拍照
+                else if (addressConfig.In_FixedCameraPickExe.Address.Contains(tuple.nodeId))
                 {
-                    if (state)
+                    if (tuple.value is bool state)
                     {
-                        SendTaskMessage($"触发固定相机取料拍照...", MessageLevel.Debug);
-                        await plc.WriteNodeAsync(addressConfig.Out_FixedCameraPickStatus.Address, (Int16)1);
-                    }
-                    else
-                    {
-                        SendTaskMessage($"触发固定相机取料拍照信号已关闭", MessageLevel.Alarm);
-                        await plc.WriteNodeAsync(addressConfig.Out_FixedCameraPickStatus.Address, (Int16)0);
+                        if (state)
+                        {
+                            SendTaskMessage($"触发固定相机取料拍照...", MessageLevel.Debug);
+                            await plc.WriteNodeAsync(addressConfig.Out_FixedCameraPickStatus.Address, (Int16)1);
+                        }
+                        else
+                        {
+                            SendTaskMessage($"触发固定相机取料拍照信号已关闭", MessageLevel.Alarm);
+                            await plc.WriteNodeAsync(addressConfig.Out_FixedCameraPickStatus.Address, (Int16)0);
+                        }
                     }
                 }
-            }
-            // 固定相机锁附/组装拍照
-            else if (tuple.nodeId.Contains(addressConfig.In_FixedCameraPutExe.Address))
-            {
-                if (tuple.value is bool state)
+                // 固定相机锁附/组装拍照
+                else if (addressConfig.In_FixedCameraPutExe.Address.Contains(tuple.nodeId))
                 {
-                    if (state)
-                    {
-                        SendTaskMessage($"触发固定相机锁附/组装拍照...", MessageLevel.Debug);
-                        await plc.WriteNodeAsync(addressConfig.Out_FixedCameraPutStatus.Address, (Int16)1);
-                    }
-                    else
+                    if (tuple.value is bool state)
                     {
-                        SendTaskMessage($"触发固定相机锁附/组装拍照信号已关闭", MessageLevel.Alarm);
-                        await plc.WriteNodeAsync(addressConfig.Out_FixedCameraPutStatus.Address, (Int16)0);
+                        if (state)
+                        {
+                            SendTaskMessage($"触发固定相机锁附/组装拍照...", MessageLevel.Debug);
+                            await plc.WriteNodeAsync(addressConfig.Out_FixedCameraPutStatus.Address, (Int16)1);
+                        }
+                        else
+                        {
+                            SendTaskMessage($"触发固定相机锁附/组装拍照信号已关闭", MessageLevel.Alarm);
+                            await plc.WriteNodeAsync(addressConfig.Out_FixedCameraPutStatus.Address, (Int16)0);
+                        }
                     }
                 }
-            }
-            // 固定相机检测拍照
-            else if (tuple.nodeId.Contains(addressConfig.In_FixedCameracheckExe.Address))
-            {
-                if (tuple.value is bool state)
+                // 固定相机检测拍照
+                else if (addressConfig.In_FixedCameracheckExe.Address.Contains(tuple.nodeId))
                 {
-                    if (state)
+                    if (tuple.value is bool state)
                     {
-                        SendTaskMessage($"触发固定相机检测拍照...", MessageLevel.Debug);
-                        await plc.WriteNodeAsync(addressConfig.Out_FixedCameracheckStatus.Address, (Int16)1);
-                    }
-                    else
-                    {
-                        SendTaskMessage($"触发固定相机检测拍照信号已关闭", MessageLevel.Alarm);
-                        await plc.WriteNodeAsync(addressConfig.Out_FixedCameracheckStatus.Address, (Int16)0);
+                        if (state)
+                        {
+                            SendTaskMessage($"触发固定相机检测拍照...", MessageLevel.Debug);
+                            await plc.WriteNodeAsync(addressConfig.Out_FixedCameracheckStatus.Address, (Int16)1);
+                        }
+                        else
+                        {
+                            SendTaskMessage($"触发固定相机检测拍照信号已关闭", MessageLevel.Alarm);
+                            await plc.WriteNodeAsync(addressConfig.Out_FixedCameracheckStatus.Address, (Int16)0);
+                        }
                     }
                 }
-            }
-            // 开始锁付
-            else if (tuple.nodeId.Contains(addressConfig.In_WorkStart.Address))
-            {
-                if (tuple.value is bool state)
+                // 开始锁付
+                else if (addressConfig.In_WorkStart.Address.Contains(tuple.nodeId))
                 {
-                    if (state)
-                    {
-                        SendTaskMessage($"收到开始锁付信号...", MessageLevel.Debug);
-                        // 这里保留扩展点:可在此添加写 PLC 或启动工作流程的代码
-                    }
-                    else
+                    if (tuple.value is bool state)
                     {
-                        SendTaskMessage($"开始锁付信号已关闭", MessageLevel.Alarm);
-                        // 关闭时的处理(如需)可放在这里
+                        if (state)
+                        {
+                            SendTaskMessage($"收到开始锁付信号...", MessageLevel.Debug);
+                            // 这里保留扩展点:可在此添加写 PLC 或启动工作流程的代码
+                        }
+                        else
+                        {
+                            SendTaskMessage($"开始锁付信号已关闭", MessageLevel.Alarm);
+                            // 关闭时的处理(如需)可放在这里
+                        }
                     }
                 }
-            }
-            // 停止锁付
-            else if (tuple.nodeId.Contains(addressConfig.In_WorkDone.Address))
-            {
-                if (tuple.value is bool state)
+                // 停止锁付
+                else if (addressConfig.In_WorkDone.Address.Contains(tuple.nodeId))
                 {
-                    if (state)
+                    if (tuple.value is bool state)
                     {
-                        SendTaskMessage($"收到停止锁付信号...", MessageLevel.Debug);
-                        // 停止动作的处理点
-                    }
-                    else
-                    {
-                        SendTaskMessage($"停止锁付信号已关闭", MessageLevel.Alarm);
+                        if (state)
+                        {
+                            SendTaskMessage($"收到停止锁付信号...", MessageLevel.Debug);
+                            // 停止动作的处理点
+                        }
+                        else
+                        {
+                            SendTaskMessage($"停止锁付信号已关闭", MessageLevel.Alarm);
+                        }
                     }
                 }
-            }
-            // 多相机坐标合并
-            else if (tuple.nodeId.Contains(addressConfig.In_RequestPosition.Address))
-            {
-                if (tuple.value is Int16 state)
+                // 多相机坐标合并
+                else if (addressConfig.In_RequestPosition.Address.Contains(tuple.nodeId))
                 {
-                    if (state == 1)
-                    {
-                        SendTaskMessage($"收到多相机坐标合并请求,开始合并...", MessageLevel.Debug);
-                        await plc.WriteNodeAsync(addressConfig.Out_CameraDone.Address, (Int16)1);
-                    }
-                    else
+                    if (tuple.value is Int16 state)
                     {
-                        SendTaskMessage($"多相机坐标合并请求已结束或被取消,state={state}", MessageLevel.Alarm);
-                        await plc.WriteNodeAsync(addressConfig.Out_CameraDone.Address, (Int16)0);
+                        if (state == 1)
+                        {
+                            SendTaskMessage($"收到多相机坐标合并请求,开始合并...", MessageLevel.Debug);
+                            await plc.WriteNodeAsync(addressConfig.Out_CameraDone.Address, (Int16)1);
+                        }
+                        else
+                        {
+                            SendTaskMessage($"多相机坐标合并请求已结束或被取消,state={state}", MessageLevel.Alarm);
+                            await plc.WriteNodeAsync(addressConfig.Out_CameraDone.Address, (Int16)0);
+                        }
                     }
                 }
-            }
-            // 过站检查
-            else if (tuple.nodeId.Contains(addressConfig.In_MesCheck.Address))
-            {
-                if (tuple.value is Int16 state)
+                // 过站检查
+                else if (addressConfig.In_MesCheck.Address.Contains(tuple.nodeId))
                 {
-                    if (state == 1)
+                    if (tuple.value is Int16 state)
                     {
-                        SendTaskMessage($"收到过站检查请求(当站是否生产)...", MessageLevel.Debug);
-                        await plc.WriteNodeAsync(addressConfig.Out_MesStatus.Address, (Int16)1);
-                    }
-                    // 上传本站数据
-                    else if (state == 2)
-                    {
-                        SendTaskMessage($"收到上传本站数据请求...", MessageLevel.Debug);
-                        await plc.WriteNodeAsync(addressConfig.Out_MesStatus.Address, (Int16)3);
-                    }
-                    else
-                    {
-                        SendTaskMessage($"过站检查信号:state={state},处理为默认状态", MessageLevel.Alarm);
-                        await plc.WriteNodeAsync(addressConfig.Out_MesStatus.Address, (Int16)0);
+                        if (state == 1)
+                        {
+                            SendTaskMessage($"收到过站检查请求(当站是否生产)...", MessageLevel.Debug);
+                            await plc.WriteNodeAsync(addressConfig.Out_MesStatus.Address, (Int16)1);
+                        }
+                        // 上传本站数据
+                        else if (state == 2)
+                        {
+                            SendTaskMessage($"收到上传本站数据请求...", MessageLevel.Debug);
+                            await plc.WriteNodeAsync(addressConfig.Out_MesStatus.Address, (Int16)3);
+                        }
+                        else
+                        {
+                            SendTaskMessage($"过站检查信号:state={state},处理为默认状态", MessageLevel.Alarm);
+                            await plc.WriteNodeAsync(addressConfig.Out_MesStatus.Address, (Int16)0);
+                        }
                     }
                 }
             }
+            catch (Exception ex)
+            {
+                SendTaskMessage(ex.Message, MessageLevel.Error);
+            }
         }
 
         #endregion
@@ -1153,7 +1170,10 @@ namespace TeamAAS_VP.Core
 
         private void SendTaskMessage(string msg, MessageLevel level)
         {
-            _eventAggregator.GetEvent<TaskMessageNotification>().Publish(new Models.MessageStruct() { Message = msg, level = level });
+            App.Current.Dispatcher.Invoke(() =>
+            {
+                _eventAggregator.GetEvent<TaskMessageNotification>().Publish(new Models.MessageStruct() { Message = msg, level = level });
+            });
         }
 
         private async void DoYieldTime(object state)

+ 90 - 90
TeamAAS-VM/Models/PLC/PlcAddressConfig.cs

@@ -598,116 +598,116 @@ namespace TeamAAS_VP.Models.PLC
             // Out_PickCamera 初始化并赋地址
             Out_PickCamera = EnsurePoint(Out_PickCamera);
             Out_PickCamera.Description = "取料拍照点位参数";
-            Out_PickCamera.X_Position.Address = "ns=4;s=DB_Communication|FromPC.Point_PickCamera{0}.X_Position";
-            Out_PickCamera.X_Velocity.Address = "ns=4;s=DB_Communication|FromPC.Point_PickCamera{0}.X_Velocity";
-            Out_PickCamera.Y_Position.Address = "ns=4;s=DB_Communication|FromPC.Point_PickCamera{0}.Y_Position";
-            Out_PickCamera.Y_Velocity.Address = "ns=4;s=DB_Communication|FromPC.Point_PickCamera{0}.Y_Velocity";
-            Out_PickCamera.Z_Position_Start.Address = "ns=4;s=DB_Communication|FromPC.Point_PickCamera{0}.Z_Position_Start";
-            Out_PickCamera.Z_Velocity_Start.Address = "ns=4;s=DB_Communication|FromPC.Point_PickCamera{0}.Z_Velocity_Start";
-            Out_PickCamera.Z_Position_Stop.Address = "ns=4;s=DB_Communication|FromPC.Point_PickCamera{0}.Z_Position_Stop";
-            Out_PickCamera.Z_Velocity_Stop.Address = "ns=4;s=DB_Communication|FromPC.Point_PickCamera{0}.Z_Velocity_Stop";
-            Out_PickCamera.U_Position.Address = "ns=4;s=DB_Communication|FromPC.Point_PickCamera{0}.U_Position";
-            Out_PickCamera.U_Velocity.Address = "ns=4;s=DB_Communication|FromPC.Point_PickCamera{0}.U_Velocity";
-            Out_PickCamera.R_Position.Address = "ns=4;s=DB_Communication|FromPC.Point_PickCamera{0}.R_Position";
-            Out_PickCamera.R_Velocity.Address = "ns=4;s=DB_Communication|FromPC.Point_PickCamera{0}.R_Velocity";
-            Out_PickCamera.Torque.Address = "ns=4;s=DB_Communication|FromPC.Point_PickCamera{0}.Torque";
-            Out_PickCamera.Feeder.Address = "ns=4;s=DB_Communication|FromPC.Point_PickCamera{0}.Feeder";
-            Out_PickCamera.ScrewProNum.Address = "ns=4;s=DB_Communication|FromPC.Point_PickCamera{0}.ScrewProNum";
+            Out_PickCamera.X_Position.Address = "ns=4;s=DB_Communication|FromPC.Point_PickCamera[{0}].X_Position";
+            Out_PickCamera.X_Velocity.Address = "ns=4;s=DB_Communication|FromPC.Point_PickCamera[{0}].X_Velocity";
+            Out_PickCamera.Y_Position.Address = "ns=4;s=DB_Communication|FromPC.Point_PickCamera[{0}].Y_Position";
+            Out_PickCamera.Y_Velocity.Address = "ns=4;s=DB_Communication|FromPC.Point_PickCamera[{0}].Y_Velocity";
+            Out_PickCamera.Z_Position_Start.Address = "ns=4;s=DB_Communication|FromPC.Point_PickCamera[{0}].Z_Position_Start";
+            Out_PickCamera.Z_Velocity_Start.Address = "ns=4;s=DB_Communication|FromPC.Point_PickCamera[{0}].Z_Velocity_Start";
+            Out_PickCamera.Z_Position_Stop.Address = "ns=4;s=DB_Communication|FromPC.Point_PickCamera[{0}].Z_Position_Stop";
+            Out_PickCamera.Z_Velocity_Stop.Address = "ns=4;s=DB_Communication|FromPC.Point_PickCamera[{0}].Z_Velocity_Stop";
+            Out_PickCamera.U_Position.Address = "ns=4;s=DB_Communication|FromPC.Point_PickCamera[{0}].U_Position";
+            Out_PickCamera.U_Velocity.Address = "ns=4;s=DB_Communication|FromPC.Point_PickCamera[{0}].U_Velocity";
+            Out_PickCamera.R_Position.Address = "ns=4;s=DB_Communication|FromPC.Point_PickCamera[{0}].R_Position";
+            Out_PickCamera.R_Velocity.Address = "ns=4;s=DB_Communication|FromPC.Point_PickCamera[{0}].R_Velocity";
+            Out_PickCamera.Torque.Address = "ns=4;s=DB_Communication|FromPC.Point_PickCamera[{0}].Torque";
+            Out_PickCamera.Feeder.Address = "ns=4;s=DB_Communication|FromPC.Point_PickCamera[{0}].Feeder";
+            Out_PickCamera.ScrewProNum.Address = "ns=4;s=DB_Communication|FromPC.Point_PickCamera[{0}].ScrewProNum";
 
             // Out_Pick(取料点位)初始化并赋地址
             Out_Pick = EnsurePoint(Out_Pick);
             Out_Pick.Description = "取料点位参数";
-            Out_Pick.X_Position.Address = "ns=4;s=DB_Communication|FromPC.Point_Pick{0}.X_Position";
-            Out_Pick.X_Velocity.Address = "ns=4;s=DB_Communication|FromPC.Point_Pick{0}.X_Velocity";
-            Out_Pick.Y_Position.Address = "ns=4;s=DB_Communication|FromPC.Point_Pick{0}.Y_Position";
-            Out_Pick.Y_Velocity.Address = "ns=4;s=DB_Communication|FromPC.Point_Pick{0}.Y_Velocity";
-            Out_Pick.Z_Position_Start.Address = "ns=4;s=DB_Communication|FromPC.Point_Pick{0}.Z_Position_Start";
-            Out_Pick.Z_Velocity_Start.Address = "ns=4;s=DB_Communication|FromPC.Point_Pick{0}.Z_Velocity_Start";
-            Out_Pick.Z_Position_Stop.Address = "ns=4;s=DB_Communication|FromPC.Point_Pick{0}.Z_Position_Stop";
-            Out_Pick.Z_Velocity_Stop.Address = "ns=4;s=DB_Communication|FromPC.Point_Pick{0}.Z_Velocity_Stop";
-            Out_Pick.U_Position.Address = "ns=4;s=DB_Communication|FromPC.Point_Pick{0}.U_Position";
-            Out_Pick.U_Velocity.Address = "ns=4;s=DB_Communication|FromPC.Point_Pick{0}.U_Velocity";
-            Out_Pick.R_Position.Address = "ns=4;s=DB_Communication|FromPC.Point_Pick{0}.R_Position";
-            Out_Pick.R_Velocity.Address = "ns=4;s=DB_Communication|FromPC.Point_Pick{0}.R_Velocity";
-            Out_Pick.Torque.Address = "ns=4;s=DB_Communication|FromPC.Point_Pick{0}.Torque";
-            Out_Pick.Feeder.Address = "ns=4;s=DB_Communication|FromPC.Point_Pick{0}.Feeder";
-            Out_Pick.ScrewProNum.Address = "ns=4;s=DB_Communication|FromPC.Point_Pick{0}.ScrewProNum";
+            Out_Pick.X_Position.Address = "ns=4;s=DB_Communication|FromPC.Point_Pick[{0}].X_Position";
+            Out_Pick.X_Velocity.Address = "ns=4;s=DB_Communication|FromPC.Point_Pick[{0}].X_Velocity";
+            Out_Pick.Y_Position.Address = "ns=4;s=DB_Communication|FromPC.Point_Pick[{0}].Y_Position";
+            Out_Pick.Y_Velocity.Address = "ns=4;s=DB_Communication|FromPC.Point_Pick[{0}].Y_Velocity";
+            Out_Pick.Z_Position_Start.Address = "ns=4;s=DB_Communication|FromPC.Point_Pick[{0}].Z_Position_Start";
+            Out_Pick.Z_Velocity_Start.Address = "ns=4;s=DB_Communication|FromPC.Point_Pick[{0}].Z_Velocity_Start";
+            Out_Pick.Z_Position_Stop.Address = "ns=4;s=DB_Communication|FromPC.Point_Pick[{0}].Z_Position_Stop";
+            Out_Pick.Z_Velocity_Stop.Address = "ns=4;s=DB_Communication|FromPC.Point_Pick[{0}].Z_Velocity_Stop";
+            Out_Pick.U_Position.Address = "ns=4;s=DB_Communication|FromPC.Point_Pick[{0}].U_Position";
+            Out_Pick.U_Velocity.Address = "ns=4;s=DB_Communication|FromPC.Point_Pick[{0}].U_Velocity";
+            Out_Pick.R_Position.Address = "ns=4;s=DB_Communication|FromPC.Point_Pick[{0}].R_Position";
+            Out_Pick.R_Velocity.Address = "ns=4;s=DB_Communication|FromPC.Point_Pick[{0}].R_Velocity";
+            Out_Pick.Torque.Address = "ns=4;s=DB_Communication|FromPC.Point_Pick[{0}].Torque";
+            Out_Pick.Feeder.Address = "ns=4;s=DB_Communication|FromPC.Point_Pick[{0}].Feeder";
+            Out_Pick.ScrewProNum.Address = "ns=4;s=DB_Communication|FromPC.Point_Pick[{0}].ScrewProNum";
 
             // Out_SecPosCamera(下相机二次定位)初始化并赋地址
             Out_SecPosCamera = EnsurePoint(Out_SecPosCamera);
             Out_SecPosCamera.Description = "下相机二次定位点位参数";
-            Out_SecPosCamera.X_Position.Address = "ns=4;s=DB_Communication|FromPC.Point_SecPosCamera{0}.X_Position";
-            Out_SecPosCamera.X_Velocity.Address = "ns=4;s=DB_Communication|FromPC.Point_SecPosCamera{0}.X_Velocity";
-            Out_SecPosCamera.Y_Position.Address = "ns=4;s=DB_Communication|FromPC.Point_SecPosCamera{0}.Y_Position";
-            Out_SecPosCamera.Y_Velocity.Address = "ns=4;s=DB_Communication|FromPC.Point_SecPosCamera{0}.Y_Velocity";
-            Out_SecPosCamera.Z_Position_Start.Address = "ns=4;s=DB_Communication|FromPC.Point_SecPosCamera{0}.Z_Position_Start";
-            Out_SecPosCamera.Z_Velocity_Start.Address = "ns=4;s=DB_Communication|FromPC.Point_SecPosCamera{0}.Z_Velocity_Start";
-            Out_SecPosCamera.Z_Position_Stop.Address = "ns=4;s=DB_Communication|FromPC.Point_SecPosCamera{0}.Z_Position_Stop";
-            Out_SecPosCamera.Z_Velocity_Stop.Address = "ns=4;s=DB_Communication|FromPC.Point_SecPosCamera{0}.Z_Velocity_Stop";
-            Out_SecPosCamera.U_Position.Address = "ns=4;s=DB_Communication|FromPC.Point_SecPosCamera{0}.U_Position";
-            Out_SecPosCamera.U_Velocity.Address = "ns=4;s=DB_Communication|FromPC.Point_SecPosCamera{0}.U_Velocity";
-            Out_SecPosCamera.R_Position.Address = "ns=4;s=DB_Communication|FromPC.Point_SecPosCamera{0}.R_Position";
-            Out_SecPosCamera.R_Velocity.Address = "ns=4;s=DB_Communication|FromPC.Point_SecPosCamera{0}.R_Velocity";
-            Out_SecPosCamera.Torque.Address = "ns=4;s=DB_Communication|FromPC.Point_SecPosCamera{0}.Torque";
-            Out_SecPosCamera.Feeder.Address = "ns=4;s=DB_Communication|FromPC.Point_SecPosCamera{0}.Feeder";
-            Out_SecPosCamera.ScrewProNum.Address = "ns=4;s=DB_Communication|FromPC.Point_SecPosCamera{0}.ScrewProNum";
+            Out_SecPosCamera.X_Position.Address = "ns=4;s=DB_Communication|FromPC.Point_SecPosCamera[{0}].X_Position";
+            Out_SecPosCamera.X_Velocity.Address = "ns=4;s=DB_Communication|FromPC.Point_SecPosCamera[{0}].X_Velocity";
+            Out_SecPosCamera.Y_Position.Address = "ns=4;s=DB_Communication|FromPC.Point_SecPosCamera[{0}].Y_Position";
+            Out_SecPosCamera.Y_Velocity.Address = "ns=4;s=DB_Communication|FromPC.Point_SecPosCamera[{0}].Y_Velocity";
+            Out_SecPosCamera.Z_Position_Start.Address = "ns=4;s=DB_Communication|FromPC.Point_SecPosCamera[{0}].Z_Position_Start";
+            Out_SecPosCamera.Z_Velocity_Start.Address = "ns=4;s=DB_Communication|FromPC.Point_SecPosCamera[{0}].Z_Velocity_Start";
+            Out_SecPosCamera.Z_Position_Stop.Address = "ns=4;s=DB_Communication|FromPC.Point_SecPosCamera[{0}].Z_Position_Stop";
+            Out_SecPosCamera.Z_Velocity_Stop.Address = "ns=4;s=DB_Communication|FromPC.Point_SecPosCamera[{0}].Z_Velocity_Stop";
+            Out_SecPosCamera.U_Position.Address = "ns=4;s=DB_Communication|FromPC.Point_SecPosCamera[{0}].U_Position";
+            Out_SecPosCamera.U_Velocity.Address = "ns=4;s=DB_Communication|FromPC.Point_SecPosCamera[{0}].U_Velocity";
+            Out_SecPosCamera.R_Position.Address = "ns=4;s=DB_Communication|FromPC.Point_SecPosCamera[{0}].R_Position";
+            Out_SecPosCamera.R_Velocity.Address = "ns=4;s=DB_Communication|FromPC.Point_SecPosCamera[{0}].R_Velocity";
+            Out_SecPosCamera.Torque.Address = "ns=4;s=DB_Communication|FromPC.Point_SecPosCamera[{0}].Torque";
+            Out_SecPosCamera.Feeder.Address = "ns=4;s=DB_Communication|FromPC.Point_SecPosCamera[{0}].Feeder";
+            Out_SecPosCamera.ScrewProNum.Address = "ns=4;s=DB_Communication|FromPC.Point_SecPosCamera[{0}].ScrewProNum";
 
             // Out_ScrewCamera(锁附拍照点位)初始化并赋地址
             Out_ScrewCamera = EnsurePoint(Out_ScrewCamera);
             Out_ScrewCamera.Description = "锁附拍照点位参数";
-            Out_ScrewCamera.X_Position.Address = "ns=4;s=DB_Communication|FromPC.Point_ScrewCamera{0}.X_Position";
-            Out_ScrewCamera.X_Velocity.Address = "ns=4;s=DB_Communication|FromPC.Point_ScrewCamera{0}.X_Velocity";
-            Out_ScrewCamera.Y_Position.Address = "ns=4;s=DB_Communication|FromPC.Point_ScrewCamera{0}.Y_Position";
-            Out_ScrewCamera.Y_Velocity.Address = "ns=4;s=DB_Communication|FromPC.Point_ScrewCamera{0}.Y_Velocity";
-            Out_ScrewCamera.Z_Position_Start.Address = "ns=4;s=DB_Communication|FromPC.Point_ScrewCamera{0}.Z_Position_Start";
-            Out_ScrewCamera.Z_Velocity_Start.Address = "ns=4;s=DB_Communication|FromPC.Point_ScrewCamera{0}.Z_Velocity_Start";
-            Out_ScrewCamera.Z_Position_Stop.Address = "ns=4;s=DB_Communication|FromPC.Point_ScrewCamera{0}.Z_Position_Stop";
-            Out_ScrewCamera.Z_Velocity_Stop.Address = "ns=4;s=DB_Communication|FromPC.Point_ScrewCamera{0}.Z_Velocity_Stop";
-            Out_ScrewCamera.U_Position.Address = "ns=4;s=DB_Communication|FromPC.Point_ScrewCamera{0}.U_Position";
-            Out_ScrewCamera.U_Velocity.Address = "ns=4;s=DB_Communication|FromPC.Point_ScrewCamera{0}.U_Velocity";
-            Out_ScrewCamera.R_Position.Address = "ns=4;s=DB_Communication|FromPC.Point_ScrewCamera{0}.R_Position";
-            Out_ScrewCamera.R_Velocity.Address = "ns=4;s=DB_Communication|FromPC.Point_ScrewCamera{0}.R_Velocity";
-            Out_ScrewCamera.Torque.Address = "ns=4;s=DB_Communication|FromPC.Point_ScrewCamera{0}.Torque";
-            Out_ScrewCamera.Feeder.Address = "ns=4;s=DB_Communication|FromPC.Point_ScrewCamera{0}.Feeder";
-            Out_ScrewCamera.ScrewProNum.Address = "ns=4;s=DB_Communication|FromPC.Point_ScrewCamera{0}.ScrewProNum";
+            Out_ScrewCamera.X_Position.Address = "ns=4;s=DB_Communication|FromPC.Point_ScrewCamera[{0}].X_Position";
+            Out_ScrewCamera.X_Velocity.Address = "ns=4;s=DB_Communication|FromPC.Point_ScrewCamera[{0}].X_Velocity";
+            Out_ScrewCamera.Y_Position.Address = "ns=4;s=DB_Communication|FromPC.Point_ScrewCamera[{0}].Y_Position";
+            Out_ScrewCamera.Y_Velocity.Address = "ns=4;s=DB_Communication|FromPC.Point_ScrewCamera[{0}].Y_Velocity";
+            Out_ScrewCamera.Z_Position_Start.Address = "ns=4;s=DB_Communication|FromPC.Point_ScrewCamera[{0}].Z_Position_Start";
+            Out_ScrewCamera.Z_Velocity_Start.Address = "ns=4;s=DB_Communication|FromPC.Point_ScrewCamera[{0}].Z_Velocity_Start";
+            Out_ScrewCamera.Z_Position_Stop.Address = "ns=4;s=DB_Communication|FromPC.Point_ScrewCamera[{0}].Z_Position_Stop";
+            Out_ScrewCamera.Z_Velocity_Stop.Address = "ns=4;s=DB_Communication|FromPC.Point_ScrewCamera[{0}].Z_Velocity_Stop";
+            Out_ScrewCamera.U_Position.Address = "ns=4;s=DB_Communication|FromPC.Point_ScrewCamera[{0}].U_Position";
+            Out_ScrewCamera.U_Velocity.Address = "ns=4;s=DB_Communication|FromPC.Point_ScrewCamera[{0}].U_Velocity";
+            Out_ScrewCamera.R_Position.Address = "ns=4;s=DB_Communication|FromPC.Point_ScrewCamera[{0}].R_Position";
+            Out_ScrewCamera.R_Velocity.Address = "ns=4;s=DB_Communication|FromPC.Point_ScrewCamera[{0}].R_Velocity";
+            Out_ScrewCamera.Torque.Address = "ns=4;s=DB_Communication|FromPC.Point_ScrewCamera[{0}].Torque";
+            Out_ScrewCamera.Feeder.Address = "ns=4;s=DB_Communication|FromPC.Point_ScrewCamera[{0}].Feeder";
+            Out_ScrewCamera.ScrewProNum.Address = "ns=4;s=DB_Communication|FromPC.Point_ScrewCamera[{0}].ScrewProNum";
 
             // Out_Screw(锁附点位)初始化并赋地址
             Out_Screw = EnsurePoint(Out_Screw);
             Out_Screw.Description = "锁附点位参数";
-            Out_Screw.X_Position.Address = "ns=4;s=DB_Communication|FromPC.Point_Screw{0}.X_Position";
-            Out_Screw.X_Velocity.Address = "ns=4;s=DB_Communication|FromPC.Point_Screw{0}.X_Velocity";
-            Out_Screw.Y_Position.Address = "ns=4;s=DB_Communication|FromPC.Point_Screw{0}.Y_Position";
-            Out_Screw.Y_Velocity.Address = "ns=4;s=DB_Communication|FromPC.Point_Screw{0}.Y_Velocity";
-            Out_Screw.Z_Position_Start.Address = "ns=4;s=DB_Communication|FromPC.Point_Screw{0}.Z_Position_Start";
-            Out_Screw.Z_Velocity_Start.Address = "ns=4;s=DB_Communication|FromPC.Point_Screw{0}.Z_Velocity_Start";
-            Out_Screw.Z_Position_Stop.Address = "ns=4;s=DB_Communication|FromPC.Point_Screw{0}.Z_Position_Stop";
-            Out_Screw.Z_Velocity_Stop.Address = "ns=4;s=DB_Communication|FromPC.Point_Screw{0}.Z_Velocity_Stop";
-            Out_Screw.U_Position.Address = "ns=4;s=DB_Communication|FromPC.Point_Screw{0}.U_Position";
-            Out_Screw.U_Velocity.Address = "ns=4;s=DB_Communication|FromPC.Point_Screw{0}.U_Velocity";
-            Out_Screw.R_Position.Address = "ns=4;s=DB_Communication|FromPC.Point_Screw{0}.R_Position";
-            Out_Screw.R_Velocity.Address = "ns=4;s=DB_Communication|FromPC.Point_Screw{0}.R_Velocity";
-            Out_Screw.Torque.Address = "ns=4;s=DB_Communication|FromPC.Point_Screw{0}.Torque";
-            Out_Screw.Feeder.Address = "ns=4;s=DB_Communication|FromPC.Point_Screw{0}.Feeder";
-            Out_Screw.ScrewProNum.Address = "ns=4;s=DB_Communication|FromPC.Point_Screw{0}.ScrewProNum";
+            Out_Screw.X_Position.Address = "ns=4;s=DB_Communication|FromPC.Point_Screw[{0}].X_Position";
+            Out_Screw.X_Velocity.Address = "ns=4;s=DB_Communication|FromPC.Point_Screw[{0}].X_Velocity";
+            Out_Screw.Y_Position.Address = "ns=4;s=DB_Communication|FromPC.Point_Screw[{0}].Y_Position";
+            Out_Screw.Y_Velocity.Address = "ns=4;s=DB_Communication|FromPC.Point_Screw[{0}].Y_Velocity";
+            Out_Screw.Z_Position_Start.Address = "ns=4;s=DB_Communication|FromPC.Point_Screw[{0}].Z_Position_Start";
+            Out_Screw.Z_Velocity_Start.Address = "ns=4;s=DB_Communication|FromPC.Point_Screw[{0}].Z_Velocity_Start";
+            Out_Screw.Z_Position_Stop.Address = "ns=4;s=DB_Communication|FromPC.Point_Screw[{0}].Z_Position_Stop";
+            Out_Screw.Z_Velocity_Stop.Address = "ns=4;s=DB_Communication|FromPC.Point_Screw[{0}].Z_Velocity_Stop";
+            Out_Screw.U_Position.Address = "ns=4;s=DB_Communication|FromPC.Point_Screw[{0}].U_Position";
+            Out_Screw.U_Velocity.Address = "ns=4;s=DB_Communication|FromPC.Point_Screw[{0}].U_Velocity";
+            Out_Screw.R_Position.Address = "ns=4;s=DB_Communication|FromPC.Point_Screw[{0}].R_Position";
+            Out_Screw.R_Velocity.Address = "ns=4;s=DB_Communication|FromPC.Point_Screw[{0}].R_Velocity";
+            Out_Screw.Torque.Address = "ns=4;s=DB_Communication|FromPC.Point_Screw[{0}].Torque";
+            Out_Screw.Feeder.Address = "ns=4;s=DB_Communication|FromPC.Point_Screw[{0}].Feeder";
+            Out_Screw.ScrewProNum.Address = "ns=4;s=DB_Communication|FromPC.Point_Screw[{0}].ScrewProNum";
 
             // Out_CheckCamera(复检点位)初始化并赋地址
             Out_CheckCamera = EnsurePoint(Out_CheckCamera);
             Out_CheckCamera.Description = "复检点位参数";
-            Out_CheckCamera.X_Position.Address = "ns=4;s=DB_Communication|FromPC.Point_CheckCamera{0}.X_Position";
-            Out_CheckCamera.X_Velocity.Address = "ns=4;s=DB_Communication|FromPC.Point_CheckCamera{0}.X_Velocity";
-            Out_CheckCamera.Y_Position.Address = "ns=4;s=DB_Communication|FromPC.Point_CheckCamera{0}.Y_Position";
-            Out_CheckCamera.Y_Velocity.Address = "ns=4;s=DB_Communication|FromPC.Point_CheckCamera{0}.Y_Velocity";
-            Out_CheckCamera.Z_Position_Start.Address = "ns=4;s=DB_Communication|FromPC.Point_CheckCamera{0}.Z_Position_Start";
-            Out_CheckCamera.Z_Velocity_Start.Address = "ns=4;s=DB_Communication|FromPC.Point_CheckCamera{0}.Z_Velocity_Start";
-            Out_CheckCamera.Z_Position_Stop.Address = "ns=4;s=DB_Communication|FromPC.Point_CheckCamera{0}.Z_Position_Stop";
-            Out_CheckCamera.Z_Velocity_Stop.Address = "ns=4;s=DB_Communication|FromPC.Point_CheckCamera{0}.Z_Velocity_Stop";
-            Out_CheckCamera.U_Position.Address = "ns=4;s=DB_Communication|FromPC.Point_CheckCamera{0}.U_Position";
-            Out_CheckCamera.U_Velocity.Address = "ns=4;s=DB_Communication|FromPC.Point_CheckCamera{0}.U_Velocity";
-            Out_CheckCamera.R_Position.Address = "ns=4;s=DB_Communication|FromPC.Point_CheckCamera{0}.R_Position";
-            Out_CheckCamera.R_Velocity.Address = "ns=4;s=DB_Communication|FromPC.Point_CheckCamera{0}.R_Velocity";
-            Out_CheckCamera.Torque.Address = "ns=4;s=DB_Communication|FromPC.Point_CheckCamera{0}.Torque";
-            Out_CheckCamera.Feeder.Address = "ns=4;s=DB_Communication|FromPC.Point_CheckCamera{0}.Feeder";
-            Out_CheckCamera.ScrewProNum.Address = "ns=4;s=DB_Communication|FromPC.Point_CheckCamera{0}.ScrewProNum";
+            Out_CheckCamera.X_Position.Address = "ns=4;s=DB_Communication|FromPC.Point_CheckCamera[{0}].X_Position";
+            Out_CheckCamera.X_Velocity.Address = "ns=4;s=DB_Communication|FromPC.Point_CheckCamera[{0}].X_Velocity";
+            Out_CheckCamera.Y_Position.Address = "ns=4;s=DB_Communication|FromPC.Point_CheckCamera[{0}].Y_Position";
+            Out_CheckCamera.Y_Velocity.Address = "ns=4;s=DB_Communication|FromPC.Point_CheckCamera[{0}].Y_Velocity";
+            Out_CheckCamera.Z_Position_Start.Address = "ns=4;s=DB_Communication|FromPC.Point_CheckCamera[{0}].Z_Position_Start";
+            Out_CheckCamera.Z_Velocity_Start.Address = "ns=4;s=DB_Communication|FromPC.Point_CheckCamera[{0}].Z_Velocity_Start";
+            Out_CheckCamera.Z_Position_Stop.Address = "ns=4;s=DB_Communication|FromPC.Point_CheckCamera[{0}].Z_Position_Stop";
+            Out_CheckCamera.Z_Velocity_Stop.Address = "ns=4;s=DB_Communication|FromPC.Point_CheckCamera[{0}].Z_Velocity_Stop";
+            Out_CheckCamera.U_Position.Address = "ns=4;s=DB_Communication|FromPC.Point_CheckCamera[{0}].U_Position";
+            Out_CheckCamera.U_Velocity.Address = "ns=4;s=DB_Communication|FromPC.Point_CheckCamera[{0}].U_Velocity";
+            Out_CheckCamera.R_Position.Address = "ns=4;s=DB_Communication|FromPC.Point_CheckCamera[{0}].R_Position";
+            Out_CheckCamera.R_Velocity.Address = "ns=4;s=DB_Communication|FromPC.Point_CheckCamera[{0}].R_Velocity";
+            Out_CheckCamera.Torque.Address = "ns=4;s=DB_Communication|FromPC.Point_CheckCamera[{0}].Torque";
+            Out_CheckCamera.Feeder.Address = "ns=4;s=DB_Communication|FromPC.Point_CheckCamera[{0}].Feeder";
+            Out_CheckCamera.ScrewProNum.Address = "ns=4;s=DB_Communication|FromPC.Point_CheckCamera[{0}].ScrewProNum";
 
             // 4. In_* 默认(假定从 PLC 读到 PC,使用 ToPC 前缀)
             In_Code = Ensure(In_Code);