| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481 | using Aitex.Core.Common.DeviceData;using Aitex.Core.UI.Control;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.Windows.Threading;using Venus_Core;using Venus_MainPages.Unity;using Venus_Themes.CustomControls;using Venus_Themes.Unity;namespace Venus_MainPages.ViewModels{    public class TMOperationViewModel : BindableBase    {        #region 私有字段        private bool m_TMIsOFFline;        private bool m_LLIsOFFline;        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<string, object> 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<string> m_RtDataKeys=new List<string> ();        private int m_TMOutChamberPressure;        private int m_TMChamberPressureSetPoint;        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); }        }                #endregion        #region 属性        public bool TMIsOFFline        {            get { return m_TMIsOFFline; }            set { SetProperty(ref m_TMIsOFFline, value); }        }        public bool LLIsOFFline        {            get { return m_LLIsOFFline; }            set { SetProperty(ref m_LLIsOFFline, value); }        }        public bool PMADoorIsOpen        {            get { return m_PMADoorIsOpen; }            set { SetProperty(ref m_PMADoorIsOpen, value); }        }        public bool LLADoorIsOpen        {            get { return m_LLADoorIsOpen; }            set { SetProperty(ref m_LLADoorIsOpen, value); }        }        public Dictionary<string, object> 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 TMOutChamberPressure        {            get { return m_TMOutChamberPressure; }            set             {                if (value != m_TMOutChamberPressure)                {                    InvokeClient.Instance.Service.DoOperation($"TM.SetChamberPressure",value);                }                SetProperty(ref m_TMOutChamberPressure, value);            }        }                #endregion        #region 命令        private DelegateCommand _HomeCommand;        public DelegateCommand HomeCommand =>            _HomeCommand ?? (_HomeCommand = 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<object> _ModuleCheckedCommand;        public DelegateCommand<object> ModuleCheckedCommand =>            _ModuleCheckedCommand ?? (_ModuleCheckedCommand = new DelegateCommand<object>(OnModuleChecked));        private DelegateCommand<object> _ControlValveCommand;        public DelegateCommand<object> ControlValveCommand =>            _ControlValveCommand ?? (_ControlValveCommand = new DelegateCommand<object>(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<object> _DoorUpDownCommand;        public DelegateCommand<object> DoorUpDownCommand =>            _DoorUpDownCommand ?? (_DoorUpDownCommand = new DelegateCommand<object>(OnDoorUpDown));        private DelegateCommand<object> _ChamberDoorOpenCommand;        public DelegateCommand<object> ChamberDoorOpenCommand =>            _ChamberDoorOpenCommand ?? (_ChamberDoorOpenCommand = new DelegateCommand<object>(OnChamberDoorOpen));        private DelegateCommand<object> _ChamberDoorCloseCommand;        public DelegateCommand<object> ChamberDoorCloseCommand =>            _ChamberDoorCloseCommand ?? (_ChamberDoorCloseCommand = new DelegateCommand<object>(OnChamberDoorClose));        private DelegateCommand _SetTMChamberPressureCommand;        public DelegateCommand SetTMChamberPressureCommand =>            _SetTMChamberPressureCommand ?? (_SetTMChamberPressureCommand = new DelegateCommand(OnSetTMChamberPressure));                #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;        }        #endregion        #region 命令方法        private void OnHome()        {            InvokeClient.Instance.Service.DoOperation($"{m_ModuleCheckedName}.Home");        }        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.ChamberPressure", TMChamberPressureSetPoint.ToString());        }              #endregion        #region 私有方法        void timer_Tick(object sender, EventArgs e)        {            TMOutChamberPressure = (int)QueryDataClient.Instance.Service.GetConfig("TM.ChamberPressure");            RtDataValues = QueryDataClient.Instance.Service.PollData(m_RtDataKeys);            if (RtDataValues == null)            {                return;            }            TMValveN2IsOpen = CommonFunction.GetValue<bool>(RtDataValues, "TM.TMValveN2.IsOpen");            TMSoftPumpValveIsOpen = CommonFunction.GetValue<bool>(RtDataValues, "TM.TMSoftPumpValve.IsOpen"); ;            TMFastPumpValveIsOpen = CommonFunction.GetValue<bool>(RtDataValues, "TM.TMFastPumpValve.IsOpen"); ;            //TMPurgeValveIsOpen = CommonFunction.GetValue<bool>(RtDataValues, "TM.TMPurgeValve.IsOpen"); ;            TMSoftVentValveIsOpen = CommonFunction.GetValue<bool>(RtDataValues, "TM.TMPurgeValve.IsOpen"); ;            TMFastVentValveIsOpen = CommonFunction.GetValue<bool>(RtDataValues, "TM.TMVentValve.IsOpen"); ;            LLASoftPumpValveIsOpen = CommonFunction.GetValue<bool>(RtDataValues, "TM.LLASoftPumpValve.IsOpen");            LLAFastPumpValveIsOpen = CommonFunction.GetValue<bool>(RtDataValues, "TM.LLAFastPumpValve.IsOpen");            LLAPurgeValveIsOpen = CommonFunction.GetValue<bool>(RtDataValues, "TM.LLAPurgeValve.IsOpen");            LLAVentValveIsOpen = CommonFunction.GetValue<bool>(RtDataValues, "TM.LLAVentValve.IsOpen");            LLBSoftPumpValveIsOpen = CommonFunction.GetValue<bool>(RtDataValues, "TM.LLBSoftPumpValve.IsOpen");            LLBFastPumpValveIsOpen = CommonFunction.GetValue<bool>(RtDataValues, "TM.LLBFastPumpValve.IsOpen");            LLBPurgeValveIsOpen = CommonFunction.GetValue<bool>(RtDataValues, "TM.LLBPurgeValve.IsOpen");            LLBVentValveIsOpen = CommonFunction.GetValue<bool>(RtDataValues, "TM.LLBVentValve.IsOpen");        }        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");        }        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    }}
 |