Utils.cs 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using Aitex.Sorter.Common;
  6. using MECF.Framework.Common.Equipment;
  7. using Aitex.Core.RT.SCCore;
  8. using Aitex.Core.RT.Log;
  9. namespace Aitex.Sorter.RT.Device.Robot.SR100
  10. {
  11. public class RobotConvertor
  12. {
  13. public static Dictionary<ModuleName, string> TeachStation = new Dictionary<ModuleName, string>()
  14. {
  15. {ModuleName.LP1, "C01"},
  16. {ModuleName.LP2, "C02"},
  17. {ModuleName.LP3, "C03"},
  18. {ModuleName.LP4, "C04"},
  19. {ModuleName.LP5, "C05"},
  20. {ModuleName.LP6, "C06"},
  21. {ModuleName.LP7, "C07"},
  22. {ModuleName.LP8, "C08"},
  23. {ModuleName.Aligner, "P01"},
  24. {ModuleName.Buffer, "C05"},
  25. {ModuleName.TurnOverStation, "S01"},
  26. {ModuleName.PM1, "S01"},
  27. {ModuleName.PM2, "S02"},
  28. {ModuleName.PM3, "S03"},
  29. {ModuleName.PM4, "S04"},
  30. {ModuleName.PM5, "S05"},
  31. {ModuleName.PM6, "S06"},
  32. {ModuleName.PM7, "S07"},
  33. {ModuleName.PM8, "S08"},
  34. {ModuleName.Spin1L, "S01"},
  35. {ModuleName.Spin1H, "S02"},
  36. {ModuleName.Spin2L, "S03"},
  37. {ModuleName.Spin2H, "S04"},
  38. {ModuleName.Spin3L, "S05"},
  39. {ModuleName.Spin3H, "S06"},
  40. {ModuleName.Spin4L, "S07"},
  41. {ModuleName.Spin4H, "S08"},
  42. {ModuleName.LL1, "S01"},
  43. {ModuleName.LL2, "S02"},
  44. {ModuleName.LL3, "S03"},
  45. {ModuleName.LL4, "S04"},
  46. };
  47. public static string chamber2staion(ModuleName chamber)
  48. {
  49. if (!TeachStation.ContainsKey(chamber))
  50. {
  51. LOG.Error($"not define teach position {chamber}");
  52. return "";
  53. }
  54. string ret = TeachStation[chamber];
  55. if (chamber == ModuleName.Aligner && SC.ContainsItem("Aligner.AlignerStation"))
  56. return SC.GetStringValue("Aligner.AlignerStation");
  57. if (SC.ContainsItem($"CarrierInfo.{chamber}CarrierIndex"))
  58. {
  59. int idex = SC.GetValue<int>($"CarrierInfo.{chamber}CarrierIndex");
  60. if (SC.ContainsItem($"CarrierInfo.{chamber}Station{idex}"))
  61. {
  62. ret = SC.GetStringValue($"CarrierInfo.{chamber}Station{idex}");
  63. }
  64. }
  65. return ret;
  66. }
  67. public static string chamberSlot2Slot(ModuleName chamber, int slot)
  68. {
  69. string sslot = "";
  70. switch (chamber)
  71. {
  72. case ModuleName.LP1:
  73. case ModuleName.LP2:
  74. case ModuleName.LP3:
  75. case ModuleName.LP4:
  76. case ModuleName.LP5:
  77. case ModuleName.LP6:
  78. case ModuleName.LP7:
  79. case ModuleName.LP8:
  80. case ModuleName.LP10:
  81. case ModuleName.Buffer:
  82. sslot = string.Format("{0:D2}", slot + 1);
  83. break;
  84. case ModuleName.Aligner:
  85. case ModuleName.Robot:
  86. case ModuleName.LL1:
  87. case ModuleName.LL2:
  88. case ModuleName.LL3:
  89. case ModuleName.LL4:
  90. case ModuleName.LLA:
  91. case ModuleName.LLB:
  92. case ModuleName.LLC:
  93. case ModuleName.LLD:
  94. case ModuleName.TurnOverStation:
  95. sslot = "00";
  96. break;
  97. }
  98. return sslot;
  99. }
  100. public static string hand2string(Hand hand)
  101. {
  102. string st = "";
  103. switch (hand)
  104. {
  105. case Hand.Blade1:
  106. st = "1";
  107. break;
  108. case Hand.Blade2:
  109. st = "2";
  110. break;
  111. case Hand.Both:
  112. st = "F";
  113. break;
  114. }
  115. return st;
  116. }
  117. public static string IsPick2Position(bool isPick)
  118. {
  119. var pos = isPick ? "P1" : "G1";
  120. return pos;
  121. }
  122. public static string Offset2String(int offset)
  123. {
  124. string st = "";
  125. if (offset >= 0)
  126. {
  127. st = string.Format("{0:D8}", offset);
  128. }
  129. else
  130. {
  131. st = string.Format("{0:D7}", offset);
  132. }
  133. return st;
  134. }
  135. }
  136. }