SicMultiplate/Modules/Mainframe/TMs/Routines/TMVentRoutine.cs

264 lines
8.6 KiB
C#
Raw Normal View History

2023-04-13 15:35:13 +08:00
using System.Diagnostics;
2023-03-03 15:42:13 +08:00
using Aitex.Core.RT.Device;
using Aitex.Core.RT.Device.Devices;
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.Temps.P116PIDTC;
2023-04-13 15:35:13 +08:00
using SicModules.LLs;
using SicModules.TMs.Routines.Base;
using IoInterLock = SicModules.Devices.IoInterLock;
2023-03-03 15:42:13 +08:00
2023-04-13 15:35:13 +08:00
namespace SicModules.TMs.Routines
2023-03-03 15:42:13 +08:00
{
public class TMVentRoutine : TMBaseRoutine
{
enum RoutineStep
{
CloseTurboPumpValves, //Fast pump, backing valve, iso valve
CloseValveDelay,
TurboPumpOff,
Vent,
VentDelay,
CloseVentValves,
CloseVentValveDelay,
TimeDelay,
OpenV80,
CloseV80,
CloseV81,
CloseV82,
SetMFC1,
SetMFC2,
OpenSlowVent,
OpenFastVent,
OpenVent,
2023-03-03 15:42:13 +08:00
TimeStayATM,
CloseSlowVent
}
private double _ventBasePressure;
private double _slowFastVentSwitchPressure;
private int _ventTimeout;
2023-03-03 15:42:13 +08:00
private int _ventDelayTime;
private bool _useSettingValue;
private int _routineTimeOut;
private double _bufferMaxTemp;
private SicTM _tm;
private IoSensor _bufferLid;
private IoSensor _tmLid;
private Devices.IoPump _pumpType;
private LoadLock _ll;
private IoSensor _preHeatLid;
private IoMFC _mfc60;
2023-04-13 15:35:13 +08:00
private IoInterLock _tmIoInterLock;
2023-03-03 15:42:13 +08:00
private P116PIDTC _p116PIDTC;
private double _mfc60Default1;
private double _mfc60Default2;
private Stopwatch _swTimer = new Stopwatch();
public TMVentRoutine( )
{
Module = ModuleName.TM.ToString();
Name = "Vent";
_tm = DEVICE.GetDevice<SicTM>($"{ ModuleName.System.ToString()}.{ Module}");
_ll = DEVICE.GetDevice<SicLoadLock>($"LoadLock.LoadLock");
_bufferLid = DEVICE.GetDevice<IoSensor>($"Buffer.BufferLidClosed");
_tmLid = DEVICE.GetDevice<IoSensor>($"TM.TMLidClosed");
_pumpType = DEVICE.GetDevice<Devices.IoPump>($"TM.TMPump1");
_preHeatLid = DEVICE.GetDevice<IoSensor>($"TM.PreHeatStationLidClosed");
_mfc60 = DEVICE.GetDevice<IoMFC>($"TM.Mfc60");
2023-04-13 15:35:13 +08:00
_tmIoInterLock = DEVICE.GetDevice<IoInterLock>("TM.IoInterLock");
2023-03-03 15:42:13 +08:00
_p116PIDTC = DEVICE.GetDevice<P116PIDTC>("TM.P116PIDTC");
}
public void Init()
{
_useSettingValue = false;
}
public void Init(double basePressure, int ventDelayTime)
{
_ventBasePressure = basePressure;
_ventDelayTime = ventDelayTime;
_useSettingValue = true;
}
public bool Initalize()
{
return true;
}
public override Result Start(params object[] objs)
{
Reset();
string reason;
if (!_tm.SetSlowPumpValve(false, out reason) || !_tm.SetFastPumpValve(false, out reason) )
{
EV.PostAlarmLog(Module, $"Can not turn off valves, {reason}");
return Result.FAIL;
}
if (_tm.CheckAtm())
{
EV.PostInfoLog(Module, $"{_tm.Module} in atm, vent skipped");
return Result.DONE;
}
////Buffer温度超过设定值TM不能Vent
//_bufferMaxTemp = SC.GetValue<double>("TM.Vent.BufferMaxTemp");
//if(_p116PIDTC.fPVInValue >= _bufferMaxTemp)
//{
// EV.PostWarningLog(Module, $"Can not vent, Buffer Temp more than {_bufferMaxTemp}");
// return Result.FAIL;
//}
ModuleName[] modules = new ModuleName[] { ModuleName.LoadLock, ModuleName.PM1, ModuleName.PM2, ModuleName.UnLoad };
foreach (var moduleName in modules)
{
if (!_tm.CheckSlitValveClose(moduleName))
{
EV.PostAlarmLog(Module, $"Can not vent, {moduleName} slit valve not closed");
return Result.FAIL;
}
}
_routineTimeOut = SC.GetValue<int>("TM.Vent.RoutineTimeOut");
_mfc60Default1 = SC.GetValue<double>("TM.Vent.Mfc60Default1");
_mfc60Default2 = SC.GetValue<double>("TM.Vent.Mfc60Default2");
_slowFastVentSwitchPressure = SC.GetValue<double>("TM.Vent.SlowFastVentSwitchPressure");
_ventTimeout = SC.GetValue<int>("TM.Vent.VentTimeout");
2023-03-03 15:42:13 +08:00
if (!_useSettingValue)
{
_ventBasePressure = SC.GetValue<double>("TM.Vent.VentBasePressure");
_ventDelayTime = SC.GetValue<int>("TM.Vent.VentDelayTime");
}
if (!_bufferLid.Value)
{
EV.PostAlarmLog(Module, $"Can not vent,Buffer lid is not open");
return Result.FAIL;
}
if (!_tmLid.Value)
{
EV.PostAlarmLog(Module, $"Can not vent,TM lid is not open");
return Result.FAIL;
}
if (_pumpType.IsAlarm)
{
EV.PostAlarmLog(Module, $"can not vent,TM pump alarm");
return Result.FAIL;
}
if (!_pumpType.IsRunning)
{
EV.PostAlarmLog(Module, $"can not vent,TM pump is not running");
return Result.FAIL;
}
if (!_tm.SetTmToLLVent(false, out _))
{
EV.PostAlarmLog(Module, $"can not vent,can not close v85!");
}
if (!_tmIoInterLock.SetTMVentRoutineRunning(true, out reason))
{
EV.PostAlarmLog(Module, $"can not vent,{reason}");
return Result.FAIL;
}
2023-04-26 11:27:40 +08:00
if (_slowFastVentSwitchPressure > _ventBasePressure)
{
_slowFastVentSwitchPressure = _ventBasePressure;
}
2023-03-03 15:42:13 +08:00
_swTimer.Restart();
Notify("Start");
return Result.RUN;
}
public override Result Monitor()
{
try
{
CheckRoutineTimeOut();
//关闭V81
CloseFastPump((int)RoutineStep.CloseV81);
//关闭V82
CloseSlowPump((int)RoutineStep.CloseV82);
//设定MFC60慢充流量
2023-03-28 13:24:11 +08:00
SetMFCToSetPoint((int)RoutineStep.SetMFC1, _mfc60, _mfc60Default1);
2023-03-03 15:42:13 +08:00
////打开V77,等待压力大于200mbar
//OpenSlowVent((int)RoutineStep.OpenSlowVent, _tm, _slowFastVentSwitchPressure, _slowVentTimeout);
2023-03-03 15:42:13 +08:00
////设定MFC60快充流量
//SetMFCToSetPoint((int)RoutineStep.SetMFC2, _mfc60, _mfc60Default2);
2023-03-03 15:42:13 +08:00
//等待压力大于1020mbar
//OpenFastVent((int)RoutineStep.OpenFastVent, _tm, _ventBasePressure, _fastVentTime);
//充气过程中检查是否到达打开快充流量的条件
OpenVent((int)RoutineStep.OpenVent, _tm, _ventBasePressure, _slowFastVentSwitchPressure, _mfc60Default2, _ventTimeout);
2023-03-03 15:42:13 +08:00
//等待5s
TimeDelay((int)RoutineStep.TimeStayATM, _ventDelayTime);
2023-03-28 13:24:11 +08:00
//关闭V77
2023-03-03 15:42:13 +08:00
CloseSlowVentValve((int)RoutineStep.CloseSlowVent, _tm);
}
catch (RoutineBreakException)
{
return Result.RUN;
}
catch (RoutineFaildException)
{
_tm.SetFastVentValve(false, out _);
_tm.SetSlowVentValve(false, out _);
return Result.FAIL;
}
Notify($"Finished ! Elapsed time: {(int)(_swTimer.ElapsedMilliseconds / 1000)} s");
_tmIoInterLock.DoTmVentUpRoutineRunning = false;
return Result.DONE;
}
public override void Abort()
{
_tmIoInterLock.DoTmVentUpRoutineRunning = false;
//_tm.SetFastVentValve(false, out _);
//_tm.SetSlowVentValve(false, out _);
base.Abort();
}
private void CheckRoutineTimeOut()
{
if (_routineTimeOut > 10)
{
if ((int)(_swTimer.ElapsedMilliseconds / 1000) > _routineTimeOut)
{
EV.PostAlarmLog(Module, $"Routine TimeOut! over {_routineTimeOut} s");
throw (new RoutineFaildException());
}
}
}
}
}