Handler.cs 55 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536
  1. using System;
  2. using System.Text;
  3. using Aitex.Core.RT.Device;
  4. using Aitex.Sorter.Common;
  5. using MECF.Framework.Common.Equipment;
  6. using MECF.Framework.Common.SubstrateTrackings;
  7. using System.Text.RegularExpressions;
  8. using Aitex.Core.RT.Log;
  9. using System.Collections.Generic;
  10. namespace MECF.Framework.RT.EquipmentLibrary.HardwareUnits.Robot.NX100
  11. {
  12. /*
  13. * A command is transmitted from the host in the following format.
  14. * $ UNo (SeqNo) COMMAND Parameter Sum CR\
  15. * • $: Start mark (1 byte)
  16. Indicates the start of the message.
  17. • UNo: Unit No. (1 byte)
  18. Indicates the unit number
  19. • SeqNo: Sequence number (Non/1/2/3 bytes)
  20. Sequence number is used to avoid duplicate motion when sending of
  21. commands improperly. An integer parameter can specify the length of
  22. SeqNo. (Non/1/2/3 bytes). See parameter table for more details. (Default:
  23. Non), 设置 2bytes
  24. • Parameter: Parameter (Differs depending on the command.)
  25. Sets the operation axis, the moving amount, etc. following a command.
  26. • Sum: Checksum (2 bytes)
  27. This information is used for the communications error check.
  28. Calculate the sum of the ASCII characters (‘0’ to ‘9’ and ‘A’ to ‘F’), in “Uno”,
  29. “COMMAND” and “Parameter” section, and take the lowest tow digit.
  30. */
  31. public class handler<T> : IHandler where T : ITransferMsg, new()
  32. {
  33. public int ID { get; set; }
  34. public int Unit { get; set; }
  35. public bool IsBackground { get { return _imp.background; } }
  36. private static int retry_time = 3;
  37. private int retry_count = retry_time;
  38. private object[] _objs = null;
  39. private TokenGenerator _generator;
  40. private T _imp = new T();
  41. private List<string> _words = new List<string>();
  42. public handler(IDevice device)
  43. {
  44. _imp.Robot = device;
  45. }
  46. public handler(IDevice device, ref TokenGenerator gen, params object[] objs)
  47. {
  48. _imp.Robot = device;
  49. this._generator = gen;
  50. this._objs = objs;
  51. }
  52. public bool Execute<TPort>(ref TPort port) where TPort : ICommunication
  53. {
  54. retry_count = retry_time;
  55. ID = _generator.create();
  56. return port.Write(string.Format("{0}{1}{2}", ProtocolTag.tag_cmd_start, package().Replace(",", ""), ProtocolTag.tag_end));
  57. }
  58. /// <summary>
  59. /// return value: bhandle
  60. /// </summary>
  61. /// <typeparam name="TPort"></typeparam>
  62. /// <param name="port"></param>
  63. /// <param name="msg"></param>
  64. /// <param name="completed"></param>
  65. /// <returns></returns>
  66. ///
  67. public bool OnMessage<TPort>(ref TPort port, string message, out bool completed) where TPort : ICommunication
  68. {
  69. //$1E000003AC0300010
  70. //message = ">,1,EVNT,100,2018/11/16 17:01:06,2BA0,A1";
  71. //message = " !,1,36,40,2BA0,MTRS,002200,-0011931,-0610171,00179995,00049818,00186336,57";
  72. //message = "!,1,16,40,0000,MTCH,000483,-0011862,00000000,00179516,00090369,00172882,0A";
  73. //message = "$156000000RMAPC2FF01OK02OK03OK04OK05OK06OK07OK08OK09--10--11--12--13--14--15--16--17--18--19--20--21--22--23--24--25--96";
  74. //message =!283000000MALNE5.
  75. try
  76. {
  77. completed = false;
  78. string package = message;
  79. _words.Clear();
  80. string type = package.Substring(0,1);
  81. _words.Add(type);
  82. int unit = int.Parse(package.Substring(1, 1));
  83. _words.Add(package.Substring(1, 1));
  84. string sum = package.Substring(package.Length - 2, 2);
  85. string check = Checksum(package);
  86. if (sum != check)
  87. {
  88. throw (new InvalidPackageException(string.Format("check sum error{0}", package)));
  89. }
  90. if (type != ProtocolTag.resp_tag_event && type != ProtocolTag.resp_tag_error)
  91. {
  92. _words.Add(package.Substring(2, 2));
  93. int seq = int.Parse(package.Substring(2,2));
  94. if (seq != ID)
  95. return false;
  96. if (unit != Unit)
  97. {
  98. throw (new InvalidPackageException(string.Format("invalid unit {0}", package)));
  99. }
  100. }
  101. if (type == ProtocolTag.resp_tag_error)
  102. {
  103. //? Ackcd Sum CR
  104. string error = package.Substring(1,4);
  105. //‘1’: Warning 1 (W1), ‘2’: Warning 2 (W2), ‘3’: Important alarm 1 (A1), ‘4’: Important alarm 2 (A2),
  106. //‘5’: Serious alarm (F)
  107. if (error[0] != '1' || error[0] != '2')
  108. {
  109. string warning = string.Format("can't execute retry, {0}", error);
  110. //LOG.Warning(warning);
  111. throw (new ExcuteFailedException(warning));
  112. }
  113. if (retry_count-- <= 0)
  114. {
  115. string warning = string.Format("retry over {0} times", retry_time);
  116. //LOG.Warning(warning);
  117. throw (new ExcuteFailedException(warning));
  118. }
  119. port.Write(string.Format("{0}{1}{2}", ProtocolTag.tag_cmd_start, this.package(), ProtocolTag.tag_end));
  120. return true;
  121. }
  122. else if (type == ProtocolTag.resp_tag_event)
  123. {
  124. //0 1 2-3 4-7 8-10
  125. //> UNo SeqNo COMMAND EvNo EvData Sum CR
  126. //• COMMAND : Command (4 Byte) EVNT(Fixed length)
  127. //• EvNo: Event number(
  128. _words.Add(package.Substring(4, 4)); //stsN
  129. string evtType = package.Substring(8, 10);
  130. _words.Add(evtType); //Errcd
  131. string evtInfo = package.Substring(11, package.Length - 10 -2 );
  132. _words.Add(evtInfo); //Errcd
  133. if (_imp.evt)
  134. completed = _imp.unpackage(type, _words.ToArray());
  135. return _imp.evt;
  136. }
  137. else
  138. {
  139. //0 1 2,3 4,5 6-9
  140. //! UNo (SeqNo) StsN Errcd COMMAND Sum
  141. _words.Add(package.Substring(4, 2)); //stsN
  142. string error = package.Substring(6, 4);
  143. //int intError = Convert.ToInt32(error, 16);
  144. if (error != "0000")
  145. {
  146. string warning = string.Format("Robot execute failed, return error {0}", error);
  147. throw (new ExcuteFailedException(warning));
  148. }
  149. _words.Add(error); //Errcd
  150. _words.Add(package.Substring(10, package.Length - 10 -2)) ; //COMMAND
  151. completed = _imp.unpackage(type, _words.ToArray());
  152. if (completed)
  153. {
  154. _generator.release(ID);
  155. if (_imp.background)
  156. {
  157. ID = this._generator.create();
  158. port.Write(string.Format("{0}{1}{2}", ProtocolTag.tag_cmd_start, ackn(), ProtocolTag.tag_end));
  159. _generator.release(ID);
  160. }
  161. //wait 2ms
  162. return true;
  163. }
  164. return true;
  165. }
  166. }
  167. catch (ExcuteFailedException e)
  168. {
  169. throw (e);
  170. }
  171. catch (InvalidPackageException e)
  172. {
  173. throw e;
  174. }
  175. catch (Exception ex)
  176. {
  177. LOG.WriteExeption(ex);
  178. throw (new InvalidPackageException(message));
  179. }
  180. }
  181. private string Checksum(string package)
  182. {
  183. int start = package.IndexOf(ProtocolTag.cmd_token);
  184. int end = package.LastIndexOf(ProtocolTag.cmd_token);
  185. start = 1;
  186. end = package.Length - 2 - 1;
  187. int len = end - start + 1;
  188. if (len > 1)
  189. {
  190. string data = package.Substring(start, len);
  191. return Checksum(Encoding.Default.GetBytes(data));
  192. }
  193. return "";
  194. }
  195. private string Checksum(byte[] bytes)
  196. {
  197. int sum = 0;
  198. foreach (byte code in bytes)
  199. {
  200. sum += code;
  201. }
  202. string hex = String.Format("{0:X2}", sum % 256);
  203. return hex;
  204. }
  205. private string package()
  206. {
  207. //$,<UNo>(,<SeqNo>),<Command>,<Parameter>(,<Sum>)<CR>
  208. string data = string.Empty;
  209. data = string.Format("{0:D1}{1:D2}{2}", Unit, ID, _imp.package(this._objs).Replace(",",""));
  210. string sum = Checksum(Encoding.ASCII.GetBytes(data));
  211. return data + sum;
  212. }
  213. private string ackn()
  214. {
  215. //$<UNo>(<SeqNo>)ACKN(<Sum>)<CR>
  216. string data = string.Empty;
  217. data = string.Format("{0:D1}{1:D2}ACKN", Unit, ID);
  218. string sum = Checksum(Encoding.ASCII.GetBytes(data));
  219. return data + sum;
  220. }
  221. }
  222. public class RobotMotionHandler : ITransferMsg
  223. {
  224. public bool background { get; protected set; }
  225. public bool evt { get { return false; } }
  226. public string deviceID { private get; set; }
  227. public string _cmd = string.Empty;
  228. public IDevice Robot { set { _device = (Robot)value; } }
  229. protected Robot _device;
  230. public RobotMotionHandler()
  231. {
  232. background = false;
  233. }
  234. public virtual string package(params object[] args)
  235. {
  236. return "";
  237. }
  238. public bool unpackage(string type, string[] items)
  239. {
  240. //! <UNo> (<SeqNo>) <StsN> <Errcd> MTRG <Sum> <CR>
  241. int value = Convert.ToInt32(items[3],16);
  242. _device.Status = value;
  243. int error = Convert.ToInt32(items[4], 16);
  244. _device.ErrorCode = error;
  245. if(error > 0)
  246. _device.LastErrorCode = error;
  247. if (type.Equals(ProtocolTag.resp_tag_excute))
  248. {
  249. //_device.ElapseTime = int.Parse(items[6]);
  250. //_device.Rotation = int.Parse(items[7]);
  251. //_device.Extension = int.Parse(items[8]);
  252. //_device.Wrist1= int.Parse(items[9]);
  253. //_device.Wrist2= int.Parse(items[10]);
  254. //_device.Evevation = int.Parse(items[11]);
  255. if (error == 0)
  256. {
  257. update(items);
  258. }
  259. return true;
  260. }
  261. return !background;
  262. }
  263. protected virtual void update(string[] data)
  264. {
  265. }
  266. }
  267. public class RbInitHandler : RobotMotionHandler
  268. {
  269. public RbInitHandler()
  270. {
  271. background = true;
  272. }
  273. public override string package(params object[] args)
  274. {
  275. //$ <UNo> (<SeqNo>) INIT<IMode> <Sum> <CR>
  276. // IMode: Initialization mode(2 Byte)
  277. //• ”00”: Error clear, servo ON and all axes move to home position
  278. //• ”01”: Servo ON and all axes move to home position
  279. //• ”05”: Error clear, servo ON and arm moves to home position.
  280. //• ”06”: Servo ON and arm moves to home position
  281. //• ”10”: Error clear and servo ON
  282. updateBefore();
  283. return ",INIT,00,";
  284. }
  285. protected void updateBefore()
  286. {
  287. _device.Blade1Target = ModuleHelper.Converter(_device.Name);
  288. _device.Blade2Target = ModuleHelper.Converter(_device.Name);
  289. }
  290. protected override void update(string[] data)
  291. {
  292. _device.Initalized = true;
  293. _device.Swap = false;
  294. }
  295. }
  296. public class RbHomeHandler : RobotMotionHandler
  297. {
  298. public RbHomeHandler()
  299. {
  300. background = true;
  301. }
  302. public override string package(params object[] args)
  303. {
  304. //$ < UNo > > (< SeqNo >) MHOM<MMode> < Sum > < CR >
  305. //• UNo: Unit number(1 byte)
  306. //• ‘1’ to ‘4’: Unit specified
  307. //• SeqNo: Sequence number(Non/ 1 / 2 / 3 byte)
  308. //• MMode: Motion mode(1 byte)
  309. //• ‘F’: All axes
  310. //• ‘A’: Arm(s) only
  311. updateBefore();
  312. return ",MHOM,F,";
  313. }
  314. protected void updateBefore()
  315. {
  316. _device.Blade1Target = ModuleHelper.Converter(_device.Name);
  317. _device.Blade2Target = ModuleHelper.Converter(_device.Name);
  318. _device.CmdBladeTarget = $"{_device.Name}.A";
  319. _device.CmdBlade1Extend = "0";
  320. _device.CmdBlade2Extend = "0";
  321. }
  322. protected override void update(string[] data)
  323. {
  324. _device.Initalized = true;
  325. _device.Swap = false;
  326. }
  327. }
  328. public class RbClearErrorHandler : RobotMotionHandler
  329. {
  330. public RbClearErrorHandler()
  331. {
  332. background = true;
  333. }
  334. //$ <UNo> (<SeqNo>) CCLR <CMode> <Sum> <CR>
  335. public override string package(params object[] args)
  336. {
  337. //• CMode: Clear mode(1 byte)
  338. //• ‘E’: Releases the error status.
  339. //• ‘H’: Clears the error history.
  340. return ",CCLR,E,";
  341. }
  342. }
  343. public class RbGripHandler : RobotMotionHandler
  344. {
  345. Hand _hand;
  346. public RbGripHandler()
  347. {
  348. background = true;
  349. }
  350. //Command wafer hold/release signal to the solenoid of the specified unit.
  351. //$ <UNo> (<SeqNo>) CSOL <Fork> <Sw> <Sum> <CR>
  352. //• Fork: Fork specified(1 byte)
  353. //• ‘A’: Extension axis 1 (Blade 1), pre-aligner
  354. //• ‘B’: Extension axis 2 (Blade 2)
  355. //• Sw: Chucking command(1 byte)
  356. //• ‘0’: Chucking OFF
  357. //• ‘1’: Chucking ON
  358. public override string package(params object[] args)
  359. {
  360. _hand = (Hand)args[0];
  361. bool bHold = (bool)args[1];
  362. if(bHold)
  363. return string.Format(",CSOL,{0},1,",RobotConvertor.hand2string(_hand));
  364. return string.Format(",CSOL,{0},0,", RobotConvertor.hand2string(_hand));
  365. }
  366. }
  367. public class RbStopHandler : RobotMotionHandler
  368. {
  369. public RbStopHandler()
  370. {
  371. background = true;
  372. }
  373. //$ <UNo> (<SeqNo>) CHLTs <Sum> <CR>
  374. //Pause (decelerate and stop) the motion of the specified unit during the drive command execution.
  375. public override string package(params object[] args)
  376. {
  377. bool isEmergency = (bool)args[0];
  378. if (isEmergency)
  379. return ",CEMG,";
  380. //$ < UNo > (< SeqNo >) CHLT<Sum> < CR >
  381. return ",CHLT,";
  382. //return ",MHOM,F,";
  383. }
  384. }
  385. public class RbResumeHandler : RobotMotionHandler
  386. {
  387. public RbResumeHandler()
  388. {
  389. background = true;
  390. }
  391. //$ <UNo> (<SeqNo>) CRSM <Sum> <CR>
  392. public override string package(params object[] args)
  393. {
  394. return ",CRSM,";
  395. }
  396. }
  397. public class PickHandler : RobotMotionHandler
  398. {
  399. private ModuleName _chamber;
  400. private int _slot;
  401. private Hand _hand;
  402. public PickHandler()
  403. {
  404. background = true;
  405. }
  406. public override string package(params object[] args)
  407. {
  408. //Move To Ready position and wafer Get motion(MTRS+MGET)
  409. //$ <UNo> (<SeqNo>) MTRG <TrsSt> <SlotNo> <MtnMode> <Posture> <Sum> <CR>
  410. // • TrsSt: Transfer station(2 bytes)
  411. //• "C1" to "C8": When cassette stage specified
  412. //• "S1" to "SC": When transfer stage specified
  413. //• "P1" to “P2”: When P/ A stage specified
  414. //Note: P2 station is effective only when two or more PA stations exist.
  415. //• SlotNo: Slot number(2 bytes)
  416. //< Manipulator >
  417. //• "01" to "XX": When cassette stage is specified by < TrsST >
  418. //(The maximum value of "XX" is in the ASCII code of the number of slots specified by parameter.)
  419. //• "00": When transfer stage or P / A stage specified by < TrsSt >
  420. //• MtnMode: Motion mode(2 bytes)
  421. //• "GA": Wafer Get motion at extension axis 1(Blade 1).
  422. //• "GB": Wafer Get motion at extension axis 2(Blade 2).
  423. //• "GW": Wafer Get motion with extension axis 1 and 2(Blade 1 and 2). < WGet motion >
  424. _chamber = (ModuleName)args[0];
  425. _slot = (int)args[1];
  426. _hand = (Hand)args[2];
  427. updateBefore();
  428. if (_hand == Hand.Both)
  429. {
  430. return string.Format(",MTRG,{0},{1:D2},G{2},A,",
  431. RobotConvertor.chamber2staion(_chamber),
  432. RobotConvertor.chamberSlot2Slot(_chamber, _slot + 1) ,
  433. RobotConvertor.hand2string(_hand));
  434. }
  435. return string.Format(",MTRG,{0},{1:D2},G{2},A,",
  436. RobotConvertor.chamber2staion(_chamber),
  437. RobotConvertor.chamberSlot2Slot(_chamber, _slot),
  438. RobotConvertor.hand2string(_hand));
  439. }
  440. private void updateBefore()
  441. {
  442. _device.Blade1Target = _chamber;
  443. _device.Blade2Target = _chamber;
  444. string arm = _hand == Hand.Blade1 ? "A" : "B";
  445. _device.CmdBladeTarget = $"{_chamber}.{arm}";
  446. _device.CmdBlade1Extend = _hand == Hand.Blade1 ? "1" : "0";
  447. _device.CmdBlade2Extend = _hand == Hand.Blade1 ? "0" : "1";
  448. }
  449. protected override void update(string[] data)
  450. {
  451. if (_hand == Hand.Blade1)
  452. {
  453. WaferManager.Instance.WaferMoved(_chamber, _slot, ModuleHelper.Converter(_device.Name), (int)Hand.Blade1);
  454. }
  455. else if (_hand == Hand.Blade2)
  456. {
  457. for (int i = 0; i < _device.Blade2Slots; i++)
  458. WaferManager.Instance.WaferMoved(_chamber, _slot + i, ModuleHelper.Converter(_device.Name), (int)Hand.Blade2 + i);
  459. }
  460. else
  461. {
  462. for (int i = 0; i < _device.Blade2Slots + 1; i++)
  463. WaferManager.Instance.WaferMoved(_chamber, _slot + i, ModuleHelper.Converter(_device.Name), (int)Hand.Blade1 + i);
  464. }
  465. string arm = _hand == Hand.Blade1 ? "A" : "B";
  466. _device.CmdBladeTarget = $"{_chamber}.{arm}";
  467. _device.CmdBlade1Extend = "0";
  468. _device.CmdBlade2Extend = "0";
  469. _device.Blade1Target = ModuleHelper.Converter(_device.Name);
  470. _device.Blade2Target = ModuleHelper.Converter(_device.Name);
  471. }
  472. }
  473. public class PickExtendHandler : RobotMotionHandler
  474. {
  475. private ModuleName _chamber;
  476. private int _slot;
  477. private Hand _hand;
  478. public PickExtendHandler()
  479. {
  480. background = true;
  481. }
  482. public override string package(params object[] args)
  483. {
  484. //$ <UNo> (<SeqNo>) MTPT <TrsSt> <SlotNo> <NextMtn> <Posture> <TrsPnt> <Sum> <CR>
  485. _chamber = (ModuleName)args[0];
  486. _slot = (int)args[1];
  487. _hand = (Hand)args[2];
  488. updateBefore();
  489. return string.Format(",MTPT,{0},{1:D2},G{2},A,Gb,",
  490. RobotConvertor.chamber2staion(_chamber),
  491. RobotConvertor.chamberSlot2Slot(_chamber, _slot + 1),
  492. RobotConvertor.hand2string(_hand));
  493. }
  494. private void updateBefore()
  495. {
  496. _device.Blade1Target = _chamber;
  497. _device.Blade2Target = _chamber;
  498. string arm = _hand == Hand.Blade1 ? "A" : "B";
  499. _device.CmdBladeTarget = $"{_chamber}.{arm}";
  500. _device.CmdBlade1Extend = _hand == Hand.Blade1 ? "1" : "0";
  501. _device.CmdBlade2Extend = _hand == Hand.Blade1 ? "0" : "1";
  502. }
  503. }
  504. public class PickRetractHandler : RobotMotionHandler
  505. {
  506. private ModuleName _chamber;
  507. private int _slot;
  508. private Hand _hand;
  509. public PickRetractHandler()
  510. {
  511. background = true;
  512. }
  513. public override string package(params object[] args)
  514. {
  515. // $ <UNo> (<SeqNo>) MPNT <TrsPnt> <Sum> <CR>
  516. _chamber = (ModuleName)args[0];
  517. _slot = (int)args[1];
  518. _hand = (Hand)args[2];
  519. updateBefore();
  520. return ",MPNT,G4,";
  521. }
  522. private void updateBefore()
  523. {
  524. _device.Blade1Target = _chamber;
  525. _device.Blade2Target = _chamber;
  526. string arm = _hand == Hand.Blade1 ? "A" : "B";
  527. _device.CmdBladeTarget = $"{_chamber}.{arm}";
  528. _device.CmdBlade1Extend = _hand == Hand.Blade1 ? "1" : "0";
  529. _device.CmdBlade2Extend = _hand == Hand.Blade1 ? "0" : "1";
  530. }
  531. protected override void update(string[] data)
  532. {
  533. if (_hand == Hand.Both)
  534. {
  535. WaferManager.Instance.WaferMoved(_chamber, _slot, ModuleHelper.Converter(_device.Name), (int)Hand.Blade1);
  536. WaferManager.Instance.WaferMoved(_chamber, _slot + 1, ModuleHelper.Converter(_device.Name), (int)Hand.Blade2);
  537. }
  538. else
  539. {
  540. WaferManager.Instance.WaferMoved(_chamber, _slot, ModuleHelper.Converter(_device.Name), (int)_hand);
  541. }
  542. string arm = _hand == Hand.Blade1 ? "A" : "B";
  543. _device.CmdBladeTarget = $"{_chamber}.{arm}";
  544. _device.CmdBlade1Extend = "0";
  545. _device.CmdBlade2Extend = "0";
  546. _device.Blade1Target = ModuleHelper.Converter(_device.Name);
  547. _device.Blade2Target = ModuleHelper.Converter(_device.Name);
  548. }
  549. }
  550. public class PlaceHandler : RobotMotionHandler
  551. {
  552. private ModuleName _chamber;
  553. private int _slot;
  554. private Hand _hand;
  555. public PlaceHandler()
  556. {
  557. background = true;
  558. }
  559. public override string package(params object[] args)
  560. {
  561. // $ <UNo> (<SeqNo>) MTRP <TrsSt> <SlotNo> <MtnMode> <Posture> <Sum> <CR>
  562. _chamber = (ModuleName)args[0];
  563. _slot = (int)args[1];
  564. _hand = (Hand)args[2];
  565. updateBefore();
  566. if (_hand == Hand.Both)
  567. {
  568. return string.Format(",MTRP,{0},{1:D2},P{2},A,",
  569. RobotConvertor.chamber2staion(_chamber),
  570. RobotConvertor.chamberSlot2Slot(_chamber, _slot + 1),
  571. RobotConvertor.hand2string(_hand));
  572. }
  573. return string.Format(",MTRP,{0},{1:D2},P{2},A,",
  574. RobotConvertor.chamber2staion(_chamber),
  575. RobotConvertor.chamberSlot2Slot(_chamber, _slot),
  576. RobotConvertor.hand2string(_hand));
  577. }
  578. private void updateBefore()
  579. {
  580. _device.Blade1Target = _chamber;
  581. _device.Blade2Target = _chamber;
  582. string arm = _hand == Hand.Blade1 ? "A" : "B";
  583. _device.CmdBladeTarget = $"{_chamber}.{arm}";
  584. _device.CmdBlade1Extend = _hand == Hand.Blade1 ? "1" : "0";
  585. _device.CmdBlade2Extend = _hand == Hand.Blade1 ? "0" : "1";
  586. }
  587. protected override void update(string[] data)
  588. {
  589. if (_hand == Hand.Blade1)
  590. {
  591. WaferManager.Instance.WaferMoved(ModuleHelper.Converter(_device.Name), (int)Hand.Blade1, _chamber, _slot);
  592. }
  593. else if (_hand == Hand.Blade2)
  594. {
  595. for (int i = 0; i < _device.Blade2Slots; i++)
  596. WaferManager.Instance.WaferMoved(ModuleHelper.Converter(_device.Name), (int)Hand.Blade2 +i, _chamber, _slot + i);
  597. }
  598. else
  599. {
  600. for (int i = 0; i < _device.Blade2Slots + 1; i++)
  601. WaferManager.Instance.WaferMoved(ModuleHelper.Converter(_device.Name), (int)Hand.Blade1 + i, _chamber, _slot + i);
  602. }
  603. string arm = _hand == Hand.Blade1 ? "A" : "B";
  604. _device.CmdBladeTarget = $"{_chamber}.{arm}";
  605. _device.CmdBlade1Extend = "0";
  606. _device.CmdBlade2Extend = "0";
  607. _device.Blade1Target = ModuleHelper.Converter(_device.Name);
  608. _device.Blade2Target = ModuleHelper.Converter(_device.Name);
  609. }
  610. }
  611. public class PlaceExtendHandler : RobotMotionHandler
  612. {
  613. private ModuleName _chamber;
  614. private int _slot;
  615. private Hand _hand;
  616. public PlaceExtendHandler()
  617. {
  618. background = true;
  619. }
  620. public override string package(params object[] args)
  621. {
  622. //$ <UNo> (<SeqNo>) MTPT <TrsSt> <SlotNo> <NextMtn> <Posture> <TrsPnt> <Sum> <CR>
  623. _chamber = (ModuleName)args[0];
  624. _slot = (int)args[1];
  625. _hand = (Hand)args[2];
  626. updateBefore();
  627. return string.Format(",MTPT,{0},{1:D2},G{2},A,Pb,",
  628. RobotConvertor.chamber2staion(_chamber),
  629. RobotConvertor.chamberSlot2Slot(_chamber, _slot + 1),
  630. RobotConvertor.hand2string(_hand));
  631. }
  632. private void updateBefore()
  633. {
  634. _device.Blade1Target = _chamber;
  635. _device.Blade2Target = _chamber;
  636. string arm = _hand == Hand.Blade1 ? "A" : "B";
  637. _device.CmdBladeTarget = $"{_chamber}.{arm}";
  638. _device.CmdBlade1Extend = _hand == Hand.Blade1 ? "1" : "0";
  639. _device.CmdBlade2Extend = _hand == Hand.Blade1 ? "0" : "1";
  640. }
  641. }
  642. public class PlaceRetractHandler : RobotMotionHandler
  643. {
  644. private ModuleName _chamber;
  645. private int _slot;
  646. private Hand _hand;
  647. public PlaceRetractHandler()
  648. {
  649. background = true;
  650. }
  651. public override string package(params object[] args)
  652. {
  653. //$ <UNo> (<SeqNo>) MPNT <TrsPnt> <Sum> <CR>
  654. _chamber = (ModuleName)args[0];
  655. _slot = (int)args[1];
  656. _hand = (Hand)args[2];
  657. updateBefore();
  658. return ",MPNT,P4,";
  659. }
  660. private void updateBefore()
  661. {
  662. _device.Blade1Target = _chamber;
  663. _device.Blade2Target = _chamber;
  664. string arm = _hand == Hand.Blade1 ? "A" : "B";
  665. _device.CmdBladeTarget = $"{_chamber}.{arm}";
  666. _device.CmdBlade1Extend = _hand == Hand.Blade1 ? "1" : "0";
  667. _device.CmdBlade2Extend = _hand == Hand.Blade1 ? "0" : "1";
  668. }
  669. protected override void update(string[] data)
  670. {
  671. if (_hand == Hand.Both)
  672. {
  673. WaferManager.Instance.WaferMoved(ModuleHelper.Converter(_device.Name), (int)Hand.Blade1, _chamber, _slot);
  674. WaferManager.Instance.WaferMoved(ModuleHelper.Converter(_device.Name), (int)Hand.Blade2, _chamber, _slot + 1);
  675. }
  676. else
  677. {
  678. WaferManager.Instance.WaferMoved(ModuleHelper.Converter(_device.Name), (int)_hand, _chamber, _slot);
  679. }
  680. string arm = _hand == Hand.Blade1 ? "A" : "B";
  681. _device.CmdBladeTarget = $"{_chamber}.{arm}";
  682. _device.CmdBlade1Extend = "0";
  683. _device.CmdBlade2Extend = "0";
  684. _device.Blade1Target = ModuleHelper.Converter(_device.Name);
  685. _device.Blade2Target = ModuleHelper.Converter(_device.Name);
  686. }
  687. }
  688. public class ExchangeHandler : RobotMotionHandler
  689. {
  690. private ModuleName _chamber;
  691. private int _slot;
  692. private Hand _hand;
  693. public ExchangeHandler()
  694. {
  695. background = true;
  696. }
  697. public override string package(params object[] args)
  698. {
  699. // $ <UNo> (<SeqNo>) MTRE <TrsSt> <SlotNo> <MtnMode> <Posture> <Sum> <CR>
  700. _chamber = (ModuleName)args[0];
  701. _slot = (int)args[1];
  702. _hand = (Hand)args[2];
  703. if (_hand == Hand.Blade1)
  704. _hand = Hand.Blade2;
  705. else
  706. _hand = Hand.Blade1;
  707. updateBefore();
  708. return string.Format(",MTRE,{0},{1:D2},E{2},A,",
  709. RobotConvertor.chamber2staion(_chamber),
  710. RobotConvertor.chamberSlot2Slot(_chamber, _slot),
  711. RobotConvertor.hand2string(_hand));
  712. }
  713. private void updateBefore()
  714. {
  715. _device.Blade1Target = _chamber;
  716. _device.Blade2Target = _chamber;
  717. _device.Swap = true;
  718. _device.PlaceBalde = _hand;
  719. }
  720. protected override void update(string[] data)
  721. {
  722. if (_hand == Hand.Blade2)
  723. {
  724. WaferManager.Instance.WaferMoved(_chamber, _slot, ModuleHelper.Converter(_device.Name), (int)Hand.Blade2);
  725. WaferManager.Instance.WaferMoved(ModuleHelper.Converter(_device.Name), (int)Hand.Blade1, _chamber, _slot);
  726. }
  727. else
  728. {
  729. WaferManager.Instance.WaferMoved(_chamber, _slot, ModuleHelper.Converter(_device.Name), (int)Hand.Blade1);
  730. WaferManager.Instance.WaferMoved(ModuleHelper.Converter(_device.Name), (int)Hand.Blade2, _chamber, _slot);
  731. }
  732. _device.Swap = false;
  733. _device.Blade1Target = ModuleHelper.Converter(_device.Name);
  734. _device.Blade2Target = ModuleHelper.Converter(_device.Name);
  735. }
  736. }
  737. public class GotoHandler : RobotMotionHandler
  738. {
  739. private ModuleName _chamber;
  740. private int _slot;
  741. private Motion _next;
  742. private Hand _hand;
  743. public GotoHandler()
  744. {
  745. background = true;
  746. }
  747. public override string package(params object[] args)
  748. {
  749. //Move to ready position with specified adjustment offset
  750. //$<UNo>(<SeqNo>) MTRO <TrsSt> <SlotNo> <NextMtn> <Posture> <OffsetX> <OffsetY> <OffsetZ> <Sum>
  751. //• OffsetN: Offset(5 bytes each)
  752. //• OffsetX: X direction offset
  753. //• OffsetY: Y direction offset
  754. //• OffsetZ: Z direction offset
  755. //• Specified in the range between "-9999" and "99999"(Resolution: 0.01[mm])
  756. //• If value is less than 5 digits, fill the higher digit with ‘0’ so that the field always has 5 digits.
  757. _chamber = (ModuleName)args[0];
  758. _slot = (int)args[1];
  759. _next = (Motion)args[2];
  760. _hand = (Hand)args[3];
  761. int x = (int)args[4];
  762. int y = (int)args[5];
  763. int z = (int)args[6];
  764. updateBefore();
  765. return string.Format(",MTRO,{0},{1:D2},{2},A,{3},{4},{5}",
  766. RobotConvertor.chamber2staion(_chamber),
  767. RobotConvertor.chamberSlot2Slot(_chamber, _slot),
  768. RobotConvertor.NextMotion2String(_next, _hand),
  769. RobotConvertor.Offset2String(x),
  770. RobotConvertor.Offset2String(y),
  771. RobotConvertor.Offset2String(z)
  772. ); ;
  773. }
  774. private void updateBefore()
  775. {
  776. if(_hand == Hand.Blade1)
  777. _device.Blade1Target = _chamber;
  778. else if (_hand == Hand.Blade2)
  779. _device.Blade2Target = _chamber;
  780. else
  781. {
  782. _device.Blade1Target = _chamber;
  783. _device.Blade2Target = _chamber;
  784. }
  785. }
  786. }
  787. public class PickHandlerEx : RobotMotionHandler
  788. {
  789. private ModuleName _chamber;
  790. private int _slot;
  791. private Hand _hand;
  792. public PickHandlerEx()
  793. {
  794. background = true;
  795. }
  796. public override string package(params object[] args)
  797. {
  798. //Move to ready position and get wafer with adjustment offset(MTRO+MGET)
  799. //$ < UNo > (< SeqNo >) MTGO<TrsSt> < SlotNo > < NextMtn > < Posture > < OffsetX > < OffsetY > < OffsetZ > < Sum > < CR >
  800. //• UNo: Unit number(1 byte)
  801. //• ‘1’ to ‘4’: Unit specified
  802. //• SeqNo: Sequence number(Non/ 1 / 2 / 3 byte)
  803. //• TrsSt: Transfer station(2 bytes)
  804. //• "C1" to "C8": When cassette stage specified
  805. //• "S1" to "SC": When transfer stage specified
  806. //• "P1" to “P2”: When P/ A stage specified
  807. //Note: P2 station is effective only when two or more PA stations exist.
  808. //• SlotNo: Slot number(2 bytes)
  809. //• "01" to "XX": When cassette stage specified by<TrsST>
  810. //(The maximum value of "XX" is in the ASCII code of the number of slots specified by parameter.)
  811. //• "00": When transfer stage or P / A stage specified by < TrsSt >
  812. //• NextMtn: Next motion mode(2 bytes)
  813. //• "GA": Next motion is wafer Get motion with extension axis 1(Blade 1).
  814. //• "GB": Next motion is wafer Get motion with extension axis 2(Blade 2).
  815. //• "GW": Next motion is wafer Get motion with extension axis 1 and 2(Blade 1 and 2). < WGet motion >
  816. //Note 1.The motion of extension axis 2(or blade 2) is available only for a dual-arm manipulator and dual blade
  817. //linear motion manipulator.
  818. //2.The WGet motion is available for a dual-arm manipulator and dual blade linear motion manipulator.
  819. _chamber = (ModuleName)args[0];
  820. _slot = (int)args[1];
  821. _hand = (Hand)args[2];
  822. int x = (int)args[3];
  823. int y = (int)args[4];
  824. int z = (int)args[5];
  825. updateBefore();
  826. if (_hand == Hand.Both)
  827. {
  828. return string.Format(",MTGO,{0},{1:D2},G{2},A,{3},{4},{5}",
  829. RobotConvertor.chamber2staion(_chamber),
  830. RobotConvertor.chamberSlot2Slot(_chamber, _slot + 1),
  831. RobotConvertor.hand2string(_hand),
  832. RobotConvertor.Offset2String(x),
  833. RobotConvertor.Offset2String(y),
  834. RobotConvertor.Offset2String(z)
  835. );
  836. }
  837. return string.Format(",MTGO,{0},{1:D2},G{2},A,{3},{4},{5}",
  838. RobotConvertor.chamber2staion(_chamber),
  839. RobotConvertor.chamberSlot2Slot(_chamber, _slot),
  840. RobotConvertor.hand2string(_hand),
  841. RobotConvertor.Offset2String(x),
  842. RobotConvertor.Offset2String(y),
  843. RobotConvertor.Offset2String(z)
  844. );
  845. }
  846. private void updateBefore()
  847. {
  848. _device.Blade1Target = _chamber;
  849. _device.Blade2Target = _chamber;
  850. string arm = _hand == Hand.Blade1 ? "A" : "B";
  851. _device.CmdBladeTarget = $"{_chamber}.{arm}";
  852. _device.CmdBlade1Extend = _hand == Hand.Blade1 ? "1" : "0";
  853. _device.CmdBlade2Extend = _hand == Hand.Blade1 ? "0" : "1";
  854. }
  855. protected override void update(string[] data)
  856. {
  857. if (_hand == Hand.Blade1)
  858. {
  859. WaferManager.Instance.WaferMoved(_chamber, _slot, ModuleHelper.Converter(_device.Name), (int)Hand.Blade1);
  860. }
  861. else if (_hand == Hand.Blade2)
  862. {
  863. for (int i = 0; i < _device.Blade2Slots; i++)
  864. WaferManager.Instance.WaferMoved(_chamber, _slot + i, ModuleHelper.Converter(_device.Name), (int)Hand.Blade2 + i);
  865. }
  866. else
  867. {
  868. for (int i = 0; i < _device.Blade2Slots + 1; i++)
  869. WaferManager.Instance.WaferMoved(_chamber, _slot + i, ModuleHelper.Converter(_device.Name), (int)Hand.Blade1 + i);
  870. }
  871. string arm = _hand == Hand.Blade1 ? "A" : "B";
  872. _device.CmdBladeTarget = $"{_chamber}.{arm}";
  873. _device.CmdBlade1Extend = "0";
  874. _device.CmdBlade2Extend = "0";
  875. _device.Blade1Target = ModuleHelper.Converter(_device.Name);
  876. _device.Blade2Target = ModuleHelper.Converter(_device.Name);
  877. }
  878. }
  879. public class PlaceHandlerEx : RobotMotionHandler
  880. {
  881. private ModuleName _chamber;
  882. private int _slot;
  883. private Hand _hand;
  884. public PlaceHandlerEx()
  885. {
  886. background = true;
  887. }
  888. public override string package(params object[] args)
  889. {
  890. _chamber = (ModuleName)args[0];
  891. _slot = (int)args[1];
  892. _hand = (Hand)args[2];
  893. int x = (int)args[3];
  894. int y = (int)args[4];
  895. int z = (int)args[5];
  896. updateBefore();
  897. if (_hand == Hand.Both)
  898. {
  899. return string.Format(",MTPO,{0},{1:D2},P{2},A,{3},{4},{5}",
  900. RobotConvertor.chamber2staion(_chamber),
  901. RobotConvertor.chamberSlot2Slot(_chamber, _slot + 1),
  902. RobotConvertor.hand2string(_hand),
  903. RobotConvertor.Offset2String(x),
  904. RobotConvertor.Offset2String(y),
  905. RobotConvertor.Offset2String(z)
  906. );
  907. }
  908. return string.Format(",MTPO,{0},{1:D2},P{2},A,{3},{4},{5}",
  909. RobotConvertor.chamber2staion(_chamber),
  910. RobotConvertor.chamberSlot2Slot(_chamber, _slot),
  911. RobotConvertor.hand2string(_hand),
  912. RobotConvertor.Offset2String(x),
  913. RobotConvertor.Offset2String(y),
  914. RobotConvertor.Offset2String(z)
  915. );
  916. }
  917. private void updateBefore()
  918. {
  919. _device.Blade1Target = _chamber;
  920. _device.Blade2Target = _chamber;
  921. string arm = _hand == Hand.Blade1 ? "A" : "B";
  922. _device.CmdBladeTarget = $"{_chamber}.{arm}";
  923. _device.CmdBlade1Extend = _hand == Hand.Blade1 ? "1" : "0";
  924. _device.CmdBlade2Extend = _hand == Hand.Blade1 ? "0" : "1";
  925. }
  926. protected override void update(string[] data)
  927. {
  928. if (_hand == Hand.Blade1)
  929. {
  930. WaferManager.Instance.WaferMoved(ModuleHelper.Converter(_device.Name), (int)Hand.Blade1, _chamber, _slot);
  931. }
  932. else if (_hand == Hand.Blade2)
  933. {
  934. for (int i = 0; i < _device.Blade2Slots; i++)
  935. WaferManager.Instance.WaferMoved(ModuleHelper.Converter(_device.Name), (int)Hand.Blade2 + i, _chamber, _slot + i);
  936. }
  937. else
  938. {
  939. for (int i = 0; i < _device.Blade2Slots + 1; i++)
  940. WaferManager.Instance.WaferMoved(ModuleHelper.Converter(_device.Name), (int)Hand.Blade1 + i, _chamber, _slot + i);
  941. }
  942. _device.Blade1Target = ModuleHelper.Converter(_device.Name);
  943. _device.Blade2Target = ModuleHelper.Converter(_device.Name);
  944. string arm = _hand == Hand.Blade1 ? "A" : "B";
  945. _device.CmdBladeTarget = $"{_chamber}.{arm}";
  946. _device.CmdBlade1Extend = "0";
  947. _device.CmdBlade2Extend = "0";
  948. }
  949. }
  950. //NOT SUPPORT with OFFSET
  951. //public class ExchangeHandlerEx : RobotMotionHandler
  952. //{
  953. // private ModuleName _chamber;
  954. // private int _slot;
  955. // private Hand _hand;
  956. // public ExchangeHandlerEx()
  957. // {
  958. // background = true;
  959. // }
  960. // public override string package(params object[] args)
  961. // {
  962. // // $ <UNo> (<SeqNo>) MEXG <Sum> <CR>
  963. // _chamber = (ModuleName)args[0];
  964. // _slot = (int)args[1];
  965. // _hand = (Hand)args[2];
  966. // if (_hand == Hand.Blade1)
  967. // _hand = Hand.Blade2;
  968. // else
  969. // _hand = Hand.Blade1;
  970. // updateBefore();
  971. // int x = (int)args[3];
  972. // int y = (int)args[4];
  973. // int z = (int)args[5];
  974. // updateBefore();
  975. // if (_hand == Hand.Both)
  976. // {
  977. // return string.Format(",MTPO,{0},{1:D2},G{2},A,{3},{4},{5}",
  978. // RobotConvertor.chamber2staion(_chamber),
  979. // RobotConvertor.chamberSlot2Slot(_chamber, _slot + 1),
  980. // RobotConvertor.hand2string(_hand),
  981. // RobotConvertor.Offset2String(x),
  982. // RobotConvertor.Offset2String(y),
  983. // RobotConvertor.Offset2String(z)
  984. // );
  985. // }
  986. // return string.Format(",MTPO,{0},{1:D2},G{2},A,{3},{4},{5}",
  987. // RobotConvertor.chamber2staion(_chamber),
  988. // RobotConvertor.chamberSlot2Slot(_chamber, _slot),
  989. // RobotConvertor.hand2string(_hand),
  990. // RobotConvertor.Offset2String(x),
  991. // RobotConvertor.Offset2String(y),
  992. // RobotConvertor.Offset2String(z));
  993. // }
  994. // private void updateBefore()
  995. // {
  996. // _device.Blade1Target = _chamber;
  997. // _device.Blade2Target = _chamber;
  998. // _device.Swap = true;
  999. // _device.PlaceBalde = _hand;
  1000. // }
  1001. // protected override void update(string[] data)
  1002. // {
  1003. // if (_hand == Hand.Blade2)
  1004. // {
  1005. // WaferManager.Instance.WaferMoved(_chamber, _slot, ModuleName.Robot, (int)Hand.Blade2);
  1006. // WaferManager.Instance.WaferMoved(ModuleName.Robot, (int)Hand.Blade1, _chamber, _slot);
  1007. // }
  1008. // else
  1009. // {
  1010. // WaferManager.Instance.WaferMoved(_chamber, _slot, ModuleName.Robot, (int)Hand.Blade1);
  1011. // WaferManager.Instance.WaferMoved(ModuleName.Robot, (int)Hand.Blade2, _chamber, _slot);
  1012. // }
  1013. // _device.Swap = false;
  1014. // _device.Blade1Target = ModuleName.Robot;
  1015. // _device.Blade2Target = ModuleName.Robot;
  1016. // }
  1017. //}
  1018. public class RBWaferMappingHandler : RobotMotionHandler
  1019. {
  1020. private ModuleName _chamber;
  1021. public RBWaferMappingHandler()
  1022. {
  1023. background = true;
  1024. }
  1025. public override string package(params object[] args)
  1026. {
  1027. //$ <UNo> (<SeqNo>) MMAP <TrsSt> <SlotNo> <Sum> <CR>
  1028. // SlotNo: Slot number(2 bytes)
  1029. //• "FF": When all slots specified
  1030. //• ”01” to ”XX”: When cassette stage is specified by < TrsSt >
  1031. //(The maximum value of "XX" is in ASCII code of the number of slots specified by parameter.)
  1032. //• ”00”: When transfer stage or P / A stage specified by<TrsSt>
  1033. // Note: Specific slot section definition cannot be performed.
  1034. //• Reception rejected: Responds with the error code.
  1035. _chamber = (ModuleName)args[0];
  1036. //_slot = (int)args[1];
  1037. //_hand = (Hand)args[2];
  1038. updateBefore();
  1039. return string.Format(",MMAP,{0},FF,",
  1040. RobotConvertor.chamber2staion(_chamber));
  1041. }
  1042. private void updateBefore()
  1043. {
  1044. _device.Blade1Target = _chamber;
  1045. _device.Blade2Target = _chamber;
  1046. }
  1047. }
  1048. public class RBQueryWaferMapHandler : ITransferMsg
  1049. {
  1050. public bool background { get; protected set; }
  1051. public bool evt { get { return false; } }
  1052. public string deviceID { private get; set; }
  1053. public string _cmd = string.Empty;
  1054. private ModuleName _chamber;
  1055. public IDevice Robot { set { _device = (Robot)value; } }
  1056. protected Robot _device;
  1057. public RBQueryWaferMapHandler()
  1058. {
  1059. background = false;
  1060. }
  1061. //$ <UNo> (<SeqNo>) RMAP <TrsSt> <SlotNo> <Sum> <CR>
  1062. public string package(params object[] args)
  1063. {
  1064. _chamber = (ModuleName)args[0];
  1065. return string.Format(",RMAP,{0},FF,",
  1066. RobotConvertor.chamber2staion(_chamber));
  1067. }
  1068. public bool unpackage(string type, string[] items)
  1069. {
  1070. //$,<UNo>(,<SeqNo>),<Sts>,<Ackcd>,RMAP,<TrsSt>,<Slot>,
  1071. //01:<Result1>…,N:<ResultN>(,<Sum>)<CR>
  1072. //• UNo : Unit number (1 byte)
  1073. //• SeqNo : Sequence number (None / 2 bytes)
  1074. //• Sts : Status (2 bytes)
  1075. //• Ackcd : Response code (4 bytes)
  1076. //• TrsSt : Transfer station (3 bytes)
  1077. //• Slot : Slot number (2 bytes)
  1078. //• Result* : Mapping result (2 bytes each)
  1079. //• “--” : No wafer detected.
  1080. //• “OK” : Wafer inserted correctly.
  1081. //• “CW” : Wafer inserted incorrectly (inclined).
  1082. //• “DW” : Wafer inserted incorrectly (duplicated).
  1083. //Note) Responds with the number of slots of the specified transfer station.
  1084. //$,1,00,0000,RMAP,C02,00,
  1085. //01:OK,02:DW,03:OK,04:CW,05:CW,06:OK,07:OK,08:--,09:OK,10:OK
  1086. // No wafer: "0", Wafer: "1", Crossed:"2", Undefined: "?", Overlapping wafers: "W"
  1087. if (items.Length > 5)
  1088. {
  1089. string data = items[5];
  1090. StringBuilder sb = new StringBuilder();
  1091. for (int i = 0; i < data.Length; i += 4)
  1092. {
  1093. string value = data.Substring(i + 2, 2);
  1094. switch (value)
  1095. {
  1096. case "--":
  1097. sb.Append("0");
  1098. break;
  1099. case "OK":
  1100. sb.Append("1");
  1101. break;
  1102. case "CW":
  1103. sb.Append("2");
  1104. break;
  1105. case "DW":
  1106. sb.Append("W");
  1107. break;
  1108. }
  1109. }
  1110. _device.NotifySlotMapResult(_chamber, sb.ToString());
  1111. return true;
  1112. }
  1113. return !background;
  1114. }
  1115. }
  1116. // Transfer speed level setting
  1117. public class RbSetSpeedHandler : RobotMotionHandler
  1118. {
  1119. private int _speed = 0;
  1120. public RbSetSpeedHandler()
  1121. {
  1122. background = false;
  1123. }
  1124. public override string package(params object[] args)
  1125. {
  1126. _speed = (int)args[0];
  1127. //$ < UNo > (< SeqNo >) SSLV<Level> < Sum > < CR >
  1128. ///
  1129. /// • ’H’ : High speed level
  1130. //• ’M’ : Medium speed level
  1131. //• ’L’ : Low speed level
  1132. ///
  1133. if(_speed == 1)
  1134. return string.Format(",SSLV,H,");
  1135. else if (_speed == 2)
  1136. return string.Format(",SSLV,M,");
  1137. return string.Format(",SSLV,L,");
  1138. }
  1139. }
  1140. // Transfer speed level setting
  1141. public class RbSetOffsetHandler : RobotMotionHandler
  1142. {
  1143. public RbSetOffsetHandler()
  1144. {
  1145. background = false;
  1146. }
  1147. public override string package(params object[] args)
  1148. {
  1149. //$ <UNo> (<SeqNo>) SOFS <Mem> <TrsSt> <Offset1> <Offset2> … <Offset5> <Sum> <CR>
  1150. ///Mem: Memory (1 byte) ‘V’: Volatile memory ‘N’: Non -volatile memory
  1151. //• TrsSt: Transfer station(2 bytes)
  1152. //• "C1" to "C8": When cassette stage specified
  1153. //• "S1" to "SC": When transfer stage specified
  1154. //• "P1" to “P2”: When P/ A stage specified
  1155. //Note: P2 station is effective only when two or more PA stations exist.
  1156. //• Offset: Transfer offset(4 bytes each)
  1157. //• Offset1: Downward offset
  1158. //• Offset2: Upward offset
  1159. //• Offset3: Offset in the extending direction(with the edge - grip - type fork)
  1160. //• Offset4: Offset in the retracting direction(with the edge - grip - type fork)
  1161. //• Offset5: Put downward offset(with the edge - grip - type fork)
  1162. //Note: Offset3 to Offset5 are omitted when the fork type is not the edge - grip type.
  1163. //• About Offset3 to Offset5, it is omissible with a parameter setup.
  1164. //• Specified in the range between "-999" and "9999"(resolution: 0.01[mm])
  1165. //• If a value is less than specified digits, fill the higher digit with ‘0’ so that the field always has specfied digits.
  1166. ModuleName _chamber = (ModuleName)args[0];
  1167. int down = (int)args[1];
  1168. int up = (int)args[2];
  1169. int extend = (int)args[2];
  1170. int retract = (int)args[2];
  1171. int pdown = (int)args[2];
  1172. return string.Format(",SOFS,V,{0},{1:D4},{2:D4},{3:D4},{4:D4},",
  1173. RobotConvertor.chamber2staion(_chamber),
  1174. down,
  1175. up,
  1176. extend,
  1177. retract,
  1178. pdown
  1179. );
  1180. }
  1181. }
  1182. public class RBQueryStateHandler : ITransferMsg
  1183. {
  1184. public bool background { get; protected set; }
  1185. public bool evt { get { return false; } }
  1186. public string deviceID { private get; set; }
  1187. public string _cmd = string.Empty;
  1188. public IDevice Robot { set { _device = (Robot)value; } }
  1189. protected Robot _device;
  1190. public RBQueryStateHandler()
  1191. {
  1192. background = false;
  1193. }
  1194. //$ <UNo> (<SeqNo>) <StsN> <Ackcd> <Sum> <CR>
  1195. //$ <UNo> (<SeqNo>) <StsN> <Ackcd> <Errcd> <Status1> … <Status4> <Sum> <CR>
  1196. public string package(params object[] args)
  1197. {
  1198. return ",RSTS,";
  1199. }
  1200. public bool unpackage(string type, string[] items)
  1201. {
  1202. return !background;
  1203. }
  1204. }
  1205. public class RbEventHandler : ITransferMsg
  1206. {
  1207. public bool background { get { return false; } }
  1208. public bool evt { get { return true; } }
  1209. public string deviceID { private get; set; }
  1210. public string _cmd = string.Empty;
  1211. public IDevice Robot { set { _device = (Robot)value; } }
  1212. protected Robot _device;
  1213. public RbEventHandler()
  1214. {
  1215. }
  1216. //$,<UNo>(,<SeqNo>),RSTS(,<Sum>)<CR>
  1217. public string package(params object[] args)
  1218. {
  1219. return "";
  1220. }
  1221. public bool unpackage(string type, string[] items)
  1222. {
  1223. string evtType = items[3];
  1224. if (evtType.Equals(ProtocolTag.resp_evt_error))
  1225. {
  1226. int error = Convert.ToInt32(items[5], 16);
  1227. _device.ErrorCode = error;
  1228. if (error > 0)
  1229. _device.LastErrorCode = error;
  1230. return true;
  1231. }
  1232. return false;
  1233. }
  1234. }
  1235. public class RBQueryPositionHandler : ITransferMsg
  1236. {
  1237. public bool background { get; protected set; }
  1238. public bool evt { get { return false; } }
  1239. public string deviceID { private get; set; }
  1240. public string _cmd = string.Empty;
  1241. public IDevice Robot { set { _device = (Robot)value; } }
  1242. protected Robot _device;
  1243. public RBQueryPositionHandler()
  1244. {
  1245. background = false;
  1246. }
  1247. //$ <UNo> (<SeqNo>) RPOS <TrsSt> <Fork> <Posture> <Sum> <CR>
  1248. // • TrsSt: Transfer station(2 bytes)
  1249. //• "C1" to "C8": When the lowest-layer position of the cassette stage specified
  1250. //• "H1" to "H8": When the highest-layer position of the cassette stage specified
  1251. //• "S1" to "SC": When transfer stage specified
  1252. //• "P1" to “P2”: When P/A stage specified
  1253. //Note: P2 station is effective only when two or more PA stations exist.
  1254. //• "FF": When current position specified
  1255. //• "FE": When specify the feedback of present location
  1256. //<Three-axis pre-aligner, Edge-grip pre-aligner>
  1257. //• "FF": When current position specified
  1258. //• "FE": When specify the feedback of present location
  1259. //• Fork: Fork specified(1 byte)
  1260. //• ‘A’: When extension axis 1 (Blade 1) specified
  1261. //• ‘B’: When extension axis 2 (Blade 2) specified(for dual-arm manipulator and dual blade linear motion
  1262. //manipulator only)
  1263. //Note: Fixed to ‘A’ when the current position and feedback of present location are specified at<TrsSt>
  1264. public string package(params object[] args)
  1265. {
  1266. return ",RPOS,FF,A,A,";
  1267. }
  1268. public bool unpackage(string type, string[] items)
  1269. {
  1270. //$ <UNo> (<SeqNo>) <StsN> <Ackcd> <Value1> … <ValueN> <Sum> <CR>
  1271. // • ValueN: Coordinate(8 bytes each)
  1272. //• Specified in the range as follows (The resolution is 0.01[mm] or[deg])
  1273. //8 Byte: between "-9999999" ~"99999999"
  1274. //• If a value is less than specified digits, fill the higher digit with ‘0’ so that the field always has specfied digits.
  1275. //• The sign is added to the highest digit.
  1276. //• The number of “ValueN” depends on the unit type.
  1277. //Responds with as many axis numbers as the specified unit has.See the table bellow.
  1278. //Unit Value1 Value2 Value3 Value4 Value5 Value6
  1279. //Single - arm manipulator Rotation //Elevation //(Track
  1280. //Dual - arm manipulator Rotation //Extension //axis 1 //axis 2 //(Track
  1281. if (items.Length > 7)
  1282. {
  1283. _device.Rotation = int.Parse(items[7]);
  1284. _device.Extension = int.Parse(items[8]);
  1285. _device.Wrist1 = int.Parse(items[9]);
  1286. _device.Wrist2 = int.Parse(items[10]);
  1287. _device.Evevation = int.Parse(items[11]);
  1288. return true;
  1289. }
  1290. return !background;
  1291. }
  1292. }
  1293. }