1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618 |
- 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<string, RState> _taskState = new Dictionary<string, RState>();
- 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<DeviceDefineManager>.Instance.GetValue<int>(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<RouteManager1>(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<IoCoolingBuffer>("CoolingBuffer1");
- IoCoolingBuffer CoolingBuffer2 = DEVICE.GetDevice<IoCoolingBuffer>("CoolingBuffer2");
- PreAligner Aligner1 = DEVICE.GetDevice<PreAligner>("Aligner1");
- PreAligner Aligner2 = DEVICE.GetDevice<PreAligner>("Aligner2");
- DATA.Subscribe($"{ModuleName.LP1}.Status", () => { return IsLP1Installed ? DEVICE.GetDevice<LoadPortBaseDevice>("LP1").CurrentState.ToString() : ""; });
- DATA.Subscribe($"{ModuleName.LP2}.Status", () => { return IsLP2Installed ? DEVICE.GetDevice<LoadPortBaseDevice>("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<RobotBaseDevice>("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<DeviceDefineManager>.Instance.GetValue<int>(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<DeviceDefineManager>.Instance.GetValue<int>(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<DeviceDefineManager>.Instance.GetValue<int>(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<DeviceDefineManager>.Instance.GetValue<bool>(nameof(AlignerInstalled)).GetValueOrDefault();
- IsAligner1Installed = AlignerInstalled;
- //Flipper
- bool FlipperInstalled = Singleton<DeviceDefineManager>.Instance.GetValue<bool>(nameof(FlipperInstalled)).GetValueOrDefault();
- IsFlipper1Installed = FlipperInstalled;
- int BufferSlot = Singleton<DeviceDefineManager>.Instance.GetValue<int>(nameof(BufferSlot)).GetValueOrDefault();
- BufferNum = BufferSlot;
- }
- private bool CheckSensorNoWafer(ModuleName chamber, int slot)
- {
- RobotBaseDevice robot = DEVICE.GetDevice<RobotBaseDevice>("Robot");
- if (SC.GetValue<bool>("System.IsSimulatorMode") || chamber != ModuleName.Robot)
- return Singleton<WaferManager>.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<ModuleName> mods = new List<ModuleName>(); ;
- 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;
- }
- /// <summary>
- /// param参数说明 [0]设备名 [1]旋转角度
- /// </summary>
- /// <param name="param"></param>
- /// <returns></returns>
- 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;//??? 别问 问就是反编译源码就是这么写的
- /// <summary>
- /// 给LP发送消息 通过chamber的名称 获取LP1-10后的后缀数字
- /// 在不越过LP数量的情况下 对LP 发送Post信息
- /// </summary>
- /// <param name="chamber"></param>
- /// <param name="msg"></param>
- /// <param name="objs"></param>
- /// <returns></returns>
- 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<RobotBaseDevice>("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<IoSensor, bool>(SensorSMIF1PODOPEN_OnSignalChanged);
- DeviceModel.SensorSMIF2PODOPEN.OnSignalChanged += new Action<IoSensor, bool>(SensorSMIF2PODOPEN_OnSignalChanged);
- DeviceModel.SensorWaterLeakSW.OnSignalChanged += new Action<IoSensor, bool>(SensorWaterLeakSW_OnSignalChanged);
- DeviceModel.SensorGratingSensorIN1.OnSignalChanged += new Action<IoSensor, bool>(SensorGratingSensorIN1_OnSignalChanged);
- }
- else
- {
- DeviceModel.SensorPMASystemInterlock.OnSignalChanged += new Action<IoSensor, bool>(SensorPMASystemInterlock_OnSignalChanged);
- DeviceModel.SensorPMBSystemInterlock.OnSignalChanged += new Action<IoSensor, bool>(SensorPMBSystemInterlock_OnSignalChanged);
- DeviceModel.SensorRBNotExtendSIMF1.OnSignalChanged += new Action<IoSensor, bool>(SensorRBNotExtendSIMF1_OnSignalChanged);
- DeviceModel.SensorRBNotExtendSIMF2.OnSignalChanged += new Action<IoSensor, bool>(SensorRBNotExtendSIMF2_OnSignalChanged);
- DeviceModel.SensorSMIF1PODOPEN.OnSignalChanged += new Action<IoSensor, bool>(SensorSMIF1PODOPEN_OnSignalChanged);
- DeviceModel.SensorSMIF2PODOPEN.OnSignalChanged += new Action<IoSensor, bool>(SensorSMIF2PODOPEN_OnSignalChanged);
- DeviceModel.SensorWaterLeakSW.OnSignalChanged += new Action<IoSensor, bool>(SensorWaterLeakSW_OnSignalChanged);
- DeviceModel.SensorGratingSensorIN1.OnSignalChanged += new Action<IoSensor, bool>(SensorGratingSensorIN1_OnSignalChanged);
- }
- }
- else
- {
- DeviceModel.SensorPMASystemInterlock.OnSignalChanged += new Action<IoSensor, bool>(SensorPMASystemInterlock_OnSignalChanged);
- DeviceModel.SensorPMBSystemInterlock.OnSignalChanged += new Action<IoSensor, bool>(SensorPMBSystemInterlock_OnSignalChanged);
- DeviceModel.SensorRBNotExtendSIMF1.OnSignalChanged += new Action<IoSensor, bool>(SensorRBNotExtendSIMF1_OnSignalChanged);
- DeviceModel.SensorRBNotExtendSIMF2.OnSignalChanged += new Action<IoSensor, bool>(SensorRBNotExtendSIMF2_OnSignalChanged);
- DeviceModel.SensorSMIF1PODOPEN.OnSignalChanged += new Action<IoSensor, bool>(SensorSMIF1PODOPEN_OnSignalChanged);
- DeviceModel.SensorSMIF2PODOPEN.OnSignalChanged += new Action<IoSensor, bool>(SensorSMIF2PODOPEN_OnSignalChanged);
- DeviceModel.SensorWaterLeakSW.OnSignalChanged += new Action<IoSensor, bool>(SensorWaterLeakSW_OnSignalChanged);
- DeviceModel.SensorGratingSensorIN1.OnSignalChanged += new Action<IoSensor, bool>(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<EventEnum>("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<RouteManager1.MSG>(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<EventEnum>("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<RouteManager1.MSG>(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<EventEnum>("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>(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<EventEnum>("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>(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<EventEnum>("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>(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<bool> boolList1 = new List<bool>()
- {
- false,
- false,
- false,
- false,
- false
- };
- int num1 = 0;
- foreach (bool flag in boolList1)
- {
- if (!flag && Singleton<WaferManager>.Instance.CheckNoWafer(ModuleName.Buffer, num1))
- Singleton<WaferManager>.Instance.CreateWafer(ModuleName.Buffer, num1, WaferStatus.Normal);
- else if (flag && Singleton<WaferManager>.Instance.CheckHasWafer(ModuleName.Buffer, num1))
- Singleton<WaferManager>.Instance.DeleteWafer(ModuleName.Buffer, num1);
- ++num1;
- }
- List<bool> boolList2 = new List<bool>()
- {
- DeviceModel.SensorRBlowerArmhavewafer.Value,
- DeviceModel.SensorRBupperArmhavewafer.Value
- };
- int num2 = 0;
- foreach (bool flag in boolList2)
- {
- if (!flag && Singleton<WaferManager>.Instance.CheckNoWafer(ModuleName.Robot, num2))
- Singleton<WaferManager>.Instance.CreateWafer(ModuleName.Robot, num2, WaferStatus.Normal);
- else if (flag && Singleton<WaferManager>.Instance.CheckHasWafer(ModuleName.Robot, num2))
- Singleton<WaferManager>.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<LoadPortBaseDevice>(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<WaferManager>.Instance.IsWaferSlotLocationValid(source, slot))
- {
- reason = string.Format("非法的参数。{0}:{1:D2}", (object)source.ToString(), (object)slot);
- return false;
- }
- if (!Singleton<WaferManager>.Instance.IsWaferSlotLocationValid(dest, dslot))
- {
- reason = string.Format("非法的参数。{0}:{1:D2}", (object)dest.ToString(), (object)dslot);
- return false;
- }
- if (!Singleton<WaferManager>.Instance.CheckWafer(source, slot, WaferStatus.Normal))
- {
- reason = string.Format("源位置没有wafer。{0}:{1:D2}", (object)source.ToString(), (object)slot);
- return false;
- }
- if (Singleton<WaferManager>.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<WaferManager>.Instance.IsWaferSlotLocationValid(source, slot))
- {
- reason = string.Format("Invalid source parameter, {0}:{1:D2}", (object)source.ToString(), (object)slot);
- return false;
- }
- if (!Singleton<WaferManager>.Instance.IsWaferSlotLocationValid(dest, dslot))
- {
- reason = string.Format("Invalid destination parameter, {0}:{1:D2}", (object)dest.ToString(), (object)dslot);
- return false;
- }
- if (!Singleton<WaferManager>.Instance.CheckWafer(source, slot, WaferStatus.Normal))
- {
- if (ModuleHelper.IsLoadLock(source) && Singleton<EfemEntity>.Instance.IsOnlineMode)
- {
- Singleton<WaferManager>.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<WaferManager>.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<WaferManager>.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<WaferManager>.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
- }
- }
- }
|