TransferSelectionViewModel.cs 8.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211
  1. using Aitex.Core.Common;
  2. using Aitex.Core.UI.MVVM;
  3. using Aitex.Core.Utilities;
  4. using Aitex.Sorter.Common;
  5. using Aitex.Sorter.UI.ViewModel;
  6. using MECF.Framework.Common.Equipment;
  7. using System;
  8. using System.Collections.Generic;
  9. using System.Collections.ObjectModel;
  10. using System.Linq;
  11. using System.Text;
  12. using System.Threading.Tasks;
  13. using System.Windows;
  14. using System.Windows.Controls;
  15. using System.Windows.Input;
  16. namespace Aitex.Sorter.UI.Controls
  17. {
  18. public class TransferSelectionViewModel : FoupListViewModelBase
  19. {
  20. public ObservableCollection<string> LoadPortList { get; set; }
  21. public TransferSelectionDialog MyTransferSelectionDialog { get; set; }
  22. public ICommand TransferCommand { get; set; }
  23. public ICommand OKCommand { get; set; }
  24. public ICommand CloseCommand { get; set; }
  25. public ICommand SelectionChangedCommand { get; set; }
  26. public ICommand QselectCommand { get; set; }
  27. public ICommand WaferTransferCommand { get; set; }
  28. public string TransferType { get; set; }
  29. public ObservableCollection<SorterRecipeTransferTableItem> TransferItems
  30. {
  31. get; set;
  32. }
  33. public void SetFoupCount(int foupCount)
  34. {
  35. LoadPortList = new ObservableCollection<string>();
  36. for (int i = 0; i < foupCount; i++)
  37. {
  38. LoadPortList.Add($"LP{ i + 1}");
  39. }
  40. }
  41. public string OriginalSelectedValue { get; set; }
  42. public string DestinationSelectedValue { get; set; }
  43. public TransferSelectionViewModel() : base("TransferSelection", 8)
  44. {
  45. TransferCommand = new DelegateCommand<string>(DoTransferCommand);
  46. OKCommand = new DelegateCommand<object>(DoOKCommand);
  47. CloseCommand = new DelegateCommand<object>(DoCloseCommand);
  48. SelectionChangedCommand = new DelegateCommand<object>(DoSelectionChangedCommand);
  49. QselectCommand=new DelegateCommand<object>(DoQselectCommand);
  50. WaferTransferCommand = new DelegateCommand<object>(DoWaferTransferCommand);
  51. TransferItems = new ObservableCollection<SorterRecipeTransferTableItem>();
  52. }
  53. private void DoWaferTransferCommand(object obj)
  54. {
  55. // TransferItems.Add(obj);
  56. }
  57. private void DoQselectCommand(object obj)
  58. {
  59. var placeMode = MyTransferSelectionDialog.CmbPlaceMode.Text;
  60. var cboOriginalTxt = MyTransferSelectionDialog.CboOriginal.Text;
  61. var cboDestination = MyTransferSelectionDialog.CboDestination.Text;
  62. if (placeMode != "")
  63. {
  64. switch (placeMode)
  65. {
  66. case "Opposite":
  67. foreach (var item in MyTransferSelectionDialog.OriginalFoupItem.Slots)
  68. {
  69. if (((WaferInfo)item).IsChecked)
  70. {
  71. var sorterRecipeTransferTableItem = new SorterRecipeTransferTableItem();
  72. sorterRecipeTransferTableItem.SourceStation = (ModuleName)Enum.Parse(typeof(ModuleName), cboOriginalTxt);
  73. sorterRecipeTransferTableItem.SourceSlot = ((WaferInfo)item).Slot;
  74. sorterRecipeTransferTableItem.DestinationStation = (ModuleName)Enum.Parse(typeof(ModuleName), cboDestination);
  75. sorterRecipeTransferTableItem.DestinationSlot =24- ((WaferInfo)item).Slot;
  76. TransferItems.Add(sorterRecipeTransferTableItem);
  77. }
  78. }
  79. break;
  80. case "Same":
  81. foreach (var item in MyTransferSelectionDialog.OriginalFoupItem.Slots)
  82. {
  83. if (((WaferInfo)item).IsChecked)
  84. {
  85. var sorterRecipeTransferTableItem = new SorterRecipeTransferTableItem();
  86. sorterRecipeTransferTableItem.SourceStation = (ModuleName)Enum.Parse(typeof(ModuleName), cboOriginalTxt);
  87. sorterRecipeTransferTableItem.SourceSlot = ((WaferInfo)item).Slot;
  88. sorterRecipeTransferTableItem.DestinationStation = (ModuleName)Enum.Parse(typeof(ModuleName), cboDestination);
  89. sorterRecipeTransferTableItem.DestinationSlot = ((WaferInfo)item).Slot;
  90. TransferItems.Add(sorterRecipeTransferTableItem);
  91. }
  92. }
  93. break;
  94. case "FromTop":
  95. int indexadd = 0;
  96. foreach (var item in MyTransferSelectionDialog.OriginalFoupItem.Slots)
  97. {
  98. if (((WaferInfo)item).IsChecked)
  99. {
  100. var sorterRecipeTransferTableItem = new SorterRecipeTransferTableItem();
  101. sorterRecipeTransferTableItem.SourceStation = (ModuleName)Enum.Parse(typeof(ModuleName), cboOriginalTxt);
  102. sorterRecipeTransferTableItem.SourceSlot = ((WaferInfo)item).Slot;
  103. sorterRecipeTransferTableItem.DestinationStation = (ModuleName)Enum.Parse(typeof(ModuleName), cboDestination);
  104. sorterRecipeTransferTableItem.DestinationSlot = indexadd;
  105. TransferItems.Add(sorterRecipeTransferTableItem);
  106. indexadd++;
  107. }
  108. }
  109. break;
  110. case "FromButtom":
  111. int indexsub = 24;
  112. foreach (var item in MyTransferSelectionDialog.OriginalFoupItem.Slots)
  113. {
  114. if (((WaferInfo)item).IsChecked)
  115. {
  116. var sorterRecipeTransferTableItem = new SorterRecipeTransferTableItem();
  117. sorterRecipeTransferTableItem.SourceStation = (ModuleName)Enum.Parse(typeof(ModuleName), cboOriginalTxt);
  118. sorterRecipeTransferTableItem.SourceSlot = ((WaferInfo)item).Slot;
  119. sorterRecipeTransferTableItem.DestinationStation = (ModuleName)Enum.Parse(typeof(ModuleName), cboDestination);
  120. sorterRecipeTransferTableItem.DestinationSlot = indexsub;
  121. TransferItems.Add(sorterRecipeTransferTableItem);
  122. indexsub--;
  123. }
  124. }
  125. break;
  126. default:
  127. break;
  128. }
  129. }
  130. }
  131. private void DoSelectionChangedCommand(object obj)
  132. {
  133. ComboBox comboBox = (ComboBox)obj;
  134. if (comboBox.Name == "CboOriginal")
  135. {
  136. if (MyTransferSelectionDialog.OriginalFoupItem.Slots != null)
  137. {
  138. foreach (var item in MyTransferSelectionDialog.OriginalFoupItem.Slots)
  139. {
  140. ((WaferInfo)item).IsChecked = false;
  141. }
  142. }
  143. MyTransferSelectionDialog.OriginalFoupItem.Slots = FoupList[int.Parse(((string)comboBox.SelectedValue).Replace("LP", "")) - 1].WaferInfos;
  144. }
  145. if (((ComboBox)obj).Name == "CboDestination")
  146. {
  147. foreach (var item in MyTransferSelectionDialog.DestinationFoupItem.Slots)
  148. {
  149. ((WaferInfo)item).IsChecked = false;
  150. }
  151. MyTransferSelectionDialog.DestinationFoupItem.Slots = FoupList[int.Parse(((string)comboBox.SelectedValue).Replace("LP", "")) - 1].WaferInfos;
  152. }
  153. }
  154. private void DoCloseCommand(object obj)
  155. {
  156. MyTransferSelectionDialog.DialogResult = false;
  157. MyTransferSelectionDialog.Close();
  158. }
  159. private void DoOKCommand(object obj)
  160. {
  161. MyTransferSelectionDialog.DialogResult = true;
  162. MyTransferSelectionDialog.Close();
  163. }
  164. //直接执行函数
  165. private void DoTransferCommand(string obj)
  166. {
  167. TransferType = obj;
  168. //switch (obj)
  169. //{
  170. // case "Opposite":
  171. // break;
  172. // case "Same":
  173. // break;
  174. // case "FromTop":
  175. // break;
  176. // case "FromButtom":
  177. // break;
  178. // default:
  179. // break;
  180. //}
  181. }
  182. }
  183. }