AlignerHandler.cs 8.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281
  1. using System;
  2. using Aitex.Core.RT.Device;
  3. using Aitex.Sorter.Common;
  4. namespace Aitex.Sorter.RT.Device.Robot.SR100.AL
  5. {
  6. public class AlignerHandler : ITransferMsg
  7. {
  8. public int LastErrorCode { get; set; }
  9. public bool background { get; protected set; }
  10. public bool evt { get { return false; } }
  11. public string deviceID { private get; set; }
  12. public string _cmd = string.Empty;
  13. protected Aligner _device;
  14. public AlignerHandler()
  15. {
  16. background = false;
  17. _device = DEVICE.GetDevice<Aligner>(DeviceName.Aligner);
  18. }
  19. public virtual string package(params object[] args)
  20. {
  21. return "";
  22. }
  23. public bool unpackage(string type, string[] items)
  24. {
  25. int value = Convert.ToInt32(items[3], 16);
  26. _device.Status = value;
  27. int error = Convert.ToInt32(items[4], 16);
  28. _device.ErrorCode = error;
  29. if (error > 0)
  30. _device.LastErrorCode = error;
  31. if (type.Equals(ProtocolTag.resp_tag_excute))
  32. {
  33. _device.ElapseTime = int.Parse(items[6]);
  34. if (error == 0)
  35. {
  36. update(items);
  37. }
  38. return true;
  39. }
  40. return !background;
  41. }
  42. protected virtual void update(string[] data)
  43. {
  44. }
  45. }
  46. public class AlInitHandler : AlignerHandler
  47. {
  48. public AlInitHandler()
  49. {
  50. background = true;
  51. }
  52. //$,<UNo>(,<SeqNo>),CCLR,<CMode>(,<Sum>)<CR>
  53. public override string package(params object[] args)
  54. {
  55. return ",CCLR,E,";
  56. }
  57. }
  58. public class AlHomeHandler : AlignerHandler
  59. {
  60. public AlHomeHandler()
  61. {
  62. background = true;
  63. }
  64. public override string package(params object[] args)
  65. {
  66. return ",INIT,1,1,G,";
  67. }
  68. protected override void update(string[] data)
  69. {
  70. _device.Initalized = true;
  71. }
  72. }
  73. public class AlClearErrorHandler : AlignerHandler
  74. {
  75. public AlClearErrorHandler()
  76. {
  77. background = true;
  78. }
  79. //$,<UNo>(,<SeqNo>),CCLR,<CMode>(,<Sum>)<CR>
  80. public override string package(params object[] args)
  81. {
  82. return ",CCLR,E,";
  83. }
  84. }
  85. public class AlGripHandler : AlignerHandler
  86. {
  87. public AlGripHandler()
  88. {
  89. background = true;
  90. }
  91. //$,<UNo>(,<SeqNo>),CSOL,<Sol>,<Sw>,<Wait>(,<Sum>)<CR>
  92. //sol Solenoid control specification (1 byte) • ‘1’ : Blade 1. • ‘2’ : Blade 2. • ‘F’ : Blade 1 + Blade 2.
  93. // Solenoid command (1 byte) • ‘0’ : Wafer release. / Lifter down. • ‘1’ : Wafer hold. / Lifter up.
  94. public override string package(params object[] args)
  95. {
  96. bool bHold = (bool)args[1];
  97. //bool bHold = (bool)args[0];
  98. if (bHold)
  99. return ",CSOL,1,1,0,";
  100. return ",CSOL,1,0,0,";
  101. }
  102. }
  103. public class ALLiftHandler : AlignerHandler
  104. {
  105. public ALLiftHandler()
  106. {
  107. background = true;
  108. }
  109. //$,<UNo>(,<SeqNo>),CSOL,<Sol>,<Sw>,<Wait>(,<Sum>)<CR>
  110. //sol Solenoid control specification (1 byte) • ‘1’ : Blade 1. • ‘2’ : Blade 2. • ‘F’ : Blade 1 + Blade 2.
  111. // Solenoid command (1 byte) • ‘0’ : Wafer release. / Lifter down. • ‘1’ : Wafer hold. / Lifter up.
  112. public override string package(params object[] args)
  113. {
  114. bool bUp = (bool)args[0];
  115. if (bUp)
  116. return ",CSOL,2,1,0,";
  117. return ",CSOL,2,0,0,";
  118. }
  119. }
  120. public class AlStopHandler : AlignerHandler
  121. {
  122. public AlStopHandler()
  123. {
  124. background = true;
  125. }
  126. //$,<UNo>(,<SeqNo>),CSTP,<Sw>(,<Sum>)<CR>
  127. //• ‘H’ : Deceleration to a stop.
  128. //• ‘E’ : Emergency stop.
  129. public override string package(params object[] args)
  130. {
  131. return ",CSTP,H,";
  132. }
  133. }
  134. public class ALQueryStateHandler : ITransferMsg
  135. {
  136. public bool background { get; protected set; }
  137. public bool evt { get { return false; } }
  138. public string deviceID { private get; set; }
  139. public string _cmd = string.Empty;
  140. protected Aligner _device;
  141. public ALQueryStateHandler()
  142. {
  143. background = false;
  144. _device = DEVICE.GetDevice<Aligner>(DeviceName.Aligner);
  145. }
  146. //$,<UNo>(,<SeqNo>),RSTS(,<Sum>)<CR>
  147. public string package(params object[] args)
  148. {
  149. return ",RSTS,";
  150. }
  151. public bool unpackage(string type, string[] items)
  152. {
  153. if (items.Length > 7)
  154. {
  155. int errorCode = Convert.ToInt32(items[6], 16);
  156. _device.ErrorCode = errorCode;
  157. }
  158. if (items.Length > 8)
  159. {
  160. int status = Convert.ToInt32(items[7], 16);
  161. _device.StateVacuumGripStatus = (status & 0x01) == 0x01;
  162. _device.StateWaferPresent = (status & 0x02) == 0x02;
  163. _device.StateWaferHold = (status & 0x04) == 0x04;
  164. }
  165. return !background;
  166. }
  167. }
  168. public class AlAlignHandler : AlignerHandler
  169. {
  170. public AlAlignHandler()
  171. {
  172. background = true;
  173. }
  174. // $,<UNo>(,<SeqNo>),MALN,<Mode>,<Angle>(,<Sum>)<CR>
  175. //Mode : Motion mode (1 byte) If the case of edge grip type pre-Aligner, specify ‘0’.
  176. public override string package(params object[] args)
  177. {
  178. int angle = (int)Math.Round((double)args[0] * 1000.0, 2);
  179. return string.Format(",MALN,0,{0:D8},", angle);
  180. }
  181. //!,<UNo>(,<SeqNo>),<Sts>,<Errcd>,MALN,<ExeTime>,<PosData1>…,<PosDataN>,<Value1>…,<Value10>(,<Sum>)<CR>
  182. protected override void update(string[] data)
  183. {
  184. /*
  185. • Value1 : Wafer eccentric amount before alignment operation (8 bytes, Resolution: 0.001 [mm])
  186. • Value2 : Wafer eccentric angle direction before alignment operation (8 bytes, Resolution: 0.001 [deg])
  187. • Value3 : Notch/Orientation Flat direction before alignment operation (8 bytes, Resolution: 0.001 [deg])
  188. • Value4 : X direction offset amount before alignment operation (8 bytes, Resolution: 0.001 [mm])
  189. • Value5 : Y direction offset amount before alignment operation (8 bytes, Resolution: 0.001 [mm])
  190. • Value6 : Pre-aligner adjustment angle (8 bytes, Resolution: 0.001 [deg])
  191. • Value7 : Manipulator adjustment amount (8 bytes, Resolution: 0.001 [mm])
  192. • Value8 : Manipulator adjustment angle (8 bytes, Resolution: 0.001 [deg])
  193. • Value9 : X direction offset amount after alignment operation (8 bytes, Resolution: 0.001 [mm])
  194. • Value10 : Y direction offset amount after alignment operation (8 bytes, Resolution: 0.001 [mm])
  195. * //value index is 9
  196. */
  197. _device.Notch = int.Parse(data[11]);
  198. }
  199. }
  200. public class ALEventHandler : ITransferMsg
  201. {
  202. public bool background { get { return false; } }
  203. public bool evt { get { return true; } }
  204. public string deviceID { private get; set; }
  205. public string _cmd = string.Empty;
  206. protected Aligner _device;
  207. public ALEventHandler()
  208. {
  209. _device = DEVICE.GetDevice<Aligner>(DeviceName.Aligner);
  210. }
  211. //$,<UNo>(,<SeqNo>),RSTS(,<Sum>)<CR>
  212. public string package(params object[] args)
  213. {
  214. return "";
  215. }
  216. public bool unpackage(string type, string[] items)
  217. {
  218. string evtType = items[3];
  219. if (evtType.Equals(ProtocolTag.resp_evt_error))
  220. {
  221. int error = Convert.ToInt32(items[5], 16);
  222. _device.ErrorCode = error;
  223. if (error > 0)
  224. _device.LastErrorCode = error;
  225. return true;
  226. }
  227. return false;
  228. }
  229. }
  230. }