CassetteViewV2.xaml.cs 7.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189
  1. using MECF.Framework.Common.OperationCenter;
  2. using MECF.Framework.Common.SubstrateTrackings;
  3. using MECF.Framework.UI.Client.Annotations;
  4. using System;
  5. using System.ComponentModel;
  6. using System.Runtime.CompilerServices;
  7. using System.Windows;
  8. using System.Windows.Controls;
  9. using System.Windows.Media;
  10. using System.Windows.Media.Animation;
  11. namespace FurnaceUI.Controls.Parts
  12. {
  13. /// <summary>
  14. /// CassetteView.xaml 的交互逻辑
  15. /// </summary>
  16. public partial class CassetteViewV2 : UserControl, INotifyPropertyChanged
  17. {
  18. public bool DiSensorValue
  19. {
  20. get { return (bool)GetValue(DiSensorValueProperty); }
  21. set { SetValue(DiSensorValueProperty, value); }
  22. }
  23. public static readonly DependencyProperty DiSensorValueProperty =
  24. DependencyProperty.Register("DiSensorValue", typeof(bool), typeof(CassetteViewV2), new FrameworkPropertyMetadata(true, FrameworkPropertyMetadataOptions.AffectsRender));
  25. public string CarrierModule
  26. {
  27. get { return (string)GetValue(CarrierModuleProperty); }
  28. set
  29. {
  30. SetValue(CarrierModuleProperty, value);
  31. }
  32. }
  33. public static readonly DependencyProperty CarrierModuleProperty =
  34. DependencyProperty.Register("CarrierModule", typeof(string), typeof(CassetteViewV2), new PropertyMetadata("System"));
  35. public int CarrierSlot
  36. {
  37. get { return (int)GetValue(CarrierSlotProperty); }
  38. set
  39. {
  40. SetValue(CarrierSlotProperty, value);
  41. }
  42. }
  43. public static readonly DependencyProperty CarrierSlotProperty =
  44. DependencyProperty.Register("CarrierSlot", typeof(int), typeof(CassetteViewV2), new PropertyMetadata(0));
  45. public CarrierInfo CarrierData
  46. {
  47. get { return (CarrierInfo)GetValue(CarrierDataProperty); }
  48. set
  49. {
  50. SetValue(CarrierDataProperty, value);
  51. }
  52. }
  53. public static readonly DependencyProperty CarrierDataProperty =
  54. DependencyProperty.Register("CarrierData", typeof(CarrierInfo), typeof(CassetteViewV2), new PropertyMetadata(new CarrierInfo(1), CarrierDataChangedCallback));
  55. public string CassetteType
  56. {
  57. get { return (string)GetValue(CassetteTypeProperty); }
  58. set
  59. {
  60. SetValue(CassetteTypeProperty, value);
  61. }
  62. }
  63. // Using a DependencyProperty as the backing store for CassetteType. This enables animation, styling, binding, etc...
  64. public static readonly DependencyProperty CassetteTypeProperty =
  65. DependencyProperty.Register("CassetteType", typeof(string), typeof(CassetteViewV2), new PropertyMetadata(""));
  66. public int WaferCount
  67. {
  68. get { return (int)GetValue(WaferCountProperty); }
  69. set
  70. {
  71. SetValue(WaferCountProperty, value);
  72. }
  73. }
  74. // Using a DependencyProperty as the backing store for WaferCount. This enables animation, styling, binding, etc...
  75. public static readonly DependencyProperty WaferCountProperty =
  76. DependencyProperty.Register("WaferCount", typeof(int), typeof(CassetteViewV2), new PropertyMetadata(0));
  77. private string _cassetteStatus;
  78. /// <summary>
  79. /// Foup的状态,如果在Processing中会显示绿色
  80. /// 其他状态根据waferType定义显示颜色
  81. /// </summary>
  82. public string CassetteStatus
  83. {
  84. get { return _cassetteStatus; }
  85. set
  86. {
  87. if (_cassetteStatus != value)
  88. {
  89. _cassetteStatus = value;
  90. OnPropertyChanged();
  91. }
  92. }
  93. }
  94. //P(P1,P2),M1(M,M1),M2,SD,ED,V,R(R1,R2),Process
  95. public double oldScale = 0;
  96. public static void CarrierDataChangedCallback(DependencyObject d, DependencyPropertyChangedEventArgs e)
  97. {
  98. var selfView = (CassetteViewV2)d;
  99. var carrierInfo = (CarrierInfo)e.NewValue;
  100. var moduleName = selfView.CarrierModule;
  101. }
  102. public CassetteViewV2()
  103. {
  104. InitializeComponent();
  105. }
  106. public event PropertyChangedEventHandler PropertyChanged;
  107. [NotifyPropertyChangedInvocator]
  108. protected virtual void OnPropertyChanged([CallerMemberName] string propertyName = null)
  109. {
  110. PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
  111. }
  112. public void Filp(int filp, int angle, bool absolute = true, int ms = 0, double accelerationRatio = 0, double decelerationRatio = 0, Action onComplete = null)
  113. {
  114. var storyboard = new Storyboard();
  115. storyboard.Completed += (s, e) => onComplete?.Invoke();
  116. if (Filp(storyboard, filp, angle, absolute, ms, accelerationRatio, decelerationRatio, onComplete))
  117. {
  118. storyboard.Begin();
  119. }
  120. else
  121. {
  122. onComplete?.Invoke();
  123. }
  124. }
  125. public bool Filp(Storyboard storyboard, int filp, int angle, bool absolute = true, int ms = 0, double accelerationRatio = 0, double decelerationRatio = 0, Action onComplete = null)
  126. {
  127. var newScale = 0.5;
  128. if (newScale == oldScale)
  129. {
  130. return false;
  131. }
  132. ScaleTransform scaleTransform = new ScaleTransform();
  133. if (filp == 180)
  134. {
  135. scaleTransform.ScaleX = -1;
  136. }
  137. else
  138. {
  139. scaleTransform.ScaleX = 1;
  140. }
  141. TransformGroup Group = new TransformGroup();
  142. Group.Children.Add(scaleTransform);
  143. tbWaferCount.RenderTransform = Group;
  144. tbWaferCount.RenderTransformOrigin = new Point(0.5, 0.5);
  145. var animation = new DoubleAnimation(oldScale, angle, TimeSpan.FromMilliseconds(ms));
  146. animation.AccelerationRatio = accelerationRatio;
  147. animation.DecelerationRatio = decelerationRatio;
  148. storyboard.Children.Add(animation);
  149. Storyboard.SetTarget(animation, tbWaferCount);
  150. Storyboard.SetTargetProperty(animation, new PropertyPath("RenderTransform.(TransformGroup.Children)[0].(TranslateTransform.X)"));
  151. oldScale = angle;
  152. return true;
  153. }
  154. private void CreateCassette(object sender, RoutedEventArgs e)
  155. {
  156. InvokeClient.Instance.Service.DoOperation("System.CreateCarrier", CarrierModule, 0);
  157. }
  158. private void DeleteCassette(object sender, RoutedEventArgs e)
  159. {
  160. InvokeClient.Instance.Service.DoOperation("System.DeleteCarrier", CarrierModule, 0);
  161. }
  162. }
  163. }