1、优化当飞拍穴位定位失败后定拍时,先检测穴位有无,无产品自动跳过,有产品才3次定拍。

develop
lhiven 2 months ago
parent 77f3775a65
commit c9323fda1a

@ -54,7 +54,7 @@ namespace Rs.MotionPlat
string logFileName = "";
string regstr = tf.Index+"_(\\d{0,10}).txt";
//打印日志
string logDir = $"d:\\log\\debug\\{DateTime.Now.ToString("yyyyMMdd")}";
string logDir = $"d:\\log\\communication\\{DateTime.Now.ToString("yyyyMMdd")}";
if (!Directory.Exists(logDir))
{
Directory.CreateDirectory(logDir);

@ -386,106 +386,122 @@ namespace Rs.MotionPlat.Flow
bool exit = false;
while (!exit)
{
ProductLocationResult fixtureret = FixedGrabProductFlow.Instance.TakePicture(ETrayType.Input, ret.SlotIndex);
if (fixtureret.Result == EOneGrabSixteenResult.Ok)
//先进行有无料判断
ProductLocationResult fixtureret = FixedGrabProductFlow.Instance.TakePicture(ETrayType.Input, ret.SlotIndex,1,true);
if (fixtureret.Result == EOneGrabSixteenResult.NoHaveProdut)
{
if(fixtureret.SN.Length==GlobalVar.BarcodeLength)
{
ret.Change(fixtureret.SN, fixtureret.OffsetX, fixtureret.OffsetY);
//takeSlotIndex++;
StockTakeFlow.Instance.Take(ETrayType.Input, takeSlotIndex, NozzleManager.GetIdelNozzle().NozzleIndex);
takeSlotIndex++;
flowStep = EDischargeFlowStep.;
exit = true;
}
else
{
//报警弹框
alarmEntity = AlarmCollection.Get(AlarmConstID.).Transform(ret.SlotIndex);
EButtonType buttonSelect = Msgbox.ShowDialog(alarmEntity, EButtonType.Retry, true);
if (buttonSelect == EButtonType.Retry)
{
logInfo = GetClassName() + "选择了重试";
MessageQueue.Instance.Insert(logInfo);
}
}
logInfo = GetClassName() + $"视觉检测到穴位{ret.SlotIndex}无料,自动跳过";
LogHelper.Debug(logInfo);
exit = true;
GlobalTray.InputTray.ChangeStatus(ret.SlotIndex, ESlotStatus.NotHave);
takeSlotIndex++;
flowStep = EDischargeFlowStep.;
}
else if (fixtureret.Result == EOneGrabSixteenResult.LocationOkScanBarcodeFail)
else if (fixtureret.Result == EOneGrabSixteenResult.Slant)
{
Nozzle idleNozzle = NozzleManager.GetIdelNozzle();
if(false)
logInfo = GetClassName() + $"视觉检测到穴位{ret.SlotIndex}有料";
LogHelper.Debug(logInfo);
fixtureret = FixedGrabProductFlow.Instance.TakePicture(ETrayType.Input, ret.SlotIndex);
if (fixtureret.Result == EOneGrabSixteenResult.Ok)
{
StockTakeFlow.Instance.Take(ETrayType.Input, ret.SlotIndex, idleNozzle.NozzleIndex);
//放料
TraySlot noProductSlot = GlobalTray.RetestTray.GetSlot(ESlotStatus.NotHave);
if (noProductSlot != null)
if (fixtureret.SN.Length == GlobalVar.BarcodeLength)
{
StockPlaceFlow.Instance.Place(ETrayType.ReTest, noProductSlot.Index, idleNozzle.NozzleIndex);
ret.Change(fixtureret.SN, fixtureret.OffsetX, fixtureret.OffsetY);
//takeSlotIndex++;
StockTakeFlow.Instance.Take(ETrayType.Input, takeSlotIndex, NozzleManager.GetIdelNozzle().NozzleIndex);
takeSlotIndex++;
flowStep = EDischargeFlowStep.;
exit = true;
}
else
{
Msgbox.ShowTipDialog(EButtonType.Ok, "Retest tray full,please change tray and click ok button", "tip", true);
GlobalTray.RetestTray.ChangeStatus(ESlotStatus.NotHave);
ThreePointLocationFlow.Instance.Location(ETrayType.ReTest);
//放料
noProductSlot = GlobalTray.RetestTray.GetSlot(ESlotStatus.NotHave);
StockPlaceFlow.Instance.Place(ETrayType.ReTest, noProductSlot.Index, idleNozzle.NozzleIndex);
//报警弹框
alarmEntity = AlarmCollection.Get(AlarmConstID.).Transform(ret.SlotIndex);
EButtonType buttonSelect = Msgbox.ShowDialog(alarmEntity, EButtonType.Retry, true);
if (buttonSelect == EButtonType.Retry)
{
logInfo = GetClassName() + "选择了重试";
MessageQueue.Instance.Insert(logInfo);
}
}
takeSlotIndex++;
flowStep = EDischargeFlowStep.;
exit = true;
}
else
else if (fixtureret.Result == EOneGrabSixteenResult.LocationOkScanBarcodeFail)
{
StockTakeFlow.Instance.Take(ETrayType.Input, ret.SlotIndex, idleNozzle.NozzleIndex);
if(NozzleManager.GetNozzle(idleNozzle.NozzleIndex).Product!=null)
Nozzle idleNozzle = NozzleManager.GetIdelNozzle();
if (false)
{
NozzleManager.GetNozzle(idleNozzle.NozzleIndex).Product.SN = "SLK11111111PNK60X";
StockTakeFlow.Instance.Take(ETrayType.Input, ret.SlotIndex, idleNozzle.NozzleIndex);
//放料
TraySlot noProductSlot = GlobalTray.RetestTray.GetSlot(ESlotStatus.NotHave);
if (noProductSlot != null)
{
StockPlaceFlow.Instance.Place(ETrayType.ReTest, noProductSlot.Index, idleNozzle.NozzleIndex);
}
else
{
Msgbox.ShowTipDialog(EButtonType.Ok, "Retest tray full,please change tray and click ok button", "tip", true);
GlobalTray.RetestTray.ChangeStatus(ESlotStatus.NotHave);
ThreePointLocationFlow.Instance.Location(ETrayType.ReTest);
//放料
noProductSlot = GlobalTray.RetestTray.GetSlot(ESlotStatus.NotHave);
StockPlaceFlow.Instance.Place(ETrayType.ReTest, noProductSlot.Index, idleNozzle.NozzleIndex);
}
takeSlotIndex++;
flowStep = EDischargeFlowStep.;
exit = true;
}
takeSlotIndex++;
exit = true;
flowStep = EDischargeFlowStep.;
}
}
else if (fixtureret.Result == EOneGrabSixteenResult.Slant)
{
//报警弹框
alarmEntity = AlarmCollection.Get(AlarmConstID.).Transform(ret.SlotIndex);
EButtonType buttonSelect = Msgbox.ShowDialog(alarmEntity, EButtonType.Skip | EButtonType.Retry | EButtonType.EndInput, true);
//EButtonType buttonSelect = Msgbox.ShowDialog(EButtonType.Skip | EButtonType.Retry | EButtonType.EndInput, $"穴位{ret.SlotIndex}定位失败,请把产品手动取走后点击跳过","tip",true);
if(buttonSelect== EButtonType.Retry)
{
logInfo = GetClassName() + "选择了重试";
MessageQueue.Instance.Insert(logInfo);
}
else if (buttonSelect == EButtonType.Skip)
{
logInfo = GetClassName() + "选择了跳过";
MessageQueue.Instance.Insert(logInfo);
exit = true;
GlobalTray.InputTray.ChangeStatus(ret.SlotIndex, ESlotStatus.NotHave);
takeSlotIndex++;
flowStep = EDischargeFlowStep.;
else
{
StockTakeFlow.Instance.Take(ETrayType.Input, ret.SlotIndex, idleNozzle.NozzleIndex);
if (NozzleManager.GetNozzle(idleNozzle.NozzleIndex).Product != null)
{
NozzleManager.GetNozzle(idleNozzle.NozzleIndex).Product.SN = "SLK11111111PNK60X";
}
takeSlotIndex++;
exit = true;
flowStep = EDischargeFlowStep.;
}
}
else if (buttonSelect == EButtonType.EndInput)
else if (fixtureret.Result == EOneGrabSixteenResult.Slant)
{
logInfo = GetClassName() + "选择了结束上料";
MessageQueue.Instance.Insert(logInfo);
exit = true;
GlobalVar.Clear = true;
takeSlotIndex++;
flowStep = EDischargeFlowStep.;
//报警弹框
alarmEntity = AlarmCollection.Get(AlarmConstID.).Transform(ret.SlotIndex);
EButtonType buttonSelect = Msgbox.ShowDialog(alarmEntity, EButtonType.Skip | EButtonType.Retry | EButtonType.EndInput, true);
//EButtonType buttonSelect = Msgbox.ShowDialog(EButtonType.Skip | EButtonType.Retry | EButtonType.EndInput, $"穴位{ret.SlotIndex}定位失败,请把产品手动取走后点击跳过","tip",true);
if (buttonSelect == EButtonType.Retry)
{
logInfo = GetClassName() + "选择了重试";
MessageQueue.Instance.Insert(logInfo);
}
else if (buttonSelect == EButtonType.Skip)
{
logInfo = GetClassName() + "选择了跳过";
MessageQueue.Instance.Insert(logInfo);
exit = true;
GlobalTray.InputTray.ChangeStatus(ret.SlotIndex, ESlotStatus.NotHave);
takeSlotIndex++;
flowStep = EDischargeFlowStep.;
}
else if (buttonSelect == EButtonType.EndInput)
{
logInfo = GetClassName() + "选择了结束上料";
MessageQueue.Instance.Insert(logInfo);
exit = true;
GlobalVar.Clear = true;
takeSlotIndex++;
flowStep = EDischargeFlowStep.;
}
}
}
else if(fixtureret.Result== EOneGrabSixteenResult.NoHaveProdut)
{
logInfo =GetClassName()+ $"视觉检测到穴位{ret.SlotIndex}无料,自动跳过";
exit = true;
GlobalTray.InputTray.ChangeStatus(ret.SlotIndex, ESlotStatus.NotHave);
takeSlotIndex++;
flowStep = EDischargeFlowStep.;
//else if (fixtureret.Result == EOneGrabSixteenResult.NoHaveProdut)
//{
// logInfo = GetClassName() + $"视觉检测到穴位{ret.SlotIndex}无料,自动跳过";
// exit = true;
// GlobalTray.InputTray.ChangeStatus(ret.SlotIndex, ESlotStatus.NotHave);
// takeSlotIndex++;
// flowStep = EDischargeFlowStep.判断是否需要从料仓取料;
//}
}
}

@ -268,10 +268,10 @@ namespace Rs.MotionPlat.Flow
}
break;
case EGrrFlowStep.:
if(VisionHelper.oneGrabOneVision.ClearQueue())
if(VisionHelper.oneGrabOneVision.ClearQueue("C"))
{
UpCameraHelper.Grab();
string msg = VisionHelper.OneGrabOne();//.Grab(EVisionScene.SingleScanBarcode);
string msg = VisionHelper.OneGrabOne("M");//.Grab(EVisionScene.SingleScanBarcode);
if(!string.IsNullOrEmpty(msg))
{
vProductResult.Parse(msg);

@ -1,517 +0,0 @@
using Rs.Controls;
using Rs.Framework;
using Rs.Motion;
using Rs.MotionPlat.Commom;
using Rs.MotionPlat.Entitys;
using Rs.MotionPlat.Flow.Common;
using Rs.MotionPlat.Flow.NormalFlow;
using Rs.MotionPlat.Flow.SafePosFlow;
using Rs.MotionPlat.Vision;
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
namespace Rs.MotionPlat.Flow.SubFlow
{
enum EFiveProductTestFlowStep
{
OK,
,
,
,
,
,
,
,
,
,
,
,
,
,
,
,
,
}
public class FiveProductTestFlow
{
private Task mainTask;
private FiveProductTestFlow() { }
private static FiveProductTestFlow instance;
public static FiveProductTestFlow Instance
{
get
{
if (instance == null)
{
instance = new FiveProductTestFlow();
}
return instance;
}
}
private AlarmEntity alarmEntity;
Stopwatch timeout = new Stopwatch();
EFiveProductTestFlowStep flowStep = EFiveProductTestFlowStep.OK;
int scanNum = 0;
string logInfo = string.Empty;
string alarmInfo = string.Empty;
private bool stop = true;
private bool run = true;
TargetPosition targetPosition = new TargetPosition();
ErrorCode errCode = ErrorCode.Ok;
/// <summary>
/// 当前取料穴位
/// </summary>
TraySlot curTakeSlot = null;
/// <summary>
/// 当前取料穴位的点位
/// </summary>
SlotPoint curTakeSlotPoint = null;
//Nozzle curNozzle = null;
Nozzle curTakeNozzle = null;
Nozzle curDumpNozzle = null;
TestFixture curFixture = null;
//放料穴位
TraySlot curDumpSlot = null;
/// <summary>
/// 最后一次换料的治具编号
/// </summary>
private int lastFixtureIndex = 0;
/// <summary>
/// 已经取走的产品数量
/// </summary>
private int takedNum = 0;
//相机拍照结果
VisionResult vResult = new VisionResult();
ProductLocationResult vProductResult = new ProductLocationResult();
List<TestFixture> needGrrFixtureList = new List<TestFixture>();
/// <summary>
/// 测试完成的数量
/// </summary>
private int testFinishedNum = 0;
private void Reset()
{
curTakeSlot = null;
curTakeSlotPoint = null;
curTakeNozzle = null;
curDumpNozzle = null;
curFixture = null;
curDumpSlot = null;
lastFixtureIndex = 0;
takedNum = 0;
testFinishedNum = 0;
VirtualBarCode.Reset();
}
bool binit = false;
public void Init()
{
if(binit)
{
return;
}
binit = true;
mainTask = new Task(Run);
mainTask.Start();
}
public void Deinit()
{
run = false;
}
int takeNum = 0;
private void Run()
{
while (run)
{
if (stop)
{
Thread.Sleep(10);
continue;
}
switch (flowStep)
{
#region 料仓取料
case EFiveProductTestFlowStep.OK:
ThreePointLocationFlow.Instance.Location(ETrayType.Ok);
flowStep = EFiveProductTestFlowStep.;
break;
case EFiveProductTestFlowStep.:
//GlobalTray.InputTray.ChangeStatus(1, ESlotStatus.Have);
//GlobalTray.InputTray.ChangeStatus(2, ESlotStatus.Have);
//GlobalTray.InputTray.ChangeStatus(3, ESlotStatus.Have);
//GlobalTray.InputTray.ChangeStatus(4, ESlotStatus.Have);
//GlobalTray.InputTray.ChangeStatus(5, ESlotStatus.Have);
curTakeSlot = GlobalTray.InputTray.GetSlot(ESlotStatus.Have);
if (curTakeSlot != null)
{
curTakeSlotPoint = TrayPointManager.GetSlotPoint(ETrayType.Input, curTakeSlot.Index);
if (curTakeSlotPoint != null)
{
targetPosition.X = curTakeSlotPoint.X;
targetPosition.Y1 = GlobalVar.StockSideY1;
targetPosition.Y2 = curTakeSlotPoint.Y;
//double curLoadX = Ops.GetCurPosition(AxisControl.LoadX);
//if (curLoadX - GlobalVar.FixtureSafePosX > 50)
//{
// DischargeModuleGoSafePosFlow.Instance.GoSafePostion(ESafePosSide.PlaceToStock);
//}
if (GroupAxisMove.XY1Y2MovePos(targetPosition, GlobalVar.WholeSpeed, EGoWhichSide.StockSide))
{
AxisPosPrint.PrintXY1Y2TargetPos("轴loadx,loady1,loady2已停止运动,", targetPosition, GetClassName());
flowStep = EFiveProductTestFlowStep.;
}
}
}
else
{
//没有料了,判断是否需要换料
GlobalTray.GrabTray.ChangeStatus(ESlotStatus.Have);
}
break;
case EFiveProductTestFlowStep.:
if (Ops.IsStop("LoadX", "LoadY1", "LoadY2"))
{
AxisPosPrint.PrintXY1Y2CurrentPos("轴loadx,loady1,loady2已停止运动,", GetClassName());
if (AxisArrived.LoadXY1Y2IsArrived(targetPosition.X, targetPosition.Y1, targetPosition.Y2))
{
AxisPosPrint.PrintXY1Y2CurrentPos("已运动到料仓拍照位上方,", GetClassName());
flowStep = EFiveProductTestFlowStep.;
}
else
{
flowStep = EFiveProductTestFlowStep.;
}
}
break;
case EFiveProductTestFlowStep.:
UpCameraHelper.Grab();
string msg = VisionHelper.OneGrabOne();//.Grab(EVisionScene.SingleScanBarcode);
vProductResult.Parse(msg);
if (vProductResult != null && (vProductResult.Result == EOneGrabSixteenResult.Ok || vProductResult.Result== EOneGrabSixteenResult.LocationOkScanBarcodeFail))
{
flowStep = EFiveProductTestFlowStep.;
}
else if (vProductResult != null && vProductResult.Result == EOneGrabSixteenResult.LocationOkScanBarcodeFail)
{
GrrScanFailFrm scanFail = new GrrScanFailFrm((act, qrcode) => {
if (act == 1)
{
vProductResult.SN = qrcode;
flowStep = EFiveProductTestFlowStep.;
}
});
scanFail.ShowDialog();
//vProductResult.SN = VirtualBarCode.Code;
}
else
{
alarmEntity = AlarmCollection.Get(AlarmConstID.);
Msgbox.ShowDialog(alarmEntity, EButtonType.Retry);
}
break;
case EFiveProductTestFlowStep.:
//获取空闲吸嘴
//curTakeNozzle = NozzleManager.GetIdelNozzle();
curTakeNozzle = NozzleManager.GetNozzle(1);
if (curTakeNozzle != null)
{
targetPosition = NozzleManager.GetToTraySlot(ETrayType.Input, curTakeSlot.Index, curTakeNozzle.NozzleIndex);
if (curTakeNozzle != null)
{
targetPosition.X += vProductResult.OffsetX + offsetX;
targetPosition.Y2 += vProductResult.OffsetY + offsetY;
if (GroupAxisMove.XY1Y2MovePos(targetPosition, GlobalVar.WholeSpeed, EGoWhichSide.StockSide))
{
AxisPosPrint.PrintXY1Y2TargetPos("到料仓取料位上方,", targetPosition, GetClassName());
flowStep = EFiveProductTestFlowStep.;
}
}
}
break;
case EFiveProductTestFlowStep.:
if (Ops.IsStop("LoadX", "LoadY1", "LoadY2") || GlobalVar.VirtualAxis)
{
AxisPosPrint.PrintXY1Y2CurrentPos("轴XY1Y2已停止运动,", GetClassName());
if (AxisArrived.LoadXY1Y2IsArrived(targetPosition.X, targetPosition.Y1, targetPosition.Y2))
{
AxisPosPrint.PrintXY1Y2CurrentPos("已运动到等待到料仓取料位上方,", GetClassName());
flowStep = EFiveProductTestFlowStep.;
}
else
{
flowStep = EFiveProductTestFlowStep.;
}
}
break;
case EFiveProductTestFlowStep.:
targetPosition.NozzleZ = NozzleManager.GetNozzleToTrayTakeProductPos(ETrayType.Input, curTakeNozzle.NozzleIndex);
errCode = AxisControl.GetAxis($"NozzleZ{curTakeNozzle.NozzleIndex}").MovePos(targetPosition.NozzleZ, GlobalVar.WholeSpeed);
if (errCode == ErrorCode.Ok)
{
logInfo = $"{GetClassName()}到料仓取料位下方";
MessageQueue.Instance.Insert(logInfo);
flowStep = EFiveProductTestFlowStep.;
}
break;
case EFiveProductTestFlowStep.:
if (Ops.IsStop($"NozzleZ{curTakeNozzle.NozzleIndex}"))
{
logInfo = $"{GetClassName()}已运动到料仓取料位下方";
MessageQueue.Instance.Insert(logInfo);
if (GlobalVar.RunSpace)
{
flowStep = EFiveProductTestFlowStep.;
}
else
{
Ops.On($"吸料真空{curTakeNozzle.NozzleIndex}吸");
Thread.Sleep(100);
flowStep = EFiveProductTestFlowStep.;
}
}
break;
case EFiveProductTestFlowStep.:
if (NozzleManager.GotoSafePos(curTakeNozzle.NozzleIndex))
{
logInfo = $"{GetClassName()}料仓取料完成抬起";
MessageQueue.Instance.Insert(logInfo);
flowStep = EFiveProductTestFlowStep.;
}
break;
case EFiveProductTestFlowStep.:
if (Ops.IsStop($"NozzleZ{curTakeNozzle.NozzleIndex}"))
{
logInfo = $"{GetClassName()}料仓取料完成已抬起";
MessageQueue.Instance.Insert(logInfo);
flowStep = EFiveProductTestFlowStep.;
}
break;
case EFiveProductTestFlowStep.:
if (Ops.IsOn($"吸料真空{curTakeNozzle.NozzleIndex}检测") || GlobalVar.RunSpace)
{
curTakeNozzle.Product = new TestProduct() { SN = "", FromSlotIndex = curTakeSlot.Index };
curTakeNozzle.Status = ENozzleStatus.ToUnload;
GlobalTray.NozzleTray.ChangeStatus(curTakeNozzle.NozzleIndex, ESlotStatus.Have);
GlobalTray.InputTray.ChangeStatus(curTakeSlot.Index, ESlotStatus.NotHave);
logInfo = $"{GetClassName()}料仓{curTakeSlot.Index}号穴位取料完成真空检测OK,产品SN:{curTakeNozzle.Product.SN}被吸嘴{curTakeNozzle.NozzleIndex}取走";
MessageQueue.Instance.Insert(logInfo);
flowStep = EFiveProductTestFlowStep.;
}
else
{
alarmEntity = AlarmCollection.Get(AlarmConstID.GRR);
Msgbox.ShowDialog(alarmEntity, EButtonType.Retry);
flowStep = EFiveProductTestFlowStep.;
}
break;
#endregion
//料仓放料
case EFiveProductTestFlowStep.:
//curDumpNozzle = NozzleManager.GetToUnloadNozzle();
curDumpNozzle = NozzleManager.GetNozzle(1);
if (curDumpNozzle != null)
{
//吸嘴放料,加测吸嘴上的产品的测试结果,决定把料放到哪个料仓
//目前先都方到OK料仓
//curDumpSlot = GlobalTray.GrrTray.GetSlot(ESlotStatus.NotHave);
curDumpSlot = GlobalTray.OkTary.GetSlot(ESlotStatus.NotHave);
if (curDumpSlot != null)
{
//double curLoadX = Ops.GetCurPosition(AxisControl.LoadX);
//if (curLoadX - GlobalVar.FixtureSafePosX > 50)
//{
// DischargeModuleGoSafePosFlow.Instance.GoSafePostion(ESafePosSide.PlaceToStock);
//}
targetPosition = NozzleManager.GetToTraySlot(ETrayType.Ok, curDumpSlot.Index, curDumpNozzle.NozzleIndex);
if (GroupAxisMove.XY1Y2MovePos(targetPosition, GlobalVar.WholeSpeed, EGoWhichSide.StockSide))
{
AxisPosPrint.PrintXY1Y2TargetPos("到料仓放料位上方,", targetPosition, GetClassName());
flowStep = EFiveProductTestFlowStep.;
}
}
else
{
GlobalTray.GrrTray.ChangeStatus(ESlotStatus.NotHave);
}
}
break;
case EFiveProductTestFlowStep.:
if (Ops.IsStop("LoadX", "LoadY1", "LoadY2"))
{
AxisPosPrint.PrintXY1Y2CurrentPos("轴loadx,loady1,loady2已停止运动,", GetClassName());
if (AxisArrived.LoadXY1Y2IsArrived(targetPosition.X, targetPosition.Y1, targetPosition.Y2))
{
AxisPosPrint.PrintXY1Y2CurrentPos("已运动到料仓放料位上方,", GetClassName());
flowStep = EFiveProductTestFlowStep.;
}
else
{
flowStep = EFiveProductTestFlowStep.;
}
}
break;
case EFiveProductTestFlowStep.:
targetPosition.NozzleZ = NozzleManager.GetNozzleToTrayTakeProductPos(ETrayType.Ok, curDumpNozzle.NozzleIndex);
if (NozzleManager.Go(curDumpNozzle, targetPosition.NozzleZ, GlobalVar.WholeSpeed))
{
logInfo = $"{GetClassName()}到料仓放料位下方";
MessageQueue.Instance.Insert(logInfo);
flowStep = EFiveProductTestFlowStep.;
}
break;
case EFiveProductTestFlowStep.:
if (Ops.IsStop($"NozzleZ{curDumpNozzle.NozzleIndex}"))
{
logInfo = $"{GetClassName()}已运动到料仓放料位下方";
MessageQueue.Instance.Insert(logInfo);
if (GlobalVar.RunSpace)
{
flowStep = EFiveProductTestFlowStep.;
}
else
{
curDumpNozzle.VacSuction(EIoOperate.Close, GetClassName());
curDumpNozzle.VacBreak(EIoOperate.Open, GetClassName());
curDumpNozzle.VacBreak(EIoOperate.Close, GetClassName());
flowStep = EFiveProductTestFlowStep.;
}
}
break;
case EFiveProductTestFlowStep.:
if (NozzleManager.GotoSafePos(curDumpNozzle.NozzleIndex))
{
logInfo = $"{GetClassName()}料仓放料完成抬起";
MessageQueue.Instance.Insert(logInfo);
flowStep = EFiveProductTestFlowStep.;
}
break;
case EFiveProductTestFlowStep.:
if (Ops.IsStop($"NozzleZ{curDumpNozzle.NozzleIndex}"))
{
logInfo = $"{GetClassName()}料仓放料完成已抬起";
MessageQueue.Instance.Insert(logInfo);
takedNum++;
curDumpNozzle.Status = ENozzleStatus.IDLE;
GlobalTray.OkTary.ChangeStatus(curDumpSlot.Index, ESlotStatus.Have);
if (takedNum < 5)
{
flowStep = EFiveProductTestFlowStep.;
}
else
{
DischargeModuleGoSafePosFlow.Instance.GoSafePostion();
stop = true;
}
}
break;
}
Thread.Sleep(5);
}
}
public void Start()
{
GlobalTray.InputTray.ChangeStatus(1, ESlotStatus.Have);
GlobalTray.InputTray.ChangeStatus(2, ESlotStatus.Have);
GlobalTray.InputTray.ChangeStatus(3, ESlotStatus.Have);
GlobalTray.InputTray.ChangeStatus(4, ESlotStatus.Have);
GlobalTray.InputTray.ChangeStatus(5, ESlotStatus.Have);
GlobalTray.OkTary.ChangeStatus(1, ESlotStatus.NotHave);
GlobalTray.OkTary.ChangeStatus(2, ESlotStatus.NotHave);
GlobalTray.OkTary.ChangeStatus(3, ESlotStatus.NotHave);
GlobalTray.OkTary.ChangeStatus(4, ESlotStatus.NotHave);
GlobalTray.OkTary.ChangeStatus(5, ESlotStatus.NotHave);
flowStep = EFiveProductTestFlowStep.OK;
takedNum = 0;
stop = false;
}
public void Stop()
{
stop = true;
}
private string GetClassName()
{
return "GrrFlow-";
}
private double offsetX = 0;
private double offsetY = 0;
public void SetOffset(double x,double y)
{
offsetX = x;
offsetY = y;
}
/// <summary>
/// 获取吸嘴取料取不起来时,吸嘴在原取料位的偏移
/// 奇数向下偏移
/// 偶数向上偏移
/// </summary>
/// <param name="fetchNum"></param>
/// <returns></returns>
private double GetVacOffsetHeight(int fetchNum)
{
if (fetchNum == 0) return 0;
//先判断是奇数还是偶数
int count = 0;
int oddOrEven = fetchNum & 0x01;
double offsetDisct = 0.0;
if (oddOrEven == 1)
{
count = (fetchNum / 2) + 1;
offsetDisct = -0.1 * count;
}
else if (oddOrEven == 0)
{
count = (fetchNum / 2);
offsetDisct = 0.1 * count;
}
return offsetDisct;
}
public string GetCurStep()
{
return flowStep.ToString();
}
public void VirtualAxisSleep()
{
if (GlobalVar.VirtualAxis)
{
Thread.Sleep(GlobalVar.VirtualAxisMoveTime);
}
}
private void GotoNextFixture()
{
lastFixtureIndex = ((lastFixtureIndex + 1) % needGrrFixtureList.Count);
}
}
}

@ -41,7 +41,7 @@ namespace Rs.MotionPlat.Flow.SubFlow
bool finished = true;
EFixedGrabProductFlowStep step = EFixedGrabProductFlowStep.;
public ProductLocationResult TakePicture(ETrayType trayType,int slotInex,int grabNum=3)
public ProductLocationResult TakePicture(ETrayType trayType,int slotInex,int grabNum=3,bool hasProdcutCheck=false)
{
ProductLocationResult result = new ProductLocationResult()
{
@ -119,43 +119,69 @@ namespace Rs.MotionPlat.Flow.SubFlow
}
break;
case EFixedGrabProductFlowStep.:
VisionHelper.oneGrabOneVision.ClearQueue();
UpCameraHelper.Grab();
string msg = VisionHelper.OneGrabOne();
result.Parse(msg);
//VisionResult vResult = VisionHelper.Grab(EVisionScene.SingleScanBarcode);
if ((result != null && result.Result== EOneGrabSixteenResult.Ok) || GlobalVar.RunSpace)
if(hasProdcutCheck)
{
finished = true;
if (GlobalVar.RunSpace)
VisionHelper.oneGrabOneVision.ClearQueue("C2");
UpCameraHelper.Grab();
string msg = VisionHelper.OneGrabOne("M2");
result.Parse(msg);
//VisionResult vResult = VisionHelper.Grab(EVisionScene.SingleScanBarcode);
if ((result != null && result.Result == EOneGrabSixteenResult.Ok) || GlobalVar.RunSpace)
{
result = new ProductLocationResult() { Result= EOneGrabSixteenResult.Ok};
finished = true;
if (GlobalVar.RunSpace)
{
result = new ProductLocationResult() { Result = EOneGrabSixteenResult.Ok };
}
return result;
}
else
{
finished = true;
return result;
}
return result;
}
else
{
if(curGrabNum<=3)
VisionHelper.oneGrabOneVision.ClearQueue("C");
UpCameraHelper.Grab();
string msg = VisionHelper.OneGrabOne("M");
result.Parse(msg);
//VisionResult vResult = VisionHelper.Grab(EVisionScene.SingleScanBarcode);
if ((result != null && result.Result == EOneGrabSixteenResult.Ok) || GlobalVar.RunSpace)
{
step = EFixedGrabProductFlowStep.;
finished = true;
if (GlobalVar.RunSpace)
{
result = new ProductLocationResult() { Result = EOneGrabSixteenResult.Ok };
}
return result;
}
else
{
AlarmEntity alarmEntity = AlarmCollection.Get(AlarmConstID.).Transform(grabSlot.Index);
// EButtonType btn = Msgbox.ShowDialog(alarmEntity, EButtonType.Retry| EButtonType.Cancel);
//if(btn== EButtonType.Retry)
//{
// curGrabNum = 1;
// step = EFixedGrabProductFlowStep.到拍照位上方;
//}
//else if(btn== EButtonType.Cancel)
if (curGrabNum <= 3)
{
step = EFixedGrabProductFlowStep.;
}
else
{
finished=true;
return result;
//AlarmEntity alarmEntity = AlarmCollection.Get(AlarmConstID.料仓取料拍照失败).Transform(grabSlot.Index);
// EButtonType btn = Msgbox.ShowDialog(alarmEntity, EButtonType.Retry| EButtonType.Cancel);
//if(btn== EButtonType.Retry)
//{
// curGrabNum = 1;
// step = EFixedGrabProductFlowStep.到拍照位上方;
//}
//else if(btn== EButtonType.Cancel)
{
finished = true;
return result;
}
}
curGrabNum++;
}
curGrabNum++;
}
break;
}

@ -31,6 +31,6 @@ using System.Runtime.InteropServices;
//
//可以指定所有这些值,也可以使用“生成号”和“修订号”的默认值
//通过使用 "*",如下所示:
[assembly: AssemblyVersion("20.25.24.1")]
[assembly: AssemblyVersion("20.25.25.1")]
//[assembly: AssemblyVersion("1.0.0.0")]
//[assembly: AssemblyFileVersion("1.0.0.0")]

@ -164,7 +164,6 @@
<DependentUpon>DataRecords.cs</DependentUpon>
</Compile>
<Compile Include="Entitys\OneGrabSixteenManager.cs" />
<Compile Include="Flow\SubFlow\FiveProductTestFlow.cs" />
<Compile Include="Flow\SubFlow\StockGrabFlow.cs" />
<Compile Include="Flow\SubFlow\EnvironmentPrepareFlow.cs" />
<Compile Include="Flow\SubFlow\FixedGrabProductFlow.cs" />

@ -4,6 +4,7 @@ using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading;
using System.Threading.Tasks;
@ -25,12 +26,12 @@ namespace Rs.MotionPlat.Vision
else
{
data = Encoding.ASCII.GetString(reciveBuffer.ToArray());
MessageQueue.Instance.Insert(data);
if (data == "M,0")
//MessageQueue.Instance.Insert(data);
if (Regex.IsMatch(data, "M\\d{0,1},0"))//data == "M,0")
{
MessageQueue.Instance.Insert("视觉收到拍照指令");
}
else if (data == "C,0")
else if (Regex.IsMatch( data,"C\\d{0,1},0"))// == "C,0")
{
visionGrabEvent.Set();
MessageQueue.Instance.Insert($" >>> {data}");
@ -71,10 +72,10 @@ namespace Rs.MotionPlat.Vision
}
}
public bool ClearQueue(int timeout = 10000)
public bool ClearQueue(string cmd,int timeout = 10000)
{
visionGrabEvent.Reset();
string content = $"C;";
string content = $"{cmd};";
int len = vNozzleCalib.Send(content);
//reciveData = true;
if (len > 0)
@ -103,18 +104,19 @@ namespace Rs.MotionPlat.Vision
/// </summary>
/// <param name="timeout"></param>
/// <returns></returns>
public string OneGrabOne(int timeout = 10000)
public string OneGrabOne(string cmd,int timeout = 10000)
{
data = "";
result = null;
NozzleCalibReciveEvent.Reset();
int len = vNozzleCalib.Send("M;");
int len = vNozzleCalib.Send($"{cmd};");
LogHelper.Debug($"<<< {cmd};len={len}");
if (len > 0)
{
if (NozzleCalibReciveEvent.WaitOne(timeout))
{
MessageQueue.Instance.Insert($"收到视觉结果:{data}");
MessageQueue.Instance.Insert($">>> {data}");
return data;
}
else

@ -85,9 +85,9 @@ namespace Rs.MotionPlat.Commom
}
public static string OneGrabOne()
public static string OneGrabOne(string cmd)
{
return oneGrabOneVision.OneGrabOne();
return oneGrabOneVision.OneGrabOne(cmd);
}
}
}

Loading…
Cancel
Save