WaferRobotModifyViewModel.cs 7.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203
  1. using Aitex.Core.Common;
  2. using Aitex.Core.Util;
  3. using Caliburn.Micro.Core;
  4. using MECF.Framework.Common.DataCenter;
  5. using MECF.Framework.Common.OperationCenter;
  6. using MECF.Framework.UI.Client.ClientBase;
  7. using OpenSEMI.ClientBase;
  8. using System;
  9. using System.Collections.Generic;
  10. using System.Collections.ObjectModel;
  11. using System.Linq;
  12. using System.Text;
  13. using System.Threading.Tasks;
  14. using System.Windows;
  15. using FurnaceUI.Models;
  16. namespace FurnaceUI.Views.Operations
  17. {
  18. public class WaferRobotModifyViewModel : FurnaceUIViewModelBase
  19. {
  20. public WaferRobotModifyViewModel(string module)
  21. {
  22. IsProcessCanModifyFoupInfo = (bool)QueryDataClient.Instance.Service.GetConfig("System.ProcessStatusCanModifyFoupInfo");
  23. ModuleName = module;
  24. for (int i = 1; i <= 21; i++)
  25. {
  26. OriginModuleItems.Add($"Stocker{i}");
  27. }
  28. for (int i = (int)QueryDataClient.Instance.Service.GetConfig("WaferRobot.SlotCount"); i > 0; i--)
  29. {
  30. WaferRobotWaferInfoItems.Add(new WaferInfoItem() { SlotID = i });
  31. }
  32. }
  33. public string ModuleName { set; get; }
  34. public List<string> OriginModuleItems { get; set; } = new List<string>();
  35. private int? _waferRobotSlot = 1;
  36. public int? WaferRobotSlot
  37. {
  38. get => _waferRobotSlot;
  39. set
  40. {
  41. _waferRobotSlot = value;
  42. NotifyOfPropertyChange(nameof(WaferRobotSlot));
  43. }
  44. }
  45. private string _originSelectModule = "Stocker1";
  46. public string OriginSelectModule
  47. {
  48. get => _originSelectModule;
  49. set
  50. {
  51. _originSelectModule = value;
  52. NotifyOfPropertyChange(nameof(OriginSelectModule));
  53. }
  54. }
  55. private int? _originSlot = 1;
  56. public int? OriginSlot
  57. {
  58. get => _originSlot;
  59. set
  60. {
  61. _originSlot = value;
  62. NotifyOfPropertyChange(nameof(OriginSlot));
  63. }
  64. }
  65. public bool SDIsChecked { get; set; } = true;
  66. public bool EDIsChecked { get; set; }
  67. public bool PIsChecked { get; set; }
  68. public bool M1IsChecked { get; set; }
  69. public bool M2IsChecked { get; set; }
  70. public bool TIsChecked { get; set; }
  71. public bool XDIsChecked { get; set; }
  72. [Subscription("Stocker1.CassettePresent")]
  73. public bool IsCassettePresent { get; set; }
  74. [Subscription("Rt.Status")]
  75. public string RtStatus { get; set; }
  76. [Subscription("PM1.Status")]
  77. public string PM1Status { get; set; }
  78. public bool IsProcessCanModifyFoupInfo { get; set; } = false;
  79. public bool IsWaferRobotModifyEnabled
  80. {
  81. get
  82. {
  83. var pmStatus = PM1Status == "Init" || PM1Status == "Idle" || PM1Status == "Error" || (IsProcessCanModifyFoupInfo && PM1Status == "Process");
  84. var rtstatus = (RtStatus == "Init" || RtStatus == "Idle" || RtStatus == "Error") || (IsProcessCanModifyFoupInfo && RtStatus == "AutoRunning");
  85. return pmStatus && rtstatus;
  86. }
  87. }
  88. private ObservableCollection<WaferInfoItem> _waferRobotWaferInfoItems = new ObservableCollection<WaferInfoItem>();
  89. public ObservableCollection<WaferInfoItem> WaferRobotWaferInfoItems
  90. {
  91. get => _waferRobotWaferInfoItems;
  92. set
  93. {
  94. _waferRobotWaferInfoItems = value;
  95. NotifyOfPropertyChange(nameof(WaferRobotWaferInfoItems));
  96. }
  97. }
  98. protected override void InvokeAfterUpdateProperty(Dictionary<string, object> data)
  99. {
  100. RefreshCassetteDataTask();
  101. }
  102. private void RefreshCassetteDataTask()
  103. {
  104. var wafers = ModuleManager.ModuleInfos[ModuleName].WaferManager.Wafers;
  105. if (wafers != null)
  106. {
  107. int iIndex = wafers.Count - 1;
  108. for (int i = 0; i < wafers.Count; i++)
  109. {
  110. if (wafers[i].WaferStatus != 0)
  111. {
  112. WaferRobotWaferInfoItems[iIndex].ModuleID = wafers[i].ModuleID;
  113. WaferRobotWaferInfoItems[iIndex].SourceName = wafers[i].SourceName;
  114. WaferRobotWaferInfoItems[iIndex].WaferStatus = wafers[i].WaferStatus;
  115. WaferRobotWaferInfoItems[iIndex].WaferType = wafers[i].WaferType.ToString();
  116. WaferRobotWaferInfoItems[iIndex].UseCount = wafers[i].UseCount.ToString();
  117. WaferRobotWaferInfoItems[iIndex].UseTime = wafers[i].UseTime.ToString();
  118. WaferRobotWaferInfoItems[iIndex].UseThick = wafers[i].UseThick.ToString();
  119. }
  120. else
  121. {
  122. WaferRobotWaferInfoItems[iIndex].ModuleID = "";
  123. WaferRobotWaferInfoItems[iIndex].SourceName = "";
  124. WaferRobotWaferInfoItems[iIndex].WaferStatus = 0;
  125. WaferRobotWaferInfoItems[iIndex].WaferType = "";
  126. WaferRobotWaferInfoItems[iIndex].UseCount = "";
  127. WaferRobotWaferInfoItems[iIndex].UseTime = "";
  128. WaferRobotWaferInfoItems[iIndex].UseThick = "";
  129. }
  130. iIndex--;
  131. }
  132. }
  133. }
  134. public void CreateWafer()
  135. {
  136. if (!DialogBox.Confirm("Are you sure want to CreateWafer?"))
  137. return;
  138. WaferType waferType = WaferType.None;
  139. if (SDIsChecked)
  140. waferType = WaferType.SD;
  141. else if (EDIsChecked)
  142. waferType = WaferType.ED;
  143. else if (PIsChecked)
  144. waferType = WaferType.P;
  145. else if (M1IsChecked)
  146. waferType = WaferType.M1;
  147. else if (M2IsChecked)
  148. waferType = WaferType.M2;
  149. else if (XDIsChecked)
  150. waferType = WaferType.XD;
  151. else if (TIsChecked)
  152. waferType = WaferType.T;
  153. if (WaferRobotSlot < 1 || WaferRobotSlot > (int)QueryDataClient.Instance.Service.GetConfig("WaferRobot.SlotCount"))
  154. {
  155. DialogBox.ShowWarning($"WaferRobotSlot input error,can not create,input range 1 to {(int)QueryDataClient.Instance.Service.GetConfig("WaferRobot.SlotCount")}");
  156. return;
  157. }
  158. if (OriginSlot < 1 || OriginSlot > (int)QueryDataClient.Instance.Service.GetConfig("System.CassetteSlotCount"))
  159. {
  160. DialogBox.ShowWarning($"OriginSlot input error,can not create,input range 1 to {(int)QueryDataClient.Instance.Service.GetConfig("System.CassetteSlotCount")}");
  161. return;
  162. }
  163. InvokeClient.Instance.Service.DoOperation("CreateWafer", $"{ModuleName}", WaferRobotSlot - 1, waferType.ToString(), OriginSelectModule, OriginSlot - 1);
  164. }
  165. public void DeleteWafer()
  166. {
  167. if (!DialogBox.Confirm("Are you sure want to DeleteWafer?"))
  168. return;
  169. if (WaferRobotSlot < 1 || WaferRobotSlot > (int)QueryDataClient.Instance.Service.GetConfig("WaferRobot.SlotCount"))
  170. {
  171. DialogBox.ShowWarning($"WaferRobotSlot input error,can not delete,input range 1 to {(int)QueryDataClient.Instance.Service.GetConfig("WaferRobot.SlotCount")}");
  172. return;
  173. }
  174. InvokeClient.Instance.Service.DoOperation("DeleteWafer", $"{ModuleName}", WaferRobotSlot - 1);
  175. }
  176. public void CassetteClose()
  177. {
  178. ((Window)GetView()).DialogResult = false;
  179. }
  180. }
  181. }