using Aitex.Core.Common; using Aitex.Core.Util; using Caliburn.Micro; using MECF.Framework.Common.DataCenter; using MECF.Framework.Common.Equipment; using MECF.Framework.UI.Client.ClientBase; using System.Collections.Generic; using System.Collections.ObjectModel; using System.Linq; using System.Windows; using System.Windows.Media; using FurnaceUI.Models; namespace FurnaceUI.Views.Operations { public class StockerViewModel : FurnaceUIViewModelBase { public bool IsPermission { get => this.Permission == 3; } public Visibility IsReplace { get; set; } public StockerViewModel() { this.DisplayName = "StockerViewModel"; _stokcers = new List() { ModuleName.Stocker1, ModuleName.Stocker2, ModuleName.Stocker3, ModuleName.Stocker4, ModuleName.Stocker5, ModuleName.Stocker6, ModuleName.Stocker7, ModuleName.Stocker8, ModuleName.Stocker9, ModuleName.Stocker10, ModuleName.Stocker11, ModuleName.Stocker12, ModuleName.Stocker13, ModuleName.Stocker14, ModuleName.Stocker15, ModuleName.Stocker16, ModuleName.Stocker17, ModuleName.Stocker18, //ModuleName.Stocker19, //ModuleName.Stocker20, //ModuleName.Stocker21, }; StockerSlots = new ObservableCollection() { "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", }; StockerWaferType = Enumerable.Repeat("", 21).ToList(); _eDUseWarningLimit = (int)QueryDataClient.Instance.Service.GetConfig("PM1.WaferCycleTime.EDCountWarning"); _eDUseAlarmLimit = (int)QueryDataClient.Instance.Service.GetConfig("PM1.WaferCycleTime.EDCountAlarm"); StockerBackground = new List(); for (int i = 0; i < 21; i++) { StockerBackground.Add(_WhiteFill); } } private List _stokcers; private List _stokcerWaferType; double _eDUseWarningLimit; double _eDUseAlarmLimit; public List StockerWaferType { get => _stokcerWaferType; set { _stokcerWaferType = value; NotifyOfPropertyChange(nameof(StockerWaferType)); } } private int _cassetteSlot = 0; private ObservableCollection _stockerSlots; public ObservableCollection StockerSlots { get { return _stockerSlots; } set { _stockerSlots = value; NotifyOfPropertyChange("StockerSlots"); } } private SolidColorBrush _WhiteFill = new SolidColorBrush(Colors.White); private SolidColorBrush _abortFill = new SolidColorBrush(Colors.Red); private SolidColorBrush _productionFill = new SolidColorBrush((Color)ColorConverter.ConvertFromString("#bedadb")); private SolidColorBrush _SD_ED_M_Fill = new SolidColorBrush((Color)ColorConverter.ConvertFromString("LightGray")); private SolidColorBrush _waringFill = new SolidColorBrush(Colors.Yellow); private SolidColorBrush _alarmFill = new SolidColorBrush(Colors.Red); private List _stockerBackground = new List(); public List StockerBackground { get => _stockerBackground; set { _stockerBackground = value; NotifyOfPropertyChange(nameof(StockerBackground)); } } [Subscription("Stocker1.CassettePresent")] public bool IsCassettePresent { get; set; } [Subscription("Stocker1.LotID")] public string Stocker1LotID { get; set; } [Subscription("Stocker2.LotID")] public string Stocker2LotID { get; set; } [Subscription("Stocker3.LotID")] public string Stocker3LotID { get; set; } [Subscription("Stocker4.LotID")] public string Stocker4LotID { get; set; } [Subscription("Stocker5.LotID")] public string Stocker5LotID { get; set; } [Subscription("Stocker6.LotID")] public string Stocker6LotID { get; set; } [Subscription("Stocker7.LotID")] public string Stocker7LotID { get; set; } [Subscription("Stocker8.LotID")] public string Stocker8LotID { get; set; } [Subscription("Stocker9.LotID")] public string Stocker9LotID { get; set; } [Subscription("Stocker10.LotID")] public string Stocker10LotID { get; set; } [Subscription("Stocker11.LotID")] public string Stocker11LotID { get; set; } [Subscription("Stocker12.LotID")] public string Stocker12LotID { get; set; } [Subscription("Stocker13.LotID")] public string Stocker13LotID { get; set; } [Subscription("Stocker14.LotID")] public string Stocker14LotID { get; set; } [Subscription("Stocker15.LotID")] public string Stocker15LotID { get; set; } [Subscription("Stocker16.LotID")] public string Stocker16LotID { get; set; } [Subscription("Stocker17.LotID")] public string Stocker17LotID { get; set; } [Subscription("Stocker18.LotID")] public string Stocker18LotID { get; set; } public Visibility IsStockerVisibility { get; set; } public Visibility IsLPVisibility { get; set; } protected override void OnInitialize() { base.OnInitialize(); //base.InitFOUP(); //base.InitLL(); //base.InitTM(); //base.InitEFEM(); //base.InitPM(); //base.InitBuffer(); } protected override void OnActivate() { base.OnActivate(); _cassetteSlot = (int)QueryDataClient.Instance.Service.GetConfig("System.CassetteSlotCount"); for (int i = 0; i < _stokcers.Count; i++) { StockerWaferType[i] = (string)QueryDataClient.Instance.Service.GetConfig($"System.Stocker.{_stokcers[i]}WaferType"); } } protected override void InvokeAfterUpdateProperty(Dictionary data) { var isLoadPortPosition = (string)QueryDataClient.Instance.Service.GetConfig("LoadPort.LoadPortPosition"); if (isLoadPortPosition == "Upper") { IsStockerVisibility = Visibility.Hidden; IsLPVisibility = Visibility.Visible; } else { IsStockerVisibility = Visibility.Visible; IsLPVisibility = Visibility.Hidden; } UpdateStockerSlots(); } private void UpdateStockerSlots() { for (int i = 0; i < _stokcers.Count; i++) { bool bHaveAbort = false; var wafers = ModuleManager.ModuleInfos[_stokcers[i].ToString()].WaferManager.Wafers; int waferNumber = 0; SolidColorBrush _tempFill = _SD_ED_M_Fill; if (wafers != null) { foreach (var wafer in wafers) { if (wafer.WaferStatus != 0) { waferNumber++; if (wafer.WaferStatus == 5) // EnumWaferProcessStatus.Failed bHaveAbort = true; if (wafer.UseCount > _eDUseWarningLimit) { _tempFill = _waringFill; } if (wafer.UseCount > _eDUseAlarmLimit) { _tempFill = _alarmFill; } } } } StockerSlots[i] = $"{waferNumber}/{_cassetteSlot}"; if (StockerWaferType[i].Contains("P")) { if (waferNumber > 0) { if (bHaveAbort) StockerBackground[i] = _abortFill; else { StockerBackground[i] = _productionFill; } } else { StockerBackground[i] = _WhiteFill; } } else { if (waferNumber > 0) { if (bHaveAbort) StockerBackground[i] = _abortFill; else StockerBackground[i] = _tempFill; ; } else { StockerBackground[i] = _WhiteFill; } } } } public void SwitchPage(string page) { } public void StokcerInfo(string module, string type) { WindowManager wm = new WindowManager(); CassetteViewModel svm = new CassetteViewModel(module); svm.WaferType = type; switch (ModuleHelper.Converter(module)) { case ModuleName.Stocker1: svm.LotID = Stocker1LotID; break; case ModuleName.Stocker2: svm.LotID = Stocker2LotID; break; case ModuleName.Stocker3: svm.LotID = Stocker3LotID; break; case ModuleName.Stocker4: svm.LotID = Stocker4LotID; break; case ModuleName.Stocker5: svm.LotID = Stocker5LotID; break; case ModuleName.Stocker6: svm.LotID = Stocker6LotID; break; case ModuleName.Stocker7: svm.LotID = Stocker7LotID; break; case ModuleName.Stocker8: svm.LotID = Stocker8LotID; break; case ModuleName.Stocker9: svm.LotID = Stocker9LotID; break; case ModuleName.Stocker10: svm.LotID = Stocker10LotID; break; case ModuleName.Stocker11: svm.LotID = Stocker11LotID; break; case ModuleName.Stocker12: svm.LotID = Stocker12LotID; break; case ModuleName.Stocker13: svm.LotID = Stocker13LotID; break; case ModuleName.Stocker14: svm.LotID = Stocker14LotID; break; case ModuleName.Stocker15: svm.LotID = Stocker15LotID; break; case ModuleName.Stocker16: svm.LotID = Stocker16LotID; break; case ModuleName.Stocker17: svm.LotID = Stocker17LotID; break; case ModuleName.Stocker18: svm.LotID = Stocker18LotID; break; } wm.ShowDialogWithTitle(svm, null, $"{svm.ModuleName} Information"); } } }