123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333 |
- using System;
- using Aitex.Core.RT.Routine;
- using MECF.Framework.Common.Equipment;
- using MECF.Framework.RT.EquipmentLibrary.HardwareUnits.PMs;
- namespace FurnaceRT.Equipments.PMs.Routines
- {
- public class PMBaseRoutine : ModuleRoutine, IRoutine
- {
- protected PMModule PMModule
- {
- get { return _pm; }
- }
- private PMModule _pm;
-
- public PMBaseRoutine(ModuleName module, PMModule pm)
- {
- Module = module.ToString();
- _pm = pm;
- }
- public virtual Result Start(params object[] objs)
- {
- return Result.DONE;
- }
- public virtual Result Monitor()
- {
- return Result.DONE;
- }
- public virtual void Abort()
- {
- }
- protected void TurnPumpOn(int id, PMModule pm, int timeout)
- {
- Tuple<bool, Result> ret = ExecuteAndWait(id, () =>
- {
- Notify($"Turn on {pm.Name} pump");
- //if (!pm.MainPump.SetPump(out string reason, 0, true))
- //{
- // Stop(reason);
- // return false;
- //}
- return true;
- }, () =>
- {
- return true/*pm.MainPump.IsRunning*/;
- }, timeout * 1000);
- if (ret.Item1)
- {
- if (ret.Item2 == Result.FAIL)
- {
- throw (new RoutineFaildException());
- }
- else
- {
- throw (new RoutineBreakException());
- }
- }
- }
- protected void StopAllGasFlow(int id, PMModule pm)
- {
- Tuple<bool, Result> ret = Execute (id, () =>
- {
- Notify($"Turn off all {pm.Name} gas flow");
- string reason = "";
- foreach(var stick in PMModule.GasSticks)
- {
- if (!stick.SetFlow(out reason, 0, 0))
- {
- Stop(reason);
- return false;
- }
- }
- return true;
- } );
- if (ret.Item1)
- {
- if (ret.Item2 == Result.FAIL)
- {
- throw (new RoutineFaildException());
- }
- else
- throw (new RoutineBreakException());
- }
- }
- protected void PumpToHighVacuum(int id, string stepName, PM pm, double pumpHighVacuumPressure, int tvPosition, int timeout)
- {
- Tuple<bool, Result> ret = ExecuteAndWait(id, () =>
- {
- Notify($"Run {pm.Name} fast pump to {pumpHighVacuumPressure:F2} Torr");
- //if (!pm.FastPump(tvPosition, out string reason))
- //{
- // Stop(reason);
- // return false;
- //}
- _stepSpan = new TimeSpan(0, 0, 0, (int)timeout);
- _stepStartTime = DateTime.Now;
- _stepName = stepName;
- return true;
- }, () =>
- {
- if (pm.IsError)
- {
- Stop($"{pm.Name} error");
- return null;
- }
- return pm.ChamberPressure < pumpHighVacuumPressure;
- }, timeout * 1000);
- if (ret.Item1)
- {
- if (ret.Item2 == Result.FAIL)
- {
- throw (new RoutineFaildException());
- }
- else if (ret.Item2 == Result.TIMEOUT) //timeout
- {
- Stop($"{pm.Name} pump to gas line pump pressure timeout, over {timeout} seconds");
- throw (new RoutineFaildException());
- }
- else
- throw (new RoutineBreakException());
- }
- }
- protected void CheckForelinePressure(int id, string stepName, PM pm, double forelineBasePressure, int timeout)
- {
- Tuple<bool, Result> ret = ExecuteAndWait(id, () =>
- {
- Notify($"Run {pm.Name} check foreline pressure lower than {forelineBasePressure:F2} Torr");
- _stepSpan = new TimeSpan(0, 0, 0, (int)timeout);
- _stepStartTime = DateTime.Now;
- _stepName = stepName;
- return true;
- }, () =>
- {
- if (pm.IsError)
- {
- Stop($"{pm.Name} error");
- return null;
- }
- return pm.ForelinePressure <= forelineBasePressure;
- }, timeout * 1000);
- if (ret.Item1)
- {
- if (ret.Item2 == Result.FAIL)
- {
- throw (new RoutineFaildException());
- }
- else if (ret.Item2 == Result.TIMEOUT) //timeout
- {
- Stop($"{pm.Name} wait foreline lower than {forelineBasePressure:F2} Torr timeout, over {timeout} seconds");
- throw (new RoutineFaildException());
- }
- else
- throw (new RoutineBreakException());
- }
- }
-
- protected void CheckChamberOk(int id, PMModuleBase pm)
- {
- Tuple<bool, Result> ret = Execute(id, () =>
- {
- Notify($"Run {pm.Name} check chamber running no error");
- if (pm.IsError)
- {
- Stop($"{pm.Name} error");
- return false;
- }
- return true;
- });
- if (ret.Item1)
- {
- if (ret.Item2 == Result.FAIL)
- {
- throw (new RoutineFaildException());
- }
- else
- {
- throw (new RoutineBreakException());
- }
- }
- }
- public void ToReadyProcessState(int id, PMModule pm,int timeout)
- {
- Tuple<bool, Result> ret = ExecuteAndWait(id, () =>
- {
- Notify($"prepare chamber {pm.Name} ready to run process");
- string reason = "";
- //if (!pm.ChamberDoor.Close(out string reason))
- //{
- // Stop(reason);
- // return false;
- //}
- foreach (var stick in PMModule.GasSticks)
- {
- if (!stick.SetFlow(out reason, 0, 0))
- {
- Stop(reason);
- return false;
- }
- }
- return true;
- }, () =>
- {
- return true/*pm.ChamberDoor.IsClose*/;
- }, timeout * 1000);
- if (ret.Item1)
- {
- if (ret.Item2 == Result.FAIL)
- {
- throw (new RoutineFaildException());
- }
- else if (ret.Item2 == Result.TIMEOUT) //timeout
- {
- Stop($"{pm.Name} prepare process timeout, over {timeout} seconds");
- throw (new RoutineFaildException());
- }
- else
- {
- throw (new RoutineBreakException());
- }
- }
- }
- public void MovePinDown(int id, PMModule pm, int timeout)
- {
- Tuple<bool, Result> ret = ExecuteAndWait(id, () =>
- {
- Notify($"move {pm.Name} lift pin down");
- //if (!pm.ChamberLiftPin.MoveDown(out string reason))
- //{
- // Stop(reason);
- // return false;
- //}
- return true;
- }, () =>
- {
- return true/*pm.ChamberLiftPin.IsDown*/;
- }, timeout * 1000);
- if (ret.Item1)
- {
- if (ret.Item2 == Result.FAIL)
- {
- throw (new RoutineFaildException());
- }
- else if (ret.Item2 == Result.TIMEOUT) //timeout
- {
- Stop($"{pm.Name} move lift pin timeout, over {timeout} seconds");
- throw (new RoutineFaildException());
- }
- else
- {
- throw (new RoutineBreakException());
- }
- }
- }
- public void MovePinUp(int id, PMModule pm, int timeout)
- {
- Tuple<bool, Result> ret = ExecuteAndWait(id, () =>
- {
- Notify($"move {pm.Name} lift pin up");
- //if (!pm.ChamberLiftPin.MoveUp(out string reason))
- //{
- // Stop(reason);
- // return false;
- //}
- return true;
- }, () =>
- {
- return true/*pm.ChamberLiftPin.IsUp*/;
- }, timeout * 1000);
- if (ret.Item1)
- {
- if (ret.Item2 == Result.FAIL)
- {
- throw (new RoutineFaildException());
- }
- else if (ret.Item2 == Result.TIMEOUT) //timeout
- {
- Stop($"{pm.Name} move lift pin timeout, over {timeout} seconds");
- throw (new RoutineFaildException());
- }
- else
- {
- throw (new RoutineBreakException());
- }
- }
- }
- }
- }
|