Bläddra i källkod

Merge branch 'master' of http://49.235.130.76/XXF_1122/DaisyNPILine

徐孝锋 8 månader sedan
förälder
incheckning
8d9a198e47

+ 123 - 2
TeamAAS-VM/Core/Management.cs

@@ -369,7 +369,7 @@ namespace TeamAAS_VP.Core
             }
             catch (Exception ex)
             {
-                LogHelper.WriteLogError("为PLC写入系统参数和订阅变量时出错", ex);
+                LogHelper.WriteLogError(Lang.为PLC写入系统参数和订阅变量时出错, ex);
             }
             if (sb.Length == 0)
             {
@@ -1180,7 +1180,19 @@ namespace TeamAAS_VP.Core
         PointF[] DowmCameraResults = new PointF[10];
         PointF[] UpCameraPutResults = new PointF[10];
 
-
+        bool _LastDowmCameraExe = false;
+        bool _LastScrewTeachExe = false;
+        bool _LastUpCameraPickExe = false;
+        bool _LastUpCameraPutExe = false;
+        bool _LastUPCameracheckExe = false;
+        bool _LastFixedCameraPickExe = false;
+        bool _LastFixedCameraPutExe = false;
+        bool _LastFixedCameracheckExe = false;
+        Int16 _LastWorkStart = 0;
+        Int16 _LastWorkDone = 0;
+        Int16 _LastRequestPosition = 0;
+        Int16[] _LastMesCheck = new Int16[10];
+        Int16 _LastPickINC = 0;
         /// <summary>
         /// PLC命令触发时
         /// </summary>
@@ -1217,6 +1229,15 @@ namespace TeamAAS_VP.Core
                 {
                     if (tuple.value is bool state)
                     {
+                        if (_LastDowmCameraExe != state)
+                        {
+                            _LastDowmCameraExe = state;
+                        }
+                        else
+                        {
+                            return;
+                        }
+
                         if (state)
                         {
                             SendTaskMessage($"触发下相机拍照...", MessageLevel.Debug);
@@ -1275,6 +1296,15 @@ namespace TeamAAS_VP.Core
                 {
                     if (tuple.value is bool state)
                     {
+                        if (_LastScrewTeachExe != state)
+                        {
+                            _LastScrewTeachExe = state;
+                        }
+                        else
+                        {
+                            return;
+                        }
+
                         if (state)
                         {
                             SendTaskMessage($"触发下相机拍照...", MessageLevel.Debug);
@@ -1333,6 +1363,15 @@ namespace TeamAAS_VP.Core
                 {
                     if (tuple.value is bool state)
                     {
+                        if (_LastUpCameraPickExe != state)
+                        {
+                            _LastUpCameraPickExe = state;
+                        }
+                        else
+                        {
+                            return;
+                        }
+
                         if (state)
                         {
                             SendTaskMessage($"触发上相机取料拍照...", MessageLevel.Debug);
@@ -1354,6 +1393,15 @@ namespace TeamAAS_VP.Core
                 {
                     if (tuple.value is bool state)
                     {
+                        if (_LastUpCameraPutExe != state)
+                        {
+                            _LastUpCameraPutExe = state;
+                        }
+                        else
+                        {
+                            return;
+                        }
+
                         if (state)
                         {
                             SendTaskMessage($"触发上相机锁附/组装拍照...", MessageLevel.Debug);
@@ -1408,6 +1456,14 @@ namespace TeamAAS_VP.Core
                 {
                     if (tuple.value is bool state)
                     {
+                        if (_LastUPCameracheckExe != state)
+                        {
+                            _LastUPCameracheckExe = state;
+                        }
+                        else
+                        {
+                            return;
+                        }
                         if (state)
                         {
                             SendTaskMessage($"触发上相机检测拍照...", MessageLevel.Debug);
@@ -1430,6 +1486,14 @@ namespace TeamAAS_VP.Core
                 {
                     if (tuple.value is bool state)
                     {
+                        if (_LastFixedCameraPickExe != state)
+                        {
+                            _LastFixedCameraPickExe = state;
+                        }
+                        else
+                        {
+                            return;
+                        }
                         if (state)
                         {
                             SendTaskMessage($"触发固定相机取料拍照...", MessageLevel.Debug);
@@ -1452,6 +1516,14 @@ namespace TeamAAS_VP.Core
                 {
                     if (tuple.value is bool state)
                     {
+                        if (_LastFixedCameraPutExe != state)
+                        {
+                            _LastFixedCameraPutExe = state;
+                        }
+                        else
+                        {
+                            return;
+                        }
                         if (state)
                         {
                             SendTaskMessage($"触发固定相机锁附/组装拍照...", MessageLevel.Debug);
@@ -1473,6 +1545,14 @@ namespace TeamAAS_VP.Core
                 {
                     if (tuple.value is bool state)
                     {
+                        if (_LastFixedCameracheckExe != state)
+                        {
+                            _LastFixedCameracheckExe = state;
+                        }
+                        else
+                        {
+                            return;
+                        }
                         if (state)
                         {
                             SendTaskMessage($"触发固定相机检测拍照...", MessageLevel.Debug);
@@ -1494,6 +1574,14 @@ namespace TeamAAS_VP.Core
                 {
                     if (tuple.value is Int16 state)
                     {
+                        if (_LastWorkStart != state)
+                        {
+                            _LastWorkStart = state;
+                        }
+                        else
+                        {
+                            return;
+                        }
                         if (state == 1)
                         {
                             SendTaskMessage($"收到开始锁付信号...", MessageLevel.Debug);
@@ -1513,6 +1601,14 @@ namespace TeamAAS_VP.Core
                 {
                     if (tuple.value is Int16 state)
                     {
+                        if (_LastWorkDone != state)
+                        {
+                            _LastWorkDone = state;
+                        }
+                        else
+                        {
+                            return;
+                        }
                         if (state == 1 || state == 2)
                         {
                             SendTaskMessage($"收到停止锁付信号...", MessageLevel.Debug);
@@ -1589,6 +1685,14 @@ namespace TeamAAS_VP.Core
                 {
                     if (tuple.value is Int16 state)
                     {
+                        if (_LastRequestPosition != state)
+                        {
+                            _LastRequestPosition = state;
+                        }
+                        else
+                        {
+                            return;
+                        }
                         if (state == 1)
                         {
                             SendTaskMessage($"收到多相机坐标合并请求,开始合并...", MessageLevel.Debug);
@@ -1638,6 +1742,14 @@ namespace TeamAAS_VP.Core
                 {
                     if (tuple.value is Int16 state)
                     {
+                        if (_LastPickINC != state)
+                        {
+                            _LastPickINC = state;
+                        }
+                        else
+                        {
+                            return;
+                        }
                         if (state != 0)
                         {
                             SendTaskMessage($"螺丝供料器...", MessageLevel.Info);
@@ -1670,6 +1782,15 @@ namespace TeamAAS_VP.Core
                         {
                             if (tuple.value is Int16 state)
                             {
+                                if (_LastMesCheck[i] != state)
+                                {
+                                    _LastMesCheck[i] = state;
+                                }
+                                else
+                                {
+                                    return;
+                                }
+
                                 if (state == 1)
                                 {
                                     if(i == 0)

+ 11 - 11
TeamAAS-VM/Core/Robots/XYZU_Robot.cs

@@ -747,11 +747,11 @@ namespace TeamAAS_VP.Core.Robots
                 {
                     isError = (bool)res[axis.State.PausedNode];
                 }
-                if (isError)
-                {
-                    isAnyError = true;
-                    break;
-                }
+                //if (isError)
+                //{
+                //    isAnyError = true;
+                //    break;
+                //}
                 //检查是否到位和位置一致
                 float targetPos = 0;
                 switch (axis.Name)
@@ -763,13 +763,13 @@ namespace TeamAAS_VP.Core.Robots
                     default: targetPos = 0; break;
                 }
                 //如果定位完成且位置一致,则此轴完成,如果有错误则失败
-                if (!(posOk && Math.Abs(actualPos - targetPos) < 0.02))
+                if (!(Math.Abs(actualPos - targetPos) < 0.02))
                 {
-                    if (isError)
-                    {
-                        isAnyError = true;
-                        break;
-                    }
+                    //if (isError)
+                    //{
+                    //    isAnyError = true;
+                    //    break;
+                    //}
                     allOk = false;
                     break;
                 }

+ 2 - 2
TeamAAS-VM/Properties/AssemblyInfo.cs

@@ -51,5 +51,5 @@ using System.Windows;
 //可以指定所有这些值,也可以使用“生成号”和“修订号”的默认值
 //通过使用 "*",如下所示:
 // [assembly: AssemblyVersion("1.0.*")]
-[assembly: AssemblyVersion("1.2.0.4")]
-[assembly: AssemblyFileVersion("1.2.0.4")]
+[assembly: AssemblyVersion("1.2.0.5")]
+[assembly: AssemblyFileVersion("1.2.0.5")]

+ 28 - 1
TeamAAS-VM/Resources/Languages/Lang.Designer.cs

@@ -19,7 +19,7 @@ namespace TeamAAS_VP.Resources.Languages {
     // 类通过类似于 ResGen 或 Visual Studio 的工具自动生成的。
     // 若要添加或移除成员,请编辑 .ResX 文件,然后重新运行 ResGen
     // (以 /str 作为命令选项),或重新生成 VS 项目。
-    [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "17.0.0.0")]
+    [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "18.0.0.0")]
     [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
     [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
     public class Lang {
@@ -1320,6 +1320,15 @@ namespace TeamAAS_VP.Resources.Languages {
             }
         }
         
+        /// <summary>
+        ///   查找类似 为PLC写入系统参数和订阅变量时出错 的本地化字符串。
+        /// </summary>
+        public static string 为PLC写入系统参数和订阅变量时出错 {
+            get {
+                return ResourceManager.GetString("为PLC写入系统参数和订阅变量时出错", resourceCulture);
+            }
+        }
+        
         /// <summary>
         ///   查找类似 二次定位相机测试 的本地化字符串。
         /// </summary>
@@ -2787,6 +2796,15 @@ namespace TeamAAS_VP.Resources.Languages {
             }
         }
         
+        /// <summary>
+        ///   查找类似 导入点位 的本地化字符串。
+        /// </summary>
+        public static string 导入点位 {
+            get {
+                return ResourceManager.GetString("导入点位", resourceCulture);
+            }
+        }
+        
         /// <summary>
         ///   查找类似 导出当前页 的本地化字符串。
         /// </summary>
@@ -5370,6 +5388,15 @@ namespace TeamAAS_VP.Resources.Languages {
             }
         }
         
+        /// <summary>
+        ///   查找类似 确认要从点位编号 {0} 开始导入 {1} 个点位吗? 的本地化字符串。
+        /// </summary>
+        public static string 确认要从点位编号0开始导入1个点位吗 {
+            get {
+                return ResourceManager.GetString("确认要从点位编号0开始导入1个点位吗", resourceCulture);
+            }
+        }
+        
         /// <summary>
         ///   查找类似 示教 的本地化字符串。
         /// </summary>

+ 9 - 0
TeamAAS-VM/Resources/Languages/Lang.resx

@@ -2612,4 +2612,13 @@
   <data name="设置吸嘴报警值" xml:space="preserve">
     <value>设置吸嘴报警值</value>
   </data>
+  <data name="为PLC写入系统参数和订阅变量时出错" xml:space="preserve">
+    <value>为PLC写入系统参数和订阅变量时出错</value>
+  </data>
+  <data name="确认要从点位编号0开始导入1个点位吗" xml:space="preserve">
+    <value>确认要从点位编号 {0} 开始导入 {1} 个点位吗?</value>
+  </data>
+  <data name="导入点位" xml:space="preserve">
+    <value>导入点位</value>
+  </data>
 </root>

+ 222 - 57
TeamAAS-VM/Services/CameraCalibrationService.cs

@@ -62,7 +62,11 @@ namespace TeamAAS_VP.Services
             Matrix<double> RobotCameraRotationMatrix = null;
 
             //移动机器人至待机位置
-            await robot.CalibMotionAsync(calibrationInfo.HomePoint, 0);
+            bool isSuccess = await robot.CalibMotionAsync(calibrationInfo.HomePoint, 0);
+            if (!isSuccess)
+            {
+                return (false, null, 0, 0, 0, 0);
+            }
             if (cancellationToken.IsCancellationRequested)
             {
                 return (false, null, 0, 0, 0, 0);
@@ -108,7 +112,11 @@ namespace TeamAAS_VP.Services
             RPoint RobotU = calibrationInfo.CenterPoint.Clone();
             RobotU.U += (float)calibrationInfo.Angle;
             //移动机器人中心点
-            await robot.CalibMotionAsync(calibrationInfo.CenterPoint, 0);
+            isSuccess = await robot.CalibMotionAsync(calibrationInfo.CenterPoint, 0);
+            if (!isSuccess)
+            {
+                return (false, null, 0, 0, 0, 0);
+            }
             if (cancellationToken.IsCancellationRequested)
             {
                 return (false, null, 0, 0, 0, 0);
@@ -117,7 +125,11 @@ namespace TeamAAS_VP.Services
             await robot.CalibOutIOAsync(true);
 
             //机器人U轴旋转
-            await robot.CalibMotionAsync(RobotU, 0);
+            isSuccess = await robot.CalibMotionAsync(RobotU, 0);
+            if (!isSuccess)
+            {
+                return (false, null, 0, 0, 0, 0);
+            }
             if (cancellationToken.IsCancellationRequested)
             {
                 return (false, null, 0, 0, 0, 0);
@@ -126,7 +138,11 @@ namespace TeamAAS_VP.Services
             //关闭吸气
             await robot.CalibOutIOAsync(false);
             //移动机器人至待机位置
-            await robot.CalibMotionAsync(calibrationInfo.HomePoint, 0);
+            isSuccess = await robot.CalibMotionAsync(calibrationInfo.HomePoint, 0);
+            if (!isSuccess)
+            {
+                return (false, null, 0, 0, 0, 0);
+            }
             if (cancellationToken.IsCancellationRequested)
             {
                 return (false, null, 0, 0, 0, 0);
@@ -148,7 +164,11 @@ namespace TeamAAS_VP.Services
                 double offsety = (P0.Y - curPixel.Y) * pixelScaleY;
                 var pos = RobotCameraRotationMatrix.Inverse() * Vector<double>.Build.Dense(new double[] { offsetx, offsety });
                 //移动机器人取标定块
-                await robot.CalibMotionAsync(RobotU, 0);
+                isSuccess = await robot.CalibMotionAsync(RobotU, 0);
+                if (!isSuccess)
+                {
+                    return (false, null, 0, 0, 0, 0);
+                }
                 if (cancellationToken.IsCancellationRequested)
                 {
                     return (false, null, 0, 0, 0, 0);
@@ -159,7 +179,11 @@ namespace TeamAAS_VP.Services
                 RobotU.X += (float)pos[0];
                 RobotU.Y += (float)pos[1];
                 //机器人移动
-                await robot.CalibMotionAsync(RobotU, 0);
+                isSuccess = await robot.CalibMotionAsync(RobotU, 0);
+                if (!isSuccess)
+                {
+                    return (false, null, 0, 0, 0, 0);
+                }
                 if (cancellationToken.IsCancellationRequested)
                 {
                     return (false, null, 0, 0, 0, 0);
@@ -168,7 +192,11 @@ namespace TeamAAS_VP.Services
                 //关闭吸气
                 await robot.CalibOutIOAsync(false);
                 //移动机器人至待机位置
-                await robot.CalibMotionAsync(calibrationInfo.HomePoint, 0);
+                isSuccess = await robot.CalibMotionAsync(calibrationInfo.HomePoint, 0);
+                if (!isSuccess)
+                {
+                    return (false, null, 0, 0, 0, 0);
+                }
                 if (cancellationToken.IsCancellationRequested)
                 {
                     return (false, null, 0, 0, 0, 0);
@@ -186,7 +214,11 @@ namespace TeamAAS_VP.Services
                 if (Math.Abs(offsetx) < 1 && Math.Abs(offsetx) < 1)
                 {
                     //移动机器人取标定块
-                    await robot.CalibMotionAsync(RobotU, 0);
+                    isSuccess = await robot.CalibMotionAsync(RobotU, 0);
+                    if (!isSuccess)
+                    {
+                        return (false, null, 0, 0, 0, 0);
+                    }
                     if (cancellationToken.IsCancellationRequested)
                     {
                         return (false, null, 0, 0, 0, 0);
@@ -194,7 +226,11 @@ namespace TeamAAS_VP.Services
                     //打开吸气
                     await robot.CalibOutIOAsync(true);
                     //移动机器人至待机位置
-                    await robot.CalibMotionAsync(calibrationInfo.HomePoint, 0);
+                    isSuccess = await robot.CalibMotionAsync(calibrationInfo.HomePoint, 0);
+                    if (!isSuccess)
+                    {
+                        return (false, null, 0, 0, 0, 0);
+                    }
                     IsFinish = true;
                     break;
                 }
@@ -246,7 +282,11 @@ namespace TeamAAS_VP.Services
             Matrix<double> RobotCameraRotationMatrix = null;
 
             //移动机器人至中心位置
-            await robot.CalibMotionAsync(calibrationInfo.CenterPoint, 0);
+            bool isSuccess = await robot.CalibMotionAsync(calibrationInfo.CenterPoint, 0);
+            if (!isSuccess)
+            {
+                return (false, null, 0, 0, 0, 0);
+            }
 
             //计算相机与机器人坐标系的旋转矩阵
             var robotCameraRotationMatrix = await AutoIdentifyRobotCameraRotationMatrix(calibrationInfo, robot, cancellationToken);
@@ -271,7 +311,11 @@ namespace TeamAAS_VP.Services
             RobotU.U += (float)calibrationInfo.Angle;
 
             //机器人U轴旋转
-            await robot.CalibMotionAsync(RobotU, RobotU.Z);
+            isSuccess = await robot.CalibMotionAsync(RobotU, RobotU.Z);
+            if (!isSuccess)
+            {
+                return (false, null, 0, 0, 0, 0);
+            }
             if (cancellationToken.IsCancellationRequested)
             {
                 return (false, null, 0, 0, 0, 0);
@@ -330,7 +374,11 @@ namespace TeamAAS_VP.Services
             Matrix<double> RobotCameraRotationMatrix = null;
 
             //移动机器人至中心位置
-            await robot.CalibMotionAsync(calibrationInfo.CenterPoint, 0);
+            bool isSuccess = await robot.CalibMotionAsync(calibrationInfo.CenterPoint, 0);
+            if (!isSuccess)
+            {
+                return (false, null, 0, 0, 0, 0);
+            }
 
             if (calibrationInfo.Pick.PickPlaceModel == Enums.PickPlaceModel.Inhal)
             {
@@ -353,14 +401,14 @@ namespace TeamAAS_VP.Services
             }
 
             //计算相机与机器人坐标系的旋转矩阵
-            var robotCameraRotationMatrix= await AutoIdentifyRobotCameraRotationMatrix(calibrationInfo, robot, cancellationToken);
+            var robotCameraRotationMatrix = await AutoIdentifyRobotCameraRotationMatrix(calibrationInfo, robot, cancellationToken);
             if (!robotCameraRotationMatrix.IsSuccess)
             {
                 return (false, null, 0, 0, 0, 0);
             }
-            pixelScaleX= robotCameraRotationMatrix.PixelScaleX;
-            pixelScaleY= robotCameraRotationMatrix.PixelScaleY;
-            RobotCameraRotationMatrix= robotCameraRotationMatrix.Item2;
+            pixelScaleX = robotCameraRotationMatrix.PixelScaleX;
+            pixelScaleY = robotCameraRotationMatrix.PixelScaleY;
+            RobotCameraRotationMatrix = robotCameraRotationMatrix.Item2;
 
             //自动移动机器人至图像中心点位置
             var autoMoveResult = await AutoMoveRobotToImageCenter(robot, RobotCameraRotationMatrix, pixelScaleX, pixelScaleY, cancellationToken);
@@ -368,16 +416,20 @@ namespace TeamAAS_VP.Services
             {
                 return (false, null, 0, 0, 0, 0);
             }
-            calibrationInfo.CenterPoint.X= (float)autoMoveResult.X;
-            calibrationInfo.CenterPoint.Y= (float)autoMoveResult.Y;
+            calibrationInfo.CenterPoint.X = (float)autoMoveResult.X;
+            calibrationInfo.CenterPoint.Y = (float)autoMoveResult.Y;
 
 
             RPoint RobotU = calibrationInfo.CenterPoint.Clone();
             RobotU.U += (float)calibrationInfo.Angle;
 
             //机器人U轴旋转
-            await robot.CalibMotionAsync(RobotU, RobotU.Z);
-            if(cancellationToken.IsCancellationRequested)
+            isSuccess = await robot.CalibMotionAsync(RobotU, RobotU.Z);
+            if (!isSuccess)
+            {
+                return (false, null, 0, 0, 0, 0);
+            }
+            if (cancellationToken.IsCancellationRequested)
             {
                 return (false, null, 0, 0, 0, 0);
             }
@@ -442,7 +494,7 @@ namespace TeamAAS_VP.Services
             (bool IsSuccess, Matrix<double> RotationMatrix, double ToolX, double ToolY, double PixelScaleX, double PixelScaleY) calibresult;
             if (calibrationInfo.CameraMount == Enums.CameraMount.FixedDown)
             {
-                calibresult = await CalibrateFixedDownCameraTool(calibrationInfo,robot,cancellationToken);
+                calibresult = await CalibrateFixedDownCameraTool(calibrationInfo, robot, cancellationToken);
             }
             else if (calibrationInfo.CameraMount == Enums.CameraMount.FixedUp)
             {
@@ -460,10 +512,10 @@ namespace TeamAAS_VP.Services
             {
                 return (false, null, 0, 0, 0, 0);
             }
-            
-            pixelScaleX= calibresult.PixelScaleX;
-            pixelScaleY= calibresult.PixelScaleY;
-            RobotCameraRotationMatrix= calibresult.RotationMatrix;
+
+            pixelScaleX = calibresult.PixelScaleX;
+            pixelScaleY = calibresult.PixelScaleY;
+            RobotCameraRotationMatrix = calibresult.RotationMatrix;
 
             return (true, RobotCameraRotationMatrix, calibresult.ToolX, calibresult.ToolY, pixelScaleX, pixelScaleY);
         }
@@ -489,16 +541,24 @@ namespace TeamAAS_VP.Services
 
             //-------------------------------------------P0-----------------------------------
             //移动机器人至中心点
-
+            bool isSuccess = false;
             if (calibrationInfo.CameraMount == Enums.CameraMount.FixedDown)
             {
-                await robot.CalibMotionAsync(calibrationInfo.CenterPoint, 0);
+                isSuccess = await robot.CalibMotionAsync(calibrationInfo.CenterPoint, 0);
+                if (!isSuccess)
+                {
+                    return (false, null, 0, 0);
+                }
                 //关闭吸气
                 await robot.CalibOutIOAsync(false);
             }
             else
             {
-                await robot.CalibMotionAsync(calibrationInfo.CenterPoint, calibrationInfo.CenterPoint.Z);
+                isSuccess = await robot.CalibMotionAsync(calibrationInfo.CenterPoint, calibrationInfo.CenterPoint.Z);
+                if (!isSuccess)
+                {
+                    return (false, null, 0, 0);
+                }
             }
 
 
@@ -511,7 +571,11 @@ namespace TeamAAS_VP.Services
             if (calibrationInfo.CameraMount == Enums.CameraMount.FixedDown)
             {
                 //移动机器人至待机位置
-                await robot.CalibMotionAsync(calibrationInfo.HomePoint, 0);
+                isSuccess = await robot.CalibMotionAsync(calibrationInfo.HomePoint, 0);
+                if (!isSuccess)
+                {
+                    return (false, null, 0, 0);
+                }
             }
 
             //相机拍照并处理图像
@@ -526,15 +590,23 @@ namespace TeamAAS_VP.Services
             if (calibrationInfo.CameraMount == Enums.CameraMount.FixedDown)
             {
                 //移动机器人至P0
-                await robot.CalibMotionAsync(RobotP0, 0);
-                if(cancellationToken.IsCancellationRequested)
+                isSuccess = await robot.CalibMotionAsync(RobotP0, 0);
+                if (!isSuccess)
+                {
+                    return (false, null, 0, 0);
+                }
+                if (cancellationToken.IsCancellationRequested)
                 {
                     return (false, null, 0, 0);
                 }
                 //打开吸气
                 await robot.CalibOutIOAsync(true);
                 //移动机器人至P1
-                await robot.CalibMotionAsync(RobotP1, 0);
+                isSuccess = await robot.CalibMotionAsync(RobotP1, 0);
+                if (!isSuccess)
+                {
+                    return (false, null, 0, 0);
+                }
                 if (cancellationToken.IsCancellationRequested)
                 {
                     return (false, null, 0, 0);
@@ -542,12 +614,20 @@ namespace TeamAAS_VP.Services
                 //关闭吸气
                 await robot.CalibOutIOAsync(false);
                 //移动机器人至待机位置
-                await robot.CalibMotionAsync(calibrationInfo.HomePoint, 0);
+                isSuccess = await robot.CalibMotionAsync(calibrationInfo.HomePoint, 0);
+                if (!isSuccess)
+                {
+                    return (false, null, 0, 0);
+                }
             }
             else
             {
                 //移动机器人至P1
-                await robot.CalibMotionAsync(RobotP1, RobotP1.Z);
+                isSuccess = await robot.CalibMotionAsync(RobotP1, RobotP1.Z);
+                if (!isSuccess)
+                {
+                    return (false, null, 0, 0);
+                }
             }
 
             if (cancellationToken.IsCancellationRequested)
@@ -567,7 +647,11 @@ namespace TeamAAS_VP.Services
             if (calibrationInfo.CameraMount == Enums.CameraMount.FixedDown)
             {
                 //移动机器人至P1
-                await robot.CalibMotionAsync(RobotP1, 0);
+                isSuccess = await robot.CalibMotionAsync(RobotP1, 0);
+                if (!isSuccess)
+                {
+                    return (false, null, 0, 0);
+                }
                 if (cancellationToken.IsCancellationRequested)
                 {
                     return (false, null, 0, 0);
@@ -575,7 +659,11 @@ namespace TeamAAS_VP.Services
                 //打开吸气
                 await robot.CalibOutIOAsync(true);
                 //移动机器人至P2
-                await robot.CalibMotionAsync(RobotP2, 0);
+                isSuccess = await robot.CalibMotionAsync(RobotP2, 0);
+                if (!isSuccess)
+                {
+                    return (false, null, 0, 0);
+                }
                 if (cancellationToken.IsCancellationRequested)
                 {
                     return (false, null, 0, 0);
@@ -583,12 +671,20 @@ namespace TeamAAS_VP.Services
                 //关闭吸气
                 await robot.CalibOutIOAsync(false);
                 //移动机器人至待机位置
-                await robot.CalibMotionAsync(calibrationInfo.HomePoint, 0);
+                isSuccess = await robot.CalibMotionAsync(calibrationInfo.HomePoint, 0);
+                if (!isSuccess)
+                {
+                    return (false, null, 0, 0);
+                }
             }
             else
             {
                 //移动机器人至P2
-                await robot.CalibMotionAsync(RobotP2, RobotP2.Z);
+                isSuccess = await robot.CalibMotionAsync(RobotP2, RobotP2.Z);
+                if (!isSuccess)
+                {
+                    return (false, null, 0, 0);
+                }
             }
             if (cancellationToken.IsCancellationRequested)
             {
@@ -608,7 +704,11 @@ namespace TeamAAS_VP.Services
             if (calibrationInfo.CameraMount == Enums.CameraMount.FixedDown)
             {
                 //移动机器人至P2
-                await robot.CalibMotionAsync(RobotP2, 0);
+                isSuccess = await robot.CalibMotionAsync(RobotP2, 0);
+                if (!isSuccess)
+                {
+                    return (false, null, 0, 0);
+                }
                 if (cancellationToken.IsCancellationRequested)
                 {
                     return (false, null, 0, 0);
@@ -616,7 +716,11 @@ namespace TeamAAS_VP.Services
                 //打开吸气
                 await robot.CalibOutIOAsync(true);
                 //移动机器人至P0
-                await robot.CalibMotionAsync(RobotP0, 0);
+                isSuccess = await robot.CalibMotionAsync(RobotP0, 0);
+                if (!isSuccess)
+                {
+                    return (false, null, 0, 0);
+                }
                 if (cancellationToken.IsCancellationRequested)
                 {
                     return (false, null, 0, 0);
@@ -624,12 +728,20 @@ namespace TeamAAS_VP.Services
                 //关闭吸气
                 await robot.CalibOutIOAsync(false);
                 //移动机器人至待机位置
-                await robot.CalibMotionAsync(calibrationInfo.HomePoint, 0);
+                isSuccess = await robot.CalibMotionAsync(calibrationInfo.HomePoint, 0);
+                if (!isSuccess)
+                {
+                    return (false, null, 0, 0);
+                }
             }
             else
             {
                 //移动机器人至P0
-                await robot.CalibMotionAsync(RobotP0, RobotP0.Z);
+                isSuccess = await robot.CalibMotionAsync(RobotP0, RobotP0.Z);
+                if (!isSuccess)
+                {
+                    return (false, null, 0, 0);
+                }
             }
             if (cancellationToken.IsCancellationRequested)
             {
@@ -713,7 +825,11 @@ namespace TeamAAS_VP.Services
                 curpos.X += (float)pos[0];
                 curpos.Y += (float)pos[1];
                 //机器人移动
-                await robot.CalibMotionAsync(curpos, curpos.Z);
+                bool isSuccess = await robot.CalibMotionAsync(curpos, curpos.Z);
+                if (!isSuccess)
+                {
+                    return (false, 0, 0, 0);
+                }
 
                 result = await CaptureAndProcessCallback();
                 if (!result.IsSuccess)
@@ -780,12 +896,17 @@ namespace TeamAAS_VP.Services
             //发送校准的参数
             await robot.CalibParameAsync(calibrationInfo.Pick, calibrationInfo.Speed, calibrationInfo.Accel, calibrationInfo.Power, calibrationInfo.WaitSuction, calibrationInfo.WaitBlow);
 
+            bool isSuccess = false;
             var P0 = Vector<double>.Build.Dense(new double[] { calibrationInfo.CenterPoint.X, calibrationInfo.CenterPoint.Y });
             if (robot.Brand == Enums.RobotBrand.XYZ_Platform)
             {
 
                 //移动机器人至中心位置
-                await robot.CalibMotionAsync(calibrationInfo.CenterPoint, 0);
+                isSuccess=await robot.CalibMotionAsync(calibrationInfo.CenterPoint, 0);
+                if (!isSuccess)
+                {
+                    return (false, null, null, null);
+                }
                 if (cancellationToken.IsCancellationRequested)
                 {
                     return (false, null, null, null);
@@ -808,7 +929,7 @@ namespace TeamAAS_VP.Services
                 {
                     calibrationInfo.MarkPoint = calibrationInfo.CenterPoint.Clone();
                 }
-                
+
                 calibrationInfo.RobotCameraRotationMatrix = robotCameraRotationMatrix.RotationMatrix.ToArray();
             }
 
@@ -967,7 +1088,11 @@ namespace TeamAAS_VP.Services
             if (calibrationInfo.CameraMount == Enums.CameraMount.MobileJ4)
             {
                 //移动机器人至中心位置
-                await robot.CalibMotionAsync(calibrationInfo.CenterPoint, 0);
+                isSuccess= await robot.CalibMotionAsync(calibrationInfo.CenterPoint, 0);
+                if (!isSuccess)
+                {
+                    return (false, null, null, null);
+                }
                 if (cancellationToken.IsCancellationRequested)
                 {
                     return (false, null, null, null);
@@ -993,7 +1118,11 @@ namespace TeamAAS_VP.Services
                 //移动机器人至i
                 if (calibrationInfo.CameraMount == Enums.CameraMount.FixedDown)
                 {
-                    await robot.CalibMotionAsync(rPoints[i], 0);
+                    isSuccess= await robot.CalibMotionAsync(rPoints[i], 0);
+                    if (!isSuccess)
+                    {
+                        return (false, null, null, null);
+                    }
                     if (cancellationToken.IsCancellationRequested)
                     {
                         return (false, null, null, null);
@@ -1001,11 +1130,19 @@ namespace TeamAAS_VP.Services
                     //关闭吸气
                     await robot.CalibOutIOAsync(false);
                     //移动机器人至待机位置
-                    await robot.CalibMotionAsync(calibrationInfo.HomePoint, 0);
+                    isSuccess= await robot.CalibMotionAsync(calibrationInfo.HomePoint, 0);
+                    if (!isSuccess)
+                    {
+                        return (false, null, null, null);
+                    }
                 }
                 else
                 {
-                    await robot.CalibMotionAsync(rPoints[i], rPoints[i].Z);
+                    isSuccess= await robot.CalibMotionAsync(rPoints[i], rPoints[i].Z);
+                    if (!isSuccess)
+                    {
+                        return (false, null, null, null);
+                    }
                 }
                 if (cancellationToken.IsCancellationRequested)
                 {
@@ -1024,7 +1161,11 @@ namespace TeamAAS_VP.Services
                 if (calibrationInfo.CameraMount == Enums.CameraMount.FixedDown)
                 {
                     //移动机器人至i
-                    await robot.CalibMotionAsync(rPoints[i], 0);
+                    isSuccess= await robot.CalibMotionAsync(rPoints[i], 0);
+                    if (!isSuccess)
+                    {
+                        return (false, null, null, null);
+                    }
                     if (cancellationToken.IsCancellationRequested)
                     {
                         return (false, null, null, null);
@@ -1047,7 +1188,11 @@ namespace TeamAAS_VP.Services
             if (calibrationInfo.CameraMount == Enums.CameraMount.FixedDown)
             {
                 //移动机器人至待机位置
-                await robot.CalibMotionAsync(calibrationInfo.HomePoint, 0);
+                isSuccess = await robot.CalibMotionAsync(calibrationInfo.HomePoint, 0);
+                if (!isSuccess)
+                {
+                    return (false, null, null, null);
+                }
             }
 
             if (cancellationToken.IsCancellationRequested)
@@ -1285,14 +1430,18 @@ namespace TeamAAS_VP.Services
                 Local = calibrationInfo.CenterPoint.Local,
                 Tool = calibrationInfo.CenterPoint.Tool
             });
-
+            bool isSuccess = false;
             List<Vector<double>> TestPos = new List<Vector<double>>();
             for (int i = 0; i < rPoints.Count; i++)
             {
                 if (calibrationInfo.CameraMount == Enums.CameraMount.FixedDown)
                 {
                     //移动机器人至i
-                    await robot.CalibMotionAsync(rPoints[i], 0);
+                    isSuccess= await robot.CalibMotionAsync(rPoints[i], 0);
+                    if (!isSuccess)
+                    {
+                        return (false, null);
+                    }
                     if (cancellationToken.IsCancellationRequested)
                     {
                         return (false, null);
@@ -1300,12 +1449,20 @@ namespace TeamAAS_VP.Services
                     //关闭吸气
                     await robot.CalibOutIOAsync(false);
                     //移动机器人至待机位置
-                    await robot.CalibMotionAsync(calibrationInfo.HomePoint, 0);
+                    isSuccess= await robot.CalibMotionAsync(calibrationInfo.HomePoint, 0);
+                    if (!isSuccess)
+                    {
+                        return (false, null);
+                    }
                 }
                 else
                 {
                     //移动机器人至i
-                    await robot.CalibMotionAsync(rPoints[i], rPoints[i].Z);
+                     isSuccess = await robot.CalibMotionAsync(rPoints[i], rPoints[i].Z);
+                    if (!isSuccess)
+                    {
+                        return (false, null);
+                    }
                 }
                 if (cancellationToken.IsCancellationRequested)
                 {
@@ -1326,7 +1483,11 @@ namespace TeamAAS_VP.Services
                 if (calibrationInfo.CameraMount == Enums.CameraMount.FixedDown)
                 {
                     //移动机器人至i
-                    await robot.CalibMotionAsync(rPoints[i], 0);
+                    isSuccess = await robot.CalibMotionAsync(rPoints[i], 0);
+                    if (!isSuccess)
+                    {
+                        return (false, null);
+                    }
                     //打开吸气
                     await robot.CalibOutIOAsync(true);
                 }
@@ -1340,7 +1501,11 @@ namespace TeamAAS_VP.Services
             if (calibrationInfo.CameraMount == Enums.CameraMount.FixedDown)
             {
                 //移动机器人至待机位置
-                await robot.CalibMotionAsync(calibrationInfo.HomePoint, 0);
+                isSuccess= await robot.CalibMotionAsync(calibrationInfo.HomePoint, 0);
+                if (!isSuccess)
+                {
+                    return (false, null);
+                }
             }
 
             //RMS(均方根值) 标定偏差

+ 1 - 1
TeamAAS-VM/ViewModels/Product/PlcPointParamsViewModel.cs

@@ -971,7 +971,7 @@ namespace TeamAAS_VP.ViewModels.Product
                         int startNumber = view.StartIndex;
 
                         //弹窗提示用户是否确认要导入从该编号开始的点位,点位数量为cadPoints.Count
-                        if (MessageBox.Show($"确认要从点位编号 {startNumber} 开始导入 {cadPoints.Count} 个点位吗?", "导入点位", MessageBoxButton.YesNo, MessageBoxImage.Question) != MessageBoxResult.Yes)
+                        if (MessageBox.Show( string.Format(Lang.确认要从点位编号0开始导入1个点位吗, startNumber, cadPoints.Count), Lang.导入点位, MessageBoxButton.YesNo, MessageBoxImage.Question) != MessageBoxResult.Yes)
                         {
                             return;
                         }

+ 26 - 1
TeamAAS-VM/Views/Calibration/CalibrationAuto.xaml.cs

@@ -1,4 +1,7 @@
-using System.Windows.Controls;
+using Cognex.VisionPro;
+using Cognex.VisionPro.Dimensioning;
+using System;
+using System.Windows.Controls;
 using TeamAAS_VP.ViewModels.Calibration;
 
 namespace TeamAAS_VP.Views.Calibration
@@ -20,6 +23,8 @@ namespace TeamAAS_VP.Views.Calibration
             this.display.BackColor = System.Drawing.SystemColors.ActiveCaption;
         }
 
+        private int _imageWidth;
+        private int _imageHeight;
         private void VM_PropertyChanged(object sender, System.ComponentModel.PropertyChangedEventArgs e)
         {
             try
@@ -27,10 +32,30 @@ namespace TeamAAS_VP.Views.Calibration
                 if (e.PropertyName == "Image")
                 {
                     this.display.Image = VM.Image;
+                    //图像中心点坐标
+                    _imageWidth = this.display.Image.Width;
+                    _imageHeight = this.display.Image.Height;
                 }
                 else if (e.PropertyName == "Graphic")
                 {
                     this.display.StaticGraphics.Clear();
+                    CogGraphicCollection graphic = new CogGraphicCollection();
+                    CogCreateLineTool line1 = new CogCreateLineTool();
+                    CogCreateLineTool line2 = new CogCreateLineTool();
+                    line1.InputImage = this.display.Image;
+                    line2.InputImage = this.display.Image;
+                    line1.Line.X = _imageWidth / 2;
+                    line1.Line.Y = _imageHeight / 2;
+                    line1.Line.Rotation = 0;
+                    line2.Line.X = _imageWidth / 2;
+                    line2.Line.Y = _imageHeight / 2;
+                    line2.Line.Rotation = Math.PI / 180 * 90;
+                    line1.Run();
+                    line2.Run();
+                    graphic.Add(line1.GetOutputLine());
+                    graphic.Add(line2.GetOutputLine());
+                    this.display.StaticGraphics.Clear();
+                    this.display.StaticGraphics.AddList(graphic, "");
                     if (VM.Graphic!=null)
                     {
                         this.display.StaticGraphics.AddList(VM.Graphic, "");

+ 1 - 1
TeamAAS-VM/Views/Calibration/CalibrationTeachCenterPoint.xaml

@@ -132,7 +132,7 @@
                            Grid.ColumnSpan="2"
                            Foreground="{DynamicResource PrimaryHueMidForegroundBrush}">
                     <TextBlock.Text>
-                        <MultiBinding StringFormat="{}X:{0:F3} mm Y:{1:F3} mm Z:{1:F3} mm">
+                        <MultiBinding StringFormat="{}X:{0:F3} mm Y:{1:F3} mm Z:{2:F3} mm">
                             <Binding Path="SelectCalibration.CenterPoint.X"
                                      TargetNullValue="0.000"
                                      FallbackValue="0.000" />