| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366 | 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>()            {                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<string>()            {                "",                "",                "",                "",                "",                "",                "",                "",                "",                "",                "",                "",                "",                "",                "",                "",                "",                "",                "",                "",                "",            };            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<SolidColorBrush>();            for (int i = 0; i < 21; i++)            {                StockerBackground.Add(_WhiteFill);            }        }        private List<ModuleName> _stokcers;        private List<string> _stokcerWaferType;        double _eDUseWarningLimit;        double _eDUseAlarmLimit;        public List<string> StockerWaferType        {            get => _stokcerWaferType;            set            {                _stokcerWaferType = value;                NotifyOfPropertyChange(nameof(StockerWaferType));            }        }        private int _cassetteSlot = 0;        private ObservableCollection<string> _stockerSlots;        public ObservableCollection<string> 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<SolidColorBrush> _stockerBackground = new List<SolidColorBrush>();        public List<SolidColorBrush> 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<string, object> 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");        }    }}
 |