RecipeControlMetal.xaml.cs 14 KB

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