FaManager.cs 15 KB

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