Robot.cs 75 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Text.RegularExpressions;
  4. using Aitex.Core.Common;
  5. using Aitex.Core.RT.Log;
  6. using Aitex.Core.RT.Event;
  7. using Aitex.Core.RT.DataCenter;
  8. using Aitex.Core.Util;
  9. using Aitex.Sorter.Common;
  10. using TSC = Aitex.Sorter.Common;
  11. using Aitex.Core.RT.Device;
  12. using Aitex.Core.RT.SCCore;
  13. using MECF.Framework.Common.Equipment;
  14. using MECF.Framework.Common.SubstrateTrackings;
  15. using Aitex.Core.RT.OperationCenter;
  16. using MECF.Framework.Common.CommonData;
  17. using MECF.Framework.Common.Communications;
  18. using MECF.Framework.Common.Event;
  19. namespace MECF.Framework.RT.EquipmentLibrary.HardwareUnits.Robot
  20. {
  21. public enum RobotType
  22. {
  23. SR100,
  24. NX100,
  25. MAG7,
  26. DAIHEN,
  27. HAtm,
  28. HIRATA_R4
  29. }
  30. public class Robot : BaseDevice, IDevice, IConnection
  31. {
  32. public event Action<ModuleName, string> OnSlotMapRead;
  33. public event Action<bool> ActionDone;
  34. public string Address
  35. {
  36. get { return _addr; }
  37. }
  38. public virtual bool IsConnected
  39. {
  40. get { return _socket.IsConnected; }
  41. }
  42. public bool Disconnect()
  43. {
  44. _commErr = true;
  45. _socket.Dispose();
  46. return true;
  47. }
  48. public AlarmEventItem RobotHasError { get; set; }
  49. public AlarmEventItem RobotExecuteFail { get; set; }
  50. public AlarmEventItem RobotReceiveInvalidPackage { get; set; }
  51. public bool IsOnline
  52. {
  53. get { return _isOnline; }
  54. }
  55. public const string delimiter = "\r";
  56. private bool _isOnline;
  57. public int LastErrorCode { get; set; }
  58. public int Status { get; set; }
  59. public int ErrorCode { get; set; }
  60. public int ElapseTime { get; set; }
  61. public int Speed { get; set; }
  62. public int Rotation { get; set; }
  63. public int Extension { get; set; }
  64. public int Wrist1 { get; set; }
  65. public int Wrist2 { get; set; }
  66. public int Evevation { get; set; }
  67. public bool StateWaferOnBlade1 { get; set; }
  68. public bool StateWaferOnBlade2 { get; set; }
  69. public bool StateBlade1Gripped { get; set; }
  70. public bool StateBlade2Gripped { get; set; }
  71. public bool StateInterlock1 { get; set; }
  72. public bool StateInterlock2 { get; set; }
  73. public bool StateInterlock3 { get; set; }
  74. public bool StateInterlock4 { get; set; }
  75. public bool StateInterlock5 { get; set; }
  76. public bool StateInterlock6 { get; set; }
  77. public bool StateInterlock7 { get; set; }
  78. public bool StateInterlock8 { get; set; }
  79. public bool Swap { get; set; }
  80. public Hand PlaceBalde { get; set; }
  81. public ModuleName Blade1Target
  82. {
  83. get;
  84. set;
  85. }
  86. public ModuleName Blade2Target { get; set; }
  87. public RobotMoveInfo MoveInfo { get; set; }
  88. //naming follow PM1.A LL1.A PM2.B
  89. public string CmdBladeTarget { get; set; }
  90. //naming follow 0 1
  91. public string CmdBlade1Extend { get; set; }
  92. //naming follow 0 1
  93. public string CmdBlade2Extend { get; set; }
  94. public bool Blade1Enable
  95. {
  96. get
  97. {
  98. if (SC.ContainsItem($"{Name}.Blade1Enable"))
  99. {
  100. return SC.GetValue<bool>($"{Name}.Blade1Enable");
  101. }
  102. return SC.GetValue<bool>($"Robot.Blade1Enable");
  103. }
  104. set
  105. {
  106. if (SC.ContainsItem($"{Name}.Blade1Enable"))
  107. {
  108. SC.SetItemValue($"{Name}.Blade1Enable", value);
  109. }else if (SC.ContainsItem($"Robot.Blade1Enable"))
  110. {
  111. SC.SetItemValue($"Robot.Blade1Enable", value);
  112. }
  113. }
  114. }
  115. public bool Blade2Enable
  116. {
  117. get
  118. {
  119. if (SC.ContainsItem($"{Name}.Blade2Enable"))
  120. {
  121. return SC.GetValue<bool>($"{Name}.Blade2Enable");
  122. }
  123. return SC.GetValue<bool>($"Robot.Blade2Enable");
  124. }
  125. set
  126. {
  127. if (SC.ContainsItem($"{Name}.Blade2Enable"))
  128. {
  129. SC.SetItemValue($"{Name}.Blade2Enable", value);
  130. }
  131. else if (SC.ContainsItem($"Robot.Blade2Enable"))
  132. {
  133. SC.SetItemValue($"Robot.Blade2Enable", value);
  134. }
  135. }
  136. }
  137. public int Blade2Slots
  138. {
  139. get
  140. {
  141. if (SC.ContainsItem($"{Name}.Blade2Slots"))
  142. {
  143. return SC.GetValue<int>($"{Name}.Blade2Slots");
  144. }
  145. if (SC.ContainsItem($"Robot.Blade2Slots"))
  146. {
  147. return Math.Max(SC.GetValue<int>($"Robot.Blade2Slots"), 1);
  148. }
  149. return 1;
  150. }
  151. }
  152. public bool Initalized { get; set; }
  153. public bool Communication
  154. {
  155. get
  156. {
  157. return !_commErr;
  158. }
  159. }
  160. public virtual bool Busy
  161. {
  162. get { return _backgroundHandler != null || _foregroundHandler != null; }
  163. }
  164. public virtual bool Moving
  165. {
  166. get { return _backgroundHandler != null; }
  167. }
  168. public virtual bool Error
  169. {
  170. get
  171. {
  172. return ErrorCode > 0 || _commErr || _exceuteErr;
  173. }
  174. }
  175. public DeviceState State
  176. {
  177. get
  178. {
  179. if (!Initalized)
  180. {
  181. return DeviceState.Unknown;
  182. }
  183. if (Error)
  184. {
  185. return DeviceState.Error;
  186. }
  187. if (Busy)
  188. return DeviceState.Busy;
  189. return DeviceState.Idle;
  190. }
  191. }
  192. //public string ErrorMessage
  193. //{
  194. // get
  195. // {
  196. // return _factory.GetError(LastErrorCode);
  197. // }
  198. //}
  199. public virtual bool WaferOnBlade1 { get { return (Status & (int)StateBit.WaferOnBlade1) > 0; } }
  200. public virtual bool WaferOnBlade2 { get { return (Status & (int)StateBit.WaferOnBlade2) > 0; } }
  201. public bool WaferPresentOnBlade1 { get; set; }
  202. public bool WaferPresentOnBlade2 { get; set; }
  203. public bool WaferPresentOnBlade3 { get; set; }
  204. public Hand TransferBlade {
  205. get
  206. {
  207. if (!Blade1Enable) return Hand.Blade2;
  208. if (!Blade2Enable) return Hand.Blade1;
  209. return Hand.Both;
  210. }
  211. }
  212. protected static Object _locker = new Object();
  213. protected AsyncSocket _socket;
  214. protected IHandler _eventHandler = null;
  215. protected IHandler _backgroundHandler = null; //moving
  216. protected IHandler _foregroundHandler = null; //current handler
  217. private IRobotHandlerFactory _factory = null;
  218. private DeviceTimer _timerQuery = new DeviceTimer();
  219. //private int _queryPeriod = 5000; //ms
  220. //private bool _queryState = true;
  221. protected bool _exceuteErr = false;
  222. protected bool _commErr = false;
  223. protected string _addr;
  224. protected RobotType _type = RobotType.SR100;
  225. private string AlarmRobotError = "RobotMotionError";
  226. //Active wafer Center finder Data R
  227. public int CenterOffsetR { get; private set; }
  228. //Active wafer Center finder Data T
  229. public int CenterOffsetT { get; private set; }
  230. private int _bufferMaxSlot = 6;
  231. public int BufferMaxSlot
  232. {
  233. set
  234. {
  235. _bufferMaxSlot = value;
  236. }
  237. get
  238. {
  239. return _bufferMaxSlot;
  240. }
  241. }
  242. public Robot(string module, string name, string display, string deviceId, string address, RobotType type = RobotType.SR100)
  243. : base(module, name, display, deviceId)
  244. {
  245. _addr = address;
  246. if (!string.IsNullOrEmpty(_addr))
  247. {
  248. _socket = new AsyncSocket(address);
  249. _socket.OnDataChanged += new AsyncSocket.MessageHandler(OnDataChanged);
  250. _socket.OnErrorHappened += new AsyncSocket.ErrorHandler(OnErrorHandler);
  251. }
  252. _type = type;
  253. Initalized = false;
  254. MoveInfo = new RobotMoveInfo()
  255. {
  256. Action = RobotAction.Moving,
  257. ArmTarget = RobotArm.Both,
  258. BladeTarget = "ArmA.System",
  259. };
  260. if(module == ModuleName.CassetteRobot.ToString())
  261. WaferManager.Instance.SubscribeLocation(name, SC.GetValue<int>("System.CassetteSlotCount"));
  262. else
  263. WaferManager.Instance.SubscribeLocation(name, 1+ Blade2Slots);
  264. }
  265. public Robot(string module, string name, string address, RobotType type = RobotType.SR100, int bufferMaxSlot = 6)
  266. : this(module, name, name, name, address, type)
  267. {
  268. }
  269. public virtual bool Initialize()
  270. {
  271. switch (_type)
  272. {
  273. case RobotType.NX100:
  274. //_factory = new NX100.NX100RobotHandlerFactory(this);
  275. break;
  276. case RobotType.SR100:
  277. //_factory = new SR100.SR100RobotHandlerFactory(this);
  278. break;
  279. case RobotType.MAG7:
  280. //_factory = new MAG7.Mag7RobotHandlerFactory(this);
  281. break;
  282. //case RobotType.DAIHEN:
  283. // _factory = new Daihen.DaihenRobotHandlerFactory(this);
  284. // break;
  285. }
  286. ConnectionManager.Instance.Subscribe(Name, this);
  287. if (!string.IsNullOrEmpty(_addr))
  288. Connect();
  289. DEVICE.Register(String.Format("{0}.{1}", ModuleName.Robot.ToString(), "Init"), (out string reason, int time, object[] param) =>
  290. {
  291. bool ret = Init(out reason);
  292. if (ret)
  293. {
  294. reason = string.Format("{0} {1}", Name, "Initializing");
  295. return true;
  296. }
  297. return false;
  298. });
  299. DEVICE.Register(String.Format("{0}.{1}", ModuleName.Robot.ToString(), "Home"), (out string reason, int time, object[] param) =>
  300. {
  301. bool ret = Home(out reason);
  302. if (ret)
  303. {
  304. reason = string.Format("{0} {1}", Name, "Homing");
  305. return true;
  306. }
  307. return false;
  308. });
  309. DEVICE.Register(String.Format("{0}.{1}", ModuleName.Robot.ToString(), "RobotHome"), (out string reason, int time, object[] param) =>
  310. {
  311. bool ret = Home(out reason);
  312. if (ret)
  313. {
  314. reason = string.Format("{0} {1}", Name, "Homing");
  315. return true;
  316. }
  317. return false;
  318. });
  319. DEVICE.Register(String.Format("{0}.{1}", Name, "Reset"), (out string reason, int time, object[] param) =>
  320. {
  321. bool ret = Clear(out reason);
  322. if (ret)
  323. {
  324. reason = string.Format("{0} {1}", Name, "Reset");
  325. return true;
  326. }
  327. return false;
  328. });
  329. DEVICE.Register(String.Format("{0}.{1}", Name, "RobotReset"), (out string reason, int time, object[] param) =>
  330. {
  331. bool ret = Clear(out reason);
  332. if (ret)
  333. {
  334. reason = string.Format("{0} {1}", Name, "Reset");
  335. return true;
  336. }
  337. return false;
  338. });
  339. DEVICE.Register(String.Format("{0}.{1}", Name, "Grip"), (out string reason, int time, object[] param) =>
  340. {
  341. Hand hand = (Hand)Enum.Parse(typeof(Hand), (string)param[0], true);
  342. bool ret = Grip(hand,out reason);
  343. //bool ret = WaferMapping(ModuleName.LP1, out reason);
  344. if (ret)
  345. {
  346. reason = string.Format("{0} {1}", Name, "Grip");
  347. return true;
  348. }
  349. return false;
  350. });
  351. DEVICE.Register(String.Format("{0}.{1}", Name, "RobotGrip"), (out string reason, int time, object[] param) =>
  352. {
  353. Hand hand = (Hand)Enum.Parse(typeof(Hand), (string)param[0], true);
  354. bool ret = Grip(hand, out reason);
  355. //bool ret = WaferMapping(ModuleName.LP1, out reason);
  356. if (ret)
  357. {
  358. reason = string.Format("{0} {1}", Name, "Grip");
  359. return true;
  360. }
  361. return false;
  362. });
  363. DEVICE.Register(String.Format("{0}.{1}", Name, "Release"), (out string reason, int time, object[] param) =>
  364. {
  365. Hand hand = (Hand)Enum.Parse(typeof(Hand), (string)param[0], true);
  366. bool ret = Release(hand, out reason);
  367. //bool ret = QueryWaferMap(ModuleName.LP1, out reason);
  368. if (ret)
  369. {
  370. reason = string.Format("{0} {1}", Name, "Release");
  371. return true;
  372. }
  373. return false;
  374. });
  375. DEVICE.Register(String.Format("{0}.{1}", Name, "RobotRelease"), (out string reason, int time, object[] param) =>
  376. {
  377. Hand hand = (Hand)Enum.Parse(typeof(Hand), (string)param[0], true);
  378. bool ret = Release(hand, out reason);
  379. //bool ret = QueryWaferMap(ModuleName.LP1, out reason);
  380. if (ret)
  381. {
  382. reason = string.Format("{0} {1}", Name, "Release");
  383. return true;
  384. }
  385. return false;
  386. });
  387. DEVICE.Register(String.Format("{0}.{1}", Name, "Stop"), (out string reason, int time, object[] param) =>
  388. {
  389. bool ret = Stop(false, out reason);
  390. if (ret)
  391. {
  392. reason = string.Format("{0} {1}", Name, "Stopping");
  393. return true;
  394. }
  395. return false;
  396. });
  397. DEVICE.Register(String.Format("{0}.{1}", Name, "RobotStop"), (out string reason, int time, object[] param) =>
  398. {
  399. bool ret = Stop(false, out reason);
  400. if (ret)
  401. {
  402. reason = string.Format("{0} {1}", Name, "Stopping");
  403. return true;
  404. }
  405. return false;
  406. });
  407. DEVICE.Register(String.Format("{0}.{1}", Name, "Pick"), (out string reason, int time, object[] param) =>
  408. {
  409. ModuleName chamber = (ModuleName)Enum.Parse(typeof(ModuleName), (string)param[0], true);
  410. int slot = int.Parse((string)param[1]);
  411. Hand hand = (Hand)Enum.Parse(typeof(Hand), (string)param[2], true);
  412. bool ret = Pick(chamber, slot, hand, out reason);
  413. if (ret)
  414. {
  415. reason = string.Format("{0} {1}", Name, "Pick wafer");
  416. return true;
  417. }
  418. return false;
  419. });
  420. DEVICE.Register(String.Format("{0}.{1}", Name, "RobotPick"), (out string reason, int time, object[] param) =>
  421. {
  422. ModuleName chamber = (ModuleName)Enum.Parse(typeof(ModuleName), (string)param[0], true);
  423. int slot = int.Parse((string)param[1]);
  424. Hand hand = (Hand)Enum.Parse(typeof(Hand), (string)param[2], true);
  425. bool ret = Pick(chamber, slot, hand, out reason);
  426. if (ret)
  427. {
  428. reason = string.Format("{0} {1}", Name, "Pick wafer");
  429. return true;
  430. }
  431. return false;
  432. });
  433. DEVICE.Register(String.Format("{0}.{1}", Name, "Place"), (out string reason, int time, object[] param) =>
  434. {
  435. ModuleName chamber = (ModuleName)Enum.Parse(typeof(ModuleName), (string)param[0], true);
  436. int slot = int.Parse((string)param[1]);
  437. Hand hand = (Hand)Enum.Parse(typeof(Hand), (string)param[2], true);
  438. bool ret = Place(chamber, slot, hand, out reason);
  439. if (ret)
  440. {
  441. reason = string.Format("{0} {1}", Name, "Place wafer");
  442. return true;
  443. }
  444. return false;
  445. });
  446. DEVICE.Register(String.Format("{0}.{1}", Name, "RobotPlace"), (out string reason, int time, object[] param) =>
  447. {
  448. ModuleName chamber = (ModuleName)Enum.Parse(typeof(ModuleName), (string)param[0], true);
  449. int slot = int.Parse((string)param[1]);
  450. Hand hand = (Hand)Enum.Parse(typeof(Hand), (string)param[2], true);
  451. bool ret = Place(chamber, slot, hand, out reason);
  452. if (ret)
  453. {
  454. reason = string.Format("{0} {1}", Name, "Place wafer");
  455. return true;
  456. }
  457. return false;
  458. });
  459. DEVICE.Register(String.Format("{0}.{1}", Name, "Exchange"), (out string reason, int time, object[] param) =>
  460. {
  461. ModuleName chamber = (ModuleName)Enum.Parse(typeof(ModuleName), (string)param[0], true);
  462. int slot = int.Parse((string)param[1]);
  463. Hand hand = (Hand)Enum.Parse(typeof(Hand), (string)param[2], true);
  464. bool ret = Exchange(chamber, slot, hand, out reason);
  465. if (ret)
  466. {
  467. reason = string.Format("{0} {1}", Name, "Swap wafer");
  468. return true;
  469. }
  470. return false;
  471. });
  472. DEVICE.Register(String.Format("{0}.{1}", Name, "RobotExchange"), (out string reason, int time, object[] param) =>
  473. {
  474. ModuleName chamber = (ModuleName)Enum.Parse(typeof(ModuleName), (string)param[0], true);
  475. int slot = int.Parse((string)param[1]);
  476. Hand hand = (Hand)Enum.Parse(typeof(Hand), (string)param[2], true);
  477. bool ret = Exchange(chamber, slot, hand, out reason);
  478. if (ret)
  479. {
  480. reason = string.Format("{0} {1}", Name, "Swap wafer");
  481. return true;
  482. }
  483. return false;
  484. });
  485. DEVICE.Register(String.Format("{0}.{1}", Name, "Goto"), (out string reason, int time, object[] param) =>
  486. {
  487. ModuleName chamber = (ModuleName)Enum.Parse(typeof(ModuleName), (string)param[0], true);
  488. int slot = int.Parse((string)param[1]);
  489. Hand hand = (Hand)Enum.Parse(typeof(Hand), (string)param[2], true);
  490. Motion next = (Motion)Enum.Parse(typeof(Motion), (string)param[3], true);
  491. int x = int.Parse((string)param[4]);
  492. int y = int.Parse((string)param[5]);
  493. int z = int.Parse((string)param[6]);
  494. bool ret = Goto(chamber, slot, next, hand, x,y,z, out reason);
  495. if (ret)
  496. {
  497. reason = string.Format("{0}{1}", Name, "Goto");
  498. return true;
  499. }
  500. return false;
  501. });
  502. DEVICE.Register(String.Format("{0}.{1}", Name, "RobotGoto"), (out string reason, int time, object[] param) =>
  503. {
  504. ModuleName chamber = (ModuleName)Enum.Parse(typeof(ModuleName), (string)param[0], true);
  505. int slot = int.Parse((string)param[1]);
  506. Hand hand = (Hand)Enum.Parse(typeof(Hand), (string)param[2], true);
  507. Motion next = (Motion)Enum.Parse(typeof(Motion), (string)param[3], true);
  508. int x = int.Parse((string)param[4]);
  509. int y = int.Parse((string)param[5]);
  510. int z = int.Parse((string)param[6]);
  511. bool ret = Goto(chamber, slot, next, hand, x, y, z, out reason);
  512. if (ret)
  513. {
  514. reason = string.Format("{0}{1}", Name, "Goto");
  515. return true;
  516. }
  517. return false;
  518. });
  519. DEVICE.Register(String.Format("{0}.{1}", Name, "BladeEnable"), (out string reason, int time, object[] param) =>
  520. {
  521. Hand hand = (Hand)Enum.Parse(typeof(Hand), (string)param[0], true);
  522. bool bEnable = bool.Parse((string)param[1]);
  523. bool ret = Enable(hand, bEnable, out reason);
  524. if (ret)
  525. {
  526. reason = string.Format("{0}{1}", Name, "Disable robot arm");
  527. return true;
  528. }
  529. return false;
  530. });
  531. DEVICE.Register(String.Format("{0}.{1}", Name, "RobotBladeEnable"), (out string reason, int time, object[] param) =>
  532. {
  533. Hand hand = (Hand)Enum.Parse(typeof(Hand), (string)param[0], true);
  534. bool bEnable = bool.Parse((string)param[1]);
  535. bool ret = Enable(hand, bEnable, out reason);
  536. if (ret)
  537. {
  538. reason = string.Format("{0}{1}", Name, "Disable robot arm");
  539. return true;
  540. }
  541. return false;
  542. });
  543. DATA.Subscribe($"{Name}.IsConnected", () => _socket == null ? false : _socket.IsConnected);
  544. DATA.Subscribe($"{Name}.Address", () => Address);
  545. OP.Subscribe($"{Name}.Reconnect", (string cmd, object[] args) =>
  546. {
  547. return Connect();
  548. });
  549. OP.Subscribe($"{Name}.TestRobotPosition", (string cmd, object[] param) =>
  550. {
  551. //int setValue = 0;
  552. Hand _hand = Hand.Blade1;
  553. Axis axis;
  554. if (param == null || param.Length < 2) return false;
  555. int moveValue = (int)(double.Parse(param[1].ToString()));
  556. switch (param[0].ToString())
  557. {
  558. case "TestRobotUp":
  559. axis = Axis.Z;
  560. break;
  561. case "TestRobotDown":
  562. moveValue = -moveValue;
  563. axis = Axis.Z;
  564. break;
  565. case "TestRobotArmLeft":
  566. moveValue = -moveValue;
  567. axis = Axis.S;// Axis.H;//H1
  568. break;
  569. case "TestRobotArmRight":
  570. axis = Axis.S;
  571. break;
  572. case "TestRobotArmUp":
  573. axis = Axis.A;// Axis.I;//H2
  574. break;
  575. case "TestRobotArmDown":
  576. moveValue = -moveValue;
  577. axis = Axis.A;
  578. break;
  579. case "TestRobotBlade1Left":
  580. _hand = Hand.Blade1;
  581. axis = Axis.H;
  582. break;
  583. case "TestRobotBlade1Right":
  584. moveValue = -moveValue;
  585. _hand = Hand.Blade1;
  586. axis = Axis.H;//TH
  587. break;
  588. case "TestRobotBlade2Left":
  589. _hand = Hand.Blade2;
  590. axis = Axis.I;
  591. break;
  592. case "TestRobotBlade2Right":
  593. moveValue = -moveValue;
  594. _hand = Hand.Blade2;
  595. axis = Axis.I;
  596. break;
  597. default:
  598. axis = Axis.A;
  599. break;
  600. }
  601. string reason;
  602. bool ret = PositionAdjustment(axis,_hand, moveValue, out reason);
  603. if (ret)
  604. {
  605. reason = string.Format("{0}{1}", Name, reason);
  606. return true;
  607. }
  608. return false;
  609. });
  610. OP.Subscribe($"{Name}.QueryPosition", (string cmd, object[] args) =>
  611. {
  612. string reason;
  613. bool ret = QueryPosition(out reason);
  614. if (ret)
  615. {
  616. reason = string.Format("{0}.QueryPosition,{1}", Name, reason);
  617. return true;
  618. }
  619. return false;
  620. });
  621. DATA.Subscribe($"{Name}.State", () => State);
  622. DATA.Subscribe($"{Name}.Busy", () => Busy);
  623. DATA.Subscribe($"{Name}.ErrorCode", () => ErrorCode);
  624. DATA.Subscribe($"{Name}.Blade1Target", () => Blade1Target);
  625. DATA.Subscribe($"{Name}.Blade2Target", () => Blade2Target);
  626. DATA.Subscribe($"{Name}.Blade1Enable", () => Blade1Enable);
  627. DATA.Subscribe($"{Name}.Blade2Enable", () => Blade2Enable);
  628. DATA.Subscribe($"{Name}.Swap", () => Swap);
  629. DATA.Subscribe($"{Name}.PlaceBalde", () => PlaceBalde);
  630. DATA.Subscribe($"{Name}.Speed", () => Speed);
  631. DATA.Subscribe($"{Name}.RobotSpeed", () => Speed.ToString());
  632. DATA.Subscribe($"{Name}.RobotState", () => State.ToString());
  633. DATA.Subscribe($"{Name}.Rotation", () => Rotation);
  634. DATA.Subscribe($"{Name}.Extension", () => Extension);
  635. DATA.Subscribe($"{Name}.Wrist1", () => Wrist1);
  636. DATA.Subscribe($"{Name}.Wrist2", () => Wrist2);
  637. DATA.Subscribe($"{Name}.Evevation", () => Evevation);
  638. DATA.Subscribe($"{Name}.CmdBladeTarget", () => CmdBladeTarget);
  639. DATA.Subscribe($"{Name}.CmdBlade1Extend", () => CmdBlade1Extend);
  640. DATA.Subscribe($"{Name}.CmdBlade2Extend", () => CmdBlade2Extend);
  641. DATA.Subscribe($"{Name}.RobotMoveInfo", () => MoveInfo);
  642. DATA.Subscribe($"{Name}.RobotBusy", () => Busy);
  643. DATA.Subscribe($"{Name}.RobotError", () => ErrorCode);
  644. DATA.Subscribe($"{Name}.RobotBlade1Traget", () => Blade1Target);
  645. DATA.Subscribe($"{Name}.RobotBlade2Traget", () => Blade2Target);
  646. DATA.Subscribe($"{Name}.RobotBlade1Enabled", () => Blade1Enable);
  647. DATA.Subscribe($"{Name}.RobotBlade2Enabled", () => Blade2Enable);
  648. DATA.Subscribe($"{Name}.RobotSwap", () => Swap);
  649. DATA.Subscribe($"{Name}.RobotSwapPlaceBlade", () => PlaceBalde);
  650. DATA.Subscribe($"{Name}.RobotPosRotationAxis", () => Rotation);
  651. DATA.Subscribe($"{Name}.RobotPosExtensionAxis", () => Extension);
  652. DATA.Subscribe($"{Name}.RobotPosWrist1Axis", () => Wrist1);
  653. DATA.Subscribe($"{Name}.RobotPosWrist2Axis", () => Wrist2);
  654. DATA.Subscribe($"{Name}.RobotPosEvevationAxis", () => Evevation);
  655. DATA.Subscribe($"{Name}.CenterOffsetR", () => CenterOffsetR);
  656. DATA.Subscribe($"{Name}.CenterOffsetT", () => CenterOffsetT);
  657. DATA.Subscribe($"{Name}.CommunicationStatus", () => _socket == null ? false : _socket.IsConnected);
  658. DATA.Subscribe($"{Name}.IsOnline", () => _isOnline);
  659. EV.Subscribe(new EventItem(60014,"Event", AlarmRobotError, "Robot error", EventLevel.Alarm, Aitex.Core.RT.Event.EventType.HostNotification));
  660. Reset();
  661. string str = string.Empty;
  662. if(_factory != null)
  663. _eventHandler = _factory.Event();
  664. return true;
  665. }
  666. public virtual void Terminate()
  667. {
  668. if (SC.ContainsItem("Robot.CloseSocketOnShutDown") && SC.GetValue<bool>("Robot.CloseSocketOnShutDown"))
  669. {
  670. LOG.Write($"Robot {Name} termination process: close socket");
  671. _socket.Dispose();
  672. }
  673. }
  674. public virtual void Monitor()
  675. {
  676. }
  677. public virtual void Reset()
  678. {
  679. if (Error)
  680. {
  681. lock (_locker)
  682. {
  683. _foregroundHandler = null;
  684. _backgroundHandler = null;
  685. }
  686. }
  687. _exceuteErr = false;
  688. if (_commErr)
  689. {
  690. Connect();
  691. }
  692. Swap = false;
  693. }
  694. public void SetOnline(bool online)
  695. {
  696. _isOnline = online;
  697. }
  698. public bool Enable(Hand hand, bool bEnable, out string reason)
  699. {
  700. reason = string.Empty;
  701. if (hand == Hand.Blade1)
  702. {
  703. Blade2Enable = bEnable;
  704. }
  705. else if (hand == Hand.Blade2)
  706. {
  707. Blade2Enable = bEnable;
  708. }
  709. else
  710. {
  711. reason = "Can't disable all blade";
  712. return false;
  713. }
  714. return true;
  715. }
  716. public virtual bool Connect()
  717. {
  718. _commErr = false;
  719. _socket.Connect(this._addr);
  720. return true;
  721. }
  722. #region Command
  723. public virtual bool Init(out string reason)
  724. {
  725. lock (_locker)
  726. {
  727. _foregroundHandler = null;
  728. _backgroundHandler = null;
  729. }
  730. reason = string.Empty;
  731. return execute(_factory.Init(), out reason);
  732. }
  733. public virtual bool Home(out string reason)
  734. {
  735. lock (_locker)
  736. {
  737. _foregroundHandler = null;
  738. _backgroundHandler = null;
  739. }
  740. reason = string.Empty;
  741. return execute(_factory.Home(), out reason);
  742. }
  743. public virtual bool ArmHome(out string reason)
  744. {
  745. lock (_locker)
  746. {
  747. _foregroundHandler = null;
  748. _backgroundHandler = null;
  749. }
  750. reason = string.Empty;
  751. return execute(_factory.ArmHome(), out reason);
  752. }
  753. public virtual bool Grip(Hand hand,out string reason)
  754. {
  755. reason = string.Empty;
  756. return execute(_factory.Grip(hand), out reason);
  757. }
  758. public virtual bool Release(Hand hand, out string reason)
  759. {
  760. reason = string.Empty;
  761. return execute(_factory.Release(hand), out reason);
  762. }
  763. public virtual bool WaferMapping(ModuleName loadport, out string reason)
  764. {
  765. reason = string.Empty;
  766. return execute(_factory.WaferMapping(loadport), out reason);
  767. }
  768. public virtual bool QueryWaferMap(ModuleName loadport, out string reason)
  769. {
  770. reason = string.Empty;
  771. return execute(_factory.QueryWaferMap(loadport), out reason);
  772. }
  773. public virtual bool QueryState(out string reason)
  774. {
  775. reason = string.Empty;
  776. return execute(_factory.QueryState(), out reason);
  777. }
  778. public virtual bool QueryPosition(out string reason)
  779. {
  780. reason = string.Empty;
  781. return execute(_factory.QueryPosition(), out reason);
  782. }
  783. public virtual bool Clear(out string reason)
  784. {
  785. reason = string.Empty;
  786. return execute(_factory.Clear(), out reason);
  787. }
  788. public virtual bool Stop(bool isEmergency, out string reason)
  789. {
  790. reason = string.Empty;
  791. lock (_locker)
  792. {
  793. _foregroundHandler = null;
  794. _backgroundHandler = null;
  795. }
  796. return execute(_factory.Stop(isEmergency), out reason);
  797. }
  798. public virtual bool Resume( out string reason)
  799. {
  800. reason = string.Empty;
  801. return execute(_factory.Resume(), out reason);
  802. }
  803. public virtual bool SetSpeed(int speed, out string reason)
  804. {
  805. reason = string.Empty;
  806. return execute(_factory.SetSpeed(speed), out reason);
  807. }
  808. public virtual bool SetCommunication( out string reason)
  809. {
  810. lock (_locker)
  811. {
  812. _foregroundHandler = null;
  813. _backgroundHandler = null;
  814. }
  815. reason = string.Empty;
  816. return execute(_factory.SetCommunication(), out reason);
  817. }
  818. public virtual bool SetLoad(Hand hand, out string reason)
  819. {
  820. lock (_locker)
  821. {
  822. _foregroundHandler = null;
  823. _backgroundHandler = null;
  824. }
  825. reason = string.Empty;
  826. return execute(_factory.SetLoad(hand), out reason);
  827. }
  828. public virtual bool CheckLoad(ModuleName chamber, int slot, out string reason)
  829. {
  830. reason = string.Empty;
  831. return execute(_factory.CheckLoad(chamber, slot), out reason);
  832. }
  833. public virtual bool CheckLoad(Hand hand, out string reason)
  834. {
  835. reason = string.Empty;
  836. return execute(_factory.CheckLoad(hand), out reason);
  837. }
  838. public virtual bool RequestWaferAWCData(out string reason)
  839. {
  840. reason = string.Empty;
  841. return execute(_factory.RequestAWCData(), out reason);
  842. }
  843. public virtual bool RequestWaferPresent(Hand hand, out string reason)
  844. {
  845. reason = string.Empty;
  846. return execute(_factory.RequestWaferPresent(hand), out reason);
  847. }
  848. public virtual bool RequestWaferPresent( out string reason)
  849. {
  850. reason = string.Empty;
  851. return execute(_factory.RequestWaferPresent(), out reason);
  852. }
  853. public virtual bool Goto(ModuleName chamber, int slot, Motion motion,Hand hand, int x, int y, int z,out string reason)
  854. {
  855. reason = string.Empty;
  856. if (chamber == ModuleName.Robot)
  857. {
  858. reason = string.Format("Pick invalid parameter, chamber is {0}, slot is {1}", chamber.ToString(), slot);
  859. return false;
  860. }
  861. if (ModuleHelper.IsLoadPort(chamber))
  862. {
  863. if (hand == Hand.Both)
  864. {
  865. if (!checkslot(0, 25 - Blade2Slots, slot)) //0-20 | 20,21,22,23,24
  866. {
  867. reason = string.Format("Pick invalid parameter,double hand, chamber is {0}, slot is {1}", chamber.ToString(), slot);
  868. return false;
  869. }
  870. }
  871. else if(hand == Hand.Blade2)
  872. {
  873. if (!checkslot(0, 25 - Blade2Slots + 1, slot)) //0 - 21| 21,22,23,24
  874. {
  875. reason = string.Format("Pick invalid parameter,pick, chamber is {0}, slot is {1}", chamber.ToString(), slot);
  876. return false;
  877. }
  878. }
  879. else
  880. {
  881. if (!checkslot(0, 25, slot))
  882. {
  883. reason = string.Format("Pick invalid parameter,pick, chamber is {0}, slot is {1}", chamber.ToString(), slot);
  884. return false;
  885. }
  886. }
  887. }
  888. else
  889. {
  890. if (hand == Hand.Both)
  891. {
  892. reason = string.Format("Pick invalid parameter, double pick,chamber is {0}, slot is {1}", chamber.ToString(), slot);
  893. return false;
  894. }
  895. }
  896. return execute(_factory.Goto( chamber, slot, motion, hand, x,y,z), out reason);
  897. }
  898. public virtual bool MoveTo(ModuleName chamber, int slot, Hand hand, bool isPick, int x, int y, int z,out string reason)
  899. {
  900. reason = string.Empty;
  901. if (chamber == ModuleName.Robot)
  902. {
  903. reason = string.Format("Pick invalid parameter, chamber is {0}, slot is {1}", chamber.ToString(), slot);
  904. return false;
  905. }
  906. if (ModuleHelper.IsLoadPort(chamber))
  907. {
  908. if (hand == Hand.Both)
  909. {
  910. if (!checkslot(0, 25 - Blade2Slots, slot)) //0-20 | 20,21,22,23,24
  911. {
  912. reason = string.Format("Pick invalid parameter,double hand, chamber is {0}, slot is {1}", chamber.ToString(), slot);
  913. return false;
  914. }
  915. }
  916. else if(hand == Hand.Blade2)
  917. {
  918. if (!checkslot(0, 25 - Blade2Slots + 1, slot)) //0 - 21| 21,22,23,24
  919. {
  920. reason = string.Format("Pick invalid parameter,pick, chamber is {0}, slot is {1}", chamber.ToString(), slot);
  921. return false;
  922. }
  923. }
  924. else
  925. {
  926. if (!checkslot(0, 25, slot))
  927. {
  928. reason = string.Format("Pick invalid parameter,pick, chamber is {0}, slot is {1}", chamber.ToString(), slot);
  929. return false;
  930. }
  931. }
  932. }
  933. else
  934. {
  935. if (hand == Hand.Both)
  936. {
  937. reason = string.Format("Pick invalid parameter, double pick,chamber is {0}, slot is {1}", chamber.ToString(), slot);
  938. return false;
  939. }
  940. }
  941. return execute(_factory.MoveTo( chamber, slot, hand, isPick, x,y,z), out reason);
  942. }
  943. public virtual bool Extend(ModuleName chamber, int slot, Hand hand, out string reason)
  944. {
  945. reason = string.Empty;
  946. if (chamber == ModuleName.Robot)
  947. {
  948. reason = string.Format("Extend invalid parameter, chamber is {0}, slot is {1}", chamber.ToString(), slot);
  949. return false;
  950. }
  951. if (ModuleHelper.IsLoadPort(chamber))
  952. {
  953. if (hand == Hand.Both)
  954. {
  955. if (!checkslot(0, 25 - Blade2Slots, slot)) //0-20 | 20,21,22,23,24
  956. {
  957. reason = string.Format("Extend invalid parameter,double hand, chamber is {0}, slot is {1}", chamber.ToString(), slot);
  958. return false;
  959. }
  960. }
  961. else if (hand == Hand.Blade2)
  962. {
  963. if (!checkslot(0, 25 - Blade2Slots + 1, slot)) //0 - 21| 21,22,23,24
  964. {
  965. reason = string.Format("Extend invalid parameter,pick, chamber is {0}, slot is {1}", chamber.ToString(), slot);
  966. return false;
  967. }
  968. }
  969. else
  970. {
  971. if (!checkslot(0, 25, slot))
  972. {
  973. reason = string.Format("Extend invalid parameter,pick, chamber is {0}, slot is {1}", chamber.ToString(), slot);
  974. return false;
  975. }
  976. }
  977. }
  978. else
  979. {
  980. if (hand == Hand.Both)
  981. {
  982. reason = string.Format("Extend invalid parameter, double pick,chamber is {0}, slot is {1}", chamber.ToString(), slot);
  983. return false;
  984. }
  985. }
  986. return execute(_factory.Extend(chamber, slot, hand), out reason);
  987. }
  988. public virtual bool Retract(ModuleName chamber, int slot, Hand hand, out string reason)
  989. {
  990. reason = string.Empty;
  991. if (chamber == ModuleName.Robot)
  992. {
  993. reason = string.Format("Retract invalid parameter, chamber is {0}, slot is {1}", chamber.ToString(), slot);
  994. return false;
  995. }
  996. if (ModuleHelper.IsLoadPort(chamber))
  997. {
  998. if (hand == Hand.Both)
  999. {
  1000. if (!checkslot(0, 25 - Blade2Slots, slot)) //0-20 | 20,21,22,23,24
  1001. {
  1002. reason = string.Format("Retract invalid parameter,double hand, chamber is {0}, slot is {1}", chamber.ToString(), slot);
  1003. return false;
  1004. }
  1005. }
  1006. else if (hand == Hand.Blade2)
  1007. {
  1008. if (!checkslot(0, 25 - Blade2Slots + 1, slot)) //0 - 21| 21,22,23,24
  1009. {
  1010. reason = string.Format("Retract invalid parameter,pick, chamber is {0}, slot is {1}", chamber.ToString(), slot);
  1011. return false;
  1012. }
  1013. }
  1014. else
  1015. {
  1016. if (!checkslot(0, 25, slot))
  1017. {
  1018. reason = string.Format("Retract invalid parameter,pick, chamber is {0}, slot is {1}", chamber.ToString(), slot);
  1019. return false;
  1020. }
  1021. }
  1022. }
  1023. else
  1024. {
  1025. if (hand == Hand.Both)
  1026. {
  1027. reason = string.Format("Retract invalid parameter, double pick,chamber is {0}, slot is {1}", chamber.ToString(), slot);
  1028. return false;
  1029. }
  1030. }
  1031. return execute(_factory.Retract(chamber, slot, hand), out reason);
  1032. }
  1033. public virtual bool PickExtend(ModuleName chamber, int slot, Hand hand, out string reason)
  1034. {
  1035. reason = string.Empty;
  1036. if (chamber.ToString() == Name || chamber == ModuleName.System || ModuleHelper.IsLoadPort(chamber) || ModuleHelper.IsBuffer(chamber))
  1037. {
  1038. reason = $"Pick extend target not support, chamber is {chamber.ToString()}, slot is {slot}";
  1039. return false;
  1040. }
  1041. if (hand == Hand.Both)
  1042. {
  1043. reason = string.Format("Pick extend invalid parameter, do not support double arm extend ,chamber is {0}, slot is {1}", chamber.ToString(), slot);
  1044. return false;
  1045. }
  1046. return execute(_factory.PickExtend(chamber, slot, hand), out reason);
  1047. }
  1048. public virtual bool PickRetract(ModuleName chamber, int slot, Hand hand, out string reason)
  1049. {
  1050. reason = string.Empty;
  1051. if (chamber.ToString() == Name || chamber == ModuleName.System || ModuleHelper.IsLoadPort(chamber) || ModuleHelper.IsBuffer(chamber))
  1052. {
  1053. reason = $"Pick retract target not support, chamber is {chamber.ToString()}, slot is {slot}";
  1054. return false;
  1055. }
  1056. if (hand == Hand.Both)
  1057. {
  1058. reason = string.Format("Pick retract invalid parameter, do not support double arm retract ,chamber is {0}, slot is {1}", chamber.ToString(), slot);
  1059. return false;
  1060. }
  1061. return execute(_factory.PickRetract(chamber, slot, hand), out reason);
  1062. }
  1063. public virtual bool Pick(ModuleName chamber, int slot, Hand hand, out string reason)
  1064. {
  1065. reason = string.Empty;
  1066. if (chamber == ModuleName.Robot)
  1067. {
  1068. reason = string.Format("Pick invalid parameter, chamber is {0}, slot is {1}", chamber.ToString(), slot);
  1069. return false;
  1070. }
  1071. if (ModuleHelper.IsLoadPort(chamber))
  1072. {
  1073. if (hand == Hand.Both)
  1074. {
  1075. if (!checkslot(0, 25 - Blade2Slots, slot)) //0-20 | 20,21,22,23,24
  1076. {
  1077. reason = string.Format("Pick invalid parameter,double hand, chamber is {0}, slot is {1}", chamber.ToString(), slot);
  1078. return false;
  1079. }
  1080. }
  1081. else if (hand == Hand.Blade2)
  1082. {
  1083. if (!checkslot(0, 25 - Blade2Slots + 1, slot)) //0 - 21| 21,22,23,24
  1084. {
  1085. reason = string.Format("Pick invalid parameter,pick, chamber is {0}, slot is {1}", chamber.ToString(), slot);
  1086. return false;
  1087. }
  1088. }
  1089. else
  1090. {
  1091. if (!checkslot(0, 25, slot))
  1092. {
  1093. reason = string.Format("Pick invalid parameter,pick, chamber is {0}, slot is {1}", chamber.ToString(), slot);
  1094. return false;
  1095. }
  1096. }
  1097. }
  1098. else if(ModuleHelper.IsBuffer(chamber))
  1099. {
  1100. if (hand == Hand.Both)
  1101. {
  1102. if (!checkslot(0, _bufferMaxSlot - Blade2Slots, slot)) //0-20 | 20,21,22,23,24
  1103. {
  1104. reason = string.Format("Pick invalid parameter,double hand, chamber is {0}, slot is {1}", chamber.ToString(), slot);
  1105. return false;
  1106. }
  1107. }
  1108. else if (hand == Hand.Blade2)
  1109. {
  1110. if (!checkslot(0, _bufferMaxSlot - Blade2Slots + 1, slot)) //0 - 21| 21,22,23,24
  1111. {
  1112. reason = string.Format("Pick invalid parameter,pick, chamber is {0}, slot is {1}", chamber.ToString(), slot);
  1113. return false;
  1114. }
  1115. }
  1116. else
  1117. {
  1118. if (!checkslot(0, _bufferMaxSlot, slot))
  1119. {
  1120. reason = string.Format("Pick invalid parameter,pick, chamber is {0}, slot is {1}", chamber.ToString(), slot);
  1121. return false;
  1122. }
  1123. }
  1124. }
  1125. else
  1126. {
  1127. //if (hand == Hand.Both)
  1128. //{
  1129. // reason = string.Format("Pick invalid parameter, double pick,chamber is {0}, slot is {1}", chamber.ToString(), slot);
  1130. // return false;
  1131. //}
  1132. }
  1133. return execute(_factory.Pick(chamber, slot, hand), out reason);
  1134. }
  1135. public virtual bool PickReadyPosition(ModuleName chamber, int slot, Hand hand, out string reason)
  1136. {
  1137. reason = string.Empty;
  1138. if (chamber == ModuleName.Robot)
  1139. {
  1140. reason = string.Format("Pick invalid parameter, chamber is {0}, slot is {1}", chamber.ToString(), slot);
  1141. return false;
  1142. }
  1143. return execute(_factory.PickReadyPosition(chamber, slot, hand), out reason);
  1144. }
  1145. public virtual bool Place(ModuleName chamber, int slot, Hand hand, out string reason)
  1146. {
  1147. reason = string.Empty;
  1148. if (chamber == ModuleName.Robot)
  1149. {
  1150. reason = string.Format("Place invalid parameter, chamber is {0}, slot is {1}", chamber.ToString(), slot);
  1151. return false;
  1152. }
  1153. if (ModuleHelper.IsLoadPort(chamber))
  1154. {
  1155. if (hand == Hand.Both)
  1156. {
  1157. if (!checkslot(0, 25 - Blade2Slots, slot)) //0-20 | 20,21,22,23,24
  1158. {
  1159. reason = string.Format("Place invalid parameter,double hand, chamber is {0}, slot is {1}", chamber.ToString(), slot);
  1160. return false;
  1161. }
  1162. }
  1163. else if (hand == Hand.Blade2)
  1164. {
  1165. if (!checkslot(0, 25 - Blade2Slots + 1, slot)) //0 - 21| 21,22,23,24
  1166. {
  1167. reason = string.Format("Pick invalid parameter,pick, chamber is {0}, slot is {1}", chamber.ToString(), slot);
  1168. return false;
  1169. }
  1170. }
  1171. else
  1172. {
  1173. if (!checkslot(0, 25, slot))
  1174. {
  1175. reason = string.Format("Place invalid parameter,place, chamber is {0}, slot is {1}", chamber.ToString(), slot);
  1176. return false;
  1177. }
  1178. }
  1179. }
  1180. else if (ModuleHelper.IsBuffer(chamber))
  1181. {
  1182. if (hand == Hand.Both)
  1183. {
  1184. if (!checkslot(0, _bufferMaxSlot - Blade2Slots, slot)) //0-6
  1185. {
  1186. reason = string.Format("Place invalid parameter,double hand, chamber is {0}, slot is {1}", chamber.ToString(), slot);
  1187. return false;
  1188. }
  1189. }
  1190. else if (hand == Hand.Blade2)
  1191. {
  1192. if (!checkslot(0, _bufferMaxSlot - Blade2Slots + 1, slot)) //0 - 6
  1193. {
  1194. reason = string.Format("Pick invalid parameter,pick, chamber is {0}, slot is {1}", chamber.ToString(), slot);
  1195. return false;
  1196. }
  1197. }
  1198. else
  1199. {
  1200. if (!checkslot(0, _bufferMaxSlot, slot))
  1201. {
  1202. reason = string.Format("Place invalid parameter,place, chamber is {0}, slot is {1}", chamber.ToString(), slot);
  1203. return false;
  1204. }
  1205. }
  1206. }
  1207. else
  1208. {
  1209. //if (hand == Hand.Both)
  1210. //{
  1211. // reason = string.Format("Place invalid parameter, double place,chamber is {0}, slot is {1}", chamber.ToString(), slot);
  1212. // return false;
  1213. //}
  1214. }
  1215. return execute(_factory.Place(chamber, slot, hand), out reason);
  1216. }
  1217. public virtual bool PlaceReadyPosition(ModuleName chamber, int slot, Hand hand, out string reason)
  1218. {
  1219. reason = string.Empty;
  1220. if (chamber == ModuleName.Robot)
  1221. {
  1222. reason = string.Format("Place invalid parameter, chamber is {0}, slot is {1}", chamber.ToString(), slot);
  1223. return false;
  1224. }
  1225. return execute(_factory.PlaceReadyPosition(chamber, slot, hand), out reason);
  1226. }
  1227. public virtual bool PlaceExtend(ModuleName chamber, int slot, Hand hand, out string reason)
  1228. {
  1229. reason = string.Empty;
  1230. if (chamber.ToString() == Name || chamber == ModuleName.System || ModuleHelper.IsLoadPort(chamber) || ModuleHelper.IsBuffer(chamber))
  1231. {
  1232. reason = $"Place extend target not support, chamber is {chamber.ToString()}, slot is {slot}";
  1233. return false;
  1234. }
  1235. if (hand == Hand.Both)
  1236. {
  1237. reason =
  1238. $"Place extend invalid parameter, do not support double arm extend ,chamber is {chamber.ToString()}, slot is {slot}";
  1239. return false;
  1240. }
  1241. return execute(_factory.PlaceExtend(chamber, slot, hand), out reason);
  1242. }
  1243. public virtual bool PlaceRetract(ModuleName chamber, int slot, Hand hand, out string reason)
  1244. {
  1245. reason = string.Empty;
  1246. if (chamber.ToString() == Name || chamber == ModuleName.System || ModuleHelper.IsLoadPort(chamber) ||ModuleHelper.IsBuffer(chamber) )
  1247. {
  1248. reason = $"Place retract target not support, chamber is {chamber.ToString()}, slot is {slot}";
  1249. return false;
  1250. }
  1251. if (hand == Hand.Both)
  1252. {
  1253. reason =
  1254. $"Place retract invalid parameter, do not support double arm extend ,chamber is {chamber.ToString()}, slot is {slot}";
  1255. return false;
  1256. }
  1257. return execute(_factory.PlaceRetract(chamber, slot, hand), out reason);
  1258. }
  1259. public virtual bool Exchange(ModuleName chamber, int slot, Hand hand, out string reason)
  1260. {
  1261. reason = string.Empty;
  1262. if (chamber == ModuleName.Robot)
  1263. {
  1264. reason = string.Format("Exchange invalid parameter, chamber is {0}, slot is {1}", chamber.ToString(), slot);
  1265. return false;
  1266. }
  1267. if (Blade2Slots > 1)
  1268. {
  1269. reason = string.Format("this robot don't support exchange operation.");
  1270. return false;
  1271. }
  1272. if (hand == Hand.Both)
  1273. {
  1274. reason = string.Format("Exchange invalid parameter,double hand");
  1275. return false;
  1276. }
  1277. if (ModuleHelper.IsLoadPort(chamber))
  1278. {
  1279. if (!checkslot(0, 25, slot))
  1280. {
  1281. reason = string.Format("Exchange invalid parameter,pick, chamber is {0}, slot is {1}", chamber.ToString(), slot);
  1282. return false;
  1283. }
  1284. }
  1285. return execute(_factory.Exchange(chamber, slot, hand), out reason);
  1286. }
  1287. public virtual bool ExchangeReadyPosition(ModuleName chamber, int slot, Hand pickHand, Hand placeHand, out string reason)
  1288. {
  1289. reason = string.Empty;
  1290. if (chamber == ModuleName.Robot)
  1291. {
  1292. reason = string.Format("ExchangeReadyPosition invalid parameter, chamber is {0}, slot is {1}", chamber.ToString(), slot);
  1293. return false;
  1294. }
  1295. if (Blade2Slots > 1)
  1296. {
  1297. reason = string.Format("this robot don't support exchange operation.");
  1298. return false;
  1299. }
  1300. if (pickHand == Hand.Both || placeHand == Hand.Both)
  1301. {
  1302. reason = string.Format("ExchangeReadyPosition invalid parameter,double hand");
  1303. return false;
  1304. }
  1305. if (ModuleHelper.IsLoadPort(chamber))
  1306. {
  1307. if (!checkslot(0, 25, slot))
  1308. {
  1309. reason = string.Format("ExchangeReadyPosition invalid parameter,pick, chamber is {0}, slot is {1}", chamber.ToString(), slot);
  1310. return false;
  1311. }
  1312. }
  1313. return execute(_factory.ExchangeReadyPosition(chamber, slot, pickHand, placeHand), out reason);
  1314. }
  1315. public virtual bool ExchangeReadyPositionExtend(ModuleName chamber, int slot, Hand pickHand, Hand placeHand, out string reason)
  1316. {
  1317. reason = string.Empty;
  1318. if (chamber == ModuleName.Robot)
  1319. {
  1320. reason = string.Format("ExchangeReadyPosition invalid parameter, chamber is {0}, slot is {1}", chamber.ToString(), slot);
  1321. return false;
  1322. }
  1323. if (Blade2Slots > 1)
  1324. {
  1325. reason = string.Format("this robot don't support exchange operation.");
  1326. return false;
  1327. }
  1328. if (pickHand == Hand.Both || placeHand == Hand.Both)
  1329. {
  1330. reason = string.Format("ExchangeReadyPosition invalid parameter,double hand");
  1331. return false;
  1332. }
  1333. if (ModuleHelper.IsLoadPort(chamber))
  1334. {
  1335. if (!checkslot(0, 25, slot))
  1336. {
  1337. reason = string.Format("ExchangeReadyPosition invalid parameter,pick, chamber is {0}, slot is {1}", chamber.ToString(), slot);
  1338. return false;
  1339. }
  1340. }
  1341. return execute(_factory.ExchangeReadyExtend(chamber, slot, pickHand, placeHand), out reason);
  1342. }
  1343. public virtual bool ExchangeAfterReadyPositionExtend(ModuleName chamber, int slot, Hand pickHand, Hand placeHand, out string reason)
  1344. {
  1345. reason = string.Empty;
  1346. if (chamber == ModuleName.Robot)
  1347. {
  1348. reason = string.Format("ExchangeReadyPosition invalid parameter, chamber is {0}, slot is {1}", chamber.ToString(), slot);
  1349. return false;
  1350. }
  1351. if (Blade2Slots > 1)
  1352. {
  1353. reason = string.Format("this robot don't support exchange operation.");
  1354. return false;
  1355. }
  1356. if (pickHand == Hand.Both || placeHand == Hand.Both)
  1357. {
  1358. reason = string.Format("ExchangeReadyPosition invalid parameter,double hand");
  1359. return false;
  1360. }
  1361. if (ModuleHelper.IsLoadPort(chamber))
  1362. {
  1363. if (!checkslot(0, 25, slot))
  1364. {
  1365. reason = string.Format("ExchangeReadyPosition invalid parameter,pick, chamber is {0}, slot is {1}", chamber.ToString(), slot);
  1366. return false;
  1367. }
  1368. }
  1369. return execute(_factory.ExchangeAfterReadyExtend(chamber, slot, pickHand, placeHand), out reason);
  1370. }
  1371. public virtual bool ExchangePickExtend(ModuleName chamber, int slot, Hand pickHand, Hand placeHand, out string reason)
  1372. {
  1373. reason = string.Empty;
  1374. if (chamber == ModuleName.Robot)
  1375. {
  1376. reason = string.Format("ExchangePickExtend invalid parameter, chamber is {0}, slot is {1}", chamber.ToString(), slot);
  1377. return false;
  1378. }
  1379. if (Blade2Slots > 1)
  1380. {
  1381. reason = string.Format("this robot don't support exchange operation.");
  1382. return false;
  1383. }
  1384. if (pickHand == Hand.Both || placeHand == Hand.Both)
  1385. {
  1386. reason = string.Format("ExchangePickExtend invalid parameter,double hand");
  1387. return false;
  1388. }
  1389. if (ModuleHelper.IsLoadPort(chamber))
  1390. {
  1391. if (!checkslot(0, 25, slot))
  1392. {
  1393. reason = string.Format("ExchangePickExtend invalid parameter,pick, chamber is {0}, slot is {1}", chamber.ToString(), slot);
  1394. return false;
  1395. }
  1396. }
  1397. return execute(_factory.ExchangePickExtend(chamber, slot, pickHand, placeHand), out reason);
  1398. }
  1399. public virtual bool ExchangePlaceExtend(ModuleName chamber, int slot, Hand pickHand, Hand placeHand, out string reason)
  1400. {
  1401. reason = string.Empty;
  1402. if (chamber == ModuleName.Robot)
  1403. {
  1404. reason = string.Format("ExchangePlaceExtend invalid parameter, chamber is {0}, slot is {1}", chamber.ToString(), slot);
  1405. return false;
  1406. }
  1407. if (Blade2Slots > 1)
  1408. {
  1409. reason = string.Format("this robot don't support exchange operation.");
  1410. return false;
  1411. }
  1412. if (pickHand == Hand.Both || placeHand == Hand.Both)
  1413. {
  1414. reason = string.Format("ExchangePlaceExtend invalid parameter,double hand");
  1415. return false;
  1416. }
  1417. if (ModuleHelper.IsLoadPort(chamber))
  1418. {
  1419. if (!checkslot(0, 25, slot))
  1420. {
  1421. reason = string.Format("ExchangePlaceExtend invalid parameter,pick, chamber is {0}, slot is {1}", chamber.ToString(), slot);
  1422. return false;
  1423. }
  1424. }
  1425. return execute(_factory.ExchangePlaceExtend(chamber, slot, pickHand, placeHand), out reason);
  1426. }
  1427. public virtual bool ExchangePlaceRetract(ModuleName chamber, int slot, Hand pickHand, Hand placeHand, out string reason)
  1428. {
  1429. reason = string.Empty;
  1430. if (chamber == ModuleName.Robot)
  1431. {
  1432. reason = string.Format("ExchangePlaceRetract invalid parameter, chamber is {0}, slot is {1}", chamber.ToString(), slot);
  1433. return false;
  1434. }
  1435. if (Blade2Slots > 1)
  1436. {
  1437. reason = string.Format("this robot don't support exchange operation.");
  1438. return false;
  1439. }
  1440. if (pickHand == Hand.Both || placeHand == Hand.Both)
  1441. {
  1442. reason = string.Format("ExchangePlaceRetract invalid parameter,double hand");
  1443. return false;
  1444. }
  1445. if (ModuleHelper.IsLoadPort(chamber))
  1446. {
  1447. if (!checkslot(0, 25, slot))
  1448. {
  1449. reason = string.Format("ExchangePlaceRetract invalid parameter,pick, chamber is {0}, slot is {1}", chamber.ToString(), slot);
  1450. return false;
  1451. }
  1452. }
  1453. return execute(_factory.ExchangePlaceRetract(chamber, slot, pickHand, placeHand), out reason);
  1454. }
  1455. public virtual bool SetWaferSize(int cmd, WaferSize size, out string reason)
  1456. {
  1457. reason = string.Empty;
  1458. return execute(_factory.SetWaferSize(cmd, size), out reason);
  1459. }
  1460. public virtual bool QueryParameter(int parameter, string parameterType, out string reason)
  1461. {
  1462. reason = string.Empty;
  1463. return execute(_factory.QueryParameter(parameter, parameterType), out reason);
  1464. }
  1465. public virtual bool SetServoOnOff(bool trueForOnFalseForOff, out string reason)
  1466. {
  1467. reason = string.Empty;
  1468. return execute(_factory.SetServoOnOff(trueForOnFalseForOff), out reason);
  1469. }
  1470. public virtual bool PickEx(ModuleName chamber, int slot, Hand hand, int x, int y, int z, out string reason)
  1471. {
  1472. reason = string.Empty;
  1473. if (chamber == ModuleName.Robot)
  1474. {
  1475. reason = string.Format("Pick invalid parameter, chamber is {0}, slot is {1}", chamber.ToString(), slot);
  1476. return false;
  1477. }
  1478. if (ModuleHelper.IsLoadPort(chamber))
  1479. {
  1480. if (hand == Hand.Both)
  1481. {
  1482. if (!checkslot(0, 25 - Blade2Slots, slot)) //0-20 | 20,21,22,23,24
  1483. {
  1484. reason = string.Format("Pick invalid parameter,double hand, chamber is {0}, slot is {1}", chamber.ToString(), slot);
  1485. return false;
  1486. }
  1487. }
  1488. else if (hand == Hand.Blade2)
  1489. {
  1490. if (!checkslot(0, 25 - Blade2Slots + 1, slot)) //0 - 21| 21,22,23,24
  1491. {
  1492. reason = string.Format("Pick invalid parameter,pick, chamber is {0}, slot is {1}", chamber.ToString(), slot);
  1493. return false;
  1494. }
  1495. }
  1496. else
  1497. {
  1498. if (!checkslot(0, 25, slot))
  1499. {
  1500. reason = string.Format("Pick invalid parameter,pick, chamber is {0}, slot is {1}", chamber.ToString(), slot);
  1501. return false;
  1502. }
  1503. }
  1504. }
  1505. else
  1506. {
  1507. if (hand == Hand.Both)
  1508. {
  1509. reason = string.Format("Pick invalid parameter, double pick,chamber is {0}, slot is {1}", chamber.ToString(), slot);
  1510. return false;
  1511. }
  1512. }
  1513. return execute(_factory.PickEx(chamber, slot, hand, x,y,z), out reason);
  1514. }
  1515. public virtual bool PlaceEx(ModuleName chamber, int slot, Hand hand, int x, int y, int z, out string reason)
  1516. {
  1517. reason = string.Empty;
  1518. if (chamber == ModuleName.Robot)
  1519. {
  1520. reason = string.Format("Place invalid parameter, chamber is {0}, slot is {1}", chamber.ToString(), slot);
  1521. return false;
  1522. }
  1523. if (ModuleHelper.IsLoadPort(chamber))
  1524. {
  1525. if (hand == Hand.Both)
  1526. {
  1527. if (!checkslot(0, 25 - Blade2Slots, slot)) //0-20 | 20,21,22,23,24
  1528. {
  1529. reason = string.Format("Place invalid parameter,double hand, chamber is {0}, slot is {1}", chamber.ToString(), slot);
  1530. return false;
  1531. }
  1532. }
  1533. else if (hand == Hand.Blade2)
  1534. {
  1535. if (!checkslot(0, 25 - Blade2Slots + 1, slot)) //0 - 21| 21,22,23,24
  1536. {
  1537. reason = string.Format("Pick invalid parameter,pick, chamber is {0}, slot is {1}", chamber.ToString(), slot);
  1538. return false;
  1539. }
  1540. }
  1541. else
  1542. {
  1543. if (!checkslot(0, 25, slot))
  1544. {
  1545. reason = string.Format("Place invalid parameter,place, chamber is {0}, slot is {1}", chamber.ToString(), slot);
  1546. return false;
  1547. }
  1548. }
  1549. }
  1550. else
  1551. {
  1552. if (hand == Hand.Both)
  1553. {
  1554. reason = string.Format("Place invalid parameter, double place,chamber is {0}, slot is {1}", chamber.ToString(), slot);
  1555. return false;
  1556. }
  1557. }
  1558. return execute(_factory.PlaceEx(chamber, slot, hand,x,y,z), out reason);
  1559. }
  1560. public virtual bool ExchangeEx(ModuleName chamber, int slot, Hand hand, int x, int y, int z, out string reason)
  1561. {
  1562. reason = string.Empty;
  1563. if (chamber == ModuleName.Robot)
  1564. {
  1565. reason = string.Format("Exchange invalid parameter, chamber is {0}, slot is {1}", chamber.ToString(), slot);
  1566. return false;
  1567. }
  1568. if (Blade2Slots > 1)
  1569. {
  1570. reason = string.Format("this robot don't support exchange operation.");
  1571. return false;
  1572. }
  1573. if (hand == Hand.Both)
  1574. {
  1575. reason = string.Format("Exchange invalid parameter,double hand");
  1576. return false;
  1577. }
  1578. if (ModuleHelper.IsLoadPort(chamber))
  1579. {
  1580. if (!checkslot(0, 25, slot))
  1581. {
  1582. reason = string.Format("Exchange invalid parameter,pick, chamber is {0}, slot is {1}", chamber.ToString(), slot);
  1583. return false;
  1584. }
  1585. }
  1586. return execute(_factory.ExchangeEx(chamber, slot, hand, x, y, z), out reason);
  1587. }
  1588. #endregion
  1589. public virtual bool PositionAdjustment( Axis axis, Hand hand, int value, out string reason)
  1590. {
  1591. reason = string.Empty;
  1592. return execute(_factory.PositionAdjustment( axis,hand,value), out reason);
  1593. }
  1594. public virtual bool execute(IHandler handler, out string reason)
  1595. {
  1596. reason = string.Empty;
  1597. lock (_locker)
  1598. {
  1599. if (_foregroundHandler != null)
  1600. {
  1601. reason = "System busy, please wait or reset system.";
  1602. EV.PostMessage(Name, EventEnum.DefaultWarning, string.Format("{0} {1} {2}", this.DeviceID, handler.ToString(), reason));
  1603. return false;
  1604. }
  1605. if (_backgroundHandler != null && handler.IsBackground)
  1606. {
  1607. reason = "System busy,one background command is running, please wait or reset system.";
  1608. EV.PostMessage(Name, EventEnum.DefaultWarning, string.Format("{0} {1} {2}", this.DeviceID, handler.ToString(), reason));
  1609. //reason = "系统忙,后台命令正在处理,暂时不能处理新的后台命令";
  1610. return false;
  1611. }
  1612. handler.Unit = (int)Unit.Robot;
  1613. if(!handler.Execute(ref _socket))
  1614. {
  1615. reason = "Communication error,please check it.";
  1616. OnError(reason);
  1617. return false;
  1618. }
  1619. if (handler.IsBackground)
  1620. _backgroundHandler = handler;
  1621. else
  1622. _foregroundHandler = handler;
  1623. }
  1624. return true;
  1625. }
  1626. public virtual void OnDataChanged(string package)
  1627. {
  1628. try
  1629. {
  1630. if (!package.Contains("Gb") && !package.Contains("Pb"))
  1631. package = package.ToUpper();
  1632. string[] msgs = Regex.Split(package, delimiter);
  1633. foreach (string msg in msgs)
  1634. {
  1635. if (msg.Length > 0)
  1636. {
  1637. bool completed = false;
  1638. string resp = msg;
  1639. lock (_locker)
  1640. {
  1641. if (_foregroundHandler != null && _foregroundHandler.OnMessage(ref _socket, resp, out completed))
  1642. {
  1643. _foregroundHandler = null;
  1644. }
  1645. else if (_backgroundHandler != null && _backgroundHandler.OnMessage(ref _socket, resp, out completed))
  1646. {
  1647. if (completed)
  1648. {
  1649. //string reason = string.Empty;
  1650. //QueryState(out reason);
  1651. _backgroundHandler = null;
  1652. if (ActionDone != null)
  1653. ActionDone(true);
  1654. }
  1655. }
  1656. else
  1657. {
  1658. if (_eventHandler != null)
  1659. {
  1660. if (_eventHandler.OnMessage(ref _socket, resp, out completed))
  1661. {
  1662. if (completed)
  1663. {
  1664. EV.PostMessage("Robot", EventEnum.DefaultWarning, string.Format(" has error. {0:X}", ErrorCode));
  1665. OnError(string.Format("has error. {0:X}", ErrorCode));
  1666. _exceuteErr = true;
  1667. }
  1668. }
  1669. }
  1670. }
  1671. }
  1672. }
  1673. }
  1674. }
  1675. catch (ExcuteFailedException e)
  1676. {
  1677. EV.PostMessage("Robot", EventEnum.DefaultWarning, string.Format("executed failed. {0}",e.Message));
  1678. OnError(string.Format("executed failed. {0}", e.Message));
  1679. _exceuteErr = false;
  1680. }
  1681. catch (InvalidPackageException e)
  1682. {
  1683. EV.PostMessage("Robot", EventEnum.DefaultWarning, string.Format("receive invalid package. {0}", e.Message));
  1684. OnError(string.Format("receive invalid package. {0}", e.Message));
  1685. }
  1686. catch (System.Exception ex)
  1687. {
  1688. _commErr = true;
  1689. LOG.Write("Robot failed:" + ex.ToString());
  1690. }
  1691. }
  1692. private void OnErrorHandler(ErrorEventArgs args)
  1693. {
  1694. _commErr = true;
  1695. Initalized = false;
  1696. EV.PostMessage(Module, EventEnum.CommunicationError, Display, args.Reason);
  1697. OnError("CommunicationError");
  1698. }
  1699. private bool checkslot(int min, int max, int slot)
  1700. {
  1701. return slot >= min && slot < max;
  1702. }
  1703. public void NotifySlotMapResult(ModuleName module, string slotMap)
  1704. {
  1705. if (OnSlotMapRead != null)
  1706. {
  1707. OnSlotMapRead(module, slotMap);
  1708. }
  1709. }
  1710. public void OnError(string errorcode)
  1711. {
  1712. EV.Notify(AlarmRobotError,new SerializableDictionary<string, object> {
  1713. {
  1714. "AlarmText",errorcode
  1715. }
  1716. });
  1717. if (ActionDone != null)
  1718. ActionDone(false);
  1719. }
  1720. public void NotifyWaferPresent(Hand hand, WaferStatus status)
  1721. {
  1722. if (status == WaferStatus.Empty)
  1723. {
  1724. if (hand == Hand.Blade1)
  1725. {
  1726. WaferPresentOnBlade1 = status == WaferStatus.Empty;
  1727. }
  1728. if (hand == Hand.Blade2)
  1729. {
  1730. WaferPresentOnBlade2 = status == WaferStatus.Empty;
  1731. }
  1732. }
  1733. if (status == WaferStatus.Unknown)
  1734. {
  1735. EV.PostWarningLog(Module, "Wafer present unknown");
  1736. return;
  1737. }
  1738. if (hand == Hand.Blade1)
  1739. {
  1740. WaferPresentOnBlade1 = status == WaferStatus.Normal;
  1741. }
  1742. if (hand == Hand.Blade2)
  1743. {
  1744. WaferPresentOnBlade2 = status == WaferStatus.Normal;
  1745. }
  1746. }
  1747. //Active wafer Center finder Data
  1748. public void NotifyAWCData(int rOffset, int tOffset)
  1749. {
  1750. CenterOffsetR = rOffset;
  1751. CenterOffsetT = tOffset;
  1752. }
  1753. }
  1754. }