using System; using Aitex.Core.Common.DeviceData; using Aitex.Core.RT.DataCenter; using Aitex.Core.RT.Device; using Aitex.Core.RT.Device.Unit; using Aitex.Core.RT.Event; using Aitex.Core.RT.OperationCenter; using Aitex.Core.RT.SCCore; using Aitex.Core.Util; using MECF.Framework.Common.Device.Bases; using MECF.Framework.Common.Equipment; using MECF.Framework.Common.Schedulers; using MECF.Framework.Common.SubstrateTrackings; using MECF.Framework.RT.EquipmentLibrary.HardwareUnits.PMs; using Virgo_DCommon; using Virgo_DRT.Devices.IODevices; using Virgo_DRT.Module; using Virgo_DRT.Modules; namespace Virgo_DRT.Devices { enum ValveType { PROCESS, FAST_PUMP, SOFT_PUMP, FAST_VENT, PURGE, Mfc1, Mfc2, Mfc3, Mfc4, Mfc5 } class JetPM : PM { // ----------------------------Fields-------------------------- // private readonly IoLid _Lid; //private readonly IoCylinder _LidLocker; private readonly IoSensor _ATM_sw; private readonly IoSensor _VAC_sw; private readonly IoSensor _WLK_sw; private readonly IoSensor _CDAPressure; //private readonly IoSensor _ArmNotExtend; private readonly IoSensor _RFG_Interlock; private readonly IoSensor _FactoryScrubberSensor; private readonly IoPressureControl _pressureController; private readonly IoHeater _SubstrateTC; private readonly IoHeater _ForelineTC; private readonly IoValve _SoftPumpValve; private readonly IoValve _FastPumpValve; private readonly IoValve _ProcessValve; private readonly IoValve _PurgeValve; private readonly IoValve _FastVentValve; private readonly IoValve _Mfc1Valve; private readonly IoValve _Mfc2Valve; private readonly IoValve _Mfc3Valve; private readonly IoValve _Mfc4Valve; private readonly IoValve _Mfc5Valve; private readonly IoValve _WaterValve; //private readonly IoValve _N2SupplyValve; //private readonly IoCylinder _slitDoor; private readonly IoCylinder _LiftPin; private readonly IoCylinder _PinInch3; // 3' private readonly IoCylinder _PinInch4; // 4' private readonly RfPowerBase _Generator; private readonly RfMatchBase _Match; private readonly PumpBase _MainPump; private readonly IoGasStick[] _gasLines; private readonly IoSignalTower _SignalTower; private readonly IoPlcDateTime _plcDateTime; private bool _isFactoryScrubberSysInstalled; private readonly R_TRIG _trigScrubberSysAlarm = new R_TRIG(); // --------------------------Properties------------------------ // public new ModuleName Module { get; } // 门的状态 public bool IsSlitDoorClosed => true; //public bool IsSlitDoorClosed => !_slitDoor.ONFeedback && _slitDoor.OFFFeedback; //public bool IsArmNotExtend => _ArmNotExtend.Value; // 盖子的状态 public bool IsLidClosed => _Lid.OFFFeedback; // 盖子的锁 //public bool IsLidLocked => !_LidLocker.ONSetPoint && _LidLocker.OFFSetPoint; public MovementPosition LiftPinPosition { get { MovementPosition pos = MovementPosition.Unknown; if (_LiftPin.ONFeedback && !_LiftPin.OFFFeedback) { pos = MovementPosition.Up; } else if (!_LiftPin.ONFeedback && _LiftPin.OFFFeedback) { pos = MovementPosition.Down; } return pos; } } public MovementPosition Inch3Position { get { MovementPosition res = MovementPosition.Unknown; if (_PinInch3.ONFeedback && !_PinInch3.OFFFeedback) { res = MovementPosition.Up; } else if (_PinInch3.OFFFeedback && !_PinInch3.ONFeedback) { res = MovementPosition.Down; } return res; } } public MovementPosition Inch4Position { get { MovementPosition res = MovementPosition.Unknown; if (_PinInch4.ONFeedback && !_PinInch4.OFFFeedback) { res = MovementPosition.Up; } else if (_PinInch4.OFFFeedback && !_PinInch4.ONFeedback) { res = MovementPosition.Down; } return res; } } public DateTime PlcDateTime { get { return _plcDateTime.CurrentDateTime; } } public override bool IsError { get { return _MainPump.IsError || _Generator.IsError; } } public override bool IsIdle { get; } // 腔体压力 public bool IsPressureToleranceEnabled { get => _pressureController.EnableTolerance; set => _pressureController.EnableTolerance = value; } public override double ChamberPressure => _pressureController.ProcessGauge.Value; public override double ChamberPressurePressure => _pressureController.PressureGauge.Value; public double ForelinePressure => _pressureController.ForelineGauge.Value; public PressureCtrlMode PressureMode => _pressureController.ThrottleValve.PressureMode; public double TargetPressure => _pressureController.TargetPressure; // 压力信号 public bool IsATM => _ATM_sw.Value; public bool IsVAC => _VAC_sw.Value; public bool IsWLK => _WLK_sw.Value; public bool IsRFGInterlockOn => _RFG_Interlock.Value; // 温度 public float SubstrateTempSP => _SubstrateTC.ControlTcSetPoint; public float SubstrateTempFB => _SubstrateTC.ControlTcFeedback; // Pump 状态 public bool IsPumpRunning => _MainPump.IsRunning; public bool IsFastPumpOpened => _FastPumpValve.Status; public bool IsSoftPumpOpened => _SoftPumpValve.Status; public bool IsMfc1ValveOpened => _Mfc1Valve.Status; public bool IsMfc2ValveOpened => _Mfc2Valve.Status; public bool IsMfc3ValveOpened => _Mfc3Valve.Status; public bool IsMfc4ValveOpened => _Mfc4Valve.Status; public bool IsMfc5ValveOpened => _Mfc5Valve.Status; public bool HasPumpError => _MainPump.IsError || !_MainPump.IsRunning; public bool IsCDA_OK => _CDAPressure.Value; // 蝶阀位置 public float TVPosition => _pressureController.ThrottleValve.PositionFeedback; // 腔体压力.end // 射频 public float ForwardPower => _Generator.ForwardPower; public bool IsGeneratorON => _Generator.IsPowerOn; public float GeneratorSetpoint => _Generator.PowerSetPoint; // 流气 public double TotalGasSetpoint { get { double sum = 0; foreach (var gas in _gasLines) { sum += gas.FlowSP; } return sum; } } public bool HasGasOutOfRange { get { foreach (var gas in _gasLines) { if (!gas.IsOutOfRange) return false; } return true; } } public bool CheckFactoryScrubberSysAlarm => _isFactoryScrubberSysInstalled && _FactoryScrubberSensor != null && _FactoryScrubberSensor.Value; // --------------------------Constructor----------------------- // public JetPM(ModuleName mod) : base(mod.ToString()) { Module = mod; var gasCount = SC.GetValue($"{mod}.GasCount"); _gasLines = new IoGasStick[gasCount]; _isFactoryScrubberSysInstalled = SC.ContainsItem($"{Module}.ScrubberIsInstalled") ? SC.GetValue($"{Module}.ScrubberIsInstalled") : false; for (int index = 0; index < gasCount; index++) { _gasLines[index] = DEVICE.GetDevice($"{Module}.GasStick{index + 1}"); } _Lid = DEVICE.GetDevice($"{Module}.{Virgo_DDevice.Lid}"); //_LidLocker = DEVICE.GetDevice($"{Module}.{Virgo_DDevice.LidLocker}"); _ATM_sw = DEVICE.GetDevice($"{Module}.SensorATMSwitch"); _VAC_sw = DEVICE.GetDevice($"{Module}.SensorVacSwitch"); _WLK_sw = DEVICE.GetDevice($"{Module}.SensorWaterLeakOk"); _CDAPressure = DEVICE.GetDevice($"{Module}.SensorCDAPressureOk"); _SignalTower = DEVICE.GetDevice($"{Module}.SignalTower"); //_ArmNotExtend = DEVICE.GetDevice($"{Module}.SensorArmNotExtend"); _RFG_Interlock = DEVICE.GetDevice($"{Module}.GeneratorInterlock"); _pressureController = DEVICE.GetDevice($"{Module}.{Virgo_DDevice.PressureControl}"); _SubstrateTC = DEVICE.GetDevice($"{Module}.HeaterChamber"); _ForelineTC = DEVICE.GetDevice($"{Module}.ForelineHeater"); _SoftPumpValve = DEVICE.GetDevice($"{Module}.{Virgo_DDevice.ValveSoftPumping}"); _FastPumpValve = DEVICE.GetDevice($"{Module}.{Virgo_DDevice.ValveFastPumping}"); _ProcessValve = DEVICE.GetDevice($"{Module}.{Virgo_DDevice.ValveProcess}"); _FastVentValve = DEVICE.GetDevice($"{Module}.{Virgo_DDevice.ValveFastVent}"); _PurgeValve = DEVICE.GetDevice($"{Module}.{Virgo_DDevice.ValveChamberPurge}"); _PurgeValve = DEVICE.GetDevice($"{Module}.{Virgo_DDevice.ValveChamberPurge}"); _Mfc1Valve = DEVICE.GetDevice($"{Module}.{Virgo_DDevice.ValveMfc1}"); _Mfc2Valve = DEVICE.GetDevice($"{Module}.{Virgo_DDevice.ValveMfc2}"); _Mfc3Valve = DEVICE.GetDevice($"{Module}.{Virgo_DDevice.ValveMfc3}"); _Mfc4Valve = DEVICE.GetDevice($"{Module}.{Virgo_DDevice.ValveMfc4}"); //_Mfc5Valve = DEVICE.GetDevice($"{Module}.{Virgo_DDevice.ValveMfc5}"); //_slitDoor = DEVICE.GetDevice($"{Module}.{Virgo_DDevice.SlitDoor}"); _LiftPin = DEVICE.GetDevice($"{Module}.{Virgo_DDevice.LiftPin}"); _PinInch3 = DEVICE.GetDevice($"{Module}.{Virgo_DDevice.Inch3Pin}"); _PinInch4 = DEVICE.GetDevice($"{Module}.{Virgo_DDevice.Inch4Pin}"); _Generator = DEVICE.GetDevice($"{Module}.{Virgo_DDevice.Rf}"); _MainPump = DEVICE.GetDevice($"{Module}.{Virgo_DDevice.MainPump}"); _plcDateTime = DEVICE.GetDevice($"{Module}.{Virgo_DDevice.PlcDateTime}"); _FactoryScrubberSensor = DEVICE.GetDevice($"{Module}.FactoryScrubberSysNormal"); // RS223 AdTec Generator if (SC.GetValue($"{mod}.Rf.CommunicationType") == (int)CommunicationType.RS232 && SC.GetValue($"{mod}.Rf.MFG") == (int)GeneratorMFG.AdTec) { _Generator = DEVICE.GetDevice($"{Module}.{Virgo_DDevice.Rf}"); } // RS232 AdTec match if (SC.GetValue($"{mod}.match.CommunicationType") == (int)CommunicationType.RS232 && SC.GetValue($"{mod}.match.MFG") == (int)MatchMFG.AdTec) { _Match = DEVICE.GetDevice($"{Module}.{Virgo_DDevice.Match}"); } // RS232 Dry pump, SKY if (SC.GetValue($"{mod}.DryPump.CommunicationType") == (int)CommunicationType.RS232) { if (SC.GetValue($"{mod}.DryPump.MFG") == (int)DryPumpMFG.SKY) { _MainPump = DEVICE.GetDevice($"{Module}.{Virgo_DDevice.MainPump}"); } else if (SC.GetValue($"{mod}.DryPump.MFG") == (int)DryPumpMFG.Edwards) { _MainPump = DEVICE.GetDevice($"{Module}.{Virgo_DDevice.MainPump}"); } } System.Diagnostics.Debug.Assert(null != _Generator); System.Diagnostics.Debug.Assert(null != _MainPump); WaferManager.Instance.SubscribeLocation(Module, 1); } public override bool Initialize() { base.Initialize(); DATA.Subscribe($"{Name}.IoTemperatureCtrl.TemperatureControl.SubstrateTemperature", () => SubstrateTempFB); DATA.Subscribe($"{Module}.WaferSize", () => WaferManager.Instance.GetWafer(Module, 0).Size.ToString()); return true; } // -----------------------------Method------------------------- // public override void Home() { // 与yp讨论过,PM 初始化不需要 SetLiftPin(MovementPosition.Down, out _); //SetSlitDoor(false, out _); //SetGuidePin3Inch(MovementPosition.Down); //SetGuidePin4Inch(MovementPosition.Down); TryClosePumpAndPostAlarm(); } private void TryClosePumpAndPostAlarm() { if (CheckFactoryScrubberSysAlarm) { if (IsFastPumpOpened) OpenValve(ValveType.FAST_PUMP, false); if (IsSoftPumpOpened) OpenValve(ValveType.SOFT_PUMP, false); EV.PostAlarmLog(Module.ToString(), $"{Module} {Name} Factory Scrubber System is alarm "); } } public void SetSlitDoor(bool open, out string reason) { reason = string.Empty; //// [XIAHUAN]: 只在关门的时候检查arm not extend //if (!open && !IsArmNotExtend) //{ // EV.PostAlarmLog(Module.ToString(), "Arm Not Extend 信号不满足"); // return; //} //_slitDoor.SetCylinder(open, out reason); } public void BuzzerBlinking(double time) { if (_SignalTower == null) return; _SignalTower.BuzzerBlinking(time); } public void SwitchOnBuzzerAndRed() { _SignalTower.SwitchOnBuzzerAndRed("", null); } public override bool CheckWaterLeak() { return _WLK_sw.Value; } public override bool CheckAtm() { return _ATM_sw.Value && ChamberPressure > 700000; } public override bool CheckVacuum() { return _VAC_sw.Value && ChamberPressure < 100; } public bool CheckSlitDoorOpen() { return true; //return _slitDoor.State == CylinderState.Open; } public bool CheckSlitDoorClose() { return true; //return _slitDoor.State == CylinderState.Close; } public bool CheckLiftUp() { return _LiftPin.State == CylinderState.Open; } public bool CheckLiftDown() { return _LiftPin.State == CylinderState.Close; } public void StartPump(bool on) { //_pressureController.StartPump(on); _MainPump?.SetPumpOnOff(on); } public void OpenValve(ValveType vlvType, bool on) { switch (vlvType) { case ValveType.PROCESS: _ProcessValve.TurnValve(on, out _); break; case ValveType.FAST_PUMP: _FastPumpValve.TurnValve(on, out _); break; case ValveType.SOFT_PUMP: _SoftPumpValve.TurnValve(on, out _); break; case ValveType.FAST_VENT: _FastVentValve.TurnValve(on, out _); break; case ValveType.PURGE: _PurgeValve.TurnValve(on, out _); break; case ValveType.Mfc1: _Mfc1Valve.TurnValve(on, out _); break; case ValveType.Mfc2: _Mfc2Valve.TurnValve(on, out _); break; case ValveType.Mfc3: _Mfc3Valve.TurnValve(on, out _); break; case ValveType.Mfc4: _Mfc4Valve.TurnValve(on, out _); break; //case ValveType.Mfc5: // _Mfc5Valve.TurnValve(on, out _); // break; default: throw new ArgumentOutOfRangeException($"Argument error {vlvType}-{on}"); } } public void CheckPressureStability() { } public override void Monitor() { foreach (var gas in _gasLines) { gas.Monitor(); } _trigScrubberSysAlarm.CLK = CheckFactoryScrubberSysAlarm; if (_trigScrubberSysAlarm.Q) { TryClosePumpAndPostAlarm(); } } public void CloseValves() { _SoftPumpValve.TurnValve(false, out _); _FastPumpValve.TurnValve(false, out _); _ProcessValve.TurnValve(false, out _); _PurgeValve.TurnValve(false, out _); _FastVentValve.TurnValve(false, out _); _PurgeValve.TurnValve(false, out _); _Mfc1Valve.TurnValve(false, out _); _Mfc2Valve.TurnValve(false, out _); _Mfc3Valve.TurnValve(false, out _); _Mfc4Valve.TurnValve(false, out _); //_Mfc5Valve.TurnValve(false, out _); foreach (var stick in _gasLines) { stick.Stop(); } } public bool FlowGas(int gasNum, double val) { if (_gasLines.Length <= gasNum) return false; _gasLines[gasNum].Flow(val); return true; } public void StopAllGases() { foreach (var line in _gasLines) { line.Stop(); } } public bool SetLiftPin(MovementPosition dirt, out string reason) { reason = string.Empty; switch (dirt) { case MovementPosition.Down: return _LiftPin.SetCylinder(false, out reason); case MovementPosition.Up: return _LiftPin.SetCylinder(true, out reason); case MovementPosition.Left: case MovementPosition.Right: case MovementPosition.Middle: throw new ArgumentException("Movement argument error"); } return true; } public void SetGuidePin3Inch(MovementPosition dirt) { switch (dirt) { case MovementPosition.Down: _PinInch3.SetCylinder(false, out _); break; case MovementPosition.Up: _PinInch3.SetCylinder(true, out _); break; default: throw new ArgumentException("Movement argument error"); } } public void SetGuidePin4Inch(MovementPosition dirt) { switch (dirt) { case MovementPosition.Down: _PinInch4.SetCylinder(false, out _); break; case MovementPosition.Up: _PinInch4.SetCylinder(true, out _); break; default: throw new ArgumentException("Movement argument error"); } } public void SetGeneratorCommunicationMode(int mode) { _Generator?.SetCommunicationMode(mode); } public bool GeneratorPowerOn(bool on) { if (_Generator == null) return false; if (on && !IsRFGInterlockOn) { EV.PostAlarmLog(Module.ToString(), "射频电源 Interlock条件不满足"); return false; } return _Generator.SetPowerOnOff(on, out _); } public bool GeneratorSetpower(float val) { if (_Generator == null) return false; _Generator.SetPower((ushort)val); return true; } public bool SetMatchPosition(float c1, float c2) { if (_Match == null) return false; string reason = string.Empty; _Match.SetMatchPosition(c1, c2, out reason); return true; } public void FullOpenTV() { _pressureController.FullOpenThrottleValve(); } public void HeatSubstrate(double val) { _SubstrateTC?.RampTemp((float)val); _SubstrateTC?.TurnOnOff(true); } public void HeatForeline(double val) { _ForelineTC?.RampTemp((float)val); } public override bool CheckEnableTransfer(EnumTransferType type) { if (type == EnumTransferType.Pick) { //return _slitDoor.State == CylinderState.Open && _LiftPin.State == CylinderState.Open; } if (type == EnumTransferType.Place) { //return _slitDoor.State == CylinderState.Open && _LiftPin.State == CylinderState.Close; } return false; } public override void TransferHandoff(EnumTransferType type) { switch (type) { case EnumTransferType.Pick: SetLiftPin(MovementPosition.Up, out _); break; case EnumTransferType.Place: SetLiftPin(MovementPosition.Down, out _); break; case EnumTransferType.Extend: break; case EnumTransferType.Retract: break; default: break; } } public override void Reset() { } } /// /// PM Action /// abstract class PmActionBase : ActionBase { protected internal JetPM _chamber; protected PmActionBase(ModuleName mod, JetPM pm) : base(mod) { _chamber = pm; } } class PinAction : PmActionBase { public MovementPosition Pos { get; } public bool IsWaferTransfered { get; } public PMEntity PmEntity { get; set; } public PinAction(ModuleName mod, JetPM pm, MovementPosition pos, bool isTransferWafer) : base(mod, pm) { this.Pos = pos; IsWaferTransfered = isTransferWafer; } public override void Execute() { if (Module == ModuleName.PMA) PmEntity = Singleton.Instance.PMA; else if (Module == ModuleName.PMB) PmEntity = Singleton.Instance.PMB; if (PmEntity != null) { PmEntity.PostMsg(PMEntity.MSG.MoveLiftPin, Pos, ID); } } public override void OnPostWork(string data = null) { if (IsWaferTransfered) { if (Pos == MovementPosition.Up) { WaferManager.Instance.WaferMoved(ModuleName.EfemRobot, 0, Module, 0); } else { WaferManager.Instance.WaferMoved(Module, 0, ModuleName.EfemRobot, 0); } } } } }