优化8头的料仓搬运料盘动作

Eight
lhiven 9 months ago
parent fd0f5d1b33
commit dbbc7ac7a2

@ -24,6 +24,7 @@ namespace Rs.MotionPlat.Entitys
public static void Load() public static void Load()
{ {
alarmDic.Clear(); alarmDic.Clear();
names2id2.Clear();
XSSFWorkbook book; XSSFWorkbook book;
FileStream fs = File.Open("报警文本.xlsx", FileMode.Open, FileAccess.Read, FileShare.ReadWrite); FileStream fs = File.Open("报警文本.xlsx", FileMode.Open, FileAccess.Read, FileShare.ReadWrite);
book = new XSSFWorkbook(fs); book = new XSSFWorkbook(fs);
@ -144,6 +145,25 @@ namespace Rs.MotionPlat.Entitys
Msg.ShowError("Alarm file cann't find 系统异常报警 item"); Msg.ShowError("Alarm file cann't find 系统异常报警 item");
} }
} }
public static void ShowMsg(int alarmID,Action act)
{
while (true)
{
AlarmEntity alarmEntity = AlarmCollection.Get(alarmID);
if (alarmEntity != null)
{
Msgbox.ShowDialog(alarmEntity, EButtonType.Retry, true);
act.Invoke();
break;
}
else
{
Msg.ShowError($"The alarmID = {alarmID} was not found in the translation file.");
AlarmCollection.Load();
}
}
}
} }
public class AlarmEntity public class AlarmEntity
{ {

@ -110,11 +110,11 @@ namespace Rs.MotionPlat.Flow.NormalFlow
} }
else if (stopwatch.ElapsedMilliseconds > 5000) else if (stopwatch.ElapsedMilliseconds > 5000)
{ {
Msgbox.ShowTipDialog(EButtonType.Retry, "抽屉锁原位异常,请处理后点击重试","error",true); Msgbox.ShowTipDialog(EButtonType.Retry, "抽屉锁原位异常,请处理后点击重试", "error", true);
} }
break; break;
case EOutStockFlowStep.: case EOutStockFlowStep.:
if(StockIndex==1) if (StockIndex == 1)
{ {
targetPosition.StockZ = GlobalVar.StockZ1OutStock; targetPosition.StockZ = GlobalVar.StockZ1OutStock;
} }
@ -185,7 +185,7 @@ namespace Rs.MotionPlat.Flow.NormalFlow
/// <summary> /// <summary>
/// 进仓 /// 进仓
/// </summary> /// </summary>
public void InStock(bool gotoStartPos=true) public void InStock(bool gotoStartPos = true)
{ {
if (inStockFinished) if (inStockFinished)
{ {
@ -211,7 +211,7 @@ namespace Rs.MotionPlat.Flow.NormalFlow
} }
else if (stopwatch.ElapsedMilliseconds > 20000) else if (stopwatch.ElapsedMilliseconds > 20000)
{ {
Msgbox.ShowTipDialog(EButtonType.Retry, "抽屉锁原位异常,请处理后点击重试","error",true); Msgbox.ShowTipDialog(EButtonType.Retry, "抽屉锁原位异常,请处理后点击重试", "error", true);
} }
break; break;
case EInStockFlowStep.: case EInStockFlowStep.:
@ -234,7 +234,7 @@ namespace Rs.MotionPlat.Flow.NormalFlow
else if (stopwatch.ElapsedMilliseconds > 10000) else if (stopwatch.ElapsedMilliseconds > 10000)
{ {
AlarmEntity alarmEntity = AlarmCollection.Get(AlarmConstID.).Transform(StockIndex); AlarmEntity alarmEntity = AlarmCollection.Get(AlarmConstID.).Transform(StockIndex);
Msgbox.ShowDialog(alarmEntity, EButtonType.Recheck); Msgbox.ShowDialog(alarmEntity, EButtonType.Recheck, true);
inStockStep = EInStockFlowStep.; inStockStep = EInStockFlowStep.;
} }
@ -248,7 +248,7 @@ namespace Rs.MotionPlat.Flow.NormalFlow
if (Ops.IsOn($"抽屉锁{StockIndex}动位")) if (Ops.IsOn($"抽屉锁{StockIndex}动位"))
{ {
ResetLayer(); ResetLayer();
if(gotoStartPos) if (gotoStartPos)
{ {
inStockStep = EInStockFlowStep.; inStockStep = EInStockFlowStep.;
} }
@ -285,13 +285,13 @@ namespace Rs.MotionPlat.Flow.NormalFlow
public void Up() public void Up()
{ {
if(CurrentLayer==1) if (CurrentLayer == 0)
{ {
logInfo = $"{GetClassName()} 料仓{StockIndex}已处于第层,不能再上升"; logInfo = $"{GetClassName()} 料仓{StockIndex}已处于第{CurrentLayer}层,不能再上升";
MessageQueue.Instance.Warn(logInfo); MessageQueue.Instance.Warn(logInfo);
return; return;
} }
if(Ops.IsOn($"料仓夹磁气缸{StockIndex}动位")) if (Ops.IsOn($"料仓夹磁气缸{StockIndex}动位"))
{ {
ReleaseTray(); ReleaseTray();
} }
@ -311,11 +311,11 @@ namespace Rs.MotionPlat.Flow.NormalFlow
Thread.Sleep(500); Thread.Sleep(500);
logInfo = $"{GetClassName()} 料仓{StockIndex}已运动到{CurrentLayer}层cz:{Ops.GetCurPosition($"StockZ{StockIndex}")}"; logInfo = $"{GetClassName()} 料仓{StockIndex}已运动到{CurrentLayer}层cz:{Ops.GetCurPosition($"StockZ{StockIndex}")}";
MessageQueue.Instance.Insert(logInfo); MessageQueue.Instance.Insert(logInfo);
if (HasTray()) //if (HasTray())
{ //{
ClampTray(); // ClampTray();
Thread.Sleep(GlobalVar.StepMotorMoveDelayTime); // Thread.Sleep(GlobalVar.StepMotorMoveDelayTime);
} //}
break; break;
} }
else if (stopwatch.ElapsedMilliseconds > 5000) else if (stopwatch.ElapsedMilliseconds > 5000)
@ -329,7 +329,7 @@ namespace Rs.MotionPlat.Flow.NormalFlow
public void Down() public void Down()
{ {
if(CurrentLayer==20) if (CurrentLayer == 20)
{ {
return; return;
} }
@ -362,21 +362,21 @@ namespace Rs.MotionPlat.Flow.NormalFlow
/// </summary> /// </summary>
public void ReleaseTray() public void ReleaseTray()
{ {
StockModule.ClampTrayCylinder(EIoOperate.Open, StockIndex,GetClassName()); StockModule.ClampTrayCylinder(EIoOperate.Open, StockIndex, GetClassName());
stopwatch.Restart(); stopwatch.Restart();
while (true) while (true)
{ {
if(Ops.IsOn($"料仓夹磁气缸{StockIndex}原位")) if (Ops.IsOn($"料仓夹磁气缸{StockIndex}原位"))
{ {
Thread.Sleep(1000); Thread.Sleep(1000);
break; break;
} }
else if(stopwatch.ElapsedMilliseconds>30000) else if (stopwatch.ElapsedMilliseconds > 30000)
{ {
AlarmEntity alarmEntity = AlarmCollection.Get($"料仓{StockIndex}夹磁气缸原位异常"); AlarmEntity alarmEntity = AlarmCollection.Get($"料仓{StockIndex}夹磁气缸原位异常");
if(alarmEntity != null ) if (alarmEntity != null)
{ {
Msgbox.ShowDialog(alarmEntity, EButtonType.Retry); Msgbox.ShowDialog(alarmEntity, EButtonType.Retry, true);
StockModule.ClampTrayCylinder(EIoOperate.Open, StockIndex, GetClassName()); StockModule.ClampTrayCylinder(EIoOperate.Open, StockIndex, GetClassName());
stopwatch.Restart(); stopwatch.Restart();
} }
@ -384,7 +384,7 @@ namespace Rs.MotionPlat.Flow.NormalFlow
{ {
Msg.ShowError($"翻译文件中未找到 料仓{StockIndex}夹磁气缸原位异常"); Msg.ShowError($"翻译文件中未找到 料仓{StockIndex}夹磁气缸原位异常");
} }
} }
} }
} }
@ -408,9 +408,9 @@ namespace Rs.MotionPlat.Flow.NormalFlow
else if (stopwatch.ElapsedMilliseconds > 30000) else if (stopwatch.ElapsedMilliseconds > 30000)
{ {
AlarmEntity alarmEntity = AlarmCollection.Get($"料仓{StockIndex}夹磁气缸动位异常"); AlarmEntity alarmEntity = AlarmCollection.Get($"料仓{StockIndex}夹磁气缸动位异常");
if(alarmEntity != null ) if (alarmEntity != null)
{ {
Msgbox.ShowDialog(alarmEntity, EButtonType.Retry); Msgbox.ShowDialog(alarmEntity, EButtonType.Retry, true);
StockModule.ClampTrayCylinder(EIoOperate.Close, StockIndex, GetClassName()); StockModule.ClampTrayCylinder(EIoOperate.Close, StockIndex, GetClassName());
stopwatch.Restart(); stopwatch.Restart();
} }
@ -453,7 +453,7 @@ namespace Rs.MotionPlat.Flow.NormalFlow
/// <returns></returns> /// <returns></returns>
private double GetStockZPosByLayer(int layer) private double GetStockZPosByLayer(int layer)
{ {
return (GetFirstLayerPos()- ((CurrentLayer - 1) * TrayHeight)); return (GetFirstLayerPos() - ((CurrentLayer - 1) * TrayHeight));
} }
/// <summary> /// <summary>

@ -25,6 +25,7 @@ namespace Rs.MotionPlat.Flow
, ,
, ,
, ,
,
, ,
//等待夹磁气缸松开, //等待夹磁气缸松开,
, ,
@ -76,7 +77,7 @@ namespace Rs.MotionPlat.Flow
{ {
get get
{ {
if(intance == null) if (intance == null)
intance = new TakeTrayFlow(); intance = new TakeTrayFlow();
return intance; return intance;
} }
@ -98,7 +99,7 @@ namespace Rs.MotionPlat.Flow
/// <param name="toTray"></param> /// <param name="toTray"></param>
/// <param name="isNeedGoDown"></param> /// <param name="isNeedGoDown"></param>
/// <param name="placeTrayGrab">放料盘拍照</param> /// <param name="placeTrayGrab">放料盘拍照</param>
public void Take(ETrayType fromTray, ETrayType toTray,bool isNeedGoDown=true,bool placeTrayGrab=false) public void Take(ETrayType fromTray, ETrayType toTray, bool isNeedGoDown = true, bool placeTrayGrab = false)
{ {
switch (fromTray) switch (fromTray)
{ {
@ -144,175 +145,252 @@ namespace Rs.MotionPlat.Flow
switch (step) switch (step)
{ {
case ETakeTrayFlowStep.: case ETakeTrayFlowStep.:
if(fromTray== ETrayType.Empty) try
{ {
targetPosition.TakeTrayX = GlobalVar.EmptyStockGrabPos + GlobalVar.ClampCenter2CameraCenterDist; if (fromTray == ETrayType.Empty)
} {
else if(fromTray== ETrayType.Input) targetPosition.TakeTrayX = GlobalVar.EmptyStockGrabPos + GlobalVar.ClampCenter2CameraCenterDist;
{ }
targetPosition.TakeTrayX = GlobalVar.InputStockGrabPos + GlobalVar.ClampCenter2CameraCenterDist; else if (fromTray == ETrayType.Input)
{
targetPosition.TakeTrayX = GlobalVar.InputStockGrabPos + GlobalVar.ClampCenter2CameraCenterDist;
}
else
{
Msg.ShowError($"cann't from take tray from {fromTray}");
return;
}
if (GroupAxisMove.TakeXMove(GetClassName(), targetPosition.TakeTrayX, GlobalVar.WholeSpeed))
{
if (GlobalVar.VirtualAxis)
{
Thread.Sleep(GlobalVar.VirtualAxisMoveTime);
}
AxisPosPrint.PrintTakeTrayXTargetPos($"准备运动到料仓{m_fromTray}取料盘位上方", targetPosition, GetClassName());
step = ETakeTrayFlowStep.;
}
} }
else catch (Exception ex)
{ {
Msg.ShowError($"cann't from take tray from {fromTray}"); AlarmCollection.SystemExceptionAlarm(ex);
return ;
} }
if(GroupAxisMove.TakeXMove(GetClassName(), targetPosition.TakeTrayX, GlobalVar.WholeSpeed))
break;
case ETakeTrayFlowStep.:
try
{ {
if (GlobalVar.VirtualAxis) if (Ops.IsStop("TakeTrayX") || GlobalVar.VirtualAxis)
{ {
Thread.Sleep(GlobalVar.VirtualAxisMoveTime); if (fromTray == ETrayType.Empty)
{
StockManager.CloseTray(fromStockIndex);
}
AxisPosPrint.PrintTakeTrayXCurrentPos($"已运动到料仓{m_fromTray}取料盘位上方", GetClassName());
//松开夹爪
StockManager.OpenTray(fromStockIndex);
step = ETakeTrayFlowStep.;
} }
AxisPosPrint.PrintTakeTrayXTargetPos($"准备运动到料仓{m_fromTray}取料盘位上方", targetPosition, GetClassName());
step = ETakeTrayFlowStep.;
} }
catch (Exception ex)
{
AlarmCollection.SystemExceptionAlarm(ex);
}
break; break;
case ETakeTrayFlowStep.:
if (Ops.IsStop("TakeTrayX") || GlobalVar.VirtualAxis) case ETakeTrayFlowStep.:
try
{ {
if(fromTray== ETrayType.Empty) if (Ops.IsOn($"满料{fromStockIndex}对射光电"))
{ {
StockManager.CloseTray(fromStockIndex); logInfo = GetClassName() + $"料仓{m_fromTray}料盘准备就绪";
MessageQueue.Instance.Insert(logInfo);
step = ETakeTrayFlowStep.;
//step = ETakeTrayFlowStep.等待运动到取料位下方;
}
else
{
alarmEntity = AlarmCollection.Get(AlarmConstID.).Transform(fromTray);
Msgbox.ShowDialog(alarmEntity, EButtonType.Retry, true);
} }
AxisPosPrint.PrintTakeTrayXCurrentPos($"已运动到料仓{m_fromTray}取料盘位上方", GetClassName());
step = ETakeTrayFlowStep.;
} }
catch (Exception ex)
{
AlarmCollection.SystemExceptionAlarm(ex);
}
break; break;
case ETakeTrayFlowStep.: case ETakeTrayFlowStep.:
if (Ops.IsOn($"满料{fromStockIndex}对射光电")) try
{ {
logInfo = GetClassName() + $"料仓{m_fromTray}料盘准备就绪"; StockManager.Up(fromStockIndex);
logInfo = GetClassName() + $"料仓{fromTray}上升一层";
MessageQueue.Instance.Insert(logInfo); MessageQueue.Instance.Insert(logInfo);
TakeTrayModule.CylinderGoDown(GetClassName()); step = ETakeTrayFlowStep.;
stopwatch.Restart();
step = ETakeTrayFlowStep.;
} }
else catch (Exception ex)
{ {
alarmEntity = AlarmCollection.Get(AlarmConstID.).Transform(fromTray); AlarmCollection.SystemExceptionAlarm(ex);
Msgbox.ShowDialog(alarmEntity, EButtonType.Retry);
} }
break; break;
case ETakeTrayFlowStep.: case ETakeTrayFlowStep.:
if (Ops.IsOn("料盘搬运气缸动位"))
{ {
logInfo = GetClassName() + $"料盘搬运气缸动位 OK"; TakeTrayModule.CylinderGoDown(GetClassName());
MessageQueue.Instance.Insert(logInfo);
stopwatch.Stop();
//打开真空
TakeTrayModule.VacOperation(EIoOperate.Open,GetClassName());
//松开夹爪
//StockModule.ClampTrayCylinder(EIoOperate.Open, fromStockIndex,GetClassName());
StockManager.OpenTray(fromStockIndex);
stopwatch.Restart(); stopwatch.Restart();
step = ETakeTrayFlowStep.; step = ETakeTrayFlowStep.;
} }
else if (stopwatch.ElapsedMilliseconds > 5000) break;
case ETakeTrayFlowStep.:
try
{ {
alarmEntity = AlarmCollection.Get(AlarmConstID.); if (Ops.IsOn("料盘搬运气缸动位"))
if (alarmEntity != null)
{ {
Msgbox.ShowDialog (alarmEntity, EButtonType.Retry); logInfo = GetClassName() + $"料盘搬运气缸动位 OK";
step = ETakeTrayFlowStep.; MessageQueue.Instance.Insert(logInfo);
stopwatch.Stop();
//打开真空
TakeTrayModule.VacOperation(EIoOperate.Open, GetClassName());
StockManager.CloseTray(fromStockIndex);
//stopwatch.Restart();
step = ETakeTrayFlowStep.;
} }
else else if (stopwatch.ElapsedMilliseconds > 5000)
{ {
Msg.ShowError("翻译文件中未找到料盘搬运气缸动位异常"); AlarmCollection.ShowMsg(AlarmConstID., () => { step = ETakeTrayFlowStep.; });
//alarmEntity = AlarmCollection.Get(AlarmConstID.料盘搬运气缸动位异常);
//if (alarmEntity != null)
//{
// Msgbox.ShowDialog(alarmEntity, EButtonType.Retry, true);
// step = ETakeTrayFlowStep.等待运动到取料位下方;
//}
//else
//{
// Msg.ShowError("翻译文件中未找到料盘搬运气缸动位异常");
//}
//stopwatch.Restart();
} }
stopwatch.Restart(); }
catch (Exception ex)
{
AlarmCollection.SystemExceptionAlarm(ex);
} }
break; break;
//case ETakeTrayFlowStep.等待夹磁气缸松开:
// if(Ops.IsOn($"料仓夹磁气缸{fromStockIndex}原位"))
// {
// step = ETakeTrayFlowStep.取料盘完成抬起;
// }
// else if(stopwatch.ElapsedMilliseconds>5000)
// {
// alarmEntity = AlarmCollection.Get($"料仓{fromStockIndex}夹磁气缸原位异常");
// if (alarmEntity != null)
// {
// Msgbox.ShowDialog(alarmEntity, EButtonType.Retry);
// step = ETakeTrayFlowStep.等待夹磁气缸松开;
// }
// else
// {
// Msg.ShowError($"料仓{fromStockIndex}夹磁气缸原位异常");
// }
// stopwatch.Restart();
// }
// break;
case ETakeTrayFlowStep.: case ETakeTrayFlowStep.:
TakeTrayModule.CylinderGoUp(GetClassName());
stopwatch.Restart();
step = ETakeTrayFlowStep.;
break;
case ETakeTrayFlowStep.:
if ((Ops.IsOn("料盘搬运气缸原位")))
{
logInfo = GetClassName()+$"检测到上下气缸原位 OK";
MessageQueue.Instance.Insert(logInfo);
stopwatch.Stop();
step = ETakeTrayFlowStep.;
}
else if(stopwatch.ElapsedMilliseconds > 5000)
{ {
alarmEntity = AlarmCollection.Get(AlarmConstID.); try
if (alarmEntity != null)
{ {
MessageQueue.Instance.Warn(GetClassName() + alarmEntity.CN); TakeTrayModule.CylinderGoUp(GetClassName());
Msgbox.ShowDialog(alarmEntity, EButtonType.Retry); stopwatch.Restart();
step = ETakeTrayFlowStep.;
} }
else catch (Exception ex)
{ {
Msg.ShowError("翻译文件中未找到料盘搬运气缸原位异常"); AlarmCollection.SystemExceptionAlarm(ex);
} }
stopwatch.Restart();
} }
break; break;
case ETakeTrayFlowStep.: case ETakeTrayFlowStep.:
if (TakeTrayModule.HasTray()) try
{ {
logInfo = GetClassName() + $"料盘已被抓起 OK"; if ((Ops.IsOn("料盘搬运气缸原位")))
MessageQueue.Instance.Insert(logInfo);
if ( StockManager.GetCurrentLayer(fromStockIndex) == 1)
{ {
step = ETakeTrayFlowStep.; logInfo = GetClassName() + $"检测到上下气缸原位 OK";
MessageQueue.Instance.Insert(logInfo);
stopwatch.Stop();
step = ETakeTrayFlowStep.;
} }
else else if (stopwatch.ElapsedMilliseconds > 5000)
{ {
step = ETakeTrayFlowStep.; alarmEntity = AlarmCollection.Get(AlarmConstID.);
if (alarmEntity != null)
{
MessageQueue.Instance.Warn(GetClassName() + alarmEntity.CN);
Msgbox.ShowDialog(alarmEntity, EButtonType.Retry, true);
}
else
{
Msg.ShowError("翻译文件中未找到料盘搬运气缸原位异常");
}
stopwatch.Restart();
} }
} }
else catch (Exception ex)
{
AlarmCollection.SystemExceptionAlarm(ex);
}
break;
case ETakeTrayFlowStep.:
try
{ {
alarmEntity = AlarmCollection.Get(AlarmConstID.).Transform(fromTray.ToString()); if (TakeTrayModule.HasTray())
if (alarmEntity != null)
{ {
Msgbox.ShowDialog(alarmEntity, EButtonType.Retry); logInfo = GetClassName() + $"料盘已被抓起 OK";
step = ETakeTrayFlowStep.; MessageQueue.Instance.Insert(logInfo);
if (fromTray == ETrayType.Input)
{
step = ETakeTrayFlowStep.;
}
else
{
if (placeTrayGrab && GlobalVar.EnableBeforePlaceTrayToOkGrab)
{
step = ETakeTrayFlowStep.;
}
else
{
step = ETakeTrayFlowStep.;
}
}
//if (StockManager.GetCurrentLayer(fromStockIndex) == 1)
//{
// step = ETakeTrayFlowStep.到放料盘上方;
//}
//else
//{
// step = ETakeTrayFlowStep.上升一层;
//}
} }
else else
{ {
Msg.ShowError("翻译文件中未找到抓料盘未抓起"); alarmEntity = AlarmCollection.Get(AlarmConstID.).Transform(fromTray.ToString());
if (alarmEntity != null)
{
Msgbox.ShowDialog(alarmEntity, EButtonType.Retry, true);
step = ETakeTrayFlowStep.;
}
else
{
Msg.ShowError("翻译文件中未找到抓料盘未抓起");
}
} }
} }
break; catch (Exception ex)
case ETakeTrayFlowStep.:
StockManager.Up(fromStockIndex);
logInfo = GetClassName() + $"料仓{fromTray}上升一层";
MessageQueue.Instance.Insert(logInfo);
step = ETakeTrayFlowStep.;
break;
case ETakeTrayFlowStep.:
if(fromTray== ETrayType.Input)
{ {
step = ETakeTrayFlowStep.; AlarmCollection.SystemExceptionAlarm(ex);
} }
else
break;
//case ETakeTrayFlowStep.等待上升一层完成:
// try
// {
// }
// catch (Exception ex)
// {
// AlarmCollection.SystemExceptionAlarm(ex);
// }
// break;
case ETakeTrayFlowStep.:
try
{ {
if (placeTrayGrab && GlobalVar.EnableBeforePlaceTrayToOkGrab) StockGrabFlow.Instance.Grab(fromTray);
if (placeTrayGrab)
{ {
step = ETakeTrayFlowStep.; step = ETakeTrayFlowStep.;
} }
@ -321,43 +399,45 @@ namespace Rs.MotionPlat.Flow
step = ETakeTrayFlowStep.; step = ETakeTrayFlowStep.;
} }
} }
break; catch (Exception ex)
case ETakeTrayFlowStep.:
StockGrabFlow.Instance.Grab(fromTray);
if(placeTrayGrab)
{ {
step = ETakeTrayFlowStep.; AlarmCollection.SystemExceptionAlarm(ex);
} }
else
break;
case ETakeTrayFlowStep.:
try
{ {
StockGrabFlow.Instance.Grab(toTray);
step = ETakeTrayFlowStep.; step = ETakeTrayFlowStep.;
} }
break; catch (Exception ex)
case ETakeTrayFlowStep.: {
StockGrabFlow.Instance.Grab(toTray); AlarmCollection.SystemExceptionAlarm(ex);
step = ETakeTrayFlowStep.; }
break; break;
case ETakeTrayFlowStep.: case ETakeTrayFlowStep.:
//if (DischargeFlow.Instance.XYCanGoLocalArea()) try
{ {
if(fromTray!= ETrayType.Input && toTray== ETrayType.Ok && GlobalVar.EnableOkTrayCheckFull) if (fromTray != ETrayType.Input && toTray == ETrayType.Ok && GlobalVar.EnableOkTrayCheckFull)
{ {
Msgbox.ShowTipDialog(EButtonType.Ok, "please check product in tray has placed ok?", "Tip", true); Msgbox.ShowTipDialog(EButtonType.Ok, "please check product in tray has placed ok?", "Tip", true);
} }
if(toTray== ETrayType.Ok) if (toTray == ETrayType.Ok)
{ {
targetPosition.TakeTrayX = GlobalVar.OkStockGrabPos + GlobalVar.ClampCenter2CameraCenterDist; targetPosition.TakeTrayX = GlobalVar.OkStockGrabPos + GlobalVar.ClampCenter2CameraCenterDist;
} }
else if(toTray== ETrayType.Input) else if (toTray == ETrayType.Input)
{ {
targetPosition.TakeTrayX = GlobalVar.InputStockGrabPos + GlobalVar.ClampCenter2CameraCenterDist; targetPosition.TakeTrayX = GlobalVar.InputStockGrabPos + GlobalVar.ClampCenter2CameraCenterDist;
} }
else if(toTray== ETrayType.Empty) else if (toTray == ETrayType.Empty)
{ {
targetPosition.TakeTrayX = GlobalVar.EmptyStockGrabPos + GlobalVar.ClampCenter2CameraCenterDist; targetPosition.TakeTrayX = GlobalVar.EmptyStockGrabPos + GlobalVar.ClampCenter2CameraCenterDist;
} }
//takeTrayFinishedEvent?.Invoke(); //takeTrayFinishedEvent?.Invoke();
if(GroupAxisMove.TakeXMove(GetClassName(),targetPosition.TakeTrayX,GlobalVar.WholeSpeed)) if (GroupAxisMove.TakeXMove(GetClassName(), targetPosition.TakeTrayX, GlobalVar.WholeSpeed))
{ {
if (GlobalVar.VirtualAxis) if (GlobalVar.VirtualAxis)
{ {
@ -368,156 +448,216 @@ namespace Rs.MotionPlat.Flow
step = ETakeTrayFlowStep.; step = ETakeTrayFlowStep.;
} }
} }
//else catch (Exception ex)
//{ {
// //alarmEntity = AlarmCollection.Get(AlarmConstID.运动不安全).Transform("LoadY", "TurnvoerY"); AlarmCollection.SystemExceptionAlarm(ex);
// //AlarmMessageBox.ShowDialog(alarmEntity, ETipButton.Ok, null); }
//}
break; break;
case ETakeTrayFlowStep.: case ETakeTrayFlowStep.:
if (Ops.IsStop("TakeTrayX") || GlobalVar.VirtualAxis) try
{ {
//if(toTray== ETrayType.Empty) if (Ops.IsStop("TakeTrayX") || GlobalVar.VirtualAxis)
//{ {
// if(StockManager.HasTray(3)) //if(toTray== ETrayType.Empty)
// { //{
// StockManager.Down(3); // if(StockManager.HasTray(3))
// } // {
//} // StockManager.Down(3);
//StockManager.OpenTray(toStockIndex); // }
logInfo = GetClassName() + $"已运动到{toTray}料仓放料盘上方"; //}
MessageQueue.Instance.Insert(logInfo); //StockManager.OpenTray(toStockIndex);
//arrivedDumpPosEvent?.Invoke(); logInfo = GetClassName() + $"已运动到{toTray}料仓放料盘上方";
step = ETakeTrayFlowStep.; MessageQueue.Instance.Insert(logInfo);
//arrivedDumpPosEvent?.Invoke();
step = ETakeTrayFlowStep.;
}
}
catch (Exception ex)
{
AlarmCollection.SystemExceptionAlarm(ex);
} }
break; break;
case ETakeTrayFlowStep.: case ETakeTrayFlowStep.:
//if ((StockManager.Instance.GetStock(m_toTray).Status == EStockTrayStatus.Unloaded || StockManager.Instance.GetStock(m_toTray).Status == EStockTrayStatus.Empty) || GlobalVar.VirtualAxis) //if ((StockManager.Instance.GetStock(m_toTray).Status == EStockTrayStatus.Unloaded || StockManager.Instance.GetStock(m_toTray).Status == EStockTrayStatus.Empty) || GlobalVar.VirtualAxis)
try
{ {
StockManager.OpenTray(toStockIndex); StockManager.OpenTray(toStockIndex);
TakeTrayModule.CylinderGoDown(GetClassName()); TakeTrayModule.CylinderGoDown(GetClassName());
step = ETakeTrayFlowStep.; step = ETakeTrayFlowStep.;
stopwatch.Restart(); stopwatch.Restart();
} }
catch (Exception ex)
{
AlarmCollection.SystemExceptionAlarm(ex);
}
break; break;
case ETakeTrayFlowStep.: case ETakeTrayFlowStep.:
if (Ops.IsOn("料盘搬运气缸动位")) try
{ {
logInfo = GetClassName() + "检测到料盘搬运气缸动位 OK"; if (Ops.IsOn("料盘搬运气缸动位"))
MessageQueue.Instance.Insert(logInfo); {
stopwatch.Stop(); logInfo = GetClassName() + "检测到料盘搬运气缸动位 OK";
//if(toTray!= ETrayType.Empty) MessageQueue.Instance.Insert(logInfo);
//{ stopwatch.Stop();
// //夹住料盘 //if(toTray!= ETrayType.Empty)
// Ops.On($"料仓夹磁气缸{toStockIndex}夹"); //{
// Ops.Off($"料仓夹磁气缸{toStockIndex}开"); // //夹住料盘
// Thread.Sleep(100); // Ops.On($"料仓夹磁气缸{toStockIndex}夹");
//} // Ops.Off($"料仓夹磁气缸{toStockIndex}开");
// Thread.Sleep(100);
//}
////关闭真空吸 ////关闭真空吸
//Ops.On("料盘真空关"); //Ops.On("料盘真空关");
//Ops.Off("料盘真空开"); //Ops.Off("料盘真空开");
//logInfo = GetClassName() + $"料盘真空关 on"; //logInfo = GetClassName() + $"料盘真空关 on";
//MessageQueue.Instance.Insert(logInfo); //MessageQueue.Instance.Insert(logInfo);
//Thread.Sleep(100); //Thread.Sleep(100);
if(isNeedGoDown) //关闭真空吸
TakeTrayModule.VacOperation(EIoOperate.Close, GetClassName());
if (isNeedGoDown)
{
StockManager.Down(toStockIndex);
}
StockManager.CloseTray(toStockIndex);
step = ETakeTrayFlowStep.;
}
else if (stopwatch.ElapsedMilliseconds > 5000)
{ {
StockManager.Down(toStockIndex); alarmEntity = AlarmCollection.Get(AlarmConstID.);
if (alarmEntity != null)
{
LogHelper.Debug(GetClassName() + alarmEntity.CN);
Msg.ShowError(alarmEntity.CN);
//AlarmMessageBox.ShowDialog(alarmEntity, ETipButton.Ok, null);
}
else
{
Msg.ShowError("翻译文件中未找到上下气缸动位");
}
stopwatch.Stop();
stopwatch.Restart();
} }
StockManager.CloseTray(toStockIndex);
//关闭真空吸
TakeTrayModule.VacOperation(EIoOperate.Close,GetClassName());
step = ETakeTrayFlowStep.;
} }
else if(stopwatch.ElapsedMilliseconds>5000) catch (Exception ex)
{ {
alarmEntity = AlarmCollection.Get(AlarmConstID.); AlarmCollection.SystemExceptionAlarm(ex);
if (alarmEntity != null)
{
LogHelper.Debug(GetClassName() + alarmEntity.CN);
Msg.ShowError(alarmEntity.CN);
//AlarmMessageBox.ShowDialog(alarmEntity, ETipButton.Ok, null);
}
else
{
Msg.ShowError("翻译文件中未找到上下气缸动位");
}
stopwatch.Stop();
stopwatch.Restart();
} }
break; break;
case ETakeTrayFlowStep.: case ETakeTrayFlowStep.:
TakeTrayModule.CylinderGoUp(GetClassName()); try
step = ETakeTrayFlowStep.;
stopwatch.Restart();
break;
case ETakeTrayFlowStep.:
if (Ops.IsOn("料盘搬运气缸原位"))
{ {
logInfo = GetClassName() + "料盘搬运气缸原位 OK"; TakeTrayModule.CylinderGoUp(GetClassName());
MessageQueue.Instance.Insert(logInfo); step = ETakeTrayFlowStep.;
step = ETakeTrayFlowStep.; stopwatch.Restart();
}
catch (Exception ex)
{
AlarmCollection.SystemExceptionAlarm(ex);
} }
else if(stopwatch.ElapsedMilliseconds>5000)
break;
case ETakeTrayFlowStep.:
try
{ {
alarmEntity = AlarmCollection.Get(AlarmConstID.); if (Ops.IsOn("料盘搬运气缸原位"))
if (alarmEntity != null)
{ {
LogHelper.Debug(GetClassName() + alarmEntity.CN); logInfo = GetClassName() + "料盘搬运气缸原位 OK";
Msg.ShowError(alarmEntity.CN); MessageQueue.Instance.Insert(logInfo);
//AlarmMessageBox.ShowDialog(alarmEntity, ETipButton.Ok, null); step = ETakeTrayFlowStep.;
} }
else else if (stopwatch.ElapsedMilliseconds > 5000)
{ {
Msg.ShowError("翻译文件中未找到上下气缸动位"); alarmEntity = AlarmCollection.Get(AlarmConstID.);
if (alarmEntity != null)
{
LogHelper.Debug(GetClassName() + alarmEntity.CN);
Msg.ShowError(alarmEntity.CN);
//AlarmMessageBox.ShowDialog(alarmEntity, ETipButton.Ok, null);
}
else
{
Msg.ShowError("翻译文件中未找到上下气缸动位");
}
stopwatch.Stop();
stopwatch.Restart();
} }
stopwatch.Stop();
stopwatch.Restart();
} }
catch (Exception ex)
{
AlarmCollection.SystemExceptionAlarm(ex);
}
break; break;
case ETakeTrayFlowStep.: case ETakeTrayFlowStep.:
if (!TakeTrayModule.HasTray()) try
{ {
logInfo = GetClassName() + $"放料盘完成"; if (!TakeTrayModule.HasTray())
MessageQueue.Instance.Insert(logInfo);
step = ETakeTrayFlowStep.;
if(toTray== ETrayType.Empty)
{ {
StockManager.CloseTray(toStockIndex); logInfo = GetClassName() + $"放料盘完成";
StockManager.OpenTray(toStockIndex); MessageQueue.Instance.Insert(logInfo);
step = ETakeTrayFlowStep.;
if (toTray == ETrayType.Empty)
{
StockManager.CloseTray(toStockIndex);
StockManager.OpenTray(toStockIndex);
}
//if (mLoadUnloadType == ELoadUnloadType.Load)
//{
// StockManager.Instance.Load(m_toTray, EStockTrayLoadMode.AfterTakeTray);
//}
}
else
{
step = ETakeTrayFlowStep.;
//粘料盘
//logInfo = "检测到料盘未放下,请处理后点击确定重放";
//MessageQueue.Instance.Warn(GetClassName() + logInfo);
//TestCenterMessageBox.Show(AlarmConstID.UpDownCylinderExceptionAlarm, logInfo, ETipButton.Ok);
//TestCenterMessageBox.WaitResult(AlarmConstID.UpDownCylinderExceptionAlarm);
//step = ETakeTrayFlowStep.到放料盘上方;
} }
//if (mLoadUnloadType == ELoadUnloadType.Load)
//{
// StockManager.Instance.Load(m_toTray, EStockTrayLoadMode.AfterTakeTray);
//}
} }
else catch (Exception ex)
{ {
step = ETakeTrayFlowStep.; AlarmCollection.SystemExceptionAlarm(ex);
//粘料盘
//logInfo = "检测到料盘未放下,请处理后点击确定重放";
//MessageQueue.Instance.Warn(GetClassName() + logInfo);
//TestCenterMessageBox.Show(AlarmConstID.UpDownCylinderExceptionAlarm, logInfo, ETipButton.Ok);
//TestCenterMessageBox.WaitResult(AlarmConstID.UpDownCylinderExceptionAlarm);
//step = ETakeTrayFlowStep.到放料盘上方;
} }
break; break;
case ETakeTrayFlowStep.: case ETakeTrayFlowStep.:
if(GroupAxisMove.TakeXMove(GetClassName(), GlobalVar.TakeTrayXWaitPos, GlobalVar.WholeSpeed)) try
{ {
logInfo = GetClassName() + $"到待机位"; if (GroupAxisMove.TakeXMove(GetClassName(), GlobalVar.TakeTrayXWaitPos, GlobalVar.WholeSpeed))
MessageQueue.Instance.Insert(logInfo); {
step = ETakeTrayFlowStep.; logInfo = GetClassName() + $"到待机位";
MessageQueue.Instance.Insert(logInfo);
step = ETakeTrayFlowStep.;
}
}
catch (Exception ex)
{
AlarmCollection.SystemExceptionAlarm(ex);
} }
break; break;
case ETakeTrayFlowStep.: case ETakeTrayFlowStep.:
if(Ops.IsStop("TakeTrayX")) try
{ {
logInfo = GetClassName() + $"从{fromTray}搬运到{toTray}完成"; if (Ops.IsStop("TakeTrayX"))
MessageQueue.Instance.Insert(logInfo); {
TakeStatus = ETakeStatus.TakeOK; logInfo = GetClassName() + $"从{fromTray}搬运到{toTray}完成";
//dumpTrayFinishedEvent?.Invoke(); MessageQueue.Instance.Insert(logInfo);
finisehd = true; TakeStatus = ETakeStatus.TakeOK;
//dumpTrayFinishedEvent?.Invoke();
finisehd = true;
}
}
catch (Exception ex)
{
AlarmCollection.SystemExceptionAlarm(ex);
} }
break; break;
} }

Loading…
Cancel
Save