using Aitex.Core.Common; using Aitex.Core.Util; using Caliburn.Micro.Core; using MECF.Framework.Common.DataCenter; using MECF.Framework.Common.OperationCenter; using MECF.Framework.UI.Client.ClientBase; using OpenSEMI.ClientBase; using System; using System.Collections.Generic; using System.Collections.ObjectModel; using System.Linq; using System.Text; using System.Threading.Tasks; using System.Windows; using FurnaceUI.Models; using FurnaceUI.Views.Editors; namespace FurnaceUI.Views.Operations { public class BoatModifyViewModel : FurnaceUIViewModelBase { public BoatModifyViewModel(string module) { ModuleName = module; for (int i = 1; i <= 21; i++) { OriginModuleItems.Add($"Stocker{i}"); } var count = (int)QueryDataClient.Instance.Service.GetConfig("Boat.SlotCount"); for (int i = count; i > 0; i--) { BoatWaferInfoItems.Add(new WaferInfoItem() { SlotID = i }); BoatMapWafers.Add(""); } } public string ModuleName { set; get; } public List OriginModuleItems { get; set; } = new List(); private int? _boatSlotFrom = 1; public int? BoatSlotFrom { get => _boatSlotFrom; set { _boatSlotFrom = value; NotifyOfPropertyChange(nameof(BoatSlotFrom)); } } private int? _boatSlotTo = 1; public int? BoatSlotTo { get => _boatSlotTo; set { _boatSlotTo = value; NotifyOfPropertyChange(nameof(BoatSlotTo)); } } private string _originSelectModule = "Stocker1"; public string OriginSelectModule { get => _originSelectModule; set { _originSelectModule = value; NotifyOfPropertyChange(nameof(OriginSelectModule)); } } private int? _originSlot = 1; public int? OriginSlot { get => _originSlot; set { _originSlot = value; NotifyOfPropertyChange(nameof(OriginSlot)); } } public bool SDIsChecked { get; set; } = true; public bool EDIsChecked { get; set; } public bool PIsChecked { get; set; } public bool M1IsChecked { get; set; } public bool M2IsChecked { get; set; } public bool XDIsChecked { get; set; } [Subscription("Stocker1.CassettePresent")] public bool IsCassettePresent { get; set; } [Subscription("Rt.Status")] public string RtStatus { get; set; } [Subscription("PM1.Status")] public string PM1Status { get; set; } public bool IsBoatModifyEnabled { get { return (PM1Status == "Init" || PM1Status == "Idle" || PM1Status == "Error") && (RtStatus == "Init" || RtStatus == "Idle" || RtStatus == "Error"); } } private List _boatMapWafers = new List(); public List BoatMapWafers { get => _boatMapWafers; set { _boatMapWafers = value; NotifyOfPropertyChange(nameof(BoatMapWafers)); } } private ObservableCollection _boatWaferInfoItems = new ObservableCollection(); public ObservableCollection BoatWaferInfoItems { get => _boatWaferInfoItems; set { _boatWaferInfoItems = value; NotifyOfPropertyChange(nameof(BoatWaferInfoItems)); } } private int _upperSDNum = 0; public int UpperSDNum { get => _upperSDNum; set { _upperSDNum = value; NotifyOfPropertyChange(nameof(UpperSDNum)); } } private int _productNum = 0; public int ProductNum { get => _productNum; set { _productNum = value; NotifyOfPropertyChange(nameof(ProductNum)); } } private int _monitorNum1 = 0; public int MonitorNum1 { get => _monitorNum1; set { _monitorNum1 = value; NotifyOfPropertyChange(nameof(MonitorNum1)); } } private int _monitorNum2 = 0; public int MonitorNum2 { get => _monitorNum2; set { _monitorNum2 = value; NotifyOfPropertyChange(nameof(MonitorNum2)); } } private int _lowerSDNum = 0; public int LowerSDNum { get => _lowerSDNum; set { _lowerSDNum = value; NotifyOfPropertyChange(nameof(LowerSDNum)); } } private int _lowerSideDummyNum = 9; private Tuple ComputSD(List dataSource) { List otherSlot = dataSource.Where(a => a != "SD" && !string.IsNullOrEmpty(a)).ToList().Distinct().ToList(); if (dataSource == null || dataSource.Count == 0) { return new Tuple(0, 0); } List minList = new List(); for (int i = 0; i < dataSource.Count; i++) { var item = dataSource[i]; if (otherSlot.Contains(item) && !string.IsNullOrEmpty(item)) { break; } if (string.IsNullOrEmpty(item)) { continue; } minList.Add(i); } dataSource.Reverse(); List maxList = new List(); for (int i = 0; i < dataSource.Count; i++) { var item = dataSource[i]; if (otherSlot.Contains(item) && !string.IsNullOrEmpty(item)) { break; } if (string.IsNullOrEmpty(item)) { continue; } maxList.Add(i); } return new Tuple(minList.Count(), maxList.Count()); } protected override void InvokeAfterUpdateProperty(Dictionary data) { RefreshCassetteDataTask(); if (null != BoatMapWafers && BoatMapWafers.Count > 0) { BoatMapWafers.Reverse(); UpperSDNum = BoatMapWafers.Where(x => x == "SD").Count(); LowerSDNum = BoatMapWafers.Where(x => x == "ED").Count(); ProductNum = BoatMapWafers.Where(x => x.StartsWith("P")).Count(); MonitorNum1 = BoatMapWafers.Where(x => x == "M1").Count(); MonitorNum2 = BoatMapWafers.Where(x => x == "M2").Count(); } } private void RefreshCassetteDataTask() { var wafers = ModuleManager.ModuleInfos[ModuleName].WaferManager.Wafers; if (wafers != null) { int iIndex = 0; for (int i = 0; i < wafers.Count; i++) { if (wafers[i].WaferStatus != 0) { BoatWaferInfoItems[iIndex].ModuleID = wafers[i].ModuleID; if (string.IsNullOrEmpty(wafers[i].LotId)) BoatWaferInfoItems[iIndex].SourceName = wafers[i].SourceName; else BoatWaferInfoItems[iIndex].SourceName = wafers[i].LotId + "-" + wafers[i].SourceName; BoatWaferInfoItems[iIndex].WaferStatus = wafers[i].WaferStatus; BoatWaferInfoItems[iIndex].WaferType = wafers[i].WaferType.ToString(); BoatWaferInfoItems[iIndex].UseCount = wafers[i].UseCount.ToString(); BoatWaferInfoItems[iIndex].UseTime = wafers[i].UseTime.ToString(); BoatWaferInfoItems[iIndex].UseThick = wafers[i].UseThick.ToString(); } else { BoatWaferInfoItems[iIndex].ModuleID = ""; BoatWaferInfoItems[iIndex].SourceName = ""; BoatWaferInfoItems[iIndex].WaferStatus = 0; BoatWaferInfoItems[iIndex].WaferType = ""; BoatWaferInfoItems[iIndex].UseCount = ""; BoatWaferInfoItems[iIndex].UseTime = ""; BoatWaferInfoItems[iIndex].UseThick = ""; } iIndex++; } BoatMapWafers = BoatWaferInfoItems.Select(a => a.WaferType).ToList(); } } public void CreateWafer() { WaferType waferType = WaferType.None; if (SDIsChecked) waferType = WaferType.SD; else if (EDIsChecked) waferType = WaferType.ED; else if (PIsChecked) waferType = WaferType.P; else if (M1IsChecked) waferType = WaferType.M1; else if (XDIsChecked) waferType = WaferType.XD; else if (M2IsChecked) waferType = WaferType.M2; if (BoatSlotFrom > BoatSlotTo || BoatSlotTo > (int)QueryDataClient.Instance.Service.GetConfig("Boat.SlotCount") || BoatSlotFrom < 1) { DialogBox.ShowWarning($"BoatSlot input error,can not create,input range 1 to {(int)QueryDataClient.Instance.Service.GetConfig("Boat.SlotCount")}"); return; } if (OriginSlot < 1 || OriginSlot > (int)QueryDataClient.Instance.Service.GetConfig("System.CassetteSlotCount")) { DialogBox.ShowWarning($"OriginSlot input error,can not create,input range 1 to {(int)QueryDataClient.Instance.Service.GetConfig("System.CassetteSlotCount")}"); return; } InvokeClient.Instance.Service.DoOperation("CreateWaferFromTo", $"{ModuleName}", BoatSlotFrom, BoatSlotTo, new string[] { waferType.ToString(), OriginSelectModule, (OriginSlot - 1).ToString() }); // InvokeClient.Instance.Service.DoOperation("CreateWafer", $"{ModuleName}", BoatSlotFrom, waferType.ToString(), OriginSelectModule, OriginSlot - 1); } public void DeleteWafer() { if (BoatSlotFrom < 1 || BoatSlotTo > (int)QueryDataClient.Instance.Service.GetConfig("Boat.SlotCount")) { DialogBox.ShowWarning($"BoatSlot input error,can not delete,input range 1 to {(int)QueryDataClient.Instance.Service.GetConfig("Boat.SlotCount")}"); return; } //InvokeClient.Instance.Service.DoOperation("DeleteWafer", $"{ModuleName}", BoatSlot); InvokeClient.Instance.Service.DoOperation("DeleteWaferFromTo", $"{ModuleName}", BoatSlotFrom, BoatSlotTo); } public void CassetteClose() { ((Window)GetView()).DialogResult = false; } } }