RecipeControlMetal.xaml.cs 15 KB

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