BoatModifyViewModel.cs 13 KB

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