瀏覽代碼

Duplicated wafer functions.

sangwq 11 月之前
父節點
當前提交
52349cad2b

+ 17 - 0
Venus/Framework/Common/SubstrateTrackings/WaferInfo.cs

@@ -58,6 +58,19 @@ namespace Aitex.Core.Common
 			get { return Status == WaferStatus.Empty; }
 		}
 
+		private bool _isDuplicated;
+		[DataMember]
+		public bool IsDuplicated
+        {
+			get { return _isDuplicated; }
+			set
+            {
+				_isDuplicated = value;
+				InvokePropertyChanged("WaferID");
+
+			}
+        }
+
 		private string waferID;
 		[DataMember]
 		public string WaferID
@@ -297,6 +310,7 @@ namespace Aitex.Core.Common
         public WaferInfo()
 		{
 			InnerId = Guid.Empty;
+			_isDuplicated = false;
 		}
 
 		public WaferInfo(string waferID, WaferStatus status = WaferStatus.Empty) : this()
@@ -318,6 +332,7 @@ namespace Aitex.Core.Common
 			ChuckState = source.ChuckState;
 			IsSource = source.IsSource;
 			IsDestination = source.IsDestination;
+			IsDuplicated = source.IsDuplicated;
 
 			Station = source.Station;
 			Slot = source.Slot;
@@ -357,6 +372,7 @@ namespace Aitex.Core.Common
 	        this.IsSource = false;
 
 	        this.IsDestination = false;
+			this.IsDuplicated = false;
             
 	        this.Station = 0;
 	        this.Slot = 0;
@@ -401,6 +417,7 @@ namespace Aitex.Core.Common
 			newValue.ChuckState = source.ChuckState;
 			newValue.IsSource = source.IsSource;
 			newValue.IsDestination = source.IsDestination;
+			newValue.IsDuplicated = source.IsDuplicated;
 
 			newValue.Station = source.Station;
 			newValue.Slot = source.Slot;

+ 123 - 10
Venus/Framework/Common/SubstrateTrackings/WaferManager.cs

@@ -1,7 +1,7 @@
 using System;
 using System.Collections.Generic;
 using System.Linq;
-using System.Windows.Forms;
+using System.Threading.Tasks;
 using Aitex.Core.Common;
 using Aitex.Core.RT.DataCenter;
 using Aitex.Core.RT.Event;
@@ -11,9 +11,28 @@ using Aitex.Core.Util;
 using MECF.Framework.Common.DBCore;
 using MECF.Framework.Common.Equipment;
 using MECF.Framework.Common.Utilities;
+using MECF.Framework.Common.Schedulers;
 
 namespace MECF.Framework.Common.SubstrateTrackings
 {
+    struct DulicatedWaferInfo
+    {
+        public Guid        waferId;
+        public ModuleName  source;
+        public int         sourceSlot;
+        public ModuleName  destination;
+        public int         destSlot;
+
+        public DulicatedWaferInfo(Guid id, ModuleName Source, int SrcSlot, ModuleName Destination, int DestSlot)
+        {
+            waferId     = id;
+            source      = Source;
+            sourceSlot  = SrcSlot;
+            destination = Destination;
+            destSlot    = DestSlot;
+        }
+    }
+
     public class WaferManager : Singleton<WaferManager>
     {
          Dictionary<string, WaferInfo> _dict = new Dictionary<string, WaferInfo>();
@@ -21,27 +40,33 @@ namespace MECF.Framework.Common.SubstrateTrackings
         object _lockerWaferList = new object();
 
         Dictionary<ModuleName, Dictionary<int, WaferInfo>> _locationWafers = new Dictionary<ModuleName, Dictionary<int, WaferInfo>>();
+        List<DulicatedWaferInfo> _duplicatedWafers = new List<DulicatedWaferInfo>();
 
         private const string EventWaferLeft = "WAFER_LEFT_POSITION";
         private const string EventWaferArrive = "WAFER_ARRIVE_POSITION";
 
+        public bool HasDuplicatedWafer => _duplicatedWafers.Count > 0;
+
         public WaferManager()
         {
         }
 
-        public void Serialize()
+        public async void Serialize()
         {
-            try
+            await Task.Run(() =>
             {
-                if (_locationWafers != null)
+                try
+                {
+                    if (_locationWafers != null)
+                    {
+                        BinarySerializer<Dictionary<ModuleName, Dictionary<int, WaferInfo>>>.ToStream(_locationWafers, "WaferManager");
+                    }
+                }
+                catch (Exception ex)
                 {
-                    BinarySerializer<Dictionary<ModuleName, Dictionary<int, WaferInfo>>>.ToStream(_locationWafers, "WaferManager");
+                    LOG.WriteExeption(ex);
                 }
-            }
-            catch (Exception ex)
-            {
-                LOG.WriteExeption(ex);
-            }
+            });
         }
 
         public void Deserialize()
@@ -442,6 +467,87 @@ namespace MECF.Framework.Common.SubstrateTrackings
             return _locationWafers[module][slot];
         }
 
+        public void CreateDuplicatedWafer(ModuleName source, int sourceSlot, ModuleName destination, int destSlot)
+        {
+            if (!IsWaferSlotLocationValid(source, sourceSlot))
+            {
+                LOG.Write(eEvent.ERR_WAFER_MANAGER_FAILED, ModuleName.System, string.Format("Invalid wafer source position for CreateDuplicatedWafer(), invalid parameter, {0},{1}", source, source + 1));
+                return;
+            }
+
+            if (!IsWaferSlotLocationValid(destination, destSlot))
+            {
+                LOG.Write(eEvent.ERR_WAFER_MANAGER_FAILED, ModuleName.System, string.Format("Invalid wafer destination position for CreateDuplicatedWafer(), invalid parameter, {0},{1}", destination, destSlot + 1));
+                return;
+            }
+
+            if (_locationWafers[source][sourceSlot].IsEmpty)
+            {
+                LOG.Write(eEvent.ERR_WAFER_MANAGER_FAILED, ModuleName.System, string.Format("CreateDuplicatedWafer() failed, no wafer at source, {0}{1}=>{2}{3}", source, sourceSlot + 1, destination, destSlot + 1));
+                return;
+            }
+
+            if (!_locationWafers[destination][destSlot].IsEmpty)
+            {
+                LOG.Write(eEvent.ERR_WAFER_MANAGER_FAILED, ModuleName.System, string.Format("CreateDuplicatedWafer() failed, destination has wafer, {0}{1}=>{2}{3}", source, sourceSlot + 1, destination, destSlot + 1));
+                return;
+            }
+
+            string waferOrigin = _locationWafers[source][sourceSlot].WaferOrigin;
+            _locationWafers[source][sourceSlot].IsDuplicated = true;
+
+            WaferInfo wafer = CopyWaferInfo(source, sourceSlot, _locationWafers[destination][destSlot]);
+            _duplicatedWafers.Add(new DulicatedWaferInfo(wafer.InnerId, source, sourceSlot, destination, destSlot));
+
+            LOG.Write(eEvent.EV_WAFER_DUPLICATED, ModuleName.System, waferOrigin, source.ToString(), (source + 1).ToString(), destination.ToString(), (destSlot + 1).ToString());
+
+            Serialize();
+        }
+
+        private void deleteDuplicatedWafer(ModuleName module, int slot)
+        {
+            var id = _locationWafers[module][slot].InnerId;
+            var infoIndex = _duplicatedWafers.FindIndex(info => info.waferId == id && ((info.source == module && info.sourceSlot == slot) || (info.destination == module && info.destSlot == slot)));
+            if(infoIndex == -1)
+            {
+                LOG.Write(eEvent.ERR_WAFER_MANAGER_FAILED, ModuleName.System, string.Format("Delete Duplicated Wafer failed, {0},{1}", module, slot + 1));
+                return;
+            }
+
+            var duplicatgedInfo = _duplicatedWafers[infoIndex];
+            var peerModule = duplicatgedInfo.source == module ? duplicatgedInfo.destination : duplicatgedInfo.source;
+            var peerSlot = duplicatgedInfo.source == module ? duplicatgedInfo.destSlot : duplicatgedInfo.sourceSlot;
+            if(_locationWafers[peerModule][peerSlot].IsEmpty ||!_locationWafers[peerModule][peerSlot].IsDuplicated)
+            {
+                LOG.Write(eEvent.ERR_WAFER_MANAGER_FAILED, ModuleName.System, string.Format("Delete Duplicated Wafer failed, the opponent wafer at {0},{1} is not a duplicated wafer", peerModule, peerSlot + 1));
+                return;
+            }
+
+            _locationWafers[module][slot].SetEmpty();
+            _locationWafers[peerModule][peerSlot].IsDuplicated = false;
+            _duplicatedWafers.RemoveAt(infoIndex);
+        }
+
+        public bool CheckDuplicatedWafersBeforeMove(Queue<MoveItem> moveItems)
+        {
+            foreach(var item in moveItems)
+            {
+                if(_locationWafers[item.SourceModule][item.SourceSlot].IsEmpty)
+                {
+                    LOG.Write(eEvent.ERR_WAFER_MANAGER_FAILED, ModuleName.System, string.Format("Cannot move wafer as no wafer at position:{0},{1}", item.SourceModule, item.SourceSlot + 1));
+                    return false;
+                }
+
+                if (_locationWafers[item.SourceModule][item.SourceSlot].IsDuplicated)
+                {
+                    LOG.Write(eEvent.ERR_WAFER_MANAGER_FAILED, ModuleName.System, string.Format("Cannot move wafer as the wafer at position:{0},{1} is a duplicated wafer", item.SourceModule, item.SourceSlot + 1));
+                    return false;
+                }
+            }
+
+            return true;
+        }
+
         public void DeleteWafer(ModuleName module, int slotFrom, int count = 1)
         {
             lock (_lockerWaferList)
@@ -454,6 +560,13 @@ namespace MECF.Framework.Common.SubstrateTrackings
                         LOG.Write(eEvent.ERR_WAFER_MANAGER_FAILED, ModuleName.System, string.Format("Invalid wafer delete, invalid parameter, {0},{1}", module, slot + 1));
                         continue;
                     }
+
+                    if(_locationWafers[module][slot].IsDuplicated)
+                    {
+                        deleteDuplicatedWafer(module, slotFrom);
+                        return;
+                    }
+
                     WaferDataRecorder.DeleteWafer(_locationWafers[module][slot].InnerId.ToString());
 
                     _locationWafers[module][slot].SetEmpty();

+ 1 - 0
Venus/Venus_Core/EventDefine.cs

@@ -39,6 +39,7 @@ namespace Aitex.Core.RT.Log{
 		EV_SCHEDULER = 38,
 		WARN_SCHEDULER = 39,
 		EXCEP_FSM = 40,
+		EV_WAFER_DUPLICATED = 41,
 		INFO_DEVICE_IO_HEATER = 1000,
 		WARN_DEVICE_IO_HEATER = 1001,
 		ERR_DEVICE_IO_HEATER = 1002,

+ 9 - 0
Venus/Venus_RT/Config/LogDefine.json

@@ -342,6 +342,15 @@
     "Note": "FSM Exception"
   },
   {
+    "Id": 41,
+    "Level": "Info",
+    "LogEnum": "EV_WAFER_DUPLICATED",
+    "GlobalDescription_zh": "Create duplicated wafer {0} at source: {1} {2} destination: {3} {4}",
+    "GlobalDescription_en": "Create duplicated wafer {0} at source: {1} {2} destination: {3} {4}",
+    "Module": "System",
+    "Note": "Wafer Moved"
+  },
+  {
     "Id": 1000,
     "Level": "Info",
     "LogEnum": "INFO_DEVICE_IO_HEATER",

+ 3 - 0
Venus/Venus_RT/Modules/EFEM/EfemPickRoutine.cs

@@ -48,6 +48,9 @@ namespace Venus_RT.Modules.EFEM
 
             _bDoublePick = false;
             var pickItem = (Queue<MoveItem>)objs[0];
+            if (!WaferManager.Instance.CheckDuplicatedWafersBeforeMove(pickItem))
+                return RState.Failed;
+
             _targetModule = pickItem.Peek().SourceModule;
             _targetSlot = pickItem.Peek().SourceSlot;
             _hand = pickItem.Peek().RobotHand;

+ 3 - 0
Venus/Venus_RT/Modules/EFEM/EfemPlaceRoutine.cs

@@ -50,6 +50,9 @@ namespace Venus_RT.Modules.EFEM
 
             _bDoublePlace = false;
             var placeItem = (Queue<MoveItem>)objs[0];
+            if (!WaferManager.Instance.CheckDuplicatedWafersBeforeMove(placeItem))
+                return RState.Failed;
+
             _targetModule = placeItem.Peek().DestinationModule;
             _targetSlot = placeItem.Peek().DestinationSlot;
             _hand = placeItem.Peek().RobotHand;

+ 3 - 0
Venus/Venus_RT/Modules/EFEM/EfemSwapRoutine.cs

@@ -66,6 +66,9 @@ namespace Venus_RT.Modules.EFEM
                 _actionList.Enqueue(new MoveItem(item.SourceModule, item.SourceSlot, item.DestinationModule, item.DestinationSlot, item.RobotHand));
             }
 
+            if (!WaferManager.Instance.CheckDuplicatedWafersBeforeMove(_actionList))
+                return RState.Failed;
+
             var firtItem = _actionList.Peek();
             if (ModuleHelper.IsLoadLock(firtItem.SourceModule))
                 _targetModule = firtItem.SourceModule;

+ 6 - 0
Venus/Venus_RT/Modules/SystemDispatcher.cs

@@ -798,6 +798,12 @@ namespace Venus_RT.Modules
 
         public RState Start(params object[] objs)
         {
+            if(WaferManager.Instance.HasDuplicatedWafer)
+            {
+                LOG.Write(eEvent.ERR_ROUTER, ModuleName.System, "System has dummy wafers, please verify all the wafer position, and delete the invalid wafer");
+                return RState.Failed;
+            }
+
             _efemRobotSingleArmOption   = SC.GetValue<int>("EFEM.SingleArmOption");
             _tmRobotSingleArmOption     = SC.GetValue<int>("TM.SingleArmOption");
             _isCycleMode                = SC.GetValue<bool>("System.IsCycleMode");

+ 3 - 0
Venus/Venus_RT/Modules/TM/MFPMPickRoutine.cs

@@ -85,6 +85,9 @@ namespace Venus_RT.Modules.TM
             }
 
             var pickItem = (Queue<MoveItem>)objs[0];
+            if (!WaferManager.Instance.CheckDuplicatedWafersBeforeMove(pickItem))
+                return RState.Failed;
+
             _targetModule = pickItem.Peek().SourceModule;
             _targetSlot = pickItem.Peek().SourceSlot;
             _hand = pickItem.Peek().RobotHand;

+ 3 - 0
Venus/Venus_RT/Modules/TM/MFPMPlaceRoutine.cs

@@ -79,6 +79,9 @@ namespace Venus_RT.Modules.TM
             }
 
             var placeItem = (Queue<MoveItem>)objs[0];
+            if (!WaferManager.Instance.CheckDuplicatedWafersBeforeMove(placeItem))
+                return RState.Failed;
+
             _targetModule = placeItem.Peek().DestinationModule;
             _targetSlot = placeItem.Peek().DestinationSlot;
             _hand = placeItem.Peek().RobotHand;

+ 3 - 0
Venus/Venus_RT/Modules/TM/MFPMSwapRoutine.cs

@@ -74,6 +74,9 @@ namespace Venus_RT.Modules.TM
             }
 
             var swapItem = (Queue<MoveItem>)objs[0];
+            if (!WaferManager.Instance.CheckDuplicatedWafersBeforeMove(swapItem))
+                return RState.Failed;
+
             _targetModule = swapItem.Peek().SourceModule;
             _targetSlot = swapItem.Peek().SourceSlot;
             _pickHand = swapItem.Peek().RobotHand;

+ 3 - 0
Venus/Venus_RT/Modules/TM/MFPickRoutine.cs

@@ -71,6 +71,9 @@ namespace Venus_RT.Modules.TM
 
 
             var pickItem = (Queue<MoveItem>)objs[0];
+            if (!WaferManager.Instance.CheckDuplicatedWafersBeforeMove(pickItem))
+                return RState.Failed;
+
             _targetModule = pickItem.Peek().SourceModule;
             _targetSlot = pickItem.Peek().SourceSlot;
             _hand = pickItem.Peek().RobotHand;

+ 2 - 0
Venus/Venus_RT/Modules/TM/MFPlaceRoutine.cs

@@ -73,6 +73,8 @@ namespace Venus_RT.Modules.TM
             }
 
             var placeItem = (Queue<MoveItem>)objs[0];
+            if (!WaferManager.Instance.CheckDuplicatedWafersBeforeMove(placeItem))
+                return RState.Failed;
             _targetModule = placeItem.Peek().DestinationModule;
             _targetSlot = placeItem.Peek().DestinationSlot;
             _hand = placeItem.Peek().RobotHand;

+ 4 - 0
Venus/Venus_RT/Modules/TM/MFSwapRoutine.cs

@@ -67,6 +67,10 @@ namespace Venus_RT.Modules.TM
             {
                 _actionList.Enqueue(new MoveItem(item.SourceModule, item.SourceSlot, item.DestinationModule, item.DestinationSlot, item.RobotHand));
             }
+
+            if (!WaferManager.Instance.CheckDuplicatedWafersBeforeMove(_actionList))
+                return RState.Failed;
+
             var firtItem = _actionList.Peek();
             if (ModuleHelper.IsLoadLock(firtItem.SourceModule))
                 _targetModule = firtItem.SourceModule;