Handler.cs 53 KB

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