HAtmRobot.cs 28 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817
  1. using Aitex.Core.RT.DataCenter;
  2. using Aitex.Core.RT.Device;
  3. using Aitex.Core.RT.Event;
  4. using Aitex.Core.RT.Log;
  5. using Aitex.Core.RT.OperationCenter;
  6. using Aitex.Core.RT.SCCore;
  7. using Aitex.Core.Util;
  8. using Aitex.Sorter.Common;
  9. using MECF.Framework.Common.Communications;
  10. using MECF.Framework.Common.Equipment;
  11. using MECF.Framework.Common.SubstrateTrackings;
  12. using MECF.Framework.RT.EquipmentLibrary.HardwareUnits.Robot;
  13. using System;
  14. using System.Collections.Generic;
  15. using System.Linq;
  16. using System.Text;
  17. using System.Text.RegularExpressions;
  18. using System.Threading;
  19. using System.Threading.Tasks;
  20. namespace MECF.Framework.RT.EquipmentLibrary.HardwareUnits.Robot.HineAutomation
  21. {
  22. public class HAtmRobot : Robot
  23. {
  24. #region properties
  25. public override bool Error
  26. {
  27. get
  28. {
  29. return _exceuteErr;
  30. }
  31. }
  32. public bool IsThetaBusy { get; set; }
  33. public bool IsZBusy { get; set; }
  34. public bool IsRadialBusy { get; set; }
  35. public override bool Busy
  36. {
  37. get
  38. {
  39. return IsBusy || IsThetaBusy || IsZBusy || IsRadialBusy || (!_motionTimer.IsIdle() && _motionTimer.GetElapseTime() < _motionTime) /*|| ThetaAxisAddressPosition != _targetThetaAxisAddressPosition || ZAxisAddressPosition != _targetZAxisAddressPosition*/;
  40. }
  41. }
  42. public override bool Moving
  43. {
  44. get
  45. {
  46. return IsBusy || IsThetaBusy || IsZBusy || IsRadialBusy || (!_motionTimer.IsIdle() && _motionTimer.GetElapseTime() < _motionTime) /*|| ThetaAxisAddressPosition != _targetThetaAxisAddressPosition || ZAxisAddressPosition != _targetZAxisAddressPosition*/;
  47. }
  48. }
  49. public override bool WaferOnBlade1 => WaferPresentOnBlade1;
  50. public bool IsBusy { private get; set; }
  51. public bool IsRetract { get; set; }
  52. public bool IsUp { get; set; }
  53. public int ThetaAxisAddressPosition { get; set; }
  54. public int ZAxisAddressPosition { get; set; }
  55. public int RetractReqPos { get; set; }
  56. public int RotateReqPos { get; set; }
  57. public int ZReqPos { get; set; }
  58. public int ZActPos { get; set; }
  59. public string SlotMap { get; set; }
  60. public Dictionary<string, string> ErrorCodeReference;
  61. public R_TRIG IsRotationAxisUnreferencedTrig { get; set; }
  62. public R_TRIG IsExtensionAxisUnreferencedTrig { get; set; }
  63. public R_TRIG IsZAxisUnreferencedTrig { get; set; }
  64. public bool IsHomed => _isHomed;
  65. #endregion
  66. #region fields
  67. private HAtmConnection _connection;
  68. private string _address;
  69. private PeriodicJob _thread;
  70. private LinkedList<HandlerBase> _lstHandler = new LinkedList<HandlerBase>();
  71. private object _lockerHandlerList = new object();
  72. private R_TRIG _trigError = new R_TRIG();
  73. private R_TRIG _trigWarningMessage = new R_TRIG();
  74. private string _lastError = string.Empty;
  75. private int _errorCode;
  76. private int _targetThetaAxisAddressPosition;
  77. private int _targetZAxisAddressPosition;
  78. private HandlerBase _waferMoveHandler;
  79. private HandlerBase _homeHandler;
  80. private bool _isHomed;
  81. private bool _isSimulator;
  82. //private bool _isFirstHome = true;
  83. private bool _enableLog;
  84. private bool _isPowerUp = true;
  85. private DeviceTimer _motionTimer = new DeviceTimer();
  86. private int _motionTime = 1000;
  87. private Dictionary<string, int> _motionTimeDic;
  88. private ModuleName _lastTarget;
  89. private R_TRIG _zAxisHomeTrig = new R_TRIG();
  90. #endregion
  91. public HAtmRobot(string module)
  92. : base(module, module, module, module, "", RobotType.HAtm)
  93. {
  94. IsRetract = true;
  95. }
  96. static bool CheckAddressPort(string s)
  97. {
  98. bool isLegal;
  99. Regex regex = new Regex(@"^((2[0-4]\d|25[0-5]|[1]?\d\d?)\.){3}(2[0-4]\d|25[0-5]|[1]?\d\d?)\:([1-9]|[1-9][0-9]|[1-9][0-9][0-9]|[1-9][0-9][0-9][0-9]|[1-6][0-5][0-5][0-3][0-5])$");//CheckAddressPort
  100. Match match = regex.Match(s);
  101. if (match.Success)
  102. {
  103. isLegal = true;
  104. }
  105. else
  106. {
  107. isLegal = false;
  108. }
  109. return isLegal;
  110. }
  111. public override bool Initialize()
  112. {
  113. _address = SC.GetStringValue($"{Module}.Address");
  114. _isSimulator = SC.GetValue<bool>("System.IsSimulatorMode");
  115. _enableLog = SC.GetValue<bool>($"{Module}.EnableLogMessage");
  116. _connection = new HAtmConnection(_address);
  117. if (CheckAddressPort(_address))
  118. {
  119. if (_connection.Connect())
  120. {
  121. EV.PostInfoLog(Module, $"{Module} connected");
  122. }
  123. }
  124. else EV.PostWarningLog(Module, $"{Module} Adress is illegal");
  125. _thread = new PeriodicJob(50, OnTimer, $"{Module} MonitorHandler", true);
  126. DATA.Subscribe($"{Name}.IsHomed", () => _isHomed);
  127. DATA.Subscribe($"{Name}.IsConnected", () => _connection.IsConnected);
  128. OP.Subscribe("Robot.QueryOperationalStatus", (string cmd, object[] args) =>
  129. {
  130. QueryOperationalStatus();
  131. return true;
  132. });
  133. _motionTimeDic = new Dictionary<string, int>()
  134. {
  135. { $"{ModuleName.Cassette}.{ModuleName.PM}.Picking",4000},
  136. { $"{ModuleName.PM}.{ModuleName.PM}.Picking",1500},
  137. { $"{ModuleName.PM}.{ModuleName.Cooling}.Picking",2400},
  138. { $"{ModuleName.Cooling}.{ModuleName.Cooling}.Picking",1500},
  139. { $"{ModuleName.Cooling}.{ModuleName.PM}.Picking",2400},
  140. { $"{ModuleName.Cassette}.{ModuleName.Cooling}.Picking",2200},
  141. { $"{ModuleName.Cooling}.{ModuleName.Cassette}.Picking",2200},
  142. { $"{ModuleName.Cassette}.{ModuleName.Cassette}.Picking",1500},
  143. { $"{ModuleName.PM}.{ModuleName.Cassette}.Picking",4000},
  144. { $"{ModuleName.TMRobot}.{ModuleName.Cassette}.Picking",5000},
  145. { $"{ModuleName.TMRobot}.{ModuleName.Cooling}.Picking",3700},
  146. { $"{ModuleName.TMRobot}.{ModuleName.PM}.Picking",2200},
  147. { $"System.{ModuleName.Cassette}.Picking",5000},
  148. { $"System.{ModuleName.Cooling}.Picking",3700},
  149. { $"System.{ModuleName.PM}.Picking",2200},
  150. };
  151. ErrorCodeReference = new Dictionary<string, string>()
  152. {
  153. { "S0","Serial response timeout"},
  154. { "S1","Illegal sc interrupt"},
  155. { "S2","Parity Error"},
  156. { "S3","Input Buffer overflow"},
  157. { "C0","Command not recognized"},
  158. { "C1","Illegal Z-Axis Command Address"},
  159. { "C2","Illegal Radial Axis Command Address"},
  160. { "C3","Illegal Theta Axis Command Address"},
  161. { "C4","Illegal Pick – wafer on pan"},
  162. { "C5","Illegal Place – wafer not on pan"},
  163. { "C6","Illegal action command – error present"},
  164. { "C7","Command overrun – Hatm5.0 Busy"},
  165. { "C8","Illegal command – not in learn mode"},
  166. { "C9","Illegal Search – hardware not present"},
  167. { "CA","Illegal Fetch – hardware not present"},
  168. { "CB","Illegal Action – data not valid"},
  169. { "CC","Illegal Action – Request Queue overrun"},
  170. { "CD","Illegal Action – Overcurrent Latch Set"},
  171. { "CE","Illegal Action – Interlock Open"},
  172. { "CF","Loss of Vacuum Detect"},
  173. { "D0","Illegal Pitch"},
  174. { "D1","Illegal Offset"},
  175. { "D2","Illegal number of slots"},
  176. { "D3","Illegal rotate position"},
  177. { "D4","Illegal difference value"},
  178. { "D5","Parameter missing"},
  179. { "D6","Illegal Set Command"},
  180. { "D7","Illegal Option"},
  181. { "D8","Illegal Category"},
  182. { "D9","Illegal Bias"},
  183. { "DA","Illegal Bias Set, Z not valid"},
  184. { "DB","Invalid rotational speed data(exceeded the legal percent range)"},
  185. { "DC","Invalid z-axis speed data (exceeded the legal percent range)"},
  186. { "I0","Z requested position is out of range"},
  187. { "I1","Theta requested position is out of range"},
  188. { "I2","Radial requested position is out of range"},
  189. { "I3","Illegal Z Position"},
  190. { "I4","Illegal Theta Position"},
  191. { "I5","Illegal Data"},
  192. { "A0","Theta Axis action timeout"},
  193. { "A1","Z-Axis action timeout"},
  194. { "A2","Radial Axis action timeout"},
  195. { "A3","Theta overtravel"},
  196. { "A4","Theta Axis reference detect"},
  197. { "A5","Z-Axis reference detect"},
  198. { "A6","Function timeout"},
  199. { "A7","Loss of Retrace on Rotate"},
  200. { "A8","Cassette Interlock error"},
  201. { "A9","Overcurrent shutdown"},
  202. { "P0","Bad Checksum – Theta Parameters"},
  203. { "P1","Bad Checksum – Z Parameters"},
  204. { "P2","Bad Checksum – Radial Parameters"},
  205. { "F0","Flipper current limit activated"},
  206. { "F1","Flipper device error"},
  207. { "F2","Flipper over voltage"},
  208. { "F3","Flipper over temperature"},
  209. { "F4","Flipper continuous current limit"},
  210. { "F5","No Flipper is installed"},
  211. };
  212. IsRotationAxisUnreferencedTrig = new R_TRIG();
  213. IsExtensionAxisUnreferencedTrig = new R_TRIG();
  214. IsZAxisUnreferencedTrig = new R_TRIG();
  215. return base.Initialize();
  216. }
  217. private bool OnTimer()
  218. {
  219. try
  220. {
  221. _connection.MonitorTimeout();
  222. _connection.MonitorConnection(SC.GetValue<int>("TMRobot.ReconnectCount"), out bool retried);
  223. if (retried)
  224. {
  225. lock (_lockerHandlerList)
  226. {
  227. _lstHandler.Clear();
  228. }
  229. }
  230. if (!_connection.IsConnected || _connection.IsCommunicationError)
  231. {
  232. return true;
  233. }
  234. if (_connection.IsBusy)
  235. return true;
  236. HandlerBase handler = null;
  237. lock (_lockerHandlerList)
  238. {
  239. if (_isPowerUp)
  240. {
  241. if(SC.GetValue<bool>("TMRobot.AllCommandsHaveResponse"))
  242. _lstHandler.AddFirst(new SetCommandResponseHandler(this));
  243. _isPowerUp = false;
  244. }
  245. if (_lstHandler.Count == 0)
  246. {
  247. _lstHandler.AddLast(new QueryOperationalStatusHandler(this));
  248. _lstHandler.AddLast(new QueryAllAxisStatusHandler(this));
  249. _lstHandler.AddLast(new QueryThetaAxisStatusHandler(this));
  250. _lstHandler.AddLast(new QueryZAxisStatusHandler(this));
  251. _lstHandler.AddLast(new QueryRadialAxisStatusHandler(this));
  252. _lstHandler.AddLast(new QueryPositionHandler(this));
  253. }
  254. if (_lstHandler.Count > 0)
  255. {
  256. handler = _lstHandler.First.Value;
  257. _lstHandler.RemoveFirst();
  258. }
  259. }
  260. if (handler != null)
  261. {
  262. handler.SendText = ((HAtmHandler)handler).Package();
  263. _connection.Execute(handler);
  264. }
  265. if (_waferMoveHandler != null)
  266. {
  267. var pick = _waferMoveHandler as PickHandler;
  268. if (pick != null && WaferOnBlade1 && WaferManager.Instance.CheckHasWafer(pick.Target, pick.Slot))
  269. {
  270. WaferManager.Instance.WaferMoved(pick.Target, pick.Slot, ModuleHelper.Converter(Name), (int)Hand.Blade1);
  271. CmdBladeTarget = $"{pick.Target}.Retract";
  272. }
  273. var place = _waferMoveHandler as PlaceHandler;
  274. if (place != null && !WaferOnBlade1 && WaferManager.Instance.CheckHasWafer(ModuleHelper.Converter(Name), (int)Hand.Blade1))
  275. {
  276. WaferManager.Instance.WaferMoved(ModuleHelper.Converter(Name), (int)Hand.Blade1, place.Target, place.Slot);
  277. CmdBladeTarget = $"{place.Target}.Retract";
  278. }
  279. }
  280. if (_waferMoveHandler != null && !Moving)
  281. {
  282. _lastTarget = ((HAtmHandler)_waferMoveHandler).Target;
  283. ((HAtmHandler)_waferMoveHandler).Update();
  284. _waferMoveHandler = null;
  285. _motionTimer.Stop();
  286. }
  287. if (_homeHandler != null)
  288. {
  289. _zAxisHomeTrig.CLK = ZReqPos == 0;
  290. if(_zAxisHomeTrig.Q)//means ZAXis is homed
  291. {
  292. ChangeRobotBladeTarget();
  293. }
  294. if (!Moving)
  295. {
  296. _lastTarget = ((HAtmHandler)_homeHandler).Target;
  297. _isHomed = true;
  298. _homeHandler = null;
  299. _motionTimer.Stop();
  300. }
  301. }
  302. }
  303. catch (Exception ex)
  304. {
  305. LOG.Write(ex);
  306. }
  307. return true;
  308. }
  309. private void ChangeRobotBladeTarget()
  310. {
  311. //CmdBladeTarget = $"{ModuleHelper.Converter(RobotDevice.Name)}.Retract";
  312. int cassette = 180;
  313. int cooling = 110;
  314. int pm = 55;
  315. if(Math.Abs(RotateReqPos - cassette) < 10)
  316. {
  317. CmdBladeTarget = $"{ModuleName.Cassette}.{ModuleHelper.Converter(Name)}.Retract";
  318. return;
  319. }
  320. if (Math.Abs(RotateReqPos - cooling) < 10)
  321. {
  322. CmdBladeTarget = $"{ModuleName.Cooling}.{ModuleHelper.Converter(Name)}.Retract";
  323. return;
  324. }
  325. if (Math.Abs(RotateReqPos - pm) < 10)
  326. {
  327. CmdBladeTarget = $"{ModuleName.PM}.{ModuleHelper.Converter(Name)}.Retract";
  328. return;
  329. }
  330. if (Math.Abs(RotateReqPos) < 10)
  331. {
  332. CmdBladeTarget = $"{ModuleHelper.Converter(Name)}.{ModuleHelper.Converter(Name)}.Retract";
  333. return;
  334. }
  335. CmdBladeTarget = $"{ModuleHelper.Converter(Name)}.Retract";
  336. }
  337. public override void Monitor()
  338. {
  339. }
  340. public override void Reset()
  341. {
  342. _trigError.RST = true;
  343. _trigWarningMessage.RST = true;
  344. IsRotationAxisUnreferencedTrig.RST = true;
  345. IsExtensionAxisUnreferencedTrig.RST = true;
  346. IsZAxisUnreferencedTrig.RST = true;
  347. _connection.Reset();
  348. _exceuteErr = false;
  349. lock (_lockerHandlerList)
  350. {
  351. _lstHandler.AddFirst(new ResetHandler(this));
  352. }
  353. _motionTimer.Stop();
  354. _zAxisHomeTrig.RST = true;
  355. _isHomed = false;
  356. base.Reset();
  357. }
  358. public void SetErrorCode(int errorCode)
  359. {
  360. _errorCode = errorCode;
  361. }
  362. public void SetError(string reason)
  363. {
  364. _trigWarningMessage.CLK = true;
  365. if (_trigWarningMessage.Q)
  366. {
  367. EV.PostWarningLog(Module, $"{Module} error, {reason}");
  368. lock (_lockerHandlerList)
  369. {
  370. _lstHandler.AddFirst(new QueryErrorHandler(this));
  371. }
  372. }
  373. _exceuteErr = true;
  374. }
  375. public override void OnDataChanged(string package)
  376. {
  377. }
  378. public override bool Home(out string reason)
  379. {
  380. reason = string.Empty;
  381. var handler = new HomeHandler(this);
  382. //if (_lstHandler.Count > 0 && Moving && !_isFirstHome)
  383. //{
  384. // reason = "Robot busy, please wait or abort.";
  385. // EV.PostMessage(Name, EventEnum.DefaultWarning, string.Format("{0} {1} {2}", this.Name, handler.Name.ToString(), reason));
  386. // return false;
  387. //}
  388. SetBusy();
  389. _exceuteErr = false;
  390. _targetThetaAxisAddressPosition = 0;
  391. _targetZAxisAddressPosition = 0;
  392. ThetaAxisAddressPosition = -1;
  393. ZAxisAddressPosition = -1;
  394. lock (_lockerHandlerList)
  395. {
  396. _lstHandler.AddFirst(handler);
  397. if(SC.GetValue<bool>("TMRobot.AllCommandsHaveResponse"))
  398. _lstHandler.AddFirst(new SetCommandResponseHandler(this));
  399. }
  400. _homeHandler = handler;
  401. _isHomed = false;
  402. //_isFirstHome = false;
  403. _enableLog = SC.GetValue<bool>($"{Module}.EnableLogMessage");
  404. IsThetaBusy = true;
  405. IsZBusy = true;
  406. IsRadialBusy = true;
  407. _motionTimer.Start(0);
  408. _zAxisHomeTrig.RST = true;
  409. return true;
  410. }
  411. public bool Pick(ModuleName target, int slot, out string reason)
  412. {
  413. reason = string.Empty;
  414. var handler = new PickHandler(this, target, slot);
  415. if (_lstHandler.Count > 0 && Moving)
  416. {
  417. reason = "Robot busy, please wait or abort.";
  418. EV.PostMessage(Name, EventEnum.DefaultWarning, string.Format("{0} {1} {2}", this.Name, handler.Name.ToString(), reason));
  419. return false;
  420. }
  421. SetBusy();
  422. _targetThetaAxisAddressPosition = RobotConvertor.Chamber2ThetaAxisPosition(target);
  423. _targetZAxisAddressPosition = RobotConvertor.ChamberSlot2ZAxisPosition(target, slot);
  424. ThetaAxisAddressPosition = -1;
  425. ZAxisAddressPosition = -1;
  426. lock (_lockerHandlerList)
  427. {
  428. _lstHandler.AddFirst(handler);
  429. }
  430. _waferMoveHandler = handler;
  431. IsThetaBusy = true;
  432. IsZBusy = true;
  433. IsRadialBusy = true;
  434. _motionTimer.Start(0);
  435. if(_isSimulator)
  436. WaferPresentOnBlade1 = false;
  437. return true;
  438. }
  439. public bool Place(ModuleName target, int slot, out string reason)
  440. {
  441. reason = string.Empty;
  442. var handler = new PlaceHandler(this, target, slot);
  443. if (_lstHandler.Count > 0 && Moving)
  444. {
  445. reason = "Robot busy, please wait or abort.";
  446. EV.PostMessage(Name, EventEnum.DefaultWarning, string.Format("{0} {1} {2}", this.Name, handler.Name.ToString(), reason));
  447. return false;
  448. }
  449. SetBusy();
  450. _targetThetaAxisAddressPosition = RobotConvertor.Chamber2ThetaAxisPosition(target);
  451. _targetZAxisAddressPosition = RobotConvertor.ChamberSlot2ZAxisPosition(target, slot);
  452. ThetaAxisAddressPosition = -1;
  453. ZAxisAddressPosition = -1;
  454. lock (_lockerHandlerList)
  455. {
  456. _lstHandler.AddFirst(handler);
  457. }
  458. _waferMoveHandler = handler;
  459. IsThetaBusy = true;
  460. IsZBusy = true;
  461. IsRadialBusy = true;
  462. _motionTimer.Start(0);
  463. if (_isSimulator)
  464. WaferPresentOnBlade1 = true;
  465. return true;
  466. }
  467. public bool GotoExtend(ModuleName target, int slot, bool isPick, bool isUp, out string reason)
  468. {
  469. reason = string.Empty;
  470. var handler = new GotoHandler(this, target, slot, isPick, isUp);
  471. if (_lstHandler.Count > 0 && Moving)
  472. {
  473. reason = "Robot busy, please wait or abort.";
  474. EV.PostMessage(Name, EventEnum.DefaultWarning, string.Format("{0} {1} {2}", this.Name, handler.Name.ToString(), reason));
  475. return false;
  476. }
  477. SetBusy();
  478. _targetThetaAxisAddressPosition = RobotConvertor.Chamber2ThetaAxisPosition(target);
  479. _targetZAxisAddressPosition = RobotConvertor.ChamberSlot2ZAxisPosition(target, slot);
  480. ThetaAxisAddressPosition = -1;
  481. ZAxisAddressPosition = -1;
  482. lock (_lockerHandlerList)
  483. {
  484. _lstHandler.AddFirst(handler);
  485. }
  486. _waferMoveHandler = handler;
  487. IsThetaBusy = true;
  488. IsZBusy = true;
  489. IsRadialBusy = true;
  490. _motionTimer.Start(0);
  491. return true;
  492. }
  493. public bool ZAxisMove(ModuleName target, int slot, bool isUp, out string reason)
  494. {
  495. reason = string.Empty;
  496. var handler = new ZAxisMoveHandler(this, target, slot, isUp);
  497. if (_lstHandler.Count > 0 && Moving)
  498. {
  499. reason = "Robot busy, please wait or abort.";
  500. EV.PostMessage(Name, EventEnum.DefaultWarning, string.Format("{0} {1} {2}", this.Name, handler.Name.ToString(), reason));
  501. return false;
  502. }
  503. _targetZAxisAddressPosition = RobotConvertor.ChamberSlot2ZAxisPosition(target, slot);
  504. ZAxisAddressPosition = -1;
  505. lock (_lockerHandlerList)
  506. {
  507. _lstHandler.AddFirst(handler);
  508. }
  509. IsZBusy = true;
  510. _motionTimer.Start(0);
  511. return true;
  512. }
  513. public bool PlaceRetract(ModuleName target, int slot, out string reason)
  514. {
  515. reason = string.Empty;
  516. var handler = new PlaceRetractHandler(this, target, slot);
  517. if (_lstHandler.Count > 0 && Moving)
  518. {
  519. reason = "Robot busy, please wait or abort.";
  520. EV.PostMessage(Name, EventEnum.DefaultWarning, string.Format("{0} {1} {2}", this.Name, handler.Name.ToString(), reason));
  521. return false;
  522. }
  523. SetBusy();
  524. _targetThetaAxisAddressPosition = RobotConvertor.Chamber2ThetaAxisPosition(target);
  525. _targetZAxisAddressPosition = RobotConvertor.ChamberSlot2ZAxisPosition(target, slot);
  526. ThetaAxisAddressPosition = -1;
  527. ZAxisAddressPosition = -1;
  528. lock (_lockerHandlerList)
  529. {
  530. _lstHandler.AddFirst(handler);
  531. }
  532. _waferMoveHandler = handler;
  533. IsThetaBusy = true;
  534. IsZBusy = true;
  535. IsRadialBusy = true;
  536. _motionTimer.Start(0);
  537. return true;
  538. }
  539. public bool PickRetract(ModuleName target, int slot, bool isNeedWaferMove, out string reason)
  540. {
  541. reason = string.Empty;
  542. var handler = new PickRetractHandler(this, target, slot, isNeedWaferMove);
  543. if (_lstHandler.Count > 0 && Moving)
  544. {
  545. reason = "Robot busy, please wait or abort.";
  546. EV.PostMessage(Name, EventEnum.DefaultWarning, string.Format("{0} {1} {2}", this.Name, handler.Name.ToString(), reason));
  547. return false;
  548. }
  549. SetBusy();
  550. _targetThetaAxisAddressPosition = RobotConvertor.Chamber2ThetaAxisPosition(target);
  551. _targetZAxisAddressPosition = RobotConvertor.ChamberSlot2ZAxisPosition(target, slot);
  552. ThetaAxisAddressPosition = -1;
  553. ZAxisAddressPosition = -1;
  554. lock (_lockerHandlerList)
  555. {
  556. _lstHandler.AddFirst(handler);
  557. }
  558. _waferMoveHandler = handler;
  559. IsThetaBusy = true;
  560. IsZBusy = true;
  561. IsRadialBusy = true;
  562. _motionTimer.Start(0);
  563. return true;
  564. }
  565. public void Abort()
  566. {
  567. lock (_lockerHandlerList)
  568. {
  569. _lstHandler.AddFirst(new AbortHandler(this));
  570. }
  571. _waferMoveHandler = null;
  572. _homeHandler = null;
  573. _motionTimer.Stop();
  574. _zAxisHomeTrig.RST = true;
  575. }
  576. public void QueryAllAxisStatus()
  577. {
  578. lock (_lockerHandlerList)
  579. {
  580. _lstHandler.AddFirst(new QueryAllAxisStatusHandler(this));
  581. }
  582. }
  583. public void QueryError()
  584. {
  585. lock (_lockerHandlerList)
  586. {
  587. _lstHandler.AddFirst(new QueryErrorHandler(this));
  588. }
  589. }
  590. public void SetSpeed()
  591. {
  592. lock (_lockerHandlerList)
  593. {
  594. _lstHandler.AddFirst(new SetThetaSpeedHandler(this, SC.GetValue<int>("TMRobot.Speed"), SC.GetValue<int>("TMRobot.Speed")));
  595. _lstHandler.AddFirst(new SetReachSpeedHandler(this, SC.GetValue<int>("TMRobot.Speed"), SC.GetValue<int>("TMRobot.Speed")));
  596. }
  597. }
  598. public void QueryOperationalStatus()
  599. {
  600. lock (_lockerHandlerList)
  601. {
  602. _lstHandler.AddFirst(new QueryOperationalStatusHandler(this));
  603. }
  604. }
  605. public bool VacuumOn(out string reason)
  606. {
  607. reason = string.Empty;
  608. var handler = new VacuumOnHandler(this);
  609. //if (_lstHandler.Count > 0)
  610. //{
  611. // reason = "Robot busy, please wait or abort.";
  612. // EV.PostMessage(Name, EventEnum.DefaultWarning, string.Format("{0} {1} {2}", this.Name, handler.Name.ToString(), reason));
  613. // return false;
  614. //}
  615. lock (_lockerHandlerList)
  616. {
  617. _lstHandler.AddFirst(handler);
  618. }
  619. return true;
  620. }
  621. public bool VacuumOff(out string reason)
  622. {
  623. reason = string.Empty;
  624. var handler = new VacuumOffHandler(this);
  625. //if (_lstHandler.Count > 0)
  626. //{
  627. // reason = "Robot busy, please wait or abort.";
  628. // EV.PostMessage(Name, EventEnum.DefaultWarning, string.Format("{0} {1} {2}", this.Name, handler.Name.ToString(), reason));
  629. // return false;
  630. //}
  631. lock (_lockerHandlerList)
  632. {
  633. _lstHandler.AddFirst(handler);
  634. }
  635. return true;
  636. }
  637. public bool WaferMap(ModuleName target, out string reason)
  638. {
  639. reason = string.Empty;
  640. var handler = new WaferMapHandler(this, target);
  641. if (_lstHandler.Count > 0 && Moving)
  642. {
  643. reason = "Robot busy, please wait or abort.";
  644. EV.PostMessage(Name, EventEnum.DefaultWarning, string.Format("{0} {1} {2}", this.Name, handler.Name.ToString(), reason));
  645. return false;
  646. }
  647. SetBusy();
  648. _targetThetaAxisAddressPosition = RobotConvertor.Chamber2ThetaAxisPosition(target);
  649. ThetaAxisAddressPosition = -1;
  650. ZAxisAddressPosition = -1;
  651. lock (_lockerHandlerList)
  652. {
  653. _lstHandler.AddFirst(handler);
  654. }
  655. IsThetaBusy = true;
  656. IsZBusy = true;
  657. IsRadialBusy = true;
  658. _motionTimer.Start(0);
  659. return true;
  660. }
  661. public bool GetWaferMap(ModuleName target, out string reason)
  662. {
  663. reason = string.Empty;
  664. var handler = new QueryWaferMapHandler(this, target);
  665. SlotMap = string.Empty;
  666. lock (_lockerHandlerList)
  667. {
  668. _lstHandler.AddFirst(handler);
  669. }
  670. return true;
  671. }
  672. private void SetBusy()
  673. {
  674. //IsBusy || IsThetaBusy || IsZBusy || IsRadialBusy
  675. IsBusy = true;
  676. IsThetaBusy = true;
  677. IsZBusy = true;
  678. IsRadialBusy = true;
  679. }
  680. }
  681. }