411 lines
13 KiB
C#
411 lines
13 KiB
C#
using System;
|
|
using System.Text;
|
|
using Aitex.Core.RT.Device;
|
|
using Aitex.Core.RT.Device.Unit;
|
|
using Aitex.Core.RT.Event;
|
|
using Aitex.Core.RT.Routine;
|
|
using Aitex.Core.RT.SCCore;
|
|
using MECF.Framework.Common.Equipment;
|
|
using MECF.Framework.RT.EquipmentLibrary.HardwareUnits.LoadLocks;
|
|
using MECF.Framework.RT.EquipmentLibrary.HardwareUnits.Robot.MAG7;
|
|
using MECF.Framework.RT.EquipmentLibrary.HardwareUnits.TMs;
|
|
using Mainframe.Devices;
|
|
using Mainframe.TMs;
|
|
using System.Diagnostics;
|
|
|
|
namespace Mainframe.LLs
|
|
{
|
|
public class LoadLockPumpRoutine : ModuleRoutine, IRoutine
|
|
{
|
|
enum RoutineStep
|
|
{
|
|
CheckForelinePressure,
|
|
RequestPump,
|
|
RequestPumpDelay,
|
|
SlowPump,
|
|
CloseSlowValve,
|
|
FastPump,
|
|
PumpDelay,
|
|
CloseFastValve,
|
|
Delay,
|
|
TimeDelay1,
|
|
}
|
|
|
|
private double _pumpBasePressure;
|
|
private double _forelineBasePressure;
|
|
private double _pumpSwitchPressure;
|
|
|
|
private int _waitForelineTimeout;
|
|
private int _slowPumpTimeout;
|
|
private int _fastPumpTimeout;
|
|
private int _pumpDelayTime;
|
|
private int _routineTimeOut;
|
|
|
|
private int _waitPumpTimeout;
|
|
|
|
private LoadLock _ll;
|
|
private SicTM _tm;
|
|
private Devices.IoPump _pumpType;
|
|
private IoInterLock _tmIoInterLock;
|
|
|
|
private bool _useSettingValue;
|
|
|
|
private Stopwatch _swTimer = new Stopwatch();
|
|
private bool isAtmMode = false;
|
|
|
|
public LoadLockPumpRoutine(ModuleName module )
|
|
{
|
|
Module = module.ToString();
|
|
Name = "Pump";
|
|
_ll = DEVICE.GetDevice<SicLoadLock>($"{ Module}.{ Module}");
|
|
_tm = DEVICE.GetDevice<SicTM>($"{ModuleName.System.ToString()}.{"TM"}");
|
|
|
|
_pumpType = DEVICE.GetDevice<Devices.IoPump>($"TM.TMPump");
|
|
_tmIoInterLock = DEVICE.GetDevice<IoInterLock>("TM.IoInterLock");
|
|
}
|
|
|
|
public void Init()
|
|
{
|
|
_useSettingValue = false;
|
|
}
|
|
|
|
public void Init(double basePressure, int pumpDelayTime)
|
|
{
|
|
_pumpBasePressure = basePressure;
|
|
_pumpDelayTime = pumpDelayTime;
|
|
_useSettingValue = true;
|
|
}
|
|
|
|
public Result Start(params object[] objs)
|
|
{
|
|
Reset();
|
|
|
|
string reason;
|
|
if (!_ll.SetFastVentValve(false, out reason) || !_ll.SetSlowVentValve(false, out reason))
|
|
{
|
|
EV.PostAlarmLog(Module, $"Can not turn off valves, {reason}");
|
|
return Result.FAIL;
|
|
}
|
|
|
|
|
|
_forelineBasePressure = SC.GetValue<double>("LoadLock.ForelinePressureBase");
|
|
_pumpSwitchPressure = SC.GetValue<double>("LoadLock.Pump.SlowFastPumpSwitchPressure");
|
|
_waitPumpTimeout = SC.GetValue<int>("LoadLock.WaitPumpTimeout");
|
|
_waitForelineTimeout = SC.GetValue<int>("LoadLock.WaitForelinePressureTimeout");
|
|
_slowPumpTimeout = SC.GetValue<int>("LoadLock.Pump.SlowPumpTimeout");
|
|
_fastPumpTimeout = SC.GetValue<int>("LoadLock.Pump.FastPumpTimeout");
|
|
_routineTimeOut = SC.GetValue<int>("LoadLock.Pump.RoutineTimeOut");
|
|
|
|
if (!_useSettingValue)
|
|
{
|
|
_pumpBasePressure = SC.GetValue<double>("LoadLock.Pump.PumpBasePressure");
|
|
_pumpDelayTime = SC.GetValue<int>("LoadLock.Pump.PumpDelayTime");
|
|
}
|
|
|
|
if (_pumpType.IsAlarm)
|
|
{
|
|
EV.PostAlarmLog(Module, $"can not pump,TM pump alarm");
|
|
return Result.FAIL;
|
|
}
|
|
if (!_pumpType.IsRunning)
|
|
{
|
|
EV.PostAlarmLog(Module, $"can not pump,TM pump is not running");
|
|
return Result.FAIL;
|
|
}
|
|
if (!_tm.SetFastPumpValve(false, out reason))
|
|
{
|
|
EV.PostAlarmLog(Module, $"can not pump, TM fast pump value can not close");
|
|
return Result.FAIL;
|
|
}
|
|
|
|
|
|
if (SC.ContainsItem("LoadLock.RunPumpRoutineEventBelowBasePressure") && !SC.GetValue<bool>("LoadLock.RunPumpRoutineEventBelowBasePressure"))
|
|
{
|
|
if (_ll.ChamberPressure < _pumpBasePressure)
|
|
{
|
|
EV.PostInfoLog(Module, $"{_ll.Module} already under pump base pressure");
|
|
return Result.DONE;
|
|
}
|
|
}
|
|
|
|
if (!_ll.CheckDoorClose())
|
|
{
|
|
EV.PostAlarmLog(Module, $"Can not pump, door is open");
|
|
return Result.FAIL;
|
|
}
|
|
|
|
if (!_tm.CheckSlitValveClose(ModuleHelper.Converter(_ll.Module)))
|
|
{
|
|
EV.PostAlarmLog(Module, $"Can not pump, slit valve is open");
|
|
return Result.FAIL;
|
|
}
|
|
if (!_tm.SetTmToLLVent(false, out _))
|
|
{
|
|
EV.PostAlarmLog(Module, $"can not pump,can not close v85!");
|
|
}
|
|
if (!_tmIoInterLock.SetLLPumpRoutineRunning(true, out reason))
|
|
{
|
|
EV.PostAlarmLog(Module, $"can not pump,{reason}");
|
|
return Result.FAIL;
|
|
}
|
|
|
|
_swTimer.Restart();
|
|
Notify("Start");
|
|
return Result.RUN;
|
|
}
|
|
|
|
|
|
public Result Monitor()
|
|
{
|
|
try
|
|
{
|
|
if (isAtmMode)
|
|
{
|
|
return Result.DONE;
|
|
}
|
|
|
|
|
|
CheckRoutineTimeOut();
|
|
|
|
CheckForelinePressure((int)RoutineStep.CheckForelinePressure, _ll, _forelineBasePressure, _waitForelineTimeout);
|
|
|
|
TimeDelay((int)RoutineStep.RequestPumpDelay, 1);
|
|
|
|
SlowPump((int)RoutineStep.SlowPump, _ll, _pumpSwitchPressure, _slowPumpTimeout);
|
|
|
|
FastPump((int)RoutineStep.FastPump, _ll, _pumpBasePressure, _fastPumpTimeout);
|
|
|
|
TimeDelay((int)RoutineStep.PumpDelay, _pumpDelayTime);
|
|
|
|
CloseFastPumpValve((int)RoutineStep.CloseFastValve, _ll);
|
|
|
|
CloseSlowPumpValve((int)RoutineStep.CloseSlowValve, _ll);
|
|
|
|
|
|
|
|
}
|
|
catch (RoutineBreakException)
|
|
{
|
|
return Result.RUN;
|
|
}
|
|
catch (RoutineFaildException)
|
|
{
|
|
_ll.SetSlowPumpValve(false, out _);
|
|
_ll.SetFastPumpValve(false, out _);
|
|
return Result.FAIL;
|
|
}
|
|
|
|
|
|
Notify($"Finished ! Elapsed time: {(int)(_swTimer.ElapsedMilliseconds / 1000)} s");
|
|
_tmIoInterLock.DoLLPumpDownRoutineRunning = false;
|
|
|
|
return Result.DONE;
|
|
}
|
|
|
|
public void Abort()
|
|
{
|
|
_tmIoInterLock.DoLLPumpDownRoutineRunning = false;
|
|
_ll.SetFastPumpValve(false, out string reason);
|
|
_ll.SetSlowPumpValve(false, out reason);
|
|
_ll.SetFastVentValve(false, out reason);
|
|
_ll.SetSlowVentValve(false, out reason);
|
|
}
|
|
private void CheckRoutineTimeOut()
|
|
{
|
|
if (_routineTimeOut > 10)
|
|
{
|
|
if ((int)(_swTimer.ElapsedMilliseconds / 1000) > _routineTimeOut)
|
|
{
|
|
Notify($"Routine TimeOut! over {_routineTimeOut} s");
|
|
throw (new RoutineFaildException());
|
|
}
|
|
}
|
|
}
|
|
public void CheckForelinePressure(int id, LoadLock ll, double basePressure, int timeout)
|
|
{
|
|
Tuple<bool, Result> ret = ExecuteAndWait(id, () =>
|
|
{
|
|
Notify($"Check {ll.Name} foreline pressure under {basePressure} mbar");
|
|
|
|
return true;
|
|
}, () =>
|
|
{
|
|
return ll.ForelinePressure <= basePressure;
|
|
|
|
}, timeout * 1000);
|
|
|
|
if (ret.Item1)
|
|
{
|
|
if (ret.Item2 == Result.FAIL)
|
|
{
|
|
throw (new RoutineFaildException());
|
|
}
|
|
else if (ret.Item2 == Result.TIMEOUT) //timeout
|
|
{
|
|
Stop($"{ll.Name} foreline pressure can not lower than {basePressure} in {timeout} seconds");
|
|
throw (new RoutineFaildException());
|
|
}
|
|
else
|
|
throw (new RoutineBreakException());
|
|
}
|
|
}
|
|
|
|
public void RequestPump(int id, LoadLock ll, int timeout)
|
|
{
|
|
Tuple<bool, Result> ret = ExecuteAndWait(id, () =>
|
|
{
|
|
Notify($"Check pump ready for {ll.Name}");
|
|
|
|
return true;
|
|
}, () =>
|
|
{
|
|
//return SharedPump.Instance.RequestPump(ModuleHelper.Converter(ll.Module));
|
|
return true;
|
|
|
|
}, timeout * 1000);
|
|
|
|
if (ret.Item1)
|
|
{
|
|
if (ret.Item2 == Result.FAIL)
|
|
{
|
|
throw (new RoutineFaildException());
|
|
}
|
|
else if (ret.Item2 == Result.TIMEOUT) //timeout
|
|
{
|
|
Stop($"pump can not ready for {ll.Module} in {timeout} seconds");
|
|
throw (new RoutineFaildException());
|
|
}
|
|
else
|
|
throw (new RoutineBreakException());
|
|
}
|
|
}
|
|
|
|
public void SlowPump(int id, LoadLock ll, double switchPressure, int timeout)
|
|
{
|
|
Tuple<bool, Result> ret = ExecuteAndWait(id, () =>
|
|
{
|
|
Notify($"Open {ll.Name} slow pump valve to {switchPressure} mbar");
|
|
|
|
if (!_ll.SetSlowPumpValve(true, out string reason))
|
|
{
|
|
Stop(reason);
|
|
return false;
|
|
}
|
|
|
|
return true;
|
|
}, () =>
|
|
{
|
|
return ll.ChamberPressure <= switchPressure;
|
|
|
|
}, timeout * 1000);
|
|
|
|
if (ret.Item1)
|
|
{
|
|
if (ret.Item2 == Result.FAIL)
|
|
{
|
|
throw (new RoutineFaildException());
|
|
}
|
|
else if (ret.Item2 == Result.TIMEOUT) //timeout
|
|
{
|
|
_ll.SetSlowPumpValve(false, out string _);
|
|
|
|
Stop($"{ll.Name} pressure can not pump to {switchPressure} in {timeout} seconds");
|
|
throw (new RoutineFaildException());
|
|
}
|
|
else
|
|
throw (new RoutineBreakException());
|
|
}
|
|
}
|
|
|
|
public void FastPump(int id, LoadLock ll, double basePressure, int timeout)
|
|
{
|
|
Tuple<bool, Result> ret = ExecuteAndWait(id, () =>
|
|
{
|
|
Notify($"Open {ll.Name} fast pump valve to {basePressure} mbar");
|
|
|
|
if (!_ll.SetFastPumpValve(true, out string reason))
|
|
{
|
|
Stop(reason);
|
|
return false;
|
|
}
|
|
|
|
return true;
|
|
}, () =>
|
|
{
|
|
return ll.ChamberPressure <= basePressure;
|
|
|
|
}, timeout * 1000);
|
|
|
|
if (ret.Item1)
|
|
{
|
|
if (ret.Item2 == Result.FAIL)
|
|
{
|
|
throw (new RoutineFaildException());
|
|
}
|
|
else if (ret.Item2 == Result.TIMEOUT) //timeout
|
|
{
|
|
_ll.SetSlowPumpValve(false, out string _);
|
|
_ll.SetFastPumpValve(false, out string _);
|
|
|
|
Stop($"{ll.Name} pressure can not pump to {basePressure} in {timeout} seconds");
|
|
throw (new RoutineFaildException());
|
|
}
|
|
else
|
|
throw (new RoutineBreakException());
|
|
}
|
|
}
|
|
|
|
public void CloseSlowPumpValve(int id, LoadLock ll)
|
|
{
|
|
Tuple<bool, Result> ret = Execute(id, () =>
|
|
{
|
|
Notify($"Close {ll.Name} slow pump valve");
|
|
|
|
if (!_ll.SetSlowPumpValve(false, out string reason))
|
|
{
|
|
Stop(reason);
|
|
return false;
|
|
}
|
|
|
|
return true;
|
|
});
|
|
|
|
if (ret.Item1)
|
|
{
|
|
if (ret.Item2 == Result.FAIL)
|
|
{
|
|
throw (new RoutineFaildException());
|
|
}
|
|
else
|
|
throw (new RoutineBreakException());
|
|
}
|
|
}
|
|
|
|
public void CloseFastPumpValve(int id, LoadLock ll)
|
|
{
|
|
Tuple<bool, Result> ret = Execute(id, () =>
|
|
{
|
|
Notify($"Close {ll.Name} fast pump valve");
|
|
|
|
if (!_ll.SetFastPumpValve(false, out string reason))
|
|
{
|
|
Stop(reason);
|
|
return false;
|
|
}
|
|
|
|
return true;
|
|
});
|
|
|
|
if (ret.Item1)
|
|
{
|
|
if (ret.Item2 == Result.FAIL)
|
|
{
|
|
throw (new RoutineFaildException());
|
|
}
|
|
else
|
|
throw (new RoutineBreakException());
|
|
}
|
|
}
|
|
}
|
|
}
|