Browse Source

重构托盘点位示教与批量计算,支持多托盘

重构托盘点位管理,新增 PalletEx 扩展模型,PalletTool 支持自动计算所有点位。ViewModel 由单点属性改为多托盘结构,命令参数与逻辑同步调整。界面重构为多托盘分组,支持独立示教、移动和批量计算,提升灵活性与可维护性。
孝锋 徐 8 tháng trước cách đây
mục cha
commit
22e4480813

+ 221 - 0
TeamAAS-VM/Core/PalletTool.cs

@@ -12,6 +12,7 @@ using System.Text;
 using System.Threading.Tasks;
 using System.Windows.Controls;
 using TeamAAS_VP.Models;
+using TeamAAS_VP.Models.PLC;
 using TeamAAS_VP.Models.Robot;
 using Unity;
 
@@ -20,8 +21,11 @@ namespace TeamAAS_VP.Core
     public class PalletTool
     {
         private List<List<RPoint>> rPoints=new List<List<RPoint>>();
+        private List<List<PlcPoint>> plcPoints = new List<List<PlcPoint>>();
         public RPoint[] Points { get; set; }
+        public PlcPoint[] PlcPoints { get; set; }
         Pallet pallet;
+        PalletEx _pallet1;
         public PalletTool(Pallet pallet1) 
         {
             pallet= pallet1;
@@ -239,6 +243,223 @@ namespace TeamAAS_VP.Core
             }
         }
 
+        public PalletTool(PalletEx pallet1)
+        {
+            _pallet1 = pallet1;
+
+            //----------------------------------------计算旋转矩阵-----------------------------------------------------------------
+            Vector<double> p1 = Vector<double>.Build.Dense(new double[] { _pallet1.P0.X_Position, _pallet1.P0.Y_Position });
+            Vector<double> p2 = Vector<double>.Build.Dense(new double[] { _pallet1.P1.X_Position, _pallet1.P1.Y_Position });
+            Vector<double> p3 = Vector<double>.Build.Dense(new double[] { _pallet1.P2.X_Position, _pallet1.P2.Y_Position });
+            //计算正交时的X与Y轴的单位向量
+            Vector<double> E1 = (p2 - p1) / (p2 - p1).L2Norm();
+            Vector<double> E2 = (p3 - p1 - E1.DotProduct(p3 - p1) * E1) / (p3 - p1 - E1.DotProduct(p3 - p1) * E1).L2Norm();
+            //得到旋转矩阵
+            Matrix<double> R = Matrix<double>.Build.DenseOfColumnVectors(E1, E2);
+
+            //--------------------------------------计算切变矩阵--------------------------------------------------------
+            double a = (E1.DotProduct(p3 - p1) * E1).L2Norm() / (p3 - p1 - (E1.DotProduct(p3 - p1) * E1))[1];
+            Matrix<double> Shear = Matrix<double>.Build.DenseOfArray(new double[,] { { 1, a }, { 0, 1 } });
+
+            //--------------------------------------计算托盘行列间距---------------------------------------------------------
+            double distanceX = (p2 - p1).L2Norm() / (_pallet1.Column - 1);
+            double distanceY = (p3 - p1 - E1.DotProduct(p3 - p1) * E1).L2Norm() / (_pallet1.Row - 1);
+
+            //------------------------------------生成切变前的行列坐标集合-------------------------------------------------------
+            List<double> cols = new List<double>();
+            for (int i = 0; i < _pallet1.Column; i++)
+            {
+                cols.Add(distanceX * i);
+            }
+            List<double> rows = new List<double>();
+            for (int i = 0; i < _pallet1.Row; i++)
+            {
+                rows.Add(distanceY * i);
+            }
+            //-------------------------------------计算转换后的机器人绝对坐标系下的所有托盘点---------------------------------------
+            plcPoints.Clear();
+            for (int i = 0; i < rows.Count; i++)
+            {
+                plcPoints.Add(new List<PlcPoint>());
+                for (int j = 0; j < cols.Count; j++)
+                {
+                    //切变前的坐标
+                    Vector<double> q = Vector<double>.Build.Dense(new double[] { cols[j], rows[i] });
+                    //切变后的坐标
+                    Vector<double> h = Shear * q;
+                    //转换后的机器人坐标
+                    Vector<double> rp = R * h + p1;
+                    //输出完整的机器人坐标
+                    plcPoints[plcPoints.Count - 1].Add(new PlcPoint() { X_Position = (float)rp[0], Y_Position = (float)rp[1], Z_Position_Start = _pallet1.P0.Z_Position_Start,Z_Position_Stop= _pallet1.P0.Z_Position_Stop, U_Position = _pallet1.P0.U_Position});
+                }
+            }
+            //-----------------------------------------------排序---------------------------------------------------------------
+            List<PlcPoint> newPoints = new List<PlcPoint>();
+            if (_pallet1.Arrangement == Enums.PalletArrangement.Z)
+            {
+                foreach (var item in plcPoints)
+                {
+                    foreach (var item1 in item)
+                    {
+                        newPoints.Add(item1);
+                    }
+                }
+                PlcPoints = newPoints.ToArray();
+            }
+            else
+            {
+                for (int i = 0; i < rows.Count; i++)
+                {
+                    if (i % 2 == 0) //偶数
+                    {
+                        for (int j = 0; j < cols.Count; j++)
+                        {
+                            newPoints.Add(plcPoints[i][j]);
+                        }
+                    }
+                    else
+                    {
+                        for (int j = cols.Count - 1; j > -1; j--)
+                        {
+                            newPoints.Add(plcPoints[i][j]);
+                        }
+                    }
+                }
+                PlcPoints = newPoints.ToArray();
+            }
+
+            //组合托盘
+            if (_pallet1.Extend != null)
+            {
+                //-------------------------------------计算转换后的用户坐标系中的机器人点位---------------------------------------
+                plcPoints.Clear();
+                for (int i = 0; i < rows.Count; i++)
+                {
+                    plcPoints.Add(new List<PlcPoint>());
+                    for (int j = 0; j < cols.Count; j++)
+                    {
+                        //切变前的坐标
+                        Vector<double> q = Vector<double>.Build.Dense(new double[] { cols[j], rows[i] });
+                        //切变后的坐标
+                        Vector<double> h = Shear * q;
+                        //未转换前的托盘点
+                        plcPoints[plcPoints.Count - 1].Add(new PlcPoint() { X_Position = (float)h[0], Y_Position = (float)h[1], Z_Position_Start = _pallet1.P0.Z_Position_Start,Z_Position_Stop= pallet1.P0.Z_Position_Stop, U_Position = _pallet1.P0.U_Position});
+                    }
+                }
+
+                //-----------------------------------------------排序---------------------------------------------------------------
+                newPoints.Clear();
+                if (_pallet1.Arrangement == Enums.PalletArrangement.Z)
+                {
+                    foreach (var item in plcPoints)
+                    {
+                        foreach (var item1 in item)
+                        {
+                            newPoints.Add(item1);
+                        }
+                    }
+                }
+                else
+                {
+                    for (int i = 0; i < rows.Count; i++)
+                    {
+                        if (i % 2 == 0) //偶数
+                        {
+                            for (int j = 0; j < cols.Count; j++)
+                            {
+                                newPoints.Add(plcPoints[i][j]);
+                            }
+                        }
+                        else
+                        {
+                            for (int j = cols.Count - 1; j > -1; j--)
+                            {
+                                newPoints.Add(plcPoints[i][j]);
+                            }
+                        }
+                    }
+                }
+
+                //一个大托盘中,包含每个托盘的点位(大托盘<一行托盘>-<一行托盘中所有列托盘>-<一个托盘中所有的点位>)
+                List<List<List<PlcPoint>>> nPoints = new List<List<List<PlcPoint>>>();
+                //遍历所有的行
+                for (int i = 0; i < _pallet1.Extend.Pallet_Row; i++)
+                {
+                    nPoints.Add(new List<List<PlcPoint>>());
+                    //遍历每行中所有列
+                    for (int j = 0; j < _pallet1.Extend.Pallet_Column; j++)
+                    {
+                        nPoints[nPoints.Count - 1].Add(new List<PlcPoint>());
+                        double dx = _pallet1.Extend.Pallet_X_Interval * i;
+                        double dy = _pallet1.Extend.Pallet_Y_Interval * j;
+
+                        //如果是切变矩阵模式
+                        if (_pallet1.Extend.CoordinateModel == Enums.CoordinateModel.Shear)
+                        {
+                            //切变前的坐标
+                            Vector<double> q = Vector<double>.Build.Dense(new double[] { 0, dx });
+                            //切变后的坐标
+                            Vector<double> h = Shear * q;
+                            dy += h[0];
+                            dx = h[1];
+                        }
+
+                        foreach (var item in newPoints)
+                        {
+                            //偏移的向量
+                            Vector<double> q = Vector<double>.Build.Dense(new double[] { dy, dx });
+                            Vector<double> q1 = Vector<double>.Build.Dense(new double[] { item.X_Position, item.Y_Position });
+                            Vector<double> rp = R * (q + q1) + p1;
+                            nPoints[nPoints.Count - 1][nPoints[nPoints.Count - 1].Count - 1].Add(new PlcPoint() { X_Position = (float)rp[0], Y_Position = (float)rp[1], Z_Position_Start = item.Z_Position_Start,Z_Position_Stop=item.Z_Position_Stop, U_Position = item.U_Position});
+                        }
+                    }
+                }
+                newPoints = new List<PlcPoint>();
+                //对组合的所有托盘排序
+                if (_pallet1.Arrangement == Enums.PalletArrangement.Z)
+                {
+                    foreach (var item in nPoints)
+                    {
+                        foreach (var item1 in item)
+                        {
+                            foreach (var item2 in item1)
+                            {
+                                newPoints.Add(item2);
+                            }
+                        }
+                    }
+                    PlcPoints = newPoints.ToArray();
+                }
+                else
+                {
+                    for (int i = 0; i < nPoints.Count; i++)
+                    {
+                        if (i % 2 == 0) //偶数
+                        {
+                            for (int j = 0; j < nPoints[i].Count; j++)
+                            {
+                                foreach (var item2 in nPoints[i][j])
+                                {
+                                    newPoints.Add(item2);
+                                }
+                            }
+                        }
+                        else
+                        {
+                            for (int j = nPoints[i].Count - 1; j > -1; j--)
+                            {
+                                foreach (var item2 in nPoints[i][j])
+                                {
+                                    newPoints.Add(item2);
+                                }
+                            }
+                        }
+                    }
+                    PlcPoints = newPoints.ToArray();
+                }
+            }
+        }
+
         /// <summary>
         /// 绘制
         /// </summary>

+ 122 - 0
TeamAAS-VM/Models/Robot/Pallet.cs

@@ -7,6 +7,7 @@ using System.Text;
 using System.Threading.Tasks;
 using TeamAAS_VP.Enums;
 using TeamAAS_VP.Interfaces;
+using TeamAAS_VP.Models.PLC;
 
 namespace TeamAAS_VP.Models.Robot
 {
@@ -116,4 +117,125 @@ namespace TeamAAS_VP.Models.Robot
             return JsonConvert.DeserializeObject<Pallet>(JsonConvert.SerializeObject(this)); ;
         }
     }
+
+    /// <summary>
+    /// 托盘
+    /// </summary>
+    public class PalletEx : BindableBase
+    {
+        private Guid _Id;
+
+        public Guid Id
+        {
+            get { return _Id; }
+            set { SetProperty(ref _Id, value); }
+        }
+
+        private int _PalletNo;
+        /// <summary>
+        /// 编号
+        /// </summary> 
+        public int PalletNo
+        {
+            get { return _PalletNo; }
+            set { SetProperty(ref _PalletNo, value); }
+        }
+
+        private string _Name;
+
+        public string Name
+        {
+            get { return _Name; }
+            set { SetProperty(ref _Name, value); }
+        }
+
+        private string _Description;
+        /// <summary>
+        /// 描述
+        /// </summary>
+        public string Description
+        {
+            get { return _Description; }
+            set { SetProperty(ref _Description, value); }
+        }
+
+        private int _Row;
+
+        public int Row
+        {
+            get { return _Row; }
+            set { SetProperty(ref _Row, value); }
+        }
+
+
+        private int _Column;
+
+        public int Column
+        {
+            get { return _Column; }
+            set { SetProperty(ref _Column, value); }
+        }
+
+
+        private PlcPoint _P0;
+
+        public PlcPoint P0
+        {
+            get { return _P0; }
+            set { SetProperty(ref _P0, value); }
+        }
+
+        private PlcPoint _P1;
+
+        public PlcPoint P1
+        {
+            get { return _P1; }
+            set { SetProperty(ref _P1, value); }
+        }
+
+        private PlcPoint _P2;
+
+        public PlcPoint P2
+        {
+            get { return _P2; }
+            set { SetProperty(ref _P2, value); }
+        }
+
+        private PalletArrangement _Arrangement;
+
+        public PalletArrangement Arrangement
+        {
+            get { return _Arrangement; }
+            set { SetProperty(ref _Arrangement, value); }
+        }
+
+        private PalletExtend _Extend;
+        /// <summary>
+        /// 组合托盘功能
+        /// </summary>
+        public PalletExtend Extend
+        {
+            get { return _Extend; }
+            set { SetProperty(ref _Extend, value); }
+        }
+
+        public PalletEx Clone()
+        {
+            return new PalletEx()
+            {
+                Id = this.Id,
+                PalletNo = this.PalletNo,
+                Name = this.Name,
+                Description = this.Description,
+                Row = this.Row,
+                Column = this.Column,
+                P0 = this.P0?.Clone(),
+                P1 = this.P1?.Clone(),
+                P2 = this.P2?.Clone(),
+                Arrangement = this.Arrangement,
+                Extend = this.Extend
+
+            };
+        }
+    }
 }

+ 199 - 101
TeamAAS-VM/ViewModels/Product/PlcPointParamsViewModel.cs

@@ -281,33 +281,34 @@ namespace TeamAAS_VP.ViewModels.Product
         }
 
         private int _Inhal = 1;
+        /// <summary>
+        /// 吸真空编号
+        /// </summary>
         public int Inhal
         {
             get { return _Inhal; }
             set { SetProperty(ref _Inhal, value); }
         }
 
-        private PlcPoint _PickP1 = new PlcPoint();
-        public PlcPoint PickP1
-        {
-            get { return _PickP1; }
-            set { SetProperty(ref _PickP1, value); }
-        }
-
-        private PlcPoint _PickP2 = new PlcPoint();
-        public PlcPoint PickP2
+        private PalletEx _Pallet1;
+        /// <summary>
+        /// 托盘1
+        /// </summary>
+        public PalletEx Pallet1
         {
-            get { return _PickP2; }
-            set { SetProperty(ref _PickP2, value); }
+            get { return _Pallet1; }
+            set { SetProperty(ref _Pallet1, value); }
         }
 
-        private int _ColumnNum = 18;
-        public int ColumnNum
+        private PalletEx _Pallet2;
+        /// <summary>
+        /// 托盘2
+        /// </summary>
+        public PalletEx Pallet2
         {
-            get { return _ColumnNum; }
-            set { SetProperty(ref _ColumnNum, value); }
+            get { return _Pallet2; }
+            set { SetProperty(ref _Pallet2, value); }
         }
-
         #endregion
 
         #region 命令
@@ -424,11 +425,9 @@ namespace TeamAAS_VP.ViewModels.Product
         public DelegateCommand<string> PickMoveCommand =>
             _PickMoveCommand ?? (_PickMoveCommand = new DelegateCommand<string>(ExecutePickMoveCommand));
 
-        private DelegateCommand _CalPickPosCommand;
-        public DelegateCommand CalPickPosCommand =>
-            _CalPickPosCommand ?? (_CalPickPosCommand = new DelegateCommand(ExecuteCalPickPosCommand));
-
-
+        private DelegateCommand<string> _CalPickPosCommand;
+        public DelegateCommand<string> CalPickPosCommand =>
+            _CalPickPosCommand ?? (_CalPickPosCommand = new DelegateCommand<string>(ExecuteCalPickPosCommand));
 
         #endregion
 
@@ -1279,7 +1278,7 @@ namespace TeamAAS_VP.ViewModels.Product
                 }
                 // 执行视觉任务
                 var _cts = new CancellationTokenSource();
-                var visionResult =await _remoteCommandService.ExecutePhotoGetSinglePoint(process1, null, new double[] { rpoint.X, rpoint.Y, rpoint.U }, _cts.Token);
+                var visionResult = await _remoteCommandService.ExecutePhotoGetSinglePoint(process1, null, new double[] { rpoint.X, rpoint.Y, rpoint.U }, _cts.Token);
                 if (visionResult.IsSucceed)
                 {
                     _PutPoints[0] = new OpenCvSharp.Point3f((float)visionResult.X, (float)visionResult.Y, (float)visionResult.U);
@@ -1308,7 +1307,7 @@ namespace TeamAAS_VP.ViewModels.Product
                 await Task.Delay(200);
 
                 //获取移动向下相机1的流程
-                var process2= _productService.GetCurrentProductProcedureModelById(SelectProduct.MoveDownCamera2LockPhotoProcedureId);
+                var process2 = _productService.GetCurrentProductProcedureModelById(SelectProduct.MoveDownCamera2LockPhotoProcedureId);
                 if (process2 == null)
                 {
                     _eventAggregator.GetEvent<SnackbarMessageNotification>().Publish(new MessageParameter() { Msg = $"移动向下相机2视觉流程,流程ID:{SelectProduct.MoveDownCamera2LockPhotoProcedureId} 未找到!", Duration = 1 });
@@ -1550,33 +1549,80 @@ namespace TeamAAS_VP.ViewModels.Product
                 {
                     return;
                 }
-                int index = int.Parse(parameter);
+                int palletIndex = int.Parse(parameter.Split('-')[0]);
+                int pointIndex = int.Parse(parameter.Split('-')[1]);
                 var curpos = await Robot.GetRobotPosAsync();
                 var addpos = await Robot.GetAdditionalAxisCurrentPosAsync(Robot.AdditionalAxisList[0].Name);
-                if (index == 1)
+                PlcPoint pn = null;
+                if (palletIndex == 1)
                 {
-                    curpos.Z = 0;
-                    await Robot.CalibMotionAsync(curpos, 0);
+                    switch (pointIndex)
+                    {
+                        case 1:
+                            pn = Pallet1.P0.Clone();
+                            break;
+                        case 2:
+                            pn = Pallet1.P1.Clone();
+                            break;
+                        case 3:
+                            pn = Pallet1.P2.Clone();
+                            break;
+                        default:
+                            break;
+                    }
+                }
+                else
+                {
+                    switch (pointIndex)
+                    {
+                        case 1:
+                            pn = Pallet2.P0.Clone();
+                            break;
+                        case 2:
+                            pn = Pallet2.P1.Clone();
+                            break;
+                        case 3:
+                            pn = Pallet2.P2.Clone();
+                            break;
+                        default:
+                            break;
+                    }
+                }
+                if(pn==null)
+                {
+                    return;
+                }
+
 
-                    await Robot.AdditionalAxisMoveAsync(Robot.AdditionalAxisList[0].Name, PickP1.Z_Position_Stop);
-                    curpos.X = PickP1.X_Position;
-                    curpos.Y = PickP1.Y_Position;
-                    curpos.Z = PickP1.Z_Position_Start;
-                    curpos.U = PickP1.U_Position;
-                    await Robot.CalibMotionAsync(curpos, 0);
+                // 1.Z轴上升到安全高度
+                curpos.Z = 0;
+                bool isSuccess = await Robot.CalibMotionAsync(curpos, 0);
+                if (!isSuccess)
+                {
+                    _eventAggregator.GetEvent<SnackbarMessageNotification>().Publish(new MessageParameter() { Msg = "机器人移动失败!", Duration = 1 });
+                    return;
                 }
-                else if (index == 2)
+
+                // 2.附加轴移动
+                isSuccess = await Robot.AdditionalAxisMoveAsync(Robot.AdditionalAxisList[0].Name, pn.Z_Position_Stop);
+                if (!isSuccess)
                 {
-                    curpos.Z = 0;
-                    await Robot.CalibMotionAsync(curpos, 0);
+                    _eventAggregator.GetEvent<SnackbarMessageNotification>().Publish(new MessageParameter() { Msg = "附加轴移动失败!", Duration = 1 });
+                    return;
+                }
 
-                    await Robot.AdditionalAxisMoveAsync(Robot.AdditionalAxisList[0].Name, PickP2.Z_Position_Stop);
-                    curpos.X = PickP2.X_Position;
-                    curpos.Y = PickP2.Y_Position;
-                    curpos.Z = PickP2.Z_Position_Start;
-                    curpos.U = PickP2.U_Position;
-                    await Robot.CalibMotionAsync(curpos, 0);
+                // 3.移动XY轴到位
+                curpos.X = pn.X_Position;
+                curpos.Y = pn.Y_Position;
+                curpos.Z = pn.Z_Position_Start;
+                curpos.U = pn.U_Position;
+                isSuccess = await Robot.CalibMotionAsync(curpos, 0);
+                if (!isSuccess)
+                {
+                    _eventAggregator.GetEvent<SnackbarMessageNotification>().Publish(new MessageParameter() { Msg = "机器人移动失败!", Duration = 1 });
+                    return;
                 }
+
                 _eventAggregator.GetEvent<SnackbarMessageNotification>().Publish(new MessageParameter() { Msg = $"{Lang.完成}!", Duration = 0.4 });
             }
             catch (Exception ex)
@@ -1595,30 +1641,75 @@ namespace TeamAAS_VP.ViewModels.Product
             if (Robot == null || !Robot.IsConnected) return;
             try
             {
+
                 //弹窗用户是否确认要示教该点位
                 if (MessageBox.Show($"确认要示教取料点位 {parameter} 吗?", "示教点位", MessageBoxButton.YesNo, MessageBoxImage.Question) != MessageBoxResult.Yes)
                 {
                     return;
                 }
 
-                int index = int.Parse(parameter);
+                int palletIndex = int.Parse(parameter.Split('-')[0]);
+                int pointIndex = int.Parse(parameter.Split('-')[1]);
+
                 var curpos = await Robot.GetRobotPosAsync();
                 var addpos = await Robot.GetAdditionalAxisCurrentPosAsync(Robot.AdditionalAxisList[0].Name);
-                if (index == 1)
+                if (palletIndex == 1)
                 {
-                    PickP1.X_Position = curpos.X;
-                    PickP1.Y_Position = curpos.Y;
-                    PickP1.Z_Position_Start = curpos.Z;
-                    PickP1.U_Position = curpos.U;
-                    PickP1.Z_Position_Stop = addpos;
+                    switch (pointIndex)
+                    {
+                        case 1:
+                            Pallet1.P0.X_Position = curpos.X;
+                            Pallet1.P0.Y_Position = curpos.Y;
+                            Pallet1.P0.Z_Position_Start = curpos.Z;
+                            Pallet1.P0.U_Position = curpos.U;
+                            Pallet1.P0.Z_Position_Stop = addpos;
+                            break;
+                        case 2:
+                            Pallet1.P1.X_Position = curpos.X;
+                            Pallet1.P1.Y_Position = curpos.Y;
+                            Pallet1.P1.Z_Position_Start = curpos.Z;
+                            Pallet1.P1.U_Position = curpos.U;
+                            Pallet1.P1.Z_Position_Stop = addpos;
+                            break;
+                        case 3:
+                            Pallet1.P2.X_Position = curpos.X;
+                            Pallet1.P2.Y_Position = curpos.Y;
+                            Pallet1.P2.Z_Position_Start = curpos.Z;
+                            Pallet1.P2.U_Position = curpos.U;
+                            Pallet1.P2.Z_Position_Stop = addpos;
+                            break;
+                        default:
+                            break;
+                    }
                 }
-                else if (index == 2)
+                else
                 {
-                    PickP2.X_Position = curpos.X;
-                    PickP2.Y_Position = curpos.Y;
-                    PickP2.Z_Position_Start = curpos.Z;
-                    PickP2.U_Position = curpos.U;
-                    PickP2.Z_Position_Stop = addpos;
+                    switch (pointIndex)
+                    {
+                        case 1:
+                            Pallet2.P0.X_Position = curpos.X;
+                            Pallet2.P0.Y_Position = curpos.Y;
+                            Pallet2.P0.Z_Position_Start = curpos.Z;
+                            Pallet2.P0.U_Position = curpos.U;
+                            Pallet2.P0.Z_Position_Stop = addpos;
+                            break;
+                        case 2:
+                            Pallet2.P1.X_Position = curpos.X;
+                            Pallet2.P1.Y_Position = curpos.Y;
+                            Pallet2.P1.Z_Position_Start = curpos.Z;
+                            Pallet2.P1.U_Position = curpos.U;
+                            Pallet2.P1.Z_Position_Stop = addpos;
+                            break;
+                        case 3:
+                            Pallet2.P2.X_Position = curpos.X;
+                            Pallet2.P2.Y_Position = curpos.Y;
+                            Pallet2.P2.Z_Position_Start = curpos.Z;
+                            Pallet2.P2.U_Position = curpos.U;
+                            Pallet2.P2.Z_Position_Stop = addpos;
+                            break;
+                        default:
+                            break;
+                    }
                 }
                 _eventAggregator.GetEvent<SnackbarMessageNotification>().Publish(new MessageParameter() { Msg = $"{Lang.完成}!", Duration = 0.4 });
             }
@@ -1633,58 +1724,68 @@ namespace TeamAAS_VP.ViewModels.Product
         /// <summary>
         /// 计算所有托盘点
         /// </summary>
-        void ExecuteCalPickPosCommand()
+        void ExecuteCalPickPosCommand(string parameter)
         {
             try
             {
-                if (ColumnNum < 1)
+                int palletIndex = int.Parse(parameter);
+                if (palletIndex == 1)
                 {
-                    _eventAggregator.GetEvent<SnackbarMessageNotification>().Publish(new MessageParameter() { Msg = $"请设置托盘列数!", Duration = 1 });
-                    return;
-                }
-
-                //弹窗用户是否确认要示教该点位
-                if (MessageBox.Show($"确认要计算托盘 吗?", "计算托盘", MessageBoxButton.YesNo, MessageBoxImage.Question) != MessageBoxResult.Yes)
-                {
-                    return;
+                    PalletTool palletTool = new PalletTool(Pallet1);
+                    //托盘中所有的点‘
+                    var points = palletTool.PlcPoints;
+                    //将所有的点写入到取料点中,如果当前定义的取料点不存在,则新增
+                    for (int i = 0; i < points.Length; i++)
+                    {
+                        //如果当前的取料点数量小于等于i,则新增一个取料点
+                        if(SelectProduct.PickPoints.Count<=i)
+                        {
+                            SelectProduct.PickPoints.Add(new PlcPoint());
+                        }
+                        else
+                        {
+                            //否则更新当前的取料点
+                            SelectProduct.PickPoints[i].X_Position = points[i].X_Position;
+                            SelectProduct.PickPoints[i].Y_Position = points[i].Y_Position;
+                            SelectProduct.PickPoints[i].Z_Position_Start = points[i].Z_Position_Start;
+                            SelectProduct.PickPoints[i].U_Position = points[i].U_Position;
+                            SelectProduct.PickPoints[i].Z_Position_Stop = points[i].Z_Position_Stop;
+                        }
+                    }
                 }
-
-                //托盘间隔
-                double invt = (PickP2.Z_Position_Stop - PickP1.Z_Position_Stop) / (ColumnNum - 1);
-                for (int i = 0; i < ColumnNum; i++)
+                else
                 {
-                    if (Points.Count - 1 <= i)
+                    //如果当前的取料点数量小于托盘1的点数量,则提示用户先计算托盘1的点
+                    if (SelectProduct.PickPoints.Count < Pallet1.Row * Pallet1.Column)
                     {
-                        Points[i].Number = i + 1;
-                        Points[i].X_Position = PickP1.X_Position;
-                        Points[i].X_Velocity = 100;
-                        Points[i].Y_Position = PickP1.Y_Position;
-                        Points[i].Y_Velocity = 100;
-                        Points[i].Z_Position_Start = PickP1.Z_Position_Start;
-                        Points[i].Z_Velocity_Start = 100;
-                        Points[i].U_Position = PickP1.U_Position;
-                        Points[i].U_Velocity = 100;
-                        Points[i].Z_Position_Stop = (float)(PickP1.Z_Position_Stop + i * invt);
-                        Points[i].Z_Velocity_Stop = 100;
+                        _eventAggregator.GetEvent<SnackbarMessageNotification>().Publish(new MessageParameter() { Msg = "请先计算托盘1的点位!", Duration = 1 });
+                        return;
                     }
-                    else
+
+                    PalletTool palletTool = new PalletTool(Pallet2);
+                    //托盘中所有的点‘
+                    var points = palletTool.PlcPoints;
+                    //将所有的点写入到取料点中,如果当前定义的取料点不存在,则新增
+                    for (int i = 0; i < points.Length; i++)
                     {
-                        Points.Add(new PlcPoint()
+                        int index = i + Pallet1.Row * Pallet1.Column;
+                        //如果当前的取料点数量小于等于index,则新增一个取料点
+                        if (SelectProduct.PickPoints.Count <= index)
                         {
-                            Number= i + 1,
-                            X_Position = PickP1.X_Position,
-                            X_Velocity = 100,
-                            Y_Position = PickP1.Y_Position,
-                            Y_Velocity = 100,
-                            Z_Position_Start = PickP1.Z_Position_Start,
-                            Z_Velocity_Start = 100,
-                            U_Position = PickP1.U_Position,
-                            U_Velocity = 100,
-                            Z_Position_Stop = (float)(PickP1.Z_Position_Stop + i * invt),
-                            Z_Velocity_Stop = 100
-                        });
+                            SelectProduct.PickPoints.Add(new PlcPoint());
+                        }
+                        else
+                        {
+                            //否则更新当前的取料点
+                            SelectProduct.PickPoints[index].X_Position = points[i].X_Position;
+                            SelectProduct.PickPoints[index].Y_Position = points[i].Y_Position;
+                            SelectProduct.PickPoints[index].Z_Position_Start = points[i].Z_Position_Start;
+                            SelectProduct.PickPoints[index].U_Position = points[i].U_Position;
+                            SelectProduct.PickPoints[index].Z_Position_Stop = points[i].Z_Position_Stop;
+                        }
                     }
                 }
+
                 _eventAggregator.GetEvent<SnackbarMessageNotification>().Publish(new MessageParameter() { Msg = $"{Lang.完成}!", Duration = 0.4 });
             }
             catch (Exception ex)
@@ -1745,12 +1846,9 @@ namespace TeamAAS_VP.ViewModels.Product
                     }
                 }
                 CameraList = new ObservableCollection<CameraInfo>(_configService.GetAllCameras());
-                if (SelectProduct.PickPoints!=null && SelectProduct.PickPoints.Count>0)
-                {
-                    PickP1 = SelectProduct.PickPoints.FirstOrDefault().Clone();
-                    PickP2 = SelectProduct.PickPoints.LastOrDefault().Clone();
-                    ColumnNum = SelectProduct.PickPoints.Count;
-                }
+                Pallet1 = new PalletEx() { Row = 4, Column = 2 };
+                Pallet2 = new PalletEx() { Row = 4, Column = 2 };
+
             }
             catch (Exception ex)
             {

+ 312 - 115
TeamAAS-VM/Views/Product/PlcPointParams.xaml

@@ -364,121 +364,318 @@
 
                                         <StackPanel Orientation="Vertical"
                                                     HorizontalAlignment="Left">
-                                            <!--<Grid>
-                                                <Grid.RowDefinitions>
-                                                    <RowDefinition Height="auto" />
-                                                    <RowDefinition Height="auto" />
-                                                    <RowDefinition Height="auto" />
-                                                    <RowDefinition Height="auto" />
-                                                </Grid.RowDefinitions>
-                                                <Grid.ColumnDefinitions>
-                                                    <ColumnDefinition Width="auto" />
-                                                    <ColumnDefinition Width="auto" />
-                                                    <ColumnDefinition Width="auto" />
-                                                    <ColumnDefinition Width="auto" />
-                                                    <ColumnDefinition Width="auto" />
-                                                    <ColumnDefinition Width="auto" />
-                                                    <ColumnDefinition Width="auto" />
-                                                    <ColumnDefinition Width="auto" />
-                                                </Grid.ColumnDefinitions>
-                                                <Grid.Resources>
-                                                    <Style TargetType="TextBlock">
-                                                        <Setter Property="HorizontalAlignment"
-                                                                Value="Center" />
-                                                        <Setter Property="VerticalAlignment"
-                                                                Value="Center" />
-                                                    </Style>
-                                                    <Style TargetType="TextBox">
-                                                        <Setter Property="HorizontalAlignment"
-                                                                Value="Center" />
-                                                        <Setter Property="VerticalAlignment"
-                                                                Value="Center" />
-                                                        <Setter Property="MinWidth"
-                                                                Value="50" />
-                                                    </Style>
-                                                </Grid.Resources>
-                                                <TextBlock Text="X"
-                                                           Grid.Column="1" />
-                                                <TextBlock Text="Y"
-                                                           Grid.Column="2" />
-                                                <TextBlock Text="Z"
-                                                           Grid.Column="3" />
-                                                <TextBlock Text="U"
-                                                           Grid.Column="4" />
-                                                <TextBlock Text="附加轴"
-                                                           Grid.Column="5" />
-                                                <TextBlock Text="点1:"
-                                                           Grid.Row="1"
-                                                           Grid.Column="0" />
-                                                <TextBlock Text="点2:"
-                                                           Grid.Row="2"
-                                                           Grid.Column="0" />
-                                                <TextBox Text="{Binding PickP1.X_Position}"
-                                                         Grid.Row="1"
-                                                         Grid.Column="1" />
-                                                <TextBox Text="{Binding PickP1.Y_Position}"
-                                                         Grid.Row="1"
-                                                         Grid.Column="2" />
-                                                <TextBox Text="{Binding PickP1.Z_Position_Start}"
-                                                         Grid.Row="1"
-                                                         Grid.Column="3" />
-                                                <TextBox Text="{Binding PickP1.U_Position}"
-                                                         Grid.Row="1"
-                                                         Grid.Column="4" />
-                                                <TextBox Text="{Binding PickP1.Z_Position_Stop}"
-                                                         Grid.Row="1"
-                                                         Grid.Column="5" />
-                                                <Button Content="示教"
-                                                        Grid.Row="1"
-                                                        Grid.Column="6"
-                                                        Margin="5,0"
-                                                        Command="{Binding PickTechCommand}"
-                                                        CommandParameter="1" />
-                                                <Button Content="移动"
-                                                        Grid.Row="1"
-                                                        Grid.Column="7"
-                                                        Command="{Binding PickMoveCommand}"
-                                                        CommandParameter="1" />
-                                                <TextBox Text="{Binding PickP2.X_Position}"
-                                                         Grid.Row="2"
-                                                         Grid.Column="1" />
-                                                <TextBox Text="{Binding PickP2.Y_Position}"
-                                                         Grid.Row="2"
-                                                         Grid.Column="2" />
-                                                <TextBox Text="{Binding PickP2.Z_Position_Start}"
-                                                         Grid.Row="2"
-                                                         Grid.Column="3" />
-                                                <TextBox Text="{Binding PickP2.U_Position}"
-                                                         Grid.Row="2"
-                                                         Grid.Column="4" />
-                                                <TextBox Text="{Binding PickP2.Z_Position_Stop}"
-                                                         Grid.Row="2"
-                                                         Grid.Column="5" />
-                                                <Button Content="示教"
-                                                        Grid.Row="2"
-                                                        Grid.Column="6"
-                                                        Margin="5,0"
-                                                        Command="{Binding PickTechCommand}"
-                                                        CommandParameter="2" />
-                                                <Button Content="移动"
-                                                        Grid.Row="2"
-                                                        Grid.Column="7"
-                                                        Command="{Binding PickMoveCommand}"
-                                                        CommandParameter="2" />
-                                                <TextBlock Text="列数:"
-                                                           Grid.Row="3"
-                                                           Grid.Column="0" />
-                                                <TextBox Text="{Binding ColumnNum}"
-                                                         Grid.Row="3"
-                                                         Grid.Column="1" />
-                                                <Button Content="计算取料点"
-                                                        Grid.Row="3"
-                                                        Grid.ColumnSpan="4"
-                                                        Margin="5,0"
-                                                        HorizontalAlignment="Left"
-                                                        Grid.Column="2"
-                                                        Command="{Binding CalPickPosCommand}" />
-                                            </Grid>-->
+                                            <ScrollViewer>
+                                                <StackPanel Orientation="Horizontal">
+                                                    <GroupBox Header="托盘1">
+                                                        <Grid>
+                                                            <Grid.RowDefinitions>
+                                                                <RowDefinition Height="auto" />
+                                                                <RowDefinition Height="auto" />
+                                                                <RowDefinition Height="auto" />
+                                                                <RowDefinition Height="auto" />
+                                                                <RowDefinition Height="auto" />
+                                                            </Grid.RowDefinitions>
+                                                            <Grid.ColumnDefinitions>
+                                                                <ColumnDefinition Width="auto" />
+                                                                <ColumnDefinition Width="auto" />
+                                                                <ColumnDefinition Width="auto" />
+                                                                <ColumnDefinition Width="auto" />
+                                                                <ColumnDefinition Width="auto" />
+                                                                <ColumnDefinition Width="auto" />
+                                                                <ColumnDefinition Width="auto" />
+                                                                <ColumnDefinition Width="auto" />
+                                                            </Grid.ColumnDefinitions>
+                                                            <Grid.Resources>
+                                                                <Style TargetType="TextBlock">
+                                                                    <Setter Property="HorizontalAlignment"
+                                                                            Value="Center" />
+                                                                    <Setter Property="VerticalAlignment"
+                                                                            Value="Center" />
+                                                                </Style>
+                                                                <Style TargetType="TextBox">
+                                                                    <Setter Property="HorizontalAlignment"
+                                                                            Value="Center" />
+                                                                    <Setter Property="VerticalAlignment"
+                                                                            Value="Center" />
+                                                                    <Setter Property="MinWidth"
+                                                                            Value="50" />
+                                                                </Style>
+                                                            </Grid.Resources>
+                                                            <TextBlock Text="X"
+                                                                       Grid.Column="1" />
+                                                            <TextBlock Text="Y"
+                                                                       Grid.Column="2" />
+                                                            <TextBlock Text="Z"
+                                                                       Grid.Column="3" />
+                                                            <TextBlock Text="U"
+                                                                       Grid.Column="4" />
+                                                            <TextBlock Text="附加轴"
+                                                                       Grid.Column="5" />
+                                                            <TextBlock Text="点1:"
+                                                                       Grid.Row="1"
+                                                                       Grid.Column="0" />
+                                                            <TextBlock Text="点2:"
+                                                                       Grid.Row="2"
+                                                                       Grid.Column="0" />
+                                                            <TextBlock Text="点3:"
+                                                                       Grid.Row="3"
+                                                                       Grid.Column="0" />
+                                                            <TextBox Text="{Binding Pallet1.P0.X_Position}"
+                                                                     Grid.Row="1"
+                                                                     Grid.Column="1" />
+                                                            <TextBox Text="{Binding Pallet1.P0.Y_Position}"
+                                                                     Grid.Row="1"
+                                                                     Grid.Column="2" />
+                                                            <TextBox Text="{Binding Pallet1.P0.Z_Position_Start}"
+                                                                     Grid.Row="1"
+                                                                     Grid.Column="3" />
+                                                            <TextBox Text="{Binding Pallet1.P0.U_Position}"
+                                                                     Grid.Row="1"
+                                                                     Grid.Column="4" />
+                                                            <TextBox Text="{Binding Pallet1.P0.Z_Position_Stop}"
+                                                                     Grid.Row="1"
+                                                                     Grid.Column="5" />
+                                                            <Button Content="示教"
+                                                                    Grid.Row="1"
+                                                                    Grid.Column="6"
+                                                                    Margin="5,0"
+                                                                    Command="{Binding PickTechCommand}"
+                                                                    CommandParameter="1-1" />
+                                                            <Button Content="移动"
+                                                                    Grid.Row="1"
+                                                                    Grid.Column="7"
+                                                                    Command="{Binding PickMoveCommand}"
+                                                                    CommandParameter="1-1" />
+                                                            <TextBox Text="{Binding Pallet1.P1.X_Position}"
+                                                                     Grid.Row="2"
+                                                                     Grid.Column="1" />
+                                                            <TextBox Text="{Binding Pallet1.P1.Y_Position}"
+                                                                     Grid.Row="2"
+                                                                     Grid.Column="2" />
+                                                            <TextBox Text="{Binding Pallet1.P1.Z_Position_Start}"
+                                                                     Grid.Row="2"
+                                                                     Grid.Column="3" />
+                                                            <TextBox Text="{Binding Pallet1.P1.U_Position}"
+                                                                     Grid.Row="2"
+                                                                     Grid.Column="4" />
+                                                            <TextBox Text="{Binding Pallet1.P1.Z_Position_Stop}"
+                                                                     Grid.Row="2"
+                                                                     Grid.Column="5" />
+                                                            <Button Content="示教"
+                                                                    Grid.Row="2"
+                                                                    Grid.Column="6"
+                                                                    Margin="5,0"
+                                                                    Command="{Binding PickTechCommand}"
+                                                                    CommandParameter="1-2" />
+                                                            <Button Content="移动"
+                                                                    Grid.Row="2"
+                                                                    Grid.Column="7"
+                                                                    Command="{Binding PickMoveCommand}"
+                                                                    CommandParameter="1-2" />
+                                                            <TextBox Text="{Binding Pallet1.P2.X_Position}"
+                                                                     Grid.Row="3"
+                                                                     Grid.Column="1" />
+                                                            <TextBox Text="{Binding Pallet1.P2.Y_Position}"
+                                                                     Grid.Row="3"
+                                                                     Grid.Column="2" />
+                                                            <TextBox Text="{Binding Pallet1.P2.Z_Position_Start}"
+                                                                     Grid.Row="3"
+                                                                     Grid.Column="3" />
+                                                            <TextBox Text="{Binding Pallet1.P2.U_Position}"
+                                                                     Grid.Row="3"
+                                                                     Grid.Column="4" />
+                                                            <TextBox Text="{Binding Pallet1.P2.Z_Position_Stop}"
+                                                                     Grid.Row="3"
+                                                                     Grid.Column="5" />
+                                                            <Button Content="示教"
+                                                                    Grid.Row="3"
+                                                                    Grid.Column="6"
+                                                                    Margin="5,0"
+                                                                    Command="{Binding PickTechCommand}"
+                                                                    CommandParameter="1-3" />
+                                                            <Button Content="移动"
+                                                                    Grid.Row="3"
+                                                                    Grid.Column="7"
+                                                                    Command="{Binding PickMoveCommand}"
+                                                                    CommandParameter="1-3" />
+                                                            <TextBlock Text="行数:"
+                                                                       Grid.Row="4"
+                                                                       Grid.Column="0" />
+                                                            <TextBox Text="{Binding Pallet1.Row}"
+                                                                     Grid.Row="4"
+                                                                     Grid.Column="1" />
+                                                            <TextBlock Text="列数:"
+                                                                       Grid.Row="4"
+                                                                       Grid.Column="2" />
+                                                            <TextBox Text="{Binding Pallet1.Column}"
+                                                                     Grid.Row="4"
+                                                                     Grid.Column="3" />
+                                                            <Button Content="计算取料点"
+                                                                    Grid.Row="4"
+                                                                    Grid.ColumnSpan="4"
+                                                                    Margin="5,0"
+                                                                    HorizontalAlignment="Left"
+                                                                    Grid.Column="4"
+                                                                    Command="{Binding CalPickPosCommand}" 
+                                                                    CommandParameter="1"/>
+                                                        </Grid>
+                                                    </GroupBox>
+                                                    <GroupBox Header="托盘2" Margin="2,0">
+                                                        <Grid>
+                                                            <Grid.RowDefinitions>
+                                                                <RowDefinition Height="auto" />
+                                                                <RowDefinition Height="auto" />
+                                                                <RowDefinition Height="auto" />
+                                                                <RowDefinition Height="auto" />
+                                                                <RowDefinition Height="auto" />
+                                                            </Grid.RowDefinitions>
+                                                            <Grid.ColumnDefinitions>
+                                                                <ColumnDefinition Width="auto" />
+                                                                <ColumnDefinition Width="auto" />
+                                                                <ColumnDefinition Width="auto" />
+                                                                <ColumnDefinition Width="auto" />
+                                                                <ColumnDefinition Width="auto" />
+                                                                <ColumnDefinition Width="auto" />
+                                                                <ColumnDefinition Width="auto" />
+                                                                <ColumnDefinition Width="auto" />
+                                                            </Grid.ColumnDefinitions>
+                                                            <Grid.Resources>
+                                                                <Style TargetType="TextBlock">
+                                                                    <Setter Property="HorizontalAlignment"
+                                                                            Value="Center" />
+                                                                    <Setter Property="VerticalAlignment"
+                                                                            Value="Center" />
+                                                                </Style>
+                                                                <Style TargetType="TextBox">
+                                                                    <Setter Property="HorizontalAlignment"
+                                                                            Value="Center" />
+                                                                    <Setter Property="VerticalAlignment"
+                                                                            Value="Center" />
+                                                                    <Setter Property="MinWidth"
+                                                                            Value="50" />
+                                                                </Style>
+                                                            </Grid.Resources>
+                                                            <TextBlock Text="X"
+                                                                       Grid.Column="1" />
+                                                            <TextBlock Text="Y"
+                                                                       Grid.Column="2" />
+                                                            <TextBlock Text="Z"
+                                                                       Grid.Column="3" />
+                                                            <TextBlock Text="U"
+                                                                       Grid.Column="4" />
+                                                            <TextBlock Text="附加轴"
+                                                                       Grid.Column="5" />
+                                                            <TextBlock Text="点1:"
+                                                                       Grid.Row="1"
+                                                                       Grid.Column="0" />
+                                                            <TextBlock Text="点2:"
+                                                                       Grid.Row="2"
+                                                                       Grid.Column="0" />
+                                                            <TextBlock Text="点3:"
+                                                                       Grid.Row="3"
+                                                                       Grid.Column="0" />
+                                                            <TextBox Text="{Binding Pallet2.P0.X_Position}"
+                                                                     Grid.Row="1"
+                                                                     Grid.Column="1" />
+                                                            <TextBox Text="{Binding Pallet2.P0.Y_Position}"
+                                                                     Grid.Row="1"
+                                                                     Grid.Column="2" />
+                                                            <TextBox Text="{Binding Pallet2.P0.Z_Position_Start}"
+                                                                     Grid.Row="1"
+                                                                     Grid.Column="3" />
+                                                            <TextBox Text="{Binding Pallet2.P0.U_Position}"
+                                                                     Grid.Row="1"
+                                                                     Grid.Column="4" />
+                                                            <TextBox Text="{Binding Pallet2.P0.Z_Position_Stop}"
+                                                                     Grid.Row="1"
+                                                                     Grid.Column="5" />
+                                                            <Button Content="示教"
+                                                                    Grid.Row="1"
+                                                                    Grid.Column="6"
+                                                                    Margin="5,0"
+                                                                    Command="{Binding PickTechCommand}"
+                                                                    CommandParameter="2-1" />
+                                                            <Button Content="移动"
+                                                                    Grid.Row="1"
+                                                                    Grid.Column="7"
+                                                                    Command="{Binding PickMoveCommand}"
+                                                                    CommandParameter="2-1" />
+                                                            <TextBox Text="{Binding Pallet2.P1.X_Position}"
+                                                                     Grid.Row="2"
+                                                                     Grid.Column="1" />
+                                                            <TextBox Text="{Binding Pallet2.P1.Y_Position}"
+                                                                     Grid.Row="2"
+                                                                     Grid.Column="2" />
+                                                            <TextBox Text="{Binding Pallet2.P1.Z_Position_Start}"
+                                                                     Grid.Row="2"
+                                                                     Grid.Column="3" />
+                                                            <TextBox Text="{Binding Pallet2.P1.U_Position}"
+                                                                     Grid.Row="2"
+                                                                     Grid.Column="4" />
+                                                            <TextBox Text="{Binding Pallet2.P1.Z_Position_Stop}"
+                                                                     Grid.Row="2"
+                                                                     Grid.Column="5" />
+                                                            <Button Content="示教"
+                                                                    Grid.Row="2"
+                                                                    Grid.Column="6"
+                                                                    Margin="5,0"
+                                                                    Command="{Binding PickTechCommand}"
+                                                                    CommandParameter="2-2" />
+                                                            <Button Content="移动"
+                                                                    Grid.Row="2"
+                                                                    Grid.Column="7"
+                                                                    Command="{Binding PickMoveCommand}"
+                                                                    CommandParameter="2-2" />
+                                                            <TextBox Text="{Binding Pallet2.P2.X_Position}"
+                                                                     Grid.Row="3"
+                                                                     Grid.Column="1" />
+                                                            <TextBox Text="{Binding Pallet2.P2.Y_Position}"
+                                                                     Grid.Row="3"
+                                                                     Grid.Column="2" />
+                                                            <TextBox Text="{Binding Pallet2.P2.Z_Position_Start}"
+                                                                     Grid.Row="3"
+                                                                     Grid.Column="3" />
+                                                            <TextBox Text="{Binding Pallet2.P2.U_Position}"
+                                                                     Grid.Row="3"
+                                                                     Grid.Column="4" />
+                                                            <TextBox Text="{Binding Pallet2.P2.Z_Position_Stop}"
+                                                                     Grid.Row="3"
+                                                                     Grid.Column="5" />
+                                                            <Button Content="示教"
+                                                                    Grid.Row="3"
+                                                                    Grid.Column="6"
+                                                                    Margin="5,0"
+                                                                    Command="{Binding PickTechCommand}"
+                                                                    CommandParameter="2-3" />
+                                                            <Button Content="移动"
+                                                                    Grid.Row="3"
+                                                                    Grid.Column="7"
+                                                                    Command="{Binding PickMoveCommand}"
+                                                                    CommandParameter="2-3" />
+                                                            <TextBlock Text="行数:"
+                                                                       Grid.Row="4"
+                                                                       Grid.Column="0" />
+                                                            <TextBox Text="{Binding Pallet2.Row}"
+                                                                     Grid.Row="4"
+                                                                     Grid.Column="1" />
+                                                            <TextBlock Text="列数:"
+                                                                       Grid.Row="4"
+                                                                       Grid.Column="2" />
+                                                            <TextBox Text="{Binding Pallet2.Column}"
+                                                                     Grid.Row="4"
+                                                                     Grid.Column="3" />
+                                                            <Button Content="计算取料点"
+                                                                    Grid.Row="4"
+                                                                    Grid.ColumnSpan="4"
+                                                                    Margin="5,0"
+                                                                    HorizontalAlignment="Left"
+                                                                    Grid.Column="4"
+                                                                    Command="{Binding CalPickPosCommand}"
+                                                                    CommandParameter="2"/>
+                                                        </Grid>
+                                                    </GroupBox>
+                                                </StackPanel>
+                                            </ScrollViewer>
                                             <StackPanel Orientation="Horizontal">
                                                 <TextBlock Text="吸真空编号:"
                                                            VerticalAlignment="Center" />