| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145 | using Aitex.Core.Common.DeviceData;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.Reflection;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 SETMOperationViewModel : BindableBase    {        #region 私有变量        private bool m_TMValveN2IsOpen;        private bool m_TMSoftPumpIsOpen;        private bool m_TMSoftVentIsOpen;        private bool m_TMFastPumpIsOpen;        private bool m_TMFastVentIsOpen;        private bool m_VCESoftPumpIsOpen;        private bool m_VCESoftVentIsOpen;        private bool m_VCEFastPumpIsOpen;        private bool m_VCEFastVentIsOpen;        private bool m_PMAIsInstalled;        private bool m_PMBIsInstalled;        private bool m_PMCIsInstalled;        private Dictionary<string, object> m_RtDataValues = new Dictionary<string, object>();        private List<string> m_RtDataKeys = new List<string>();        #endregion        #region 暴露变量        public bool TMValveN2IsOpen        {            get => m_TMValveN2IsOpen;            set => SetProperty(ref m_TMValveN2IsOpen, value);        }        public bool TMSoftPumpIsOpen { get => m_TMSoftPumpIsOpen; set => SetProperty(ref m_TMSoftPumpIsOpen, value); }        public bool TMSoftVentIsOpen { get => m_TMSoftVentIsOpen; set => SetProperty(ref m_TMSoftVentIsOpen, value); }        public bool TMFastPumpIsOpen { get => m_TMFastPumpIsOpen; set => SetProperty(ref m_TMFastPumpIsOpen, value); }        public bool TMFastVentIsOpen { get => m_TMFastVentIsOpen; set => SetProperty(ref m_TMFastVentIsOpen, value); }        public bool VCESoftPumpIsOpen { get => m_VCESoftPumpIsOpen; set => SetProperty(ref m_VCESoftPumpIsOpen, value); }        public bool VCESoftVentIsOpen { get => m_VCESoftVentIsOpen; set => SetProperty(ref m_VCESoftVentIsOpen, value); }        public bool VCEFastPumpIsOpen { get => m_VCEFastPumpIsOpen; set => SetProperty(ref m_VCEFastPumpIsOpen, value); }        public bool VCEFastVentIsOpen { get => m_VCEFastVentIsOpen; set => SetProperty(ref m_VCEFastVentIsOpen, value); }        public bool PMAIsInstalled { get => m_PMAIsInstalled; set => SetProperty(ref m_PMAIsInstalled,value); }        public bool PMBIsInstalled { get => m_PMBIsInstalled; set => SetProperty(ref m_PMBIsInstalled,value); }        public bool PMCIsInstalled { get => m_PMCIsInstalled; set => SetProperty(ref m_PMCIsInstalled,value); }        public Dictionary<string, object> RtDataValues        {            get { return m_RtDataValues; }            set { SetProperty(ref m_RtDataValues, value); }        }        public bool TMIsOFFline => true;        #endregion        #region 构造函数        public SETMOperationViewModel()        {            addDataKeys();            string[] allModules = QueryDataClient.Instance.Service.GetConfig($"System.InstalledModules").ToString().Split(',');            PMAIsInstalled = allModules.Contains("PMA");            PMBIsInstalled = allModules.Contains("PMB");            PMCIsInstalled = allModules.Contains("PMC");            RtDataValues = QueryDataClient.Instance.Service.PollData(m_RtDataKeys);            //2023/10/20 朱永吉 郭治川 取消N2 valve 动画保持流的状态            TMValveN2IsOpen = true;            TMSoftPumpIsOpen = CommonFunction.GetValue<bool>(RtDataValues,  "SETM.TMSoftPumpValve.IsOpen");            TMSoftVentIsOpen = CommonFunction.GetValue<bool>(RtDataValues,  "SETM.TMSoftVentValve.IsOpen");            TMFastPumpIsOpen = CommonFunction.GetValue<bool>(RtDataValues,  "SETM.TMFastPumpValve.IsOpen");            TMFastVentIsOpen = CommonFunction.GetValue<bool>(RtDataValues,  "SETM.TMFastVentValve.IsOpen");            VCESoftPumpIsOpen = CommonFunction.GetValue<bool>(RtDataValues, "SETM.VCESoftPumpValve.IsOpen");            VCESoftVentIsOpen = CommonFunction.GetValue<bool>(RtDataValues, "SETM.VCESoftVentValve.IsOpen");            VCEFastPumpIsOpen = CommonFunction.GetValue<bool>(RtDataValues, "SETM.VCEFastPumpValve.IsOpen");            VCEFastVentIsOpen = CommonFunction.GetValue<bool>(RtDataValues, "SETM.VCEFastVentValve.IsOpen");            DispatcherTimer timer = new DispatcherTimer();            timer.Interval = TimeSpan.FromSeconds(0.5);            timer.Tick += timer_Tick;            timer.Start();        }        #endregion        #region 公共方法        private DelegateCommand<object> _ControlValveCommand;        public DelegateCommand<object> ControlValveCommand =>            _ControlValveCommand ?? (_ControlValveCommand = new DelegateCommand<object>(OnControlValve));        #endregion        #region 私有方法        private void addDataKeys()        {            //m_RtDataKeys.Add($"SETM.TMValveN2.IsOpen");            m_RtDataKeys.Add($"SETM.TMSoftPumpValve.IsOpen");            m_RtDataKeys.Add($"SETM.TMSoftVentValve.IsOpen");            m_RtDataKeys.Add($"SETM.TMFastPumpValve.IsOpen");            m_RtDataKeys.Add($"SETM.TMFastVentValve.IsOpen");            m_RtDataKeys.Add($"SETM.VCESoftPumpValve.IsOpen");            m_RtDataKeys.Add($"SETM.VCESoftVentValve.IsOpen");            m_RtDataKeys.Add($"SETM.VCEFastPumpValve.IsOpen");            m_RtDataKeys.Add($"SETM.VCESlitDoorClosed");            m_RtDataKeys.Add($"SETM.PMASlitDoorClosed");            m_RtDataKeys.Add($"SETM.PMBSlitDoorClosed");            m_RtDataKeys.Add($"SETM.PMCSlitDoorClosed");        }        private void timer_Tick(object sender, EventArgs e)        {            RtDataValues = QueryDataClient.Instance.Service.PollData(m_RtDataKeys);            //TMValveN2IsOpen = CommonFunction.GetValue<bool>(RtDataValues, "SETM.TMValveN2.IsOpen");            TMSoftPumpIsOpen = CommonFunction.GetValue<bool>(RtDataValues, "SETM.TMSoftPumpValve.IsOpen");            TMSoftVentIsOpen = CommonFunction.GetValue<bool>(RtDataValues, "SETM.TMSoftVentValve.IsOpen");            TMFastPumpIsOpen = CommonFunction.GetValue<bool>(RtDataValues, "SETM.TMFastPumpValve.IsOpen");            TMFastVentIsOpen = CommonFunction.GetValue<bool>(RtDataValues, "SETM.TMFastVentValve.IsOpen");            VCESoftPumpIsOpen = CommonFunction.GetValue<bool>(RtDataValues, "SETM.VCESoftPumpValve.IsOpen");            VCESoftVentIsOpen = CommonFunction.GetValue<bool>(RtDataValues, "SETM.VCESoftVentValve.IsOpen");            VCEFastPumpIsOpen = CommonFunction.GetValue<bool>(RtDataValues, "SETM.VCEFastPumpValve.IsOpen");            VCEFastVentIsOpen = CommonFunction.GetValue<bool>(RtDataValues, "SETM.VCEFastVentValve.IsOpen");        }        private void OnControlValve(object obj)        {            CommonValveControl commonValveControl = (CommonValveControl)obj;            if (commonValveControl.IsCanEdit == true)            {                InvokeClient.Instance.Service.DoOperation($"SETM.{commonValveControl.Tag.ToString()}Valve.{AITValveOperation.GVTurnValve}", !commonValveControl.Status);            }        }        #endregion    }}
 |