|
|
@@ -1,4 +1,5 @@
|
|
|
using Cognex.VisionPro;
|
|
|
+using MahApps.Metro.Controls;
|
|
|
using MaterialDesignThemes.Wpf;
|
|
|
using MathNet.Numerics.LinearAlgebra;
|
|
|
using NPOI.SS.Formula.Functions;
|
|
|
@@ -202,86 +203,6 @@ namespace TeamAAS_VP.ViewModels.Product
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- private float _LockPointStartZ;
|
|
|
- /// <summary>
|
|
|
- /// 批量设置锁付点的起始Z坐标
|
|
|
- /// </summary>
|
|
|
- public float LockPointStartZ
|
|
|
- {
|
|
|
- get { return _LockPointStartZ; }
|
|
|
- set { SetProperty(ref _LockPointStartZ, value); }
|
|
|
- }
|
|
|
-
|
|
|
- private float _LockZDepth;
|
|
|
- /// <summary>
|
|
|
- /// 批量设置锁付点Z深度
|
|
|
- /// </summary>
|
|
|
- public float LockZDepth
|
|
|
- {
|
|
|
- get { return _LockZDepth; }
|
|
|
- set { SetProperty(ref _LockZDepth, value); }
|
|
|
- }
|
|
|
-
|
|
|
- private float _LockXSpeed;
|
|
|
- /// <summary>
|
|
|
- /// 批量设置锁付点X轴速度
|
|
|
- /// </summary>
|
|
|
- public float LockXSpeed
|
|
|
- {
|
|
|
- get { return _LockXSpeed; }
|
|
|
- set { SetProperty(ref _LockXSpeed, value); }
|
|
|
- }
|
|
|
-
|
|
|
- private float _LockYSpeed;
|
|
|
- /// <summary>
|
|
|
- /// 批量设置锁付点Y轴速度
|
|
|
- /// </summary>
|
|
|
- public float LockYSpeed
|
|
|
- {
|
|
|
- get { return _LockYSpeed; }
|
|
|
- set { SetProperty(ref _LockYSpeed, value); }
|
|
|
- }
|
|
|
-
|
|
|
- private float _LockZSpeed;
|
|
|
- /// <summary>
|
|
|
- /// 批量设置锁付点Z轴速度
|
|
|
- /// </summary>
|
|
|
- public float LockZSpeed
|
|
|
- {
|
|
|
- get { return _LockZSpeed; }
|
|
|
- set { SetProperty(ref _LockZSpeed, value); }
|
|
|
- }
|
|
|
-
|
|
|
- private float _LockZDescendSpeed;
|
|
|
- /// <summary>
|
|
|
- /// 批量设置锁付点Z轴下降速度
|
|
|
- /// </summary>
|
|
|
- public float LockZDescendSpeed
|
|
|
- {
|
|
|
- get { return _LockZDescendSpeed; }
|
|
|
- set { SetProperty(ref _LockZDescendSpeed, value); }
|
|
|
- }
|
|
|
-
|
|
|
- private Int16 _LockFeederNumber;
|
|
|
- /// <summary>
|
|
|
- /// 批量设置锁付点供料器编号
|
|
|
- /// </summary>
|
|
|
- public Int16 LockFeederNumber
|
|
|
- {
|
|
|
- get { return _LockFeederNumber; }
|
|
|
- set { SetProperty(ref _LockFeederNumber, value); }
|
|
|
- }
|
|
|
-
|
|
|
- private Int16 _LockScrewProgramNumber;
|
|
|
- /// <summary>
|
|
|
- /// 批量设置锁付点螺丝程序编号
|
|
|
- /// </summary>
|
|
|
- public Int16 LockScrewProgramNumber
|
|
|
- {
|
|
|
- get { return _LockScrewProgramNumber; }
|
|
|
- set { SetProperty(ref _LockScrewProgramNumber, value); }
|
|
|
- }
|
|
|
-
|
|
|
private bool _IsGrap;
|
|
|
public bool IsGrap
|
|
|
{
|
|
|
@@ -364,6 +285,28 @@ namespace TeamAAS_VP.ViewModels.Product
|
|
|
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
|
|
|
+ {
|
|
|
+ get { return _PickP2; }
|
|
|
+ set { SetProperty(ref _PickP2, value); }
|
|
|
+ }
|
|
|
+
|
|
|
+ private int _ColumnNum = 18;
|
|
|
+ public int ColumnNum
|
|
|
+ {
|
|
|
+ get { return _ColumnNum; }
|
|
|
+ set { SetProperty(ref _ColumnNum, value); }
|
|
|
+ }
|
|
|
+
|
|
|
#endregion
|
|
|
|
|
|
#region 命令
|
|
|
@@ -471,6 +414,21 @@ namespace TeamAAS_VP.ViewModels.Product
|
|
|
private DelegateCommand<object> _AdditionalAxisMotorOffCommand;
|
|
|
public DelegateCommand<object> AdditionalAxisMotorOffCommand =>
|
|
|
_AdditionalAxisMotorOffCommand ?? (_AdditionalAxisMotorOffCommand = new DelegateCommand<object>(ExecuteAdditionalAxisMotorOffCommand).ObservesCanExecute(() => CanExecute).ObservesProperty(() => Robot).ObservesProperty(() => Robot.CanExecute));
|
|
|
+
|
|
|
+ private DelegateCommand<string> _PickTechCommand;
|
|
|
+ public DelegateCommand<string> PickTechCommand =>
|
|
|
+ _PickTechCommand ?? (_PickTechCommand = new DelegateCommand<string>(ExecutePickTechCommand));
|
|
|
+
|
|
|
+ private DelegateCommand<string> _PickMoveCommand;
|
|
|
+ public DelegateCommand<string> PickMoveCommand =>
|
|
|
+ _PickMoveCommand ?? (_PickMoveCommand = new DelegateCommand<string>(ExecutePickMoveCommand));
|
|
|
+
|
|
|
+ private DelegateCommand _CalPickPosCommand;
|
|
|
+ public DelegateCommand CalPickPosCommand =>
|
|
|
+ _CalPickPosCommand ?? (_CalPickPosCommand = new DelegateCommand(ExecuteCalPickPosCommand));
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
#endregion
|
|
|
|
|
|
#region 事件
|
|
|
@@ -689,6 +647,11 @@ namespace TeamAAS_VP.ViewModels.Product
|
|
|
_eventAggregator.GetEvent<SnackbarMessageNotification>().Publish(new MessageParameter() { Msg = $"{Lang.完成}!", Duration = 0.4 });
|
|
|
return;
|
|
|
}
|
|
|
+ else if (SelectedIndex == 1)
|
|
|
+ {
|
|
|
+ _eventAggregator.GetEvent<SnackbarMessageNotification>().Publish(new MessageParameter() { Msg = "当前模式不允许直接示教取料点!", Duration = 1 });
|
|
|
+ return;
|
|
|
+ }
|
|
|
else
|
|
|
{
|
|
|
//弹窗用户是否确认要示教该点位
|
|
|
@@ -1154,7 +1117,6 @@ namespace TeamAAS_VP.ViewModels.Product
|
|
|
return SelectedPoint != null;
|
|
|
}
|
|
|
|
|
|
-
|
|
|
ToolCoord toolCoord = null;
|
|
|
double _FixedUpCameraTempletAngle = 0;
|
|
|
double _MoveCameraTempletAngle = 0;
|
|
|
@@ -1548,6 +1510,163 @@ namespace TeamAAS_VP.ViewModels.Product
|
|
|
_eventAggregator.GetEvent<SnackbarMessageNotification>().Publish(new MessageParameter() { Msg = ex.Message, Duration = 1 });
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
+ /// <summary>
|
|
|
+ /// 移动取料托盘点
|
|
|
+ /// </summary>
|
|
|
+ async void ExecutePickMoveCommand(string parameter)
|
|
|
+ {
|
|
|
+ if (Robot == null || !Robot.IsConnected) return;
|
|
|
+ try
|
|
|
+ {
|
|
|
+ //弹窗用户是否确认要示教该点位
|
|
|
+ if (MessageBox.Show($"确认要移动取料点位 {parameter} 吗?", "移动点位", MessageBoxButton.YesNo, MessageBoxImage.Question) != MessageBoxResult.Yes)
|
|
|
+ {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ int index = int.Parse(parameter);
|
|
|
+ var curpos = await Robot.GetRobotPosAsync();
|
|
|
+ var addpos = await Robot.GetAdditionalAxisCurrentPosAsync(Robot.AdditionalAxisList[0].Name);
|
|
|
+ if (index == 1)
|
|
|
+ {
|
|
|
+ curpos.Z = 0;
|
|
|
+ await Robot.CalibMotionAsync(curpos, 0);
|
|
|
+
|
|
|
+ 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);
|
|
|
+ }
|
|
|
+ else if (index == 2)
|
|
|
+ {
|
|
|
+ curpos.Z = 0;
|
|
|
+ await Robot.CalibMotionAsync(curpos, 0);
|
|
|
+
|
|
|
+ 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);
|
|
|
+ }
|
|
|
+ _eventAggregator.GetEvent<SnackbarMessageNotification>().Publish(new MessageParameter() { Msg = $"{Lang.完成}!", Duration = 0.4 });
|
|
|
+ }
|
|
|
+ catch (Exception ex)
|
|
|
+ {
|
|
|
+ LogHelper.WriteLogError("示教取料托盘点时出错!", ex);
|
|
|
+ _eventAggregator.GetEvent<SnackbarMessageNotification>().Publish(new MessageParameter() { Msg = ex.Message, Duration = 1 });
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ /// <summary>
|
|
|
+ /// 示教取料托盘点
|
|
|
+ /// </summary>
|
|
|
+ /// <param name="parameter"></param>
|
|
|
+ async void ExecutePickTechCommand(string parameter)
|
|
|
+ {
|
|
|
+ if (Robot == null || !Robot.IsConnected) return;
|
|
|
+ try
|
|
|
+ {
|
|
|
+ //弹窗用户是否确认要示教该点位
|
|
|
+ if (MessageBox.Show($"确认要示教取料点位 {parameter} 吗?", "示教点位", MessageBoxButton.YesNo, MessageBoxImage.Question) != MessageBoxResult.Yes)
|
|
|
+ {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
+ int index = int.Parse(parameter);
|
|
|
+ var curpos = await Robot.GetRobotPosAsync();
|
|
|
+ var addpos = await Robot.GetAdditionalAxisCurrentPosAsync(Robot.AdditionalAxisList[0].Name);
|
|
|
+ if (index == 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;
|
|
|
+ }
|
|
|
+ else if (index == 2)
|
|
|
+ {
|
|
|
+ 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;
|
|
|
+ }
|
|
|
+ _eventAggregator.GetEvent<SnackbarMessageNotification>().Publish(new MessageParameter() { Msg = $"{Lang.完成}!", Duration = 0.4 });
|
|
|
+ }
|
|
|
+ catch (Exception ex)
|
|
|
+ {
|
|
|
+ LogHelper.WriteLogError("示教取料托盘点时出错!", ex);
|
|
|
+ _eventAggregator.GetEvent<SnackbarMessageNotification>().Publish(new MessageParameter() { Msg = ex.Message, Duration = 1 });
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ /// <summary>
|
|
|
+ /// 计算所有托盘点
|
|
|
+ /// </summary>
|
|
|
+ void ExecuteCalPickPosCommand()
|
|
|
+ {
|
|
|
+ try
|
|
|
+ {
|
|
|
+ if (ColumnNum < 1)
|
|
|
+ {
|
|
|
+ _eventAggregator.GetEvent<SnackbarMessageNotification>().Publish(new MessageParameter() { Msg = $"请设置托盘列数!", Duration = 1 });
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
+ //弹窗用户是否确认要示教该点位
|
|
|
+ if (MessageBox.Show($"确认要计算托盘 吗?", "计算托盘", MessageBoxButton.YesNo, MessageBoxImage.Question) != MessageBoxResult.Yes)
|
|
|
+ {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
+ //托盘间隔
|
|
|
+ double invt = (PickP2.Z_Position_Stop - PickP1.Z_Position_Stop) / (ColumnNum - 1);
|
|
|
+ for (int i = 0; i < ColumnNum; i++)
|
|
|
+ {
|
|
|
+ if (Points.Count - 1 <= i)
|
|
|
+ {
|
|
|
+ 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;
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ Points.Add(new PlcPoint()
|
|
|
+ {
|
|
|
+ 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
|
|
|
+ });
|
|
|
+ }
|
|
|
+ }
|
|
|
+ _eventAggregator.GetEvent<SnackbarMessageNotification>().Publish(new MessageParameter() { Msg = $"{Lang.完成}!", Duration = 0.4 });
|
|
|
+ }
|
|
|
+ catch (Exception ex)
|
|
|
+ {
|
|
|
+ LogHelper.WriteLogError("示教取料托盘点时出错!", ex);
|
|
|
+ _eventAggregator.GetEvent<SnackbarMessageNotification>().Publish(new MessageParameter() { Msg = ex.Message, Duration = 1 });
|
|
|
+ }
|
|
|
+ }
|
|
|
#endregion
|
|
|
|
|
|
#region 继承
|
|
|
@@ -1600,18 +1719,13 @@ namespace TeamAAS_VP.ViewModels.Product
|
|
|
ProcedureModels.Add(item1);
|
|
|
}
|
|
|
}
|
|
|
-
|
|
|
- //对锁付点的批量设置进行初始化
|
|
|
- LockPointStartZ = SelectProduct.ScrewPoints.FirstOrDefault()?.Z_Position_Start ?? 0;
|
|
|
- LockZDepth = SelectProduct.ScrewPoints.FirstOrDefault() != null ? (SelectProduct.ScrewPoints.FirstOrDefault().Z_Position_Start - SelectProduct.ScrewPoints.FirstOrDefault().Z_Position_Stop) : 0;
|
|
|
- LockXSpeed = SelectProduct.ScrewPoints.FirstOrDefault()?.X_Velocity ?? 100;
|
|
|
- LockYSpeed = SelectProduct.ScrewPoints.FirstOrDefault()?.Y_Velocity ?? 100;
|
|
|
- LockZSpeed = SelectProduct.ScrewPoints.FirstOrDefault()?.Z_Velocity_Start ?? 100;
|
|
|
- LockZDescendSpeed = SelectProduct.ScrewPoints.FirstOrDefault()?.Z_Velocity_Stop ?? 100;
|
|
|
- LockFeederNumber = SelectProduct.ScrewPoints.FirstOrDefault()?.Feeder ?? 1;
|
|
|
- LockScrewProgramNumber = SelectProduct.ScrewPoints.FirstOrDefault()?.ScrewProNum ?? 1;
|
|
|
-
|
|
|
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;
|
|
|
+ }
|
|
|
}
|
|
|
catch (Exception ex)
|
|
|
{
|