1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240 |
- using System;
- using System.Linq;
- using System.Windows.Forms;
- using Aitex.Core.RT.Device.Unit;
- using Aitex.Core.RT.Fsm;
- using Aitex.Core.RT.Job;
- using Aitex.Core.Utilities;
- using Aitex.RT.Properties;
- using Aitex.Triton160.RT.Device;
- using Aitex.Triton160.RT.Routine.PM;
- using Aitex.Core.RT.DataCenter;
- using Aitex.Triton160.Common;
- using Aitex.Triton160.RT.Routine.Process;
- using Aitex.Core.RT.Event;
- using Aitex.Core.RT.OperationCenter;
- using Aitex.Core.RT.RecipeCenter;
- using Aitex.Core.RT.Routine;
- using Aitex.Core.RT.SCCore;
- using Aitex.Core.Util;
- using Aitex.RT.FactoryAutomation;
- using System.Threading.Tasks;
- using Aitex.Core.MES;
- using Aitex.Core.MES.YZQZ;
- using System.Collections.Generic;
- namespace Aitex.Triton160.RT.Module
- {
- public enum EnumEquipmentMode
- {
- Auto,
- Manual,
- }
- public enum EnumEquipmentStatus
- {
- Uninit,
- Idle,
- Running,
- Error,
- }
- public class PMEntity : Entity, IEntity
- {
- //public enum STATE
- //{
- //};
- public enum MSG
- {
- Idle,
- SetAutoMode,
- SetManualMode,
- Abort,
- Vent,
-
- PumpDown,
- StopPumpDown,
- GasFlow,
- StopGasFlow,
- RfPower,
-
- CyclePurge,
-
- LeakCheck,
- RunRecipe,
- Process,
- PreProcess,
- PostProcess,
- RciepeAbort,
- RecipeSkipStep,
- RecipePause,
- RecipeResume,
- RecipeUpdate,
- Error,
- Reset,
- };
- private VentRountine _ventRountine = new VentRountine(ModuleName.System.ToString(), "Vent");
- private PumpDownRoutine _pumpRoutine = new PumpDownRoutine(ModuleName.System.ToString(), "Pump");
- private StopPumpRoutine _stopPumpRoutine = new StopPumpRoutine(ModuleName.System.ToString(), "Stop Pump");
- private GasFlowRoutine _gasFlowRoutine = new GasFlowRoutine(ModuleName.System.ToString(), "Gas Flow");
- private StopGasFlowRoutine _stopGasFlowRoutine = new StopGasFlowRoutine(ModuleName.System.ToString(), "Stop Gas Flow");
- private RfPowerRoutine _rfPowerRoutine = new RfPowerRoutine(ModuleName.System.ToString(), "Rf PowerOn");
- private CyclePurgeRoutine cyclePurgeRoutine = new CyclePurgeRoutine(ModuleName.System.ToString(), "Cycle Purge");
-
- private Process processRoutine = new Process(ModuleName.System.ToString(), "Process");
- private PreProcess preProcessRoutine = new PreProcess(ModuleName.System.ToString(), "PreProcess");
- private PostProcess postProcessRoutine = new PostProcess(ModuleName.System.ToString(), "PostProcess");
- private LeakCheckRoutine _leakCheckRoutine = new LeakCheckRoutine(ModuleName.System.ToString(), "Leak Check");
- public string Name { get; set; }
- public bool IsIdle { get { return fsm.State == (int)PMState.Idle; } }
- public string Status { get { return fsm.State.ToString(); } }
- public bool IsAutoMode
- {
- get;
- private set;
- }
- public bool IsProcessMode { get { return (fsm.State == (int)PMState.LoadProcessRecipe) || (fsm.State == (int)PMState.Processing) || (fsm.State == (int)PMState.PreProcess) || (fsm.State == (int)PMState.PostProcess); } }
- public bool IsRunRecipe { get { return (fsm.State == (int)PMState.Processing); } }
- //public bool IsAlarm { get; private set; }
- //public bool IsWarning { get; private set; }
- //public Guid CurrentRecipeRunGuid { get; set; }
- public JobInfo CurrentRunningJob
- {
- get; set;
- }
-
- private string _processStatus = string.Empty;
- private DateTime _pumpStartTime;
- private TimeSpan _pumpElapsedTime;
- private string PumpTime
- {
- get
- {
- if ((fsm.State == (int)PMState.Pumping) || (fsm.State == (int)PMState.PreProcess))
- _pumpElapsedTime = DateTime.Now - _pumpStartTime;
- return string.Format("{0}:{1}:{2}", ((int)_pumpElapsedTime.TotalHours).ToString("00"),
- _pumpElapsedTime.Minutes.ToString("00"), _pumpElapsedTime.Seconds.ToString("00"));
- }
- }
- //private int _rfTime;
- //int RfTime
- //{
- // get
- // {
- // if (fsm.State == (int)PMState.RfPowering)
- // _rfTime = _rfPowerRoutine.Elapsed;
- // else
- // {
- // _rfTime = 0;
- // }
- // return _rfTime;
- // }
- //}
- bool IsPumpingOkForProcess
- {
- get
- {
- return DeviceModel.MainPump.IsRunning &&
- DeviceModel.ValveChamberPumping.Status;
- }
- }
- bool IsGasFlowingOkForProcess
- {
- get
- {
- if (!IsPumpingOkForProcess)
- return false;
-
- if (! ( (DeviceModel.ValveProcessGasFinal!=null && DeviceModel.ValveProcessGasFinal.Status)))
- return false;
- IoValve[] valves = { DeviceModel.ValveMfc1, DeviceModel.ValveMfc2 , DeviceModel.ValveMfc3, DeviceModel.ValveMfc4, DeviceModel.ValveMfc5};
- if (!Array.Exists(valves, v => v!=null && v.Status))
- return false;
- IoMfc[] mfcs = { DeviceModel.MfcGas1, DeviceModel.MfcGas2, DeviceModel.MfcGas3, DeviceModel.MfcGas4, DeviceModel.MfcGas5 };
- if (!Array.Exists(mfcs, m => m!=null && m.FeedBack > 0.1))
- return false;
- return true ;
- }
- }
- private DateTime _recipeStartTime;
- private TimeSpan _recipeElapsedTime;
- public string RecipeElapsedTime
- {
- get
- {
- if (fsm.State == (int) PMState.LoadProcessRecipe || fsm.State == (int) PMState.PreProcess
- || fsm.State == (int) PMState.Processing || fsm.State == (int) PMState.PostProcess)
- _recipeElapsedTime = DateTime.Now - _recipeStartTime;
- return string.Format("{0}:{1}:{2}", ((int)_recipeElapsedTime.TotalHours).ToString("00"),
- _recipeElapsedTime.Minutes.ToString("00"), _recipeElapsedTime.Seconds.ToString("00"));
- }
- }
- private DateTime _leakCheckStartTime;
- private TimeSpan _leakCheckElapsedTime;
- private string LeakCheckElapseTime
- {
- get
- {
- if ((fsm.State == (int)PMState.LeakCheck) )
- _leakCheckElapsedTime = DateTime.Now - _leakCheckStartTime;
- return string.Format("{0}:{1}:{2}", ((int)_leakCheckElapsedTime.TotalHours).ToString("00"),
- _leakCheckElapsedTime.Minutes.ToString("00"), _leakCheckElapsedTime.Seconds.ToString("00"));
- }
- }
- private const string EventCarrierLoaded = "CarrierLoaded";
- private const string EventCarrierUnloaded = "CarrierUnloaded";
- private const string EventLotStart = "LotStart";
- private const string EventLotFinished = "LotFinished";
- private const string EventEquipmentStatusChanged = "EquipmentStatusChanged";
- private const string EventEquipmentModeChanged = "EquipmentModeChanged";
- private int _preEquipmentState;
- public PMEntity()
- {
- Running = false;
- IsAutoMode = false;
- //IsAlarm = false;
- //IsWarning = false;
- Name = "Chamber";
- fsm = new StateMachine<PMEntity>(Name, (int)PMState.Init, 50);
- EnterExitTransition<PMState, MSG>(PMState.Init, fEnterInit, MSG.Idle, null);
- Transition(PMState.Init, MSG.Idle, fInit, PMState.Idle);
- EnterExitTransition<PMState, FSM_MSG>(PMState.Error, fEnterError, FSM_MSG.NONE, null);
-
- AnyStateTransition(FSM_MSG.WARNING, fWarning, FSM_STATE.SAME);
- AnyStateTransition((int)FSM_MSG.ALARM, fAlarm, (int)PMState.Error);
- AnyStateTransition(MSG.Reset, fReset, PMState.Idle);
- //Auto/manual sequence
- Transition(PMState.Idle, MSG.SetAutoMode, fSetAutoMode, PMState.Idle);
- Transition(PMState.Idle, MSG.SetManualMode, fSetManualMode, PMState.Idle);
-
- //vent sequence
- Transition(PMState.Idle, MSG.Vent, fStartVent, PMState.Vent);
- Transition(PMState.Vent, FSM_MSG.TIMER, fVent, PMState.Idle);
- Transition(PMState.Vent, MSG.Abort, fAbortVent, PMState.Idle);
- Transition(PMState.Vent, MSG.PumpDown, fVentToPumping, PMState.Pumping);
- //Pump sequence
- Transition(PMState.Idle, MSG.PumpDown, fStartPumpDown, PMState.Pumping);
- Transition(PMState.Pumping, FSM_MSG.TIMER, fPumpDown, PMState.Idle);
- Transition(PMState.Pumping, MSG.Abort, fAbortPumping, PMState.Idle);
- Transition(PMState.Pumping, MSG.Vent, fPumpingToVent, PMState.Vent);
- //Stop Pump sequence
- Transition(PMState.Idle, MSG.StopPumpDown, fStartStopPump, PMState.StopPumping);
- Transition(PMState.StopPumping, FSM_MSG.TIMER, fStopPump, PMState.Idle);
- Transition(PMState.StopPumping, MSG.Abort, fAbortStopPump, PMState.Idle);
- //Gas Flow sequence
- Transition(PMState.Idle, MSG.GasFlow, fStartGasFlow, PMState.GasFlowing);
- Transition(PMState.GasFlowing, FSM_MSG.TIMER, fGasFlow, PMState.Idle);
- Transition(PMState.GasFlowing, MSG.Abort, fAbortGasFlow, PMState.Idle);
- //Stop Gas Flow sequence
- Transition(PMState.Idle, MSG.StopGasFlow, fStartStopGasFlow, PMState.StopGasFlowing);
- Transition(PMState.StopGasFlowing, FSM_MSG.TIMER, fStopGasFlow, PMState.Idle);
- Transition(PMState.StopGasFlowing, MSG.Abort, fAbortStopGasFlow, PMState.Idle);
- //RF Power sequence
- Transition(PMState.Idle, MSG.RfPower, fStartRfPower, PMState.RfPowering);
- Transition(PMState.RfPowering, FSM_MSG.TIMER, fRfPower, PMState.Idle);
- Transition(PMState.RfPowering, MSG.Abort, fAbortRfPower, PMState.Idle);
- //Leak check sequence
- Transition(PMState.Idle, MSG.LeakCheck, fStartLeakCheck, PMState.LeakCheck);
- Transition(PMState.LeakCheck, FSM_MSG.TIMER, fLeakCheck, PMState.Idle);
- Transition(PMState.LeakCheck, MSG.Abort, fAbortLeakCheck, PMState.Idle);
- //CyclePurge sequence
- Transition(PMState.Idle, MSG.CyclePurge, fStartCyclePurge, PMState.CyclePurge);
- Transition(PMState.CyclePurge, FSM_MSG.TIMER, fCyclePurge, PMState.Idle);
- Transition(PMState.CyclePurge, MSG.Abort, fAbortCyclePurge, PMState.Idle);
-
- //PreProcess sequence
- Transition(PMState.Idle, MSG.RunRecipe, fProcessLoadRecipe, PMState.LoadProcessRecipe );
- Transition(PMState.LoadProcessRecipe, MSG.PreProcess, fStartPreProcess, PMState.PreProcess);
- Transition(PMState.LoadProcessRecipe, MSG.Abort, null, PMState.Idle);
- Transition(PMState.LoadProcessRecipe, MSG.Error, null, PMState.Idle);
-
- Transition(PMState.PreProcess, FSM_MSG.TIMER, fPreProcess, PMState.PreProcess);
- Transition(PMState.PreProcess, MSG.Abort, fAbortPreProcess, PMState.Idle);
- Transition(PMState.PreProcess, MSG.RciepeAbort, fAbortPreProcess, PMState.Idle);
- Transition(PMState.PreProcess, MSG.Error, fAbortPreProcess, PMState.Error);
- Transition(PMState.PreProcess, MSG.Process, fStartProcess, PMState.Processing);
- Transition(PMState.Processing, FSM_MSG.TIMER, fProcess, PMState.Processing);
- Transition(PMState.Processing, MSG.Error, fAbortProcess, PMState.Error);
-
- Transition(PMState.Processing, MSG.RciepeAbort, fAbortProcess, PMState.PostProcess);
- Transition(PMState.Processing, MSG.RecipePause, fPauseProcess, PMState.Processing);
- Transition(PMState.Processing, MSG.RecipeResume, fResumeRecipe, PMState.Processing);
- Transition(PMState.Processing, MSG.RecipeUpdate, fUpdateRecipe, PMState.Processing);
- Transition(PMState.Processing, MSG.RecipeSkipStep, fSkipStep, PMState.Processing);
- EnterExitTransition<PMState,FSM_MSG>(PMState.Processing, fEnterProcess, FSM_MSG.NONE, fExitProcess);
- //PostProcess sequence
- Transition(PMState.Processing, MSG.PostProcess, fStartPostProcess, PMState.PostProcess);
- Transition(PMState.PostProcess, FSM_MSG.TIMER, fPostProcess, PMState.Idle);
- Transition(PMState.PostProcess, MSG.Abort, fAbortPostProcess, PMState.Idle);
- Transition(PMState.PostProcess, MSG.RciepeAbort, fAbortPostProcess, PMState.Idle);
- EnterExitTransition<PMState, FSM_MSG>(PMState.PostProcess, null, FSM_MSG.NONE, fExitPostProcess);
- DATA.Subscribe(ModuleName.System.ToString(), StateData.IsAutoMode.ToString(), () => IsAutoMode);
- DATA.Subscribe(ModuleName.System.ToString(), StateData.PMState.ToString(), () => fsm.State);
- DATA.Subscribe(ModuleName.System.ToString(), StateData.IsPumpingOkForProcess.ToString(), () => IsPumpingOkForProcess);
- DATA.Subscribe(ModuleName.System.ToString(), StateData.IsGasFlowingOkForProcess.ToString(), () => IsGasFlowingOkForProcess);
- DATA.Subscribe(ModuleName.System.ToString(), StateData.PumpTime.ToString(), () => PumpTime);
- //DATA.Subscribe(ModuleName.System.ToString(), StateData.RfTimeElapsed.ToString(), () => RfTime);
- DATA.Subscribe(ModuleName.System.ToString(), StateData.RecipeStepRfTimeSetPoint.ToString(), () => (processRoutine.CurStepTotalRfTime /1000).ToString("F0"));
- DATA.Subscribe(ModuleName.System.ToString(), StateData.RecipeStepTimeElapsed.ToString(), () => (processRoutine.CurStepElpasedTime / 1000).ToString("F0"));
- DATA.Subscribe(ModuleName.System.ToString(), StateData.RecipeStepTimeSetPoint.ToString(), () => (processRoutine.CurStepTotalTime / 1000) .ToString("F0"));
- DATA.Subscribe(ModuleName.System.ToString(), StateData.ProcessStatus.ToString(), () => _processStatus);
- DATA.Subscribe(ModuleName.System.ToString(), StateData.RecipeProcessTime.ToString(), () => RecipeElapsedTime);
- DATA.Subscribe(ModuleName.System.ToString(), StateData.LeakCheckElapseTime.ToString(), () => LeakCheckElapseTime);
- DATA.Subscribe(string.Format("{0}.{1}", ModuleName.System, StateData.AlarmEvent), EV.GetAlarmEvent);
- DATA.Subscribe(ModuleName.System.ToString(), StateData.RecipeStepNo.ToString(), () => processRoutine.CurStepNum + 1);
- DATA.Subscribe(ModuleName.System.ToString(), StateData.RecipeName.ToString(), () =>
- {
- switch ((PMState)fsm.State)
- {
- case PMState.PreProcess:
- return preProcessRoutine.CurrentRecipeBaseName;
- default:
- return processRoutine.CurrentRecipeBaseName;
- }
- });
- DATA.Subscribe(ModuleName.System.ToString(), StateData.TotalCycle.ToString(), () => processRoutine.TotalCycle);
- DATA.Subscribe(ModuleName.System.ToString(), StateData.DataLogName.ToString(), () => processRoutine.CurrentRecipeRunningName);
- DATA.Subscribe(ModuleName.System.ToString(), StateData.LotName.ToString(), () =>
- {
- switch ((PMState)fsm.State)
- {
- case PMState.PreProcess:
- return preProcessRoutine.CurrentLotName;
- default:
- return processRoutine.CurrentLotName;
- }
-
- });
- DATA.Subscribe("RecipeList", () => RecipeFileManager.Instance.GetRecipes("System", false).ToList());
- DATA.Subscribe("EquipmentMode", () => { return (int) (IsAutoMode ? EnumEquipmentMode.Auto : EnumEquipmentMode.Manual); });
- DATA.Subscribe("EquipmentStatus", () =>
- {
- int result = 0;
- switch ((PMState)fsm.State)
- {
- case PMState.Error:
- result = (int) EnumEquipmentStatus.Error;
- break;
- case PMState.Init:
- result = (int) EnumEquipmentStatus.Uninit;
- break;
- case PMState.Idle:
- result = (int) EnumEquipmentStatus.Idle;
- break;
- default:
- result = (int) EnumEquipmentStatus.Running;
- break;
- }
- if (_preEquipmentState != result)
- {
- EV.Notify(EventEquipmentStatusChanged, new SerializableDictionary<string, string>());
- }
- _preEquipmentState = result;
- return result;
- });
- EnumLoop<PMState>.ForEach((item) =>
- {
- fsm.MapState((int)item, item.ToString());
- });
- EnumLoop<MSG>.ForEach((item) =>
- {
- fsm.MapMessage((int)item, item.ToString());
- });
- EV.Subscribe(new EventItem("Event", EventCarrierLoaded, "Event Carrier Loaded"));
- EV.Subscribe(new EventItem("Event", EventCarrierUnloaded, "Event Carrier Unloaded"));
- EV.Subscribe(new EventItem("Event", EventLotStart, "EventLotStart"));
- EV.Subscribe(new EventItem("Event", EventLotFinished, "EventLotFinished"));
- EV.Subscribe(new EventItem("Event", EventEquipmentStatusChanged, "EventEquipmentStatusChanged"));
- EV.Subscribe(new EventItem("Event", EventEquipmentModeChanged, "EventEquipmentModeChanged"));
- OP.Subscribe("CarrierLoad", (string cmd, object[] args) =>
- {
- var dvid = new SerializableDictionary<string, string>();
- EV.Notify(EventCarrierLoaded, dvid);
- return true;
- });
- OP.Subscribe("CarrierUnload", (string cmd, object[] args) =>
- {
- //var dvid = new SerializableDictionary<string, string>();
- //EV.Notify(EventCarrierUnloaded, dvid);
- EV.Notify(EventCarrierUnloaded, new SerializableDictionary<string, string>()
- {
- {DVIDName.LotId, preProcessRoutine.CurrentLotName},
- {DVIDName.JobId, preProcessRoutine.CurrentJobName},
- {DVIDName.RecipeId, preProcessRoutine.CurrentRecipeBaseName }
- });
- return true;
- });
- }
- public Tuple<string, string> GetRecipeInfo()
- {
- if (fsm.State == (int)PMState.PreProcess)
- return new Tuple<string, string>(preProcessRoutine.CurrentRecipeRunningName, preProcessRoutine.CurrentRecipeContent);
- else if(fsm.State == (int)PMState.Processing)
- return new Tuple<string, string>(processRoutine.CurrentRecipeRunningName, processRoutine.CurrentRecipeContent);
- return new Tuple<string, string>(String.Empty, String.Empty);
- }
- public bool Check(int msg, out string reason, params object[] args)
- {
- if (!fsm.FindTransition(fsm.State, msg))
- {
- reason = String.Format("{0} is in {1},can not do {2}", Name, (PMState)fsm.State, (MSG)msg);
- return false;
- }
- bool bRet = true;
- reason = "";
- switch (msg)
- {
- case (int)MSG.RunRecipe:
- if (fsm.State != (int)PMState.Idle)
- {
- reason = String.Format("{0} Is In {1},Can not do {2}", Name, (PMState)fsm.State, (MSG)msg);
- bRet = false;
- }
- break;
- case (int)MSG.RecipePause:
- case (int)MSG.RecipeResume:
- case (int)MSG.RecipeSkipStep:
- case (int)MSG.RecipeUpdate:
- if (fsm.State != (int)PMState.Processing)
- {
- reason = String.Format("{0} not running recipe,can not do {1}", Name, (MSG)(msg));
- bRet = false;
- }
- break;
- default:
- break;
- }
- return bRet;
- }
- protected override bool Init()
- {
- _rfPowerRoutine.Initialize();
- _gasFlowRoutine.Initialize();
- _stopGasFlowRoutine.Initialize();
- _pumpRoutine.Initialize();
- _stopPumpRoutine.Initialize();
- cyclePurgeRoutine.Initialize();
- _ventRountine.Initialize();
-
- processRoutine.Initialize();
- preProcessRoutine.Initialize();
- postProcessRoutine.Initialize();
- _leakCheckRoutine.Initialize();
- Running = true;
- Default();
- return true;
- }
- private bool fSetAutoMode(object[] objs)
- {
- if (IsAutoMode)
- return true;
- IsAutoMode = true;
- EV.Notify(EventEquipmentModeChanged, new SerializableDictionary<string, string>()
- {
-
- });
- EV.PostMessage(ModuleNameString.System, Triton160EventEnum.RunningModeChanged, Resources.GlobalLableAutoMode);
- return true;
- }
- private bool fSetManualMode(object[] objs)
- {
- if (!IsAutoMode)
- return true;
- if (SC.GetValue<bool>(SCName.System_EnableFa)
- && Singleton<FaManager>.Instance.FaControlState== "OnlineRemote"
- && Singleton<FaManager>.Instance.FaCommunicationState == "EnabledCommunicating")
- {
- EV.PostWarningLog("System", Aitex.RT.Properties.Resources.SystemInOnlineRemoteModeCanNotSwitchToManualSwitchOffHostControlFirst);
- return true;
- }
- IsAutoMode = false;
-
- EV.Notify(EventEquipmentModeChanged, new SerializableDictionary<string, string>()
- {
- });
- EV.PostMessage(ModuleNameString.System, Triton160EventEnum.RunningModeChanged, Resources.GlobalLableManualMode );
- return true;
- }
- private bool fEnterInit(object[] objs)
- {
-
- return true;
- }
- private bool fInit(object[] objs)
- {
-
- return true;
- }
- private bool fEnterError(object[] objs)
- {
- if (IsProcessMode)
- {
- EV.Notify(EventLotFinished, new SerializableDictionary<string, string>()
- {
- {DVIDName.LotId, preProcessRoutine.CurrentLotName},
- {DVIDName.JobId, preProcessRoutine.CurrentJobName},
- {DVIDName.RecipeId, preProcessRoutine.CurrentRecipeBaseName }
- });
- }
- return true;
- }
- private bool fWarning(object[] objs)
- {
- //IsWarning = false;
- return true;
- }
- private bool fAlarm(object[] objs)
- {
- StartJobRecord(false);
- if (fsm.State == (int)PMState.Init)
- return false;
- if (fsm.State == (int) PMState.Processing)
- {
- PostMsg(MSG.Error);
-
- MESErrorRecordAlarm(processRoutine.CurrentLotName, processRoutine.CurrentRecipeBaseName, objs);
- return false;
- }
- //IsAlarm = true;
- return true;
- }
- private async void MESErrorRecordAlarm(string lotId, string receipeName, object[] objs)
- {
-
- await Task.Run(() => {
- string erroMsg=string.Empty;
- if (objs != null && objs.Length > 0)
- { foreach (var o in objs)
- erroMsg += o.ToString()+"|";
- }
- erroMsg= erroMsg.TrimEnd('|');
- Fab fb = (Fab)Enum.Parse(typeof(Fab), SC.GetValue<int>(SCName.System_Company).ToString());
- if (fb == Fab.YZQZ)
- {
- List<RequestMachineErrorRecord> records = new List<RequestMachineErrorRecord>();
- FabAutoComm com = new YZQZFabAuto();
- lotId = lotId.TrimEnd('/');
- string[] items = lotId.Split('/');
- foreach (var item in items)
- {
- RequestMachineErrorRecord record = new RequestMachineErrorRecord() { LotId = item, RecipeName = receipeName, MachineNumber = SC.GetSCString(SCName.System_YZQZMachineNumber).Value, MachineType = SC.GetSCString(SCName.System_YZQZMachineType).Value, ErrorMessage = erroMsg };
- records.Add(record);
- }
- com.SaveMachineErrorRecord(records);
- }
- });
- }
- private bool fReset(object[] objs)
- {
-
- //IsAlarm = false;
- if (fsm.State == (int)PMState.Error)
- return true;
- return false;
- }
- public void ToggleChamberStatus()
- {
- string reason = string.Empty;
- }
- public void Default()
- {
- }
- public void AlarmEvent()
- {
-
- }
- #region Vent
- private bool fStartVent(object[] objs)
- {
- Result ret = _ventRountine.Start();
- if (ret == Result.DONE)
- {
- return false;
- }
- else if (ret == Result.FAIL)
- {
- return false; //do noting
- }
- return true;
- }
- private bool fVent(object[] objs)
- {
- Result ret = _ventRountine.Monitor();
- if (ret == Result.DONE)
- return true;
- else if (ret == Result.FAIL)
- {
- //do nothing
- return true;
- }
- return false; ;
- }
- private bool fAbortVent(object[] objs)
- {
- _ventRountine.Abort();
- return true;
- }
- private bool fVentToPumping(object[] objs)
- {
- if (_ventRountine.Abort() != Result.DONE)
- {
- PostMsg(MSG.Error);
- return true;
- }
- fStartPumpDown(null);
- return true;
- }
- #endregion
-
- #region Pumping
- private bool fStartPumpDown(object[] objs)
- {
- _pumpStartTime = DateTime.Now;
- Result ret = _pumpRoutine.Start();
- if (ret == Result.DONE)
- {
- return false;
- }
- else if (ret == Result.FAIL || ret == Result.TIMEOUT)
- {
- return false; //do noting
- }
- return true;
- }
- private bool fPumpDown(object[] objs)
- {
- Result ret = _pumpRoutine.Monitor();
- if (ret == Result.DONE)
- return true;
- else if (ret == Result.FAIL || ret == Result.TIMEOUT)
- {
- //do nothing
- return true;
- }
- return false; ;
- }
- private bool fAbortPumping(object[] objs)
- {
- _pumpRoutine.Abort();
- return true;
- }
- private bool fPumpingToVent(object[] objs)
- {
- if (_pumpRoutine.Abort() != Result.DONE)
- {
- PostMsg(MSG.Error);
- return true;
- }
- fStartVent(null);
- return true;
- }
- #endregion
- #region Stop Pump
- private bool fStartStopPump(object[] objs)
- {
- Result ret = _stopPumpRoutine.Start(objs);
- if (ret == Result.DONE)
- {
- return false;
- }
- else if (ret == Result.FAIL || ret == Result.TIMEOUT)
- {
- return false; //do noting
- }
- return true;
- }
- private bool fStopPump(object[] objs)
- {
- Result ret = _stopPumpRoutine.Monitor();
- if (ret == Result.DONE)
- return true;
- else if (ret == Result.FAIL || ret == Result.TIMEOUT)
- {
- //do nothing
- return true;
- }
- return false;
- ;
- }
- private bool fAbortStopPump(object[] objs)
- {
- _stopPumpRoutine.Abort();
- return true;
- }
- #endregion
- #region Gas Flow
- private bool fStartGasFlow(object[] objs)
- {
- Result ret = _gasFlowRoutine.Start(objs);
- if (ret == Result.DONE)
- {
- return false;
- }
- else if (ret == Result.FAIL || ret == Result.TIMEOUT)
- {
- return false; //do noting
- }
- return true;
- }
- private bool fGasFlow(object[] objs)
- {
- Result ret = _gasFlowRoutine.Monitor();
- if (ret == Result.DONE)
- return true;
- else if (ret == Result.FAIL || ret == Result.TIMEOUT)
- {
- //do nothing
- return true;
- }
- return false;
- ;
- }
- private bool fAbortGasFlow(object[] objs)
- {
- _gasFlowRoutine.Abort();
- return true;
- }
- #endregion
- #region Stop Gas Flow
- private bool fStartStopGasFlow(object[] objs)
- {
- Result ret = _stopGasFlowRoutine.Start(objs);
- if (ret == Result.DONE)
- {
- return false;
- }
- else if (ret == Result.FAIL || ret == Result.TIMEOUT)
- {
- return false; //do noting
- }
- return true;
- }
- private bool fStopGasFlow(object[] objs)
- {
- Result ret = _stopGasFlowRoutine.Monitor();
- if (ret == Result.DONE)
- return true;
- else if (ret == Result.FAIL || ret == Result.TIMEOUT)
- {
- //do nothing
- return true;
- }
- return false;
- ;
- }
- private bool fAbortStopGasFlow(object[] objs)
- {
- _stopGasFlowRoutine.Abort();
- return true;
- }
- #endregion
- #region Rf Power On
- private bool fStartRfPower(object[] objs)
- {
- Result ret = _rfPowerRoutine.Start(objs);
- if (ret == Result.DONE)
- {
- return false;
- }
- else if (ret == Result.FAIL || ret == Result.TIMEOUT)
- {
- return false; //do noting
- }
- return true;
- }
- private bool fRfPower(object[] objs)
- {
- Result ret = _rfPowerRoutine.Monitor();
- if (ret == Result.DONE)
- return true;
- else if (ret == Result.FAIL || ret == Result.TIMEOUT)
- {
- //do nothing
- return true;
- }
- return false;
- ;
- }
- private bool fAbortRfPower(object[] objs)
- {
- _rfPowerRoutine.AbortRf();
- _rfPowerRoutine.Abort();
- return true;
- }
- #endregion
-
- #region CyclePurge
- private bool fStartCyclePurge(object[] objs)
- {
- Result ret = cyclePurgeRoutine.Start(objs);
- if (ret == Result.DONE)
- {
- return false;
- }
- else if (ret == Result.FAIL)
- {
- return false; //do noting
- }
- return true;
- }
- private bool fCyclePurge(object[] objs)
- {
- Result ret = cyclePurgeRoutine.Monitor();
- if (ret == Result.DONE)
- return true;
- else if (ret == Result.FAIL)
- {
- //do nothing
- return true;
- }
- return false; ;
- }
- private bool fAbortCyclePurge(object[] objs)
- {
- cyclePurgeRoutine.Abort();
- return true;
- }
- #endregion
- #region PreProcess
- private bool fProcessLoadRecipe(object[] objs)
- {
- _processStatus = Resources.PMEntity_fProcessLoadRecipe_LoadingRecipeFile;
- _recipeStartTime = DateTime.Now;
- Result ret = preProcessRoutine.LoadRecipe(objs);
- if (ret == Result.DONE)
- {
- //if (preProcessRoutine.HighVac)
- // PostMsg(MSG.HighVacTest);
- //else
- PostMsg(MSG.PreProcess);
- return true;
- }
- else if (ret == Result.FAIL)
- {
- _processStatus = Resources.PMEntity_fProcessLoadRecipe_LoadingRecipeFileFailed;
- return false; //do noting
- }
- return true;
- }
- private bool fStartPreProcess(object[] objs)
- {
- _pumpStartTime = DateTime.Now;
- _processStatus = Resources.PMEntity_fStartPreProcess_PreparingRunningRecipe;
- Result ret = preProcessRoutine.Start(objs);
- if (ret == Result.DONE)
- {
- return false;
- }
- else if (ret == Result.FAIL)
- {
- _processStatus = Resources.PMEntity_fStartPreProcess_PreparingRunningRecipeFailed;
- PostMsg(MSG.Error);
- return false; //do noting
- }
- EV.Notify(EventLotStart, new SerializableDictionary<string, string>()
- {
- {DVIDName.LotId, preProcessRoutine.CurrentLotName},
- {DVIDName.RecipeId, preProcessRoutine.CurrentRecipeBaseName },
- {DVIDName.JobId, preProcessRoutine.CurrentJobName},
- });
- StartJobRecord(true,preProcessRoutine.CurrentLotName, preProcessRoutine.CurrentRecipeBaseName,preProcessRoutine.CurrentJobName, preProcessRoutine.CurrentUserId);
- return true;
- }
- private async void StartJobRecord(bool startEnd, string lotId="", string receipeName = "",string operation="",string operatorId="" )
- {
- await Task.Run(() => {
-
- Fab fb = (Fab)Enum.Parse(typeof(Fab), SC.GetValue<int>(SCName.System_Company).ToString());
- if (fb == Fab.YZQZ)
- {
- FabAutoComm com = new YZQZFabAuto();
- if (startEnd)
- com.StartJobRecord(lotId, receipeName,operation,operatorId);
- else com.EndJobRecord();
- }
- });
- }
- private bool fPreProcess(object[] objs)
- {
- _processStatus = Resources.PMEntity_fPreProcess_RunRecipePumpingDown;
- Result ret = preProcessRoutine.Monitor();
- if (ret == Result.DONE)
- {
- PostMsg(MSG.Process,
- preProcessRoutine.CurrentRecipeBaseName,
- preProcessRoutine.CurrentRecipeRunningName,
- 0,
- preProcessRoutine.CurrentLotName,
- preProcessRoutine.CurrentRecipeContent,
- preProcessRoutine.CurrentRecipeHead,
- preProcessRoutine.CurrentRecipeStepList,
- preProcessRoutine.CurrentJobName);
- return true;
- }
- else if (ret == Result.FAIL)
- {
- _processStatus = Resources.PMEntity_fPreProcess_RunRecipePumpingDownFailed;
- PostMsg(MSG.Error);
- return true;
- }
- return false; ;
- }
- private bool fAbortPreProcess(object[] objs)
- {
- _processStatus = Resources.PMEntity_fAbortPreProcess_RunRecipePumpingDownAborted;
- preProcessRoutine.Abort();
- return true;
- }
- #endregion
- #region Process
- private bool fStartProcess(object[] objs)
- {
- _processStatus = Resources.PMEntity_fStartProcess_StartRunningRecipe;
- Result ret = processRoutine.Start(objs);
- if (ret == Result.DONE)
- {
- return true;
- }
- else if (ret == Result.FAIL)
- {
- _processStatus = Resources.PMEntity_fStartProcess_RunRecipeFailed;
- PostMsg(MSG.Error);
- return true; //do noting
- }
- return true;
- }
- private bool fProcess(object[] objs)
- {
- _processStatus = Resources.PMEntity_fProcess_RunningRecipe;
- Result ret = processRoutine.Monitor();
- {
- if (ret == Result.DONE)
- {
- PostMsg(MSG.PostProcess, processRoutine.CurrentRecipeRunningName, processRoutine.CurrentRecipeContent);
- return true;
- }
- else if (ret == Result.FAIL)
- {
- _processStatus = Resources.PMEntity_fStartProcess_RunRecipeFailed;
- PostMsg(MSG.Error);
- //MESErrorRecordAlarm(processRoutine.CurrentRecipeRunningName, MSG.Error);
- return true;
- }
- return false;
- }
- }
-
- private bool fAbortProcess(object[] objs)
- {
- _processStatus = Resources.PMEntity_fAbortProcess_RunningRecipeAborted;
- processRoutine.AbortRecipe();
- Result ret = postProcessRoutine.Start(new object[] { processRoutine.CurrentRecipeRunningName, processRoutine.CurrentRecipeContent });
- if (ret == Result.DONE)
- {
- return false;
- }
- else if (ret == Result.FAIL)
- {
- PostMsg(MSG.Error);
- _processStatus = Resources.PMEntity_fAbortProcess_RunRecipeAborted;
- return false; //do noting
- }
- return true;
- }
- private bool fEnterProcess(object[] objs)
- {
- return true;
- }
- private bool fExitProcess(object[] objs)
- {
- processRoutine.Exit();
- return true;
- }
- private bool fExitPostProcess(object[] objs)
- {
- postProcessRoutine.Exit();
- EV.Notify(EventLotFinished, new SerializableDictionary<string, string>()
- {
- {DVIDName.LotId, preProcessRoutine.CurrentLotName},
- {DVIDName.JobId, preProcessRoutine.CurrentJobName},
- {DVIDName.RecipeId, preProcessRoutine.CurrentRecipeBaseName }
- });
- StartJobRecord(false);
- return true;
- }
-
- private bool fPauseProcess(object[] objs)
- {
- _processStatus = "run recipe paused";
- processRoutine.PauseRecipe();
- return false;
- }
-
- private bool fResumeRecipe(object[] objs)
- {
- _processStatus = "run recipe resumed";
- processRoutine.ResumeRecipe();
- return false;
- }
- private bool fSkipStep(object[] objs)
- {
- _processStatus = Resources.PMEntity_fSkipStep_RunRecipeSkipped;
- processRoutine.SkipCurrentRecipeStep();
- return false;
- }
- private bool fUpdateRecipe(object[] objs)
- {
- processRoutine.UpdateRecipe((string)objs[0]);
- return false;
- }
-
- #endregion
- #region PostProcess
- private bool fStartPostProcess(object[] objs)
- {
- _processStatus = Resources.PMEntity_fStartPostProcess_RunRecipePostProcess;
- Result ret = postProcessRoutine.Start(objs);
- if (ret == Result.DONE)
- {
- return false;
- }
- else if (ret == Result.FAIL)
- {
- PostMsg(MSG.Error);
- return false; //do noting
- }
- return true;
- }
- private bool fPostProcess(object[] objs)
- {
- _processStatus = Resources.PMEntity_fPostProcess_RunRecipeCyclePurge;
- Result ret = postProcessRoutine.Monitor();
-
- if (ret == Result.DONE)
- {
- _processStatus = Resources.PMEntity_fPostProcess_RecipeCompleted;
- if ((int)SC.GetValue<double>(SCName.ProcessConfig_ProcessFinishedReminderFlag) != 0)
- {
- processRoutine.PopProcessEndDialog();
- }
- return true;
- }
- else if (ret == Result.FAIL)
- {
- _processStatus = Resources.PMEntity_fPostProcess_RunRecipeCyclePurgeError;
- PostMsg(MSG.Error);
- return true;
- }
-
- return false;
- }
- private bool fAbortPostProcess(object[] objs)
- {
- _processStatus = Resources.PMEntity_fAbortPostProcess_RecipeAborted;
- postProcessRoutine.Abort();
- return true;
- }
- #endregion
- #region Leak Check
- private bool fStartLeakCheck(object[] objs)
- {
- _leakCheckStartTime = DateTime.Now;
- Result ret = _leakCheckRoutine.Start(objs);
- if (ret == Result.DONE)
- {
- return false;
- }
- else if (ret == Result.FAIL || ret == Result.TIMEOUT)
- {
- return false; //do noting
- }
- return true;
- }
- private bool fLeakCheck(object[] objs)
- {
- Result ret = _leakCheckRoutine.Monitor();
- if (ret == Result.DONE)
- return true;
- else if (ret == Result.FAIL || ret == Result.TIMEOUT)
- {
- PostMsg(MSG.Error);
- EV.PostMessage(ModuleNameString.System, EventEnum.GeneralInfo, "Leak check stopped due to error");
- return true;
- }
- return false;
- ;
- }
- private bool fAbortLeakCheck(object[] objs)
- {
- _leakCheckRoutine.AbortLeakCheck();
- return true;
- }
- #endregion
- }
- }
|