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 }); } } 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 ObservableCollection _boatWaferInfoItems = new ObservableCollection(); public ObservableCollection BoatWaferInfoItems { get => _boatWaferInfoItems; set { _boatWaferInfoItems = value; NotifyOfPropertyChange(nameof(BoatWaferInfoItems)); } } protected override void InvokeAfterUpdateProperty(Dictionary data) { RefreshCassetteDataTask(); } 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++; } } } 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; } } }