|
|
@@ -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)
|
|
|
{
|