using Caliburn.Micro; using MECF.Framework.Common.DataCenter; using MECF.Framework.UI.Client.CenterViews.Editors.Recipe; using MECF.Framework.UI.Client.ClientBase; using OpenSEMI.ClientBase; using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; using System.Windows; using System.Windows.Media; using FurnaceUI.Models; using FurnaceUI.Views.Editors; namespace FurnaceUI.Views.Recipes { public class RecipeLayoutExpertEditViewModel : FurnaceUIViewModelBase { #region properties public int FoupListMaxValue { get; set; } private int waferNumberP; public int WaferNumberP { get { return waferNumberP; } set { waferNumberP = value; NotifyOfPropertyChange(nameof(waferNumberP)); } } private int waferNumberXD; public int WaferNumberXD { get { return waferNumberXD; } set { waferNumberXD = value; NotifyOfPropertyChange(nameof(waferNumberXD)); } } private int waferNumberT; public int WaferNumberT { get { return waferNumberT; } set { waferNumberT = value; NotifyOfPropertyChange(nameof(waferNumberT)); } } private int currentItemIndex; private string SelectedSlotType { get; set; } public int CurrentItemIndex { get { return currentItemIndex; } set { currentItemIndex = value; SelecteSlot(); this.NotifyOfPropertyChange(nameof(CurrentItemIndex)); } } private RecipeProvider _recipeProvider = new RecipeProvider(); private SolidColorBrush _DefaultdBk = new SolidColorBrush(Colors.White); private SolidColorBrush _PBk = new SolidColorBrush(Colors.SkyBlue); private SolidColorBrush _SDBk = new SolidColorBrush(Colors.White); private SolidColorBrush _EDBk = new SolidColorBrush(Colors.Yellow); private SolidColorBrush _MBk = new SolidColorBrush(Colors.Pink); private SolidColorBrush _XDBk = new SolidColorBrush(Colors.White); private SolidColorBrush _TBk = new SolidColorBrush(Colors.DarkGreen); #endregion public RecipeDataLayout CurrentRecipe { get; set; } = new RecipeDataLayout(); public RecipeLayoutEntityNormal NormalEntity { get { return CurrentRecipe.NormalSteps[0]; } set { CurrentRecipe.NormalSteps[0] = value; this.NotifyOfPropertyChange(nameof(NormalEntity)); } } public List BoatWafers { get { return CurrentRecipe.ExpertSteps[0].Items; } set { CurrentRecipe.ExpertSteps[0].Items = value; } } private bool _IsStandardPitchEnabled = true; public bool IsStandardPitchEnabled { get => _IsStandardPitchEnabled; set { _IsStandardPitchEnabled = value; NotifyOfPropertyChange(nameof(IsStandardPitchEnabled)); } } private bool _IsDoublePitchEnabled; public bool IsDoublePitchEnabled { get => _IsDoublePitchEnabled; set { _IsDoublePitchEnabled = value; NotifyOfPropertyChange(nameof(IsDoublePitchEnabled)); } } private bool _IsTriplePitchEnabled; public bool IsTriplePitchEnabled { get => _IsTriplePitchEnabled; set { _IsTriplePitchEnabled = value; NotifyOfPropertyChange(nameof(IsTriplePitchEnabled)); } } public int index; public bool IsEnable => CGlobal.RecipeLayoutEditViewEnable;//是否是View模式 private int _cassetteSlotCount; public List WaferIndex { get; set; } = new List(); public RecipeLayoutExpertEditViewModel(string strPrefixPath, string strName, string permission = "") { FoupListMaxValue = (int)QueryDataClient.Instance.Service.GetConfig("Boat.SlotCount"); _cassetteSlotCount = (int)QueryDataClient.Instance.Service.GetConfig("System.CassetteSlotCount"); bool IsStandardPitchChecked = (bool)QueryDataClient.Instance.Service.GetConfig("PM1.RecipeEditParameter.LayoutPitch.StandardPitch"); bool IsDoublePitchChecked = (bool)QueryDataClient.Instance.Service.GetConfig("PM1.RecipeEditParameter.LayoutPitch.DoublePitch"); bool IsTriplePitchChecked = (bool)QueryDataClient.Instance.Service.GetConfig("PM1.RecipeEditParameter.LayoutPitch.TriplePitch"); IsDoublePitchEnabled = IsDoublePitchChecked; IsTriplePitchEnabled = IsTriplePitchChecked; LoadData(strPrefixPath, strName, permission); } private void LoadData(string strPrefixPath, string strName, string permission) { CurrentRecipe.Clear(); CurrentRecipe.PrefixPath = strPrefixPath; CurrentRecipe.Name = strName; CurrentRecipe.RecipePermission = permission; var recipeContent = _recipeProvider.LoadRecipe(strPrefixPath, strName); if (string.IsNullOrEmpty(recipeContent)) { System.Windows.MessageBox.Show($"{CurrentRecipe.PrefixPath}\\{CurrentRecipe.Name} is empty, please confirm the file is valid."); return; } CurrentRecipe.RecipeChamberType = "OriginChamber"; CurrentRecipe.InitData(CurrentRecipe.PrefixPath, CurrentRecipe.Name, recipeContent, CurrentRecipe.Configs, "PM1"); if (CurrentRecipe.ExpertSteps.Count == 0 || CurrentRecipe.ExpertSteps[0].Items.Count <= 0) { RecipeLayoutEntityExpert expert = new RecipeLayoutEntityExpert(); CurrentRecipe.ExpertSteps.Add(expert); for (int i = 0; i < FoupListMaxValue; i++) { BoatWaferItem item = new BoatWaferItem() { Slot = i + 1, Description = $"" }; CurrentRecipe.ExpertSteps[0].Items.Add(item); } } if (CurrentRecipe.NormalSteps.Count == 0 || CurrentRecipe.ExpertSteps[0].Items.Count <= 0) { RecipeLayoutEntityNormal normal = new RecipeLayoutEntityNormal(); CurrentRecipe.NormalSteps.Add(normal); } } protected override void OnActivate() { base.OnActivate(); RefreshBoatWafers(); } public void SelecteSlot() { switch (SelectedSlotType) { case "T": NormalEntity.ProductSlotNo = ProccessSlotNoPositionString("Add", NormalEntity.ProductSlotNo, currentItemIndex); NormalEntity.Monitor1SlotNo = ProccessSlotNoPositionString("Delete", NormalEntity.Monitor1SlotNo, currentItemIndex); break; case "XD": NormalEntity.Monitor1SlotNo = ProccessSlotNoPositionString("Add", NormalEntity.Monitor1SlotNo, currentItemIndex); NormalEntity.ProductSlotNo = ProccessSlotNoPositionString("Delete", NormalEntity.ProductSlotNo, currentItemIndex); break; case "Space": NormalEntity.ProductSlotNo = ProccessSlotNoPositionString("Delete", NormalEntity.ProductSlotNo, currentItemIndex); NormalEntity.Monitor1SlotNo = ProccessSlotNoPositionString("Delete", NormalEntity.Monitor1SlotNo, currentItemIndex); break; } this.RefreshBoatWafers(); } public void SetCommand(object obj) { WindowManager wm = new WindowManager(); switch (obj.ToString()) { case "All Dummy": NormalEntity.DummyUpperSlot = "170"; SelectedSlotType = obj.ToString(); break; case "All Clear": NormalEntity = new RecipeLayoutEntityNormal() { WhenPWaferShort = NormalEntity.WhenPWaferShort, SDRule = NormalEntity.SDRule, WhenCassetteInBatchAreShort = NormalEntity.WhenCassetteInBatchAreShort, WhenWaferInCassetteAreShort = NormalEntity.WhenWaferInCassetteAreShort, WhenEDAreShort = NormalEntity.WhenEDAreShort, RuleOfSpaceInBoat = NormalEntity.RuleOfSpaceInBoat, }; foreach (var item in BoatWafers) { item.Description = ""; } SelectedSlotType = obj.ToString(); break; case "T": NormalEntity.DummyUpperSlot = ""; SelectedSlotType = obj.ToString(); break; case "XD": NormalEntity.DummyUpperSlot = ""; SelectedSlotType = obj.ToString(); break; case "Space": NormalEntity.DummyUpperSlot = ""; SelectedSlotType = obj.ToString(); break; } this.RefreshBoatWafers(); } private string ProccessSlotNoPositionString(string strType, string str, int iCurrentItemIndex) { string strRet = ""; if (iCurrentItemIndex <= 0) return strRet; string strOrgTemp = "," + str; string strDesTemp = "," + iCurrentItemIndex; string strComTemp = "," + iCurrentItemIndex + ","; if (strType == "Add") { if (!strOrgTemp.Contains(strComTemp)) strOrgTemp = strOrgTemp + strDesTemp; } else { if (strOrgTemp.Contains(strDesTemp)) strOrgTemp = (strOrgTemp + ",").Replace(strComTemp, ",").TrimEnd(','); } strRet = strOrgTemp; for (int i = 0; i < 2; i++) { if (strRet.StartsWith(",")) strRet = strRet.Substring(1); } return strRet; } public void RefreshBoatWafers() { List listWafers = QueryDataClient.Instance.Service.GetLayoutExpertRecipeContent(CurrentRecipe.GetXmlString(), FoupListMaxValue.ToString(), _cassetteSlotCount.ToString()); WaferNumberT = WaferNumberXD = 0; if (listWafers.Count <= 0 || (CurrentRecipe.ExpertSteps.Count <= 0 && CurrentRecipe.NormalSteps.Count <= 0)) return; CurrentRecipe.NormalSteps[0].ProductSlotNo = string.Empty; CurrentRecipe.NormalSteps[0].Monitor1SlotNo = string.Empty; for (int i = 0; i < listWafers.Count; i++) { CurrentRecipe.ExpertSteps[0].Items[i].Slot = i + 1; CurrentRecipe.ExpertSteps[0].Items[i].Description = listWafers[i].ToString() == "" ? "----" : listWafers[i].ToString(); switch (listWafers[i].ToString()) { case "XD": CurrentRecipe.NormalSteps[0].Monitor1SlotNo = ProccessSlotNoPositionString("Add", CurrentRecipe.NormalSteps[0].Monitor1SlotNo, i + 1); CurrentRecipe.ExpertSteps[0].Items[i].BkColor = _DefaultdBk; WaferNumberXD++; break; case "T": CurrentRecipe.NormalSteps[0].ProductSlotNo = ProccessSlotNoPositionString("Add", CurrentRecipe.NormalSteps[0].ProductSlotNo, i + 1); CurrentRecipe.ExpertSteps[0].Items[i].BkColor = _SDBk; WaferNumberT++; break; default: CurrentRecipe.ExpertSteps[0].Items[i].BkColor = _DefaultdBk; break; } } } public void EndEdit() { RecipePermissionSelectViewModel dialog = new RecipePermissionSelectViewModel("Save recipe and permission", CurrentRecipe.RecipePermission); WindowManager wm = new WindowManager(); bool? dialogReturn = wm.ShowDialog(dialog); if (!dialogReturn.HasValue || !dialogReturn.Value) return; CurrentRecipe.IsSavedDesc = false; this.CurrentRecipe.Revisor = BaseApp.Instance.UserContext.LoginName; this.CurrentRecipe.ReviseTime = DateTime.Now; this.CurrentRecipe.RecipeLevel = this.LevelDisplay; this.CurrentRecipe.RecipePermission = dialog.RecipePermission; this._recipeProvider.SaveRecipe(CurrentRecipe.PrefixPath, CurrentRecipe.Name, CurrentRecipe.GetXmlString()); ((Window)GetView()).DialogResult = true; } public void Cancel() { if (DialogBox.ShowDialog(DialogButton.Yes | DialogButton.No, DialogType.CONFIRM, " You confirm that you want to unsave the recipe and exit the interface?") == DialogButton.No) return; ((Window)GetView()).Close(); } } }