FaManager.cs 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526
  1. using Aitex.Common.Util;
  2. using Aitex.Core.RT.DataCenter;
  3. using Aitex.Core.RT.Event;
  4. using Aitex.Core.RT.OperationCenter;
  5. using System.Collections.Generic;
  6. using Aitex.Core.Common.DeviceData;
  7. using Aitex.Core.RT.Device;
  8. using Aitex.Core.RT.SCCore;
  9. using Aitex.Core.Util;
  10. using Aitex.Sorter.Common;
  11. using MECF.Framework.Common.Equipment;
  12. //using Venus_RT.Device.YASKAWA;
  13. //using Venus_RT.Devices.EFEM;
  14. using Venus_RT.FAs;
  15. using Venus_RT.Modules;
  16. using Aitex.Core.RT.Log;
  17. namespace Venus_RT.HostWrapper
  18. {
  19. class FaManager : FaHost, IHostCallback
  20. {
  21. private const string PROCESS_START_INQUIRY = "PROCESS_START_INQUIRY";
  22. private class DataName
  23. {
  24. public const string CommunicationStatus = "CommunicationStatus";
  25. public const string ControlStatus = "ControlStatus";
  26. public const string ControlSubStatus = "ControlSubStatus";
  27. public const string SpoolingState = "SpoolingState";
  28. public const string SpoolingActual = "SpoolingActual";
  29. public const string SpoolingTotal = "SpoolingTotal";
  30. public const string SpoolingFullTime = "SpoolingFullTime";
  31. public const string SpoolingStartTime = "SpoolingStartTime";
  32. public const string IsSpoolingEnable = "IsSpoolingEnable";
  33. }
  34. private Dictionary<string, ModuleName> _dicPortModule = new Dictionary<string, ModuleName>()
  35. {
  36. {"1", ModuleName.LP1},
  37. {"2", ModuleName.LP2},
  38. };
  39. public void Initialize()
  40. {
  41. base.Initialize(this, PathManager.GetCfgDir() + "ClusterGemModel.xml");
  42. OP.Subscribe("System.FACommand", InvokeFaCommand);
  43. DATA.Subscribe("System.CommunicationStatus", () => FaCommunicationState);
  44. DATA.Subscribe("System.ControlStatus", () => FaControlState);
  45. DATA.Subscribe("System.ControlSubStatus", () => FaControlSubState);
  46. DATA.Subscribe("System.SpoolingState", () => SpoolingState);
  47. DATA.Subscribe("System.SpoolingActual", () => SpoolingActual);
  48. DATA.Subscribe("System.SpoolingTotal", () => SpoolingTotal);
  49. DATA.Subscribe("System.SpoolingFullTime", () => SpoolingFullTime);
  50. DATA.Subscribe("System.SpoolingStartTime", () => SpoolingStartTime);
  51. DATA.Subscribe("System.IsSpoolingEnable", () => IsSpoolingEnable);
  52. EV.Subscribe(new EventItem(PROCESS_START_INQUIRY));
  53. }
  54. private bool InvokeFaCommand(string arg1, object[] arg2)
  55. {
  56. LOG.Write(eEvent.INFO_FA, ModuleName.System, arg1 + ":" + arg2[0]);
  57. Invoke(arg2[0].ToString(), null);
  58. return true;
  59. }
  60. public string GetSvidValue(string svName)
  61. {
  62. switch (svName)
  63. {
  64. case "PMA.RecipeProcessTime":
  65. svName = "PMA.RecipeTotalElapsedSeconds";
  66. break;
  67. case "PMB.RecipeProcessTime":
  68. svName = "PMB.RecipeTotalElapsedSeconds";
  69. break;
  70. //case "PMC.RecipeProcessTime":
  71. // svName = "PMC.RecipeTotalElapsedSeconds";
  72. // break;
  73. //case "PMD.RecipeProcessTime":
  74. // svName = "PMD.RecipeTotalElapsedSeconds";
  75. // break;
  76. }
  77. //if (svName == "PMA.RecipeProcessTime")
  78. // svName = "PMA.RecipeTotalElapsedSeconds";
  79. //else if (svName == "PMB.RecipeProcessTime")
  80. // svName = "PMB.RecipeTotalElapsedSeconds";
  81. object data = DATA.Poll(svName);
  82. if (data != null)
  83. {
  84. return data.ToString();
  85. }
  86. return "";
  87. }
  88. public List<string> GetListSvidValue(string svName)
  89. {
  90. List<string> result = new List<string>();
  91. foreach (var VARIABLE in result)
  92. {
  93. }
  94. return result;
  95. }
  96. public bool MapCassette(string portId, out string reason)
  97. {
  98. if (!_dicPortModule.ContainsKey(portId))
  99. {
  100. reason = $"{portId} not valid";
  101. return false;
  102. }
  103. //var LPDevice = Singleton<RouteManager>.Instance.EFEM.EfemDevice[_dicPortModule[portId]] as Loadport;
  104. //if (LPDevice==null)
  105. //{
  106. // reason = $"{portId} not valid";
  107. // return false;
  108. //}
  109. //if (!LPDevice.HasCassette )
  110. //{
  111. // reason = $"{portId} cassette not placed";
  112. // return false;
  113. //}
  114. //if (LPDevice.Protrusion)
  115. //{
  116. // reason = $"{portId} cassette wafer protrude";
  117. // return false;
  118. //}
  119. //if (LPDevice.Status == DeviceState.Error)
  120. //{
  121. // reason = $"{portId} port in error, need reset";
  122. // return false;
  123. //}
  124. if (SC.ContainsItem("EFEM.CheckSideDoorOnEAPMap") && SC.GetValue<bool>("EFEM.CheckSideDoorOnEAPMap"))
  125. {
  126. //if (Singleton<RouteManager>.Instance.EFEM.EfemDevice.DoorSwitch != LidState.Close)
  127. {
  128. reason = $"EFEM side door not closed, can not map {portId}";
  129. return false;
  130. }
  131. }
  132. if (SC.ContainsItem("EFEM.CheckCassetteDoorOnEAPMap") &&
  133. SC.GetValue<bool>("EFEM.CheckCassetteDoorOnEAPMap"))
  134. {
  135. //if (Singleton<RouteManager>.Instance.EFEM.EfemDevice.CassetteDoor != LidState.Close)
  136. {
  137. reason = $"Cassette door not closed, can not map {portId}";
  138. return false;
  139. }
  140. }
  141. OP.DoOperation($"{_dicPortModule[portId]}.Map");
  142. reason = string.Empty;
  143. return true;
  144. }
  145. public bool PPSelect(string portId, string jobId, string lotId, string[] slotSequence, out string reason)
  146. {
  147. if (!_dicPortModule.ContainsKey(portId))
  148. {
  149. reason = $"{portId} not valid";
  150. return false;
  151. }
  152. //if (!Singleton<RouteManager>.Instance.IsAutoMode)
  153. //{
  154. // reason = $"System not in auto mode";
  155. // return false;
  156. //}
  157. Dictionary<string, object> param = new Dictionary<string, object>()
  158. {
  159. {"JobId", jobId},
  160. {"LotId", lotId},
  161. {"Module", _dicPortModule[portId].ToString()},
  162. {"SlotSequence", slotSequence},
  163. {"AutoStart", false},
  164. };
  165. OP.DoOperation("System.CreateJob", param);
  166. reason = string.Empty;
  167. return true;
  168. }
  169. public bool StartJob(string jobId, out string reason)
  170. {
  171. var param = new object[] { jobId };
  172. OP.DoOperation("System.StartJob", param);
  173. reason = string.Empty;
  174. return true;
  175. }
  176. public bool AbortJob(string jobId, out string reason)
  177. {
  178. var param = new object[] { jobId };
  179. OP.DoOperation("System.AbortJob", param);
  180. reason = string.Empty;
  181. return true;
  182. }
  183. public bool PauseJob(string jobId, out string reason)
  184. {
  185. var param = new object[] { jobId };
  186. OP.DoOperation("System.PauseJob", param);
  187. reason = string.Empty;
  188. return true;
  189. }
  190. public bool ResumeJob(string jobId, out string reason)
  191. {
  192. var param = new object[] { jobId };
  193. OP.DoOperation("System.ResumeJob", param);
  194. reason = string.Empty;
  195. return true;
  196. }
  197. public bool StopJob(string jobId, out string reason)
  198. {
  199. var param = new object[] { jobId };
  200. OP.DoOperation("System.StopJob", param);
  201. reason = string.Empty;
  202. return true;
  203. }
  204. public bool Load(string portId, out string reason)
  205. {
  206. if (!_dicPortModule.ContainsKey(portId))
  207. {
  208. reason = $"{portId} not valid";
  209. return false;
  210. }
  211. //var LPDevice = Singleton<RouteManager>.Instance.EFEM.EfemDevice[_dicPortModule[portId]] as Loadport;
  212. //if (LPDevice == null)
  213. //{
  214. // reason = $"{portId} not valid";
  215. // return false;
  216. //}
  217. //if (!LPDevice.HasCassette)
  218. //{
  219. // reason = $"{portId} cassette not placed";
  220. // return false;
  221. //}
  222. //if (LPDevice.Status == DeviceState.Error)
  223. //{
  224. // reason = $"{portId} port in error, need reset";
  225. // return false;
  226. //}
  227. OP.DoOperation($"{_dicPortModule[portId]}.Load");
  228. reason = string.Empty;
  229. return true;
  230. }
  231. public bool Unload(string portId, out string reason)
  232. {
  233. if (!_dicPortModule.ContainsKey(portId))
  234. {
  235. reason = $"{portId} not valid";
  236. return false;
  237. }
  238. //var LPDevice = Singleton<RouteManager>.Instance.EFEM.EfemDevice[_dicPortModule[portId]] as Loadport;
  239. //if (LPDevice == null)
  240. //{
  241. // reason = $"{portId} not valid";
  242. // return false;
  243. //}
  244. //if (!LPDevice.HasCassette)
  245. //{
  246. // reason = $"{portId} cassette not placed";
  247. // return false;
  248. //}
  249. //if (LPDevice.Status == DeviceState.Error)
  250. //{
  251. // reason = $"{portId} port in error, need reset";
  252. // return false;
  253. //}
  254. //if (SC.GetValue<bool>("EFEM.AutoUnlockAfterUnload") )
  255. //{
  256. // OP.DoOperation($"{_dicPortModule[portId]}.Unload");
  257. //}
  258. //else
  259. //{
  260. // OP.DoOperation($"{_dicPortModule[portId]}.Undock");
  261. //}
  262. reason = string.Empty;
  263. return true;
  264. }
  265. public bool Lock(string portId, out string reason)
  266. {
  267. if (!_dicPortModule.ContainsKey(portId))
  268. {
  269. reason = $"{portId} not valid";
  270. return false;
  271. }
  272. //var LPDevice = Singleton<RouteManager>.Instance.EFEM.EfemDevice[_dicPortModule[portId]] as Loadport;
  273. //if (LPDevice == null)
  274. //{
  275. // reason = $"{portId} not valid";
  276. // return false;
  277. //}
  278. //if (!LPDevice.HasCassette)
  279. //{
  280. // reason = $"{portId} cassette not placed";
  281. // return false;
  282. //}
  283. //if (LPDevice.Status == DeviceState.Error)
  284. //{
  285. // reason = $"{portId} port in error, need reset";
  286. // return false;
  287. //}
  288. OP.DoOperation($"{_dicPortModule[portId]}.Clamp");
  289. reason = string.Empty;
  290. return true;
  291. }
  292. public bool Unlock(string portId, out string reason)
  293. {
  294. if (!_dicPortModule.ContainsKey(portId))
  295. {
  296. reason = $"{portId} not valid";
  297. return false;
  298. }
  299. //var LPDevice = Singleton<RouteManager>.Instance.EFEM.EfemDevice[_dicPortModule[portId]] as Loadport;
  300. //if (LPDevice == null)
  301. //{
  302. // reason = $"{portId} not valid";
  303. // return false;
  304. //}
  305. //if (!LPDevice.HasCassette)
  306. //{
  307. // reason = $"{portId} cassette not placed";
  308. // return false;
  309. //}
  310. //if (LPDevice.Status == DeviceState.Error)
  311. //{
  312. // reason = $"{portId} port in error, need reset";
  313. // return false;
  314. //}
  315. OP.DoOperation($"{_dicPortModule[portId]}.Unclamp");
  316. reason = string.Empty;
  317. return true;
  318. }
  319. public bool ReadID(string portId, out string reason)
  320. {
  321. if (!_dicPortModule.ContainsKey(portId))
  322. {
  323. reason = $"{portId} not valid";
  324. return false;
  325. }
  326. //var LPDevice = Singleton<RouteManager>.Instance.EFEM.EfemDevice[_dicPortModule[portId]] as Loadport;
  327. //if (LPDevice == null)
  328. //{
  329. // reason = $"{portId} not valid";
  330. // return false;
  331. //}
  332. //if (!LPDevice.HasCassette)
  333. //{
  334. // reason = $"{portId} cassette not placed";
  335. // return false;
  336. //}
  337. //if (LPDevice.Status == DeviceState.Error)
  338. //{
  339. // reason = $"{portId} port in error, need reset";
  340. // return false;
  341. //}
  342. OP.DoOperation($"{_dicPortModule[portId]}.ReadCarrierId");
  343. reason = string.Empty;
  344. return true;
  345. }
  346. public bool ReadTag(string portId, out string reason)
  347. {
  348. if (!_dicPortModule.ContainsKey(portId))
  349. {
  350. reason = $"{portId} not valid";
  351. return false;
  352. }
  353. //var LPDevice = Singleton<RouteManager>.Instance.EFEM.EfemDevice[_dicPortModule[portId]] as Loadport;
  354. //if (LPDevice == null)
  355. //{
  356. // reason = $"{portId} not valid";
  357. // return false;
  358. //}
  359. //if (!LPDevice.HasCassette)
  360. //{
  361. // reason = $"{portId} cassette not placed";
  362. // return false;
  363. //}
  364. //if (LPDevice.Status == DeviceState.Error)
  365. //{
  366. // reason = $"{portId} port in error, need reset";
  367. // return false;
  368. //}
  369. OP.DoOperation($"{_dicPortModule[portId]}.ReadTagData");
  370. reason = string.Empty;
  371. return true;
  372. }
  373. public bool WriteID(string portId, string carrierID, out string reason)
  374. {
  375. if (!_dicPortModule.ContainsKey(portId))
  376. {
  377. reason = $"{portId} not valid";
  378. return false;
  379. }
  380. //var LPDevice = Singleton<RouteManager>.Instance.EFEM.EfemDevice[_dicPortModule[portId]] as Loadport;
  381. //if (LPDevice == null)
  382. //{
  383. // reason = $"{portId} not valid";
  384. // return false;
  385. //}
  386. //if (!LPDevice.HasCassette)
  387. //{
  388. // reason = $"{portId} cassette not placed";
  389. // return false;
  390. //}
  391. //if (LPDevice.Status == DeviceState.Error)
  392. //{
  393. // reason = $"{portId} port in error, need reset";
  394. // return false;
  395. //}
  396. OP.DoOperation($"{_dicPortModule[portId]}.WriteCarrierID", carrierID);
  397. reason = string.Empty;
  398. return true;
  399. }
  400. public bool WriteTag(string portId, string tagData, out string reason)
  401. {
  402. if (!_dicPortModule.ContainsKey(portId))
  403. {
  404. reason = $"{portId} not valid";
  405. return false;
  406. }
  407. //var LPDevice = Singleton<RouteManager>.Instance.EFEM.EfemDevice[_dicPortModule[portId]] as Loadport;
  408. //if (LPDevice == null)
  409. //{
  410. // reason = $"{portId} not valid";
  411. // return false;
  412. //}
  413. //if (!LPDevice.HasCassette)
  414. //{
  415. // reason = $"{portId} cassette not placed";
  416. // return false;
  417. //}
  418. //if (LPDevice.Status == DeviceState.Error)
  419. //{
  420. // reason = $"{portId} port in error, need reset";
  421. // return false;
  422. //}
  423. OP.DoOperation($"{_dicPortModule[portId]}.WriteTagData", tagData);
  424. reason = string.Empty;
  425. return true;
  426. }
  427. }
  428. }