123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473 |
- using System;
- using Aitex.Core.Common;
- using Aitex.Core.RT.Routine;
- using Aitex.Core.RT.SCCore;
- using MECF.Framework.Common.Equipment;
- using MECF.Framework.Common.Schedulers;
- using MECF.Framework.Common.SubstrateTrackings;
- using JetVirgoPM.Devices;
- using MECF.Framework.RT.EquipmentLibrary.HardwareUnits.PMs;
- using Aitex.Sorter.Common;
- namespace JetVirgoPM.PMs.Routines
- {
- class PMPrepareTransferRoutine : PMRoutineBase, IStepRoutine
- {
- enum RoutineStep
- {
- LiftUpDown,
- Vent,
- VentDelay,
- SetGuidePin,
- CheckCoolantTemp1,
- CheckCoolantTemp2,
- CheckTemp1,
- CheckTemp2,
- CheckLETemp,
- SetSlitDoor,
- SlitDoorDelay,
- PrepareTransferPlace,
- PrepareTransferPick,
- kEnd
- }
- private EnumTransferType _TransferType;
- private EnumDualPM _pos;
- private int _timeout;
- private readonly VentRoutine _ventRoutine;
- private WaferSize _ws;
- private double _temp;
- private double _tolerance;
- private double _Chiller1OffsetTemp = 0.0f;
- private double _Chiller2OffsetTemp = 0.0f;
- private double _TargetTemp1 = 0.0f;
- private double _TargetTemp2 = 0.0f;
- private bool _enableCheckTemp = false;
- private int _checkChamberTempTimeout = 60;
- private bool _isATMMode;
- public bool _Chamber1Disabled;
- public bool _Chamber2Disabled;
- private bool _enableChiller1;
- private bool _enableChiller2;
- private bool _enableLE1;
- private bool _enableLE2;
- private bool _isVented = false;
- public bool GuidePinInstalled;
- public PMPrepareTransferRoutine(JetDualPM chamber, VentRoutine _vRoutine) : base(chamber)
- {
- Name = "PrepareTransfer";
- _ventRoutine = _vRoutine;
- }
- public RState Init(EnumTransferType type, EnumDualPM pos, WaferSize size, double temp1, double temp2, bool EnableCheckTemp)
- {
- if (type == EnumTransferType.Place)
- {
- Name = $"Prepare Place {_ws}";
- }
- else if (type == EnumTransferType.Pick)
- {
- size = WaferManager.Instance.GetWafer(_chamber.Module, pos == EnumDualPM.Left ? 0 : 1).Size;
- Name = $"Prepare Pick {_ws}";
- }
- _TargetTemp1 = temp1;
- _TargetTemp2 = temp2;
- _enableCheckTemp = EnableCheckTemp;
- _pos = pos;
- _TransferType = type;
- _ws = size;
- return RState.End;
- }
- public RState Init(EnumTransferType type, int[] slot, double temp1, double temp2, bool EnableCheckTemp, int handSlot = -1, EnumDualPM autoPos= EnumDualPM.None)
- {
- EnumDualPM pos = (slot.Length > 1) ? EnumDualPM.Both : (slot[0] == 0) ? EnumDualPM.Left : EnumDualPM.Right;
- if(autoPos != EnumDualPM.None)
- {
- pos = autoPos;
- }
- if (SC.IsDoubleFork) pos = EnumDualPM.Both;
- WaferSize ws = WaferSize.WS0;
- if(handSlot != -1 && type == EnumTransferType.Place)
- {
- Hand hand = (Hand)handSlot;
- if (hand == Hand.Both)
- {
- ws = WaferManager.Instance.GetWafer(ModuleName.TMRobot, (int)Hand.Blade1).Size;
- }
- else
- {
- ws = WaferManager.Instance.GetWafer(ModuleName.TMRobot, (int)hand).Size;
- }
- }
- else if (type == EnumTransferType.Pick)
- {
- if(pos == EnumDualPM.Left || pos == EnumDualPM.Both)
- {
- ws = WaferManager.Instance.GetWafer(_chamber.Module, (int)EnumDualPM.Left - 1).Size;
- }
- else if(pos == EnumDualPM.Right)
- {
- ws = WaferManager.Instance.GetWafer(_chamber.Module, (int)EnumDualPM.Right - 1).Size;
- }
- }
- _TargetTemp1 = temp1;
- _TargetTemp2 = temp2;
- _enableCheckTemp = EnableCheckTemp;
- return Init(type, pos, ws, temp1, temp2, EnableCheckTemp);
- }
- public RState Start(params object[] objs)
- {
- Reset();
- _timeout = SC.GetValue<int>($"{Module}.PrepareTransferTimeout");
- _Chamber1Disabled = SC.GetValue<bool>($"System.SetUp.{Module}Chamber1Disabled.IsInstalled");
- _Chamber2Disabled = SC.GetValue<bool>($"System.SetUp.{Module}Chamber2Disabled.IsInstalled");
- _enableChiller1 = SC.GetValue<bool>($"{Module}.Chiller1.EnableChiller");
- _enableChiller2 = SC.GetValue<bool>($"{Module}.Chiller2.EnableChiller");
- GuidePinInstalled = SC.GetValue<bool>($"{Module}.GuidePin.IsInstalled");
- if(GuidePinInstalled && _ws == WaferSize.WS0)
- {
- Stop($"GuidePin 开启后,检查到Wafer size is {_ws.ToString()}");
- return RState.Failed;
- }
- _checkChamberTempTimeout = SC.GetValue<int>($"{Module}.CheckChamberTempTimeout");
- _temp = SC.GetValue<double>($"{Module}.ChamberBaseTemperatureThreshold");
- _tolerance = SC.GetValue<double>($"System.MaxTemperatureToleranceToTarget");
- _Chiller1OffsetTemp = SC.GetValue<double>($"{Module}.Chiller1.ChillerTemperatureOffset");
- _Chiller2OffsetTemp = SC.GetValue<double>($"{Module}.Chiller2.ChillerTemperatureOffset");
- if (CheckAlreadyReadyForTransfer())
- {
- return RState.End;
- }
- _isATMMode = SC.IsATMMode;
- if (_isATMMode && !_chamber.CheckAtm())
- {
- Stop($"Running in ATMmode,{_chamber.DeviceID} not in atmos now!");
- return RState.Failed;
- }
- Notify($"开始, 准备 {(_TransferType == EnumTransferType.Place ? "放" : _TransferType == EnumTransferType.Pick ? "取" : "动作未知")}{_ws} 寸片, ");
- _enableLE1 = true;
- _enableLE2 = true;
- return Runner.Start(_chamber.Module.ToString(), Name);
- }
- public RState Monitor()
- {
- Runner.Run(RoutineStep.Vent, Vent, CheckVent)
- .Run(RoutineStep.CheckCoolantTemp1, SetCoolant1Temp, CheckCoolant1Temp, _checkChamberTempTimeout * 1000)
- .Run(RoutineStep.CheckCoolantTemp2, SetCoolant2Temp, CheckCoolant2Temp, _checkChamberTempTimeout * 1000)
- .Run(RoutineStep.CheckLETemp, SetLETemp, CheckLETemp, _checkChamberTempTimeout * 1000)
- .Run(RoutineStep.CheckTemp1, SetLETemp1, CheckLETemp1, _checkChamberTempTimeout * 1000)
- .Run(RoutineStep.CheckTemp2, SetLETemp2, CheckLETemp2, _checkChamberTempTimeout * 1000)
- .Run(RoutineStep.PrepareTransferPlace, PMPreparePlace, CheckPMPreparePlace, _timeout * 1000)
- .Run(RoutineStep.PrepareTransferPick, PMPreparePick, CheckPMPreparePick, _timeout * 1000)
- .End(RoutineStep.kEnd, EndFunc, _delay_0s);
- return Runner.Status;
- }
- public override void Abort()
- {
- }
- bool Vent()
- {
- _isVented = SC.IsATMMode || _chamber.CheckSlitDoor1Open() || _chamber.CheckSlitDoor2Open();
- if (!_isVented)
- {
- var status = _ventRoutine.Start();
- _isVented = status == RState.End;
- if (!_isVented) return status == RState.Running;
- }
- return _isVented;
- }
- bool CheckVent()
- {
- if (_isVented) return true;
- var status = _ventRoutine.Monitor();
- if (status == RState.End)
- return true;
- else if (status == RState.Failed || status == RState.Timeout)
- {
- Runner.Stop($"Vent failed.");
- return true;
- }
- return false;
- }
- bool SetCoolant1Temp()
- {
- if (_TransferType == EnumTransferType.Place && !SC.IsATMMode && _enableCheckTemp && !_Chamber1Disabled && _TargetTemp1 > 0 && _enableChiller1)
- {
- _enableLE1 = false;
- return SetCoolant1Temp(_TargetTemp1, _Chiller1OffsetTemp, _tolerance);
- }
- return true;
- }
- bool CheckCoolant1Temp()
- {
- if (_TransferType == EnumTransferType.Place && !SC.IsATMMode && _enableCheckTemp && !_Chamber1Disabled && _TargetTemp1 > 0 && _enableChiller1)
- {
- return CheckCoolant1Temp(_TargetTemp1, _Chiller1OffsetTemp, _tolerance);
- }
- return true;
- }
- bool SetCoolant2Temp()
- {
- if(_TransferType == EnumTransferType.Place && !SC.IsATMMode && _enableCheckTemp && !_Chamber2Disabled && _TargetTemp2 > 0 && _enableChiller2)
- {
- _enableLE2 = false;
- return SetCoolant2Temp(_TargetTemp2, _Chiller2OffsetTemp, _tolerance);
- }
- return true;
- }
- bool CheckCoolant2Temp()
- {
- if (_TransferType == EnumTransferType.Place && !SC.IsATMMode && _enableCheckTemp && !_Chamber2Disabled && _TargetTemp2 > 0 && _enableChiller2)
- {
- return CheckCoolant2Temp(_TargetTemp2, _Chiller2OffsetTemp, _tolerance);
- }
- return true;
- }
- bool SetLETemp()
- {
- if(_TransferType == EnumTransferType.Place && !SC.IsATMMode && (_enableLE1 && !_Chamber1Disabled && _TargetTemp1 > 0) && (_enableLE2 && !_Chamber2Disabled && _TargetTemp2 > 0))
- {
- return SetLETemp(_TargetTemp1, _TargetTemp2, _tolerance, _enableLE1, _enableLE2);
- }
- return true;
- }
- bool CheckLETemp()
- {
- if (_TransferType == EnumTransferType.Place && !SC.IsATMMode && (_enableLE1 && !_Chamber1Disabled && _TargetTemp1 > 0) && (_enableLE2 && !_Chamber2Disabled && _TargetTemp2 > 0))
- {
- return CheckLETemp(_TargetTemp1, _TargetTemp2, _tolerance, _enableLE1, _enableLE2);
- }
- return true;
- }
- bool SetLETemp1()
- {
- if (_TransferType == EnumTransferType.Place && !SC.IsATMMode && _enableLE1 && !_Chamber1Disabled && _TargetTemp1 > 0)
- {
- return SetLETemp(_TargetTemp1, 0, _tolerance, _enableLE1, false);
- }
- return true;
- }
- bool CheckLETemp1()
- {
- if (_TransferType == EnumTransferType.Place && !SC.IsATMMode && _enableLE1 && !_Chamber1Disabled && _TargetTemp1 > 0)
- {
- return CheckLETemp(_TargetTemp1, 0, _tolerance, _enableLE1, false);
- }
- return true;
- }
- bool SetLETemp2()
- {
- if (_TransferType == EnumTransferType.Place && !SC.IsATMMode && _enableLE2 && !_Chamber2Disabled && _TargetTemp2 > 0)
- {
- return SetLETemp(0, _TargetTemp2, _tolerance, false, _enableLE2);
- }
- return true;
- }
- bool CheckLETemp2()
- {
- if (_TransferType == EnumTransferType.Place && !SC.IsATMMode && _enableLE2 && !_Chamber2Disabled && _TargetTemp2 > 0)
- {
- return CheckLETemp(0, _TargetTemp2, _tolerance, false, _enableLE2);
- }
- return true;
- }
- bool CheckAlreadyReadyForTransfer()
- {
- if (_pos == EnumDualPM.Left)
- {
- if (_TransferType == EnumTransferType.Pick)
- {
- if (!_chamber.CheckSlitDoor1Open())
- {
- return false;
- }
- if (!_chamber.CheckLift1Up())
- {
- return false;
- }
- return _chamber.CheckSlitDoor1Open() && _chamber.CheckLift1Up();
- }
- else if (_TransferType == EnumTransferType.Place)
- {
- if (!_chamber.CheckSlitDoor1Open())
- {
- return false;
- }
- if (!_chamber.CheckLift1Down())
- {
- return false;
- }
- return _chamber.CheckSlitDoor1Open() && _chamber.CheckLift1Down();
- }
- }
- if (_pos == EnumDualPM.Right)
- {
- if (_TransferType == EnumTransferType.Pick)
- {
- if (!_chamber.CheckSlitDoor2Open())
- {
- return false;
- }
- if (!_chamber.CheckLift2Up())
- {
- return false;
- }
- return _chamber.CheckSlitDoor2Open() && _chamber.CheckLift2Up();
- }
- else if (_TransferType == EnumTransferType.Place)
- {
- if (!_chamber.CheckSlitDoor2Open())
- {
- return false;
- }
- if (!_chamber.CheckLift2Down())
- {
- return false;
- }
- return _chamber.CheckSlitDoor2Open() && _chamber.CheckLift2Down();
- }
- }
- if (_pos == EnumDualPM.Both)
- {
- bool checkSlitDoorBothResult = _chamber.CheckSlitDoor1Open() && _chamber.CheckSlitDoor2Open();
- if (!checkSlitDoorBothResult)
- {
- return checkSlitDoorBothResult;
- }
- if (_TransferType == EnumTransferType.Pick)
- {
- return _chamber.CheckLift1Up() && _chamber.CheckLift2Up();
- }
- else if (_TransferType == EnumTransferType.Place)
- {
- return _chamber.CheckLift1Down() && _chamber.CheckLift2Down();
- }
- }
- return false;
- }
- bool PMPreparePlace()
- {
- if(_TransferType == EnumTransferType.Place)
- {
- return SetLiftPinAndSlitDoorAndGuidePin(false, _ws, true, GuidePinInstalled);
- }
- return true;
- }
- bool CheckPMPreparePlace()
- {
- if (_TransferType == EnumTransferType.Place)
- {
- return CheckLiftPinAndSlitDoorAndGuidePin(false, _ws, true, GuidePinInstalled);
- }
- return true;
- }
- bool SetLiftPinAndSlitDoorAndGuidePin(bool isUp, WaferSize ws, bool isOpen, bool _guidePinInstalled)
- {
- Notify($"设置 {_chamber.Name}{_pos} liftPin {(isUp ? "升" : "降")}, 设置 {ws} Pin 升, 设置 {_chamber.Name}{_pos} SlitDoor {(isOpen ? "开" : "关")}");
- if (_pos == EnumDualPM.Left || _pos == EnumDualPM.Both)
- {
- if (!_chamber.SetLiftPin1(isUp ? MovementPosition.Up : MovementPosition.Down, out string reason))
- {
- Stop(reason);
- return false;
- }
- if (GuidePinInstalled)
- {
- _chamber.PrepareGuidePinForPlaceLeft(ws);
- }
- _chamber.SetSlitDoor1(isOpen, out string reason1);
- }
- if (_pos == EnumDualPM.Right || _pos == EnumDualPM.Both)
- {
- if (!_chamber.SetLiftPin2(isUp ? MovementPosition.Up : MovementPosition.Down, out string reason))
- {
- Stop(reason);
- return false;
- }
- if (GuidePinInstalled)
- {
- _chamber.PrepareGuidePinForPlaceRight(ws);
- }
- _chamber.SetSlitDoor2(isOpen, out string reason2);
- }
- return true;
- }
- bool CheckLiftPinAndSlitDoorAndGuidePin(bool isUp, WaferSize ws, bool isOpen, bool _guidePinInstalled)
- {
- bool Check1()
- {
- bool res1 = isUp ? _chamber.CheckLift1Up() : _chamber.CheckLift1Down();
- bool res2 = isOpen ? _chamber.CheckSlitDoor1Open() : _chamber.CheckSlitDoor1Close();
- bool res3 = _guidePinInstalled ? _chamber.CheckGuidePinIsReadyForTransferLeft(ws) : true;
- return res1 && res2 && res3;
- }
- bool Check2()
- {
- bool res1 = isUp ? _chamber.CheckLift2Up() : _chamber.CheckLift2Down();
- bool res2 = isOpen ? _chamber.CheckSlitDoor2Open() : _chamber.CheckSlitDoor2Close();
- bool res3 = _guidePinInstalled ? _chamber.CheckGuidePinIsReadyForTransferRight(ws) : true;
- return res1 && res2 && res3;
- }
- return ((_pos != EnumDualPM.Left && _pos != EnumDualPM.Both) || Check1()) && ((_pos != EnumDualPM.Right && _pos != EnumDualPM.Both) || Check2());
- }
- bool PMPreparePick()
- {
- if (_TransferType == EnumTransferType.Pick)
- {
- return SetLiftPinAndSlitDoorAndGuidePin(true, _ws, true, false);
- }
- return true;
- }
- bool CheckPMPreparePick()
- {
- if (_TransferType == EnumTransferType.Pick)
- {
- return CheckLiftPinAndSlitDoorAndGuidePin(true, _ws, true, false);
- }
- return true;
- }
- }
- }
|