OperationOverViewModel.cs 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347
  1. using MECF.Framework.Common.CommonData;
  2. using MECF.Framework.Common.DataCenter;
  3. using OpenSEMI.ClientBase;
  4. using Prism.Mvvm;
  5. using System;
  6. using System.Collections.Generic;
  7. using System.Linq;
  8. using System.Text;
  9. using System.Threading.Tasks;
  10. using System.Windows.Threading;
  11. using Venus_MainPages.Unity;
  12. using Venus_Themes.CustomControls;
  13. namespace Venus_MainPages.ViewModels
  14. {
  15. public class OperationOverViewModel : BindableBase
  16. {
  17. #region 私有字段
  18. private bool m_TabIsChecked=true;
  19. private ModuleInfo m_LP1ModuleInfo;
  20. private ModuleInfo m_LP2ModuleInfo;
  21. private WaferRobotTAction m_Robot1TAction;
  22. private WaferRobotXAction m_Robot1XAction;
  23. private WaferRobotTAction m_Robot2TAction;
  24. private WaferRobotXAction m_Robot2XAction;
  25. private RobotMoveInfo m_robotMoveInfo;
  26. int arm1oldWaferStatus = 100;
  27. int arm2oldWaferStatus = 100;
  28. private WaferInfo m_PMAWafer;
  29. private WaferInfo m_PMBWafer;
  30. private WaferInfo m_PMCWafer;
  31. private WaferInfo m_PMDWafer;
  32. private WaferInfo m_LLAWafer;
  33. private WaferInfo m_LLBWafer;
  34. private WaferInfo m_BladeAWafer;
  35. private WaferInfo m_BladeBWafer;
  36. private List<string> m_RtDataKeys = new List<string>();
  37. private Dictionary<string, object> m_RtDataValues;
  38. private bool m_PMAIsInstalled;
  39. private bool m_PMBIsInstalled;
  40. private bool m_PMCIsInstalled;
  41. private bool m_PMDIsInstalled;
  42. private bool m_LLAIsInstalled;
  43. private bool m_LLBIsInstalled;
  44. #endregion
  45. #region 属性
  46. public bool TabIsChecked
  47. {
  48. get { return m_TabIsChecked; }
  49. set { SetProperty(ref m_TabIsChecked, value); }
  50. }
  51. public ModuleInfo LP1ModuleInfo
  52. {
  53. get { return m_LP1ModuleInfo; }
  54. set { SetProperty(ref m_LP1ModuleInfo, value); }
  55. }
  56. public ModuleInfo LP2ModuleInfo
  57. {
  58. get { return m_LP2ModuleInfo; }
  59. set { SetProperty(ref m_LP2ModuleInfo, value); }
  60. }
  61. public WaferRobotTAction Robot1TAction
  62. {
  63. get { return m_Robot1TAction; }
  64. set { SetProperty(ref m_Robot1TAction, value); }
  65. }
  66. public WaferRobotXAction Robot1XAction
  67. {
  68. get { return m_Robot1XAction; }
  69. set { SetProperty(ref m_Robot1XAction, value); }
  70. }
  71. public WaferRobotTAction Robot2TAction
  72. {
  73. get { return m_Robot2TAction; }
  74. set { SetProperty(ref m_Robot2TAction, value); }
  75. }
  76. public WaferRobotXAction Robot2XAction
  77. {
  78. get { return m_Robot2XAction; }
  79. set { SetProperty(ref m_Robot2XAction, value); }
  80. }
  81. public RobotMoveInfo RobotMoveInfo
  82. {
  83. get { return m_robotMoveInfo; }
  84. set
  85. {
  86. RobotMoveInfoChanged(m_robotMoveInfo, value);
  87. m_robotMoveInfo = value;
  88. }
  89. }
  90. public WaferInfo LLAWafer
  91. {
  92. get { return m_LLAWafer; }
  93. set { SetProperty(ref m_LLAWafer, value); }
  94. }
  95. public WaferInfo LLBWafer
  96. {
  97. get { return m_LLBWafer; }
  98. set { SetProperty(ref m_LLBWafer, value); }
  99. }
  100. public WaferInfo PMAWafer
  101. {
  102. get { return m_PMAWafer; }
  103. set { SetProperty(ref m_PMAWafer, value); }
  104. }
  105. public WaferInfo PMBWafer
  106. {
  107. get { return m_PMBWafer; }
  108. set { SetProperty(ref m_PMBWafer, value); }
  109. }
  110. public WaferInfo PMCWafer
  111. {
  112. get { return m_PMCWafer; }
  113. set { SetProperty(ref m_PMCWafer, value); }
  114. }
  115. public WaferInfo PMDWafer
  116. {
  117. get { return m_PMDWafer; }
  118. set { SetProperty(ref m_PMDWafer, value); }
  119. }
  120. public WaferInfo BladeAWafer
  121. {
  122. get { return m_BladeAWafer; }
  123. set { SetProperty(ref m_BladeAWafer, value); }
  124. }
  125. public WaferInfo BladeBWafer
  126. {
  127. get { return m_BladeBWafer; }
  128. set { SetProperty(ref m_BladeBWafer, value); }
  129. }
  130. public Dictionary<string, object> RtDataValues
  131. {
  132. get { return m_RtDataValues; }
  133. set { SetProperty(ref m_RtDataValues, value); }
  134. }
  135. public bool PMAIsInstalled
  136. {
  137. get { return m_PMAIsInstalled; }
  138. set { SetProperty(ref m_PMAIsInstalled, value); }
  139. }
  140. public bool PMBIsInstalled
  141. {
  142. get { return m_PMBIsInstalled; }
  143. set { SetProperty(ref m_PMBIsInstalled, value); }
  144. }
  145. public bool PMCIsInstalled
  146. {
  147. get { return m_PMCIsInstalled; }
  148. set { SetProperty(ref m_PMCIsInstalled, value); }
  149. }
  150. public bool PMDIsInstalled
  151. {
  152. get { return m_PMDIsInstalled; }
  153. set { SetProperty(ref m_PMDIsInstalled, value); }
  154. }
  155. public bool LLAIsInstalled
  156. {
  157. get { return m_LLAIsInstalled; }
  158. set { SetProperty(ref m_LLAIsInstalled, value); }
  159. }
  160. public bool LLBIsInstalled
  161. {
  162. get { return m_LLBIsInstalled; }
  163. set { SetProperty(ref m_LLBIsInstalled, value); }
  164. }
  165. #endregion
  166. #region 构造函数
  167. public OperationOverViewModel()
  168. {
  169. DispatcherTimer timer = new DispatcherTimer();
  170. timer.Interval = TimeSpan.FromSeconds(0.5);
  171. timer.Tick += Timer_Tick;
  172. timer.Start();
  173. addDataKeys();
  174. string[] allModules = QueryDataClient.Instance.Service.GetConfig($"System.InstalledModules").ToString().Split(',');
  175. PMAIsInstalled = allModules.Contains("PMA");
  176. PMBIsInstalled = allModules.Contains("PMB");
  177. PMCIsInstalled = allModules.Contains("PMC");
  178. PMDIsInstalled = allModules.Contains("PMD");
  179. LLAIsInstalled = allModules.Contains("LLA");
  180. LLBIsInstalled = allModules.Contains("LLB");
  181. }
  182. #endregion
  183. #region 私有方法
  184. private void Timer_Tick(object sender, EventArgs e)
  185. {
  186. LP1ModuleInfo = ModuleManager.ModuleInfos["LP1"];
  187. LP2ModuleInfo = ModuleManager.ModuleInfos["LP1"];
  188. if (LLAIsInstalled == true)
  189. {
  190. LLAWafer = ModuleManager.ModuleInfos["LLA"].WaferManager.Wafers.FirstOrDefault(x => x.WaferStatus != 0);
  191. }
  192. if (LLBIsInstalled == true)
  193. {
  194. LLBWafer = ModuleManager.ModuleInfos["LLB"].WaferManager.Wafers.FirstOrDefault(x => x.WaferStatus != 0);
  195. }
  196. if (PMAIsInstalled == true)
  197. {
  198. PMAWafer = ModuleManager.ModuleInfos["PMA"].WaferManager.Wafers[0];
  199. }
  200. if (PMBIsInstalled == true)
  201. {
  202. PMBWafer = ModuleManager.ModuleInfos["PMB"].WaferManager.Wafers[0];
  203. }
  204. if (PMCIsInstalled == true)
  205. {
  206. PMCWafer = ModuleManager.ModuleInfos["PMC"].WaferManager.Wafers[0];
  207. }
  208. if (PMDIsInstalled == true)
  209. {
  210. PMDWafer = ModuleManager.ModuleInfos["PMD"].WaferManager.Wafers[0];
  211. }
  212. BladeAWafer = ModuleManager.ModuleInfos["TM"].WaferManager.Wafers[0];
  213. BladeBWafer = ModuleManager.ModuleInfos["TM"].WaferManager.Wafers[1];
  214. RobotMoveInfo = (RobotMoveInfo)QueryDataClient.Instance.Service.GetData("TM.RobotMoveAction");
  215. RtDataValues = QueryDataClient.Instance.Service.PollData(m_RtDataKeys);
  216. }
  217. private async void RobotMoveInfoChanged(RobotMoveInfo oldValue, RobotMoveInfo newValue)
  218. {
  219. string RobotTarget;
  220. if (oldValue == null || newValue == null)
  221. {
  222. return;
  223. }
  224. #region pick 和 place LL
  225. if (oldValue.Action == RobotAction.None && (newValue.Action == RobotAction.Placing || newValue.Action == RobotAction.Picking))
  226. {
  227. var TMRobotMoveActionBladeTarget = newValue.BladeTarget;
  228. if (TMRobotMoveActionBladeTarget != null)
  229. {
  230. RobotTarget = TMRobotMoveActionBladeTarget.ToString();
  231. }
  232. else
  233. {
  234. return;
  235. }
  236. var values = RobotTarget.Split('.');
  237. var arm = values[0];
  238. var module = values[1];
  239. if (arm == "ArmA")
  240. {
  241. Robot1TAction = (WaferRobotTAction)Enum.Parse(typeof(WaferRobotTAction), module, true);
  242. await Task.Delay(1500);
  243. Robot1XAction = WaferRobotXAction.Extend;
  244. await Task.Delay(3000);
  245. Robot1XAction = WaferRobotXAction.Retract;
  246. }
  247. else if (arm == "ArmB")
  248. {
  249. Robot2TAction = (WaferRobotTAction)Enum.Parse(typeof(WaferRobotTAction), module, true);
  250. await Task.Delay(1500);
  251. Robot2XAction = WaferRobotXAction.Extend;
  252. await Task.Delay(3000);
  253. Robot2XAction = WaferRobotXAction.Retract;
  254. }
  255. }
  256. #endregion
  257. #region pick 和 place pm
  258. if (oldValue.Action == RobotAction.None && newValue.Action == RobotAction.Extending)
  259. {
  260. var TMRobotMoveActionBladeTarget = newValue.BladeTarget;
  261. if (TMRobotMoveActionBladeTarget != null)
  262. {
  263. RobotTarget = TMRobotMoveActionBladeTarget.ToString();
  264. }
  265. else
  266. {
  267. return;
  268. }
  269. var values = RobotTarget.Split('.');
  270. var arm = values[0];
  271. var module = values[1];
  272. if (arm == "ArmA")
  273. {
  274. Robot1TAction = (WaferRobotTAction)Enum.Parse(typeof(WaferRobotTAction), module, true);
  275. await Task.Delay(1500);
  276. Robot1XAction = WaferRobotXAction.Extend;
  277. }
  278. else if (arm == "ArmB")
  279. {
  280. Robot2TAction = (WaferRobotTAction)Enum.Parse(typeof(WaferRobotTAction), module, true);
  281. await Task.Delay(1500);
  282. Robot2XAction = WaferRobotXAction.Extend;
  283. }
  284. }
  285. if (oldValue.Action == RobotAction.None && newValue.Action == RobotAction.Retracting)
  286. {
  287. var TMRobotMoveActionBladeTarget = newValue.BladeTarget;
  288. if (TMRobotMoveActionBladeTarget != null)
  289. {
  290. RobotTarget = TMRobotMoveActionBladeTarget.ToString();
  291. }
  292. else
  293. {
  294. return;
  295. }
  296. var values = RobotTarget.Split('.');
  297. var arm = values[0];
  298. if (arm == "ArmA")
  299. {
  300. Robot1XAction = WaferRobotXAction.Retract;
  301. }
  302. else if (arm == "ArmB")
  303. {
  304. Robot2XAction = WaferRobotXAction.Retract;
  305. }
  306. }
  307. #endregion
  308. arm1oldWaferStatus = ModuleManager.ModuleInfos["TM"].WaferManager.Wafers[0].WaferStatus;
  309. arm2oldWaferStatus = ModuleManager.ModuleInfos["TM"].WaferManager.Wafers[1].WaferStatus;
  310. }
  311. private void addDataKeys()
  312. {
  313. m_RtDataKeys.Add("PMA.IsSlitDoorClosed");
  314. m_RtDataKeys.Add("PMB.IsSlitDoorClosed");
  315. m_RtDataKeys.Add("PMC.IsSlitDoorClosed");
  316. m_RtDataKeys.Add("PMD.IsSlitDoorClosed");
  317. m_RtDataKeys.Add("TM.LLATSlitDoor.IsClosed");
  318. m_RtDataKeys.Add("TM.LLBTSlitDoor.IsClosed");
  319. }
  320. #endregion
  321. }
  322. }