TDKIILoadPort.cs 29 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825
  1. using Aitex.Core.Common;
  2. using Aitex.Core.RT.Device.Unit;
  3. using Aitex.Core.RT.Event;
  4. using Aitex.Core.RT.Log;
  5. using Aitex.Core.RT.SCCore;
  6. using Aitex.Core.Util;
  7. using Aitex.Sorter.Common;
  8. using MECF.Framework.Common.Communications;
  9. using MECF.Framework.RT.EquipmentLibrary.HardwareUnits.LoadPorts.LoadPortBase;
  10. using MECF.Framework.RT.EquipmentLibrary.HardwareUnits.LoadPorts.TDK;
  11. using MECF.Framework.RT.EquipmentLibrary.HardwareUnits.Robots.RobotBase;
  12. using System;
  13. using System.Collections.Generic;
  14. using System.IO.Ports;
  15. using System.Linq;
  16. using System.Text;
  17. using System.Threading;
  18. using System.Threading.Tasks;
  19. namespace MECF.Framework.RT.EquipmentLibrary.HardwareUnits.LoadPorts.TDKII
  20. {
  21. public class TDKIILoadPort:LoadPortBaseDevice,IConnection
  22. {
  23. public TDKIILoadPort(string module, string name, string scRoot, IoTrigger[] dos = null,IoSensor[] dis=null,RobotBaseDevice robot=null, bool IsTCPconnection = false) :base(module,name,robot)
  24. {
  25. _scRoot = scRoot;
  26. _isTcpConnection = IsTCPconnection;
  27. LoadPortType = "TDKLoadPort";
  28. if (dos != null && dos.Length >= 1)
  29. {
  30. _doLoadPortOK = dos[0];
  31. }
  32. if (dis != null && dis.Length >= 1)
  33. {
  34. _diInfoPadA = dis[0];
  35. _diInfoPadA.OnSignalChanged += _diInfoPad_OnSignalChanged;
  36. }
  37. if (dis != null && dis.Length >= 2)
  38. {
  39. _diInfoPadB = dis[1];
  40. _diInfoPadB.OnSignalChanged += _diInfoPad_OnSignalChanged;
  41. }
  42. if (dis != null && dis.Length >= 3)
  43. {
  44. _diInfoPadC = dis[2];
  45. _diInfoPadC.OnSignalChanged += _diInfoPad_OnSignalChanged;
  46. }
  47. if (dis != null && dis.Length >= 4)
  48. {
  49. _diInfoPadD = dis[3];
  50. _diInfoPadB.OnSignalChanged += _diInfoPad_OnSignalChanged;
  51. }
  52. InitializeLP();
  53. }
  54. private void _diInfoPad_OnSignalChanged(IoSensor arg1, bool arg2)
  55. {
  56. if(_infoPadType == 1)
  57. InfoPadCarrierIndex = (_diInfoPadA== null || !_diInfoPadA.Value ? 0 :1) +
  58. (_diInfoPadB == null || !_diInfoPadB.Value ? 0 : 2) +
  59. (_diInfoPadC == null || !_diInfoPadC.Value ? 0 : 4) +
  60. (_diInfoPadD == null || !_diInfoPadD.Value ? 0 : 8);
  61. }
  62. private void InitializeLP()
  63. {
  64. IsMapWaferByLoadPort = true;
  65. if (_doLoadPortOK != null)
  66. _doLoadPortOK.SetTrigger(true, out _);
  67. //_deviceAddress = SC.GetValue<int>($"{Name}.DeviceAddress");
  68. _infoPadType = SC.ContainsItem($"LoadPort.{Name}.InfoPadType") ? SC.GetValue<int>($"LoadPort.{Name}.InfoPadType") : 2;
  69. //InfoPadType,0=TDK,1=Ext,2=FixedbySC
  70. if(_infoPadType == 1)
  71. {
  72. InfoPadCarrierIndex = (_diInfoPadA == null || !_diInfoPadA.Value ? 0 : 1) +
  73. (_diInfoPadB == null || !_diInfoPadB.Value ? 0 : 2) +
  74. (_diInfoPadC == null || !_diInfoPadC.Value ? 0 : 4) +
  75. (_diInfoPadD == null || !_diInfoPadD.Value ? 0 : 8);
  76. }
  77. if(_infoPadType == 2 || !IsAutoDetectCarrierType)
  78. {
  79. InfoPadCarrierIndex = SC.GetValue<int>($"LoadPort.{Name}.CarrierIndex");
  80. }
  81. _enableLog = SC.GetValue<bool>($"LoadPort.{Name}.EnableLogMessage");
  82. if (_isTcpConnection)
  83. {
  84. Address = SC.GetStringValue($"LoadPort.{Name}.Address");
  85. _tcpConnection = new TDKLoadPortTCPConnection(this, Address);
  86. _tcpConnection.EnableLog(_enableLog);
  87. if (_tcpConnection.Connect())
  88. {
  89. //LOG.Write($"Connected with {Module}.{Name} .");
  90. EV.PostInfoLog(Module, $"Connected with {Module}.{Name} .");
  91. }
  92. else
  93. {
  94. EV.PostAlarmLog(Module, $"Can't connect to {Module}.{Name}.");
  95. }
  96. }
  97. else
  98. {
  99. string portName = SC.GetStringValue($"LoadPort.{Name}.PortName");
  100. int bautRate = SC.GetValue<int>($"LoadPort.{Name}.BaudRate");
  101. int dataBits = SC.GetValue<int>($"LoadPort.{Name}.DataBits");
  102. Enum.TryParse(SC.GetStringValue($"LoadPort.{Name}.Parity"), out Parity parity);
  103. Enum.TryParse(SC.GetStringValue($"LoadPort.{Name}.StopBits"), out StopBits stopBits);
  104. _connection = new TDKLoadPortConnection(this, portName, bautRate, dataBits, parity, stopBits);
  105. _connection.EnableLog(_enableLog);
  106. int count = SC.ContainsItem("System.ComPortRetryCount") ? SC.GetValue<int>("System.ComPortRetryCount") : 5;
  107. int sleep = SC.ContainsItem("System.ComPortRetryDelayTime") ? SC.GetValue<int>("System.ComPortRetryDelayTime") : 2;
  108. if (sleep <= 0 || sleep > 10)
  109. sleep = 2;
  110. int retry = 0;
  111. do
  112. {
  113. _connection.Disconnect();
  114. Thread.Sleep(sleep * 1000);
  115. if (_connection.Connect())
  116. {
  117. //LOG.Write($"Connected with {Module}.{Name} .");
  118. EV.PostInfoLog(Module, $"Connected with {Module}.{Name} .");
  119. break;
  120. }
  121. if (count > 0 && retry++ > count)
  122. {
  123. EV.PostAlarmLog(Module, $"Can't connect to {Module}.{Name}.");
  124. break;
  125. }
  126. } while (true);
  127. }
  128. _thread = new PeriodicJob(100, OnTimer, $"{Module}.{Name} MonitorHandler", true);
  129. }
  130. private bool OnTimer()
  131. {
  132. try
  133. {
  134. if (_isTcpConnection)
  135. {
  136. _tcpConnection.MonitorTimeout();
  137. if(!_tcpConnection.IsConnected || _tcpConnection.IsCommunicationError)
  138. {
  139. lock (_locker)
  140. {
  141. _lstHandler.Clear();
  142. }
  143. _trigRetryConnect.CLK = !_tcpConnection.IsConnected;
  144. if (_trigRetryConnect.Q)
  145. {
  146. Address = SC.GetStringValue($"LoadPort.{Name}.Address");
  147. _tcpConnection = new TDKLoadPortTCPConnection(this, Address);
  148. _tcpConnection.EnableLog(_enableLog);
  149. if (!_tcpConnection.Connect())
  150. {
  151. EV.PostAlarmLog(Module, $"Can not connect with {_tcpConnection.Address}, {Module}.{Name}");
  152. }
  153. }
  154. return true;
  155. }
  156. _trigActionDone.CLK = (_lstHandler.Count == 0 && !_tcpConnection.IsBusy);
  157. if (_trigActionDone.Q)
  158. OnActionDone(null);
  159. HandlerBase handler = null;
  160. if (!_tcpConnection.IsBusy)
  161. {
  162. lock (_locker)
  163. {
  164. if (_lstHandler.Count == 0)
  165. {
  166. }
  167. if (_lstHandler.Count > 0)
  168. {
  169. handler = _lstHandler.First.Value;
  170. if (handler != null) _tcpConnection.Execute(handler);
  171. _lstHandler.RemoveFirst();
  172. }
  173. }
  174. }
  175. }
  176. else
  177. {
  178. _connection.MonitorTimeout();
  179. if (!_connection.IsConnected || _connection.IsCommunicationError)
  180. {
  181. lock (_locker)
  182. {
  183. _lstHandler.Clear();
  184. }
  185. _trigRetryConnect.CLK = !_connection.IsConnected;
  186. if (_trigRetryConnect.Q)
  187. {
  188. _connection.SetPortAddress(SC.GetStringValue($"{Name}.Address"));
  189. if (!_connection.Connect())
  190. {
  191. EV.PostAlarmLog(Module, $"Can not connect with {_connection.Address}, {Module}.{Name}");
  192. }
  193. }
  194. return true;
  195. }
  196. _trigActionDone.CLK = (_lstHandler.Count == 0 && !_connection.IsBusy);
  197. if (_trigActionDone.Q)
  198. OnActionDone(null);
  199. HandlerBase handler = null;
  200. if (!_connection.IsBusy)
  201. {
  202. lock (_locker)
  203. {
  204. if (_lstHandler.Count == 0)
  205. {
  206. }
  207. if (_lstHandler.Count > 0)
  208. {
  209. handler = _lstHandler.First.Value;
  210. if (handler != null) _connection.Execute(handler);
  211. _lstHandler.RemoveFirst();
  212. }
  213. }
  214. }
  215. }
  216. if (_infoPadType == 2)
  217. {
  218. InfoPadCarrierIndex = SC.GetValue<int>($"LoadPort.{Name}.CarrierIndex");
  219. }
  220. IsRequestFOSBMode = SC.GetValue<int>($"CarrierInfo.CarrierFosbMode{InfoPadCarrierIndex}") == 1;
  221. IsMapWaferByLoadPort = !IsRequestFOSBMode;
  222. }
  223. catch (Exception ex)
  224. {
  225. LOG.Write(ex);
  226. }
  227. return true;
  228. }
  229. public override void Monitor()
  230. {
  231. base.Monitor();
  232. try
  233. {
  234. if (_isTcpConnection)
  235. {
  236. _tcpConnection.EnableLog(_enableLog);
  237. _trigCommunicationError.CLK = _tcpConnection.IsCommunicationError;
  238. if (_trigCommunicationError.Q)
  239. {
  240. EV.PostAlarmLog(Module, $"{Module}.{Name} communication error, {_tcpConnection.LastCommunicationError}");
  241. OnError("Communicartion Error");
  242. }
  243. }
  244. else
  245. {
  246. _connection.EnableLog(_enableLog);
  247. _trigCommunicationError.CLK = _connection.IsCommunicationError;
  248. if (_trigCommunicationError.Q)
  249. {
  250. EV.PostAlarmLog(Module, $"{Module}.{Name} communication error, {_connection.LastCommunicationError}");
  251. OnError("Communicartion Error");
  252. }
  253. }
  254. }
  255. catch (Exception ex)
  256. {
  257. LOG.Write(ex);
  258. }
  259. }
  260. private R_TRIG _trigActionDone = new R_TRIG();
  261. private string _scRoot;
  262. private bool _isTcpConnection;
  263. private TDKLoadPortConnection _connection;
  264. private TDKLoadPortTCPConnection _tcpConnection;
  265. private IoTrigger _doLoadPortOK;
  266. private IoSensor _diInfoPadA;
  267. private IoSensor _diInfoPadB;
  268. private IoSensor _diInfoPadC;
  269. private IoSensor _diInfoPadD;
  270. private int _infoPadType;
  271. public int InfoPadType => _infoPadType;
  272. public TDKLoadPortConnection Connection
  273. {
  274. get => _connection;
  275. }
  276. public TDKLoadPortTCPConnection TCPConnection => _tcpConnection;
  277. private PeriodicJob _thread;
  278. private static Object _locker = new Object();
  279. private LinkedList<HandlerBase> _lstHandler = new LinkedList<HandlerBase>();
  280. private bool _enableLog = true;
  281. //private bool _commErr = false;
  282. private R_TRIG _trigError = new R_TRIG();
  283. private R_TRIG _trigWarningMessage = new R_TRIG();
  284. private R_TRIG _trigCommunicationError = new R_TRIG();
  285. private R_TRIG _trigRetryConnect = new R_TRIG();
  286. public TDKSystemStatus SystemStatus { get; set; }
  287. public TDKMode Mode { get; set; }
  288. public TDKInitPosMovement InitPosMovement { get; set; }
  289. public TDKOperationStatus OperationStatus { get; set; }
  290. public TDKContainerStatus ContainerStatus { get; set; }
  291. public TDKPosition ClampPosition { get; set; }
  292. public TDKPosition LPDoorLatchPosition { get; set; }
  293. public TDKVacummStatus VacuumStatus { get; set; }
  294. public TDKPosition LPDoorState { get; set; }
  295. public TDKWaferProtrusion WaferProtrusion { get; set; }
  296. public TDKElevatorAxisPosition ElevatorAxisPosition { get; set; }
  297. public TDKDockPosition DockPosition { get; set; }
  298. public TDKMapPosition MapperPostion { get; set; }
  299. public TDKMappingStatus MappingStatus { get; set; }
  300. public TDKModel Model { get; set; }
  301. public string Address { get; set; }
  302. public bool IsConnected => _connection.IsConnected;
  303. public bool Disconnect()
  304. {
  305. if (_isTcpConnection)
  306. return _tcpConnection.Disconnect();
  307. return _connection.Disconnect();
  308. }
  309. public void OnCarrierNotPlaced()
  310. {
  311. _isPlaced = false;
  312. ConfirmRemoveCarrier();
  313. }
  314. public void OnCarrierNotPresent()
  315. {
  316. _isPresent = false;
  317. //ConfirmRemoveCarrier();
  318. }
  319. public void OnCarrierPlaced()
  320. {
  321. _isPlaced = true;
  322. ConfirmAddCarrier();
  323. }
  324. public void OnCarrierPresent()
  325. {
  326. _isPresent = true;
  327. //ConfirmAddCarrier();
  328. }
  329. public void OnSwitchKey1()
  330. {
  331. _isAccessSwPressed = true;
  332. }
  333. public void OnSwitchKey2()
  334. {
  335. }
  336. public void OffSwitchKey1()
  337. {
  338. _isAccessSwPressed = false;
  339. }
  340. public void OffSwitchKey2()
  341. {
  342. }
  343. public bool OnEvent(out string reason)
  344. {
  345. reason = string.Empty;
  346. lock (_locker)
  347. {
  348. _lstHandler.AddLast(new TDKGetHandler(this, "STATE", null));
  349. _lstHandler.AddLast(new TDKGetHandler(this, "FSBxx", null));
  350. _lstHandler.AddLast(new TDKGetHandler(this, "LEDST", null));
  351. }
  352. return true;
  353. }
  354. private LoadportCassetteState _cassetteState = LoadportCassetteState.None;
  355. public override LoadportCassetteState CassetteState
  356. {
  357. get { return _cassetteState; }
  358. set
  359. {
  360. _cassetteState = value;
  361. }
  362. }
  363. public void SetCassetteState(LoadportCassetteState state)
  364. {
  365. _cassetteState = state;
  366. if (state == LoadportCassetteState.Normal)
  367. {
  368. if (!_isPlaced)
  369. {
  370. OnCarrierPlaced();
  371. }
  372. if (!_isPresent)
  373. {
  374. OnCarrierPresent();
  375. }
  376. }
  377. }
  378. public override WaferSize GetCurrentWaferSize()
  379. {
  380. int intwz = SC.GetValue<int>($"CarrierInfo.CarrierWaferSize{InfoPadCarrierIndex}");
  381. return (WaferSize)intwz;
  382. }
  383. public override string SpecCarrierType
  384. {
  385. get
  386. {
  387. if(_isPlaced)
  388. return SC.GetStringValue($"CarrierInfo.CarrierName{InfoPadCarrierIndex}");
  389. return "";
  390. }
  391. set => base.SpecCarrierType = value; }
  392. protected override bool fStartWrite(object[] param)
  393. {
  394. return true;
  395. }
  396. protected override bool fStartRead(object[] param)
  397. {
  398. return true;
  399. }
  400. protected override bool fStartExecute(object[] param)
  401. {
  402. try
  403. {
  404. switch(param[0].ToString())
  405. {
  406. case "SetIndicator":
  407. Indicator light = (Indicator)param[1];
  408. IndicatorState state = (IndicatorState)param[2];
  409. string[] statestr = new string[] { "","LON", "LBL", "LOF" };
  410. lock(_locker)
  411. {
  412. _lstHandler.AddLast(new TDKSetHandler(this, statestr[(int)state], $"{(int)light:D2}"));
  413. _lstHandler.AddLast(new TDKGetHandler(this, "LEDST", null));
  414. }
  415. break;
  416. case "QueryIndicator":
  417. lock (_locker)
  418. {
  419. _lstHandler.AddLast(new TDKGetHandler(this, "LEDST", null));
  420. }
  421. break;
  422. case "QueryState":
  423. lock (_locker)
  424. {
  425. _lstHandler.AddLast(new TDKGetHandler(this, "STATE", null));
  426. }
  427. break;
  428. case "Undock":
  429. lock (_locker)
  430. {
  431. _lstHandler.AddLast(new TDKMoveHandler(this, "YWAIT", null));
  432. }
  433. break;
  434. case "Dock":
  435. lock (_locker)
  436. {
  437. _lstHandler.AddLast(new TDKMoveHandler(this, "YDOOR", null));
  438. }
  439. break;
  440. case "CloseDoor":
  441. lock (_locker)
  442. {
  443. _lstHandler.AddLast(new TDKMoveHandler(this, "DORFW", null));
  444. }
  445. break;
  446. case "OpenDoor":
  447. lock (_locker)
  448. {
  449. _lstHandler.AddLast(new TDKMoveHandler(this, "DORBK", null));
  450. }
  451. break;
  452. case "Unclamp":
  453. lock (_locker)
  454. {
  455. _lstHandler.AddLast(new TDKMoveHandler(this, "PODOP", null));
  456. }
  457. break;
  458. case "Clamp":
  459. lock (_locker)
  460. {
  461. _lstHandler.AddLast(new TDKMoveHandler(this, "PODCL", null));
  462. }
  463. break;
  464. case "DoorUp":
  465. lock (_locker)
  466. {
  467. _lstHandler.AddLast(new TDKMoveHandler(this, "ZDRUP", null));
  468. }
  469. break;
  470. case "DoorDown":
  471. lock (_locker)
  472. {
  473. _lstHandler.AddLast(new TDKMoveHandler(this, "ZDRDW", null));
  474. }
  475. break;
  476. case "OpenDoorNoMap":
  477. lock (_locker)
  478. {
  479. //_lstHandler.AddLast(new TDKMoveHandler(this, "YDOOR", null));
  480. }
  481. break;
  482. case "OpenDoorAndMap":
  483. lock (_locker)
  484. {
  485. //_lstHandler.AddLast(new TDKMoveHandler(this, "YDOOR", null));
  486. }
  487. break;
  488. case "MapWafer":
  489. lock(_locker)
  490. {
  491. if (!IsMapWaferByLoadPort)
  492. {
  493. if(MapRobot!=null)
  494. return MapRobot.WaferMapping(LPModuleName, out _);
  495. return false;
  496. }
  497. if (DockPosition != TDKDockPosition.Dock)
  498. _lstHandler.AddLast(new TDKMoveHandler(this, "YDOOR", null));
  499. if(DoorState != FoupDoorState.Open)
  500. _lstHandler.AddLast(new TDKMoveHandler(this, "DORBK", null));
  501. _lstHandler.AddLast(new TDKMoveHandler(this, "MAPDO", null));
  502. _lstHandler.AddLast(new TDKGetHandler(this, "MAPRD", null));
  503. }
  504. break;
  505. }
  506. return true;
  507. }
  508. catch(Exception ex)
  509. {
  510. LOG.Write(ex);
  511. EV.PostAlarmLog(Name, $"Parameter invalid");
  512. return false;
  513. }
  514. }
  515. protected override bool fStartUnload(object[] param)
  516. {
  517. if (!_isPlaced)
  518. {
  519. EV.PostAlarmLog(Name, $"No carrier on {Name},can't unload.");
  520. return false;
  521. }
  522. if (!_isDocked)
  523. {
  524. EV.PostAlarmLog(Name, $"Carrier is not docked on {Name},can't unload.");
  525. return false;
  526. }
  527. if (IsRequestFOSBMode)
  528. {
  529. lock (_locker)
  530. {
  531. if (!IsFosbModeActual)
  532. _lstHandler.AddLast(new TDKSetHandler(this, "FSB", "ON"));
  533. _lstHandler.AddLast(new TDKMoveHandler(this, "ZDRUP", null));
  534. _lstHandler.AddLast(new TDKMoveHandler(this, "DORFW", null));
  535. _lstHandler.AddLast(new TDKMoveHandler(this, "YWAIT", null));
  536. }
  537. }
  538. else
  539. {
  540. if (IsFosbModeActual)
  541. _lstHandler.AddLast(new TDKSetHandler(this, "FSB", "OF"));
  542. if (param.Length >= 1 && param[0].ToString() == "UnloadWithMap")
  543. {
  544. _lstHandler.AddLast(new TDKMoveHandler(this, "CUDMP", null));
  545. _lstHandler.AddLast(new TDKGetHandler(this, "MAPRD", null));
  546. }
  547. if (param.Length >= 1 && param[0].ToString() == "UnloadWithoutMap")
  548. _lstHandler.AddLast(new TDKMoveHandler(this, "CULOD", null));
  549. if (param == null || param.Length == 0)
  550. {
  551. _lstHandler.AddLast(new TDKMoveHandler(this, "CUDMP", null));
  552. _lstHandler.AddLast(new TDKGetHandler(this, "MAPRD", null));
  553. }
  554. }
  555. return true;
  556. }
  557. protected override bool fStartLoad(object[] param)
  558. {
  559. if(!_isPlaced)
  560. {
  561. EV.PostAlarmLog(Name, $"No carrier on {Name},can't load.");
  562. return false;
  563. }
  564. if (_isDocked)
  565. {
  566. EV.PostAlarmLog(Name, $"Carrier is docked on {Name},can't load.");
  567. return false;
  568. }
  569. if (IsRequestFOSBMode)
  570. {
  571. lock (_locker)
  572. {
  573. if(!IsFosbModeActual)
  574. _lstHandler.AddLast(new TDKSetHandler(this, "FSB", "ON"));
  575. if(ClampPosition == TDKPosition.Open)
  576. _lstHandler.AddLast(new TDKMoveHandler(this, "PODCL", null));
  577. _lstHandler.AddLast(new TDKMoveHandler(this, "DORBK", null));
  578. _lstHandler.AddLast(new TDKMoveHandler(this, "YDOOR", null));
  579. _lstHandler.AddLast(new TDKMoveHandler(this, "ZDRDW", null));
  580. }
  581. }
  582. else
  583. {
  584. lock (_locker)
  585. {
  586. if (IsFosbModeActual)
  587. _lstHandler.AddLast(new TDKSetHandler(this, "FSB", "OF"));
  588. if (param.Length >= 1 && param[0].ToString() == "LoadWithMap")
  589. {
  590. _lstHandler.AddLast(new TDKMoveHandler(this, "CLDMP", null));
  591. _lstHandler.AddLast(new TDKGetHandler(this, "MAPRD", null));
  592. }
  593. if (param.Length >= 1 && param[0].ToString() == "LoadWithoutMap")
  594. _lstHandler.AddLast(new TDKMoveHandler(this, "CLOAD", null));
  595. if (param == null || param.Length == 0)
  596. {
  597. _lstHandler.AddLast(new TDKMoveHandler(this, "CLDMP", null));
  598. _lstHandler.AddLast(new TDKGetHandler(this, "MAPRD", null));
  599. }
  600. }
  601. }
  602. return true;
  603. }
  604. protected override bool fStartInit(object[] param)
  605. {
  606. lock (_locker)
  607. {
  608. if(param.Length >=1 && param[0].ToString() == "ForceHome")
  609. _lstHandler.AddLast(new TDKMoveHandler(this, "ABORG", null));
  610. else
  611. _lstHandler.AddLast(new TDKMoveHandler(this, "ORGSH", null));
  612. _lstHandler.AddLast(new TDKGetHandler(this, "STATE", null));
  613. _lstHandler.AddLast(new TDKGetHandler(this, "FSBxx", null));
  614. _lstHandler.AddLast(new TDKGetHandler(this, "LEDST", null));
  615. }
  616. return true;
  617. }
  618. public override bool SetIndicator(Indicator light, IndicatorState state, out string reason)
  619. {
  620. reason = "";
  621. return fStartExecute(new object[] { "SetIndicator", light, state });
  622. }
  623. protected override bool fStartReset(object[] param)
  624. {
  625. _lstHandler.Clear();
  626. if (_isTcpConnection)
  627. {
  628. if (!_tcpConnection.IsConnected)
  629. _tcpConnection.Connect();
  630. _tcpConnection.ForceClear();
  631. }
  632. else
  633. {
  634. if (!_connection.IsConnected)
  635. _connection.Connect();
  636. _connection.ForceClear();
  637. }
  638. lock (_locker)
  639. {
  640. _lstHandler.AddLast(new TDKSetHandler(this, "RESET", null));
  641. _lstHandler.AddLast(new TDKGetHandler(this, "STATE", null));
  642. _lstHandler.AddLast(new TDKGetHandler(this, "FSBxx", null));
  643. _lstHandler.AddLast(new TDKGetHandler(this, "LEDST", null));
  644. }
  645. return true;
  646. }
  647. public override void OnError(string error = "")
  648. {
  649. lock (_locker)
  650. {
  651. _lstHandler.Clear();
  652. if(_isTcpConnection)
  653. _tcpConnection.ForceClear();
  654. else
  655. _connection.ForceClear();
  656. _lstHandler.AddLast(new TDKGetHandler(this, "STATE", null));
  657. _lstHandler.AddLast(new TDKGetHandler(this, "FSBxx", null));
  658. _lstHandler.AddLast(new TDKGetHandler(this, "LEDST", null));
  659. }
  660. base.OnError(error);
  661. }
  662. }
  663. public enum TDKSystemStatus
  664. {
  665. Normal = 0x30,
  666. RecoverableError = 0x41,
  667. UnrecoverableError = 0x45,
  668. }
  669. public enum TDKMode
  670. {
  671. Online = 0x30,
  672. Teaching = 0x31,
  673. Maintenance = 0x32,
  674. }
  675. public enum TDKInitPosMovement
  676. {
  677. OperationStatus = 0x30,
  678. HomePosStatus = 0x31,
  679. LoadStatus = 0x32,
  680. }
  681. public enum TDKOperationStatus
  682. {
  683. DuringStop = 0x30,
  684. DuringOperation = 0x31,
  685. }
  686. public enum TDKContainerStatus
  687. {
  688. Absence = 0x30,
  689. NormalMount = 0x31,
  690. MountError = 0x32,
  691. }
  692. public enum TDKPosition
  693. {
  694. Open = 0x30,
  695. Close = 0x31,
  696. TBD = 0x3F
  697. }
  698. public enum TDKVacummStatus
  699. {
  700. OFF = 0x30,
  701. ON = 0x31,
  702. }
  703. public enum TDKWaferProtrusion
  704. {
  705. ShadingStatus = 0x30,
  706. LightIncidentStatus = 0x31,
  707. }
  708. public enum TDKElevatorAxisPosition
  709. {
  710. UP = 0x30,
  711. Down = 0x31,
  712. MappingStartPos = 0x32,
  713. MappingEndPos = 0x33,
  714. TBD = 0x3F,
  715. }
  716. public enum TDKDockPosition
  717. {
  718. Undock = 0x30,
  719. Dock = 0x31,
  720. TBD = 0x3F,
  721. }
  722. public enum TDKMapPosition
  723. {
  724. MeasurementPos = 0x30,
  725. WaitingPost = 0x31,
  726. TBD = 0x3F,
  727. }
  728. public enum TDKMappingStatus
  729. {
  730. NotPerformed = 0x30,
  731. NormalEnd = 0x31,
  732. ErrorStop = 0x32,
  733. }
  734. public enum TDKModel
  735. {
  736. Type1 = 0x30,
  737. Type2 = 0x31,
  738. Type3 = 0x32,
  739. Type4 = 0x33,
  740. Type5 = 0x34,
  741. }
  742. }