431 lines
13 KiB
C#
431 lines
13 KiB
C#
|
using System;
|
|||
|
using System.Diagnostics;
|
|||
|
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 Mainframe.Devices;
|
|||
|
using Mainframe.LLs;
|
|||
|
using MECF.Framework.Common.Equipment;
|
|||
|
using MECF.Framework.RT.EquipmentLibrary.HardwareUnits.LoadLocks;
|
|||
|
using MECF.Framework.RT.EquipmentLibrary.HardwareUnits.TMs;
|
|||
|
|
|||
|
namespace Mainframe.TMs
|
|||
|
{
|
|||
|
public class TMPumpRoutine : ModuleRoutine, IRoutine
|
|||
|
{
|
|||
|
enum RoutineStep
|
|||
|
{
|
|||
|
CheckForelinePressure,
|
|||
|
|
|||
|
RequestPump,
|
|||
|
SlowPump,
|
|||
|
FastPump,
|
|||
|
VaccumDelay,
|
|||
|
StartDelay,
|
|||
|
RequestPumpDelay,
|
|||
|
Pump,
|
|||
|
|
|||
|
PumpDelay,
|
|||
|
CloseValves,
|
|||
|
CLoseSlowValue,
|
|||
|
Delay,
|
|||
|
}
|
|||
|
|
|||
|
private SicTM _tm;
|
|||
|
private IoSensor _bufferLid;
|
|||
|
private IoSensor _tmLid;
|
|||
|
private Devices.IoPump _pumpType;
|
|||
|
private LoadLock _ll;
|
|||
|
private IoInterLock _tmIoInterLock;
|
|||
|
|
|||
|
|
|||
|
private double _forelineBasePressure;
|
|||
|
private double _pumpBasePressure;
|
|||
|
private double _slowFastPumpSwitchPressure;
|
|||
|
private int _waitForelineTimeout;
|
|||
|
private int _slowPumpTimeout;
|
|||
|
private int _fastPumpTime;
|
|||
|
private int _pumpDelayTime;
|
|||
|
private int _routineTimeOut;
|
|||
|
|
|||
|
|
|||
|
private bool _useSettingValue;
|
|||
|
private bool isAtmMode = false;
|
|||
|
|
|||
|
private Stopwatch _swTimer = new Stopwatch();
|
|||
|
|
|||
|
public TMPumpRoutine()
|
|||
|
{
|
|||
|
Module = ModuleName.TM.ToString();
|
|||
|
Name = "Pump";
|
|||
|
_tm = DEVICE.GetDevice<SicTM>($"{ ModuleName.System.ToString()}.{ Module}");
|
|||
|
|
|||
|
_ll = DEVICE.GetDevice<SicLoadLock>($"LoadLock.LoadLock");
|
|||
|
_bufferLid = DEVICE.GetDevice<IoSensor>($"TM.BufferLidClosed");
|
|||
|
_tmLid = DEVICE.GetDevice<IoSensor>($"TM.TMLidClosed");
|
|||
|
_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();
|
|||
|
|
|||
|
_forelineBasePressure = SC.GetValue<double>("TM.ForelinePressureBase");
|
|||
|
_slowFastPumpSwitchPressure = SC.GetValue<double>("TM.Pump.SlowFastPumpSwitchPressure");
|
|||
|
_waitForelineTimeout = SC.GetValue<int>("TM.WaitForelinePressureTimeout");
|
|||
|
_slowPumpTimeout = SC.GetValue<int>("TM.Pump.PumpSlowTimeout");
|
|||
|
_fastPumpTime = SC.GetValue<int>("TM.Pump.FastPumpTimeout");
|
|||
|
_routineTimeOut = SC.GetValue<int>("TM.Pump.RoutineTimeOut");
|
|||
|
|
|||
|
if (!_useSettingValue)
|
|||
|
{
|
|||
|
_pumpBasePressure = SC.GetValue<double>("TM.Pump.PumpBasePressure");
|
|||
|
_pumpDelayTime = SC.GetValue<int>("TM.Pump.PumpDelayTime");
|
|||
|
}
|
|||
|
|
|||
|
string reason;
|
|||
|
if (!_tm.SetFastPumpValve(false, out reason) || !_tm.SetFastVentValve(false, out reason))
|
|||
|
{
|
|||
|
EV.PostAlarmLog(Module, $"Can not turn off valves, {reason}");
|
|||
|
return Result.FAIL;
|
|||
|
}
|
|||
|
|
|||
|
if (SC.GetValue<bool>("System.IsATMMode"))
|
|||
|
{
|
|||
|
EV.PostInfoLog(Module, $"system in atm mode, {_tm.Module} pump skipped");
|
|||
|
return Result.DONE;
|
|||
|
}
|
|||
|
if (SC.ContainsItem("TM.RunPumpRoutineEventBelowBasePressure") && !SC.GetValue<bool>("TM.RunPumpRoutineEventBelowBasePressure"))
|
|||
|
{
|
|||
|
if (_tm.ChamberPressure < _pumpBasePressure)
|
|||
|
{
|
|||
|
EV.PostInfoLog(Module, $"{_tm.Module} already under pump base pressure");
|
|||
|
return Result.DONE;
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
ModuleName[] modules = new ModuleName[] { ModuleName.LoadLock, ModuleName.PM1 };
|
|||
|
foreach (var moduleName in modules)
|
|||
|
{
|
|||
|
if (!_tm.CheckSlitValveClose(moduleName))
|
|||
|
{
|
|||
|
EV.PostAlarmLog(Module, $"Can not pump, {moduleName} slit valve not closed");
|
|||
|
return Result.FAIL;
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
if (!_ll.SetFastPumpValve(false, out reason))
|
|||
|
{
|
|||
|
EV.PostAlarmLog(Module, $"Can not pump,LL fastPump can not close");
|
|||
|
return Result.FAIL;
|
|||
|
}
|
|||
|
if (!_bufferLid.Value)
|
|||
|
{
|
|||
|
EV.PostAlarmLog(Module, $"Can not pump,Buffer lid is not closed");
|
|||
|
return Result.FAIL;
|
|||
|
}
|
|||
|
if (!_tmLid.Value)
|
|||
|
{
|
|||
|
EV.PostAlarmLog(Module, $"Can not pump,TM lid is not closed");
|
|||
|
return Result.FAIL;
|
|||
|
}
|
|||
|
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.SetTmToLLVent(false, out _))
|
|||
|
{
|
|||
|
EV.PostAlarmLog(Module, $"can not pump,can not close v85!");
|
|||
|
}
|
|||
|
if (!_tm.SetTMRoughBypass(false, out _))
|
|||
|
{
|
|||
|
EV.PostAlarmLog(Module, $"can not pump,can not close v121!");
|
|||
|
}
|
|||
|
if (!_tmIoInterLock.SetTMPumpRoutineRunning(true, out reason))
|
|||
|
{
|
|||
|
EV.PostAlarmLog(Module, $"can not pump,{reason}");
|
|||
|
return Result.FAIL;
|
|||
|
}
|
|||
|
|
|||
|
isAtmMode = SC.GetValue<bool>("System.IsATMMode");
|
|||
|
|
|||
|
_swTimer.Restart();
|
|||
|
Notify("Start");
|
|||
|
return Result.RUN;
|
|||
|
}
|
|||
|
|
|||
|
|
|||
|
public Result Monitor()
|
|||
|
{
|
|||
|
try
|
|||
|
{
|
|||
|
if (isAtmMode)
|
|||
|
{
|
|||
|
return Result.DONE;
|
|||
|
}
|
|||
|
|
|||
|
CheckRoutineTimeOut();
|
|||
|
|
|||
|
CheckForelinePressure((int)RoutineStep.CheckForelinePressure, _tm, _forelineBasePressure, _waitForelineTimeout);
|
|||
|
|
|||
|
OpenSlowPump((int)RoutineStep.SlowPump, _tm, _slowFastPumpSwitchPressure, _slowPumpTimeout);
|
|||
|
|
|||
|
OpenFastPump((int)RoutineStep.FastPump, _tm, _pumpBasePressure, _fastPumpTime);
|
|||
|
|
|||
|
TimeDelay((int)RoutineStep.VaccumDelay, _pumpDelayTime);
|
|||
|
|
|||
|
CloseFastPump((int)RoutineStep.CloseValves, _tm);
|
|||
|
|
|||
|
CloseSlowPump((int)RoutineStep.CLoseSlowValue, _tm);
|
|||
|
|
|||
|
}
|
|||
|
catch (RoutineBreakException)
|
|||
|
{
|
|||
|
return Result.RUN;
|
|||
|
}
|
|||
|
catch (RoutineFaildException)
|
|||
|
{
|
|||
|
_tm.SetFastPumpValve(false, out _);
|
|||
|
_tm.SetSlowPumpValve(false, out _);
|
|||
|
return Result.FAIL;
|
|||
|
}
|
|||
|
|
|||
|
|
|||
|
Notify($"Finished ! Elapsed time: {(int)(_swTimer.ElapsedMilliseconds / 1000)} s");
|
|||
|
_tmIoInterLock.DoTmPumpDownRoutineRunning = false;
|
|||
|
|
|||
|
return Result.DONE;
|
|||
|
}
|
|||
|
|
|||
|
public void Abort()
|
|||
|
{
|
|||
|
_tmIoInterLock.DoTmPumpDownRoutineRunning = false;
|
|||
|
_tm.SetFastPumpValve(false, out _);
|
|||
|
_tm.SetSlowPumpValve(false, out _);
|
|||
|
}
|
|||
|
|
|||
|
|
|||
|
private void CheckRoutineTimeOut()
|
|||
|
{
|
|||
|
if (_routineTimeOut > 10)
|
|||
|
{
|
|||
|
if ((int)(_swTimer.ElapsedMilliseconds / 1000) > _routineTimeOut)
|
|||
|
{
|
|||
|
Notify($"Routine TimeOut! over {_routineTimeOut} s");
|
|||
|
throw (new RoutineFaildException());
|
|||
|
}
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
|
|||
|
public void CheckPressure(int id, TM tm, double basePressure, int timeout)
|
|||
|
{
|
|||
|
Tuple<bool, Result> ret = ExecuteAndWait(id, () =>
|
|||
|
{
|
|||
|
Notify($"Check {tm.Name} pressure ");
|
|||
|
|
|||
|
return true;
|
|||
|
}, () =>
|
|||
|
{
|
|||
|
return tm.ForelinePressure <= basePressure;
|
|||
|
|
|||
|
}, timeout * 1000);
|
|||
|
|
|||
|
if (ret.Item1)
|
|||
|
{
|
|||
|
if (ret.Item2 == Result.FAIL)
|
|||
|
{
|
|||
|
throw (new RoutineFaildException());
|
|||
|
}
|
|||
|
else if (ret.Item2 == Result.TIMEOUT) //timeout
|
|||
|
{
|
|||
|
Stop($"{tm.Name} pressure can not lower than {basePressure} in {timeout} seconds");
|
|||
|
throw (new RoutineFaildException());
|
|||
|
}
|
|||
|
else
|
|||
|
throw (new RoutineBreakException());
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
public void CheckForelinePressure(int id, TM tm, double basePressure, int timeout)
|
|||
|
{
|
|||
|
Tuple<bool, Result> ret = ExecuteAndWait(id, () =>
|
|||
|
{
|
|||
|
Notify($"Check {tm.Name} foreline pressure ");
|
|||
|
|
|||
|
return true;
|
|||
|
}, () =>
|
|||
|
{
|
|||
|
return tm.ForelinePressure <= basePressure;
|
|||
|
|
|||
|
}, timeout * 1000);
|
|||
|
|
|||
|
if (ret.Item1)
|
|||
|
{
|
|||
|
if (ret.Item2 == Result.FAIL)
|
|||
|
{
|
|||
|
throw (new RoutineFaildException());
|
|||
|
}
|
|||
|
else if (ret.Item2 == Result.TIMEOUT) //timeout
|
|||
|
{
|
|||
|
Stop($"{tm.Name} foreline pressure can not lower than {basePressure} in {timeout} seconds");
|
|||
|
throw (new RoutineFaildException());
|
|||
|
}
|
|||
|
else
|
|||
|
throw (new RoutineBreakException());
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
public void OpenSlowPump(int id, TM tm, double basePressure, int timeout)
|
|||
|
{
|
|||
|
Tuple<bool, Result> ret = ExecuteAndWait(id, () =>
|
|||
|
{
|
|||
|
Notify($"Open {tm.Name} slow pump valve");
|
|||
|
|
|||
|
if (!tm.SetSlowPumpValve(true, out string reason))
|
|||
|
{
|
|||
|
Stop(reason);
|
|||
|
return false;
|
|||
|
}
|
|||
|
|
|||
|
return true;
|
|||
|
}, () =>
|
|||
|
{
|
|||
|
return tm.ChamberPressure <= basePressure;
|
|||
|
|
|||
|
}, timeout * 1000);
|
|||
|
|
|||
|
if (ret.Item1)
|
|||
|
{
|
|||
|
if (ret.Item2 == Result.FAIL)
|
|||
|
{
|
|||
|
throw (new RoutineFaildException());
|
|||
|
}
|
|||
|
else if (ret.Item2 == Result.TIMEOUT) //timeout
|
|||
|
{
|
|||
|
tm.SetFastPumpValve(false, out string _);
|
|||
|
|
|||
|
Stop($"{tm.Name} pressure can not pump to {basePressure} in {timeout} seconds");
|
|||
|
throw (new RoutineFaildException());
|
|||
|
}
|
|||
|
else
|
|||
|
throw (new RoutineBreakException());
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
public void CloseSlowPump(int id, TM tm)
|
|||
|
{
|
|||
|
Tuple<bool, Result> ret = Execute(id, () =>
|
|||
|
{
|
|||
|
Notify($"Close {tm.Name} pump valves");
|
|||
|
|
|||
|
if (!_tm.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 OpenFastPump(int id, TM tm, double basePressure, int timeout)
|
|||
|
{
|
|||
|
Tuple<bool, Result> ret = ExecuteAndWait(id, () =>
|
|||
|
{
|
|||
|
Notify($"Open {tm.Name} pump valve");
|
|||
|
|
|||
|
if (!tm.SetFastPumpValve(true, out string reason))
|
|||
|
{
|
|||
|
Stop(reason);
|
|||
|
return false;
|
|||
|
}
|
|||
|
|
|||
|
return true;
|
|||
|
}, () =>
|
|||
|
{
|
|||
|
return tm.ChamberPressure <= basePressure;
|
|||
|
|
|||
|
}, timeout * 1000);
|
|||
|
|
|||
|
if (ret.Item1)
|
|||
|
{
|
|||
|
if (ret.Item2 == Result.FAIL)
|
|||
|
{
|
|||
|
throw (new RoutineFaildException());
|
|||
|
}
|
|||
|
else if (ret.Item2 == Result.TIMEOUT) //timeout
|
|||
|
{
|
|||
|
tm.SetFastPumpValve(false, out string _);
|
|||
|
|
|||
|
Stop($"{tm.Name} pressure can not pump to {basePressure} in {timeout} seconds");
|
|||
|
throw (new RoutineFaildException());
|
|||
|
}
|
|||
|
else
|
|||
|
throw (new RoutineBreakException());
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
|
|||
|
public void CloseFastPump(int id, TM tm)
|
|||
|
{
|
|||
|
Tuple<bool, Result> ret = Execute(id, () =>
|
|||
|
{
|
|||
|
Notify($"Close {tm.Name} pump valves");
|
|||
|
|
|||
|
if (!_tm.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());
|
|||
|
}
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
|
|||
|
}
|