LoadPort - 副本.cs 53 KB

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