This repository has been archived on 2023-03-29. You can view files and clone it, but cannot push or open issues or pull requests.
Sic02/Modules/Mainframe/TMs/TMRobotPlaceRoutine.cs

329 lines
12 KiB
C#

using System;
using Aitex.Core.RT.Device;
using Aitex.Core.RT.Event;
using Aitex.Core.RT.Routine;
using Aitex.Core.RT.SCCore;
using Aitex.Sorter.Common;
using MECF.Framework.Common.Equipment;
using MECF.Framework.Common.Schedulers;
using MECF.Framework.Common.SubstrateTrackings;
using MECF.Framework.RT.EquipmentLibrary.HardwareUnits.LoadLocks;
using MECF.Framework.RT.EquipmentLibrary.HardwareUnits.PMs;
using MECF.Framework.RT.EquipmentLibrary.HardwareUnits.Robot;
using MECF.Framework.RT.EquipmentLibrary.HardwareUnits.TMs;
using MECF.Framework.RT.EquipmentLibrary.HardwareUnits.Robots;
using Aitex.Core.RT.Log;
namespace Mainframe.TMs
{
public class TMRobotPlaceRoutine : TMBaseRoutine
{
enum RoutineStep
{
WaitOpenSlitValveInterlock,
OpenSlitValve,
CheckBeforePlace,
Place,
PrepareTransfer,
Extend,
Handoff,
HandoffDelay,
Retract,
UpdateWaferInfoByHandoff,
RequestWaferPresent,
BeforePlaceRequestWaferPresent,
AfterPlaceRequestWaferPresent,
CheckWaferInfoByRobotSensor,
BeforePlaceCheckWaferInfoByRobotSensor,
AfterPlaceCheckWaferInfoByRobotSensor,
RequestAWCData,
SetRobortExtendToDo,
ClearRobortExtendToDo,
WaitCloseSlitValveInterlock,
CloseSlitValve,
WaitPMSensor,
PostTransfer,
OpenShutter,
CloseShutter,
Delay1,
Delay2,
VceMoveToSlot,
RobotGotoNotWait,
PrepareTransferNotWait,
CheckRobotReady,
CheckTransferPrepared,
TimeDelay1
}
private ModuleName _target;
private int _targetSlot;
private RobotArmEnum _blade;
private int _placeTimeout;
private int _postTransferTimeout;
private bool _requestAWCData;
private double _shutterAndSlitValveMotionInterval;
private bool _autoHand;
private TMSlitValveRoutine _openSlitValveRoutine = new TMSlitValveRoutine();
private TMSlitValveRoutine _closeSlitValveRoutine = new TMSlitValveRoutine();
//private VCEMoveToSlotRoutine _vceMoveToSlotRoutine;
private bool _isShutterAndSlitValveMotionOneByOne;
private SicTM _tm;
public TMRobotPlaceRoutine()
{
Module = "TMRobot";
Name = "Place";
_tm = DEVICE.GetDevice<SicTM>($"{ ModuleName.System.ToString()}.{ ModuleName.TM.ToString()}");
}
public void Init(ModuleName target, int targetSlot, RobotArmEnum blade)
{
Init(target, targetSlot, blade, false);
}
public void Init(ModuleName target, int targetSlot, int blade)
{
Init(target, targetSlot, blade == 0 ? RobotArmEnum.Blade1 : RobotArmEnum.Blade2, false);
}
public void Init(ModuleName target, int targetSlot)
{
Init(target, targetSlot, RobotArmEnum.Blade1, true);
}
private void Init(ModuleName target, int targetSlot, RobotArmEnum blade, bool autoHand)
{
_autoHand = autoHand;
_target = target;
_targetSlot = targetSlot;
_blade = blade;
_openSlitValveRoutine.Init(target.ToString(), true);
_closeSlitValveRoutine.Init(target.ToString(), false);
}
public override Result Start(params object[] objs)
{
Reset();
if (RobotDevice.RobotState != RobotStateEnum.Idle)
{
EV.PostWarningLog(Module, $"Can not place, TMRobot Is Not IDLE");
return Result.FAIL;
}
_placeTimeout = SC.GetValue<int>("TMRobot.PlaceTimeout");
//if (ModuleHelper.IsPm(_target))
//{
// _postTransferTimeout = SC.GetValue<int>($"{_target}.PostTransferTimeout");
// _shutterAndSlitValveMotionInterval = SC.GetValue<double>($"{_target}.ShutterAndSlitValveMotionInterval");
// _isShutterAndSlitValveMotionOneByOne = SC.GetValue<bool>($"{_target}.ShutterAndSlitValveMotionOneByOne");
// CoralPM pm = DEVICE.GetDevice<CoralPM>(_target.ToString());
// if (!pm.PickPlaceCheck(out string reason, false))
// {
// EV.PostWarningLog(Module, $"Can not place, {reason}");
// return Result.FAIL;
// }
//}
_requestAWCData = SC.GetValue<bool>("System.RequestAWCDataAfterPlace");
if (!WaferManager.Instance.CheckNoWafer(_target, _targetSlot))
{
EV.PostWarningLog(Module, $"Can not place, should no wafer at {_target}, {_targetSlot + 1}");
return Result.FAIL;
}
if (_autoHand)
{
if (WaferManager.Instance.CheckHasWafer(Module, 0))
{
_blade = RobotArmEnum.Blade1;
}
else if (WaferManager.Instance.CheckHasWafer(Module, 1))
{
_blade = RobotArmEnum.Blade2;
}
else
{
EV.PostWarningLog(Module, $"Can not place, Robot both arm no wafer");
return Result.FAIL;
}
}
int slot = _blade == RobotArmEnum.Blade1 ? 0 : 1;
if (!WaferManager.Instance.CheckHasWafer(Module, slot))
{
EV.PostWarningLog(Module, $"Can not place, Robot arm {slot + 1} no wafer");
return Result.FAIL;
}
//Place之前先,根据Sensor检测是否有盘
if (!SC.GetValue<bool>("System.IsSimulatorMode"))
{
if (ModuleHelper.IsLoadLock(_target) && SensorLLWaferPresence.Value)
{
EV.PostWarningLog(Module, $"Can not place, LoadLock sensor has wafer");
return Result.FAIL;
}
if (ModuleHelper.IsBuffer(_target) && SensorBufferWaferPresence.Value)
{
EV.PostWarningLog(Module, $"Can not place,Buffer sensor check has wafer");
return Result.FAIL;
}
}
//if (ModuleHelper.IsVCE(_target))
//{
// var vce = DEVICE.GetDevice<CoralVCE>(_target.ToString());
// if (!vce.CheckEnableTransfer(EnumTransferType.Place))
// {
// EV.PostWarningLog(Module, $"can not place, {_target} not ready for transfer");
// return Result.FAIL;
// }
// _vceMoveToSlotRoutine = new VCEMoveToSlotRoutine(_target.ToString());
// _vceMoveToSlotRoutine.Init(_targetSlot);
//}
//if (ModuleHelper.IsPm(_target))
//{
// PM pm = DEVICE.GetDevice<PM>(_target.ToString());
// if (!pm.CheckEnableTransfer(EnumTransferType.Place, out string reason))
// {
// EV.PostWarningLog(Module, $"can not place, {_target} not ready for transfer");
// return Result.FAIL;
// }
//}
Notify($"Start, Place to {_target} slot {_targetSlot + 1}, by {(_blade == RobotArmEnum.Blade1 ? "Blade1" : "Blade2")}");
return Result.RUN;
}
public override void Abort()
{
_tm.CloseAllVentPumpValue();
if (!IsPicking)
{
RobotDevice.Stop();
}
Notify("Abort");
}
public override Result Monitor()
{
try
{
WaitSlitValveOpenInterlock((int)RoutineStep.WaitOpenSlitValveInterlock, TMDevice.GetSlitValve(_target), _placeTimeout);
// if (ModuleHelper.IsPm(_target))
{
RobotGotoNotWait((int)RoutineStep.RobotGotoNotWait, RobotDevice, _target, _targetSlot, _blade, _placeTimeout);
if (_isShutterAndSlitValveMotionOneByOne)
{
Delay((int)RoutineStep.Delay1, _shutterAndSlitValveMotionInterval);
ExecuteRoutine((int)RoutineStep.OpenSlitValve, _openSlitValveRoutine);
}
else
{
ExecuteRoutine((int)RoutineStep.OpenSlitValve, _openSlitValveRoutine);
}
CheckRobotReady((int)RoutineStep.CheckRobotReady, RobotDevice, _placeTimeout);
}
if (_target == ModuleName.VCEA || _target == ModuleName.VCEB)
ExecuteRoutine((int)RoutineStep.OpenSlitValve, _openSlitValveRoutine);
CheckBeforePlace((int)RoutineStep.CheckBeforePlace, _target, _targetSlot, _blade);
RobotRequestWaferPresent((int)RoutineStep.BeforePlaceRequestWaferPresent, RobotDevice, _blade, _placeTimeout);
CheckWaferInfoByRobotRQ((int)RoutineStep.BeforePlaceCheckWaferInfoByRobotSensor, RobotDevice, _blade, 1000);
WaitPMReadySensor((int)RoutineStep.WaitPMSensor, _target, 5);
SetRobortExtendToDO((int)RoutineStep.SetRobortExtendToDo, _target, 2);
//if (ModuleHelper.IsVCE(_target))
//{
// RobotGotoNotWait((int)RoutineStep.RobotGotoNotWait, RobotDevice, _target, _targetSlot, _blade, _placeTimeout);
// ExecuteRoutine((int)RoutineStep.VceMoveToSlot, _vceMoveToSlotRoutine);
//}
//if (ModuleHelper.IsPm(_target) && DEVICE.GetDevice<PM>(_target.ToString()).IsActiveHandoff)
//{
// CheckTransferPrepared((int)RoutineStep.CheckTransferPrepared, DEVICE.GetDevice<PM>(_target.ToString()), EnumTransferType.Place, _placeTimeout);
// //PrepareTransfer((int)RoutineStep.PrepareTransfer, DEVICE.GetDevice<PM>(_target.ToString()), EnumTransferType.Place, _placeTimeout);
// PlaceExtend((int)RoutineStep.Extend, RobotDevice, _target, _targetSlot, _blade, _placeTimeout);
// TransferHandoff((int)RoutineStep.Handoff, DEVICE.GetDevice<PM>(_target.ToString()), EnumTransferType.Place, _placeTimeout);
// Delay((int)RoutineStep.HandoffDelay, 2);
// UpdateWaferInfoDueHandoff((int)RoutineStep.UpdateWaferInfoByHandoff, ModuleHelper.Converter(Module), _blade == RobotArmEnum.Blade1 ? 0 : 1, _target, _targetSlot);
// PlaceRetract((int)RoutineStep.Retract, RobotDevice, _target, _targetSlot, _blade, _placeTimeout);
//}
//else
{
CheckRobotReady((int)RoutineStep.CheckRobotReady, RobotDevice, _placeTimeout);
Place((int)RoutineStep.Place, RobotDevice, _target, _targetSlot, _blade, _placeTimeout);
IsPicking = false;
}
TimeDelay((int)RoutineStep.TimeDelay1, 1);
RobotRequestWaferPresent((int)RoutineStep.RequestWaferPresent, RobotDevice, _blade, _placeTimeout);
CheckWaferInfoByRobotRQ((int)RoutineStep.CheckWaferInfoByRobotSensor, RobotDevice, _blade, 1000);
if (_requestAWCData)
{
RobotRequestWaferAWCData((int)RoutineStep.RequestAWCData, RobotDevice, _placeTimeout);
}
ClearRobortExtendToDO((int)RoutineStep.ClearRobortExtendToDo);
ExecuteRoutine((int)RoutineStep.CloseSlitValve, _closeSlitValveRoutine);
//if (ModuleHelper.IsPm(_target))
//{
// PostTransfer((int)RoutineStep.PostTransfer, Singleton<RouteManager>.Instance.GetPMEntity(_target), DEVICE.GetDevice<PM>(_target.ToString()), EnumTransferType.Pick, _postTransferTimeout);
//}
}
catch (RoutineBreakException)
{
return Result.RUN;
}
catch (RoutineFaildException ex)
{
LOG.Error(ex.ToString());
RobotDevice.Stop();
return Result.FAIL;
}
Notify($"Finish, Place to {_target} slot {_targetSlot + 1}, by {_blade}");
return Result.DONE;
}
}
}