LoadPort.cs 64 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916
  1. using Aitex.Core.Common;
  2. using Aitex.Core.RT.DataCenter;
  3. using Aitex.Core.RT.Device;
  4. using Aitex.Core.RT.Device.Unit;
  5. using Aitex.Core.RT.Event;
  6. using Aitex.Core.RT.OperationCenter;
  7. using Aitex.Core.RT.SCCore;
  8. using Aitex.Core.Util;
  9. using Aitex.Sorter.Common;
  10. using MECF.Framework.Common.Equipment;
  11. using MECF.Framework.Common.SubstrateTrackings;
  12. using MECF.Framework.RT.EquipmentLibrary.HardwareUnits.CarrierIdReaders.CarrierIDReaderBase;
  13. using MECF.Framework.RT.EquipmentLibrary.HardwareUnits.LoadPorts.TDK;
  14. using System;
  15. using System.Collections.Generic;
  16. using MECF.Framework.RT.EquipmentLibrary.HardwareUnits.LoadPorts.LoadPortBase;
  17. using static Aitex.Core.RT.Device.Unit.IOE84Passive;
  18. using static MECF.Framework.RT.EquipmentLibrary.HardwareUnits.LoadPorts.LoadPortBase.LoadPortBaseDevice;
  19. namespace MECF.Framework.RT.EquipmentLibrary.HardwareUnits.LoadPorts
  20. {
  21. public enum IndicatorType
  22. {
  23. Load,
  24. Unload,
  25. Presence,
  26. Placement,
  27. Alarm,
  28. AccessManual,
  29. AccessAuto,
  30. Status1,
  31. Status2,
  32. Manual,
  33. Auto,
  34. Reserve,
  35. Error,
  36. Access,
  37. Busy,
  38. Complete,
  39. }
  40. public enum E84PioPosition
  41. {
  42. Floor = 0,
  43. Middle = 1,
  44. Overhead = 2
  45. }
  46. public enum E84PioSignalAtoP
  47. {
  48. VALID = 1,
  49. CS_0 = 2,
  50. CS_1 = 3,
  51. TR_REQ = 4,
  52. BUSY = 5,
  53. COMPT = 6,
  54. CONT = 7,
  55. AM_AVBL = 8
  56. }
  57. public enum E84PioSignalPtoA
  58. {
  59. L_REQ = 11,
  60. U_REQ = 12,
  61. READY = 13,
  62. HO_AVBL = 14,
  63. ES = 15,
  64. VA = 16,
  65. VS_0 = 17,
  66. VS_1 = 18
  67. }
  68. public interface IE87CallBack
  69. {
  70. void CarrierArrive();
  71. void CarrerRemove(string carrierID);
  72. void CarrierIDReadSuccess(string carrierID);
  73. void CarrierIDReadFail();
  74. void MappingComplete(string carrierID, string slotmap);
  75. void LoadportError(string errorcode);
  76. void LoadComplete();
  77. void UnloadComplete();
  78. void OnLPHomed();
  79. void OnE84HandoffStart(bool isload);
  80. void OnE84HandoffComplete(bool isload);
  81. }
  82. public interface IE84CallBack
  83. {
  84. void SetHoAutoControl(bool value);
  85. void SetHoAvailable(bool value);
  86. void SetE84SignalState(E84PassiveSignal signal, bool value);
  87. bool GetE84SignalState(E84SignalID signal);
  88. void SetFoupStatus(bool foupon);
  89. void SetReadyTransferStatus(bool ready);
  90. E84State GetCurrentE84State();
  91. void Stop();
  92. void Reset();
  93. void ResetE84();
  94. void Complete();
  95. event Action<string> OnE84HandOffStart;
  96. event Action<string> OnE84HandOffComplete;
  97. event Action<E84Timeout, string> OnE84HandOffTimeout;
  98. event Action<E84SignalID, bool> OnE84ActiveSignalChange;
  99. event Action<E84SignalID, bool> OnE84PassiveSignalChange;
  100. }
  101. public abstract class LoadPort : BaseDevice, ILoadPort
  102. {
  103. public event Action<bool> ActionDone;
  104. public IndicatorState IndicatiorLoad { get; set; }
  105. public IndicatorState IndicatiorUnload { get; set; }
  106. public IndicatorState IndicatiorPresence { get; set; }
  107. public IndicatorState IndicatorAlarm { get; set; }
  108. public IndicatorState IndicatiorPlacement { get; set; }
  109. public IndicatorState IndicatiorOpAccess { get; set; }
  110. public IndicatorState IndicatiorAccessAuto { get; set; }
  111. public IndicatorState IndicatiorAccessManual { get; set; }
  112. public IndicatorState IndicatiorStatus1 { get; set; }
  113. public IndicatorState IndicatiorStatus2 { get; set; }
  114. public IndicatorState IndicatiorManualMode { get; set; }
  115. public IndicatorState IndicatiorClampUnclamp { get; set; }
  116. public IndicatorState IndicatiorDockUndock { get; set; }
  117. public static Dictionary<IndicatorType, Indicator> LoadPortIndicatorLightMap =
  118. new Dictionary<IndicatorType, Indicator>()
  119. {
  120. {IndicatorType.Load, Indicator.LOAD},
  121. {IndicatorType.Unload, Indicator.UNLOAD},
  122. {IndicatorType.AccessAuto, Indicator.ACCESSAUTO },
  123. {IndicatorType.AccessManual, Indicator.ACCESSMANUL},
  124. {IndicatorType.Alarm, Indicator.ALARM},
  125. {IndicatorType.Presence, Indicator.PRESENCE},
  126. {IndicatorType.Placement, Indicator.PLACEMENT},
  127. {IndicatorType.Status1, Indicator.RESERVE1},
  128. {IndicatorType.Status2, Indicator.RESERVE2},
  129. };
  130. public IndicatorState[] IndicatorStateFeedback { get; set; }
  131. public virtual FoupClampState ClampState { get; set; }
  132. public virtual FoupDockState DockState { get; set; }
  133. public virtual FoupDoorState DoorState { get; set; }
  134. public virtual CasstleType CasstleType { get; set; }
  135. public string SlotMap
  136. {
  137. get { return GetSlotMap(); }
  138. }
  139. //Hirata
  140. public int WaferCount { get; set; }
  141. public virtual bool IsBusy { get; set; }
  142. public virtual bool IsIdle { get; set; }
  143. public virtual bool IsMoving { get; set; }
  144. public virtual bool IsInfoPadAOn { get; set; }
  145. public virtual bool IsInfoPadBOn { get; set; }
  146. public virtual bool IsInfoPadCOn { get; set; }
  147. public virtual bool IsInfoPadDOn { get; set; }
  148. public virtual bool IsWaferProtrude { get; set; }
  149. public virtual bool IsMonitorProtrude { get; set; } = false;
  150. public virtual string InfoPadCarrierType { get; set; } = "";
  151. public virtual string InfoPadCarrierTypeInformation
  152. {
  153. get
  154. {
  155. if (_isPresent)
  156. return ("Index:" + InfoPadCarrierIndex.ToString() + "\r\n"
  157. + "Type:" + InfoPadCarrierType + "\r\n"
  158. + "Size:" + GetCurrentWaferSize().ToString());
  159. return "";
  160. }
  161. }
  162. public virtual int InfoPadCarrierIndex { get; set; } = -1;
  163. public virtual LoadportCassetteState CassetteState
  164. {
  165. get;
  166. set;
  167. }
  168. public WaferSize Size
  169. {
  170. get
  171. {
  172. IoWaferSizeDetector detector = DEVICE.GetDevice<IoWaferSizeDetector>($"{Name}WaferDetector");
  173. if (detector != null)
  174. return detector.Value;
  175. int carrierIndex = SC.ContainsItem($"CarrierInfo.{Name}CarrierIndex") ?
  176. SC.GetValue<int>($"CarrierInfo.{Name}CarrierIndex") : 0;
  177. WaferSize wsize = SC.ContainsItem($"CarrierInfo.CarrierWaferSize{carrierIndex}") ?
  178. (WaferSize)SC.GetValue<int>($"CarrierInfo.CarrierWaferSize{carrierIndex}") : WaferSize.WS12;
  179. return wsize;
  180. }
  181. }
  182. public virtual WaferSize GetCurrentWaferSize()
  183. {
  184. return Size;
  185. }
  186. public bool IsMapWaferByLoadPort { get; set; }
  187. public EnumLoadPortType PortType { get; set; }
  188. public bool Initalized { get; set; }
  189. public bool IsPresent
  190. {
  191. get { return _isPresent; }
  192. }
  193. public bool IsPlacement
  194. {
  195. get { return _isPlaced; }
  196. }
  197. public bool IsMapped
  198. {
  199. get { return _isMapped; }
  200. }
  201. public bool IsComplete { get; set; }
  202. public bool IsAccessSwPressed
  203. {
  204. get { return _isAccessSwPressed; }
  205. }
  206. public bool Error { get; set; }
  207. public string ErrorCode { get; set; }
  208. public bool MapError { get; set; }
  209. public bool ReadCarrierIDError { get; set; }
  210. public bool ExecuteError { get; set; } = false;
  211. /// <summary>
  212. /// 是否处于FOSB模式
  213. /// </summary>
  214. public bool IsFOSBMode { get; set; }
  215. public TDKY_AxisPos DockPOS { get; set; } = TDKY_AxisPos.Unknown;
  216. public TDKZ_AxisPos DoorPOS { get; set; } = TDKZ_AxisPos.Unknown;
  217. public DeviceState State
  218. {
  219. get
  220. {
  221. if (!Initalized)
  222. {
  223. return DeviceState.Unknown;
  224. }
  225. if (Error || ExecuteError || MapError || ReadCarrierIDError)
  226. {
  227. return DeviceState.Error;
  228. }
  229. if (IsBusy)
  230. return DeviceState.Busy;
  231. return DeviceState.Idle;
  232. }
  233. }
  234. public string CarrierId
  235. {
  236. get { return _carrierId; }
  237. }
  238. public string LPLotID
  239. {
  240. get { return _lplotID; }
  241. }
  242. public string RfId
  243. {
  244. get { return _rfid; }
  245. }
  246. public RD_TRIG PresentTrig
  247. {
  248. get { return _presentTrig; }
  249. }
  250. public RD_TRIG PlacedtTrig
  251. {
  252. get { return _placetTrig; }
  253. }
  254. public RD_TRIG AccessSwPressedTrig
  255. {
  256. get { return _accessSwPressedTrig; }
  257. }
  258. public RD_TRIG ClampedTrig
  259. {
  260. get { return _clampTrig; }
  261. }
  262. public RD_TRIG DockTrig
  263. {
  264. get { return _dockTrig; }
  265. }
  266. public RD_TRIG DoorTrig
  267. {
  268. get { return _doorTrig; }
  269. }
  270. protected bool _isPresent;
  271. protected bool _isPlaced;
  272. protected bool _isDocked;
  273. protected bool _isAccessSwPressed;
  274. protected string _carrierId = "";
  275. protected string _rfid;
  276. protected string _lplotID;
  277. protected bool _isMapped;
  278. private ModuleName _module;
  279. public ModuleName LPModuleName => _module;
  280. //private ModuleStateEnum _state;
  281. private readonly RD_TRIG _presentTrig = new RD_TRIG();
  282. private readonly RD_TRIG _placetTrig = new RD_TRIG();
  283. private readonly RD_TRIG _accessSwPressedTrig = new RD_TRIG();
  284. private readonly RD_TRIG _clampTrig = new RD_TRIG();
  285. private readonly RD_TRIG _dockTrig = new RD_TRIG();
  286. private readonly RD_TRIG _doorTrig = new RD_TRIG();
  287. public R_TRIG TrigWaferProtrude = new R_TRIG();
  288. private List<List<string>> _waferId = new List<List<string>>();
  289. private int _slotNumber;
  290. public string PortId
  291. {
  292. get; private set;
  293. }
  294. public string PortCategory
  295. {
  296. get
  297. {
  298. return (SC.ContainsItem($"LoadPort.LoadPort{PortId}CarrierLabel") ?
  299. SC.GetStringValue($"LoadPort.LoadPort{PortId}CarrierLabel") : "");
  300. }
  301. }
  302. ModuleName[] PortModuleNames = new[]
  303. {
  304. ModuleName.LP1,ModuleName.LP2,ModuleName.LP3,ModuleName.LP4,ModuleName.LP5,
  305. ModuleName.LP6,ModuleName.LP7,ModuleName.LP8,ModuleName.LP9,ModuleName.LP10,
  306. ModuleName.Cassette,
  307. };
  308. private string EventCarrierArrived = "CARRIER_ARRIVED";
  309. private string EventCarrierIdRead = "CARRIER_ID_READ";
  310. private string EventCarrierIdReadFailed = "CARRIER_ID_READ_FAILED";
  311. private string EventCarrierIdWrite = "CARRIER_ID_WRITE";
  312. private string EventCarrierIdWriteFailed = "CARRIER_ID_WRITE_FAILED";
  313. protected string EventSlotMapAvailable = "SLOT_MAP_AVAILABLE";
  314. private string EventCarrierRemoved = "CARRIER_REMOVED";
  315. private string EventCarrierUnloaded = "CARRIER_UNLOADED";
  316. public string EventCarrierLoaded = "CARRIER_LOADED";
  317. public string EventCarrierClamped = "CCLMP";
  318. public string EventCarrierUnClamped = "CUCLMP";
  319. private string EventLPHomed = "LP_HOMED";
  320. protected string PORT_ID = "PORT_ID";
  321. protected string CAR_ID = "CAR_ID";
  322. protected string SLOT_MAP = "SLOT_MAP";
  323. protected string PORT_CTGRY = "PORT_CTGRY";
  324. protected string RF_ID = "RF_ID";
  325. protected string PORT_CARRIER_TYPE = "PORT_CARRIER_TYPE";
  326. private string EventRfIdRead = "RF_ID_READ";
  327. private string EventRfIdReadFailed = "RF_ID_READ_FAILED";
  328. private string EventRfIdWrite = "RF_ID_WRITE";
  329. private string EventRfIdWriteFailed = "RF_ID_WRITE_FAILED";
  330. public string AlarmLoadPortError { get => _module + "Error"; }
  331. public string AlarmLoadPortMappingError { get => _module + "MappingError"; }
  332. public string AlarmCarrierIDReadError { get => _module + "CarrierIDReadFail"; }
  333. private IE87CallBack _lpcallback = null;
  334. public IE87CallBack LPCallBack
  335. {
  336. get { return _lpcallback; }
  337. set { _lpcallback = value; }
  338. }
  339. private IE84CallBack _lpE84Callback = null;
  340. public IE84CallBack LPE84Callback
  341. {
  342. get { return _lpE84Callback; }
  343. set { _lpE84Callback = value; }
  344. }
  345. private ICarrierIDReader _carrierIDReadercallback = null;
  346. public ICarrierIDReader CarrierIDReaderCallBack
  347. {
  348. get { return _carrierIDReadercallback; }
  349. set { _carrierIDReadercallback = value; }
  350. }
  351. public LoadPort(int slotNumber = 25)
  352. {
  353. _slotNumber = slotNumber;
  354. }
  355. public LoadPort(string module, string name, int slotNumber = 25) : base(module, name, name, "")
  356. {
  357. _slotNumber = slotNumber;
  358. }
  359. public virtual bool IsAutoClampOnFoupOn
  360. {
  361. get
  362. {
  363. if (SC.ContainsItem($"LoadPort.LP{PortId}.AutoClampOnFoupOn"))
  364. return SC.GetValue<bool>($"LoadPort.LP{PortId}.AutoClampOnFoupOn");
  365. return false;
  366. }
  367. }
  368. public virtual bool Initialize()
  369. {
  370. for (int i = 0; i < 25; i++)
  371. {
  372. _waferId.Add(new List<string>()
  373. {
  374. i.ToString("D2"),"","",""
  375. });
  376. }
  377. if (!Enum.TryParse(Name, out ModuleName m))
  378. Enum.TryParse(Module, out m);
  379. _module = m;
  380. if ((int)_module >= 97)
  381. PortId = ((int)_module - 96).ToString();
  382. else
  383. PortId = ((int)_module).ToString();
  384. DoorState = FoupDoorState.Unknown;
  385. WaferManager.Instance.SubscribeLocation(_module, _slotNumber);
  386. CarrierManager.Instance.SubscribeLocation(_module.ToString());
  387. DATA.Subscribe(Name, "IsPresent", () => _isPresent);
  388. DATA.Subscribe(Name, "IsPlaced", () => _isPlaced);
  389. DATA.Subscribe(Name, "IsClamped", () => ClampState == FoupClampState.Close);
  390. DATA.Subscribe(Name, "IsDocked", () => DockState == FoupDockState.Docked);
  391. DATA.Subscribe(Name, "IsDoorOpen", () => DoorState == FoupDoorState.Open);
  392. DATA.Subscribe(Name, "ModuleState", () => "Idle");
  393. DATA.Subscribe(Name, "CarrierId", () => _carrierId);
  394. DATA.Subscribe(Name, "LPLotID", () => _lplotID);
  395. DATA.Subscribe(Name, "IsMapped", () => _isMapped);
  396. DATA.Subscribe($"{Name}.LoadportState", () => State);
  397. DATA.Subscribe($"{Name}.LoadportBusy", () => IsBusy);
  398. DATA.Subscribe($"{Name}.LoadportError", () => ErrorCode);
  399. DATA.Subscribe($"{Name}.CassetteState", () => CassetteState);
  400. DATA.Subscribe($"{Name}.FoupClampState", () => ClampState);
  401. DATA.Subscribe($"{Name}.FoupDockState", () => DockState);
  402. DATA.Subscribe($"{Name}.FoupDoorState", () => DoorState);
  403. DATA.Subscribe($"{Name}.SlotMap", () => SlotMap);
  404. DATA.Subscribe($"{Name}.IndicatiorLoad", () => IndicatiorLoad);
  405. DATA.Subscribe($"{Name}.IndicatiorUnload", () => IndicatiorUnload);
  406. DATA.Subscribe($"{Name}.IndicatiorPresence", () => IndicatiorPresence);
  407. DATA.Subscribe($"{Name}.IndicatiorPlacement", () => IndicatiorPlacement);
  408. DATA.Subscribe($"{Name}.IndicatiorAlarm", () => IndicatorAlarm);
  409. DATA.Subscribe($"{Name}.IndicatiorAccessAuto", () => IndicatiorAccessAuto);
  410. DATA.Subscribe($"{Name}.IndicatiorAccessManual", () => IndicatiorAccessManual);
  411. DATA.Subscribe($"{Name}.IndicatiorOpAccess", () => IndicatiorOpAccess);
  412. DATA.Subscribe($"{Name}.IndicatiorStatus1", () => IndicatiorStatus1);
  413. DATA.Subscribe($"{Name}.IndicatiorStatus2", () => IndicatiorStatus2);
  414. DATA.Subscribe($"{Name}.CasstleType", () => (int)CasstleType);
  415. DATA.Subscribe($"{Name}.InfoPadCarrierType", () => InfoPadCarrierType);
  416. DATA.Subscribe($"{Name}.InfoPadCarrierTypeInformation", () => InfoPadCarrierTypeInformation);
  417. DATA.Subscribe($"{Name}.InfoPadCarrierIndex", () => InfoPadCarrierIndex);
  418. DATA.Subscribe($"{Name}.IsError", () => State == DeviceState.Error);
  419. //if (PortStateVariableNames.Length > _lpIndex)
  420. // DATA.Subscribe(PortStateVariableNames[_lpIndex], () => (_isPlaced && _isPresent) ? "1" : "0");
  421. //if (PortSlotMapVariableNames.Length > _lpIndex)
  422. // DATA.Subscribe(PortSlotMapVariableNames[_lpIndex], () => SlotMap);
  423. //if (PortWaferIdVariableNames.Length > _lpIndex)
  424. // DATA.Subscribe(PortWaferIdVariableNames[_lpIndex], UpdatedWaferIdList);
  425. EV.Subscribe(new EventItem("Event", EventCarrierArrived, "Carrier arrived"));
  426. EV.Subscribe(new EventItem("Event", EventCarrierRemoved, "Carrier removed"));
  427. EV.Subscribe(new EventItem("Event", EventCarrierIdRead, "Carrier ID read"));
  428. EV.Subscribe(new EventItem("Event", EventCarrierIdReadFailed, "Carrier ID read failed"));
  429. EV.Subscribe(new EventItem("Event", EventCarrierIdWrite, "Carrier ID write"));
  430. EV.Subscribe(new EventItem("Event", EventCarrierIdWriteFailed, "Carrier ID write failed"));
  431. EV.Subscribe(new EventItem("Event", EventSlotMapAvailable, "Slot map available"));
  432. EV.Subscribe(new EventItem("Event", EventCarrierUnloaded, "Carrier unloaded"));
  433. EV.Subscribe(new EventItem("Event", EventCarrierLoaded, "Carrier loaded"));
  434. EV.Subscribe(new EventItem("Event", EventRfIdRead, "Carrier RFID read"));
  435. EV.Subscribe(new EventItem("Event", EventRfIdReadFailed, "Carrier RFID read failed"));
  436. EV.Subscribe(new EventItem("Event", EventRfIdWrite, "Carrier RFID write"));
  437. EV.Subscribe(new EventItem("Event", EventRfIdWriteFailed, "Carrier RFID write failed"));
  438. EV.Subscribe(new EventItem("Event", EventCarrierClamped, "Carrier was clamped."));
  439. EV.Subscribe(new EventItem("Event", EventCarrierUnClamped, "Carrier was unclamped."));
  440. EV.Subscribe(new EventItem("Event", AlarmLoadPortError, $"Load Port {Name}error", EventLevel.Alarm, EventType.EventUI_Notify));
  441. EV.Subscribe(new EventItem("Event", AlarmLoadPortMappingError, $"Load Port {Name} mapping error", EventLevel.Alarm, EventType.EventUI_Notify));
  442. EV.Subscribe(new EventItem("Event", AlarmCarrierIDReadError, $"Load Port {Name} read carrierID error", EventLevel.Alarm, EventType.EventUI_Notify));
  443. //}
  444. IsIdle = true;
  445. //_state = ModuleStateEnum.Idle;
  446. IndicatorStateFeedback = new IndicatorState[20];
  447. if (_lpE84Callback != null)
  448. {
  449. _lpE84Callback.OnE84ActiveSignalChange += _lpE84Callback_OnE84ActiveSignalChange;
  450. _lpE84Callback.OnE84PassiveSignalChange += _lpE84Callback_OnE84PassiveSignalChange;
  451. _lpE84Callback.OnE84HandOffComplete += _lpE84Callback_OnE84HandOffComplete;
  452. _lpE84Callback.OnE84HandOffStart += _lpE84Callback_OnE84HandOffStart;
  453. _lpE84Callback.OnE84HandOffTimeout += _lpE84Callback_OnE84HandOffTimeout;
  454. }
  455. RegisterOperation();
  456. return true;
  457. }
  458. private void _lpE84Callback_OnE84PassiveSignalChange(E84SignalID arg2, bool arg3)
  459. {
  460. ;
  461. }
  462. private void _lpE84Callback_OnE84HandOffTimeout(E84Timeout arg2, string arg3)
  463. {
  464. ;
  465. }
  466. private void _lpE84Callback_OnE84HandOffStart(string arg2)
  467. {
  468. OnE84HandOffStart(arg2 == "Load");
  469. }
  470. private void _lpE84Callback_OnE84HandOffComplete(string arg2)
  471. {
  472. OnE84HandOffComplete(arg2 == "Load");
  473. }
  474. private void _lpE84Callback_OnE84ActiveSignalChange(E84SignalID arg2, bool arg3)
  475. {
  476. ;
  477. }
  478. public virtual bool Connect()
  479. {
  480. return true;
  481. }
  482. public virtual bool IsAutoReadCarrierID
  483. {
  484. get
  485. {
  486. return SC.ContainsItem($"LoadPort.{_module}.EnableAutoCarrierIdRead") ?
  487. SC.GetValue<bool>($"LoadPort.{_module}.EnableAutoCarrierIdRead") : true;
  488. }
  489. }
  490. public virtual bool IsBypassCarrierIDReader
  491. {
  492. get
  493. {
  494. return SC.ContainsItem($"LoadPort.{_module}.BypassCarrierIDReader") ?
  495. SC.GetValue<bool>($"LoadPort.{_module}.BypassCarrierIDReader") : false;
  496. }
  497. }
  498. private void RegisterOperation()
  499. {
  500. OP.Subscribe($"{Name}.LoadportHome", (string cmd, object[] param) =>
  501. {
  502. if (!Home(out string reason))
  503. {
  504. EV.PostWarningLog(Module, $"{Name} can not start home, {reason}");
  505. return false;
  506. }
  507. EV.PostInfoLog(Module, $"{Name} start home");
  508. return true;
  509. });
  510. OP.Subscribe($"{Name}.LoadportReset", (string cmd, object[] param) =>
  511. {
  512. if (!ClearError(out string reason))
  513. {
  514. EV.PostWarningLog(Module, $"{Name} can not reset, {reason}");
  515. return false;
  516. }
  517. EV.PostInfoLog(Module, $"{Name} start reset");
  518. return true;
  519. });
  520. OP.Subscribe($"{Name}.LoadportStop", (string cmd, object[] param) =>
  521. {
  522. if (!Stop(out string reason))
  523. {
  524. EV.PostWarningLog(Module, $"{Name} can not stop, {reason}");
  525. return false;
  526. }
  527. EV.PostInfoLog(Module, $"{Name} stop");
  528. return true;
  529. });
  530. OP.Subscribe($"{Name}.LoadportLoad", (string cmd, object[] param) =>
  531. {
  532. if (!Load(out string reason))
  533. {
  534. EV.PostWarningLog(Module, $"{Name} can not load, {reason}");
  535. return false;
  536. }
  537. EV.PostInfoLog(Module, $"{Name} start load");
  538. return true;
  539. });
  540. OP.Subscribe($"{Name}.LoadportLoadWithoutMap", (string cmd, object[] param) =>
  541. {
  542. if (!LoadWithoutMap(out string reason))
  543. {
  544. EV.PostWarningLog(Module, $"{Name} can not load without map, {reason}");
  545. return false;
  546. }
  547. EV.PostInfoLog(Module, $"{Name} start load without map");
  548. return true;
  549. });
  550. OP.Subscribe($"{Name}.LoadportLoadWithMap", (string cmd, object[] param) =>
  551. {
  552. if (!Load(out string reason))
  553. {
  554. EV.PostWarningLog(Module, $"{Name} can not load with map, {reason}");
  555. return false;
  556. }
  557. if (!QueryWaferMap(out reason))
  558. {
  559. EV.PostWarningLog(Module, $"{Name} can not map, {reason}");
  560. return false;
  561. }
  562. EV.PostInfoLog(Module, $"{Name} start load with map");
  563. return true;
  564. });
  565. OP.Subscribe($"{Name}.LoadportUnload", (string cmd, object[] param) =>
  566. {
  567. if (!Unload(out string reason))
  568. {
  569. EV.PostWarningLog(Module, $"{Name} can not unload, {reason}");
  570. return false;
  571. }
  572. EV.PostInfoLog(Module, $"{Name} start unload");
  573. return true;
  574. });
  575. OP.Subscribe($"{Name}.LoadportClamp", (string cmd, object[] param) =>
  576. {
  577. if (!Clamp(out string reason))
  578. {
  579. EV.PostWarningLog(Module, $"{Name} can not clamp, {reason}");
  580. return false;
  581. }
  582. EV.PostInfoLog(Module, $"{Name} start clamp");
  583. return true;
  584. });
  585. OP.Subscribe($"{Name}.LoadportUnclamp", (string cmd, object[] param) =>
  586. {
  587. if (!Unclamp(out string reason))
  588. {
  589. EV.PostWarningLog(Module, $"{Name} can not unclamp, {reason}");
  590. return false;
  591. }
  592. EV.PostInfoLog(Module, $"{Name} start unclamp");
  593. return true;
  594. });
  595. OP.Subscribe($"{Name}.LoadportOpenDoor", (string cmd, object[] param) =>
  596. {
  597. if (!OpenDoor(out string reason))
  598. {
  599. EV.PostWarningLog(Module, $"{Name} can not open door, {reason}");
  600. return false;
  601. }
  602. EV.PostInfoLog(Module, $"{Name} start open door");
  603. return true;
  604. });
  605. OP.Subscribe($"{Name}.LoadportOpenDoorNoMap", (string cmd, object[] param) =>
  606. {
  607. if (!OpenDoorNoMap(out string reason))
  608. {
  609. EV.PostWarningLog(Module, $"{Name} can not open door, {reason}");
  610. return false;
  611. }
  612. EV.PostInfoLog(Module, $"{Name} start open door");
  613. return true;
  614. });
  615. OP.Subscribe($"{Name}.LoadportCloseDoor", (string cmd, object[] param) =>
  616. {
  617. if (!CloseDoor(out string reason))
  618. {
  619. EV.PostWarningLog(Module, $"{Name} can not close door, {reason}");
  620. return false;
  621. }
  622. EV.PostInfoLog(Module, $"{Name} start close door");
  623. return true;
  624. });
  625. OP.Subscribe($"{Name}.LoadportDock", (string cmd, object[] param) =>
  626. {
  627. if (!Dock(out string reason))
  628. {
  629. EV.PostWarningLog(Module, $"{Name} can not dock, {reason}");
  630. return false;
  631. }
  632. EV.PostInfoLog(Module, $"{Name} start dock");
  633. return true;
  634. });
  635. OP.Subscribe($"{Name}.LoadportUndock", (string cmd, object[] param) =>
  636. {
  637. if (!Undock(out string reason))
  638. {
  639. EV.PostWarningLog(Module, $"{Name} can not undock, {reason}");
  640. return false;
  641. }
  642. EV.PostInfoLog(Module, $"{Name} start undock");
  643. return true;
  644. });
  645. OP.Subscribe($"{Name}.LoadportQueryState", (string cmd, object[] param) =>
  646. {
  647. if (!QueryState(out string reason))
  648. {
  649. EV.PostWarningLog(Module, $"{Name} can not query state, {reason}");
  650. return false;
  651. }
  652. EV.PostInfoLog(Module, $"{Name} start query state");
  653. return true;
  654. });
  655. OP.Subscribe($"{Name}.LoadportQueryLED", (string cmd, object[] param) =>
  656. {
  657. if (!QueryIndicator(out string reason))
  658. {
  659. EV.PostWarningLog(Module, $"{Name} can not query led state, {reason}");
  660. return false;
  661. }
  662. EV.PostInfoLog(Module, $"{Name} start query led state");
  663. return true;
  664. });
  665. OP.Subscribe($"{Name}.LoadportSetLED", (string cmd, object[] param) =>
  666. {
  667. int light = (int)param[0];
  668. int state = (int)param[1];
  669. if (!SetIndicator((Indicator)light, (IndicatorState)state, out string reason))
  670. {
  671. EV.PostWarningLog(Module, $"{Name} can not set led state, {reason}");
  672. return true;
  673. }
  674. EV.PostInfoLog(Module, $"{Name} start set led state");
  675. return true;
  676. });
  677. OP.Subscribe($"{Name}.LoadportMap", (string cmd, object[] param) =>
  678. {
  679. if (!QueryWaferMap(out string reason))
  680. {
  681. EV.PostWarningLog(Module, $"{Name} can not map, {reason}");
  682. return false;
  683. }
  684. EV.PostInfoLog(Module, $"{Name} start map");
  685. return true;
  686. });
  687. OP.Subscribe($"{Name}.SetCassetteType", (string cmd, object[] param) =>
  688. {
  689. if (!SetCassetteType(param, out string reason))
  690. {
  691. EV.PostWarningLog(Module, $"{Name} can not set type, {reason}");
  692. return false;
  693. }
  694. EV.PostInfoLog(Module, $"{Name} cassette type have set to {CasstleType}");
  695. return true;
  696. });
  697. OP.Subscribe($"{Name}.LoadportForceHome", (string cmd, object[] param) =>
  698. {
  699. if (!ForceHome(out string reason))
  700. {
  701. EV.PostWarningLog(Module, $"{Name} can not start force home, {reason}");
  702. return false;
  703. }
  704. EV.PostInfoLog(Module, $"{Name} start force home");
  705. return true;
  706. });
  707. OP.Subscribe($"{Name}.LoadportFOSBMode", (string cmd, object[] param) =>
  708. {
  709. if (!FOSBMode(out string reason))
  710. {
  711. EV.PostWarningLog(Module, $"{Name} can not change to FOSB mode, {reason}");
  712. return false;
  713. }
  714. IsFOSBMode = true;
  715. EV.PostInfoLog(Module, $"{Name} changed to FOSB mode");
  716. return true;
  717. });
  718. OP.Subscribe($"{Name}.LoadportFOUPMode", (string cmd, object[] param) =>
  719. {
  720. if (!FOUPMode(out string reason))
  721. {
  722. EV.PostWarningLog(Module, $"{Name} can not change to FOSB mode, {reason}");
  723. return false;
  724. }
  725. IsFOSBMode = true;
  726. EV.PostInfoLog(Module, $"{Name} changed to FOSB mode");
  727. return true;
  728. });
  729. OP.Subscribe($"{Name}.LoadportQueryFOSBMode", (string cmd, object[] param) =>
  730. {
  731. if (!QueryFOSBMode(out string reason))
  732. {
  733. EV.PostWarningLog(Module, $"{Name} can not change to FOUP mode, {reason}");
  734. return false;
  735. }
  736. IsFOSBMode = false;
  737. EV.PostInfoLog(Module, $"{Name} changed to FOSB mode");
  738. return true;
  739. });
  740. OP.Subscribe($"{Name}.SetLoadportLotID", (string cmd, object[] param) =>
  741. {
  742. if (!SetLotID(param, out string reason))
  743. {
  744. return false;
  745. }
  746. EV.PostInfoLog(Module, $"{Name} set lotID for loadport.");
  747. return true;
  748. });
  749. }
  750. private bool SetLotID(object[] param, out string reason)
  751. {
  752. reason = "";
  753. if (param == null || param.Length == 0) return false;
  754. _lplotID = param[0].ToString();
  755. return true;
  756. }
  757. private bool SetCassetteType(object[] param, out string reason)
  758. {
  759. reason = "";
  760. if (param.Length != 1)
  761. {
  762. reason = "Invalid setting parameter.";
  763. return false;
  764. }
  765. CasstleType = (CasstleType)int.Parse(param[0].ToString());
  766. return true;
  767. }
  768. public virtual bool FALoad(out string reason)
  769. {
  770. reason = "";
  771. return true;
  772. }
  773. public virtual bool Load(out string reason)
  774. {
  775. reason = "";
  776. return true;
  777. }
  778. public virtual bool LoadWithoutMap(out string reason)
  779. {
  780. reason = "";
  781. return true;
  782. }
  783. public virtual bool QueryWaferMap(out string reason)
  784. {
  785. reason = "";
  786. return true;
  787. }
  788. public virtual bool SetWaferMap(out string reason)
  789. {
  790. reason = "";
  791. return true;
  792. }
  793. public virtual bool QueryFOSBMode(out string reason)
  794. {
  795. reason = "";
  796. return true;
  797. }
  798. /// <summary>
  799. /// FOSB模式下的Dock指令
  800. /// </summary>
  801. /// <param name="reason"></param>
  802. /// <returns></returns>
  803. public virtual bool FOSBDock(out string reason)
  804. {
  805. reason = "";
  806. return true;
  807. }
  808. /// <summary>
  809. /// FOSB模式下的FOSBUnDock指令
  810. /// </summary>
  811. /// <param name="reason"></param>
  812. /// <returns></returns>
  813. public virtual bool FOSBUnDock(out string reason)
  814. {
  815. reason = "";
  816. return true;
  817. }
  818. /// <summary>
  819. /// FOSB模式下的开门指令
  820. /// </summary>
  821. /// <param name="reason"></param>
  822. /// <returns></returns>
  823. public virtual bool FOSBDoorOpen(out string reason)
  824. {
  825. reason = "";
  826. return true;
  827. }
  828. /// <summary>
  829. /// FOSB模式下的关门指令
  830. /// </summary>
  831. /// <param name="reason"></param>
  832. /// <returns></returns>
  833. public virtual bool FOSBDoorClose(out string reason)
  834. {
  835. reason = "";
  836. return true;
  837. }
  838. /// <summary>
  839. /// FOSB模式下的门下移指令
  840. /// </summary>
  841. /// <param name="reason"></param>
  842. /// <returns></returns>
  843. public virtual bool FOSBDoorDown(out string reason)
  844. {
  845. reason = "";
  846. return true;
  847. }
  848. /// <summary>
  849. /// FOSB模式下的门上移指令
  850. /// </summary>
  851. /// <param name="reason"></param>
  852. /// <returns></returns>
  853. public virtual bool FOSBDoorUp(out string reason)
  854. {
  855. reason = "";
  856. return true;
  857. }
  858. public virtual bool SetIndicator(IndicatorType light, IndicatorState state)
  859. {
  860. if (LoadPortIndicatorLightMap.ContainsKey(light))
  861. {
  862. SetIndicator(LoadPortIndicatorLightMap[light], state, out string _);
  863. return true;
  864. }
  865. EV.PostWarningLog(Module, $"Not supported indicator {light}");
  866. return false;
  867. }
  868. public IndicatorState GetIndicator(IndicatorType light)
  869. {
  870. if (LoadPortIndicatorLightMap.ContainsKey(light))
  871. {
  872. return IndicatorStateFeedback[(int)LoadPortIndicatorLightMap[light]];
  873. }
  874. EV.PostWarningLog(Module, $"Not supported indicator {light}");
  875. return IndicatorState.OFF;
  876. }
  877. public virtual bool SetE84Available(out string reason)
  878. {
  879. if (_lpE84Callback != null)
  880. {
  881. _lpE84Callback.SetHoAutoControl(false);
  882. _lpE84Callback.SetHoAvailable(true);
  883. }
  884. reason = "";
  885. return true;
  886. }
  887. public virtual bool SetE84Unavailable(out string reason)
  888. {
  889. if (_lpE84Callback != null)
  890. {
  891. _lpE84Callback.SetHoAutoControl(false);
  892. _lpE84Callback.SetHoAvailable(false);
  893. }
  894. reason = "";
  895. return true;
  896. }
  897. public virtual bool SetIndicator(Indicator light, IndicatorState state, out string reason)
  898. {
  899. reason = "";
  900. return true;
  901. }
  902. public virtual bool QueryIndicator(out string reason)
  903. {
  904. reason = "";
  905. return true;
  906. }
  907. public virtual bool QueryState(out string reason)
  908. {
  909. reason = "";
  910. return true;
  911. }
  912. public virtual bool Undock(out string reason)
  913. {
  914. reason = "";
  915. return true;
  916. }
  917. public virtual bool Dock(out string reason)
  918. {
  919. reason = "";
  920. return true;
  921. }
  922. public virtual bool CloseDoor(out string reason)
  923. {
  924. reason = "";
  925. return true;
  926. }
  927. public virtual bool OpenDoor(out string reason)
  928. {
  929. reason = "";
  930. return true;
  931. }
  932. public virtual bool OpenDoorNoMap(out string reason)
  933. {
  934. reason = "";
  935. return true;
  936. }
  937. public virtual bool OpenDoorAndMap(out string reason)
  938. {
  939. reason = "";
  940. return true;
  941. }
  942. public virtual bool Unclamp(out string reason)
  943. {
  944. reason = "";
  945. return true;
  946. }
  947. public virtual bool Clamp(out string reason)
  948. {
  949. reason = "";
  950. return true;
  951. }
  952. public virtual bool Unload(out string reason)
  953. {
  954. reason = "";
  955. return true;
  956. }
  957. public virtual bool Stop(out string reason)
  958. {
  959. reason = "";
  960. return true;
  961. }
  962. public virtual bool ClearError(out string reason)
  963. {
  964. reason = "";
  965. return true;
  966. }
  967. public virtual bool Init(out string reason)
  968. {
  969. reason = "";
  970. return true;
  971. }
  972. public virtual bool Home(out string reason)
  973. {
  974. reason = "";
  975. return true;
  976. }
  977. public virtual bool ForceHome(out string reason)
  978. {
  979. reason = "";
  980. return true;
  981. }
  982. public virtual bool FOSBMode(out string reason)
  983. {
  984. reason = "";
  985. return true;
  986. }
  987. public virtual bool FOUPMode(out string reason)
  988. {
  989. reason = "";
  990. return true;
  991. }
  992. public virtual bool ReadRfId(out string reason)
  993. {
  994. reason = "";
  995. return true;
  996. }
  997. public virtual bool ReadRfid(int startpage, int length, out string reason)
  998. {
  999. reason = "";
  1000. return true;
  1001. }
  1002. public virtual bool WriteRfid(string cid, int startpage, int length, out string reason)
  1003. {
  1004. reason = "";
  1005. return true;
  1006. }
  1007. public virtual bool ChangeAccessMode(bool auto, out string reason)
  1008. {
  1009. reason = "";
  1010. return true;
  1011. }
  1012. //public virtual bool ChangeTransferState(LoadPortTransferState newState, out string reason)
  1013. //{
  1014. // reason = "";
  1015. // return true;
  1016. //}
  1017. public virtual bool SetServiceCommand(bool inService, out string reason)
  1018. {
  1019. reason = "";
  1020. return true;
  1021. }
  1022. public virtual bool GetE84HandoffActiveSignalState(E84PioPosition piopostion, E84PioSignalAtoP AtoPsignal)
  1023. {
  1024. if (_lpE84Callback == null) return false;
  1025. switch (AtoPsignal)
  1026. {
  1027. case E84PioSignalAtoP.AM_AVBL:
  1028. return _lpE84Callback.GetE84SignalState(E84SignalID.AM_AVBL);
  1029. case E84PioSignalAtoP.BUSY:
  1030. return _lpE84Callback.GetE84SignalState(E84SignalID.BUSY);
  1031. case E84PioSignalAtoP.COMPT:
  1032. return _lpE84Callback.GetE84SignalState(E84SignalID.COMPT);
  1033. case E84PioSignalAtoP.CONT:
  1034. return _lpE84Callback.GetE84SignalState(E84SignalID.CONT);
  1035. case E84PioSignalAtoP.CS_0:
  1036. return _lpE84Callback.GetE84SignalState(E84SignalID.CS_0);
  1037. case E84PioSignalAtoP.CS_1:
  1038. return _lpE84Callback.GetE84SignalState(E84SignalID.CS_1);
  1039. case E84PioSignalAtoP.TR_REQ:
  1040. return _lpE84Callback.GetE84SignalState(E84SignalID.TR_REQ);
  1041. case E84PioSignalAtoP.VALID:
  1042. return _lpE84Callback.GetE84SignalState(E84SignalID.VALID);
  1043. default:
  1044. return false;
  1045. }
  1046. }
  1047. public virtual bool GetE84HandoffPassiveSignalState(E84PioPosition piopostion, E84PioSignalPtoA PtoAsignal)
  1048. {
  1049. if (_lpE84Callback == null) return false;
  1050. switch (PtoAsignal)
  1051. {
  1052. case E84PioSignalPtoA.ES:
  1053. return _lpE84Callback.GetE84SignalState(E84SignalID.ES);
  1054. case E84PioSignalPtoA.HO_AVBL:
  1055. return _lpE84Callback.GetE84SignalState(E84SignalID.HO_AVBL);
  1056. case E84PioSignalPtoA.L_REQ:
  1057. return _lpE84Callback.GetE84SignalState(E84SignalID.L_REQ);
  1058. case E84PioSignalPtoA.READY:
  1059. return _lpE84Callback.GetE84SignalState(E84SignalID.READY);
  1060. case E84PioSignalPtoA.U_REQ:
  1061. return _lpE84Callback.GetE84SignalState(E84SignalID.U_REQ);
  1062. default:
  1063. return false;
  1064. }
  1065. }
  1066. public virtual void SetE84HandoffSignalState(E84PioPosition piopostion, E84PioSignalPtoA PtoAsignal, bool state)
  1067. {
  1068. if (_lpE84Callback == null) return;
  1069. switch (PtoAsignal)
  1070. {
  1071. case E84PioSignalPtoA.ES:
  1072. _lpE84Callback.SetE84SignalState(E84PassiveSignal.ES, state);
  1073. break;
  1074. case E84PioSignalPtoA.HO_AVBL:
  1075. _lpE84Callback.SetE84SignalState(E84PassiveSignal.HOAvbl, state);
  1076. break;
  1077. case E84PioSignalPtoA.L_REQ:
  1078. _lpE84Callback.SetE84SignalState(E84PassiveSignal.LoadReq, state);
  1079. break;
  1080. case E84PioSignalPtoA.READY:
  1081. _lpE84Callback.SetE84SignalState(E84PassiveSignal.Ready, state);
  1082. break;
  1083. case E84PioSignalPtoA.U_REQ:
  1084. _lpE84Callback.SetE84SignalState(E84PassiveSignal.UnloadReq, state);
  1085. break;
  1086. default:
  1087. break;
  1088. }
  1089. }
  1090. public virtual void Monitor()
  1091. {
  1092. _presentTrig.CLK = _isPresent;
  1093. _placetTrig.CLK = _isPlaced;
  1094. _dockTrig.CLK = _isDocked;
  1095. _clampTrig.CLK = ClampState == FoupClampState.Close;
  1096. _doorTrig.CLK = DoorState == FoupDoorState.Close;
  1097. _accessSwPressedTrig.CLK = _isAccessSwPressed;
  1098. if (_lpE84Callback != null)
  1099. {
  1100. _lpE84Callback.SetFoupStatus(_isPlaced);
  1101. _lpE84Callback.SetReadyTransferStatus((ClampState == FoupClampState.Open) &&
  1102. (DockState == FoupDockState.Undocked) && Initalized);
  1103. }
  1104. }
  1105. public virtual void Reset()
  1106. {
  1107. Error = false;
  1108. ExecuteError = false;
  1109. MapError = false;
  1110. ReadCarrierIDError = false;
  1111. if (_carrierIDReadercallback != null)
  1112. _carrierIDReadercallback.Reset();
  1113. }
  1114. public virtual void Terminate()
  1115. {
  1116. }
  1117. private List<List<string>> UpdatedWaferIdList()
  1118. {
  1119. WaferInfo[] wafers = WaferManager.Instance.GetWafers(_module);
  1120. for (int i = 0; i < wafers.Length; i++)
  1121. {
  1122. _waferId[i][1] = wafers[i].LaserMarker;
  1123. _waferId[i][2] = wafers[i].T7Code;
  1124. _waferId[i][3] = wafers[i].WaferID;
  1125. }
  1126. return _waferId;
  1127. }
  1128. public abstract bool IsEnableMapWafer();
  1129. public abstract bool IsEnableTransferWafer();
  1130. public abstract bool IsEnableTransferWafer(out string reason);
  1131. public virtual bool IsEnableLoad()
  1132. {
  1133. return _isPresent && _isPlaced;
  1134. }
  1135. private CarrierOnLPState _CarrierOnState { get; set; } = CarrierOnLPState.Unknow;
  1136. protected void ConfirmAddCarrier()
  1137. {
  1138. if (_isPresent && _isPlaced)
  1139. {
  1140. if (_CarrierOnState != CarrierOnLPState.On)
  1141. {
  1142. CarrierManager.Instance.CreateCarrier(Name);
  1143. _CarrierOnState = CarrierOnLPState.On;
  1144. SerializableDictionary<string, string> dvid = new SerializableDictionary<string, string>();
  1145. dvid[PORT_ID] = PortId;
  1146. dvid["PortID"] = PortId;
  1147. dvid[PORT_CTGRY] = PortCategory;
  1148. dvid[PORT_CARRIER_TYPE] = InfoPadCarrierType;
  1149. EV.Notify(EventCarrierArrived, dvid);
  1150. if (_lpcallback != null) _lpcallback.CarrierArrive();
  1151. if (IsAutoClampOnFoupOn)
  1152. Clamp(out _);
  1153. if (IsAutoReadCarrierID)
  1154. ReadRfId(out _);
  1155. }
  1156. IsComplete = false;
  1157. }
  1158. }
  1159. protected void ConfirmRemoveCarrier()
  1160. {
  1161. if (!_isPlaced)
  1162. {
  1163. for (int i = 0; i < _slotNumber; i++)
  1164. {
  1165. WaferManager.Instance.DeleteWafer(ModuleHelper.Converter(Name), 0, _slotNumber);
  1166. }
  1167. CarrierManager.Instance.DeleteCarrier(Name);
  1168. if (_CarrierOnState != CarrierOnLPState.Off)
  1169. {
  1170. _CarrierOnState = CarrierOnLPState.Off;
  1171. SerializableDictionary<string, string> dvid = new SerializableDictionary<string, string>();
  1172. dvid[PORT_ID] = PortId;
  1173. dvid["PortID"] = PortId;
  1174. dvid[PORT_CTGRY] = PortCategory;
  1175. dvid[CAR_ID] = _carrierId ?? "";
  1176. dvid["CarrierID"] = _carrierId ?? "";
  1177. EV.Notify(EventCarrierRemoved, dvid);
  1178. if (_lpcallback != null) _lpcallback.CarrerRemove(_carrierId);
  1179. }
  1180. IsComplete = false;
  1181. for (int i = 0; i < _slotNumber; i++)
  1182. {
  1183. WaferManager.Instance.DeleteWafer(ModuleHelper.Converter(Name), 0, _slotNumber);
  1184. }
  1185. _isMapped = false;
  1186. _carrierId = "";
  1187. }
  1188. }
  1189. public void OnSlotMapRead(string _slotMap)
  1190. {
  1191. for (int i = 0; i < _slotNumber; i++)
  1192. {
  1193. // No wafer: "0", Wafer: "1", Crossed:"2", Undefined: "?", Overlapping wafers: "W"
  1194. WaferInfo wafer = null;
  1195. switch (_slotMap[i])
  1196. {
  1197. case '0':
  1198. WaferManager.Instance.DeleteWafer(_module, i);
  1199. CarrierManager.Instance.UnregisterCarrierWafer(Name, i);
  1200. break;
  1201. case '1':
  1202. wafer = WaferManager.Instance.CreateWafer(_module, i, WaferStatus.Normal);
  1203. WaferManager.Instance.UpdateWaferSize(_module, i, GetCurrentWaferSize());
  1204. CarrierManager.Instance.RegisterCarrierWafer(Name, i, wafer);
  1205. break;
  1206. case '2':
  1207. wafer = WaferManager.Instance.CreateWafer(_module, i, WaferStatus.Crossed);
  1208. WaferManager.Instance.UpdateWaferSize(_module, i, GetCurrentWaferSize());
  1209. CarrierManager.Instance.RegisterCarrierWafer(Name, i, wafer);
  1210. //NotifyWaferError(Name, i, WaferStatus.Crossed);
  1211. break;
  1212. case 'W':
  1213. wafer = WaferManager.Instance.CreateWafer(_module, i, WaferStatus.Double);
  1214. WaferManager.Instance.UpdateWaferSize(_module, i, GetCurrentWaferSize());
  1215. CarrierManager.Instance.RegisterCarrierWafer(Name, i, wafer);
  1216. //NotifyWaferError(Name, i, WaferStatus.Double);
  1217. break;
  1218. case '?':
  1219. wafer = WaferManager.Instance.CreateWafer(_module, i, WaferStatus.Unknown);
  1220. WaferManager.Instance.UpdateWaferSize(_module, i, GetCurrentWaferSize());
  1221. CarrierManager.Instance.RegisterCarrierWafer(Name, i, wafer);
  1222. //NotifyWaferError(Name, i, WaferStatus.Unknown);
  1223. break;
  1224. }
  1225. }
  1226. SerializableDictionary<string, string> dvid = new SerializableDictionary<string, string>();
  1227. dvid[SLOT_MAP] = _slotMap;
  1228. dvid[PORT_ID] = PortId;
  1229. dvid[PORT_CTGRY] = PortCategory;
  1230. dvid[CAR_ID] = CarrierId == null ? "" : CarrierId;
  1231. dvid["CarrierID"] = CarrierId ?? "";
  1232. EV.Notify(EventSlotMapAvailable, dvid);
  1233. if (_slotMap.Contains("2"))
  1234. {
  1235. MapError = true;
  1236. Error = true;
  1237. EV.Notify(AlarmLoadPortMappingError, new SerializableDictionary<string, object> {
  1238. {"AlarmText","Mapped Crossed wafer." }
  1239. });
  1240. }
  1241. if (_slotMap.Contains("W"))
  1242. {
  1243. MapError = true;
  1244. Error = true;
  1245. EV.Notify(AlarmLoadPortMappingError, new SerializableDictionary<string, object> {
  1246. {"AlarmText","Mapped Double wafer." }
  1247. });
  1248. }
  1249. if (_slotMap.Contains("?"))
  1250. {
  1251. MapError = true;
  1252. Error = true;
  1253. EV.Notify(AlarmLoadPortMappingError, new SerializableDictionary<string, object> {
  1254. {"AlarmText","Mapped Unknown wafer." }
  1255. });
  1256. }
  1257. if (_lpcallback != null) _lpcallback.MappingComplete(_carrierId, _slotMap);
  1258. _isMapped = true;
  1259. }
  1260. private string GetSlotMap()
  1261. {
  1262. WaferInfo[] wafers = WaferManager.Instance.GetWafers(ModuleHelper.Converter(Name));
  1263. string slot = "";
  1264. for (int i = 0; i < _slotNumber && i < wafers.Length; i++)
  1265. {
  1266. slot += wafers[i].IsEmpty ? "0" : "1";
  1267. }
  1268. return slot;
  1269. }
  1270. public bool IsWaferEnableTransfer()
  1271. {
  1272. WaferInfo[] wafers = WaferManager.Instance.GetWafers(ModuleHelper.Converter(Name));
  1273. foreach (WaferInfo wafer in wafers)
  1274. {
  1275. if (wafer.Status == WaferStatus.Crossed || wafer.Status == WaferStatus.Double)
  1276. {
  1277. EV.PostWarningLog(Name, $"At least one wafer is {wafer.Status.ToString()}.");
  1278. return false;
  1279. }
  1280. }
  1281. return true;
  1282. }
  1283. /// <summary>
  1284. /// 获取LP中空缺Slot
  1285. /// </summary>
  1286. /// <returns>返回一个list, 顺序为从下到上.(0-25)</returns>
  1287. public List<int> GetEmptySlot()
  1288. {
  1289. List<int> slot = new List<int>();
  1290. if (IsMapped)
  1291. {
  1292. WaferInfo[] wafers = WaferManager.Instance.GetWafers(ModuleHelper.Converter(Name));
  1293. for (int i = 0; i < _slotNumber; i++)
  1294. {
  1295. if (wafers[i].IsEmpty)
  1296. slot.Add(i);
  1297. }
  1298. return slot;
  1299. }
  1300. else
  1301. {
  1302. return null;
  1303. }
  1304. }
  1305. public virtual bool ReadCarrierID(int offset = 0, int length = 16)
  1306. {
  1307. if (_carrierIDReadercallback != null)
  1308. return _carrierIDReadercallback.ReadCarrierID(offset, length);
  1309. return false;
  1310. }
  1311. public virtual bool WriteCarrierID(string carrierID, int offset = 0, int length = 16)
  1312. {
  1313. if (_carrierIDReadercallback != null)
  1314. return _carrierIDReadercallback.WriteCarrierID(offset, length, carrierID);
  1315. return false;
  1316. }
  1317. public void OnCarrierIdRead(string carrierId)
  1318. {
  1319. if (_isPlaced && _isPresent)
  1320. {
  1321. _carrierId = carrierId;
  1322. SerializableDictionary<string, string> dvid = new SerializableDictionary<string, string>();
  1323. dvid["CarrierID"] = carrierId ?? "";
  1324. dvid[CAR_ID] = carrierId ?? "";
  1325. dvid[PORT_ID] = PortId;
  1326. dvid["PortID"] = PortId;
  1327. dvid[PORT_CTGRY] = PortCategory;
  1328. dvid[PORT_CARRIER_TYPE] = InfoPadCarrierType;
  1329. EV.Notify(EventCarrierIdRead, dvid);
  1330. CarrierManager.Instance.UpdateCarrierId(Name, carrierId);
  1331. if (_lpcallback != null) _lpcallback.CarrierIDReadSuccess(_carrierId);
  1332. ReadCarrierIDError = false;
  1333. }
  1334. else
  1335. {
  1336. EV.PostWarningLog(Module, $"No FOUP found, carrier id {carrierId} not saved");
  1337. }
  1338. }
  1339. public void OnCarrierIdRead(ModuleName module, string name, string code)
  1340. {
  1341. OnCarrierIdRead(code);
  1342. }
  1343. public void ProceedSetCarrierID(string cid)
  1344. {
  1345. _carrierId = cid;
  1346. CarrierManager.Instance.UpdateCarrierId(Name, cid);
  1347. }
  1348. public void OnCarrierIdWrite(ModuleName module, string name, string id)
  1349. {
  1350. OnCarrierIdWrite(id);
  1351. }
  1352. public void OnCarrierIdWrite(string carrierId)
  1353. {
  1354. if (_isPlaced && _isPresent)
  1355. {
  1356. SerializableDictionary<string, string> dvid = new SerializableDictionary<string, string>();
  1357. dvid[CAR_ID] = carrierId ?? "";
  1358. dvid["CarrierID"] = carrierId ?? "";
  1359. dvid[PORT_ID] = PortId;
  1360. dvid[PORT_CTGRY] = PortCategory;
  1361. EV.Notify(EventCarrierIdWrite, dvid);
  1362. }
  1363. else
  1364. {
  1365. EV.PostWarningLog(Module, $"No FOUP found, carrier id {carrierId} not saved");
  1366. }
  1367. }
  1368. public void OnCarrierIdReadFailed(ModuleName module, string name)
  1369. {
  1370. OnCarrierIdReadFailed();
  1371. }
  1372. public void OnCarrierIdReadFailed()
  1373. {
  1374. if (_isPlaced && _isPresent)
  1375. {
  1376. _carrierId = "";
  1377. SerializableDictionary<string, string> dvid = new SerializableDictionary<string, string>();
  1378. dvid[PORT_ID] = PortId;
  1379. dvid["PortID"] = PortId;
  1380. dvid[PORT_CTGRY] = PortCategory;
  1381. EV.Notify(EventCarrierIdReadFailed, dvid);
  1382. //if (_lpcallback != null) _lpcallback.CarrierIDReadFail();
  1383. EV.Notify(AlarmCarrierIDReadError, new SerializableDictionary<string, object> {
  1384. {"AlarmText","CarrierID read fail." }
  1385. });
  1386. //ReadCarrierIDError = true;
  1387. }
  1388. else
  1389. {
  1390. EV.PostWarningLog(Module, "No FOUP found, carrier id read is not valid");
  1391. }
  1392. }
  1393. public void OnCarrierIdWriteFailed(ModuleName module, string name)
  1394. {
  1395. OnCarrierIdWriteFailed();
  1396. }
  1397. public void OnCarrierIdWriteFailed()
  1398. {
  1399. if (_isPlaced && _isPresent)
  1400. {
  1401. SerializableDictionary<string, string> dvid = new SerializableDictionary<string, string>();
  1402. dvid[PORT_ID] = PortId;
  1403. dvid[PORT_CTGRY] = PortCategory;
  1404. EV.Notify(EventCarrierIdWriteFailed, dvid);
  1405. }
  1406. else
  1407. {
  1408. EV.PostWarningLog(Module, "No FOUP found, carrier id not valid");
  1409. }
  1410. }
  1411. public void OnCarrierIdRead(ModuleName module, string carrierId)
  1412. {
  1413. OnCarrierIdRead(carrierId);
  1414. }
  1415. public void OnCarrierIdReadFailed(ModuleName module)
  1416. {
  1417. OnCarrierIdReadFailed();
  1418. }
  1419. public void OnCarrierIdWrite(ModuleName module, string carrierId)
  1420. {
  1421. OnCarrierIdWrite(carrierId);
  1422. }
  1423. public void OnCarrierIdWriteFailed(ModuleName module)
  1424. {
  1425. OnCarrierIdWriteFailed();
  1426. }
  1427. public void OnRfIdRead(ModuleName module, string rfid)
  1428. {
  1429. if (_isPlaced && _isPresent)
  1430. {
  1431. _rfid = rfid;
  1432. SerializableDictionary<string, string> dvid = new SerializableDictionary<string, string>();
  1433. dvid[CAR_ID] = _carrierId ?? "";
  1434. dvid["CarrierID"] = _carrierId ?? "";
  1435. dvid[PORT_ID] = PortId;
  1436. dvid[PORT_CTGRY] = PortCategory;
  1437. dvid[RF_ID] = rfid ?? "";
  1438. EV.Notify(EventRfIdRead, dvid);
  1439. CarrierManager.Instance.UpdateRfId(Name, rfid);
  1440. ReadCarrierIDError = false;
  1441. }
  1442. else
  1443. {
  1444. EV.PostWarningLog(Module, "No FOUP found, rf id read not valid");
  1445. }
  1446. }
  1447. public void OnRfIdReadFailed(ModuleName module)
  1448. {
  1449. if (_isPlaced && _isPresent)
  1450. {
  1451. _rfid = "";
  1452. SerializableDictionary<string, string> dvid = new SerializableDictionary<string, string>();
  1453. dvid[CAR_ID] = _carrierId ?? "";
  1454. dvid["CarrierID"] = _carrierId ?? "";
  1455. dvid[PORT_ID] = PortId;
  1456. dvid[PORT_CTGRY] = PortCategory;
  1457. EV.Notify(EventRfIdReadFailed, dvid);
  1458. }
  1459. else
  1460. {
  1461. EV.PostWarningLog(Module, "No FOUP found, rf id read is not valid");
  1462. }
  1463. }
  1464. public void OnRfIdWrite(ModuleName module, string rfid)
  1465. {
  1466. if (_isPlaced && _isPresent)
  1467. {
  1468. _rfid = rfid;
  1469. SerializableDictionary<string, string> dvid = new SerializableDictionary<string, string>();
  1470. dvid[CAR_ID] = _carrierId ?? "";
  1471. dvid["CarrierID"] = _carrierId ?? "";
  1472. dvid[PORT_ID] = PortId;
  1473. dvid[PORT_CTGRY] = PortCategory;
  1474. dvid[RF_ID] = rfid ?? "";
  1475. EV.Notify(EventRfIdWrite, dvid);
  1476. CarrierManager.Instance.UpdateRfId(Name, rfid);
  1477. }
  1478. else
  1479. {
  1480. EV.PostWarningLog(Module, "No FOUP found, rf id write not valid");
  1481. }
  1482. }
  1483. public void OnRfIdWriteFailed(ModuleName module)
  1484. {
  1485. if (_isPlaced && _isPresent)
  1486. {
  1487. _rfid = "";
  1488. SerializableDictionary<string, string> dvid = new SerializableDictionary<string, string>();
  1489. dvid[CAR_ID] = _carrierId ?? "";
  1490. dvid["CarrierID"] = _carrierId ?? "";
  1491. dvid[PORT_ID] = PortId;
  1492. dvid[PORT_CTGRY] = PortCategory;
  1493. dvid[RF_ID] = "";
  1494. //EV.PostWarningLog(Module, "Write RFID failed.");
  1495. EV.Notify(EventRfIdWriteFailed, dvid);
  1496. }
  1497. else
  1498. {
  1499. EV.PostWarningLog(Module, "No FOUP found, rf id write not valid");
  1500. }
  1501. }
  1502. public void OnLoaded()
  1503. {
  1504. var dvid = new SerializableDictionary<string, string>
  1505. {
  1506. [CAR_ID] = _carrierId ?? "",
  1507. ["CarrierID"] = _carrierId ?? "",
  1508. [PORT_ID] = PortId
  1509. };
  1510. EV.Notify(EventCarrierLoaded, dvid);
  1511. if (_lpcallback != null) _lpcallback.LoadComplete();
  1512. //}
  1513. }
  1514. public void OnUnloaded()
  1515. {
  1516. var dvid = new SerializableDictionary<string, string>();
  1517. dvid[PORT_CTGRY] = PortCategory;
  1518. dvid[PORT_ID] = PortId;
  1519. dvid[CAR_ID] = _carrierId ?? "";
  1520. dvid["CarrierID"] = _carrierId ?? "";
  1521. EV.Notify(EventCarrierUnloaded, dvid);
  1522. //}
  1523. DockState = FoupDockState.Undocked;
  1524. if (_lpcallback != null) _lpcallback.UnloadComplete();
  1525. _isMapped = false;
  1526. }
  1527. public void OnE84HandOffStart(bool isload)
  1528. {
  1529. if (_lpcallback != null) _lpcallback.OnE84HandoffStart(isload);
  1530. }
  1531. public void OnE84HandOffComplete(bool isload)
  1532. {
  1533. if (_lpcallback != null) _lpcallback.OnE84HandoffComplete(isload);
  1534. }
  1535. public void OnFosbUndock()
  1536. {
  1537. var dvid = new SerializableDictionary<string, string>();
  1538. dvid[PORT_CTGRY] = PortCategory;
  1539. dvid[PORT_ID] = PortId;
  1540. dvid[CAR_ID] = _carrierId ?? "";
  1541. dvid["CarrierID"] = _carrierId ?? "";
  1542. EV.Notify(EventCarrierUnloaded, dvid);
  1543. //}
  1544. if (_lpcallback != null) _lpcallback.UnloadComplete();
  1545. }
  1546. public void OnHomed()
  1547. {
  1548. //for (int i = 0; i < _slotNumber; i++)
  1549. //{
  1550. WaferManager.Instance.DeleteWafer(ModuleHelper.Converter(Name), 0, _slotNumber);
  1551. //}
  1552. _isMapped = false;
  1553. var dvid = new SerializableDictionary<string, object>();
  1554. dvid[PORT_CTGRY] = PortCategory;
  1555. dvid[PORT_ID] = PortId;
  1556. dvid[CAR_ID] = _carrierId ?? "";
  1557. dvid["CarrierID"] = _carrierId ?? "";
  1558. EV.Notify(EventLPHomed);
  1559. if (_lpcallback != null) _lpcallback.OnLPHomed();
  1560. }
  1561. public void OnCloseDoor()
  1562. {
  1563. for (int i = 0; i < _slotNumber; i++)
  1564. {
  1565. WaferManager.Instance.DeleteWafer(ModuleHelper.Converter(Name), 0, _slotNumber);
  1566. }
  1567. _isMapped = false;
  1568. }
  1569. public void OnError(string error = "")
  1570. {
  1571. EV.Notify($"{_module}{AlarmLoadPortError}", new SerializableDictionary<string, object> {
  1572. {"AlarmText",error }
  1573. });
  1574. if (ActionDone != null)
  1575. ActionDone(false);
  1576. }
  1577. protected void SetPresent(bool isPresent)
  1578. {
  1579. _isPresent = isPresent;
  1580. if (_isPresent)
  1581. {
  1582. //ConfirmAddCarrier();
  1583. }
  1584. else
  1585. {
  1586. //ConfirmRemoveCarrier();
  1587. }
  1588. }
  1589. protected void SetPlaced(bool isPlaced)
  1590. {
  1591. _isPlaced = isPlaced;
  1592. if (_isPlaced)
  1593. {
  1594. ConfirmAddCarrier();
  1595. }
  1596. else
  1597. {
  1598. ConfirmRemoveCarrier();
  1599. }
  1600. }
  1601. public void OnActionDone(bool result)
  1602. {
  1603. if (ActionDone != null)
  1604. ActionDone(result);
  1605. }
  1606. public virtual bool FAUnload(out string reason)
  1607. {
  1608. reason = "";
  1609. return true;
  1610. }
  1611. }
  1612. }