Utils.cs 6.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using Aitex.Core.RT.Log;
  6. using Aitex.Core.RT.SCCore;
  7. using Aitex.Sorter.Common;
  8. using MECF.Framework.Common.Equipment;
  9. namespace MECF.Framework.RT.EquipmentLibrary.HardwareUnits.Robot.SR100
  10. {
  11. public class ProtocolTag
  12. {
  13. public const string tag_end = "\r";
  14. public const string tag_cmd_start = "$";
  15. public const string cmd_token = ",";
  16. public const string resp_tag_normal = "$";
  17. public const string resp_tag_error = "?";
  18. public const string resp_tag_excute = "!";
  19. public const string resp_tag_event = ">";
  20. public const string resp_evt_error = "100";
  21. }
  22. public class RobotConvertor
  23. {
  24. public static Dictionary<ModuleName, string> TeachStation = new Dictionary<ModuleName, string>()
  25. {
  26. {ModuleName.LP1, "C01"},
  27. {ModuleName.LP2, "C02"},
  28. {ModuleName.LP3, "C03"},
  29. {ModuleName.LP4, "C04"},
  30. {ModuleName.LP5, "C05"},
  31. {ModuleName.LP6, "C06"},
  32. {ModuleName.LP7, "C07"},
  33. {ModuleName.LP8, "C08"},
  34. {ModuleName.Aligner, "P01"},
  35. {ModuleName.Buffer, "C05"},
  36. {ModuleName.TurnOverStation, "S01"},
  37. {ModuleName.PM1, "S01"},
  38. {ModuleName.PM2, "S02"},
  39. {ModuleName.PM3, "S03"},
  40. {ModuleName.PM4, "S04"},
  41. {ModuleName.PM5, "S05"},
  42. {ModuleName.PM6, "S06"},
  43. {ModuleName.PM7, "S07"},
  44. {ModuleName.PM8, "S08"},
  45. {ModuleName.Spin1L, "S01"},
  46. {ModuleName.Spin1H, "S02"},
  47. {ModuleName.Spin2L, "S03"},
  48. {ModuleName.Spin2H, "S04"},
  49. {ModuleName.Spin3L, "S05"},
  50. {ModuleName.Spin3H, "S06"},
  51. {ModuleName.Spin4L, "S07"},
  52. {ModuleName.Spin4H, "S08"},
  53. {ModuleName.LL1, "S01"},
  54. {ModuleName.LL2, "S02"},
  55. {ModuleName.LL3, "S03"},
  56. {ModuleName.LL4, "S04"},
  57. };
  58. public static string chamber2staion(ModuleName chamber)
  59. {
  60. if (!TeachStation.ContainsKey(chamber))
  61. {
  62. LOG.Error($"not define teach position {chamber}");
  63. return "";
  64. }
  65. string ret =TeachStation[chamber];
  66. if(chamber == ModuleName.Aligner && SC.ContainsItem("Aligner.AlignerStation"))
  67. return SC.GetStringValue("Aligner.AlignerStation");
  68. if (SC.ContainsItem($"CarrierInfo.{chamber}CarrierIndex"))
  69. {
  70. int idex = SC.GetValue<int>($"CarrierInfo.{chamber}CarrierIndex");
  71. if(SC.ContainsItem($"CarrierInfo.{chamber}Station{idex}"))
  72. {
  73. ret = SC.GetStringValue($"CarrierInfo.{chamber}Station{idex}");
  74. }
  75. }
  76. return ret;
  77. }
  78. public static Dictionary<ModuleName, string> Slot2Slot = new Dictionary<ModuleName, string>()
  79. {
  80. {ModuleName.LP1, "SlotPlusOne"},
  81. {ModuleName.LP2, "SlotPlusOne"},
  82. {ModuleName.LP3, "SlotPlusOne"},
  83. {ModuleName.LP4, "SlotPlusOne"},
  84. {ModuleName.LP5, "SlotPlusOne"},
  85. {ModuleName.LP6, "SlotPlusOne"},
  86. {ModuleName.LP7, "SlotPlusOne"},
  87. {ModuleName.LP8, "SlotPlusOne"},
  88. {ModuleName.LP9, "SlotPlusOne"},
  89. {ModuleName.LP10, "SlotPlusOne"},
  90. {ModuleName.Buffer, "SlotPlusOne"},
  91. {ModuleName.Aligner, "00"},
  92. {ModuleName.Robot, "00"},
  93. {ModuleName.PM1, "00"},
  94. {ModuleName.PM2, "00"},
  95. {ModuleName.PM3, "00"},
  96. {ModuleName.PM4, "00"},
  97. {ModuleName.PM5, "00"},
  98. {ModuleName.PM6, "00"},
  99. {ModuleName.PM7, "00"},
  100. {ModuleName.PM8, "00"},
  101. {ModuleName.Spin1L, "00"},
  102. {ModuleName.Spin1H, "00"},
  103. {ModuleName.Spin2L, "00"},
  104. {ModuleName.Spin2H, "00"},
  105. {ModuleName.Spin3L, "00"},
  106. {ModuleName.Spin3H, "00"},
  107. {ModuleName.Spin4L, "00"},
  108. {ModuleName.Spin4H, "00"},
  109. {ModuleName.LL1, "00"},
  110. {ModuleName.LL2, "00"},
  111. {ModuleName.LL3, "00"},
  112. {ModuleName.LL4, "00"},
  113. {ModuleName.LL5, "00"},
  114. {ModuleName.LL6, "00"},
  115. {ModuleName.LL7, "00"},
  116. {ModuleName.LL8, "00"},
  117. {ModuleName.LLA, "00"},
  118. {ModuleName.LLB, "00"},
  119. {ModuleName.LLC, "00"},
  120. {ModuleName.LLD, "00"},
  121. {ModuleName.TurnOverStation, "00"},
  122. };
  123. public static string chamberSlot2Slot(ModuleName chamber, int slot)
  124. {
  125. if (!Slot2Slot.ContainsKey(chamber))
  126. {
  127. LOG.Error($"not define slot2slot config {chamber}");
  128. return "";
  129. }
  130. string sslot = Slot2Slot[chamber];
  131. if(sslot == "SlotPlusOne")
  132. {
  133. sslot = string.Format("{0:D2}", slot + 1);
  134. }
  135. return sslot;
  136. }
  137. public static string hand2string(Hand hand)
  138. {
  139. string st = "";
  140. switch (hand)
  141. {
  142. case Hand.Blade1:
  143. st = "1";
  144. break;
  145. case Hand.Blade2:
  146. st = "2";
  147. break;
  148. case Hand.Both:
  149. st = "F";
  150. break;
  151. }
  152. return st;
  153. }
  154. public static string AxisToStr(Axis axis)
  155. {
  156. string st = "";
  157. switch (axis)
  158. {
  159. case Axis.S:
  160. st = "S";
  161. break;
  162. case Axis.A:
  163. st = "A";
  164. break;
  165. case Axis.H:
  166. st = "H";
  167. break;
  168. case Axis.I:
  169. st = "I";
  170. break;
  171. case Axis.Z:
  172. st = "Z";
  173. break;
  174. default:
  175. break;
  176. }
  177. return st;
  178. }
  179. public static string IsPick2Position(bool isPick)
  180. {
  181. var pos = isPick ? "P1" : "G1";
  182. return pos;
  183. }
  184. public static string Offset2String(int offset)
  185. {
  186. string st = "";
  187. if (offset >= 0)
  188. {
  189. st = string.Format("{0:D8}", offset);
  190. }
  191. else
  192. {
  193. st = string.Format("{0:D7}", offset);
  194. }
  195. return st;
  196. }
  197. }
  198. }