WaferAssociationViewModel.cs 6.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211
  1. using System.Collections.Generic;
  2. using System.Collections.ObjectModel;
  3. using System.Linq;
  4. using Caliburn.Micro;
  5. using MECF.Framework.Common.RecipeCenter;
  6. using MECF.Framework.UI.Client.CenterViews.Editors.Sequence;
  7. using MECF.Framework.UI.Client.ClientBase;
  8. using OpenSEMI.ClientBase;
  9. namespace MECF.Framework.UI.Client.CenterViews.Operations.WaferAssociation
  10. {
  11. public class WaferAssociationViewModel : BaseModel
  12. {
  13. private WaferAssociationInfo _LP1;
  14. public WaferAssociationInfo LP1
  15. {
  16. get { return _LP1; }
  17. set { _LP1 = value; }
  18. }
  19. private WaferAssociationInfo _LP2;
  20. public WaferAssociationInfo LP2
  21. {
  22. get { return _LP2; }
  23. set { _LP2 = value; }
  24. }
  25. private WaferAssociationInfo _LP3;
  26. public WaferAssociationInfo LP3
  27. {
  28. get { return _LP3; }
  29. set { _LP3 = value; }
  30. }
  31. protected override void OnInitialize()
  32. {
  33. base.OnInitialize();
  34. #region test data
  35. LP1 = new WaferAssociationInfo();
  36. LP1.ModuleData = ModuleManager.ModuleInfos["LP1"];
  37. LP2 = new WaferAssociationInfo();
  38. LP2.ModuleData = ModuleManager.ModuleInfos["LP2"];
  39. LP3 = new WaferAssociationInfo();
  40. LP3.ModuleData = ModuleManager.ModuleInfos["LP3"];
  41. #endregion
  42. }
  43. #region functions
  44. #region Sequence operation
  45. public void SelectSequence(WaferAssociationInfo info)
  46. {
  47. SequenceDialogViewModel dialog = new SequenceDialogViewModel();
  48. dialog.DisplayName = "Select Sequence";
  49. dialog.Files = new ObservableCollection<FileNode>(RecipeSequenceTreeBuilder.GetFiles("",
  50. RecipeClient.Instance.Service.GetSequenceNameList()
  51. ));
  52. WindowManager wm = new WindowManager();
  53. bool? bret = wm.ShowDialog(dialog);
  54. if ((bool)bret)
  55. {
  56. info.SequenceName = dialog.DialogResult;
  57. }
  58. }
  59. public void SetSlot(WaferAssociationInfo info)
  60. {
  61. if (InputSlotCheck(info.SlotFrom, info.SlotTo))
  62. AssociateSequence(info, true);
  63. }
  64. public void SkipSlot(WaferAssociationInfo info)
  65. {
  66. if (InputSlotCheck(info.SlotFrom, info.SlotTo))
  67. AssociateSequence(info, false);
  68. }
  69. public void SetAll(WaferAssociationInfo info)
  70. {
  71. info.SlotFrom = 1;
  72. info.SlotTo = 25;
  73. AssociateSequence(info, true);
  74. }
  75. public void DeselectAll(WaferAssociationInfo info)
  76. {
  77. info.SlotFrom = 1;
  78. info.SlotTo = 25;
  79. AssociateSequence(info, false);
  80. }
  81. public void SetSequence(WaferAssociationInfo info, int slotIndex, string seqName)
  82. {
  83. bool flag = string.IsNullOrEmpty(seqName);
  84. AssociateSequence(info, flag, slotIndex - 1);
  85. }
  86. private bool InputSlotCheck(int from, int to)
  87. {
  88. if (from > to)
  89. {
  90. DialogBox.ShowInfo("This index of from slot should be large than the index of to slot.");
  91. return false;
  92. }
  93. if (from < 1 || to > 25)
  94. {
  95. DialogBox.ShowInfo("This input value for from should be between 1 and 25.");
  96. return false;
  97. }
  98. return true;
  99. }
  100. private void AssociateSequence(WaferAssociationInfo info, bool flag, int slot = -1)
  101. {
  102. ObservableCollection<WaferInfo> wafers = info.ModuleData.WaferManager.Wafers;
  103. if (slot >= 0) //by wafer
  104. {
  105. int index = wafers.Count - slot - 1;
  106. if (index < wafers.Count)
  107. {
  108. if (flag && HasWaferOnSlot(wafers.ToList(), index))
  109. wafers[index].SequenceName = info.SequenceName;
  110. else
  111. wafers[index].SequenceName = string.Empty;
  112. }
  113. }
  114. else //by from-to
  115. {
  116. for (int i = info.SlotFrom - 1; i < info.SlotTo; i++)
  117. {
  118. int index = wafers.Count - i - 1;
  119. if (index < wafers.Count)
  120. {
  121. if (flag && HasWaferOnSlot(wafers.ToList(), index))
  122. wafers[index].SequenceName = info.SequenceName;
  123. else
  124. wafers[index].SequenceName = string.Empty;
  125. }
  126. }
  127. }
  128. }
  129. private bool HasWaferOnSlot(List<WaferInfo> wafers, int index)
  130. {
  131. if (wafers[index].WaferStatus == 0)
  132. return false;
  133. return true;
  134. }
  135. #endregion
  136. #region Job operation
  137. private bool JobCheck(string jobID)
  138. {
  139. if (jobID.Length == 0)
  140. {
  141. DialogBox.ShowWarning("Please create job first.");
  142. return false;
  143. }
  144. else
  145. return true;
  146. }
  147. public void CreateJob(WaferAssociationInfo info)
  148. {
  149. List<object> param = new List<object>();
  150. param.Add(info.ModuleData.ModuleID);
  151. foreach (var wafer in info.ModuleData.WaferManager.Wafers)
  152. {
  153. param.Add(wafer.SequenceName);
  154. }
  155. param.Add(false); //auto start
  156. //WaferAssociationProvider.Instance.CreateJob(param.ToArray());
  157. }
  158. public void AbortJob(string jobID)
  159. {
  160. if (JobCheck(jobID))
  161. WaferAssociationProvider.Instance.AbortJob(jobID);
  162. }
  163. public void Start(string jobID)
  164. {
  165. if (JobCheck(jobID))
  166. WaferAssociationProvider.Instance.Start(jobID);
  167. }
  168. public void Pause(string jobID)
  169. {
  170. if (JobCheck(jobID))
  171. WaferAssociationProvider.Instance.Pause(jobID);
  172. }
  173. public void Resume(string jobID)
  174. {
  175. if (JobCheck(jobID))
  176. WaferAssociationProvider.Instance.Resume(jobID);
  177. }
  178. public void Stop(string jobID)
  179. {
  180. if (JobCheck(jobID))
  181. WaferAssociationProvider.Instance.Stop(jobID);
  182. }
  183. #endregion
  184. #endregion
  185. }
  186. }