Sic03-8inch/Modules/Mainframe/Aligners/Routines/Base/AlignerBaseRoutine.cs

236 lines
7.3 KiB
C#

using System;
using Aitex.Core.RT.Device;
using Aitex.Core.RT.Routine;
using MECF.Framework.Common.Equipment;
using MECF.Framework.Common.SubstrateTrackings;
using MECF.Framework.RT.EquipmentLibrary.HardwareUnits.Aligners.HiWinAligner;
namespace SicModules.Aligners.Routines.Base
{
public class AlignerBaseRoutine : ModuleRoutine, IRoutine
{
private readonly HwAlignerGuide _alignerDevice = null;
protected AlignerBaseRoutine() : base(ModuleName.Aligner.ToString())
{
_alignerDevice = DEVICE.GetDevice<HwAlignerGuide>($"EFEM.HiWinAligner");
}
public override void Abort()
{
}
//清除Aligner报警
protected void AlignerERS(int id,int timeout)
{
Tuple<bool, Result> ret = ExecuteAndWait(id, () =>
{
Notify($"Aligner ERS");
_alignerDevice.Set("ERS");
return true;
}, () => !_alignerDevice.IsBusy, timeout * 1000);
if (ret.Item1)
{
if (ret.Item2 == Result.FAIL)
{
throw (new RoutineFaildException());
}
else if (ret.Item2 == Result.TIMEOUT)
{
Stop($"Aligner ERS Timeout, over {timeout} seconds");
throw (new RoutineFaildException());
}
else
throw (new RoutineBreakException());
}
}
//初始化变量
protected void ResetVar(int id)
{
Tuple<bool, Result> ret = Execute(id, () =>
{
Notify($"Aligner Reset Variate ");
_alignerDevice.Reset();
return true;
});
if (ret.Item1)
{
if (ret.Item2 == Result.FAIL)
{
Stop($"Sensor[DI-32] check no tray");
throw (new RoutineFaildException());
}
else
throw (new RoutineBreakException());
}
}
//电机回原点
protected void Home(int id, int timeout)
{
Tuple<bool, Result> ret = ExecuteAndWait(id, () =>
{
Notify($"Aligner Home Msg");
_alignerDevice.Set("HOM");
return true;
}, () =>
{
return !_alignerDevice.IsBusy;
}, timeout * 1000);
if (ret.Item1)
{
if (ret.Item2 == Result.FAIL)
{
throw (new RoutineFaildException());
}
else if (ret.Item2 == Result.TIMEOUT) //timeout
{
Stop($"Aligner home Timeout, over {timeout} seconds");
throw (new RoutineFaildException());
}
else
throw (new RoutineBreakException());
}
}
//移动到测量中心
protected void AlignerMoveToMeasure(int id, int timeout)
{
Tuple<bool, Result> ret = ExecuteAndWait(id, () =>
{
Notify($"Move to Measure position");
_alignerDevice.Set("MTM");
return true;
}, () =>
{
return !_alignerDevice.IsBusy;
}, timeout * 1000);
if (ret.Item1)
{
if (ret.Item2 == Result.FAIL)
{
throw (new RoutineFaildException());
}
else if (ret.Item2 == Result.TIMEOUT)
{
Stop($"Aligner Move to Measure position Timeout, over {timeout} seconds");
throw (new RoutineFaildException());
}
else
throw (new RoutineBreakException());
}
}
//检查是否有Wafer
protected void CheckHaveWafer(int id, int timeout)
{
Tuple<bool, Result> ret = ExecuteAndWait(id, () =>
{
Notify($"Check wafer in position");
_alignerDevice.CheckWaferLoad();
return true;
}, () =>
{
if (!_alignerDevice.IsBusy)
{
if (_alignerDevice.HaveWafer)
{
if (WaferManager.Instance.CheckNoWafer(Module, 0))
{
WaferManager.Instance.CreateWafer(ModuleHelper.Converter(Module), 0,Aitex.Core.Common.WaferStatus.Normal);
}
return true;
}
else
{
if (WaferManager.Instance.CheckHasWafer(Module, 0))
{
WaferManager.Instance.DeleteWafer(ModuleHelper.Converter(Module), 0);
}
return true;
}
}
return false;
}, timeout * 1000);
if (ret.Item1)
{
if (ret.Item2 == Result.FAIL)
{
throw (new RoutineFaildException());
}
else if (ret.Item2 == Result.TIMEOUT)
{
Stop($"Aligner Check Wafer Timeout, over {timeout} seconds");
throw (new RoutineFaildException());
}
else
throw (new RoutineBreakException());
}
}
protected void MoveToMeasurementCenter(int id, int timeout)
{
Tuple<bool, Result> ret = ExecuteAndWait(id, () =>
{
Notify($"Move to aligner put place");
_alignerDevice.MoveToRobotPutPlace();
return true;
}, () => !_alignerDevice.IsBusy, timeout * 1000);
if (ret.Item1)
{
if (ret.Item2 == Result.FAIL)
{
throw (new RoutineFaildException());
}
else if (ret.Item2 == Result.TIMEOUT) //timeout
{
Stop($"Aligner Move to Robot Put Place Timeout, over {timeout} seconds");
throw (new RoutineFaildException());
}
else
throw (new RoutineBreakException());
}
}
protected void AlignerMove(int id, int timeout)
{
var ret = ExecuteAndWait(id, () =>
{
Notify($"Start to align");
_alignerDevice.DoAliger();
return true;
}, () => !_alignerDevice.IsBusy, timeout * 1000);
if (ret.Item1)
{
if (ret.Item2 == Result.FAIL)
{
throw (new RoutineFaildException());
}
else if (ret.Item2 == Result.TIMEOUT) //timeout
{
Stop($"Aligner Align Timeout, over {timeout} seconds");
throw (new RoutineFaildException());
}
else
throw (new RoutineBreakException());
}
}
}
}