AlignerHandler.cs 7.9 KB

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