FaManager.cs 15 KB

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