298 lines
11 KiB
C#
298 lines
11 KiB
C#
using System.Collections.Generic;
|
||
using System.Diagnostics;
|
||
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 SicModules.PMs.Routines.Base;
|
||
|
||
namespace SicModules.PMs.Routines
|
||
{
|
||
public class PMToAtmIdleRoutine : PMBaseRoutine
|
||
{
|
||
private enum RoutineStep
|
||
{
|
||
RotationEnable,
|
||
HeatEnable,
|
||
V72,
|
||
ArSupply,
|
||
|
||
SetGroupA,
|
||
SetGroupB,
|
||
SetGroupC,
|
||
SetGroupE,
|
||
SetGroupF,
|
||
SetGroupH,
|
||
SetGroupD,
|
||
SetGroupG,
|
||
SetGroupK,
|
||
|
||
SetMFCMode,
|
||
SetPCMode,
|
||
|
||
SetM1to16,
|
||
SetM2toM45,
|
||
SetPC,
|
||
SetM291519to38,
|
||
SetGroupJ,
|
||
SetM19to38,
|
||
|
||
SetGasOut,
|
||
SetTv,
|
||
|
||
SetGasIn1, //V68
|
||
OpenFinal1, //V91-96
|
||
SetMfcFinal1, //M32-38
|
||
SetMfc19to26,
|
||
|
||
SetTVCloseMode,
|
||
SetTvPositionToZero,
|
||
CheckPM1000,
|
||
|
||
SetGasIn2,
|
||
SetGroupJOpen,
|
||
SetM2toM26M43M44M45,
|
||
|
||
OpenFinal2,
|
||
SetMfcFinal2,
|
||
WaitPmPressureUp,
|
||
WaitPmPressureUp1,
|
||
|
||
SetEPV1,
|
||
SetEPV2,
|
||
SetTvMode,
|
||
SetEPVV1,
|
||
SetMfc28to40Special,
|
||
SetMfc28to40Default,
|
||
|
||
|
||
SetPC567Close,
|
||
SetPC567Mode,
|
||
SetPC567Default,
|
||
CheckFinal1Open,
|
||
|
||
SetV76,
|
||
SetV75,
|
||
SetV30,
|
||
SetV31,
|
||
SetV32,
|
||
SetV35V36,
|
||
SetGroupV25,
|
||
|
||
SetV93V95,
|
||
SetV94,
|
||
SetV96,
|
||
SetV68,
|
||
SetM35M37,
|
||
SetM36,
|
||
SetM38,
|
||
|
||
TimeDelay1,
|
||
TimeDelay2,
|
||
TimeDelay3,
|
||
TimeDelay4,
|
||
TimeDelay5,
|
||
TimeDelay6,
|
||
TimeDelay7,
|
||
TimeDelay8,
|
||
TimeDelay9,
|
||
TimeDelay10,
|
||
TimeDelay11,
|
||
TimeDelay18,
|
||
TimeDelay20,
|
||
TimeDelay21,
|
||
TimeDelay22,
|
||
Notify1,
|
||
}
|
||
|
||
private IoThrottleValve2 _IoThrottle;
|
||
private IoInterLock _pmIoInterLock;
|
||
|
||
private int _rotationCheckSpeed = 0; //设置旋转速度为0后检查是否转速低于此数值
|
||
|
||
private int _rotationCloseTimeout; //旋转停止超时
|
||
private int _IoValueOpenCloseTimeout = 10; //开关超时时间
|
||
private int _heatTimeOut = 5; //Heat关闭等待Di反馈超时时间
|
||
|
||
private int _waitPMPressureUpTimeout = 300; //等待反应腔压力到达1000的超时时间
|
||
|
||
private int _routineTimeOut;
|
||
private double _ventBasePressure;
|
||
|
||
private Stopwatch _swTimer = new Stopwatch();
|
||
public PMToAtmIdleRoutine(ModuleName module, PMModule pm) : base(module, pm)
|
||
{
|
||
Module = module.ToString();
|
||
Name = "AtmIdle";
|
||
|
||
_IoThrottle = DEVICE.GetDevice<IoThrottleValve2>($"{Module}.TV");
|
||
_pmIoInterLock = DEVICE.GetDevice<IoInterLock>($"{Module}.PMInterLock");
|
||
}
|
||
|
||
public override Result Start(params object[] objs)
|
||
{
|
||
Reset();
|
||
|
||
_rotationCloseTimeout = SC.GetValue<int>($"PM.{Module}.RotationCloseTimeout");
|
||
|
||
_routineTimeOut = SC.GetValue<int>($"PM.{Module}.Vent.RoutineTimeOut");
|
||
_ventBasePressure = SC.GetValue<double>($"PM.{Module}.Vent.VentBasePressure");
|
||
|
||
_waitPMPressureUpTimeout = SC.GetValue<int>($"PM.{Module}.Vent.VentTimeout");
|
||
|
||
if (!_pmIoInterLock.SetPMAtmIdleRountingRunning(true, out var reason))
|
||
{
|
||
EV.PostAlarmLog(Module, $"can not run ToATMIdle, {reason}");
|
||
return Result.FAIL;
|
||
}
|
||
|
||
currentPressureUpOrDown = PressureUpOrDown.None;
|
||
_swTimer.Restart();
|
||
_finalOpen = false;
|
||
|
||
Notify("Start");
|
||
return Result.RUN;
|
||
}
|
||
|
||
public override Result Monitor()
|
||
{
|
||
try
|
||
{
|
||
CheckRoutineTimeOut();
|
||
|
||
//1 关闭V76,打开V75
|
||
SetIoValueByGroup((int)RoutineStep.SetV76, IoGroupName.V76, false, _IoValueOpenCloseTimeout);
|
||
SetIoValueByGroup((int)RoutineStep.SetV75, IoGroupName.V75, true, _IoValueOpenCloseTimeout);
|
||
|
||
//2 旋转停止,加热停止
|
||
SetHeatEnable((int)RoutineStep.HeatEnable, false, _heatTimeOut);
|
||
SetRotationValve((int)RoutineStep.RotationEnable, _rotationCheckSpeed, false, _rotationCloseTimeout);
|
||
|
||
//3 关闭V72,打开V25
|
||
SetIoValueByGroup((int)RoutineStep.V72, IoGroupName.V72, false, _IoValueOpenCloseTimeout);
|
||
SetIoValueByGroup((int)RoutineStep.SetGroupV25, IoGroupName.V25, true, _IoValueOpenCloseTimeout);
|
||
|
||
//4 打开V30,打开V31,打开V32
|
||
SetIoValueByGroup((int)RoutineStep.SetV30, IoGroupName.V30, true, _IoValueOpenCloseTimeout);
|
||
SetIoValueByGroup((int)RoutineStep.SetV31, IoGroupName.V31, true, _IoValueOpenCloseTimeout);
|
||
SetIoValueByGroup((int)RoutineStep.SetV32, IoGroupName.V32, true, _IoValueOpenCloseTimeout);
|
||
|
||
//5 打开V35,打开V36
|
||
SetIoValueByGroup((int)RoutineStep.SetV35V36, IoGroupName.V35V36, true, _IoValueOpenCloseTimeout);
|
||
|
||
//关闭B/C/E/F/H/K 阀门
|
||
SetIoValueByGroup((int)RoutineStep.SetGroupB, IoGroupName.B, false, _IoValueOpenCloseTimeout);
|
||
SetIoValueByGroup((int)RoutineStep.SetGroupC, IoGroupName.C, false, _IoValueOpenCloseTimeout);
|
||
SetIoValueByGroup((int)RoutineStep.SetGroupE, IoGroupName.E, false, _IoValueOpenCloseTimeout);
|
||
SetIoValueByGroup((int)RoutineStep.SetGroupF, IoGroupName.F, false, _IoValueOpenCloseTimeout);
|
||
SetIoValueByGroup((int)RoutineStep.SetGroupH, IoGroupName.H, false, _IoValueOpenCloseTimeout);
|
||
SetIoValueByGroup((int)RoutineStep.SetGroupK, IoGroupName.K, false, _IoValueOpenCloseTimeout);
|
||
|
||
//打开D/G 阀门
|
||
SetIoValueByGroup((int)RoutineStep.SetGroupD, IoGroupName.D, true, _IoValueOpenCloseTimeout);
|
||
SetIoValueByGroup((int)RoutineStep.SetGroupG, IoGroupName.G, true, _IoValueOpenCloseTimeout);
|
||
|
||
//设置MFC和PC的模式
|
||
SetMfcModeToNormalByGroup((int)RoutineStep.SetMFCMode, MfcGroupName.All);
|
||
SetPcModeToNormal((int)RoutineStep.SetPCMode, _lstPcList);
|
||
|
||
//6 M1-M16设定为default值(M2、M9、M15除外)
|
||
SetMfcToDefaultByGroup((int)RoutineStep.SetM1to16, MfcGroupName.M1to16, 0);
|
||
|
||
//设置所有PC到默认值
|
||
SetPcToDefault((int)RoutineStep.SetPC, _lstPcList);
|
||
|
||
//M2、M9、M15、M19-M45 MFC 5s ramp 到默认值
|
||
SetMfcToDefaultByGroup((int)RoutineStep.SetM2toM45, MfcGroupName.M2toM45, 5);
|
||
|
||
//7 关闭蝶阀
|
||
SetThrottleToCloseMode((int)RoutineStep.SetTVCloseMode, _IoThrottle, 8);
|
||
SetThrottleDisable((int)RoutineStep.SetTvPositionToZero, _IoThrottle, 8);
|
||
TimeDelay((int)RoutineStep.TimeDelay1, 1);
|
||
SetIoValueByGroup((int)RoutineStep.SetEPV2, IoGroupName.EPV2, false, _IoValueOpenCloseTimeout);
|
||
|
||
//8 打开A 组阀
|
||
SetIoValueByGroup((int)RoutineStep.SetGroupA, IoGroupName.A, true, _IoValueOpenCloseTimeout);
|
||
|
||
//打开Final2阀
|
||
SetIoValueByGroup((int)RoutineStep.OpenFinal2, IoGroupName.Final2, true, _IoValueOpenCloseTimeout);
|
||
//Final2阀对应的MFC 3s Ramp到Default值
|
||
SetMfcToDefaultByGroup((int)RoutineStep.SetMfcFinal2, MfcGroupName.Final2, 3);
|
||
|
||
SetIoValueByGroup((int)RoutineStep.SetV93V95, IoGroupName.V93V95, true, _IoValueOpenCloseTimeout);
|
||
TimeDelay((int)RoutineStep.TimeDelay2, 3);
|
||
|
||
//M35、M37依次设定3S ramp 到default值 ; 等待3S。
|
||
SetMfcToDefaultByGroup((int)RoutineStep.SetM35M37, MfcGroupName.M35M37, 3);
|
||
|
||
//打开V68
|
||
//SetIoValueByGroup((int)RoutineStep.SetV68, IoGroupName.V68, true, _IoValueOpenCloseTimeout);
|
||
|
||
//打开J Valves
|
||
SetIoValueByGroup((int)RoutineStep.SetGroupJOpen, IoGroupName.J, true, _IoValueOpenCloseTimeout);
|
||
|
||
//设置M2,M9,M15,M19-M26 M43-M45 3s ramp 到default 值
|
||
SetMfcToDefaultByGroup((int)RoutineStep.SetM2toM26M43M44M45, MfcGroupName.M2toM26M43M44M45, 3);
|
||
|
||
//开V94,V96需等到腔体压力大于950
|
||
WaitPMPressureAndSetMfcSpecial((int)RoutineStep.WaitPmPressureUp1, 950, _waitPMPressureUpTimeout);
|
||
|
||
SetIoValueByGroup((int)RoutineStep.SetV94, IoGroupName.V94, true, _IoValueOpenCloseTimeout);
|
||
SetMfcToDefaultByGroup((int)RoutineStep.SetM36, MfcGroupName.M36, 5);
|
||
TimeDelay((int)RoutineStep.TimeDelay3, 3);
|
||
|
||
SetIoValueByGroup((int)RoutineStep.SetV96, IoGroupName.V96, true, _IoValueOpenCloseTimeout);
|
||
SetMfcToDefaultByGroup((int)RoutineStep.SetM38, MfcGroupName.M38, 5);
|
||
TimeDelay((int)RoutineStep.TimeDelay4, 3);
|
||
|
||
//等待反应腔压力大于1000
|
||
NotifyInfo((int)RoutineStep.Notify1, $"Wait pm pressure to {_ventBasePressure} mbar!");
|
||
WaitPMPressureAndSetMfcSpecial((int)RoutineStep.WaitPmPressureUp, _ventBasePressure, _waitPMPressureUpTimeout);
|
||
|
||
//设置M28,M29,M31,M40 3s ramp 到default 值
|
||
//SetMfcToDefaultByGroup((int)RoutineStep.SetMfc28to40Default, MfcGroupName.M27To3540To42, 3);
|
||
}
|
||
catch (RoutineBreakException)
|
||
{
|
||
return Result.RUN;
|
||
}
|
||
catch (RoutineFaildException)
|
||
{
|
||
return Result.FAIL;
|
||
}
|
||
|
||
_pmIoInterLock.SetPMAtmIdleRountingRunning(false, out var reason);
|
||
Notify($"Finished ! Elapsed time: {(int)(_swTimer.ElapsedMilliseconds / 1000)} s");
|
||
_swTimer.Stop();
|
||
|
||
return Result.DONE;
|
||
}
|
||
|
||
public override void Abort()
|
||
{
|
||
_pmIoInterLock.SetPMAtmIdleRountingRunning(false, out var reason);
|
||
_pmIoInterLock.SetPMVentRoutineRunning(false, out _);
|
||
PmDevice._ioThrottleValve.StopRamp();
|
||
PmDevice.SetMfcStopRamp(PmDevice.GetMfcListByGroupName(MfcGroupName.All));
|
||
PmDevice.SetRotationServo(0, 0);
|
||
|
||
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());
|
||
}
|
||
}
|
||
}
|
||
|
||
}
|
||
}
|