123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257 |
- using System;
- using System.Collections.Generic;
- using Aitex.Core.RT.Event;
- using Aitex.Core.RT.SCCore;
- using Aitex.Core.Util;
- using MECF.Framework.Common.Equipment;
- namespace EFEM.RT.Modules
- {
- public class RobotOffsetConfig : Singleton<RobotOffsetConfig>
- {
- public enum MotionName
- {
- GET,
- PUT,
- EXCHANGE
- }
- private string[] scOffsetsLoadLock = new string[]
- {
- "Robot.OffsetForLL.LLAGET",
- "Robot.OffsetForLL.LLAPUT",
- "Robot.OffsetForLL.LLAEXCHANGE",
- "Robot.OffsetForLL.LLBGET",
- "Robot.OffsetForLL.LLBPUT",
- "Robot.OffsetForLL.LLBEXCHANGE",
- "Robot.OffsetForLL.LL1GET",
- "Robot.OffsetForLL.LL1PUT",
- "Robot.OffsetForLL.LL1EXCHANGE",
- "Robot.OffsetForLL.LL2GET",
- "Robot.OffsetForLL.LL2PUT",
- "Robot.OffsetForLL.LL2EXCHANGE",
- "Robot.OffsetForLL.LL3GET",
- "Robot.OffsetForLL.LL3PUT",
- "Robot.OffsetForLL.LL3EXCHANGE",
- "Robot.OffsetForLL.LL4GET",
- "Robot.OffsetForLL.LL4PUT",
- "Robot.OffsetForLL.LL4EXCHANGE",
- "Robot.OffsetForLL.LL5GET",
- "Robot.OffsetForLL.LL5PUT",
- "Robot.OffsetForLL.LL5EXCHANGE",
- "Robot.OffsetForLL.LL6GET",
- "Robot.OffsetForLL.LL6PUT",
- "Robot.OffsetForLL.LL6EXCHANGE",
- "Robot.OffsetForLL.LL7GET",
- "Robot.OffsetForLL.LL7PUT",
- "Robot.OffsetForLL.LL7EXCHANGE",
- "Robot.OffsetForLL.LL8GET",
- "Robot.OffsetForLL.LL8PUT",
- "Robot.OffsetForLL.LL8EXCHANGE",
- };
-
- private string[] scOffsets = new string[]
- {
- "Robot.OffsetForLP.Type1",
- "Robot.OffsetForLP.Type2",
- "Robot.OffsetForLP.Type3",
- "Robot.OffsetForLP.Type4",
- "Robot.OffsetForLP.Type5",
- "Robot.OffsetForLP.Type6",
- "Robot.OffsetForLP.Type7",
- "Robot.OffsetForLP.Type8",
- "Robot.OffsetForLP.Type9",
- "Robot.OffsetForLP.Type10",
- "Robot.OffsetForLP.Type11",
- "Robot.OffsetForLP.Type12",
- "Robot.OffsetForLP.Type13",
- "Robot.OffsetForLP.Type14",
- "Robot.OffsetForLP.Type15",
- "Robot.OffsetForLP.Type16",
- "Robot.OffsetForLP.Type17",
- "Robot.OffsetForLP.Type18",
- "Robot.OffsetForLP.Type19",
- "Robot.OffsetForLP.Type20"
- };
- private Dictionary<string, Tuple<int, int, int>> _offsetsForLoadLock = new Dictionary<string, Tuple<int, int, int>>();
- private Dictionary<string, Tuple<int, int, int>> _offsetsForLoadPort = new Dictionary<string, Tuple<int, int, int>>();
- /// <summary>
- /// Get offset for different cassette type
- /// </summary>
- /// <param name="chamber">Load Port Name</param>
- /// <param name="x">Reference for x</param>
- /// <param name="y">Reference for y</param>
- /// <param name="z">Reference for z</param>
- /// <param name="reason">out reason</param>
- /// <returns>return whether success or not</returns>
- public bool GetOffset(ModuleName chamber, ref int x, ref int y, ref int z, out string reason)
- {
- x = 0;
- y = 0;
- z = 0;
- reason = "";
- if (!ModuleHelper.IsLoadPort(chamber))
- return true;
- string scNameType = $"LoadPort.{chamber.ToString().Replace("LP", "LoadPort")}CassetteType";
-
- if (!SC.ContainsItem(scNameType))
- {
- reason = $"Not found {chamber} foup type system config item";
- return false;
- }
- string type = SC.GetStringValue(scNameType);
- if (string.IsNullOrEmpty(type.Trim()))
- {
- reason = $"{chamber} foup type system config can not be empty";
- return false;
- }
- UpdateOffsetConfigForLoadPort();
- if (!_offsetsForLoadPort.ContainsKey(type))
- {
- reason = $"did not find {chamber} {type} type robot offset config";
- return false;
- }
- x = _offsetsForLoadPort[type].Item1;
- y = _offsetsForLoadPort[type].Item2;
- z = _offsetsForLoadPort[type].Item3;
- return true;
- }
-
- /// <summary>
- /// Get offset for get/put/exchange motion on Load Lock
- /// </summary>
- /// <param name="chamber">LLA/LLB</param>
- /// <param name="ePutOrGet">MotionName</param>
- /// <param name="x">Reference for x</param>
- /// <param name="y">Reference for y</param>
- /// <param name="z">Reference for z</param>
- /// <param name="reason">out reason</param>
- /// <returns>return whether success or not</returns>
- public bool GetOffset(ModuleName chamber,MotionName ePutOrGet, ref int x, ref int y, ref int z, out string reason)
- {
- x = 0;
- y = 0;
- z = 0;
- reason = "";
-
- string scNameType = $"Robot.OffsetForLL.{chamber.ToString()}{ePutOrGet.ToString()}";
-
- if (!SC.ContainsItem(scNameType))
- {
- reason = $"Not found {chamber} foup type system config item";
- return false;
- }
- string type = SC.GetStringValue(scNameType);
- if (string.IsNullOrEmpty(type.Trim()))
- {
- reason = $"{chamber} foup type system config can not be empty";
- return false;
- }
- UpdateOffsetConfigForLoadLock();
- if (!_offsetsForLoadLock.ContainsKey(scNameType))
- {
- reason = $"did not find {chamber} {type} type robot offset config";
- return false;
- }
- x = _offsetsForLoadLock[scNameType].Item1;
- y = _offsetsForLoadLock[scNameType].Item2;
- z = _offsetsForLoadLock[scNameType].Item3;
- return true;
- }
- private void UpdateOffsetConfigForLoadPort()
- {
- _offsetsForLoadPort.Clear();
-
- //有配置错误的SC,这里忽略。
- foreach (var sc in scOffsets)
- {
- string[] config = SC.ContainsItem(sc) ? SC.GetStringValue(sc).Split(',') : null;
- if (config == null || config.Length != 4)
- {
- continue;
- }
- if (string.IsNullOrEmpty(config[0]))
- continue;
- int x = 0;
- int y = 0;
- int z = 0;
- if (!int.TryParse(config[1].Trim(), out x))
- continue;
- if (!int.TryParse(config[2].Trim(), out y))
- continue;
- if (!int.TryParse(config[3].Trim(), out z))
- continue;
- if (x < SC.GetValue<int>("Robot.Offset.OffsetXMin")
- || x > SC.GetValue<int>("Robot.Offset.OffsetXMax")
- || y < SC.GetValue<int>("Robot.Offset.OffsetYMin")
- || y > SC.GetValue<int>("Robot.Offset.OffsetYMax")
- || z < SC.GetValue<int>("Robot.Offset.OffsetZMin")
- || z > SC.GetValue<int>("Robot.Offset.OffsetZMax"))
- {
- EV.PostWarningLog(ModuleNameString.System, $"Robot offset config {sc} value out of range");
- continue;
- }
- _offsetsForLoadPort[config[0]] = Tuple.Create(x, y, z);
- }
- }
-
- private void UpdateOffsetConfigForLoadLock()
- {
- _offsetsForLoadLock.Clear();
- var i = 0;
- //有配置错误的SC,这里忽略。
- foreach (var sc in scOffsetsLoadLock)
- {
- string[] config = SC.ContainsItem(sc) ? SC.GetStringValue(sc).Split(',') : null;
- if (config == null || config.Length != 3)
- {
- continue;
- }
- int x = 0;
- int y = 0;
- int z = 0;
- if (!int.TryParse(config[0].Trim(), out x))
- continue;
- if (!int.TryParse(config[1].Trim(), out y))
- continue;
- if (!int.TryParse(config[2].Trim(), out z))
- continue;
- if (x < SC.GetValue<int>("Robot.Offset.OffsetXMin")
- || x > SC.GetValue<int>("Robot.Offset.OffsetXMax")
- || y < SC.GetValue<int>("Robot.Offset.OffsetYMin")
- || y > SC.GetValue<int>("Robot.Offset.OffsetYMax")
- || z < SC.GetValue<int>("Robot.Offset.OffsetZMin")
- || z > SC.GetValue<int>("Robot.Offset.OffsetZMax"))
- {
- EV.PostWarningLog(ModuleNameString.System, $"Robot offset config {sc} value out of range");
- continue;
- }
- _offsetsForLoadLock[scOffsetsLoadLock[i]] = Tuple.Create(x, y, z);
- i++;
- }
- }
- }
- }
|