FaManager.cs 16 KB

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