BoatModifyViewModel.cs 12 KB

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