using Caliburn.Micro; using MECF.Framework.Common.CommonData; 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.Windows; using System.Windows.Media; using FurnaceUI.Models; using FurnaceUI.Views.Editors; using System.Windows.Controls; using FurnaceUI.Views.DataLog; using System.Linq; using RecipeEditorLib.RecipeModel.Params; using System.Collections.ObjectModel; using FurnaceUI.Client.Dialog; using SciChart.Core.Extensions; namespace FurnaceUI.Views.Recipes { public class RecipeLayoutEditViewModel : FurnaceUIViewModelBase { #region properties private string _recipeName; public string RecipeName { get => _recipeName; set { _recipeName = value; NotifyOfPropertyChange(nameof(RecipeName)); } } public int FoupListMaxValue { get; set; } private int waferNumberP; public int WaferNumberP { get { return waferNumberP; } set { waferNumberP = value; NotifyOfPropertyChange(nameof(waferNumberP)); } } private int waferNumberSD; public int WaferNumberSD { get { return waferNumberSD; } set { waferNumberSD = value; NotifyOfPropertyChange(nameof(waferNumberSD)); } } private int waferNumberM; public int WaferNumberM { get { return waferNumberM; } set { waferNumberM = value; NotifyOfPropertyChange(nameof(waferNumberM)); } } private int currentItemIndex; private string SelectedSlotType { get; set; } 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 bool IsEnable => CGlobal.RecipeLayoutEditViewEnable;//是否是View模式 private int _cassetteSlotCount; private TotalWaferNumberMode _totalWaferNumber = TotalWaferNumberMode.Total; public TotalWaferNumberMode TotalWaferNumber { get => _totalWaferNumber; set { _totalWaferNumber = value; NotifyOfPropertyChange(nameof(TotalWaferNumber)); } } private string _totalWaferNumberValue = ""; public string TotalWaferNumberValue { get => _totalWaferNumberValue; set { _totalWaferNumberValue = value; NotifyOfPropertyChange(nameof(TotalWaferNumberValue)); } } private LayoutReplacement _setLayoutReplacement = LayoutReplacement.Upper; public LayoutReplacement SetLayoutReplacement { get => _setLayoutReplacement; set { _setLayoutReplacement = value; NotifyOfPropertyChange(nameof(SetLayoutReplacement)); } } private string _setLayoutReplacementValue = ""; public string SetLayoutReplacementValue { get => _setLayoutReplacementValue; set { _setLayoutReplacementValue = value; NotifyOfPropertyChange(nameof(SetLayoutReplacementValue)); } } private MonitorTransferType _waferChargeMonitor1 = MonitorTransferType.AutoLayout; public MonitorTransferType WaferChargeMonitor1 { get => _waferChargeMonitor1; set { _waferChargeMonitor1 = value; NotifyOfPropertyChange(nameof(WaferChargeMonitor1)); } } private string _waferChargeMonitorValue1 = ""; public string WaferChargeMonitorValue1 { get => _waferChargeMonitorValue1; set { _waferChargeMonitorValue1 = value; NotifyOfPropertyChange(nameof(WaferChargeMonitorValue1)); } } private MonitorTransferType _waferChargeMonitor2 = MonitorTransferType.AutoLayout; public MonitorTransferType WaferChargeMonitor2 { get => _waferChargeMonitor2; set { _waferChargeMonitor2 = value; NotifyOfPropertyChange(nameof(WaferChargeMonitor2)); } } private string _waferChargeMonitorValue2 = ""; public string WaferChargeMonitorValue2 { get => _waferChargeMonitorValue2; set { _waferChargeMonitorValue2 = value; NotifyOfPropertyChange(nameof(WaferChargeMonitorValue2)); } } private string _fillDummyTransferStr = "None"; public string FillDummyTransferStr { get => _fillDummyTransferStr; set { _fillDummyTransferStr = value; NotifyOfPropertyChange(nameof(FillDummyTransferStr)); } } private string _productZeroStr; public string ProductZeroStr { get => _productZeroStr; set { _productZeroStr = value; NotifyOfPropertyChange(nameof(ProductZeroStr)); } } private string _ProductTransferStr; public string ProductTransferStr { get => _ProductTransferStr; set { _ProductTransferStr = value; NotifyOfPropertyChange(nameof(ProductTransferStr)); } } private MonitorReturnType _dialogResultmonitor1 = MonitorReturnType.ChargeSlot; public MonitorReturnType DialogResultmonitor1 { get => _dialogResultmonitor1; set { _dialogResultmonitor1 = value; NotifyOfPropertyChange(nameof(DialogResultmonitor1)); } } private MonitorReturnType _dialogResultmonitor2 = MonitorReturnType.ChargeSlot; public MonitorReturnType DialogResultmonitor2 { get => _dialogResultmonitor2; set { _dialogResultmonitor2 = value; NotifyOfPropertyChange(nameof(DialogResultmonitor2)); } } private string _yAxisModeStr = "Normal"; public string YAxisModeStr { get => _yAxisModeStr; set { _yAxisModeStr = value; NotifyOfPropertyChange(nameof(YAxisModeStr)); } } private int _topSlotNo = 149; public int TopSlotNo { get => _topSlotNo; set { _topSlotNo = value; NotifyOfPropertyChange(nameof(TopSlotNo)); } } private int _upperSideDummyNum = 3; public int UpperSideDummyNum { get => _upperSideDummyNum; set { _upperSideDummyNum = value; NotifyOfPropertyChange(nameof(UpperSideDummyNum)); } } private int _boatTotalSlot = 143; public int BoatTotalSlot { get => _boatTotalSlot; set { _boatTotalSlot = value; NotifyOfPropertyChange(nameof(BoatTotalSlot)); } } 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; public int LowerSideDummyNum { get => _lowerSideDummyNum; set { _lowerSideDummyNum = value; NotifyOfPropertyChange(nameof(LowerSideDummyNum)); } } private List _boatMapWafers = new List(); public List BoatMapWafers { get => _boatMapWafers; set { _boatMapWafers = value; NotifyOfPropertyChange(nameof(BoatMapWafers)); } } public RecipeFormatBuilder ColumnBuilder { get; set; } public RecipeLayoutEditViewModel(string strPrefixPath, string strName, RecipeFormatBuilder columnBuilder, string permission = "") { FoupListMaxValue = (int)QueryDataClient.Instance.Service.GetConfig("Boat.SlotCount"); _cassetteSlotCount = (int)QueryDataClient.Instance.Service.GetConfig("System.CassetteSlotCount"); RecipeName = strName; ColumnBuilder = columnBuilder; 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, ColumnBuilder.Configs, "PM1"); var waferNumberAll = (int)QueryDataClient.Instance.Service.GetConfig("Boat.SlotCount"); var cassetteSlotCount = (int)QueryDataClient.Instance.Service.GetConfig("System.CassetteSlotCount"); List listWafers = QueryDataClient.Instance.Service.GetLayoutRecipeContent(CurrentRecipe.GetXmlString(), waferNumberAll.ToString(), cassetteSlotCount.ToString()); BoatMapWafers = listWafers; 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); } if (CurrentRecipe.ConfigItems != null && CurrentRecipe.ConfigItems.Count > 0) { var asd = CurrentRecipe.ConfigItems.Select(a => a.Name).ToList(); if (CurrentRecipe.ConfigItems.Where(x => x.Name == "BoatTotalSlot").Count() > 0) { BoatTotalSlot = ((NumParam)CurrentRecipe.ConfigItems.Where(x => x.Name == "BoatTotalSlot").FirstOrDefault()).Value; } if (CurrentRecipe.ConfigItems.Where(x => x.Name == "UpperSDNum").Count() > 0) { UpperSDNum = ((NumParam)CurrentRecipe.ConfigItems.Where(x => x.Name == "UpperSDNum").FirstOrDefault()).Value; } if (CurrentRecipe.ConfigItems.Where(x => x.Name == "ProductNum").Count() > 0) { ProductNum = ((NumParam)CurrentRecipe.ConfigItems.Where(x => x.Name == "ProductNum").FirstOrDefault()).Value; } if (CurrentRecipe.ConfigItems.Where(x => x.Name == "MonitorNum1").Count() > 0) { ProductNum = ((NumParam)CurrentRecipe.ConfigItems.Where(x => x.Name == "MonitorNum1").FirstOrDefault()).Value; } if (CurrentRecipe.ConfigItems.Where(x => x.Name == "MonitorNum2").Count() > 0) { ProductNum = ((NumParam)CurrentRecipe.ConfigItems.Where(x => x.Name == "MonitorNum2").FirstOrDefault()).Value; } if (CurrentRecipe.ConfigItems.Where(x => x.Name == "LowerSDNum").Count() > 0) { LowerSDNum = ((NumParam)CurrentRecipe.ConfigItems.Where(x => x.Name == "LowerSDNum").FirstOrDefault()).Value; } if (CurrentRecipe.ConfigItems.Where(x => x.Name == "TopSlotNo").Count() > 0) { TopSlotNo = ((NumParam)CurrentRecipe.ConfigItems.Where(x => x.Name == "TopSlotNo").FirstOrDefault()).Value; } if (CurrentRecipe.ConfigItems.Where(x => x.Name == "UpperSideDummyNum").Count() > 0) { UpperSideDummyNum = ((NumParam)CurrentRecipe.ConfigItems.Where(x => x.Name == "UpperSideDummyNum").FirstOrDefault()).Value; } if (CurrentRecipe.ConfigItems.Where(x => x.Name == "BoatMapDecisionMethod").Count() > 0) { IsDispTypeEnabled = ((NumParam)CurrentRecipe.ConfigItems.Where(x => x.Name == "BoatMapDecisionMethod").FirstOrDefault()).Value == 0 ? true : false; } if (CurrentRecipe.ConfigItems.Where(x => x.Name == "LowerSideDummyNum").Count() > 0) { LowerSideDummyNum = ((NumParam)CurrentRecipe.ConfigItems.Where(x => x.Name == "LowerSideDummyNum").FirstOrDefault()).Value; } if (CurrentRecipe.ConfigItems.Where(x => x.Name == "ProductAndFill").Count() > 0) { if (string.IsNullOrEmpty(((StringParam)CurrentRecipe.ConfigItems.Where(x => x.Name == "ProductAndFill").FirstOrDefault()).Value)) { TotalWaferNumber = TotalWaferNumberMode.Total; } else { TotalWaferNumber = (TotalWaferNumberMode)Enum.Parse(typeof(TotalWaferNumberMode), ((StringParam)CurrentRecipe.ConfigItems.Where(x => x.Name == "ProductAndFill").FirstOrDefault()).Value); } } if (CurrentRecipe.ConfigItems.Where(x => x.Name == "ProductAndFillValue").Count() > 0) { if (!string.IsNullOrEmpty(((StringParam)CurrentRecipe.ConfigItems.Where(x => x.Name == "ProductAndFillValue").FirstOrDefault()).Value)) { TotalWaferNumberValue = ((StringParam)CurrentRecipe.ConfigItems.Where(x => x.Name == "ProductAndFillValue").FirstOrDefault()).Value; } } if (CurrentRecipe.ConfigItems.Where(x => x.Name == "WaferSupplement").Count() > 0) { if (string.IsNullOrEmpty(((StringParam)CurrentRecipe.ConfigItems.Where(x => x.Name == "WaferSupplement").FirstOrDefault()).Value)) { SetLayoutReplacement = LayoutReplacement.Upper; } else { SetLayoutReplacement = (LayoutReplacement)Enum.Parse(typeof(LayoutReplacement), ((StringParam)CurrentRecipe.ConfigItems.Where(x => x.Name == "WaferSupplement").FirstOrDefault()).Value); } } if (CurrentRecipe.ConfigItems.Where(x => x.Name == "WaferSupplementValue").Count() > 0) { if (!string.IsNullOrEmpty(((StringParam)CurrentRecipe.ConfigItems.Where(x => x.Name == "WaferSupplementValue").FirstOrDefault()).Value)) { SetLayoutReplacementValue = ((StringParam)CurrentRecipe.ConfigItems.Where(x => x.Name == "WaferSupplementValue").FirstOrDefault()).Value; } } if (CurrentRecipe.ConfigItems.Where(x => x.Name == "WaferChargeMonitor1").Count() > 0) { if (string.IsNullOrEmpty(((StringParam)CurrentRecipe.ConfigItems.Where(x => x.Name == "WaferChargeMonitor1").FirstOrDefault()).Value)) { WaferChargeMonitor1 = MonitorTransferType.AutoLayout; } else { WaferChargeMonitor1 = (MonitorTransferType)Enum.Parse(typeof(MonitorTransferType), ((StringParam)CurrentRecipe.ConfigItems.Where(x => x.Name == "WaferChargeMonitor1").FirstOrDefault()).Value); } } if (CurrentRecipe.ConfigItems.Where(x => x.Name == "WaferChargeMonitorValue1").Count() > 0) { if (!string.IsNullOrEmpty(((StringParam)CurrentRecipe.ConfigItems.Where(x => x.Name == "WaferChargeMonitorValue1").FirstOrDefault()).Value)) { WaferChargeMonitorValue1 = ((StringParam)CurrentRecipe.ConfigItems.Where(x => x.Name == "WaferChargeMonitorValue1").FirstOrDefault()).Value; } } if (CurrentRecipe.ConfigItems.Where(x => x.Name == "WaferChargeMonitor2").Count() > 0) { if (string.IsNullOrEmpty(((StringParam)CurrentRecipe.ConfigItems.Where(x => x.Name == "WaferChargeMonitor2").FirstOrDefault()).Value)) { WaferChargeMonitor2 = MonitorTransferType.AutoLayout; } else { WaferChargeMonitor2 = (MonitorTransferType)Enum.Parse(typeof(MonitorTransferType), ((StringParam)CurrentRecipe.ConfigItems.Where(x => x.Name == "WaferChargeMonitor2").FirstOrDefault()).Value); } } if (CurrentRecipe.ConfigItems.Where(x => x.Name == "WaferChargeMonitorValue2").Count() > 0) { if (!string.IsNullOrEmpty(((StringParam)CurrentRecipe.ConfigItems.Where(x => x.Name == "WaferChargeMonitorValue2").FirstOrDefault()).Value)) { WaferChargeMonitorValue2 = ((StringParam)CurrentRecipe.ConfigItems.Where(x => x.Name == "WaferChargeMonitorValue2").FirstOrDefault()).Value; } } if (CurrentRecipe.ConfigItems.Where(x => x.Name == "FillDummyTransfer").Count() > 0) { if (string.IsNullOrEmpty(((StringParam)CurrentRecipe.ConfigItems.Where(x => x.Name == "FillDummyTransfer").FirstOrDefault()).Value)) { FillDummyTransferStr = "None"; } else { FillDummyTransferStr = ((StringParam)CurrentRecipe.ConfigItems.Where(x => x.Name == "FillDummyTransfer").FirstOrDefault()).Value; } } if (CurrentRecipe.ConfigItems.Where(x => x.Name == "ProductZeroNotFill").Count() > 0) { if (string.IsNullOrEmpty(((StringParam)CurrentRecipe.ConfigItems.Where(x => x.Name == "ProductZeroNotFill").FirstOrDefault()).Value)) { ProductZeroStr = "None"; } else { ProductZeroStr = ((StringParam)CurrentRecipe.ConfigItems.Where(x => x.Name == "ProductZeroNotFill").FirstOrDefault()).Value; } } if (CurrentRecipe.ConfigItems.Where(x => x.Name == "ProductTransferPosition").Count() > 0) { if (string.IsNullOrEmpty(((StringParam)CurrentRecipe.ConfigItems.Where(x => x.Name == "ProductTransferPosition").FirstOrDefault()).Value)) { ProductTransferStr = "None"; } else { ProductTransferStr = ((StringParam)CurrentRecipe.ConfigItems.Where(x => x.Name == "ProductTransferPosition").FirstOrDefault()).Value; } } if (CurrentRecipe.ConfigItems.Where(x => x.Name == "WaferDischargeMonitor1").Count() > 0) { if (string.IsNullOrEmpty(((StringParam)CurrentRecipe.ConfigItems.Where(x => x.Name == "WaferDischargeMonitor1").FirstOrDefault()).Value)) { DialogResultmonitor1 = MonitorReturnType.ChargeSlot; } else { DialogResultmonitor1 = (MonitorReturnType)Enum.Parse(typeof(MonitorReturnType), ((StringParam)CurrentRecipe.ConfigItems.Where(x => x.Name == "WaferDischargeMonitor1").FirstOrDefault()).Value); } } if (CurrentRecipe.ConfigItems.Where(x => x.Name == "WaferDischargeMonitor2").Count() > 0) { if (string.IsNullOrEmpty(((StringParam)CurrentRecipe.ConfigItems.Where(x => x.Name == "WaferDischargeMonitor2").FirstOrDefault()).Value)) { DialogResultmonitor2 = MonitorReturnType.ChargeSlot; } else { DialogResultmonitor2 = (MonitorReturnType)Enum.Parse(typeof(MonitorReturnType), ((StringParam)CurrentRecipe.ConfigItems.Where(x => x.Name == "WaferDischargeMonitor2").FirstOrDefault()).Value); } } } if (null != BoatMapWafers && BoatMapWafers.Count > 0) { var data = ComputSD(BoatMapWafers); UpperSDNum = listWafers.Where(x => x == "SD").Count(); LowerSDNum = listWafers.Where(x => x == "FD").Count(); ProductNum = listWafers.Where(x => x.StartsWith("P")).Count(); MonitorNum1 = listWafers.Where(x => x == "M1").Count(); MonitorNum2 = listWafers.Where(x => x == "M2").Count(); } } protected override void OnActivate() { base.OnActivate(); } public void SetCommand(object obj) { WindowManager wm = new WindowManager(); switch (obj.ToString()) { case "Product Pos": RecipeProductPosViewModel viewProduct = new RecipeProductPosViewModel(); viewProduct.NormalEntity = NormalEntity; wm.ShowDialogWithTitle(viewProduct, null, obj.ToString()); SelectedSlotType = ""; break; case "Monitor Pos": RecipeMonitorPosViewModel viewMonitor = new RecipeMonitorPosViewModel(); viewMonitor.NormalEntity = NormalEntity; wm.ShowDialogWithTitle(viewMonitor, null, obj.ToString()); 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 "Wafer Charge Rule": RecipeWaferChargeRuleViewModel viewWaferChargeRule = new RecipeWaferChargeRuleViewModel(); viewWaferChargeRule.NormalEntity = NormalEntity; wm.ShowDialogWithTitle(viewWaferChargeRule, null, obj.ToString()); SelectedSlotType = obj.ToString(); break; case "Product": //NormalEntity.ProductSlotNo = ProccessSlotNoPositionString("Add",NormalEntity.ProductSlotNo,currentItemIndex); //NormalEntity.MonitorSlotNo = ProccessSlotNoPositionString("Delete", NormalEntity.MonitorSlotNo,currentItemIndex); SelectedSlotType = obj.ToString(); break; case "Monitor": //NormalEntity.MonitorSlotNo = ProccessSlotNoPositionString("Add",NormalEntity.MonitorSlotNo, currentItemIndex); //NormalEntity.ProductSlotNo = ProccessSlotNoPositionString("Delete", NormalEntity.ProductSlotNo, currentItemIndex); SelectedSlotType = obj.ToString(); break; case "Space": //NormalEntity.ProductSlotNo = ProccessSlotNoPositionString("Delete", NormalEntity.ProductSlotNo, currentItemIndex); //NormalEntity.MonitorSlotNo = ProccessSlotNoPositionString("Delete",NormalEntity.MonitorSlotNo, currentItemIndex); SelectedSlotType = obj.ToString(); break; } } 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(strDesTemp, ""); } strRet = strOrgTemp; for (int i = 0; i < 2; i++) { if (strRet.StartsWith(",")) strRet = strRet.Substring(1); } return strRet; } public void TextSelectCmdMouseDown(string cmd, object sender) { var colsender = (TextBox)sender; WindowManager wm = new WindowManager(); switch (cmd) { case "TotalWaferNumber": RecipeLayoutSetTotalWaferNumberViewModel recipeLayoutSetTotalWaferNumberViewModel = new RecipeLayoutSetTotalWaferNumberViewModel(); recipeLayoutSetTotalWaferNumberViewModel.TotalWaferNumber = TotalWaferNumber; recipeLayoutSetTotalWaferNumberViewModel.ReturnValue = TotalWaferNumberValue; bool? dialogReturn = wm.ShowDialogWithTitle(recipeLayoutSetTotalWaferNumberViewModel, null, "WAP Logic Design"); if ((bool)dialogReturn) { TotalWaferNumber = recipeLayoutSetTotalWaferNumberViewModel.DialogResultTotalWaferNumberMode; TotalWaferNumberValue = recipeLayoutSetTotalWaferNumberViewModel.ReturnValue; } break; case "Replacement": RecipeLayoutSetReplacementViewModel recipeLayoutSetReplacementViewModel = new RecipeLayoutSetReplacementViewModel(); recipeLayoutSetReplacementViewModel.SetLayoutReplacement = SetLayoutReplacement; dialogReturn = wm.ShowDialogWithTitle(recipeLayoutSetReplacementViewModel, null, "File Wafer Replacement"); if ((bool)dialogReturn) { SetLayoutReplacement = recipeLayoutSetReplacementViewModel.DialogResultLayoutReplacement; } break; case "WaferChargeMonitor1": RecipeLayoutSetMonitorTransferViewModel recipeLayoutSetMonitorTransferViewModel1 = new RecipeLayoutSetMonitorTransferViewModel(); recipeLayoutSetMonitorTransferViewModel1.WaferChargeMonitor = WaferChargeMonitor1; recipeLayoutSetMonitorTransferViewModel1.WaferChargeMonitorValue = WaferChargeMonitorValue1; dialogReturn = wm.ShowDialogWithTitle(recipeLayoutSetMonitorTransferViewModel1, null, "Monitor Transfer1"); if ((bool)dialogReturn) { WaferChargeMonitor1 = recipeLayoutSetMonitorTransferViewModel1.DialogResultMonitorTransferType; WaferChargeMonitorValue1 = recipeLayoutSetMonitorTransferViewModel1.ReturnString; } break; case "WaferChargeMonitor2": RecipeLayoutSetMonitorTransferViewModel recipeLayoutSetMonitorTransferViewModel2 = new RecipeLayoutSetMonitorTransferViewModel(); recipeLayoutSetMonitorTransferViewModel2.WaferChargeMonitor = WaferChargeMonitor2; dialogReturn = wm.ShowDialogWithTitle(recipeLayoutSetMonitorTransferViewModel2, null, "Monitor Transfer2"); if ((bool)dialogReturn) { WaferChargeMonitor2 = recipeLayoutSetMonitorTransferViewModel2.DialogResultMonitorTransferType; WaferChargeMonitorValue2 = recipeLayoutSetMonitorTransferViewModel2.ReturnString; } break; case "MonitorReturn1": RecipeLayoutSetMonitorReturnViewModel recipeLayoutSetMonitorReturnViewModel = new RecipeLayoutSetMonitorReturnViewModel(); recipeLayoutSetMonitorReturnViewModel.DialogResultmonitor = DialogResultmonitor1; dialogReturn = wm.ShowDialogWithTitle(recipeLayoutSetMonitorReturnViewModel, null, "Monitor Return1"); if ((bool)dialogReturn) { DialogResultmonitor1 = recipeLayoutSetMonitorReturnViewModel.DialogResultmonitor; } break; case "MonitorReturn2": RecipeLayoutSetMonitorReturnViewModel recipeLayoutSetMonitorReturnViewModel2 = new RecipeLayoutSetMonitorReturnViewModel(); recipeLayoutSetMonitorReturnViewModel2.DialogResultmonitor = DialogResultmonitor2; dialogReturn = wm.ShowDialogWithTitle(recipeLayoutSetMonitorReturnViewModel2, null, "Monitor Return2"); if ((bool)dialogReturn) { DialogResultmonitor2 = recipeLayoutSetMonitorReturnViewModel2.DialogResultmonitor; } break; case "FillDummyTransfer": RecipeLayoutSetFillDummyTransferViewModel recipeLayoutSetFillDummyTransferViewModel = new RecipeLayoutSetFillDummyTransferViewModel(); recipeLayoutSetFillDummyTransferViewModel.FillDummyTransferStr = FillDummyTransferStr; dialogReturn = wm.ShowDialogWithTitle(recipeLayoutSetFillDummyTransferViewModel, null, "Fill Dummy Transfer"); if ((bool)dialogReturn) { FillDummyTransferStr = recipeLayoutSetFillDummyTransferViewModel.DialogResultString; } break; case "ProductZero": SelectExistViewModel selectExistViewModel = new SelectExistViewModel(); selectExistViewModel.ProductZeroStr = ProductZeroStr; dialogReturn = wm.ShowDialogWithTitle(selectExistViewModel, null, "Select"); if ((bool)dialogReturn) { ProductZeroStr = selectExistViewModel.DialogResultString; } break; case "ProductTransfer": RecipeLayoutSetProductTransferViewModel recipeLayoutSetProductTransferViewModel = new RecipeLayoutSetProductTransferViewModel(); recipeLayoutSetProductTransferViewModel.ProductTransferStr = ProductTransferStr; dialogReturn = wm.ShowDialogWithTitle(recipeLayoutSetProductTransferViewModel, null, "Product Transfer Position"); if ((bool)dialogReturn) { ProductTransferStr = recipeLayoutSetProductTransferViewModel.DialogResultString; } break; case "Replacement1": RecipeLayoutMonitorWaferReplaceViewModel recipeLayoutMonitorWaferReplaceViewModel = new RecipeLayoutMonitorWaferReplaceViewModel(); dialogReturn = wm.ShowDialogWithTitle(recipeLayoutMonitorWaferReplaceViewModel, null, "Monitor Wafer Replace"); colsender.Text = recipeLayoutMonitorWaferReplaceViewModel.MonitorWaferFillReplace; break; case "Replacement2": RecipeLayoutMonitorWaferReplaceViewModel recipeLayoutMonitorWaferReplaceViewModel2 = new RecipeLayoutMonitorWaferReplaceViewModel(); dialogReturn = wm.ShowDialogWithTitle(recipeLayoutMonitorWaferReplaceViewModel2, null, "Monitor Wafer Replace"); colsender.Text = recipeLayoutMonitorWaferReplaceViewModel2.MonitorWaferFillReplace; break; case "YAxisMode": SelectExpandViewModel selectExpandViewModel = new SelectExpandViewModel(); dialogReturn = wm.ShowDialogWithTitle(selectExpandViewModel, null, "Select"); if ((bool)dialogReturn) { YAxisModeStr = selectExpandViewModel.DialogResultString; } break; default: break; } } public void BoatMapMouseDown() { WindowManager wm = new WindowManager(); if (CurrentRecipe != null) { RecipeLayoutBoatMapViewModel recipeLayoutBoatMapViewModel = new RecipeLayoutBoatMapViewModel(CurrentRecipe.PrefixPath, CurrentRecipe.Name, ColumnBuilder); var dialogReturn = wm.ShowDialogWithTitle(recipeLayoutBoatMapViewModel, null, "Boat Map Direct Edit"); if ((bool)dialogReturn) { BoatMapWafers = recipeLayoutBoatMapViewModel.listBoatWafers.ToList(); CurrentRecipe = recipeLayoutBoatMapViewModel.CurrentRecipe; ProductNum = recipeLayoutBoatMapViewModel.ProductSlotCount; MonitorNum1 = recipeLayoutBoatMapViewModel.Monitor1SlotCount; MonitorNum2 = recipeLayoutBoatMapViewModel.Monitor2SlotCount; var data = ComputSD(BoatMapWafers); LowerSDNum = data.Item1; UpperSDNum = data.Item2; } } } 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()); } public void CancelClick() { 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(); } public void SaveClick() { SetConfig(); EndEdit(); } private void SetConfig() { if (CurrentRecipe.ConfigItems != null && CurrentRecipe.ConfigItems.Count > 0) { if (CurrentRecipe.ConfigItems.Where(x => x.Name == "BoatTotalSlot").Count() > 0) { ((NumParam)CurrentRecipe.ConfigItems.Where(x => x.Name == "BoatTotalSlot").FirstOrDefault()).Value = BoatTotalSlot; } if (CurrentRecipe.ConfigItems.Where(x => x.DisplayName == "UpperSDNum").Count() > 0) { ((NumParam)CurrentRecipe.ConfigItems.Where(x => x.Name == "UpperSDNum").FirstOrDefault()).Value = UpperSDNum; } if (CurrentRecipe.ConfigItems.Where(x => x.Name == "ProductNum").Count() > 0) { ((NumParam)CurrentRecipe.ConfigItems.Where(x => x.Name == "ProductNum").FirstOrDefault()).Value = ProductNum; } if (CurrentRecipe.ConfigItems.Where(x => x.Name == "MonitorNum1").Count() > 0) { ((NumParam)CurrentRecipe.ConfigItems.Where(x => x.Name == "MonitorNum1").FirstOrDefault()).Value = ProductNum; } if (CurrentRecipe.ConfigItems.Where(x => x.Name == "MonitorNum2").Count() > 0) { ((NumParam)CurrentRecipe.ConfigItems.Where(x => x.Name == "MonitorNum2").FirstOrDefault()).Value = ProductNum; } if (CurrentRecipe.ConfigItems.Where(x => x.Name == "LowerSDNum").Count() > 0) { ((NumParam)CurrentRecipe.ConfigItems.Where(x => x.Name == "LowerSDNum").FirstOrDefault()).Value = LowerSDNum; } } if (CurrentRecipe.ConfigItems.Where(x => x.Name == "TopSlotNo").Count() > 0) { ((NumParam)CurrentRecipe.ConfigItems.Where(x => x.Name == "TopSlotNo").FirstOrDefault()).Value = TopSlotNo; } if (CurrentRecipe.ConfigItems.Where(x => x.Name == "UpperSideDummyNum").Count() > 0) { ((NumParam)CurrentRecipe.ConfigItems.Where(x => x.Name == "UpperSideDummyNum").FirstOrDefault()).Value = UpperSideDummyNum; } if (CurrentRecipe.ConfigItems.Where(x => x.Name == "BoatMapDecisionMethod").Count() > 0) { // IsDispTypeEnabled = ((NumParam)CurrentRecipe.ConfigItems.Where(x => x.Name == "BoatMapDecisionMethod").FirstOrDefault()).Value == 0 ? true : false; } if (CurrentRecipe.ConfigItems.Where(x => x.Name == "LowerSideDummyNum").Count() > 0) { ((NumParam)CurrentRecipe.ConfigItems.Where(x => x.Name == "LowerSideDummyNum").FirstOrDefault()).Value = LowerSideDummyNum; } if (CurrentRecipe.ConfigItems.Where(x => x.Name == "ProductAndFill").Count() > 0) { ((StringParam)CurrentRecipe.ConfigItems.Where(x => x.Name == "ProductAndFill").FirstOrDefault()).Value = TotalWaferNumber.ToString(); } if (CurrentRecipe.ConfigItems.Where(x => x.Name == "ProductAndFillValue").Count() > 0) { ((StringParam)CurrentRecipe.ConfigItems.Where(x => x.Name == "ProductAndFillValue").FirstOrDefault()).Value = TotalWaferNumberValue; } if (CurrentRecipe.ConfigItems.Where(x => x.Name == "WaferSupplement").Count() > 0) { ((StringParam)CurrentRecipe.ConfigItems.Where(x => x.Name == "WaferSupplement").FirstOrDefault()).Value = SetLayoutReplacement.ToString(); } if (CurrentRecipe.ConfigItems.Where(x => x.Name == "WaferSupplementValue").Count() > 0) { ((StringParam)CurrentRecipe.ConfigItems.Where(x => x.Name == "WaferSupplementValue").FirstOrDefault()).Value = SetLayoutReplacementValue; } if (CurrentRecipe.ConfigItems.Where(x => x.Name == "WaferChargeMonitor1").Count() > 0) { ((StringParam)CurrentRecipe.ConfigItems.Where(x => x.Name == "WaferChargeMonitor1").FirstOrDefault()).Value = WaferChargeMonitor1.ToString(); } if (CurrentRecipe.ConfigItems.Where(x => x.Name == "WaferChargeMonitorValue1").Count() > 0) { ((StringParam)CurrentRecipe.ConfigItems.Where(x => x.Name == "WaferChargeMonitorValue1").FirstOrDefault()).Value = WaferChargeMonitorValue1; } if (CurrentRecipe.ConfigItems.Where(x => x.Name == "WaferChargeMonitor2").Count() > 0) { ((StringParam)CurrentRecipe.ConfigItems.Where(x => x.Name == "WaferChargeMonitor2").FirstOrDefault()).Value = WaferChargeMonitor2.ToString(); } if (CurrentRecipe.ConfigItems.Where(x => x.Name == "WaferChargeMonitorValue2").Count() > 0) { ((StringParam)CurrentRecipe.ConfigItems.Where(x => x.Name == "WaferChargeMonitorValue2").FirstOrDefault()).Value = WaferChargeMonitorValue2; } if (CurrentRecipe.ConfigItems.Where(x => x.Name == "FillDummyTransfer").Count() > 0) { ((StringParam)CurrentRecipe.ConfigItems.Where(x => x.Name == "FillDummyTransfer").FirstOrDefault()).Value = FillDummyTransferStr; } if (CurrentRecipe.ConfigItems.Where(x => x.Name == "ProductZeroNotFill").Count() > 0) { ((StringParam)CurrentRecipe.ConfigItems.Where(x => x.Name == "ProductZeroNotFill").FirstOrDefault()).Value = ProductZeroStr; } if (CurrentRecipe.ConfigItems.Where(x => x.Name == "ProductTransferPosition").Count() > 0) { ((StringParam)CurrentRecipe.ConfigItems.Where(x => x.Name == "ProductTransferPosition").FirstOrDefault()).Value = ProductTransferStr; } if (CurrentRecipe.ConfigItems.Where(x => x.Name == "WaferDischargeMonitor1").Count() > 0) { ((StringParam)CurrentRecipe.ConfigItems.Where(x => x.Name == "WaferDischargeMonitor1").FirstOrDefault()).Value = DialogResultmonitor1.ToString(); } if (CurrentRecipe.ConfigItems.Where(x => x.Name == "WaferDischargeMonitor2").Count() > 0) { ((StringParam)CurrentRecipe.ConfigItems.Where(x => x.Name == "WaferDischargeMonitor2").FirstOrDefault()).Value = DialogResultmonitor2.ToString(); } } public void EndEdit() { RecipePermissionSelectViewModel dialog = new RecipePermissionSelectViewModel("Save recipe and permission", "",CurrentRecipe.Description); WindowManager wm = new WindowManager(); bool? dialogReturn = wm.ShowDialog(dialog); if (!dialogReturn.HasValue || !dialogReturn.Value) return; if (string.IsNullOrEmpty(CurrentRecipe.NormalSteps[0].DummyLowerSlot)) { DialogBox.ShowWarning("DummyLowerSlot is empty,can not save!"); return; } if (string.IsNullOrEmpty(CurrentRecipe.NormalSteps[0].DummyUpperSlot)) { DialogBox.ShowWarning("DummyUpperSlot is empty,can not save!"); return; } if (string.IsNullOrEmpty(CurrentRecipe.NormalSteps[0].CenteringSlotPosition)) { DialogBox.ShowWarning("CenteringSlotPosition is empty,can not save!"); return; } //if (string.IsNullOrEmpty(CurrentRecipe.NormalSteps[0].Pitch)) //{ // DialogBox.ShowWarning("Pitch is empty,can not save!"); // return; //} if (string.IsNullOrEmpty(CurrentRecipe.NormalSteps[0].ProductPosition)) { DialogBox.ShowWarning("ProductPosition is empty,can not save!"); return; } if (string.IsNullOrEmpty(CurrentRecipe.NormalSteps[0].MonitorPosition)) { DialogBox.ShowWarning("MonitorPosition is empty,can not save!"); return; } if (string.IsNullOrEmpty(CurrentRecipe.NormalSteps[0].WhenCassetteInBatchAreShort)) { DialogBox.ShowWarning("WhenCassetteInBatchAreShort is empty,can not save!"); return; } if (string.IsNullOrEmpty(CurrentRecipe.NormalSteps[0].WhenPWaferShort)) { DialogBox.ShowWarning("WhenPWaferShort is empty,can not save!"); return; } if (string.IsNullOrEmpty(CurrentRecipe.NormalSteps[0].WhenWaferInCassetteAreShort)) { DialogBox.ShowWarning("WhenWaferInCassetteAreShort is empty,can not save!"); return; } if (string.IsNullOrEmpty(CurrentRecipe.NormalSteps[0].WhenEDAreShort)) { DialogBox.ShowWarning("WhenEDAreShort is empty,can not save!"); return; } if (string.IsNullOrEmpty(CurrentRecipe.NormalSteps[0].SDRule)) { DialogBox.ShowWarning("SDRule is empty,can not save!"); return; } if (string.IsNullOrEmpty(CurrentRecipe.NormalSteps[0].RuleOfSpaceInBoat)) { DialogBox.ShowWarning("RuleOfSpaceInBoat is empty,can not save!"); return; } CurrentRecipe.IsSavedDesc = false; this.CurrentRecipe.Revisor = BaseApp.Instance.UserContext.LoginName; this.CurrentRecipe.ReviseTime = DateTime.Now; this.CurrentRecipe.RecipeLevel = this.LevelDisplay; this.CurrentRecipe.Description = dialog.RecipeComment; 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(); } public void EditModeSelectClick(string cmd) { switch (cmd) { case "Before": SetBeforeEdit(); break; case "After": SetAfterEdit(); break; default: break; } } private void SetBeforeEdit() { } private void SetAfterEdit() { } private Visibility _istBoatMapLogicalVisibility; public Visibility IstBoatMapLogicalVisibility { get => _istBoatMapLogicalVisibility; set { _istBoatMapLogicalVisibility = value; NotifyOfPropertyChange(nameof(IstBoatMapLogicalVisibility)); } } private Visibility _istBoatMapDirectVisibility = Visibility.Hidden; public Visibility IstBoatMapDirectVisibility { get => _istBoatMapDirectVisibility; set { _istBoatMapDirectVisibility = value; NotifyOfPropertyChange(nameof(IstBoatMapDirectVisibility)); } } private bool _isDispTypeEnabled = true; public bool IsDispTypeEnabled { get => _isDispTypeEnabled; set { _isDispTypeEnabled = value; NotifyOfPropertyChange(nameof(IsDispTypeEnabled)); } } private void SetBoatMapLogical() { IstBoatMapLogicalVisibility = Visibility.Visible; IstBoatMapDirectVisibility = Visibility.Hidden; IsDispTypeEnabled = true; } private void SetBoatMapDirect() { IstBoatMapLogicalVisibility = Visibility.Hidden; IstBoatMapDirectVisibility = Visibility.Visible; IsDispTypeEnabled = false; } public void BoatMapSelectClick(string cmd) { switch (cmd) { case "Logical": SetBoatMapLogical(); break; case "Direct": SetBoatMapDirect(); break; default: break; } } private Visibility _istDispTypeToNumber; public Visibility IstDispTypeToNumber { get => _istDispTypeToNumber; set { _istDispTypeToNumber = value; NotifyOfPropertyChange(nameof(IstDispTypeToNumber)); } } private Visibility _istDispTypeToMap; public Visibility IstDispTypeToMap { get => _istDispTypeToMap; set { _istDispTypeToMap = value; NotifyOfPropertyChange(nameof(IstDispTypeToMap)); } } private Visibility _istDispTypeToCarrier; public Visibility IstDispTypeToCarrier { get => _istDispTypeToCarrier; set { _istDispTypeToCarrier = value; NotifyOfPropertyChange(nameof(IstDispTypeToCarrier)); } } private void SetDispTypeToNumber() { IstDispTypeToNumber = Visibility.Visible; IstDispTypeToMap = Visibility.Hidden; IstDispTypeToCarrier = Visibility.Hidden; } private void SetDispTypeToMap() { IstDispTypeToNumber = Visibility.Hidden; IstDispTypeToMap = Visibility.Visible; IstDispTypeToCarrier = Visibility.Hidden; } private void SetDispTypeToCarrier() { IstDispTypeToNumber = Visibility.Hidden; IstDispTypeToMap = Visibility.Hidden; IstDispTypeToCarrier = Visibility.Visible; } public void DispTypeSelectClick(string cmd) { switch (cmd) { case "Number": SetDispTypeToNumber(); break; case "Map": SetDispTypeToMap(); break; case "Carrier": SetDispTypeToCarrier(); break; default: break; } } } }