修改上相机单拍时不开线程执行

master
lhiven 1 year ago
parent 154209ef43
commit 0b46395e6f

@ -1473,8 +1473,8 @@ namespace Rs.MotionPlat.Flow
else else
{ {
//如果没有粘料,说明产品放下去了,这个时候用相机检测产品是否在穴位种 //如果没有粘料,说明产品放下去了,这个时候用相机检测产品是否在穴位种
UpCameraScanBarCodeFlow.Instance.ScanSingle(curNozzle.ToIndex + 1, true,true,false); VisionResult vr = UpCameraScanBarCodeFlow.Instance.ScanSingle(curNozzle.ToIndex + 1, true,true,false);
VisionResult vr = UpCameraScanBarCodeFlow.Instance.WaitSingle(); //VisionResult vr = UpCameraScanBarCodeFlow.Instance.WaitSingle();
if (UpCameraScanBarCodeFlow.Instance.CheckResult(vr)) if (UpCameraScanBarCodeFlow.Instance.CheckResult(vr))
{ {
logInfo = GetClassName() + $"排料吸嘴{curNozzle.NozzleIndex}号SN={curNozzle.SN}放{WitchTrayWitchSlot(curNozzle.ToType, curNozzle.ToIndex)}"; logInfo = GetClassName() + $"排料吸嘴{curNozzle.NozzleIndex}号SN={curNozzle.SN}放{WitchTrayWitchSlot(curNozzle.ToType, curNozzle.ToIndex)}";
@ -1506,8 +1506,8 @@ namespace Rs.MotionPlat.Flow
case ETipButton.Retry://重拍 case ETipButton.Retry://重拍
logInfo = GetClassName() + $"选择了重拍"; logInfo = GetClassName() + $"选择了重拍";
MessageQueue.Instance.Insert(logInfo); MessageQueue.Instance.Insert(logInfo);
UpCameraScanBarCodeFlow.Instance.ScanSingle(curNozzle.ToIndex + 1, true,true,true); vr = UpCameraScanBarCodeFlow.Instance.ScanSingle(curNozzle.ToIndex + 1, true,true,true);
vr = UpCameraScanBarCodeFlow.Instance.WaitSingle(); //vr = UpCameraScanBarCodeFlow.Instance.WaitSingle();
if (UpCameraScanBarCodeFlow.Instance.CheckResult(vr)) if (UpCameraScanBarCodeFlow.Instance.CheckResult(vr))
{ {
logInfo = GetClassName() + $"排料吸嘴{curNozzle.NozzleIndex}号SN={curNozzle.SN}放{WitchTrayWitchSlot(curNozzle.ToType, curNozzle.ToIndex)}"; logInfo = GetClassName() + $"排料吸嘴{curNozzle.NozzleIndex}号SN={curNozzle.SN}放{WitchTrayWitchSlot(curNozzle.ToType, curNozzle.ToIndex)}";
@ -1874,8 +1874,8 @@ namespace Rs.MotionPlat.Flow
if (failNum < 4) if (failNum < 4)
{ {
//如果扫码失败再重扫一次 //如果扫码失败再重扫一次
UpCameraScanBarCodeFlow.Instance.ScanSingle(vr.SlotIndex, true,false,true); VisionResult vrsigle =UpCameraScanBarCodeFlow.Instance.ScanSingle(vr.SlotIndex, true,false,true);
VisionResult vrsigle = UpCameraScanBarCodeFlow.Instance.WaitSingle(); //VisionResult vrsigle = UpCameraScanBarCodeFlow.Instance.WaitSingle();
if (vrsigle.ScanBarCodeOK) if (vrsigle.ScanBarCodeOK)
{ {
OnShowGrabResult?.Invoke(vrsigle, true); OnShowGrabResult?.Invoke(vrsigle, true);
@ -1976,8 +1976,8 @@ namespace Rs.MotionPlat.Flow
{ {
//如果扫码失败再重扫一次 //如果扫码失败再重扫一次
UpCameraScanBarCodeFlow.Instance.ScanSingle(vr.SlotIndex, true,false,true); VisionResult vrsigle =UpCameraScanBarCodeFlow.Instance.ScanSingle(vr.SlotIndex, true,false,true);
VisionResult vrsigle = UpCameraScanBarCodeFlow.Instance.WaitSingle(); //VisionResult vrsigle = UpCameraScanBarCodeFlow.Instance.WaitSingle();
if (vrsigle.ScanBarCodeOK) if (vrsigle.ScanBarCodeOK)
{ {
OnShowGrabResult?.Invoke(vrsigle, true); OnShowGrabResult?.Invoke(vrsigle, true);

@ -1919,8 +1919,8 @@ namespace Rs.MotionPlat.Flow
TransitModuleSafePosFlow.Instance.GoSafePostion( EExceptionSafePos.Socket); TransitModuleSafePosFlow.Instance.GoSafePostion( EExceptionSafePos.Socket);
//2 排料轴上相机过来检测 //2 排料轴上相机过来检测
DischargeFlow.Instance.WaitCanMove(); DischargeFlow.Instance.WaitCanMove();
UpCameraScanBarCodeFlow.Instance.ScanSingle(slot.Index, true,true,false); VisionResult vr = UpCameraScanBarCodeFlow.Instance.ScanSingle(slot.Index, true,true,false);
VisionResult vr = UpCameraScanBarCodeFlow.Instance.WaitSingle(); //VisionResult vr = UpCameraScanBarCodeFlow.Instance.WaitSingle();
needGoSafePos = true; needGoSafePos = true;
if (!UpCameraScanBarCodeFlow.Instance.CheckResult(vr))//如果不在穴位中,就弹框报警 if (!UpCameraScanBarCodeFlow.Instance.CheckResult(vr))//如果不在穴位中,就弹框报警
{ {
@ -1935,8 +1935,8 @@ namespace Rs.MotionPlat.Flow
case ETipButton.Retry: case ETipButton.Retry:
logInfo = GetClassName() + "选择了重试"; logInfo = GetClassName() + "选择了重试";
MessageQueue.Instance.Insert(logInfo); MessageQueue.Instance.Insert(logInfo);
UpCameraScanBarCodeFlow.Instance.ScanSingle(slot.Index, true,true,false); vr = UpCameraScanBarCodeFlow.Instance.ScanSingle(slot.Index, true,true,false);
vr = UpCameraScanBarCodeFlow.Instance.WaitSingle(); //vr = UpCameraScanBarCodeFlow.Instance.WaitSingle();
if(UpCameraScanBarCodeFlow.Instance.CheckResult(vr)) if(UpCameraScanBarCodeFlow.Instance.CheckResult(vr))
{ {
slot.AddProduct(nozzle); slot.AddProduct(nozzle);

@ -61,9 +61,9 @@ namespace Rs.MotionPlat.Flow.SubFlow
Stopwatch timeout = new Stopwatch(); Stopwatch timeout = new Stopwatch();
string logInfo = string.Empty; string logInfo = string.Empty;
VisionResult singleResult;
bool exit = true; bool exit = true;
ManualResetEvent grabFinishedEvent = new ManualResetEvent(true); //ManualResetEvent grabFinishedEvent = new ManualResetEvent(true);
/// <summary> /// <summary>
/// /// 开始扫码,先把所有的穴位全部扫一遍,扫不到的最后再定点扫码, /// /// 开始扫码,先把所有的穴位全部扫一遍,扫不到的最后再定点扫码,
/// 如果定位失败的穴位,即便没有扫到码,也不再扫码 /// 如果定位失败的穴位,即便没有扫到码,也不再扫码
@ -75,7 +75,7 @@ namespace Rs.MotionPlat.Flow.SubFlow
{ {
List<VisionResult> vReslutList = new List<VisionResult>(); List<VisionResult> vReslutList = new List<VisionResult>();
if (exit == false) return null; if (exit == false) return null;
grabFinishedEvent.Reset(); //grabFinishedEvent.Reset();
SlotPoint startPoint = TrayPointManager.GetSlotPoint(ETrayType.Turnover, startSlotIndex); SlotPoint startPoint = TrayPointManager.GetSlotPoint(ETrayType.Turnover, startSlotIndex);
SlotPoint endPoint = new SlotPoint(); SlotPoint endPoint = new SlotPoint();
@ -252,7 +252,7 @@ namespace Rs.MotionPlat.Flow.SubFlow
slotIndex++; slotIndex++;
} }
exit = true; exit = true;
grabFinishedEvent.Set(); //grabFinishedEvent.Set();
break; break;
} }
} }
@ -262,10 +262,11 @@ namespace Rs.MotionPlat.Flow.SubFlow
} }
public void ScanSingle(int SlotIndex,bool needGo=true,bool bNeedLocate=true,bool bNeedScanBarcode=true) public VisionResult ScanSingle(int SlotIndex,bool needGo=true,bool bNeedLocate=true,bool bNeedScanBarcode=true)
{ {
if (exit == false) return; VisionResult singleResult = null;
grabFinishedEvent.Reset(); if (exit == false) return null;
//grabFinishedEvent.Reset();
HObject imageSingle = new HObject(); HObject imageSingle = new HObject();
exit = false; exit = false;
if(!needGo) if(!needGo)
@ -281,7 +282,7 @@ namespace Rs.MotionPlat.Flow.SubFlow
{ {
fixedStep = EUpCameraFixedScanBarCodeFlowStep.; fixedStep = EUpCameraFixedScanBarCodeFlowStep.;
} }
Task.Run(() => { //Task.Run(() => {
while (!exit) while (!exit)
{ {
if (MachineManage.Instance.MachineStatus == EMachineStatus.Stop) if (MachineManage.Instance.MachineStatus == EMachineStatus.Stop)
@ -291,7 +292,6 @@ namespace Rs.MotionPlat.Flow.SubFlow
} }
switch (fixedStep) switch (fixedStep)
{ {
case EUpCameraFixedScanBarCodeFlowStep.: case EUpCameraFixedScanBarCodeFlowStep.:
SlotPoint targetPoint = TrayPointManager.GetSlotPoint(ETrayType.Turnover, SlotIndex); SlotPoint targetPoint = TrayPointManager.GetSlotPoint(ETrayType.Turnover, SlotIndex);
errCode = AxisControl.LoadX.MovePos(targetPoint.X, GlobalVar.FlyCameraSpeed); errCode = AxisControl.LoadX.MovePos(targetPoint.X, GlobalVar.FlyCameraSpeed);
@ -340,13 +340,13 @@ namespace Rs.MotionPlat.Flow.SubFlow
singleResult = VisionManager.TurnoverTrayDumpProductOK(imageSingle, bNeedLocate, bNeedScanBarcode, SlotIndex); singleResult = VisionManager.TurnoverTrayDumpProductOK(imageSingle, bNeedLocate, bNeedScanBarcode, SlotIndex);
singleResult.SlotIndex = SlotIndex; singleResult.SlotIndex = SlotIndex;
exit = true; exit = true;
grabFinishedEvent.Set(); //grabFinishedEvent.Set();
break; break;
} }
} }
}); //});
return singleResult;
} }
public string GetClassName() public string GetClassName()
@ -359,11 +359,11 @@ namespace Rs.MotionPlat.Flow.SubFlow
// return vReslutList; // return vReslutList;
//} //}
public VisionResult WaitSingle() //public VisionResult WaitSingle()
{ //{
grabFinishedEvent.WaitOne(); // grabFinishedEvent.WaitOne();
return singleResult; // return singleResult;
} //}
public bool CheckResult(VisionResult vr) public bool CheckResult(VisionResult vr)
{ {

@ -118,8 +118,8 @@ namespace Rs.MotionPlat.Recipe
btnLocateCheck.Enabled = false; btnLocateCheck.Enabled = false;
})); }));
UpCameraScanBarCodeFlow.Instance.ScanSingle(1,false,true,false); VisionResult vr = UpCameraScanBarCodeFlow.Instance.ScanSingle(1,false,true,false);
VisionResult vr= UpCameraScanBarCodeFlow.Instance.WaitSingle(); //VisionResult vr= UpCameraScanBarCodeFlow.Instance.WaitSingle();
if(vr != null) if(vr != null)
{ {
bool result = UpCameraScanBarCodeFlow.Instance.CheckResult(vr); bool result = UpCameraScanBarCodeFlow.Instance.CheckResult(vr);

Loading…
Cancel
Save