|
@@ -9,6 +9,7 @@ using SCADA_DAQ.Plugin.Core.Service;
|
|
|
using SCADA_DAQ.Plugin.Machine.Device;
|
|
|
using SCADA_DAQ.Plugin.Robot.Stacking;
|
|
|
using System;
|
|
|
+using System.Collections.Generic;
|
|
|
using System.Collections.ObjectModel;
|
|
|
using System.ComponentModel;
|
|
|
using System.Linq;
|
|
@@ -59,47 +60,20 @@ namespace SCADA_DAQ.Customer.Machines
|
|
|
/// </summary>
|
|
|
public event EventHandler<StackStartEventArgs> StackStarted;
|
|
|
|
|
|
+ /// <summary>
|
|
|
+ ///
|
|
|
+ /// </summary>
|
|
|
public event EventHandler<StackFinishEventArgs> StackFinished;
|
|
|
|
|
|
- ///// <summary>
|
|
|
- ///// X轴取料点
|
|
|
- ///// </summary>
|
|
|
- //private double XReclaimPoint { get; set; }
|
|
|
-
|
|
|
- ///// <summary>
|
|
|
- ///// Y轴取料点
|
|
|
- ///// </summary>
|
|
|
- //private double YReclaimPoint { get; set; }
|
|
|
-
|
|
|
- ///// <summary>
|
|
|
- ///// Z轴取料点
|
|
|
- ///// </summary>
|
|
|
- //private double ZReclaimPoint { get; set; }
|
|
|
-
|
|
|
- ///// <summary>
|
|
|
- ///// R轴取料点
|
|
|
- ///// </summary>
|
|
|
- //private double RReclaimPoint { get; set; }
|
|
|
-
|
|
|
- ///// <summary>
|
|
|
- ///// X轴放料点
|
|
|
- ///// </summary>
|
|
|
- //private double XDischargePoint { get; set; }
|
|
|
-
|
|
|
- ///// <summary>
|
|
|
- ///// Y轴放料点
|
|
|
- ///// </summary>
|
|
|
- //private double YDischargePoint { get; set; }
|
|
|
-
|
|
|
- ///// <summary>
|
|
|
- ///// Z轴放料点
|
|
|
- ///// </summary>
|
|
|
- //private double ZDischargePoint { get; set; }
|
|
|
-
|
|
|
- ///// <summary>
|
|
|
- ///// R轴放料点
|
|
|
- ///// </summary>
|
|
|
- //private double RDischargePoint { get; set; }
|
|
|
+ /// <summary>
|
|
|
+ /// 实时坐标信息
|
|
|
+ /// </summary>
|
|
|
+ public Dictionary<string, CenterPoint> Coordinates { get; set; } = new Dictionary<string, CenterPoint>();
|
|
|
+
|
|
|
+ private CenterPoint takeLocation { get; set; } = new CenterPoint();
|
|
|
+ private CenterPoint releaseLocation { get; set; } = new CenterPoint();
|
|
|
+
|
|
|
+ private CenterPoint actLocation { get; set; } = new CenterPoint();
|
|
|
|
|
|
/// <summary>
|
|
|
///
|
|
@@ -113,6 +87,11 @@ namespace SCADA_DAQ.Customer.Machines
|
|
|
.Select(t => new Alarm() { AlarmCode = t.AlarmCode_Str, Desc = t.AlarmDesc_Str })?
|
|
|
.ToLookup(t => t.AlarmCode).ToDictionary(t => t.Key, t => t.First());
|
|
|
|
|
|
+ Coordinates.Add("机械0点", CustomerEnv.CustomerConfig.MachineOrigin);
|
|
|
+ Coordinates.Add("纸箱位置", CustomerEnv.CustomerConfig.CaputreBoxLocation);
|
|
|
+ Coordinates.Add("抓取位置", takeLocation);
|
|
|
+ Coordinates.Add("释放位置", releaseLocation);
|
|
|
+ Coordinates.Add("实时位置", actLocation);
|
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
@@ -144,9 +123,7 @@ namespace SCADA_DAQ.Customer.Machines
|
|
|
var BoxLength = (int)StackSln.BoxLength_Dec;
|
|
|
var BoxWidth = (int)StackSln.BoxWidth_Dec;
|
|
|
var BoxHeight = (int)StackSln.BoxHeight_Dec;
|
|
|
- var TakeBoxX = GetListenReg("X轴取料点位置").Int32;
|
|
|
- var TakeBoxY = GetListenReg("Y轴取料点位置").Int32;
|
|
|
- var TakeBoxZ = GetListenReg("Z轴取料点位置").Int32;
|
|
|
+
|
|
|
var TakeBoxR = GetListenReg("R轴取料点位置").Int32;
|
|
|
var PutBoxX = GetListenReg("X轴放料点位置").Int32;
|
|
|
var PutBoxY = GetListenReg("Y轴放料点位置").Int32;
|
|
@@ -156,31 +133,38 @@ namespace SCADA_DAQ.Customer.Machines
|
|
|
var Ymm = (int)GetListenReg("Y伺服每mm脉冲数").Float;
|
|
|
var Zmm = (int)GetListenReg("Z伺服每mm脉冲数").Float;
|
|
|
var Rmm = (int)GetListenReg("R伺服每mm脉冲数").Float;
|
|
|
- int jiaodu = 0;
|
|
|
|
|
|
- var TakeBoxYIsSucess = GetListenReg("Y轴取料点上方").WriteReg(TakeBoxY);
|
|
|
- var TakeBoxXIsSucess = GetListenReg("X轴取料点上方").WriteReg((((BoxLength * Xmm) - (200 * Xmm)) / 2) + TakeBoxX);//(箱子长度-吸盘长度)/2=X轴左移距离
|
|
|
+ //var TakeBoxYIsSucess = GetListenReg("Y轴取料点上方").WriteReg(TakeBoxY);
|
|
|
+ //var TakeBoxXIsSucess = GetListenReg("X轴取料点上方").WriteReg((((BoxLength * Xmm) - (200 * Xmm)) / 2) + TakeBoxX);//(箱子长度-吸盘长度)/2=X轴左移距离
|
|
|
+ //var TakeBoxZIsSucess = GetListenReg("Z轴取料点").WriteReg(((BoxHeight - 10) * Zmm) + TakeBoxZ);
|
|
|
+
|
|
|
+
|
|
|
+ takeLocation.X = CustomerEnv.CustomerConfig.CaputreBoxLocation.X - CustomerEnv.CustomerConfig.MachineOrigin.X - StackSln.BoxWidth_Dec / 2;
|
|
|
+ takeLocation.Y = CustomerEnv.CustomerConfig.MachineOrigin.Y - CustomerEnv.CustomerConfig.MachineOrigin.Y - StackSln.BoxWidth_Dec / 2;
|
|
|
+ takeLocation.Z = CustomerEnv.CustomerConfig.MachineOrigin.Z - CustomerEnv.CustomerConfig.MachineOrigin.Z + StackSln.BoxHeight_Dec;
|
|
|
+ takeLocation.R = 0;
|
|
|
|
|
|
- var TakeBoxZIsSucess = GetListenReg("Z轴取料点").WriteReg(((BoxHeight - 10) * Zmm) + TakeBoxZ);
|
|
|
+ var TakeBoxYIsSucess = GetListenReg(Tag_Y轴取料点上方).WriteReg($"{takeLocation.X}");
|
|
|
+ var TakeBoxXIsSucess = GetListenReg(Tag_X轴取料点上方).WriteReg($"{takeLocation.Y}");
|
|
|
+ var TakeBoxZIsSucess = GetListenReg(Tag_Z轴取料点).WriteReg($"{takeLocation.Z}");
|
|
|
|
|
|
- if (StackCapture.RotationAngle == 90) { jiaodu = 12760; }
|
|
|
- else if (StackCapture.RotationAngle == -90) { jiaodu = 12760; }
|
|
|
- else if (StackCapture.RotationAngle == 180 || StackCapture.RotationAngle == -180) { jiaodu = 25520; }
|
|
|
- var x = PutBoxX + ((int)StackCapture.CaptureX * Xmm);
|
|
|
- var y = PutBoxY + ((int)StackCapture.CaptureY * Ymm);
|
|
|
- var z = (int)(StackCapture.CaptureZ + (StackCapture.CaptureZ / 2));
|
|
|
+ releaseLocation.X = (decimal)StackCapture.CaptureX - CustomerEnv.CustomerConfig.MachineOrigin.X;
|
|
|
+ releaseLocation.Y = (decimal)StackCapture.CaptureY - CustomerEnv.CustomerConfig.MachineOrigin.Y;
|
|
|
+ releaseLocation.Z = (decimal)StackCapture.CaptureZ + StackSln.BoxHeight_Dec / 2 - CustomerEnv.CustomerConfig.MachineOrigin.Z;
|
|
|
+ releaseLocation.R = (decimal)currentBox.RotationAngle;
|
|
|
|
|
|
+ var PutBoxXIsSucess = GetListenReg(Tag_X轴放料点上方).WriteReg($"{(int)releaseLocation.X}");
|
|
|
+ var PutBoxYIsSucess = GetListenReg(Tag_Y轴放料点上方).WriteReg($"{(int)releaseLocation.Y}");
|
|
|
+ var PutBoxRIsSucess = GetListenReg(Tag_R轴放料点角度).WriteReg($"{(int)currentBox.RotationAngle}");
|
|
|
+ var PutBoxZIsSucess = GetListenReg(Tag_Z轴放料点).WriteReg($"{(int)releaseLocation.Z}");
|
|
|
|
|
|
- var PutBoxXIsSucess = GetListenReg("X轴放料点上方").WriteReg($"{x}");
|
|
|
- var PutBoxYIsSucess = GetListenReg("Y轴放料点上方").WriteReg($"{y}");
|
|
|
- var PutBoxRIsSucess = GetListenReg("R轴放料点角度").WriteReg($"{jiaodu}");
|
|
|
- var PutBoxZIsSucess = GetListenReg("Z轴放料点").WriteReg($"{z}");
|
|
|
if (TakeBoxYIsSucess && TakeBoxXIsSucess && TakeBoxZIsSucess &&
|
|
|
PutBoxXIsSucess && PutBoxYIsSucess && PutBoxRIsSucess && PutBoxZIsSucess)
|
|
|
{
|
|
|
GetListenReg("HMI开始作业").WriteReg(1);
|
|
|
}
|
|
|
- Log.Info($"开始堆码,X:{x / (Xmm == 0 ? 1 : Xmm)},Y:{y / (Ymm == 0 ? 1 : Ymm)},Z:{z},角度:{jiaodu}");
|
|
|
+ Log.Info($"开始堆码,抓取,X:{takeLocation.X},Y:{takeLocation.Y},Z:{takeLocation.Y},角度:{0}\r\n" +
|
|
|
+ $"摆放,X:{releaseLocation.X},Y:{releaseLocation.Y},Z:{releaseLocation.Z},角度:{releaseLocation.R}");
|
|
|
}
|
|
|
if (reg.Comment.Variable == "作业完成" && reg.Value == 1)
|
|
|
{
|
|
@@ -199,8 +183,6 @@ namespace SCADA_DAQ.Customer.Machines
|
|
|
{
|
|
|
CurrentCaputerIndex++; //抓取完毕,序号自增
|
|
|
}
|
|
|
-
|
|
|
-
|
|
|
}
|
|
|
else
|
|
|
{
|
|
@@ -223,6 +205,7 @@ namespace SCADA_DAQ.Customer.Machines
|
|
|
StackSln.BoxHeight_Dec = (decimal)parameter.BoxHeight;
|
|
|
|
|
|
StackSln.StackCaptureList = Env.DAL.App_Stack_Capture.GetData<CaptureModel>(t => t.SlnId == parameter.ID);
|
|
|
+ CurrentCaputerIndex = 1; //修改方案后重置抓取序号
|
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
@@ -234,6 +217,11 @@ namespace SCADA_DAQ.Customer.Machines
|
|
|
{
|
|
|
if (RedundancyService?.RedundancyState == RedundancyStates.Standby) { return; } //如果是待机模式就不执行下面的逻辑
|
|
|
base.ScanCompleted(sender, e);
|
|
|
+
|
|
|
+ actLocation.X = (decimal)GetListenReg(Tag_X轴所在位置mm).ScaleValue;
|
|
|
+ actLocation.Y = (decimal)GetListenReg(Tag_Y轴所在位置mm).ScaleValue;
|
|
|
+ actLocation.Z = (decimal)GetListenReg(Tag_Z轴所在位置mm).ScaleValue;
|
|
|
+ actLocation.R = (decimal)GetListenReg(Tag_R轴所在位置mm).ScaleValue;
|
|
|
}
|
|
|
|
|
|
/// <summary>
|