RecipeViewModel.cs 71 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552
  1. using Aitex.Core.Common.DeviceData;
  2. using Aitex.Core.RT.Log;
  3. using Aitex.Core.UI.View.Common;
  4. using MECF.Framework.Common.DataCenter;
  5. using MECF.Framework.Common.OperationCenter;
  6. using Microsoft.VisualBasic;
  7. using Newtonsoft.Json;
  8. using Prism.Commands;
  9. using Prism.Mvvm;
  10. using System;
  11. using System.Collections;
  12. using System.Collections.Generic;
  13. using System.IO;
  14. using System.Linq;
  15. using System.Reflection;
  16. using System.Text;
  17. using System.Threading;
  18. using System.Windows;
  19. using System.Windows.Controls;
  20. using System.Windows.Data;
  21. using System.Windows.Input;
  22. using System.Windows.Media;
  23. using System.Xml;
  24. using Venus_Core;
  25. using Venus_Core.Attributes;
  26. using Venus_MainPages.PMs;
  27. using Venus_MainPages.Unity;
  28. using Venus_MainPages.Views;
  29. using Venus_Themes.UserControls;
  30. using Venus_Unity;
  31. using WPF.Themes.UserControls;
  32. using RecipeStep = Venus_Core.RecipeStep;
  33. namespace Venus_MainPages.ViewModels
  34. {
  35. public enum EPDType
  36. {
  37. Socket,
  38. WCF,
  39. None
  40. }
  41. internal class RecipeViewModel : BindableBase
  42. {
  43. #region 私有字段
  44. public string ModuleName = "PMA";
  45. private string m_CurrentRecipeName;
  46. private UiRecipeManager m_uiRecipeManager = new UiRecipeManager();
  47. private RecipeView recipeView;
  48. private TreeView treeViewRcpList;
  49. private Recipe m_currentRecipe;
  50. private string m_recipeType;
  51. private bool firstLoad=true;
  52. private WrapPanel headWrapPanel;
  53. private StackPanel bodyStackPanel;
  54. private List<SolidColorBrush> solidColorBrushes = new List<SolidColorBrush>()
  55. {
  56. new SolidColorBrush(Colors.Coral),
  57. new SolidColorBrush(Colors.Cyan),
  58. new SolidColorBrush(Colors.Honeydew)
  59. };
  60. private Grid currentRecipeGrid;
  61. private int copyIndex = -1;
  62. private List<string> EPDCfgList=new List<string> ();
  63. private EPDType currentEPDType=EPDType.None;
  64. private JetChamber currentChamber;
  65. private bool isInstalledEPD;
  66. private bool m_IsFrozen;
  67. private bool m_PMAIsInstalled;
  68. private bool m_PMBIsInstalled;
  69. private bool m_PMCIsInstalled;
  70. private bool m_PMDIsInstalled;
  71. private List<string> moduleList = new List<string> ();
  72. TreeViewFileItem selectedItem;
  73. #endregion
  74. #region 属性
  75. public string CurrentRecipeName
  76. {
  77. get { return m_CurrentRecipeName; }
  78. set { SetProperty(ref m_CurrentRecipeName, value); }
  79. }
  80. public Recipe CurrentRecipe
  81. {
  82. get { return m_currentRecipe; }
  83. set
  84. {
  85. m_currentRecipe = value;
  86. RecipeType = m_currentRecipe.Header.Type.ToString();
  87. }
  88. }
  89. public string RecipeType
  90. {
  91. get { return m_recipeType; }
  92. set { SetProperty(ref m_recipeType, value); }
  93. }
  94. public bool IsFrozen
  95. {
  96. get { return m_IsFrozen; }
  97. set { SetProperty(ref m_IsFrozen, value); }
  98. }
  99. public bool PMAIsInstalled
  100. {
  101. get { return m_PMAIsInstalled; }
  102. set { SetProperty(ref m_PMAIsInstalled, value); }
  103. }
  104. public bool PMBIsInstalled
  105. {
  106. get { return m_PMBIsInstalled; }
  107. set { SetProperty(ref m_PMBIsInstalled, value); }
  108. }
  109. public bool PMCIsInstalled
  110. {
  111. get { return m_PMCIsInstalled; }
  112. set { SetProperty(ref m_PMCIsInstalled, value); }
  113. }
  114. public bool PMDIsInstalled
  115. {
  116. get { return m_PMDIsInstalled; }
  117. set { SetProperty(ref m_PMDIsInstalled, value); }
  118. }
  119. #endregion
  120. #region 命令
  121. private DelegateCommand<Object> _MouseRightButtonDownCommand;
  122. public DelegateCommand<Object> MouseRightButtonDownCommand =>
  123. _MouseRightButtonDownCommand ?? (_MouseRightButtonDownCommand = new DelegateCommand<Object>(OnMouseRightButtonDown));
  124. private DelegateCommand<Object> _LoadedCommand;
  125. public DelegateCommand<Object> LoadedCommand =>
  126. _LoadedCommand ?? (_LoadedCommand = new DelegateCommand<Object>(OnLoaded));
  127. private DelegateCommand _SaveRecipeCommand;
  128. public DelegateCommand SaveRecipeCommand =>
  129. _SaveRecipeCommand ?? (_SaveRecipeCommand = new DelegateCommand(OnSaveRecipe));
  130. private DelegateCommand<object> _SaveToRecipeCommand;
  131. public DelegateCommand<object> SaveToRecipeCommand =>
  132. _SaveToRecipeCommand ?? (_SaveToRecipeCommand = new DelegateCommand<object>(OnSaveToRecipe));
  133. private DelegateCommand _AddStepCommand;
  134. public DelegateCommand AddStepCommand =>
  135. _AddStepCommand ?? (_AddStepCommand = new DelegateCommand(OnAddStep));
  136. private DelegateCommand _DeleteStepCommand;
  137. public DelegateCommand DeleteStepCommand =>
  138. _DeleteStepCommand ?? (_DeleteStepCommand = new DelegateCommand(OnDeleteStep));
  139. private DelegateCommand _RefreshCommand;
  140. public DelegateCommand RefreshCommand =>
  141. _RefreshCommand ?? (_RefreshCommand = new DelegateCommand(OnRefresh));
  142. private DelegateCommand _ToleranceCommand;
  143. public DelegateCommand ToleranceCommand =>
  144. _ToleranceCommand ?? (_ToleranceCommand = new DelegateCommand(OnTolerance));
  145. #endregion
  146. #region 命令方法
  147. private void OnAddStep()
  148. {
  149. if (CurrentRecipe != null)
  150. {
  151. var index = currentRecipeGrid.ColumnDefinitions.Count;
  152. RecipeStep recipeStep;
  153. if (copyIndex == -1)
  154. {
  155. recipeStep = new RecipeStep();
  156. recipeStep.LstUnit = RecipeUnity.GetAllUnits(currentChamber,CurrentRecipe.Header.Type);
  157. //switch (currentChamber)
  158. //{
  159. // case JetChamber.Venus:
  160. // recipeStep.LstUnit.Add(new PressureByPressureModeUnit());
  161. // recipeStep.LstUnit.Add(new TCPUnit());
  162. // recipeStep.LstUnit.Add(new BiasUnit());
  163. // recipeStep.LstUnit.Add(new GasControlUnit());
  164. // recipeStep.LstUnit.Add(new ESCHVUnit());
  165. // recipeStep.LstUnit.Add(new ProcessKitUnit());
  166. // break;
  167. // case JetChamber.Kepler2300:
  168. // recipeStep.LstUnit.Add(new PressureByPressureModeUnit());
  169. // recipeStep.LstUnit.Add(new TCPUnit());
  170. // recipeStep.LstUnit.Add(new BiasUnit());
  171. // recipeStep.LstUnit.Add(new GasControlUnit());
  172. // recipeStep.LstUnit.Add(new ProcessKitUnit());
  173. // break;
  174. // case JetChamber.Kepler2200A:
  175. // recipeStep.LstUnit.Add(new Kepler2200GasControlUnit());
  176. // recipeStep.LstUnit.Add(new HeaterUnit());
  177. // recipeStep.LstUnit.Add(new Kepler2200RFUnit());
  178. // break;
  179. //}
  180. CurrentRecipe.Steps.Insert(index - 1, recipeStep);
  181. }
  182. else
  183. {
  184. var t = JsonConvert.SerializeObject(CurrentRecipe);
  185. recipeStep = Recipe.Load(t).Steps[copyIndex - 1];
  186. CurrentRecipe.Steps.Insert(index - 1, recipeStep);
  187. }
  188. RecipeStepToGridColumn(recipeStep, currentRecipeGrid, index, true);
  189. for (int i = 1; i <= CurrentRecipe.Steps.Count; i++)
  190. {
  191. CurrentRecipe.Steps[i - 1].StepNo = i;
  192. }
  193. }
  194. }
  195. private void OnDeleteStep()
  196. {
  197. if (CurrentRecipe != null)
  198. {
  199. OnDeleteStep(CurrentRecipe.Steps.Count - 1);
  200. }
  201. }
  202. private void OnSaveRecipe()
  203. {
  204. CurrentRecipe.Header.EditTime = DateTime.Now.ToString();
  205. SaveRecipe(CurrentRecipeName, RecipeUnity.RecipeToString(CurrentRecipe));
  206. LoadHeadWrapPanel(headWrapPanel, CurrentRecipe);
  207. }
  208. private void OnSaveToRecipe(object obj)
  209. {
  210. if (CurrentRecipe == null)
  211. {
  212. return;
  213. }
  214. //JetChamber jetChamber = JetChamber.None;
  215. string moduleName = "";
  216. switch (obj.ToString())
  217. {
  218. case "0":
  219. moduleName = "PMA";
  220. break;
  221. case "1":
  222. moduleName = "PMB";
  223. break;
  224. case "2":
  225. moduleName = "PMC";
  226. break;
  227. case "3":
  228. moduleName = "PMD";
  229. break;
  230. case "4":
  231. moduleName = "ALL";
  232. break;
  233. }
  234. if (moduleName == "")
  235. {
  236. return;
  237. }
  238. if (moduleName == "ALL")
  239. {
  240. var newName = Interaction.InputBox(" ", $"Save Recipe To All", CurrentRecipeName, -1, -1);
  241. foreach (var x in moduleList)
  242. {
  243. if (newName != "")
  244. {
  245. var targetChamber = (JetChamber)Enum.Parse(typeof(JetChamber), QueryDataClient.Instance.Service.GetConfig($"{x}.ChamberType").ToString());
  246. if (currentChamber != targetChamber || x== ModuleName)
  247. {
  248. continue;
  249. }
  250. var newRecipe = CurrentRecipe;
  251. newRecipe.Header.Name = newName;
  252. newRecipe.Header.CreateTime = DateTime.Now.ToString();
  253. var newrecipePath = Path.Combine(QueryDataClient.Instance.Service.GetData("GetRTPath").ToString(), "Recipes", x, newName + ".rcp");
  254. File.WriteAllText(newrecipePath, RecipeUnity.RecipeToString(newRecipe));
  255. UpdateRecipeFileList();
  256. }
  257. }
  258. //moduleList.ForEach(x =>
  259. //{
  260. //});
  261. }
  262. else
  263. {
  264. var targetChamber = (JetChamber)Enum.Parse(typeof(JetChamber), QueryDataClient.Instance.Service.GetConfig($"{moduleName}.ChamberType").ToString());
  265. if (currentChamber != targetChamber)
  266. {
  267. WPFMessageBox.ShowError($"Recipe can not from {currentChamber.ToString()} copy to {targetChamber.ToString()}");
  268. return;
  269. }
  270. var newName = Interaction.InputBox(" ", $"Save Recipe To {moduleName}", CurrentRecipeName, -1, -1);
  271. if (newName != "")
  272. {
  273. var newRecipe = CurrentRecipe;
  274. newRecipe.Header.Name = newName;
  275. newRecipe.Header.CreateTime = DateTime.Now.ToString();
  276. var newrecipePath = Path.Combine(QueryDataClient.Instance.Service.GetData("GetRTPath").ToString(), "Recipes", moduleName, newName + ".rcp");
  277. File.WriteAllText(newrecipePath, RecipeUnity.RecipeToString(newRecipe));
  278. UpdateRecipeFileList();
  279. }
  280. }
  281. }
  282. private void OnLoaded(Object myrecipeView)
  283. {
  284. if (firstLoad == true)
  285. {
  286. currentChamber = (JetChamber)Enum.Parse(typeof(JetChamber), QueryDataClient.Instance.Service.GetConfig($"{ModuleName}.ChamberType").ToString());
  287. isInstalledEPD = bool.Parse(QueryDataClient.Instance.Service.GetConfig($"{ModuleName}.EPD.IsEnabled").ToString()) ;
  288. firstLoad = false;
  289. recipeView = myrecipeView as RecipeView;
  290. treeViewRcpList = recipeView.treeViewRcpList;
  291. headWrapPanel = recipeView.headWrapPanel;
  292. bodyStackPanel = recipeView.bodyStackPanel;
  293. UpdateRecipeFileList();
  294. treeViewRcpList.SelectedItemChanged += TreeViewRcpList_SelectedItemChanged;
  295. //DispatcherTimer timer = new DispatcherTimer();
  296. //timer.Interval = TimeSpan.FromSeconds(1);
  297. //timer.Tick += Timer_Tick; ;
  298. //timer.Start();
  299. for (int i = 0; i < 5; i++)
  300. {
  301. InvokeClient.Instance.Service.DoOperation($"{ModuleName}.EndPoint.SearchCfg");
  302. Thread.Sleep(200);
  303. currentEPDType = (EPDType)System.Convert.ToInt32(QueryDataClient.Instance.Service.GetConfig($"{ModuleName}.EPD.EPDType"));
  304. if (currentEPDType == EPDType.Socket)
  305. {
  306. EPDCfgList = (List<string>)QueryDataClient.Instance.Service.GetData($"{ModuleName}.EPDCfgList");
  307. }
  308. if (EPDCfgList != null)
  309. {
  310. break;
  311. }
  312. }
  313. string allModules = QueryDataClient.Instance.Service.GetConfig($"System.InstalledModules").ToString();
  314. if (allModules.Contains("PMA"))
  315. {
  316. PMAIsInstalled = true;
  317. moduleList.Add("PMA");
  318. }
  319. if (allModules.Contains("PMB"))
  320. {
  321. PMBIsInstalled = true;
  322. moduleList.Add("PMB");
  323. }
  324. if (allModules.Contains("PMC"))
  325. {
  326. PMCIsInstalled = true;
  327. moduleList.Add("PMC");
  328. }
  329. if (allModules.Contains("PMD"))
  330. {
  331. PMDIsInstalled = true;
  332. moduleList.Add("PMD");
  333. }
  334. }
  335. UpdateRecipeFileList();
  336. }
  337. private void TreeViewRcpList_SelectedItemChanged(object sender, RoutedPropertyChangedEventArgs<object> e)
  338. {
  339. selectedItem = e.NewValue as TreeViewFileItem;
  340. if (selectedItem == null)
  341. return;
  342. try
  343. {
  344. CurrentRecipeName = selectedItem.FileName;
  345. string xmlRecipeData = m_uiRecipeManager.LoadRecipe(ModuleName, selectedItem.FileName);
  346. if (xmlRecipeData == "")
  347. {
  348. treeViewRcpList.Items.Remove(selectedItem);
  349. return;
  350. }
  351. CurrentRecipe = Recipe.Load(xmlRecipeData);
  352. LoadHeadWrapPanel(headWrapPanel, CurrentRecipe);
  353. LoadRecipe(CurrentRecipe);
  354. }
  355. catch (Exception ex)
  356. {
  357. MessageBox.Show(string.Format(Application.Current.Resources["GlobalLableTitleRecipeEditor"].ToString(), ex.Message), Application.Current.Resources["GlobalLableTitleRecipeEditor"].ToString(), MessageBoxButton.OK, MessageBoxImage.Error);
  358. }
  359. e.Handled = true;
  360. }
  361. public bool SaveRecipe(string recipeName, string recipeContent)
  362. {
  363. return m_uiRecipeManager.SaveRecipe(ModuleName, recipeName, recipeContent);
  364. }
  365. private void OnMouseRightButtonDown(Object treeView)
  366. {
  367. //treeViewRcpList = treeView as TreeView;
  368. treeViewRcpList.ContextMenu = new ContextMenu() { Background = new SolidColorBrush(Colors.AliceBlue)};
  369. MenuItem menuItem = new MenuItem();
  370. menuItem = new MenuItem();
  371. menuItem.Tag = "\\";
  372. menuItem.Click += new RoutedEventHandler(menuItem_MouseClick_CreateRecipe);
  373. menuItem.Header = "New Recipe";
  374. treeViewRcpList.ContextMenu.Items.Add(menuItem);
  375. menuItem = new MenuItem();
  376. menuItem.Tag = "\\";
  377. menuItem.Click += new RoutedEventHandler(menuItem_MouseClick_DeleteRecipe);
  378. menuItem.Header = "Delete Recipe";
  379. treeViewRcpList.ContextMenu.Items.Add(menuItem);
  380. menuItem = new MenuItem();
  381. menuItem.Tag = "\\";
  382. menuItem.Click += new RoutedEventHandler(menuItem_MouseClick_SaveAsRecipe);
  383. menuItem.Header = "Save As Recipe";
  384. treeViewRcpList.ContextMenu.Items.Add(menuItem);
  385. menuItem = new MenuItem();
  386. menuItem.Tag = "\\";
  387. menuItem.Click += new RoutedEventHandler(menuItem_MouseClick_RenameRecipe);
  388. menuItem.Header = "Rename";
  389. treeViewRcpList.ContextMenu.Items.Add(menuItem);
  390. treeViewRcpList.ContextMenu.Visibility = Visibility.Visible;
  391. }
  392. private void menuItem_MouseClick_CreateRecipe(object sender, RoutedEventArgs e)
  393. {
  394. MenuItem mit = sender as MenuItem;
  395. string folderName = mit.Tag as string;
  396. PerformCreateRecipe(folderName);
  397. }
  398. private void PerformCreateRecipe(string folderName)
  399. {
  400. try
  401. {
  402. bool hasHV=false;
  403. if (currentChamber == JetChamber.Venus)
  404. {
  405. hasHV = true;
  406. }
  407. RecipeNameInputDlg dlg = new RecipeNameInputDlg(Application.Current.Resources["GlobalLableMsgInputRecipeName"].ToString(),hasHV)
  408. {
  409. Owner = Application.Current.MainWindow
  410. };
  411. if (dlg.ShowDialog() == true)
  412. {
  413. var recipeName = folderName + "\\" + dlg.InputText;
  414. RecipeType type = (RecipeType)Enum.Parse(typeof(RecipeType), dlg.SelectedType);
  415. string newRecipe =RecipeUnity.CreateRecipe(currentChamber,type, dlg.InputText);
  416. //string recipeContent = m_uiRecipeManager.GetRecipeTemplate(ModuleName);
  417. //m_uiRecipeManager.SaveAsRecipe(ModuleName, recipeName, m_uiRecipeManager.LoadRecipe("system",folderName));
  418. if (SaveAsRecipe(recipeName, newRecipe))
  419. {
  420. //UpdateRecipeFileList();
  421. //SelectRecipe(recipeName);
  422. treeViewRcpList.Items.Add(new TreeViewFileItem(dlg.InputText));
  423. }
  424. else
  425. {
  426. WPFMessageBox.ShowError("Error");
  427. }
  428. }
  429. }
  430. catch (Exception ex)
  431. {
  432. LOG.WriteExeption(ex);
  433. MessageBox.Show(string.Format(Application.Current.Resources["GlobalLableMsgRecipeCreateException"].ToString(), ex.Message), Application.Current.Resources["GlobalLableTitleRecipeEditor"].ToString(), MessageBoxButton.OK, MessageBoxImage.Error);
  434. }
  435. }
  436. private void menuItem_MouseClick_DeleteRecipe(object sender, RoutedEventArgs e)
  437. {
  438. if (CurrentRecipe == null)
  439. {
  440. return;
  441. }
  442. if (WPFMessageBox.ShowQuestion($"Delete {CurrentRecipeName}?","删除后无法恢复!!!") == MessageBoxResult.Yes)
  443. {
  444. MenuItem mit = sender as MenuItem;
  445. //string recipename = mit.Header.ToString();
  446. m_uiRecipeManager.DeleteRecipe(ModuleName, CurrentRecipeName);
  447. //PerformCreateRecipe(folderName);
  448. treeViewRcpList.Items.Remove(selectedItem);
  449. }
  450. }
  451. private void menuItem_MouseClick_SaveAsRecipe(object sender, RoutedEventArgs e)
  452. {
  453. if (CurrentRecipe == null)
  454. {
  455. return;
  456. }
  457. var newName = Interaction.InputBox(" ", "Save As Recipe", CurrentRecipeName, -1, -1);
  458. if (newName != CurrentRecipeName && newName != "")
  459. {
  460. var newRecipe = CurrentRecipe;
  461. newRecipe.Header.Name = newName;
  462. newRecipe.Header.CreateTime = DateTime.Now.ToString();
  463. var newrecipePath = Path.Combine(QueryDataClient.Instance.Service.GetData("GetRTPath").ToString(), "Recipes", ModuleName, newName + ".rcp");
  464. File.WriteAllText(newrecipePath, RecipeUnity.RecipeToString(newRecipe));
  465. UpdateRecipeFileList();
  466. }
  467. }
  468. private void menuItem_MouseClick_RenameRecipe(object sender, RoutedEventArgs e)
  469. {
  470. if (CurrentRecipe == null)
  471. {
  472. return;
  473. }
  474. var newName= Interaction.InputBox(" ", "Rename Recipe", CurrentRecipeName, -1, -1);
  475. if (newName != CurrentRecipeName && newName!="")
  476. {
  477. var oldrecipePath = Path.Combine(QueryDataClient.Instance.Service.GetData("GetRTPath").ToString(), "Recipes", ModuleName, CurrentRecipeName + ".rcp");
  478. var newrecipePath = Path.Combine(QueryDataClient.Instance.Service.GetData("GetRTPath").ToString(), "Recipes", ModuleName, newName + ".rcp");
  479. CurrentRecipe.Header.Name = newName;
  480. SaveRecipe(CurrentRecipeName, RecipeUnity.RecipeToString(CurrentRecipe));
  481. File.Move(oldrecipePath, newrecipePath);
  482. UpdateRecipeFileList();
  483. }
  484. }
  485. public bool SaveAsRecipe(string recipeName, string recipeContent)
  486. {
  487. return m_uiRecipeManager.SaveAsRecipe(ModuleName, recipeName, recipeContent);
  488. }
  489. public bool SaveAsRecipe2(string recipeName,string type, string recipeContent)
  490. {
  491. return m_uiRecipeManager.SaveAsRecipe2(ModuleName,type, recipeName, recipeContent);
  492. }
  493. public string GetXmlRecipeList()
  494. {
  495. return m_uiRecipeManager.GetXmlRecipeList(ModuleName, true) ?? "";
  496. }
  497. void CreateTreeViewItems(XmlElement curElementNode, ItemsControl itemsControl)
  498. {
  499. foreach (XmlElement ele in curElementNode.ChildNodes)
  500. {
  501. if (ele.Name == "File")
  502. {
  503. string fileName = ele.Attributes["Name"].Value;
  504. fileName = fileName.Substring(fileName.LastIndexOf('\\') + 1);
  505. TreeViewFileItem item = new TreeViewFileItem(ele.Attributes["Name"].Value);
  506. item.Tag = ele.Attributes["Name"].Value;
  507. //item.ToolTip = fileName;
  508. itemsControl.Items.Add(item);
  509. }
  510. else if (ele.Name == "Folder")
  511. {
  512. string folderName = ele.Attributes["Name"].Value;
  513. folderName = folderName.Substring(folderName.LastIndexOf('\\') + 1);
  514. TreeViewFolderItem item = new TreeViewFolderItem(folderName);
  515. item.Tag = ele.Attributes["Name"].Value;
  516. CreateTreeViewItems(ele, item);
  517. item.IsExpanded = false;
  518. itemsControl.Items.Add(item);
  519. }
  520. }
  521. }
  522. private IEnumerable<string> GetFilesNames(string path)
  523. {
  524. return Directory.GetFiles(path, "*.rcp")?
  525. .Select(Path.GetFileNameWithoutExtension);
  526. }
  527. private void LoadHeadWrapPanel(WrapPanel HeadWrapPanel, Recipe recipe)
  528. {
  529. HeadWrapPanel.Children.Clear();
  530. Type type = recipe.Header.GetType();
  531. foreach (var propertyInfo in type.GetProperties())
  532. {
  533. TextBlock textBlock = new TextBlock();
  534. textBlock.FontSize = 15;
  535. //textBlock.Width = 100;
  536. switch (propertyInfo.Name)
  537. {
  538. case "ChuckRecipe":
  539. if (currentChamber != JetChamber.Venus)
  540. {
  541. continue;
  542. }
  543. textBlock.Text = "Chuck:";
  544. break;
  545. case "DechuckRecipe":
  546. if (currentChamber != JetChamber.Venus)
  547. {
  548. continue;
  549. }
  550. textBlock.Text = "DeChuck:";
  551. break;
  552. default:
  553. textBlock.Text = propertyInfo.Name + ":";
  554. break;
  555. }
  556. textBlock.Margin = new Thickness(15, 0, 0, 0);
  557. textBlock.VerticalAlignment = VerticalAlignment.Center;
  558. HeadWrapPanel.Children.Add(textBlock);
  559. Binding binding = new Binding()
  560. {
  561. Source = recipe.Header, // 数据源
  562. Path = new PropertyPath(propertyInfo.Name), // 需绑定的数据源属性名
  563. Mode = BindingMode.TwoWay, // 绑定模式
  564. UpdateSourceTrigger = UpdateSourceTrigger.PropertyChanged, //触发器
  565. };
  566. var propertyTypeName = propertyInfo.PropertyType.Name;
  567. var propertyInfoName = propertyInfo.Name;
  568. Control control = new Control();
  569. switch (propertyInfoName)
  570. {
  571. case "ChamberType":
  572. control = new ComboBox();
  573. control.Height = 23;
  574. control.SetBinding(ComboBox.SelectedItemProperty, binding);
  575. ItemsControlHelper.SetEnumValuesToItemsSource(control, true);
  576. break;
  577. case "Type":
  578. ComboBox cb = new ComboBox();
  579. cb.SelectionChanged += ChangeUI;
  580. control = cb;
  581. control.Height = 23;
  582. ItemsControlHelper.SetEnumValuesToItemsSource(control, true);
  583. control.SetBinding(ComboBox.SelectedItemProperty, binding);
  584. break;
  585. case "ChuckRecipe":
  586. if (currentChamber != JetChamber.Venus)
  587. {
  588. continue;
  589. }
  590. string[] chucklist = new string[] { "" };
  591. ArrayList arrayList = new ArrayList(chucklist.ToList());
  592. IEnumerable<string> chlist= GetFilesNames(Path.Combine(QueryDataClient.Instance.Service.GetData("GetRTPath").ToString(), "Recipes", ModuleName)).ToList().Where(item => item.ToLower().Contains("chuck") && (item.ToLower().Contains("dechuck") == false));
  593. foreach (var i in chlist)
  594. {
  595. arrayList.Add(i);
  596. }
  597. chucklist = (string[])arrayList.ToArray(typeof(string));
  598. StringBuilder stringBuilder = new StringBuilder();
  599. //输出
  600. for (int i = 0; i < chucklist.Length; i++)
  601. {
  602. stringBuilder.Append(chucklist[i] + "\t");
  603. }
  604. control = new ComboBox()
  605. {
  606. ItemsSource = chucklist
  607. };
  608. control.Height = 23;
  609. control.MinWidth = 100;
  610. control.MaxWidth = 300;
  611. control.SetBinding(ComboBox.SelectedItemProperty, binding);
  612. break;
  613. case "DechuckRecipe":
  614. if (currentChamber != JetChamber.Venus)
  615. {
  616. continue;
  617. }
  618. string[] dechucklist = new string[] { "" };
  619. ArrayList dearrayList = new ArrayList(dechucklist.ToList());
  620. IEnumerable<string> delist = GetFilesNames(Path.Combine(QueryDataClient.Instance.Service.GetData("GetRTPath").ToString(), "Recipes", ModuleName)).ToList().Where(item => item.ToLower().Contains("dechuck"));
  621. foreach (var i in delist)
  622. {
  623. dearrayList.Add(i);
  624. }
  625. dechucklist = (string[])dearrayList.ToArray(typeof(string));
  626. StringBuilder destringBuilder = new StringBuilder();
  627. for (int i = 0; i < dechucklist.Length; i++)
  628. {
  629. destringBuilder.Append(dechucklist[i] + "\t");
  630. }
  631. control = new ComboBox()
  632. {
  633. ItemsSource= dechucklist
  634. };
  635. control.Height = 23;
  636. control.MinWidth = 100;
  637. control.MaxWidth = 300;
  638. control.SetBinding(ComboBox.SelectedItemProperty, binding);
  639. break;
  640. default:
  641. control = new TextBox();
  642. control.Margin = new Thickness(1, 0, 0, 0);
  643. control.BorderThickness = new Thickness(0, 0, 0, 1);
  644. //control.BorderBrush = Brushes.Black;
  645. control.FontSize = 15;
  646. control.Foreground = Brushes.Green;
  647. control.Background = Brushes.Transparent;
  648. control.VerticalAlignment = VerticalAlignment.Center;
  649. control.MinWidth = 15;
  650. control.SetBinding(TextBox.TextProperty, binding);
  651. object[] objAttrs = propertyInfo.GetCustomAttributes(typeof(IsOnlyReadAttribute), true);
  652. if (objAttrs.Length > 0)
  653. {
  654. (control as TextBox).IsReadOnly = true;
  655. }
  656. break;
  657. }
  658. //switch (propertyTypeName)
  659. //{
  660. // case "Int32":
  661. // case "String":
  662. // control = new TextBox();
  663. // control.Margin = new Thickness(1, 0, 0, 0);
  664. // control.BorderThickness = new Thickness(0, 0, 0, 1);
  665. // //control.BorderBrush = Brushes.Black;
  666. // control.FontSize = 15;
  667. // control.Foreground = Brushes.Green;
  668. // control.Background = Brushes.Transparent;
  669. // control.VerticalAlignment = VerticalAlignment.Center;
  670. // control.MinWidth = 15;
  671. // control.SetBinding(TextBox.TextProperty, binding);
  672. // object[] objAttrs = propertyInfo.GetCustomAttributes(typeof(IsOnlyReadAttribute), true);
  673. // if (objAttrs.Length > 0)
  674. // {
  675. // (control as TextBox).IsReadOnly = true;
  676. // }
  677. // break;
  678. // case "Boolean":
  679. // control = new CheckBox();
  680. // control.SetBinding(CheckBox.IsCheckedProperty, binding);
  681. // break;
  682. // default:
  683. // control = new ComboBox();
  684. // control.Height = 23;
  685. // control.SetBinding(ComboBox.SelectedItemProperty, binding);
  686. // ItemsControlHelper.SetEnumValuesToItemsSource(control, true);
  687. // break;
  688. //}
  689. HeadWrapPanel.Children.Add(control);
  690. }
  691. }
  692. private void ChangeUI(object sender, SelectionChangedEventArgs e)
  693. {
  694. var t = sender as ComboBox;
  695. if (t.SelectedValue.ToString() != "Process")
  696. {
  697. headWrapPanel.Children[8].Visibility = Visibility.Collapsed;
  698. headWrapPanel.Children[9].Visibility = Visibility.Collapsed;
  699. headWrapPanel.Children[10].Visibility = Visibility.Collapsed;
  700. headWrapPanel.Children[11].Visibility = Visibility.Collapsed;
  701. }
  702. else
  703. {
  704. headWrapPanel.Children[8].Visibility = Visibility.Visible;
  705. headWrapPanel.Children[9].Visibility = Visibility.Visible;
  706. headWrapPanel.Children[10].Visibility = Visibility.Visible;
  707. headWrapPanel.Children[11].Visibility = Visibility.Visible;
  708. }
  709. }
  710. private void MenuItemLeftInsert_Click(object sender, RoutedEventArgs e)
  711. {
  712. var t = ((sender as MenuItem).Parent as ContextMenu).PlacementTarget as TextBox;
  713. int insertIndex = Convert.ToInt32(t.Text);
  714. if (copyIndex == -1)
  715. {
  716. var recipeStep = new RecipeStep();
  717. //switch (currentChamber)
  718. //{
  719. // case JetChamber.Venus:
  720. // case JetChamber.Kepler2300:
  721. // recipeStep.LstUnit.Add(new PressureByPressureModeUnit());
  722. // recipeStep.LstUnit.Add(new TCPUnit());
  723. // recipeStep.LstUnit.Add(new BiasUnit());
  724. // recipeStep.LstUnit.Add(new GasControlUnit());
  725. // recipeStep.LstUnit.Add(new ESCHVUnit());
  726. // recipeStep.LstUnit.Add(new ProcessKitUnit());
  727. // break;
  728. // case JetChamber.Kepler2200A:
  729. // recipeStep.LstUnit.Add(new Kepler2200GasControlUnit());
  730. // recipeStep.LstUnit.Add(new HeaterUnit());
  731. // recipeStep.LstUnit.Add(new Kepler2200RFUnit());
  732. // break;
  733. //}
  734. recipeStep.LstUnit = RecipeUnity.GetAllUnits(currentChamber, CurrentRecipe.Header.Type);
  735. CurrentRecipe.Steps.Insert(insertIndex - 1, recipeStep);
  736. }
  737. else
  738. {
  739. var t1 = JsonConvert.SerializeObject(CurrentRecipe);
  740. var recipeStep = Recipe.Load(t1).Steps[copyIndex - 1];
  741. CurrentRecipe.Steps.Insert(insertIndex - 1, recipeStep);
  742. }
  743. for (int i = 0; i < CurrentRecipe.Steps.Count; i++)
  744. {
  745. CurrentRecipe.Steps[i].StepNo = i + 1;
  746. }
  747. LoadRecipe(CurrentRecipe);
  748. }
  749. private void MenuItemRightInsert_Click(object sender, RoutedEventArgs e)
  750. {
  751. var t = ((sender as MenuItem).Parent as ContextMenu).PlacementTarget as TextBox;
  752. int insertIndex = Convert.ToInt32(t.Text);
  753. if (copyIndex == -1)
  754. {
  755. var recipeStep = new RecipeStep();
  756. //switch (currentChamber)
  757. //{
  758. // case JetChamber.Venus:
  759. // recipeStep.LstUnit.Add(new PressureByPressureModeUnit());
  760. // recipeStep.LstUnit.Add(new TCPUnit());
  761. // recipeStep.LstUnit.Add(new BiasUnit());
  762. // recipeStep.LstUnit.Add(new GasControlUnit());
  763. // recipeStep.LstUnit.Add(new ESCHVUnit());
  764. // recipeStep.LstUnit.Add(new ProcessKitUnit());
  765. // break;
  766. // case JetChamber.Kepler2300:
  767. // recipeStep.LstUnit.Add(new PressureByPressureModeUnit());
  768. // recipeStep.LstUnit.Add(new TCPUnit());
  769. // recipeStep.LstUnit.Add(new BiasUnit());
  770. // recipeStep.LstUnit.Add(new GasControlUnit());
  771. // recipeStep.LstUnit.Add(new ProcessKitUnit());
  772. // break;
  773. // case JetChamber.Kepler2200A:
  774. // recipeStep.LstUnit.Add(new Kepler2200GasControlUnit());
  775. // recipeStep.LstUnit.Add(new HeaterUnit());
  776. // recipeStep.LstUnit.Add(new Kepler2200RFUnit());
  777. // break;
  778. //}
  779. recipeStep.LstUnit=RecipeUnity.GetAllUnits(currentChamber, CurrentRecipe.Header.Type);
  780. CurrentRecipe.Steps.Insert(insertIndex, recipeStep);
  781. }
  782. else
  783. {
  784. var t1 = JsonConvert.SerializeObject(CurrentRecipe);
  785. var recipeStep = Recipe.Load(t1).Steps[copyIndex - 1];
  786. CurrentRecipe.Steps.Insert(insertIndex, recipeStep);
  787. }
  788. for (int i = 0; i < CurrentRecipe.Steps.Count; i++)
  789. {
  790. CurrentRecipe.Steps[i].StepNo = i + 1;
  791. }
  792. LoadRecipe(CurrentRecipe);
  793. }
  794. private void MenuItemDelete_Click(object sender, RoutedEventArgs e)
  795. {
  796. var t = ((sender as MenuItem).Parent as ContextMenu).PlacementTarget as TextBox;
  797. int deleteIndex = Convert.ToInt32(t.Text);
  798. //OnDeleteStep(deleteIndex - 1);
  799. CurrentRecipe.Steps.RemoveAt(deleteIndex-1);
  800. for (int i = 0; i < CurrentRecipe.Steps.Count; i++)
  801. {
  802. CurrentRecipe.Steps[i].StepNo = i + 1;
  803. }
  804. LoadRecipe(CurrentRecipe);
  805. }
  806. private void MenuItemCopy_Click(object sender, RoutedEventArgs e)
  807. {
  808. var t = ((sender as MenuItem).Parent as ContextMenu).PlacementTarget as TextBox;
  809. copyIndex = Convert.ToInt32(t.Text);
  810. }
  811. #endregion
  812. #region 私有方法
  813. private void RecipeStepToGridColumn(RecipeStep recipeStep, Grid grid, int index, bool isInsert)
  814. {
  815. int location = 1;
  816. if (isInsert == true)
  817. {
  818. location -= 1;
  819. }
  820. Type recipeType = recipeStep.GetType();
  821. int cycleCount = 1;
  822. if (index == 0)
  823. {
  824. cycleCount = 2;
  825. }
  826. for (int j = 0; j < cycleCount; j++)
  827. {
  828. int i = 0;
  829. ColumnDefinition col1 = new ColumnDefinition();
  830. //col1.MinWidth = 50;
  831. grid.ColumnDefinitions.Insert(index, col1);
  832. //Binding stepcheckbinding = null;
  833. //grid.MinWidth = 200;
  834. foreach (PropertyInfo propertyInfo in recipeType.GetProperties())
  835. {
  836. string propertyInfoName = propertyInfo.Name;
  837. string propertyTypeName = propertyInfo.PropertyType.Name;
  838. if (propertyInfoName != "LstUnit")
  839. {
  840. if ((propertyInfoName == "EPDConfig" || propertyInfoName == "MinEndPointTime" || propertyInfoName == "MaxEndPointTime") && isInstalledEPD == false)
  841. {
  842. continue;
  843. }
  844. if (index == 0 && grid.ColumnDefinitions.Count == 1)
  845. {
  846. RowDefinition row1 = new RowDefinition();
  847. grid.RowDefinitions.Add(row1);
  848. }
  849. if (grid.ColumnDefinitions.Count == 1 && j == 0)
  850. {
  851. TextBox textBlock = new TextBox();
  852. textBlock.IsReadOnly = true;
  853. textBlock.Text = propertyInfoName;
  854. grid.Children.Add(textBlock);
  855. textBlock.Background = new SolidColorBrush(Colors.BurlyWood);
  856. Grid.SetRow(textBlock, i);
  857. Grid.SetColumn(textBlock, 0);
  858. }
  859. else
  860. {
  861. Binding binding = new Binding()
  862. {
  863. Source = recipeStep, // 数据源
  864. Path = new PropertyPath(propertyInfoName), // 需绑定的数据源属性名
  865. Mode = BindingMode.TwoWay, // 绑定模式
  866. UpdateSourceTrigger = UpdateSourceTrigger.PropertyChanged //触发器
  867. };
  868. switch (propertyTypeName)
  869. {
  870. case "Int32":
  871. case "String":
  872. if (propertyInfoName == "EPDConfig")
  873. {
  874. if (currentEPDType == EPDType.Socket)
  875. {
  876. ComboBox EPDcomboBox = new ComboBox();
  877. EPDcomboBox.Style = (Style)recipeView.FindResource("customeComboBoxStyle");
  878. EPDcomboBox.Background = new SolidColorBrush(Colors.Black);
  879. EPDcomboBox.SetBinding(ComboBox.SelectedItemProperty, binding);
  880. EPDcomboBox.ItemsSource = EPDCfgList;
  881. grid.Children.Add(EPDcomboBox);
  882. Grid.SetRow(EPDcomboBox, i);
  883. Grid.SetColumn(EPDcomboBox, index + location);
  884. //EPDcomboBox.DropDownOpened += EPDcomboBox_DropDownOpened;
  885. }
  886. else if (currentEPDType == EPDType.WCF)
  887. {
  888. Button EPDButton = new Button();
  889. EPDButton.Content = "EndPoint";
  890. EPDButton.Cursor = Cursors.Hand;
  891. EPDButton.Tag = $"{CurrentRecipeName}.{(index + location).ToString()}";
  892. EPDButton.Style = null;
  893. EPDButton.Click += EPDButton_Click;
  894. grid.Children.Add(EPDButton);
  895. Grid.SetRow(EPDButton, i);
  896. Grid.SetColumn(EPDButton, index + location);
  897. }
  898. break;
  899. }
  900. TextBox textBox = new TextBox();
  901. textBox.HorizontalContentAlignment = HorizontalAlignment.Center;
  902. textBox.VerticalContentAlignment = VerticalAlignment.Center;
  903. //if (stepcheckbinding == null)
  904. //{
  905. // textBox.IsEnabled = true;
  906. //}
  907. //else
  908. //{
  909. // textBox.SetBinding(TextBox.IsEnabledProperty, stepcheckbinding);
  910. //}
  911. textBox.SetBinding(TextBox.TextProperty, binding);
  912. grid.Children.Add(textBox);
  913. Grid.SetRow(textBox, i);
  914. Grid.SetColumn(textBox, index + location);
  915. object[] objAttrs = propertyInfo.GetCustomAttributes(typeof(IsOnlyReadAttribute), true);
  916. if (objAttrs.Length > 0)
  917. {
  918. textBox.IsReadOnly = true;
  919. ContextMenu contextmenu = new ContextMenu();
  920. textBox.ContextMenu = contextmenu;
  921. MenuItem menuItemDelete = new MenuItem();
  922. menuItemDelete.Header = "Delete";
  923. menuItemDelete.Click += MenuItemDelete_Click;
  924. MenuItem menuItemLeftInsert = new MenuItem();
  925. menuItemLeftInsert.Header = "Left Insert";
  926. menuItemLeftInsert.Click += MenuItemLeftInsert_Click;
  927. MenuItem menuItemRightInsert = new MenuItem();
  928. menuItemRightInsert.Header = "Right Insert";
  929. menuItemRightInsert.Click += MenuItemRightInsert_Click;
  930. MenuItem menuItemCopy = new MenuItem();
  931. menuItemCopy.Tag = textBox.Text;
  932. menuItemCopy.Header = "Copy";
  933. menuItemCopy.Click += MenuItemCopy_Click;
  934. contextmenu.Items.Add(menuItemCopy);
  935. contextmenu.Items.Add(menuItemDelete);
  936. contextmenu.Items.Add(menuItemLeftInsert);
  937. contextmenu.Items.Add(menuItemRightInsert);
  938. }
  939. break;
  940. case "Boolean":
  941. CheckBox checkBox = new CheckBox();
  942. checkBox.SetBinding(CheckBox.IsCheckedProperty, binding);
  943. grid.Children.Add(checkBox);
  944. Grid.SetRow(checkBox, i);
  945. Grid.SetColumn(checkBox, index + location);
  946. //if (stepcheckbinding == null)
  947. //{
  948. // stepcheckbinding = new Binding
  949. // {
  950. // Source = checkBox, // 数据源
  951. // Path = new PropertyPath("IsChecked"), // 需绑定的数据源属性名
  952. // Mode = BindingMode.TwoWay, // 绑定模式
  953. // UpdateSourceTrigger = UpdateSourceTrigger.PropertyChanged //触发器
  954. // };
  955. //}
  956. //else
  957. //{
  958. //}
  959. //if (stepcheckbinding == null)
  960. //{
  961. // checkBox.IsEnabled = true;
  962. //}
  963. //else
  964. //{
  965. // checkBox.SetBinding(TextBox.IsEnabledProperty, stepcheckbinding);
  966. //}
  967. break;
  968. default:
  969. ComboBox comboBox = new ComboBox();
  970. comboBox.Style = (Style)recipeView.FindResource("customeComboBoxStyle");
  971. comboBox.Background = new SolidColorBrush(Colors.Black);
  972. comboBox.SetBinding(ComboBox.SelectedItemProperty, binding);
  973. ItemsControlHelper.SetEnumValuesToItemsSource(comboBox, true);
  974. grid.Children.Add(comboBox);
  975. Grid.SetRow(comboBox, i);
  976. Grid.SetColumn(comboBox, index + location);
  977. //if (stepcheckbinding == null)
  978. //{
  979. // comboBox.IsEnabled = true;
  980. //}
  981. //else
  982. //{
  983. // comboBox.SetBinding(TextBox.IsEnabledProperty, stepcheckbinding);
  984. //}
  985. break;
  986. }
  987. }
  988. i++;
  989. }
  990. }
  991. int k = 0;
  992. foreach (var x in recipeStep.LstUnit.ToList())
  993. {
  994. Type unitType = x.GetType();
  995. bool isIgnore = false;
  996. //switch (currentChamber)
  997. //{
  998. // case JetChamber.Venus:
  999. // var VenusUnitsValues = Enum.GetValues(typeof(VenusUnits));
  1000. // foreach (var item in VenusUnitsValues)
  1001. // {
  1002. // if (item.ToString() == unitType.Name)
  1003. // {
  1004. // isIgnore = true;
  1005. // break;
  1006. // }
  1007. // }
  1008. // break;
  1009. // case JetChamber.Kepler2300:
  1010. // var Kepler2300UintsValues = Enum.GetValues(typeof(Kepler2300Uints));
  1011. // foreach (var item in Kepler2300UintsValues)
  1012. // {
  1013. // if (item.ToString() == unitType.Name)
  1014. // {
  1015. // isIgnore = true;
  1016. // break;
  1017. // }
  1018. // }
  1019. // break;
  1020. // case JetChamber.Kepler2200A:
  1021. // var Kepler2200AUintsValues = Enum.GetValues(typeof(Kepler2200AUnits));
  1022. // foreach (var item in Kepler2200AUintsValues)
  1023. // {
  1024. // if (item.ToString() == unitType.Name)
  1025. // {
  1026. // isIgnore = true;
  1027. // break;
  1028. // }
  1029. // }
  1030. // break;
  1031. // case JetChamber.Kepler2200B:
  1032. // break;
  1033. //}
  1034. //if (!isIgnore)
  1035. //{
  1036. // continue;
  1037. //}
  1038. Binding checkbinding = null;
  1039. foreach (PropertyInfo propertyInfo in unitType.GetProperties())
  1040. {
  1041. object[] IgnoreAttrs = propertyInfo.GetCustomAttributes(typeof(IsCanConfigIgnore), true);
  1042. bool IsEnableRecipeExtension = Convert.ToBoolean(QueryDataClient.Instance.Service.GetConfig($"{ModuleName}.IsEnableRecipeExtension"));
  1043. if (IgnoreAttrs.Length > 0 && IsEnableRecipeExtension == false)
  1044. {
  1045. break;
  1046. }
  1047. if (index == 0 && grid.ColumnDefinitions.Count == 1)
  1048. {
  1049. RowDefinition row1 = new RowDefinition();
  1050. grid.RowDefinitions.Add(row1);
  1051. }
  1052. if (grid.ColumnDefinitions.Count == 1 && j == 0)
  1053. {
  1054. TextBox textBlock = new TextBox();
  1055. textBlock.IsReadOnly = true;
  1056. switch (propertyInfo.Name)
  1057. {
  1058. case "Gas1":
  1059. var data1 = (AITMfcData)QueryDataClient.Instance.Service.GetData($"{ModuleName}.MfcGas1");
  1060. textBlock.Text = $"{propertyInfo.Name}({data1.DisplayName},{data1.Scale})";
  1061. break;
  1062. case "Gas2":
  1063. var data2 = (AITMfcData)QueryDataClient.Instance.Service.GetData($"{ModuleName}.MfcGas2");
  1064. textBlock.Text = $"{propertyInfo.Name}({data2.DisplayName},{data2.Scale})";
  1065. break;
  1066. case "Gas3":
  1067. var data3 = (AITMfcData)QueryDataClient.Instance.Service.GetData($"{ModuleName}.MfcGas3");
  1068. textBlock.Text = $"{propertyInfo.Name}({data3.DisplayName},{data3.Scale})";
  1069. break;
  1070. case "Gas4":
  1071. var data4 = (AITMfcData)QueryDataClient.Instance.Service.GetData($"{ModuleName}.MfcGas4");
  1072. textBlock.Text = $"{propertyInfo.Name}({data4.DisplayName},{data4.Scale})";
  1073. break;
  1074. case "Gas5":
  1075. var data5 = (AITMfcData)QueryDataClient.Instance.Service.GetData($"{ModuleName}.MfcGas5");
  1076. textBlock.Text = $"{propertyInfo.Name}({data5.DisplayName},{data5.Scale})";
  1077. break;
  1078. case "Gas6":
  1079. var data6 = (AITMfcData)QueryDataClient.Instance.Service.GetData($"{ModuleName}.MfcGas6");
  1080. textBlock.Text = $"{propertyInfo.Name}({data6.DisplayName},{data6.Scale})";
  1081. break;
  1082. case "Gas7":
  1083. var data7 = (AITMfcData)QueryDataClient.Instance.Service.GetData($"{ModuleName}.MfcGas7");
  1084. textBlock.Text = $"{propertyInfo.Name}({data7.DisplayName},{data7.Scale})";
  1085. break;
  1086. case "Gas8":
  1087. var data8 = (AITMfcData)QueryDataClient.Instance.Service.GetData($"{ModuleName}.MfcGas8");
  1088. textBlock.Text = $"{propertyInfo.Name}({data8.DisplayName},{data8.Scale})";
  1089. break;
  1090. case "HeaterPressure":
  1091. textBlock.Text = "Pressure(Pa)";
  1092. break;
  1093. case "HeaterTemp":
  1094. textBlock.Text = "Heater Temp(℃)";
  1095. break;
  1096. case "HeaterRatio":
  1097. textBlock.Text = "Heater Ratio";
  1098. break;
  1099. default:
  1100. textBlock.Text = propertyInfo.Name;
  1101. break;
  1102. }
  1103. textBlock.Background = solidColorBrushes[k % 3];
  1104. grid.Children.Add(textBlock);
  1105. Grid.SetRow(textBlock, i);
  1106. Grid.SetColumn(textBlock, 0);
  1107. }
  1108. else
  1109. {
  1110. Binding binding = new Binding()
  1111. {
  1112. Source = recipeStep.LstUnit[k], // 数据源
  1113. //Path = new PropertyPath($"LstUnit[{k}]." + propertyInfo.Name), // 需绑定的数据源属性名
  1114. Path = new PropertyPath(propertyInfo.Name), // 需绑定的数据源属性名
  1115. Mode = BindingMode.TwoWay, // 绑定模式
  1116. UpdateSourceTrigger = UpdateSourceTrigger.PropertyChanged //触发器
  1117. };
  1118. var item = propertyInfo.PropertyType.Name;
  1119. if (propertyInfo.Name == "UnitName")
  1120. {
  1121. TextBox textBlock1 = new TextBox();
  1122. textBlock1.HorizontalContentAlignment = HorizontalAlignment.Center;
  1123. textBlock1.VerticalContentAlignment = VerticalAlignment.Center;
  1124. textBlock1.Text = propertyInfo.GetValue(x).ToString();
  1125. textBlock1.IsReadOnly = true;
  1126. grid.Children.Add(textBlock1);
  1127. Grid.SetRow(textBlock1, i);
  1128. Grid.SetColumn(textBlock1, index + location);
  1129. }
  1130. else
  1131. {
  1132. switch (item)
  1133. {
  1134. case "Int32":
  1135. case "String":
  1136. //if (checkbinding != null)
  1137. //{
  1138. // break;
  1139. //}
  1140. TextBox textBox = new TextBox();
  1141. textBox.HorizontalContentAlignment = HorizontalAlignment.Center;
  1142. textBox.VerticalContentAlignment = VerticalAlignment.Center;
  1143. if (checkbinding == null)
  1144. {
  1145. textBox.IsEnabled = true;
  1146. }
  1147. else
  1148. {
  1149. textBox.SetBinding(TextBox.IsEnabledProperty, checkbinding);
  1150. }
  1151. switch (propertyInfo.Name)
  1152. {
  1153. case "Gas1":
  1154. var data1 = (AITMfcData)QueryDataClient.Instance.Service.GetData($"{ModuleName}.MfcGas1");
  1155. TextBoxMaxValue.SetMaxValue(textBox, (int)data1.Scale);
  1156. break;
  1157. case "Gas2":
  1158. var data2 = (AITMfcData)QueryDataClient.Instance.Service.GetData($"{ModuleName}.MfcGas2");
  1159. TextBoxMaxValue.SetMaxValue(textBox, (int)data2.Scale);
  1160. break;
  1161. case "Gas3":
  1162. var data3 = (AITMfcData)QueryDataClient.Instance.Service.GetData($"{ModuleName}.MfcGas3");
  1163. TextBoxMaxValue.SetMaxValue(textBox, (int)data3.Scale);
  1164. break;
  1165. case "Gas4":
  1166. var data4 = (AITMfcData)QueryDataClient.Instance.Service.GetData($"{ModuleName}.MfcGas4");
  1167. TextBoxMaxValue.SetMaxValue(textBox, (int)data4.Scale);
  1168. break;
  1169. case "Gas5":
  1170. var data5 = (AITMfcData)QueryDataClient.Instance.Service.GetData($"{ModuleName}.MfcGas5");
  1171. TextBoxMaxValue.SetMaxValue(textBox, (int)data5.Scale);
  1172. break;
  1173. case "Gas6":
  1174. var data6 = (AITMfcData)QueryDataClient.Instance.Service.GetData($"{ModuleName}.MfcGas6");
  1175. TextBoxMaxValue.SetMaxValue(textBox, (int)data6.Scale);
  1176. break;
  1177. case "Gas7":
  1178. var data7 = (AITMfcData)QueryDataClient.Instance.Service.GetData($"{ModuleName}.MfcGas7");
  1179. TextBoxMaxValue.SetMaxValue(textBox, (int)data7.Scale);
  1180. break;
  1181. case "Gas8":
  1182. var data8 = (AITMfcData)QueryDataClient.Instance.Service.GetData($"{ModuleName}.MfcGas8");
  1183. TextBoxMaxValue.SetMaxValue(textBox, (int)data8.Scale);
  1184. break;
  1185. }
  1186. textBox.SetBinding(TextBox.TextProperty, binding);
  1187. grid.Children.Add(textBox);
  1188. Grid.SetRow(textBox, i);
  1189. Grid.SetColumn(textBox, index + location);
  1190. object[] objAttrs = propertyInfo.GetCustomAttributes(typeof(IsOnlyReadAttribute), true);
  1191. if (objAttrs.Length > 0)
  1192. {
  1193. textBox.IsReadOnly = true;
  1194. }
  1195. break;
  1196. case "Boolean":
  1197. CheckBox checkBox = new CheckBox();
  1198. if (checkbinding == null)
  1199. {
  1200. checkbinding = new Binding
  1201. {
  1202. Source = checkBox, // 数据源
  1203. Path = new PropertyPath("IsChecked"), // 需绑定的数据源属性名
  1204. Mode = BindingMode.TwoWay, // 绑定模式
  1205. UpdateSourceTrigger = UpdateSourceTrigger.PropertyChanged //触发器
  1206. };
  1207. }
  1208. checkBox.SetBinding(CheckBox.IsCheckedProperty, binding);
  1209. grid.Children.Add(checkBox);
  1210. Grid.SetRow(checkBox, i);
  1211. Grid.SetColumn(checkBox, index + location);
  1212. break;
  1213. default:
  1214. //if (checkbinding != null)
  1215. //{
  1216. // break;
  1217. //}
  1218. ComboBox comboBox = new ComboBox();
  1219. comboBox.BorderBrush = Brushes.Gray;
  1220. comboBox.Style = (Style)recipeView.FindResource("customeComboBoxStyle");
  1221. if (checkbinding == null)
  1222. {
  1223. comboBox.IsEnabled = true;
  1224. }
  1225. else
  1226. {
  1227. comboBox.SetBinding(TextBox.IsEnabledProperty, checkbinding);
  1228. }
  1229. comboBox.Background = Brushes.White;
  1230. string path = propertyInfo.Name;
  1231. comboBox.SetBinding(ComboBox.SelectedItemProperty, binding);
  1232. ItemsControlHelper.SetEnumValuesToItemsSource(comboBox, true);
  1233. grid.Children.Add(comboBox);
  1234. Grid.SetRow(comboBox, i);
  1235. Grid.SetColumn(comboBox, index + location);
  1236. break;
  1237. }
  1238. }
  1239. }
  1240. i++;
  1241. }
  1242. k++;
  1243. }
  1244. }
  1245. }
  1246. private void EPDButton_Click(object sender, RoutedEventArgs e)
  1247. {
  1248. Button button = sender as Button;
  1249. string para = button.Tag.ToString();
  1250. int stepno = Convert.ToInt32(para.Split('.')[1])-1;
  1251. var endpointconfigitem = new MECF.Framework.Common.CommonData.EndPointConfigItem();
  1252. if (CurrentRecipe.Steps[stepno].EPDConfig!=null && CurrentRecipe.Steps[stepno].EPDConfig.Length>20)
  1253. {
  1254. endpointconfigitem.SetValue(CurrentRecipe.Steps[stepno].EPDConfig);
  1255. }
  1256. (new EndPointDlg(para, endpointconfigitem,CurrentRecipe)).ShowDialog();
  1257. }
  1258. private void UpdateRecipeFileList()
  1259. {
  1260. XmlDocument doc = new XmlDocument();
  1261. doc.LoadXml(GetXmlRecipeList());
  1262. treeViewRcpList.Items.Clear();
  1263. CreateTreeViewItems(doc.DocumentElement, this.treeViewRcpList);
  1264. }
  1265. private void LoadRecipe(Recipe recipe)
  1266. {
  1267. copyIndex = -1;
  1268. bodyStackPanel.Children.Clear();
  1269. //CurrentRecipe = null;
  1270. GC.Collect(); // This should pick up the control removed at a previous MouseDown
  1271. GC.WaitForPendingFinalizers(); // Doesn't help either
  1272. GC.Collect();
  1273. GC.WaitForPendingFinalizers(); // Doesn't help either
  1274. CurrentRecipe = recipe;
  1275. if (CurrentRecipe.Header.Type==Venus_Core.RecipeType.Process && CurrentRecipe.Header.ChuckRecipe != "" && CurrentRecipe.Header.ChuckRecipe != null)
  1276. {
  1277. Grid chuckGrid = new Grid();
  1278. chuckGrid.IsEnabled = false;
  1279. chuckGrid.Margin = new Thickness(15);
  1280. string chuckRecipeData = m_uiRecipeManager.LoadRecipe(ModuleName, CurrentRecipe.Header.ChuckRecipe);
  1281. //index = 0;
  1282. var chuckRecipe = Recipe.Load(chuckRecipeData);
  1283. for (int i = 0; i < chuckRecipe.Steps.Count; i++)
  1284. {
  1285. RecipeStepToGridColumn(chuckRecipe.Steps[i], chuckGrid, i, false);
  1286. }
  1287. bodyStackPanel.Children.Add(chuckGrid);
  1288. }
  1289. Grid proressGrid = new Grid();
  1290. proressGrid.Margin = new Thickness(15);
  1291. //index = 0;
  1292. for (int i = 0; i < recipe.Steps.Count; i++)
  1293. {
  1294. RecipeStepToGridColumn(recipe.Steps[i], proressGrid, i, false);
  1295. }
  1296. bodyStackPanel.Children.Add(proressGrid);
  1297. currentRecipeGrid = proressGrid;
  1298. if (CurrentRecipe.Header.Type == Venus_Core.RecipeType.Process && CurrentRecipe.Header.DechuckRecipe != "" && CurrentRecipe.Header.DechuckRecipe != null)
  1299. {
  1300. Grid deChuckGrid = new Grid();
  1301. deChuckGrid.IsEnabled = false;
  1302. deChuckGrid.Margin = new Thickness(15);
  1303. string DechuckRecipeData = m_uiRecipeManager.LoadRecipe(ModuleName, CurrentRecipe.Header.DechuckRecipe);
  1304. //index = 0;
  1305. var dechuckRecipe = Recipe.Load(DechuckRecipeData);
  1306. for (int i = 0; i < dechuckRecipe.Steps.Count; i++)
  1307. {
  1308. RecipeStepToGridColumn(dechuckRecipe.Steps[i], deChuckGrid, i, false);
  1309. }
  1310. bodyStackPanel.Children.Add(deChuckGrid);
  1311. }
  1312. }
  1313. ////private void OnAddStep(int index)
  1314. ////{
  1315. //// if (CurrentRecipe != null)
  1316. //// {
  1317. //// RecipeStep recipeStep;
  1318. //// if (copyIndex == -1)
  1319. //// {
  1320. //// recipeStep = new RecipeStep();
  1321. //// switch (currentChamber)
  1322. //// {
  1323. //// case JetChamber.Venus:
  1324. //// recipeStep.LstUnit.Add(new PressureByPressureModeUnit());
  1325. //// recipeStep.LstUnit.Add(new TCPUnit());
  1326. //// recipeStep.LstUnit.Add(new BiasUnit());
  1327. //// recipeStep.LstUnit.Add(new GasControlUnit());
  1328. //// recipeStep.LstUnit.Add(new ESCHVUnit());
  1329. //// recipeStep.LstUnit.Add(new ProcessKitUnit());
  1330. //// break;
  1331. //// case JetChamber.Kepler2300:
  1332. //// recipeStep.LstUnit.Add(new PressureByPressureModeUnit());
  1333. //// recipeStep.LstUnit.Add(new TCPUnit());
  1334. //// recipeStep.LstUnit.Add(new BiasUnit());
  1335. //// recipeStep.LstUnit.Add(new GasControlUnit());
  1336. //// recipeStep.LstUnit.Add(new ProcessKitUnit());
  1337. //// break;
  1338. //// case JetChamber.Kepler2200A:
  1339. //// recipeStep.LstUnit.Add(new Kepler2200GasControlUnit());
  1340. //// recipeStep.LstUnit.Add(new HeaterUnit());
  1341. //// recipeStep.LstUnit.Add(new Kepler2200RFUnit());
  1342. //// break;
  1343. //// }
  1344. //// CurrentRecipe.Steps.Insert(index - 1, recipeStep);
  1345. //// }
  1346. //// else
  1347. //// {
  1348. //// var t = JsonConvert.SerializeObject(CurrentRecipe);
  1349. //// recipeStep = Recipe.Load(t).Steps[copyIndex - 1];
  1350. //// CurrentRecipe.Steps.Insert(index - 1, recipeStep);
  1351. //// }
  1352. //// RecipeStepToGridColumn(recipeStep, currentRecipeGrid, index, true);
  1353. //// for (int i = 1; i <= CurrentRecipe.Steps.Count; i++)
  1354. //// {
  1355. //// CurrentRecipe.Steps[i - 1].StepNo = i;
  1356. //// }
  1357. //// }
  1358. ////}
  1359. private void OnDeleteStep(int index)
  1360. {
  1361. if (CurrentRecipe != null && CurrentRecipe.Steps.Count > 1)
  1362. {
  1363. currentRecipeGrid.Children.RemoveRange(currentRecipeGrid.RowDefinitions.Count * (index + 1), currentRecipeGrid.RowDefinitions.Count);
  1364. currentRecipeGrid.ColumnDefinitions.RemoveAt(index);
  1365. for (int i = 1; i <= CurrentRecipe.Steps.Count; i++)
  1366. {
  1367. CurrentRecipe.Steps[i - 1].StepNo = i;
  1368. }
  1369. CurrentRecipe.Steps.RemoveAt(index);
  1370. }
  1371. }
  1372. private void OnRefresh()
  1373. {
  1374. if (CurrentRecipeName != "")
  1375. {
  1376. string xmlRecipeData = m_uiRecipeManager.LoadRecipe(ModuleName, CurrentRecipeName);
  1377. CurrentRecipe = Recipe.Load(xmlRecipeData);
  1378. LoadRecipe(CurrentRecipe);
  1379. }
  1380. }
  1381. private void OnTolerance()
  1382. {
  1383. List<Kepler2300Tolerance> kepler2300Tolerances = new List<Kepler2300Tolerance>();
  1384. kepler2300Tolerances.Add(new Kepler2300Tolerance());
  1385. kepler2300Tolerances.Add(new Kepler2300Tolerance());
  1386. var str= SerializeHelper.Instance.ObjectToJsonString<List<Kepler2300Tolerance>>(kepler2300Tolerances);
  1387. }
  1388. #endregion
  1389. }
  1390. }