WaferPro.xaml.cs 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353
  1. using Aitex.Core.Common;
  2. using Aitex.Core.RT.SCCore;
  3. using Aitex.Core.UI.MVVM;
  4. using Aitex.Sorter.Common;
  5. using MECF.Framework.Common.OperationCenter;
  6. using System;
  7. using System.ComponentModel;
  8. using System.Windows;
  9. using System.Windows.Controls;
  10. using System.Windows.Input;
  11. using MECF.Framework.Common.Equipment;
  12. namespace Aitex.Sorter.UI.Controls
  13. {
  14. /// <summary>
  15. /// Wafer.xaml 的交互逻辑
  16. /// </summary>
  17. public partial class WaferPro : UserControl
  18. {
  19. public static readonly DependencyProperty WaferItemProperty = DependencyProperty.Register(
  20. "WaferItem", typeof(WaferInfo), typeof(WaferPro),
  21. new FrameworkPropertyMetadata(null, FrameworkPropertyMetadataOptions.AffectsRender));
  22. public WaferInfo WaferItem
  23. {
  24. get
  25. {
  26. return (WaferInfo)GetValue(WaferItemProperty);
  27. }
  28. set
  29. {
  30. SetValue(WaferItemProperty, value);
  31. }
  32. }
  33. public int Slot
  34. {
  35. get { return (int)GetValue(SlotProperty); }
  36. set { SetValue(SlotProperty, value); }
  37. }
  38. // Using a DependencyProperty as the backing store for Slot. This enables animation, styling, binding, etc...
  39. public static readonly DependencyProperty SlotProperty =
  40. DependencyProperty.Register("Slot", typeof(int), typeof(WaferPro), new PropertyMetadata(-1));
  41. public ModuleName Station
  42. {
  43. get { return (ModuleName)GetValue(StationProperty); }
  44. set { SetValue(StationProperty, value); }
  45. }
  46. // Using a DependencyProperty as the backing store for Station. This enables animation, styling, binding, etc...
  47. public static readonly DependencyProperty StationProperty =
  48. DependencyProperty.Register("Station", typeof(ModuleName), typeof(WaferPro), new PropertyMetadata(ModuleName.System));
  49. public ICommand WaferTransferCommand
  50. {
  51. get { return (ICommand)GetValue(WaferTransferCommandProperty); }
  52. set { SetValue(WaferTransferCommandProperty, value); }
  53. }
  54. public bool ShowSlot
  55. {
  56. get { return (bool)GetValue(ShowSlotProperty); }
  57. set { SetValue(ShowSlotProperty, value); }
  58. }
  59. // Using a DependencyProperty as the backing store for ShowSlot. This enables animation, styling, binding, etc...
  60. public static readonly DependencyProperty ShowSlotProperty =
  61. DependencyProperty.Register("ShowSlot", typeof(bool), typeof(WaferPro), new PropertyMetadata(false));
  62. public bool ShowControl
  63. {
  64. get { return (bool)GetValue(ShowControlProperty); }
  65. set
  66. {
  67. SetValue(ShowControlProperty, value);
  68. }
  69. }
  70. public static readonly DependencyProperty ShowControlProperty =
  71. DependencyProperty.Register("ShowControl", typeof(bool), typeof(WaferPro), new FrameworkPropertyMetadata(true, FrameworkPropertyMetadataOptions.None));
  72. public Visibility ShowSlotIndex
  73. {
  74. get { return (Visibility)GetValue(ShowSlotIndexProperty); }
  75. set { SetValue(ShowSlotIndexProperty, value); }
  76. }
  77. // Using a DependencyProperty as the backing store for ShowSlot. This enables animation, styling, binding, etc...
  78. public static readonly DependencyProperty ShowSlotIndexProperty =
  79. DependencyProperty.Register("ShowSlotIndex", typeof(Visibility), typeof(WaferPro), new PropertyMetadata(Visibility.Hidden));
  80. // Using a DependencyProperty as the backing store for WaferMovementCommand. This enables animation, styling, binding, etc...
  81. public static readonly DependencyProperty WaferTransferCommandProperty =
  82. DependencyProperty.Register("WaferTransferCommand", typeof(ICommand), typeof(WaferPro), new PropertyMetadata(null));
  83. public WaferDisplayMode WaferIDDisplayMode
  84. {
  85. get { return (WaferDisplayMode)GetValue(WaferDisplayModeProperty); }
  86. set { SetValue(WaferDisplayModeProperty, value); }
  87. }
  88. // Using a DependencyProperty as the backing store for WaferIDDisplayMode. This enables animation, styling, binding, etc...
  89. public static readonly DependencyProperty WaferDisplayModeProperty =
  90. DependencyProperty.Register("WaferIDDisplayMode", typeof(WaferDisplayMode), typeof(WaferPro), new PropertyMetadata(WaferDisplayMode.None));
  91. public ICommand WaferTransferOptionCommand
  92. {
  93. get { return (ICommand)GetValue(WaferTransferOptionCommandProperty); }
  94. set { SetValue(WaferTransferOptionCommandProperty, value); }
  95. }
  96. // Using a DependencyProperty as the backing store for WaferTransferOptionCommand. This enables animation, styling, binding, etc...
  97. public static readonly DependencyProperty WaferTransferOptionCommandProperty =
  98. DependencyProperty.Register("WaferTransferOptionCommand", typeof(ICommand), typeof(WaferPro), new PropertyMetadata(null));
  99. public ICommand CreateDeleteWaferCommand
  100. {
  101. get { return (ICommand)GetValue(CreateDeleteWaferCommandProperty); }
  102. set { SetValue(CreateDeleteWaferCommandProperty, value); }
  103. }
  104. // Using a DependencyProperty as the backing store for CreateDeleteWaferCommand. This enables animation, styling, binding, etc...
  105. public static readonly DependencyProperty CreateDeleteWaferCommandProperty =
  106. DependencyProperty.Register("CreateDeleteWaferCommand", typeof(ICommand), typeof(WaferPro), new PropertyMetadata(null));
  107. private WaferStyle waferStyle = WaferStyle.Rect;
  108. public WaferStyle WaferStyle
  109. {
  110. get
  111. {
  112. return waferStyle;
  113. }
  114. set
  115. {
  116. waferStyle = value;
  117. }
  118. }
  119. public WaferPro()
  120. {
  121. InitializeComponent();
  122. CreateDeleteWaferCommand = new DelegateCommand<string>(CreateDeleteWafer);
  123. root.DataContext = this;
  124. }
  125. private void Wafer_MouseMove(object sender, MouseEventArgs e)
  126. {
  127. if (WaferItem == null || !ShowSlot)
  128. {
  129. return;
  130. }
  131. //if (Keyboard.IsKeyDown(Key.LeftCtrl) || Keyboard.IsKeyDown(Key.LeftShift))
  132. //{ return; }
  133. if (e.LeftButton == MouseButtonState.Pressed && (WaferItem.Status == WaferStatus.Normal || WaferItem.Status == WaferStatus.Dummy) && !WaferItem.IsSource)
  134. {
  135. var data = new DataObject();
  136. data.SetData("Object", WaferItem);
  137. data.SetData("Station", Station);
  138. data.SetData("Slot", Slot);
  139. DragDrop.DoDragDrop(sender as DependencyObject,
  140. data,
  141. DragDropEffects.Copy | DragDropEffects.Move);
  142. }
  143. }
  144. private void Wafer_Drop(object sender, DragEventArgs e)
  145. {
  146. //if (Keyboard.IsKeyDown(Key.LeftCtrl) || Keyboard.IsKeyDown(Key.LeftShift))
  147. //{ return; }
  148. if (sender != null)
  149. {
  150. var target = (Border)sender;
  151. target.BorderThickness = new Thickness(0);
  152. if (target.ToolTip as ToolTip != null)
  153. ((ToolTip)target.ToolTip).IsOpen = false;
  154. var sourceWafer = (WaferInfo)e.Data.GetData("Object");
  155. var sourceStation = (ModuleName)e.Data.GetData("Station");
  156. var sourceSlot = (int)e.Data.GetData("Slot");
  157. if (sourceWafer == null)
  158. {
  159. return;
  160. }
  161. if (sourceStation == ModuleName.Robot && Station == ModuleName.Robot)
  162. {
  163. return;
  164. }
  165. WaferTransferOption transferOption = null;
  166. if (WaferTransferOptionCommand != null)
  167. {
  168. transferOption = new WaferTransferOption();
  169. WaferTransferOptionCommand.Execute(transferOption);
  170. }
  171. //if (sourceWafer.SubstE90Status == EnumE90Status.InProcess || sourceWafer.SubstE90Status== EnumE90Status.NeedProcessing)
  172. //{
  173. // return;
  174. //}
  175. var dialog = new WaferTransferDialog(sourceWafer, sourceStation, sourceSlot, Station, Slot, transferOption);
  176. //dialog.SetControlShow(ShowControl);
  177. dialog.Owner = Window.GetWindow(this);
  178. if (dialog.ShowDialog() == true)
  179. {
  180. if (sourceWafer.Status == WaferStatus.Empty)
  181. {
  182. if (WaferTransferCommand != null)
  183. {
  184. WaferTransferCommand.Execute(new SorterRecipeTransferTableItem
  185. {
  186. SourceStation = sourceStation,
  187. SourceSlot = sourceSlot,
  188. DestinationStation = Station,
  189. DestinationSlot = Slot,
  190. IsAlign = dialog.Aligner,
  191. IsTurnOver = dialog.TurnOver,
  192. IsReadLaserMarker = dialog.ReadLaserMarker,
  193. IsReadT7Code = dialog.ReadT7Code,
  194. AlignAngle = dialog.AlignerAngle
  195. });
  196. }
  197. }
  198. else
  199. {
  200. if (WaferTransferCommand != null)
  201. {
  202. WaferTransferCommand.Execute(new SorterRecipeTransferTableItem
  203. {
  204. SourceStation = sourceStation,
  205. SourceSlot = sourceSlot,
  206. DestinationStation = Station,
  207. DestinationSlot = Slot,
  208. IsAlign = dialog.Aligner,
  209. IsTurnOver = dialog.TurnOver,
  210. IsReadLaserMarker = dialog.ReadLaserMarker,
  211. IsReadT7Code = dialog.ReadT7Code,
  212. AlignAngle = dialog.AlignerAngle
  213. });
  214. }
  215. else
  216. {
  217. var moveType = MoveType.Move;
  218. MoveOption moveOption = 0;
  219. if (dialog.Aligner)
  220. {
  221. moveOption |= MoveOption.Align;
  222. }
  223. if (dialog.TurnOver)
  224. {
  225. moveOption |= MoveOption.Turnover;
  226. }
  227. if (dialog.ReadLaserMarker)
  228. {
  229. moveOption |= MoveOption.ReadID;
  230. }
  231. if (dialog.ReadT7Code)
  232. {
  233. moveOption |= MoveOption.ReadID2;
  234. }
  235. var hand = (Hand)dialog.Blade;
  236. object[] param;
  237. if (hand == Hand.Both)
  238. {
  239. param = new object[]
  240. {
  241. moveType,
  242. moveOption,
  243. hand,
  244. sourceStation,
  245. sourceSlot,
  246. Station,
  247. Slot
  248. };
  249. InvokeClient.Instance.Service.DoOperation(OperationName.MultiMoveWafer, param);
  250. }
  251. else
  252. {
  253. param = new object[]
  254. {
  255. moveType,
  256. moveOption,
  257. hand,
  258. sourceStation,
  259. sourceSlot,
  260. Station,
  261. Slot
  262. };
  263. InvokeClient.Instance.Service.DoOperation(OperationName.MoveWafer.ToString(), param);
  264. }
  265. }
  266. }
  267. }
  268. }
  269. }
  270. private void CreateDeleteWafer(string cmd)
  271. {
  272. var param = new object[] { Station, Slot, WaferStatus.Normal };
  273. InvokeClient.Instance.Service.DoOperation(cmd, param);
  274. }
  275. private void Border_DragOver(object sender, DragEventArgs e)
  276. {
  277. //if (Keyboard.IsKeyDown(Key.LeftCtrl) || Keyboard.IsKeyDown(Key.LeftShift))
  278. //{ return; }
  279. var sourceWafer = (WaferInfo)e.Data.GetData("Object");
  280. var sourceStation = (ModuleName)e.Data.GetData("Station");
  281. var sourceSlot = (int)e.Data.GetData("Slot");
  282. if (!(sourceStation == Station && sourceSlot == Slot))
  283. {
  284. var target = (Border)sender;
  285. target.BorderThickness = new Thickness(1);
  286. ((ToolTip)target.ToolTip).Content = Slot + 1;
  287. ((ToolTip)target.ToolTip).IsOpen = true;
  288. }
  289. }
  290. private void Border_DragLeave(object sender, DragEventArgs e)
  291. {
  292. //if (Keyboard.IsKeyDown(Key.LeftCtrl) || Keyboard.IsKeyDown(Key.LeftShift))
  293. //{ return; }
  294. var sourceWafer = (WaferInfo)e.Data.GetData("Object");
  295. var sourceStation = (ModuleName)e.Data.GetData("Station");
  296. var sourceSlot = (int)e.Data.GetData("Slot");
  297. if (!(sourceStation == Station && sourceSlot == Slot))
  298. {
  299. var target = (Border)sender;
  300. target.BorderThickness = new Thickness(0);
  301. ((ToolTip)target.ToolTip).IsOpen = false;
  302. }
  303. }
  304. }
  305. }