BoatModifyViewModel.cs 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342
  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. using FurnaceUI.Views.Editors;
  17. namespace FurnaceUI.Views.Operations
  18. {
  19. public class BoatModifyViewModel : FurnaceUIViewModelBase
  20. {
  21. public BoatModifyViewModel(string module)
  22. {
  23. IsProcessCanModifyFoupInfo = (bool)QueryDataClient.Instance.Service.GetConfig("System.ProcessStatusCanModifyFoupInfo");
  24. ModuleName = module;
  25. for (int i = 1; i <= 21; i++)
  26. {
  27. OriginModuleItems.Add($"Stocker{i}");
  28. }
  29. var count = (int)QueryDataClient.Instance.Service.GetConfig("Boat.SlotCount");
  30. for (int i = count; i > 0; i--)
  31. {
  32. BoatWaferInfoItems.Add(new WaferInfoItem() { SlotID = i });
  33. BoatMapWafers.Add("");
  34. }
  35. }
  36. public string ModuleName { set; get; }
  37. public List<string> OriginModuleItems { get; set; } = new List<string>();
  38. public bool IsPermission { get => this.Permission == 3; }
  39. public bool IsEnableManualOperation => IsPermission && RtStatus != "AutoRunning";
  40. private int? _boatSlotFrom = 1;
  41. public int? BoatSlotFrom
  42. {
  43. get => _boatSlotFrom;
  44. set
  45. {
  46. _boatSlotFrom = value;
  47. NotifyOfPropertyChange(nameof(BoatSlotFrom));
  48. }
  49. }
  50. private int? _boatSlotTo = 1;
  51. public int? BoatSlotTo
  52. {
  53. get => _boatSlotTo;
  54. set
  55. {
  56. _boatSlotTo = value;
  57. NotifyOfPropertyChange(nameof(BoatSlotTo));
  58. }
  59. }
  60. private string _originSelectModule = "Stocker1";
  61. public string OriginSelectModule
  62. {
  63. get => _originSelectModule;
  64. set
  65. {
  66. _originSelectModule = value;
  67. NotifyOfPropertyChange(nameof(OriginSelectModule));
  68. }
  69. }
  70. private int? _originSlot = 1;
  71. public int? OriginSlot
  72. {
  73. get => _originSlot;
  74. set
  75. {
  76. _originSlot = value;
  77. NotifyOfPropertyChange(nameof(OriginSlot));
  78. }
  79. }
  80. public bool SDIsChecked { get; set; } = true;
  81. public bool EDIsChecked { get; set; }
  82. public bool PIsChecked { get; set; }
  83. public bool M1IsChecked { get; set; }
  84. public bool M2IsChecked { get; set; }
  85. public bool XDIsChecked { get; set; }
  86. [Subscription("Stocker1.CassettePresent")]
  87. public bool IsCassettePresent { get; set; }
  88. [Subscription("Rt.Status")]
  89. public string RtStatus { get; set; }
  90. [Subscription("PM1.Status")]
  91. public string PM1Status { get; set; }
  92. public bool IsProcessCanModifyFoupInfo { get; set; } = false;
  93. public bool IsEnableWaferManualOperation
  94. {
  95. get
  96. {
  97. var pmStatus = PM1Status == "Init" || PM1Status == "Idle" || PM1Status == "Error" || (IsProcessCanModifyFoupInfo && PM1Status == "Process");
  98. var rtstatus = (RtStatus == "Init" || RtStatus == "Idle" || RtStatus == "Error") || (IsProcessCanModifyFoupInfo && RtStatus == "AutoRunning");
  99. return pmStatus && rtstatus;
  100. }
  101. }
  102. private List<string> _boatMapWafers = new List<string>();
  103. public List<string> BoatMapWafers
  104. {
  105. get => _boatMapWafers;
  106. set
  107. {
  108. _boatMapWafers = value;
  109. NotifyOfPropertyChange(nameof(BoatMapWafers));
  110. }
  111. }
  112. private ObservableCollection<WaferInfoItem> _boatWaferInfoItems = new ObservableCollection<WaferInfoItem>();
  113. public ObservableCollection<WaferInfoItem> BoatWaferInfoItems
  114. {
  115. get => _boatWaferInfoItems;
  116. set
  117. {
  118. _boatWaferInfoItems = value;
  119. NotifyOfPropertyChange(nameof(BoatWaferInfoItems));
  120. }
  121. }
  122. private int _upperSDNum = 0;
  123. public int UpperSDNum
  124. {
  125. get => _upperSDNum;
  126. set
  127. {
  128. _upperSDNum = value;
  129. NotifyOfPropertyChange(nameof(UpperSDNum));
  130. }
  131. }
  132. private int _productNum = 0;
  133. public int ProductNum
  134. {
  135. get => _productNum;
  136. set
  137. {
  138. _productNum = value;
  139. NotifyOfPropertyChange(nameof(ProductNum));
  140. }
  141. }
  142. private int _monitorNum1 = 0;
  143. public int MonitorNum1
  144. {
  145. get => _monitorNum1;
  146. set
  147. {
  148. _monitorNum1 = value;
  149. NotifyOfPropertyChange(nameof(MonitorNum1));
  150. }
  151. }
  152. private int _monitorNum2 = 0;
  153. public int MonitorNum2
  154. {
  155. get => _monitorNum2;
  156. set
  157. {
  158. _monitorNum2 = value;
  159. NotifyOfPropertyChange(nameof(MonitorNum2));
  160. }
  161. }
  162. private int _lowerSDNum = 0;
  163. public int LowerSDNum
  164. {
  165. get => _lowerSDNum;
  166. set
  167. {
  168. _lowerSDNum = value;
  169. NotifyOfPropertyChange(nameof(LowerSDNum));
  170. }
  171. }
  172. private int _lowerSideDummyNum = 9;
  173. private Tuple<int, int> ComputSD(List<string> dataSource)
  174. {
  175. List<string> otherSlot = dataSource.Where(a => a != "SD" && !string.IsNullOrEmpty(a)).ToList().Distinct().ToList();
  176. if (dataSource == null || dataSource.Count == 0)
  177. {
  178. return new Tuple<int, int>(0, 0);
  179. }
  180. List<int> minList = new List<int>();
  181. for (int i = 0; i < dataSource.Count; i++)
  182. {
  183. var item = dataSource[i];
  184. if (otherSlot.Contains(item) && !string.IsNullOrEmpty(item))
  185. {
  186. break;
  187. }
  188. if (string.IsNullOrEmpty(item))
  189. {
  190. continue;
  191. }
  192. minList.Add(i);
  193. }
  194. dataSource.Reverse();
  195. List<int> maxList = new List<int>();
  196. for (int i = 0; i < dataSource.Count; i++)
  197. {
  198. var item = dataSource[i];
  199. if (otherSlot.Contains(item) && !string.IsNullOrEmpty(item))
  200. {
  201. break;
  202. }
  203. if (string.IsNullOrEmpty(item))
  204. {
  205. continue;
  206. }
  207. maxList.Add(i);
  208. }
  209. return new Tuple<int, int>(minList.Count(), maxList.Count());
  210. }
  211. protected override void InvokeAfterUpdateProperty(Dictionary<string, object> data)
  212. {
  213. RefreshCassetteDataTask();
  214. if (null != BoatMapWafers && BoatMapWafers.Count > 0)
  215. {
  216. BoatMapWafers.Reverse();
  217. UpperSDNum = BoatMapWafers.Where(x => x == "SD").Count();
  218. LowerSDNum = BoatMapWafers.Where(x => x == "ED").Count();
  219. ProductNum = BoatMapWafers.Where(x => !string.IsNullOrEmpty(x) && x.StartsWith("P")).Count();
  220. MonitorNum1 = BoatMapWafers.Where(x => x == "M1").Count();
  221. MonitorNum2 = BoatMapWafers.Where(x => x == "M2").Count();
  222. }
  223. }
  224. private void RefreshCassetteDataTask()
  225. {
  226. var wafers = ModuleManager.ModuleInfos[ModuleName].WaferManager.Wafers;
  227. if (wafers != null)
  228. {
  229. int iIndex = 0;
  230. for (int i = 0; i < wafers.Count; i++)
  231. {
  232. if (wafers[i].WaferStatus != 0)
  233. {
  234. BoatWaferInfoItems[iIndex].ModuleID = wafers[i].ModuleID;
  235. if (string.IsNullOrEmpty(wafers[i].LotId))
  236. BoatWaferInfoItems[iIndex].SourceName = wafers[i].SourceName;
  237. else
  238. BoatWaferInfoItems[iIndex].SourceName = wafers[i].LotId + "-" + wafers[i].SourceName;
  239. BoatWaferInfoItems[iIndex].WaferStatus = wafers[i].WaferStatus;
  240. BoatWaferInfoItems[iIndex].WaferType = wafers[i].WaferType.ToString();
  241. BoatWaferInfoItems[iIndex].UseCount = wafers[i].UseCount.ToString();
  242. BoatWaferInfoItems[iIndex].UseTime = wafers[i].UseTime.ToString();
  243. BoatWaferInfoItems[iIndex].UseThick = wafers[i].UseThick.ToString();
  244. }
  245. else
  246. {
  247. BoatWaferInfoItems[iIndex].ModuleID = "";
  248. BoatWaferInfoItems[iIndex].SourceName = "";
  249. BoatWaferInfoItems[iIndex].WaferStatus = 0;
  250. BoatWaferInfoItems[iIndex].WaferType = "";
  251. BoatWaferInfoItems[iIndex].UseCount = "";
  252. BoatWaferInfoItems[iIndex].UseTime = "";
  253. BoatWaferInfoItems[iIndex].UseThick = "";
  254. }
  255. iIndex++;
  256. }
  257. BoatMapWafers = BoatWaferInfoItems.Select(a => a.WaferType).ToList();
  258. }
  259. }
  260. public void CreateWafer()
  261. {
  262. if (!DialogBox.Confirm("Are you sure want to CreateWafer?"))
  263. return;
  264. WaferType waferType = WaferType.None;
  265. if (SDIsChecked)
  266. waferType = WaferType.SD;
  267. else if (EDIsChecked)
  268. waferType = WaferType.ED;
  269. else if (PIsChecked)
  270. waferType = WaferType.P;
  271. else if (M1IsChecked)
  272. waferType = WaferType.M1;
  273. else if (XDIsChecked)
  274. waferType = WaferType.XD;
  275. else if (M2IsChecked)
  276. waferType = WaferType.M2;
  277. if (BoatSlotFrom > BoatSlotTo || BoatSlotTo > (int)QueryDataClient.Instance.Service.GetConfig("Boat.SlotCount") || BoatSlotFrom < 1)
  278. {
  279. DialogBox.ShowWarning($"BoatSlot input error,can not create,input range 1 to {(int)QueryDataClient.Instance.Service.GetConfig("Boat.SlotCount")}");
  280. return;
  281. }
  282. if (OriginSlot < 1 || OriginSlot > (int)QueryDataClient.Instance.Service.GetConfig("System.CassetteSlotCount"))
  283. {
  284. DialogBox.ShowWarning($"OriginSlot input error,can not create,input range 1 to {(int)QueryDataClient.Instance.Service.GetConfig("System.CassetteSlotCount")}");
  285. return;
  286. }
  287. InvokeClient.Instance.Service.DoOperation("CreateWaferFromTo", $"{ModuleName}", BoatSlotFrom, BoatSlotTo, new string[] { waferType.ToString(), OriginSelectModule, (OriginSlot - 1).ToString() });
  288. // InvokeClient.Instance.Service.DoOperation("CreateWafer", $"{ModuleName}", BoatSlotFrom, waferType.ToString(), OriginSelectModule, OriginSlot - 1);
  289. }
  290. public void DeleteWafer()
  291. {
  292. if (!DialogBox.Confirm("Are you sure want to DeleteWafer?"))
  293. return;
  294. if (BoatSlotFrom < 1 || BoatSlotTo > (int)QueryDataClient.Instance.Service.GetConfig("Boat.SlotCount"))
  295. {
  296. DialogBox.ShowWarning($"BoatSlot input error,can not delete,input range 1 to {(int)QueryDataClient.Instance.Service.GetConfig("Boat.SlotCount")}");
  297. return;
  298. }
  299. //InvokeClient.Instance.Service.DoOperation("DeleteWafer", $"{ModuleName}", BoatSlot);
  300. InvokeClient.Instance.Service.DoOperation("DeleteWaferFromTo", $"{ModuleName}", BoatSlotFrom, BoatSlotTo);
  301. }
  302. public void CassetteClose()
  303. {
  304. ((Window)GetView()).DialogResult = false;
  305. }
  306. }
  307. }