428 lines
13 KiB
C#
428 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;
|
|||
|
|
|||
|
namespace Mainframe.LLs
|
|||
|
{
|
|||
|
public class LoadLockServoTo : ModuleRoutine, IRoutine
|
|||
|
{
|
|||
|
enum RoutineStep
|
|||
|
{
|
|||
|
CheckForelinePressure,
|
|||
|
RequestPump,
|
|||
|
RequestPumpDelay,
|
|||
|
SlowPump,
|
|||
|
CloseSlowValve,
|
|||
|
FastPump,
|
|||
|
PumpDelay,
|
|||
|
CloseFastValve,
|
|||
|
Delay,
|
|||
|
SlowVent,
|
|||
|
CloseSlowVentValve,
|
|||
|
TimeDelay1,
|
|||
|
}
|
|||
|
|
|||
|
private double _pumpSwitchPressure;
|
|||
|
|
|||
|
private int _waitForelineTimeout;
|
|||
|
private int _slowPumpTimeout=100;
|
|||
|
private int _fastPumpTimeout=100;
|
|||
|
private int _slowVentTimeout = 100;
|
|||
|
|
|||
|
private LoadLock _ll;
|
|||
|
private TM _tm;
|
|||
|
private Devices.IoPump _pumpType;
|
|||
|
|
|||
|
private bool _useSettingValue;
|
|||
|
private double _targetPressure;
|
|||
|
private bool _needPump = false;
|
|||
|
private double _llVacPressure = 0;
|
|||
|
private bool isAtmMode = false;
|
|||
|
|
|||
|
public LoadLockServoTo(ModuleName module)
|
|||
|
{
|
|||
|
Module = module.ToString();
|
|||
|
Name = "LoadLockServoTo";
|
|||
|
_ll = DEVICE.GetDevice<SicLoadLock>($"{ Module}.{ Module}");
|
|||
|
_tm = DEVICE.GetDevice<SicTM>($"{ModuleName.System.ToString()}.{"TM"}");
|
|||
|
|
|||
|
_pumpType = DEVICE.GetDevice<Devices.IoPump>($"TM.TMPump");
|
|||
|
}
|
|||
|
|
|||
|
|
|||
|
public Result Start(params object[] objs)
|
|||
|
{
|
|||
|
Reset();
|
|||
|
_targetPressure = SC.GetConfigItem("TM.PressureBalance.BalancePressureForLL").DoubleValue;
|
|||
|
_llVacPressure = SC.GetValue<double>("LoadLock.VacuumPressureBase");
|
|||
|
_pumpSwitchPressure = SC.GetValue<double>("LoadLock.Pump.SlowFastPumpSwitchPressure");
|
|||
|
|
|||
|
|
|||
|
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;
|
|||
|
}
|
|||
|
if (!_ll.SetFastPumpValve(false, out reason) || !_ll.SetSlowPumpValve(false, out reason))
|
|||
|
{
|
|||
|
EV.PostAlarmLog(Module, $"Can not turn off valves, {reason}");
|
|||
|
return Result.FAIL;
|
|||
|
}
|
|||
|
|
|||
|
isAtmMode = SC.GetValue<bool>("System.IsATMMode");
|
|||
|
|
|||
|
//if (isAtmMode)
|
|||
|
//{
|
|||
|
// EV.PostInfoLog(Module, $"system in atm mode, {_ll.Module} pump skipped");
|
|||
|
// 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, $"LoadLock Can not servo to pressure, slit valve is open");
|
|||
|
return Result.FAIL;
|
|||
|
}
|
|||
|
|
|||
|
|
|||
|
if (Math.Abs(_targetPressure - _ll.ChamberPressure) < SC.GetConfigItem("TM.PressureBalance.BalanceMaxDiffPressure").DoubleValue && _ll.CheckVacuum())
|
|||
|
{
|
|||
|
return Result.DONE;
|
|||
|
}
|
|||
|
_needPump = _ll.ChamberPressure > _targetPressure;
|
|||
|
|
|||
|
|
|||
|
Notify("Start");
|
|||
|
return Result.RUN;
|
|||
|
}
|
|||
|
|
|||
|
|
|||
|
public Result Monitor()
|
|||
|
{
|
|||
|
try
|
|||
|
{
|
|||
|
if (isAtmMode)
|
|||
|
{
|
|||
|
return Result.DONE;
|
|||
|
}
|
|||
|
|
|||
|
//TimeDelay((int)RoutineStep.TimeDelay1, 1);
|
|||
|
|
|||
|
if (_needPump)
|
|||
|
{
|
|||
|
//需要调节的压力低于打开快抽的压力
|
|||
|
if (_targetPressure < _pumpSwitchPressure)
|
|||
|
{
|
|||
|
SlowPump((int)RoutineStep.SlowPump, _ll, _pumpSwitchPressure, _slowPumpTimeout);
|
|||
|
|
|||
|
FastPump((int)RoutineStep.FastPump, _ll, _targetPressure, _fastPumpTimeout);
|
|||
|
|
|||
|
CloseFastPumpValve((int)RoutineStep.CloseFastValve, _ll);
|
|||
|
|
|||
|
CloseSlowPumpValve((int)RoutineStep.CloseSlowValve, _ll);
|
|||
|
}
|
|||
|
else
|
|||
|
{
|
|||
|
SlowPump((int)RoutineStep.SlowPump, _ll, _targetPressure, _slowPumpTimeout);
|
|||
|
|
|||
|
CloseSlowPumpValve((int)RoutineStep.CloseSlowValve, _ll);
|
|||
|
}
|
|||
|
}
|
|||
|
else
|
|||
|
{
|
|||
|
SlowVent((int)RoutineStep.SlowVent, _ll, _targetPressure, _slowVentTimeout);
|
|||
|
|
|||
|
CloseSlowVentValve((int)RoutineStep.CloseSlowVentValve, _ll);
|
|||
|
}
|
|||
|
}
|
|||
|
catch (RoutineBreakException)
|
|||
|
{
|
|||
|
return Result.RUN;
|
|||
|
}
|
|||
|
catch (RoutineFaildException)
|
|||
|
{
|
|||
|
return Result.FAIL;
|
|||
|
}
|
|||
|
|
|||
|
|
|||
|
Notify("Finished");
|
|||
|
|
|||
|
return Result.DONE;
|
|||
|
}
|
|||
|
|
|||
|
public void Abort()
|
|||
|
{
|
|||
|
_ll.SetFastPumpValve(false, out string reason);
|
|||
|
_ll.SetSlowPumpValve(false, out reason);
|
|||
|
_ll.SetFastVentValve(false, out reason);
|
|||
|
_ll.SetSlowVentValve(false, out reason);
|
|||
|
}
|
|||
|
|
|||
|
public void SlowVent(int id, LoadLock ll, double switchPressure, int timeout)
|
|||
|
{
|
|||
|
Tuple<bool, Result> ret = ExecuteAndWait(id, () =>
|
|||
|
{
|
|||
|
Notify($"Open {ll.Name} slow vent valve to {switchPressure} mbar");
|
|||
|
|
|||
|
if (!_ll.SetSlowVentValve(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.SetSlowVentValve(false, out string _);
|
|||
|
|
|||
|
Stop($"{ll.Name} pressure can not vent to {switchPressure} mbar in {timeout} seconds");
|
|||
|
throw (new RoutineFaildException());
|
|||
|
}
|
|||
|
else
|
|||
|
throw (new RoutineBreakException());
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
public void CloseSlowVentValve(int id, LoadLock ll)
|
|||
|
{
|
|||
|
Tuple<bool, Result> ret = Execute(id, () =>
|
|||
|
{
|
|||
|
Notify($"Close {ll.Name} slow vent valve");
|
|||
|
|
|||
|
if (!_ll.SetSlowVentValve(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 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());
|
|||
|
}
|
|||
|
}
|
|||
|
}
|
|||
|
}
|