RouteManager1.cs 69 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618
  1. using Aitex.Core.Common;
  2. using Aitex.Core.RT.Device;
  3. using Aitex.Core.RT.Device.Unit;
  4. using Aitex.Core.RT.Event;
  5. using Aitex.Core.RT.Fsm;
  6. using Aitex.Core.RT.SCCore;
  7. using Aitex.Core.Util;
  8. using Aitex.Sorter.Common;
  9. using athosRT.Devices;
  10. using athosRT.FSM;
  11. using athosRT.Modules.EFEMs;
  12. using athosRT.Modules.EFEMs.Routine;
  13. using athosRT.Modules.EFEMs.Tasks;
  14. using athosRT.Modules.LPs;
  15. using athosRT.Modules.Robot;
  16. using athosRT.tool;
  17. using MECF.Framework.Common.Equipment;
  18. using MECF.Framework.Common.SubstrateTrackings;
  19. using System;
  20. using System.Collections.Generic;
  21. using System.Diagnostics;
  22. using System.Linq;
  23. using System.Text.RegularExpressions;
  24. using OP = Common.OP.OP;
  25. using DATA = Common.DataCenter.DATA;
  26. using EV = athosRT.tool.EV;
  27. using MECF.Framework.RT.EquipmentLibrary.HardwareUnits.LoadPorts.LoadPortBase;
  28. using MECF.Framework.RT.EquipmentLibrary.HardwareUnits.Robots.RobotBase;
  29. using athosRT.Devices.PA;
  30. using athosRT.Modules.FLP;
  31. using RtState = athosCore.RtState;
  32. namespace athosRT.Modules
  33. {
  34. public class RouteManager1 : Entity, IModuleEntity
  35. {
  36. private InitRoutine initRoutine = null;
  37. private SetSpeedRoutine setspeedRoutine = null;
  38. private WaferMappingRoutine _waferMapRoutine;
  39. private LoadFoupRoutine _loadFoupRoutine;
  40. private PickRoutine _pickRoutine;
  41. private PickExtendRoutine _pickExtendRoutine;
  42. private PlaceRoutine _placeRoutine;
  43. private PlaceExtendRoutine _placeExtendRoutine;
  44. private SwapRoutine _swapRoutine;
  45. private AlignRoutine _alignRoutine;
  46. private StaticTransfer _staticTransfer;
  47. private AutoCycle _cycle;
  48. //记录任务运行状态的
  49. private Dictionary<string, RState> _taskState = new Dictionary<string, RState>();
  50. public RState GetTaskState(string task) => _taskState.ContainsKey(task) ? _taskState[task] : RState.End;
  51. private static LoadPortEntity _lp1 = null;
  52. private static LoadPortEntity _lp2 = null;
  53. private static LoadPortEntity _lp3 = null;
  54. private static LoadPortEntity _lp4 = null;
  55. private static LoadPortEntity _lp5 = null;
  56. private static LoadPortEntity _lp6 = null;
  57. private static LoadPortEntity _lp7 = null;
  58. private static LoadPortEntity _lp8 = null;
  59. private static LoadPortEntity _lp9 = null;
  60. private static LoadPortEntity _lp10 = null;
  61. private FlipperEntity _flipper = null;
  62. private RobotBaseDevice _robot = null;
  63. public int BufferNum { get; set; }
  64. public bool IsLP1Installed { get; set; }
  65. public bool IsLP2Installed { get; set; }
  66. public bool IsLP3Installed { get; set; }
  67. public bool IsBuffer1Installed { get; set; }
  68. public bool IsBuffer2Installed { get; set; }
  69. public bool IsAligner1Installed { get; set; }
  70. public bool IsLL1Installed { get; set; }
  71. public bool IsLL2Installed { get; set; }
  72. public bool IsFlipper1Installed { get; set; }
  73. public RobotBaseDevice Robot;
  74. public WaferInfo[] LP1WaferInfo
  75. {
  76. get
  77. {
  78. return WaferManager.Instance.GetWafers(ModuleName.LP1);
  79. }
  80. }
  81. private LoadPortEntity[] _loadportEntities;
  82. private int LoadPortQuantity = Singleton<DeviceDefineManager>.Instance.GetValue<int>(nameof(LoadPortQuantity)).GetValueOrDefault();
  83. public bool IsInit => fsm.State == (int)RtState.Init;
  84. public bool IsIdle => fsm.State == (int)RtState.Idle;
  85. public bool IsError => fsm.State == (int)RtState.Error;
  86. public bool IsMaintenanceMode => fsm.State == (int)RtState.Maintenance;
  87. public bool IsFFUOk { get; set; }//
  88. public bool IsCycle => fsm.State == (int)RtState.Cycle;
  89. public bool Initializing => fsm.State == (int)RtState.Initializing;
  90. public bool IsRunning => !IsIdle && !IsInit && !IsError && !IsMaintenanceMode;
  91. public bool IsBusy => !IsInit && !IsError && !IsIdle;
  92. public string GetFsmState => fsm.State.ToString();
  93. public bool IsEMSStop { get; set; }//
  94. public bool IsOnline { get; set; }//
  95. public bool Check(int msg, out string reason, params object[] args)
  96. {
  97. reason = "";
  98. return true;
  99. }
  100. public string EFemNum => SC.GetStringValue("System.EFEMNUM");
  101. public string Name;
  102. public RouteManager1() {
  103. Name = "RT";
  104. //基于xml文件建立设备
  105. //设备初始化 device+robot
  106. InitDevice();
  107. //routine初始化
  108. RoutineInit();
  109. //wafermanager初始化
  110. //fsm初始化
  111. fsm = new StateMachine<RouteManager1>(Name, (int)RtState.Init, 50);
  112. //时序改变
  113. BuildTransitionTable();
  114. SubscribeList();
  115. SetInstalledModules();
  116. Running = true;
  117. //PostMsg(MSG.Debug);
  118. }
  119. public void SubscribeList()
  120. {
  121. OP.Subscribe($"{ModuleName.EFEM}.{MSG.HOME}", (cmd, args) => { PostMsg(MSG.HOME); return true; });
  122. OP.Subscribe($"{ModuleName.EFEM}.{MSG.ERROR}", (cmd, args) => { PostMsg(MSG.ERROR); return true; });
  123. OP.Subscribe($"{ModuleName.EFEM}.{MSG.ABORT}", (cmd, args) => { PostMsg(MSG.ABORT); return true; });
  124. OP.Subscribe($"{ModuleName.EFEM}.{MSG.LOAD}", (cmd, args) => { PostMsg(MSG.LOAD); return true; });
  125. OP.Subscribe($"{ModuleName.EFEM}.{MSG.ReadAndLoad}", (cmd, args) => { PostMsg(MSG.ReadAndLoad); return true; });
  126. OP.Subscribe($"{ModuleName.EFEM}.{MSG.UNLOAD}", (cmd, args) => { PostMsg(MSG.UNLOAD); return true; });
  127. OP.Subscribe($"{ModuleName.EFEM}.{MSG.ReadID}", (cmd, args) => { PostMsg(MSG.ReadID); return true; });
  128. OP.Subscribe($"{ModuleName.EFEM}.{MSG.WriteID}", (cmd, args) => { PostMsg(MSG.WriteID); return true; });
  129. OP.Subscribe($"{ModuleName.EFEM}.{MSG.SetSpeed}", (cmd, args) => { PostMsg(MSG.SetSpeed); return true; });
  130. OP.Subscribe($"{ModuleName.EFEM}.{MSG.MapWafer}", (cmd, args) => { PostMsg(MSG.MapWafer); return true; });
  131. OP.Subscribe($"{ModuleName.EFEM}.{MSG.ChangeCassette}", (cmd, args) => { PostMsg(MSG.ChangeCassette); return true; });
  132. OP.Subscribe($"{ModuleName.EFEM}.{MSG.MoveWafer}", (cmd, args) => { PostMsg(MSG.MoveWafer, args); return true; });
  133. OP.Subscribe($"{ModuleName.EFEM}.{MSG.ReturnWafer}", (cmd, args) => { PostMsg(MSG.ReturnWafer); return true; });
  134. OP.Subscribe($"{ModuleName.EFEM}.{MSG.StartCycle}", (cmd, args) => { PostMsg(MSG.StartCycle, args); return true; });
  135. OP.Subscribe($"{ModuleName.EFEM}.{MSG.Stop}", (cmd, args) => { PostMsg(MSG.Stop); return true; });
  136. OP.Subscribe($"{ModuleName.EFEM}.{MSG.RobotActionDone}", (cmd, args) => { PostMsg(MSG.RobotActionDone); return true; });
  137. OP.Subscribe($"{ModuleName.EFEM}.{MSG.Pick}", (cmd, args) => { PostMsg(MSG.Pick, args); return true; });
  138. OP.Subscribe($"{ModuleName.EFEM}.{MSG.Place}", (cmd, args) => { PostMsg(MSG.Place, args); return true; });
  139. OP.Subscribe($"{ModuleName.EFEM}.{MSG.Swap}", (cmd, args) => { PostMsg(MSG.Swap, args); return true; });
  140. OP.Subscribe($"{ModuleName.EFEM}.{MSG.MPNTPick}", (cmd, args) => { PostMsg(MSG.MPNTPick); return true; });
  141. OP.Subscribe($"{ModuleName.EFEM}.{MSG.MPNTPlace}", (cmd, args) => { PostMsg(MSG.MPNTPlace); return true; });
  142. OP.Subscribe($"{ModuleName.EFEM}.{MSG.Align}", (cmd, args) => { PostMsg(MSG.Align); return true; });
  143. OP.Subscribe("CreateWafer", (cmd, args) => {
  144. Trace.WriteLine("开始创建Wafer");
  145. ModuleName module = (ModuleName)args[0];
  146. int slot = (int)args[1];
  147. WaferSize size = (WaferSize)args[2];
  148. //如果是LP 从小于slot的槽开始加wafer
  149. if (module == ModuleName.LP1 || module == ModuleName.LP2)
  150. {
  151. int _SlotNumber = slot;
  152. //给loadport的所有slot加上wafer
  153. for (int i = 0; i < _SlotNumber; i++)
  154. {
  155. //这里创建
  156. WaferManager.Instance.CreateWafer(module, i, WaferStatus.Normal, size);
  157. }
  158. }
  159. else
  160. {
  161. Trace.WriteLine($"{module}");
  162. //其他设备直接加
  163. WaferManager.Instance.CreateWafer(module, slot, WaferStatus.Normal, size);
  164. }
  165. return true;
  166. });
  167. OP.Subscribe("CreateLPSingleWafer", (cmd, args) => {
  168. Trace.WriteLine("开始创建LP的单片Wafer");
  169. ModuleName module = (ModuleName)args[0];
  170. int slot = (int)args[1];
  171. WaferSize size = (WaferSize)args[2];
  172. WaferManager.Instance.CreateWafer(module, slot, WaferStatus.Normal, size);
  173. return true;
  174. });
  175. OP.Subscribe("CreatebufferSingleWafer", (cmd, args) => {
  176. Trace.WriteLine("开始创建buffer的单片Wafer");
  177. ModuleName module = (ModuleName)args[0];
  178. int slot = (int)args[1];
  179. WaferSize size = (WaferSize)args[2];
  180. WaferManager.Instance.CreateWafer(module, slot, WaferStatus.Normal, size);
  181. return true;
  182. });
  183. OP.Subscribe("DeleteWafer", (cmd, args) => {
  184. Trace.WriteLine("开始删除Wafer");
  185. ModuleName module = (ModuleName)args[0];
  186. int slot = (int)args[1];
  187. WaferSize size = (WaferSize)args[2];
  188. //如果是LP 从小于slot的槽开始加wafer
  189. WaferManager.Instance.DeleteWafer(module, slot, 1);
  190. return true;
  191. });
  192. OP.Subscribe("MoveWafer", (cmd,args) => {
  193. ModuleName source = ModuleHelper.Converter(args[0].ToString());
  194. int source_slot = Convert.ToInt16(args[1].ToString());
  195. ModuleName destation = ModuleHelper.Converter(args[2].ToString());
  196. int des_slot = Convert.ToInt16(args[3].ToString());
  197. WaferManager.Instance.WaferMoved(source,source_slot, destation, des_slot);
  198. return true;
  199. });
  200. OP.Subscribe("ClearLogList", (cmd, args) => LogObject.ClearLogList());
  201. WaferManager.Instance.DeleteWafer(ModuleName.LL1, 0, 1);
  202. //LP12、Aligner12、CoolingBuffer12、LL12
  203. DATA.Subscribe($"{ModuleName.LP1}.WaferInfos", () => WaferManager.Instance.GetWafers(ModuleName.LP1));
  204. DATA.Subscribe($"{ModuleName.LP2}.WaferInfos", () => WaferManager.Instance.GetWafers(ModuleName.LP2));
  205. DATA.Subscribe($"{ModuleName.LL1}.WaferInfos", () => WaferManager.Instance.GetWafers(ModuleName.LL1));
  206. DATA.Subscribe($"{ModuleName.LL2}.WaferInfos", () => WaferManager.Instance.GetWafers(ModuleName.LL2));
  207. DATA.Subscribe($"{ModuleName.Buffer}.WaferInfos", () => WaferManager.Instance.GetWafers(ModuleName.Buffer));
  208. DATA.Subscribe($"{ModuleName.Aligner1}.WaferInfos", () => WaferManager.Instance.GetWafers(ModuleName.Aligner1));
  209. DATA.Subscribe($"{ModuleName.Aligner2}.WaferInfos", () => WaferManager.Instance.CheckHasWafer(ModuleName.Aligner2, 0));
  210. DATA.Subscribe($"{ModuleName.CoolingBuffer1}.WaferInfos", () => WaferManager.Instance.CheckHasWafer(ModuleName.CoolingBuffer1, 0));
  211. DATA.Subscribe($"{ModuleName.CoolingBuffer2}.WaferInfos", () => WaferManager.Instance.CheckHasWafer(ModuleName.CoolingBuffer2, 0));
  212. DATA.Subscribe($"{ModuleName.TurnOverStation}.WaferInfos", () => WaferManager.Instance.GetWafers(ModuleName.TurnOverStation));
  213. DATA.Subscribe($"All.WaferInfos", () => WaferManager.Instance.AllLocationWafers);
  214. DATA.Subscribe($"{ModuleName.Robot}.{Hand.Blade1}.WaferInfos", () => !CheckSensorNoWafer(ModuleName.Robot, 0));
  215. DATA.Subscribe($"{ModuleName.Robot}.{Hand.Blade2}.WaferInfos", () => !CheckSensorNoWafer(ModuleName.Robot, 1));
  216. DATA.Subscribe($"{ModuleName.Robot}.WaferInfos", () => WaferManager.Instance.GetWafers(ModuleName.Robot));
  217. IoCoolingBuffer CoolingBuffer1 = DEVICE.GetDevice<IoCoolingBuffer>("CoolingBuffer1");
  218. IoCoolingBuffer CoolingBuffer2 = DEVICE.GetDevice<IoCoolingBuffer>("CoolingBuffer2");
  219. PreAligner Aligner1 = DEVICE.GetDevice<PreAligner>("Aligner1");
  220. PreAligner Aligner2 = DEVICE.GetDevice<PreAligner>("Aligner2");
  221. DATA.Subscribe($"{ModuleName.LP1}.Status", () => { return IsLP1Installed ? DEVICE.GetDevice<LoadPortBaseDevice>("LP1").CurrentState.ToString() : ""; });
  222. DATA.Subscribe($"{ModuleName.LP2}.Status", () => { return IsLP2Installed ? DEVICE.GetDevice<LoadPortBaseDevice>("LP2").CurrentState.ToString() : ""; });
  223. DATA.Subscribe($"{ModuleName.Aligner1}.Status", () => Aligner1?.Status.ToString());
  224. DATA.Subscribe($"{ModuleName.Aligner2}.Status", () => Aligner2?.Status.ToString());
  225. DATA.Subscribe($"{ModuleName.CoolingBuffer1}.Status", () => CoolingBuffer1?.FeedbackLift.ToString());
  226. DATA.Subscribe($"{ModuleName.CoolingBuffer2}.Status", () => CoolingBuffer2?.FeedbackLift.ToString());
  227. DATA.Subscribe($"{ModuleName.Robot}.Status", () => DEVICE.GetDevice<RobotBaseDevice>("Robot").RobotState.ToString());
  228. DATA.Subscribe($"{ModuleName.CoolingBuffer1}.SetPoint4Inch", () => CoolingBuffer1?.SetPoint4Inch.ToString());
  229. DATA.Subscribe($"{ModuleName.CoolingBuffer1}.SetPoint3Inch", () => CoolingBuffer1?.SetPoint3Inch.ToString());
  230. DATA.Subscribe($"{ModuleName.CoolingBuffer1}.Feedback4Inch", () => CoolingBuffer1?.Feedback4Inch.ToString());
  231. DATA.Subscribe($"{ModuleName.CoolingBuffer1}.Feedback3Inch", () => CoolingBuffer1?.Feedback3Inch.ToString());
  232. DATA.Subscribe($"{ModuleName.CoolingBuffer1}.SetPointLift ", () => CoolingBuffer1?.SetPointLift.ToString());
  233. DATA.Subscribe($"{ModuleName.CoolingBuffer2}.SetPoint4Inch", () => CoolingBuffer2?.SetPoint4Inch.ToString());
  234. DATA.Subscribe($"{ModuleName.CoolingBuffer2}.SetPoint3Inch", () => CoolingBuffer2?.SetPoint3Inch.ToString());
  235. DATA.Subscribe($"{ModuleName.CoolingBuffer2}.Feedback4Inch", () => CoolingBuffer2?.Feedback4Inch.ToString());
  236. DATA.Subscribe($"{ModuleName.CoolingBuffer2}.Feedback3Inch", () => CoolingBuffer2?.Feedback3Inch.ToString());
  237. DATA.Subscribe($"{ModuleName.CoolingBuffer2}.SetPointLift ", () => CoolingBuffer2?.SetPointLift.ToString());
  238. DATA.Subscribe($"{ModuleName.Aligner1}.SetPoint4Inch", () => Aligner1?.SetPoint4Inch.ToString());
  239. DATA.Subscribe($"{ModuleName.Aligner1}.SetPoint3Inch", () => Aligner1?.SetPoint3Inch.ToString());
  240. DATA.Subscribe($"{ModuleName.Aligner1}.Feedback4Inch", () => Aligner1?.Feedback4Inch.ToString());
  241. DATA.Subscribe($"{ModuleName.Aligner1}.Feedback3Inch", () => Aligner1?.Feedback3Inch.ToString());
  242. DATA.Subscribe($"{ModuleName.Aligner1}.SetPointLift ", () => Aligner1?.SetPointLift.ToString());
  243. DATA.Subscribe($"{ModuleName.Aligner2}.SetPoint4Inch", () => Aligner2?.SetPoint4Inch.ToString());
  244. DATA.Subscribe($"{ModuleName.Aligner2}.SetPoint3Inch", () => Aligner2?.SetPoint3Inch.ToString());
  245. DATA.Subscribe($"{ModuleName.Aligner2}.Feedback4Inch", () => Aligner2?.Feedback4Inch.ToString());
  246. DATA.Subscribe($"{ModuleName.Aligner2}.Feedback3Inch", () => Aligner2?.Feedback3Inch.ToString());
  247. DATA.Subscribe($"{ModuleName.Aligner2}.SetPointLift ", () => Aligner2?.SetPointLift.ToString());
  248. DATA.Subscribe($"{ModuleName.System}.Status", () => ((RtState)fsm.State).ToString());
  249. DATA.Subscribe($"{ModuleName.System}.IsAlarm", () => IsError);
  250. DATA.Subscribe($"{ModuleName.System}.IsIdle", () => IsIdle);
  251. DATA.Subscribe($"{ModuleName.System}.IsRunning", () => IsRunning);
  252. DATA.Subscribe($"{ModuleName.System}.IsMaintenanceMode", () => IsMaintenanceMode);
  253. DATA.Subscribe($"{ModuleName.LP1}.IsInstalled", () => IsLP1Installed);
  254. DATA.Subscribe($"{ModuleName.LP2}.IsInstalled", () => IsLP2Installed);
  255. DATA.Subscribe($"{ModuleName.Buffer1}.IsInstalled", () => IsBuffer1Installed);
  256. DATA.Subscribe($"{ModuleName.Buffer2}.IsInstalled", () => IsBuffer2Installed);
  257. DATA.Subscribe($"{ModuleName.Aligner1}.IsInstalled", () => IsAligner1Installed);
  258. DATA.Subscribe($"{ModuleName.LL1}.IsInstalled", () => IsLL1Installed);
  259. DATA.Subscribe($"{ModuleName.LL2}.IsInstalled", () => IsLL2Installed);
  260. DATA.Subscribe($"{ModuleName.TurnOverStation}.IsInstalled", () => IsFlipper1Installed);
  261. DATA.Subscribe($"{ModuleName.Buffer}.BufferNum", () => BufferNum);
  262. }
  263. private void SetInstalledModules()
  264. {
  265. //LL(PM)
  266. int LoadLockQuantity = Singleton<DeviceDefineManager>.Instance.GetValue<int>(nameof(LoadLockQuantity)).GetValueOrDefault();
  267. switch (LoadLockQuantity)
  268. {
  269. case 0:
  270. IsLL1Installed = false;
  271. IsLL2Installed = false;
  272. break;
  273. case 1:
  274. IsLL1Installed = true;
  275. IsLL2Installed = false;
  276. break;
  277. case 2:
  278. IsLL1Installed = true;
  279. IsLL2Installed = true;
  280. break;
  281. default:
  282. break;
  283. }
  284. //Buffer
  285. int BufferQuantity = Singleton<DeviceDefineManager>.Instance.GetValue<int>(nameof(BufferQuantity)).GetValueOrDefault();
  286. switch (BufferQuantity)
  287. {
  288. case 0:
  289. IsBuffer1Installed = false;
  290. IsBuffer2Installed = false;
  291. break;
  292. case 1:
  293. IsBuffer1Installed = true;
  294. IsBuffer2Installed = false;
  295. break;
  296. case 2:
  297. IsBuffer1Installed = true;
  298. IsBuffer2Installed = true;
  299. break;
  300. default:
  301. break;
  302. }
  303. //LP
  304. int LoadPortQuantity = Singleton<DeviceDefineManager>.Instance.GetValue<int>(nameof(LoadPortQuantity)).GetValueOrDefault();
  305. switch (LoadPortQuantity)
  306. {
  307. case 0:
  308. IsLP1Installed = false;
  309. IsLP2Installed = false;
  310. break;
  311. case 1:
  312. IsLP1Installed = true;
  313. IsLP2Installed = false;
  314. break;
  315. case 2:
  316. IsLP1Installed = true;
  317. IsLP2Installed = true;
  318. break;
  319. default:
  320. break;
  321. }
  322. //Aligner
  323. bool AlignerInstalled = Singleton<DeviceDefineManager>.Instance.GetValue<bool>(nameof(AlignerInstalled)).GetValueOrDefault();
  324. IsAligner1Installed = AlignerInstalled;
  325. //Flipper
  326. bool FlipperInstalled = Singleton<DeviceDefineManager>.Instance.GetValue<bool>(nameof(FlipperInstalled)).GetValueOrDefault();
  327. IsFlipper1Installed = FlipperInstalled;
  328. int BufferSlot = Singleton<DeviceDefineManager>.Instance.GetValue<int>(nameof(BufferSlot)).GetValueOrDefault();
  329. BufferNum = BufferSlot;
  330. }
  331. private bool CheckSensorNoWafer(ModuleName chamber, int slot)
  332. {
  333. RobotBaseDevice robot = DEVICE.GetDevice<RobotBaseDevice>("Robot");
  334. if (SC.GetValue<bool>("System.IsSimulatorMode") || chamber != ModuleName.Robot)
  335. return Singleton<WaferManager>.Instance.CheckNoWafer(chamber, slot);
  336. return slot == 0 ? !robot.IsWaferPresenceOnBlade1 : !robot.IsWaferPresenceOnBlade2;
  337. }
  338. public FlipperEntity GetFlipper() => _flipper;
  339. public RouteManager1 GetRT()
  340. {
  341. return this;
  342. }
  343. public void BuildTransitionTable() {
  344. //接收到MSG 任何状态直接执行
  345. //AnyStateTransition(MSG.Debug,fdebug,RtState.Idle);
  346. AnyStateTransition(MSG.RESET, fStartReset, RtState.Idle);
  347. AnyStateTransition(MSG.ERROR, fError, RtState.Error);
  348. AnyStateTransition(MSG.SetMaintenanceMode, fSetMaintenanceMode, RtState.Maintenance);
  349. //脱出Maintance维护状态
  350. Transition(RtState.Maintenance, MSG.SetManualMode, null, RtState.Idle);
  351. //Init squence 😀
  352. //InitRoutine start 进Initializing 成功进Idle 错误进Error
  353. Transition(RtState.Init, MSG.HOME, fStartInit, RtState.Initializing);
  354. Transition(RtState.Idle, MSG.HOME, fStartInit, RtState.Initializing);
  355. Transition(RtState.Error, MSG.HOME, fStartInit, RtState.Initializing);
  356. Transition(RtState.Initializing, FSM_MSG.TIMER, (fInit), RtState.Idle);
  357. Transition(RtState.Initializing, MSG.ERROR, (fError), RtState.Error);
  358. Transition(RtState.Initializing, MSG.ABORT, null, RtState.Init);
  359. //Idle下 无需切换状态的MSG
  360. EnterExitTransition(RtState.Idle, fIdle, new FSM_MSG?(FSM_MSG.NONE), null);
  361. //mode
  362. Transition(RtState.Idle, MSG.SetAutoMode, fSetAutoMode, RtState.Idle);
  363. Transition(RtState.Idle, MSG.SetManualMode, fSetManualMode, RtState.Idle);
  364. //LP
  365. Transition(RtState.Idle, MSG.LOAD, fLPLoad, RtState.Idle);
  366. Transition(RtState.Idle, MSG.ReadAndLoad, fReadAndLoad, RtState.Idle);
  367. Transition(RtState.Idle, MSG.UNLOAD, fLPUnLoad, RtState.Idle);
  368. Transition(RtState.Idle, MSG.ReadID, fReadID, RtState.Idle);
  369. Transition(RtState.Idle, MSG.WriteID, fWriteID, RtState.Idle);
  370. //SetSpeed squence
  371. Transition(RtState.Idle, MSG.SetSpeed, fStartSetSpeed, RtState.SetSpeed);
  372. Transition(RtState.SetSpeed, FSM_MSG.TIMER, fSetSpeed, RtState.Idle);
  373. //MapWafer squence
  374. Transition(RtState.Init, MSG.MapWafer, fStartMapWafer, RtState.WaferMapping);
  375. Transition(RtState.Idle, MSG.MapWafer, fStartMapWafer, RtState.WaferMapping);
  376. Transition(RtState.WaferMapping, FSM_MSG.TIMER, fMapWafer, RtState.Idle);
  377. Transition(RtState.WaferMapping, MSG.ChangeCassette, fChangeCassette, RtState.Error);
  378. //Transfer squence
  379. Transition(RtState.Idle, MSG.MoveWafer, fStartTransfer, RtState.Transfer);
  380. Transition(RtState.Init, MSG.MoveWafer, fStartTransfer, RtState.Transfer);
  381. //EnterExitTransition(RtState.Transfer, null, new FSM_MSG?(FSM_MSG.NONE), fExitTransfer);
  382. Transition(RtState.Idle, MSG.ReturnWafer, fStartReturn, RtState.Transfer);
  383. Transition(RtState.Transfer, FSM_MSG.TIMER, fTransfer, RtState.Idle);
  384. Transition(RtState.Transfer, MSG.ABORT, fAbortTransfer, RtState.Idle);
  385. Transition(RtState.Transfer, MSG.ChangeCassette, fChangeCassette, RtState.Error);
  386. //Cycle
  387. Transition(RtState.Idle, MSG.StartCycle, fStartCycle, RtState.Cycle);
  388. //Transition(RtState.Init, MSG.StartCycle, fStartCycle, RtState.Cycle);
  389. EnterExitTransition(RtState.Cycle, fEnterCycle, new FSM_MSG?(FSM_MSG.NONE), fExitCycle);
  390. Transition(RtState.Cycle, FSM_MSG.TIMER, fCycle, RtState.Idle);
  391. Transition(RtState.Cycle, MSG.Stop, fCycleStop, RtState.Cycle);
  392. Transition(RtState.Cycle, MSG.ABORT, fAbortCycle, RtState.Idle);
  393. Transition(RtState.Cycle, MSG.ChangeCassette, fChangeCassette, RtState.Error);
  394. Transition(RtState.Cycle, MSG.RobotActionDone, fCycle, RtState.Cycle);
  395. //Pick squence
  396. Transition(RtState.Idle, MSG.Pick, fStartPick, RtState.Picking);
  397. Transition(RtState.Picking, FSM_MSG.TIMER, fPick, RtState.Idle);
  398. Transition(RtState.Picking, MSG.ABORT, fAbort, RtState.Idle);
  399. Transition(RtState.Picking, MSG.ChangeCassette, fChangeCassette, RtState.Error);
  400. //Place squence
  401. Transition(RtState.Idle, MSG.Place, fStartPlace, RtState.Placing);
  402. Transition(RtState.Placing, FSM_MSG.TIMER, fPlace, RtState.Idle);
  403. Transition(RtState.Picking, MSG.ABORT, fAbort, RtState.Idle);
  404. Transition(RtState.Picking, MSG.ChangeCassette, fChangeCassette, RtState.Error);
  405. //Swap squence
  406. Transition(RtState.Idle, MSG.Swap, fStartSwap, RtState.Swaping);
  407. Transition(RtState.Swaping, FSM_MSG.TIMER, fSwap, RtState.Idle);
  408. Transition(RtState.Swaping, MSG.ABORT, fAbort, RtState.Idle);
  409. Transition(RtState.Swaping, MSG.ChangeCassette, fChangeCassette, RtState.Error);
  410. //PickPM squence
  411. Transition(RtState.Idle, MSG.MPNTPick, fStartMPNTPick, RtState.PickingPM);
  412. Transition(RtState.PickingPM, FSM_MSG.TIMER, fMPNTPick, RtState.Idle);
  413. Transition(RtState.PickingPM, MSG.ABORT, fAbort, RtState.Idle);
  414. //PlacePM squence
  415. Transition(RtState.Idle, MSG.MPNTPlace, fStartMPNTPlace, RtState.PlacingPM);
  416. Transition(RtState.PlacingPM, FSM_MSG.TIMER, fMPNTPlace, RtState.Idle);
  417. Transition(RtState.PlacingPM, MSG.ABORT, fAbort, RtState.Idle);
  418. //PreAlign squence
  419. Transition(RtState.Idle, MSG.Align, fStartAlign, RtState.Align);
  420. Transition(RtState.Align, FSM_MSG.TIMER, fAlign, RtState.Idle);
  421. Transition(RtState.Align, MSG.ABORT, fAbort, RtState.Idle);
  422. }
  423. public bool CheckToPostMessage(int msg, params object[] args)
  424. {
  425. if (!fsm.FindTransition(fsm.State, msg))
  426. {
  427. LogObject.Info(ModuleName.System.ToString(), $"System is in {(RtState)fsm.State} state,can not do {(MSG)msg}");
  428. return false;
  429. }
  430. Running = true;
  431. fsm.PostMsg(msg, args);
  432. return true;
  433. }
  434. private bool fdebug(object[] param)
  435. {
  436. //debug 进入idle状态 用于测试
  437. return true;
  438. }
  439. private bool fSetManualMode(object[] param)
  440. {
  441. return true;
  442. }
  443. private bool fSetAutoMode(object[] param)
  444. {
  445. throw new NotImplementedException();
  446. }
  447. private bool fSetMaintenanceMode(object[] param)
  448. {
  449. return true ;
  450. }
  451. private bool fExitCycle(object[] param)
  452. {
  453. return true;
  454. }
  455. private bool fEnterCycle(object[] param)
  456. {
  457. return true;
  458. }
  459. private bool fAbortCycle(object[] param)
  460. {
  461. _cycle.Abort();
  462. return true;
  463. }
  464. private bool fCycleStop(object[] param)
  465. {
  466. throw new NotImplementedException();
  467. }
  468. private bool fCycle(object[] param)
  469. {
  470. try
  471. {
  472. RState result = _cycle.Monitor();
  473. if (result == RState.Failed || result == RState.Timeout)
  474. {
  475. LogObject.Error("Cycle", "失败");
  476. PostMsg(MSG.ERROR);
  477. return false;
  478. }
  479. return result == RState.End;
  480. }
  481. catch (Exception ex)
  482. {
  483. Trace.WriteLine("抛出错误:" + ex);
  484. return true;
  485. }
  486. }
  487. private bool fStartCycle(object[] param)
  488. {
  489. //ModuleName.TurnOverStation
  490. if (param.Length > 0)
  491. {
  492. string[] mods_raw = param[2].ToString().Split('|');
  493. LogObject.Info("Cycle",$"经过module:{mods_raw}");
  494. List<ModuleName> mods = new List<ModuleName>(); ;
  495. mods_raw.ToList().ForEach(mod=> {
  496. if (!string.IsNullOrEmpty(mod))
  497. {
  498. LogObject.Info("Cycle", $"经过module:{mod}");
  499. mods.Add(ModuleHelper.Converter(mod));
  500. }
  501. });
  502. return _cycle.Start(param[0].ToString(), param[1].ToString(), mods) == RState.Running;
  503. }
  504. else
  505. {
  506. return false;
  507. }
  508. }
  509. private bool fExitTransfer(object[] param)
  510. {
  511. _staticTransfer.Clear();
  512. _taskState.Remove("MoveWafer");
  513. return true;
  514. }
  515. private bool fAbortTransfer(object[] param)
  516. {
  517. LogObject.Info(Name, "transfer中断");
  518. return true;
  519. }
  520. private bool fStartReturn(object[] param)
  521. {
  522. _staticTransfer.Clear();
  523. _taskState.Remove("MoveWafer");
  524. if (_staticTransfer.Return(param))
  525. {
  526. LogObject.Info(Name, "Return开始");
  527. return true;
  528. }
  529. else
  530. {
  531. LogObject.Error(Name, "Return无法开始");
  532. return false;
  533. }
  534. }
  535. private bool fTransfer(object[] param)
  536. {
  537. if (_staticTransfer.Monitor(param))
  538. {
  539. LogObject.Info(Name, "Monitor执行完毕");
  540. return true;
  541. }
  542. else
  543. {
  544. //LogObject.Error(Name, "Monitor执行失败");
  545. return false;
  546. }
  547. }
  548. private bool fStartTransfer(object[] param)
  549. {
  550. _staticTransfer.Clear();
  551. _taskState.Remove("MoveWafer");
  552. Running = true;
  553. if (_staticTransfer.Start(param))
  554. {
  555. LogObject.Info(Name, "transfer开始");
  556. return true;
  557. }
  558. else
  559. {
  560. LogObject.Error(Name, "transfer无法开始");
  561. return false;
  562. }
  563. }
  564. // 多个部分都有涉及 注意case和goto的方向
  565. private bool fChangeCassette(object[] param)
  566. {
  567. string str1 = param[0].ToString();
  568. switch (fsm.State)
  569. {
  570. case (int)RtState.Transfer:
  571. //调整transfer的内容
  572. return true;
  573. case (int)RtState.Cycle:
  574. //调整Cycle的内容
  575. return true;
  576. case (int)RtState.WaferMapping:
  577. if (str1 == _waferMapRoutine.Source.ToString())
  578. {
  579. return true;
  580. }
  581. goto default;
  582. case (int)RtState.Picking:
  583. if (str1 == _pickRoutine.Source.ToString())
  584. break;
  585. goto default;
  586. case (int)RtState.Placing:
  587. if (str1 == _placeRoutine.Station.ToString())
  588. break;
  589. goto default;
  590. default:
  591. return false;
  592. }
  593. Robot.Stop();
  594. return true;
  595. }
  596. /// <summary>
  597. /// param参数说明 [0]设备名 [1]旋转角度
  598. /// </summary>
  599. /// <param name="param"></param>
  600. /// <returns></returns>
  601. private bool fStartAlign(object[] param)
  602. {
  603. RState result = _alignRoutine.Start(param);
  604. if (result == RState.Running)
  605. {
  606. LogObject.Info(Name, "开始 Align");
  607. return true;
  608. }
  609. else
  610. {
  611. LogObject.Error(Name, "无法开始 Align");
  612. return false;
  613. }
  614. }
  615. private bool fAlign(object[] param)
  616. {
  617. RState result = _alignRoutine.Monitor();
  618. if (result == RState.Failed || result == RState.Timeout)
  619. {
  620. LogObject.Error(Name, "Align 执行失败 置错误");
  621. PostMsg(MSG.ERROR);
  622. return false;
  623. }
  624. return result == RState.End;
  625. }
  626. private bool fMPNTPlace(object[] param)
  627. {
  628. RState result = _placeExtendRoutine.Monitor();
  629. if (result == RState.Failed || result == RState.Timeout)
  630. {
  631. LogObject.Error(Name, "MPNTPlace 执行失败 置错误");
  632. PostMsg(MSG.ERROR);
  633. return false;
  634. }
  635. return result == RState.End;
  636. }
  637. private bool fStartMPNTPlace(object[] param)
  638. {
  639. if (param.Length != 4)
  640. {
  641. LogObject.Error(Name, "参数数量不符要求 MPNTPick无法执行");
  642. return false;
  643. }
  644. _placeExtendRoutine.Station = ModuleHelper.Converter((string)param[0]);
  645. _placeExtendRoutine.Slot = (int)param[1];
  646. _placeExtendRoutine.Blade = (Hand)param[2];
  647. _placeExtendRoutine.TaskEnum = (MpntTaskEnum)param[3];
  648. RState result = _placeExtendRoutine.Start(param);
  649. if (result == RState.Running)
  650. {
  651. LogObject.Info(Name, "开始 MPNTPlace");
  652. return true;
  653. }
  654. else
  655. {
  656. LogObject.Error(Name, "无法开始 MPNTPlace");
  657. return false;
  658. }
  659. }
  660. private bool fMPNTPick(object[] param)
  661. {
  662. RState result = _pickExtendRoutine.Monitor();
  663. if (result == RState.Failed || result == RState.Timeout)
  664. {
  665. LogObject.Error(Name, "MPNTPick 执行失败 置错误");
  666. PostMsg(MSG.ERROR);
  667. return false;
  668. }
  669. return result == RState.End;
  670. }
  671. private bool fStartMPNTPick(object[] param)
  672. {
  673. if (param.Length != 4)
  674. {
  675. LogObject.Error(Name, "参数数量不符要求 MPNTPick无法执行");
  676. return false;
  677. }
  678. _pickExtendRoutine.Source = ModuleHelper.Converter((string)param[0]);
  679. _pickExtendRoutine.Slot = (int)param[1];
  680. _pickExtendRoutine.Blade = (Hand)param[2];
  681. _pickExtendRoutine.TaskEnum = (MpntTaskEnum)param[3];
  682. RState result = _pickExtendRoutine.Start(param);
  683. if (result == RState.Running)
  684. {
  685. LogObject.Info(Name, "开始 MPNTPick");
  686. return true;
  687. }
  688. else
  689. {
  690. LogObject.Error(Name, "无法开始 MPNTPick");
  691. return false;
  692. }
  693. }
  694. private bool fPlace(object[] param)
  695. {
  696. RState result = _placeRoutine.Monitor();
  697. if (result == RState.Failed || result == RState.Timeout)
  698. {
  699. LogObject.Error(Name, "place 执行失败 置错误");
  700. PostMsg(MSG.ERROR);
  701. return false;
  702. }
  703. return result == RState.End;
  704. }
  705. private bool fStartPlace(object[] param)
  706. {
  707. if (param.Length != 3)
  708. {
  709. LogObject.Error(Name, "参数数量不符要求 Place无法执行");
  710. return false;
  711. }
  712. _placeRoutine.Station = ModuleHelper.Converter((string)param[0]);
  713. _placeRoutine.Slot = (int)param[1];
  714. _placeRoutine.Blade = (Hand)Enum.Parse(typeof(Hand), (string)param[2]);
  715. RState result = _placeRoutine.Start(param);
  716. if (result == RState.Running)
  717. {
  718. LogObject.Info(Name, "开始 Place");
  719. return true;
  720. }
  721. else
  722. {
  723. LogObject.Error(Name, "无法开始 Place");
  724. return false;
  725. }
  726. }
  727. private bool fPick(object[] param)
  728. {
  729. RState result = _pickRoutine.Monitor();
  730. if (result == RState.Failed || result == RState.Timeout)
  731. {
  732. LogObject.Error(Name, "pick 执行失败 置错误");
  733. PostMsg(MSG.ERROR);
  734. return false;
  735. }
  736. return result == RState.End;
  737. }
  738. private bool fStartPick(object[] param)
  739. {
  740. if (param.Length != 3)
  741. {
  742. LogObject.Error(Name, "参数数量不符要求 Pick无法执行");
  743. return false;
  744. }
  745. _pickRoutine.Source = ModuleHelper.Converter((string)param[0]);
  746. _pickRoutine.Slot = (int)param[1];
  747. _pickRoutine.Blade = (Hand)Enum.Parse(typeof(Hand), (string)param[2]);
  748. RState result = _pickRoutine.Start(param);
  749. if (result == RState.Running)
  750. {
  751. LogObject.Info(Name, "开始 Pick");
  752. return true;
  753. }
  754. else
  755. {
  756. LogObject.Error(Name, "无法开始 Pick");
  757. return false;
  758. }
  759. }
  760. private bool fSwap(object[] param)
  761. {
  762. RState result = _swapRoutine.Monitor();
  763. if (result == RState.Failed || result == RState.Timeout)
  764. {
  765. LogObject.Error(Name, "swap 执行失败 置错误");
  766. PostMsg(MSG.ERROR);
  767. return false;
  768. }
  769. return result == RState.End;
  770. }
  771. private bool fStartSwap(object[] param)
  772. {
  773. if (param.Length != 3)
  774. {
  775. LogObject.Error(Name, "参数数量不符要求 Swap无法执行");
  776. return false;
  777. }
  778. _swapRoutine.Source = ModuleHelper.Converter((string)param[0]);
  779. _swapRoutine.Slot = (int)param[1];
  780. _swapRoutine.PlaceBlade = (Hand)Enum.Parse(typeof(Hand), (string)param[2]);
  781. RState result = _swapRoutine.Start(param);
  782. if (result == RState.Running)
  783. {
  784. LogObject.Info(Name, "开始 Swap");
  785. return true;
  786. }
  787. else
  788. {
  789. LogObject.Error(Name, "无法开始 Swap");
  790. return false;
  791. }
  792. }
  793. private bool fMapWafer(object[] param)
  794. {
  795. RState result = _waferMapRoutine.Monitor();
  796. if (result == RState.Failed || result == RState.Timeout)
  797. {
  798. LogObject.Error(Name, "Wafer Map 执行失败 置错误");
  799. PostMsg(MSG.ERROR);
  800. return false;
  801. }
  802. return result == RState.End;
  803. }
  804. private bool fStartMapWafer(object[] param)
  805. {
  806. RState result = _waferMapRoutine.Start(param);
  807. if (result == RState.Running)
  808. {
  809. LogObject.Info(Name, "开始 Wafer Map");
  810. return true;
  811. }
  812. else
  813. {
  814. LogObject.Error(Name, "无法开始 Wafer Map");
  815. return false;
  816. }
  817. }
  818. private bool fSetSpeed(object[] param)
  819. {
  820. RState result = setspeedRoutine.Monitor();
  821. if (result == RState.Failed || result == RState.Timeout)
  822. {
  823. LogObject.Error(Name, "set speed 执行失败 置错误");
  824. PostMsg(MSG.ERROR);
  825. return false;
  826. }
  827. return result == RState.End;
  828. }
  829. private bool fStartSetSpeed(object[] param)
  830. {
  831. RState result = setspeedRoutine.Start();
  832. //setspeedRoutine.Speed = (int)param[0];
  833. if (result == RState.Running)
  834. {
  835. LogObject.Info(Name, "开始进入 set speed ");
  836. return true;
  837. }
  838. else
  839. {
  840. LogObject.Error(Name, "无法开始 set speed");
  841. return false;
  842. }
  843. }
  844. private bool fWriteID(object[] param)
  845. {
  846. LogObject.Info(Name, "LP WriteRFID 开始");
  847. PostToLP((ModuleName)param[0], LoadPortEntity.MSG.WriteRFID);
  848. return true;
  849. }
  850. private bool fReadAndLoad(object[] param)
  851. {
  852. LogObject.Info(Name, "LP ReadAndLoad 开始");
  853. PostToLP((ModuleName)param[0], LoadPortEntity.MSG.ReadAndLoad);
  854. return true;
  855. }
  856. private bool fReadID(object[] param)
  857. {
  858. LogObject.Info(Name, "LP fReadID 开始");
  859. PostToLP((ModuleName)param[0], LoadPortEntity.MSG.ReadRFID);
  860. return true;
  861. }
  862. private bool fLPUnLoad(object[] param)
  863. {
  864. LogObject.Info(Name, "LP unLoad 开始");
  865. PostToLP((ModuleName)param[0], LoadPortEntity.MSG.Unload);
  866. return true;
  867. }
  868. private bool fLPLoad(object[] param)
  869. {
  870. //debug
  871. LogObject.Info(Name, "LP Load 开始");
  872. PostToLP((ModuleName)param[0], LoadPortEntity.MSG.Load);
  873. return true;
  874. }
  875. private bool fIdle(object[] param)
  876. {
  877. LogObject.Info(Name, "置为Idle 清空所有task");
  878. _taskState.Clear();
  879. return true;
  880. }
  881. private bool fStartReset(object[] objs)
  882. {
  883. LogObject.Info(Name, "开始重置");
  884. if (fsm.State == 9)
  885. {
  886. LogObject.Info(Name, "FSM重置成功");
  887. return true;
  888. }
  889. else
  890. {
  891. LogObject.Error(Name, "FSM重置失败");
  892. return false;
  893. }
  894. }
  895. private bool fError(object[] param)
  896. {
  897. //切换到错误状态
  898. for (int index = 0; index < _taskState.Count; index++)
  899. {
  900. //将所有任务置错误状态
  901. _taskState[_taskState.ElementAt(index).Key] = RState.Failed;
  902. }
  903. return true;
  904. }
  905. private bool fInit(object[] param)
  906. {
  907. switch (initRoutine.Monitor())
  908. {
  909. case RState.End:
  910. return true;
  911. case RState.Failed:
  912. return true;
  913. default:
  914. return false;
  915. }
  916. }
  917. private bool fStartInit(object[] param)
  918. {
  919. //开始初始化 部分内容
  920. switch (initRoutine.Start())
  921. {
  922. case RState.End:
  923. return false;
  924. case RState.Failed:
  925. return false;
  926. default:
  927. return true;
  928. }
  929. }
  930. private bool fAbort(object[] param) => true;//??? 别问 问就是反编译源码就是这么写的
  931. /// <summary>
  932. /// 给LP发送消息 通过chamber的名称 获取LP1-10后的后缀数字
  933. /// 在不越过LP数量的情况下 对LP 发送Post信息
  934. /// </summary>
  935. /// <param name="chamber"></param>
  936. /// <param name="msg"></param>
  937. /// <param name="objs"></param>
  938. /// <returns></returns>
  939. private bool PostToLP(ModuleName chamber, LoadPortEntity.MSG msg, params object[] objs)
  940. {
  941. //获取是哪一个LP发送msg信息
  942. int num = int.Parse(new Regex("[1-9]\\d*").Match(chamber.ToString()).ToString());
  943. //在不越界的情况下 进行信息发送
  944. if (num <= LoadPortQuantity)
  945. {
  946. LogObject.Info(Name, $"给{chamber}发送{msg}");
  947. _loadportEntities[num - 1].PostMsg(msg, objs);
  948. }
  949. return true;
  950. }
  951. public LoadPortEntity GetLP(ModuleName chamber)
  952. {
  953. int num = int.Parse(new Regex("[1-9]\\d*").Match(chamber.ToString()).ToString());
  954. return _loadportEntities[num - 1];
  955. }
  956. public bool CheckAcked(int msg) => fsm.CheckExecuted(msg);
  957. public int Invoke(string function, params object[] args)
  958. {
  959. switch (function)
  960. {
  961. //case "Home":
  962. // CheckToPostMsg(MSG.HOME);
  963. // return (int)MSG.HOME;
  964. case "RESET":
  965. CheckToPostMsg(MSG.RESET);
  966. return (int)MSG.RESET;
  967. case "MPNTPlace":
  968. CheckToPostMsg(MSG.MPNTPlace, args[0], args[1], args[2], args[3]);
  969. return (int)MSG.MPNTPlace;
  970. case "MPNTPick":
  971. CheckToPostMsg(MSG.MPNTPick, args[0], args[1], args[2], args[3]);
  972. return (int)MSG.MPNTPick;
  973. case "Pick":
  974. CheckToPostMsg(MSG.Pick, args[0], args[1], args[2]);
  975. return (int)MSG.Pick;
  976. case "Place":
  977. CheckToPostMsg(MSG.Place, args[0], args[1], args[2]);
  978. return (int)MSG.Place;
  979. default:
  980. LogObject.Warning("TASK","Task下发的指令不在预期");
  981. return -1;
  982. }
  983. }
  984. public void InitDevice() {
  985. _flipper = new FlipperEntity(ModuleName.TurnOverStation);
  986. _flipper.Initialize();
  987. Robot = DEVICE.GetDevice<RobotBaseDevice>("Robot");//连接做在初始化里面了
  988. //RR751.InitializeRobot();
  989. _lp1 = new LoadPortEntity(ModuleName.LP1.ToString(), Robot);
  990. _lp2 = new LoadPortEntity(ModuleName.LP2.ToString(), Robot);
  991. _lp3 = new LoadPortEntity(ModuleName.LP3.ToString(), Robot);
  992. _lp4 = new LoadPortEntity(ModuleName.LP4.ToString(), Robot);
  993. _lp5 = new LoadPortEntity(ModuleName.LP5.ToString(), Robot);
  994. _lp6 = new LoadPortEntity(ModuleName.LP6.ToString(), Robot);
  995. _lp7 = new LoadPortEntity(ModuleName.LP7.ToString(), Robot);
  996. _lp8 = new LoadPortEntity(ModuleName.LP8.ToString(), Robot);
  997. _lp9 = new LoadPortEntity(ModuleName.LP9.ToString(), Robot);
  998. _lp10 = new LoadPortEntity(ModuleName.LP10.ToString(), Robot);
  999. _loadportEntities = new LoadPortEntity[10]
  1000. {
  1001. _lp1,
  1002. _lp2,
  1003. _lp3,
  1004. _lp4,
  1005. _lp5,
  1006. _lp6,
  1007. _lp7,
  1008. _lp8,
  1009. _lp9,
  1010. _lp10
  1011. };
  1012. Trace.WriteLine(LoadPortQuantity);
  1013. for (int index = 0; index < LoadPortQuantity; ++index)
  1014. _loadportEntities[index].Initialize();
  1015. Trace.WriteLine(EFemNum);
  1016. string efemNum = EFemNum;
  1017. if (!(efemNum == "001"))
  1018. {
  1019. if (efemNum == "002")
  1020. {
  1021. DeviceModel.SensorSMIF1PODOPEN.OnSignalChanged += new Action<IoSensor, bool>(SensorSMIF1PODOPEN_OnSignalChanged);
  1022. DeviceModel.SensorSMIF2PODOPEN.OnSignalChanged += new Action<IoSensor, bool>(SensorSMIF2PODOPEN_OnSignalChanged);
  1023. DeviceModel.SensorWaterLeakSW.OnSignalChanged += new Action<IoSensor, bool>(SensorWaterLeakSW_OnSignalChanged);
  1024. DeviceModel.SensorGratingSensorIN1.OnSignalChanged += new Action<IoSensor, bool>(SensorGratingSensorIN1_OnSignalChanged);
  1025. }
  1026. else
  1027. {
  1028. DeviceModel.SensorPMASystemInterlock.OnSignalChanged += new Action<IoSensor, bool>(SensorPMASystemInterlock_OnSignalChanged);
  1029. DeviceModel.SensorPMBSystemInterlock.OnSignalChanged += new Action<IoSensor, bool>(SensorPMBSystemInterlock_OnSignalChanged);
  1030. DeviceModel.SensorRBNotExtendSIMF1.OnSignalChanged += new Action<IoSensor, bool>(SensorRBNotExtendSIMF1_OnSignalChanged);
  1031. DeviceModel.SensorRBNotExtendSIMF2.OnSignalChanged += new Action<IoSensor, bool>(SensorRBNotExtendSIMF2_OnSignalChanged);
  1032. DeviceModel.SensorSMIF1PODOPEN.OnSignalChanged += new Action<IoSensor, bool>(SensorSMIF1PODOPEN_OnSignalChanged);
  1033. DeviceModel.SensorSMIF2PODOPEN.OnSignalChanged += new Action<IoSensor, bool>(SensorSMIF2PODOPEN_OnSignalChanged);
  1034. DeviceModel.SensorWaterLeakSW.OnSignalChanged += new Action<IoSensor, bool>(SensorWaterLeakSW_OnSignalChanged);
  1035. DeviceModel.SensorGratingSensorIN1.OnSignalChanged += new Action<IoSensor, bool>(SensorGratingSensorIN1_OnSignalChanged);
  1036. }
  1037. }
  1038. else
  1039. {
  1040. DeviceModel.SensorPMASystemInterlock.OnSignalChanged += new Action<IoSensor, bool>(SensorPMASystemInterlock_OnSignalChanged);
  1041. DeviceModel.SensorPMBSystemInterlock.OnSignalChanged += new Action<IoSensor, bool>(SensorPMBSystemInterlock_OnSignalChanged);
  1042. DeviceModel.SensorRBNotExtendSIMF1.OnSignalChanged += new Action<IoSensor, bool>(SensorRBNotExtendSIMF1_OnSignalChanged);
  1043. DeviceModel.SensorRBNotExtendSIMF2.OnSignalChanged += new Action<IoSensor, bool>(SensorRBNotExtendSIMF2_OnSignalChanged);
  1044. DeviceModel.SensorSMIF1PODOPEN.OnSignalChanged += new Action<IoSensor, bool>(SensorSMIF1PODOPEN_OnSignalChanged);
  1045. DeviceModel.SensorSMIF2PODOPEN.OnSignalChanged += new Action<IoSensor, bool>(SensorSMIF2PODOPEN_OnSignalChanged);
  1046. DeviceModel.SensorWaterLeakSW.OnSignalChanged += new Action<IoSensor, bool>(SensorWaterLeakSW_OnSignalChanged);
  1047. DeviceModel.SensorGratingSensorIN1.OnSignalChanged += new Action<IoSensor, bool>(SensorGratingSensorIN1_OnSignalChanged);
  1048. }
  1049. }
  1050. public void RoutineInit() {
  1051. setspeedRoutine = new SetSpeedRoutine(ModuleName.System);
  1052. initRoutine = new InitRoutine(ModuleName.System);
  1053. _waferMapRoutine = new WaferMappingRoutine(ModuleName.System);
  1054. _loadFoupRoutine = new LoadFoupRoutine(ModuleName.LP1);
  1055. _pickRoutine = new PickRoutine(ModuleName.System);
  1056. _placeRoutine = new PlaceRoutine(ModuleName.System);
  1057. _pickExtendRoutine = new PickExtendRoutine(ModuleName.System);
  1058. _placeExtendRoutine = new PlaceExtendRoutine(ModuleName.System);
  1059. _alignRoutine = new AlignRoutine();
  1060. _staticTransfer = new StaticTransfer();
  1061. _cycle = new AutoCycle(ModuleName.System);
  1062. _swapRoutine = new SwapRoutine(ModuleName.System);
  1063. }
  1064. private void SensorRBNotExtendSIMF2_OnSignalChanged(IoSensor arg1, bool arg2)
  1065. {
  1066. string reason = "";
  1067. if (!arg2)
  1068. {
  1069. DeviceModel.TrigRBbusytoSIMF2.SetTrigger(true, out reason);
  1070. LogObject.Error(Name, "SensorRBNotExtendSIMF2 signal change,set TrigRBbusytoSIMF2 signal on.");
  1071. }
  1072. else
  1073. {
  1074. DeviceModel.TrigRBbusytoSIMF2.SetTrigger(false, out reason);
  1075. LogObject.Error(Name, "SensorRBNotExtendSIM2 signal change,set TrigRBbusytoSIMF2 signal off.");
  1076. }
  1077. }
  1078. private void SensorRBNotExtendSIMF1_OnSignalChanged(IoSensor arg1, bool arg2)
  1079. {
  1080. string reason = "";
  1081. if (!arg2)
  1082. {
  1083. DeviceModel.TrigRBbusytoSIMF1.SetTrigger(true, out reason);
  1084. LogObject.Error(Name, "SensorRBNotExtendSIMF1 signal change,set TrigRBbusytoSIMF1 signal on.");
  1085. //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);
  1086. }
  1087. else
  1088. {
  1089. DeviceModel.TrigRBbusytoSIMF1.SetTrigger(false, out reason);
  1090. LogObject.Error(Name, "SensorRBNotExtendSIMF1 signal change,set TrigRBbusytoSIMF1 signal off.");
  1091. //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);
  1092. }
  1093. }
  1094. private void SensorGratingSensorIN1_OnSignalChanged(IoSensor arg1, bool arg2)
  1095. {
  1096. string reason = "";
  1097. if (!arg2)
  1098. {
  1099. if (fsm.State != 5 && fsm.State != 4 && fsm.State != 22 && fsm.State != 21)
  1100. return;
  1101. DeviceModel.TrigPauseResumetoRobot.SetTrigger(true, out reason);
  1102. }
  1103. else
  1104. DeviceModel.TrigPauseResumetoRobot.SetTrigger(false, out reason);
  1105. }
  1106. private void SensorWaterLeakSW_OnSignalChanged(IoSensor arg1, bool arg2)
  1107. {
  1108. string reason;
  1109. if (!arg2)
  1110. {
  1111. if (fsm.State != 5 && fsm.State != 4 && fsm.State != 22 && fsm.State != 21)
  1112. return;
  1113. DeviceModel.TrigPauseResumetoRobot.SetTrigger(true, out reason);
  1114. }
  1115. else
  1116. DeviceModel.TrigPauseResumetoRobot.SetTrigger(false, out reason);
  1117. }
  1118. private void SensorSMIF2PODOPEN_OnSignalChanged(IoSensor arg1, bool arg2)
  1119. {
  1120. string reason = "";
  1121. if (arg2)
  1122. {
  1123. DeviceModel.TrigSafetytoSMIF2.SetTrigger(true, out reason);
  1124. LogObject.Error(Name, "SensorSMIF2PODOPEN signal change,set TrigSafetytoSMIF2 signal on.");
  1125. //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);
  1126. }
  1127. else
  1128. {
  1129. DeviceModel.TrigSafetytoSMIF2.SetTrigger(false, out reason);
  1130. LogObject.Error(Name, "SensorSMIF2PODOPEN signal change,set TrigSafetytoSMIF2 signal off.");
  1131. //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);
  1132. }
  1133. }
  1134. private void SensorSMIF1PODOPEN_OnSignalChanged(IoSensor arg1, bool arg2)
  1135. {
  1136. string reason = "";
  1137. if (arg2)
  1138. {
  1139. DeviceModel.TrigSafetytoSMIF1.SetTrigger(true, out reason);
  1140. LogObject.Error(Name, "SensorSMIF1PODOPEN signal change,set TrigSafetytoSMIF1 signal on.");
  1141. //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);
  1142. }
  1143. else
  1144. {
  1145. DeviceModel.TrigSafetytoSMIF1.SetTrigger(false, out reason);
  1146. LogObject.Error(Name, "SensorSMIF1PODOPEN signal change,set TrigSafetytoSMIF1 signal off.");
  1147. //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);
  1148. }
  1149. }
  1150. private void SensorPMBSystemInterlock_OnSignalChanged(IoSensor arg1, bool arg2)
  1151. {
  1152. string reason = "";
  1153. if (arg2)
  1154. {
  1155. DeviceModel.TrigSafetytoPMB.SetTrigger(true, out reason);
  1156. LogObject.Error("RT", "SensorPMBSystemInterlock signal change,set TrigSafetytoPMB signal on.");
  1157. //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);
  1158. }
  1159. else
  1160. {
  1161. DeviceModel.TrigSafetytoPMB.SetTrigger(false, out reason);
  1162. LogObject.Error("RT", "SensorPMBSystemInterlock signal change,set TrigSafetytoPMA signal off.");
  1163. }
  1164. }
  1165. public bool CheckToPostMsg(RouteManager1.MSG msg)
  1166. {
  1167. Trace.WriteLine($"收到信息{msg}");
  1168. if (!this.fsm.FindTransition(this.fsm.State, (int)msg))
  1169. {
  1170. 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));
  1171. return false;
  1172. }
  1173. this.PostMsg<RouteManager1.MSG>(msg);
  1174. return true;
  1175. }
  1176. public bool CheckToPostMsg(MSG msg, object param1)
  1177. {
  1178. Trace.WriteLine($"收到信息{msg},包含参数{param1}");
  1179. if (!this.fsm.FindTransition(this.fsm.State, (int)msg))
  1180. {
  1181. 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));
  1182. return false;
  1183. }
  1184. this.PostMsg<RouteManager1.MSG>(msg, param1);
  1185. return true;
  1186. }
  1187. public bool CheckToPostMsg(MSG msg, object param1, object param2)
  1188. {
  1189. Trace.WriteLine($"收到信息{msg},包含参数{param1}/{param2}");
  1190. if (!this.fsm.FindTransition(this.fsm.State, (int)msg))
  1191. {
  1192. 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));
  1193. return false;
  1194. }
  1195. this.PostMsg<MSG>(msg, param1, param2);
  1196. return true;
  1197. }
  1198. public bool CheckToPostMsg(MSG msg, object param1, object param2, object param3)
  1199. {
  1200. Trace.WriteLine($"收到信息{msg},包含参数{param1}/{param2}/{param3}");
  1201. if (!this.fsm.FindTransition(this.fsm.State, (int)msg))
  1202. {
  1203. 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));
  1204. return false;
  1205. }
  1206. this.PostMsg<MSG>(msg, param1, param2, param3);
  1207. return true;
  1208. }
  1209. public bool CheckToPostMsg(
  1210. MSG msg,
  1211. object param1,
  1212. object param2,
  1213. object param3,
  1214. object param4)
  1215. {
  1216. Trace.WriteLine($"收到信息{msg},包含参数{param1}/{param2}/{param3}/{param4}");
  1217. if (!this.fsm.FindTransition(this.fsm.State, (int)msg))
  1218. {
  1219. 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));
  1220. return false;
  1221. }
  1222. this.PostMsg<MSG>(msg, param1, param2, param3, param4);
  1223. return true;
  1224. }
  1225. private void SensorPMASystemInterlock_OnSignalChanged(IoSensor arg1, bool arg2)
  1226. {
  1227. string reason = "";
  1228. if (arg2)
  1229. {
  1230. DeviceModel.TrigSafetytoPMA.SetTrigger(true, out reason);
  1231. LogObject.Error(Name, "SensorPMASystemInterlock signal change,set TrigSafetytoPMB signal on.");
  1232. }
  1233. else
  1234. {
  1235. DeviceModel.TrigSafetytoPMA.SetTrigger(false, out reason);
  1236. LogObject.Error(Name, "SensorPMASystemInterlock signal change,set TrigSafetytoPMB signal off.");
  1237. }
  1238. }
  1239. public void MapBuffer()
  1240. {
  1241. List<bool> boolList1 = new List<bool>()
  1242. {
  1243. false,
  1244. false,
  1245. false,
  1246. false,
  1247. false
  1248. };
  1249. int num1 = 0;
  1250. foreach (bool flag in boolList1)
  1251. {
  1252. if (!flag && Singleton<WaferManager>.Instance.CheckNoWafer(ModuleName.Buffer, num1))
  1253. Singleton<WaferManager>.Instance.CreateWafer(ModuleName.Buffer, num1, WaferStatus.Normal);
  1254. else if (flag && Singleton<WaferManager>.Instance.CheckHasWafer(ModuleName.Buffer, num1))
  1255. Singleton<WaferManager>.Instance.DeleteWafer(ModuleName.Buffer, num1);
  1256. ++num1;
  1257. }
  1258. List<bool> boolList2 = new List<bool>()
  1259. {
  1260. DeviceModel.SensorRBlowerArmhavewafer.Value,
  1261. DeviceModel.SensorRBupperArmhavewafer.Value
  1262. };
  1263. int num2 = 0;
  1264. foreach (bool flag in boolList2)
  1265. {
  1266. if (!flag && Singleton<WaferManager>.Instance.CheckNoWafer(ModuleName.Robot, num2))
  1267. Singleton<WaferManager>.Instance.CreateWafer(ModuleName.Robot, num2, WaferStatus.Normal);
  1268. else if (flag && Singleton<WaferManager>.Instance.CheckHasWafer(ModuleName.Robot, num2))
  1269. Singleton<WaferManager>.Instance.DeleteWafer(ModuleName.Robot, num2);
  1270. ++num2;
  1271. }
  1272. }
  1273. private bool check(MoveType type, Hand blade, out string reason)
  1274. {
  1275. reason = string.Empty;
  1276. if (type == MoveType.Move || blade != Hand.Both)
  1277. return true;
  1278. reason = string.Format("非法的参数。单片传盘时,不能指定Both blade");
  1279. return false;
  1280. }
  1281. private bool checkMove(out string reason, params object[] args)
  1282. {
  1283. MoveType type = (MoveType)args[0];
  1284. MoveOption option = (MoveOption)args[1];
  1285. Hand blade = (Hand)args[2];
  1286. ModuleName source1 = (ModuleName)args[3];
  1287. int slot1 = (int)args[4];
  1288. ModuleName dest1 = (ModuleName)args[5];
  1289. int dslot1 = (int)args[6];
  1290. ModuleName source2 = (ModuleName)args[3];
  1291. int slot2 = (int)args[4];
  1292. ModuleName dest2 = (ModuleName)args[5];
  1293. int dslot2 = (int)args[6];
  1294. if (type != 0)
  1295. {
  1296. source2 = (ModuleName)args[7];
  1297. slot2 = (int)args[8];
  1298. dest2 = (ModuleName)args[9];
  1299. dslot2 = (int)args[10];
  1300. }
  1301. if (!this.check(type, blade, out reason))
  1302. {
  1303. EV.PostWarningLog("System", "Can not move wafer, " + reason);
  1304. return false;
  1305. }
  1306. if (!this.check(source1, slot1, dest1, dslot1, blade, option, out reason))
  1307. {
  1308. EV.PostWarningLog("System", "Can not move wafer, " + reason);
  1309. return false;
  1310. }
  1311. if (type == 0 || this.check(source2, slot2, dest2, dslot2, out reason))
  1312. return true;
  1313. EV.PostWarningLog("System", "Can not move wafer, " + reason);
  1314. return false;
  1315. }
  1316. public bool InvokeMoveWafer(string arg1, object[] args)
  1317. {
  1318. this.Running = false;
  1319. string reason = "";
  1320. if (this.checkMove(out reason, args))
  1321. {
  1322. MoveType moveType = (MoveType)args[0];
  1323. MoveOption moveOption = (MoveOption)args[1];
  1324. Hand hand = (Hand)args[2];
  1325. ModuleName moduleName1 = (ModuleName)args[3];
  1326. int num1 = (int)args[4];
  1327. ModuleName moduleName2 = (ModuleName)args[5];
  1328. int num2 = (int)args[6];
  1329. ModuleName moduleName3 = (ModuleName)args[3];
  1330. int num3 = (int)args[4];
  1331. ModuleName moduleName4 = (ModuleName)args[5];
  1332. int num4 = (int)args[6];
  1333. if (moveType != 0)
  1334. {
  1335. moduleName3 = (ModuleName)args[7];
  1336. num3 = (int)args[8];
  1337. moduleName4 = (ModuleName)args[9];
  1338. num4 = (int)args[10];
  1339. }
  1340. this._taskState[arg1] = RState.Running;
  1341. 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);
  1342. }
  1343. else
  1344. this._taskState[arg1] = RState.Failed;
  1345. return true;
  1346. }
  1347. private bool checkFoup(ModuleName chamber, out string reason)
  1348. {
  1349. reason = string.Empty;
  1350. if (!ModuleHelper.IsLoadPort(chamber) || DEVICE.GetDevice<LoadPortBaseDevice>(chamber.ToString()).IsEnableTransferWafer(out reason))
  1351. return true;
  1352. reason = string.Format("{0} isn't Ready, {1}", (object)chamber.ToString(), (object)reason);
  1353. return false;
  1354. }
  1355. private bool check(
  1356. ModuleName source,
  1357. int slot,
  1358. ModuleName dest,
  1359. int dslot,
  1360. out string reason)
  1361. {
  1362. reason = string.Empty;
  1363. if (!this.checkFoup(source, out reason) || !this.checkFoup(dest, out reason))
  1364. return false;
  1365. if (!Singleton<WaferManager>.Instance.IsWaferSlotLocationValid(source, slot))
  1366. {
  1367. reason = string.Format("非法的参数。{0}:{1:D2}", (object)source.ToString(), (object)slot);
  1368. return false;
  1369. }
  1370. if (!Singleton<WaferManager>.Instance.IsWaferSlotLocationValid(dest, dslot))
  1371. {
  1372. reason = string.Format("非法的参数。{0}:{1:D2}", (object)dest.ToString(), (object)dslot);
  1373. return false;
  1374. }
  1375. if (!Singleton<WaferManager>.Instance.CheckWafer(source, slot, WaferStatus.Normal))
  1376. {
  1377. reason = string.Format("源位置没有wafer。{0}:{1:D2}", (object)source.ToString(), (object)slot);
  1378. return false;
  1379. }
  1380. if (Singleton<WaferManager>.Instance.CheckWafer(dest, dslot, WaferStatus.Empty))
  1381. return true;
  1382. reason = string.Format("目标位置有wafer。{0}:{1:D2}", (object)dest.ToString(), (object)dslot);
  1383. return false;
  1384. }
  1385. private bool check(
  1386. ModuleName source,
  1387. int slot,
  1388. ModuleName dest,
  1389. int dslot,
  1390. Hand blade,
  1391. MoveOption option,
  1392. out string reason)
  1393. {
  1394. reason = string.Empty;
  1395. if (!this.checkFoup(source, out reason) || !this.checkFoup(dest, out reason))
  1396. return false;
  1397. if (!Singleton<WaferManager>.Instance.IsWaferSlotLocationValid(source, slot))
  1398. {
  1399. reason = string.Format("Invalid source parameter, {0}:{1:D2}", (object)source.ToString(), (object)slot);
  1400. return false;
  1401. }
  1402. if (!Singleton<WaferManager>.Instance.IsWaferSlotLocationValid(dest, dslot))
  1403. {
  1404. reason = string.Format("Invalid destination parameter, {0}:{1:D2}", (object)dest.ToString(), (object)dslot);
  1405. return false;
  1406. }
  1407. if (!Singleton<WaferManager>.Instance.CheckWafer(source, slot, WaferStatus.Normal))
  1408. {
  1409. if (ModuleHelper.IsLoadLock(source) && Singleton<EfemEntity>.Instance.IsOnlineMode)
  1410. {
  1411. Singleton<WaferManager>.Instance.CreateWafer(source, slot, WaferStatus.Normal);
  1412. }
  1413. else
  1414. {
  1415. reason = string.Format("Source no normal wafer, {0}:{1:D2}", (object)source.ToString(), (object)slot);
  1416. return false;
  1417. }
  1418. }
  1419. if (!Singleton<WaferManager>.Instance.CheckWafer(dest, dslot, WaferStatus.Empty))
  1420. {
  1421. reason = string.Format("destination has wafer, {0}:{1:D2}", (object)dest.ToString(), (object)dslot);
  1422. return false;
  1423. }
  1424. if (source != ModuleName.Robot && dest != ModuleName.Robot && !Singleton<WaferManager>.Instance.CheckWafer(ModuleName.Robot, (int)blade, WaferStatus.Empty))
  1425. {
  1426. reason = string.Format("robot has wafer on arm");
  1427. return false;
  1428. }
  1429. 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))
  1430. return true;
  1431. reason = string.Format("aligner has wafer on");
  1432. return false;
  1433. }
  1434. public enum MSG
  1435. {
  1436. MultiMoveWafer,
  1437. MoveWafer,
  1438. ReturnWafer,
  1439. SetSpeed,
  1440. HomeUnit,
  1441. ReadID,
  1442. WriteID,
  1443. ReadAndLoad,
  1444. LOAD,
  1445. UNLOAD,
  1446. Pause,
  1447. Resume,
  1448. Stop,
  1449. StartCycle,
  1450. Init,
  1451. HOME,
  1452. RESET,
  1453. ABORT,
  1454. ERROR,
  1455. StartRecipe,
  1456. StopRecipe,
  1457. PauseRecipe,
  1458. ResumeRecipe,
  1459. SetAutoMode,
  1460. SetManualMode,
  1461. SetMaintenanceMode,
  1462. MapWafer,
  1463. Pick,
  1464. Place,
  1465. MPNTPick,
  1466. MPNTPlace,
  1467. RobotActionDone,
  1468. LoadPortActionDone,
  1469. ChangeCassette,
  1470. Debug,
  1471. Align,
  1472. Swap
  1473. }
  1474. }
  1475. }