浏览代码

fix centerCharge逻辑提交

jiangjy 1 周之前
父节点
当前提交
534e915868
共有 1 个文件被更改,包括 132 次插入14 次删除
  1. 132 14
      Furnace/FurnaceRT/Equipments/Jobs/AutoTransfer.cs

+ 132 - 14
Furnace/FurnaceRT/Equipments/Jobs/AutoTransfer.cs

@@ -48,6 +48,7 @@ using MECF.Framework.Common.Tolerance;
 using MECF.Framework.Common.CommonData.SorterDefines;
 using MECF.Framework.Common.Extens;
 using MECF.Framework.RT.EquipmentLibrary.HardwareUnits.LoadPorts.TDK;
+using System.Windows.Ink;
 
 namespace FurnaceRT.Equipments.Jobs
 {
@@ -4666,7 +4667,27 @@ namespace FurnaceRT.Equipments.Jobs
             return slots;
         }
         #region charge rule
+        public static int[] InsertIntoMiddleRight(int[] A, int B)
+        {
+            if (A == null)
+            {
+                return new int[] { B }; // 处理A为null的情况
+            }
+
+            int lengthA = A.Length;
+            // 计算中间偏右位置:(长度 + 1) / 2(整数除法)
+            int middleRight = (lengthA + 1) / 2;
+            int[] newArray = new int[lengthA + 1]; // 新数组长度+1
 
+            // 复制左侧元素(0到middleRight-1)
+            Array.Copy(A, 0, newArray, 0, middleRight);
+            // 插入B到中间偏右位置
+            newArray[middleRight] = B;
+            // 复制右侧元素(从A的middleRight位置开始,复制到新数组的middleRight+1位置)
+            Array.Copy(A, middleRight, newArray, middleRight + 1, lengthA - middleRight);
+
+            return newArray;
+        }
         private bool CheckChargeRule(ProcessJobInfo pj, out bool waferShort, bool needCheckPWafer, bool needCheckMWafer, out string reason)
         {
             waferShort = false;
@@ -4703,6 +4724,14 @@ namespace FurnaceRT.Equipments.Jobs
             bool isFileDumy = false;
             if (layoutRecipeDataConfig.FillDummyTransfer.ToLower() == "exist" && layoutRecipeDataConfig.ProductZeroNotFill.ToLower() == "exist" && layoutRecipeDataConfig.ProductTransferPosition.ToLower() == "none")
             {
+                var layoutSlotDic = new Dictionary<int, string>();
+                var layoutSlotList = new List<string>();
+                for (int i = 0; i < layoutRecipeDataExpert.Items.Count; i++)
+                {
+                    layoutSlotDic.Add(i, layoutRecipeDataExpert.Items[i]);
+
+                }
+
                 var pjPWaferCount = GetCurrentWaferNum(pj, WaferType.P, out bool pSlotSelectA);
                 if (pjPWaferCount == 0)
                 {
@@ -4729,29 +4758,119 @@ namespace FurnaceRT.Equipments.Jobs
                                 $"supplement P wafer {needPAndCurrect}, surplusDumyCount={surplusDumyCount},Not enough dummy ";
                             return false;
                         }
-
                         isFileDumy = true;
-                        for (int i = 0; i < layoutRecipeDataExpert.Items.Count; i++)
+                        List<string> chargeRuleStr = new List<string>() { "Center", "Upper", "Lower" };
+                        if (string.IsNullOrEmpty(layoutRecipeDataConfig.WaferSupplement) || !chargeRuleStr.Contains(layoutRecipeDataConfig.WaferSupplement))
                         {
-                            if (layoutRecipeDataExpert.Items[i].ToLower() == WaferType.P.ToDescription())
+                            for (int i = 0; i < layoutRecipeDataExpert.Items.Count; i++)
                             {
-                                if (needPAndCurrect == 0)
-                                    continue;
+                                if (layoutRecipeDataExpert.Items[i].ToLower() == WaferType.P.ToDescription())
+                                {
+                                    if (needPAndCurrect == 0)
+                                        continue;
+
+                                    if (currentEDWaferNum > 0)
+                                    {
+                                        layoutRecipeDataExpert.Items[i] = WaferType.ED.ToDescription().ToUpper();
+                                        currentEDWaferNum--;
+                                        needPAndCurrect--;
+                                    }
+                                    if (currentSDWaferNum > 0 && layoutRecipeDataExpert.Items[i].ToLower() == WaferType.P.ToDescription())
+                                    {
+                                        layoutRecipeDataExpert.Items[i] = WaferType.SD.ToString();
+                                        currentSDWaferNum--;
+                                        needPAndCurrect--;
+                                    }
+                                }
+                            }
+                        }
+                        else
+                        {
+
+                            if (layoutRecipeDataConfig.WaferSupplement == "Center")
+                            {
+
+                                var pdWaferSlot = layoutSlotDic.Where(a => a.Value.ToLower() == WaferType.P.ToDescription()).Select(a => a.Key).ToList();
+                                var startReplacePWafer = (pdWaferSlot.Count - pjPWaferCount) / 2;
+                                var noReplacePSlot = pdWaferSlot.GetRange(startReplacePWafer, pjPWaferCount);
+
+                                for (int i = 0; i < layoutRecipeDataExpert.Items.Count; i++)
+                                {
+                                    if (layoutRecipeDataExpert.Items[i].ToLower() == WaferType.P.ToDescription())
+                                    {
+                                        if (needPAndCurrect == 0 || noReplacePSlot.Contains(i))
+                                            continue;
 
-                                if (currentEDWaferNum > 0)
+                                        if (currentEDWaferNum > 0)
+                                        {
+                                            layoutRecipeDataExpert.Items[i] = WaferType.ED.ToDescription().ToUpper();
+                                            currentEDWaferNum--;
+                                            needPAndCurrect--;
+                                        }
+                                        if (currentSDWaferNum > 0 && layoutRecipeDataExpert.Items[i].ToLower() == WaferType.P.ToDescription())
+                                        {
+                                            layoutRecipeDataExpert.Items[i] = WaferType.SD.ToString();
+                                            currentSDWaferNum--;
+                                            needPAndCurrect--;
+                                        }
+                                    }
+                                }
+                            }
+                            else if (layoutRecipeDataConfig.WaferSupplement == "Upper")
+                            {
+                                layoutSlotDic = layoutSlotDic.Reverse().ToDictionary(a => a.Key, a => a.Value);
+
+                                foreach (var item in layoutSlotDic)
                                 {
-                                    layoutRecipeDataExpert.Items[i] = WaferType.ED.ToDescription().ToUpper();
-                                    currentEDWaferNum--;
-                                    needPAndCurrect--;
+                                    if (layoutRecipeDataExpert.Items[item.Key].ToLower() == WaferType.P.ToDescription())
+                                    {
+                                        if (needPAndCurrect == 0)
+                                            continue;
+
+                                        if (currentEDWaferNum > 0)
+                                        {
+                                            layoutRecipeDataExpert.Items[item.Key] = WaferType.ED.ToDescription().ToUpper();
+                                            currentEDWaferNum--;
+                                            needPAndCurrect--;
+                                        }
+                                        if (currentSDWaferNum > 0 && layoutRecipeDataExpert.Items[item.Key].ToLower() == WaferType.P.ToDescription())
+                                        {
+                                            layoutRecipeDataExpert.Items[item.Key] = WaferType.SD.ToString();
+                                            currentSDWaferNum--;
+                                            needPAndCurrect--;
+                                        }
+                                    }
                                 }
-                                if (currentSDWaferNum > 0 && layoutRecipeDataExpert.Items[i].ToLower() == WaferType.P.ToDescription())
+
+                            }
+                            else if (layoutRecipeDataConfig.WaferSupplement == "Lower")
+                            {
+                                for (int i = 0; i < layoutRecipeDataExpert.Items.Count; i++)
                                 {
-                                    layoutRecipeDataExpert.Items[i] = WaferType.SD.ToString();
-                                    currentSDWaferNum--;
-                                    needPAndCurrect--;
+                                    if (layoutRecipeDataExpert.Items[i].ToLower() == WaferType.P.ToDescription())
+                                    {
+                                        if (needPAndCurrect == 0)
+                                            continue;
+
+                                        if (currentEDWaferNum > 0)
+                                        {
+                                            layoutRecipeDataExpert.Items[i] = WaferType.ED.ToDescription().ToUpper();
+                                            currentEDWaferNum--;
+                                            needPAndCurrect--;
+                                        }
+                                        if (currentSDWaferNum > 0 && layoutRecipeDataExpert.Items[i].ToLower() == WaferType.P.ToDescription())
+                                        {
+                                            layoutRecipeDataExpert.Items[i] = WaferType.SD.ToString();
+                                            currentSDWaferNum--;
+                                            needPAndCurrect--;
+                                        }
+                                    }
                                 }
                             }
+
                         }
+
+
                     }
                     else
                     {
@@ -4769,7 +4888,6 @@ namespace FurnaceRT.Equipments.Jobs
                 sideDummySlots = GetWaferSlots(layoutRecipeDataExpert, WaferType.SD);
                 extraDummySlots = GetWaferSlots(layoutRecipeDataExpert, WaferType.ED);
 
-
             }