EquipmentManager_FA.cs 37 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Collections.ObjectModel;
  4. using System.Linq;
  5. using System.Threading.Tasks;
  6. using System.Xml.Linq;
  7. using Aitex.Common.Util;
  8. using Aitex.Core.Common;
  9. using Aitex.Core.RT.DataCenter;
  10. using Aitex.Core.RT.Event;
  11. using Aitex.Core.RT.Log;
  12. using Aitex.Core.RT.OperationCenter;
  13. using Aitex.Core.RT.RecipeCenter;
  14. using Aitex.Core.RT.SCCore;
  15. using Aitex.Core.Util;
  16. using FabConnect.SecsGemInterface.Application.Objects.ProcessManagement;
  17. using FabConnect.SecsGemInterface.Common;
  18. using FabConnect.SecsGemInterface.Common.ToolModel;
  19. using FabConnect.SecsGemInterface.GemModel;
  20. using FabConnect.SecsGemInterface.HostCommon;
  21. using FACore.E87FA;
  22. using FurnaceRT.Equipments.LPs;
  23. using FurnaceRT.Equipments.PMs;
  24. using FurnaceRT.Equipments.Schedulers;
  25. using FurnaceRT.Equipments.Stockers;
  26. using MECF.Framework.Common.DataCenter;
  27. using MECF.Framework.Common.Equipment;
  28. using MECF.Framework.Common.FAServices;
  29. using MECF.Framework.Common.FAServices.E40s;
  30. using MECF.Framework.Common.SubstrateTrackings;
  31. using MECF.Framework.FA.Core.CommonTypes;
  32. using MECF.Framework.FA.Core.ConcurrentCollections;
  33. using MECF.Framework.FA.Core.E40FA;
  34. using MECF.Framework.FA.Core.E87FA;
  35. using MECF.Framework.FA.Core.E94FA;
  36. using MECF.Framework.FA.Core.FAControl;
  37. using MtrlOutSpecPair = MECF.Framework.FA.Core.E94FA.MtrlOutSpecPair;
  38. namespace FurnaceRT.Equipments.Systems
  39. {
  40. public partial class EquipmentManager
  41. {
  42. private SchedulerDBCallback _dbCallback;
  43. public SECsDataItem _SideDummyStateDetail = new SECsDataItem(SECsFormat.List);
  44. public SECsDataItem SideDummyStateDetail
  45. {
  46. get
  47. {
  48. _SideDummyStateDetail = new SECsDataItem(SECsFormat.List);
  49. foreach (var _carrier in CarrierManager.Instance.GetCarrierbytype(CarrierType.SD))
  50. {
  51. SECsDataItem _carrierCountsecsdat = new SECsDataItem(SECsFormat.List);
  52. SECsDataItem _carrierTimesecsdat = new SECsDataItem(SECsFormat.List);
  53. SECsDataItem _carrierThicksecsdat = new SECsDataItem(SECsFormat.List);
  54. SECsDataItem _carriersecsdat = new SECsDataItem(SECsFormat.List);
  55. float maxUseCount = 0;
  56. float maxUseTime = 0;
  57. float maxUseThick = 0;
  58. foreach (var key in Singleton<EquipmentManager>.Instance.Modules.Keys)
  59. {
  60. var wafers = WaferManager.Instance.GetWafers(key);
  61. if (wafers == null)
  62. continue;
  63. foreach (var wafer in wafers)
  64. {
  65. if (wafer != null && !wafer.IsEmpty && wafer.WaferType == WaferType.SD && wafer.OriginStation == (int)_carrier.InternalModuleName)
  66. {
  67. if (wafer.UseCount > maxUseCount)
  68. maxUseCount = wafer.UseCount;
  69. if (wafer.UseTime > maxUseTime)
  70. maxUseTime = wafer.UseTime;
  71. if (wafer.UseThick > maxUseThick)
  72. maxUseThick = wafer.UseThick;
  73. }
  74. }
  75. }
  76. string useCountState = "UNDIFINE";
  77. string useTimeState = "UNDIFINE";
  78. string useThickState = "UNDIFINE";
  79. if (maxUseCount >= SC.GetValue<int>($"PM1.WaferCycleTime.SDCountAlarm") && maxUseCount > 0)
  80. useCountState = "EXCHANGE";
  81. else if (maxUseCount >= SC.GetValue<int>($"PM1.WaferCycleTime.SDCountWarning") && maxUseCount > 0)
  82. useCountState = "OVER";
  83. else
  84. useCountState = "NORMAL";
  85. if (maxUseTime >= SC.GetValue<int>($"PM1.WaferCycleTime.SDTimeAlarm") && maxUseTime > 0)
  86. useTimeState = "EXCHANGE";
  87. else if (maxUseTime >= SC.GetValue<int>($"PM1.WaferCycleTime.SDTimeWarning") && maxUseTime > 0)
  88. useTimeState = "OVER";
  89. else
  90. useTimeState = "NORMAL";
  91. if (maxUseThick >= SC.GetValue<int>($"PM1.WaferCycleTime.SDThicknessAlarm") && maxUseThick > 0)
  92. useThickState = "EXCHANGE";
  93. else if (maxUseThick >= SC.GetValue<int>($"PM1.WaferCycleTime.SDThicknessWarning") && maxUseThick > 0)
  94. useThickState = "OVER";
  95. else
  96. useThickState = "NORMAL";
  97. int dummystate = 1;
  98. if (useCountState == "OVER" || useTimeState == "OVER" || useThickState == "OVER")
  99. {
  100. dummystate = 3;
  101. }
  102. if (useCountState == "EXCHANGE" || useTimeState == "EXCHANGE" || useThickState == "EXCHANGE")
  103. {
  104. dummystate = 2;
  105. }
  106. _carrierCountsecsdat.Add("UsedCountCaution", SC.GetValue<int>($"PM1.WaferCycleTime.SDCountWarning"), SECsFormat.U2);
  107. _carrierCountsecsdat.Add("UsedCountAlarm", SC.GetValue<int>($"PM1.WaferCycleTime.SDCountAlarm"), SECsFormat.U2);
  108. _carrierCountsecsdat.Add("UsedCount", (int)maxUseCount, SECsFormat.U2);
  109. //_carrierCountsecsdat.Add("UsedCountState", useCountState, SECsFormat.Ascii);
  110. _carrierTimesecsdat.Add("UsedTimeCaution", (int)SC.GetValue<double>($"PM1.WaferCycleTime.SDTimeWarning"), SECsFormat.U2);
  111. _carrierTimesecsdat.Add("UsedTimeAlarm", (int)SC.GetValue<double>($"PM1.WaferCycleTime.SDTimeAlarm"), SECsFormat.U2);
  112. _carrierTimesecsdat.Add("UsedTime", (int)maxUseTime, SECsFormat.U2);
  113. //_carrierTimesecsdat.Add("UsedTimeState", useTimeState, SECsFormat.Ascii);
  114. _carrierThicksecsdat.Add("UsedThicknessCaution", (int)SC.GetValue<double>($"PM1.WaferCycleTime.SDThicknessWarning"), SECsFormat.U4);
  115. _carrierThicksecsdat.Add("UsedThicknessAlarm", (int)SC.GetValue<double>($"PM1.WaferCycleTime.SDThicknessAlarm"), SECsFormat.U4);
  116. _carrierThicksecsdat.Add("UsedThickness", (int)maxUseThick, SECsFormat.U4);
  117. //_carrierThicksecsdat.Add("UsedThicknessState", useThickState, SECsFormat.Ascii);
  118. _carriersecsdat.Add("CarrierID", _carrier.CarrierId, SECsFormat.Ascii);
  119. _carriersecsdat.Add("State", dummystate, SECsFormat.U1);
  120. _carriersecsdat.Add(_carrierCountsecsdat);
  121. _carriersecsdat.Add(_carrierTimesecsdat);
  122. _carriersecsdat.Add(_carrierThicksecsdat);
  123. _SideDummyStateDetail.Add(_carriersecsdat);
  124. }
  125. return _SideDummyStateDetail;
  126. }
  127. }
  128. public SECsDataItem _ExtraDummyStateDetail = new SECsDataItem(SECsFormat.List);
  129. public SECsDataItem ExtraDummyStateDetail
  130. {
  131. get
  132. {
  133. _ExtraDummyStateDetail = new SECsDataItem(SECsFormat.List);
  134. foreach (var _carrier in CarrierManager.Instance.GetCarrierbytype(CarrierType.ED))
  135. {
  136. SECsDataItem _carrierCountsecsdat = new SECsDataItem(SECsFormat.List);
  137. SECsDataItem _carrierTimesecsdat = new SECsDataItem(SECsFormat.List);
  138. SECsDataItem _carrierThicksecsdat = new SECsDataItem(SECsFormat.List);
  139. SECsDataItem _carriersecsdat = new SECsDataItem(SECsFormat.List);
  140. float maxUseCount = 0;
  141. float maxUseTime = 0;
  142. float maxUseThick = 0;
  143. foreach (var key in Singleton<EquipmentManager>.Instance.Modules.Keys)
  144. {
  145. var wafers = WaferManager.Instance.GetWafers(key);
  146. if (wafers == null)
  147. continue;
  148. foreach (var wafer in wafers)
  149. {
  150. if (wafer != null && !wafer.IsEmpty && wafer.WaferType == WaferType.ED && wafer.OriginStation == (int)_carrier.InternalModuleName)
  151. {
  152. if (wafer.UseCount > maxUseCount)
  153. maxUseCount = wafer.UseCount;
  154. if (wafer.UseTime > maxUseTime)
  155. maxUseTime = wafer.UseTime;
  156. if (wafer.UseThick > maxUseThick)
  157. maxUseThick = wafer.UseThick;
  158. }
  159. }
  160. }
  161. string useCountState = "UNDIFINE";
  162. string useTimeState = "UNDIFINE";
  163. string useThickState = "UNDIFINE";
  164. if (maxUseCount >= SC.GetValue<int>($"PM1.WaferCycleTime.EDCountAlarm") && maxUseCount > 0)
  165. useCountState = "EXCHANGE";
  166. else if (maxUseCount >= SC.GetValue<int>($"PM1.WaferCycleTime.EDCountWarning") && maxUseCount > 0)
  167. useCountState = "OVER";
  168. else
  169. useCountState = "NORMAL";
  170. if (maxUseTime >= SC.GetValue<int>($"PM1.WaferCycleTime.EDTimeAlarm") && maxUseTime > 0)
  171. useTimeState = "EXCHANGE";
  172. else if (maxUseTime >= SC.GetValue<int>($"PM1.WaferCycleTime.EDTimeWarning") && maxUseTime > 0)
  173. useTimeState = "OVER";
  174. else
  175. useTimeState = "NORMAL";
  176. if (maxUseThick >= SC.GetValue<int>($"PM1.WaferCycleTime.EDThicknessAlarm") && maxUseThick > 0)
  177. useThickState = "EXCHANGE";
  178. else if (maxUseThick >= SC.GetValue<int>($"PM1.WaferCycleTime.EDThicknessWarning") && maxUseThick > 0)
  179. useThickState = "OVER";
  180. else
  181. useThickState = "NORMAL";
  182. int dummystate = 1;
  183. if (useCountState == "OVER" || useTimeState == "OVER" || useThickState == "OVER")
  184. {
  185. dummystate = 3;
  186. }
  187. if (useCountState == "EXCHANGE" || useTimeState == "EXCHANGE" || useThickState == "EXCHANGE")
  188. {
  189. dummystate = 2;
  190. }
  191. _carrierCountsecsdat.Add("UsedCountCaution", SC.GetValue<int>($"PM1.WaferCycleTime.EDCountWarning"), SECsFormat.U2);
  192. _carrierCountsecsdat.Add("UsedCountAlarm", SC.GetValue<int>($"PM1.WaferCycleTime.EDCountAlarm"), SECsFormat.U2);
  193. _carrierCountsecsdat.Add("UsedCount", (int)maxUseCount, SECsFormat.U2);
  194. //_carrierCountsecsdat.Add("UsedCountState", useCountState, SECsFormat.Ascii);
  195. _carrierTimesecsdat.Add("UsedTimeCaution", (int)SC.GetValue<double>($"PM1.WaferCycleTime.EDTimeWarning"), SECsFormat.U2);
  196. _carrierTimesecsdat.Add("UsedTimeAlarm", (int)SC.GetValue<double>($"PM1.WaferCycleTime.EDTimeAlarm"), SECsFormat.U2);
  197. _carrierTimesecsdat.Add("UsedTime", (int)maxUseTime, SECsFormat.U2);
  198. //_carrierTimesecsdat.Add("UsedTimeState", useTimeState, SECsFormat.Ascii);
  199. _carrierThicksecsdat.Add("UsedThicknessCaution", (int)SC.GetValue<double>($"PM1.WaferCycleTime.EDThicknessWarning"), SECsFormat.U4);
  200. _carrierThicksecsdat.Add("UsedThicknessAlarm", (int)SC.GetValue<double>($"PM1.WaferCycleTime.EDThicknessAlarm"), SECsFormat.U4);
  201. _carrierThicksecsdat.Add("UsedThickness", (int)maxUseThick, SECsFormat.U4);
  202. //_carrierThicksecsdat.Add("UsedThicknessState", useThickState, SECsFormat.Ascii);
  203. _carriersecsdat.Add("CarrierID", _carrier.CarrierId, SECsFormat.Ascii);
  204. _carriersecsdat.Add("State", dummystate, SECsFormat.U1);
  205. _carriersecsdat.Add(_carrierCountsecsdat);
  206. _carriersecsdat.Add(_carrierTimesecsdat);
  207. _carriersecsdat.Add(_carrierThicksecsdat);
  208. _ExtraDummyStateDetail.Add(_carriersecsdat);
  209. }
  210. return _ExtraDummyStateDetail;
  211. }
  212. }
  213. public void CreatePj(string processName)
  214. {
  215. _auto.CreatePj(processName);
  216. }
  217. public void StartPj()
  218. {
  219. _auto.StartPj();
  220. }
  221. public void EndPj(string endStatus = "Normal")
  222. {
  223. _auto?.EndPj(endStatus);
  224. //_auto.UpdataPJAlarmStatus(endStatus);
  225. }
  226. public string GetFirstPJId()
  227. {
  228. return _auto.GetFirstPJId();
  229. }
  230. }
  231. public partial class EquipmentManager : IEquipmentCallBack
  232. {
  233. public void InitializeFA(string file)
  234. {
  235. Singleton<FAJobController>.Instance.Initialize("Furnace", file,
  236. new int[] { 1, 2, 3, 4 }, Singleton<EquipmentManager>.Instance, null);
  237. SubscribeFAState();
  238. }
  239. private void SubscribeFAState()
  240. {
  241. //foreach (var portId in new int[] { 1, 2, 3, 4 })
  242. //{
  243. // var lp = Singleton<FAJobController>.Instance.GetLoadPort(portId);
  244. // DATA.Subscribe($"LP{portId}.AccessMode", lp.CurrentAccessMode.ToString());
  245. // DATA.Subscribe($"LP{portId}.TransferState", lp.CurrentTransferState.ToString());
  246. // DATA.Subscribe($"LP{portId}.ReserveState", lp.CurrentReserveState.ToString());
  247. // DATA.Subscribe($"LP{portId}.ReserveState", lp.CurrentReserveState.ToString());
  248. //}
  249. //DATA.Subscribe($"System.CommunicationStatus", () => Singleton<FAJobController>.Instance.FaCommunicationState.ToString());
  250. //DATA.Subscribe($"System.ControlStatus", () => Singleton<FAJobController>.Instance.FaControlState.ToString());
  251. //DATA.Subscribe($"System.SpoolingState", () => Singleton<FAJobController>.Instance.SpoolingState.ToString());
  252. //OP.Subscribe("FACommand", InvokeFaCommand);
  253. }
  254. private bool InvokeFaCommand(string method, object[] arg2)
  255. {
  256. Singleton<FAJobController>.Instance.Invoke(arg2[0].ToString(), arg2);
  257. return true;
  258. }
  259. public bool SetContentMap(int portId, ContentMap[] cmaps)
  260. {
  261. return true;
  262. }
  263. public bool SetCarrierID(int portId, string carrierId)
  264. {
  265. return true;
  266. }
  267. public bool SetCarrierUsage(int portId, string usage)
  268. {
  269. return true;
  270. }
  271. public bool VerifySlotMap(int portId, SlotSubstrateStatus[] slotmap)
  272. {
  273. return true;
  274. }
  275. public bool VerifySubstrateCount(int portId, int count)
  276. {
  277. return true;
  278. }
  279. public bool ReleaseCarrier(int portId)
  280. {
  281. var _lp = Modules[ModuleName.LP1] as LoadPortModule;
  282. if (portId == 1)
  283. {
  284. _lp = Modules[ModuleName.LP1] as LoadPortModule;
  285. }
  286. else if (portId == 2)
  287. {
  288. _lp = Modules[ModuleName.LP2] as LoadPortModule;
  289. }
  290. else
  291. {
  292. return false;
  293. }
  294. //return _lp.LPDevice.SetCatchRelease(false);
  295. return true;
  296. }
  297. public bool ProceedToGetSlotMap(int portId, string carrierId)
  298. {
  299. return true;
  300. }
  301. public bool ReadCarrierID(int portId, out string carrierId, out string reason, int startPage = 0, int length = 16)
  302. {
  303. carrierId = "";
  304. reason = "";
  305. return true;
  306. }
  307. public bool WriteCarrierID(int portId, string carrierId, out string reason, int startPage = 0, int length = 16)
  308. {
  309. reason = "";
  310. return true;
  311. }
  312. public bool InformAccessModeChanged(int portId, bool isauto)
  313. {
  314. return true;
  315. }
  316. public bool InformTransferStateChanged(int portId, LPTransferState state)
  317. {
  318. return true;
  319. }
  320. public bool IsTransferReady(int portId, out bool isCarrierOn)
  321. {
  322. isCarrierOn = true;
  323. return true;
  324. }
  325. private bool fMonitorFAJob()
  326. {
  327. //Singleton<FAJobController>.Instance.MonitorJob();
  328. E40ProcessJob[] pjs = Singleton<FAJobController>.Instance.FAProcessJobs.Values.ToArray();
  329. E94ControlJob[] cjs = Singleton<FAJobController>.Instance.FAControlJobs.Values.ToArray();
  330. if (Singleton<FAJobController>.Instance.FAProcessJobs.Count == 0) return true;
  331. if (Singleton<FAJobController>.Instance.FAControlJobs.Count == 0) return true;
  332. foreach (var pj in pjs)
  333. {
  334. if ((pj.PRJobState == PRJobState.NO_STATE || pj.PRJobState == PRJobState.PROCESS_COMPLETE)
  335. && Singleton<FAJobController>.Instance.FAProcessJobs.ContainsKey(pj.objID))
  336. Singleton<FAJobController>.Instance.FAProcessJobs.Remove(pj.objID);
  337. if (pj.PRJobState == PRJobState.ABORTING)
  338. Singleton<FAJobController>.Instance.FAProcessJobs[pj.objID].RequestStop();
  339. if (pj.PRJobState == PRJobState.ABORTED)
  340. Singleton<FAJobController>.Instance.FAProcessJobs.Remove(pj.objID);
  341. }
  342. foreach (var cj in cjs)
  343. {
  344. if ((cj.State == CtrlJobState.Nostate || cj.State == CtrlJobState.Completed)
  345. && Singleton<FAJobController>.Instance.FAControlJobs.ContainsKey(cj.objID))
  346. Singleton<FAJobController>.Instance.FAControlJobs.Remove(cj.objID);
  347. }
  348. foreach (var pj in pjs)
  349. {
  350. if (pj.PRJobState == PRJobState.QUEUED && pj.ControlJobID != null)
  351. {
  352. bool checkMapOk = true;
  353. foreach (var mtrlname in pj.PRMtlNameList)
  354. {
  355. var test = Singleton<FAJobController>.Instance.GetCarrier(mtrlname.CarrierID).CarrierIdStatus;
  356. var test1 = Singleton<FAJobController>.Instance.GetCarrier(mtrlname.CarrierID).SlotMapStatus;
  357. if (test == CarrierIDStatus.ID_VERIFICATION_OK &&
  358. test1 == SlotMapStatus.SLOT_MAP_VERIFICATION_OK)
  359. {
  360. }
  361. else
  362. {
  363. checkMapOk = false;
  364. }
  365. }
  366. if (checkMapOk)
  367. {
  368. pj.ProcessResourceAllocated();
  369. AssignProcessJob(pj);
  370. }
  371. }
  372. }
  373. foreach (var cj in cjs)
  374. {
  375. if (cj.State == CtrlJobState.Queued)
  376. {
  377. bool allPjSetUp = true;
  378. foreach (var pj in cj.ProcessingCtrlSpec)
  379. {
  380. if (!Singleton<FAJobController>.Instance.FAProcessJobs.ContainsKey(pj.PRJobID))
  381. {
  382. allPjSetUp = false;
  383. break;
  384. }
  385. if (Singleton<FAJobController>.Instance.FAProcessJobs[pj.PRJobID].PRJobState != PRJobState.SETTING_UP)
  386. {
  387. allPjSetUp = false;
  388. break;
  389. }
  390. }
  391. if (allPjSetUp)
  392. {
  393. cj.CJSelected();
  394. }
  395. }
  396. //string sourceModule = "";
  397. //检查source ready
  398. if (cj.State == CtrlJobState.Selected)
  399. {
  400. if (!_auto.IsCJExisted(cj.objID))
  401. {
  402. AssignControlJob(cj);
  403. }
  404. if (_auto.IsCJExcuting(cj.objID))
  405. {
  406. Task.Delay(1500).ContinueWith(x =>
  407. {
  408. if (_auto.IsCJExisted(cj.objID))
  409. {
  410. cj.MaterialArrived();
  411. Task.Delay(500).ContinueWith(y =>
  412. {
  413. foreach (var pj in cj.ProcessingCtrlSpec)
  414. {
  415. Singleton<FAJobController>.Instance.FAProcessJobs[pj.PRJobID].MaterialPresentAndResouceReady();
  416. }
  417. });
  418. }
  419. else
  420. {
  421. foreach (var pj in cj.ProcessingCtrlSpec)
  422. {
  423. Singleton<FAJobController>.Instance.FAProcessJobs[pj.PRJobID].RequestAbort();
  424. }
  425. Task.Delay(500).ContinueWith(y =>
  426. {
  427. var Status = new MECF.Framework.FA.Core.E94FA.Status();
  428. cj.CJAbort(out Status);
  429. });
  430. }
  431. });
  432. }
  433. cj.MtrlOutSpec.Clear();
  434. }
  435. }
  436. return true;
  437. }
  438. public bool AssignProcessJob(E40ProcessJob pj)
  439. {
  440. //return true;
  441. string M1CarrierPara = "";
  442. string M2CarrierPara = "";
  443. string PCarrierPara = "";
  444. List<string> _processcridlst = new List<string>();
  445. foreach (var item in pj.PRMtlNameList)
  446. {
  447. foreach (var _modulename in Modules.Keys)
  448. {
  449. var stockermodule = Modules[_modulename] as StockerModule;
  450. if (_modulename.ToString().Contains("Stocker") && stockermodule.CurrentCarrier.CarrierId == item.CarrierID)
  451. {
  452. if (stockermodule.CurrentCarrier.CarrierType == CarrierType.P)
  453. {
  454. PCarrierPara += _modulename + "," + (item.CarrierID) + ";";
  455. _processcridlst.Add(item.CarrierID);
  456. }
  457. if (stockermodule.CurrentCarrier.CarrierType == CarrierType.M1)
  458. {
  459. M1CarrierPara += _modulename + "," + (item.CarrierID) + ";";
  460. _processcridlst.Add(item.CarrierID);
  461. }
  462. if (stockermodule.CurrentCarrier.CarrierType == CarrierType.M2)
  463. {
  464. M2CarrierPara += _modulename + "," + (item.CarrierID) + ";";
  465. _processcridlst.Add(item.CarrierID);
  466. }
  467. }
  468. }
  469. }
  470. string pCarrierPara = string.IsNullOrEmpty(PCarrierPara) ? "" : PCarrierPara.TrimEnd(';');
  471. string m1CarrierPara = string.IsNullOrEmpty(M1CarrierPara) ? "" : M1CarrierPara.TrimEnd(';');
  472. string m2CarrierPara = string.IsNullOrEmpty(M2CarrierPara) ? "" : M2CarrierPara.TrimEnd(';');
  473. int cooltime = !SC.ContainsItem("System.Scheduler.DefaultCoolTime") ? 10 : (int)(SC.GetValue<double>("System.Scheduler.DefaultCoolTime") * 60);
  474. Dictionary<string, object> para = new Dictionary<string, object>();
  475. para.Add("PJID", pj.objID);
  476. para.Add("CarrierPara", PCarrierPara);
  477. para.Add("m1CarrierPara", m1CarrierPara);
  478. para.Add("m2CarrierPara", m2CarrierPara);
  479. para.Add("JobRecipe", pj.RecID.Replace("Furnace\\Job\\", ""));
  480. para.Add("ProcessRecipe", pj.RecID.Replace("Furnace\\Process\\", ""));
  481. para.Add("LayoutRecipe", ((pj.RecVariableList != null) && (pj.RecVariableList.Count() > 0)) ? pj.RecVariableList[0].RecipeVarValue.ToString() : "");
  482. para.Add("ControlJobName", pj.ControlJobID);
  483. para.Add("CoolTime", cooltime);
  484. para.Add("ProcessCarrierID", _processcridlst);
  485. CheckToPostMessage((int)MSG.FAJobCommand, new object[] { "CreateProcessJob", para });
  486. return true;
  487. }
  488. public bool AssignControlJob(E94ControlJob cj)
  489. {
  490. //return false;
  491. CheckToPostMessage((int)MSG.FAJobCommand, new object[] { "CreateControlJob", cj.objID, cj.CurrentPRJob });
  492. return true;
  493. }
  494. public bool RegisterEvent(bool isAlarm, string eventname, string eventcontext)
  495. {
  496. return true;
  497. }
  498. public int MaxPRJobSpace { get; } = 100;
  499. public int MaxCtrJobSpace { get; } = 100;
  500. public bool PostEvent(string eventName, string eventText)
  501. {
  502. EV.PostInfoLog("FA", $"{eventName}:{eventText}");
  503. return true;
  504. }
  505. public bool PostLog(string module, string logText)
  506. {
  507. LOG.Write($"{module}:{logText}");
  508. return true;
  509. }
  510. public bool ExcuteCommand(string command, ThreadSafeList<MECF.Framework.FA.Core.E87FA.Properties> properties, out RcmdStatus status)
  511. {
  512. status = new RcmdStatus();
  513. status.ack = RcmdAcknowledge.Ok_All_Normal;
  514. Dictionary<string, object> para = new Dictionary<string, object>();
  515. EV.PostInfoLog(Module, "进入ExcuteCommand");
  516. PMModule pm1 = Modules[ModuleName.PM1] as PMModule;
  517. switch (command.ToUpper())
  518. {
  519. case "GOREMOTE":
  520. OP.DoOperation("FACommand", "FARemote");
  521. break;
  522. case "GOLOCAL":
  523. OP.DoOperation("FACommand", "FALocal");
  524. break;
  525. case "HOLD ON":
  526. //if (pm1.Hold())
  527. //{
  528. // return true;
  529. //}
  530. //else
  531. //{
  532. // status.ack = RcmdAcknowledge.Cannot_perform_now;
  533. // return false;
  534. //}
  535. case "HOLD OFF":
  536. //if (pm1.RecipeContinue())
  537. //{
  538. // return true;
  539. //}
  540. //else
  541. //{
  542. // status.ack = RcmdAcknowledge.Cannot_perform_now;
  543. // return false;
  544. //}
  545. default:
  546. status.ack = RcmdAcknowledge.Invalid_command;
  547. return false;
  548. }
  549. return true;
  550. }
  551. public string[] GetRecipeList()
  552. {
  553. List<string> namelist = new List<string>();
  554. var processType = SC.GetStringValue("System.Recipe.FASupportedRecipeType");
  555. if (processType == null)
  556. {
  557. processType = "WaferFlow,COT,DEV,ADH,Oven,Pump,WEE,System,Dummy,Wash";
  558. //processType = "Process";
  559. }
  560. string[] recipeProcessType = ((string)processType).Split(',');
  561. for (int i = 0; i < recipeProcessType.Length; i++)
  562. {
  563. var prefix = $"Furnace\\{recipeProcessType[i]}";
  564. var recipes = RecipeFileManager.Instance.GetXmlRecipeNmaeList(prefix, false);
  565. namelist.AddRange(recipes);
  566. }
  567. return namelist.ToArray();
  568. }
  569. public string GetRecipeBody(string recipename)
  570. {
  571. var recipeContent = RecipeFileManager.Instance.LoadRecipeByFullPathForFA(recipename);
  572. if (recipename.StartsWith("Furnace\\Layout"))
  573. {
  574. // 解析XML
  575. XDocument doc = XDocument.Parse(recipeContent);
  576. // 获取Config节点
  577. XElement configElement = doc.Descendants("Config").Last();
  578. // 获取Name为"Normal"的Step节点
  579. XElement normalStepElement = doc.Descendants("Step").FirstOrDefault(step => step.Attribute("Name")?.Value == "Normal");
  580. if (normalStepElement != null && configElement != null)
  581. {
  582. // 将Config节点的所有属性添加到Normal Step节点
  583. foreach (XAttribute attr in configElement.Attributes())
  584. {
  585. // 检查属性是否已存在,如果不存在则添加
  586. if (normalStepElement.Attribute(attr.Name) == null)
  587. {
  588. normalStepElement.Add(new XAttribute(attr.Name, attr.Value));
  589. }
  590. }
  591. recipeContent = doc.ToString();
  592. }
  593. }
  594. return recipeContent;
  595. }
  596. public bool DeleteRecipes(string[] recipenames)
  597. {
  598. return true;
  599. }
  600. public bool IsAllowedToChangeRemote()
  601. {
  602. return true;
  603. }
  604. public PRJobCreatState InformPRJobCreate(IE40ProcessJob job, ref APCTunRetCode[] tuningResult)
  605. {
  606. return PRJobCreatState.SUCCESS;
  607. }
  608. public int InformPRJobDelete(IE40ProcessJob job)
  609. {
  610. return 0;
  611. }
  612. public void InformTargetCarrierArrived(IE40ProcessJob job)
  613. {
  614. }
  615. public virtual void InformCommunicationStateChange(CommunicationState state)
  616. {
  617. }
  618. public virtual void InformControlStateChange(ControlState state)
  619. {
  620. }
  621. public virtual object GetECValue(string ecname)
  622. {
  623. SCConfigItem sc;
  624. if (!SC.ContainsItem(ecname)) return null;
  625. sc = SC.GetConfigItem(ecname);
  626. return sc.Value;
  627. }
  628. public virtual bool SetECValue(string ecName, object ecValue)
  629. {
  630. if (SC.ContainsItem(ecName))
  631. SC.SetItemValueFromString(ecName, ecValue.ToString());
  632. return true;
  633. }
  634. public virtual object GetSVValue(string svname)
  635. {
  636. object data = DATA.Poll(svname);
  637. if (data != null)
  638. {
  639. return data;
  640. }
  641. return "";
  642. }
  643. public virtual void OnReceivedTerminalMessage(List<string> msg)
  644. {
  645. foreach (var message in msg)
  646. {
  647. EV.PostPopDialogMessage(EventLevel.Warning, "TerminalMessage", message);
  648. }
  649. }
  650. public virtual void InformCtrlJobHOQ(IE94ControlJob job)
  651. {
  652. return;
  653. }
  654. public virtual void InformCtrlJobInQueued(LinkedList<string> jobs)
  655. {
  656. }
  657. public virtual bool PerformPreConditioning(IE40ProcessJob pjob)
  658. {
  659. return true;
  660. }
  661. public virtual bool InformProcessStart(IE40ProcessJob pjob)
  662. {
  663. return true;
  664. }
  665. public virtual bool PerformPostConditioning(IE40ProcessJob pjob)
  666. {
  667. return true;
  668. }
  669. public virtual bool PerformTerminate(IE40ProcessJob pjob)
  670. {
  671. return true;
  672. }
  673. public bool InformCarrierAccessStateChange(int portId, string carrierId, AccessStatus state)
  674. {
  675. return true;
  676. }
  677. public bool InformCarrierIDStateChange(int portId, string carrierId, string carrierType, CarrierIDStatus state)
  678. {
  679. if ((carrierId != null && carrierId != "") && state == CarrierIDStatus.ID_VERIFICATION_OK)
  680. {
  681. StockerNameForFATJob.Clear();
  682. foreach (var moduleName in Modules.Keys)
  683. {
  684. var stockerModule = Modules[moduleName] as StockerModule;
  685. if (stockerModule == null || !stockerModule.CurrentCarrier.IsEmpty)
  686. continue;
  687. var occupyStockers = _transferJob.GetOccupyStockers();
  688. if (occupyStockers != null && occupyStockers.Any(x => x == moduleName.ToString()))
  689. continue;
  690. if (stockerModule.WaferType.Contains(carrierType.Replace("_", "")) || stockerModule.WaferType.Contains("None"))
  691. {
  692. StockerNameForFATJob.Add(moduleName);
  693. break;
  694. }
  695. }
  696. if (StockerNameForFATJob.Count == 0)
  697. {
  698. return false;
  699. }
  700. var _lp = Modules[ModuleName.LP1] as LoadPortModule;
  701. if (portId == 1)
  702. {
  703. _lp = Modules[ModuleName.LP1] as LoadPortModule;
  704. }
  705. else if (portId == 2)
  706. {
  707. _lp = Modules[ModuleName.LP2] as LoadPortModule;
  708. }
  709. else if (portId == 3)
  710. {
  711. _lp = Modules[ModuleName.LP3] as LoadPortModule;
  712. }
  713. else if (portId == 4)
  714. {
  715. _lp = Modules[ModuleName.LP4] as LoadPortModule;
  716. }
  717. else
  718. {
  719. return false;
  720. }
  721. _lp.UpdateCarrierID(carrierId);
  722. Dictionary<string, object> para = new Dictionary<string, object>();
  723. para.Add("WaferType", carrierType.Replace("_", ""));
  724. para.Add("CarrierPara", $"{StockerNameForFATJob.FirstOrDefault().ToString()},{carrierId},0,,,{_lp.Name.ToString()}");
  725. para.Add("TransferType", "Loading");
  726. return CheckToPostJobMessage((int)MSG.CreateTransferJob, para);
  727. //_transferJob.CreateJob(para);
  728. }
  729. return true;
  730. }
  731. public bool InformCarrierSlotMapStateChange(int portId, string carrierId, SlotMapStatus state)
  732. {
  733. return true;
  734. }
  735. public int InformPRJobStateChange(IE40ProcessJob job, PRJobState state)
  736. {
  737. return 0;
  738. }
  739. public void InformCtrlJobStateChange(IE94ControlJob job, CtrlJobState state)
  740. {
  741. }
  742. public virtual int InformCtrlJobCreate(IE94ControlJob job)
  743. {
  744. return 0;
  745. }
  746. public bool CarrierOutByID(string id, int portid)
  747. {
  748. StockerModule currrentStocker = null;
  749. foreach (var _modulename in Modules.Keys)
  750. {
  751. var stockermodule = Modules[_modulename] as StockerModule;
  752. if (_modulename.ToString().Contains("Stocker") && stockermodule.CurrentCarrier.CarrierId == id)
  753. {
  754. currrentStocker = stockermodule;
  755. }
  756. }
  757. var _lp = Modules[ModuleName.LP1] as LoadPortModule;
  758. if (portid == 1)
  759. {
  760. _lp = Modules[ModuleName.LP1] as LoadPortModule;
  761. }
  762. else if (portid == 2)
  763. {
  764. _lp = Modules[ModuleName.LP2] as LoadPortModule;
  765. }
  766. else if (portid == 3)
  767. {
  768. _lp = Modules[ModuleName.LP3] as LoadPortModule;
  769. }
  770. else if (portid == 4)
  771. {
  772. _lp = Modules[ModuleName.LP4] as LoadPortModule;
  773. }
  774. else
  775. {
  776. return false;
  777. }
  778. if (currrentStocker != null)
  779. {
  780. Dictionary<string, object> para = new Dictionary<string, object>();
  781. para.Add("WaferType", currrentStocker.CurrentCarrier.CarrierType.ToString());
  782. para.Add("CarrierPara", $"{currrentStocker.Name},{_lp.Name.ToString()}");
  783. para.Add("TransferType", "Unloading");
  784. bool result = CheckToPostJobMessage((int)MSG.CreateTransferJob, para);
  785. if (result)
  786. {
  787. (Singleton<EquipmentManager>.Instance.Modules[ModuleName.PM1] as PMModule).CarrierOutStart(currrentStocker.CurrentCarrier);
  788. }
  789. return result;
  790. }
  791. else
  792. {
  793. return false;
  794. }
  795. }
  796. }
  797. }