RobotOffsetConfig.cs 9.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257
  1. using System;
  2. using System.Collections.Generic;
  3. using Aitex.Core.RT.Event;
  4. using Aitex.Core.RT.SCCore;
  5. using Aitex.Core.Util;
  6. using MECF.Framework.Common.Equipment;
  7. namespace EFEM.RT.Modules
  8. {
  9. public class RobotOffsetConfig : Singleton<RobotOffsetConfig>
  10. {
  11. public enum MotionName
  12. {
  13. GET,
  14. PUT,
  15. EXCHANGE
  16. }
  17. private string[] scOffsetsLoadLock = new string[]
  18. {
  19. "Robot.OffsetForLL.LLAGET",
  20. "Robot.OffsetForLL.LLAPUT",
  21. "Robot.OffsetForLL.LLAEXCHANGE",
  22. "Robot.OffsetForLL.LLBGET",
  23. "Robot.OffsetForLL.LLBPUT",
  24. "Robot.OffsetForLL.LLBEXCHANGE",
  25. "Robot.OffsetForLL.LL1GET",
  26. "Robot.OffsetForLL.LL1PUT",
  27. "Robot.OffsetForLL.LL1EXCHANGE",
  28. "Robot.OffsetForLL.LL2GET",
  29. "Robot.OffsetForLL.LL2PUT",
  30. "Robot.OffsetForLL.LL2EXCHANGE",
  31. "Robot.OffsetForLL.LL3GET",
  32. "Robot.OffsetForLL.LL3PUT",
  33. "Robot.OffsetForLL.LL3EXCHANGE",
  34. "Robot.OffsetForLL.LL4GET",
  35. "Robot.OffsetForLL.LL4PUT",
  36. "Robot.OffsetForLL.LL4EXCHANGE",
  37. "Robot.OffsetForLL.LL5GET",
  38. "Robot.OffsetForLL.LL5PUT",
  39. "Robot.OffsetForLL.LL5EXCHANGE",
  40. "Robot.OffsetForLL.LL6GET",
  41. "Robot.OffsetForLL.LL6PUT",
  42. "Robot.OffsetForLL.LL6EXCHANGE",
  43. "Robot.OffsetForLL.LL7GET",
  44. "Robot.OffsetForLL.LL7PUT",
  45. "Robot.OffsetForLL.LL7EXCHANGE",
  46. "Robot.OffsetForLL.LL8GET",
  47. "Robot.OffsetForLL.LL8PUT",
  48. "Robot.OffsetForLL.LL8EXCHANGE",
  49. };
  50. private string[] scOffsets = new string[]
  51. {
  52. "Robot.OffsetForLP.Type1",
  53. "Robot.OffsetForLP.Type2",
  54. "Robot.OffsetForLP.Type3",
  55. "Robot.OffsetForLP.Type4",
  56. "Robot.OffsetForLP.Type5",
  57. "Robot.OffsetForLP.Type6",
  58. "Robot.OffsetForLP.Type7",
  59. "Robot.OffsetForLP.Type8",
  60. "Robot.OffsetForLP.Type9",
  61. "Robot.OffsetForLP.Type10",
  62. "Robot.OffsetForLP.Type11",
  63. "Robot.OffsetForLP.Type12",
  64. "Robot.OffsetForLP.Type13",
  65. "Robot.OffsetForLP.Type14",
  66. "Robot.OffsetForLP.Type15",
  67. "Robot.OffsetForLP.Type16",
  68. "Robot.OffsetForLP.Type17",
  69. "Robot.OffsetForLP.Type18",
  70. "Robot.OffsetForLP.Type19",
  71. "Robot.OffsetForLP.Type20"
  72. };
  73. private Dictionary<string, Tuple<int, int, int>> _offsetsForLoadLock = new Dictionary<string, Tuple<int, int, int>>();
  74. private Dictionary<string, Tuple<int, int, int>> _offsetsForLoadPort = new Dictionary<string, Tuple<int, int, int>>();
  75. /// <summary>
  76. /// Get offset for different cassette type
  77. /// </summary>
  78. /// <param name="chamber">Load Port Name</param>
  79. /// <param name="x">Reference for x</param>
  80. /// <param name="y">Reference for y</param>
  81. /// <param name="z">Reference for z</param>
  82. /// <param name="reason">out reason</param>
  83. /// <returns>return whether success or not</returns>
  84. public bool GetOffset(ModuleName chamber, ref int x, ref int y, ref int z, out string reason)
  85. {
  86. x = 0;
  87. y = 0;
  88. z = 0;
  89. reason = "";
  90. if (!ModuleHelper.IsLoadPort(chamber))
  91. return true;
  92. string scNameType = $"LoadPort.{chamber.ToString().Replace("LP", "LoadPort")}CassetteType";
  93. if (!SC.ContainsItem(scNameType))
  94. {
  95. reason = $"Not found {chamber} foup type system config item";
  96. return false;
  97. }
  98. string type = SC.GetStringValue(scNameType);
  99. if (string.IsNullOrEmpty(type.Trim()))
  100. {
  101. reason = $"{chamber} foup type system config can not be empty";
  102. return false;
  103. }
  104. UpdateOffsetConfigForLoadPort();
  105. if (!_offsetsForLoadPort.ContainsKey(type))
  106. {
  107. reason = $"did not find {chamber} {type} type robot offset config";
  108. return false;
  109. }
  110. x = _offsetsForLoadPort[type].Item1;
  111. y = _offsetsForLoadPort[type].Item2;
  112. z = _offsetsForLoadPort[type].Item3;
  113. return true;
  114. }
  115. /// <summary>
  116. /// Get offset for get/put/exchange motion on Load Lock
  117. /// </summary>
  118. /// <param name="chamber">LLA/LLB</param>
  119. /// <param name="ePutOrGet">MotionName</param>
  120. /// <param name="x">Reference for x</param>
  121. /// <param name="y">Reference for y</param>
  122. /// <param name="z">Reference for z</param>
  123. /// <param name="reason">out reason</param>
  124. /// <returns>return whether success or not</returns>
  125. public bool GetOffset(ModuleName chamber,MotionName ePutOrGet, ref int x, ref int y, ref int z, out string reason)
  126. {
  127. x = 0;
  128. y = 0;
  129. z = 0;
  130. reason = "";
  131. string scNameType = $"Robot.OffsetForLL.{chamber.ToString()}{ePutOrGet.ToString()}";
  132. if (!SC.ContainsItem(scNameType))
  133. {
  134. reason = $"Not found {chamber} foup type system config item";
  135. return false;
  136. }
  137. string type = SC.GetStringValue(scNameType);
  138. if (string.IsNullOrEmpty(type.Trim()))
  139. {
  140. reason = $"{chamber} foup type system config can not be empty";
  141. return false;
  142. }
  143. UpdateOffsetConfigForLoadLock();
  144. if (!_offsetsForLoadLock.ContainsKey(scNameType))
  145. {
  146. reason = $"did not find {chamber} {type} type robot offset config";
  147. return false;
  148. }
  149. x = _offsetsForLoadLock[scNameType].Item1;
  150. y = _offsetsForLoadLock[scNameType].Item2;
  151. z = _offsetsForLoadLock[scNameType].Item3;
  152. return true;
  153. }
  154. private void UpdateOffsetConfigForLoadPort()
  155. {
  156. _offsetsForLoadPort.Clear();
  157. //有配置错误的SC,这里忽略。
  158. foreach (var sc in scOffsets)
  159. {
  160. string[] config = SC.ContainsItem(sc) ? SC.GetStringValue(sc).Split(',') : null;
  161. if (config == null || config.Length != 4)
  162. {
  163. continue;
  164. }
  165. if (string.IsNullOrEmpty(config[0]))
  166. continue;
  167. int x = 0;
  168. int y = 0;
  169. int z = 0;
  170. if (!int.TryParse(config[1].Trim(), out x))
  171. continue;
  172. if (!int.TryParse(config[2].Trim(), out y))
  173. continue;
  174. if (!int.TryParse(config[3].Trim(), out z))
  175. continue;
  176. if (x < SC.GetValue<int>("Robot.Offset.OffsetXMin")
  177. || x > SC.GetValue<int>("Robot.Offset.OffsetXMax")
  178. || y < SC.GetValue<int>("Robot.Offset.OffsetYMin")
  179. || y > SC.GetValue<int>("Robot.Offset.OffsetYMax")
  180. || z < SC.GetValue<int>("Robot.Offset.OffsetZMin")
  181. || z > SC.GetValue<int>("Robot.Offset.OffsetZMax"))
  182. {
  183. EV.PostWarningLog(ModuleNameString.System, $"Robot offset config {sc} value out of range");
  184. continue;
  185. }
  186. _offsetsForLoadPort[config[0]] = Tuple.Create(x, y, z);
  187. }
  188. }
  189. private void UpdateOffsetConfigForLoadLock()
  190. {
  191. _offsetsForLoadLock.Clear();
  192. var i = 0;
  193. //有配置错误的SC,这里忽略。
  194. foreach (var sc in scOffsetsLoadLock)
  195. {
  196. string[] config = SC.ContainsItem(sc) ? SC.GetStringValue(sc).Split(',') : null;
  197. if (config == null || config.Length != 3)
  198. {
  199. continue;
  200. }
  201. int x = 0;
  202. int y = 0;
  203. int z = 0;
  204. if (!int.TryParse(config[0].Trim(), out x))
  205. continue;
  206. if (!int.TryParse(config[1].Trim(), out y))
  207. continue;
  208. if (!int.TryParse(config[2].Trim(), out z))
  209. continue;
  210. if (x < SC.GetValue<int>("Robot.Offset.OffsetXMin")
  211. || x > SC.GetValue<int>("Robot.Offset.OffsetXMax")
  212. || y < SC.GetValue<int>("Robot.Offset.OffsetYMin")
  213. || y > SC.GetValue<int>("Robot.Offset.OffsetYMax")
  214. || z < SC.GetValue<int>("Robot.Offset.OffsetZMin")
  215. || z > SC.GetValue<int>("Robot.Offset.OffsetZMax"))
  216. {
  217. EV.PostWarningLog(ModuleNameString.System, $"Robot offset config {sc} value out of range");
  218. continue;
  219. }
  220. _offsetsForLoadLock[scOffsetsLoadLock[i]] = Tuple.Create(x, y, z);
  221. i++;
  222. }
  223. }
  224. }
  225. }