Handler.cs 72 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067
  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. using Aitex.Core.Common;
  11. namespace MECF.Framework.RT.EquipmentLibrary.HardwareUnits.Robot.NX100
  12. {
  13. /*
  14. * A command is transmitted from the host in the following format.
  15. * $ UNo (SeqNo) COMMAND Parameter Sum CR\
  16. * • $: Start mark (1 byte)
  17. Indicates the start of the message.
  18. • UNo: Unit No. (1 byte)
  19. Indicates the unit number
  20. • SeqNo: Sequence number (Non/1/2/3 bytes)
  21. Sequence number is used to avoid duplicate motion when sending of
  22. commands improperly. An integer parameter can specify the length of
  23. SeqNo. (Non/1/2/3 bytes). See parameter table for more details. (Default:
  24. Non), 设置 2bytes
  25. • Parameter: Parameter (Differs depending on the command.)
  26. Sets the operation axis, the moving amount, etc. following a command.
  27. • Sum: Checksum (2 bytes)
  28. This information is used for the communications error check.
  29. Calculate the sum of the ASCII characters (‘0’ to ‘9’ and ‘A’ to ‘F’), in “Uno”,
  30. “COMMAND” and “Parameter” section, and take the lowest tow digit.
  31. */
  32. public class handler<T> : IHandler where T : ITransferMsg, new()
  33. {
  34. public int ID { get; set; }
  35. public int Unit { get; set; }
  36. public bool IsBackground { get { return _imp.background; } }
  37. private static int retry_time = 3;
  38. private int retry_count = retry_time;
  39. private object[] _objs = null;
  40. private TokenGenerator _generator;
  41. private T _imp = new T();
  42. private List<string> _words = new List<string>();
  43. public handler(IDevice device)
  44. {
  45. _imp.Robot = device;
  46. }
  47. public handler(IDevice device, ref TokenGenerator gen, params object[] objs)
  48. {
  49. _imp.Robot = device;
  50. this._generator = gen;
  51. this._objs = objs;
  52. }
  53. public bool Execute<TPort>(ref TPort port) where TPort : ICommunication
  54. {
  55. retry_count = retry_time;
  56. ID = _generator.create();
  57. return port.Write(string.Format("{0}{1}{2}", ProtocolTag.tag_cmd_start, package().Replace(",", ""), ProtocolTag.tag_end));
  58. }
  59. /// <summary>
  60. /// return value: bhandle
  61. /// </summary>
  62. /// <typeparam name="TPort"></typeparam>
  63. /// <param name="port"></param>
  64. /// <param name="msg"></param>
  65. /// <param name="completed"></param>
  66. /// <returns></returns>
  67. ///
  68. public bool OnMessage<TPort>(ref TPort port, string message, out bool completed) where TPort : ICommunication
  69. {
  70. //$1E000003AC0300010
  71. //message = ">,1,EVNT,100,2018/11/16 17:01:06,2BA0,A1";
  72. //message = " !,1,36,40,2BA0,MTRS,002200,-0011931,-0610171,00179995,00049818,00186336,57";
  73. //message = "!,1,16,40,0000,MTCH,000483,-0011862,00000000,00179516,00090369,00172882,0A";
  74. //message = "$156000000RMAPC2FF01OK02OK03OK04OK05OK06OK07OK08OK09--10--11--12--13--14--15--16--17--18--19--20--21--22--23--24--25--96";
  75. //message =!283000000MALNE5.
  76. try
  77. {
  78. completed = false;
  79. string package = message;
  80. _words.Clear();
  81. string type = package.Substring(0,1);
  82. _words.Add(type);
  83. int unit = int.Parse(package.Substring(1, 1));
  84. _words.Add(package.Substring(1, 1));
  85. string sum = package.Substring(package.Length - 2, 2);
  86. string check = Checksum(package);
  87. if (sum != check)
  88. {
  89. throw (new InvalidPackageException(string.Format("check sum error{0}", package)));
  90. }
  91. if (type != ProtocolTag.resp_tag_event && type != ProtocolTag.resp_tag_error)
  92. {
  93. _words.Add(package.Substring(2, 2));
  94. int seq = int.Parse(package.Substring(2,2));
  95. if (seq != ID)
  96. return false;
  97. if (unit != Unit)
  98. {
  99. throw (new InvalidPackageException(string.Format("invalid unit {0}", package)));
  100. }
  101. }
  102. if (type == ProtocolTag.resp_tag_error)
  103. {
  104. //? Ackcd Sum CR
  105. string error = package.Substring(1,4);
  106. //‘1’: Warning 1 (W1), ‘2’: Warning 2 (W2), ‘3’: Important alarm 1 (A1), ‘4’: Important alarm 2 (A2),
  107. //‘5’: Serious alarm (F)
  108. if (error[0] != '1' || error[0] != '2')
  109. {
  110. string warning = string.Format("can't execute retry, {0}", error);
  111. LOG.Warning(warning);
  112. throw (new ExcuteFailedException(warning));
  113. }
  114. if (retry_count-- <= 0)
  115. {
  116. string warning = string.Format("retry over {0} times", retry_time);
  117. LOG.Warning(warning);
  118. throw (new ExcuteFailedException(warning));
  119. }
  120. port.Write(string.Format("{0}{1}{2}", ProtocolTag.tag_cmd_start, this.package(), ProtocolTag.tag_end));
  121. return true;
  122. }
  123. else if (type == ProtocolTag.resp_tag_event)
  124. {
  125. //0 1 2-3 4-7 8-10
  126. //> UNo SeqNo COMMAND EvNo EvData Sum CR
  127. //• COMMAND : Command (4 Byte) EVNT(Fixed length)
  128. //• EvNo: Event number(
  129. _words.Add(package.Substring(4, 4)); //stsN
  130. string evtType = package.Substring(8, 10);
  131. _words.Add(evtType); //Errcd
  132. string evtInfo = package.Substring(11, package.Length - 10 -2 );
  133. _words.Add(evtInfo); //Errcd
  134. if (_imp.evt)
  135. completed = _imp.unpackage(type, _words.ToArray());
  136. return _imp.evt;
  137. }
  138. else
  139. {
  140. //0 1 2,3 4,5 6-9
  141. //! UNo (SeqNo) StsN Errcd COMMAND Sum
  142. _words.Add(package.Substring(4, 2)); //stsN
  143. string error = package.Substring(6, 4);
  144. //int intError = Convert.ToInt32(error, 16);
  145. if (error != "0000")
  146. {
  147. string warning = string.Format("Robot execute failed, return error {0}", error);
  148. throw (new ExcuteFailedException(warning));
  149. }
  150. _words.Add(error); //Errcd
  151. _words.Add(package.Substring(10, package.Length - 10 -2)) ; //COMMAND
  152. completed = _imp.unpackage(type, _words.ToArray());
  153. if (completed)
  154. {
  155. _generator.release(ID);
  156. if (_imp.background)
  157. {
  158. ID = this._generator.create();
  159. port.Write(string.Format("{0}{1}{2}", ProtocolTag.tag_cmd_start, ackn(), ProtocolTag.tag_end));
  160. _generator.release(ID);
  161. }
  162. //wait 2ms
  163. return true;
  164. }
  165. return true;
  166. }
  167. }
  168. catch (ExcuteFailedException e)
  169. {
  170. throw (e);
  171. }
  172. catch (InvalidPackageException e)
  173. {
  174. throw e;
  175. }
  176. catch (Exception ex)
  177. {
  178. LOG.Write(ex);
  179. throw (new InvalidPackageException(message));
  180. }
  181. }
  182. private string Checksum(string package)
  183. {
  184. int start = package.IndexOf(ProtocolTag.cmd_token);
  185. int end = package.LastIndexOf(ProtocolTag.cmd_token);
  186. start = 1;
  187. end = package.Length - 2 - 1;
  188. int len = end - start + 1;
  189. if (len > 1)
  190. {
  191. string data = package.Substring(start, len);
  192. return Checksum(Encoding.Default.GetBytes(data));
  193. }
  194. return "";
  195. }
  196. private string Checksum(byte[] bytes)
  197. {
  198. int sum = 0;
  199. foreach (byte code in bytes)
  200. {
  201. sum += code;
  202. }
  203. string hex = String.Format("{0:X2}", sum % 256);
  204. return hex;
  205. }
  206. private string package()
  207. {
  208. //$,<UNo>(,<SeqNo>),<Command>,<Parameter>(,<Sum>)<CR>
  209. string data = string.Empty;
  210. data = string.Format("{0:D1}{1:D2}{2}", Unit, ID, _imp.package(this._objs).Replace(",",""));
  211. string sum = Checksum(Encoding.ASCII.GetBytes(data));
  212. return data + sum;
  213. }
  214. private string ackn()
  215. {
  216. //$<UNo>(<SeqNo>)ACKN(<Sum>)<CR>
  217. string data = string.Empty;
  218. data = string.Format("{0:D1}{1:D2}ACKN", Unit, ID);
  219. string sum = Checksum(Encoding.ASCII.GetBytes(data));
  220. return data + sum;
  221. }
  222. }
  223. public class RobotMotionHandler : ITransferMsg
  224. {
  225. public bool background { get; protected set; }
  226. public bool evt { get { return false; } }
  227. public string deviceID { private get; set; }
  228. public string _cmd = string.Empty;
  229. public IDevice Robot { set { _device = (Robot)value; } }
  230. protected Robot _device;
  231. public RobotMotionHandler()
  232. {
  233. background = false;
  234. }
  235. public virtual string package(params object[] args)
  236. {
  237. return "";
  238. }
  239. public bool unpackage(string type, string[] items)
  240. {
  241. //! <UNo> (<SeqNo>) <StsN> <Errcd> MTRG <Sum> <CR>
  242. int value = Convert.ToInt32(items[3],16);
  243. _device.Status = value;
  244. int error = Convert.ToInt32(items[4], 16);
  245. _device.ErrorCode = error;
  246. if(error > 0)
  247. _device.LastErrorCode = error;
  248. if (type.Equals(ProtocolTag.resp_tag_excute))
  249. {
  250. //_device.ElapseTime = int.Parse(items[6]);
  251. //_device.Rotation = int.Parse(items[7]);
  252. //_device.Extension = int.Parse(items[8]);
  253. //_device.Wrist1= int.Parse(items[9]);
  254. //_device.Wrist2= int.Parse(items[10]);
  255. //_device.Evevation = int.Parse(items[11]);
  256. if (error == 0)
  257. {
  258. update(items);
  259. }
  260. return true;
  261. }
  262. return !background;
  263. }
  264. protected virtual void update(string[] data)
  265. {
  266. }
  267. }
  268. public class RbInitHandler : RobotMotionHandler
  269. {
  270. public RbInitHandler()
  271. {
  272. background = true;
  273. }
  274. public override string package(params object[] args)
  275. {
  276. //$ <UNo> (<SeqNo>) INIT<IMode> <Sum> <CR>
  277. // IMode: Initialization mode(2 Byte)
  278. //• ”00”: Error clear, servo ON and all axes move to home position
  279. //• ”01”: Servo ON and all axes move to home position
  280. //• ”05”: Error clear, servo ON and arm moves to home position.
  281. //• ”06”: Servo ON and arm moves to home position
  282. //• ”10”: Error clear and servo ON
  283. updateBefore();
  284. return ",INIT,00,";
  285. }
  286. protected void updateBefore()
  287. {
  288. _device.Blade1Target = ModuleHelper.Converter(_device.Name);
  289. _device.Blade2Target = ModuleHelper.Converter(_device.Name);
  290. }
  291. protected override void update(string[] data)
  292. {
  293. _device.Initalized = true;
  294. _device.Swap = false;
  295. }
  296. }
  297. public class RbHomeHandler : RobotMotionHandler
  298. {
  299. public RbHomeHandler()
  300. {
  301. background = true;
  302. }
  303. public override string package(params object[] args)
  304. {
  305. //$ < UNo > > (< SeqNo >) MHOM<MMode> < Sum > < CR >
  306. //• UNo: Unit number(1 byte)
  307. //• ‘1’ to ‘4’: Unit specified
  308. //• SeqNo: Sequence number(Non/ 1 / 2 / 3 byte)
  309. //• MMode: Motion mode(1 byte)
  310. //• ‘F’: All axes
  311. //• ‘A’: Arm(s) only
  312. updateBefore();
  313. return ",MHOM,F,";
  314. }
  315. protected void updateBefore()
  316. {
  317. _device.Blade1Target = ModuleHelper.Converter(_device.Name);
  318. _device.Blade2Target = ModuleHelper.Converter(_device.Name);
  319. _device.CmdBladeTarget = $"{_device.Name}.A";
  320. _device.CmdBlade1Extend = "0";
  321. _device.CmdBlade2Extend = "0";
  322. }
  323. protected override void update(string[] data)
  324. {
  325. _device.Initalized = true;
  326. _device.Swap = false;
  327. }
  328. }
  329. public class RbArmHomeHandler : RobotMotionHandler
  330. {
  331. public RbArmHomeHandler()
  332. {
  333. background = true;
  334. }
  335. public override string package(params object[] args)
  336. {
  337. //$ < UNo > > (< SeqNo >) MHOM<MMode> < Sum > < CR >
  338. //• UNo: Unit number(1 byte)
  339. //• ‘1’ to ‘4’: Unit specified
  340. //• SeqNo: Sequence number(Non/ 1 / 2 / 3 byte)
  341. //• MMode: Motion mode(1 byte)
  342. //• ‘F’: All axes
  343. //• ‘A’: Arm(s) only
  344. updateBefore();
  345. return ",MHOM,A,";
  346. }
  347. protected void updateBefore()
  348. {
  349. _device.Blade1Target = ModuleHelper.Converter(_device.Name);
  350. _device.Blade2Target = ModuleHelper.Converter(_device.Name);
  351. _device.CmdBladeTarget = $"{_device.Name}.A";
  352. _device.CmdBlade1Extend = "0";
  353. _device.CmdBlade2Extend = "0";
  354. }
  355. protected override void update(string[] data)
  356. {
  357. _device.Initalized = true;
  358. _device.Swap = false;
  359. }
  360. }
  361. public class RbClearErrorHandler : RobotMotionHandler
  362. {
  363. public RbClearErrorHandler()
  364. {
  365. background = true;
  366. }
  367. //$ <UNo> (<SeqNo>) CCLR <CMode> <Sum> <CR>
  368. public override string package(params object[] args)
  369. {
  370. //• CMode: Clear mode(1 byte)
  371. //• ‘E’: Releases the error status.
  372. //• ‘H’: Clears the error history.
  373. return ",CCLR,E,";
  374. }
  375. }
  376. public class RbGripHandler : RobotMotionHandler
  377. {
  378. Hand _hand;
  379. public RbGripHandler()
  380. {
  381. background = true;
  382. }
  383. //Command wafer hold/release signal to the solenoid of the specified unit.
  384. //$ <UNo> (<SeqNo>) CSOL <Fork> <Sw> <Sum> <CR>
  385. //• Fork: Fork specified(1 byte)
  386. //• ‘A’: Extension axis 1 (Blade 1), pre-aligner
  387. //• ‘B’: Extension axis 2 (Blade 2)
  388. //• Sw: Chucking command(1 byte)
  389. //• ‘0’: Chucking OFF
  390. //• ‘1’: Chucking ON
  391. public override string package(params object[] args)
  392. {
  393. _hand = (Hand)args[0];
  394. bool bHold = (bool)args[1];
  395. if(bHold)
  396. return string.Format(",CSOL,{0},1,",RobotConvertor.hand2string(_hand));
  397. return string.Format(",CSOL,{0},0,", RobotConvertor.hand2string(_hand));
  398. }
  399. }
  400. public class RbStopHandler : RobotMotionHandler
  401. {
  402. public RbStopHandler()
  403. {
  404. background = true;
  405. }
  406. //$ <UNo> (<SeqNo>) CHLTs <Sum> <CR>
  407. //Pause (decelerate and stop) the motion of the specified unit during the drive command execution.
  408. public override string package(params object[] args)
  409. {
  410. bool isEmergency = (bool)args[0];
  411. if (isEmergency)
  412. return ",CEMG,";
  413. //$ < UNo > (< SeqNo >) CHLT<Sum> < CR >
  414. return ",CHLT,";
  415. //return ",MHOM,F,";
  416. }
  417. }
  418. public class RbResumeHandler : RobotMotionHandler
  419. {
  420. public RbResumeHandler()
  421. {
  422. background = true;
  423. }
  424. //$ <UNo> (<SeqNo>) CRSM <Sum> <CR>
  425. public override string package(params object[] args)
  426. {
  427. return ",CRSM,";
  428. }
  429. }
  430. public class PickHandler : RobotMotionHandler
  431. {
  432. private ModuleName _chamber;
  433. private int _slot;
  434. private Hand _hand;
  435. public PickHandler()
  436. {
  437. background = true;
  438. }
  439. public override string package(params object[] args)
  440. {
  441. //Move To Ready position and wafer Get motion(MTRS+MGET)
  442. //$ <UNo> (<SeqNo>) MTRG <TrsSt> <SlotNo> <MtnMode> <Posture> <Sum> <CR>
  443. // • TrsSt: Transfer station(2 bytes)
  444. //• "C1" to "C8": When cassette stage specified
  445. //• "S1" to "SC": When transfer stage specified
  446. //• "P1" to “P2”: When P/ A stage specified
  447. //Note: P2 station is effective only when two or more PA stations exist.
  448. //• SlotNo: Slot number(2 bytes)
  449. //< Manipulator >
  450. //• "01" to "XX": When cassette stage is specified by < TrsST >
  451. //(The maximum value of "XX" is in the ASCII code of the number of slots specified by parameter.)
  452. //• "00": When transfer stage or P / A stage specified by < TrsSt >
  453. //• MtnMode: Motion mode(2 bytes)
  454. //• "GA": Wafer Get motion at extension axis 1(Blade 1).
  455. //• "GB": Wafer Get motion at extension axis 2(Blade 2).
  456. //• "GW": Wafer Get motion with extension axis 1 and 2(Blade 1 and 2). < WGet motion >
  457. _chamber = (ModuleName)args[0];
  458. _slot = (int)args[1];
  459. _hand = (Hand)args[2];
  460. updateBefore();
  461. if (_hand == Hand.Both)
  462. {
  463. return string.Format(",MTRG,{0},{1:D2},G{2},A,",
  464. RobotConvertor.chamber2staion(_chamber),
  465. RobotConvertor.chamberSlot2Slot(_chamber, _slot + 1) ,
  466. RobotConvertor.hand2string(_hand));
  467. }
  468. return string.Format(",MTRG,{0},{1:D2},G{2},A,",
  469. RobotConvertor.chamber2staion(_chamber),
  470. RobotConvertor.chamberSlot2Slot(_chamber, _slot),
  471. RobotConvertor.hand2string(_hand));
  472. }
  473. private void updateBefore()
  474. {
  475. _device.Blade1Target = _chamber;
  476. _device.Blade2Target = _chamber;
  477. string arm = _hand == Hand.Blade1 ? "A" : "B";
  478. _device.CmdBladeTarget = $"{_chamber}.{arm}";
  479. _device.CmdBlade1Extend = _hand == Hand.Blade1 ? "1" : "0";
  480. _device.CmdBlade2Extend = _hand == Hand.Blade1 ? "0" : "1";
  481. }
  482. protected override void update(string[] data)
  483. {
  484. if (_hand == Hand.Blade1)
  485. {
  486. WaferManager.Instance.WaferMoved(_chamber, _slot, ModuleHelper.Converter(_device.Name), (int)Hand.Blade1);
  487. }
  488. else if (_hand == Hand.Blade2)
  489. {
  490. for (int i = 0; i < _device.Blade2Slots; i++)
  491. WaferManager.Instance.WaferMoved(_chamber, _slot + i, ModuleHelper.Converter(_device.Name), (int)Hand.Blade2 + i);
  492. }
  493. else
  494. {
  495. for (int i = 0; i < _device.Blade2Slots + 1; i++)
  496. WaferManager.Instance.WaferMoved(_chamber, _slot + i, ModuleHelper.Converter(_device.Name), (int)Hand.Blade1 + i);
  497. }
  498. string arm = _hand == Hand.Blade1 ? "A" : "B";
  499. _device.CmdBladeTarget = $"{_chamber}.{arm}";
  500. _device.CmdBlade1Extend = "0";
  501. _device.CmdBlade2Extend = "0";
  502. _device.Blade1Target = ModuleHelper.Converter(_device.Name);
  503. _device.Blade2Target = ModuleHelper.Converter(_device.Name);
  504. }
  505. }
  506. public class PickExtendHandler : RobotMotionHandler
  507. {
  508. private ModuleName _chamber;
  509. private int _slot;
  510. private Hand _hand;
  511. public PickExtendHandler()
  512. {
  513. background = true;
  514. }
  515. public override string package(params object[] args)
  516. {
  517. //$ <UNo> (<SeqNo>) MTPT <TrsSt> <SlotNo> <NextMtn> <Posture> <TrsPnt> <Sum> <CR>
  518. _chamber = (ModuleName)args[0];
  519. _slot = (int)args[1];
  520. _hand = (Hand)args[2];
  521. updateBefore();
  522. return string.Format(",MTPT,{0},{1:D2},G{2},A,Gb,",
  523. RobotConvertor.chamber2staion(_chamber),
  524. RobotConvertor.chamberSlot2Slot(_chamber, _slot + 1),
  525. RobotConvertor.hand2string(_hand));
  526. }
  527. private void updateBefore()
  528. {
  529. _device.Blade1Target = _chamber;
  530. _device.Blade2Target = _chamber;
  531. string arm = _hand == Hand.Blade1 ? "A" : "B";
  532. _device.CmdBladeTarget = $"{_chamber}.{arm}";
  533. _device.CmdBlade1Extend = _hand == Hand.Blade1 ? "1" : "0";
  534. _device.CmdBlade2Extend = _hand == Hand.Blade1 ? "0" : "1";
  535. }
  536. }
  537. public class PickRetractHandler : RobotMotionHandler
  538. {
  539. private ModuleName _chamber;
  540. private int _slot;
  541. private Hand _hand;
  542. public PickRetractHandler()
  543. {
  544. background = true;
  545. }
  546. public override string package(params object[] args)
  547. {
  548. //$ <UNo> (<SeqNo>) MPNT <TrsPnt> <Sum> <CR>
  549. _chamber = (ModuleName)args[0];
  550. _slot = (int)args[1];
  551. _hand = (Hand)args[2];
  552. updateBefore();
  553. return ",MPNT,G4,";
  554. }
  555. private void updateBefore()
  556. {
  557. _device.Blade1Target = _chamber;
  558. _device.Blade2Target = _chamber;
  559. string arm = _hand == Hand.Blade1 ? "A" : "B";
  560. _device.CmdBladeTarget = $"{_chamber}.{arm}";
  561. _device.CmdBlade1Extend = _hand == Hand.Blade1 ? "1" : "0";
  562. _device.CmdBlade2Extend = _hand == Hand.Blade1 ? "0" : "1";
  563. }
  564. protected override void update(string[] data)
  565. {
  566. if (_hand == Hand.Both)
  567. {
  568. WaferManager.Instance.WaferMoved(_chamber, _slot, ModuleHelper.Converter(_device.Name), (int)Hand.Blade1);
  569. WaferManager.Instance.WaferMoved(_chamber, _slot + 1, ModuleHelper.Converter(_device.Name), (int)Hand.Blade2);
  570. }
  571. else
  572. {
  573. WaferManager.Instance.WaferMoved(_chamber, _slot, ModuleHelper.Converter(_device.Name), (int)_hand);
  574. }
  575. string arm = _hand == Hand.Blade1 ? "A" : "B";
  576. _device.CmdBladeTarget = $"{_chamber}.{arm}";
  577. _device.CmdBlade1Extend = "0";
  578. _device.CmdBlade2Extend = "0";
  579. _device.Blade1Target = ModuleHelper.Converter(_device.Name);
  580. _device.Blade2Target = ModuleHelper.Converter(_device.Name);
  581. }
  582. }
  583. public class PickReadyPositionHandler : RobotMotionHandler
  584. {
  585. private ModuleName _chamber;
  586. private int _slot;
  587. private Hand _hand;
  588. public PickReadyPositionHandler()
  589. {
  590. background = true;
  591. }
  592. public override string package(params object[] args)
  593. {
  594. //$ <UNo> (<SeqNo>) MTRS <TrsSt> <SlotNo> <NextMtn> <Posture> <Sum> <CR>
  595. _chamber = (ModuleName)args[0];
  596. _slot = (int)args[1];
  597. _hand = (Hand)args[2];
  598. updateBefore();
  599. return string.Format(",MTRS,{0},{1:D2},G{2},A,",
  600. RobotConvertor.chamber2staion(_chamber),
  601. RobotConvertor.chamberSlot2Slot(_chamber, _slot + 1),
  602. RobotConvertor.hand2string(_hand));
  603. }
  604. private void updateBefore()
  605. {
  606. _device.Blade1Target = _chamber;
  607. _device.Blade2Target = _chamber;
  608. string arm = _hand == Hand.Blade1 ? "A" : "B";
  609. _device.CmdBladeTarget = $"{_chamber}.{arm}";
  610. _device.CmdBlade1Extend = _hand == Hand.Blade1 ? "1" : "0";
  611. _device.CmdBlade2Extend = _hand == Hand.Blade1 ? "0" : "1";
  612. }
  613. }
  614. public class PlaceHandler : RobotMotionHandler
  615. {
  616. private ModuleName _chamber;
  617. private int _slot;
  618. private Hand _hand;
  619. public PlaceHandler()
  620. {
  621. background = true;
  622. }
  623. public override string package(params object[] args)
  624. {
  625. // $ <UNo> (<SeqNo>) MTRP <TrsSt> <SlotNo> <MtnMode> <Posture> <Sum> <CR>
  626. _chamber = (ModuleName)args[0];
  627. _slot = (int)args[1];
  628. _hand = (Hand)args[2];
  629. updateBefore();
  630. if (_hand == Hand.Both)
  631. {
  632. return string.Format(",MTRP,{0},{1:D2},P{2},A,",
  633. RobotConvertor.chamber2staion(_chamber),
  634. RobotConvertor.chamberSlot2Slot(_chamber, _slot + 1),
  635. RobotConvertor.hand2string(_hand));
  636. }
  637. return string.Format(",MTRP,{0},{1:D2},P{2},A,",
  638. RobotConvertor.chamber2staion(_chamber),
  639. RobotConvertor.chamberSlot2Slot(_chamber, _slot),
  640. RobotConvertor.hand2string(_hand));
  641. }
  642. private void updateBefore()
  643. {
  644. _device.Blade1Target = _chamber;
  645. _device.Blade2Target = _chamber;
  646. string arm = _hand == Hand.Blade1 ? "A" : "B";
  647. _device.CmdBladeTarget = $"{_chamber}.{arm}";
  648. _device.CmdBlade1Extend = _hand == Hand.Blade1 ? "1" : "0";
  649. _device.CmdBlade2Extend = _hand == Hand.Blade1 ? "0" : "1";
  650. }
  651. protected override void update(string[] data)
  652. {
  653. if (_hand == Hand.Blade1)
  654. {
  655. WaferManager.Instance.WaferMoved(ModuleHelper.Converter(_device.Name), (int)Hand.Blade1, _chamber, _slot);
  656. }
  657. else if (_hand == Hand.Blade2)
  658. {
  659. for (int i = 0; i < _device.Blade2Slots; i++)
  660. WaferManager.Instance.WaferMoved(ModuleHelper.Converter(_device.Name), (int)Hand.Blade2 +i, _chamber, _slot + i);
  661. }
  662. else
  663. {
  664. for (int i = 0; i < _device.Blade2Slots + 1; i++)
  665. WaferManager.Instance.WaferMoved(ModuleHelper.Converter(_device.Name), (int)Hand.Blade1 + i, _chamber, _slot + i);
  666. }
  667. string arm = _hand == Hand.Blade1 ? "A" : "B";
  668. _device.CmdBladeTarget = $"{_chamber}.{arm}";
  669. _device.CmdBlade1Extend = "0";
  670. _device.CmdBlade2Extend = "0";
  671. _device.Blade1Target = ModuleHelper.Converter(_device.Name);
  672. _device.Blade2Target = ModuleHelper.Converter(_device.Name);
  673. }
  674. }
  675. public class PlaceExtendHandler : RobotMotionHandler
  676. {
  677. private ModuleName _chamber;
  678. private int _slot;
  679. private Hand _hand;
  680. public PlaceExtendHandler()
  681. {
  682. background = true;
  683. }
  684. public override string package(params object[] args)
  685. {
  686. //$ <UNo> (<SeqNo>) MTPT <TrsSt> <SlotNo> <NextMtn> <Posture> <TrsPnt> <Sum> <CR>
  687. _chamber = (ModuleName)args[0];
  688. _slot = (int)args[1];
  689. _hand = (Hand)args[2];
  690. updateBefore();
  691. return string.Format(",MTPT,{0},{1:D2},P{2},A,Pb,",
  692. RobotConvertor.chamber2staion(_chamber),
  693. RobotConvertor.chamberSlot2Slot(_chamber, _slot + 1),
  694. RobotConvertor.hand2string(_hand));
  695. }
  696. private void updateBefore()
  697. {
  698. _device.Blade1Target = _chamber;
  699. _device.Blade2Target = _chamber;
  700. string arm = _hand == Hand.Blade1 ? "A" : "B";
  701. _device.CmdBladeTarget = $"{_chamber}.{arm}";
  702. _device.CmdBlade1Extend = _hand == Hand.Blade1 ? "1" : "0";
  703. _device.CmdBlade2Extend = _hand == Hand.Blade1 ? "0" : "1";
  704. }
  705. }
  706. public class PlaceRetractHandler : RobotMotionHandler
  707. {
  708. private ModuleName _chamber;
  709. private int _slot;
  710. private Hand _hand;
  711. public PlaceRetractHandler()
  712. {
  713. background = true;
  714. }
  715. public override string package(params object[] args)
  716. {
  717. //$ <UNo> (<SeqNo>) MPNT <TrsPnt> <Sum> <CR>
  718. _chamber = (ModuleName)args[0];
  719. _slot = (int)args[1];
  720. _hand = (Hand)args[2];
  721. updateBefore();
  722. return ",MPNT,P4,";
  723. }
  724. private void updateBefore()
  725. {
  726. _device.Blade1Target = _chamber;
  727. _device.Blade2Target = _chamber;
  728. string arm = _hand == Hand.Blade1 ? "A" : "B";
  729. _device.CmdBladeTarget = $"{_chamber}.{arm}";
  730. _device.CmdBlade1Extend = _hand == Hand.Blade1 ? "1" : "0";
  731. _device.CmdBlade2Extend = _hand == Hand.Blade1 ? "0" : "1";
  732. }
  733. protected override void update(string[] data)
  734. {
  735. if (_hand == Hand.Both)
  736. {
  737. WaferManager.Instance.WaferMoved(ModuleHelper.Converter(_device.Name), (int)Hand.Blade1, _chamber, _slot);
  738. WaferManager.Instance.WaferMoved(ModuleHelper.Converter(_device.Name), (int)Hand.Blade2, _chamber, _slot + 1);
  739. }
  740. else
  741. {
  742. WaferManager.Instance.WaferMoved(ModuleHelper.Converter(_device.Name), (int)_hand, _chamber, _slot);
  743. }
  744. string arm = _hand == Hand.Blade1 ? "A" : "B";
  745. _device.CmdBladeTarget = $"{_chamber}.{arm}";
  746. _device.CmdBlade1Extend = "0";
  747. _device.CmdBlade2Extend = "0";
  748. _device.Blade1Target = ModuleHelper.Converter(_device.Name);
  749. _device.Blade2Target = ModuleHelper.Converter(_device.Name);
  750. }
  751. }
  752. public class PlaceReadyPositionHandler : RobotMotionHandler
  753. {
  754. private ModuleName _chamber;
  755. private int _slot;
  756. private Hand _hand;
  757. public PlaceReadyPositionHandler()
  758. {
  759. background = true;
  760. }
  761. public override string package(params object[] args)
  762. {
  763. //$ <UNo> (<SeqNo>) MTRS <TrsSt> <SlotNo> <NextMtn> <Posture> <Sum> <CR>
  764. _chamber = (ModuleName)args[0];
  765. _slot = (int)args[1];
  766. _hand = (Hand)args[2];
  767. updateBefore();
  768. return string.Format(",MTRS,{0},{1:D2},P{2},A,",
  769. RobotConvertor.chamber2staion(_chamber),
  770. RobotConvertor.chamberSlot2Slot(_chamber, _slot + 1),
  771. RobotConvertor.hand2string(_hand));
  772. }
  773. private void updateBefore()
  774. {
  775. _device.Blade1Target = _chamber;
  776. _device.Blade2Target = _chamber;
  777. string arm = _hand == Hand.Blade1 ? "A" : "B";
  778. _device.CmdBladeTarget = $"{_chamber}.{arm}";
  779. _device.CmdBlade1Extend = _hand == Hand.Blade1 ? "1" : "0";
  780. _device.CmdBlade2Extend = _hand == Hand.Blade1 ? "0" : "1";
  781. }
  782. }
  783. public class ExchangeReadyPositionHandler : RobotMotionHandler
  784. {
  785. private ModuleName _chamber;
  786. private int _slot;
  787. private Hand _pickHand;
  788. private Hand _placeHand;
  789. public ExchangeReadyPositionHandler()
  790. {
  791. background = true;
  792. }
  793. public override string package(params object[] args)
  794. {
  795. ////$ <UNo> (<SeqNo>) MTRS <TrsSt> <SlotNo> <NextMtn> <Posture> <Sum> <CR>
  796. //_chamber = (ModuleName)args[0];
  797. //_slot = (int)args[1];
  798. //_pickHand = (Hand)args[2];
  799. //_placeHand = (Hand)args[3];
  800. //updateBefore();
  801. //return string.Format(",MTRS,{0},{1:D2},E{2},A,",
  802. // RobotConvertor.chamber2staion(_chamber),
  803. // RobotConvertor.chamberSlot2Slot(_chamber, _slot + 1),
  804. // RobotConvertor.hand2string(_pickHand));
  805. //$ <UNo> (<SeqNo>) MTPT <TrsSt> <SlotNo> <NextMtn> <Posture> <TrsPnt> <Sum> <CR>
  806. _chamber = (ModuleName)args[0];
  807. _slot = (int)args[1];
  808. _pickHand = (Hand)args[2];
  809. _placeHand = (Hand)args[3];
  810. updateBefore();
  811. return string.Format(",MTPT,{0},{1:D2},E{2},A,G1,",
  812. RobotConvertor.chamber2staion(_chamber),
  813. RobotConvertor.chamberSlot2Slot(_chamber, _slot + 1),
  814. RobotConvertor.hand2string(_pickHand));
  815. }
  816. private void updateBefore()
  817. {
  818. _device.Blade1Target = _chamber;
  819. _device.Blade2Target = _chamber;
  820. string arm = _pickHand == Hand.Blade1 ? "A" : "B";
  821. _device.CmdBladeTarget = $"{_chamber}.{arm}";
  822. _device.CmdBlade1Extend = "0";
  823. _device.CmdBlade2Extend = "0";
  824. }
  825. }
  826. public class ExchangePickExtendHandler : RobotMotionHandler
  827. {
  828. private ModuleName _chamber;
  829. private int _slot;
  830. private Hand _hand;
  831. public ExchangePickExtendHandler()
  832. {
  833. background = true;
  834. }
  835. public override string package(params object[] args)
  836. {
  837. //$ <UNo> (<SeqNo>) MPNT <TrsPnt> <Sum> <CR>
  838. _chamber = (ModuleName)args[0];
  839. _slot = (int)args[1];
  840. _hand = (Hand)args[2];
  841. updateBefore();
  842. return ",MPNT,Gb,";
  843. }
  844. private void updateBefore()
  845. {
  846. _device.Blade1Target = _chamber;
  847. _device.Blade2Target = _chamber;
  848. string arm = _hand == Hand.Blade1 ? "A" : "B";
  849. _device.CmdBladeTarget = $"{_chamber}.{arm}";
  850. _device.CmdBlade1Extend = _hand == Hand.Blade1 ? "1" : "0";
  851. _device.CmdBlade2Extend = _hand == Hand.Blade1 ? "0" : "1";
  852. }
  853. }
  854. public class ExchangePlaceExtendHandler : RobotMotionHandler
  855. {
  856. private ModuleName _chamber;
  857. private int _slot;
  858. private Hand _pickHand;
  859. private Hand _placeHand;
  860. public ExchangePlaceExtendHandler()
  861. {
  862. background = true;
  863. }
  864. public override string package(params object[] args)
  865. {
  866. //$ <UNo> (<SeqNo>) MPNT <TrsPnt> <Sum> <CR>
  867. _chamber = (ModuleName)args[0];
  868. _slot = (int)args[1];
  869. _pickHand = (Hand)args[2];
  870. _placeHand = (Hand)args[3];
  871. updateBefore();
  872. return ",MPNT,Pb,";
  873. }
  874. private void updateBefore()
  875. {
  876. _device.Blade1Target = _chamber;
  877. _device.Blade2Target = _chamber;
  878. string arm = _placeHand == Hand.Blade1 ? "A" : "B";
  879. _device.CmdBladeTarget = $"{_chamber}.{arm}";
  880. _device.CmdBlade1Extend = _placeHand == Hand.Blade1 ? "1" : "0";
  881. _device.CmdBlade2Extend = _placeHand == Hand.Blade1 ? "0" : "1";
  882. }
  883. }
  884. public class ExchangePlaceRetractHandler : RobotMotionHandler
  885. {
  886. private ModuleName _chamber;
  887. private int _slot;
  888. private Hand _pickHand;
  889. private Hand _placeHand;
  890. public ExchangePlaceRetractHandler()
  891. {
  892. background = true;
  893. }
  894. public override string package(params object[] args)
  895. {
  896. //$ <UNo> (<SeqNo>) MPNT <TrsPnt> <Sum> <CR>
  897. _chamber = (ModuleName)args[0];
  898. _slot = (int)args[1];
  899. _pickHand = (Hand)args[2];
  900. _placeHand = (Hand)args[3];
  901. updateBefore();
  902. return ",MPNT,P4,";
  903. }
  904. private void updateBefore()
  905. {
  906. _device.Blade1Target = _chamber;
  907. _device.Blade2Target = _chamber;
  908. string arm = _placeHand == Hand.Blade1 ? "A" : "B";
  909. _device.CmdBladeTarget = $"{_chamber}.{arm}";
  910. _device.CmdBlade1Extend = "0";
  911. _device.CmdBlade2Extend = "0";
  912. }
  913. protected override void update(string[] data)
  914. {
  915. if (_placeHand == Hand.Blade1)
  916. {
  917. WaferManager.Instance.WaferMoved(_chamber, _slot, ModuleHelper.Converter(_device.Name), (int)Hand.Blade2);
  918. WaferManager.Instance.WaferMoved(ModuleHelper.Converter(_device.Name), (int)Hand.Blade1, _chamber, _slot);
  919. }
  920. else
  921. {
  922. WaferManager.Instance.WaferMoved(_chamber, _slot, ModuleHelper.Converter(_device.Name), (int)Hand.Blade1);
  923. WaferManager.Instance.WaferMoved(ModuleHelper.Converter(_device.Name), (int)Hand.Blade2, _chamber, _slot);
  924. }
  925. _device.Swap = false;
  926. _device.Blade1Target = ModuleHelper.Converter(_device.Name);
  927. _device.Blade2Target = ModuleHelper.Converter(_device.Name);
  928. }
  929. }
  930. public class ExchangeHandler : RobotMotionHandler
  931. {
  932. private ModuleName _chamber;
  933. private int _slot;
  934. private Hand _hand;
  935. public ExchangeHandler()
  936. {
  937. background = true;
  938. }
  939. public override string package(params object[] args)
  940. {
  941. // $ <UNo> (<SeqNo>) MTRE <TrsSt> <SlotNo> <MtnMode> <Posture> <Sum> <CR>
  942. _chamber = (ModuleName)args[0];
  943. _slot = (int)args[1];
  944. _hand = (Hand)args[2];
  945. if (_hand == Hand.Blade1)
  946. _hand = Hand.Blade2;
  947. else
  948. _hand = Hand.Blade1;
  949. updateBefore();
  950. return string.Format(",MTRE,{0},{1:D2},E{2},A,",
  951. RobotConvertor.chamber2staion(_chamber),
  952. RobotConvertor.chamberSlot2Slot(_chamber, _slot),
  953. RobotConvertor.hand2string(_hand));
  954. }
  955. private void updateBefore()
  956. {
  957. _device.Blade1Target = _chamber;
  958. _device.Blade2Target = _chamber;
  959. _device.Swap = true;
  960. _device.PlaceBalde = _hand;
  961. }
  962. protected override void update(string[] data)
  963. {
  964. if (_hand == Hand.Blade2)
  965. {
  966. WaferManager.Instance.WaferMoved(_chamber, _slot, ModuleHelper.Converter(_device.Name), (int)Hand.Blade2);
  967. WaferManager.Instance.WaferMoved(ModuleHelper.Converter(_device.Name), (int)Hand.Blade1, _chamber, _slot);
  968. }
  969. else
  970. {
  971. WaferManager.Instance.WaferMoved(_chamber, _slot, ModuleHelper.Converter(_device.Name), (int)Hand.Blade1);
  972. WaferManager.Instance.WaferMoved(ModuleHelper.Converter(_device.Name), (int)Hand.Blade2, _chamber, _slot);
  973. }
  974. _device.Swap = false;
  975. _device.Blade1Target = ModuleHelper.Converter(_device.Name);
  976. _device.Blade2Target = ModuleHelper.Converter(_device.Name);
  977. }
  978. }
  979. public class ExchangeReadyExtHandler : RobotMotionHandler
  980. {
  981. private ModuleName _chamber;
  982. private int _slot;
  983. private Hand _pickHand;
  984. private Hand _placeHand;
  985. public ExchangeReadyExtHandler()
  986. {
  987. background = true;
  988. }
  989. public override string package(params object[] args)
  990. {
  991. ////$ <UNo> (<SeqNo>) MTRS <TrsSt> <SlotNo> <NextMtn> <Posture> <Sum> <CR>
  992. _chamber = (ModuleName)args[0];
  993. _slot = (int)args[1];
  994. _pickHand = (Hand)args[2];
  995. _placeHand = (Hand)args[3];
  996. updateBefore();
  997. return string.Format(",MTRS,{0},{1:D2},E{2},A,",
  998. RobotConvertor.chamber2staion(_chamber),
  999. RobotConvertor.chamberSlot2Slot(_chamber, _slot + 1),
  1000. RobotConvertor.hand2string(_pickHand));
  1001. //$ <UNo> (<SeqNo>) MTPT <TrsSt> <SlotNo> <NextMtn> <Posture> <TrsPnt> <Sum> <CR>
  1002. //_chamber = (ModuleName)args[0];
  1003. //_slot = (int)args[1];
  1004. //_pickHand = (Hand)args[2];
  1005. //_placeHand = (Hand)args[3];
  1006. //updateBefore();
  1007. //return string.Format(",MTPT,{0},{1:D2},E{2},A,G1,",
  1008. // RobotConvertor.chamber2staion(_chamber),
  1009. // RobotConvertor.chamberSlot2Slot(_chamber, _slot + 1),
  1010. // RobotConvertor.hand2string(_pickHand));
  1011. }
  1012. private void updateBefore()
  1013. {
  1014. _device.Blade1Target = _chamber;
  1015. _device.Blade2Target = _chamber;
  1016. string arm = _pickHand == Hand.Blade1 ? "A" : "B";
  1017. _device.CmdBladeTarget = $"{_chamber}.{arm}";
  1018. _device.CmdBlade1Extend = "0";
  1019. _device.CmdBlade2Extend = "0";
  1020. }
  1021. }
  1022. public class ExchangeAfterReadyHandler : RobotMotionHandler
  1023. {
  1024. private ModuleName _chamber;
  1025. private int _slot;
  1026. private Hand _hand;
  1027. public ExchangeAfterReadyHandler()
  1028. {
  1029. background = true;
  1030. }
  1031. public override string package(params object[] args)
  1032. {
  1033. // $ <UNo> (<SeqNo>) MEXG <Sum> <CR>
  1034. _chamber = (ModuleName)args[0];
  1035. _slot = (int)args[1];
  1036. _hand = (Hand)args[2];
  1037. //if (_hand == Hand.Blade1)
  1038. // _hand = Hand.Blade2;
  1039. //else
  1040. // _hand = Hand.Blade1;
  1041. updateBefore();
  1042. return ",MEXG,";
  1043. }
  1044. private void updateBefore()
  1045. {
  1046. _device.Blade1Target = _chamber;
  1047. _device.Blade2Target = _chamber;
  1048. _device.Swap = true;
  1049. _device.PlaceBalde = _hand;
  1050. }
  1051. protected override void update(string[] data)
  1052. {
  1053. if (_hand == Hand.Blade2)
  1054. {
  1055. WaferManager.Instance.WaferMoved(_chamber, _slot, ModuleHelper.Converter(_device.Name), (int)Hand.Blade2);
  1056. WaferManager.Instance.WaferMoved(ModuleHelper.Converter(_device.Name), (int)Hand.Blade1, _chamber, _slot);
  1057. }
  1058. else
  1059. {
  1060. WaferManager.Instance.WaferMoved(_chamber, _slot, ModuleHelper.Converter(_device.Name), (int)Hand.Blade1);
  1061. WaferManager.Instance.WaferMoved(ModuleHelper.Converter(_device.Name), (int)Hand.Blade2, _chamber, _slot);
  1062. }
  1063. _device.Swap = false;
  1064. _device.Blade1Target = ModuleHelper.Converter(_device.Name);
  1065. _device.Blade2Target = ModuleHelper.Converter(_device.Name);
  1066. }
  1067. }
  1068. public class GotoHandler : RobotMotionHandler
  1069. {
  1070. private ModuleName _chamber;
  1071. private int _slot;
  1072. private Motion _next;
  1073. private Hand _hand;
  1074. public GotoHandler()
  1075. {
  1076. background = true;
  1077. }
  1078. public override string package(params object[] args)
  1079. {
  1080. //Move to ready position with specified adjustment offset
  1081. //$<UNo>(<SeqNo>) MTRO <TrsSt> <SlotNo> <NextMtn> <Posture> <OffsetX> <OffsetY> <OffsetZ> <Sum>
  1082. //• OffsetN: Offset(5 bytes each)
  1083. //• OffsetX: X direction offset
  1084. //• OffsetY: Y direction offset
  1085. //• OffsetZ: Z direction offset
  1086. //• Specified in the range between "-9999" and "99999"(Resolution: 0.01[mm])
  1087. //• If value is less than 5 digits, fill the higher digit with ‘0’ so that the field always has 5 digits.
  1088. _chamber = (ModuleName)args[0];
  1089. _slot = (int)args[1];
  1090. _next = (Motion)args[2];
  1091. _hand = (Hand)args[3];
  1092. int x = (int)args[4];
  1093. int y = (int)args[5];
  1094. int z = (int)args[6];
  1095. updateBefore();
  1096. return string.Format(",MTRO,{0},{1:D2},{2},A,{3},{4},{5}",
  1097. RobotConvertor.chamber2staion(_chamber),
  1098. RobotConvertor.chamberSlot2Slot(_chamber, _slot),
  1099. RobotConvertor.NextMotion2String(_next, _hand),
  1100. RobotConvertor.Offset2String(x),
  1101. RobotConvertor.Offset2String(y),
  1102. RobotConvertor.Offset2String(z)
  1103. ); ;
  1104. }
  1105. private void updateBefore()
  1106. {
  1107. if(_hand == Hand.Blade1)
  1108. _device.Blade1Target = _chamber;
  1109. else if (_hand == Hand.Blade2)
  1110. _device.Blade2Target = _chamber;
  1111. else
  1112. {
  1113. _device.Blade1Target = _chamber;
  1114. _device.Blade2Target = _chamber;
  1115. }
  1116. }
  1117. }
  1118. public class PickHandlerEx : RobotMotionHandler
  1119. {
  1120. private ModuleName _chamber;
  1121. private int _slot;
  1122. private Hand _hand;
  1123. public PickHandlerEx()
  1124. {
  1125. background = true;
  1126. }
  1127. public override string package(params object[] args)
  1128. {
  1129. //Move to ready position and get wafer with adjustment offset(MTRO+MGET)
  1130. //$ < UNo > (< SeqNo >) MTGO<TrsSt> < SlotNo > < NextMtn > < Posture > < OffsetX > < OffsetY > < OffsetZ > < Sum > < CR >
  1131. //• UNo: Unit number(1 byte)
  1132. //• ‘1’ to ‘4’: Unit specified
  1133. //• SeqNo: Sequence number(Non/ 1 / 2 / 3 byte)
  1134. //• TrsSt: Transfer station(2 bytes)
  1135. //• "C1" to "C8": When cassette stage specified
  1136. //• "S1" to "SC": When transfer stage specified
  1137. //• "P1" to “P2”: When P/ A stage specified
  1138. //Note: P2 station is effective only when two or more PA stations exist.
  1139. //• SlotNo: Slot number(2 bytes)
  1140. //• "01" to "XX": When cassette stage specified by<TrsST>
  1141. //(The maximum value of "XX" is in the ASCII code of the number of slots specified by parameter.)
  1142. //• "00": When transfer stage or P / A stage specified by < TrsSt >
  1143. //• NextMtn: Next motion mode(2 bytes)
  1144. //• "GA": Next motion is wafer Get motion with extension axis 1(Blade 1).
  1145. //• "GB": Next motion is wafer Get motion with extension axis 2(Blade 2).
  1146. //• "GW": Next motion is wafer Get motion with extension axis 1 and 2(Blade 1 and 2). < WGet motion >
  1147. //Note 1.The motion of extension axis 2(or blade 2) is available only for a dual-arm manipulator and dual blade
  1148. //linear motion manipulator.
  1149. //2.The WGet motion is available for a dual-arm manipulator and dual blade linear motion manipulator.
  1150. _chamber = (ModuleName)args[0];
  1151. _slot = (int)args[1];
  1152. _hand = (Hand)args[2];
  1153. int x = (int)args[3];
  1154. int y = (int)args[4];
  1155. int z = (int)args[5];
  1156. updateBefore();
  1157. if (_hand == Hand.Both)
  1158. {
  1159. return string.Format(",MTGO,{0},{1:D2},G{2},A,{3},{4},{5}",
  1160. RobotConvertor.chamber2staion(_chamber),
  1161. RobotConvertor.chamberSlot2Slot(_chamber, _slot + 1),
  1162. RobotConvertor.hand2string(_hand),
  1163. RobotConvertor.Offset2String(x),
  1164. RobotConvertor.Offset2String(y),
  1165. RobotConvertor.Offset2String(z)
  1166. );
  1167. }
  1168. return string.Format(",MTGO,{0},{1:D2},G{2},A,{3},{4},{5}",
  1169. RobotConvertor.chamber2staion(_chamber),
  1170. RobotConvertor.chamberSlot2Slot(_chamber, _slot),
  1171. RobotConvertor.hand2string(_hand),
  1172. RobotConvertor.Offset2String(x),
  1173. RobotConvertor.Offset2String(y),
  1174. RobotConvertor.Offset2String(z)
  1175. );
  1176. }
  1177. private void updateBefore()
  1178. {
  1179. _device.Blade1Target = _chamber;
  1180. _device.Blade2Target = _chamber;
  1181. string arm = _hand == Hand.Blade1 ? "A" : "B";
  1182. _device.CmdBladeTarget = $"{_chamber}.{arm}";
  1183. _device.CmdBlade1Extend = _hand == Hand.Blade1 ? "1" : "0";
  1184. _device.CmdBlade2Extend = _hand == Hand.Blade1 ? "0" : "1";
  1185. }
  1186. protected override void update(string[] data)
  1187. {
  1188. if (_hand == Hand.Blade1)
  1189. {
  1190. WaferManager.Instance.WaferMoved(_chamber, _slot, ModuleHelper.Converter(_device.Name), (int)Hand.Blade1);
  1191. }
  1192. else if (_hand == Hand.Blade2)
  1193. {
  1194. for (int i = 0; i < _device.Blade2Slots; i++)
  1195. WaferManager.Instance.WaferMoved(_chamber, _slot + i, ModuleHelper.Converter(_device.Name), (int)Hand.Blade2 + i);
  1196. }
  1197. else
  1198. {
  1199. for (int i = 0; i < _device.Blade2Slots + 1; i++)
  1200. WaferManager.Instance.WaferMoved(_chamber, _slot + i, ModuleHelper.Converter(_device.Name), (int)Hand.Blade1 + i);
  1201. }
  1202. string arm = _hand == Hand.Blade1 ? "A" : "B";
  1203. _device.CmdBladeTarget = $"{_chamber}.{arm}";
  1204. _device.CmdBlade1Extend = "0";
  1205. _device.CmdBlade2Extend = "0";
  1206. _device.Blade1Target = ModuleHelper.Converter(_device.Name);
  1207. _device.Blade2Target = ModuleHelper.Converter(_device.Name);
  1208. }
  1209. }
  1210. public class PlaceHandlerEx : RobotMotionHandler
  1211. {
  1212. private ModuleName _chamber;
  1213. private int _slot;
  1214. private Hand _hand;
  1215. public PlaceHandlerEx()
  1216. {
  1217. background = true;
  1218. }
  1219. public override string package(params object[] args)
  1220. {
  1221. _chamber = (ModuleName)args[0];
  1222. _slot = (int)args[1];
  1223. _hand = (Hand)args[2];
  1224. int x = (int)args[3];
  1225. int y = (int)args[4];
  1226. int z = (int)args[5];
  1227. updateBefore();
  1228. if (_hand == Hand.Both)
  1229. {
  1230. return string.Format(",MTPO,{0},{1:D2},P{2},A,{3},{4},{5}",
  1231. RobotConvertor.chamber2staion(_chamber),
  1232. RobotConvertor.chamberSlot2Slot(_chamber, _slot + 1),
  1233. RobotConvertor.hand2string(_hand),
  1234. RobotConvertor.Offset2String(x),
  1235. RobotConvertor.Offset2String(y),
  1236. RobotConvertor.Offset2String(z)
  1237. );
  1238. }
  1239. return string.Format(",MTPO,{0},{1:D2},P{2},A,{3},{4},{5}",
  1240. RobotConvertor.chamber2staion(_chamber),
  1241. RobotConvertor.chamberSlot2Slot(_chamber, _slot),
  1242. RobotConvertor.hand2string(_hand),
  1243. RobotConvertor.Offset2String(x),
  1244. RobotConvertor.Offset2String(y),
  1245. RobotConvertor.Offset2String(z)
  1246. );
  1247. }
  1248. private void updateBefore()
  1249. {
  1250. _device.Blade1Target = _chamber;
  1251. _device.Blade2Target = _chamber;
  1252. string arm = _hand == Hand.Blade1 ? "A" : "B";
  1253. _device.CmdBladeTarget = $"{_chamber}.{arm}";
  1254. _device.CmdBlade1Extend = _hand == Hand.Blade1 ? "1" : "0";
  1255. _device.CmdBlade2Extend = _hand == Hand.Blade1 ? "0" : "1";
  1256. }
  1257. protected override void update(string[] data)
  1258. {
  1259. if (_hand == Hand.Blade1)
  1260. {
  1261. WaferManager.Instance.WaferMoved(ModuleHelper.Converter(_device.Name), (int)Hand.Blade1, _chamber, _slot);
  1262. }
  1263. else if (_hand == Hand.Blade2)
  1264. {
  1265. for (int i = 0; i < _device.Blade2Slots; i++)
  1266. WaferManager.Instance.WaferMoved(ModuleHelper.Converter(_device.Name), (int)Hand.Blade2 + i, _chamber, _slot + i);
  1267. }
  1268. else
  1269. {
  1270. for (int i = 0; i < _device.Blade2Slots + 1; i++)
  1271. WaferManager.Instance.WaferMoved(ModuleHelper.Converter(_device.Name), (int)Hand.Blade1 + i, _chamber, _slot + i);
  1272. }
  1273. _device.Blade1Target = ModuleHelper.Converter(_device.Name);
  1274. _device.Blade2Target = ModuleHelper.Converter(_device.Name);
  1275. string arm = _hand == Hand.Blade1 ? "A" : "B";
  1276. _device.CmdBladeTarget = $"{_chamber}.{arm}";
  1277. _device.CmdBlade1Extend = "0";
  1278. _device.CmdBlade2Extend = "0";
  1279. }
  1280. }
  1281. //NOT SUPPORT with OFFSET
  1282. //public class ExchangeHandlerEx : RobotMotionHandler
  1283. //{
  1284. // private ModuleName _chamber;
  1285. // private int _slot;
  1286. // private Hand _hand;
  1287. // public ExchangeHandlerEx()
  1288. // {
  1289. // background = true;
  1290. // }
  1291. // public override string package(params object[] args)
  1292. // {
  1293. // // $ <UNo> (<SeqNo>) MEXG <Sum> <CR>
  1294. // _chamber = (ModuleName)args[0];
  1295. // _slot = (int)args[1];
  1296. // _hand = (Hand)args[2];
  1297. // if (_hand == Hand.Blade1)
  1298. // _hand = Hand.Blade2;
  1299. // else
  1300. // _hand = Hand.Blade1;
  1301. // updateBefore();
  1302. // int x = (int)args[3];
  1303. // int y = (int)args[4];
  1304. // int z = (int)args[5];
  1305. // updateBefore();
  1306. // if (_hand == Hand.Both)
  1307. // {
  1308. // return string.Format(",MTPO,{0},{1:D2},G{2},A,{3},{4},{5}",
  1309. // RobotConvertor.chamber2staion(_chamber),
  1310. // RobotConvertor.chamberSlot2Slot(_chamber, _slot + 1),
  1311. // RobotConvertor.hand2string(_hand),
  1312. // RobotConvertor.Offset2String(x),
  1313. // RobotConvertor.Offset2String(y),
  1314. // RobotConvertor.Offset2String(z)
  1315. // );
  1316. // }
  1317. // return string.Format(",MTPO,{0},{1:D2},G{2},A,{3},{4},{5}",
  1318. // RobotConvertor.chamber2staion(_chamber),
  1319. // RobotConvertor.chamberSlot2Slot(_chamber, _slot),
  1320. // RobotConvertor.hand2string(_hand),
  1321. // RobotConvertor.Offset2String(x),
  1322. // RobotConvertor.Offset2String(y),
  1323. // RobotConvertor.Offset2String(z));
  1324. // }
  1325. // private void updateBefore()
  1326. // {
  1327. // _device.Blade1Target = _chamber;
  1328. // _device.Blade2Target = _chamber;
  1329. // _device.Swap = true;
  1330. // _device.PlaceBalde = _hand;
  1331. // }
  1332. // protected override void update(string[] data)
  1333. // {
  1334. // if (_hand == Hand.Blade2)
  1335. // {
  1336. // WaferManager.Instance.WaferMoved(_chamber, _slot, ModuleName.Robot, (int)Hand.Blade2);
  1337. // WaferManager.Instance.WaferMoved(ModuleName.Robot, (int)Hand.Blade1, _chamber, _slot);
  1338. // }
  1339. // else
  1340. // {
  1341. // WaferManager.Instance.WaferMoved(_chamber, _slot, ModuleName.Robot, (int)Hand.Blade1);
  1342. // WaferManager.Instance.WaferMoved(ModuleName.Robot, (int)Hand.Blade2, _chamber, _slot);
  1343. // }
  1344. // _device.Swap = false;
  1345. // _device.Blade1Target = ModuleName.Robot;
  1346. // _device.Blade2Target = ModuleName.Robot;
  1347. // }
  1348. //}
  1349. public class RBWaferMappingHandler : RobotMotionHandler
  1350. {
  1351. private ModuleName _chamber;
  1352. public RBWaferMappingHandler()
  1353. {
  1354. background = true;
  1355. }
  1356. public override string package(params object[] args)
  1357. {
  1358. //$ <UNo> (<SeqNo>) MMAP <TrsSt> <SlotNo> <Sum> <CR>
  1359. // SlotNo: Slot number(2 bytes)
  1360. //• "FF": When all slots specified
  1361. //• ”01” to ”XX”: When cassette stage is specified by < TrsSt >
  1362. //(The maximum value of "XX" is in ASCII code of the number of slots specified by parameter.)
  1363. //• ”00”: When transfer stage or P / A stage specified by<TrsSt>
  1364. // Note: Specific slot section definition cannot be performed.
  1365. //• Reception rejected: Responds with the error code.
  1366. _chamber = (ModuleName)args[0];
  1367. //_slot = (int)args[1];
  1368. //_hand = (Hand)args[2];
  1369. updateBefore();
  1370. return string.Format(",MMAP,{0},FF,",
  1371. RobotConvertor.chamber2staion(_chamber));
  1372. }
  1373. private void updateBefore()
  1374. {
  1375. _device.Blade1Target = _chamber;
  1376. _device.Blade2Target = _chamber;
  1377. }
  1378. protected override void update(string[] data)
  1379. {
  1380. _device.Blade1Target = ModuleHelper.Converter(_device.Name);
  1381. _device.Blade2Target = ModuleHelper.Converter(_device.Name);
  1382. }
  1383. }
  1384. public class RBQueryWaferMapHandler : ITransferMsg
  1385. {
  1386. public bool background { get; protected set; }
  1387. public bool evt { get { return false; } }
  1388. public string deviceID { private get; set; }
  1389. public string _cmd = string.Empty;
  1390. private ModuleName _chamber;
  1391. public IDevice Robot { set { _device = (Robot)value; } }
  1392. protected Robot _device;
  1393. public RBQueryWaferMapHandler()
  1394. {
  1395. background = false;
  1396. }
  1397. //$ <UNo> (<SeqNo>) RMAP <TrsSt> <SlotNo> <Sum> <CR>
  1398. public string package(params object[] args)
  1399. {
  1400. _chamber = (ModuleName)args[0];
  1401. return string.Format(",RMAP,{0},FF,",
  1402. RobotConvertor.chamber2staion(_chamber));
  1403. }
  1404. public bool unpackage(string type, string[] items)
  1405. {
  1406. //$,<UNo>(,<SeqNo>),<Sts>,<Ackcd>,RMAP,<TrsSt>,<Slot>,
  1407. //01:<Result1>…,N:<ResultN>(,<Sum>)<CR>
  1408. //• UNo : Unit number (1 byte)
  1409. //• SeqNo : Sequence number (None / 2 bytes)
  1410. //• Sts : Status (2 bytes)
  1411. //• Ackcd : Response code (4 bytes)
  1412. //• TrsSt : Transfer station (3 bytes)
  1413. //• Slot : Slot number (2 bytes)
  1414. //• Result* : Mapping result (2 bytes each)
  1415. //• “--” : No wafer detected.
  1416. //• “OK” : Wafer inserted correctly.
  1417. //• “CW” : Wafer inserted incorrectly (inclined).
  1418. //• “DW” : Wafer inserted incorrectly (duplicated).
  1419. //Note) Responds with the number of slots of the specified transfer station.
  1420. //$,1,00,0000,RMAP,C02,00,
  1421. //01:OK,02:DW,03:OK,04:CW,05:CW,06:OK,07:OK,08:--,09:OK,10:OK
  1422. // No wafer: "0", Wafer: "1", Crossed:"2", Undefined: "?", Overlapping wafers: "W"
  1423. if (items.Length > 5)
  1424. {
  1425. string data = items[5];
  1426. StringBuilder sb = new StringBuilder();
  1427. for (int i = 0; i < data.Length; i += 4)
  1428. {
  1429. string value = data.Substring(i + 2, 2);
  1430. switch (value)
  1431. {
  1432. case "--":
  1433. sb.Append("0");
  1434. break;
  1435. case "OK":
  1436. sb.Append("1");
  1437. break;
  1438. case "CW":
  1439. sb.Append("2");
  1440. break;
  1441. case "DW":
  1442. sb.Append("W");
  1443. break;
  1444. }
  1445. }
  1446. _device.NotifySlotMapResult(_chamber, sb.ToString());
  1447. return true;
  1448. }
  1449. return !background;
  1450. }
  1451. }
  1452. // Transfer speed level setting
  1453. public class RbSetSpeedHandler : RobotMotionHandler
  1454. {
  1455. private int _speed = 0;
  1456. public RbSetSpeedHandler()
  1457. {
  1458. background = false;
  1459. }
  1460. public override string package(params object[] args)
  1461. {
  1462. _speed = (int)args[0];
  1463. //$ < UNo > (< SeqNo >) SSLV<Level> < Sum > < CR >
  1464. ///
  1465. /// • ’H’ : High speed level
  1466. //• ’M’ : Medium speed level
  1467. //• ’L’ : Low speed level
  1468. ///
  1469. if(_speed == 1)
  1470. return string.Format(",SSLV,H,");
  1471. else if (_speed == 2)
  1472. return string.Format(",SSLV,M,");
  1473. return string.Format(",SSLV,L,");
  1474. }
  1475. }
  1476. // Transfer speed level setting
  1477. public class RbSetOffsetHandler : RobotMotionHandler
  1478. {
  1479. public RbSetOffsetHandler()
  1480. {
  1481. background = false;
  1482. }
  1483. public override string package(params object[] args)
  1484. {
  1485. //$ <UNo> (<SeqNo>) SOFS <Mem> <TrsSt> <Offset1> <Offset2> … <Offset5> <Sum> <CR>
  1486. ///Mem: Memory (1 byte) ‘V’: Volatile memory ‘N’: Non -volatile memory
  1487. //• TrsSt: Transfer station(2 bytes)
  1488. //• "C1" to "C8": When cassette stage specified
  1489. //• "S1" to "SC": When transfer stage specified
  1490. //• "P1" to “P2”: When P/ A stage specified
  1491. //Note: P2 station is effective only when two or more PA stations exist.
  1492. //• Offset: Transfer offset(4 bytes each)
  1493. //• Offset1: Downward offset
  1494. //• Offset2: Upward offset
  1495. //• Offset3: Offset in the extending direction(with the edge - grip - type fork)
  1496. //• Offset4: Offset in the retracting direction(with the edge - grip - type fork)
  1497. //• Offset5: Put downward offset(with the edge - grip - type fork)
  1498. //Note: Offset3 to Offset5 are omitted when the fork type is not the edge - grip type.
  1499. //• About Offset3 to Offset5, it is omissible with a parameter setup.
  1500. //• Specified in the range between "-999" and "9999"(resolution: 0.01[mm])
  1501. //• If a value is less than specified digits, fill the higher digit with ‘0’ so that the field always has specfied digits.
  1502. ModuleName _chamber = (ModuleName)args[0];
  1503. int down = (int)args[1];
  1504. int up = (int)args[2];
  1505. int extend = (int)args[2];
  1506. int retract = (int)args[2];
  1507. int pdown = (int)args[2];
  1508. return string.Format(",SOFS,V,{0},{1:D4},{2:D4},{3:D4},{4:D4},",
  1509. RobotConvertor.chamber2staion(_chamber),
  1510. down,
  1511. up,
  1512. extend,
  1513. retract,
  1514. pdown
  1515. );
  1516. }
  1517. }
  1518. public class RBQueryStateHandler : ITransferMsg
  1519. {
  1520. public bool background { get; protected set; }
  1521. public bool evt { get { return false; } }
  1522. public string deviceID { private get; set; }
  1523. public string _cmd = string.Empty;
  1524. public IDevice Robot { set { _device = (Robot)value; } }
  1525. protected Robot _device;
  1526. public RBQueryStateHandler()
  1527. {
  1528. background = false;
  1529. }
  1530. //$ <UNo> (<SeqNo>) <StsN> <Ackcd> <Sum> <CR>
  1531. //$ <UNo> (<SeqNo>) <StsN> <Ackcd> <Errcd> <Status1> … <Status4> <Sum> <CR>
  1532. public string package(params object[] args)
  1533. {
  1534. return ",RSTS,";
  1535. }
  1536. public bool unpackage(string type, string[] items)
  1537. {
  1538. //status1 bit 0 --blade 1 wafer status 0=wafer present, 1=wafer absent. Here balde 1 is upper
  1539. //status1 bit 1 --blade 2 wafer status 0=wafer present, 1=wafer absent. Here balde 2 is lower
  1540. //$,1,10,A0,0000,29D05000 status1 = 5 measn blade1 has wafer, blade2 no wafer
  1541. int status1 = 0;
  1542. if (items!=null && items.Length >= 6 && items[5].Length > 4)
  1543. {
  1544. var content = items[5];
  1545. var status1Bit = content[4];
  1546. if (status1Bit >= 'A' && status1Bit <= 'F')
  1547. status1 = status1Bit - 'A' + 10;
  1548. else if (status1Bit >= 'a' && status1Bit <= 'f')
  1549. status1 = status1Bit - 'a' + 10;
  1550. else
  1551. int.TryParse(status1Bit.ToString(), out status1);
  1552. //Here balde 1 is upper,balde 2 is lower
  1553. ((Robot)_device).NotifyWaferPresent(Hand.Blade2, (status1&0x0001) == 0 ? WaferStatus.Normal : WaferStatus.Empty);
  1554. ((Robot)_device).NotifyWaferPresent(Hand.Blade1, (status1&0x0002) == 0 ? WaferStatus.Normal : WaferStatus.Empty);
  1555. }
  1556. return !background;
  1557. }
  1558. }
  1559. public class RbEventHandler : ITransferMsg
  1560. {
  1561. public bool background { get { return false; } }
  1562. public bool evt { get { return true; } }
  1563. public string deviceID { private get; set; }
  1564. public string _cmd = string.Empty;
  1565. public IDevice Robot { set { _device = (Robot)value; } }
  1566. protected Robot _device;
  1567. public RbEventHandler()
  1568. {
  1569. }
  1570. //$,<UNo>(,<SeqNo>),RSTS(,<Sum>)<CR>
  1571. public string package(params object[] args)
  1572. {
  1573. return "";
  1574. }
  1575. public bool unpackage(string type, string[] items)
  1576. {
  1577. string evtType = items[3];
  1578. if (evtType.Equals(ProtocolTag.resp_evt_error))
  1579. {
  1580. int error = Convert.ToInt32(items[5], 16);
  1581. _device.ErrorCode = error;
  1582. if (error > 0)
  1583. _device.LastErrorCode = error;
  1584. return true;
  1585. }
  1586. return false;
  1587. }
  1588. }
  1589. public class RBQueryPositionHandler : ITransferMsg
  1590. {
  1591. public bool background { get; protected set; }
  1592. public bool evt { get { return false; } }
  1593. public string deviceID { private get; set; }
  1594. public string _cmd = string.Empty;
  1595. public IDevice Robot { set { _device = (Robot)value; } }
  1596. protected Robot _device;
  1597. public RBQueryPositionHandler()
  1598. {
  1599. background = false;
  1600. }
  1601. //$ <UNo> (<SeqNo>) RPOS <TrsSt> <Fork> <Posture> <Sum> <CR>
  1602. // • TrsSt: Transfer station(2 bytes)
  1603. //• "C1" to "C8": When the lowest-layer position of the cassette stage specified
  1604. //• "H1" to "H8": When the highest-layer position of the cassette stage specified
  1605. //• "S1" to "SC": When transfer stage specified
  1606. //• "P1" to “P2”: When P/A stage specified
  1607. //Note: P2 station is effective only when two or more PA stations exist.
  1608. //• "FF": When current position specified
  1609. //• "FE": When specify the feedback of present location
  1610. //<Three-axis pre-aligner, Edge-grip pre-aligner>
  1611. //• "FF": When current position specified
  1612. //• "FE": When specify the feedback of present location
  1613. //• Fork: Fork specified(1 byte)
  1614. //• ‘A’: When extension axis 1 (Blade 1) specified
  1615. //• ‘B’: When extension axis 2 (Blade 2) specified(for dual-arm manipulator and dual blade linear motion
  1616. //manipulator only)
  1617. //Note: Fixed to ‘A’ when the current position and feedback of present location are specified at<TrsSt>
  1618. public string package(params object[] args)
  1619. {
  1620. return ",RPOS,FF,A,A,";
  1621. }
  1622. public bool unpackage(string type, string[] items)
  1623. {
  1624. //$ <UNo> (<SeqNo>) <StsN> <Ackcd> <Value1> … <ValueN> <Sum> <CR>
  1625. // • ValueN: Coordinate(8 bytes each)
  1626. //• Specified in the range as follows (The resolution is 0.01[mm] or[deg])
  1627. //8 Byte: between "-9999999" ~"99999999"
  1628. //• If a value is less than specified digits, fill the higher digit with ‘0’ so that the field always has specfied digits.
  1629. //• The sign is added to the highest digit.
  1630. //• The number of “ValueN” depends on the unit type.
  1631. //Responds with as many axis numbers as the specified unit has.See the table bellow.
  1632. //Unit Value1 Value2 Value3 Value4 Value5 Value6
  1633. //Single - arm manipulator Rotation //Elevation //(Track
  1634. //Dual - arm manipulator Rotation //Extension //axis 1 //axis 2 //(Track
  1635. if (items.Length > 7)
  1636. {
  1637. _device.Rotation = int.Parse(items[7]);
  1638. _device.Extension = int.Parse(items[8]);
  1639. _device.Wrist1 = int.Parse(items[9]);
  1640. _device.Wrist2 = int.Parse(items[10]);
  1641. _device.Evevation = int.Parse(items[11]);
  1642. return true;
  1643. }
  1644. return !background;
  1645. }
  1646. }
  1647. public class RbSetWaferSizeHandler : RobotMotionHandler
  1648. {
  1649. public RbSetWaferSizeHandler()
  1650. {
  1651. background = false;
  1652. }
  1653. public override string package(params object[] args)
  1654. {
  1655. ////$ < UNo > (< SeqNo >) SPRM<Type> < PrmNo > < Value > < Sum > < CR >
  1656. //// UNo: Unit No. (1 Byte)
  1657. ////  ‘1’ : RB
  1658. ////  ‘2’ : PA
  1659. //// SeqNo: Sequence No. (None / 1 / 2 / 3 Byte)
  1660. //// Type: Parameter type(3 Byte)
  1661. ////  ”CIU” : Common integral number parameter
  1662. ////  ”CRU” : Common real number parameter
  1663. ////  ”CRS” : Common real number system parameter
  1664. ////  ”UIU” : Unit integral number parameter
  1665. ////  ”URU” : Unit real number parameter
  1666. ////  ”URS” : Unit real number system parameter
  1667. //// PrmNo: Parameter No. (4 Byte)
  1668. ////  Designate in the range of ”0000” - ”9999”
  1669. ////  In case of less than 4 - digit, put 0 in front of the numbers. Always designate numbers in
  1670. ////4 - digit format.
  1671. //// Value: Parameter value(12 Byte)
  1672. //// Designate in the range of ”-99999999999” - ”999999999999” (Resolving power of real
  1673. ////number parameter is 0.0001)  In case of less than 12 - digit, put 0 in front of the numbers. Always designate numbers in
  1674. ////12 - digit format.
  1675. //// Simbol is added on most significant bit
  1676. ////[Response format](Response message) $ < UNo > (< SeqNo >) < StsN > < Ackcd > < Sum > < CR >
  1677. //// UNo: Unit No.(1 Byte)
  1678. ////  ‘1’ : RB
  1679. ////  ‘2’ : PA
  1680. //// SeqNo: Sequence No. (None / 1 / 2 / 3 Byte)
  1681. //// StsN: Status(1 / 2 Byte)
  1682. //// Ackcd: Response code(4 Byte)
  1683. ////  In case of reception normally  Response ”0000”
  1684. ////  Incase of reception denial  Response error code
  1685. ///
  1686. //SPRMCRS0000 000000625000 68
  1687. int cmd = (int)args[0];
  1688. WaferSize size = (WaferSize)args[1];
  1689. string package = "";
  1690. switch (cmd)
  1691. {
  1692. case 0x0000:
  1693. package = string.Format("SPRM,CRS,0000,{0:D12},",
  1694. RobotConvertor.WaferSize2Int(size)
  1695. );
  1696. break;
  1697. case 0x0114:
  1698. package = string.Format("SPRM,URS,0114,{0:D12},",
  1699. RobotConvertor.MappingOffset2Int(size)
  1700. );
  1701. break;
  1702. }
  1703. return package;
  1704. }
  1705. }
  1706. /*
  1707. public class RBQueryWaferSizeHandler : ITransferMsg
  1708. {
  1709. public bool background { get; protected set; }
  1710. public bool evt { get { return false; } }
  1711. public string deviceID { private get; set; }
  1712. public string _cmd = string.Empty;
  1713. public IDevice Robot { set { _device = (Robot)value; } }
  1714. protected Robot _device;
  1715. public RBQueryWaferSizeHandler()
  1716. {
  1717. background = false;
  1718. }
  1719. //$ <UNo> (<SeqNo>) <StsN> <Ackcd> <Sum> <CR>
  1720. //$ <UNo> (<SeqNo>) <StsN> <Ackcd> <Errcd> <Status1> … <Status4> <Sum> <CR>
  1721. public string package(params object[] args)
  1722. {
  1723. return ",RSTS,";
  1724. }
  1725. public bool unpackage(string type, string[] items)
  1726. {
  1727. //status1 bit 0 --blade 1 wafer status 0=wafer present, 1=wafer absent. Here balde 1 is upper
  1728. //status1 bit 1 --blade 2 wafer status 0=wafer present, 1=wafer absent. Here balde 2 is lower
  1729. //$,1,10,A0,0000,29D05000 status1 = 5 measn blade1 has wafer, blade2 no wafer
  1730. int status1 = 0;
  1731. if (items != null && items.Length >= 6 && items[5].Length > 4)
  1732. {
  1733. var content = items[5];
  1734. var status1Bit = content[4];
  1735. if (status1Bit >= 'A' && status1Bit <= 'F')
  1736. status1 = status1Bit - 'A' + 10;
  1737. else if (status1Bit >= 'a' && status1Bit <= 'f')
  1738. status1 = status1Bit - 'a' + 10;
  1739. else
  1740. int.TryParse(status1Bit.ToString(), out status1);
  1741. //Here balde 1 is upper,balde 2 is lower
  1742. ((Robot)_device).NotifyWaferPresent(Hand.Blade2, (status1 & 0x0001) == 0 ? WaferStatus.Normal : WaferStatus.Empty);
  1743. ((Robot)_device).NotifyWaferPresent(Hand.Blade1, (status1 & 0x0002) == 0 ? WaferStatus.Normal : WaferStatus.Empty);
  1744. }
  1745. return !background;
  1746. }
  1747. }
  1748. */
  1749. }