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 m_RtDataValues = new Dictionary(); private List m_RtDataKeys = new List(); #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 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(RtDataValues, "SETM.TMSoftPumpValve.IsOpen"); TMSoftVentIsOpen = CommonFunction.GetValue(RtDataValues, "SETM.TMSoftVentValve.IsOpen"); TMFastPumpIsOpen = CommonFunction.GetValue(RtDataValues, "SETM.TMFastPumpValve.IsOpen"); TMFastVentIsOpen = CommonFunction.GetValue(RtDataValues, "SETM.TMFastVentValve.IsOpen"); VCESoftPumpIsOpen = CommonFunction.GetValue(RtDataValues, "SETM.VCESoftPumpValve.IsOpen"); VCESoftVentIsOpen = CommonFunction.GetValue(RtDataValues, "SETM.VCESoftVentValve.IsOpen"); VCEFastPumpIsOpen = CommonFunction.GetValue(RtDataValues, "SETM.VCEFastPumpValve.IsOpen"); VCEFastVentIsOpen = CommonFunction.GetValue(RtDataValues, "SETM.VCEFastVentValve.IsOpen"); DispatcherTimer timer = new DispatcherTimer(); timer.Interval = TimeSpan.FromSeconds(0.5); timer.Tick += timer_Tick; timer.Start(); } #endregion #region 公共方法 private DelegateCommand _ControlValveCommand; public DelegateCommand ControlValveCommand => _ControlValveCommand ?? (_ControlValveCommand = new DelegateCommand(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(RtDataValues, "SETM.TMValveN2.IsOpen"); TMSoftPumpIsOpen = CommonFunction.GetValue(RtDataValues, "SETM.TMSoftPumpValve.IsOpen"); TMSoftVentIsOpen = CommonFunction.GetValue(RtDataValues, "SETM.TMSoftVentValve.IsOpen"); TMFastPumpIsOpen = CommonFunction.GetValue(RtDataValues, "SETM.TMFastPumpValve.IsOpen"); TMFastVentIsOpen = CommonFunction.GetValue(RtDataValues, "SETM.TMFastVentValve.IsOpen"); VCESoftPumpIsOpen = CommonFunction.GetValue(RtDataValues, "SETM.VCESoftPumpValve.IsOpen"); VCESoftVentIsOpen = CommonFunction.GetValue(RtDataValues, "SETM.VCESoftVentValve.IsOpen"); VCEFastPumpIsOpen = CommonFunction.GetValue(RtDataValues, "SETM.VCEFastPumpValve.IsOpen"); VCEFastVentIsOpen = CommonFunction.GetValue(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 } }