using MECF.Framework.Common.CommonData; using MECF.Framework.Common.DataCenter; using OpenSEMI.ClientBase; using Prism.Mvvm; using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; using System.Windows.Threading; using Venus_MainPages.Unity; using Venus_Themes.CustomControls; namespace Venus_MainPages.ViewModels { public class OperationOverViewModel : BindableBase { #region 私有字段 private bool m_TabIsChecked=true; private ModuleInfo m_LP1ModuleInfo; private ModuleInfo m_LP2ModuleInfo; private WaferRobotTAction m_Robot1TAction; private WaferRobotXAction m_Robot1XAction; private WaferRobotTAction m_Robot2TAction; private WaferRobotXAction m_Robot2XAction; private RobotMoveInfo m_robotMoveInfo; int arm1oldWaferStatus = 100; int arm2oldWaferStatus = 100; private WaferInfo m_PMAWafer; private WaferInfo m_PMBWafer; private WaferInfo m_PMCWafer; private WaferInfo m_PMDWafer; private WaferInfo m_LLAWafer; private WaferInfo m_LLBWafer; private WaferInfo m_BladeAWafer; private WaferInfo m_BladeBWafer; private List m_RtDataKeys = new List(); private Dictionary m_RtDataValues; private bool m_PMAIsInstalled; private bool m_PMBIsInstalled; private bool m_PMCIsInstalled; private bool m_PMDIsInstalled; private bool m_LLAIsInstalled; private bool m_LLBIsInstalled; #endregion #region 属性 public bool TabIsChecked { get { return m_TabIsChecked; } set { SetProperty(ref m_TabIsChecked, value); } } public ModuleInfo LP1ModuleInfo { get { return m_LP1ModuleInfo; } set { SetProperty(ref m_LP1ModuleInfo, value); } } public ModuleInfo LP2ModuleInfo { get { return m_LP2ModuleInfo; } set { SetProperty(ref m_LP2ModuleInfo, value); } } public WaferRobotTAction Robot1TAction { get { return m_Robot1TAction; } set { SetProperty(ref m_Robot1TAction, value); } } public WaferRobotXAction Robot1XAction { get { return m_Robot1XAction; } set { SetProperty(ref m_Robot1XAction, value); } } public WaferRobotTAction Robot2TAction { get { return m_Robot2TAction; } set { SetProperty(ref m_Robot2TAction, value); } } public WaferRobotXAction Robot2XAction { get { return m_Robot2XAction; } set { SetProperty(ref m_Robot2XAction, value); } } public RobotMoveInfo RobotMoveInfo { get { return m_robotMoveInfo; } set { RobotMoveInfoChanged(m_robotMoveInfo, value); m_robotMoveInfo = value; } } public WaferInfo LLAWafer { get { return m_LLAWafer; } set { SetProperty(ref m_LLAWafer, value); } } public WaferInfo LLBWafer { get { return m_LLBWafer; } set { SetProperty(ref m_LLBWafer, value); } } public WaferInfo PMAWafer { get { return m_PMAWafer; } set { SetProperty(ref m_PMAWafer, value); } } public WaferInfo PMBWafer { get { return m_PMBWafer; } set { SetProperty(ref m_PMBWafer, value); } } public WaferInfo PMCWafer { get { return m_PMCWafer; } set { SetProperty(ref m_PMCWafer, value); } } public WaferInfo PMDWafer { get { return m_PMDWafer; } set { SetProperty(ref m_PMDWafer, value); } } public WaferInfo BladeAWafer { get { return m_BladeAWafer; } set { SetProperty(ref m_BladeAWafer, value); } } public WaferInfo BladeBWafer { get { return m_BladeBWafer; } set { SetProperty(ref m_BladeBWafer, value); } } public Dictionary RtDataValues { get { return m_RtDataValues; } set { SetProperty(ref m_RtDataValues, value); } } public bool PMAIsInstalled { get { return m_PMAIsInstalled; } set { SetProperty(ref m_PMAIsInstalled, value); } } public bool PMBIsInstalled { get { return m_PMBIsInstalled; } set { SetProperty(ref m_PMBIsInstalled, value); } } public bool PMCIsInstalled { get { return m_PMCIsInstalled; } set { SetProperty(ref m_PMCIsInstalled, value); } } public bool PMDIsInstalled { get { return m_PMDIsInstalled; } set { SetProperty(ref m_PMDIsInstalled, value); } } public bool LLAIsInstalled { get { return m_LLAIsInstalled; } set { SetProperty(ref m_LLAIsInstalled, value); } } public bool LLBIsInstalled { get { return m_LLBIsInstalled; } set { SetProperty(ref m_LLBIsInstalled, value); } } #endregion #region 构造函数 public OperationOverViewModel() { DispatcherTimer timer = new DispatcherTimer(); timer.Interval = TimeSpan.FromSeconds(0.5); timer.Tick += Timer_Tick; timer.Start(); addDataKeys(); string[] allModules = QueryDataClient.Instance.Service.GetConfig($"System.InstalledModules").ToString().Split(','); PMAIsInstalled = allModules.Contains("PMA"); PMBIsInstalled = allModules.Contains("PMB"); PMCIsInstalled = allModules.Contains("PMC"); PMDIsInstalled = allModules.Contains("PMD"); LLAIsInstalled = allModules.Contains("LLA"); LLBIsInstalled = allModules.Contains("LLB"); } #endregion #region 私有方法 private void Timer_Tick(object sender, EventArgs e) { LP1ModuleInfo = ModuleManager.ModuleInfos["LP1"]; LP2ModuleInfo = ModuleManager.ModuleInfos["LP1"]; if (LLAIsInstalled == true) { LLAWafer = ModuleManager.ModuleInfos["LLA"].WaferManager.Wafers.FirstOrDefault(x => x.WaferStatus != 0); } if (LLBIsInstalled == true) { LLBWafer = ModuleManager.ModuleInfos["LLB"].WaferManager.Wafers.FirstOrDefault(x => x.WaferStatus != 0); } if (PMAIsInstalled == true) { PMAWafer = ModuleManager.ModuleInfos["PMA"].WaferManager.Wafers[0]; } if (PMBIsInstalled == true) { PMBWafer = ModuleManager.ModuleInfos["PMB"].WaferManager.Wafers[0]; } if (PMCIsInstalled == true) { PMCWafer = ModuleManager.ModuleInfos["PMC"].WaferManager.Wafers[0]; } if (PMDIsInstalled == true) { PMDWafer = ModuleManager.ModuleInfos["PMD"].WaferManager.Wafers[0]; } BladeAWafer = ModuleManager.ModuleInfos["TM"].WaferManager.Wafers[0]; BladeBWafer = ModuleManager.ModuleInfos["TM"].WaferManager.Wafers[1]; RobotMoveInfo = (RobotMoveInfo)QueryDataClient.Instance.Service.GetData("TM.RobotMoveAction"); RtDataValues = QueryDataClient.Instance.Service.PollData(m_RtDataKeys); } private async void RobotMoveInfoChanged(RobotMoveInfo oldValue, RobotMoveInfo newValue) { string RobotTarget; if (oldValue == null || newValue == null) { return; } #region pick 和 place LL if (oldValue.Action == RobotAction.None && (newValue.Action == RobotAction.Placing || newValue.Action == RobotAction.Picking)) { var TMRobotMoveActionBladeTarget = newValue.BladeTarget; if (TMRobotMoveActionBladeTarget != null) { RobotTarget = TMRobotMoveActionBladeTarget.ToString(); } else { return; } var values = RobotTarget.Split('.'); var arm = values[0]; var module = values[1]; if (arm == "ArmA") { Robot1TAction = (WaferRobotTAction)Enum.Parse(typeof(WaferRobotTAction), module, true); await Task.Delay(1500); Robot1XAction = WaferRobotXAction.Extend; await Task.Delay(3000); Robot1XAction = WaferRobotXAction.Retract; } else if (arm == "ArmB") { Robot2TAction = (WaferRobotTAction)Enum.Parse(typeof(WaferRobotTAction), module, true); await Task.Delay(1500); Robot2XAction = WaferRobotXAction.Extend; await Task.Delay(3000); Robot2XAction = WaferRobotXAction.Retract; } } #endregion #region pick 和 place pm if (oldValue.Action == RobotAction.None && newValue.Action == RobotAction.Extending) { var TMRobotMoveActionBladeTarget = newValue.BladeTarget; if (TMRobotMoveActionBladeTarget != null) { RobotTarget = TMRobotMoveActionBladeTarget.ToString(); } else { return; } var values = RobotTarget.Split('.'); var arm = values[0]; var module = values[1]; if (arm == "ArmA") { Robot1TAction = (WaferRobotTAction)Enum.Parse(typeof(WaferRobotTAction), module, true); await Task.Delay(1500); Robot1XAction = WaferRobotXAction.Extend; } else if (arm == "ArmB") { Robot2TAction = (WaferRobotTAction)Enum.Parse(typeof(WaferRobotTAction), module, true); await Task.Delay(1500); Robot2XAction = WaferRobotXAction.Extend; } } if (oldValue.Action == RobotAction.None && newValue.Action == RobotAction.Retracting) { var TMRobotMoveActionBladeTarget = newValue.BladeTarget; if (TMRobotMoveActionBladeTarget != null) { RobotTarget = TMRobotMoveActionBladeTarget.ToString(); } else { return; } var values = RobotTarget.Split('.'); var arm = values[0]; if (arm == "ArmA") { Robot1XAction = WaferRobotXAction.Retract; } else if (arm == "ArmB") { Robot2XAction = WaferRobotXAction.Retract; } } #endregion arm1oldWaferStatus = ModuleManager.ModuleInfos["TM"].WaferManager.Wafers[0].WaferStatus; arm2oldWaferStatus = ModuleManager.ModuleInfos["TM"].WaferManager.Wafers[1].WaferStatus; } private void addDataKeys() { m_RtDataKeys.Add("PMA.IsSlitDoorClosed"); m_RtDataKeys.Add("PMB.IsSlitDoorClosed"); m_RtDataKeys.Add("PMC.IsSlitDoorClosed"); m_RtDataKeys.Add("PMD.IsSlitDoorClosed"); m_RtDataKeys.Add("TM.LLATSlitDoor.IsClosed"); m_RtDataKeys.Add("TM.LLBTSlitDoor.IsClosed"); } #endregion } }