using Aitex.Core.Common; using Aitex.Core.RT.Device; using Aitex.Core.RT.Device.Unit; using Aitex.Core.RT.Event; using Aitex.Core.RT.Fsm; using Aitex.Core.RT.SCCore; using Aitex.Core.Util; using Aitex.Sorter.Common; using athosRT.Devices; using athosRT.FSM; using athosRT.Modules.EFEMs; using athosRT.Modules.EFEMs.Routine; using athosRT.Modules.EFEMs.Tasks; using athosRT.Modules.LPs; using athosRT.Modules.Robot; using athosRT.tool; using MECF.Framework.Common.Equipment; using MECF.Framework.Common.SubstrateTrackings; using System; using System.Collections.Generic; using System.Diagnostics; using System.Linq; using System.Text.RegularExpressions; using OP = Common.OP.OP; using DATA = Common.DataCenter.DATA; using EV = athosRT.tool.EV; using MECF.Framework.RT.EquipmentLibrary.HardwareUnits.LoadPorts.LoadPortBase; using MECF.Framework.RT.EquipmentLibrary.HardwareUnits.Robots.RobotBase; using athosRT.Devices.PA; using athosRT.Modules.FLP; using RtState = athosCore.RtState; namespace athosRT.Modules { public class RouteManager1 : Entity, IModuleEntity { private InitRoutine initRoutine = null; private SetSpeedRoutine setspeedRoutine = null; private WaferMappingRoutine _waferMapRoutine; private LoadFoupRoutine _loadFoupRoutine; private PickRoutine _pickRoutine; private PickExtendRoutine _pickExtendRoutine; private PlaceRoutine _placeRoutine; private PlaceExtendRoutine _placeExtendRoutine; private SwapRoutine _swapRoutine; private AlignRoutine _alignRoutine; private StaticTransfer _staticTransfer; private AutoCycle _cycle; //记录任务运行状态的 private Dictionary _taskState = new Dictionary(); public RState GetTaskState(string task) => _taskState.ContainsKey(task) ? _taskState[task] : RState.End; private static LoadPortEntity _lp1 = null; private static LoadPortEntity _lp2 = null; private static LoadPortEntity _lp3 = null; private static LoadPortEntity _lp4 = null; private static LoadPortEntity _lp5 = null; private static LoadPortEntity _lp6 = null; private static LoadPortEntity _lp7 = null; private static LoadPortEntity _lp8 = null; private static LoadPortEntity _lp9 = null; private static LoadPortEntity _lp10 = null; private FlipperEntity _flipper = null; private RobotBaseDevice _robot = null; public int BufferNum { get; set; } public bool IsLP1Installed { get; set; } public bool IsLP2Installed { get; set; } public bool IsLP3Installed { get; set; } public bool IsBuffer1Installed { get; set; } public bool IsBuffer2Installed { get; set; } public bool IsAligner1Installed { get; set; } public bool IsLL1Installed { get; set; } public bool IsLL2Installed { get; set; } public bool IsFlipper1Installed { get; set; } public RobotBaseDevice Robot; public WaferInfo[] LP1WaferInfo { get { return WaferManager.Instance.GetWafers(ModuleName.LP1); } } private LoadPortEntity[] _loadportEntities; private int LoadPortQuantity = Singleton.Instance.GetValue(nameof(LoadPortQuantity)).GetValueOrDefault(); public bool IsInit => fsm.State == (int)RtState.Init; public bool IsIdle => fsm.State == (int)RtState.Idle; public bool IsError => fsm.State == (int)RtState.Error; public bool IsMaintenanceMode => fsm.State == (int)RtState.Maintenance; public bool IsFFUOk { get; set; }// public bool IsCycle => fsm.State == (int)RtState.Cycle; public bool Initializing => fsm.State == (int)RtState.Initializing; public bool IsRunning => !IsIdle && !IsInit && !IsError && !IsMaintenanceMode; public bool IsBusy => !IsInit && !IsError && !IsIdle; public string GetFsmState => fsm.State.ToString(); public bool IsEMSStop { get; set; }// public bool IsOnline { get; set; }// public bool Check(int msg, out string reason, params object[] args) { reason = ""; return true; } public string EFemNum => SC.GetStringValue("System.EFEMNUM"); public string Name; public RouteManager1() { Name = "RT"; //基于xml文件建立设备 //设备初始化 device+robot InitDevice(); //routine初始化 RoutineInit(); //wafermanager初始化 //fsm初始化 fsm = new StateMachine(Name, (int)RtState.Init, 50); //时序改变 BuildTransitionTable(); SubscribeList(); SetInstalledModules(); Running = true; //PostMsg(MSG.Debug); } public void SubscribeList() { OP.Subscribe($"{ModuleName.EFEM}.{MSG.HOME}", (cmd, args) => { PostMsg(MSG.HOME); return true; }); OP.Subscribe($"{ModuleName.EFEM}.{MSG.ERROR}", (cmd, args) => { PostMsg(MSG.ERROR); return true; }); OP.Subscribe($"{ModuleName.EFEM}.{MSG.ABORT}", (cmd, args) => { PostMsg(MSG.ABORT); return true; }); OP.Subscribe($"{ModuleName.EFEM}.{MSG.LOAD}", (cmd, args) => { PostMsg(MSG.LOAD); return true; }); OP.Subscribe($"{ModuleName.EFEM}.{MSG.ReadAndLoad}", (cmd, args) => { PostMsg(MSG.ReadAndLoad); return true; }); OP.Subscribe($"{ModuleName.EFEM}.{MSG.UNLOAD}", (cmd, args) => { PostMsg(MSG.UNLOAD); return true; }); OP.Subscribe($"{ModuleName.EFEM}.{MSG.ReadID}", (cmd, args) => { PostMsg(MSG.ReadID); return true; }); OP.Subscribe($"{ModuleName.EFEM}.{MSG.WriteID}", (cmd, args) => { PostMsg(MSG.WriteID); return true; }); OP.Subscribe($"{ModuleName.EFEM}.{MSG.SetSpeed}", (cmd, args) => { PostMsg(MSG.SetSpeed); return true; }); OP.Subscribe($"{ModuleName.EFEM}.{MSG.MapWafer}", (cmd, args) => { PostMsg(MSG.MapWafer); return true; }); OP.Subscribe($"{ModuleName.EFEM}.{MSG.ChangeCassette}", (cmd, args) => { PostMsg(MSG.ChangeCassette); return true; }); OP.Subscribe($"{ModuleName.EFEM}.{MSG.MoveWafer}", (cmd, args) => { PostMsg(MSG.MoveWafer, args); return true; }); OP.Subscribe($"{ModuleName.EFEM}.{MSG.ReturnWafer}", (cmd, args) => { PostMsg(MSG.ReturnWafer); return true; }); OP.Subscribe($"{ModuleName.EFEM}.{MSG.StartCycle}", (cmd, args) => { PostMsg(MSG.StartCycle, args); return true; }); OP.Subscribe($"{ModuleName.EFEM}.{MSG.Stop}", (cmd, args) => { PostMsg(MSG.Stop); return true; }); OP.Subscribe($"{ModuleName.EFEM}.{MSG.RobotActionDone}", (cmd, args) => { PostMsg(MSG.RobotActionDone); return true; }); OP.Subscribe($"{ModuleName.EFEM}.{MSG.Pick}", (cmd, args) => { PostMsg(MSG.Pick, args); return true; }); OP.Subscribe($"{ModuleName.EFEM}.{MSG.Place}", (cmd, args) => { PostMsg(MSG.Place, args); return true; }); OP.Subscribe($"{ModuleName.EFEM}.{MSG.Swap}", (cmd, args) => { PostMsg(MSG.Swap, args); return true; }); OP.Subscribe($"{ModuleName.EFEM}.{MSG.MPNTPick}", (cmd, args) => { PostMsg(MSG.MPNTPick); return true; }); OP.Subscribe($"{ModuleName.EFEM}.{MSG.MPNTPlace}", (cmd, args) => { PostMsg(MSG.MPNTPlace); return true; }); OP.Subscribe($"{ModuleName.EFEM}.{MSG.Align}", (cmd, args) => { PostMsg(MSG.Align); return true; }); OP.Subscribe("CreateWafer", (cmd, args) => { Trace.WriteLine("开始创建Wafer"); ModuleName module = (ModuleName)args[0]; int slot = (int)args[1]; WaferSize size = (WaferSize)args[2]; //如果是LP 从小于slot的槽开始加wafer if (module == ModuleName.LP1 || module == ModuleName.LP2) { int _SlotNumber = slot; //给loadport的所有slot加上wafer for (int i = 0; i < _SlotNumber; i++) { //这里创建 WaferManager.Instance.CreateWafer(module, i, WaferStatus.Normal, size); } } else { Trace.WriteLine($"{module}"); //其他设备直接加 WaferManager.Instance.CreateWafer(module, slot, WaferStatus.Normal, size); } return true; }); OP.Subscribe("CreateLPSingleWafer", (cmd, args) => { Trace.WriteLine("开始创建LP的单片Wafer"); ModuleName module = (ModuleName)args[0]; int slot = (int)args[1]; WaferSize size = (WaferSize)args[2]; WaferManager.Instance.CreateWafer(module, slot, WaferStatus.Normal, size); return true; }); OP.Subscribe("CreatebufferSingleWafer", (cmd, args) => { Trace.WriteLine("开始创建buffer的单片Wafer"); ModuleName module = (ModuleName)args[0]; int slot = (int)args[1]; WaferSize size = (WaferSize)args[2]; WaferManager.Instance.CreateWafer(module, slot, WaferStatus.Normal, size); return true; }); OP.Subscribe("DeleteWafer", (cmd, args) => { Trace.WriteLine("开始删除Wafer"); ModuleName module = (ModuleName)args[0]; int slot = (int)args[1]; WaferSize size = (WaferSize)args[2]; //如果是LP 从小于slot的槽开始加wafer WaferManager.Instance.DeleteWafer(module, slot, 1); return true; }); OP.Subscribe("MoveWafer", (cmd,args) => { ModuleName source = ModuleHelper.Converter(args[0].ToString()); int source_slot = Convert.ToInt16(args[1].ToString()); ModuleName destation = ModuleHelper.Converter(args[2].ToString()); int des_slot = Convert.ToInt16(args[3].ToString()); WaferManager.Instance.WaferMoved(source,source_slot, destation, des_slot); return true; }); OP.Subscribe("ClearLogList", (cmd, args) => LogObject.ClearLogList()); WaferManager.Instance.DeleteWafer(ModuleName.LL1, 0, 1); //LP12、Aligner12、CoolingBuffer12、LL12 DATA.Subscribe($"{ModuleName.LP1}.WaferInfos", () => WaferManager.Instance.GetWafers(ModuleName.LP1)); DATA.Subscribe($"{ModuleName.LP2}.WaferInfos", () => WaferManager.Instance.GetWafers(ModuleName.LP2)); DATA.Subscribe($"{ModuleName.LL1}.WaferInfos", () => WaferManager.Instance.GetWafers(ModuleName.LL1)); DATA.Subscribe($"{ModuleName.LL2}.WaferInfos", () => WaferManager.Instance.GetWafers(ModuleName.LL2)); DATA.Subscribe($"{ModuleName.Buffer}.WaferInfos", () => WaferManager.Instance.GetWafers(ModuleName.Buffer)); DATA.Subscribe($"{ModuleName.Aligner1}.WaferInfos", () => WaferManager.Instance.GetWafers(ModuleName.Aligner1)); DATA.Subscribe($"{ModuleName.Aligner2}.WaferInfos", () => WaferManager.Instance.CheckHasWafer(ModuleName.Aligner2, 0)); DATA.Subscribe($"{ModuleName.CoolingBuffer1}.WaferInfos", () => WaferManager.Instance.CheckHasWafer(ModuleName.CoolingBuffer1, 0)); DATA.Subscribe($"{ModuleName.CoolingBuffer2}.WaferInfos", () => WaferManager.Instance.CheckHasWafer(ModuleName.CoolingBuffer2, 0)); DATA.Subscribe($"{ModuleName.TurnOverStation}.WaferInfos", () => WaferManager.Instance.GetWafers(ModuleName.TurnOverStation)); DATA.Subscribe($"All.WaferInfos", () => WaferManager.Instance.AllLocationWafers); DATA.Subscribe($"{ModuleName.Robot}.{Hand.Blade1}.WaferInfos", () => !CheckSensorNoWafer(ModuleName.Robot, 0)); DATA.Subscribe($"{ModuleName.Robot}.{Hand.Blade2}.WaferInfos", () => !CheckSensorNoWafer(ModuleName.Robot, 1)); DATA.Subscribe($"{ModuleName.Robot}.WaferInfos", () => WaferManager.Instance.GetWafers(ModuleName.Robot)); IoCoolingBuffer CoolingBuffer1 = DEVICE.GetDevice("CoolingBuffer1"); IoCoolingBuffer CoolingBuffer2 = DEVICE.GetDevice("CoolingBuffer2"); PreAligner Aligner1 = DEVICE.GetDevice("Aligner1"); PreAligner Aligner2 = DEVICE.GetDevice("Aligner2"); DATA.Subscribe($"{ModuleName.LP1}.Status", () => { return IsLP1Installed ? DEVICE.GetDevice("LP1").CurrentState.ToString() : ""; }); DATA.Subscribe($"{ModuleName.LP2}.Status", () => { return IsLP2Installed ? DEVICE.GetDevice("LP2").CurrentState.ToString() : ""; }); DATA.Subscribe($"{ModuleName.Aligner1}.Status", () => Aligner1?.Status.ToString()); DATA.Subscribe($"{ModuleName.Aligner2}.Status", () => Aligner2?.Status.ToString()); DATA.Subscribe($"{ModuleName.CoolingBuffer1}.Status", () => CoolingBuffer1?.FeedbackLift.ToString()); DATA.Subscribe($"{ModuleName.CoolingBuffer2}.Status", () => CoolingBuffer2?.FeedbackLift.ToString()); DATA.Subscribe($"{ModuleName.Robot}.Status", () => DEVICE.GetDevice("Robot").RobotState.ToString()); DATA.Subscribe($"{ModuleName.CoolingBuffer1}.SetPoint4Inch", () => CoolingBuffer1?.SetPoint4Inch.ToString()); DATA.Subscribe($"{ModuleName.CoolingBuffer1}.SetPoint3Inch", () => CoolingBuffer1?.SetPoint3Inch.ToString()); DATA.Subscribe($"{ModuleName.CoolingBuffer1}.Feedback4Inch", () => CoolingBuffer1?.Feedback4Inch.ToString()); DATA.Subscribe($"{ModuleName.CoolingBuffer1}.Feedback3Inch", () => CoolingBuffer1?.Feedback3Inch.ToString()); DATA.Subscribe($"{ModuleName.CoolingBuffer1}.SetPointLift ", () => CoolingBuffer1?.SetPointLift.ToString()); DATA.Subscribe($"{ModuleName.CoolingBuffer2}.SetPoint4Inch", () => CoolingBuffer2?.SetPoint4Inch.ToString()); DATA.Subscribe($"{ModuleName.CoolingBuffer2}.SetPoint3Inch", () => CoolingBuffer2?.SetPoint3Inch.ToString()); DATA.Subscribe($"{ModuleName.CoolingBuffer2}.Feedback4Inch", () => CoolingBuffer2?.Feedback4Inch.ToString()); DATA.Subscribe($"{ModuleName.CoolingBuffer2}.Feedback3Inch", () => CoolingBuffer2?.Feedback3Inch.ToString()); DATA.Subscribe($"{ModuleName.CoolingBuffer2}.SetPointLift ", () => CoolingBuffer2?.SetPointLift.ToString()); DATA.Subscribe($"{ModuleName.Aligner1}.SetPoint4Inch", () => Aligner1?.SetPoint4Inch.ToString()); DATA.Subscribe($"{ModuleName.Aligner1}.SetPoint3Inch", () => Aligner1?.SetPoint3Inch.ToString()); DATA.Subscribe($"{ModuleName.Aligner1}.Feedback4Inch", () => Aligner1?.Feedback4Inch.ToString()); DATA.Subscribe($"{ModuleName.Aligner1}.Feedback3Inch", () => Aligner1?.Feedback3Inch.ToString()); DATA.Subscribe($"{ModuleName.Aligner1}.SetPointLift ", () => Aligner1?.SetPointLift.ToString()); DATA.Subscribe($"{ModuleName.Aligner2}.SetPoint4Inch", () => Aligner2?.SetPoint4Inch.ToString()); DATA.Subscribe($"{ModuleName.Aligner2}.SetPoint3Inch", () => Aligner2?.SetPoint3Inch.ToString()); DATA.Subscribe($"{ModuleName.Aligner2}.Feedback4Inch", () => Aligner2?.Feedback4Inch.ToString()); DATA.Subscribe($"{ModuleName.Aligner2}.Feedback3Inch", () => Aligner2?.Feedback3Inch.ToString()); DATA.Subscribe($"{ModuleName.Aligner2}.SetPointLift ", () => Aligner2?.SetPointLift.ToString()); DATA.Subscribe($"{ModuleName.System}.Status", () => ((RtState)fsm.State).ToString()); DATA.Subscribe($"{ModuleName.System}.IsAlarm", () => IsError); DATA.Subscribe($"{ModuleName.System}.IsIdle", () => IsIdle); DATA.Subscribe($"{ModuleName.System}.IsRunning", () => IsRunning); DATA.Subscribe($"{ModuleName.System}.IsMaintenanceMode", () => IsMaintenanceMode); DATA.Subscribe($"{ModuleName.LP1}.IsInstalled", () => IsLP1Installed); DATA.Subscribe($"{ModuleName.LP2}.IsInstalled", () => IsLP2Installed); DATA.Subscribe($"{ModuleName.Buffer1}.IsInstalled", () => IsBuffer1Installed); DATA.Subscribe($"{ModuleName.Buffer2}.IsInstalled", () => IsBuffer2Installed); DATA.Subscribe($"{ModuleName.Aligner1}.IsInstalled", () => IsAligner1Installed); DATA.Subscribe($"{ModuleName.LL1}.IsInstalled", () => IsLL1Installed); DATA.Subscribe($"{ModuleName.LL2}.IsInstalled", () => IsLL2Installed); DATA.Subscribe($"{ModuleName.TurnOverStation}.IsInstalled", () => IsFlipper1Installed); DATA.Subscribe($"{ModuleName.Buffer}.BufferNum", () => BufferNum); } private void SetInstalledModules() { //LL(PM) int LoadLockQuantity = Singleton.Instance.GetValue(nameof(LoadLockQuantity)).GetValueOrDefault(); switch (LoadLockQuantity) { case 0: IsLL1Installed = false; IsLL2Installed = false; break; case 1: IsLL1Installed = true; IsLL2Installed = false; break; case 2: IsLL1Installed = true; IsLL2Installed = true; break; default: break; } //Buffer int BufferQuantity = Singleton.Instance.GetValue(nameof(BufferQuantity)).GetValueOrDefault(); switch (BufferQuantity) { case 0: IsBuffer1Installed = false; IsBuffer2Installed = false; break; case 1: IsBuffer1Installed = true; IsBuffer2Installed = false; break; case 2: IsBuffer1Installed = true; IsBuffer2Installed = true; break; default: break; } //LP int LoadPortQuantity = Singleton.Instance.GetValue(nameof(LoadPortQuantity)).GetValueOrDefault(); switch (LoadPortQuantity) { case 0: IsLP1Installed = false; IsLP2Installed = false; break; case 1: IsLP1Installed = true; IsLP2Installed = false; break; case 2: IsLP1Installed = true; IsLP2Installed = true; break; default: break; } //Aligner bool AlignerInstalled = Singleton.Instance.GetValue(nameof(AlignerInstalled)).GetValueOrDefault(); IsAligner1Installed = AlignerInstalled; //Flipper bool FlipperInstalled = Singleton.Instance.GetValue(nameof(FlipperInstalled)).GetValueOrDefault(); IsFlipper1Installed = FlipperInstalled; int BufferSlot = Singleton.Instance.GetValue(nameof(BufferSlot)).GetValueOrDefault(); BufferNum = BufferSlot; } private bool CheckSensorNoWafer(ModuleName chamber, int slot) { RobotBaseDevice robot = DEVICE.GetDevice("Robot"); if (SC.GetValue("System.IsSimulatorMode") || chamber != ModuleName.Robot) return Singleton.Instance.CheckNoWafer(chamber, slot); return slot == 0 ? !robot.IsWaferPresenceOnBlade1 : !robot.IsWaferPresenceOnBlade2; } public FlipperEntity GetFlipper() => _flipper; public RouteManager1 GetRT() { return this; } public void BuildTransitionTable() { //接收到MSG 任何状态直接执行 //AnyStateTransition(MSG.Debug,fdebug,RtState.Idle); AnyStateTransition(MSG.RESET, fStartReset, RtState.Idle); AnyStateTransition(MSG.ERROR, fError, RtState.Error); AnyStateTransition(MSG.SetMaintenanceMode, fSetMaintenanceMode, RtState.Maintenance); //脱出Maintance维护状态 Transition(RtState.Maintenance, MSG.SetManualMode, null, RtState.Idle); //Init squence 😀 //InitRoutine start 进Initializing 成功进Idle 错误进Error Transition(RtState.Init, MSG.HOME, fStartInit, RtState.Initializing); Transition(RtState.Idle, MSG.HOME, fStartInit, RtState.Initializing); Transition(RtState.Error, MSG.HOME, fStartInit, RtState.Initializing); Transition(RtState.Initializing, FSM_MSG.TIMER, (fInit), RtState.Idle); Transition(RtState.Initializing, MSG.ERROR, (fError), RtState.Error); Transition(RtState.Initializing, MSG.ABORT, null, RtState.Init); //Idle下 无需切换状态的MSG EnterExitTransition(RtState.Idle, fIdle, new FSM_MSG?(FSM_MSG.NONE), null); //mode Transition(RtState.Idle, MSG.SetAutoMode, fSetAutoMode, RtState.Idle); Transition(RtState.Idle, MSG.SetManualMode, fSetManualMode, RtState.Idle); //LP Transition(RtState.Idle, MSG.LOAD, fLPLoad, RtState.Idle); Transition(RtState.Idle, MSG.ReadAndLoad, fReadAndLoad, RtState.Idle); Transition(RtState.Idle, MSG.UNLOAD, fLPUnLoad, RtState.Idle); Transition(RtState.Idle, MSG.ReadID, fReadID, RtState.Idle); Transition(RtState.Idle, MSG.WriteID, fWriteID, RtState.Idle); //SetSpeed squence Transition(RtState.Idle, MSG.SetSpeed, fStartSetSpeed, RtState.SetSpeed); Transition(RtState.SetSpeed, FSM_MSG.TIMER, fSetSpeed, RtState.Idle); //MapWafer squence Transition(RtState.Init, MSG.MapWafer, fStartMapWafer, RtState.WaferMapping); Transition(RtState.Idle, MSG.MapWafer, fStartMapWafer, RtState.WaferMapping); Transition(RtState.WaferMapping, FSM_MSG.TIMER, fMapWafer, RtState.Idle); Transition(RtState.WaferMapping, MSG.ChangeCassette, fChangeCassette, RtState.Error); //Transfer squence Transition(RtState.Idle, MSG.MoveWafer, fStartTransfer, RtState.Transfer); Transition(RtState.Init, MSG.MoveWafer, fStartTransfer, RtState.Transfer); //EnterExitTransition(RtState.Transfer, null, new FSM_MSG?(FSM_MSG.NONE), fExitTransfer); Transition(RtState.Idle, MSG.ReturnWafer, fStartReturn, RtState.Transfer); Transition(RtState.Transfer, FSM_MSG.TIMER, fTransfer, RtState.Idle); Transition(RtState.Transfer, MSG.ABORT, fAbortTransfer, RtState.Idle); Transition(RtState.Transfer, MSG.ChangeCassette, fChangeCassette, RtState.Error); //Cycle Transition(RtState.Idle, MSG.StartCycle, fStartCycle, RtState.Cycle); //Transition(RtState.Init, MSG.StartCycle, fStartCycle, RtState.Cycle); EnterExitTransition(RtState.Cycle, fEnterCycle, new FSM_MSG?(FSM_MSG.NONE), fExitCycle); Transition(RtState.Cycle, FSM_MSG.TIMER, fCycle, RtState.Idle); Transition(RtState.Cycle, MSG.Stop, fCycleStop, RtState.Cycle); Transition(RtState.Cycle, MSG.ABORT, fAbortCycle, RtState.Idle); Transition(RtState.Cycle, MSG.ChangeCassette, fChangeCassette, RtState.Error); Transition(RtState.Cycle, MSG.RobotActionDone, fCycle, RtState.Cycle); //Pick squence Transition(RtState.Idle, MSG.Pick, fStartPick, RtState.Picking); Transition(RtState.Picking, FSM_MSG.TIMER, fPick, RtState.Idle); Transition(RtState.Picking, MSG.ABORT, fAbort, RtState.Idle); Transition(RtState.Picking, MSG.ChangeCassette, fChangeCassette, RtState.Error); //Place squence Transition(RtState.Idle, MSG.Place, fStartPlace, RtState.Placing); Transition(RtState.Placing, FSM_MSG.TIMER, fPlace, RtState.Idle); Transition(RtState.Picking, MSG.ABORT, fAbort, RtState.Idle); Transition(RtState.Picking, MSG.ChangeCassette, fChangeCassette, RtState.Error); //Swap squence Transition(RtState.Idle, MSG.Swap, fStartSwap, RtState.Swaping); Transition(RtState.Swaping, FSM_MSG.TIMER, fSwap, RtState.Idle); Transition(RtState.Swaping, MSG.ABORT, fAbort, RtState.Idle); Transition(RtState.Swaping, MSG.ChangeCassette, fChangeCassette, RtState.Error); //PickPM squence Transition(RtState.Idle, MSG.MPNTPick, fStartMPNTPick, RtState.PickingPM); Transition(RtState.PickingPM, FSM_MSG.TIMER, fMPNTPick, RtState.Idle); Transition(RtState.PickingPM, MSG.ABORT, fAbort, RtState.Idle); //PlacePM squence Transition(RtState.Idle, MSG.MPNTPlace, fStartMPNTPlace, RtState.PlacingPM); Transition(RtState.PlacingPM, FSM_MSG.TIMER, fMPNTPlace, RtState.Idle); Transition(RtState.PlacingPM, MSG.ABORT, fAbort, RtState.Idle); //PreAlign squence Transition(RtState.Idle, MSG.Align, fStartAlign, RtState.Align); Transition(RtState.Align, FSM_MSG.TIMER, fAlign, RtState.Idle); Transition(RtState.Align, MSG.ABORT, fAbort, RtState.Idle); } public bool CheckToPostMessage(int msg, params object[] args) { if (!fsm.FindTransition(fsm.State, msg)) { LogObject.Info(ModuleName.System.ToString(), $"System is in {(RtState)fsm.State} state,can not do {(MSG)msg}"); return false; } Running = true; fsm.PostMsg(msg, args); return true; } private bool fdebug(object[] param) { //debug 进入idle状态 用于测试 return true; } private bool fSetManualMode(object[] param) { return true; } private bool fSetAutoMode(object[] param) { throw new NotImplementedException(); } private bool fSetMaintenanceMode(object[] param) { return true ; } private bool fExitCycle(object[] param) { return true; } private bool fEnterCycle(object[] param) { return true; } private bool fAbortCycle(object[] param) { _cycle.Abort(); return true; } private bool fCycleStop(object[] param) { throw new NotImplementedException(); } private bool fCycle(object[] param) { try { RState result = _cycle.Monitor(); if (result == RState.Failed || result == RState.Timeout) { LogObject.Error("Cycle", "失败"); PostMsg(MSG.ERROR); return false; } return result == RState.End; } catch (Exception ex) { Trace.WriteLine("抛出错误:" + ex); return true; } } private bool fStartCycle(object[] param) { //ModuleName.TurnOverStation if (param.Length > 0) { string[] mods_raw = param[2].ToString().Split('|'); LogObject.Info("Cycle",$"经过module:{mods_raw}"); List mods = new List(); ; mods_raw.ToList().ForEach(mod=> { if (!string.IsNullOrEmpty(mod)) { LogObject.Info("Cycle", $"经过module:{mod}"); mods.Add(ModuleHelper.Converter(mod)); } }); return _cycle.Start(param[0].ToString(), param[1].ToString(), mods) == RState.Running; } else { return false; } } private bool fExitTransfer(object[] param) { _staticTransfer.Clear(); _taskState.Remove("MoveWafer"); return true; } private bool fAbortTransfer(object[] param) { LogObject.Info(Name, "transfer中断"); return true; } private bool fStartReturn(object[] param) { _staticTransfer.Clear(); _taskState.Remove("MoveWafer"); if (_staticTransfer.Return(param)) { LogObject.Info(Name, "Return开始"); return true; } else { LogObject.Error(Name, "Return无法开始"); return false; } } private bool fTransfer(object[] param) { if (_staticTransfer.Monitor(param)) { LogObject.Info(Name, "Monitor执行完毕"); return true; } else { //LogObject.Error(Name, "Monitor执行失败"); return false; } } private bool fStartTransfer(object[] param) { _staticTransfer.Clear(); _taskState.Remove("MoveWafer"); Running = true; if (_staticTransfer.Start(param)) { LogObject.Info(Name, "transfer开始"); return true; } else { LogObject.Error(Name, "transfer无法开始"); return false; } } // 多个部分都有涉及 注意case和goto的方向 private bool fChangeCassette(object[] param) { string str1 = param[0].ToString(); switch (fsm.State) { case (int)RtState.Transfer: //调整transfer的内容 return true; case (int)RtState.Cycle: //调整Cycle的内容 return true; case (int)RtState.WaferMapping: if (str1 == _waferMapRoutine.Source.ToString()) { return true; } goto default; case (int)RtState.Picking: if (str1 == _pickRoutine.Source.ToString()) break; goto default; case (int)RtState.Placing: if (str1 == _placeRoutine.Station.ToString()) break; goto default; default: return false; } Robot.Stop(); return true; } /// /// param参数说明 [0]设备名 [1]旋转角度 /// /// /// private bool fStartAlign(object[] param) { RState result = _alignRoutine.Start(param); if (result == RState.Running) { LogObject.Info(Name, "开始 Align"); return true; } else { LogObject.Error(Name, "无法开始 Align"); return false; } } private bool fAlign(object[] param) { RState result = _alignRoutine.Monitor(); if (result == RState.Failed || result == RState.Timeout) { LogObject.Error(Name, "Align 执行失败 置错误"); PostMsg(MSG.ERROR); return false; } return result == RState.End; } private bool fMPNTPlace(object[] param) { RState result = _placeExtendRoutine.Monitor(); if (result == RState.Failed || result == RState.Timeout) { LogObject.Error(Name, "MPNTPlace 执行失败 置错误"); PostMsg(MSG.ERROR); return false; } return result == RState.End; } private bool fStartMPNTPlace(object[] param) { if (param.Length != 4) { LogObject.Error(Name, "参数数量不符要求 MPNTPick无法执行"); return false; } _placeExtendRoutine.Station = ModuleHelper.Converter((string)param[0]); _placeExtendRoutine.Slot = (int)param[1]; _placeExtendRoutine.Blade = (Hand)param[2]; _placeExtendRoutine.TaskEnum = (MpntTaskEnum)param[3]; RState result = _placeExtendRoutine.Start(param); if (result == RState.Running) { LogObject.Info(Name, "开始 MPNTPlace"); return true; } else { LogObject.Error(Name, "无法开始 MPNTPlace"); return false; } } private bool fMPNTPick(object[] param) { RState result = _pickExtendRoutine.Monitor(); if (result == RState.Failed || result == RState.Timeout) { LogObject.Error(Name, "MPNTPick 执行失败 置错误"); PostMsg(MSG.ERROR); return false; } return result == RState.End; } private bool fStartMPNTPick(object[] param) { if (param.Length != 4) { LogObject.Error(Name, "参数数量不符要求 MPNTPick无法执行"); return false; } _pickExtendRoutine.Source = ModuleHelper.Converter((string)param[0]); _pickExtendRoutine.Slot = (int)param[1]; _pickExtendRoutine.Blade = (Hand)param[2]; _pickExtendRoutine.TaskEnum = (MpntTaskEnum)param[3]; RState result = _pickExtendRoutine.Start(param); if (result == RState.Running) { LogObject.Info(Name, "开始 MPNTPick"); return true; } else { LogObject.Error(Name, "无法开始 MPNTPick"); return false; } } private bool fPlace(object[] param) { RState result = _placeRoutine.Monitor(); if (result == RState.Failed || result == RState.Timeout) { LogObject.Error(Name, "place 执行失败 置错误"); PostMsg(MSG.ERROR); return false; } return result == RState.End; } private bool fStartPlace(object[] param) { if (param.Length != 3) { LogObject.Error(Name, "参数数量不符要求 Place无法执行"); return false; } _placeRoutine.Station = ModuleHelper.Converter((string)param[0]); _placeRoutine.Slot = (int)param[1]; _placeRoutine.Blade = (Hand)Enum.Parse(typeof(Hand), (string)param[2]); RState result = _placeRoutine.Start(param); if (result == RState.Running) { LogObject.Info(Name, "开始 Place"); return true; } else { LogObject.Error(Name, "无法开始 Place"); return false; } } private bool fPick(object[] param) { RState result = _pickRoutine.Monitor(); if (result == RState.Failed || result == RState.Timeout) { LogObject.Error(Name, "pick 执行失败 置错误"); PostMsg(MSG.ERROR); return false; } return result == RState.End; } private bool fStartPick(object[] param) { if (param.Length != 3) { LogObject.Error(Name, "参数数量不符要求 Pick无法执行"); return false; } _pickRoutine.Source = ModuleHelper.Converter((string)param[0]); _pickRoutine.Slot = (int)param[1]; _pickRoutine.Blade = (Hand)Enum.Parse(typeof(Hand), (string)param[2]); RState result = _pickRoutine.Start(param); if (result == RState.Running) { LogObject.Info(Name, "开始 Pick"); return true; } else { LogObject.Error(Name, "无法开始 Pick"); return false; } } private bool fSwap(object[] param) { RState result = _swapRoutine.Monitor(); if (result == RState.Failed || result == RState.Timeout) { LogObject.Error(Name, "swap 执行失败 置错误"); PostMsg(MSG.ERROR); return false; } return result == RState.End; } private bool fStartSwap(object[] param) { if (param.Length != 3) { LogObject.Error(Name, "参数数量不符要求 Swap无法执行"); return false; } _swapRoutine.Source = ModuleHelper.Converter((string)param[0]); _swapRoutine.Slot = (int)param[1]; _swapRoutine.PlaceBlade = (Hand)Enum.Parse(typeof(Hand), (string)param[2]); RState result = _swapRoutine.Start(param); if (result == RState.Running) { LogObject.Info(Name, "开始 Swap"); return true; } else { LogObject.Error(Name, "无法开始 Swap"); return false; } } private bool fMapWafer(object[] param) { RState result = _waferMapRoutine.Monitor(); if (result == RState.Failed || result == RState.Timeout) { LogObject.Error(Name, "Wafer Map 执行失败 置错误"); PostMsg(MSG.ERROR); return false; } return result == RState.End; } private bool fStartMapWafer(object[] param) { RState result = _waferMapRoutine.Start(param); if (result == RState.Running) { LogObject.Info(Name, "开始 Wafer Map"); return true; } else { LogObject.Error(Name, "无法开始 Wafer Map"); return false; } } private bool fSetSpeed(object[] param) { RState result = setspeedRoutine.Monitor(); if (result == RState.Failed || result == RState.Timeout) { LogObject.Error(Name, "set speed 执行失败 置错误"); PostMsg(MSG.ERROR); return false; } return result == RState.End; } private bool fStartSetSpeed(object[] param) { RState result = setspeedRoutine.Start(); //setspeedRoutine.Speed = (int)param[0]; if (result == RState.Running) { LogObject.Info(Name, "开始进入 set speed "); return true; } else { LogObject.Error(Name, "无法开始 set speed"); return false; } } private bool fWriteID(object[] param) { LogObject.Info(Name, "LP WriteRFID 开始"); PostToLP((ModuleName)param[0], LoadPortEntity.MSG.WriteRFID); return true; } private bool fReadAndLoad(object[] param) { LogObject.Info(Name, "LP ReadAndLoad 开始"); PostToLP((ModuleName)param[0], LoadPortEntity.MSG.ReadAndLoad); return true; } private bool fReadID(object[] param) { LogObject.Info(Name, "LP fReadID 开始"); PostToLP((ModuleName)param[0], LoadPortEntity.MSG.ReadRFID); return true; } private bool fLPUnLoad(object[] param) { LogObject.Info(Name, "LP unLoad 开始"); PostToLP((ModuleName)param[0], LoadPortEntity.MSG.Unload); return true; } private bool fLPLoad(object[] param) { //debug LogObject.Info(Name, "LP Load 开始"); PostToLP((ModuleName)param[0], LoadPortEntity.MSG.Load); return true; } private bool fIdle(object[] param) { LogObject.Info(Name, "置为Idle 清空所有task"); _taskState.Clear(); return true; } private bool fStartReset(object[] objs) { LogObject.Info(Name, "开始重置"); if (fsm.State == 9) { LogObject.Info(Name, "FSM重置成功"); return true; } else { LogObject.Error(Name, "FSM重置失败"); return false; } } private bool fError(object[] param) { //切换到错误状态 for (int index = 0; index < _taskState.Count; index++) { //将所有任务置错误状态 _taskState[_taskState.ElementAt(index).Key] = RState.Failed; } return true; } private bool fInit(object[] param) { switch (initRoutine.Monitor()) { case RState.End: return true; case RState.Failed: return true; default: return false; } } private bool fStartInit(object[] param) { //开始初始化 部分内容 switch (initRoutine.Start()) { case RState.End: return false; case RState.Failed: return false; default: return true; } } private bool fAbort(object[] param) => true;//??? 别问 问就是反编译源码就是这么写的 /// /// 给LP发送消息 通过chamber的名称 获取LP1-10后的后缀数字 /// 在不越过LP数量的情况下 对LP 发送Post信息 /// /// /// /// /// private bool PostToLP(ModuleName chamber, LoadPortEntity.MSG msg, params object[] objs) { //获取是哪一个LP发送msg信息 int num = int.Parse(new Regex("[1-9]\\d*").Match(chamber.ToString()).ToString()); //在不越界的情况下 进行信息发送 if (num <= LoadPortQuantity) { LogObject.Info(Name, $"给{chamber}发送{msg}"); _loadportEntities[num - 1].PostMsg(msg, objs); } return true; } public LoadPortEntity GetLP(ModuleName chamber) { int num = int.Parse(new Regex("[1-9]\\d*").Match(chamber.ToString()).ToString()); return _loadportEntities[num - 1]; } public bool CheckAcked(int msg) => fsm.CheckExecuted(msg); public int Invoke(string function, params object[] args) { switch (function) { //case "Home": // CheckToPostMsg(MSG.HOME); // return (int)MSG.HOME; case "RESET": CheckToPostMsg(MSG.RESET); return (int)MSG.RESET; case "MPNTPlace": CheckToPostMsg(MSG.MPNTPlace, args[0], args[1], args[2], args[3]); return (int)MSG.MPNTPlace; case "MPNTPick": CheckToPostMsg(MSG.MPNTPick, args[0], args[1], args[2], args[3]); return (int)MSG.MPNTPick; case "Pick": CheckToPostMsg(MSG.Pick, args[0], args[1], args[2]); return (int)MSG.Pick; case "Place": CheckToPostMsg(MSG.Place, args[0], args[1], args[2]); return (int)MSG.Place; default: LogObject.Warning("TASK","Task下发的指令不在预期"); return -1; } } public void InitDevice() { _flipper = new FlipperEntity(ModuleName.TurnOverStation); _flipper.Initialize(); Robot = DEVICE.GetDevice("Robot");//连接做在初始化里面了 //RR751.InitializeRobot(); _lp1 = new LoadPortEntity(ModuleName.LP1.ToString(), Robot); _lp2 = new LoadPortEntity(ModuleName.LP2.ToString(), Robot); _lp3 = new LoadPortEntity(ModuleName.LP3.ToString(), Robot); _lp4 = new LoadPortEntity(ModuleName.LP4.ToString(), Robot); _lp5 = new LoadPortEntity(ModuleName.LP5.ToString(), Robot); _lp6 = new LoadPortEntity(ModuleName.LP6.ToString(), Robot); _lp7 = new LoadPortEntity(ModuleName.LP7.ToString(), Robot); _lp8 = new LoadPortEntity(ModuleName.LP8.ToString(), Robot); _lp9 = new LoadPortEntity(ModuleName.LP9.ToString(), Robot); _lp10 = new LoadPortEntity(ModuleName.LP10.ToString(), Robot); _loadportEntities = new LoadPortEntity[10] { _lp1, _lp2, _lp3, _lp4, _lp5, _lp6, _lp7, _lp8, _lp9, _lp10 }; Trace.WriteLine(LoadPortQuantity); for (int index = 0; index < LoadPortQuantity; ++index) _loadportEntities[index].Initialize(); Trace.WriteLine(EFemNum); string efemNum = EFemNum; if (!(efemNum == "001")) { if (efemNum == "002") { DeviceModel.SensorSMIF1PODOPEN.OnSignalChanged += new Action(SensorSMIF1PODOPEN_OnSignalChanged); DeviceModel.SensorSMIF2PODOPEN.OnSignalChanged += new Action(SensorSMIF2PODOPEN_OnSignalChanged); DeviceModel.SensorWaterLeakSW.OnSignalChanged += new Action(SensorWaterLeakSW_OnSignalChanged); DeviceModel.SensorGratingSensorIN1.OnSignalChanged += new Action(SensorGratingSensorIN1_OnSignalChanged); } else { DeviceModel.SensorPMASystemInterlock.OnSignalChanged += new Action(SensorPMASystemInterlock_OnSignalChanged); DeviceModel.SensorPMBSystemInterlock.OnSignalChanged += new Action(SensorPMBSystemInterlock_OnSignalChanged); DeviceModel.SensorRBNotExtendSIMF1.OnSignalChanged += new Action(SensorRBNotExtendSIMF1_OnSignalChanged); DeviceModel.SensorRBNotExtendSIMF2.OnSignalChanged += new Action(SensorRBNotExtendSIMF2_OnSignalChanged); DeviceModel.SensorSMIF1PODOPEN.OnSignalChanged += new Action(SensorSMIF1PODOPEN_OnSignalChanged); DeviceModel.SensorSMIF2PODOPEN.OnSignalChanged += new Action(SensorSMIF2PODOPEN_OnSignalChanged); DeviceModel.SensorWaterLeakSW.OnSignalChanged += new Action(SensorWaterLeakSW_OnSignalChanged); DeviceModel.SensorGratingSensorIN1.OnSignalChanged += new Action(SensorGratingSensorIN1_OnSignalChanged); } } else { DeviceModel.SensorPMASystemInterlock.OnSignalChanged += new Action(SensorPMASystemInterlock_OnSignalChanged); DeviceModel.SensorPMBSystemInterlock.OnSignalChanged += new Action(SensorPMBSystemInterlock_OnSignalChanged); DeviceModel.SensorRBNotExtendSIMF1.OnSignalChanged += new Action(SensorRBNotExtendSIMF1_OnSignalChanged); DeviceModel.SensorRBNotExtendSIMF2.OnSignalChanged += new Action(SensorRBNotExtendSIMF2_OnSignalChanged); DeviceModel.SensorSMIF1PODOPEN.OnSignalChanged += new Action(SensorSMIF1PODOPEN_OnSignalChanged); DeviceModel.SensorSMIF2PODOPEN.OnSignalChanged += new Action(SensorSMIF2PODOPEN_OnSignalChanged); DeviceModel.SensorWaterLeakSW.OnSignalChanged += new Action(SensorWaterLeakSW_OnSignalChanged); DeviceModel.SensorGratingSensorIN1.OnSignalChanged += new Action(SensorGratingSensorIN1_OnSignalChanged); } } public void RoutineInit() { setspeedRoutine = new SetSpeedRoutine(ModuleName.System); initRoutine = new InitRoutine(ModuleName.System); _waferMapRoutine = new WaferMappingRoutine(ModuleName.System); _loadFoupRoutine = new LoadFoupRoutine(ModuleName.LP1); _pickRoutine = new PickRoutine(ModuleName.System); _placeRoutine = new PlaceRoutine(ModuleName.System); _pickExtendRoutine = new PickExtendRoutine(ModuleName.System); _placeExtendRoutine = new PlaceExtendRoutine(ModuleName.System); _alignRoutine = new AlignRoutine(); _staticTransfer = new StaticTransfer(); _cycle = new AutoCycle(ModuleName.System); _swapRoutine = new SwapRoutine(ModuleName.System); } private void SensorRBNotExtendSIMF2_OnSignalChanged(IoSensor arg1, bool arg2) { string reason = ""; if (!arg2) { DeviceModel.TrigRBbusytoSIMF2.SetTrigger(true, out reason); LogObject.Error(Name, "SensorRBNotExtendSIMF2 signal change,set TrigRBbusytoSIMF2 signal on."); } else { DeviceModel.TrigRBbusytoSIMF2.SetTrigger(false, out reason); LogObject.Error(Name, "SensorRBNotExtendSIM2 signal change,set TrigRBbusytoSIMF2 signal off."); } } private void SensorRBNotExtendSIMF1_OnSignalChanged(IoSensor arg1, bool arg2) { string reason = ""; if (!arg2) { DeviceModel.TrigRBbusytoSIMF1.SetTrigger(true, out reason); LogObject.Error(Name, "SensorRBNotExtendSIMF1 signal change,set TrigRBbusytoSIMF1 signal on."); //LOG.Write("SensorRBNotExtendSIMF1 signal change,set TrigRBbusytoSIMF1 signal on.", file: "D:\\sorter\\trunk\\Efem\\Jet\\Jet_001_2P_Jet\\EfemRT\\Modules\\RouteManager.cs", member: nameof(SensorRBNotExtendSIMF1_OnSignalChanged), line: 311); } else { DeviceModel.TrigRBbusytoSIMF1.SetTrigger(false, out reason); LogObject.Error(Name, "SensorRBNotExtendSIMF1 signal change,set TrigRBbusytoSIMF1 signal off."); //LOG.Write("SensorRBNotExtendSIMF1 signal change,set TrigRBbusytoSIMF1 signal off.", file: "D:\\sorter\\trunk\\Efem\\Jet\\Jet_001_2P_Jet\\EfemRT\\Modules\\RouteManager.cs", member: nameof(SensorRBNotExtendSIMF1_OnSignalChanged), line: 316); } } private void SensorGratingSensorIN1_OnSignalChanged(IoSensor arg1, bool arg2) { string reason = ""; if (!arg2) { if (fsm.State != 5 && fsm.State != 4 && fsm.State != 22 && fsm.State != 21) return; DeviceModel.TrigPauseResumetoRobot.SetTrigger(true, out reason); } else DeviceModel.TrigPauseResumetoRobot.SetTrigger(false, out reason); } private void SensorWaterLeakSW_OnSignalChanged(IoSensor arg1, bool arg2) { string reason; if (!arg2) { if (fsm.State != 5 && fsm.State != 4 && fsm.State != 22 && fsm.State != 21) return; DeviceModel.TrigPauseResumetoRobot.SetTrigger(true, out reason); } else DeviceModel.TrigPauseResumetoRobot.SetTrigger(false, out reason); } private void SensorSMIF2PODOPEN_OnSignalChanged(IoSensor arg1, bool arg2) { string reason = ""; if (arg2) { DeviceModel.TrigSafetytoSMIF2.SetTrigger(true, out reason); LogObject.Error(Name, "SensorSMIF2PODOPEN signal change,set TrigSafetytoSMIF2 signal on."); //LOG.Write("SensorSMIF2PODOPEN signal change,set TrigSafetytoSMIF2 signal on.", file: "D:\\sorter\\trunk\\Efem\\Jet\\Jet_001_2P_Jet\\EfemRT\\Modules\\RouteManager.cs", member: nameof(SensorSMIF2PODOPEN_OnSignalChanged), line: 357); } else { DeviceModel.TrigSafetytoSMIF2.SetTrigger(false, out reason); LogObject.Error(Name, "SensorSMIF2PODOPEN signal change,set TrigSafetytoSMIF2 signal off."); //LOG.Write("SensorSMIF2PODOPEN signal change,set TrigSafetytoSMIF2 signal off.", file: "D:\\sorter\\trunk\\Efem\\Jet\\Jet_001_2P_Jet\\EfemRT\\Modules\\RouteManager.cs", member: nameof(SensorSMIF2PODOPEN_OnSignalChanged), line: 362); } } private void SensorSMIF1PODOPEN_OnSignalChanged(IoSensor arg1, bool arg2) { string reason = ""; if (arg2) { DeviceModel.TrigSafetytoSMIF1.SetTrigger(true, out reason); LogObject.Error(Name, "SensorSMIF1PODOPEN signal change,set TrigSafetytoSMIF1 signal on."); //LOG.Write("SensorSMIF1PODOPEN signal change,set TrigSafetytoSMIF1 signal on.", file: "D:\\sorter\\trunk\\Efem\\Jet\\Jet_001_2P_Jet\\EfemRT\\Modules\\RouteManager.cs", member: nameof(SensorSMIF1PODOPEN_OnSignalChanged), line: 371); } else { DeviceModel.TrigSafetytoSMIF1.SetTrigger(false, out reason); LogObject.Error(Name, "SensorSMIF1PODOPEN signal change,set TrigSafetytoSMIF1 signal off."); //LOG.Write("SensorSMIF1PODOPEN signal change,set TrigSafetytoSMIF1 signal off.", file: "D:\\sorter\\trunk\\Efem\\Jet\\Jet_001_2P_Jet\\EfemRT\\Modules\\RouteManager.cs", member: nameof(SensorSMIF1PODOPEN_OnSignalChanged), line: 376); } } private void SensorPMBSystemInterlock_OnSignalChanged(IoSensor arg1, bool arg2) { string reason = ""; if (arg2) { DeviceModel.TrigSafetytoPMB.SetTrigger(true, out reason); LogObject.Error("RT", "SensorPMBSystemInterlock signal change,set TrigSafetytoPMB signal on."); //LOG.Write("SensorPMBSystemInterlock signal change,set TrigSafetytoPMB signal on.", file: "D:\\sorter\\trunk\\Efem\\Jet\\Jet_001_2P_Jet\\EfemRT\\Modules\\RouteManager.cs", member: nameof(SensorPMBSystemInterlock_OnSignalChanged), line: 385); } else { DeviceModel.TrigSafetytoPMB.SetTrigger(false, out reason); LogObject.Error("RT", "SensorPMBSystemInterlock signal change,set TrigSafetytoPMA signal off."); } } public bool CheckToPostMsg(RouteManager1.MSG msg) { Trace.WriteLine($"收到信息{msg}"); if (!this.fsm.FindTransition(this.fsm.State, (int)msg)) { EV.PostMessage("System", EventEnum.DefaultWarning, (object)string.Format("{0} is in {1} state,can not do {2}", (object)this.Name, (object)(RtState)this.fsm.State, (object)msg)); return false; } this.PostMsg(msg); return true; } public bool CheckToPostMsg(MSG msg, object param1) { Trace.WriteLine($"收到信息{msg},包含参数{param1}"); if (!this.fsm.FindTransition(this.fsm.State, (int)msg)) { EV.PostMessage("System", EventEnum.DefaultWarning, (object)string.Format("{0} is in {1} state,can not do {2}", (object)this.Name, (object)(RtState)this.fsm.State, (object)msg)); return false; } this.PostMsg(msg, param1); return true; } public bool CheckToPostMsg(MSG msg, object param1, object param2) { Trace.WriteLine($"收到信息{msg},包含参数{param1}/{param2}"); if (!this.fsm.FindTransition(this.fsm.State, (int)msg)) { EV.PostMessage("System", EventEnum.DefaultWarning, (object)string.Format("{0} is in {1} state,can not do {2}", (object)this.Name, (object)(RtState)this.fsm.State, (object)msg)); return false; } this.PostMsg(msg, param1, param2); return true; } public bool CheckToPostMsg(MSG msg, object param1, object param2, object param3) { Trace.WriteLine($"收到信息{msg},包含参数{param1}/{param2}/{param3}"); if (!this.fsm.FindTransition(this.fsm.State, (int)msg)) { EV.PostMessage("System", EventEnum.DefaultWarning, (object)string.Format("{0} is in {1} state,can not do {2}", (object)this.Name, (object)(RtState)this.fsm.State, (object)msg)); return false; } this.PostMsg(msg, param1, param2, param3); return true; } public bool CheckToPostMsg( MSG msg, object param1, object param2, object param3, object param4) { Trace.WriteLine($"收到信息{msg},包含参数{param1}/{param2}/{param3}/{param4}"); if (!this.fsm.FindTransition(this.fsm.State, (int)msg)) { EV.PostMessage("System", EventEnum.DefaultWarning, (object)string.Format("{0} is in {1} state,can not do {2}", (object)this.Name, (object)(RtState)this.fsm.State, (object)msg)); return false; } this.PostMsg(msg, param1, param2, param3, param4); return true; } private void SensorPMASystemInterlock_OnSignalChanged(IoSensor arg1, bool arg2) { string reason = ""; if (arg2) { DeviceModel.TrigSafetytoPMA.SetTrigger(true, out reason); LogObject.Error(Name, "SensorPMASystemInterlock signal change,set TrigSafetytoPMB signal on."); } else { DeviceModel.TrigSafetytoPMA.SetTrigger(false, out reason); LogObject.Error(Name, "SensorPMASystemInterlock signal change,set TrigSafetytoPMB signal off."); } } public void MapBuffer() { List boolList1 = new List() { false, false, false, false, false }; int num1 = 0; foreach (bool flag in boolList1) { if (!flag && Singleton.Instance.CheckNoWafer(ModuleName.Buffer, num1)) Singleton.Instance.CreateWafer(ModuleName.Buffer, num1, WaferStatus.Normal); else if (flag && Singleton.Instance.CheckHasWafer(ModuleName.Buffer, num1)) Singleton.Instance.DeleteWafer(ModuleName.Buffer, num1); ++num1; } List boolList2 = new List() { DeviceModel.SensorRBlowerArmhavewafer.Value, DeviceModel.SensorRBupperArmhavewafer.Value }; int num2 = 0; foreach (bool flag in boolList2) { if (!flag && Singleton.Instance.CheckNoWafer(ModuleName.Robot, num2)) Singleton.Instance.CreateWafer(ModuleName.Robot, num2, WaferStatus.Normal); else if (flag && Singleton.Instance.CheckHasWafer(ModuleName.Robot, num2)) Singleton.Instance.DeleteWafer(ModuleName.Robot, num2); ++num2; } } private bool check(MoveType type, Hand blade, out string reason) { reason = string.Empty; if (type == MoveType.Move || blade != Hand.Both) return true; reason = string.Format("非法的参数。单片传盘时,不能指定Both blade"); return false; } private bool checkMove(out string reason, params object[] args) { MoveType type = (MoveType)args[0]; MoveOption option = (MoveOption)args[1]; Hand blade = (Hand)args[2]; ModuleName source1 = (ModuleName)args[3]; int slot1 = (int)args[4]; ModuleName dest1 = (ModuleName)args[5]; int dslot1 = (int)args[6]; ModuleName source2 = (ModuleName)args[3]; int slot2 = (int)args[4]; ModuleName dest2 = (ModuleName)args[5]; int dslot2 = (int)args[6]; if (type != 0) { source2 = (ModuleName)args[7]; slot2 = (int)args[8]; dest2 = (ModuleName)args[9]; dslot2 = (int)args[10]; } if (!this.check(type, blade, out reason)) { EV.PostWarningLog("System", "Can not move wafer, " + reason); return false; } if (!this.check(source1, slot1, dest1, dslot1, blade, option, out reason)) { EV.PostWarningLog("System", "Can not move wafer, " + reason); return false; } if (type == 0 || this.check(source2, slot2, dest2, dslot2, out reason)) return true; EV.PostWarningLog("System", "Can not move wafer, " + reason); return false; } public bool InvokeMoveWafer(string arg1, object[] args) { this.Running = false; string reason = ""; if (this.checkMove(out reason, args)) { MoveType moveType = (MoveType)args[0]; MoveOption moveOption = (MoveOption)args[1]; Hand hand = (Hand)args[2]; ModuleName moduleName1 = (ModuleName)args[3]; int num1 = (int)args[4]; ModuleName moduleName2 = (ModuleName)args[5]; int num2 = (int)args[6]; ModuleName moduleName3 = (ModuleName)args[3]; int num3 = (int)args[4]; ModuleName moduleName4 = (ModuleName)args[5]; int num4 = (int)args[6]; if (moveType != 0) { moduleName3 = (ModuleName)args[7]; num3 = (int)args[8]; moduleName4 = (ModuleName)args[9]; num4 = (int)args[10]; } this._taskState[arg1] = RState.Running; this.PostMsg(MSG.MoveWafer, (object)moveType, (object)moveOption, (object)hand, (object)moduleName1, (object)num1, (object)moduleName2, (object)num2, (object)moduleName3, (object)num3, (object)moduleName4, (object)num4); } else this._taskState[arg1] = RState.Failed; return true; } private bool checkFoup(ModuleName chamber, out string reason) { reason = string.Empty; if (!ModuleHelper.IsLoadPort(chamber) || DEVICE.GetDevice(chamber.ToString()).IsEnableTransferWafer(out reason)) return true; reason = string.Format("{0} isn't Ready, {1}", (object)chamber.ToString(), (object)reason); return false; } private bool check( ModuleName source, int slot, ModuleName dest, int dslot, out string reason) { reason = string.Empty; if (!this.checkFoup(source, out reason) || !this.checkFoup(dest, out reason)) return false; if (!Singleton.Instance.IsWaferSlotLocationValid(source, slot)) { reason = string.Format("非法的参数。{0}:{1:D2}", (object)source.ToString(), (object)slot); return false; } if (!Singleton.Instance.IsWaferSlotLocationValid(dest, dslot)) { reason = string.Format("非法的参数。{0}:{1:D2}", (object)dest.ToString(), (object)dslot); return false; } if (!Singleton.Instance.CheckWafer(source, slot, WaferStatus.Normal)) { reason = string.Format("源位置没有wafer。{0}:{1:D2}", (object)source.ToString(), (object)slot); return false; } if (Singleton.Instance.CheckWafer(dest, dslot, WaferStatus.Empty)) return true; reason = string.Format("目标位置有wafer。{0}:{1:D2}", (object)dest.ToString(), (object)dslot); return false; } private bool check( ModuleName source, int slot, ModuleName dest, int dslot, Hand blade, MoveOption option, out string reason) { reason = string.Empty; if (!this.checkFoup(source, out reason) || !this.checkFoup(dest, out reason)) return false; if (!Singleton.Instance.IsWaferSlotLocationValid(source, slot)) { reason = string.Format("Invalid source parameter, {0}:{1:D2}", (object)source.ToString(), (object)slot); return false; } if (!Singleton.Instance.IsWaferSlotLocationValid(dest, dslot)) { reason = string.Format("Invalid destination parameter, {0}:{1:D2}", (object)dest.ToString(), (object)dslot); return false; } if (!Singleton.Instance.CheckWafer(source, slot, WaferStatus.Normal)) { if (ModuleHelper.IsLoadLock(source) && Singleton.Instance.IsOnlineMode) { Singleton.Instance.CreateWafer(source, slot, WaferStatus.Normal); } else { reason = string.Format("Source no normal wafer, {0}:{1:D2}", (object)source.ToString(), (object)slot); return false; } } if (!Singleton.Instance.CheckWafer(dest, dslot, WaferStatus.Empty)) { reason = string.Format("destination has wafer, {0}:{1:D2}", (object)dest.ToString(), (object)dslot); return false; } if (source != ModuleName.Robot && dest != ModuleName.Robot && !Singleton.Instance.CheckWafer(ModuleName.Robot, (int)blade, WaferStatus.Empty)) { reason = string.Format("robot has wafer on arm"); return false; } if ((option & MoveOption.Align) != MoveOption.Align && (option & MoveOption.ReadID) != MoveOption.ReadID && (option & MoveOption.ReadID2) != MoveOption.ReadID2 || source == ModuleName.Aligner || dest == ModuleName.Aligner || Singleton.Instance.CheckWafer(ModuleName.Aligner, 0, WaferStatus.Empty)) return true; reason = string.Format("aligner has wafer on"); return false; } public enum MSG { MultiMoveWafer, MoveWafer, ReturnWafer, SetSpeed, HomeUnit, ReadID, WriteID, ReadAndLoad, LOAD, UNLOAD, Pause, Resume, Stop, StartCycle, Init, HOME, RESET, ABORT, ERROR, StartRecipe, StopRecipe, PauseRecipe, ResumeRecipe, SetAutoMode, SetManualMode, SetMaintenanceMode, MapWafer, Pick, Place, MPNTPick, MPNTPlace, RobotActionDone, LoadPortActionDone, ChangeCassette, Debug, Align, Swap } } }