| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276 | 
							- using System;
 
- using System.Collections.Generic;
 
- using System.Linq;
 
- using Aitex.Core.Common;
 
- using Aitex.Core.RT.DataCenter;
 
- using Aitex.Core.RT.Event;
 
- using Aitex.Core.RT.Log;
 
- using Aitex.Core.Util;
 
- using Aitex.Sorter.RT.Module.DBRecorder;
 
- using MECF.Framework.Common.DBCore;
 
- using MECF.Framework.Common.Equipment;
 
- using MECF.Framework.Common.Utilities;
 
- namespace MECF.Framework.Common.SubstrateTrackings
 
- {
 
-     public class CarrierManager : Singleton<CarrierManager>
 
-     {
 
-         Dictionary<string, Dictionary<int, CarrierInfo>> _locationCarriers = new Dictionary<string, Dictionary<int, CarrierInfo>>();
 
-         object _lockerCarrierList = new object();
 
-         private const string EventCarrierMoveIn = "CarrierMoveIn";
 
-         private const string EventCarrierMoveOut = "CarrierMoveOut";
 
-         private const string DvidCarrierId = "CarrierId";
 
-         private const string DvidStation = "Station";
 
-         public void Initialize()
 
-         {
 
-             EV.Subscribe(new EventItem("Event", EventCarrierMoveIn, "carrier move in"));
 
-             EV.Subscribe(new EventItem("Event", EventCarrierMoveOut, "carrier move out"));
 
-             Deserialize();
 
-         }
 
-         public void Terminate()
 
-         {
 
-             Serialize();
 
-         }
 
-         public void Deserialize()
 
-         {
 
-  
 
-             var ccc = BinarySerializer<Dictionary<string, Dictionary<int, CarrierInfo>>>.FromStream("CarrierManager");
 
-             if (ccc != null)
 
-                 _locationCarriers = ccc;
 
-         }
 
-         public void Serialize()
 
-         {
 
-             if (_locationCarriers != null)
 
-             {
 
-                 BinarySerializer<Dictionary<string, Dictionary<int, CarrierInfo>> >.ToStream(_locationCarriers, "CarrierManager");
 
-             }
 
-         }
 
-         /// <summary>
 
-         /// 由各个模块自己定义注册可以放置几个载盒
 
-         /// </summary>
 
-         /// <param name="module">模块名称</param>
 
-         /// <param name="capacity">有几个位置可以放</param>
 
-         public void SubscribeLocation(string module, int capacity=1)
 
-         {
 
-             if (!_locationCarriers.ContainsKey(module))
 
-             {
 
-                 _locationCarriers[module] = new Dictionary<int, CarrierInfo>();
 
-                 for (int i = 0; i < capacity; i++)
 
-                 {
 
-                     _locationCarriers[module][i] = new CarrierInfo(25);
 
-                 }
 
-             }
 
-             DATA.Subscribe(module, "Carrier", () => _locationCarriers[module][0]);
 
-         }
 
-         public void CreateCarrier(string module)
 
-         {
 
-             if (!_locationCarriers.ContainsKey(module))
 
-                 return;
 
-             _locationCarriers[module][0].Status = CarrierStatus.Normal;
 
-             _locationCarriers[module][0].InnerId = Guid.NewGuid() ;
 
-             _locationCarriers[module][0].Name = $"Cassette{DateTime.Now.ToString("yyyyMMddHHmmss")}";
 
-             _locationCarriers[module][0].LoadTime = DateTime.Now;
 
-             CarrierDataRecorder.Loaded(_locationCarriers[module][0].InnerId.ToString(), module);
 
-             Serialize();
 
-         }
 
-         public void DeleteCarrier(string module)
 
-         {
 
-             if (!_locationCarriers.ContainsKey(module))
 
-                 return;
 
-             CarrierDataRecorder.Unloaded(_locationCarriers[module][0].InnerId.ToString());
 
-             _locationCarriers[module][0].Clear();
 
-             Serialize();
 
-         }
 
-         public void RegisterCarrierWafer(string module, int index, WaferInfo wafer)
 
-         {
 
-             if (!_locationCarriers.ContainsKey(module))
 
-                 return;
 
-             _locationCarriers[module][0].Wafers[index] = wafer;
 
-         }
 
-         public void UnregisterCarrierWafer(string module, int index)
 
-         {
 
-             if (!_locationCarriers.ContainsKey(module))
 
-                 return;
 
-             _locationCarriers[module][0].Wafers[index] = null;
 
-         }
 
-         public CarrierInfo GetCarrier(string module)
 
-         {
 
-             if (!_locationCarriers.ContainsKey(module))
 
-                 return null;
 
-             return _locationCarriers[module][0];
 
-         }
 
-         public string GetLocationByCarrierId(string carrierId)
 
-         {
 
-             foreach (var locationCarrier in _locationCarriers)
 
-             {
 
-                 foreach (var carrierInfo in locationCarrier.Value)
 
-                 {
 
-                     if (!carrierInfo.Value.IsEmpty && carrierInfo.Value.CarrierId == carrierId)
 
-                         return locationCarrier.Key;
 
-                 }
 
-             }
 
-             return null;
 
-         }
 
-         /// <summary>
 
-         /// 传入LPn, 返回该LP的LotId
 
-         /// </summary>
 
-         /// <param name="moduleName">LP1/2/n</param>
 
-         /// <returns>LotId string</returns>
 
-         public string GetLotIdByLoadPort(string moduleName)
 
-         {
 
-             return _locationCarriers.ContainsKey(moduleName) ? _locationCarriers[moduleName][0].LotId : "";
 
-         }
 
-         public bool HasCarrier(string module)
 
-         {
 
-             if (!_locationCarriers.ContainsKey(module))
 
-                 return false;
 
-             return !_locationCarriers[module][0].IsEmpty;
 
-         }
 
-         public void CarrierMoved(string moduleFrom,  string moduleTo)
 
-         {
 
-             if (_locationCarriers[moduleFrom][0].IsEmpty)
 
-             {
 
-                 //LOG.Write(string.Format("Invalid carrier move, no carrier at source, {0}{1}=>{2}{3}", moduleFrom, 0 + 1, moduleTo, 0 + 1));
 
-                 return;
 
-             }
 
-             if (!_locationCarriers[moduleTo][0].IsEmpty)
 
-             {
 
-                 //LOG.Write(string.Format("Invalid carrier move, destination has carrier, {0}{1}=>{2}{3}", moduleFrom, 0 + 1, moduleTo, 0 + 1));
 
-                 return;
 
-             }
 
-             _locationCarriers[moduleTo][0].CopyInfo(_locationCarriers[moduleFrom][0]);
 
-             DeleteCarrier(moduleFrom);
 
-  
 
-                 EV.Notify(EventCarrierMoveOut, new SerializableDictionary<string, string>()
 
-                 {
 
-                     {DvidCarrierId, GetCarrier(moduleFrom).CarrierId},
 
-                     { DvidStation, moduleFrom}
 
-                 });
 
-  
 
-                 EV.Notify(EventCarrierMoveIn, new SerializableDictionary<string, string>()
 
-                 {
 
-                     {DvidCarrierId, GetCarrier(moduleTo).CarrierId},
 
-                     { DvidStation, moduleTo}
 
-                 });
 
-  
 
-             EV.PostInfoLog(ModuleName.System.ToString(), string.Format("Carrier moved from {0} to {1}", moduleFrom, moduleTo));
 
-             WaferMoveHistoryRecorder.WaferMoved(_locationCarriers[moduleTo][0].InnerId.ToString(), moduleTo.ToString(), 0, _locationCarriers[moduleTo][0].Status.ToString());
 
-             Serialize();
 
-         }
 
-         public void UpdateCarrierId(string module, string carrierId)
 
-         {
 
-             if (!_locationCarriers.ContainsKey(module))
 
-                 return;
 
-             if (!string.IsNullOrEmpty(_locationCarriers[module][0].CarrierId))
 
-             {
 
-                 DeleteCarrier(module);
 
-                 CreateCarrier(module);
 
-             }
 
-             _locationCarriers[module][0].CarrierId = carrierId;
 
-             CarrierDataRecorder.UpdateCarrierId(_locationCarriers[module][0].InnerId.ToString(), carrierId);
 
-             Serialize();
 
-         }
 
-         public void UpdateRfId(string module, string rfid)
 
-         {
 
-             if (!_locationCarriers.ContainsKey(module))
 
-                 return;
 
-             if (!string.IsNullOrEmpty(_locationCarriers[module][0].CarrierId))
 
-             {
 
-                 DeleteCarrier(module);
 
-                 CreateCarrier(module);
 
-             }
 
-             _locationCarriers[module][0].Rfid = rfid;
 
-             Serialize();
 
-         }
 
-         public void UpdateCarrierLot(string module, string lotId)
 
-         {
 
-             if (!_locationCarriers.ContainsKey(module))
 
-                 return;
 
-             _locationCarriers[module][0].LotId = lotId;
 
-             CarrierDataRecorder.UpdateLotId(_locationCarriers[module][0].InnerId.ToString(), lotId);
 
-             Serialize();
 
-         }
 
-         public void UpdateProductCategory(string module, string productCategory)
 
-         {
 
-             if (!_locationCarriers.ContainsKey(module))
 
-                 return;
 
-             _locationCarriers[module][0].ProductCategory = productCategory;
 
-             CarrierDataRecorder.UpdateProductCategory(_locationCarriers[module][0].InnerId.ToString(), productCategory);
 
-             Serialize();
 
-         }
 
-         public void UpdateProcessJob(string module, object job)
 
-         {
 
-             if (!_locationCarriers.ContainsKey(module))
 
-                 return;
 
-             _locationCarriers[module][0].ProcessJob = job;
 
-             Serialize();
 
-         }
 
-         public void UpdateProcessStatus(string module, bool processed)
 
-         {
 
-             if (!_locationCarriers.ContainsKey(module))
 
-                 return;
 
-             _locationCarriers[module][0].ProcessStatus[module] = processed;
 
-             Serialize();
 
-         }
 
-     }
 
- }
 
 
  |