|
@@ -100,6 +100,24 @@ namespace SCADA_DAQ.Customer.Machines
|
|
|
public string AlarmStr { get => string.Join(",", AlarmCollection.Select(t => t.Desc).ToList()); }
|
|
|
|
|
|
|
|
|
+ /// <summary>
|
|
|
+ /// 解析文件的板件信息
|
|
|
+ /// </summary>
|
|
|
+ public SortingBoardLocation BoardInfo
|
|
|
+ {
|
|
|
+ get { return _BoardInfo; }
|
|
|
+ set
|
|
|
+ {
|
|
|
+ if (value != _BoardInfo)
|
|
|
+ {
|
|
|
+ _BoardInfo = value;
|
|
|
+ OnPropertyChanged(nameof(BoardInfo));
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ private SortingBoardLocation _BoardInfo;
|
|
|
+
|
|
|
+
|
|
|
/// <summary>
|
|
|
///
|
|
|
/// </summary>
|
|
@@ -189,53 +207,114 @@ namespace SCADA_DAQ.Customer.Machines
|
|
|
{
|
|
|
//角度计算与下方抓板角度计算一致
|
|
|
//拍照时先把角度转成相对应角度,避免吸盘撞机
|
|
|
- var rotation = 0m;
|
|
|
- var cupIndex = 0;
|
|
|
- //CenterX = (double)CurrentLabel.CenterX + (double)CurrentLabel.ActualWidth / 2;
|
|
|
- //CenterY = (double)CurrentLabel.CenterY + (double)CurrentLabel.ActualLength / 2;
|
|
|
+ //var cupIndex = 0;
|
|
|
+ //var rotation = 0m;
|
|
|
+ BoardInfo = new SortingBoardLocation();
|
|
|
CenterX = (double)CurrentLabel.CenterX;
|
|
|
CenterY = (double)CurrentLabel.CenterY;
|
|
|
+ BoardInfo.CupCenter = new Point(CenterX, CenterY);
|
|
|
+ //修改前
|
|
|
+ //var cup1Center = new Point(-140, -155);
|
|
|
+ //var cup3Center = new Point(135, -155);
|
|
|
+ //修改后
|
|
|
+ var cup1Center = new Point((int)CustomerEnv.SortingMacConfigValue.Cup1OriginOffset.X,
|
|
|
+ (int)CustomerEnv.SortingMacConfigValue.Cup1OriginOffset.Y);
|
|
|
+ var cup3Center = new Point((int)CustomerEnv.SortingMacConfigValue.Cup2OriginOffset.X,
|
|
|
+ (int)CustomerEnv.SortingMacConfigValue.Cup2OriginOffset.Y);
|
|
|
+
|
|
|
if ((CurrentLabel.ActualLength > 550 && CurrentLabel.ActualWidth > 200) ||
|
|
|
- (CurrentLabel.ActualWidth > 550 && CurrentLabel.ActualLength > 200))
|
|
|
+ (CurrentLabel.ActualWidth > 550 && CurrentLabel.ActualLength > 200)
|
|
|
+ )
|
|
|
{
|
|
|
+ BoardInfo.CupIndex = 2;
|
|
|
if (CurrentLabel.ActualWidth > CurrentLabel.ActualLength)
|
|
|
{
|
|
|
- rotation = -90;
|
|
|
+ BoardInfo.Rotation = -90;
|
|
|
+ BoardInfo.ReleaseY = CurrentLabel.ActualLength / 2 - 150;
|
|
|
+ //releaseY = CurrentLabel.ActualLength / 2 - 140;
|
|
|
+
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ BoardInfo.ReleaseY = CurrentLabel.ActualWidth / 2 - 150;
|
|
|
+ //BoardInfo.ReleaseY = CurrentLabel.ActualWidth / 2 - 140;
|
|
|
+
|
|
|
}
|
|
|
+
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
if ((CenterX > 600 && CurrentLabel.ActualLength > CurrentLabel.ActualWidth) || //靠近X轴且横着
|
|
|
(CenterX <= 600 && CurrentLabel.ActualLength < CurrentLabel.ActualWidth))
|
|
|
{
|
|
|
- cupIndex = 3;
|
|
|
+ BoardInfo.CupIndex = 3;
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
- cupIndex = 1;
|
|
|
+ BoardInfo.CupIndex = 1;
|
|
|
}
|
|
|
|
|
|
- if (cupIndex == 1)
|
|
|
+ if (BoardInfo.CupIndex == 1)
|
|
|
{
|
|
|
- if (CenterX > 600)
|
|
|
+ if (CenterX <= 600)
|
|
|
{
|
|
|
- rotation = -90;
|
|
|
+ if (CurrentLabel.ActualLength >= CurrentLabel.ActualWidth)
|
|
|
+ {
|
|
|
+ var cup1NewCenter = new Point(cup1Center.X, cup1Center.Y); //旋转后的坐标
|
|
|
+ BoardInfo.CupCenter = new Point(BoardInfo.CupCenter.X - cup1NewCenter.X, BoardInfo.CupCenter.Y - cup1NewCenter.Y);
|
|
|
+ BoardInfo.ReleaseY = CurrentLabel.ActualWidth / 2 - 180;
|
|
|
+ //BoardInfo.ReleaseY = CurrentLabel.ActualWidth / 2 - 170;
|
|
|
+
|
|
|
+ }
|
|
|
}
|
|
|
+ else
|
|
|
+ {
|
|
|
+ BoardInfo.Rotation = 90;
|
|
|
+ var cup1NewCenter = new Point(cup1Center.Y,-1 * (double)cup1Center.X); //旋转后的坐标
|
|
|
+ //cup3NewCenter.Offset(100, 32.5); //补偿夹具尺寸
|
|
|
+ BoardInfo.CupCenter = new Point(BoardInfo.CupCenter.X - cup1NewCenter.X, BoardInfo.CupCenter.Y - cup1NewCenter.Y);
|
|
|
+ //BoardInfo.ReleaseY = CurrentLabel.ActualWidth / 2;
|
|
|
+ BoardInfo.ReleaseY = CurrentLabel.ActualWidth / 2 - 180;
|
|
|
+ //BoardInfo.ReleaseY = CurrentLabel.ActualWidth / 2 - 20;
|
|
|
|
|
|
+
|
|
|
+ }
|
|
|
}
|
|
|
- else if (cupIndex == 3)
|
|
|
+ else if (BoardInfo.CupIndex == 3)
|
|
|
{
|
|
|
|
|
|
if (CenterX <= 600)
|
|
|
{
|
|
|
if (CurrentLabel.ActualLength < CurrentLabel.ActualWidth)
|
|
|
{
|
|
|
- rotation = 90;
|
|
|
+ BoardInfo.Rotation = -90;
|
|
|
+ var cup3NewCenter = new Point(cup3Center.Y * -1,(double)cup3Center.X); //旋转后的坐标
|
|
|
+ BoardInfo.CupCenter = new Point(BoardInfo.CupCenter.X - cup3NewCenter.X, BoardInfo.CupCenter.Y - cup3NewCenter.Y);
|
|
|
}
|
|
|
+ //BoardInfo.ReleaseY = CurrentLabel.ActualWidth / 2;
|
|
|
+ BoardInfo.ReleaseY = CurrentLabel.ActualWidth / 2 - 180;
|
|
|
+ //BoardInfo.ReleaseY = CurrentLabel.ActualWidth / 2 - 20;
|
|
|
+
|
|
|
+
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ var cup3NewCenter = new Point(cup3Center.X, (double)cup3Center.Y); //旋转后的坐标
|
|
|
+ BoardInfo.CupCenter = new Point(BoardInfo.CupCenter.X - cup3NewCenter.X, BoardInfo.CupCenter.Y - cup3NewCenter.Y);
|
|
|
+ //BoardInfo.ReleaseY = CurrentLabel.ActualWidth / 2 + 500;
|
|
|
+ BoardInfo.ReleaseY = CurrentLabel.ActualWidth / 2 - 30;
|
|
|
+ //BoardInfo.ReleaseY = CurrentLabel.ActualWidth / 2 - 20;
|
|
|
+
|
|
|
}
|
|
|
}
|
|
|
+ else
|
|
|
+ {
|
|
|
+ //BoardInfo.ReleaseY = CurrentLabel.ActualWidth / 2;
|
|
|
+ }
|
|
|
+
|
|
|
}
|
|
|
- GetListenReg(Tag_PhotoAngle).WriteObject(null,(float)rotation);
|
|
|
+
|
|
|
+ GetListenReg(Tag_PhotoAngle).WriteObject(null,(float)BoardInfo.Rotation);
|
|
|
GetListenReg(Tag_PhotographX).WriteObject(null,
|
|
|
(float)(CurrentLabel.X > originXOffset ? CurrentLabel.X - originXOffset : 0),
|
|
|
(float)(CurrentLabel.Y - cameraOriginy), (short)1);
|
|
@@ -322,143 +401,143 @@ namespace SCADA_DAQ.Customer.Machines
|
|
|
//var centerY = (double)CurrentLabel.CenterY + (double)CurrentLabel.ActualLength / 2;
|
|
|
|
|
|
//var cupCenter = new Point((double)CurrentLabel.X, (double)CurrentLabel.Y);
|
|
|
- var cupCenter = new Point(CenterX, CenterY);
|
|
|
- var cup1Center = new Point(-140, -155);
|
|
|
- var cup3Center = new Point(135, -155);
|
|
|
- var releaseY = 0m;
|
|
|
+ //var cupCenter = new Point(CenterX, CenterY);
|
|
|
+ //var cup1Center = new Point(-140, -155);
|
|
|
+ //var cup3Center = new Point(135, -155);
|
|
|
+ //var BoardInfo.RelaeaseY = 0m;
|
|
|
if (!isCancel)
|
|
|
{
|
|
|
if (_lbl.ID == CurrentLabel.ID)
|
|
|
{
|
|
|
Log.Info($"开始处理,{CurrentLabel.ID}");
|
|
|
- var cupIndex = 0;
|
|
|
- var rotation = 0m;
|
|
|
- if ((CurrentLabel.ActualLength > 550 && CurrentLabel.ActualWidth > 200) ||
|
|
|
- (CurrentLabel.ActualWidth > 550 && CurrentLabel.ActualLength > 200)
|
|
|
- )
|
|
|
- {
|
|
|
- cupIndex = 2;
|
|
|
- if (CurrentLabel.ActualWidth > CurrentLabel.ActualLength)
|
|
|
- {
|
|
|
- rotation = -90;
|
|
|
- releaseY = CurrentLabel.ActualLength / 2 - 150;
|
|
|
- //releaseY = CurrentLabel.ActualLength / 2 - 140;
|
|
|
-
|
|
|
- }
|
|
|
- else
|
|
|
- {
|
|
|
- releaseY = CurrentLabel.ActualWidth / 2 - 150;
|
|
|
- //releaseY = CurrentLabel.ActualWidth / 2 - 140;
|
|
|
-
|
|
|
- }
|
|
|
-
|
|
|
- }
|
|
|
- else
|
|
|
- {
|
|
|
- if ((CenterX > 600 && CurrentLabel.ActualLength > CurrentLabel.ActualWidth) || //靠近X轴且横着
|
|
|
- (CenterX <= 600 && CurrentLabel.ActualLength < CurrentLabel.ActualWidth))
|
|
|
- {
|
|
|
- cupIndex = 3;
|
|
|
- }
|
|
|
- else
|
|
|
- {
|
|
|
- cupIndex = 1;
|
|
|
- }
|
|
|
-
|
|
|
- if (cupIndex == 1)
|
|
|
- {
|
|
|
- if (CenterX <= 600)
|
|
|
- {
|
|
|
- if (CurrentLabel.ActualLength >= CurrentLabel.ActualWidth)
|
|
|
- {
|
|
|
- var cup1NewCenter = new Point(cup1Center.X, cup1Center.Y); //旋转后的坐标
|
|
|
- cupCenter = new Point(cupCenter.X - cup1NewCenter.X, cupCenter.Y - cup1NewCenter.Y);
|
|
|
- releaseY = CurrentLabel.ActualWidth / 2 - 180;
|
|
|
- //releaseY = CurrentLabel.ActualWidth / 2 - 170;
|
|
|
-
|
|
|
- }
|
|
|
- }
|
|
|
- else
|
|
|
- {
|
|
|
- rotation = -90;
|
|
|
- var cup3NewCenter = new Point(-1 * cup1Center.Y, (double)cup1Center.X); //旋转后的坐标
|
|
|
- //cup3NewCenter.Offset(100, 32.5); //补偿夹具尺寸
|
|
|
- cupCenter = new Point(cupCenter.X - cup3NewCenter.X, cupCenter.Y - cup3NewCenter.Y);
|
|
|
- //releaseY = CurrentLabel.ActualWidth / 2;
|
|
|
- releaseY = CurrentLabel.ActualWidth / 2 - 30;
|
|
|
- //releaseY = CurrentLabel.ActualWidth / 2 - 20;
|
|
|
-
|
|
|
-
|
|
|
- }
|
|
|
- }
|
|
|
- else if (cupIndex == 3)
|
|
|
- {
|
|
|
-
|
|
|
- if (CenterX <= 600)
|
|
|
- {
|
|
|
- if (CurrentLabel.ActualLength < CurrentLabel.ActualWidth)
|
|
|
- {
|
|
|
- rotation = 90;
|
|
|
- var cup3NewCenter = new Point(cup3Center.Y, -1 * (double)cup3Center.X); //旋转后的坐标
|
|
|
- cupCenter = new Point(cupCenter.X - cup3NewCenter.X, cupCenter.Y - cup3NewCenter.Y);
|
|
|
- }
|
|
|
- //releaseY = CurrentLabel.ActualWidth / 2;
|
|
|
- releaseY = CurrentLabel.ActualWidth / 2 - 30;
|
|
|
- //releaseY = CurrentLabel.ActualWidth / 2 - 20;
|
|
|
-
|
|
|
-
|
|
|
- }
|
|
|
- else
|
|
|
- {
|
|
|
- var cup3NewCenter = new Point(cup3Center.X, (double)cup3Center.Y); //旋转后的坐标
|
|
|
- cupCenter = new Point(cupCenter.X - cup3NewCenter.X, cupCenter.Y - cup3NewCenter.Y);
|
|
|
- //releaseY = CurrentLabel.ActualWidth / 2 + 500;
|
|
|
- releaseY = CurrentLabel.ActualWidth / 2 - 30;
|
|
|
- //releaseY = CurrentLabel.ActualWidth / 2 - 20;
|
|
|
-
|
|
|
- }
|
|
|
- }
|
|
|
- else
|
|
|
- {
|
|
|
- //releaseY = CurrentLabel.ActualWidth / 2;
|
|
|
-
|
|
|
- }
|
|
|
-
|
|
|
- }
|
|
|
+ //var cupIndex = 0;
|
|
|
+ //var rotation = 0m;
|
|
|
+ //if ((CurrentLabel.ActualLength > 550 && CurrentLabel.ActualWidth > 200) ||
|
|
|
+ // (CurrentLabel.ActualWidth > 550 && CurrentLabel.ActualLength > 200)
|
|
|
+ // )
|
|
|
+ //{
|
|
|
+ // cupIndex = 2;
|
|
|
+ // if (CurrentLabel.ActualWidth > CurrentLabel.ActualLength)
|
|
|
+ // {
|
|
|
+ // rotation = -90;
|
|
|
+ // releaseY = CurrentLabel.ActualLength / 2 - 150;
|
|
|
+ // //releaseY = CurrentLabel.ActualLength / 2 - 140;
|
|
|
+
|
|
|
+ // }
|
|
|
+ // else
|
|
|
+ // {
|
|
|
+ // releaseY = CurrentLabel.ActualWidth / 2 - 150;
|
|
|
+ // //releaseY = CurrentLabel.ActualWidth / 2 - 140;
|
|
|
+
|
|
|
+ // }
|
|
|
+
|
|
|
+ //}
|
|
|
+ //else
|
|
|
+ //{
|
|
|
+ // if ((CenterX > 600 && CurrentLabel.ActualLength > CurrentLabel.ActualWidth) || //靠近X轴且横着
|
|
|
+ // (CenterX <= 600 && CurrentLabel.ActualLength < CurrentLabel.ActualWidth))
|
|
|
+ // {
|
|
|
+ // cupIndex = 3;
|
|
|
+ // }
|
|
|
+ // else
|
|
|
+ // {
|
|
|
+ // cupIndex = 1;
|
|
|
+ // }
|
|
|
+
|
|
|
+ // if (cupIndex == 1)
|
|
|
+ // {
|
|
|
+ // if (CenterX <= 600)
|
|
|
+ // {
|
|
|
+ // if (CurrentLabel.ActualLength >= CurrentLabel.ActualWidth)
|
|
|
+ // {
|
|
|
+ // var cup1NewCenter = new Point(cup1Center.X, cup1Center.Y); //旋转后的坐标
|
|
|
+ // cupCenter = new Point(cupCenter.X - cup1NewCenter.X, cupCenter.Y - cup1NewCenter.Y);
|
|
|
+ // releaseY = CurrentLabel.ActualWidth / 2 - 180;
|
|
|
+ // //releaseY = CurrentLabel.ActualWidth / 2 - 170;
|
|
|
+
|
|
|
+ // }
|
|
|
+ // }
|
|
|
+ // else
|
|
|
+ // {
|
|
|
+ // rotation = -90;
|
|
|
+ // var cup3NewCenter = new Point(-1 * cup1Center.Y, (double)cup1Center.X); //旋转后的坐标
|
|
|
+ // //cup3NewCenter.Offset(100, 32.5); //补偿夹具尺寸
|
|
|
+ // cupCenter = new Point(cupCenter.X - cup3NewCenter.X, cupCenter.Y - cup3NewCenter.Y);
|
|
|
+ // //releaseY = CurrentLabel.ActualWidth / 2;
|
|
|
+ // releaseY = CurrentLabel.ActualWidth / 2 - 30;
|
|
|
+ // //releaseY = CurrentLabel.ActualWidth / 2 - 20;
|
|
|
+
|
|
|
+
|
|
|
+ // }
|
|
|
+ // }
|
|
|
+ // else if (cupIndex == 3)
|
|
|
+ // {
|
|
|
+
|
|
|
+ // if (CenterX <= 600)
|
|
|
+ // {
|
|
|
+ // if (CurrentLabel.ActualLength < CurrentLabel.ActualWidth)
|
|
|
+ // {
|
|
|
+ // rotation = 90;
|
|
|
+ // var cup3NewCenter = new Point(cup3Center.Y, -1 * (double)cup3Center.X); //旋转后的坐标
|
|
|
+ // cupCenter = new Point(cupCenter.X - cup3NewCenter.X, cupCenter.Y - cup3NewCenter.Y);
|
|
|
+ // }
|
|
|
+ // //releaseY = CurrentLabel.ActualWidth / 2;
|
|
|
+ // releaseY = CurrentLabel.ActualWidth / 2 - 30;
|
|
|
+ // //releaseY = CurrentLabel.ActualWidth / 2 - 20;
|
|
|
+
|
|
|
+
|
|
|
+ // }
|
|
|
+ // else
|
|
|
+ // {
|
|
|
+ // var cup3NewCenter = new Point(cup3Center.X, (double)cup3Center.Y); //旋转后的坐标
|
|
|
+ // cupCenter = new Point(cupCenter.X - cup3NewCenter.X, cupCenter.Y - cup3NewCenter.Y);
|
|
|
+ // //releaseY = CurrentLabel.ActualWidth / 2 + 500;
|
|
|
+ // releaseY = CurrentLabel.ActualWidth / 2 - 30;
|
|
|
+ // //releaseY = CurrentLabel.ActualWidth / 2 - 20;
|
|
|
+
|
|
|
+ // }
|
|
|
+ // }
|
|
|
+ // else
|
|
|
+ // {
|
|
|
+ // //releaseY = CurrentLabel.ActualWidth / 2;
|
|
|
+ // }
|
|
|
+
|
|
|
+ //}
|
|
|
+ var rotation = BoardInfo.Rotation;
|
|
|
var releaseRotation = rotation == -90 ? -90 : 90;
|
|
|
var releaseXOffset = 0f;
|
|
|
- if (cupIndex != 2)
|
|
|
+ if (BoardInfo.CupIndex != 2)
|
|
|
{
|
|
|
- releaseXOffset = releaseRotation == 90 ? 155f : -155f;
|
|
|
+ releaseXOffset = releaseRotation == 90 ? -155f : 155f;
|
|
|
|
|
|
}
|
|
|
- releaseY = Math.Max(10, releaseY);
|
|
|
+ BoardInfo.ReleaseY = Math.Max(10, BoardInfo.ReleaseY);
|
|
|
rotation += _lbl.R;
|
|
|
|
|
|
- var moveX = (float)((double)_lbl.X + cupCenter.X);
|
|
|
+ var moveX = (float)((double)_lbl.X + BoardInfo.CupCenter.X);
|
|
|
moveX = moveX > originXOffset ? moveX - originXOffset : 0;
|
|
|
- var moveY = (float)((double)_lbl.Y + cupCenter.Y);
|
|
|
- if (((double)_lbl.X + cupCenter.X) > 0 && ((double)_lbl.Y + cupCenter.Y) > 0)
|
|
|
+ var moveY = (float)((double)_lbl.Y + BoardInfo.CupCenter.Y);
|
|
|
+ if (moveX < GetListenReg(Tag_XMaxLimitPos).ScaleValue && moveY < 2800)
|
|
|
{
|
|
|
GetListenReg(Tag_CaptureX).WriteObject(null,
|
|
|
moveX, //D1512
|
|
|
moveY, //D1514
|
|
|
(float)rotation, //D1516
|
|
|
(short)1, // D1518
|
|
|
- (short)cupIndex, // D1519.
|
|
|
+ (short)BoardInfo.CupIndex, // D1519.
|
|
|
(float)18.0, // D1520 //厚度
|
|
|
(float)470 + releaseXOffset, // D1522 放板位置X
|
|
|
- (float)releaseY, // D1524 放板位置Y
|
|
|
+ (float)BoardInfo.ReleaseY, // D1524 放板位置Y
|
|
|
(float)releaseRotation //放板角度
|
|
|
);
|
|
|
|
|
|
- CupMove?.Invoke(this, new CupMoveEventArgs() { X = (double)_lbl.X + cupCenter.X, Y = (double)_lbl.Y + cupCenter.Y, R = (double)rotation, CupIndex = cupIndex });
|
|
|
+ CupMove?.Invoke(this, new CupMoveEventArgs() { X = (double)_lbl.X + BoardInfo.CupCenter.X, Y = (double)_lbl.Y + BoardInfo.CupCenter.Y, R = (double)rotation, CupIndex = BoardInfo.CupIndex });
|
|
|
|
|
|
- Log.Info($"正在分拣:{CurrentLabel.ID},X:{moveX},Y:{moveY},角度:{rotation},吸盘:{cupIndex}");
|
|
|
+ Log.Info($"正在分拣:{CurrentLabel.ID},X:{moveX},Y:{moveY},角度:{rotation},吸盘:{BoardInfo.CupIndex}");
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
- Log.Info("位置错误");
|
|
|
+ Log.Warn($"位置错误,取料X坐标为{moveX},Y坐标为{moveY}");
|
|
|
}
|
|
|
}
|
|
|
else
|
|
@@ -501,6 +580,7 @@ namespace SCADA_DAQ.Customer.Machines
|
|
|
OnPropertyChanged(nameof(AlarmStr));
|
|
|
}
|
|
|
|
|
|
+
|
|
|
private string CycFilePath(params int[] values)
|
|
|
{
|
|
|
var str = "";
|