优化排料流程

master
lhiven 2 years ago
parent 1a1d68a968
commit 89c6df5697

@ -137,14 +137,17 @@ namespace Rs.MotionPlat.Commom
public static void Start() public static void Start()
{ {
Task.Run(() => { Task.Run(() => {
WorkEnvironment.Instance.Ready(); if(MachineManage.Instance.MachineStatus== EMachineStatus.Homed || MachineManage.Instance.MachineStatus== EMachineStatus.Stop)
if (WorkEnvironment.Instance.EnvReadyOkEvent.WaitOne()) {
if(!WorkEnvironment.Instance.EnvironmentOk)
{ {
WorkEnvironment.Instance.Ready();
WorkEnvironment.Instance.EnvReadyOkEvent.WaitOne();
}
DischargeFlow.Instance.Start(); DischargeFlow.Instance.Start();
TurnoverFlow.Instance.Start(); TurnoverFlow.Instance.Start();
MachineManage.Instance.SetCenterMachineStatus(ERunStatus.Started); MachineManage.Instance.SetCenterMachineStatus(ERunStatus.Started);
var status = MachineManage.Instance.GetLoadUnloadStatus(); if (DischargeFlow.Instance.GetCurStep() == "等待任务" && TurnoverFlow.Instance.GetStep() == "等待任务")
if(DischargeFlow.Instance.GetCurStep()=="等待任务" && TurnoverFlow.Instance.GetStep()== "等待任务")
{ {
MachineManage.Instance.SetLoadUnloadStatus(ERunState.Waiting); MachineManage.Instance.SetLoadUnloadStatus(ERunState.Waiting);
} }
@ -154,13 +157,24 @@ namespace Rs.MotionPlat.Commom
} }
public static void Stop() public static void Stop()
{
if(MachineManage.Instance.MachineStatus== EMachineStatus.Working)
{ {
DischargeFlow.Instance.Stop(); DischargeFlow.Instance.Stop();
TurnoverFlow.Instance.Stop(); TurnoverFlow.Instance.Stop();
MachineManage.Instance.SetCenterMachineStatus(ERunStatus.Stopped); MachineManage.Instance.SetCenterMachineStatus(ERunStatus.Stopped);
MachineManage.Instance.SetLoadUnloadStatus(ERunState.Interrupt); //MachineManage.Instance.SetLoadUnloadStatus(ERunState.Interrupt);
MachineManage.Instance.MachineStatus = EMachineStatus.Stop; MachineManage.Instance.MachineStatus = EMachineStatus.Stop;
} }
else if(MachineManage.Instance.MachineStatus== EMachineStatus.Homing)
{
foreach (IAxis axis in AxisControl.GetAllAxis())
{
axis.Abort_Go_Home();
}
}
}
public static void GoHome() public static void GoHome()
{ {

@ -179,6 +179,15 @@ namespace Rs.MotionPlat.Flow
turnoverResult.Add(turnoverInfo); turnoverResult.Add(turnoverInfo);
} }
public void CopyBarcodeToTask(int slotIndex,string sn)
{
TurnoverInfo ti = turnoverResult.Where(r => r.ToIndex == slotIndex && r.ToType == TurnoverType.Turnover).First();
if(ti!=null)
{
ti.SN = sn;
}
}
/// <summary> /// <summary>
/// 获取测试治具上料的任务信息 /// 获取测试治具上料的任务信息
/// </summary> /// </summary>

@ -943,33 +943,24 @@ namespace Rs.MotionPlat.Flow
} }
else else
{ {
//获取所有需要放料的吸嘴,检测真空是否还在,如果真空异常则报警 if(!curNozzle.HasProduct())
List<Nozzle> lostNozzles = new List<Nozzle>();
List<Nozzle> toUnloadNozzles = NozzleManager.GetNozzlesByStatus(ENozzleStatus.ToUnload);
if (toUnloadNozzles.Count > 0)
{ {
bool exit = false;
foreach (var nozzle in toUnloadNozzles) while(!exit)
{
if (!nozzle.HasProduct())
{
lostNozzles.Add(nozzle);
}
}
if (lostNozzles.Count > 0)
{
bool bSkip = false;
while (!bSkip)
{ {
//弹框报警 //弹框报警
alarmInfo = $"检测到{lostNozzles.Select(ln => ln.NozzleIndex).ToJoinString()}吸嘴真空吸异常,可能丢料,请检查吸嘴的状态"; alarmInfo = $"检测到{curNozzle.NozzleIndex}吸嘴真空吸异常,可能丢料,请检查吸嘴的状态";
TestCenterMessageBox.Show(AlarmConstID.DischargeNozzleLostProductAlarm, alarmInfo, MessageButtonManager.GetSkip_MoveToSafe_Button(), MessageButtonManager.GetSkip_MoveToSafe_ButtonText()); TestCenterMessageBox.Show(AlarmConstID.DischargeNozzleLostProductAlarm, alarmInfo, MessageButtonManager.GetSkip_MoveToSafe_Button(), MessageButtonManager.GetSkip_MoveToSafe_ButtonText());
msgBox = TestCenterMessageBox.WaitResult(AlarmConstID.DischargeNozzleLostProductAlarm); msgBox = TestCenterMessageBox.WaitResult(AlarmConstID.DischargeNozzleLostProductAlarm);
switch (msgBox.Button) switch (msgBox.Button)
{ {
case ETipButton.Skip: case ETipButton.Skip:
bSkip = true; if (!curNozzle.HasProduct())
lostNozzles.ForEach(ln => ln.Reset()); {
curNozzle.Reset();
exit= true;
flowStep = EDischargeFlowStep.;
}
break; break;
case ETipButton.Yes: case ETipButton.Yes:
DischargeModuleGoSafePosFlow.Instance.GoSafePostion(); DischargeModuleGoSafePosFlow.Instance.GoSafePostion();
@ -978,26 +969,71 @@ namespace Rs.MotionPlat.Flow
break; break;
} }
} }
} }
else else
{
if (curNozzle.Status == ENozzleStatus.ToUnload)
{ {
flowStep = EDischargeFlowStep.; flowStep = EDischargeFlowStep.;
} }
else #region 临时屏蔽
{ // //获取所有需要放料的吸嘴,检测真空是否还在,如果真空异常则报警
flowStep = EDischargeFlowStep.; // List<Nozzle> lostNozzles = new List<Nozzle>();
} // List<Nozzle> toUnloadNozzles = NozzleManager.GetNozzlesByStatus(ENozzleStatus.ToUnload);
} // if (toUnloadNozzles.Count > 0)
} // {
else
{
flowStep = EDischargeFlowStep.;
}
}
// foreach (var nozzle in toUnloadNozzles)
// {
// if (!nozzle.HasProduct())
// {
// //lostNozzles.Add(nozzle);
// while (!bSkip)
// {
// }
// }
// }
// if (lostNozzles.Count > 0)
// {
// bool bSkip = false;
// while (!bSkip)
// {
// //弹框报警
// alarmInfo = $"检测到{lostNozzles.Select(ln => ln.NozzleIndex).ToJoinString()}吸嘴真空吸异常,可能丢料,请检查吸嘴的状态";
// TestCenterMessageBox.Show(AlarmConstID.DischargeNozzleLostProductAlarm, alarmInfo, MessageButtonManager.GetSkip_MoveToSafe_Button(), MessageButtonManager.GetSkip_MoveToSafe_ButtonText());
// msgBox = TestCenterMessageBox.WaitResult(AlarmConstID.DischargeNozzleLostProductAlarm);
// switch (msgBox.Button)
// {
// case ETipButton.Skip:
// bSkip = true;
// lostNozzles.ForEach(ln => ln.Reset());
// break;
// case ETipButton.Yes:
// DischargeModuleGoSafePosFlow.Instance.GoSafePostion();
// break;
// default:
// break;
// }
// }
// }
// else
// {
// if (curNozzle.Status == ENozzleStatus.ToUnload)
// {
// flowStep = EDischargeFlowStep.到放料位下方;
// }
// else
// {
// flowStep = EDischargeFlowStep.放料任务完成;
// }
// }
// }
// else
// {
// flowStep = EDischargeFlowStep.放料任务完成;
// }
#endregion
}
break; break;
//case EDischargeFlowStep.到放料位下方: //case EDischargeFlowStep.到放料位下方:
// DischargeDumpFlow.Instance.Start(curNozzle.ToType, curNozzle.NozzleIndex, curNozzle.ToIndex); // DischargeDumpFlow.Instance.Start(curNozzle.ToType, curNozzle.NozzleIndex, curNozzle.ToIndex);
@ -1136,10 +1172,14 @@ namespace Rs.MotionPlat.Flow
switch (msgBox.Button) switch (msgBox.Button)
{ {
case ETipButton.Skip: case ETipButton.Skip:
curNozzle.Reset();
skip = true;
logInfo = GetClassName() + "选择了跳过按钮"; logInfo = GetClassName() + "选择了跳过按钮";
MessageQueue.Instance.Insert(logInfo); MessageQueue.Instance.Insert(logInfo);
if (!curNozzle.HasProduct())
{
curNozzle.Reset();
skip = true;
flowStep = EDischargeFlowStep.;
}
break; break;
case ETipButton.Yes: case ETipButton.Yes:
logInfo = GetClassName() + "选择了移动到安全位按钮"; logInfo = GetClassName() + "选择了移动到安全位按钮";
@ -1153,90 +1193,99 @@ namespace Rs.MotionPlat.Flow
else else
{ {
curNozzle.VacSuction(EIoOperate.Close); curNozzle.VacSuction(EIoOperate.Close);
flowStep = EDischargeFlowStep.;
}
break;
case EDischargeFlowStep.:
if (curNozzle.ToType == TurnoverType.Turnover)
{
if (Ops.IsOn($"周转盘{curNozzle.ToIndex + 1}号穴位真空吸检测") || GlobalVar.RunSpace)
{
logInfo = GetClassName()+$"周转盘{curNozzle.ToIndex + 1}号穴位真空吸检测OK";
MessageQueue.Instance.Insert(logInfo);
flowStep = EDischargeFlowStep.;
}
else
{
bool exit = false;
Dictionary<ETipButton, string> buttons = new Dictionary<ETipButton, string>() {
{ ETipButton.Retry,"重拍|Regrab" },
{ETipButton.Skip,"跳过|Skip" },
{ETipButton.Yes,"移动到安全位|MoveToSafePos" }
};
while (!exit)
{
TestCenterMessageBox.Show(AlarmConstID.TurnoverDumpFailAlarm, alarmInfo, ETipButton.Retry | ETipButton.Skip | ETipButton.Yes, buttons);
msgBox = TestCenterMessageBox.WaitResult(AlarmConstID.TurnoverDumpFailAlarm);
if (msgBox != null)
{
switch (msgBox.Button)
{
case ETipButton.Retry://重拍
logInfo = GetClassName()+$"选择了重拍";
MessageQueue.Instance.Insert(logInfo);
if (UpCameraCheckFlow.Instance.CheckTurnoverTrayDumpOK(curNozzle.ToIndex))
{
exit=true;
flowStep = EDischargeFlowStep.; flowStep = EDischargeFlowStep.;
} }
break; break;
#region 临时屏蔽,排料头放料到周转盘时,不进行周转盘的真空检测,只要没有粘料就继续执行 case ETipButton.Skip://跳过
//case EDischargeFlowStep.放料真空检测: logInfo = GetClassName()+$"选择了跳过";
// if (curNozzle.ToType == TurnoverType.Turnover) MessageQueue.Instance.Insert(logInfo);
// { //logInfo = $"{nameof(DischargeFlow)}-通知强力吸头到{curNozzle.ToType}盘{curNozzle.ToIndex}穴位处理异常料";
// if (Ops.IsOn($"周转盘{curNozzle.ToIndex + 1}号穴位真空吸检测") || GlobalVar.RunSpace) //MessageQueue.Instance.Insert(logInfo);
// { //WarningSuckerNgFlow.Instance.Start(ETrayType.Turnover, curNozzle.ToIndex);
// logInfo = $"{nameof(DischargeFlow)}-周转盘{curNozzle.ToIndex + 1}号穴位真空吸检测OK"; //WarningSuckerNgFlow.Instance.Wait();
// MessageQueue.Instance.Insert(logInfo); if (!UpCameraCheckFlow.Instance.CheckTurnoverTrayHasProduct(null,curNozzle.ToIndex))
// flowStep = EDischargeFlowStep.放料任务完成; {
// } exit=true;
// else curNozzle.Reset();
// { flowStep = EDischargeFlowStep.;
// logInfo = $"{nameof(DischargeFlow)}-周转盘{curNozzle.ToIndex + 1}号穴位真空吸异常"; }
// MessageQueue.Instance.Warn(logInfo); break;
// if(UpCameraCheckFlow.Instance.CheckStockTrayHasProduct(null,EStockType.Turnover, curNozzle.ToIndex)) case ETipButton.Yes://移动到安全位
// { logInfo = GetClassName() + $"选择了移动到安全位";
MessageQueue.Instance.Insert(logInfo);
DischargeModuleGoSafePosFlow.Instance.GoSafePostion();
break;
default:
break;
}
}
}
//logInfo = $"{nameof(DischargeFlow)}-周转盘{curNozzle.ToIndex + 1}号穴位真空吸异常";
//MessageQueue.Instance.Warn(logInfo);
//if (UpCameraCheckFlow.Instance.CheckStockTrayHasProduct(null, EStockType.Turnover, curNozzle.ToIndex))
//{
// flowStep = EDischargeFlowStep.放料任务完成; // flowStep = EDischargeFlowStep.放料任务完成;
// } //}
// else //else
// { //{
// flowStep = EDischargeFlowStep.周转盘放料真空报警; // flowStep = EDischargeFlowStep.周转盘放料真空报警;
// } //}
// //DialogResult dr = Msg.ShowError($"周转盘{curNozzle.ToIndex + 1}号穴位真空吸异常,点击确定后跳过"); //DialogResult dr = Msg.ShowError($"周转盘{curNozzle.ToIndex + 1}号穴位真空吸异常,点击确定后跳过");
// //alarmInfo = $"周转盘{curNozzle.ToIndex + 1}号穴位真空吸异常"; //alarmInfo = $"周转盘{curNozzle.ToIndex + 1}号穴位真空吸异常";
// //TestCenterMessageBox.Show(AlarmConstID.TurnoverDumpFailAlarm, alarmInfo, ETipButton.Ok); //TestCenterMessageBox.Show(AlarmConstID.TurnoverDumpFailAlarm, alarmInfo, ETipButton.Ok);
// //box = TestCenterMessageBox.WaitResult(AlarmConstID.TurnoverDumpFailAlarm); //box = TestCenterMessageBox.WaitResult(AlarmConstID.TurnoverDumpFailAlarm);
// //if (box.Button== ETipButton.Ok) //if (box.Button== ETipButton.Ok)
// //{ //{
// //flowStep = EDischargeFlowStep.放料任务完成; //flowStep = EDischargeFlowStep.放料任务完成;
// //} //}
// } }
// } }
// else else
// { {
// flowStep = EDischargeFlowStep.放料任务完成; flowStep = EDischargeFlowStep.;
// } }
// break; break;
//case EDischargeFlowStep.周转盘放料真空报警:
// Dictionary<ETipButton, string> buttons = new Dictionary<ETipButton, string>() {
// { ETipButton.Retry,"重拍|Regrab" },
// {ETipButton.Skip,"跳过|Skip" },
// {ETipButton.Yes,"移动到安全位|MoveToSafePos" }
// };
// TestCenterMessageBox.Show(AlarmConstID.TurnoverDumpFailAlarm, alarmInfo, ETipButton.Retry| ETipButton.Skip| ETipButton.Yes,buttons);
// msgBox = TestCenterMessageBox.WaitResult(AlarmConstID.TurnoverDumpFailAlarm);
// if(msgBox!=null)
// {
// switch (msgBox.Button)
// {
// case ETipButton.Retry://重拍
// logInfo = $"{nameof(DischargeFlow)}-选择了重拍";
// MessageQueue.Instance.Insert(logInfo);
// if(UpCameraCheckFlow.Instance.CheckTurnoverTrayDumpOK(curNozzle.ToIndex))
// {
// flowStep = EDischargeFlowStep.放料任务完成;
// }
// break;
// case ETipButton.Skip://跳过
// logInfo = $"{nameof(DischargeFlow)}-选择了跳过";
// MessageQueue.Instance.Insert(logInfo);
// logInfo = $"{nameof(DischargeFlow)}-通知强力吸头到{curNozzle.ToType}盘{curNozzle.ToIndex}穴位处理异常料";
// MessageQueue.Instance.Insert(logInfo);
// WarningSuckerNgFlow.Instance.Start( ETrayType.Turnover, curNozzle.ToIndex);
// WarningSuckerNgFlow.Instance.Wait();
// flowStep = EDischargeFlowStep.放料任务完成;
// break;
// case ETipButton.Yes://移动到安全位
// logInfo = $"{nameof(DischargeFlow)}-选择了移动到安全位";
// MessageQueue.Instance.Insert(logInfo);
// logInfo = $"{nameof(DischargeFlow)}-通知排料头回安全位";
// MessageQueue.Instance.Insert(logInfo);
// DischargeModuleGoSafePosFlow.Instance.GoSafePostion();
// logInfo = $"{nameof(DischargeFlow)}-排料头已回到安全位";
// MessageQueue.Instance.Insert(logInfo);
// break;
// default:
// break;
// }
// }
// break;
#endregion
case EDischargeFlowStep.: case EDischargeFlowStep.:
//AxisControl.GetAxis($"NozzleZ{curNozzle.NozzleIndex}").Home(); //AxisControl.GetAxis($"NozzleZ{curNozzle.NozzleIndex}").Home();
@ -1277,6 +1326,7 @@ namespace Rs.MotionPlat.Flow
GlobalTray.MultiTray.ChangeStatus(curNozzle.ToIndex + 1, ESlotStatus.Have); GlobalTray.MultiTray.ChangeStatus(curNozzle.ToIndex + 1, ESlotStatus.Have);
} }
LoadAndUnloadTask.Instance.AddTurnoverResult(curNozzle); LoadAndUnloadTask.Instance.AddTurnoverResult(curNozzle);
} }
curNozzle.Reset(); curNozzle.Reset();
if (NozzleManager.GetNozzlesByStatus(ENozzleStatus.ToUnload).Count > 0) if (NozzleManager.GetNozzlesByStatus(ENozzleStatus.ToUnload).Count > 0)
@ -1298,6 +1348,21 @@ namespace Rs.MotionPlat.Flow
SlotPoint grabEndPoint = TrayPointManager.GetSlotPoint(ETrayType.Turnover, 8); SlotPoint grabEndPoint = TrayPointManager.GetSlotPoint(ETrayType.Turnover, 8);
UpCameraScanBarCodeFlow.Instance.Scan(1, false); UpCameraScanBarCodeFlow.Instance.Scan(1, false);
List<VisionResult> result = UpCameraScanBarCodeFlow.Instance.Wait(); List<VisionResult> result = UpCameraScanBarCodeFlow.Instance.Wait();
foreach (var vr in result)
{
if(TurnoverTrayManager.Instance.Slot(vr.SlotIndex).IsHasProduct)
{
if (vr.SearchModelOK && vr.OffsetX < 0.5 && vr.OffsetY < 0.5 && vr.OffsetR < 5)//定位成功
{
if(vr.ScanBarCodeOK)
{
//复制二维码
LoadAndUnloadTask.Instance.CopyBarcodeToTask(vr.SlotIndex, vr.SN);
}
}
}
}
OnUpCameraGrabResult?.Invoke(result); OnUpCameraGrabResult?.Invoke(result);
} }
//判断周转盘第三行有没有产品,如果有产品则拍第三行 //判断周转盘第三行有没有产品,如果有产品则拍第三行
@ -1308,6 +1373,20 @@ namespace Rs.MotionPlat.Flow
SlotPoint grabEndPoint = TrayPointManager.GetSlotPoint(ETrayType.Turnover, 24); SlotPoint grabEndPoint = TrayPointManager.GetSlotPoint(ETrayType.Turnover, 24);
UpCameraScanBarCodeFlow.Instance.Scan(24, true); UpCameraScanBarCodeFlow.Instance.Scan(24, true);
List<VisionResult> result = UpCameraScanBarCodeFlow.Instance.Wait(); List<VisionResult> result = UpCameraScanBarCodeFlow.Instance.Wait();
foreach (var vr in result)
{
if (TurnoverTrayManager.Instance.Slot(vr.SlotIndex).IsHasProduct)
{
if (vr.SearchModelOK && vr.OffsetX < 0.5 && vr.OffsetY < 0.5 && vr.OffsetR < 5)//定位成功
{
if (vr.ScanBarCodeOK)
{
//复制二维码
LoadAndUnloadTask.Instance.CopyBarcodeToTask(vr.SlotIndex, vr.SN);
}
}
}
}
OnUpCameraGrabResult?.Invoke(result); OnUpCameraGrabResult?.Invoke(result);
} }
@ -1346,7 +1425,7 @@ namespace Rs.MotionPlat.Flow
{ {
Thread.Sleep(GlobalVar.VirtualAxisMoveTime); Thread.Sleep(GlobalVar.VirtualAxisMoveTime);
} }
logInfo = $"{nameof(DischargeFlow)}-排料任务结束到安全位"; logInfo =GetClassName()+ $"排料任务结束到安全位";
MessageQueue.Instance.Insert(logInfo); MessageQueue.Instance.Insert(logInfo);
flowStep = EDischargeFlowStep.; flowStep = EDischargeFlowStep.;
} }

@ -77,7 +77,7 @@ namespace Rs.MotionPlat.Flow.SubFlow
/// <returns></returns> /// <returns></returns>
public bool CheckTurnoverTrayHasProduct(Action<HObject> checkFinishedEvent,int slotIndex=1) public bool CheckTurnoverTrayHasProduct(Action<HObject> checkFinishedEvent,int slotIndex=1)
{ {
//Go(ETrayType.Turnover, slotIndex); Go(ETrayType.Turnover, slotIndex);
int result = VisionManager.TurnoverTrayHasProduct(checkFinishedEvent); int result = VisionManager.TurnoverTrayHasProduct(checkFinishedEvent);
if (result == 1) if (result == 1)
return true; return true;

Loading…
Cancel
Save