123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520 |
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- using Aitex.Core.Common;
- using Aitex.Core.RT.Device;
- using Aitex.Core.RT.SCCore;
- using Aitex.Sorter.Common;
- using MECF.Framework.Common.Equipment;
- using MECF.Framework.Common.SubstrateTrackings;
- using MECF.Framework.RT.EquipmentLibrary.HardwareUnits.LoadPorts;
- namespace Aitex.Sorter.RT.Module.Recipe
- {
- public class RecipeParserByPort1ToN
- {
- public List<TransferInfo> Parse(SorterRecipeXml xmlRecipe, out string reason)
- {
- List<TransferInfo> result = new List<TransferInfo>();
- reason = string.Empty;
- List<WaferInfo[]> wafersInSourceList = new List<WaferInfo[]>();
- List<WaferInfo[]> wafersInDestinationList = new List<WaferInfo[]>();
- List<ModuleName> destinationModules = new List<ModuleName>();
- bool isLoad = false;
- for (int i = 0; i < xmlRecipe.Source.Count; i++)
- {
- LoadPort lp = DEVICE.GetDevice<LoadPort>(xmlRecipe.Source[i].ToString());
- if (lp.IsEnableTransferWafer(out reason))
- {
- isLoad = true;
- WaferInfo[] wafersInSource = WaferManager.Instance.GetWafers(xmlRecipe.Source[i]);
- wafersInSourceList.Add(wafersInSource);
- }
- }
- if (!isLoad)
- {
- if (string.IsNullOrEmpty(reason))
- reason = "Source is not valid for transfer.";
- return result;
- }
- reason = string.Empty;
- isLoad = false;
- for (int i = 0; i < xmlRecipe.Destination.Count; i++)
- {
- LoadPort lp = DEVICE.GetDevice<LoadPort>(xmlRecipe.Destination[i].ToString());
- if (lp.IsEnableTransferWafer(out reason))
- {
- isLoad = true;
- if (!lp.IsEnableTransferWafer())
- continue;
- destinationModules.Add(xmlRecipe.Destination[i]);
- WaferInfo[] wafersInDestination = WaferManager.Instance.GetWafers(xmlRecipe.Destination[i]);
- wafersInDestinationList.Add(wafersInDestination);
- }
- }
- if (!isLoad)
- {
- if (string.IsNullOrEmpty(reason))
- reason = "Destination is not valid for transfer..";
- return result;
- }
- if (wafersInSourceList.Count == 0 || wafersInDestinationList.Count == 0)
- {
- reason = "Recipe has no vaild transfer task.";
- return result;
- }
- switch (xmlRecipe.PlaceModeTransfer1To1)
- {
- case SorterRecipePlaceModeTransfer1To1.FromBottom:
- FromBottom(xmlRecipe, wafersInSourceList, wafersInDestinationList, destinationModules, ref result, out reason);
- break;
- case SorterRecipePlaceModeTransfer1To1.FromTop:
- FromTop(xmlRecipe, wafersInSourceList, wafersInDestinationList, destinationModules, ref result, out reason);
- break;
- case SorterRecipePlaceModeTransfer1To1.SameSlot:
- SameSlot(xmlRecipe, wafersInSourceList, wafersInDestinationList, destinationModules, ref result, out reason);
- break;
- default:
- reason = string.Format("recipe PlaceModeTransfer1To1 {0} not valid", xmlRecipe.PlaceModeTransfer1To1);
- return result;
- }
- //if (result.Count == 0)
- // reason = "Recipe has no vaild transfer task.";
- return result;
- }
- /// <summary>
- /// 从source最下面开始取wafer,顺序放在destination的最下面
- /// </summary>
- /// <param name="lst"></param>
- /// <param name="reason"></param>
- /// <returns></returns>
- bool FromBottom(SorterRecipeXml xmlRecipe, List<WaferInfo[]> sourceList, List<WaferInfo[]> destinationList, List<ModuleName> destinationModules, ref List<TransferInfo> lst, out string reason)
- {
- reason = string.Empty;
- SCConfigItem _scLP2Pitch = SC.GetConfigItem("LoadPort.LoadPort2Pitch");
- if (_scLP2Pitch == null || _scLP2Pitch.IntValue == 10)
- {
- int destinationIndex = -1;
- for (int i = 0; i < sourceList.Count * sourceList[0].Length; i++)
- {
- WaferInfo[] source = sourceList[i / sourceList[0].Length];
- if (source[i % sourceList[0].Length].IsEmpty)
- continue;
- int to = destinationIndex;
- for (int j = destinationIndex + 1; j < destinationList.Count * destinationList[0].Length; j++)
- {
- WaferInfo[] destination = destinationList[j / destinationList[0].Length];
- if (destination[j % destinationList[0].Length].IsEmpty)
- {
- to = j;
- break;
- }
- }
- if (to == destinationIndex)
- break;
- destinationIndex = to;
- lst.Add(new TransferInfo()
- {
- Source = (ModuleName)source[i % sourceList[0].Length].Station,
- SourceSlot = source[i % sourceList[0].Length].Slot,
- Angle = xmlRecipe.AlignAngle,
- Option = (xmlRecipe.IsAlign ? MoveOption.Align : MoveOption.None)
- | (xmlRecipe.IsReadLaserMarker ? MoveOption.ReadID : MoveOption.None)
- | (xmlRecipe.IsReadT7Code ? MoveOption.ReadID2 : MoveOption.None) | (xmlRecipe.WaferReaderIndex == 1 ? MoveOption.Reader1 : MoveOption.None)
- | (xmlRecipe.WaferReaderIndex == 2 ? MoveOption.Reader2 : MoveOption.None)
- | (xmlRecipe.IsTurnOver ? MoveOption.Turnover : MoveOption.None),
- Slot = to % destinationList[0].Length,
- Station = destinationModules[to / destinationList[0].Length],
- WaferID = source[i % sourceList[0].Length].WaferID,
- }); ;
- }
- }
- else
- {
- if (sourceList.Count > 1 || destinationList.Count > 1)
- {
- reason = "Multiple Sources and Destinations are not supported in SameSlot mode";
- return false;
- }
- int destinationIndex = -1;
- SCConfigItem _scEnable = SC.GetConfigItem("LoadPort.EnableSlot1OnLP2");
- bool isContinue = false;
- for (int i = 0; i < sourceList[0].Length; i++)
- {
- WaferInfo[] source = sourceList[0];
- if (isContinue && source[i].IsEmpty)
- isContinue = false;
- if (source[i].IsEmpty)
- {
- continue;
- }
- if (!_scEnable.BoolValue && i == 0)
- {
- isContinue = true;
- continue;
- }
- if (isContinue)
- continue;
- int to = destinationIndex;
- for (int j = destinationIndex + 1; j < destinationList.Count * destinationList[0].Length; j++)
- {
- WaferInfo[] destination = destinationList[j / destinationList[0].Length];
- if (destination[j % destinationList[0].Length].IsEmpty)
- {
- to = j;
- break;
- }
- }
- if (to == destinationIndex)
- break;
- destinationIndex = to;
- lst.Add(new TransferInfo()
- {
- Source = (ModuleName)source[i % sourceList[0].Length].Station,
- SourceSlot = source[i % sourceList[0].Length].Slot,
- Angle = xmlRecipe.AlignAngle,
- Option = (xmlRecipe.IsAlign ? MoveOption.Align : MoveOption.None)
- | (xmlRecipe.IsReadLaserMarker ? MoveOption.ReadID : MoveOption.None)
- | (xmlRecipe.IsReadT7Code ? MoveOption.ReadID2 : MoveOption.None)
- | (xmlRecipe.WaferReaderIndex == 1 ? MoveOption.Reader1 : MoveOption.None)
- | (xmlRecipe.WaferReaderIndex == 2 ? MoveOption.Reader2 : MoveOption.None)
- | (xmlRecipe.IsTurnOver ? MoveOption.Turnover : MoveOption.None),
- Slot = to % destinationList[0].Length,
- Station = destinationModules[to / destinationList[0].Length],
- WaferID = source[i % sourceList[0].Length].WaferID,
- });
- }
- }
- return true;
- }
- /// <summary>
- /// 放在同一位置,如果有冲突,直接忽略
- /// </summary>
- /// <param name="lst"></param>
- /// <param name="reason"></param>
- /// <returns></returns>
- bool SameSlot(SorterRecipeXml xmlRecipe, List<WaferInfo[]> sourceList, List<WaferInfo[]> destinationList, List<ModuleName> destinationModules, ref List<TransferInfo> lst, out string reason)
- {
- reason = string.Empty;
- if (sourceList.Count > 1 || destinationList.Count > 1)
- {
- reason = "Multiple Sources and Destinations are not supported in SameSlot mode";
- return false;
- }
- WaferInfo[] source = sourceList[0];
- WaferInfo[] destination = destinationList[0];
- //int destinationIndex = -1;
- SCConfigItem _scLP2Pitch = SC.GetConfigItem("LoadPort.LoadPort2Pitch");
- if (_scLP2Pitch == null || _scLP2Pitch.IntValue == 10)
- {
- for (int i = 0; i < source.Length && i < destination.Length; i++)
- {
- if (source[i].IsEmpty || (!destination[i].IsEmpty && !(source[i].Station == destination[i].Station
- && source[i].Slot == destination[i].Slot)))
- continue;
- lst.Add(new TransferInfo()
- {
- Source = (ModuleName)source[i].Station,
- SourceSlot = source[i].Slot,
- Angle = xmlRecipe.AlignAngle,
- Option = (xmlRecipe.IsAlign ? MoveOption.Align : MoveOption.None)
- | (xmlRecipe.IsReadLaserMarker ? MoveOption.ReadID : MoveOption.None)
- | (xmlRecipe.IsReadT7Code ? MoveOption.ReadID2 : MoveOption.None) | (xmlRecipe.WaferReaderIndex == 1 ? MoveOption.Reader1 : MoveOption.None)
- | (xmlRecipe.WaferReaderIndex == 2 ? MoveOption.Reader2 : MoveOption.None)
- | (xmlRecipe.IsTurnOver ? MoveOption.Turnover : MoveOption.None),
- Slot = i,
- Station = destinationModules[0],
- WaferID = source[i].WaferID,
- });
- }
- }
- else if (_scLP2Pitch.IntValue == 7 && xmlRecipe.Destination[0] == ModuleName.LP2)
- {
- SCConfigItem _scEnable = SC.GetConfigItem("LoadPort.EnableSlot1OnLP2");
- for (int i = source.Length - 1; i >= 0; i--)
- {
- if (source[i].IsEmpty || !destination[i].IsEmpty || (!_scEnable.BoolValue && i == 0) || (i > 0 && !destination[i - 1].IsEmpty))
- continue;
- lst.Add(new TransferInfo()
- {
- Source = (ModuleName)source[i].Station,
- SourceSlot = source[i].Slot,
- Angle = xmlRecipe.AlignAngle,
- Option = (xmlRecipe.IsAlign ? MoveOption.Align : MoveOption.None)
- | (xmlRecipe.IsReadLaserMarker ? MoveOption.ReadID : MoveOption.None)
- | (xmlRecipe.IsReadT7Code ? MoveOption.ReadID2 : MoveOption.None)
- | (xmlRecipe.WaferReaderIndex == 1 ? MoveOption.Reader1 : MoveOption.None)
- | (xmlRecipe.WaferReaderIndex == 2 ? MoveOption.Reader2 : MoveOption.None)
- | (xmlRecipe.IsTurnOver ? MoveOption.Turnover : MoveOption.None),
- Slot = i,
- Station = destinationModules[0],
- WaferID = source[i].WaferID,
- });
- }
- }
- else if ((_scLP2Pitch.IntValue == 7 && xmlRecipe.Source[0] == ModuleName.LP2))
- {
- SCConfigItem _scEnable = SC.GetConfigItem("LoadPort.EnableSlot1OnLP2");
- bool isContinue = false;
- for (int i = 0; i < source.Length && i < destination.Length; i++)
- {
- if (isContinue && source[i].IsEmpty)
- isContinue = false;
- if (source[i].IsEmpty || !destination[i].IsEmpty)
- continue;
- if (!_scEnable.BoolValue && i == 0 || (i > 0 && !destination[i - 1].IsEmpty))
- {
- isContinue = true;
- continue;
- }
- if (isContinue)
- continue;
- lst.Add(new TransferInfo()
- {
- Source = (ModuleName)source[i].Station,
- SourceSlot = source[i].Slot,
- Angle = xmlRecipe.AlignAngle,
- Option = (xmlRecipe.IsAlign ? MoveOption.Align : MoveOption.None)
- | (xmlRecipe.IsReadLaserMarker ? MoveOption.ReadID : MoveOption.None)
- | (xmlRecipe.IsReadT7Code ? MoveOption.ReadID2 : MoveOption.None)
- | (xmlRecipe.WaferReaderIndex == 1 ? MoveOption.Reader1 : MoveOption.None)
- | (xmlRecipe.WaferReaderIndex == 2 ? MoveOption.Reader2 : MoveOption.None)
- | (xmlRecipe.IsTurnOver ? MoveOption.Turnover : MoveOption.None),
- Slot = i,
- Station = destinationModules[0],
- WaferID = source[i].WaferID,
- });
- }
- }
- return true;
- }
- /// <summary>
- /// 从source最上面开始取wafer,顺序放在destination的最上面
- /// </summary>
- /// <param name="lst"></param>
- /// <param name="reason"></param>
- /// <returns></returns>
- bool FromTop(SorterRecipeXml xmlRecipe, List<WaferInfo[]> sourceList, List<WaferInfo[]> destinationList, List<ModuleName> destinationModules, ref List<TransferInfo> lst, out string reason)
- {
- reason = string.Empty;
- SCConfigItem _scLP2Pitch = SC.GetConfigItem("LoadPort.LoadPort2Pitch");
- if (_scLP2Pitch == null || _scLP2Pitch.IntValue == 10)
- {
- int destinationIndex = destinationList.Count * destinationList[0].Length;
- for (int i = 0; i < sourceList.Count * sourceList[0].Length; i++)
- {
- WaferInfo[] source = sourceList[sourceList.Count - i / sourceList[0].Length - 1];
- if (source[i % sourceList[0].Length].IsEmpty)
- continue;
- if (SC.ContainsItem("Process.EnableSlot25OnLP2") && (!SC.GetValue<bool>("Process.EnableSlot25OnLP2")) && destinationModules[0] == ModuleName.LP2 && destinationIndex == 25)
- destinationIndex = 24;
- int to = destinationIndex;
- for (int j = destinationIndex - 1; j >= 0; j--)
- {
- WaferInfo[] destination = destinationList[destinationList.Count - j / destinationList[0].Length - 1];
- if (destination[j % destinationList[0].Length].IsEmpty)
- {
- to = j;
- break;
- }
- }
- if (to == destinationIndex)
- break;
- destinationIndex = to;
- lst.Add(new TransferInfo()
- {
- Source = (ModuleName)source[i % sourceList[0].Length].Station,
- SourceSlot = source[i % sourceList[0].Length].Slot,
- Angle = xmlRecipe.AlignAngle,
- Option = (xmlRecipe.IsAlign ? MoveOption.Align : MoveOption.None)
- | (xmlRecipe.IsReadLaserMarker ? MoveOption.ReadID : MoveOption.None)
- | (xmlRecipe.IsReadT7Code ? MoveOption.ReadID2 : MoveOption.None) | (xmlRecipe.WaferReaderIndex == 1 ? MoveOption.Reader1 : MoveOption.None)
- | (xmlRecipe.WaferReaderIndex == 2 ? MoveOption.Reader2 : MoveOption.None)
- | (xmlRecipe.IsTurnOver ? MoveOption.Turnover : MoveOption.None),
- Slot = to % destinationList[0].Length,
- Station = destinationModules[destinationList.Count - to / destinationList[0].Length - 1],
- WaferID = source[i % sourceList[0].Length].WaferID,
- });
- }
- }
- else
- {
- if (sourceList.Count > 1 || destinationList.Count > 1)
- {
- reason = "Multiple Sources and Destinations are not supported in SameSlot mode";
- return false;
- }
- SCConfigItem _scEnable = SC.GetConfigItem("LoadPort.EnableSlot1OnLP2");
- if (xmlRecipe.Source[0] == ModuleName.LP2) //Source为LP2
- {
- bool isContinue = false;
- int destinationIndex = destinationList[0].Length;
-
- for (int i = 0; i < sourceList[0].Length; i++)
- {
- WaferInfo[] source = sourceList[0];
- if (isContinue && source[i].IsEmpty)
- isContinue = false;
- if (source[i].IsEmpty)
- continue;
- if (!_scEnable.BoolValue && i == 0)
- {
- isContinue = true;
- continue;
- }
- if (isContinue)
- continue;
- int to = destinationIndex;
- for (int j = destinationIndex - 1; j >= 0; j--)
- {
- WaferInfo[] destination = destinationList[0];
- if (destination[j].IsEmpty)
- {
- to = j;
- break;
- }
- }
- if (to == destinationIndex)
- break;
- destinationIndex = to;
- lst.Add(new TransferInfo()
- {
- Source = (ModuleName)source[i].Station,
- SourceSlot = source[i].Slot,
- Angle = xmlRecipe.AlignAngle,
- Option = (xmlRecipe.IsAlign ? MoveOption.Align : MoveOption.None)
- | (xmlRecipe.IsReadLaserMarker ? MoveOption.ReadID : MoveOption.None)
- | (xmlRecipe.IsReadT7Code ? MoveOption.ReadID2 : MoveOption.None)
- | (xmlRecipe.WaferReaderIndex == 1 ? MoveOption.Reader1 : MoveOption.None)
- | (xmlRecipe.WaferReaderIndex == 2 ? MoveOption.Reader2 : MoveOption.None)
- | (xmlRecipe.IsTurnOver ? MoveOption.Turnover : MoveOption.None),
- Slot = to,
- Station = destinationModules[0],
- WaferID = source[i].WaferID,
- });
- }
- }
- else //Station为LP2
- {
- int destinationIndex = destinationList[0].Length;
- if (SC.ContainsItem("Process.EnableSlot25OnLP2") && (!SC.GetValue<bool>("Process.EnableSlot25OnLP2"))&& destinationIndex == 25)
- destinationIndex = 24;
- for (int i = sourceList[0].Length - 1; i >= 0; i--)
- {
- WaferInfo[] source = sourceList[0];
- if (source[i].IsEmpty)
- continue;
- int to = destinationIndex;
- for (int j = destinationIndex - 1; j >= 0; j--)
- {
- WaferInfo[] destination = destinationList[0];
- if (j == 0)
- {
- if (_scEnable.BoolValue)
- {
- if (destination[j].IsEmpty)
- {
- to = j;
- break;
- }
- }
- }
- else
- {
- if (destination[j - 1].IsEmpty && destination[j].IsEmpty)
- {
- to = j;
- break;
- }
- }
- }
- if (to == destinationIndex)
- break;
- destinationIndex = to;
- lst.Add(new TransferInfo()
- {
- Angle = xmlRecipe.AlignAngle,
- Option = (xmlRecipe.IsAlign ? MoveOption.Align : MoveOption.None)
- | (xmlRecipe.IsReadLaserMarker ? MoveOption.ReadID : MoveOption.None)
- | (xmlRecipe.IsReadT7Code ? MoveOption.ReadID2 : MoveOption.None)
- | (xmlRecipe.WaferReaderIndex == 1 ? MoveOption.Reader1 : MoveOption.None)
- | (xmlRecipe.WaferReaderIndex == 2 ? MoveOption.Reader2 : MoveOption.None)
- | (xmlRecipe.IsTurnOver ? MoveOption.Turnover : MoveOption.None),
- Slot = to,
- Station = destinationModules[0],
- WaferID = source[i].WaferID,
- });
- }
- }
- }
- return true;
- }
- }
- }
|