OperationOverViewModel.cs 12 KB

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