RecipeLayoutExpertEditViewModel.cs 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289
  1. using Caliburn.Micro;
  2. using MECF.Framework.Common.DataCenter;
  3. using MECF.Framework.UI.Client.CenterViews.Editors.Recipe;
  4. using MECF.Framework.UI.Client.ClientBase;
  5. using OpenSEMI.ClientBase;
  6. using System;
  7. using System.Collections.Generic;
  8. using System.Linq;
  9. using System.Text;
  10. using System.Threading.Tasks;
  11. using System.Windows;
  12. using System.Windows.Media;
  13. using FurnaceUI.Models;
  14. using FurnaceUI.Views.Editors;
  15. namespace FurnaceUI.Views.Recipes
  16. {
  17. public class RecipeLayoutExpertEditViewModel : FurnaceUIViewModelBase
  18. {
  19. #region properties
  20. public int FoupListMaxValue { get; set; }
  21. private int waferNumberP;
  22. public int WaferNumberP { get { return waferNumberP; } set { waferNumberP = value; NotifyOfPropertyChange(nameof(waferNumberP)); } }
  23. private int waferNumberXD;
  24. public int WaferNumberXD { get { return waferNumberXD; } set { waferNumberXD = value; NotifyOfPropertyChange(nameof(waferNumberXD)); } }
  25. private int waferNumberT;
  26. public int WaferNumberT { get { return waferNumberT; } set { waferNumberT = value; NotifyOfPropertyChange(nameof(waferNumberT)); } }
  27. private int currentItemIndex;
  28. private string SelectedSlotType { get; set; }
  29. public int CurrentItemIndex
  30. {
  31. get { return currentItemIndex; }
  32. set { currentItemIndex = value; SelecteSlot(); this.NotifyOfPropertyChange(nameof(CurrentItemIndex)); }
  33. }
  34. private RecipeProvider _recipeProvider = new RecipeProvider();
  35. private SolidColorBrush _DefaultdBk = new SolidColorBrush(Colors.White);
  36. private SolidColorBrush _PBk = new SolidColorBrush(Colors.SkyBlue);
  37. private SolidColorBrush _SDBk = new SolidColorBrush(Colors.White);
  38. private SolidColorBrush _EDBk = new SolidColorBrush(Colors.Yellow);
  39. private SolidColorBrush _MBk = new SolidColorBrush(Colors.Pink);
  40. private SolidColorBrush _XDBk = new SolidColorBrush(Colors.White);
  41. private SolidColorBrush _TBk = new SolidColorBrush(Colors.DarkGreen);
  42. #endregion
  43. public RecipeDataLayout CurrentRecipe { get; set; } = new RecipeDataLayout();
  44. public RecipeLayoutEntityNormal NormalEntity { get { return CurrentRecipe.NormalSteps[0]; } set { CurrentRecipe.NormalSteps[0] = value; this.NotifyOfPropertyChange(nameof(NormalEntity)); } }
  45. public List<BoatWaferItem> BoatWafers { get { return CurrentRecipe.ExpertSteps[0].Items; } set { CurrentRecipe.ExpertSteps[0].Items = value; } }
  46. private bool _IsStandardPitchEnabled = true;
  47. public bool IsStandardPitchEnabled
  48. {
  49. get => _IsStandardPitchEnabled;
  50. set
  51. {
  52. _IsStandardPitchEnabled = value;
  53. NotifyOfPropertyChange(nameof(IsStandardPitchEnabled));
  54. }
  55. }
  56. private bool _IsDoublePitchEnabled;
  57. public bool IsDoublePitchEnabled
  58. {
  59. get => _IsDoublePitchEnabled;
  60. set
  61. {
  62. _IsDoublePitchEnabled = value;
  63. NotifyOfPropertyChange(nameof(IsDoublePitchEnabled));
  64. }
  65. }
  66. private bool _IsTriplePitchEnabled;
  67. public bool IsTriplePitchEnabled
  68. {
  69. get => _IsTriplePitchEnabled;
  70. set
  71. {
  72. _IsTriplePitchEnabled = value;
  73. NotifyOfPropertyChange(nameof(IsTriplePitchEnabled));
  74. }
  75. }
  76. public int index;
  77. public bool IsEnable => CGlobal.RecipeLayoutEditViewEnable;//是否是View模式
  78. private int _cassetteSlotCount;
  79. public List<string> WaferIndex { get; set; } = new List<string>();
  80. public RecipeLayoutExpertEditViewModel(string strPrefixPath, string strName, string permission = "")
  81. {
  82. FoupListMaxValue = (int)QueryDataClient.Instance.Service.GetConfig("Boat.SlotCount");
  83. _cassetteSlotCount = (int)QueryDataClient.Instance.Service.GetConfig("System.CassetteSlotCount");
  84. bool IsStandardPitchChecked = (bool)QueryDataClient.Instance.Service.GetConfig("PM1.RecipeEditParameter.LayoutPitch.StandardPitch");
  85. bool IsDoublePitchChecked = (bool)QueryDataClient.Instance.Service.GetConfig("PM1.RecipeEditParameter.LayoutPitch.DoublePitch");
  86. bool IsTriplePitchChecked = (bool)QueryDataClient.Instance.Service.GetConfig("PM1.RecipeEditParameter.LayoutPitch.TriplePitch");
  87. IsDoublePitchEnabled = IsDoublePitchChecked;
  88. IsTriplePitchEnabled = IsTriplePitchChecked;
  89. LoadData(strPrefixPath, strName, permission);
  90. }
  91. private void LoadData(string strPrefixPath, string strName, string permission)
  92. {
  93. CurrentRecipe.Clear();
  94. CurrentRecipe.PrefixPath = strPrefixPath;
  95. CurrentRecipe.Name = strName;
  96. CurrentRecipe.RecipePermission = permission;
  97. var recipeContent = _recipeProvider.LoadRecipe(strPrefixPath, strName);
  98. if (string.IsNullOrEmpty(recipeContent))
  99. {
  100. System.Windows.MessageBox.Show($"{CurrentRecipe.PrefixPath}\\{CurrentRecipe.Name} is empty, please confirm the file is valid.");
  101. return;
  102. }
  103. CurrentRecipe.RecipeChamberType = "OriginChamber";
  104. CurrentRecipe.InitData(CurrentRecipe.PrefixPath, CurrentRecipe.Name, recipeContent, CurrentRecipe.Configs, "PM1");
  105. if (CurrentRecipe.ExpertSteps.Count == 0 || CurrentRecipe.ExpertSteps[0].Items.Count <= 0)
  106. {
  107. RecipeLayoutEntityExpert expert = new RecipeLayoutEntityExpert();
  108. CurrentRecipe.ExpertSteps.Add(expert);
  109. for (int i = 0; i < FoupListMaxValue; i++)
  110. {
  111. BoatWaferItem item = new BoatWaferItem() { Slot = i + 1, Description = $"" };
  112. CurrentRecipe.ExpertSteps[0].Items.Add(item);
  113. }
  114. }
  115. if (CurrentRecipe.NormalSteps.Count == 0 || CurrentRecipe.ExpertSteps[0].Items.Count <= 0)
  116. {
  117. RecipeLayoutEntityNormal normal = new RecipeLayoutEntityNormal();
  118. CurrentRecipe.NormalSteps.Add(normal);
  119. }
  120. }
  121. protected override void OnActivate()
  122. {
  123. base.OnActivate();
  124. RefreshBoatWafers();
  125. }
  126. public void SelecteSlot()
  127. {
  128. switch (SelectedSlotType)
  129. {
  130. case "T":
  131. NormalEntity.ProductSlotNo = ProccessSlotNoPositionString("Add", NormalEntity.ProductSlotNo, currentItemIndex);
  132. NormalEntity.Monitor1SlotNo = ProccessSlotNoPositionString("Delete", NormalEntity.Monitor1SlotNo, currentItemIndex);
  133. break;
  134. case "XD":
  135. NormalEntity.Monitor1SlotNo = ProccessSlotNoPositionString("Add", NormalEntity.Monitor1SlotNo, currentItemIndex);
  136. NormalEntity.ProductSlotNo = ProccessSlotNoPositionString("Delete", NormalEntity.ProductSlotNo, currentItemIndex);
  137. break;
  138. case "Space":
  139. NormalEntity.ProductSlotNo = ProccessSlotNoPositionString("Delete", NormalEntity.ProductSlotNo, currentItemIndex);
  140. NormalEntity.Monitor1SlotNo = ProccessSlotNoPositionString("Delete", NormalEntity.Monitor1SlotNo, currentItemIndex);
  141. break;
  142. }
  143. this.RefreshBoatWafers();
  144. }
  145. public void SetCommand(object obj)
  146. {
  147. WindowManager wm = new WindowManager();
  148. switch (obj.ToString())
  149. {
  150. case "All Dummy":
  151. NormalEntity.DummyUpperSlot = "170";
  152. SelectedSlotType = obj.ToString();
  153. break;
  154. case "All Clear":
  155. NormalEntity = new RecipeLayoutEntityNormal()
  156. {
  157. WhenPWaferShort = NormalEntity.WhenPWaferShort,
  158. SDRule = NormalEntity.SDRule,
  159. WhenCassetteInBatchAreShort = NormalEntity.WhenCassetteInBatchAreShort,
  160. WhenWaferInCassetteAreShort = NormalEntity.WhenWaferInCassetteAreShort,
  161. WhenEDAreShort = NormalEntity.WhenEDAreShort,
  162. RuleOfSpaceInBoat = NormalEntity.RuleOfSpaceInBoat,
  163. };
  164. foreach (var item in BoatWafers)
  165. {
  166. item.Description = "";
  167. }
  168. SelectedSlotType = obj.ToString();
  169. break;
  170. case "T":
  171. NormalEntity.DummyUpperSlot = "";
  172. SelectedSlotType = obj.ToString();
  173. break;
  174. case "XD":
  175. NormalEntity.DummyUpperSlot = "";
  176. SelectedSlotType = obj.ToString();
  177. break;
  178. case "Space":
  179. NormalEntity.DummyUpperSlot = "";
  180. SelectedSlotType = obj.ToString();
  181. break;
  182. }
  183. this.RefreshBoatWafers();
  184. }
  185. private string ProccessSlotNoPositionString(string strType, string str, int iCurrentItemIndex)
  186. {
  187. string strRet = "";
  188. if (iCurrentItemIndex <= 0) return strRet;
  189. string strOrgTemp = "," + str;
  190. string strDesTemp = "," + iCurrentItemIndex;
  191. string strComTemp = "," + iCurrentItemIndex + ",";
  192. if (strType == "Add")
  193. {
  194. if (!strOrgTemp.Contains(strComTemp))
  195. strOrgTemp = strOrgTemp + strDesTemp;
  196. }
  197. else
  198. {
  199. if (strOrgTemp.Contains(strDesTemp))
  200. strOrgTemp = (strOrgTemp + ",").Replace(strComTemp, ",").TrimEnd(',');
  201. }
  202. strRet = strOrgTemp;
  203. for (int i = 0; i < 2; i++)
  204. {
  205. if (strRet.StartsWith(","))
  206. strRet = strRet.Substring(1);
  207. }
  208. return strRet;
  209. }
  210. public void RefreshBoatWafers()
  211. {
  212. List<string> listWafers = QueryDataClient.Instance.Service.GetLayoutExpertRecipeContent(CurrentRecipe.GetXmlString(), FoupListMaxValue.ToString(), _cassetteSlotCount.ToString());
  213. WaferNumberT = WaferNumberXD = 0;
  214. if (listWafers.Count <= 0 || (CurrentRecipe.ExpertSteps.Count <= 0 && CurrentRecipe.NormalSteps.Count <= 0)) return;
  215. CurrentRecipe.NormalSteps[0].ProductSlotNo = string.Empty;
  216. CurrentRecipe.NormalSteps[0].Monitor1SlotNo = string.Empty;
  217. for (int i = 0; i < listWafers.Count; i++)
  218. {
  219. CurrentRecipe.ExpertSteps[0].Items[i].Slot = i + 1;
  220. CurrentRecipe.ExpertSteps[0].Items[i].Description = listWafers[i].ToString() == "" ? "----" : listWafers[i].ToString();
  221. switch (listWafers[i].ToString())
  222. {
  223. case "XD":
  224. CurrentRecipe.NormalSteps[0].Monitor1SlotNo = ProccessSlotNoPositionString("Add", CurrentRecipe.NormalSteps[0].Monitor1SlotNo, i + 1);
  225. CurrentRecipe.ExpertSteps[0].Items[i].BkColor = _DefaultdBk;
  226. WaferNumberXD++;
  227. break;
  228. case "T":
  229. CurrentRecipe.NormalSteps[0].ProductSlotNo = ProccessSlotNoPositionString("Add", CurrentRecipe.NormalSteps[0].ProductSlotNo, i + 1);
  230. CurrentRecipe.ExpertSteps[0].Items[i].BkColor = _SDBk;
  231. WaferNumberT++;
  232. break;
  233. default:
  234. CurrentRecipe.ExpertSteps[0].Items[i].BkColor = _DefaultdBk;
  235. break;
  236. }
  237. }
  238. }
  239. public void EndEdit()
  240. {
  241. RecipePermissionSelectViewModel dialog = new RecipePermissionSelectViewModel("Save recipe and permission", CurrentRecipe.RecipePermission);
  242. WindowManager wm = new WindowManager();
  243. bool? dialogReturn = wm.ShowDialog(dialog);
  244. if (!dialogReturn.HasValue || !dialogReturn.Value)
  245. return;
  246. CurrentRecipe.IsSavedDesc = false;
  247. this.CurrentRecipe.Revisor = BaseApp.Instance.UserContext.LoginName;
  248. this.CurrentRecipe.ReviseTime = DateTime.Now;
  249. this.CurrentRecipe.RecipeLevel = this.LevelDisplay;
  250. this.CurrentRecipe.RecipePermission = dialog.RecipePermission;
  251. this._recipeProvider.SaveRecipe(CurrentRecipe.PrefixPath, CurrentRecipe.Name, CurrentRecipe.GetXmlString());
  252. ((Window)GetView()).DialogResult = true;
  253. }
  254. public void Cancel()
  255. {
  256. if (DialogBox.ShowDialog(DialogButton.Yes | DialogButton.No, DialogType.CONFIRM, " You confirm that you want to unsave the recipe and exit the interface?") == DialogButton.No)
  257. return;
  258. ((Window)GetView()).Close();
  259. }
  260. }
  261. }