|
@@ -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();
|