Utils.cs 8.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using Aitex.Core.Common;
  6. using Aitex.Core.RT.Log;
  7. using Aitex.Core.RT.SCCore;
  8. using Aitex.Sorter.Common;
  9. using MECF.Framework.Common.Equipment;
  10. namespace MECF.Framework.RT.EquipmentLibrary.HardwareUnits.Robot.NX100
  11. {
  12. public class ProtocolTag
  13. {
  14. public const string tag_end = "\r";
  15. public const string tag_cmd_start = "$";
  16. public const string cmd_token = ",";
  17. public const string resp_tag_normal = "$";
  18. public const string resp_tag_error = "?";
  19. public const string resp_tag_excute = "!";
  20. public const string resp_tag_event = ">";
  21. public const string resp_evt_error = "100";
  22. }
  23. public class RobotConvertor
  24. {
  25. public static Dictionary<ModuleName, string> TeachStation = new Dictionary<ModuleName, string>()
  26. {
  27. {ModuleName.LP1, "C1"},
  28. {ModuleName.LP2, "C2"},
  29. {ModuleName.LP3, "C3"},
  30. {ModuleName.LP4, "C4"},
  31. {ModuleName.LP5, "C5"},
  32. {ModuleName.LP6, "C6"},
  33. {ModuleName.LP7, "C7"},
  34. {ModuleName.LP8, "C8"},
  35. {ModuleName.LP9, "C9"},
  36. {ModuleName.LP10, "CA"},
  37. {ModuleName.Aligner, "P1"},
  38. {ModuleName.Buffer, "C5"},
  39. {ModuleName.TurnOverStation, "S1"},
  40. {ModuleName.PM1, "S1"},
  41. {ModuleName.PM2, "S2"},
  42. {ModuleName.PM3, "S3"},
  43. {ModuleName.PM4, "S4"},
  44. {ModuleName.PM5, "S5"},
  45. {ModuleName.PM6, "S6"},
  46. {ModuleName.PM7, "S7"},
  47. {ModuleName.PM8, "S8"},
  48. {ModuleName.Spin1L, "S1"},
  49. {ModuleName.Spin1H, "S2"},
  50. {ModuleName.Spin2L, "S3"},
  51. {ModuleName.Spin2H, "S4"},
  52. {ModuleName.Spin3L, "S5"},
  53. {ModuleName.Spin3H, "S6"},
  54. {ModuleName.Spin4L, "S7"},
  55. {ModuleName.Spin4H, "S8"},
  56. {ModuleName.LL1, "S1"},
  57. {ModuleName.LL2, "SA"},
  58. {ModuleName.LL3, "SB"},
  59. {ModuleName.LL4, "SC"},
  60. };
  61. public static string chamber2staion(ModuleName chamber)
  62. {
  63. if (!TeachStation.ContainsKey(chamber))
  64. {
  65. LOG.Error($"not define teach position {chamber}");
  66. return "";
  67. }
  68. if (chamber == ModuleName.Aligner && SC.ContainsItem("Aligner.AlignerStation"))
  69. return SC.GetStringValue("Aligner.AlignerStation");
  70. int index = SC.ContainsItem($"CarrierInfo.{chamber.ToString()}CarrierIndex") ?
  71. SC.GetValue<int>($"CarrierInfo.{chamber.ToString()}CarrierIndex") : -1;
  72. if (SC.ContainsItem($"CarrierInfo.{chamber.ToString()}Station{index}"))
  73. return SC.GetStringValue($"CarrierInfo.{chamber.ToString()}Station{index}");
  74. return TeachStation[chamber];
  75. }
  76. public static Dictionary<ModuleName, string> Slot2Slot = new Dictionary<ModuleName, string>()
  77. {
  78. {ModuleName.LP1, "SlotPlusOne"},
  79. {ModuleName.LP2, "SlotPlusOne"},
  80. {ModuleName.LP3, "SlotPlusOne"},
  81. {ModuleName.LP4, "SlotPlusOne"},
  82. {ModuleName.LP5, "SlotPlusOne"},
  83. {ModuleName.LP6, "SlotPlusOne"},
  84. {ModuleName.LP7, "SlotPlusOne"},
  85. {ModuleName.LP8, "SlotPlusOne"},
  86. {ModuleName.LP9, "SlotPlusOne"},
  87. {ModuleName.LP10, "SlotPlusOne"},
  88. {ModuleName.Buffer, "SlotPlusOne"},
  89. {ModuleName.Aligner, "00"},
  90. {ModuleName.Robot, "00"},
  91. {ModuleName.PM1, "00"},
  92. {ModuleName.PM2, "00"},
  93. {ModuleName.PM3, "00"},
  94. {ModuleName.PM4, "00"},
  95. {ModuleName.PM5, "00"},
  96. {ModuleName.PM6, "00"},
  97. {ModuleName.PM7, "00"},
  98. {ModuleName.PM8, "00"},
  99. {ModuleName.Spin1L, "00"},
  100. {ModuleName.Spin1H, "00"},
  101. {ModuleName.Spin2L, "00"},
  102. {ModuleName.Spin2H, "00"},
  103. {ModuleName.Spin3L, "00"},
  104. {ModuleName.Spin3H, "00"},
  105. {ModuleName.Spin4L, "00"},
  106. {ModuleName.Spin4H, "00"},
  107. {ModuleName.LL1, "00"},
  108. {ModuleName.LL2, "00"},
  109. {ModuleName.LL3, "00"},
  110. {ModuleName.LL4, "00"},
  111. {ModuleName.LL5, "00"},
  112. {ModuleName.LL6, "00"},
  113. {ModuleName.LL7, "00"},
  114. {ModuleName.LL8, "00"},
  115. {ModuleName.LLA, "00"},
  116. {ModuleName.LLB, "00"},
  117. {ModuleName.LLC, "00"},
  118. {ModuleName.LLD, "00"},
  119. {ModuleName.TurnOverStation, "00"},
  120. };
  121. public static string chamberSlot2Slot(ModuleName chamber, int slot)
  122. {
  123. if (!Slot2Slot.ContainsKey(chamber))
  124. {
  125. LOG.Error($"not define slot2slot config {chamber}");
  126. return "";
  127. }
  128. string sslot = Slot2Slot[chamber];
  129. if (sslot == "SlotPlusOne")
  130. {
  131. sslot = string.Format("{0:D2}", slot + 1);
  132. }
  133. return sslot;
  134. }
  135. public static string hand2string(Hand hand)
  136. {
  137. string st = "";
  138. if (SC.ContainsItem("Robot.BladeUpDownReverse") && SC.GetValue<bool>("Robot.BladeUpDownReverse"))
  139. {
  140. switch (hand)
  141. {
  142. case Hand.Blade1:
  143. st = "A"; //单手臂 下
  144. break;
  145. case Hand.Blade2:
  146. st = "B"; //4手臂 上
  147. break;
  148. case Hand.Both:
  149. st = "W";
  150. break;
  151. }
  152. }
  153. else
  154. {
  155. switch (hand)
  156. {
  157. case Hand.Blade1:
  158. st = "B"; //单手臂 下
  159. break;
  160. case Hand.Blade2:
  161. st = "A"; //4手臂 上
  162. break;
  163. case Hand.Both:
  164. st = "W";
  165. break;
  166. }
  167. }
  168. return st;
  169. }
  170. public static string NextMotion2String(Motion motion,Hand hand)
  171. {
  172. string st = "";
  173. switch (motion)
  174. {
  175. case Motion.Pick:
  176. st = string.Format("G{0}", hand2string(hand));
  177. break;
  178. case Motion.Place:
  179. st = string.Format("P{0}", hand2string(hand));
  180. break;
  181. case Motion.Exchange:
  182. st = string.Format("E{0}", hand2string(hand));
  183. break;
  184. default:
  185. st = "AL";
  186. break;
  187. }
  188. return st;
  189. }
  190. public static string Offset2String(int offset)
  191. {
  192. string st = "";
  193. if (offset >= 0)
  194. {
  195. st = string.Format("{0:D5}", offset);
  196. }
  197. else
  198. {
  199. st = string.Format("{0:D4}", offset);
  200. }
  201. return st;
  202. }
  203. public static int WaferSize2Int(WaferSize size)
  204. {
  205. int ret = 0;
  206. switch (size)
  207. {
  208. case WaferSize.WS3:
  209. ret = 625000; //
  210. break;
  211. case WaferSize.WS4:
  212. ret = 750000; //
  213. break;
  214. case WaferSize.WS6:
  215. ret = 1000000; //
  216. break;
  217. }
  218. return ret;
  219. }
  220. public static int MappingOffset2Int(WaferSize size)
  221. {
  222. int ret = 0;
  223. switch (size)
  224. {
  225. case WaferSize.WS3:
  226. ret = 2357000; //
  227. break;
  228. case WaferSize.WS4:
  229. ret = 2452000; //
  230. break;
  231. case WaferSize.WS6:
  232. ret = 2732000; //
  233. break;
  234. }
  235. return ret;
  236. }
  237. }
  238. }