WaferAssociationViewModel.cs 6.0 KB

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