LoadPort.cs 51 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467
  1. using Aitex.Core.RT.Device;
  2. using System;
  3. using System.Collections.Generic;
  4. using System.Linq;
  5. using System.Net.Configuration;
  6. using System.Text;
  7. using System.Text.RegularExpressions;
  8. using System.Threading.Tasks;
  9. using Aitex.Core.Common;
  10. using Aitex.Core.RT.DataCenter;
  11. using Aitex.Core.RT.Event;
  12. using Aitex.Core.RT.OperationCenter;
  13. using Aitex.Core.RT.SCCore;
  14. using Aitex.Core.Util;
  15. using Aitex.Sorter.Common;
  16. using MECF.Framework.Common.Equipment;
  17. using MECF.Framework.RT.Core.Equipments;
  18. using MECF.Framework.Common.SubstrateTrackings;
  19. using MECF.Framework.RT.EquipmentLibrary.HardwareUnits.LoadPorts.TDK;
  20. namespace MECF.Framework.RT.EquipmentLibrary.HardwareUnits.LoadPorts
  21. {
  22. public enum IndicatorType
  23. {
  24. Load,
  25. Unload,
  26. Presence,
  27. Placement,
  28. Alarm,
  29. Access,
  30. Status1,
  31. Status2,
  32. }
  33. public interface IE87CallBack
  34. {
  35. void CarrierArrive();
  36. void CarrerRemove(string carrierID);
  37. void CarrierIDReadSuccess(string carrierID);
  38. void CarrierIDReadFail();
  39. void MappingComplete(string carrierID, string slotmap);
  40. void LoadStart();
  41. void LoadportError(string errorcode);
  42. void LoadComplete();
  43. void UnLoadStart();
  44. void UnloadComplete();
  45. void OnLPHomed();
  46. void OnE84HandoffStart(bool isload);
  47. void OnE84HandoffComplete(bool isload);
  48. }
  49. public abstract class LoadPort : BaseDevice, IDevice
  50. {
  51. public IndicatorState IndicatiorLoad { get; set; }
  52. public IndicatorState IndicatiorUnload { get; set; }
  53. public IndicatorState IndicatiorPresence { get; set; }
  54. public IndicatorState IndicatorAlarm { get; set; }
  55. public IndicatorState IndicatiorPlacement { get; set; }
  56. public IndicatorState IndicatiorOpAccess { get; set; }
  57. public IndicatorState IndicatiorStatus1 { get; set; }
  58. public IndicatorState IndicatiorStatus2 { get; set; }
  59. public virtual FoupClampState ClampState { get; set; }
  60. public virtual FoupDoorState DoorState { get; set; }
  61. public virtual CasstleType CasstleType { get; set; }
  62. public string SlotMap
  63. {
  64. get { return GetSlotMap(); }
  65. }
  66. public virtual bool IsBusy { get; set; }
  67. public virtual bool IsIdle { get; set; }
  68. public virtual bool IsMoving { get; set; }
  69. public virtual LoadportCassetteState CassetteState
  70. {
  71. get;
  72. set;
  73. }
  74. public bool IsMapWaferByLoadPort { get; set; }
  75. public EnumLoadPortType PortType { get; set; }
  76. public bool Initalized { get; set; }
  77. public bool IsPresent
  78. {
  79. get { return _isPresent; }
  80. }
  81. public bool IsPlacement
  82. {
  83. get { return _isPlaced; }
  84. }
  85. public bool IsMapped
  86. {
  87. get { return _isMapped; }
  88. }
  89. public bool Error { get; set; }
  90. public string ErrorCode { get; set; }
  91. /// <summary>
  92. /// 是否处于FOSB模式
  93. /// </summary>
  94. public bool IsFOSBMode { get; set; }
  95. public DeviceState State
  96. {
  97. get
  98. {
  99. if (!Initalized)
  100. {
  101. return DeviceState.Unknown;
  102. }
  103. if (Error)
  104. {
  105. return DeviceState.Error;
  106. }
  107. if (IsBusy)
  108. return DeviceState.Busy;
  109. return DeviceState.Idle;
  110. }
  111. }
  112. public string CarrierId
  113. {
  114. get { return _carrierId; }
  115. }
  116. public string RfId
  117. {
  118. get { return _rfid; }
  119. }
  120. protected bool _isPresent;
  121. protected bool _isPlaced;
  122. protected string _carrierId;
  123. protected string _rfid;
  124. protected bool _isMapped;
  125. private ModuleName _module;
  126. private ModuleStateEnum _state;
  127. private List<List<string>> _waferId = new List<List<string>>();
  128. private static bool _isIndependentCEID = SC.ContainsItem("Fa.IndependentCEIDForLp")?SC.GetValue<bool>("Fa.IndependentCEIDForLp"):false;
  129. public string PortId
  130. {
  131. get { return (_lpIndex+1).ToString(); }
  132. }
  133. public string PortCategory
  134. {
  135. get
  136. {
  137. if (SC.GetConfigItem(PortLabelScNames[_lpIndex]) == null)
  138. return "";
  139. return SC.GetStringValue(PortLabelScNames[_lpIndex]) ;
  140. }
  141. }
  142. string[] PortStateVariableNames = new[]
  143. {
  144. "CARRIER_PORT1_STATE", "CARRIER_PORT2_STATE", "CARRIER_PORT3_STATE",
  145. "CARRIER_PORT4_STATE", "CARRIER_PORT5_STATE", "CARRIER_PORT6_STATE", "CARRIER_PORT7_STATE",
  146. "CARRIER_PORT8_STATE", "CARRIER_PORT9_STATE", "CARRIER_PORT10_STATE"
  147. };
  148. ModuleName[] PortModuleNames = new[]
  149. {
  150. ModuleName.LP1,ModuleName.LP2,ModuleName.LP3,ModuleName.LP4,ModuleName.LP5,
  151. ModuleName.LP6,ModuleName.LP7,ModuleName.LP8,ModuleName.LP9,ModuleName.LP10,
  152. };
  153. string[] PortSlotMapVariableNames = new[]
  154. {
  155. "CARRIER_PORT1_CURRENT_SLOTMAP", "CARRIER_PORT2_CURRENT_SLOTMAP", "CARRIER_PORT3_CURRENT_SLOTMAP",
  156. "CARRIER_PORT4_CURRENT_SLOTMAP", "CARRIER_PORT5_CURRENT_SLOTMAP", "CARRIER_PORT6_CURRENT_SLOTMAP", "CARRIER_PORT7_CURRENT_SLOTMAP",
  157. "CARRIER_PORT8_CURRENT_SLOTMAP", "CARRIER_PORT9_CURRENT_SLOTMAP", "CARRIER_PORT10_CURRENT_SLOTMAP"
  158. };
  159. string[] PortWaferIdVariableNames = new[]
  160. {
  161. "CARRIER_PORT1_CURRENT_WAFERID", "CARRIER_PORT2_CURRENT_WAFERID", "CARRIER_PORT3_CURRENT_WAFERID",
  162. "CARRIER_PORT4_CURRENT_WAFERID", "CARRIER_PORT5_CURRENT_WAFERID", "CARRIER_PORT6_CURRENT_WAFERID", "CARRIER_PORT7_CURRENT_WAFERID",
  163. "CARRIER_PORT8_CURRENT_WAFERID", "CARRIER_PORT9_CURRENT_WAFERID", "CARRIER_PORT10_CURRENT_WAFERID"
  164. };
  165. private string[] PortLabelScNames = new[]
  166. {
  167. "LoadPort.LoadPort1CarrierLabel","LoadPort.LoadPort2CarrierLabel","LoadPort.LoadPort3CarrierLabel","LoadPort.LoadPort4CarrierLabel",
  168. "LoadPort.LoadPort5CarrierLabel","LoadPort.LoadPort6CarrierLabel","LoadPort.LoadPort7CarrierLabel","LoadPort.LoadPort8CarrierLabel",
  169. "LoadPort.LoadPort9CarrierLabel","LoadPort.LoadPort10CarrierLabel",
  170. };
  171. private int _lpIndex = -1;
  172. private string EventCarrierArrived= "CARRIER_ARRIVED";
  173. private string EventCarrierIdRead= "CARRIER_ID_READ";
  174. private string EventCarrierIdReadFailed = "CARRIER_ID_READ_FAILED";
  175. private string EventCarrierIdWrite = "CARRIER_ID_WRITE";
  176. private string EventCarrierIdWriteFailed = "CARRIER_ID_WRITE_FAILED";
  177. private string EventSlotMapAvailable= "SLOT_MAP_AVAILABLE";
  178. private string EventCarrierRemoved = "CARRIER_REMOVED";
  179. private string EventCarrierUnloaded = "CARRIER_UNLOADED";
  180. private string EventCarrierloaded = "CARRIR_DOCK_COMPLETE";
  181. private string PORT_ID = "PORT_ID";
  182. private string CAR_ID = "CAR_ID";
  183. private string SLOT_MAP = "SLOT_MAP";
  184. private string PORT_CTGRY = "PORT_CTGRY";
  185. private string RF_ID = "RF_ID";
  186. private string EventRfIdRead = "RF_ID_READ";
  187. private string EventRfIdReadFailed = "RF_ID_READ_FAILED";
  188. private string EventRfIdWrite = "RF_ID_WRITE";
  189. #pragma warning disable 414
  190. private string EventRfIdWriteFailed = "RF_ID_WRITE_FAILED";
  191. #pragma warning restore 414
  192. private string AlarmCarrierPortError = "CarrierPortError";
  193. public LoadPort(string module, string name):base(module, name, name, "")
  194. {
  195. for (int i = 0; i < 25; i++)
  196. {
  197. _waferId.Add(new List<string>()
  198. {
  199. i.ToString("D2"),"","",""
  200. });
  201. }
  202. if (!Enum.TryParse(name, out ModuleName m))
  203. Enum.TryParse(module, out m);
  204. _module = m;
  205. _lpIndex = Array.IndexOf(PortModuleNames, _module);
  206. DoorState = FoupDoorState.Unknown;
  207. System.Diagnostics.Trace.Assert(_lpIndex != -1);
  208. }
  209. public virtual bool Initialize()
  210. {
  211. WaferManager.Instance.SubscribeLocation(_module, 25);
  212. CarrierManager.Instance.SubscribeLocation(_module.ToString());
  213. DATA.Subscribe(Name, "IsPresent", ()=>_isPresent);
  214. DATA.Subscribe(Name, "IsPlaced", () => _isPlaced);
  215. DATA.Subscribe(Name, "ModuleState", () => _state.ToString());
  216. DATA.Subscribe(Name, "CarrierId", () => _carrierId);
  217. DATA.Subscribe(Name, "IsMapped", () => _isMapped);
  218. DATA.Subscribe($"{Name}.LoadportState", () => State);
  219. DATA.Subscribe($"{Name}.LoadportBusy", () => IsBusy);
  220. DATA.Subscribe($"{Name}.LoadportError", () => ErrorCode);
  221. DATA.Subscribe($"{Name}.CassetteState", () => CassetteState);
  222. DATA.Subscribe($"{Name}.FoupClampState", () => ClampState);
  223. DATA.Subscribe($"{Name}.FoupDoorState", () => DoorState);
  224. DATA.Subscribe($"{Name}.SlotMap", () => SlotMap);
  225. DATA.Subscribe($"{Name}.IndicatiorLoad", () => IndicatiorLoad);
  226. DATA.Subscribe($"{Name}.IndicatiorUnload", () => IndicatiorUnload);
  227. DATA.Subscribe($"{Name}.IndicatiorPresence", () => IndicatiorPresence);
  228. DATA.Subscribe($"{Name}.IndicatiorPlacement", () => IndicatiorPlacement);
  229. DATA.Subscribe($"{Name}.IndicatiorAlarm", () => IndicatorAlarm);
  230. DATA.Subscribe($"{Name}.IndicatiorOpAccess", () => IndicatiorOpAccess);
  231. DATA.Subscribe($"{Name}.IndicatiorStatus1", () => IndicatiorStatus1);
  232. DATA.Subscribe($"{Name}.IndicatiorStatus2", () => IndicatiorStatus2);
  233. DATA.Subscribe($"{Name}.CasstleType", () => CasstleType);
  234. DATA.Subscribe(PortStateVariableNames[_lpIndex], () => (_isPlaced && _isPresent) ? "1" : "0");
  235. DATA.Subscribe(PortSlotMapVariableNames[_lpIndex], () => SlotMap);
  236. DATA.Subscribe(PortWaferIdVariableNames[_lpIndex], UpdatedWaferIdList);
  237. if (_isIndependentCEID)
  238. {
  239. EV.Subscribe(new EventItem("Event", $"{_module}_{EventCarrierArrived}", "Carrier arrived"));
  240. EV.Subscribe(new EventItem("Event", $"{_module}_{EventCarrierRemoved}", "Carrier removed"));
  241. EV.Subscribe(new EventItem("Event", $"{_module}_{EventCarrierIdRead}", "Carrier ID read"));
  242. EV.Subscribe(new EventItem("Event", $"{_module}_{EventCarrierIdReadFailed}", "Carrier ID read failed"));
  243. EV.Subscribe(new EventItem("Event", $"{_module}_CAR_ID_WRITE_SUCCESSFULLY", "Carrier ID write"));
  244. EV.Subscribe(new EventItem("Event", $"{_module}_CAR_ID_WRITE_FAIL", "Carrier ID write failed"));
  245. EV.Subscribe(new EventItem("Event", $"{_module}_{EventSlotMapAvailable}", "Slot map available"));
  246. EV.Subscribe(new EventItem("Event", $"{_module}_{EventCarrierUnloaded}", "Carrier unloaded"));
  247. EV.Subscribe(new EventItem("Event", $"{_module}_CARRIR_LOAD_COMPLETE", "Carrier loaded"));
  248. EV.Subscribe(new EventItem("Event", $"{_module}_{EventRfIdRead}", "Carrier RFID read"));
  249. EV.Subscribe(new EventItem("Event", $"{_module}_{EventRfIdReadFailed}", "Carrier RFID read failed"));
  250. EV.Subscribe(new EventItem("Event", $"{_module}_{EventRfIdWrite}", "Carrier RFID write"));
  251. EV.Subscribe(new EventItem("Event", $"{_module}_{AlarmCarrierPortError}", "Carrier Port error", EventLevel.Alarm, EventType.HostNotification));
  252. }
  253. else
  254. {
  255. EV.Subscribe(new EventItem("Event", EventCarrierArrived, "Carrier arrived"));
  256. EV.Subscribe(new EventItem("Event", EventCarrierRemoved, "Carrier removed"));
  257. EV.Subscribe(new EventItem("Event", EventCarrierIdRead, "Carrier ID read"));
  258. EV.Subscribe(new EventItem("Event", EventCarrierIdReadFailed, "Carrier ID read failed"));
  259. EV.Subscribe(new EventItem("Event", EventCarrierIdWrite, "Carrier ID write"));
  260. EV.Subscribe(new EventItem("Event", EventCarrierIdWriteFailed, "Carrier ID write failed"));
  261. EV.Subscribe(new EventItem("Event", EventSlotMapAvailable, "Slot map available"));
  262. EV.Subscribe(new EventItem("Event", EventCarrierUnloaded, "Carrier unloaded"));
  263. EV.Subscribe(new EventItem("Event", EventCarrierloaded, "Carrier loaded"));
  264. EV.Subscribe(new EventItem("Event", EventRfIdRead, "Carrier RFID read"));
  265. EV.Subscribe(new EventItem("Event", EventRfIdReadFailed, "Carrier RFID read failed"));
  266. EV.Subscribe(new EventItem("Event", EventRfIdWrite, "Carrier RFID write"));
  267. EV.Subscribe(new EventItem("Event", AlarmCarrierPortError, "Carrier Port error", EventLevel.Alarm, EventType.HostNotification));
  268. }
  269. IsIdle = true;
  270. _state = ModuleStateEnum.Idle;
  271. RegisterOperation();
  272. return true;
  273. }
  274. public virtual bool Connect()
  275. {
  276. return true;
  277. }
  278. private void RegisterOperation()
  279. {
  280. OP.Subscribe($"{Name}.LoadportHome", (string cmd, object[] param) =>
  281. {
  282. if (!Home(out string reason))
  283. {
  284. EV.PostWarningLog(Module, $"{Name} can not start home, {reason}");
  285. return false;
  286. }
  287. EV.PostInfoLog(Module, $"{Name} start home");
  288. return true;
  289. });
  290. OP.Subscribe($"{Name}.LoadportReset", (string cmd, object[] param) =>
  291. {
  292. if (!ClearError(out string reason))
  293. {
  294. EV.PostWarningLog(Module, $"{Name} can not reset, {reason}");
  295. return false;
  296. }
  297. EV.PostInfoLog(Module, $"{Name} start reset");
  298. return true;
  299. });
  300. OP.Subscribe($"{Name}.LoadportStop", (string cmd, object[] param) =>
  301. {
  302. if (!Stop(out string reason))
  303. {
  304. EV.PostWarningLog(Module, $"{Name} can not stop, {reason}");
  305. return false;
  306. }
  307. EV.PostInfoLog(Module, $"{Name} stop");
  308. return true;
  309. });
  310. OP.Subscribe($"{Name}.LoadportLoad", (string cmd, object[] param) =>
  311. {
  312. if (!Load(out string reason))
  313. {
  314. EV.PostWarningLog(Module, $"{Name} can not load, {reason}");
  315. return false;
  316. }
  317. EV.PostInfoLog(Module, $"{Name} start load");
  318. return true;
  319. });
  320. OP.Subscribe($"{Name}.LoadportLoadWithoutMap", (string cmd, object[] param) =>
  321. {
  322. if (!LoadWithoutMap(out string reason))
  323. {
  324. EV.PostWarningLog(Module, $"{Name} can not load without map, {reason}");
  325. return false;
  326. }
  327. EV.PostInfoLog(Module, $"{Name} start load without map");
  328. return true;
  329. });
  330. OP.Subscribe($"{Name}.LoadportLoadWithMap", (string cmd, object[] param) =>
  331. {
  332. if (!Load(out string reason))
  333. {
  334. EV.PostWarningLog(Module, $"{Name} can not load with map, {reason}");
  335. return false;
  336. }
  337. if (!QueryWaferMap(out reason))
  338. {
  339. EV.PostWarningLog(Module, $"{Name} can not map, {reason}");
  340. return false;
  341. }
  342. EV.PostInfoLog(Module, $"{Name} start load with map");
  343. return true;
  344. });
  345. OP.Subscribe($"{Name}.LoadportUnload", (string cmd, object[] param) =>
  346. {
  347. if (!Unload(out string reason))
  348. {
  349. EV.PostWarningLog(Module, $"{Name} can not unload, {reason}");
  350. return false;
  351. }
  352. EV.PostInfoLog(Module, $"{Name} start unload");
  353. return true;
  354. });
  355. OP.Subscribe($"{Name}.LoadportClamp", (string cmd, object[] param) =>
  356. {
  357. if (!Clamp(out string reason))
  358. {
  359. EV.PostWarningLog(Module, $"{Name} can not clamp, {reason}");
  360. return false;
  361. }
  362. EV.PostInfoLog(Module, $"{Name} start clamp");
  363. return true;
  364. });
  365. OP.Subscribe($"{Name}.LoadportUnclamp", (string cmd, object[] param) =>
  366. {
  367. if (!Unclamp(out string reason))
  368. {
  369. EV.PostWarningLog(Module, $"{Name} can not unclamp, {reason}");
  370. return false;
  371. }
  372. EV.PostInfoLog(Module, $"{Name} start unclamp");
  373. return true;
  374. });
  375. OP.Subscribe($"{Name}.LoadportOpenDoor", (string cmd, object[] param) =>
  376. {
  377. if (!OpenDoor(out string reason))
  378. {
  379. EV.PostWarningLog(Module, $"{Name} can not open door, {reason}");
  380. return false;
  381. }
  382. EV.PostInfoLog(Module, $"{Name} start open door");
  383. return true;
  384. });
  385. OP.Subscribe($"{Name}.LoadportOpenDoorNoMap", (string cmd, object[] param) =>
  386. {
  387. if (!OpenDoorNoMap(out string reason))
  388. {
  389. EV.PostWarningLog(Module, $"{Name} can not open door, {reason}");
  390. return false;
  391. }
  392. EV.PostInfoLog(Module, $"{Name} start open door");
  393. return true;
  394. });
  395. OP.Subscribe($"{Name}.LoadportCloseDoor", (string cmd, object[] param) =>
  396. {
  397. if (!CloseDoor(out string reason))
  398. {
  399. EV.PostWarningLog(Module, $"{Name} can not close door, {reason}");
  400. return false;
  401. }
  402. EV.PostInfoLog(Module, $"{Name} start close door");
  403. return true;
  404. });
  405. OP.Subscribe($"{Name}.LoadportDock", (string cmd, object[] param) =>
  406. {
  407. if (!Dock(out string reason))
  408. {
  409. EV.PostWarningLog(Module, $"{Name} can not dock, {reason}");
  410. return false;
  411. }
  412. EV.PostInfoLog(Module, $"{Name} start dock");
  413. return true;
  414. });
  415. OP.Subscribe($"{Name}.LoadportUndock", (string cmd, object[] param) =>
  416. {
  417. if (!Undock(out string reason))
  418. {
  419. EV.PostWarningLog(Module, $"{Name} can not undock, {reason}");
  420. return false;
  421. }
  422. EV.PostInfoLog(Module, $"{Name} start undock");
  423. return true;
  424. });
  425. OP.Subscribe($"{Name}.LoadportQueryState", (string cmd, object[] param) =>
  426. {
  427. if (!QueryState(out string reason))
  428. {
  429. EV.PostWarningLog(Module, $"{Name} can not query state, {reason}");
  430. return false;
  431. }
  432. EV.PostInfoLog(Module, $"{Name} start query state");
  433. return true;
  434. });
  435. OP.Subscribe($"{Name}.LoadportQueryLED", (string cmd, object[] param) =>
  436. {
  437. if (!QueryIndicator(out string reason))
  438. {
  439. EV.PostWarningLog(Module, $"{Name} can not query led state, {reason}");
  440. return false;
  441. }
  442. EV.PostInfoLog(Module, $"{Name} start query led state");
  443. return true;
  444. });
  445. OP.Subscribe($"{Name}.LoadportSetLED", (string cmd, object[] param) =>
  446. {
  447. int light = (int) param[0];
  448. int state = (int) param[1];
  449. if (!SetIndicator((Indicator) light, (IndicatorState) state, out string reason))
  450. {
  451. EV.PostWarningLog(Module, $"{Name} can not set led state, {reason}");
  452. return true;
  453. }
  454. EV.PostInfoLog(Module, $"{Name} start set led state");
  455. return true;
  456. });
  457. OP.Subscribe($"{Name}.LoadportMap", (string cmd, object[] param) =>
  458. {
  459. if (!QueryWaferMap(out string reason))
  460. {
  461. EV.PostWarningLog(Module, $"{Name} can not map, {reason}");
  462. return false;
  463. }
  464. EV.PostInfoLog(Module, $"{Name} start map");
  465. return true;
  466. });
  467. OP.Subscribe($"{Name}.SetCassetteType", (string cmd, object[] param) =>
  468. {
  469. if (!SetCassetteType(param,out string reason))
  470. {
  471. EV.PostWarningLog(Module, $"{Name} can not set type, {reason}");
  472. return false;
  473. }
  474. EV.PostInfoLog(Module, $"{Name} cassette type have set to {CasstleType}");
  475. return true;
  476. });
  477. OP.Subscribe($"{Name}.LoadportForceHome", (string cmd, object[] param) =>
  478. {
  479. if (!ForceHome(out string reason))
  480. {
  481. EV.PostWarningLog(Module, $"{Name} can not start force home, {reason}");
  482. return false;
  483. }
  484. EV.PostInfoLog(Module, $"{Name} start force home");
  485. return true;
  486. });
  487. OP.Subscribe($"{Name}.LoadportFOSBMode", (string cmd, object[] param) =>
  488. {
  489. if (!FOSBMode(out string reason))
  490. {
  491. EV.PostWarningLog(Module, $"{Name} can not change to FOSB mode, {reason}");
  492. return false;
  493. }
  494. IsFOSBMode = true;
  495. EV.PostInfoLog(Module, $"{Name} changed to FOSB mode");
  496. return true;
  497. });
  498. OP.Subscribe($"{Name}.LoadportFOUPMode", (string cmd, object[] param) =>
  499. {
  500. if (!FOUPMode(out string reason))
  501. {
  502. EV.PostWarningLog(Module, $"{Name} can not change to FOSB mode, {reason}");
  503. return false;
  504. }
  505. IsFOSBMode = true;
  506. EV.PostInfoLog(Module, $"{Name} changed to FOSB mode");
  507. return true;
  508. });
  509. OP.Subscribe($"{Name}.LoadportQueryFOSBMode", (string cmd, object[] param) =>
  510. {
  511. if (!QueryFOSBMode(out string reason))
  512. {
  513. EV.PostWarningLog(Module, $"{Name} can not change to FOUP mode, {reason}");
  514. return false;
  515. }
  516. IsFOSBMode = false;
  517. EV.PostInfoLog(Module, $"{Name} changed to FOSB mode");
  518. return true;
  519. });
  520. }
  521. private bool SetCassetteType(object[] param,out string reason)
  522. {
  523. reason = "";
  524. if (param.Length != 1)
  525. {
  526. reason = "Invalid setting parameter.";
  527. return false;
  528. }
  529. CasstleType = (CasstleType)int.Parse(param[0].ToString());
  530. return true;
  531. }
  532. public virtual bool Load(out string reason)
  533. {
  534. reason = "";
  535. return true;
  536. }
  537. public virtual bool LoadWithoutMap(out string reason)
  538. {
  539. reason = "";
  540. return true;
  541. }
  542. public virtual bool QueryWaferMap(out string reason)
  543. {
  544. reason = "";
  545. return true;
  546. }
  547. public virtual bool QueryFOSBMode(out string reason)
  548. {
  549. reason = "";
  550. return true;
  551. }
  552. /// <summary>
  553. /// FOSB模式下的Dock指令
  554. /// </summary>
  555. /// <param name="reason"></param>
  556. /// <returns></returns>
  557. public virtual bool FOSBDock(out string reason)
  558. {
  559. reason = "";
  560. return true;
  561. }
  562. /// <summary>
  563. /// FOSB模式下的FOSBUnDock指令
  564. /// </summary>
  565. /// <param name="reason"></param>
  566. /// <returns></returns>
  567. public virtual bool FOSBUnDock(out string reason)
  568. {
  569. reason = "";
  570. return true;
  571. }
  572. /// <summary>
  573. /// FOSB模式下的开门指令
  574. /// </summary>
  575. /// <param name="reason"></param>
  576. /// <returns></returns>
  577. public virtual bool FOSBDoorOpen(out string reason)
  578. {
  579. reason = "";
  580. return true;
  581. }
  582. /// <summary>
  583. /// FOSB模式下的关门指令
  584. /// </summary>
  585. /// <param name="reason"></param>
  586. /// <returns></returns>
  587. public virtual bool FOSBDoorClose(out string reason)
  588. {
  589. reason = "";
  590. return true;
  591. }
  592. /// <summary>
  593. /// FOSB模式下的门下移指令
  594. /// </summary>
  595. /// <param name="reason"></param>
  596. /// <returns></returns>
  597. public virtual bool FOSBDoorDown(out string reason)
  598. {
  599. reason = "";
  600. return true;
  601. }
  602. /// <summary>
  603. /// FOSB模式下的门上移指令
  604. /// </summary>
  605. /// <param name="reason"></param>
  606. /// <returns></returns>
  607. public virtual bool FOSBDoorUp(out string reason)
  608. {
  609. reason = "";
  610. return true;
  611. }
  612. public bool SetIndicator(IndicatorType light, IndicatorState state)
  613. {
  614. switch (light)
  615. {
  616. case IndicatorType.Load:
  617. SetIndicator(Indicator.LOAD, state, out string _);
  618. break;
  619. case IndicatorType.Unload:
  620. SetIndicator(Indicator.UNLOAD, state, out string _);
  621. break;
  622. case IndicatorType.Access:
  623. SetIndicator(Indicator.OPACCESS, state, out string _);
  624. break;
  625. case IndicatorType.Alarm:
  626. SetIndicator(Indicator.ALARM, state, out string _);
  627. break;
  628. case IndicatorType.Presence:
  629. SetIndicator(Indicator.PRESENCE, state, out string _);
  630. break;
  631. case IndicatorType.Placement:
  632. SetIndicator(Indicator.PLACEMENT, state, out string _);
  633. break;
  634. case IndicatorType.Status1:
  635. SetIndicator(Indicator.STATUS1, state, out string _);
  636. break;
  637. case IndicatorType.Status2:
  638. SetIndicator(Indicator.STATUS2, state, out string _);
  639. break;
  640. default:
  641. EV.PostWarningLog(Module, $"Not supported indicator {light}");
  642. return false;
  643. }
  644. return true;
  645. }
  646. public virtual bool SetIndicator(Indicator light, IndicatorState state, out string reason)
  647. {
  648. reason = "";
  649. return true;
  650. }
  651. public virtual bool QueryIndicator(out string reason)
  652. {
  653. reason = "";
  654. return true;
  655. }
  656. public virtual bool QueryState(out string reason)
  657. {
  658. reason = "";
  659. return true;
  660. }
  661. public virtual bool Undock(out string reason)
  662. {
  663. reason = "";
  664. return true;
  665. }
  666. public virtual bool Dock(out string reason)
  667. {
  668. reason = "";
  669. return true;
  670. }
  671. public virtual bool CloseDoor(out string reason)
  672. {
  673. reason = "";
  674. return true;
  675. }
  676. public virtual bool OpenDoor(out string reason)
  677. {
  678. reason = "";
  679. return true;
  680. }
  681. public virtual bool OpenDoorNoMap(out string reason)
  682. {
  683. reason = "";
  684. return true;
  685. }
  686. public virtual bool OpenDoorAndMap(out string reason)
  687. {
  688. reason = "";
  689. return true;
  690. }
  691. public virtual bool Unclamp(out string reason)
  692. {
  693. reason = "";
  694. return true;
  695. }
  696. public virtual bool Clamp(out string reason)
  697. {
  698. reason = "";
  699. return true;
  700. }
  701. public virtual bool Unload(out string reason)
  702. {
  703. reason = "";
  704. return true;
  705. }
  706. public virtual bool Stop(out string reason)
  707. {
  708. reason = "";
  709. return true;
  710. }
  711. public virtual bool ClearError(out string reason)
  712. {
  713. reason = "";
  714. return true;
  715. }
  716. public virtual bool Home(out string reason )
  717. {
  718. reason = "";
  719. return true;
  720. }
  721. public virtual bool ForceHome(out string reason )
  722. {
  723. reason = "";
  724. return true;
  725. }
  726. public virtual bool FOSBMode(out string reason)
  727. {
  728. reason = "";
  729. return true;
  730. }
  731. public virtual bool FOUPMode(out string reason)
  732. {
  733. reason = "";
  734. return true;
  735. }
  736. public virtual void Monitor()
  737. {
  738. }
  739. public virtual void Reset()
  740. {
  741. }
  742. public virtual void Terminate()
  743. {
  744. }
  745. private List<List<string>> UpdatedWaferIdList()
  746. {
  747. WaferInfo[] wafers = WaferManager.Instance.GetWafers(_module);
  748. for (int i = 0; i < wafers.Length; i++)
  749. {
  750. _waferId[i][1] = wafers[i].LaserMarker;
  751. _waferId[i][2] = wafers[i].T7Code;
  752. _waferId[i][3] = wafers[i].WaferID;
  753. }
  754. return _waferId;
  755. }
  756. public abstract bool IsEnableMapWafer();
  757. public abstract bool IsEnableTransferWafer();
  758. public abstract bool IsEnableTransferWafer(out string reason);
  759. public virtual bool IsEnableLoad()
  760. {
  761. return _isPresent && _isPlaced;
  762. }
  763. protected void ConfirmAddCarrier()
  764. {
  765. if (_isPresent && _isPlaced)
  766. {
  767. CarrierManager.Instance.CreateCarrier(Name);
  768. if (_isIndependentCEID)
  769. {
  770. var dvid1 = new SerializableDictionary<string, string>
  771. {
  772. [$"{PORT_ID}_{_module}"] = PortId,
  773. [$"{PORT_CTGRY}_{_module}"] = PortCategory
  774. };
  775. EV.Notify($"{_module}_{EventCarrierArrived}", dvid1);
  776. }
  777. else
  778. {
  779. SerializableDictionary<string, string> dvid = new SerializableDictionary<string, string>();
  780. dvid[PORT_ID] = PortId;
  781. dvid[PORT_CTGRY] = PortCategory;
  782. EV.Notify(EventCarrierArrived, dvid );
  783. }
  784. }
  785. }
  786. protected void ConfirmRemoveCarrier()
  787. {
  788. if (!_isPresent && !_isPlaced)
  789. {
  790. for (int i = 0; i < 25; i++)
  791. {
  792. WaferManager.Instance.DeleteWafer(ModuleHelper.Converter(Name), 0,25);
  793. }
  794. CarrierManager.Instance.DeleteCarrier(Name);
  795. if (_isIndependentCEID)
  796. {
  797. var dvid1 = new SerializableDictionary<string, string>
  798. {
  799. [$"{PORT_ID}_{_module}"] = PortId,
  800. [$"{CAR_ID}_{_module}"] = _carrierId ?? ""
  801. };
  802. EV.Notify($"{_module}_{EventCarrierRemoved}", dvid1);
  803. }
  804. else
  805. {
  806. SerializableDictionary<string, string> dvid = new SerializableDictionary<string, string>();
  807. dvid[PORT_ID] = PortId;
  808. dvid[PORT_CTGRY] = PortCategory;
  809. dvid[CAR_ID] = _carrierId ?? "";
  810. EV.Notify(EventCarrierRemoved, dvid);
  811. }
  812. _isMapped = false;
  813. _carrierId = "";
  814. }
  815. }
  816. public void OnSlotMapRead(string slotMap)
  817. {
  818. for (int i = 0; i < 25; i++)
  819. {
  820. // No wafer: "0", Wafer: "1", Crossed:"2", Undefined: "?", Overlapping wafers: "W"
  821. WaferInfo wafer = null;
  822. switch (slotMap[i])
  823. {
  824. case '0':
  825. WaferManager.Instance.DeleteWafer(_module, i);
  826. CarrierManager.Instance.UnregisterCarrierWafer(Name, i);
  827. break;
  828. case '1':
  829. wafer = WaferManager.Instance.CreateWafer(_module, i, WaferStatus.Normal);
  830. CarrierManager.Instance.RegisterCarrierWafer(Name, i, wafer);
  831. break;
  832. case '2':
  833. wafer = WaferManager.Instance.CreateWafer(_module, i, WaferStatus.Crossed);
  834. CarrierManager.Instance.RegisterCarrierWafer(Name, i, wafer);
  835. //NotifyWaferError(Name, i, WaferStatus.Crossed);
  836. break;
  837. case 'W':
  838. wafer = WaferManager.Instance.CreateWafer(_module, i, WaferStatus.Double);
  839. CarrierManager.Instance.RegisterCarrierWafer(Name, i, wafer);
  840. //NotifyWaferError(Name, i, WaferStatus.Double);
  841. break;
  842. case '?':
  843. wafer = WaferManager.Instance.CreateWafer(_module, i, WaferStatus.Unknown);
  844. CarrierManager.Instance.RegisterCarrierWafer(Name, i, wafer);
  845. //NotifyWaferError(Name, i, WaferStatus.Unknown);
  846. break;
  847. }
  848. }
  849. if (_isIndependentCEID)
  850. {
  851. var dvid1 = new SerializableDictionary<string, string>
  852. {
  853. [$"{SLOT_MAP}_{_module}"] = SlotMap,
  854. [$"{PORT_ID}_{_module}"] = PortId,
  855. [$"{PORT_CTGRY}_{_module}"] = PortCategory,
  856. [$"{CAR_ID}_{_module}"] = _carrierId ?? ""
  857. };
  858. EV.Notify($"{_module}_{EventSlotMapAvailable}", dvid1);
  859. }
  860. else
  861. {
  862. SerializableDictionary<string, string> dvid = new SerializableDictionary<string, string>();
  863. dvid[SLOT_MAP] = SlotMap;
  864. dvid[PORT_ID] = PortId;
  865. dvid[PORT_CTGRY] = PortCategory;
  866. dvid[CAR_ID] = CarrierId == null ? "" : CarrierId;
  867. EV.Notify(EventSlotMapAvailable, dvid);
  868. }
  869. _isMapped = true;
  870. }
  871. private string GetSlotMap()
  872. {
  873. WaferInfo[] wafers = WaferManager.Instance.GetWafers(ModuleHelper.Converter(Name) );
  874. string slot = "";
  875. for (int i = 0; i < 25; i++)
  876. {
  877. slot += wafers[i].IsEmpty? "0" : "1";
  878. }
  879. return slot;
  880. }
  881. /// <summary>
  882. /// 获取LP中空缺Slot
  883. /// </summary>
  884. /// <returns>返回一个list, 顺序为从下到上.(0-25)</returns>
  885. public List<int> GetEmptySlot()
  886. {
  887. List<int> slot = new List<int>();
  888. if (IsMapped)
  889. {
  890. WaferInfo[] wafers = WaferManager.Instance.GetWafers(ModuleHelper.Converter(Name));
  891. for (int i = 0; i < 25 ; i++)
  892. {
  893. if(wafers[i].IsEmpty)
  894. slot.Add(i);
  895. }
  896. return slot;
  897. }
  898. else
  899. {
  900. return null;
  901. }
  902. }
  903. public void OnCarrierIdRead(ModuleName module, string name, string carrierId)
  904. {
  905. if (_isPlaced && _isPresent)
  906. {
  907. _carrierId = carrierId;
  908. if (_isIndependentCEID)
  909. {
  910. var dvid1 = new SerializableDictionary<string, string>
  911. {
  912. [$"{CAR_ID}_{_module}"] = _carrierId ?? "",
  913. [$"{PORT_ID}_{_module}"] = PortId,
  914. [$"{PORT_CTGRY}_{_module}"] = PortCategory
  915. };
  916. EV.Notify($"{_module}_{EventCarrierIdRead}", dvid1);
  917. }
  918. else
  919. {
  920. SerializableDictionary<string, string> dvid = new SerializableDictionary<string, string>();
  921. dvid[CAR_ID] = carrierId ?? "";
  922. dvid[PORT_ID] = PortId;
  923. dvid[PORT_CTGRY] = PortCategory;
  924. EV.Notify(EventCarrierIdRead, dvid);
  925. }
  926. CarrierManager.Instance.UpdateCarrierId(Name, carrierId);
  927. }
  928. else
  929. {
  930. EV.PostWarningLog(Module, $"No FOUP found, carrier id {carrierId} not saved");
  931. }
  932. }
  933. public void OnCarrierIdWrite(ModuleName module, string name, string carrierId)
  934. {
  935. if (_isPlaced && _isPresent)
  936. {
  937. //_carrierId = carrierId;
  938. if (_isIndependentCEID)
  939. {
  940. var dvid1 = new SerializableDictionary<string, string>
  941. {
  942. [$"{CAR_ID}_{_module}"] = carrierId ?? "",
  943. [$"{PORT_ID}_{_module}"] = PortId
  944. };
  945. EV.Notify($"{_module}_CAR_ID_WRITE_SUCCESSFULLY", dvid1);
  946. }
  947. else
  948. {
  949. SerializableDictionary<string, string> dvid = new SerializableDictionary<string, string>();
  950. dvid[CAR_ID] = carrierId ?? "";
  951. dvid[PORT_ID] = PortId;
  952. dvid[PORT_CTGRY] = PortCategory;
  953. EV.Notify(EventCarrierIdWrite, dvid);
  954. }
  955. }
  956. else
  957. {
  958. EV.PostWarningLog(Module, $"No FOUP found, carrier id {carrierId} not saved");
  959. }
  960. }
  961. public void OnCarrierIdReadFailed(ModuleName module, string name)
  962. {
  963. if (_isPlaced && _isPresent)
  964. {
  965. _carrierId = "";
  966. if (_isIndependentCEID)
  967. {
  968. var dvid1 = new SerializableDictionary<string, string>
  969. {
  970. [$"{PORT_ID}_{_module}"] = PortId,
  971. [$"{PORT_CTGRY}_{_module}"] = PortCategory
  972. };
  973. EV.Notify($"{_module}_{EventCarrierIdReadFailed}", dvid1);
  974. }
  975. else
  976. {
  977. SerializableDictionary<string, string> dvid = new SerializableDictionary<string, string>();
  978. dvid[PORT_ID] = PortId;
  979. dvid[PORT_CTGRY] = PortCategory;
  980. EV.Notify(EventCarrierIdReadFailed, dvid);
  981. }
  982. }
  983. else
  984. {
  985. EV.PostWarningLog(Module, "No FOUP found, carrier id read is not valid");
  986. }
  987. }
  988. public void OnCarrierIdWriteFailed(ModuleName module, string name)
  989. {
  990. if (_isPlaced && _isPresent)
  991. {
  992. //_carrierId = "";
  993. if (_isIndependentCEID)
  994. {
  995. var dvid1 = new SerializableDictionary<string, string>
  996. {
  997. [$"{PORT_ID}_{_module}"] = PortId,
  998. [$"{PORT_CTGRY}_{_module}"] = PortCategory,
  999. [$"{CAR_ID}_{_module}"] = _carrierId ?? ""
  1000. };
  1001. EV.Notify($"{_module}_CAR_ID_WRITE_FAIL", dvid1);
  1002. }
  1003. else
  1004. {
  1005. SerializableDictionary<string, string> dvid = new SerializableDictionary<string, string>();
  1006. dvid[PORT_ID] = PortId;
  1007. dvid[PORT_CTGRY] = PortCategory;
  1008. EV.Notify(EventCarrierIdWriteFailed, dvid);
  1009. }
  1010. }
  1011. else
  1012. {
  1013. EV.PostWarningLog(Module, "No FOUP found, carrier id not valid");
  1014. }
  1015. }
  1016. public void OnCarrierIdRead(ModuleName module, string carrierId)
  1017. {
  1018. OnCarrierIdRead(module, "", carrierId);
  1019. }
  1020. public void OnCarrierIdReadFailed(ModuleName module)
  1021. {
  1022. OnCarrierIdReadFailed(module, "");
  1023. }
  1024. public void OnCarrierIdWrite(ModuleName module, string carrierId)
  1025. {
  1026. OnCarrierIdWrite(module, "", carrierId);
  1027. }
  1028. public void OnCarrierIdWriteFailed(ModuleName module)
  1029. {
  1030. OnCarrierIdWriteFailed(module, "");
  1031. }
  1032. public void OnRfIdRead(ModuleName module, string rfid)
  1033. {
  1034. if (_isPlaced && _isPresent)
  1035. {
  1036. _rfid = rfid;
  1037. if (_isIndependentCEID)
  1038. {
  1039. var dvid1 = new SerializableDictionary<string, string>
  1040. {
  1041. [$"{CAR_ID}_{_module}"] = _carrierId ?? "",
  1042. [$"{PORT_ID}_{_module}"] = PortId,
  1043. [$"{PORT_CTGRY}_{_module}"] = PortCategory,
  1044. [$"{RF_ID}_{_module}"] = rfid ?? ""
  1045. };
  1046. EV.Notify($"{_module}_{EventRfIdRead}", dvid1);
  1047. }
  1048. else
  1049. {
  1050. SerializableDictionary<string, string> dvid = new SerializableDictionary<string, string>();
  1051. dvid[CAR_ID] = _carrierId ?? "";
  1052. dvid[PORT_ID] = PortId;
  1053. dvid[PORT_CTGRY] = PortCategory;
  1054. dvid[RF_ID] = rfid ?? "";
  1055. EV.Notify(EventRfIdRead, dvid);
  1056. }
  1057. CarrierManager.Instance.UpdateRfId(Name, rfid);
  1058. }
  1059. else
  1060. {
  1061. EV.PostWarningLog(Module, "No FOUP found, rf id read not valid");
  1062. }
  1063. }
  1064. public void OnRfIdReadFailed(ModuleName module)
  1065. {
  1066. if (_isPlaced && _isPresent)
  1067. {
  1068. _rfid = "";
  1069. if (_isIndependentCEID)
  1070. {
  1071. var dvid1 = new SerializableDictionary<string, string>
  1072. {
  1073. [$"{CAR_ID}_{_module}"] = _carrierId ?? "",
  1074. [$"{PORT_ID}_{_module}"] = PortId,
  1075. [$"{PORT_CTGRY}_{_module}"] = PortCategory
  1076. };
  1077. EV.Notify($"{_module}_{EventRfIdReadFailed}", dvid1);
  1078. }
  1079. else
  1080. {
  1081. SerializableDictionary<string, string> dvid = new SerializableDictionary<string, string>();
  1082. dvid[CAR_ID] = _carrierId ?? "";
  1083. dvid[PORT_ID] = PortId;
  1084. dvid[PORT_CTGRY] = PortCategory;
  1085. EV.Notify(EventRfIdReadFailed, dvid);
  1086. }
  1087. }
  1088. else
  1089. {
  1090. EV.PostWarningLog(Module, "No FOUP found, rf id read is not valid");
  1091. }
  1092. }
  1093. public void OnRfIdWrite(ModuleName module, string rfid)
  1094. {
  1095. if (_isPlaced && _isPresent)
  1096. {
  1097. _rfid = rfid;
  1098. if (_isIndependentCEID)
  1099. {
  1100. var dvid1 = new SerializableDictionary<string, string>
  1101. {
  1102. [$"{CAR_ID}_{_module}"] = _carrierId ?? "",
  1103. [$"{PORT_ID}_{_module}"] = PortId,
  1104. [$"{PORT_CTGRY}_{_module}"] = PortCategory,
  1105. [$"{RF_ID}_{_module}"] = rfid ?? ""
  1106. };
  1107. EV.Notify($"{_module}_{EventRfIdWrite}", dvid1);
  1108. }
  1109. else
  1110. {
  1111. SerializableDictionary<string, string> dvid = new SerializableDictionary<string, string>();
  1112. dvid[CAR_ID] = _carrierId ?? "";
  1113. dvid[PORT_ID] = PortId;
  1114. dvid[PORT_CTGRY] = PortCategory;
  1115. dvid[RF_ID] = rfid ?? "";
  1116. EV.Notify(EventRfIdWrite, dvid);
  1117. }
  1118. CarrierManager.Instance.UpdateRfId(Name, rfid);
  1119. }
  1120. else
  1121. {
  1122. EV.PostWarningLog(Module, "No FOUP found, rf id write not valid");
  1123. }
  1124. }
  1125. public void OnRfIdWriteFailed(ModuleName module )
  1126. {
  1127. if (_isPlaced && _isPresent)
  1128. {
  1129. _rfid = "";
  1130. if (_isIndependentCEID)
  1131. {
  1132. var dvid1 = new SerializableDictionary<string, string>
  1133. {
  1134. [$"{CAR_ID}_{_module}"] = _carrierId ?? "",
  1135. [$"{PORT_ID}_{_module}"] = PortId,
  1136. [$"{PORT_CTGRY}_{_module}"] = PortCategory,
  1137. [$"{RF_ID}_{_module}"] = ""
  1138. };
  1139. EV.Notify($"{_module}_{EventRfIdWrite}", dvid1);
  1140. }
  1141. else
  1142. {
  1143. SerializableDictionary<string, string> dvid = new SerializableDictionary<string, string>();
  1144. dvid[CAR_ID] = _carrierId ?? "";
  1145. dvid[PORT_ID] = PortId;
  1146. dvid[PORT_CTGRY] = PortCategory;
  1147. dvid[RF_ID] = "";
  1148. //EV.PostWarningLog(Module, "Write RFID failed.");
  1149. EV.Notify(EventRfIdWrite, dvid);
  1150. }
  1151. }
  1152. else
  1153. {
  1154. EV.PostWarningLog(Module, "No FOUP found, rf id write not valid");
  1155. }
  1156. }
  1157. public void OnLoaded()
  1158. {
  1159. if (_isIndependentCEID)
  1160. {
  1161. var dvid1 = new SerializableDictionary<string, string>
  1162. {
  1163. [$"{CAR_ID}_{_module}"] = _carrierId ?? "",
  1164. [$"{PORT_ID}_{_module}"] = PortId
  1165. };
  1166. EV.Notify($"{_module}_CARRIR_LOAD_COMPLETE", dvid1);
  1167. }
  1168. else
  1169. {
  1170. var dvid = new SerializableDictionary<string, string>
  1171. {
  1172. [CAR_ID] = _carrierId ?? "",
  1173. [PORT_ID] = PortId
  1174. };
  1175. EV.Notify(EventCarrierloaded, dvid);
  1176. }
  1177. }
  1178. public void OnUnloaded()
  1179. {
  1180. if (_isIndependentCEID)
  1181. {
  1182. var dvid1 = new SerializableDictionary<string, string>
  1183. {
  1184. [$"{PORT_CTGRY}_{_module}"] = PortCategory,
  1185. [$"{PORT_ID}_{_module}"] = PortId,
  1186. [$"{CAR_ID}_{_module}"] = _carrierId ?? "",
  1187. [$"{SLOT_MAP}_{_module}"] = SlotMap,
  1188. [$"LOT_ID_{_module}"] = CarrierManager.Instance.GetLotIdByLoadPort(_module.ToString())
  1189. };
  1190. EV.Notify($"{_module}_{EventCarrierUnloaded}", dvid1);
  1191. }
  1192. else
  1193. {
  1194. var dvid = new SerializableDictionary<string, string>();
  1195. dvid[PORT_CTGRY] = PortCategory;
  1196. dvid[PORT_ID] = PortId;
  1197. dvid[CAR_ID] = _carrierId ?? "";
  1198. EV.Notify(EventCarrierUnloaded, dvid);
  1199. }
  1200. for (int i = 0; i < 25; i++)
  1201. {
  1202. WaferManager.Instance.DeleteWafer(ModuleHelper.Converter(Name), 0, 25);
  1203. }
  1204. _isMapped = false;
  1205. }
  1206. public void OnHomed()
  1207. {
  1208. for (int i = 0; i < 25; i++)
  1209. {
  1210. WaferManager.Instance.DeleteWafer(ModuleHelper.Converter(Name), 0, 25);
  1211. }
  1212. _isMapped = false;
  1213. }
  1214. public void OnCloseDoor()
  1215. {
  1216. for (int i = 0; i < 25; i++)
  1217. {
  1218. WaferManager.Instance.DeleteWafer(ModuleHelper.Converter(Name), 0, 25);
  1219. }
  1220. _isMapped = false;
  1221. }
  1222. public void OnError()
  1223. {
  1224. EV.Notify(AlarmCarrierPortError);
  1225. EV.Notify($"{_module}_{AlarmCarrierPortError}");
  1226. }
  1227. protected void SetPresent(bool isPresent)
  1228. {
  1229. _isPresent = isPresent;
  1230. if (_isPresent)
  1231. {
  1232. ConfirmAddCarrier();
  1233. }
  1234. else
  1235. {
  1236. ConfirmRemoveCarrier();
  1237. }
  1238. }
  1239. protected void SetPlaced(bool isPlaced)
  1240. {
  1241. _isPlaced = isPlaced;
  1242. if (_isPlaced)
  1243. {
  1244. ConfirmAddCarrier();
  1245. }
  1246. else
  1247. {
  1248. ConfirmRemoveCarrier();
  1249. }
  1250. }
  1251. }
  1252. }