LPStatus.xaml.cs 8.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220
  1. using Aitex.Core.UI.MVVM;
  2. using Aitex.Sorter.Common;
  3. using MECF.Framework.Common.OperationCenter;
  4. using System.Windows;
  5. using System.Windows.Controls;
  6. using System.Windows.Input;
  7. using MECF.Framework.Common.Equipment;
  8. namespace Aitex.Sorter.UI.Controls
  9. {
  10. /// <summary>
  11. /// LPStatus.xaml 的交互逻辑
  12. /// </summary>
  13. public partial class LPStatus : UserControl
  14. {
  15. public bool Placed
  16. {
  17. get { return (bool)GetValue(PlacedProperty); }
  18. set { SetValue(PlacedProperty, value); }
  19. }
  20. // Using a DependencyProperty as the backing store for Placed. This enables animation, styling, binding, etc...
  21. public static readonly DependencyProperty PlacedProperty =
  22. DependencyProperty.Register("Placed", typeof(bool), typeof(LPStatus), new PropertyMetadata(false));
  23. public bool Present
  24. {
  25. get { return (bool)GetValue(PresentProperty); }
  26. set { SetValue(PresentProperty, value); }
  27. }
  28. // Using a DependencyProperty as the backing store for Present. This enables animation, styling, binding, etc...
  29. public static readonly DependencyProperty PresentProperty =
  30. DependencyProperty.Register("Present", typeof(bool), typeof(LPStatus), new PropertyMetadata(false));
  31. public ModuleName Station
  32. {
  33. get { return (ModuleName)GetValue(StationSetProperty); }
  34. set { SetValue(StationSetProperty, value); }
  35. }
  36. // Using a DependencyProperty as the backing store for UnitName. This enables animation, styling, binding, etc...
  37. public static readonly DependencyProperty StationSetProperty =
  38. DependencyProperty.Register("Station", typeof(ModuleName), typeof(LPStatus), new PropertyMetadata(ModuleName.System));
  39. public string FoupID
  40. {
  41. get { return (string)GetValue(FoupIDProperty); }
  42. set { SetValue(FoupIDProperty, value); }
  43. }
  44. // Using a DependencyProperty as the backing store for FoupID. This enables animation, styling, binding, etc...
  45. public static readonly DependencyProperty FoupIDProperty =
  46. DependencyProperty.Register("FoupID", typeof(string), typeof(LPStatus), new PropertyMetadata(null));
  47. public string RFReader
  48. {
  49. get { return (string)GetValue(RFReaderProperty); }
  50. set { SetValue(RFReaderProperty, value); }
  51. }
  52. // Using a DependencyProperty as the backing store for RFReader. This enables animation, styling, binding, etc...
  53. public static readonly DependencyProperty RFReaderProperty =
  54. DependencyProperty.Register("RFReader", typeof(string), typeof(LPStatus), new PropertyMetadata(null));
  55. public string Status
  56. {
  57. get { return (string)GetValue(StatusProperty); }
  58. set { SetValue(StatusProperty, value); }
  59. }
  60. // Using a DependencyProperty as the backing store for Status. This enables animation, styling, binding, etc...
  61. public static readonly DependencyProperty StatusProperty =
  62. DependencyProperty.Register("Status", typeof(string), typeof(LPStatus), new PropertyMetadata(null));
  63. public string CassetteState
  64. {
  65. get { return (string)GetValue(CassetteStateProperty); }
  66. set { SetValue(CassetteStateProperty, value); }
  67. }
  68. // Using a DependencyProperty as the backing store for CassetteState. This enables animation, styling, binding, etc...
  69. public static readonly DependencyProperty CassetteStateProperty =
  70. DependencyProperty.Register("CassetteState", typeof(string), typeof(LPStatus), new PropertyMetadata(null));
  71. public string ClampStatus
  72. {
  73. get { return (string)GetValue(ClampStatusProperty); }
  74. set { SetValue(ClampStatusProperty, value); }
  75. }
  76. // Using a DependencyProperty as the backing store for ClampStatus. This enables animation, styling, binding, etc...
  77. public static readonly DependencyProperty ClampStatusProperty =
  78. DependencyProperty.Register("ClampStatus", typeof(string), typeof(LPStatus), new PropertyMetadata(null));
  79. public string FoupDoorStatus
  80. {
  81. get { return (string)GetValue(FoupDoorStatusProperty); }
  82. set { SetValue(FoupDoorStatusProperty, value); }
  83. }
  84. // Using a DependencyProperty as the backing store for FoupDoorStatus. This enables animation, styling, binding, etc...
  85. public static readonly DependencyProperty FoupDoorStatusProperty =
  86. DependencyProperty.Register("FoupDoorStatus", typeof(string), typeof(LPStatus), new PropertyMetadata(null));
  87. public bool LoadPortLoaded
  88. {
  89. get { return (bool)GetValue(LoadPortLoadedProperty); }
  90. set { SetValue(LoadPortLoadedProperty, value); }
  91. }
  92. // Using a DependencyProperty as the backing store for LoadPortLoaded. This enables animation, styling, binding, etc...
  93. public static readonly DependencyProperty LoadPortLoadedProperty =
  94. DependencyProperty.Register("LoadPortLoaded", typeof(bool), typeof(LPStatus), new PropertyMetadata(false));
  95. public bool LoadPortUnloaded
  96. {
  97. get { return (bool)GetValue(LoadPortUnloadedProperty); }
  98. set { SetValue(LoadPortUnloadedProperty, value); }
  99. }
  100. // Using a DependencyProperty as the backing store for LoadPortUnloaded. This enables animation, styling, binding, etc...
  101. public static readonly DependencyProperty LoadPortUnloadedProperty =
  102. DependencyProperty.Register("LoadPortUnloaded", typeof(bool), typeof(LPStatus), new PropertyMetadata(false));
  103. public bool IsAlarm
  104. {
  105. get { return (bool)GetValue(IsAlarmProperty); }
  106. set { SetValue(IsAlarmProperty, value); }
  107. }
  108. // Using a DependencyProperty as the backing store for IsAlarm. This enables animation, styling, binding, etc...
  109. public static readonly DependencyProperty IsAlarmProperty =
  110. DependencyProperty.Register("IsAlarm", typeof(bool), typeof(LPStatus), new PropertyMetadata(false));
  111. public int RoutManagerState
  112. {
  113. get { return (int)GetValue(RoutManagerStateProperty); }
  114. set { SetValue(RoutManagerStateProperty, value); }
  115. }
  116. // Using a DependencyProperty as the backing store for RoutManagerState. This enables animation, styling, binding, etc...
  117. public static readonly DependencyProperty RoutManagerStateProperty =
  118. DependencyProperty.Register("RoutManagerState", typeof(int), typeof(LPStatus), new PropertyMetadata((int)RtState.Init, StateChangedCallback));
  119. public bool IsAutoMode
  120. {
  121. get { return (bool)GetValue(IsAutoModeProperty); }
  122. set { SetValue(IsAutoModeProperty, value); }
  123. }
  124. // Using a DependencyProperty as the backing store for IsAutoMode. This enables animation, styling, binding, etc...
  125. public static readonly DependencyProperty IsAutoModeProperty =
  126. DependencyProperty.Register("IsAutoMode", typeof(bool), typeof(LPStatus), new PropertyMetadata(false, StateChangedCallback));
  127. public bool IsManualMode
  128. {
  129. get { return (bool)GetValue(IsManualModeProperty); }
  130. set { SetValue(IsManualModeProperty, value); }
  131. }
  132. // Using a DependencyProperty as the backing store for IsAutoMode. This enables animation, styling, binding, etc...
  133. public static readonly DependencyProperty IsManualModeProperty =
  134. DependencyProperty.Register("IsManualMode", typeof(bool), typeof(LPStatus), new PropertyMetadata(false, StateChangedCallback));
  135. public static void StateChangedCallback(DependencyObject d, DependencyPropertyChangedEventArgs e)
  136. {
  137. var self = d as LPStatus;
  138. if (self.DeviceOperationCommand != null)
  139. {
  140. ((IDelegateCommand)self.DeviceOperationCommand).RaiseCanExecuteChanged();
  141. }
  142. if (self.RFReaderCommand != null)
  143. {
  144. ((IDelegateCommand)self.RFReaderCommand).RaiseCanExecuteChanged();
  145. }
  146. }
  147. public LPStatus()
  148. {
  149. InitializeComponent();
  150. DeviceOperationCommand = new DelegateCommand<string>(DeviceOperation, x => RoutManagerState != (int)RtState.Maintenance && !IsAutoMode);
  151. RFReaderCommand = new DelegateCommand<string>(RFReaderOperation, x => RoutManagerState != (int)RtState.Maintenance && !IsAutoMode);
  152. root.DataContext = this;
  153. }
  154. public ICommand DeviceOperationCommand
  155. {
  156. get;
  157. private set;
  158. }
  159. public ICommand RFReaderCommand
  160. {
  161. get;
  162. private set;
  163. }
  164. void DeviceOperation(string cmd)
  165. {
  166. var deviceName = Station.ToString();
  167. var param = new object[] { deviceName, cmd };
  168. InvokeClient.Instance.Service.DoOperation(OperationName.DeviceOperation.ToString(), param);
  169. }
  170. void RFReaderOperation(string cmd)
  171. {
  172. var deviceName = RFReader;
  173. var param = new object[] { deviceName, cmd };
  174. InvokeClient.Instance.Service.DoOperation(OperationName.DeviceOperation.ToString(), param);
  175. }
  176. }
  177. }