StockerViewModel.cs 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366
  1. using Aitex.Core.Common;
  2. using Aitex.Core.Util;
  3. using Caliburn.Micro;
  4. using MECF.Framework.Common.DataCenter;
  5. using MECF.Framework.Common.Equipment;
  6. using MECF.Framework.UI.Client.ClientBase;
  7. using System.Collections.Generic;
  8. using System.Collections.ObjectModel;
  9. using System.Linq;
  10. using System.Windows;
  11. using System.Windows.Media;
  12. using FurnaceUI.Models;
  13. namespace FurnaceUI.Views.Operations
  14. {
  15. public class StockerViewModel : FurnaceUIViewModelBase
  16. {
  17. public bool IsPermission { get => this.Permission == 3; }
  18. public Visibility IsReplace { get; set; }
  19. public StockerViewModel()
  20. {
  21. this.DisplayName = "StockerViewModel";
  22. _stokcers = new List<ModuleName>()
  23. {
  24. ModuleName.Stocker1,
  25. ModuleName.Stocker2,
  26. ModuleName.Stocker3,
  27. ModuleName.Stocker4,
  28. ModuleName.Stocker5,
  29. ModuleName.Stocker6,
  30. ModuleName.Stocker7,
  31. ModuleName.Stocker8,
  32. ModuleName.Stocker9,
  33. ModuleName.Stocker10,
  34. ModuleName.Stocker11,
  35. ModuleName.Stocker12,
  36. ModuleName.Stocker13,
  37. ModuleName.Stocker14,
  38. ModuleName.Stocker15,
  39. ModuleName.Stocker16,
  40. ModuleName.Stocker17,
  41. ModuleName.Stocker18,
  42. //ModuleName.Stocker19,
  43. //ModuleName.Stocker20,
  44. //ModuleName.Stocker21,
  45. };
  46. StockerSlots = new ObservableCollection<string>()
  47. {
  48. "",
  49. "",
  50. "",
  51. "",
  52. "",
  53. "",
  54. "",
  55. "",
  56. "",
  57. "",
  58. "",
  59. "",
  60. "",
  61. "",
  62. "",
  63. "",
  64. "",
  65. "",
  66. "",
  67. "",
  68. "",
  69. };
  70. StockerWaferType = Enumerable.Repeat("", 21).ToList();
  71. _eDUseWarningLimit = (int)QueryDataClient.Instance.Service.GetConfig("PM1.WaferCycleTime.EDCountWarning");
  72. _eDUseAlarmLimit = (int)QueryDataClient.Instance.Service.GetConfig("PM1.WaferCycleTime.EDCountAlarm");
  73. StockerBackground = new List<SolidColorBrush>();
  74. for (int i = 0; i < 21; i++)
  75. {
  76. StockerBackground.Add(_WhiteFill);
  77. }
  78. }
  79. private List<ModuleName> _stokcers;
  80. private List<string> _stokcerWaferType;
  81. double _eDUseWarningLimit;
  82. double _eDUseAlarmLimit;
  83. public List<string> StockerWaferType
  84. {
  85. get => _stokcerWaferType;
  86. set
  87. {
  88. _stokcerWaferType = value;
  89. NotifyOfPropertyChange(nameof(StockerWaferType));
  90. }
  91. }
  92. private int _cassetteSlot = 0;
  93. private ObservableCollection<string> _stockerSlots;
  94. public ObservableCollection<string> StockerSlots
  95. {
  96. get { return _stockerSlots; }
  97. set
  98. {
  99. _stockerSlots = value;
  100. NotifyOfPropertyChange("StockerSlots");
  101. }
  102. }
  103. private SolidColorBrush _WhiteFill = new SolidColorBrush(Colors.White);
  104. private SolidColorBrush _abortFill = new SolidColorBrush(Colors.Red);
  105. private SolidColorBrush _productionFill = new SolidColorBrush((Color)ColorConverter.ConvertFromString("#bedadb"));
  106. private SolidColorBrush _SD_ED_M_Fill = new SolidColorBrush((Color)ColorConverter.ConvertFromString("LightGray"));
  107. private SolidColorBrush _waringFill = new SolidColorBrush(Colors.Yellow);
  108. private SolidColorBrush _alarmFill = new SolidColorBrush(Colors.Red);
  109. private List<SolidColorBrush> _stockerBackground = new List<SolidColorBrush>();
  110. public List<SolidColorBrush> StockerBackground
  111. {
  112. get => _stockerBackground;
  113. set
  114. {
  115. _stockerBackground = value;
  116. NotifyOfPropertyChange(nameof(StockerBackground));
  117. }
  118. }
  119. [Subscription("Stocker1.CassettePresent")]
  120. public bool IsCassettePresent { get; set; }
  121. [Subscription("Stocker1.LotID")]
  122. public string Stocker1LotID { get; set; }
  123. [Subscription("Stocker2.LotID")]
  124. public string Stocker2LotID { get; set; }
  125. [Subscription("Stocker3.LotID")]
  126. public string Stocker3LotID { get; set; }
  127. [Subscription("Stocker4.LotID")]
  128. public string Stocker4LotID { get; set; }
  129. [Subscription("Stocker5.LotID")]
  130. public string Stocker5LotID { get; set; }
  131. [Subscription("Stocker6.LotID")]
  132. public string Stocker6LotID { get; set; }
  133. [Subscription("Stocker7.LotID")]
  134. public string Stocker7LotID { get; set; }
  135. [Subscription("Stocker8.LotID")]
  136. public string Stocker8LotID { get; set; }
  137. [Subscription("Stocker9.LotID")]
  138. public string Stocker9LotID { get; set; }
  139. [Subscription("Stocker10.LotID")]
  140. public string Stocker10LotID { get; set; }
  141. [Subscription("Stocker11.LotID")]
  142. public string Stocker11LotID { get; set; }
  143. [Subscription("Stocker12.LotID")]
  144. public string Stocker12LotID { get; set; }
  145. [Subscription("Stocker13.LotID")]
  146. public string Stocker13LotID { get; set; }
  147. [Subscription("Stocker14.LotID")]
  148. public string Stocker14LotID { get; set; }
  149. [Subscription("Stocker15.LotID")]
  150. public string Stocker15LotID { get; set; }
  151. [Subscription("Stocker16.LotID")]
  152. public string Stocker16LotID { get; set; }
  153. [Subscription("Stocker17.LotID")]
  154. public string Stocker17LotID { get; set; }
  155. [Subscription("Stocker18.LotID")]
  156. public string Stocker18LotID { get; set; }
  157. public Visibility IsStockerVisibility { get; set; }
  158. public Visibility IsLPVisibility { get; set; }
  159. protected override void OnInitialize()
  160. {
  161. base.OnInitialize();
  162. //base.InitFOUP();
  163. //base.InitLL();
  164. //base.InitTM();
  165. //base.InitEFEM();
  166. //base.InitPM();
  167. //base.InitBuffer();
  168. }
  169. protected override void OnActivate()
  170. {
  171. base.OnActivate();
  172. _cassetteSlot = (int)QueryDataClient.Instance.Service.GetConfig("System.CassetteSlotCount");
  173. for (int i = 0; i < _stokcers.Count; i++)
  174. {
  175. StockerWaferType[i] = (string)QueryDataClient.Instance.Service.GetConfig($"System.Stocker.{_stokcers[i]}WaferType");
  176. }
  177. }
  178. protected override void InvokeAfterUpdateProperty(Dictionary<string, object> data)
  179. {
  180. var isLoadPortPosition = (string)QueryDataClient.Instance.Service.GetConfig("LoadPort.LoadPortPosition");
  181. if (isLoadPortPosition == "Upper")
  182. {
  183. IsStockerVisibility = Visibility.Hidden;
  184. IsLPVisibility = Visibility.Visible;
  185. }
  186. else
  187. {
  188. IsStockerVisibility = Visibility.Visible;
  189. IsLPVisibility = Visibility.Hidden;
  190. }
  191. UpdateStockerSlots();
  192. }
  193. private void UpdateStockerSlots()
  194. {
  195. for (int i = 0; i < _stokcers.Count; i++)
  196. {
  197. bool bHaveAbort = false;
  198. var wafers = ModuleManager.ModuleInfos[_stokcers[i].ToString()].WaferManager.Wafers;
  199. int waferNumber = 0;
  200. SolidColorBrush _tempFill = _SD_ED_M_Fill;
  201. if (wafers != null)
  202. {
  203. foreach (var wafer in wafers)
  204. {
  205. if (wafer.WaferStatus != 0)
  206. {
  207. waferNumber++;
  208. if (wafer.WaferStatus == 5) // EnumWaferProcessStatus.Failed
  209. bHaveAbort = true;
  210. if (wafer.UseCount > _eDUseWarningLimit)
  211. {
  212. _tempFill = _waringFill;
  213. }
  214. if (wafer.UseCount > _eDUseAlarmLimit)
  215. {
  216. _tempFill = _alarmFill;
  217. }
  218. }
  219. }
  220. }
  221. StockerSlots[i] = $"{waferNumber}/{_cassetteSlot}";
  222. if (StockerWaferType[i].Contains("P"))
  223. {
  224. if (waferNumber > 0)
  225. {
  226. if (bHaveAbort)
  227. StockerBackground[i] = _abortFill;
  228. else
  229. {
  230. StockerBackground[i] = _productionFill;
  231. }
  232. }
  233. else
  234. {
  235. StockerBackground[i] = _WhiteFill;
  236. }
  237. }
  238. else
  239. {
  240. if (waferNumber > 0)
  241. {
  242. if (bHaveAbort)
  243. StockerBackground[i] = _abortFill;
  244. else
  245. StockerBackground[i] = _tempFill;
  246. ;
  247. }
  248. else
  249. {
  250. StockerBackground[i] = _WhiteFill;
  251. }
  252. }
  253. }
  254. }
  255. public void SwitchPage(string page)
  256. {
  257. }
  258. public void StokcerInfo(string module, string type)
  259. {
  260. WindowManager wm = new WindowManager();
  261. CassetteViewModel svm = new CassetteViewModel(module);
  262. svm.WaferType = type;
  263. switch (ModuleHelper.Converter(module))
  264. {
  265. case ModuleName.Stocker1:
  266. svm.LotID = Stocker1LotID;
  267. break;
  268. case ModuleName.Stocker2:
  269. svm.LotID = Stocker2LotID;
  270. break;
  271. case ModuleName.Stocker3:
  272. svm.LotID = Stocker3LotID;
  273. break;
  274. case ModuleName.Stocker4:
  275. svm.LotID = Stocker4LotID;
  276. break;
  277. case ModuleName.Stocker5:
  278. svm.LotID = Stocker5LotID;
  279. break;
  280. case ModuleName.Stocker6:
  281. svm.LotID = Stocker6LotID;
  282. break;
  283. case ModuleName.Stocker7:
  284. svm.LotID = Stocker7LotID;
  285. break;
  286. case ModuleName.Stocker8:
  287. svm.LotID = Stocker8LotID;
  288. break;
  289. case ModuleName.Stocker9:
  290. svm.LotID = Stocker9LotID;
  291. break;
  292. case ModuleName.Stocker10:
  293. svm.LotID = Stocker10LotID;
  294. break;
  295. case ModuleName.Stocker11:
  296. svm.LotID = Stocker11LotID;
  297. break;
  298. case ModuleName.Stocker12:
  299. svm.LotID = Stocker12LotID;
  300. break;
  301. case ModuleName.Stocker13:
  302. svm.LotID = Stocker13LotID;
  303. break;
  304. case ModuleName.Stocker14:
  305. svm.LotID = Stocker14LotID;
  306. break;
  307. case ModuleName.Stocker15:
  308. svm.LotID = Stocker15LotID;
  309. break;
  310. case ModuleName.Stocker16:
  311. svm.LotID = Stocker16LotID;
  312. break;
  313. case ModuleName.Stocker17:
  314. svm.LotID = Stocker17LotID;
  315. break;
  316. case ModuleName.Stocker18:
  317. svm.LotID = Stocker18LotID;
  318. break;
  319. }
  320. wm.ShowDialogWithTitle(svm, null, $"{svm.ModuleName} Information");
  321. }
  322. }
  323. }