EquipmentManager_FA.cs 36 KB

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