WaferRobotViewModel.cs 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302
  1. using Caliburn.Micro;
  2. using Caliburn.Micro.Core;
  3. using Aitex.Core.Common.DeviceData;
  4. using Aitex.Core.UI.ControlDataContext;
  5. using Aitex.Core.Util;
  6. using MECF.Framework.Common.DataCenter;
  7. using MECF.Framework.Common.OperationCenter;
  8. using MECF.Framework.UI.Client.ClientBase;
  9. using FurnaceUI.Models;
  10. using FurnaceUI.Views.Editors;
  11. using System.Collections.ObjectModel;
  12. using System.Collections.Generic;
  13. using System.Threading.Tasks;
  14. using System.Reflection;
  15. using System;
  16. using Aitex.Core.RT.Log;
  17. using System.Linq;
  18. using System.Windows;
  19. using MECF.Framework.Common.SubstrateTrackings;
  20. using MECF.Framework.Common.Equipment;
  21. using System.Text.RegularExpressions;
  22. using OpenSEMI.ClientBase;
  23. namespace FurnaceUI.Views.Maintenances
  24. {
  25. public class WaferRobotViewModel : FurnaceUIViewModelBase
  26. {
  27. public bool IsPermission { get => this.Permission == 3; }
  28. [Subscription("WaferRobot.Status")]
  29. public string WaferRobotStatus { get; set; }
  30. [Subscription("Rt.Status")]
  31. public string RtStatus { get; set; }
  32. public bool IsSelectButtonEnable => IsSystemStaus;
  33. public bool IsSystemStaus => (RtStatus != "AutoRunning");
  34. [Subscription("WaferRobot.IsOnline")]
  35. public bool WaferRobotIsOnline { get; set; }
  36. public bool IsWaferRobotOfflineButtonEnable => WaferRobotIsOnline;
  37. public bool IsWaferRobotOnlineButtonEnable => !WaferRobotIsOnline;
  38. #region test TMRobot
  39. private List<int> _slotsTMRobot = new List<int>() { 170, 25, 25 };
  40. private List<string> _modulesTMRobot = new List<string>() { "Boat", "FIMS1", "FIMS2" };
  41. private List<string> _bladesTMRobot = new List<string>() { "Single", "Multiple" };
  42. private string _pickSelectedModuleTMRobot;
  43. public string PickSelectedModuleTMRobot
  44. {
  45. get { return _pickSelectedModuleTMRobot; }
  46. set
  47. {
  48. _pickSelectedModuleTMRobot = value;
  49. PickSlotsTMRobot = GetSlotsByModuleTMRobot(_pickSelectedModuleTMRobot);
  50. PickSelectedSlotTMRobot = 1;
  51. NotifyOfPropertyChange("PickSelectedModuleTMRobot");
  52. }
  53. }
  54. private int _pickSelectedSlotTMRobot;
  55. public int PickSelectedSlotTMRobot
  56. {
  57. get { return _pickSelectedSlotTMRobot; }
  58. set { _pickSelectedSlotTMRobot = value; NotifyOfPropertyChange("PickSelectedSlotTMRobot"); }
  59. }
  60. private string _pickSelectedBladeTMRobot;
  61. public string PickSelectedBladeTMRobot
  62. {
  63. get { return _pickSelectedBladeTMRobot; }
  64. set { _pickSelectedBladeTMRobot = value; NotifyOfPropertyChange("PickSelectedBladeTMRobot"); }
  65. }
  66. private List<int> _pickSlotsTMRobot;
  67. public List<int> PickSlotsTMRobot
  68. {
  69. get { return _pickSlotsTMRobot; }
  70. set { _pickSlotsTMRobot = value; NotifyOfPropertyChange("PickSlotsTMRobot"); }
  71. }
  72. private string _placeSelectedModuleTMRobot;
  73. public string PlaceSelectedModuleTMRobot
  74. {
  75. get { return _placeSelectedModuleTMRobot; }
  76. set
  77. {
  78. _placeSelectedModuleTMRobot = value;
  79. PlaceSlotsTMRobot = GetSlotsByModuleTMRobot(_placeSelectedModuleTMRobot);
  80. PlaceSelectedSlotTMRobot = 1;
  81. NotifyOfPropertyChange("PlaceSelectedModuleTMRobot");
  82. }
  83. }
  84. private int _placeSelectedSlotTMRobot;
  85. public int PlaceSelectedSlotTMRobot
  86. {
  87. get { return _placeSelectedSlotTMRobot; }
  88. set { _placeSelectedSlotTMRobot = value; NotifyOfPropertyChange("PlaceSelectedSlotTMRobot"); }
  89. }
  90. private string _placeSelectedBladeTMRobot;
  91. public string PlaceSelectedBladeTMRobot
  92. {
  93. get { return _placeSelectedBladeTMRobot; }
  94. set { _placeSelectedBladeTMRobot = value; NotifyOfPropertyChange("PlaceSelectedBladeTMRobot"); }
  95. }
  96. private List<int> _placeSlotsTMRobot;
  97. public List<int> PlaceSlotsTMRobot
  98. {
  99. get { return _placeSlotsTMRobot; }
  100. set { _placeSlotsTMRobot = value; NotifyOfPropertyChange("PlaceSlotsTMRobot"); }
  101. }
  102. public List<string> ModulesTMRobot
  103. {
  104. get { return _modulesTMRobot; }
  105. set { _modulesTMRobot = value; NotifyOfPropertyChange("ModulesTMRobot"); }
  106. }
  107. public List<string> BladesTMRobot
  108. {
  109. get { return _bladesTMRobot; }
  110. set { _bladesTMRobot = value; NotifyOfPropertyChange("BladesTMRobot"); }
  111. }
  112. private string _swapFromSelectedModuleTMRobot;
  113. public string SwapFromSelectedModuleTMRobot
  114. {
  115. get { return _swapFromSelectedModuleTMRobot; }
  116. set
  117. {
  118. _swapFromSelectedModuleTMRobot = value;
  119. SwapFromSlotsTMRobot = GetSlotsByModuleTMRobot(_swapFromSelectedModuleTMRobot);
  120. SwapFromSelectedSlotTMRobot = 1;
  121. NotifyOfPropertyChange("SwapFromSelectedModuleTMRobot");
  122. }
  123. }
  124. private int _swapFromSelectedSlotTMRobot;
  125. public int SwapFromSelectedSlotTMRobot
  126. {
  127. get { return _swapFromSelectedSlotTMRobot; }
  128. set { _swapFromSelectedSlotTMRobot = value; NotifyOfPropertyChange("SwapFromSelectedSlotTMRobot"); }
  129. }
  130. private string _swapSelectedBladeTMRobot;
  131. public string SwapSelectedBladeTMRobot
  132. {
  133. get { return _swapSelectedBladeTMRobot; }
  134. set { _swapSelectedBladeTMRobot = value; NotifyOfPropertyChange("SwapSelectedBladeTMRobot"); }
  135. }
  136. private List<int> _swapFromSlotsTMRobot;
  137. public List<int> SwapFromSlotsTMRobot
  138. {
  139. get { return _swapFromSlotsTMRobot; }
  140. set { _swapFromSlotsTMRobot = value; NotifyOfPropertyChange("SwapFromSlotsTMRobot"); }
  141. }
  142. private string _swapToSelectedModuleTMRobot;
  143. public string SwapToSelectedModuleTMRobot
  144. {
  145. get { return _swapToSelectedModuleTMRobot; }
  146. set
  147. {
  148. _swapToSelectedModuleTMRobot = value;
  149. SwapToSlotsTMRobot = GetSlotsByModuleTMRobot(_swapToSelectedModuleTMRobot);
  150. SwapToSelectedSlotTMRobot = 1;
  151. NotifyOfPropertyChange("SwapToSelectedModuleTMRobot");
  152. }
  153. }
  154. private int _swapToSelectedSlotTMRobot;
  155. public int SwapToSelectedSlotTMRobot
  156. {
  157. get { return _swapToSelectedSlotTMRobot; }
  158. set { _swapToSelectedSlotTMRobot = value; NotifyOfPropertyChange("SwapToSelectedSlotTMRobot"); }
  159. }
  160. private List<int> _swapToSlotsTMRobot;
  161. public List<int> SwapToSlotsTMRobot
  162. {
  163. get { return _swapToSlotsTMRobot; }
  164. set { _swapToSlotsTMRobot = value; NotifyOfPropertyChange("SwapToSlotsTMRobot"); }
  165. }
  166. private WaferInfo _robotWafer1;
  167. public WaferInfo RobotWafer1
  168. {
  169. get { return _robotWafer1; }
  170. set
  171. {
  172. _robotWafer1 = value;
  173. NotifyOfPropertyChange("RobotWafer1");
  174. }
  175. }
  176. private string _mappingSelectedModuleTMRobot;
  177. public string MappingSelectedModuleTMRobot
  178. {
  179. get { return _mappingSelectedModuleTMRobot; }
  180. set
  181. {
  182. _mappingSelectedModuleTMRobot = value;
  183. NotifyOfPropertyChange("MappingSelectedModuleTMRobot");
  184. }
  185. }
  186. #endregion
  187. public WaferRobotViewModel()
  188. {
  189. _slotsTMRobot = new List<int>();
  190. _slotsTMRobot.Add((int)QueryDataClient.Instance.Service.GetConfig("Boat.SlotCount"));
  191. _slotsTMRobot.Add((int)QueryDataClient.Instance.Service.GetConfig("System.CassetteSlotCount"));
  192. _slotsTMRobot.Add((int)QueryDataClient.Instance.Service.GetConfig("System.CassetteSlotCount"));
  193. }
  194. private List<int> GetSlotsByModuleTMRobot(string module)
  195. {
  196. List<int> slots = new List<int>();
  197. int i = _modulesTMRobot.IndexOf(module);
  198. int num = 0;
  199. if (i >= 0 && i < _slotsTMRobot.Count)
  200. num = _slotsTMRobot[i];
  201. int j = 0;
  202. while (j < num)
  203. {
  204. slots.Add(j + 1);
  205. j++;
  206. }
  207. return slots;
  208. }
  209. public void Home()
  210. {
  211. InvokeClient.Instance.Service.DoOperation("WaferRobot.Home");
  212. }
  213. public void TMRobot_Pick()
  214. {
  215. var module = PickSelectedModuleTMRobot.Replace("Boat", "PM1");
  216. if (DialogBox.Confirm($"Are you sure you want to Pick Wafer?"))
  217. {
  218. InvokeClient.Instance.Service.DoOperation($"WaferRobot.Pick", module, PickSelectedSlotTMRobot - 1, PickSelectedBladeTMRobot == "Single" ? 0 : (PickSelectedBladeTMRobot == "Blade2" ? 1 : 2));
  219. }
  220. }
  221. public void TMRobot_Place()
  222. {
  223. if (DialogBox.Confirm($"Are you sure you want to place Wafer?"))
  224. {
  225. var module = PlaceSelectedModuleTMRobot.Replace("Boat", "PM1");
  226. InvokeClient.Instance.Service.DoOperation($"WaferRobot.Place", module, PlaceSelectedSlotTMRobot - 1, PlaceSelectedBladeTMRobot == "Single" ? 0 : (PlaceSelectedBladeTMRobot == "Blade2" ? 1 : 2));
  227. }
  228. }
  229. public void TMRobot_Mapping()
  230. {
  231. if (!DialogBox.Confirm($"Are you sure you want to Mapping Wafer?"))
  232. return;
  233. var module = MappingSelectedModuleTMRobot.Replace("Boat", "PM1");
  234. string mappingSlot = string.Empty;
  235. var wafers = ModuleManager.ModuleInfos[module].WaferManager.Wafers;
  236. if (wafers != null)
  237. {
  238. for (int i = wafers.Count - 1; i >= 0; i--)
  239. {
  240. if (wafers[i].WaferStatus != 0)
  241. mappingSlot += "1";
  242. else
  243. mappingSlot += "0";
  244. }
  245. }
  246. InvokeClient.Instance.Service.DoOperation($"WaferRobot.Mapping", module, mappingSlot.Length == 0 ? 0 : Regex.Matches(mappingSlot, "1").Count, 0, mappingSlot, true, true);
  247. }
  248. public void WaferRobot_Swap()
  249. {
  250. var fromModule = SwapFromSelectedModuleTMRobot.Replace("Boat", "PM1"); ;
  251. var toModule = SwapToSelectedModuleTMRobot.Replace("Boat", "PM1"); ;
  252. InvokeClient.Instance.Service.DoOperation($"WaferRobot.Swap", fromModule, toModule, SwapFromSelectedSlotTMRobot - 1, SwapToSelectedSlotTMRobot - 1,
  253. SwapSelectedBladeTMRobot == "Single" ? 0 : (SwapSelectedBladeTMRobot == "Blade2" ? 1 : 2));
  254. }
  255. public void SetOnline(object target)
  256. {
  257. InvokeClient.Instance.Service.DoOperation($"{target}.SetOnline");
  258. }
  259. public void SetOffline(object target)
  260. {
  261. InvokeClient.Instance.Service.DoOperation($"{target}.SetOffline");
  262. }
  263. public void ClosedCmd()
  264. {
  265. (GetView() as Window).Close();
  266. }
  267. }
  268. }