CustomRobot.cs 7.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210
  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. None,
  45. UpperToDown,
  46. DownToUpper
  47. }
  48. public enum WaferRobotTAction
  49. {
  50. T_Origin,
  51. PMA,
  52. PMB,
  53. PMC,
  54. PMD,
  55. LLA,
  56. LLB,
  57. LP1,
  58. LP2,
  59. LP3,
  60. Aligner1,
  61. RightLocation,
  62. LeftLocation,
  63. Dummy1,
  64. Dummy2,
  65. SRD1,
  66. SRD2,
  67. VPW1,
  68. VPW2,
  69. PlatingCell1,
  70. PlatingCell2,
  71. PlatingCell3,
  72. PlatingCell4
  73. }
  74. public class WaferRobotControl : Control
  75. {
  76. static WaferRobotControl()
  77. {
  78. DefaultStyleKeyProperty.OverrideMetadata(typeof(WaferRobotControl), new FrameworkPropertyMetadata(typeof(WaferRobotControl)));
  79. }
  80. public static readonly DependencyProperty WaferProperty = DependencyProperty.Register("Wafer", typeof(int), typeof(WaferRobotControl));
  81. public int Wafer { get => (int)GetValue(WaferProperty); set => SetValue(WaferProperty, value); }
  82. public static readonly DependencyProperty ExtendTimeProperty = DependencyProperty.Register("ExtendTime", typeof(KeyTime), typeof(WaferRobotControl),new PropertyMetadata (KeyTime.FromTimeSpan(TimeSpan.FromSeconds(9))));
  83. public KeyTime ExtendTime { get => (KeyTime)GetValue(ExtendTimeProperty); set => SetValue(ExtendTimeProperty, value); }
  84. public static readonly DependencyProperty RobotWaferProperty = DependencyProperty.Register(
  85. "RobotWafer",
  86. typeof(WaferInfo),
  87. typeof(WaferRobotControl));
  88. public WaferInfo RobotWafer
  89. {
  90. get => (WaferInfo)GetValue(RobotWaferProperty);
  91. set => SetValue(RobotWaferProperty, value);
  92. }
  93. public static readonly DependencyProperty RobotXActionProperty = DependencyProperty.Register(
  94. "RobotXAction",
  95. typeof(WaferRobotXAction),
  96. typeof(WaferRobotControl),
  97. new PropertyMetadata(WaferRobotXAction.X_Origin, RobotXActionPropertyChangedCallback));
  98. public WaferRobotXAction RobotXAction
  99. {
  100. get => (WaferRobotXAction)GetValue(RobotXActionProperty);
  101. set => SetValue(RobotXActionProperty, value);
  102. }
  103. private static void RobotXActionPropertyChangedCallback(DependencyObject d, DependencyPropertyChangedEventArgs e)
  104. {
  105. //KeyTime value = KeyTime.FromTimeSpan(TimeSpan.FromSeconds(9));
  106. var control = d as WaferRobotControl;
  107. var oldAct = (WaferRobotXAction)e.OldValue;
  108. var newAct = (WaferRobotXAction)e.NewValue;
  109. switch (newAct)
  110. {
  111. case WaferRobotXAction.X_Origin:
  112. VisualStateManager.GoToState(control, newAct.ToString(), true);
  113. break;
  114. case WaferRobotXAction.Extend:
  115. if (newAct != oldAct)
  116. {
  117. VisualStateManager.GoToState(control, newAct.ToString(), true);
  118. }
  119. break;
  120. case WaferRobotXAction.Extend2:
  121. if (newAct != oldAct)
  122. {
  123. VisualStateManager.GoToState(control, newAct.ToString(), true);
  124. }
  125. break;
  126. case WaferRobotXAction.Retract2:
  127. if (newAct != oldAct)
  128. {
  129. VisualStateManager.GoToState(control, newAct.ToString(), true);
  130. }
  131. break;
  132. case WaferRobotXAction.Retract:
  133. if (newAct != oldAct)
  134. {
  135. VisualStateManager.GoToState(control, newAct.ToString(), true);
  136. }
  137. break;
  138. default:
  139. break;
  140. }
  141. }
  142. public static readonly DependencyProperty RobotTActionProperty = DependencyProperty.Register(
  143. "RobotTAction",
  144. typeof(WaferRobotTAction),
  145. typeof(WaferRobotControl),
  146. new PropertyMetadata(WaferRobotTAction.T_Origin, RobotTActionPropertyChangedCallback));
  147. public WaferRobotTAction RobotTAction
  148. {
  149. get => (WaferRobotTAction)GetValue(RobotTActionProperty);
  150. set => SetValue(RobotTActionProperty, value);
  151. }
  152. public static readonly DependencyProperty RobotSpeedProperty = DependencyProperty.Register(
  153. "RobotSpeed",
  154. typeof(double),
  155. typeof(WaferRobotControl),
  156. new PropertyMetadata(9.0d, RobotSpeedPropertyChangedCallback));
  157. public double RobotSpeed
  158. {
  159. get => (double)GetValue(RobotSpeedProperty);
  160. set => SetValue(RobotSpeedProperty, value);
  161. }
  162. private static void RobotSpeedPropertyChangedCallback(DependencyObject d, DependencyPropertyChangedEventArgs e)
  163. {
  164. }
  165. public string OriginT { get; set; }
  166. private static void RobotTActionPropertyChangedCallback(DependencyObject d, DependencyPropertyChangedEventArgs e)
  167. {
  168. var control = d as WaferRobotControl;
  169. var oldAct = (WaferRobotTAction)e.OldValue;
  170. var newAct = (WaferRobotTAction)e.NewValue;
  171. if(oldAct!=newAct)
  172. {
  173. VisualStateManager.GoToState(control, newAct.ToString(), true);
  174. }
  175. }
  176. public override void OnApplyTemplate()
  177. {
  178. base.OnApplyTemplate();
  179. VisualStateManager.GoToState(this, WaferRobotXAction.X_Origin.ToString(), true);
  180. VisualStateManager.GoToState(this, OriginT, true);
  181. }
  182. }
  183. }