EquipmentManager.cs 69 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871
  1. using System;
  2. using System.Collections.Generic;
  3. using System.IO;
  4. using System.Linq;
  5. using System.Threading.Tasks;
  6. using System.Windows.Media;
  7. using System.Xml;
  8. using Aitex.Common.Util;
  9. using Aitex.Core.Common;
  10. using Aitex.Core.RT.DataCenter;
  11. using Aitex.Core.RT.Device;
  12. using Aitex.Core.RT.Event;
  13. using Aitex.Core.RT.Fsm;
  14. using Aitex.Core.RT.Log;
  15. using Aitex.Core.RT.OperationCenter;
  16. using Aitex.Core.RT.RecipeCenter;
  17. using Aitex.Core.RT.Routine;
  18. using Aitex.Core.RT.SCCore;
  19. using Aitex.Core.Util;
  20. using Aitex.Core.Utilities;
  21. using FurnaceRT.Devices;
  22. using FurnaceRT.Equipments.CarrierRobots;
  23. using FurnaceRT.Equipments.FIMSs;
  24. using FurnaceRT.Equipments.Jobs;
  25. using FurnaceRT.Equipments.LPs;
  26. using FurnaceRT.Equipments.PMs;
  27. using FurnaceRT.Equipments.PMs.RecipeExecutions;
  28. using FurnaceRT.Equipments.Schedulers;
  29. using FurnaceRT.Equipments.Stockers;
  30. using FurnaceRT.Equipments.WaferRobots;
  31. using FurnaceRT.Instances;
  32. using MECF.Framework.Common.Alarms;
  33. using MECF.Framework.Common.DataCenter;
  34. using MECF.Framework.Common.Device.Bases;
  35. using MECF.Framework.Common.Equipment;
  36. using MECF.Framework.Common.FAServices;
  37. using MECF.Framework.Common.Jobs;
  38. using MECF.Framework.Common.SCCore;
  39. using MECF.Framework.Common.SubstrateTrackings;
  40. using MECF.Framework.FA.Core.FAControl;
  41. using MECF.Framework.RT.Core.Applications;
  42. using MECF.Framework.RT.Core.IoProviders;
  43. using MECF.Framework.RT.EquipmentLibrary.HardwareUnits.PMs;
  44. using AutoTransfer = FurnaceRT.Equipments.Jobs.AutoTransfer;
  45. using ReturnAllWafer = FurnaceRT.Equipments.Jobs.ReturnAllWafer;
  46. namespace FurnaceRT.Equipments.Systems
  47. {
  48. public enum RtState
  49. {
  50. Init,
  51. Initializing,
  52. Idle,
  53. Transfer,
  54. AutoRunning,
  55. AutoIdle,
  56. ReturnAllWafer,
  57. Error,
  58. Loading,
  59. Unloading,
  60. ChargeProcessDischarging,
  61. LoadProcessStockering,
  62. LoadProcessUnloading,
  63. ReturnWafer,
  64. }
  65. public enum TransferJobState
  66. {
  67. Idle,
  68. Error,
  69. Loading,
  70. Unloading,
  71. }
  72. public enum ProcessJobState
  73. {
  74. Idle,
  75. Error,
  76. Charging,
  77. Processing,
  78. Cooling,
  79. Discharging,
  80. }
  81. public partial class EquipmentManager : FsmDevice
  82. {
  83. public enum MSG
  84. {
  85. MoveWafer,
  86. ReturnAllWafer,
  87. Stop,
  88. HOME,
  89. RESET,
  90. ABORT,
  91. ERROR,
  92. ToInit,
  93. SetAutoMode,
  94. SetManualMode,
  95. FAJobCommand,
  96. CreateJob,
  97. PauseJob,
  98. ResumeJob,
  99. StartJob,
  100. StopJob,
  101. AbortJob,
  102. JobAutoStart,
  103. JobDone,
  104. ModuleError,
  105. Map,
  106. Load,
  107. Unload,
  108. ChargeProcessDischarge,
  109. LoadProcessStocker,
  110. LoadProcessUnload,
  111. CancelUnloadingJob,
  112. ToUnloading,
  113. ToLoading,
  114. CreateTransferJob,
  115. AbortTransferJob,
  116. }
  117. public Dictionary<ModuleName, ModuleFsmDevice> Modules { get; set; }
  118. public bool IsAutoMode
  119. {
  120. get
  121. {
  122. return FsmState == (int)RtState.AutoRunning || FsmState == (int)RtState.AutoIdle;
  123. }
  124. }
  125. public bool IsReturnWafer
  126. {
  127. get
  128. {
  129. return FsmState == (int)RtState.ReturnAllWafer || FsmState == (int)RtState.ReturnWafer;
  130. }
  131. }
  132. public bool IsInit
  133. {
  134. get { return FsmState == (int)RtState.Init; }
  135. }
  136. public bool IsIdle
  137. {
  138. get { return FsmState == (int)RtState.Idle; }
  139. }
  140. public bool IsAlarm
  141. {
  142. get { return FsmState == (int)RtState.Error; }
  143. }
  144. public bool IsRunning
  145. {
  146. get
  147. {
  148. return !IsAlarm && !IsIdle && !IsInit && (FsmState != (int)RtState.AutoIdle);
  149. }
  150. }
  151. public bool IsReturnWaferMode
  152. {
  153. get
  154. {
  155. return FsmState == (int)RtState.ReturnAllWafer || FsmState == (int)RtState.ReturnWafer;
  156. }
  157. }
  158. public bool IsAlarmConditionBuzzerOn { get; set; }
  159. public TransferJobState TransferJobStatus { get; set; } = TransferJobState.Idle;
  160. public ProcessJobState ProcessJobStatus { get; set; } = ProcessJobState.Idle;
  161. public object JsonConvert { get; private set; }
  162. private bool _isInited;
  163. protected IRoutine _manualTransfer;
  164. private AutoTransfer _auto = null;
  165. private TransferJob _transferJob = null;
  166. protected IRoutine _homeAll;
  167. protected IRoutine _returnAll;
  168. private string _batchType;
  169. private string _processJob;
  170. private string _processRecipe;
  171. private DeviceTimer _coolTimer = new DeviceTimer();
  172. private int _cycledCount = 0;
  173. private int _jobMSG = 0;
  174. private object[] _jobParas;
  175. private object _locker = new object();
  176. private List<string> _modules;
  177. private PeriodicJob _cycleJob;
  178. private RD_TRIG _plcConnectTrig = new RD_TRIG();
  179. public List<ModuleName> StockerNameForFATJob = new List<ModuleName>();
  180. public EquipmentManager()
  181. {
  182. Module = "System";
  183. Name = "System";
  184. Modules = new Dictionary<ModuleName, ModuleFsmDevice>();
  185. _modules = new List<string>() { "System" };
  186. }
  187. public override bool Initialize()
  188. {
  189. InitDevices();
  190. InitModules();
  191. EnumLoop<RtState>.ForEach((item) =>
  192. {
  193. MapState((int)item, item.ToString());
  194. });
  195. EnumLoop<MSG>.ForEach((item) =>
  196. {
  197. MapMessage((int)item, item.ToString());
  198. });
  199. EnableFsm(50, RtState.Init);
  200. BuildTransitionTable();
  201. SubscribeDataVariable();
  202. SubscribeOperation();
  203. InitRoutine();
  204. InitAlarmDefine();
  205. _auto = new AutoTransfer();
  206. _transferJob = new TransferJob();
  207. _cycleJob = new PeriodicJob(100, OnCycleTimer, Name, true);
  208. Singleton<EventManager>.Instance.OnAlarmEvent += Instance_OnAlarmEvent;
  209. return true;
  210. }
  211. protected void BuildModules(params ModuleFsmDevice[] modules)
  212. {
  213. if (modules != null && modules.Length > 0)
  214. {
  215. foreach (var moduleFsmDevice in modules)
  216. {
  217. Modules[ModuleHelper.Converter(moduleFsmDevice.Module)] = moduleFsmDevice;
  218. }
  219. foreach (var modulesKey in Modules.Keys)
  220. {
  221. _modules.Add(modulesKey.ToString());
  222. }
  223. foreach (var modulesValue in Modules.Values)
  224. {
  225. modulesValue.Initialize();
  226. }
  227. }
  228. }
  229. protected virtual void InitRoutine()
  230. {
  231. _homeAll = new HomeAll();
  232. _returnAll = new ReturnAllWafer();
  233. _dbCallback = new SchedulerDBCallback();
  234. }
  235. //private PeriodicJob _job1;
  236. //Stopwatch _sw = new Stopwatch();
  237. //private bool OnJob1()
  238. //{
  239. // _sw.Restart();
  240. // BufferModule buffer = Modules[ModuleName.Buffer] as BufferModule;
  241. // if (!buffer.CheckToPostMessage(BufferModule.MSG.InTransfer))
  242. // {
  243. // System.Diagnostics.Trace.Assert(false)
  244. // System.Diagnostics.Trace.WriteLine("fail to in transfer");
  245. // }
  246. // if (buffer.IsIdle)
  247. // {
  248. // System.Diagnostics.Trace.Assert(false);
  249. // System.Diagnostics.Trace.WriteLine("!!!==========>IsIdle");
  250. // }
  251. // //System.Diagnostics.Trace.Assert(buffer.IsIdle, $"in {buffer.StringFsmStatus}");
  252. // while (buffer.IsIdle)
  253. // {
  254. // Thread.Sleep(5);
  255. // }
  256. // //buffer.NoteTransferStop(ModuleName.EfemRobot, Hand.Blade1, 0, EnumTransferType.Place);
  257. // //Thread.Sleep(15);
  258. // if (!buffer.CheckToPostMessage(BufferModule.MSG.TransferComplete))
  259. // {
  260. // System.Diagnostics.Trace.Assert(false);
  261. // System.Diagnostics.Trace.WriteLine("fail to complete");
  262. // }
  263. // //if (!buffer.IsIdle)
  264. // //{
  265. // // System.Diagnostics.Trace.WriteLine("not idle");
  266. // //}
  267. // System.Diagnostics.Trace.WriteLine($" === {_sw.ElapsedMilliseconds}");
  268. // while (!buffer.IsIdle)
  269. // {
  270. // Thread.Sleep(5);
  271. // }
  272. // return true;
  273. //}
  274. private void BuildTransitionTable()
  275. {
  276. //Init sequence
  277. Transition(RtState.Init, MSG.HOME, FsmStartHome, RtState.Initializing);
  278. Transition(RtState.Idle, MSG.HOME, FsmStartHome, RtState.Initializing);
  279. Transition(RtState.Error, MSG.HOME, FsmStartHome, RtState.Initializing);
  280. Transition(RtState.Error, MSG.ToInit, null, RtState.Init);
  281. Transition(RtState.Initializing, FSM_MSG.TIMER, FsmMonitorHome, RtState.Idle);
  282. Transition(RtState.Initializing, MSG.ERROR, fError, RtState.Error);
  283. Transition(RtState.Initializing, MSG.ABORT, FsmAbort, RtState.Init);
  284. //Reset
  285. AnyStateTransition(MSG.ERROR, fError, RtState.Error);
  286. AnyStateTransition((int)FSM_MSG.ALARM, fError, (int)RtState.Error);
  287. Transition(RtState.Error, MSG.RESET, fStartReset, RtState.Idle);
  288. Transition(RtState.Init, MSG.RESET, fStartReset, RtState.Init);
  289. Transition(RtState.Idle, MSG.RESET, fStartReset, RtState.Idle);
  290. Transition(RtState.AutoIdle, MSG.RESET, fStartReset, RtState.AutoIdle);
  291. Transition(RtState.AutoRunning, MSG.RESET, fStartReset, RtState.AutoRunning);
  292. Transition(RtState.ReturnWafer, MSG.RESET, fStartReset, RtState.ReturnWafer);
  293. //Auto/manual sequence
  294. Transition(RtState.Idle, MSG.SetAutoMode, fStartAutoTransfer, RtState.AutoIdle);
  295. Transition(RtState.AutoRunning, FSM_MSG.TIMER, fAutoTransfer, RtState.AutoRunning);
  296. Transition(RtState.AutoRunning, MSG.JobAutoStart, FsmJobAutoStart, RtState.Idle);
  297. Transition(RtState.AutoRunning, MSG.ABORT, FsmAbort, RtState.Idle);
  298. Transition(RtState.AutoRunning, MSG.JobDone, null, RtState.AutoIdle);
  299. Transition(RtState.Idle, MSG.CreateJob, FsmCreateJob, RtState.AutoRunning);
  300. Transition(RtState.Idle, MSG.LoadProcessUnload, FsmStartLoadProcessUnload, RtState.AutoRunning);
  301. Transition(RtState.Idle, MSG.LoadProcessStocker, FsmStartLoadProcessStocker, RtState.AutoRunning);
  302. Transition(RtState.AutoRunning, MSG.FAJobCommand, FsmFAJobCommand, RtState.AutoRunning);
  303. Transition(RtState.AutoRunning, MSG.CreateJob, FsmCreateJob, RtState.AutoRunning);
  304. Transition(RtState.AutoRunning, MSG.StartJob, FsmStartJob, RtState.AutoRunning);
  305. Transition(RtState.AutoRunning, MSG.PauseJob, FsmPauseJob, RtState.AutoRunning);
  306. Transition(RtState.AutoRunning, MSG.ResumeJob, FsmResumeJob, RtState.AutoRunning);
  307. Transition(RtState.AutoRunning, MSG.StopJob, FsmStopJob, RtState.AutoRunning);
  308. Transition(RtState.AutoRunning, MSG.AbortJob, FsmAbortJob, RtState.AutoRunning);
  309. Transition(RtState.AutoRunning, MSG.ModuleError, FsmModuleError, RtState.AutoRunning);
  310. Transition(RtState.AutoRunning, MSG.Load, FsmStartLoad, RtState.AutoRunning);
  311. Transition(RtState.AutoRunning, MSG.Unload, FsmStartUnload, RtState.AutoRunning);
  312. Transition(RtState.Idle, MSG.CreateTransferJob, FsmCreateTransferJob, RtState.AutoRunning);
  313. Transition(RtState.AutoRunning, MSG.CreateTransferJob, FsmCreateTransferJob, RtState.AutoRunning);
  314. Transition(RtState.AutoRunning, MSG.AbortTransferJob, FsmAbortTransferJob, RtState.AutoRunning);
  315. Transition(RtState.AutoRunning, MSG.CancelUnloadingJob, FsmCancelUnloadingJob, RtState.AutoRunning);
  316. Transition(RtState.AutoRunning, MSG.LoadProcessUnload, FsmStartLoadProcessUnload, RtState.AutoRunning);
  317. Transition(RtState.AutoRunning, MSG.LoadProcessStocker, FsmStartLoadProcessStocker, RtState.AutoRunning);
  318. Transition(RtState.AutoIdle, MSG.FAJobCommand, FsmFAJobCommand, RtState.AutoRunning);
  319. Transition(RtState.AutoIdle, FSM_MSG.TIMER, FsmMonitorAutoIdle, RtState.AutoIdle);
  320. Transition(RtState.AutoIdle, MSG.SetManualMode, FsmStartSetManualMode, RtState.Idle);
  321. Transition(RtState.AutoIdle, MSG.CreateJob, FsmCreateJob, RtState.AutoRunning);
  322. Transition(RtState.AutoIdle, MSG.StartJob, FsmStartJob, RtState.AutoRunning);
  323. Transition(RtState.AutoIdle, MSG.ABORT, FsmAbort, RtState.Idle);
  324. Transition(RtState.AutoIdle, MSG.AbortJob, FsmAbortJob, RtState.AutoIdle);
  325. Transition(RtState.AutoIdle, MSG.Load, FsmStartLoad, RtState.AutoIdle);
  326. Transition(RtState.AutoIdle, MSG.Unload, FsmStartUnload, RtState.AutoIdle);
  327. Transition(RtState.AutoIdle, MSG.CreateTransferJob, FsmCreateTransferJob, RtState.AutoRunning);
  328. Transition(RtState.AutoIdle, MSG.AbortTransferJob, FsmAbortTransferJob, RtState.AutoIdle);
  329. Transition(RtState.AutoIdle, MSG.LoadProcessUnload, FsmStartLoadProcessUnload, RtState.AutoRunning);
  330. Transition(RtState.AutoIdle, MSG.LoadProcessStocker, FsmStartLoadProcessStocker, RtState.AutoRunning);
  331. EnterExitTransition<RtState, FSM_MSG>(RtState.AutoRunning, null, FSM_MSG.NONE, fExitAutoTransfer);
  332. //return all wafer
  333. //Transition(RtState.Idle, MSG.ReturnAllWafer, FsmStartReturnAllWafer, RtState.ReturnAllWafer);
  334. //Transition(RtState.ReturnAllWafer, FSM_MSG.TIMER, FsmMonitorReturnAllWafer, RtState.Idle);
  335. //Transition(RtState.ReturnAllWafer, MSG.ABORT, FsmAbortReturnAllWafer, RtState.Idle);
  336. //Return wafer
  337. Transition(RtState.Idle, MSG.ReturnAllWafer, FsmStartReturnWafer, RtState.ReturnWafer);
  338. Transition(RtState.AutoIdle, MSG.ReturnAllWafer, FsmStartReturnWafer, RtState.ReturnWafer);
  339. Transition(RtState.ReturnWafer, FSM_MSG.TIMER, FsmMonitorReturnWafer, RtState.Idle);
  340. Transition(RtState.ReturnWafer, MSG.ABORT, FsmAbort, RtState.Idle);
  341. //Transfer sequence
  342. Transition(RtState.Idle, MSG.MoveWafer, fStartTransfer, RtState.Transfer);
  343. Transition(RtState.Transfer, FSM_MSG.TIMER, fTransfer, RtState.Idle);
  344. EnterExitTransition<RtState, FSM_MSG>(RtState.Transfer, null, FSM_MSG.NONE, fExitTransfer);
  345. Transition(RtState.Transfer, MSG.ABORT, FsmAbort, RtState.Idle);
  346. }
  347. void SubscribeDataVariable()
  348. {
  349. DATA.Subscribe("System.FFUKeyDict", () => GetDeviceKeyDict(DeviceName.IoFFUNameKey), SubscriptionAttribute.FLAG.IgnoreSaveDB);
  350. DATA.Subscribe("System.NameKeyDict", () => GetALLDeviceKeyDict(), SubscriptionAttribute.FLAG.IgnoreSaveDB);
  351. DATA.Subscribe("Rt.Status", () => StringFsmStatus);
  352. DATA.Subscribe("System.IsInitialized", () => _isInited);
  353. DATA.Subscribe("System.IsIdle", () => IsIdle || IsInit || (FsmState == (int)RtState.AutoIdle));
  354. DATA.Subscribe("System.IsAlarm", () => IsAlarm);
  355. DATA.Subscribe("System.IsBusy", () => IsRunning);
  356. DATA.Subscribe("System.IsAutoRunning", () => IsRunning);
  357. DATA.Subscribe("System.IsAlarmConditionBuzzerOn", () => IsAlarmConditionBuzzerOn);
  358. DATA.Subscribe("System.Modules", () => _modules);
  359. }
  360. List<string> GetDeviceKeyDict(string key)
  361. {
  362. List<string> result = null;
  363. if (SC.GetStringValue("System.SetUp.ToolType") != "ELK") return null;
  364. GetXmlElement("DeviceModelPM", key, ref result);
  365. return result;
  366. }
  367. Dictionary<string, List<string>> GetALLDeviceKeyDict()
  368. {
  369. return GetXmlElement("DeviceModelPM");
  370. }
  371. public void GetXmlElement(string fileName, string type, ref List<string> result, bool isSystem = false)
  372. {
  373. result = new List<string>();
  374. XmlDocument xmlDoc = new XmlDocument();
  375. var cfDirPath = PathManager.GetCfgDir();
  376. var path = cfDirPath + $"IO\\{SC.GetStringValue("System.SetUp.ToolType")}\\{fileName}.xml";
  377. if (!File.Exists(path)) return;
  378. xmlDoc.Load(path);
  379. XmlNode node = xmlDoc.SelectSingleNode("DeviceModelDefine");
  380. foreach (XmlNode item in node.ChildNodes)
  381. {
  382. if (item.NodeType != XmlNodeType.Element) continue;
  383. var element = item as XmlElement;
  384. var classType = element.GetAttribute("classType");
  385. if (classType == null) continue;
  386. classType = classType.Split('.').LastOrDefault();
  387. if (classType == type)
  388. {
  389. foreach (XmlNode children in item.ChildNodes)
  390. {
  391. if (children is XmlElement childElement)
  392. {
  393. if (result.Contains(childElement.GetAttribute("id"))) continue;
  394. var key = isSystem ? $"System.{childElement.GetAttribute("id")}.DeviceData" : $"PM1.{childElement.GetAttribute("id")}.DeviceData";
  395. result.Add(key);
  396. }
  397. }
  398. }
  399. }
  400. }
  401. public Dictionary<string, List<string>> GetXmlElement(string fileName, bool isSystem = false)
  402. {
  403. Dictionary<string, List<string>> result = new Dictionary<string, List<string>>();
  404. XmlDocument xmlDoc = new XmlDocument();
  405. var cfDirPath = PathManager.GetCfgDir();
  406. var path = cfDirPath + $"IO\\{SC.GetStringValue("System.SetUp.ToolType")}\\{fileName}.xml";
  407. if (!File.Exists(path)) return result;
  408. xmlDoc.Load(path);
  409. XmlNode node = xmlDoc.SelectSingleNode("DeviceModelDefine");
  410. foreach (XmlNode item in node.ChildNodes)
  411. {
  412. if (item.NodeType != XmlNodeType.Element) continue;
  413. var element = item as XmlElement;
  414. var classType = element.GetAttribute("classType");
  415. if (classType == null) continue;
  416. classType = classType.Split('.').LastOrDefault();
  417. result[classType] = new List<string>();
  418. foreach (XmlNode children in item.ChildNodes)
  419. {
  420. if (children.Name != classType) continue;//类型限定一致
  421. if (children is XmlElement childElement)
  422. {
  423. if (result[classType].Contains(childElement.GetAttribute("id"))) continue;
  424. var key = isSystem ? $"System.{childElement.GetAttribute("id")}.DeviceData" : $"PM1.{childElement.GetAttribute("id")}.DeviceData";
  425. result[classType].Add(key);
  426. }
  427. }
  428. }
  429. return result;
  430. }
  431. void SubscribeOperation()
  432. {
  433. OP.Subscribe("CreateWafer", InvokeCreateWafer);
  434. OP.Subscribe("System.UpdateWafer", InvokeUpdateWafer);
  435. OP.Subscribe("CreateWaferFromTo", InvokeCreateWaferFromTo);
  436. OP.Subscribe("DeleteWafer", InvokeDeleteWafer);
  437. OP.Subscribe("DeleteWaferFromTo", InvokeDeleteWaferFromTo);
  438. OP.Subscribe("CreateCassetteWafer", InvokeCreateCassetteWafer);
  439. OP.Subscribe("DeleteCassetteWafer", InvokeDeleteCassetteWafer);
  440. OP.Subscribe("System.CreateCarrier", InvokeCreateCarrier);
  441. OP.Subscribe("System.DeleteCarrier", InvokeDeleteCarrier);
  442. OP.Subscribe("System.SetLotID", InvokeSetLotID);
  443. OP.Subscribe("System.DeleteAllWafer", InvokeDeleteAllWafer);
  444. OP.Subscribe("System.DeleteAllCarrier", InvokeDeleteAllCarrier);
  445. OP.Subscribe("ReturnWafer", InvokeReturnWafer);
  446. OP.Subscribe("System.SignalTower.SwitchOffBuzzer", InvokeSwitchOffBuzzer);
  447. OP.Subscribe("System.ReturnAllWafer", (string cmd, object[] args) =>
  448. {
  449. return CheckToPostMessage((int)MSG.ReturnAllWafer);
  450. });
  451. OP.Subscribe("System.MoveWafer", (string cmd, object[] args) =>
  452. {
  453. if (!Enum.TryParse((string)args[0], out ModuleName source))
  454. {
  455. EV.PostWarningLog(Name, $"Parameter source {(string)args[0]} not valid");
  456. return false;
  457. }
  458. if (!Enum.TryParse((string)args[2], out ModuleName destination))
  459. {
  460. EV.PostWarningLog(Name, $"Parameter destination {(string)args[1]} not valid");
  461. return false;
  462. }
  463. if (args.Length > 8)
  464. {
  465. return CheckToPostMessage((int)MSG.MoveWafer, source, (int)args[1], destination, (int)args[3],
  466. (bool)args[4], (int)args[5], (bool)args[6], (int)args[7]);
  467. }
  468. else if (args.Length > 5)
  469. {
  470. return CheckToPostMessage((int)MSG.MoveWafer, source, (int)args[1], destination, (int)args[3], (bool)args[4]);
  471. }
  472. return CheckToPostMessage((int)MSG.MoveWafer, source, (int)args[1], destination, (int)args[3]);
  473. });
  474. OP.Subscribe("System.HomeAll", (string cmd, object[] args) =>
  475. {
  476. return CheckToPostMessage((int)MSG.HOME);
  477. });
  478. OP.Subscribe("System.Abort", (string cmd, object[] args) =>
  479. {
  480. return CheckToPostMessage((int)MSG.ABORT);
  481. });
  482. OP.Subscribe("System.Reset", (string cmd, object[] args) =>
  483. {
  484. return CheckToPostMessage((int)MSG.RESET);
  485. });
  486. OP.Subscribe("System.SetAutoMode", (string cmd, object[] args) =>
  487. {
  488. return CheckToPostMessage((int)MSG.SetAutoMode);
  489. });
  490. OP.Subscribe("System.SetManualMode", (string cmd, object[] args) =>
  491. {
  492. return CheckToPostMessage((int)MSG.SetManualMode);
  493. });
  494. OP.Subscribe("System.CreateJob", (string cmd, object[] args) =>
  495. {
  496. return CheckToPostMessage((int)MSG.CreateJob, args[0]);
  497. });
  498. OP.Subscribe("System.StartJob", (string cmd, object[] args) =>
  499. {
  500. return CheckToPostMessage((int)MSG.StartJob, args[0]);
  501. });
  502. OP.Subscribe("System.PauseJob", (string cmd, object[] args) =>
  503. {
  504. return CheckToPostMessage((int)MSG.PauseJob, args[0]);
  505. });
  506. OP.Subscribe("System.ResumeJob", (string cmd, object[] args) =>
  507. {
  508. return CheckToPostMessage((int)MSG.ResumeJob, args[0]);
  509. });
  510. OP.Subscribe("System.StopJob", (string cmd, object[] args) =>
  511. {
  512. return CheckToPostMessage((int)MSG.StopJob, args[0]);
  513. });
  514. OP.Subscribe("System.AbortJob", (string cmd, object[] args) =>
  515. {
  516. return CheckToPostMessage((int)MSG.AbortJob, args[0]);
  517. });
  518. OP.Subscribe("System.CoolingSkip", (string cmd, object[] args) =>
  519. {
  520. CoolingSkip();
  521. return true;
  522. });
  523. OP.Subscribe("System.ShutDown", InvokeShutDown);
  524. OP.Subscribe($"System.Load", (string cmd, object[] args) => CheckToPostJobMessage((int)MSG.CreateTransferJob, args));
  525. OP.Subscribe($"System.Unload", (string cmd, object[] args) => CheckToPostJobMessage((int)MSG.CreateTransferJob, args));
  526. OP.Subscribe($"System.ChargeProcessDischarge", (string cmd, object[] args) => CheckToPostJobMessage((int)MSG.CreateJob, args));
  527. OP.Subscribe($"System.LoadProcessUnload", (string cmd, object[] args) => CheckToPostJobMessage((int)MSG.LoadProcessUnload, args));
  528. OP.Subscribe($"System.LoadProcessStocker", (string cmd, object[] args) => CheckToPostJobMessage((int)MSG.LoadProcessStocker, args));
  529. OP.Subscribe($"System.MonitorLoad", (string cmd, object[] args) => CheckToPostJobMessage((int)MSG.CreateTransferJob, args));
  530. OP.Subscribe($"System.MonitorUnload", (string cmd, object[] args) => CheckToPostJobMessage((int)MSG.CreateTransferJob, args));
  531. OP.Subscribe($"System.SDLoad", (string cmd, object[] args) => CheckToPostJobMessage((int)MSG.CreateTransferJob, args));
  532. OP.Subscribe($"System.SDUnload", (string cmd, object[] args) => CheckToPostJobMessage((int)MSG.CreateTransferJob, args));
  533. OP.Subscribe($"{Module}.AlarmAction", (string cmd, object[] args) =>
  534. {
  535. Enum.TryParse(args[0].ToString(), out AlarmAction alarmAction);
  536. if (alarmAction == AlarmAction.ClearAll)
  537. {
  538. CheckToPostMessage((int)MSG.RESET);
  539. return true;
  540. }
  541. string eventName = null;
  542. if (args.Length > 1)
  543. eventName = args[1].ToString();
  544. if (eventName != null)
  545. {
  546. EV.ClearAlarmEvent(eventName);
  547. var item = _triggeredAlarmList.FirstOrDefault(x => x.EventEnum == eventName);
  548. if (item != null)
  549. {
  550. item.Reset();
  551. _triggeredAlarmList.Remove(item);
  552. }
  553. if (item != null)
  554. {
  555. switch (alarmAction)
  556. {
  557. case AlarmAction.Retry:
  558. {
  559. CheckToPostMessage((int)item.RetryMessage, item.RetryMessageParas);
  560. }
  561. break;
  562. case AlarmAction.Abort:
  563. {
  564. CheckToPostMessage((int)MSG.ABORT);
  565. }
  566. break;
  567. case AlarmAction.Clear:
  568. {
  569. int alarmCount = 0;
  570. var alarms = EV.GetAlarmEvent();
  571. foreach (var alarm in alarms)
  572. {
  573. if (alarm.Level == EventLevel.Alarm && alarm.Source == Name)
  574. alarmCount++;
  575. }
  576. if (alarmCount == 0)
  577. CheckToPostMessage((int)MSG.RESET);
  578. }
  579. break;
  580. case AlarmAction.Continue:
  581. {
  582. int alarmCount = 0;
  583. var alarms = EV.GetAlarmEvent();
  584. foreach (var alarm in alarms)
  585. {
  586. if (alarm.Level == EventLevel.Alarm && alarm.Source == Name)
  587. alarmCount++;
  588. }
  589. if (alarmCount == 0)
  590. CheckToPostMessage((int)MSG.RESET);
  591. }
  592. break;
  593. }
  594. }
  595. }
  596. return true;
  597. });
  598. }
  599. private void Instance_OnAlarmEvent(EventItem item)
  600. {
  601. if (item != null && item.Level == EventLevel.Alarm && (item.Source == Name || item.Source == Module))
  602. {
  603. DEVICE.GetDevice<SignalTowerBase>("System.SignalTower")?.Reset();
  604. LOG.Write($"{item.Source} {item.EventEnum} {item.Description}\n");
  605. PostMsg(MSG.ERROR);
  606. }
  607. }
  608. #region Init
  609. private bool FsmStartHome(object[] objs)
  610. {
  611. _isInited = false;
  612. return _homeAll.Start() == Result.RUN;
  613. }
  614. private bool FsmMonitorHome(object[] objs)
  615. {
  616. Result ret = _homeAll.Monitor();
  617. if (ret == Result.DONE)
  618. {
  619. _isInited = true;
  620. return true;
  621. }
  622. if (ret == Result.FAIL)
  623. {
  624. PostMsg(MSG.ERROR);
  625. }
  626. return false;
  627. }
  628. private bool fError(object[] objs)
  629. {
  630. if (FsmState == (int)RtState.Transfer)
  631. {
  632. }
  633. return true;
  634. }
  635. #endregion
  636. #region job
  637. private bool FsmStartLoad(object[] param)
  638. {
  639. if (_transferJob.CreateJob(param) != Result.RUN)
  640. {
  641. return false;
  642. }
  643. return true;
  644. }
  645. private bool FsmStartUnload(object[] param)
  646. {
  647. if (_transferJob.CreateJob(param) != Result.RUN)
  648. {
  649. return false;
  650. }
  651. return true;
  652. }
  653. private bool FsmStartLoadProcessStocker(object[] param)
  654. {
  655. var paramDic = (Dictionary<string, object>)param[0];
  656. if (paramDic == null)
  657. {
  658. LoadProcessStockerStartFailedWarning.Set("Parameter not valid");
  659. return false;
  660. }
  661. paramDic["TransferType"] = "Loading";
  662. param[0] = paramDic;
  663. if (_transferJob.CreateJob(param) != Result.RUN)
  664. {
  665. return false;
  666. }
  667. if (_auto.CreateJob(param) != Result.RUN)
  668. {
  669. return false;
  670. }
  671. return true;
  672. }
  673. private bool FsmStartLoadProcessUnload(object[] param)
  674. {
  675. var paramDic = (Dictionary<string, object>)param[0];
  676. if (paramDic == null)
  677. {
  678. LoadProcessUnloadStartFailedWarning.Set("Parameter not valid");
  679. return false;
  680. }
  681. paramDic["TransferType"] = "Loading";
  682. param[0] = paramDic;
  683. if (_transferJob.CreateJob(param) != Result.RUN)
  684. {
  685. return false;
  686. }
  687. if (_auto.CreateJob(param) != Result.RUN)
  688. {
  689. return false;
  690. }
  691. paramDic["TransferType"] = "Unloading";
  692. param[0] = paramDic;
  693. if (_transferJob.CreateJob(param) != Result.RUN)
  694. {
  695. return false;
  696. }
  697. return true;
  698. }
  699. #endregion
  700. #region AutoTransfer
  701. private bool FsmMonitorAutoIdle(object[] param)
  702. {
  703. Result ret = _transferJob.Monitor();
  704. _auto.Monitor();
  705. if (!_auto.CheckAllJobDone() || !_transferJob.CheckAllJobDone())
  706. {
  707. return false;
  708. }
  709. return ret == Result.DONE;
  710. }
  711. private bool FsmStartSetManualMode(object[] objs)
  712. {
  713. if (_auto.HasJobRunning)
  714. {
  715. EV.PostWarningLog("System", "Can not change to manual mode, abort running job first");
  716. return false;
  717. }
  718. return true;
  719. }
  720. private bool fStartAutoTransfer(object[] objs)
  721. {
  722. Result ret = _auto.Start(objs);
  723. return ret == Result.RUN;
  724. }
  725. private bool fAutoTransfer(object[] objs)
  726. {
  727. Result ret = _transferJob.Monitor();
  728. _auto.Monitor();
  729. if (_auto.CheckAllJobDone() && _transferJob.CheckAllJobDone())
  730. {
  731. if (!CheckToPostMessage((int)MSG.JobDone))
  732. return false;
  733. }
  734. return ret == Result.DONE;
  735. }
  736. private bool fExitAutoTransfer(object[] objs)
  737. {
  738. _auto.Clear();
  739. _transferJob.Clear();
  740. return true;
  741. }
  742. private bool fAbortAutoTransfer(object[] objs)
  743. {
  744. _auto.Clear();
  745. _transferJob.Clear();
  746. return true;
  747. }
  748. #endregion
  749. #region return all wafer
  750. private bool FsmAbortReturnAllWafer(object[] param)
  751. {
  752. return true;
  753. }
  754. private bool FsmMonitorReturnAllWafer(object[] param)
  755. {
  756. return _returnAll.Monitor() == Result.DONE;
  757. }
  758. private bool FsmStartReturnAllWafer(object[] param)
  759. {
  760. return _returnAll.Start() == Result.RUN;
  761. }
  762. #endregion
  763. #region Transfer
  764. private bool fStartTransfer(object[] objs)
  765. {
  766. Result ret = _manualTransfer.Start(objs);
  767. if (ret == Result.FAIL || ret == Result.DONE)
  768. return false;
  769. return ret == Result.RUN;
  770. }
  771. private bool fTransfer(object[] objs)
  772. {
  773. Result ret = _manualTransfer.Monitor();
  774. if (ret == Result.FAIL)
  775. {
  776. PostMsg(MSG.ERROR);
  777. return false;
  778. }
  779. return ret == Result.DONE;
  780. }
  781. private bool fExitTransfer(object[] objs)
  782. {
  783. return true;
  784. }
  785. private bool fAbortTransfer(object[] objs)
  786. {
  787. return true;
  788. }
  789. #endregion
  790. #region reset
  791. private bool fStartReset(object[] objs)
  792. {
  793. EV.ClearAlarmEvent();
  794. Singleton<DeviceEntity>.Instance.PostMsg(DeviceEntity.MSG.RESET);
  795. Singleton<FAJobController>.Instance.ClearAlarm();
  796. IoProviderManager.Instance.Reset();
  797. foreach (var modulesValue in Modules.Values)
  798. {
  799. modulesValue.Reset();
  800. }
  801. _triggeredAlarmList.ForEach(x => x.Reset());
  802. _triggeredAlarmList.Clear();
  803. if (FsmState == (int)RtState.Error)
  804. {
  805. if (!_isInited)
  806. {
  807. PostMsg(MSG.ToInit);
  808. return false;
  809. }
  810. return true;
  811. }
  812. return false;
  813. }
  814. #endregion
  815. private bool FsmCreateJob(object[] param)
  816. {
  817. var paramData = (Dictionary<string, object>)param[0];
  818. if (FsmState != (int)RtState.AutoRunning && CarrierManager.Instance.CheckHasCarrier(ModuleName.CarrierRobot, 0))
  819. {
  820. EV.PostWarningLog("System", $"FOUP robot already has a FOUP, create job failed");
  821. return false;
  822. }
  823. if (param.Length > 1 && int.TryParse(param[1].ToString(), out int level) && level > 0)
  824. {
  825. if (_auto.CreateJob((Dictionary<string, object>)param[0], level) != Result.FAIL)
  826. {
  827. LOG.Info($"CreateJob with PriorityExecuteLevel [{level}]- params {string.Join(",", paramData.Select(r => r.Key + ":" + r.Value))}");
  828. }
  829. }
  830. else
  831. {
  832. _auto.CreateJob((Dictionary<string, object>)param[0]);
  833. }
  834. return true;
  835. }
  836. private bool FsmAbortJob(object[] param)
  837. {
  838. _auto.AbortJob((string)param[0]);
  839. return true;
  840. }
  841. private bool FsmStopJob(object[] param)
  842. {
  843. _auto.StopJob((string)param[0]);
  844. Singleton<FAJobController>.Instance.CJAbort((string)param[0]);
  845. //CheckToPostMessage((int)MSG.StopJob);//
  846. return true;
  847. }
  848. private bool FsmResumeJob(object[] param)
  849. {
  850. _auto.ResumeJob((string)param[0]);
  851. return true;
  852. }
  853. private bool FsmPauseJob(object[] param)
  854. {
  855. _auto.PauseJob((string)param[0]);
  856. return true;
  857. }
  858. private bool FsmStartJob(object[] param)
  859. {
  860. return _auto.StartJob((string)param[0]);
  861. }
  862. private bool FsmCreateTransferJob(object[] param)
  863. {
  864. if (FsmState != (int)RtState.AutoRunning && CarrierManager.Instance.CheckHasCarrier(ModuleName.CarrierRobot, 0))
  865. {
  866. EV.PostWarningLog("System", $"FOUP robot already has a FOUP, create job failed");
  867. return false;
  868. }
  869. _transferJob.CreateJob(param);
  870. return true;
  871. }
  872. private bool FsmAbortTransferJob(object[] param)
  873. {
  874. _transferJob.AbortJob((string)param[0]);
  875. return true;
  876. }
  877. private bool FsmCancelUnloadingJob(object[] param)
  878. {
  879. _transferJob.CancelUnloadingJob((string)param[0], (string)param[1]);
  880. return true;
  881. }
  882. private bool FsmJobAutoStart(object[] param)
  883. {
  884. _auto.PauseJob((string)param[0]);
  885. _auto.Clear();
  886. return true;
  887. }
  888. private bool FsmAbort(object[] param)
  889. {
  890. if (FsmState == (int)RtState.Transfer)
  891. {
  892. // _manualTransfer.Clear();
  893. }
  894. if (FsmState == (int)RtState.ChargeProcessDischarging || FsmState == (int)RtState.LoadProcessStockering || FsmState == (int)RtState.LoadProcessUnloading)
  895. {
  896. _auto.PjUpdated();
  897. _auto.PjFinished("Job Abort");
  898. }
  899. if (FsmState == (int)RtState.AutoRunning)
  900. {
  901. _auto.FACallBack(Gem300Events.CJ_ABORTED);
  902. _auto.Clear();
  903. }
  904. if (FsmState == (int)RtState.Initializing)
  905. {
  906. _homeAll.Abort();
  907. }
  908. return true;
  909. }
  910. private bool FsmModuleError(object[] param)
  911. {
  912. //_auto.ModuleError((string)param[0]);
  913. return true;
  914. }
  915. private bool FsmStartReturnWafer(object[] objs)
  916. {
  917. Result ret = _returnAll.Start();
  918. if (ret == Result.FAIL)
  919. {
  920. PostMsg(MSG.ERROR);
  921. return false;
  922. }
  923. return ret == Result.RUN;
  924. }
  925. private bool FsmMonitorReturnWafer(object[] objs)
  926. {
  927. Result ret = _returnAll.Monitor();
  928. if (ret == Result.FAIL)
  929. {
  930. PostMsg(MSG.ERROR);
  931. return false;
  932. }
  933. if (ret == Result.DONE)
  934. {
  935. _batchType = "";
  936. _processJob = "";
  937. _processRecipe = "";
  938. (Modules[ModuleName.CarrierRobot] as CarrierRobotModule).Home(out _);
  939. (Modules[ModuleName.WaferRobot] as WaferRobotModule).Home(out _);
  940. }
  941. return ret == Result.DONE;
  942. }
  943. private bool InvokeSwitchOffBuzzer(string arg1, object[] args)
  944. {
  945. DEVICE.GetDevice<SignalTowerBase>("System.SignalTower")?.SwitchOffBuzzer(true);
  946. IsAlarmConditionBuzzerOn = false;
  947. return true;
  948. }
  949. private bool InvokeReturnWafer(string arg1, object[] args)
  950. {
  951. ModuleName target = ModuleHelper.Converter(args[0].ToString());
  952. int slot = (int)args[1];
  953. if (ModuleHelper.IsLoadPort(target))
  954. {
  955. EV.PostInfoLog("System", string.Format("Wafer already at LoadPort {0} {1}, return operation is not valid", target.ToString(), slot + 1));
  956. return false;
  957. }
  958. if (!WaferManager.Instance.IsWaferSlotLocationValid(target, slot))
  959. {
  960. EV.PostWarningLog("System", string.Format("Invalid position,{0},{1}", target.ToString(), slot.ToString()));
  961. return false;
  962. }
  963. WaferInfo wafer = WaferManager.Instance.GetWafer(target, slot);
  964. if (wafer.IsEmpty)
  965. {
  966. EV.PostInfoLog("System", string.Format("No wafer at {0} {1}, return operation is not valid", target.ToString(), slot + 1));
  967. return false;
  968. }
  969. return CheckToPostMessage((int)MSG.MoveWafer,
  970. target, slot,
  971. (ModuleName)wafer.OriginStation, wafer.OriginSlot,
  972. false, 0, false, 0);
  973. }
  974. private bool InvokeDeleteAllWafer(string arg1, object[] args)
  975. {
  976. foreach (var item in Modules.Values)
  977. {
  978. if ((item as PMModule) != null || (item as WaferRobotModule) != null)
  979. {
  980. var wafers = WaferManager.Instance.GetWafers(ModuleHelper.Converter(item.Module));
  981. for (int i = 0; i < wafers.Length; i++)
  982. {
  983. if (!wafers[i].IsEmpty)
  984. WaferManager.Instance.DeleteWafer(ModuleHelper.Converter(item.Module), i);
  985. }
  986. }
  987. }
  988. return true;
  989. }
  990. private bool InvokeDeleteAllCarrier(string arg1, object[] args)
  991. {
  992. foreach (var item in Modules.Values)
  993. {
  994. if ((item as LoadPortModule) != null || (item as StockerModule) != null || (item as FIMSModule) != null || (item as CarrierRobotModule) != null)
  995. {
  996. if (CarrierManager.Instance.HasCarrier(item.Module.ToString()))
  997. {
  998. CarrierManager.Instance.DeleteCarrier(item.Module.ToString());
  999. var wafers = WaferManager.Instance.GetWafers(ModuleHelper.Converter(item.Module));
  1000. for (int i = 0; i < wafers.Length; i++)
  1001. {
  1002. if (!wafers[i].IsEmpty)
  1003. WaferManager.Instance.DeleteWafer(ModuleHelper.Converter(item.Module), i);
  1004. }
  1005. }
  1006. }
  1007. }
  1008. return true;
  1009. }
  1010. private bool InvokeDeleteWaferFromTo(string arg1, object[] args)
  1011. {
  1012. ModuleName chamber = ModuleHelper.Converter(args[0].ToString());
  1013. int slotFrom = (int)args[1];
  1014. int slotTo = (int)args[2];
  1015. for (int slot = slotTo - 1; slot >= slotFrom - 1; slot--)
  1016. {
  1017. if (WaferManager.Instance.IsWaferSlotLocationValid(chamber, slot))
  1018. {
  1019. if (WaferManager.Instance.CheckHasWafer(chamber, slot))
  1020. {
  1021. WaferManager.Instance.DeleteWafer(chamber, slot);
  1022. EV.PostMessage(ModuleName.System.ToString(), EventEnum.WaferDelete, chamber.ToString(), slot + 1);
  1023. }
  1024. else
  1025. {
  1026. EV.PostInfoLog("System", string.Format("No wafer at {0} {1}, delete not valid", chamber.ToString(), slot + 1));
  1027. }
  1028. }
  1029. else
  1030. {
  1031. DeleteWaferFailedWarning.Set(string.Format("Invalid position,{0},{1}", chamber.ToString(), slot.ToString()));
  1032. return false;
  1033. }
  1034. }
  1035. var carrier = CarrierManager.Instance.GetCarrier(chamber);
  1036. if (carrier != null)
  1037. {
  1038. CarrierManager.Instance.UpdateWaferIn(chamber, 0, false);
  1039. }
  1040. var wafers = WaferManager.Instance.GetWafers(chamber);
  1041. if (wafers != null && carrier != null)
  1042. {
  1043. foreach (var wafer in wafers)
  1044. {
  1045. if (wafer != null && !wafer.IsEmpty)
  1046. {
  1047. CarrierManager.Instance.UpdateWaferIn(chamber, 0, true);
  1048. break;
  1049. }
  1050. }
  1051. }
  1052. return true;
  1053. }
  1054. private bool InvokeDeleteWafer(string arg1, object[] args)
  1055. {
  1056. ModuleName chamber = ModuleHelper.Converter(args[0].ToString());
  1057. int slot = (int)args[1];
  1058. if (WaferManager.Instance.IsWaferSlotLocationValid(chamber, slot))
  1059. {
  1060. if (WaferManager.Instance.CheckHasWafer(chamber, slot))
  1061. {
  1062. WaferManager.Instance.DeleteWafer(chamber, slot);
  1063. EV.PostMessage(ModuleName.System.ToString(), EventEnum.WaferDelete, chamber.ToString(), slot + 1);
  1064. }
  1065. else
  1066. {
  1067. EV.PostInfoLog("System", string.Format("No wafer at {0} {1}, delete not valid", chamber.ToString(), slot + 1));
  1068. }
  1069. }
  1070. else
  1071. {
  1072. DeleteWaferFailedWarning.Set(string.Format("Invalid position,{0},{1}", chamber.ToString(), slot.ToString()));
  1073. return false;
  1074. }
  1075. var carrier = CarrierManager.Instance.GetCarrier(chamber);
  1076. if (carrier != null)
  1077. {
  1078. CarrierManager.Instance.UpdateWaferIn(chamber, 0, false);
  1079. }
  1080. var wafers = WaferManager.Instance.GetWafers(chamber);
  1081. if (wafers != null && carrier != null)
  1082. {
  1083. foreach (var wafer in wafers)
  1084. {
  1085. if (wafer != null && !wafer.IsEmpty)
  1086. {
  1087. CarrierManager.Instance.UpdateWaferIn(chamber, 0, true);
  1088. break;
  1089. }
  1090. }
  1091. }
  1092. return true;
  1093. }
  1094. private bool InvokeCreateWaferFromTo(string arg1, object[] args)
  1095. {
  1096. ModuleName chamber = ModuleHelper.Converter(args[0].ToString());
  1097. ModuleName originChamber = chamber;
  1098. int slotFrom = (int)args[1];
  1099. int slotTo = (int)args[2];
  1100. int originSlot = 1;
  1101. WaferStatus state = WaferStatus.Normal;
  1102. WaferType waferTye = WaferType.None;
  1103. var strs = (string[])args[3];
  1104. Enum.TryParse(strs[0].ToString(), out waferTye);
  1105. originChamber = ModuleHelper.Converter(strs[1].ToString());
  1106. originSlot = int.Parse(strs[2]);
  1107. for (int slot = slotTo - 1; slot >= slotFrom - 1; slot--)
  1108. {
  1109. if (WaferManager.Instance.IsWaferSlotLocationValid(chamber, slot))
  1110. {
  1111. if (WaferManager.Instance.CheckHasWafer(chamber, slot))
  1112. {
  1113. EV.PostInfoLog("System", string.Format("{0} slot {1} already has wafer.create wafer is not valid", chamber, slot + 1));
  1114. }
  1115. else
  1116. {
  1117. if (originChamber == chamber && WaferManager.Instance.CreateWafer(chamber, slot, state, waferTye) != null)
  1118. {
  1119. EV.PostMessage(ModuleName.System.ToString(), EventEnum.WaferCreate, chamber.ToString(), slot + 1, state.ToString());
  1120. }
  1121. else if (originChamber != chamber && WaferManager.Instance.CreateWafer(chamber, slot, originChamber, originSlot, state, waferTye) != null)
  1122. {
  1123. EV.PostMessage(ModuleName.System.ToString(), EventEnum.WaferCreate, chamber.ToString(), slot + 1, state.ToString());
  1124. }
  1125. }
  1126. }
  1127. else
  1128. {
  1129. EV.PostWarningLog("System", string.Format("Invalid position,{0},{1}", chamber.ToString(), slot.ToString()));
  1130. return false;
  1131. }
  1132. }
  1133. var carrier = CarrierManager.Instance.GetCarrier(chamber);
  1134. if (carrier != null)
  1135. {
  1136. CarrierManager.Instance.UpdateWaferIn(chamber, 0, true);
  1137. }
  1138. return true;
  1139. }
  1140. private bool InvokeCreateWafer(string arg1, object[] args)
  1141. {
  1142. ModuleName chamber = ModuleHelper.Converter(args[0].ToString());
  1143. ModuleName originChamber = chamber;
  1144. int slot = (int)args[1];
  1145. int originSlot = 1;
  1146. WaferStatus state = WaferStatus.Normal;
  1147. WaferType waferTye = WaferType.None;
  1148. if (args.Length > 2)
  1149. Enum.TryParse(args[2].ToString(), out waferTye);
  1150. if (args.Length > 3)
  1151. originChamber = ModuleHelper.Converter(args[3].ToString());
  1152. if (args.Length > 4)
  1153. originSlot = (int)args[4];
  1154. if (ModuleHelper.IsLoadPort(chamber))
  1155. {
  1156. //var lp = Modules[chamber] as LoadPortModule;
  1157. //if (lp.LPDevice.CassetteState != LoadportCassetteState.Normal)
  1158. //{
  1159. // EV.PostWarningLog("System", $"Can not create wafer at {chamber}.{slot + 1}, Cassette not placed.");
  1160. // return false;
  1161. //}
  1162. }
  1163. if (WaferManager.Instance.IsWaferSlotLocationValid(chamber, slot))
  1164. {
  1165. if (WaferManager.Instance.CheckHasWafer(chamber, slot))
  1166. {
  1167. EV.PostInfoLog("System", string.Format("{0} slot {1} already has wafer.create wafer is not valid", chamber, slot + 1));
  1168. }
  1169. else
  1170. {
  1171. if (originChamber == chamber && WaferManager.Instance.CreateWafer(chamber, slot, state, waferTye) != null)
  1172. {
  1173. EV.PostMessage(ModuleName.System.ToString(), EventEnum.WaferCreate, chamber.ToString(), slot + 1, state.ToString());
  1174. }
  1175. else if (originChamber != chamber && WaferManager.Instance.CreateWafer(chamber, slot, originChamber, originSlot, state, waferTye) != null)
  1176. {
  1177. EV.PostMessage(ModuleName.System.ToString(), EventEnum.WaferCreate, chamber.ToString(), slot + 1, state.ToString());
  1178. }
  1179. }
  1180. }
  1181. else
  1182. {
  1183. EV.PostWarningLog("System", string.Format("Invalid position,{0},{1}", chamber.ToString(), slot.ToString()));
  1184. return false;
  1185. }
  1186. var carrier = CarrierManager.Instance.GetCarrier(chamber);
  1187. if (carrier != null)
  1188. {
  1189. CarrierManager.Instance.UpdateWaferIn(chamber, 0, true);
  1190. }
  1191. return true;
  1192. }
  1193. private bool InvokeUpdateWafer(string arg1, params object[] args)
  1194. {
  1195. if (args == null || args.Length == 0) return false;
  1196. ModuleName chamber = ModuleHelper.Converter(args[0].ToString());
  1197. var carrier = CarrierManager.Instance.GetCarrier(chamber);
  1198. if (carrier == null || carrier.IsEmpty)
  1199. {
  1200. EV.PostInfoLog(Module, $"{chamber} update wafer fail for carrier not exist.");
  1201. return false;
  1202. }
  1203. if (args.Length > 3 && !carrier.CarrierType.ToString().Equals(CarrierType.None.ToString()) && !carrier.CarrierType.ToString().Equals(args[2].ToString()))
  1204. {
  1205. EV.PostInfoLog(Module, $"{chamber} type mismatch!");
  1206. return false;
  1207. }
  1208. int slot = 0;
  1209. if (args.Length > 1)
  1210. {
  1211. int.TryParse(args[1].ToString(), out slot);
  1212. slot = slot - 1;
  1213. }
  1214. WaferType waferTye = WaferType.None;
  1215. if (args.Length > 2)
  1216. {
  1217. Enum.TryParse(args[2].ToString(), out waferTye);
  1218. }
  1219. float useCount = 0, useThick = 0, UseTime = 0;
  1220. if (args.Length > 3)
  1221. {
  1222. float.TryParse(args[3].ToString(), out useCount);
  1223. }
  1224. if (args.Length > 4)
  1225. {
  1226. float.TryParse(args[4].ToString(), out useThick);
  1227. }
  1228. if (args.Length > 5)
  1229. {
  1230. float.TryParse(args[5].ToString(), out UseTime);
  1231. }
  1232. if (WaferManager.Instance.IsWaferSlotLocationValid(chamber, slot))
  1233. {
  1234. if (WaferManager.Instance.CheckHasWafer(chamber, slot))
  1235. {
  1236. WaferManager.Instance.UpdateWaferStatistics(chamber, slot, useCount, useThick, UseTime);
  1237. (Singleton<EquipmentManager>.Instance.Modules[ModuleName.PM1] as PMModule).UpdateSEDWafer(WaferManager.Instance.GetAllWafers());
  1238. }
  1239. }
  1240. if (carrier != null)
  1241. {
  1242. CarrierManager.Instance.UpdateWaferIn(chamber, 0, true);
  1243. }
  1244. return true;
  1245. }
  1246. private bool InvokeCreateCassetteWafer(string arg1, object[] args)
  1247. {
  1248. ModuleName chamber = ModuleHelper.Converter(args[0].ToString());
  1249. var carrier = CarrierManager.Instance.GetCarrier(chamber);
  1250. if (carrier == null || carrier.IsEmpty)
  1251. {
  1252. EV.PostInfoLog(Module, $"{chamber} create wafer fail for carrier not exist.");
  1253. return false;
  1254. }
  1255. if (args.Length > 3 && !carrier.CarrierType.ToString().Equals(CarrierType.None.ToString()) && !carrier.CarrierType.ToString().Equals(args[3].ToString()))
  1256. {
  1257. EV.PostInfoLog(Module, $"{chamber} type mismatch!");
  1258. return false;
  1259. }
  1260. int slotFrom = (int)args[1];
  1261. int slotTo = (int)args[2];
  1262. WaferStatus state = WaferStatus.Normal;
  1263. WaferType waferTye = WaferType.None;
  1264. if (args.Length > 3)
  1265. Enum.TryParse(args[3].ToString(), out waferTye);
  1266. for (int slot = slotTo - 1; slot >= slotFrom - 1; slot--)
  1267. {
  1268. if (WaferManager.Instance.IsWaferSlotLocationValid(chamber, slot))
  1269. {
  1270. if (WaferManager.Instance.CheckHasWafer(chamber, slot))
  1271. {
  1272. EV.PostInfoLog(Module, string.Format("{0} slot {1} already has wafer.", chamber, slot + 1));
  1273. continue;
  1274. }
  1275. else if (WaferManager.Instance.CreateWafer(chamber, slot, state, waferTye) == null)
  1276. {
  1277. CreateWaferFailedWarning.Set(string.Format($"Create slot {slot + 1} wafer failed."));
  1278. return false;
  1279. }
  1280. }
  1281. else
  1282. {
  1283. CreateWaferFailedWarning.Set(string.Format("Invalid slot,{0},{1}", chamber.ToString(), (slot + 1).ToString()));
  1284. return false;
  1285. }
  1286. }
  1287. if (carrier != null)
  1288. {
  1289. CarrierManager.Instance.UpdateWaferIn(chamber, 0, true);
  1290. }
  1291. EV.PostInfoLog(Module, $"Create wafer from {slotFrom} to {slotTo} successed.");
  1292. return true;
  1293. }
  1294. private bool InvokeDeleteCassetteWafer(string arg1, object[] args)
  1295. {
  1296. ModuleName chamber = ModuleHelper.Converter(args[0].ToString());
  1297. int slotFrom = (int)args[1];
  1298. int slotTo = (int)args[2];
  1299. if (WaferManager.Instance.IsWaferSlotLocationValid(chamber, slotFrom - 1) && WaferManager.Instance.IsWaferSlotLocationValid(chamber, slotTo - 1))
  1300. {
  1301. WaferManager.Instance.DeleteWafer(chamber, slotFrom - 1, slotTo - slotFrom + 1);
  1302. }
  1303. else
  1304. {
  1305. DeleteWaferFailedWarning.Set(string.Format($"Invalid slot,{chamber} slot from {slotFrom}, slot to {slotTo}"));
  1306. return false;
  1307. }
  1308. var carrier = CarrierManager.Instance.GetCarrier(chamber);
  1309. if (carrier != null)
  1310. {
  1311. CarrierManager.Instance.UpdateWaferIn(chamber, 0, false);
  1312. }
  1313. var wafers = WaferManager.Instance.GetWafers(chamber);
  1314. if (wafers != null && carrier != null)
  1315. {
  1316. foreach (var wafer in wafers)
  1317. {
  1318. if (wafer != null && !wafer.IsEmpty)
  1319. {
  1320. CarrierManager.Instance.UpdateWaferIn(chamber, 0, true);
  1321. break;
  1322. }
  1323. }
  1324. }
  1325. EV.PostInfoLog(Module, $"Delete wafer from {slotFrom} to {slotTo} successed.");
  1326. return true;
  1327. }
  1328. private CarrierType GetStockerType(string name)
  1329. {
  1330. var result = CarrierType.SD;
  1331. var scName = name.Contains("LP") ? $"{name}Type" : $"{name}WaferType";
  1332. string configType = SC.GetStringValue($"System.Stocker.{scName}");
  1333. if (string.IsNullOrEmpty(configType))
  1334. {
  1335. return result;
  1336. }
  1337. result = configType.StartsWith(CarrierType.P.ToString()) ? CarrierType.P : (CarrierType)Enum.Parse(typeof(CarrierType), configType);
  1338. return result;
  1339. }
  1340. public bool InvokeCreateCarrier(string arg1, object[] args)
  1341. {
  1342. ModuleName chamber = ModuleHelper.Converter(args[0].ToString());
  1343. int slot = (int)args[1];
  1344. CarrierType carrierTye = GetStockerType(chamber.ToString());
  1345. bool isCheckType = true;
  1346. if (args.Length > 2)
  1347. {
  1348. if (args.Length > 3)
  1349. {
  1350. isCheckType = bool.Parse(args[3].ToString());
  1351. }
  1352. var inputType = args[2].ToString();
  1353. if (!carrierTye.ToString().Equals(CarrierType.None.ToString()) && !carrierTye.ToString().Equals(inputType) && isCheckType)
  1354. {
  1355. EV.PostInfoLog(Module, $"{chamber} type mismatch!");
  1356. return false;
  1357. }
  1358. Enum.TryParse(args[2].ToString(), out carrierTye);
  1359. }
  1360. if (CarrierManager.Instance.HasCarrier(args[0].ToString(), slot))
  1361. {
  1362. EV.PostInfoLog("System", $"{chamber} already has carrier.create is not valid");
  1363. }
  1364. else
  1365. {
  1366. CarrierManager.Instance.CreateCarrier(args[0].ToString(), carrierTye, args[0].ToString());
  1367. EV.PostInfoLog("System", $"{chamber} create carrier");
  1368. }
  1369. var wafers = WaferManager.Instance.GetWafers(chamber);
  1370. if (wafers != null)
  1371. {
  1372. foreach (var wafer in wafers)
  1373. {
  1374. if (wafer != null && !wafer.IsEmpty)
  1375. {
  1376. CarrierManager.Instance.UpdateWaferIn(chamber, 0, true);
  1377. break;
  1378. }
  1379. }
  1380. }
  1381. return true;
  1382. }
  1383. private bool InvokeDeleteCarrier(string arg1, object[] args)
  1384. {
  1385. ModuleName chamber = ModuleHelper.Converter(args[0].ToString());
  1386. if (CarrierManager.Instance.HasCarrier(chamber.ToString()))
  1387. {
  1388. CarrierManager.Instance.DeleteCarrier(chamber.ToString());
  1389. EV.PostInfoLog("System", $"Carrier deleted from {chamber}");
  1390. var wafers = WaferManager.Instance.GetWafers(chamber);
  1391. for (int i = 0; i < wafers.Length; i++)
  1392. {
  1393. if (!wafers[i].IsEmpty)
  1394. WaferManager.Instance.DeleteWafer(chamber, i);
  1395. }
  1396. }
  1397. else
  1398. {
  1399. EV.PostInfoLog("System", string.Format("No carrier at {0}, delete not valid", chamber.ToString()));
  1400. }
  1401. return true;
  1402. }
  1403. private bool InvokeSetLotID(string arg1, object[] args)
  1404. {
  1405. ModuleName chamber = ModuleHelper.Converter(args[0].ToString());
  1406. List<string> lotIdLst = new List<string>();
  1407. foreach (var module in Modules.Keys)
  1408. {
  1409. if ((Modules[module] as StockerModule) == null)
  1410. continue;
  1411. if (CarrierManager.Instance.HasCarrier(module.ToString()))
  1412. {
  1413. lotIdLst.Add(CarrierManager.Instance.GetCarrier(module.ToString()).CarrierId);
  1414. }
  1415. }
  1416. if (lotIdLst.Any(x => x == args[1].ToString()))
  1417. {
  1418. SetLotIDFailedWarning.Set($"Carrier ID={args[1]} of {chamber} is already exist");
  1419. return false;
  1420. }
  1421. if (CarrierManager.Instance.HasCarrier(chamber.ToString()))
  1422. {
  1423. CarrierManager.Instance.UpdateCarrierId(chamber.ToString(), args[1].ToString());
  1424. EV.PostInfoLog("System", $"Carrier {chamber} update carrier ID {args[1]}");
  1425. }
  1426. else
  1427. {
  1428. EV.PostInfoLog("System", string.Format("No carrier at {0}, update carrier ID not valid", chamber.ToString()));
  1429. }
  1430. return true;
  1431. }
  1432. private bool InvokeShutDown(string arg1, object[] arg2)
  1433. {
  1434. if (IsAlarm || IsIdle || IsInit)
  1435. {
  1436. EV.PostWarningLog(Module, $"System start shut down");
  1437. EV.PostKickoutMessage("ShutDown");
  1438. RtApplication.Instance.Terminate();
  1439. return true;
  1440. }
  1441. EV.PostWarningLog(Module, $"System in {StringFsmStatus} mode, can not shut down");
  1442. return false;
  1443. }
  1444. private void OnModuleError(string module)
  1445. {
  1446. if (FsmState == (int)RtState.AutoRunning)
  1447. {
  1448. ModuleName mod = ModuleHelper.Converter(module);
  1449. PostMsg(MSG.ModuleError, module);
  1450. }
  1451. }
  1452. public override void Monitor()
  1453. {
  1454. base.Monitor();
  1455. }
  1456. private bool CheckPWaferBatch(ModuleName module, string batch)
  1457. {
  1458. string stockerWaferType = batch == "A" ? "P1" : "P2";
  1459. return SC.GetStringValue($"System.Stocker.{module}WaferType") == stockerWaferType;
  1460. }
  1461. private bool CheckMWaferBatch(ModuleName module, string batch)
  1462. {
  1463. string stockerWaferType = batch == "A" ? "M1" : "M2";
  1464. return SC.GetStringValue($"System.Stocker.{module}WaferType") == stockerWaferType;
  1465. }
  1466. private bool CheckJobPause()
  1467. {
  1468. return _pauseTrig.R;
  1469. }
  1470. private bool CheckToPostJobMessage(int msg, params object[] args)
  1471. {
  1472. _cycledCount = 0;
  1473. //只有LoadProcessUnload和ChargeProcessDischarge有cycle模式
  1474. if (SC.GetValue<bool>("System.IsCycleMode") && (msg == (int)MSG.LoadProcessUnload || msg == (int)MSG.ChargeProcessDischarge))
  1475. {
  1476. lock (_locker)
  1477. {
  1478. _jobMSG = msg;
  1479. _jobParas = args;
  1480. }
  1481. }
  1482. else
  1483. {
  1484. lock (_locker)
  1485. {
  1486. _jobMSG = 0;
  1487. _jobParas = null;
  1488. }
  1489. }
  1490. return CheckToPostMessage(msg, args);
  1491. }
  1492. private bool OnCycleTimer()
  1493. {
  1494. fMonitorFAJob();
  1495. if (!SC.GetValue<bool>("System.IsSimulatorMode"))
  1496. {
  1497. //_plcConnectTrig.CLK = !(IoProviderManager.Instance.Providers[0] as AdsPlcAdapter).IsPlcConnected;
  1498. //if (_plcConnectTrig.R)
  1499. //{
  1500. // PLCDisconnectAlarm.Set();
  1501. //}
  1502. //if (_plcConnectTrig.T)
  1503. //{
  1504. // EV.ClearAlarmEvent(PLCDisconnectAlarm.Id);
  1505. // PLCDisconnectAlarm.Reset();
  1506. // PLCConnectRecoveryWarning.Set();
  1507. //}
  1508. }
  1509. _cassetteRobotModule.Monitor();
  1510. _waferRobotModule.Monitor();
  1511. _lp1Module.Monitor();
  1512. _lp2Module.Monitor();
  1513. _lp3Module.Monitor();
  1514. _lp4Module.Monitor();
  1515. _fims1Module.Monitor();
  1516. _fims2Module.Monitor();
  1517. _boatModule.Monitor();
  1518. foreach (var module in Modules.Keys)
  1519. {
  1520. if (!(Modules[module] is StockerModule))
  1521. continue;
  1522. Modules[module].Monitor();
  1523. }
  1524. return true;
  1525. }
  1526. public List<ProcessJobInfo> GetProcessJobInfo()
  1527. {
  1528. return _auto.LstProcessJobs;
  1529. }
  1530. public List<Tuple<string, string, List<int>>> GetProcessingStockers()
  1531. {
  1532. return _auto.GetProcessingStockers();
  1533. }
  1534. public List<Tuple<string, string, List<int>>> GetAllPJStockers()
  1535. {
  1536. return _auto.GetAllPJStockers();
  1537. }
  1538. public List<CarrierPara> GetTransferJobStockers()
  1539. {
  1540. return _transferJob.GetTransferJobStockers();
  1541. }
  1542. public void ResetTask(ModuleName module)
  1543. {
  1544. _auto.ResetTask(module);
  1545. _transferJob.ResetTask(module);
  1546. (_returnAll as ReturnAllWafer).ResetTask(module);
  1547. }
  1548. private void CoolingSkip()
  1549. {
  1550. _auto.CoolingSkip();
  1551. }
  1552. public void SetVisibility(CarrierInfo carrierInfo, bool setValue, string moduleName = null)
  1553. {
  1554. if (carrierInfo == null)
  1555. {
  1556. return;
  1557. }
  1558. carrierInfo.UIExitFoup = setValue;
  1559. carrierInfo.UICarrierColorVisibility = setValue;
  1560. carrierInfo.UICarrierStatusVisibility = setValue;
  1561. carrierInfo.UICarrierTypeVisibility = setValue;
  1562. carrierInfo.UICarrierWaferCountVisibility = setValue;
  1563. }
  1564. public void SetUIWaferCount(CarrierInfo carrierInfo, ModuleName name, out WaferInfo[] wafers)
  1565. {
  1566. wafers = WaferManager.Instance.GetWafers(name);
  1567. if (carrierInfo == null)
  1568. {
  1569. return;
  1570. }
  1571. var count = wafers == null ? 0 : wafers.Count(a => !a.IsEmpty);
  1572. carrierInfo.UICarrierWaferCount = $"({count})";
  1573. }
  1574. public string GetActivePjStatus()
  1575. {
  1576. return _auto.GetFirstPJStatus();
  1577. }
  1578. public void PjFinished(string endStatus = "Normal")
  1579. {
  1580. _auto.PjFinished(endStatus);
  1581. }
  1582. #region FA
  1583. private bool FsmFAJobCommand(object[] param)
  1584. {
  1585. switch ((string)param[0])
  1586. {
  1587. case "CreateProcessJob":
  1588. _auto.CreateProcessJob(out var pj, (Dictionary<string, object>)param[1]);
  1589. break;
  1590. case "CreateControlJob":
  1591. _auto.CreateControlJob((string)param[1], (List<string>)param[2], out var cj);
  1592. //_auto.StartJob((string)param[1]);
  1593. //CheckToPostMessage((int)MSG.StartJob, (string)param[1]);
  1594. break;
  1595. }
  1596. return true;
  1597. }
  1598. public bool ScheduleMaintenanceCommandCreateJob(Dictionary<string, object> param, int priorityExecuteLevel)
  1599. {
  1600. return CheckToPostMessage((int)MSG.CreateJob, param, priorityExecuteLevel);
  1601. }
  1602. public void SetPJState()
  1603. {
  1604. if (_auto == null)
  1605. return;
  1606. _auto.SetPJState();
  1607. }
  1608. #endregion
  1609. }
  1610. }