using MECF.Framework.Common.DataCenter; using MECF.Framework.Common.OperationCenter; using Prism.Commands; using Prism.Mvvm; using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; using System.Windows; using System.Windows.Threading; using Venus_Core; using WPF.Themes.UserControls; namespace Venus_MainPages.ViewModels { public class PlatformViewModel : BindableBase { #region 私有字段 private bool m_LoadLockDoorIsOpen; private bool m_LoadLockPumpValveIsOpen; private bool m_LoadLockVentValveIsOpen; private bool m_IsATM; private string ModuleName="PMA"; private List m_RtDataKeys=new List (); private Dictionary m_RtDataValues=new Dictionary (); private bool m_PumpIsOpen; private int m_PurgeCounter; private Visibility m_WaferIsVisibility; #endregion #region 属性 public bool LoadLockDoorIsOpen { get { return m_LoadLockDoorIsOpen; } set { SetProperty(ref m_LoadLockDoorIsOpen, value); } } public bool LoadLockPumpValveIsOpen { get { return m_LoadLockPumpValveIsOpen; } set { SetProperty(ref m_LoadLockPumpValveIsOpen, value); } } public bool LoadLockVentValveIsOpen { get { return m_LoadLockVentValveIsOpen; } set { SetProperty(ref m_LoadLockVentValveIsOpen, value); } } public bool IsATM { get { return m_IsATM; } set { SetProperty(ref m_IsATM, value); } } public Dictionary RtDataValues { get { return m_RtDataValues; } set { SetProperty(ref m_RtDataValues, value); } } public bool PumpIsOpen { get { return m_PumpIsOpen; } set { SetProperty(ref m_PumpIsOpen, value); } } public int PurgeCounter { get { return m_PurgeCounter; } set { SetProperty(ref m_PurgeCounter, value); } } public Visibility WaferIsVisibility { get { return m_WaferIsVisibility; } set { SetProperty(ref m_WaferIsVisibility, value); } } #endregion #region 命令 private DelegateCommand _PurgeCommand; public DelegateCommand PurgeCommand => _PurgeCommand ?? (_PurgeCommand = new DelegateCommand(OnPurge)); private DelegateCommand _VentCommand; public DelegateCommand VentCommand => _VentCommand ?? (_VentCommand = new DelegateCommand(OnVent)); private DelegateCommand _PumpCommand; public DelegateCommand PumpCommand => _PumpCommand ?? (_PumpCommand = new DelegateCommand(OnPump)); private DelegateCommand _OpenPumpCommand; public DelegateCommand OpenPumpCommand => _OpenPumpCommand ?? (_OpenPumpCommand = new DelegateCommand(OnOpenPump)); private DelegateCommand _ClosePumpCommand; public DelegateCommand ClosePumpCommand => _ClosePumpCommand ?? (_ClosePumpCommand = new DelegateCommand(OnClosePump)); private DelegateCommand _OpenDoorCommand; public DelegateCommand OpenDoorCommand => _OpenDoorCommand ?? (_OpenDoorCommand = new DelegateCommand(OnOpenDoor)); private DelegateCommand _CloseDoorCommand; public DelegateCommand CloseDoorCommand => _CloseDoorCommand ?? (_CloseDoorCommand = new DelegateCommand(OnCloseDoor)); private DelegateCommand _NewWaferCommand; public DelegateCommand NewWaferCommand => _NewWaferCommand ?? (_NewWaferCommand = new DelegateCommand(OnNewWafer)); private DelegateCommand _DeleteWaferCommand; public DelegateCommand DeleteWaferCommand => _DeleteWaferCommand ?? (_DeleteWaferCommand = new DelegateCommand(OnDeleteWafer)); #endregion #region 构造函数 public PlatformViewModel() { m_WaferIsVisibility = Visibility.Collapsed; m_IsATM = true; //var test = RTData.GetRTData().RtDataValues; addDataKeys(); DispatcherTimer timer = new DispatcherTimer(); timer.Interval = TimeSpan.FromSeconds(1); timer.Tick += timer_Tick; timer.Start(); } #endregion #region 命令方法 private void OnPump() { //PumpValveIsOpen = true; //IsATM = !IsATM; InvokeClient.Instance.Service.DoOperation($"{ModuleName}.PumpLoadLock"); } private void OnPurge() { //if (RtDataValues[$"{ModuleName}.FsmState"].ToString() == "Purge") //{ // InvokeClient.Instance.Service.DoOperation($"{ModuleName}.StopPurge"); //} //else //{ // InvokeClient.Instance.Service.DoOperation($"{ModuleName}.Purge"); //} InvokeClient.Instance.Service.DoOperation($"{ModuleName}.PurgeLoadLock"); } private void OnVent() { //if (RtDataValues[$"{ModuleName}.FsmState"].ToString() == "Vent") //{ // //InvokeClient.Instance.Service.DoOperation($"{ModuleName}.StopPurge"); //} //else //{ // InvokeClient.Instance.Service.DoOperation($"{ModuleName}.Vent"); //} InvokeClient.Instance.Service.DoOperation($"{ModuleName}.VentLoadLock"); } private void OnOpenPump() { if (RtDataValues[$"{ModuleName}.FsmState"].ToString() == "LaunchingPump") { InvokeClient.Instance.Service.DoOperation($"{ModuleName}.{RtOperation.Abort}"); return; } InvokeClient.Instance.Service.DoOperation($"{ModuleName}.StartPump"); } private void OnClosePump() { //InvokeClient.Instance.Service.DoOperation($"{ModuleName}.{RtOperation.Abort}"); } private void OnOpenDoor() { InvokeClient.Instance.Service.DoOperation($"{ModuleName}.SetSlitDoor",true); } private void OnCloseDoor() { InvokeClient.Instance.Service.DoOperation($"{ModuleName}.SetSlitDoor",false); } private void OnNewWafer() { if (WaferIsVisibility != Visibility.Visible) { WaferIsVisibility = Visibility.Visible; } else { WPFMessageBox.ShowInformation("晶圆已创建"); } } private void OnDeleteWafer() { WaferIsVisibility = Visibility.Collapsed; } #endregion #region 私有方法 void timer_Tick(object sender, EventArgs e) { RtDataValues = QueryDataClient.Instance.Service.PollData(m_RtDataKeys); LoadLockPumpValveIsOpen = (bool)RtDataValues[$"{ModuleName}.ValveLoadlockPumping.IsOpen"]; LoadLockVentValveIsOpen = (bool)RtDataValues[$"{ModuleName}.ValveLoadlockVent.IsOpen"]; PumpIsOpen = (bool)RtDataValues[$"{ModuleName}.PumpIsRunning"]; PurgeCounter=(int)RtDataValues[$"{ModuleName}.LoadLockPurge.PurgeCounter"]; } private void addConfigKeys() { } private void addDataKeys() { m_RtDataKeys.Add($"{ModuleName}.FsmState"); m_RtDataKeys.Add($"{ModuleName}.ValveLoadlockPumping.IsOpen"); m_RtDataKeys.Add($"{ModuleName}.ValveLoadlockVent.IsOpen"); m_RtDataKeys.Add($"{ModuleName}.PumpIsRunning"); m_RtDataKeys.Add($"{ModuleName}.LoadLockPurge.PurgeCounter"); m_RtDataKeys.Add($"{ModuleName}.IsSlitDoorClosed"); m_RtDataKeys.Add($"{ModuleName}.LoadlockPressure"); } #endregion } }