using System; using System.Collections.Generic; using System.Diagnostics; using Aitex.Core.RT.DataCenter; using Aitex.Core.RT.Device; using Aitex.Core.RT.Device.Unit; using Aitex.Core.RT.Event; using Aitex.Core.RT.Fsm; using Aitex.Core.RT.OperationCenter; using Aitex.Core.RT.Routine; using Aitex.Core.RT.SCCore; using Aitex.Core.Util; using Aitex.Core.Utilities; using Aitex.Sorter.Common; using FurnaceRT.Equipments.PMs; using FurnaceRT.Equipments.Systems; using MECF.Framework.Common.Alarms; using MECF.Framework.Common.Equipment; using MECF.Framework.Common.Event; using MECF.Framework.Common.Schedulers; using MECF.Framework.Common.SubstrateTrackings; using MECF.Framework.RT.EquipmentLibrary.HardwareUnits.LoadPorts; using MECF.Framework.RT.EquipmentLibrary.HardwareUnits.Robot; using MECF.Framework.RT.EquipmentLibrary.HardwareUnits.Robots.RobotBase; namespace FurnaceRT.Equipments.Stockers { public partial class StockerModule { #region fields private IoSensor _diStationCassettePresent; private IoTrigger _foupPurge; private int _alarmNumber; #endregion private List _triggeredAlarmList = new List(); public void InitDevice() { _diStationCassettePresent = DEVICE.GetDevice($"PM1.Sensor{Module}"); _foupPurge = DEVICE.GetDevice($"PM1.TrigStockerPurge{Module}"); this.OnDeviceAlarmStateChanged += OnModuleDeviceAlarmStateChanged; } public void OnModuleDeviceAlarmStateChanged(string deviceId, AlarmEventItem alarmItem) { if (alarmItem.IsTriggered) { EventLevel level = alarmItem.Level; _triggeredAlarmList.Add(alarmItem); if (level == EventLevel.Alarm) { try { EV.PostAlarmLog(Module, alarmItem); } catch (Exception ex) { EV.WriteEvent(ex.Message.ToString()); } } else { EV.PostWarningLog(Module, alarmItem); } } else { } } private void SetDisplayName() { if (!SC.ContainsItem($"System.Stocker.{Module}WaferType")) return; var type = SC.GetStringValue($"System.Stocker.{Module}WaferType"); if (type.Contains("P")) type = "P"; else if (type.Contains("M")) type = "M"; else if (type.Contains("SD")) type = "SD"; else if (type.Contains("ED")) type = "ED"; int display = 0; for(int i = 1; i < 30; i++) { if (!SC.ContainsItem($"System.Stocker.Stocker{i}WaferType")) continue; if (SC.GetStringValue($"System.Stocker.Stocker{i}WaferType").Contains(type)) display++; if (Module == $"Stocker{i}") break; } SC.SetItemValue($"System.StockerDisplayName.{Module}", $"{display}"); } public override void Monitor() { if(_foupPurge != null && _diStationCassettePresent != null && _foupPurge.Value != _diStationCassettePresent.Value) { _foupPurge.SetTrigger(_diStationCassettePresent.Value, out _); } if (ModuleHelper.IsStocker(ModuleHelper.Converter(Module))) { var stockerFoupInfo = CarrierManager.Instance.GetCarrier(Module); var setValue = IsFoupPresent; if (IsFoupPresent && stockerFoupInfo.CarrierType == CarrierType.None) { setValue = false; } SetVisibility(stockerFoupInfo, setValue); var pmModule = Singleton.Instance.Modules[ModuleName.PM1] as PMModule; stockerFoupInfo.UICarrierColor = pmModule.GetCarrierUIColor(stockerFoupInfo.UICarrierType, stockerFoupInfo.UICarrierStatusEnum); } } private string GetStockerNo() { var stockerNo = Module.Replace("Stocker", ""); if (int.Parse(stockerNo) < 10) { return $"0{stockerNo}"; } else { return stockerNo; } } public void SetVisibility(CarrierInfo stockerCarrierInfo, bool setValue) { stockerCarrierInfo.UICarrierStatusVisibility = true; stockerCarrierInfo.UICarrierTypeVisibility = true; stockerCarrierInfo.UICarrierWaferCountVisibility = true; stockerCarrierInfo.UICarrierColorVisibility = true; stockerCarrierInfo.UIStockerExitFoup = false; stockerCarrierInfo.UIExitFoup = true; if (!setValue) { #region 判断是否在CarrierRobot上 bool isExistCarrierRobot = false; if (SC.GetValue("System.IsSimulatorMode")) { var hasFoupSensor = !CarrierManager.Instance.CheckNoCarrier(ModuleName.CarrierRobot, 0); var carrierRobotFoupInfo = CarrierManager.Instance.GetCarrier(ModuleName.CarrierRobot); if (hasFoupSensor && carrierRobotFoupInfo != null && carrierRobotFoupInfo.InternalModuleName == ModuleHelper.Converter(Module)) { isExistCarrierRobot = true; stockerCarrierInfo.UIStockerExitFoup = false; stockerCarrierInfo.UICarrierType = carrierRobotFoupInfo.CarrierType.ToString(); stockerCarrierInfo.UICarrierStatusEnum = carrierRobotFoupInfo.UICarrierStatusEnum; stockerCarrierInfo.UICarrierColorVisibility = false; } } else { var carrierRobotDevice = DEVICE.GetDevice($"{ModuleName.CarrierRobot}"); var hasFoupSensor = carrierRobotDevice.IsWaferPresenceOnBlade1 || !CarrierManager.Instance.CheckNoCarrier(ModuleName.CarrierRobot, 0); var carrierRobotFoupInfo = CarrierManager.Instance.GetCarrier(ModuleName.CarrierRobot); if (hasFoupSensor && carrierRobotFoupInfo != null && carrierRobotFoupInfo.InternalModuleName == ModuleHelper.Converter(Module)) { isExistCarrierRobot = true; stockerCarrierInfo.UIStockerExitFoup = false; stockerCarrierInfo.UICarrierStatusEnum = carrierRobotFoupInfo.UICarrierStatusEnum; stockerCarrierInfo.UICarrierType = carrierRobotFoupInfo.CarrierType.ToString(); stockerCarrierInfo.UICarrierColorVisibility = false; } } #endregion #region 判断是否在FIMS上 bool isExistFIMS1 = false; var fims1FoupInfo = CarrierManager.Instance.GetCarrier(ModuleName.FIMS1); if (fims1FoupInfo != null && !fims1FoupInfo.IsEmpty && fims1FoupInfo.InternalModuleName == ModuleHelper.Converter(Module)) { isExistFIMS1 = true; stockerCarrierInfo.UIStockerExitFoup = false; stockerCarrierInfo.UICarrierStatusEnum = fims1FoupInfo.UICarrierStatusEnum; stockerCarrierInfo.UICarrierType = fims1FoupInfo.CarrierType.ToString(); stockerCarrierInfo.UICarrierColorVisibility = false; } bool isExistFIMS2 = false; var fims2FoupInfo = CarrierManager.Instance.GetCarrier(ModuleName.FIMS2); if (fims2FoupInfo != null && !fims2FoupInfo.IsEmpty && fims2FoupInfo.InternalModuleName == ModuleHelper.Converter(Module)) { isExistFIMS1 = true; stockerCarrierInfo.UIStockerExitFoup = false; stockerCarrierInfo.UICarrierStatusEnum = fims2FoupInfo.UICarrierStatusEnum; stockerCarrierInfo.UICarrierType = fims2FoupInfo.UICarrierType; stockerCarrierInfo.UICarrierColorVisibility = false; } #endregion #region 判断是否在LP上 bool isExistLP = false; for (int i = 1; i < 5; i++) { var lpName = $"LP{i}"; var lpFoupInfo = CarrierManager.Instance.GetCarrier(lpName); if (lpFoupInfo != null && !lpFoupInfo.IsEmpty && lpFoupInfo.InternalModuleName == ModuleHelper.Converter(Module)) { isExistLP = true; stockerCarrierInfo.UIStockerExitFoup = false; stockerCarrierInfo.UIExitFoup = true; stockerCarrierInfo.UICarrierStatusEnum = lpFoupInfo.UICarrierStatusEnum; stockerCarrierInfo.UICarrierType = lpFoupInfo.UICarrierType; stockerCarrierInfo.UICarrierColorVisibility = false; } } #endregion #region 判断属于自己的foup是否放到了别的stocker上 var isExisStocker = false; var stockerCount = SC.GetValue("System.Stocker.StockerCount"); for (int i = 1; i < stockerCount; i++) { var stockerName = $"Stocker{i}"; var checkStockerFoupInfo = CarrierManager.Instance.GetCarrier(stockerName); if (Module == stockerName) { continue; } if (checkStockerFoupInfo != null && !checkStockerFoupInfo.IsEmpty && checkStockerFoupInfo.InternalModuleName == ModuleHelper.Converter(Module)) { isExisStocker = true; } } #endregion if (!isExistCarrierRobot && !isExistFIMS1 && !isExistFIMS2 && !isExistLP) { stockerCarrierInfo.UIStockerExitFoup = true; stockerCarrierInfo.UIExitFoup = false; stockerCarrierInfo.UICarrierWaferCount = $"{SC.GetValue("System.CassetteSlotCount")}"; var stockerSCTypePath = $"System.Stocker.{Module}WaferType"; if (SC.ContainsItem(stockerSCTypePath)) { stockerCarrierInfo.UICarrierType = SC.ContainsItem(stockerSCTypePath) ? $"{SC.GetStringValue(stockerSCTypePath)} {GetStockerNo()}" : ""; } } } else { stockerCarrierInfo.UICarrierType = stockerCarrierInfo.CarrierType.ToString(); stockerCarrierInfo.UICarrierStatusEnum = CarrierStatus.READY; stockerCarrierInfo.UIStockerExitFoup = false; Singleton.Instance.SetUIWaferCount(stockerCarrierInfo, ModuleHelper.Converter(Module), out var wafers); } } } }