AlignerHandler.cs 8.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293
  1. using System;
  2. using Aitex.Core.RT.Device;
  3. using Aitex.Sorter.Common;
  4. namespace MECF.Framework.RT.EquipmentLibrary.HardwareUnits.Robot.NX100.AL
  5. {
  6. public class AlignerHandler : ITransferMsg
  7. {
  8. public bool background { get; protected set; }
  9. public bool evt { get { return false; } }
  10. public string deviceID { private get; set; }
  11. public string _cmd = string.Empty;
  12. public IDevice Robot { set { _device = (Aligner)value; } }
  13. protected Aligner _device;
  14. public AlignerHandler()
  15. {
  16. background = false;
  17. }
  18. public virtual string package(params object[] args)
  19. {
  20. return "";
  21. }
  22. public bool unpackage(string type, string[] items)
  23. {
  24. int value = Convert.ToInt32(items[3], 16);
  25. _device.Status = value;
  26. int error = Convert.ToInt32(items[4], 16);
  27. _device.ErrorCode = error;
  28. if (error > 0)
  29. _device.LastErrorCode = error;
  30. if (type.Equals(ProtocolTag.resp_tag_excute))
  31. {
  32. if (error == 0)
  33. {
  34. update(items);
  35. }
  36. return true;
  37. }
  38. return !background;
  39. }
  40. protected virtual void update(string[] data)
  41. {
  42. }
  43. }
  44. public class AlInitHandler : AlignerHandler
  45. {
  46. public AlInitHandler()
  47. {
  48. background = true;
  49. }
  50. public override string package(params object[] args)
  51. {
  52. return ",INIT,00,";
  53. }
  54. protected override void update(string[] data)
  55. {
  56. _device.Initalized = true;
  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. return ",MHOM,F,";
  68. }
  69. protected override void update(string[] data)
  70. {
  71. _device.Initalized = true;
  72. }
  73. }
  74. public class AlClearErrorHandler : AlignerHandler
  75. {
  76. public AlClearErrorHandler()
  77. {
  78. background = true;
  79. }
  80. //$,<UNo>(,<SeqNo>),CCLR,<CMode>(,<Sum>)<CR>
  81. public override string package(params object[] args)
  82. {
  83. return ",CCLR,E,";
  84. }
  85. }
  86. public class AlGripHandler : AlignerHandler
  87. {
  88. public AlGripHandler()
  89. {
  90. background = true;
  91. }
  92. //Command wafer hold/release signal to the solenoid of the specified unit.
  93. //$ <UNo> (<SeqNo>) CSOL <Fork> <Sw> <Sum> <CR>
  94. //• Fork: Fork specified(1 byte)
  95. //• ‘A’: Extension axis 1 (Blade 1), pre-aligner
  96. //• ‘B’: Extension axis 2 (Blade 2)
  97. //• Sw: Chucking command(1 byte)
  98. //• ‘0’: Chucking OFF
  99. //• ‘1’: Chucking ON
  100. public override string package(params object[] args)
  101. {
  102. bool bHold = (bool)args[1];
  103. // bool bHold = (bool)args[0];
  104. if (bHold)
  105. return ",CSOL,A,1,";
  106. return ",CSOL,A,0,";
  107. }
  108. }
  109. public class ALMoveToReadyPositionHandler : AlignerHandler
  110. {
  111. public ALMoveToReadyPositionHandler()
  112. {
  113. background = true;
  114. }
  115. public override string package(params object[] args)
  116. {
  117. return ",MTRS,GP,00,AL,A,";
  118. }
  119. }
  120. public class ALLiftHandler : AlignerHandler
  121. {
  122. public ALLiftHandler()
  123. {
  124. background = true;
  125. }
  126. //$ <UNo> (<SeqNo>) CLFT<Sw> <Sum> <CR>
  127. //• UNo: Unit number(1 byte)
  128. //• ‘1’ to ‘4’: Unit specified
  129. //• SeqNo: Sequence number(Non/1/2/3 byte)
  130. //• Sw: Lifter command(1 byte)
  131. //• ‘0’: Lifter down
  132. //• ‘1’: Lifter up
  133. public override string package(params object[] args)
  134. {
  135. bool bUp = (bool)args[0];
  136. if (bUp)
  137. return ",CLFT,1,";
  138. return ",CLFT,0,";
  139. }
  140. }
  141. public class AlStopHandler : AlignerHandler
  142. {
  143. public AlStopHandler()
  144. {
  145. background = true;
  146. }
  147. public override string package(params object[] args)
  148. {
  149. return ",CHLT,";
  150. }
  151. }
  152. public class ALQueryStateHandler : ITransferMsg
  153. {
  154. public bool background { get; protected set; }
  155. public bool evt { get { return false; } }
  156. public string deviceID { private get; set; }
  157. public string _cmd = string.Empty;
  158. public IDevice Robot { set { _device = (Aligner)value; } }
  159. protected Aligner _device;
  160. public ALQueryStateHandler()
  161. {
  162. background = false;
  163. }
  164. //$,<UNo>(,<SeqNo>),RSTS(,<Sum>)<CR>
  165. public string package(params object[] args)
  166. {
  167. return ",RSTS,";
  168. }
  169. public bool unpackage(string type, string[] items)
  170. {
  171. return !background;
  172. }
  173. }
  174. public class AlAlignHandler : AlignerHandler
  175. {
  176. private int _angle = 0;
  177. public AlAlignHandler()
  178. {
  179. background = true;
  180. }
  181. // $ <UNo> (<SeqNo>) MALN <TUNo> <TrsSt> <Angle> <Sum> <CR>
  182. //Mode : Motion mode (1 byte) If the case of edge grip type pre-alinger, specify ‘0’.
  183. public override string package(params object[] args)
  184. {
  185. // • TUNo: Unit number to be compensated for (1 byte)
  186. //• ‘1’ to ‘4’: Unit specified
  187. //• TrsSt: Target station(2 Byte)
  188. //• ”P1” - ”P2”: At the time of PA stage specification
  189. //Note: P1 and P2 station are effective only when two or more PA stations exist.
  190. //When it does not exist in addition to P1 station, specification of an target station is nothing.
  191. //• Angle: Positioning angle(6 bytes)
  192. //• Relative angle from the position set by alignment calibration as the reference point.
  193. //• Specified in the range between "000000" and "035999"(0 to 359.99 degree.Resolution: 0.01[deg])
  194. //• If a value is less than specified digits, fill the higher digit with ‘0’ so that the field always has specfied digits
  195. //_angle is 0.001 pecent
  196. _angle =(int)Math.Round((double)args[0]* 100.0,2);
  197. return string.Format(",MALN,1,{0:D6},",_angle);
  198. //return string.Format(",MALN,2,{0:D6},", _angle);
  199. }
  200. //!,<UNo>(,<SeqNo>),<Sts>,<Errcd>,MALN,<ExeTime>,<PosData1>…,<PosDataN>,<Value1>…,<Value10>(,<Sum>)<CR>
  201. protected override void update(string[] data)
  202. {
  203. /*
  204. $ <UNo> (<SeqNo>) <StsN> <Ackcd> <Sum> <CR>
  205. */
  206. _device.Notch = _angle;
  207. }
  208. }
  209. public class ALEventHandler : ITransferMsg
  210. {
  211. public bool background { get { return false; } }
  212. public bool evt { get { return true; } }
  213. public string deviceID { private get; set; }
  214. public string _cmd = string.Empty;
  215. public IDevice Robot { set { _device = (Aligner)value; } }
  216. protected Aligner _device;
  217. public ALEventHandler()
  218. {
  219. }
  220. //$,<UNo>(,<SeqNo>),RSTS(,<Sum>)<CR>
  221. public string package(params object[] args)
  222. {
  223. return "";
  224. }
  225. public bool unpackage(string type, string[] items)
  226. {
  227. string evtType = items[3];
  228. if (evtType.Equals(ProtocolTag.resp_evt_error))
  229. {
  230. int error = Convert.ToInt32(items[5], 16);
  231. _device.ErrorCode = error;
  232. if (error > 0)
  233. _device.LastErrorCode = error;
  234. return true;
  235. }
  236. return false;
  237. }
  238. }
  239. }