| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088 | using System;using System.Collections.Generic;using Aitex.Core.Common;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.SCCore;using Aitex.Core.Util;using Aitex.Core.RT.OperationCenter;using Aitex.Sorter.Common;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 VirgoCommon;using VirgoRT.Devices.IODevices;using VirgoRT.Instances;using VirgoRT.Module;using VirgoRT.Modules;using Aitex.Core.RT.IOCore;namespace VirgoRT.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 IoMessage           _Messager;        private readonly IoMessage _SubstrateTemperature;        private readonly IoMessage _ForelineTemperature;        private readonly IoMessage _CHBWallTemperature;        private readonly IoSensor            _ATM_sw;        private readonly IoSensor            _VAC_sw;        private readonly IoSensor            _WLK_sw;        private readonly IoSensor            _CDAPressure;        private readonly IoSensor            _CDAPressure2;        private readonly IoSensor            _CoolantInletTC;        private readonly IoSensor            _CoolantOutletTC;        private readonly IoSensor            _ArmNotExtend;        private readonly IoSensor            _N2Pressure_sw;        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          _PinSmall;        // 3'        private readonly IoCylinder          _PinMedium;        // 4'        private readonly RfPowerBase         _Generator;        private readonly RfPowerBase         _GeneratorBias;        private readonly RfMatchBase         _Match;        private readonly RfMatchBase         _BiasMatch;        private readonly PumpBase            _MainPump;        private readonly ChillerBase         _Chiller;        private readonly IoGasStick[]        _gasLines;        private readonly IoTriStateLift      _TriStateLiftPin;        private readonly IoTriStateLift2     _TriStateLiftPin2;        private readonly IoTriStateLift4     _TriStateLiftPin4;        private readonly ChillerBase _gridChiller;        private readonly IoHeater _gridHeater;        private readonly IoReset _ResetPlcSignal;        private readonly R_TRIG _trigBasePressure = new R_TRIG();        private readonly R_TRIG _trigBaseTemperature = new R_TRIG();        private readonly R_TRIG _trigWaterLeak = new R_TRIG();        private readonly R_TRIG _trigScrubberSysAlarm = new R_TRIG();        private readonly R_TRIG _trigWaterValve = new R_TRIG();        private double BasePressure;        private double BaseTemperature;        private bool EnableBiasRF = false;        private int _bigWafer = 0;        private int _midWafer = 0;        private int _smallWafer = 0;        private int gasCount = 0;        private readonly int _LiftPinMode;        private readonly int _ChamberType;        private bool _isFactoryScrubberSysInstalled;        // --------------------------Properties------------------------        //        public new ModuleName Module { get; }        // 门的状态        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 (_LiftPinMode == 0)                {                    if (_LiftPin.ONFeedback && !_LiftPin.OFFFeedback)                    {                        pos = MovementPosition.Up;                    }                    else if (!_LiftPin.ONFeedback && _LiftPin.OFFFeedback)                    {                        pos = MovementPosition.Down;                    }                }                else if (_LiftPinMode == 1)                    pos = _TriStateLiftPin.PinPosition;                else if (_LiftPinMode == 2)                    pos = _TriStateLiftPin2.PinPosition;                else if (_LiftPinMode == 4)                    pos = _TriStateLiftPin4.PinPosition;                return pos;            }        }        public MovementPosition SmallPosition        {            get            {                if (_smallWafer == 0)                    return MovementPosition.Down;                MovementPosition res = MovementPosition.Unknown;                if (_PinSmall.ONFeedback && !_PinSmall.OFFFeedback)                {                    res = MovementPosition.Up;                }                else if (_PinSmall.OFFFeedback && !_PinSmall.ONFeedback)                {                    res = MovementPosition.Down;                }                return res;            }        }        public MovementPosition MediumPosition        {            get            {                if (_midWafer == 0)                    return MovementPosition.Down;                MovementPosition res = MovementPosition.Unknown;                if (_PinMedium.ONFeedback && !_PinMedium.OFFFeedback)                {                    res = MovementPosition.Up;                }                else if (_PinMedium.OFFFeedback && !_PinMedium.ONFeedback)                {                    res = MovementPosition.Down;                }                return res;            }        }        public override bool IsError        {            get            {                if (SC.GetValue<bool>($"{Module}.BiasRf.EnableBiasRF"))                {                    return _MainPump.IsError || _Generator.IsError || _GeneratorBias.IsError;                }                else                {                    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;        public float CoolantInletTempFB => _SubstrateTC.CoolantInletTcFeedback;        public float CoolantOutletTempFB => _SubstrateTC.CoolantOutletTcFeedback;        // 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 && (SC.GetValue<bool>("System.IsIgnoreCDAPressure2Alarm") || (_CDAPressure2?.Value ?? true));        public bool IsCoolantInletTC_OK => _CoolantInletTC.Value;        public bool IsCoolantOutletTC_OK => _CoolantOutletTC.Value;        // 蝶阀位置        public float TVPosition => _pressureController.ThrottleValve.PositionFeedback;        // 腔体压力.end        // 射频        public float ForwardPower => _Generator.ForwardPower;        public bool IsGeneratorON => _Generator.IsPowerOn;        public float GeneratorSetpoint => _Generator.PowerSetPoint;        // Bias射频        public float ForwardPowerBias => _GeneratorBias.ForwardPower;        public bool IsGeneratorONBias => _GeneratorBias.IsPowerOn;        public float GeneratorSetpointBias => _GeneratorBias.PowerSetPoint;        public float CTune => _GeneratorBias.CTune;        public float CLoad => _GeneratorBias.CLoad;        public int VPP => _GeneratorBias.VPP;        // 流气        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;                        BasePressure = SC.GetValue<double>($"{mod}.ChamberBasePressureThreshold");            BaseTemperature = SC.GetValue<double>($"{mod}.ChamberBaseTemperatureThreshold");            _smallWafer = SC.GetValue<int>($"System.SmallWafer");            _midWafer = SC.GetValue<int>($"System.MidWafer");            _bigWafer = SC.GetValue<int>($"System.BigWafer");            EnableBiasRF = SC.GetValue<bool>($"{Module}.BiasRf.EnableBiasRF");            _LiftPinMode = SC.GetValue<int>($"{Module}.LiftPinMode");            _ChamberType = SC.GetValue<int>($"System.ChamberType");            _isFactoryScrubberSysInstalled = SC.ContainsItem($"{Module}.ScrubberIsInstalled") ? SC.GetValue<bool>($"{Module}.ScrubberIsInstalled") : false;            for (int i = 1; i <= 5; i++)            {                if (SC.GetValue<bool>($"{Module}.MfcGas{i}.Enable")) gasCount++;            }            //_gasLines = new IoGasStick[gasCount];            _gasLines = new IoGasStick[5];            //for (int index = 0; index < gasCount; index++)            //{            //    _gasLines[index] = DEVICE.GetDevice<IoGasStick>($"{Module}.GasStick{index + 1}");            //}            for (int index = 0; index < 5; index++)            {                _gasLines[index] = DEVICE.GetDevice<IoGasStick>($"{Module}.GasStick{index + 1}");            }            _Lid                    = DEVICE.GetDevice<IoLid>($"{Module}.{VirgoDevice.Lid}");            //_LidLocker            = DEVICE.GetDevice<IoCylinder>($"{Module}.{VirgoDevice.LidLocker}");            _Messager               = DEVICE.GetDevice<IoMessage>($"{Module}.Messager");            _SubstrateTemperature = DEVICE.GetDevice<IoMessage>($"{Module}.SubstrateTemperature");            _ForelineTemperature = DEVICE.GetDevice<IoMessage>($"{Module}.ForelineTemperature");            _CHBWallTemperature = DEVICE.GetDevice<IoMessage>($"{Module}.CHBWallTemperature");            _ATM_sw                 = DEVICE.GetDevice<IoSensor>($"{Module}.SensorATMSwitch");            _N2Pressure_sw          = DEVICE.GetDevice<IoSensor>($"{Module}.N2PressureOk");            _VAC_sw                 = DEVICE.GetDevice<IoSensor>($"{Module}.SensorVacSwitch");            _WLK_sw                 = DEVICE.GetDevice<IoSensor>($"{Module}.SensorWaterLeakOk");            _CDAPressure            = DEVICE.GetDevice<IoSensor>($"{Module}.SensorCDAPressureOk");            _CDAPressure2            = DEVICE.GetDevice<IoSensor>($"{Module}.SensorCDAPressureOk2");            _CoolantInletTC         = DEVICE.GetDevice<IoSensor>($"{Module}.SensorCoolantInletTCOK");            _CoolantOutletTC        = DEVICE.GetDevice<IoSensor>($"{Module}.SensorCoolantOutletTCOK");            _ArmNotExtend           = DEVICE.GetDevice<IoSensor>($"{Module}.SensorArmNotExtend");            _RFG_Interlock          = DEVICE.GetDevice<IoSensor>($"{Module}.GeneratorInterlock");            _FactoryScrubberSensor = DEVICE.GetDevice<IoSensor>($"{Module}.FactoryScrubberSysNormal");            _pressureController     = DEVICE.GetDevice<IoPressureControl>($"{Module}.{VirgoDevice.PressureControl}");            _SubstrateTC            = DEVICE.GetDevice<IoHeater>($"{Module}.HeaterChamber");            _ForelineTC             = DEVICE.GetDevice<IoHeater>($"{Module}.ForelineHeater");            _SoftPumpValve          = DEVICE.GetDevice<IoValve>($"{Module}.{VirgoDevice.ValveSoftPumping}");            _FastPumpValve          = DEVICE.GetDevice<IoValve>($"{Module}.{VirgoDevice.ValveFastPumping}");            _ProcessValve           = DEVICE.GetDevice<IoValve>($"{Module}.{VirgoDevice.ValveProcess}");            _FastVentValve          = DEVICE.GetDevice<IoValve>($"{Module}.{VirgoDevice.ValveFastVent}");            _WaterValve             = DEVICE.GetDevice<IoValve>($"{Module}.WaterValve");            _PurgeValve             = DEVICE.GetDevice<IoValve>($"{Module}.{VirgoDevice.ValveChamberPurge}");            _Mfc1Valve              = DEVICE.GetDevice<IoValve>($"{Module}.{VirgoDevice.ValveMfc1}");            _Mfc2Valve              = DEVICE.GetDevice<IoValve>($"{Module}.{VirgoDevice.ValveMfc2}");            _Mfc3Valve              = DEVICE.GetDevice<IoValve>($"{Module}.{VirgoDevice.ValveMfc3}");            _Mfc4Valve              = DEVICE.GetDevice<IoValve>($"{Module}.{VirgoDevice.ValveMfc4}");            _Mfc5Valve              = DEVICE.GetDevice<IoValve>($"{Module}.{VirgoDevice.ValveMfc5}");            _slitDoor               = DEVICE.GetDevice<IoCylinder>($"{Module}.{VirgoDevice.SlitDoor}");            _LiftPin                = DEVICE.GetDevice<IoCylinder>($"{Module}.{VirgoDevice.LiftPin}");            _PinSmall               = DEVICE.GetDevice<IoCylinder>($"{Module}.{VirgoDevice.SmallPin}");            _PinMedium              = DEVICE.GetDevice<IoCylinder>($"{Module}.{VirgoDevice.MediumPin}");            _Generator              = DEVICE.GetDevice<IoRf>($"{Module}.{VirgoDevice.Rf}");            _GeneratorBias          = DEVICE.GetDevice<IoRf>($"{Module}.{VirgoDevice.BiasRf}");            _MainPump               = DEVICE.GetDevice<PumpBase>($"{Module}.{VirgoDevice.MainPump}");            _Chiller                = DEVICE.GetDevice<ChillerBase>($"{Module}.{VirgoDevice.Chiller}");            _TriStateLiftPin        = DEVICE.GetDevice<IoTriStateLift>($"{Module}.{VirgoDevice.TriStateLiftPin}");            _TriStateLiftPin2       = DEVICE.GetDevice<IoTriStateLift2>($"{Module}.{VirgoDevice.TriStateLiftPin2}");            _TriStateLiftPin4       = DEVICE.GetDevice<IoTriStateLift4>($"{Module}.{VirgoDevice.TriStateLiftPin4}");            _gridChiller = DEVICE.GetDevice<ChillerBase>($"{Module}.GridChiller");            _gridHeater = DEVICE.GetDevice<IoHeater>($"{Module}.GridHeater");            _ResetPlcSignal = DEVICE.GetDevice<IoReset>($"{Module}.ResetPlcSignal");            _gridHeater.Controller = (IoHeaterController)_gridChiller;            // RS223 AdTec Generator            if (SC.GetValue<int>($"{mod}.Rf.CommunicationType") == (int)CommunicationType.RS232 &&                SC.GetValue<int>($"{mod}.Rf.MFG") == (int)GeneratorMFG.AdTec)            {                _Generator = DEVICE.GetDevice<AdTecGenerator>($"{Module}.{VirgoDevice.Rf}");            }            // Ethernet Comet Generator Bias            if (SC.GetValue<bool>($"{mod}.BiasRf.EnableBiasRF") &&                 SC.GetValue<int>($"{mod}.BiasRf.CommunicationType") == (int)CommunicationType.Ethernet &&                SC.GetValue<int>($"{mod}.BiasRf.MFG") == (int)GeneratorMFG.Comet)            {                _GeneratorBias = DEVICE.GetDevice<CometRF>($"{Module}.{VirgoDevice.BiasRf}");            }            // RS232 AdTec match            if (SC.GetValue<int>($"{mod}.match.CommunicationType") == (int)CommunicationType.RS232 &&                SC.GetValue<int>($"{mod}.match.MFG") == (int)MatchMFG.AdTec)            {                _Match = DEVICE.GetDevice<AdTecMatch>($"{Module}.{VirgoDevice.Match}");            }            if (SC.GetValue<bool>($"{mod}.match.EnableMatch") &&               SC.GetValue<int>($"{mod}.match.CommunicationType") == (int)CommunicationType.Ethernet &&               SC.GetValue<int>($"{mod}.match.MFG") == (int)MatchMFG.Revtech)            {                _Match = DEVICE.GetDevice<RevtechMatch>($"{Module}.{VirgoDevice.Match}");            }            if (SC.GetValue<bool>($"{mod}.BiasRf.EnableBiasRF") &&                SC.GetValue<int>($"{mod}.BiasRf.CommunicationType") == (int)CommunicationType.RS232 &&                SC.GetValue<int>($"{mod}.BiasRf.MFG") == (int)GeneratorMFG.AdTec)            {                _GeneratorBias = DEVICE.GetDevice<AdTecGenerator>($"{Module}.{VirgoDevice.BiasRf}");            }            if (SC.GetValue<bool>($"{mod}.BiasMatch.EnableBiasMatch") &&               SC.GetValue<int>($"{mod}.BiasMatch.CommunicationType") == (int)CommunicationType.Ethernet &&               SC.GetValue<int>($"{mod}.BiasMatch.MFG") == (int)MatchMFG.Revtech)            {                _BiasMatch = DEVICE.GetDevice<RevtechMatch>($"{Module}.{VirgoDevice.BiasMatch.ToString()}");            }            // RS232 Dry pump, SKY            if (SC.GetValue<int>($"{mod}.DryPump.CommunicationType") == (int)CommunicationType.RS232)            {                if (SC.GetValue<int>($"{mod}.DryPump.MFG") == (int)DryPumpMFG.SKY)                {                    _MainPump = DEVICE.GetDevice<SkyPump>($"{Module}.{VirgoDevice.MainPump}");                }                else if (SC.GetValue<int>($"{mod}.DryPump.MFG") == (int)DryPumpMFG.Edwards)                {                    _MainPump = DEVICE.GetDevice<EdwardsPump>($"{Module}.{VirgoDevice.MainPump}");                }            }            if (SC.GetValue<bool>($"{mod}.Chiller.EnableChiller") &&                SC.GetValue<int>($"{mod}.Chiller.CommunicationType") == (int)CommunicationType.RS232 &&                SC.GetValue<int>($"{mod}.Chiller.MFG") == (int)ChillerMFG.SMC)            {                _Chiller = DEVICE.GetDevice<SMCChiller>($"{Module}.{VirgoDevice.Chiller}");            }            System.Diagnostics.Debug.Assert(null != _Generator);            System.Diagnostics.Debug.Assert(null != _MainPump);            if (SC.GetValue<bool>($"{Module}.BiasRf.EnableBiasRF"))            {                System.Diagnostics.Debug.Assert(null != _GeneratorBias);            }            WaferManager.Instance.SubscribeLocation(Module, 1);        }        public override bool Initialize()        {            base.Initialize();            OP.Subscribe($"{Module}.LiftPin.SetPosition", (out string reason, int time, object[] param) => {                MovementPosition dir = MovementPosition.Unknown;                if ((string)param[0] == "Up")                    dir = MovementPosition.Up;                else if ((string)param[0] == "Down")                    dir = MovementPosition.Down;                else if ((string)param[0] == "Middle")                    dir = MovementPosition.Middle;                SetLiftPin(dir, out reason);                return true;            });            DATA.Subscribe($"{Name}.IoTemperatureCtrl.TemperatureControl.SubstrateTemperature", () => SubstrateTempFB);            DATA.Subscribe($"{Module}.WaferSize", () => WaferManager.Instance.GetWafer(Module, 0).Size.ToString());            DATA.Subscribe($"{Module}.EnableBiasRF", () => EnableBiasRF);            return true;        }        // -----------------------------Method-------------------------        //        public override void Home()        {            // 与yp讨论过,PM 初始化不需要            if (IsSlitDoorClosed)            {                SetSlitDoor(false, out _);            }            else if (!IsSlitDoorClosed)            {                SetSlitDoor(false, out _);            }            else if (_slitDoor.State == CylinderState.Error)            {                SetSlitDoor(true, out _);            }            if (SC.GetValue<bool>($"{Module}.BiasRf.EnableBiasRF"))            {                _Messager.SetMessager(1);   //Virgo B            }            else            {                _Messager.SetMessager(0);   //Virgo A            }            _SubstrateTemperature?.SetMessager(SC.GetValue<int>($"{Module}.SubstrateTemperatureTCTMDiff"));            _ForelineTemperature?.SetMessager(SC.GetValue<int>($"{Module}.ForelineTemperatureTCTMDiff"));            _CHBWallTemperature?.SetMessager(SC.GetValue<int>($"{Module}.CHBWallTemperatureTCTMDiff"));            _ResetPlcSignal?.Reset();        }        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 sensor error");                return;            }            _slitDoor.SetCylinder(open, out reason);        }        public override bool CheckWaterLeak()        {            return _WLK_sw.Value;        }        public override bool CheckCDAOK()        {            return _CDAPressure.Value && (SC.GetValue<bool>("System.IsIgnoreCDAPressure2Alarm") || (_CDAPressure2?.Value ?? true));        }        public override bool CheckCoolantInletTCOK()        {            return _CoolantInletTC?.Value ?? false;        }        public override bool CheckCoolantOutletTCOK()        {            return _CoolantOutletTC?.Value ?? false;        }        public override bool CheckArmExtendOK()        {            return _ArmNotExtend.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 _slitDoor.State == CylinderState.Open;        }        public bool CheckSlitDoorClose()        {            return _slitDoor.State == CylinderState.Close;        }        public bool CheckLiftUp()        {            return LiftPinPosition == MovementPosition.Up;        }        public bool CheckLiftDown()        {            return LiftPinPosition == MovementPosition.Down;        }        public bool CheckLiftPinPos(MovementPosition pos)        {            return LiftPinPosition == pos;        }        public void StartPump(bool on)        {            //_pressureController.StartPump(on);            _MainPump?.SetPumpOnOff(on);        }        public void SetValveOnOff(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();            }            _trigBasePressure.CLK = ChamberPressurePressure >= BasePressure;            if (SC.GetValue<bool>($"{Module}.Chiller.EnableChiller"))            {                _trigBaseTemperature.CLK = CoolantOutletTempFB >= BaseTemperature;            }            else            {                _trigBaseTemperature.CLK = SubstrateTempFB >= BaseTemperature;            }            if (_trigBasePressure.Q)            {                EV.PostMessage(Module.ToString(), EventEnum.DefaultAlarm, "PM pressure out of tolerance");            }                            if (_trigBaseTemperature.Q) EV.PostMessage(Module.ToString(), EventEnum.DefaultAlarm, "PM temperature out of tolerance");            if(_ChamberType == (int)JetChamber.VirgoMask)            {                _trigWaterLeak.CLK = !IsWLK;                if (_trigWaterLeak.Q)                {                    IO.DO[$"{ModuleName.PMA}.DO_EV5_Water_Valve"].Value = false;                    IO.DO[$"{ModuleName.PMB}.DO_EV5_Water_Valve"].Value = false;                    EV.PostMessage(Module.ToString(), EventEnum.DefaultAlarm, $"PM water leak");                }                if (IsWLK && IO.DI[$"{ModuleName.PMA}.DI_Reset_Signal_Reply"].Value && !IO.DI[$"{ModuleName.PMA}.DI_Water_Valve_Opened"].Value)                {                    IO.DO[$"{ModuleName.PMA}.DO_EV5_Water_Valve"].Value = true;                    IO.DO[$"{ModuleName.PMB}.DO_EV5_Water_Valve"].Value = true;                }                _trigScrubberSysAlarm.CLK = CheckFactoryScrubberSysAlarm;                if (_trigScrubberSysAlarm.Q)                {                    TryClosePumpAndPostAlarm();                }            }            else if (_ChamberType == (int)JetChamber.VirgoR && _WaterValve != null)            {                _trigWaterLeak.CLK = !IsWLK;                if (_trigWaterLeak.Q)                {                    EV.PostWarningLog(Module.ToString(), $"Water Leak SW Sensor alarm !");                    _WaterValve.TurnValve(false, out _);                }                _trigWaterValve.CLK = IsWLK && !_WaterValve.Status;                if (_trigWaterValve.Q) EV.PostWarningLog(Module.ToString(), $"Water Valve is off !");            }        }        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:                    {                        if (_LiftPinMode == 0) return _LiftPin.SetCylinder(false, out reason);                        if (_LiftPinMode == 1) return _TriStateLiftPin.GoPosition(Position.position3);                        if (_LiftPinMode == 2) return _TriStateLiftPin2.GoPosition(Position.position3);                        if (_LiftPinMode == 4) return _TriStateLiftPin4.GoPosition(Position.position3);                        throw new ArgumentException($"{Module} {Name} {dirt} Movement argument error");                    }                case MovementPosition.Up:                    {                        if (_LiftPinMode == 0) return _LiftPin.SetCylinder(true, out reason);                        if (_LiftPinMode == 1) return _TriStateLiftPin.GoPosition(Position.position1);                        if (_LiftPinMode == 2) return _TriStateLiftPin2.GoPosition(Position.position1);                        if (_LiftPinMode == 4) return _TriStateLiftPin4.GoPosition(Position.position1);                        throw new ArgumentException($"{Module} {Name} {dirt} Movement argument error");                    }                case MovementPosition.Origin:                    {                        if (_LiftPinMode == 0) return _LiftPin.SetCylinder(false, out reason);                        if (_LiftPinMode == 1) return _TriStateLiftPin.GoPosition(Position.origin);                        if (_LiftPinMode == 2) return _TriStateLiftPin2.GoPosition(Position.origin);                        if (_LiftPinMode == 4) return _TriStateLiftPin4.GoPosition(Position.origin);                        throw new ArgumentException($"{Module} {Name} {dirt} Movement argument error");                    }                case MovementPosition.Middle:                    if (_LiftPinMode == 1) return _TriStateLiftPin.GoPosition(Position.position2);                    else if (_LiftPinMode == 2) return _TriStateLiftPin2.GoPosition(Position.position2);                    else if (_LiftPinMode == 4) return _TriStateLiftPin4.GoPosition(Position.position2);                    else                        throw new ArgumentException("Movement argument error");                case MovementPosition.Left:                case MovementPosition.Right:                        throw new ArgumentException("Movement argument error");            }            return true;        }        public void SetGuidePin(WaferSize ws, MovementPosition dirt)        {            if (ws == WaferSize.WS3)                SetGuidePinSmall(dirt);            else if (ws == WaferSize.WS4)                SetGuidePinMedium(dirt);        }        public void PrepareGuidePinForPlace(WaferSize ws)        {            if (ws == WaferSize.WS3)            {                SetGuidePinSmall(MovementPosition.Up);                SetGuidePinMedium(MovementPosition.Down);            }            else if (ws == WaferSize.WS4)            {                SetGuidePinSmall(MovementPosition.Down);                SetGuidePinMedium(MovementPosition.Up);            }        }        public bool CheckGuidePinIsReadyForTransfer(WaferSize ws)        {            if (ws == WaferSize.WS3)            {                return SmallPosition == MovementPosition.Up && MediumPosition == MovementPosition.Down;            }            else if (ws == WaferSize.WS4)            {                return SmallPosition == MovementPosition.Down && MediumPosition == MovementPosition.Up;            }            else if (ws == WaferSize.WS6 || ws == WaferSize.WS8 || ws == WaferSize.WS12)                return true;            else                return true;        }        private void SetGuidePinSmall(MovementPosition dirt)        {            EV.PostInfoLog(Module.ToString(), $"set small pin {dirt}, smallWafer={_smallWafer}");            switch (dirt)            {                case MovementPosition.Down:                    if (_smallWafer != 0)                        _PinSmall?.SetCylinder(false, out _);                    break;                case MovementPosition.Up:                    if (_smallWafer != 0)                        _PinSmall?.SetCylinder(true, out _);                    break;                default:                    throw new ArgumentException("Movement argument error");            }        }        private void SetGuidePinMedium(MovementPosition dirt)        {            EV.PostInfoLog(Module.ToString(), $"set medium pin {dirt}, midWafer={_midWafer}");            switch (dirt)            {                case MovementPosition.Down:                    if (_midWafer != 0)                        _PinMedium?.SetCylinder(false, out _);                    break;                case MovementPosition.Up:                    if (_midWafer != 0)                        _PinMedium?.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(), "RF interlock sensor error");                return false;            }            return _Generator.SetPowerOnOff(on, out _);        }        public bool GeneratorSetpower(float val)        {            if (_Generator == null) return false;            if (Math.Abs(val) > 0.01)                _Generator.SetPower((ushort)val);            return true;        }        public bool GeneratorBiasPowerOn(bool on)        {            if (_GeneratorBias == null) return false;            if (on && !IsRFGInterlockOn)            {                EV.PostAlarmLog(Module.ToString(), "Bias RF Interlock sensor error");                return false;            }            return _GeneratorBias.SetPowerOnOff(on, out _);        }        public bool GeneratorBiasSetpower(float val)        {            if (_GeneratorBias == null) return false;            if (Math.Abs(val) > 0.01)                _GeneratorBias.SetPower((ushort)val);            return true;        }        public bool GeneratorBiasSetMatchMode(bool val)        {            if (_BiasMatch != null)            {                _BiasMatch.SetMatchMode(true ? EnumRfMatchTuneMode.Auto.ToString() : EnumRfMatchTuneMode.Manual.ToString(), out _);                return true;            }            if (_GeneratorBias == null) return false;            string reason = string.Empty;            _GeneratorBias.SetMatchingAutoMode(val, out reason);            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 bool SetBiasMatchPosition(float c1, float c2)        {            if (_BiasMatch != null)            {                _BiasMatch.SetMatchPosition(c1, c2, out _);                return true;            }            if (_GeneratorBias == null) return false;            string reason = string.Empty;            _GeneratorBias.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 HeatChiller(double value, double offset)        {            _Chiller?.SetChillerTemp((float)value, (float)offset);            _Chiller?.SetChillerOnOff(true);        }        public bool CheckChillerStatus()        {            return _Chiller != null && _Chiller.IsRunning && !_Chiller.IsError;        }        public void HeatForeline(double val)        {            _ForelineTC?.RampTemp((float)val);        }        public override bool CheckEnableTransfer(EnumTransferType type)        {            if (type == EnumTransferType.Pick)            {                return _slitDoor.State == CylinderState.Open && LiftPinPosition ==  MovementPosition.Up;            }            if (type == EnumTransferType.Place)            {                return _slitDoor.State == CylinderState.Open && LiftPinPosition == MovementPosition.Down;            }            return false;        }        public bool CheckEnableTransfer(EnumTransferType type, WaferSize waferSize)        {            if (type == EnumTransferType.Pick)            {                return _slitDoor.State == CylinderState.Open                       && LiftPinPosition ==  MovementPosition.Up                    && CheckGuidePinIsReadyForTransfer(waferSize);            }            if (type == EnumTransferType.Place)            {                return _slitDoor.State == CylinderState.Open                       && LiftPinPosition == MovementPosition.Down                       && CheckGuidePinIsReadyForTransfer(waferSize);            }            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;            }        }        private void TryClosePumpAndPostAlarm()        {            if (CheckFactoryScrubberSysAlarm)            {                if (IsFastPumpOpened) SetValveOnOff(ValveType.FAST_PUMP, false);                if (IsSoftPumpOpened) SetValveOnOff(ValveType.SOFT_PUMP, false);                EV.PostAlarmLog(Module.ToString(), $"{Module} {Name} Factory Scrubber System is alarm ");            }        }        public override void Reset()        {            _trigBasePressure.RST = true;            _trigBaseTemperature.RST = true;            _trigWaterLeak.RST = true;        }    }    /// <summary>    /// PM Action    /// </summary>    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; }        private Hand _blade;        private bool _isPick;        public PinAction(ModuleName mod, JetPM pm, MovementPosition pos, bool isTransferWafer, Hand blade, bool isPick) : base(mod, pm)        {            this.Pos = pos;            IsWaferTransfered = isTransferWafer;            _blade = blade;            _isPick = isPick;        }        public override void Execute()        {            if (Module == ModuleName.PMA)                PmEntity = Singleton<RouteManager>.Instance.PMA;            else if (Module == ModuleName.PMB)                PmEntity = Singleton<RouteManager>.Instance.PMB;            if (PmEntity != null)            {                PmEntity.PostMsg(PMEntity.MSG.MoveLiftPin, Pos, ID, _isPick);            }        }        public override void OnPostWork(string data = null)        {            if (IsWaferTransfered)            {                if (Pos == MovementPosition.Up)                {                    WaferManager.Instance.WaferMoved(ModuleName.EfemRobot, _blade==Hand.Blade1 ? 0 : 1, Module, 0);                }                else                {                    WaferManager.Instance.WaferMoved(Module, 0, ModuleName.EfemRobot, _blade == Hand.Blade1 ? 0 : 1);                }                Singleton<RouteManager>.Instance.EFEM.EfemDevice.SetRobotMovingInfo( MECF.Framework.Common.CommonData.RobotAction.None, Hand.Both, ModuleName.System);            }        }    }}
 |