123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289 |
- 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<BoatWaferItem> 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<string> WaferIndex { get; set; } = new List<string>();
- 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<string> 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();
- }
- }
- }
|