using Aitex.Core.Common.DeviceData; using Aitex.Core.UI.Control; using MECF.Framework.Common.DataCenter; using MECF.Framework.Common.Equipment; using MECF.Framework.Common.OperationCenter; using Prism.Commands; using Prism.Mvvm; using System; using System.Collections.Generic; using System.Collections.ObjectModel; using System.Linq; using System.Windows.Threading; using Venus_Core; using Venus_MainPages.Unity; using Venus_MainPages.Views; using Venus_Themes.CustomControls; using Venus_Themes.Unity; namespace Venus_MainPages.ViewModels { public class TMOperationViewModel : BindableBase { #region 私有字段 private TMOperationView m_TMOperationView; private bool m_IsOFFline=true; private bool m_TMIsOFFline = true; //private bool m_PMADoorIsOpen; //private bool m_PMBDoorIsOpen; //private bool m_PMCDoorIsOpen; //private bool m_PMDDoorIsOpen; //private bool m_LLADoorIsOpen; private bool m_PMAIsInstalled; private bool m_PMBIsInstalled; private bool m_PMCIsInstalled; private bool m_PMDIsInstalled; private bool m_LLAIsInstalled; private bool m_LLBIsInstalled; private Dictionary m_RtDataValues; private string m_ModuleCheckedName = "TM"; private bool m_TMValveN2IsOpen; private bool m_TMSoftPumpValveIsOpen; private bool m_TMFastPumpValveIsOpen; private bool m_TMPurgeValveIsOpen; private bool m_TMSoftVentValveIsOpen; private bool m_TMFastVentValveIsOpen; private bool m_LLASoftPumpValveIsOpen; private bool m_LLAFastPumpValveIsOpen; private bool m_LLAPurgeValveIsOpen; private bool m_LLAVentValveIsOpen; private bool m_LLBSoftPumpValveIsOpen; private bool m_LLBFastPumpValveIsOpen; private bool m_LLBPurgeValveIsOpen; private bool m_LLBVentValveIsOpen; private List m_RtDataKeys=new List (); private int m_TMOutChamberPressure; private int m_TMOutChamberFlow; private int m_TMChamberPressureSetPoint; private int m_TMChamberFlowSetPoint; private ObservableCollection m_HomeAllSteps = new ObservableCollection(); private int m_StepProcess; private bool m_TMIsHoming; #endregion #region 属性 public bool TMValveN2IsOpen { get { return m_TMValveN2IsOpen; } set { SetProperty(ref m_TMValveN2IsOpen, value); } } public bool TMSoftPumpValveIsOpen { get { return m_TMSoftPumpValveIsOpen; } set { SetProperty(ref m_TMSoftPumpValveIsOpen, value); } } public bool TMFastPumpValveIsOpen { get { return m_TMFastPumpValveIsOpen; } set { SetProperty(ref m_TMFastPumpValveIsOpen, value); } } public bool TMPurgeValveIsOpen { get { return m_TMPurgeValveIsOpen; } set { SetProperty(ref m_TMPurgeValveIsOpen, value); } } public bool TMSoftVentValveIsOpen { get { return m_TMSoftVentValveIsOpen; } set { SetProperty(ref m_TMSoftVentValveIsOpen, value); } } public bool TMFastVentValveIsOpen { get { return m_TMFastVentValveIsOpen; } set { SetProperty(ref m_TMFastVentValveIsOpen, value); } } public bool LLAFastPumpValveIsOpen { get { return m_LLAFastPumpValveIsOpen; } set { SetProperty(ref m_LLAFastPumpValveIsOpen, value); } } public bool LLASoftPumpValveIsOpen { get { return m_LLASoftPumpValveIsOpen; } set { SetProperty(ref m_LLASoftPumpValveIsOpen, value); } } public bool LLAPurgeValveIsOpen { get { return m_LLAPurgeValveIsOpen; } set { SetProperty(ref m_LLAPurgeValveIsOpen, value); } } public bool LLAVentValveIsOpen { get { return m_LLAVentValveIsOpen; } set { SetProperty(ref m_LLAVentValveIsOpen, value); } } public bool LLBSoftPumpValveIsOpen { get { return m_LLBSoftPumpValveIsOpen; } set { SetProperty(ref m_LLBSoftPumpValveIsOpen, value); } } public bool LLBFastPumpValveIsOpen { get { return m_LLBFastPumpValveIsOpen; } set { SetProperty(ref m_LLBFastPumpValveIsOpen, value); } } public bool LLBPurgeValveIsOpen { get { return m_LLBPurgeValveIsOpen; } set { SetProperty(ref m_LLBPurgeValveIsOpen, value); } } public bool LLBVentValveIsOpen { get { return m_LLBVentValveIsOpen; } set { SetProperty(ref m_LLBVentValveIsOpen, value); } } public int TMChamberPressureSetPoint { get { return m_TMChamberPressureSetPoint; } set { SetProperty(ref m_TMChamberPressureSetPoint, value); } } public int TMChamberFlowSetPoint { get { return m_TMChamberFlowSetPoint; } set { SetProperty(ref m_TMChamberFlowSetPoint, value); } } public bool IsOFFline { get { return m_IsOFFline; } set { SetProperty(ref m_IsOFFline, value); } } public bool TMIsOFFline { get { return m_TMIsOFFline; } set { if (m_TMIsOFFline == true && value == false) { //InvokeClient.Instance.Service.DoOperation($"TM.{RtOperation.ControlPressure}"); } if (m_TMIsOFFline == false && value == true) { //InvokeClient.Instance.Service.DoOperation($"TM.{RtOperation.AbortControlPressure}"); } SetProperty(ref m_TMIsOFFline, value); } } //public bool PMADoorIsOpen //{ // get { return m_PMADoorIsOpen; } // set { SetProperty(ref m_PMADoorIsOpen, value); } //} //public bool PMBDoorIsOpen //{ // get { return m_PMBDoorIsOpen; } // set { SetProperty(ref m_PMBDoorIsOpen, value); } //} //public bool PMCDoorIsOpen //{ // get { return m_PMCDoorIsOpen; } // set { SetProperty(ref m_PMCDoorIsOpen, value); } //} //public bool PMDDoorIsOpen //{ // get { return m_PMDDoorIsOpen; } // set { SetProperty(ref m_PMDDoorIsOpen, value); } //} //public bool LLADoorIsOpen //{ // get { return m_LLADoorIsOpen; } // set { SetProperty(ref m_LLADoorIsOpen, 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); } } public int TMOutChamberFlow { get { return m_TMOutChamberFlow; } set { if (value != m_TMOutChamberFlow) { InvokeClient.Instance.Service.DoOperation($"TM.SetChamberFlow", value); } SetProperty(ref m_TMOutChamberFlow, value); } } public int TMOutChamberPressure { get { return m_TMOutChamberPressure; } set { //if (value != m_TMOutChamberPressure) //{ // InvokeClient.Instance.Service.DoOperation($"TM.SetChamberPressure",value); //} SetProperty(ref m_TMOutChamberPressure, value); } } public ObservableCollection HomeAllSteps { get { return m_HomeAllSteps; } set{SetProperty(ref m_HomeAllSteps, value);} } public int StepProcess { get { return m_StepProcess; } set { SetProperty(ref m_StepProcess, value); } } public bool TMIsHoming { get { return m_TMIsHoming; } set { SetProperty(ref m_TMIsHoming, value); } } #endregion #region 命令 private DelegateCommand _LoadCommand; public DelegateCommand LoadCommand => _LoadCommand ?? (_LoadCommand = new DelegateCommand(OnLoad)); private DelegateCommand _HomeCommand; public DelegateCommand HomeCommand => _HomeCommand ?? (_HomeCommand = new DelegateCommand(OnHome)); private DelegateCommand _RobotHomeCommand; public DelegateCommand RobotHomeCommand => _RobotHomeCommand ?? (_RobotHomeCommand = new DelegateCommand(OnHome)); private DelegateCommand _VentCommand; public DelegateCommand VentCommand => _VentCommand ?? (_VentCommand = new DelegateCommand(OnVent)); private DelegateCommand _PumpCommand; public DelegateCommand PumpCommand => _PumpCommand ?? (_PumpCommand = new DelegateCommand(OnPump)); private DelegateCommand _PurgeCommand; public DelegateCommand PurgeCommand => _PurgeCommand ?? (_PurgeCommand = new DelegateCommand(OnPurge)); private DelegateCommand _LeakCheckCommand; public DelegateCommand LeakCheckCommand => _LeakCheckCommand ?? (_LeakCheckCommand = new DelegateCommand(OnLeakCheck)); private DelegateCommand _AbortCommand; public DelegateCommand AbortCommand => _AbortCommand ?? (_AbortCommand = new DelegateCommand(OnAbort)); private DelegateCommand _ModuleCheckedCommand; public DelegateCommand ModuleCheckedCommand => _ModuleCheckedCommand ?? (_ModuleCheckedCommand = new DelegateCommand(OnModuleChecked)); private DelegateCommand _ControlValveCommand; public DelegateCommand ControlValveCommand => _ControlValveCommand ?? (_ControlValveCommand = new DelegateCommand(OnControlValve)); private DelegateCommand _OpenLLPumpCommand; public DelegateCommand OpenLLPumpCommand => _OpenLLPumpCommand ?? (_OpenLLPumpCommand = new DelegateCommand(OnOpenLLPump)); private DelegateCommand _CloseLLPumpCommand; public DelegateCommand CloseLLPumpCommand => _CloseLLPumpCommand ?? (_CloseLLPumpCommand = new DelegateCommand(OnCloseLLPump)); private DelegateCommand _OpenTMPumpCommand; public DelegateCommand OpenTMPumpCommand => _OpenTMPumpCommand ?? (_OpenTMPumpCommand = new DelegateCommand(OnOpenTMPump)); private DelegateCommand _CloseTMPumpCommand; public DelegateCommand CloseTMPumpCommand => _CloseTMPumpCommand ?? (_CloseTMPumpCommand = new DelegateCommand(OnCloseTMPump)); private DelegateCommand _DoorUpDownCommand; public DelegateCommand DoorUpDownCommand => _DoorUpDownCommand ?? (_DoorUpDownCommand = new DelegateCommand(OnDoorUpDown)); private DelegateCommand _ChamberDoorOpenCommand; public DelegateCommand ChamberDoorOpenCommand => _ChamberDoorOpenCommand ?? (_ChamberDoorOpenCommand = new DelegateCommand(OnChamberDoorOpen)); private DelegateCommand _ChamberDoorCloseCommand; public DelegateCommand ChamberDoorCloseCommand => _ChamberDoorCloseCommand ?? (_ChamberDoorCloseCommand = new DelegateCommand(OnChamberDoorClose)); private DelegateCommand _SetTMChamberPressureCommand; public DelegateCommand SetTMChamberPressureCommand => _SetTMChamberPressureCommand ?? (_SetTMChamberPressureCommand = new DelegateCommand(OnSetTMChamberPressure)); private DelegateCommand _OnlineCommand; public DelegateCommand OnlineCommand => _OnlineCommand ?? (_OnlineCommand = new DelegateCommand(OnOnline)); private DelegateCommand _OfflineCommand; public DelegateCommand OfflineCommand => _OfflineCommand ?? (_OfflineCommand = new DelegateCommand(OnOffline)); #endregion #region 构造函数 public TMOperationViewModel() { 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"); DispatcherTimer timer = new DispatcherTimer(); timer.Interval = TimeSpan.FromSeconds(0.5); timer.Tick += timer_Tick; timer.Start(); //UIEvents.PMDoorRaiseChangedEvent += UIEvents_PMDoorRaiseChangedEvent; //UIEvents.LLTDoorRaiseChangedEvent += UIEvents_LLTDoorRaiseChangedEvent; //UIEvents.LLEDoorRaiseChangedEvent += UIEvents_LLEDoorRaiseChangedEvent; HomeAllSteps.Add("Lid"); HomeAllSteps.Add("Robot"); HomeAllSteps.Add("Slit Door"); HomeAllSteps.Add("Pump"); HomeAllSteps.Add("ATM Switch"); } #endregion #region 命令方法 private void OnLoad(object tmOperationView) { m_TMOperationView = (TMOperationView)tmOperationView; } private void OnHome() { InvokeClient.Instance.Service.DoOperation($"{m_ModuleCheckedName}.Home"); } private void OnRobotHome() { InvokeClient.Instance.Service.DoOperation($"{m_ModuleCheckedName}.RobotHome"); } private void OnVent() { InvokeClient.Instance.Service.DoOperation($"{m_ModuleCheckedName}.{RtOperation.Vent}"); } private void OnPump() { InvokeClient.Instance.Service.DoOperation($"{m_ModuleCheckedName}.{RtOperation.Pump}"); } private void OnPurge() { InvokeClient.Instance.Service.DoOperation($"{m_ModuleCheckedName}.{RtOperation.Purge}"); } private void OnLeakCheck() { InvokeClient.Instance.Service.DoOperation($"{m_ModuleCheckedName}.{RtOperation.LeakCheck}"); } private void OnAbort() { InvokeClient.Instance.Service.DoOperation($"{m_ModuleCheckedName}.{RtOperation.Abort}"); } private void OnModuleChecked(object obj) { m_ModuleCheckedName = obj.ToString(); } private void OnControlValve(object obj) { CommonValveControl commonValveControl = (CommonValveControl)obj; if (commonValveControl.IsCanEdit == true) { InvokeClient.Instance.Service.DoOperation($"TM.{commonValveControl.Tag.ToString()}.{AITValveOperation.GVTurnValve}", !commonValveControl.Status); } } private void OnOpenTMPump() { InvokeClient.Instance.Service.DoOperation("TM.ControlPump",true); } private void OnCloseTMPump() { InvokeClient.Instance.Service.DoOperation("TM.ControlPump", false); } private void OnOpenLLPump() { InvokeClient.Instance.Service.DoOperation("LL.ControlPump",true); } private void OnCloseLLPump() { InvokeClient.Instance.Service.DoOperation("LL.ControlPump", false); } private void OnDoorUpDown(object obj) { //string[] value=obj.ToString().Split('.'); InvokeClient.Instance.Service.DoOperation(obj.ToString()); } private void OnChamberDoorOpen(object obj) { InvokeClient.Instance.Service.DoOperation($"{obj?.ToString()}.SlitDoor.Open"); } private void OnChamberDoorClose(object obj) { InvokeClient.Instance.Service.DoOperation($"{obj?.ToString()}.SlitDoor.Close"); } private void OnSetTMChamberPressure() { //InvokeClient.Instance.Service.DoOperation($"TM.SetChamberPressure", TMChamberPressureSetPoint); //TMOutChamberPressure = TMChamberPressureSetPoint; ////InvokeClient.Instance.Service.DoOperation("System.SetConfig", "TM.ControlPressureSetPoint", TMChamberPressureSetPoint.ToString()); } private void OnOnline() { InvokeClient.Instance.Service.DoOperation($"{m_ModuleCheckedName}.{RtOperation.Online}"); } private void OnOffline() { InvokeClient.Instance.Service.DoOperation($"{m_ModuleCheckedName}.{RtOperation.Offline}"); } #endregion #region 私有方法 void timer_Tick(object sender, EventArgs e) { TMOutChamberPressure = (int)QueryDataClient.Instance.Service.GetConfig("TM.ControlPressureSetPoint"); RtDataValues = QueryDataClient.Instance.Service.PollData(m_RtDataKeys); if (RtDataValues == null) { return; } TMValveN2IsOpen = CommonFunction.GetValue(RtDataValues, "TM.TMValveN2.IsOpen"); TMSoftPumpValveIsOpen = CommonFunction.GetValue(RtDataValues, "TM.TMSoftPumpValve.IsOpen"); ; TMFastPumpValveIsOpen = CommonFunction.GetValue(RtDataValues, "TM.TMFastPumpValve.IsOpen"); ; //TMPurgeValveIsOpen = CommonFunction.GetValue(RtDataValues, "TM.TMPurgeValve.IsOpen"); ; TMSoftVentValveIsOpen = CommonFunction.GetValue(RtDataValues, "TM.TMPurgeValve.IsOpen"); ; TMFastVentValveIsOpen = CommonFunction.GetValue(RtDataValues, "TM.TMVentValve.IsOpen"); ; LLASoftPumpValveIsOpen = CommonFunction.GetValue(RtDataValues, "TM.LLASoftPumpValve.IsOpen"); LLAFastPumpValveIsOpen = CommonFunction.GetValue(RtDataValues, "TM.LLAFastPumpValve.IsOpen"); LLAPurgeValveIsOpen = CommonFunction.GetValue(RtDataValues, "TM.LLAPurgeValve.IsOpen"); LLAVentValveIsOpen = CommonFunction.GetValue(RtDataValues, "TM.LLAVentValve.IsOpen"); LLBSoftPumpValveIsOpen = CommonFunction.GetValue(RtDataValues, "TM.LLBSoftPumpValve.IsOpen"); LLBFastPumpValveIsOpen = CommonFunction.GetValue(RtDataValues, "TM.LLBFastPumpValve.IsOpen"); LLBPurgeValveIsOpen = CommonFunction.GetValue(RtDataValues, "TM.LLBPurgeValve.IsOpen"); LLBVentValveIsOpen = CommonFunction.GetValue(RtDataValues, "TM.LLBVentValve.IsOpen"); IsOFFline= !CommonFunction.GetValue(RtDataValues, $"{m_ModuleCheckedName}.IsOnline"); TMIsOFFline= !CommonFunction.GetValue(RtDataValues, $"TM.IsOnline"); TMIsHoming= (TMState)(Enum.Parse(typeof(TMState), RtDataValues[$"TM.FsmState"].ToString()))== TMState.Initializing || (TMState)(Enum.Parse(typeof(TMState), RtDataValues[$"TM.FsmState"].ToString())) == TMState.InitializingRB; if (m_TMOperationView != null) { m_TMOperationView.stepBar.Progress= CommonFunction.GetValue(RtDataValues, "TM.Home.StepNo"); } } private void addDataKeys() { m_RtDataKeys.Add($"TM.TMValveN2.IsOpen"); m_RtDataKeys.Add($"TM.TMSoftPumpValve.IsOpen"); m_RtDataKeys.Add($"TM.TMFastPumpValve.IsOpen"); m_RtDataKeys.Add($"TM.TMPurgeValve.IsOpen"); //m_RtDataKeys.Add($"TM.TMSoftVentValve.IsOpen"); m_RtDataKeys.Add($"TM.TMVentValve.IsOpen"); m_RtDataKeys.Add($"TM.LLASoftPumpValve.IsOpen"); m_RtDataKeys.Add($"TM.LLAFastPumpValve.IsOpen"); m_RtDataKeys.Add($"TM.LLAPurgeValve.IsOpen"); m_RtDataKeys.Add($"TM.LLBPurgeValve.IsOpen"); m_RtDataKeys.Add($"TM.LLAVentValve.IsOpen"); m_RtDataKeys.Add($"TM.LLBVentValve.IsOpen"); m_RtDataKeys.Add($"TM.LLBSoftPumpValve.IsOpen"); m_RtDataKeys.Add($"TM.LLBFastPumpValve.IsOpen"); m_RtDataKeys.Add($"TM.TMVacSwitch.Value"); m_RtDataKeys.Add($"TM.LLAVacSwitch.Value"); m_RtDataKeys.Add($"TM.LLBVacSwitch.Value"); m_RtDataKeys.Add($"TM.TMATMSwitch.Value"); m_RtDataKeys.Add($"TM.LLAATMSwitch.Value"); m_RtDataKeys.Add($"TM.LLBATMSwitch.Value"); m_RtDataKeys.Add($"TM.TMProcessGauge.Value"); m_RtDataKeys.Add($"TM.TMForelineGauge.Value"); m_RtDataKeys.Add($"TM.LLAPressureGauge.Value"); m_RtDataKeys.Add($"TM.LLBPressureGauge.Value"); m_RtDataKeys.Add($"TM.LoadlockForelineGauge.Value"); m_RtDataKeys.Add($"TM.PumpIsRunning"); m_RtDataKeys.Add($"LL.PumpIsRunning"); 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"); m_RtDataKeys.Add("TM.LLAESlitDoor.IsClosed"); m_RtDataKeys.Add("TM.LLBESlitDoor.IsClosed"); m_RtDataKeys.Add("TM.N2PressureSwitch.Value"); m_RtDataKeys.Add("TM.TMPressureCtrl.TMChamberSetPoint"); m_RtDataKeys.Add("LLA.IsOnline"); m_RtDataKeys.Add("LLB.IsOnline"); m_RtDataKeys.Add("TM.IsOnline"); m_RtDataKeys.Add("TM.FsmState"); m_RtDataKeys.Add("TM.Home.StepNo"); } private void UIEvents_PMDoorRaiseChangedEvent(DoorPara obj) { InvokeClient.Instance.Service.DoOperation($"{obj?.ModuleName}.SlitDoor.{obj?.IsOpen}"); } private void UIEvents_LLTDoorRaiseChangedEvent(DoorPara obj) { InvokeClient.Instance.Service.DoOperation($"TM.{obj.ModuleName}TSlitDoor.{obj?.IsOpen}"); } private void UIEvents_LLEDoorRaiseChangedEvent(DoorPara obj) { InvokeClient.Instance.Service.DoOperation($"TM.{obj.ModuleName}ESlitDoor.{obj?.IsOpen}"); } #endregion } }