RecipeControl.xaml.cs 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414
  1. using Aitex.Core.RT.Log;
  2. using Aitex.Core.RT.RecipeCenter;
  3. using Aitex.Core.UI.MVVM;
  4. using Aitex.Core.Utilities;
  5. using MECF.Framework.Common.Equipment;
  6. using MECF.Framework.Common.OperationCenter;
  7. using MECF.Framework.Common.Persistent.Prewet;
  8. using MECF.Framework.Common.Persistent.SRD;
  9. using MECF.Framework.Common.RecipeCenter;
  10. using MECF.Framework.Common.Routine;
  11. using CyberX8_Core;
  12. using System;
  13. using System.Collections.Generic;
  14. using System.Collections.ObjectModel;
  15. using System.ComponentModel;
  16. using System.Diagnostics;
  17. using System.Linq;
  18. using System.Reflection;
  19. using System.Text;
  20. using System.Text.RegularExpressions;
  21. using System.Threading.Tasks;
  22. using System.Windows;
  23. using System.Windows.Controls;
  24. using System.Windows.Data;
  25. using System.Windows.Documents;
  26. using System.Windows.Input;
  27. using System.Windows.Media;
  28. using System.Windows.Media.Imaging;
  29. using System.Windows.Navigation;
  30. using System.Windows.Shapes;
  31. namespace CyberX8_Themes.UserControls
  32. {
  33. /// <summary>
  34. /// RecipeControl.xaml 的交互逻辑
  35. /// </summary>
  36. public partial class RecipeControl : UserControl
  37. {
  38. public RecipeControl()
  39. {
  40. InitializeComponent();
  41. }
  42. #region 属性
  43. public static readonly DependencyProperty ModuleNameProperty = DependencyProperty.Register(
  44. "ModuleName", typeof(string), typeof(RecipeControl),
  45. new FrameworkPropertyMetadata("", FrameworkPropertyMetadataOptions.AffectsRender));
  46. /// <summary>
  47. /// 模块名称
  48. /// </summary>
  49. public string ModuleName
  50. {
  51. get
  52. {
  53. return (string)this.GetValue(ModuleNameProperty);
  54. }
  55. set
  56. {
  57. this.SetValue(ModuleNameProperty, value);
  58. }
  59. }
  60. public static readonly DependencyProperty ModuleTitleProperty = DependencyProperty.Register(
  61. "ModuleTitle", typeof(string), typeof(RecipeControl),
  62. new FrameworkPropertyMetadata("", FrameworkPropertyMetadataOptions.AffectsRender));
  63. /// <summary>
  64. /// 模块名称
  65. /// </summary>
  66. public string ModuleTitle
  67. {
  68. get
  69. {
  70. return (string)this.GetValue(ModuleTitleProperty);
  71. }
  72. set
  73. {
  74. this.SetValue(ModuleTitleProperty, value);
  75. }
  76. }
  77. public static readonly DependencyProperty InputCycleTimesProperty = DependencyProperty.Register(
  78. "InputCycleTimes", typeof(int), typeof(RecipeControl), new FrameworkPropertyMetadata(0, FrameworkPropertyMetadataOptions.AffectsRender));
  79. /// <summary>
  80. /// InputCycleTimes
  81. /// </summary>
  82. public int InputCycleTimes
  83. {
  84. get
  85. {
  86. return (int)this.GetValue(InputCycleTimesProperty);
  87. }
  88. set
  89. {
  90. this.SetValue(InputCycleTimesProperty, value);
  91. }
  92. }
  93. public static readonly DependencyProperty AchievedCycleTimesProperty = DependencyProperty.Register(
  94. "AchievedCycleTimes", typeof(int), typeof(RecipeControl), new FrameworkPropertyMetadata(0, FrameworkPropertyMetadataOptions.AffectsRender));
  95. /// <summary>
  96. /// AchievedCycleTimes
  97. /// </summary>
  98. public int AchievedCycleTimes
  99. {
  100. get
  101. {
  102. return (int)this.GetValue(AchievedCycleTimesProperty);
  103. }
  104. set
  105. {
  106. this.SetValue(AchievedCycleTimesProperty, value);
  107. }
  108. }
  109. public static readonly DependencyProperty NumberOfSelectedRecipeScansProperty = DependencyProperty.Register(
  110. "NumberOfSelectedRecipeScans", typeof(int), typeof(RecipeControl), new FrameworkPropertyMetadata(0, FrameworkPropertyMetadataOptions.AffectsRender));
  111. /// <summary>
  112. /// NumberOfSelectedRecipeScans
  113. /// </summary>
  114. public int NumberOfSelectedRecipeScans
  115. {
  116. get
  117. {
  118. return (int)this.GetValue(NumberOfSelectedRecipeScansProperty);
  119. }
  120. set
  121. {
  122. this.SetValue(NumberOfSelectedRecipeScansProperty, value);
  123. }
  124. }
  125. public static readonly DependencyProperty SelectedRecipeNodeProperty = DependencyProperty.Register(
  126. "SelectedRecipeNode", typeof(RecipeNode), typeof(RecipeControl),new FrameworkPropertyMetadata(null, new PropertyChangedCallback(SelectedRecipeNodeChanged)));
  127. /// <summary>
  128. /// 当前选中recipe节点
  129. /// </summary>
  130. public RecipeNode SelectedRecipeNode
  131. {
  132. get
  133. {
  134. return (RecipeNode)this.GetValue(SelectedRecipeNodeProperty);
  135. }
  136. set
  137. {
  138. this.SetValue(SelectedRecipeNodeProperty, value);
  139. }
  140. }
  141. public static readonly DependencyProperty RecipeTypeProperty = DependencyProperty.Register(
  142. "RecipeType", typeof(string), typeof(RecipeControl));
  143. /// <summary>
  144. /// Recipe类型
  145. /// </summary>
  146. public string RecipeType
  147. {
  148. get
  149. {
  150. return (string)this.GetValue(RecipeTypeProperty);
  151. }
  152. set
  153. {
  154. this.SetValue(RecipeTypeProperty, value);
  155. }
  156. }
  157. public static readonly DependencyProperty LoadEnabledProperty = DependencyProperty.Register(
  158. "LoadEnabled", typeof(bool), typeof(RecipeControl),new FrameworkPropertyMetadata(false, FrameworkPropertyMetadataOptions.AffectsRender));
  159. /// <summary>
  160. /// 按钮可用性
  161. /// </summary>
  162. public bool LoadEnabled
  163. {
  164. get
  165. {
  166. return (bool)this.GetValue(LoadEnabledProperty);
  167. }
  168. set
  169. {
  170. this.SetValue(LoadEnabledProperty, value);
  171. }
  172. }
  173. /// <summary>
  174. /// 选中Recipe文件的触发的方法
  175. /// </summary>
  176. /// <param name="d"></param>
  177. /// <param name="e"></param>
  178. private static void SelectedRecipeNodeChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
  179. {
  180. if (e.NewValue != null)
  181. {
  182. d.SetValue(LoadEnabledProperty, true);
  183. }
  184. else
  185. {
  186. d.SetValue(LoadEnabledProperty, false);
  187. }
  188. }
  189. public static readonly DependencyProperty CurrentOperationModeProperty = DependencyProperty.Register(
  190. "CurrentOperationMode", typeof(string), typeof(RecipeControl));
  191. /// <summary>
  192. /// CurrentOperationMode
  193. /// </summary>
  194. public string CurrentOperationMode
  195. {
  196. get
  197. {
  198. return (string)this.GetValue(CurrentOperationModeProperty);
  199. }
  200. set
  201. {
  202. this.SetValue(CurrentOperationModeProperty, value);
  203. }
  204. }
  205. public static readonly DependencyProperty IsEngineeringProperty = DependencyProperty.Register(
  206. "IsEngineering", typeof(bool), typeof(RecipeControl), new FrameworkPropertyMetadata(false, FrameworkPropertyMetadataOptions.AffectsRender));
  207. /// <summary>
  208. /// IsEngineering
  209. /// </summary>
  210. public bool IsEngineering
  211. {
  212. get
  213. {
  214. return (bool)this.GetValue(IsEngineeringProperty);
  215. }
  216. set
  217. {
  218. this.SetValue(IsEngineeringProperty, value);
  219. }
  220. }
  221. public static readonly DependencyProperty IsProductionProperty = DependencyProperty.Register(
  222. "IsProduction", typeof(bool), typeof(RecipeControl), new FrameworkPropertyMetadata(false, FrameworkPropertyMetadataOptions.AffectsRender));
  223. /// <summary>
  224. /// IsProduction
  225. /// </summary>
  226. public bool IsProduction
  227. {
  228. get
  229. {
  230. return (bool)this.GetValue(IsProductionProperty);
  231. }
  232. set
  233. {
  234. this.SetValue(IsProductionProperty, value);
  235. }
  236. }
  237. public static readonly DependencyProperty RecipeModeValueProperty = DependencyProperty.Register(
  238. "RecipeModeValue", typeof(string), typeof(RecipeControl), new FrameworkPropertyMetadata("", new PropertyChangedCallback(OnItemsSourceChanged)));
  239. /// <summary>
  240. /// OpertationModeValue
  241. /// </summary>
  242. public string RecipeModeValue
  243. {
  244. get
  245. {
  246. return (string)this.GetValue(RecipeModeValueProperty);
  247. }
  248. set
  249. {
  250. this.SetValue(RecipeModeValueProperty, value);
  251. }
  252. }
  253. private static void OnItemsSourceChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
  254. {
  255. if (e.NewValue != null)
  256. {
  257. string currentMode = (string)e.NewValue;
  258. switch (currentMode)
  259. {
  260. case "Engineering":
  261. d.SetValue(IsEngineeringProperty, true);
  262. d.SetValue(IsProductionProperty, false);
  263. break;
  264. case "Production":
  265. d.SetValue(IsEngineeringProperty, false);
  266. d.SetValue(IsProductionProperty, true);
  267. break;
  268. default:
  269. break;
  270. }
  271. }
  272. }
  273. #endregion
  274. private void GetRecipeType()
  275. {
  276. if (SelectedRecipeNode.RecipeFullFileName.Contains("pwt"))
  277. {
  278. PwtRecipe pwtRecipe = RecipeFileManager.Instance.LoadGenericityRecipe<PwtRecipe>(SelectedRecipeNode.RecipeFullFileName);
  279. if (pwtRecipe != null)
  280. {
  281. NumberOfSelectedRecipeScans = pwtRecipe.NumberOfScans;
  282. }
  283. }
  284. }
  285. private void Pause_Click(object sender, RoutedEventArgs e)
  286. {
  287. if ("Manual".Equals(CurrentOperationMode))
  288. {
  289. InvokeClient.Instance.Service.DoOperation($"{ModuleName}.PauseWaferRecipe", SelectedRecipeNode.RecipeFullFileName, InputCycleTimes);
  290. }
  291. else
  292. {
  293. MessageBox.Show("Current OperationMode Can't Perform This Action", $"Current OperationMode is {CurrentOperationMode}", MessageBoxButton.OK, MessageBoxImage.Error);
  294. }
  295. }
  296. private void Resume_Click(object sender, RoutedEventArgs e)
  297. {
  298. if ("Manual".Equals(CurrentOperationMode))
  299. {
  300. InvokeClient.Instance.Service.DoOperation($"{ModuleName}.ResumeWaferRecipe", SelectedRecipeNode.RecipeFullFileName, InputCycleTimes);
  301. }
  302. else
  303. {
  304. MessageBox.Show("Current OperationMode Can't Perform This Action", $"Current OperationMode is {CurrentOperationMode}", MessageBoxButton.OK, MessageBoxImage.Error);
  305. }
  306. }
  307. private void Abort_Click(object sender, RoutedEventArgs e)
  308. {
  309. if ("Manual".Equals(CurrentOperationMode))
  310. {
  311. InvokeClient.Instance.Service.DoOperation($"{ModuleName}.Abort");
  312. }
  313. else
  314. {
  315. if (RecipeModeValue != SelectedRecipeNode.RecipeLocation)
  316. {
  317. MessageBox.Show("Recipe OperationMode is not match!", $"Current Recipe OperationMode is {RecipeModeValue}", MessageBoxButton.OK, MessageBoxImage.Error);
  318. }
  319. else
  320. {
  321. MessageBox.Show("Current OperationMode Can't Perform This Action", $"Current OperationMode is {CurrentOperationMode}", MessageBoxButton.OK, MessageBoxImage.Error);
  322. }
  323. }
  324. }
  325. private void Edit_Click(object sender, RoutedEventArgs e)
  326. {
  327. string _recipeName = "";
  328. string pattern3 = @"^SRD\d$";
  329. string pattern2 = @"^Dryer\d$";
  330. string pattern1 = @"^Rinse\d$";
  331. string pattern4 = @"^Reservoir\d$";
  332. Regex regex3 = new Regex(pattern3);
  333. Regex regex2 = new Regex(pattern2);
  334. Regex regex1 = new Regex(pattern1);
  335. Regex regex4 = new Regex(pattern4);
  336. switch (ModuleName)
  337. {
  338. case "Prewet1":
  339. _recipeName = "PwtRecipe";
  340. break;
  341. case string str when regex1.IsMatch(str):
  342. _recipeName = "QdrRecipe";
  343. break;
  344. case string str when regex2.IsMatch(str):
  345. _recipeName = "HvdRecipe";
  346. break;
  347. case string str when regex3.IsMatch(str):
  348. _recipeName = "SrdRecipe";
  349. break;
  350. case string str when regex4.IsMatch(str):
  351. _recipeName = "ResRecipe";
  352. break;
  353. default:
  354. break;
  355. }
  356. if (!"Manual".Equals(CurrentOperationMode))
  357. {
  358. MessageBox.Show("Current OperationMode Can't Perform This Action", $"Current OperationMode is {CurrentOperationMode}", MessageBoxButton.OK, MessageBoxImage.Error);
  359. }
  360. else
  361. {
  362. if (RecipeModeValue != SelectedRecipeNode.RecipeLocation)
  363. {
  364. MessageBox.Show("Recipe OperationMode is not match!", $"Current Recipe OperationMode is {RecipeModeValue}", MessageBoxButton.OK, MessageBoxImage.Error);
  365. }
  366. else
  367. {
  368. GlobalEvents.OnSwitchFixedTabItem("Recipe", "", _recipeName);
  369. }
  370. }
  371. }
  372. private void RunRecipe_Click(object sender, RoutedEventArgs e)
  373. {
  374. GetRecipeType();
  375. if ("Manual".Equals(CurrentOperationMode))
  376. {
  377. if (InputCycleTimes==0)
  378. {
  379. MessageBox.Show("Please Enter CycleTimes First!", "Current Cycle is 0", MessageBoxButton.OK, MessageBoxImage.Error);
  380. }
  381. else
  382. {
  383. InvokeClient.Instance.Service.DoOperation($"{ModuleName}.CycleManualProcessRecipe", SelectedRecipeNode.RecipeFullFileName, InputCycleTimes);
  384. }
  385. }
  386. else
  387. {
  388. MessageBox.Show("Current OperationMode Can't Perform This Action", $"Current OperationMode is {CurrentOperationMode}", MessageBoxButton.OK, MessageBoxImage.Error);
  389. }
  390. }
  391. }
  392. }