SMIFNoMapStatus.xaml.cs 8.7 KB

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