AlignerHandler.cs 7.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265
  1. using System;
  2. using Aitex.Core.RT.Device;
  3. using Aitex.Sorter.Common;
  4. namespace MECF.Framework.RT.EquipmentLibrary.HardwareUnits.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. public IDevice Robot { set { _device = (Aligner)value; } }
  14. protected Aligner _device;
  15. public AlignerHandler()
  16. {
  17. background = false;
  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[0];
  97. if (bHold)
  98. return ",CSOL,1,1,0,";
  99. return ",CSOL,1,0,0,";
  100. }
  101. }
  102. public class ALLiftHandler : AlignerHandler
  103. {
  104. public ALLiftHandler()
  105. {
  106. background = true;
  107. }
  108. //$,<UNo>(,<SeqNo>),CSOL,<Sol>,<Sw>,<Wait>(,<Sum>)<CR>
  109. //sol Solenoid control specification (1 byte) • ‘1’ : Blade 1. • ‘2’ : Blade 2. • ‘F’ : Blade 1 + Blade 2.
  110. // Solenoid command (1 byte) • ‘0’ : Wafer release. / Lifter down. • ‘1’ : Wafer hold. / Lifter up.
  111. public override string package(params object[] args)
  112. {
  113. bool bUp = (bool)args[0];
  114. if (bUp)
  115. return ",CSOL,2,1,0,";
  116. return ",CSOL,2,0,0,";
  117. }
  118. }
  119. public class AlStopHandler : AlignerHandler
  120. {
  121. public AlStopHandler()
  122. {
  123. background = true;
  124. }
  125. //$,<UNo>(,<SeqNo>),CSTP,<Sw>(,<Sum>)<CR>
  126. //• ‘H’ : Deceleration to a stop.
  127. //• ‘E’ : Emergency stop.
  128. public override string package(params object[] args)
  129. {
  130. return ",CSTP,H,";
  131. }
  132. }
  133. public class ALQueryStateHandler : ITransferMsg
  134. {
  135. public bool background { get; protected set; }
  136. public bool evt { get { return false; } }
  137. public string deviceID { private get; set; }
  138. public string _cmd = string.Empty;
  139. public IDevice Robot { set { _device = (Aligner)value; } }
  140. protected Aligner _device;
  141. public ALQueryStateHandler()
  142. {
  143. background = false;
  144. }
  145. //$,<UNo>(,<SeqNo>),RSTS(,<Sum>)<CR>
  146. public string package(params object[] args)
  147. {
  148. return ",RSTS,";
  149. }
  150. public bool unpackage(string type, string[] items)
  151. {
  152. return !background;
  153. }
  154. }
  155. public class AlAlignHandler : AlignerHandler
  156. {
  157. public AlAlignHandler()
  158. {
  159. background = true;
  160. }
  161. // $,<UNo>(,<SeqNo>),MALN,<Mode>,<Angle>(,<Sum>)<CR>
  162. //Mode : Motion mode (1 byte) If the case of edge grip type pre-alinger, specify ‘0’.
  163. public override string package(params object[] args)
  164. {
  165. int angle = (int)Math.Round((double)args[0] * 1000.0, 2);
  166. return string.Format(",MALN,0,{0:D8},", angle);
  167. }
  168. //!,<UNo>(,<SeqNo>),<Sts>,<Errcd>,MALN,<ExeTime>,<PosData1>…,<PosDataN>,<Value1>…,<Value10>(,<Sum>)<CR>
  169. protected override void update(string[] data)
  170. {
  171. /*
  172. • Value1 : Wafer eccentric amount before alignment operation (8 bytes, Resolution: 0.001 [mm])
  173. • Value2 : Wafer eccentric angle direction before alignment operation (8 bytes, Resolution: 0.001 [deg])
  174. • Value3 : Notch/Orientation Flat direction before alignment operation (8 bytes, Resolution: 0.001 [deg])
  175. • Value4 : X direction offset amount before alignment operation (8 bytes, Resolution: 0.001 [mm])
  176. • Value5 : Y direction offset amount before alignment operation (8 bytes, Resolution: 0.001 [mm])
  177. • Value6 : Pre-aligner adjustment angle (8 bytes, Resolution: 0.001 [deg])
  178. • Value7 : Manipulator adjustment amount (8 bytes, Resolution: 0.001 [mm])
  179. • Value8 : Manipulator adjustment angle (8 bytes, Resolution: 0.001 [deg])
  180. • Value9 : X direction offset amount after alignment operation (8 bytes, Resolution: 0.001 [mm])
  181. • Value10 : Y direction offset amount after alignment operation (8 bytes, Resolution: 0.001 [mm])
  182. * //value index is 9
  183. */
  184. _device.Notch = int.Parse(data[11]);
  185. }
  186. }
  187. public class ALEventHandler : ITransferMsg
  188. {
  189. public bool background { get { return false; } }
  190. public bool evt { get { return true; } }
  191. public string deviceID { private get; set; }
  192. public string _cmd = string.Empty;
  193. public IDevice Robot { set { _device = (Aligner)value; } }
  194. protected Aligner _device;
  195. public ALEventHandler()
  196. {
  197. }
  198. //$,<UNo>(,<SeqNo>),RSTS(,<Sum>)<CR>
  199. public string package(params object[] args)
  200. {
  201. return "";
  202. }
  203. public bool unpackage(string type, string[] items)
  204. {
  205. string evtType = items[3];
  206. if (evtType.Equals(ProtocolTag.resp_evt_error))
  207. {
  208. int error = Convert.ToInt32(items[5], 16);
  209. _device.ErrorCode = error;
  210. if (error > 0)
  211. _device.LastErrorCode = error;
  212. return true;
  213. }
  214. return false;
  215. }
  216. }
  217. }