BoatModifyViewModel.cs 12 KB

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