ShellView.xaml.cs 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305
  1. using Prism.Regions;
  2. using System.Collections.Generic;
  3. using System.Windows;
  4. using Venus_Themes.CustomControls;
  5. using Venus_UI.Themes.Attach;
  6. using Venus_Unity;
  7. using System.Linq;
  8. using System.Threading;
  9. using System;
  10. using Venus_MainPages.Views;
  11. using System.Windows.Controls;
  12. using Aitex.Core.UI.View.Frame;
  13. using System.Windows.Media;
  14. using Venus_Core;
  15. using System.Reflection;
  16. using Venus_MainPages.Unity;
  17. using MECF.Framework.Common.DataCenter;
  18. using MECF.Framework.Common.OperationCenter;
  19. using Aitex.Core.RT.OperationCenter;
  20. using Venus_MainPages.ViewModels;
  21. using MECF.Framework.Common.CommonData;
  22. using System.Windows.Controls.Primitives;
  23. using System.Timers;
  24. using System.Windows.Threading;
  25. using Venus_Themes.Unity;
  26. using Venus_Themes.UserControls;
  27. using OpenSEMI.Ctrlib.Controls;
  28. using OpenSEMI.ClientBase;
  29. using MECF.Framework.Common.Equipment;
  30. namespace Venus_UI.Views
  31. {
  32. /// <summary>
  33. /// ShellView.xaml 的交互逻辑
  34. /// </summary>
  35. public partial class ShellView : Window
  36. {
  37. IRegionManager m_regionManager;
  38. IRegionNavigationService m_regionNavigationService;
  39. List<VenusMenu> VenusMenu;
  40. List<TabControl> centerTabViews=new List<TabControl> ();
  41. List<Button> buttonList=new List<Button> ();
  42. DispatcherTimer timer = new DispatcherTimer();
  43. public ShellView(IRegionManager regionManager, IRegionNavigationService regionNavigationService)
  44. {
  45. InitializeComponent();
  46. m_regionManager = regionManager;
  47. m_regionNavigationService = regionNavigationService;
  48. m_regionManager.RegisterViewWithRegion("TopRegion", typeof(Venus_MainPages.Views.TopView));
  49. VenusGlobalEvents.SlotRightClickChangedEvent += Instance_SlotRightClickChangedEvent;
  50. VenusGlobalEvents.SlotWaferTransferEvent += Instance_SlotStartTransferEvent;
  51. timer.Tick += timer_Tick;
  52. timer.Interval = TimeSpan.FromSeconds(0.5);
  53. timer.Start();
  54. UIEvents.PMDoorRaiseChangedEvent += UIEvents_PMDoorRaiseChangedEvent;
  55. UIEvents.LLTDoorRaiseChangedEvent += UIEvents_LLTDoorRaiseChangedEvent;
  56. UIEvents.LLEDoorRaiseChangedEvent += UIEvents_LLEDoorRaiseChangedEvent;
  57. UIEvents.ChamberCreateDeleteWaferEvent += UIEvents_ChamberCreateDeleteWaferEvent;
  58. }
  59. void timer_Tick(object sender, EventArgs e)
  60. {
  61. if (Anychange.needchange)
  62. {
  63. Anystationchange(Anychange.menuname, Anychange.args);
  64. Anychange.needchange=false;
  65. }
  66. }
  67. private void Instance_SlotRightClickChangedEvent(OpenSEMI.Ctrlib.Controls.Slot slot)
  68. {
  69. if (slot != null)
  70. {
  71. ContextMenu cm = ContextMenuManager.Instance.GetSlotMenus(slot);
  72. if (cm != null)
  73. {
  74. slot.ContextMenu = cm;
  75. }
  76. return;
  77. }
  78. }
  79. private void Instance_SlotStartTransferEvent(OpenSEMI.Ctrlib.Controls.DragDropEventArgs e)
  80. {
  81. string info = " from " + e.TranferFrom.ModuleID + " slot " + (e.TranferFrom.SlotID + 1).ToString() + " to " + e.TranferTo.ModuleID + " slot " + (e.TranferTo.SlotID + 1).ToString();
  82. string message = "Are you sure to transfer the wafer: \n" + info;
  83. WaferDialogViewModel vm = new WaferDialogViewModel();
  84. vm.ConfirmText = message;
  85. WaferDialogView dialog = new WaferDialogView()
  86. {
  87. Owner = Application.Current.MainWindow,
  88. };
  89. dialog.DataContext = vm;
  90. dialog.Height = 300;
  91. dialog.Width = 400;
  92. bool alignflag = false;
  93. bool coolingflag = false;
  94. double angel = 0;
  95. double coolingtime = 0;
  96. if (dialog.ShowDialog() == true)
  97. {
  98. alignflag = (bool)dialog.AlignFlag;
  99. coolingflag = (bool)dialog.CoolingFlag;
  100. if (alignflag && !string.IsNullOrEmpty(dialog.Angle))
  101. {
  102. angel = Convert.ToDouble(dialog.Angle);
  103. }
  104. if (coolingflag && !string.IsNullOrEmpty(dialog.CoolingTime))
  105. {
  106. coolingtime = Convert.ToDouble(dialog.CoolingTime);
  107. }
  108. //from robot to robot is illegal. Must be stop
  109. if (e.TranferFrom.ModuleID == e.TranferTo.ModuleID && (e.TranferTo.ModuleID == ModuleName.EfemRobot.ToString() || e.TranferTo.ModuleID == ModuleName.TMRobot.ToString()))
  110. {
  111. }
  112. else
  113. InvokeClient.Instance.Service.DoOperation("System.MoveWafer",
  114. e.TranferFrom.ModuleID, e.TranferFrom.SlotID, e.TranferTo.ModuleID, e.TranferTo.SlotID, alignflag, angel, coolingflag, coolingtime, "");
  115. }
  116. else
  117. {
  118. ModuleManager.OnFlashWafer(new FlashWaferInformation() { ModuleName = e.TranferFrom.ModuleID, SoltId = e.TranferFrom.SlotID });
  119. //ModuleManager.OnFlashWafer(new FlashWaferInformation() { ModuleName = e.TranferTo.ModuleID, SoltId = e.TranferTo.SlotID });
  120. }
  121. e.TranferFrom.ClearDragDropStatus();
  122. e.TranferTo.ClearDragDropStatus();
  123. }
  124. private void CustomWnd_Loaded(object sender, RoutedEventArgs e)
  125. {
  126. VenusMenu = SerializeHelper.Instance.ReadFromJsonFile<List<VenusMenu>>($"Config/UIMenu.json");
  127. int index = 0;
  128. for (int i = 0; i < VenusMenu.Count; i++)
  129. {
  130. if (VenusMenu[i].IsShow == false)
  131. {
  132. continue;
  133. }
  134. string[] allModules = QueryDataClient.Instance.Service.GetConfig($"System.InstalledModules").ToString().Split(',');
  135. if (VenusMenu[i].Id == "PMA" || VenusMenu[i].Id == "PMB" || VenusMenu[i].Id == "PMC" || VenusMenu[i].Id == "PMD" || VenusMenu[i].Id == "TM")
  136. {
  137. if (!allModules.Contains(VenusMenu[i].Id))
  138. {
  139. continue;
  140. }
  141. }
  142. //if (VenusMenu[i].Id == "SETM" && SC.GetStringValue("System.ChamberSelect") !="4" && SC.GetStringValue("System.ChamberSelect") != "5")
  143. //{
  144. // //不是SE DE
  145. // continue;
  146. //}
  147. AduRadioButtonIcon aduRadioButtonIcon = new AduRadioButtonIcon();
  148. if (i == 0)
  149. {
  150. aduRadioButtonIcon.IsChecked = true;
  151. }
  152. IconElement.SetPathData(aduRadioButtonIcon,(Geometry)aduRadioButtonIcon.FindResource($"Icon_{VenusMenu[i].Id}"));
  153. aduRadioButtonIcon.Content = VenusMenu[i].Name;
  154. aduRadioButtonIcon.Click += AduRadioButtonIcon_Click;
  155. aduRadioButtonIcon.SelectBackground = new SolidColorBrush((Color)ColorConverter.ConvertFromString("#6AD7FF"));
  156. aduRadioButtonIcon.SelectColor = new SolidColorBrush((Colors.Black));
  157. aduRadioButtonIcon.DefaultBackground = new SolidColorBrush((Color)ColorConverter.ConvertFromString("#94BCD7"));
  158. //aduRadioButtonIcon.DefaultBackground = new SolidColorBrush(Colors.DarkGray);
  159. aduRadioButtonIcon.Width = 180;
  160. aduRadioButtonIcon.Height= 40;
  161. //aduRadioButtonIcon.Foreground=Brushes.White;
  162. aduRadioButtonIcon.Tag = index;
  163. index += 1;
  164. Bottom_Frame.Children.Add(aduRadioButtonIcon);
  165. //if (VenusMenu[i].Id == "PMC")
  166. //{
  167. // AduRadioButtonIcon aduRadioButtonIcon2 = new AduRadioButtonIcon();
  168. // IconElement.SetPathData(aduRadioButtonIcon2, (Geometry)aduRadioButtonIcon.FindResource($"Icon_{VenusMenu[i].Id}"));
  169. // aduRadioButtonIcon2.Content = "PMD";
  170. // //aduRadioButtonIcon2.Click += AduRadioButtonIcon_Click;
  171. // aduRadioButtonIcon2.SelectBackground = new SolidColorBrush((Color)ColorConverter.ConvertFromString("#6AD7FF"));
  172. // aduRadioButtonIcon2.SelectColor = new SolidColorBrush((Colors.Black));
  173. // aduRadioButtonIcon2.DefaultBackground = new SolidColorBrush((Color)ColorConverter.ConvertFromString("#94BCD7"));
  174. // //aduRadioButtonIcon.DefaultBackground = new SolidColorBrush(Colors.DarkGray);
  175. // aduRadioButtonIcon2.Width = 180;
  176. // aduRadioButtonIcon2.Height = 40;
  177. // Bottom_Frame.Children.Add(aduRadioButtonIcon2);
  178. //}
  179. TabControl tabControl = new TabControl();
  180. for (int j = 0; j < VenusMenu[i].MenuItem.Count; j++)
  181. {
  182. if (VenusMenu[i].MenuItem[j].IsShow == false)
  183. {
  184. continue;
  185. }
  186. string className;
  187. if ((VenusMenu[i].Id == "PMA" || VenusMenu[i].Id == "PMB" || VenusMenu[i].Id == "PMC" || VenusMenu[i].Id == "PMD")&& VenusMenu[i].MenuItem[j].Id== "Operation")
  188. {
  189. JetChamber jetChamber = (JetChamber)(Convert.ToInt32(QueryDataClient.Instance.Service.GetConfig($"{VenusMenu[i].Id}.ChamberType")));
  190. className = $"Venus_MainPages.Views.Over{jetChamber.ToString()}View";
  191. }
  192. else
  193. {
  194. className = $"Venus_MainPages.Views.{VenusMenu[i].MenuItem[j].View}";
  195. }
  196. Type t = Type.GetType($"{className},Venus_MainPages");
  197. var obj = System.Activator.CreateInstance(t);
  198. if (VenusMenu[i].Id=="PMA" || VenusMenu[i].Id == "PMB" || VenusMenu[i].Id == "PMC" || VenusMenu[i].Id == "PMD" || VenusMenu[i].Id == "TM" || VenusMenu[i].Id == "SETM")
  199. {
  200. MethodInfo methodInfo = t.GetMethod("Init", new Type[] { typeof(string) });
  201. methodInfo?.Invoke(obj, new object[] { VenusMenu[i].Id });
  202. }
  203. tabControl.Items.Add(new TabItem() { Header = VenusMenu[i].MenuItem[j].Name, Content = obj });
  204. }
  205. centerTabViews.Add(tabControl);
  206. }
  207. Main_Frame.Content = centerTabViews[0];
  208. ModuleManager.Initialize();
  209. }
  210. public void Anystationchange(string menuviewItem, WaferHistoryWafer queryFilter)
  211. {
  212. UserControl address = new ProcessHistoryView();
  213. ProcessHistoryViewModel vm = new ProcessHistoryViewModel() { };
  214. vm.searchlot(queryFilter.WaferGuid);
  215. //vm.OnDataGridSelectionChanged(vm.Recipes[0]);
  216. address.DataContext = vm;
  217. int s = 0;
  218. for (int i = 0; i < centerTabViews.Count; i++)
  219. {
  220. var item = centerTabViews[i];
  221. foreach (TabItem v in item.Items)
  222. {
  223. if (v.Header.ToString() == "Process History")
  224. {
  225. s = i;
  226. }
  227. }
  228. }
  229. if (s != 0)
  230. {
  231. centerTabViews[s].Items[2] = new TabItem() { Header = menuviewItem, Content = address };
  232. centerTabViews[s].SelectedIndex = 2;
  233. Main_Frame.Content = centerTabViews[s];
  234. }
  235. }
  236. private void AduRadioButtonIcon_Click(object sender, RoutedEventArgs e)
  237. {
  238. var currentButton = sender as AduRadioButtonIcon;
  239. Main_Frame.Content = centerTabViews[Convert.ToInt32(currentButton.Tag)];
  240. }
  241. private void CustomWnd_Closed(object sender, EventArgs e)
  242. {
  243. System.Diagnostics.Process.GetCurrentProcess().Kill();
  244. }
  245. private void UIEvents_ChamberCreateDeleteWaferEvent(WaferOperation obj)
  246. {
  247. if (obj.IsCreate == true)
  248. {
  249. InvokeClient.Instance.Service.DoOperation("CreateWafer", obj.ModuleName, 0);
  250. }
  251. else
  252. {
  253. InvokeClient.Instance.Service.DoOperation("DeleteWafer", obj.ModuleName, 0);
  254. }
  255. }
  256. private void UIEvents_PMDoorRaiseChangedEvent(DoorPara obj)
  257. {
  258. //InvokeClient.Instance.Service.DoOperation($"{obj?.ModuleName}.SlitDoor.{obj?.IsOpen}");
  259. InvokeClient.Instance.Service.DoOperation($"{obj?.ModuleName}.SetSlitDoor", obj.IsOpen == "Open" ? true : false);
  260. }
  261. private void UIEvents_LLTDoorRaiseChangedEvent(DoorPara obj)
  262. {
  263. InvokeClient.Instance.Service.DoOperation($"TM.SetMFSlitDoor", obj.ModuleName, obj.IsOpen == "Open" ? true : false);
  264. }
  265. private void UIEvents_LLEDoorRaiseChangedEvent(DoorPara obj)
  266. {
  267. InvokeClient.Instance.Service.DoOperation($"TM.SetEFEMSlitDoor", obj.ModuleName, obj.IsOpen == "Open" ? true : false);
  268. }
  269. }
  270. }