|
@@ -187,15 +187,31 @@ namespace SCADA_DAQ.Customer.Machines
|
|
|
//Labels = new ObservableCollection<LabelModel>(_Lbls);
|
|
|
var errorCount = 0;
|
|
|
var end = false;
|
|
|
-
|
|
|
+ if (BaseDevice.Simulated)
|
|
|
+ {
|
|
|
+ end = true;
|
|
|
+ _Lbls = GetLabes(File.FilePath);
|
|
|
+ Labels = new ObservableCollection<LabelModel>(_Lbls);
|
|
|
+ }
|
|
|
while (!end)
|
|
|
{
|
|
|
if (CuttingMac.isConnected())
|
|
|
{
|
|
|
var ncName = new int[40];
|
|
|
CuttingMac.READ_plc_register(7200, 7240, out ncName);
|
|
|
- _Lbls = GetLabes(CycFilePath(ncName));
|
|
|
- Labels = new ObservableCollection<LabelModel>(_Lbls);
|
|
|
+ var path = CycFilePath(ncName);
|
|
|
+ if (path != null)
|
|
|
+ {
|
|
|
+ _Lbls = GetLabes(path);
|
|
|
+ Labels = new ObservableCollection<LabelModel>(_Lbls);
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+
|
|
|
+ MessageBox.Show($"文件不存在");
|
|
|
+ GetListenReg(Tag_Reset).SetBit();
|
|
|
+
|
|
|
+ }
|
|
|
end = true;
|
|
|
}
|
|
|
else
|
|
@@ -352,10 +368,11 @@ namespace SCADA_DAQ.Customer.Machines
|
|
|
reg.ResetBit();
|
|
|
}
|
|
|
else if (reg.Comment.Variable == Tag_CameraMoveOK && reg.Value == 1 && reg.OldValue == 0)
|
|
|
- {
|
|
|
+ {
|
|
|
//var _lbl = new LabelModel() { ID = CurrentLabel.ID };
|
|
|
var _lbl = new LabelModel();
|
|
|
var isCancel = false;
|
|
|
+ GetListenReg(Tag_AAutoSpeed).WriteReg(CustomerEnv.SortingMacConfigValue.AxisAAutoHighSpeed);
|
|
|
if (GetListenReg(Tag_CameraEnable).Value == 0)
|
|
|
{
|
|
|
_barcodeReader = MachineServer.GetInstance().GetMachine<SampleBarcodeReader>("BarcodeReader4");
|
|
@@ -415,113 +432,12 @@ namespace SCADA_DAQ.Customer.Machines
|
|
|
{
|
|
|
_lbl.ID = CurrentLabel.ID;
|
|
|
}
|
|
|
-
|
|
|
- //var centerX = (double)CurrentLabel.CenterX + (double)CurrentLabel.ActualWidth / 2;
|
|
|
- //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 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 rotation = BoardInfo.Rotation;
|
|
|
var releaseRotation = rotation == -90 ? -90 : 90;
|
|
|
var releaseXOffset = 0f;
|
|
@@ -535,9 +451,17 @@ namespace SCADA_DAQ.Customer.Machines
|
|
|
|
|
|
var moveX = (float)((double)_lbl.X + BoardInfo.CupCenter.X);
|
|
|
moveX = moveX > originXOffset ? moveX - originXOffset : 0;
|
|
|
- var moveY = (float)((double)_lbl.Y + BoardInfo.CupCenter.Y);
|
|
|
+ var moveY = (float)((double)_lbl.Y + BoardInfo.CupCenter.Y);
|
|
|
if (moveX < GetListenReg(Tag_XMaxLimitPos).ScaleValue && moveY < 2800)
|
|
|
{
|
|
|
+ if (Math.Max(CurrentLabel.ActualLength, CurrentLabel.ActualWidth) >= 1500)
|
|
|
+ {
|
|
|
+ GetListenReg(Tag_AAutoSpeed).WriteReg(CustomerEnv.SortingMacConfigValue.AxisAAutoLowSpeed);
|
|
|
+ }
|
|
|
+ if (Math.Max(CurrentLabel.ActualLength, CurrentLabel.ActualWidth) >= 2400)
|
|
|
+ {
|
|
|
+ releaseXOffset -= 200;
|
|
|
+ }
|
|
|
GetListenReg(Tag_CaptureX).WriteObject(null,
|
|
|
moveX, //D1512
|
|
|
moveY, //D1514
|
|
@@ -549,7 +473,7 @@ namespace SCADA_DAQ.Customer.Machines
|
|
|
(float)BoardInfo.ReleaseY, // D1524 放板位置Y
|
|
|
(float)releaseRotation //放板角度
|
|
|
);
|
|
|
-
|
|
|
+
|
|
|
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},吸盘:{BoardInfo.CupIndex}");
|