Wafer.xaml.cs 11 KB

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