CustomRobot.cs 7.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209
  1. using OpenSEMI.ClientBase;
  2. using System;
  3. using System.Collections.Generic;
  4. using System.Globalization;
  5. using System.Windows;
  6. using System.Windows.Controls;
  7. using System.Windows.Data;
  8. using System.Windows.Media;
  9. using System.Windows.Media.Animation;
  10. namespace PunkHPX8_Themes.CustomControls
  11. {
  12. public class WaferIntToColorConverter : IValueConverter
  13. {
  14. public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
  15. {
  16. return int.Parse(value.ToString()) == 1 ? new SolidColorBrush(Colors.Red) : new SolidColorBrush(Colors.Green);
  17. }
  18. public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
  19. {
  20. throw new NotImplementedException();
  21. }
  22. }
  23. public class WaferIntToVisibilityConverter : IValueConverter
  24. {
  25. public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
  26. {
  27. return int.Parse(value.ToString()) == 1 ? Visibility.Visible : Visibility.Hidden;
  28. }
  29. public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
  30. {
  31. throw new NotImplementedException();
  32. }
  33. }
  34. public enum WaferRobotXAction
  35. {
  36. X_Origin,
  37. Extend,
  38. Retract,
  39. Extend2,
  40. Retract2
  41. }
  42. public enum WaferRobotFAction
  43. {
  44. Upper,
  45. Down
  46. }
  47. public enum WaferRobotTAction
  48. {
  49. T_Origin,
  50. PMA,
  51. PMB,
  52. PMC,
  53. PMD,
  54. LLA,
  55. LLB,
  56. LP1,
  57. LP2,
  58. LP3,
  59. Aligner1,
  60. RightLocation,
  61. LeftLocation,
  62. Dummy1,
  63. Dummy2,
  64. SRD1,
  65. SRD2,
  66. VPW1,
  67. VPW2,
  68. PlatingCell1,
  69. PlatingCell2,
  70. PlatingCell3,
  71. PlatingCell4
  72. }
  73. public class WaferRobotControl : Control
  74. {
  75. static WaferRobotControl()
  76. {
  77. DefaultStyleKeyProperty.OverrideMetadata(typeof(WaferRobotControl), new FrameworkPropertyMetadata(typeof(WaferRobotControl)));
  78. }
  79. public static readonly DependencyProperty WaferProperty = DependencyProperty.Register("Wafer", typeof(int), typeof(WaferRobotControl));
  80. public int Wafer { get => (int)GetValue(WaferProperty); set => SetValue(WaferProperty, value); }
  81. public static readonly DependencyProperty ExtendTimeProperty = DependencyProperty.Register("ExtendTime", typeof(KeyTime), typeof(WaferRobotControl),new PropertyMetadata (KeyTime.FromTimeSpan(TimeSpan.FromSeconds(9))));
  82. public KeyTime ExtendTime { get => (KeyTime)GetValue(ExtendTimeProperty); set => SetValue(ExtendTimeProperty, value); }
  83. public static readonly DependencyProperty RobotWaferProperty = DependencyProperty.Register(
  84. "RobotWafer",
  85. typeof(WaferInfo),
  86. typeof(WaferRobotControl));
  87. public WaferInfo RobotWafer
  88. {
  89. get => (WaferInfo)GetValue(RobotWaferProperty);
  90. set => SetValue(RobotWaferProperty, value);
  91. }
  92. public static readonly DependencyProperty RobotXActionProperty = DependencyProperty.Register(
  93. "RobotXAction",
  94. typeof(WaferRobotXAction),
  95. typeof(WaferRobotControl),
  96. new PropertyMetadata(WaferRobotXAction.X_Origin, RobotXActionPropertyChangedCallback));
  97. public WaferRobotXAction RobotXAction
  98. {
  99. get => (WaferRobotXAction)GetValue(RobotXActionProperty);
  100. set => SetValue(RobotXActionProperty, value);
  101. }
  102. private static void RobotXActionPropertyChangedCallback(DependencyObject d, DependencyPropertyChangedEventArgs e)
  103. {
  104. //KeyTime value = KeyTime.FromTimeSpan(TimeSpan.FromSeconds(9));
  105. var control = d as WaferRobotControl;
  106. var oldAct = (WaferRobotXAction)e.OldValue;
  107. var newAct = (WaferRobotXAction)e.NewValue;
  108. switch (newAct)
  109. {
  110. case WaferRobotXAction.X_Origin:
  111. VisualStateManager.GoToState(control, newAct.ToString(), true);
  112. break;
  113. case WaferRobotXAction.Extend:
  114. if (newAct != oldAct)
  115. {
  116. VisualStateManager.GoToState(control, newAct.ToString(), true);
  117. }
  118. break;
  119. case WaferRobotXAction.Extend2:
  120. if (newAct != oldAct)
  121. {
  122. VisualStateManager.GoToState(control, newAct.ToString(), true);
  123. }
  124. break;
  125. case WaferRobotXAction.Retract2:
  126. if (newAct != oldAct)
  127. {
  128. VisualStateManager.GoToState(control, newAct.ToString(), true);
  129. }
  130. break;
  131. case WaferRobotXAction.Retract:
  132. if (newAct != oldAct)
  133. {
  134. VisualStateManager.GoToState(control, newAct.ToString(), true);
  135. }
  136. break;
  137. default:
  138. break;
  139. }
  140. }
  141. public static readonly DependencyProperty RobotTActionProperty = DependencyProperty.Register(
  142. "RobotTAction",
  143. typeof(WaferRobotTAction),
  144. typeof(WaferRobotControl),
  145. new PropertyMetadata(WaferRobotTAction.T_Origin, RobotTActionPropertyChangedCallback));
  146. public WaferRobotTAction RobotTAction
  147. {
  148. get => (WaferRobotTAction)GetValue(RobotTActionProperty);
  149. set => SetValue(RobotTActionProperty, value);
  150. }
  151. public static readonly DependencyProperty RobotSpeedProperty = DependencyProperty.Register(
  152. "RobotSpeed",
  153. typeof(double),
  154. typeof(WaferRobotControl),
  155. new PropertyMetadata(9.0d, RobotSpeedPropertyChangedCallback));
  156. public double RobotSpeed
  157. {
  158. get => (double)GetValue(RobotSpeedProperty);
  159. set => SetValue(RobotSpeedProperty, value);
  160. }
  161. private static void RobotSpeedPropertyChangedCallback(DependencyObject d, DependencyPropertyChangedEventArgs e)
  162. {
  163. }
  164. public string OriginT { get; set; }
  165. private static void RobotTActionPropertyChangedCallback(DependencyObject d, DependencyPropertyChangedEventArgs e)
  166. {
  167. var control = d as WaferRobotControl;
  168. var oldAct = (WaferRobotTAction)e.OldValue;
  169. var newAct = (WaferRobotTAction)e.NewValue;
  170. if(oldAct!=newAct)
  171. {
  172. VisualStateManager.GoToState(control, newAct.ToString(), true);
  173. }
  174. }
  175. public override void OnApplyTemplate()
  176. {
  177. base.OnApplyTemplate();
  178. VisualStateManager.GoToState(this, WaferRobotXAction.X_Origin.ToString(), true);
  179. VisualStateManager.GoToState(this, OriginT, true);
  180. }
  181. }
  182. }