CassetteModifyViewModel.cs 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465
  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 MECF.Framework.Common.SubstrateTrackings;
  17. using Aitex.Core.RT.SCCore;
  18. using Aitex.Core.RT.Event;
  19. using OpenSEMI.Ctrlib.Controls;
  20. using DocumentFormat.OpenXml.Bibliography;
  21. using System.Reflection;
  22. using MECF.Framework.Common.Jobs;
  23. namespace FurnaceUI.Views.Operations
  24. {
  25. public class CassetteModifyViewModel : FurnaceUIViewModelBase
  26. {
  27. #region"订阅"
  28. [Subscription("Stocker1.Carrier")]
  29. public CarrierInfo Stocker1CarrierData { get; set; }
  30. [Subscription("Stocker2.Carrier")]
  31. public CarrierInfo Stocker2CarrierData { get; set; }
  32. [Subscription("Stocker3.Carrier")]
  33. public CarrierInfo Stocker3CarrierData { get; set; }
  34. [Subscription("Stocker4.Carrier")]
  35. public CarrierInfo Stocker4CarrierData { get; set; }
  36. [Subscription("Stocker5.Carrier")]
  37. public CarrierInfo Stocker5CarrierData { get; set; }
  38. [Subscription("Stocker6.Carrier")]
  39. public CarrierInfo Stocker6CarrierData { get; set; }
  40. [Subscription("Stocker7.Carrier")]
  41. public CarrierInfo Stocker7CarrierData { get; set; }
  42. [Subscription("Stocker8.Carrier")]
  43. public CarrierInfo Stocker8CarrierData { get; set; }
  44. [Subscription("Stocker9.Carrier")]
  45. public CarrierInfo Stocker9CarrierData { get; set; }
  46. [Subscription("Stocker10.Carrier")]
  47. public CarrierInfo Stocker10CarrierData { get; set; }
  48. [Subscription("Stocker11.Carrier")]
  49. public CarrierInfo Stocker11CarrierData { get; set; }
  50. [Subscription("Stocker12.Carrier")]
  51. public CarrierInfo Stocker12CarrierData { get; set; }
  52. [Subscription("Stocker13.Carrier")]
  53. public CarrierInfo Stocker13CarrierData { get; set; }
  54. [Subscription("Stocker14.Carrier")]
  55. public CarrierInfo Stocker14CarrierData { get; set; }
  56. [Subscription("Stocker15.Carrier")]
  57. public CarrierInfo Stocker15CarrierData { get; set; }
  58. [Subscription("Stocker16.Carrier")]
  59. public CarrierInfo Stocker16CarrierData { get; set; }
  60. [Subscription("Stocker17.Carrier")]
  61. public CarrierInfo Stocker17CarrierData { get; set; }
  62. [Subscription("Stocker18.Carrier")]
  63. public CarrierInfo Stocker18CarrierData { get; set; }
  64. [Subscription("FIMS1.Carrier")]
  65. public CarrierInfo FIMS1CarrierData { get; set; }
  66. [Subscription("FIMS2.Carrier")]
  67. public CarrierInfo FIMS2CarrierData { get; set; }
  68. [Subscription("LP1.Carrier")]
  69. public CarrierInfo LP1CarrierData { get; set; }
  70. [Subscription("LP2.Carrier")]
  71. public CarrierInfo LP2CarrierData { get; set; }
  72. [Subscription("LP3.Carrier")]
  73. public CarrierInfo LP3CarrierData { get; set; }
  74. [Subscription("LP4.Carrier")]
  75. public CarrierInfo LP4CarrierData { get; set; }
  76. [Subscription("CarrierRobot.Carrier")]
  77. public CarrierInfo CassetteRobotCarrierData { get; set; }
  78. #endregion
  79. public CassetteModifyViewModel(string module)
  80. {
  81. IsProcessCanModifyFoupInfo = (bool)QueryDataClient.Instance.Service.GetConfig("System.ProcessStatusCanModifyFoupInfo");
  82. ModuleName = module;
  83. for (int i = 1; i <= 21; i++)
  84. {
  85. OriginModuleItems.Add($"Stocker{i}");
  86. }
  87. for (int i = (int)QueryDataClient.Instance.Service.GetConfig("System.CassetteSlotCount"); i > 0; i--)
  88. {
  89. CassetteWaferInfoItems.Add(new WaferInfoItem() { SlotID = i });
  90. }
  91. }
  92. public string ModuleName { set; get; }
  93. public List<string> OriginModuleItems { get; set; } = new List<string>();
  94. private int? _cassetteSlot = 1;
  95. public int? CassetteSlot
  96. {
  97. get => _cassetteSlot;
  98. set
  99. {
  100. _cassetteSlot = value;
  101. NotifyOfPropertyChange(nameof(CassetteSlot));
  102. }
  103. }
  104. private string _originSelectModule = "Stocker1";
  105. public string OriginSelectModule
  106. {
  107. get => _originSelectModule;
  108. set
  109. {
  110. _originSelectModule = value;
  111. NotifyOfPropertyChange(nameof(OriginSelectModule));
  112. }
  113. }
  114. private int? _originSlot = 1;
  115. public int? OriginSlot
  116. {
  117. get => _originSlot;
  118. set
  119. {
  120. _originSlot = value;
  121. NotifyOfPropertyChange(nameof(OriginSlot));
  122. }
  123. }
  124. public bool SDIsChecked { get; set; } = true;
  125. public bool EDIsChecked { get; set; }
  126. public bool PIsChecked { get; set; }
  127. public bool M1IsChecked { get; set; }
  128. public bool M2IsChecked { get; set; }
  129. public bool TIsChecked { get; set; }
  130. public bool XDIsChecked { get; set; }
  131. [Subscription("Stocker1.CassettePresent")]
  132. public bool IsCassettePresent { get; set; }
  133. [Subscription("Rt.Status")]
  134. public string RtStatus { get; set; }
  135. [Subscription("PM1.Status")]
  136. public string PM1Status { get; set; }
  137. public bool IsProcessCanModifyFoupInfo { get; set; } = false;
  138. public bool IsCassetteModifyEnabled
  139. {
  140. get
  141. {
  142. if (ControlJobs != null && ControlJobs.Count > 0)
  143. {
  144. return ControlJobs.FirstOrDefault().State == EnumControlJobState.Paused;
  145. }
  146. var pmStatus = PM1Status == "Init" || PM1Status == "Idle" || PM1Status == "Error" || (IsProcessCanModifyFoupInfo && PM1Status == "Process");
  147. var rtstatus = (RtStatus == "Init" || RtStatus == "Idle" || RtStatus == "Error") || (IsProcessCanModifyFoupInfo && RtStatus == "AutoRunning");
  148. return pmStatus && rtstatus;
  149. }
  150. }
  151. [Subscription("Scheduler.ControlJobList")]
  152. public List<ControlJobInfo> ControlJobs
  153. {
  154. get;
  155. set;
  156. }
  157. private ObservableCollection<WaferInfoItem> _cassetteWaferInfoItems = new ObservableCollection<WaferInfoItem>();
  158. public ObservableCollection<WaferInfoItem> CassetteWaferInfoItems
  159. {
  160. get => _cassetteWaferInfoItems;
  161. set
  162. {
  163. _cassetteWaferInfoItems = value;
  164. NotifyOfPropertyChange(nameof(CassetteWaferInfoItems));
  165. }
  166. }
  167. protected override void InvokeAfterUpdateProperty(Dictionary<string, object> data)
  168. {
  169. RefreshCassetteDataTask();
  170. }
  171. private void RefreshCassetteDataTask()
  172. {
  173. if (!ModuleManager.ModuleInfos.ContainsKey(ModuleName))
  174. {
  175. return;
  176. }
  177. var wafers = ModuleManager.ModuleInfos[ModuleName].WaferManager.Wafers;
  178. if (wafers != null)
  179. {
  180. for (int i = 0; i < wafers.Count; i++)
  181. {
  182. if (wafers[i].WaferStatus != 0)
  183. {
  184. CassetteWaferInfoItems[i].ModuleID = wafers[i].ModuleID;
  185. CassetteWaferInfoItems[i].SourceName = wafers[i].SourceName;
  186. CassetteWaferInfoItems[i].WaferStatus = wafers[i].WaferStatus;
  187. CassetteWaferInfoItems[i].WaferType = wafers[i].WaferType.ToString();
  188. CassetteWaferInfoItems[i].UseCount = wafers[i].UseCount.ToString();
  189. CassetteWaferInfoItems[i].UseTime = wafers[i].UseTime.ToString();
  190. CassetteWaferInfoItems[i].UseThick = wafers[i].UseThick.ToString();
  191. }
  192. else
  193. {
  194. CassetteWaferInfoItems[i].ModuleID = "";
  195. CassetteWaferInfoItems[i].SourceName = "";
  196. CassetteWaferInfoItems[i].WaferStatus = 0;
  197. CassetteWaferInfoItems[i].WaferType = "";
  198. CassetteWaferInfoItems[i].UseCount = "";
  199. CassetteWaferInfoItems[i].UseTime = "";
  200. CassetteWaferInfoItems[i].UseThick = "";
  201. }
  202. }
  203. }
  204. }
  205. public void CreateWafer()
  206. {
  207. if (!DialogBox.Confirm("Are you sure want to CreateWafer?"))
  208. return;
  209. WaferType waferType = WaferType.None;
  210. if (SDIsChecked)
  211. waferType = WaferType.SD;
  212. else if (EDIsChecked)
  213. waferType = WaferType.ED;
  214. else if (PIsChecked)
  215. waferType = WaferType.P;
  216. else if (M1IsChecked)
  217. waferType = WaferType.M1;
  218. else if (M2IsChecked)
  219. waferType = WaferType.M2;
  220. else if (XDIsChecked)
  221. waferType = WaferType.XD;
  222. else if (TIsChecked)
  223. waferType = WaferType.T;
  224. if (CassetteSlot < 1 || CassetteSlot > (int)QueryDataClient.Instance.Service.GetConfig("System.CassetteSlotCount"))
  225. {
  226. DialogBox.ShowWarning($"CassetteSlot input error,can not create,input range 1 to {(int)QueryDataClient.Instance.Service.GetConfig("System.CassetteSlotCount")}");
  227. return;
  228. }
  229. if (OriginSlot < 1 || OriginSlot > (int)QueryDataClient.Instance.Service.GetConfig("System.CassetteSlotCount"))
  230. {
  231. DialogBox.ShowWarning($"OriginSlot input error,can not create,input range 1 to {(int)QueryDataClient.Instance.Service.GetConfig("System.CassetteSlotCount")}");
  232. return;
  233. }
  234. var key = $"{ModuleName.ToString()}.Carrier";
  235. var rtData = QueryDataClient.Instance.Service.PollData(new List<string>() { key });
  236. if (rtData == null)
  237. {
  238. DialogBox.ShowWarning($"{ModuleName} Carrier is null!");
  239. return;
  240. }
  241. var carrierInfo = (CarrierInfo)rtData[key];
  242. if (carrierInfo == null || carrierInfo.IsEmpty)
  243. {
  244. DialogBox.ShowWarning($"{ModuleName} Carrier is null!");
  245. return;
  246. }
  247. InvokeClient.Instance.Service.DoOperation("CreateWafer", $"{ModuleName}", CassetteSlot - 1, waferType.ToString(), OriginSelectModule, OriginSlot - 1);
  248. }
  249. public void CreateCarrier()
  250. {
  251. if (!DialogBox.Confirm("Are you sure want to CreateCarrier?"))
  252. return;
  253. WaferType waferType = WaferType.None;
  254. if (SDIsChecked)
  255. waferType = WaferType.SD;
  256. else if (EDIsChecked)
  257. waferType = WaferType.ED;
  258. else if (PIsChecked)
  259. waferType = WaferType.P;
  260. //else if (MIsChecked)
  261. // waferType = WaferType.M;
  262. else if (M1IsChecked)
  263. waferType = WaferType.M1;
  264. else if (M2IsChecked)
  265. waferType = WaferType.M2;
  266. else if (XDIsChecked)
  267. waferType = WaferType.XD;
  268. else if (TIsChecked)
  269. waferType = WaferType.T;
  270. InvokeClient.Instance.Service.DoOperation("System.CreateCarrier", $"{ModuleName}", 1, waferType.ToString(), false.ToString());
  271. }
  272. public void DeleteCarrier()
  273. {
  274. if (!DialogBox.Confirm("Are you sure want to DeleteCarrier?"))
  275. return;
  276. InvokeClient.Instance.Service.DoOperation("System.DeleteCarrier", $"{ModuleName}", 1);
  277. foreach (var item in CassetteWaferInfoItems)
  278. {
  279. item.SourceName = "";
  280. item.WaferStatus = 0;
  281. item.WaferType = "";
  282. item.UseCount = "";
  283. item.UseTime = "";
  284. item.UseThick = "";
  285. item.MappingResult = ScanResult.Init;
  286. }
  287. }
  288. public void DeleteWafer()
  289. {
  290. if (!DialogBox.Confirm("Are you sure want to DeleteWafer?"))
  291. return;
  292. if (CassetteSlot < 1 || CassetteSlot > (int)QueryDataClient.Instance.Service.GetConfig("System.CassetteSlotCount"))
  293. {
  294. DialogBox.ShowWarning($"CassetteSlot input error,can not delete,input range 1 to {(int)QueryDataClient.Instance.Service.GetConfig("System.CassetteSlotCount")}");
  295. return;
  296. }
  297. InvokeClient.Instance.Service.DoOperation("DeleteWafer", $"{ModuleName}", CassetteSlot - 1);
  298. }
  299. public void CassetteClose()
  300. {
  301. ((Window)GetView()).DialogResult = false;
  302. }
  303. }
  304. public class WaferInfoItem : PropertyChangedBase
  305. {
  306. private int _slotID;
  307. public int SlotID
  308. {
  309. get => _slotID;
  310. set
  311. {
  312. _slotID = value;
  313. NotifyOfPropertyChange(nameof(SlotID));
  314. }
  315. }
  316. private string _moduleID;
  317. public string ModuleID
  318. {
  319. get => _moduleID;
  320. set
  321. {
  322. _moduleID = value;
  323. NotifyOfPropertyChange(nameof(ModuleID));
  324. }
  325. }
  326. private string _sourceName;
  327. public string SourceName
  328. {
  329. get => _sourceName;
  330. set
  331. {
  332. _sourceName = value;
  333. NotifyOfPropertyChange(nameof(SourceName));
  334. }
  335. }
  336. private int _waferStatus = 0; // WaferStatus.Empty;
  337. public int WaferStatus
  338. {
  339. get => _waferStatus;
  340. set
  341. {
  342. _waferStatus = value;
  343. NotifyOfPropertyChange("WaferStatus");
  344. }
  345. }
  346. private string waferType;
  347. public string WaferType
  348. {
  349. get
  350. { return waferType; }
  351. set
  352. {
  353. waferType = value;
  354. NotifyOfPropertyChange("WaferType");
  355. }
  356. }
  357. private string useCount;
  358. public string UseCount
  359. {
  360. get
  361. { return useCount; }
  362. set
  363. {
  364. useCount = value;
  365. NotifyOfPropertyChange("UseCount");
  366. }
  367. }
  368. private string useTime;
  369. public string UseTime
  370. {
  371. get
  372. { return useTime; }
  373. set
  374. {
  375. useTime = value;
  376. NotifyOfPropertyChange("UseTime");
  377. }
  378. }
  379. private string useThick;
  380. public string UseThick
  381. {
  382. get
  383. { return useThick; }
  384. set
  385. {
  386. useThick = value;
  387. NotifyOfPropertyChange("UseThick");
  388. }
  389. }
  390. private string bgColor;
  391. public string BgColor
  392. {
  393. get { return bgColor; }
  394. set
  395. {
  396. bgColor = value;
  397. NotifyOfPropertyChange("BgColor");
  398. }
  399. }
  400. /// <summary>
  401. /// 记录对象是否进行过增删或者数据变动
  402. /// </summary>
  403. public bool IsChanged { get; set; }
  404. private ScanResult _mappingResult;
  405. /// <summary>
  406. /// mapping结果
  407. /// </summary>
  408. public ScanResult MappingResult
  409. {
  410. get { return _mappingResult; }
  411. set
  412. {
  413. if (_mappingResult != value)
  414. {
  415. _mappingResult = value;
  416. NotifyOfPropertyChange(nameof(MappingResult));
  417. }
  418. }
  419. }
  420. }
  421. }