WaferRobotViewModel.cs 11 KB

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