using Aitex.Core.RT.DataCenter;
using Aitex.Core.RT.Log;
using Aitex.Core.UI.Dialog;
using Aitex.Core.UI.MVVM;
using Aitex.Core.Util;
using Aitex.Core.Utilities;
using MECF.Framework.Common.CommonData;
using MECF.Framework.Common.DataCenter;
using MECF.Framework.Common.Equipment;
using MECF.Framework.Common.OperationCenter;
using MECF.Framework.Common.RecipeCenter;
using MECF.Framework.Common.Utilities;
using PunkHPX8_Core;
using PunkHPX8_MainPages.PMs;
using PunkHPX8_Themes.UserControls;
using Prism.Mvvm;
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.ComponentModel;
using System.Linq;
using System.Reflection;
using System.Text;
using System.Threading.Tasks;
using System.Timers;
using System.Windows;
using System.Windows.Input;
using System.Windows.Threading;
namespace PunkHPX8_MainPages.ViewModels
{
    public class SystemFacilitiesViewModel : BindableBase
    {
        #region 常量
        private const string FACILITIES = "Facilities";
        private const string FACILITIES_DATA = "Facilities_Data";
        private const string N2_ENABLE = "N2Enable";
        private const string CDA_ENABLE = "CDAEnable";
        private const string EXTERNAL_CDA_ENABLE = "ExternalCDAEnable";
        private const string DI_WATER_ENABLE = "DiWaterEnable";
        private const string HOUSE_CHILLED_WATER_ENABLE="HouseChilledWaterEnable";
        private const string VPW_DI_ENABLE = "VpwDiEnable";
        private const string DI_REPLEN_ENABLE = "DiReplenEnable";
        private const string DI_FILL_ENABLE = "DiFillEnable";
        private const string SRD_DI_ENABLE = "SrdDiwEnable";
        private const string SAMPLE_STATION_ENABLE = "SampleStationEnable";
        private const string FILTER_PURGE_ENABLE = "FilterPurgeEnable";
        private const string N2_BLANKET_PRESSURE_VALUE = "N2BlanketPressure";
        private const string N2_OVERFLOW_PRESSURE_VALUE = "N2OverflowPressure";
        private const string CLAMSHELL_CYLINDER_PRESSURE_VALUE = "ClamshellCylinderPressure";
        private const string TILT_CYLINDER_PRESSURE_VALUE = "TiltCylinderPressure";
        private const string FFU_PLATECELL_PRESSURE_ERROR = "FFUPlateCellPressureError";
        private const string FFU_CORRIDOR_PRESSURE_ERROR = "FFUCorridorPressureError";
        private const string FFU_PLATECELL_PRESSURE_PRESSURE = "FFUPlateCellPressure";
        private const string FFU_CORRIDOR_PRESSURE = "FFUCorridorPressure";
        #endregion
        #region 内部变量
        private CommonLimitData _nitrogen1AData = new CommonLimitData();
        private CommonLimitData _nitrogen1BData = new CommonLimitData();
        private CommonLimitData _nitrogen2AData = new CommonLimitData();
        private CommonLimitData _nitrogen2BData = new CommonLimitData();
        private CommonLimitData _cda1Data = new CommonLimitData();
        private CommonLimitData _cda2Data = new CommonLimitData();
        private CommonLimitData _extendCdaData = new CommonLimitData();
        private CommonLimitData _systemVacuumData = new CommonLimitData();
        private CommonLimitData _systemExhaust1Data = new CommonLimitData();
        private CommonLimitData _systemExhaust2Data = new CommonLimitData();
        private CommonLimitData _diWaterPressureData = new CommonLimitData();
        private CommonLimitData _diWaterReturnFlowData = new CommonLimitData();
        private CommonLimitData _houseChilledWaterFlowData = new CommonLimitData();
        private bool _nitrogenOn;
        private bool _cdaOn;
        private bool _extendCdaOn;
        private bool _diWaterPressureOn;
        private bool _houseChilledWaterFlowOn;
        private bool _vpwDiWEnable;
        private bool _diFillEnable;
        private bool _diReplenEnable;
        private bool _srdDiWEnable;
        private bool _sampleStationEnable;
        private bool _filterPurgeEnable;
        private bool _plateCellFFUPressureError;
        private bool _corridorFFUPressureError;
        private double _n2BlanketPressure;
        private double _n2OverflowPressure;
        private double _clamshellCylinderPressure;
        private double _tiltCylinderPressure;
        
        private double _plateCellFFUPressure;
        private double _corridorFFUPressure;
        /// 
        /// 定时器
        /// 
        DispatcherTimer _timer;
        /// 
        /// 查询后台数据集合
        /// 
        private List _rtDataKeys = new List();
        /// 
        /// rt查询key数值字典
        /// 
        private Dictionary _rtDataValueDic = new Dictionary();
        #region Home
        #endregion
        #endregion
        
        #region 属性
        public CommonLimitData Nitrogen1AData{ get { return _nitrogen1AData; } set { SetProperty(ref _nitrogen1AData, value); } }
        public CommonLimitData Nitrogen1BData { get { return _nitrogen1BData; } set { SetProperty(ref _nitrogen1BData, value); }}
        public CommonLimitData Nitrogen2AData { get { return _nitrogen2AData; } set { SetProperty(ref _nitrogen2AData, value); } }
        public CommonLimitData Nitrogen2BData { get { return _nitrogen2BData; } set { SetProperty(ref _nitrogen2BData, value); } }
        public CommonLimitData SystemVacuumData { get { return _systemVacuumData; } set { SetProperty(ref _systemVacuumData, value); } }
        public CommonLimitData Cda1Data { get { return _cda1Data; }set { SetProperty(ref _cda1Data, value); } }
        public CommonLimitData Cda2Data{ get { return _cda2Data; } set { SetProperty(ref _cda2Data, value); }}
        public CommonLimitData ExtendCdaData{ get { return _extendCdaData; } set { SetProperty(ref _extendCdaData, value); }}
        public CommonLimitData SystemExhaust1Data { get { return _systemExhaust1Data; } set { SetProperty(ref _systemExhaust1Data, value); } }
        
        public CommonLimitData SystemExhaust2Data { get { return _systemExhaust2Data; } set { SetProperty(ref _systemExhaust2Data, value); } }
        public CommonLimitData DiWaterPressureData { get { return _diWaterPressureData; } set { SetProperty(ref _diWaterPressureData, value); }}
        
        public CommonLimitData DiWaterReturnFlowData { get { return _diWaterReturnFlowData; } set { SetProperty(ref _diWaterReturnFlowData, value); }}
        public CommonLimitData HouseChilledWaterFlowData{ get { return _houseChilledWaterFlowData; } set { SetProperty(ref _houseChilledWaterFlowData, value); }}
        public bool NitrogenOn { get { return _nitrogenOn; } set { SetProperty(ref _nitrogenOn, value); }}
        public bool CdaOn { get { return _cdaOn; } set { SetProperty(ref _cdaOn, value); } }
        public bool ExtendCdaOn { get { return _extendCdaOn; } set { SetProperty(ref _extendCdaOn, value); } }
        public bool DiWaterPressureOn{ get { return _diWaterPressureOn; } set { SetProperty(ref _diWaterPressureOn, value); } }
        public bool HouseChilledWaterFlowOn { get { return _houseChilledWaterFlowOn; } set { SetProperty(ref _houseChilledWaterFlowOn, value); } }
  
        
        public bool DiFillEnable{ get { return _diFillEnable; } set { SetProperty(ref _diFillEnable, value); }}
        public bool DiReplenEnable{get { return _diReplenEnable; }set { SetProperty(ref _diReplenEnable, value); } }
        public bool SrdDiWEnable { get { return _srdDiWEnable; } set { SetProperty(ref _srdDiWEnable, value); } }
        public bool SampleStationEnable { get { return _sampleStationEnable; } set { SetProperty(ref _sampleStationEnable, value); } }
        public bool FilterPurgeEnable{ get { return _filterPurgeEnable; } set { SetProperty(ref _filterPurgeEnable, value);} }
        
        public double N2BlanketPressure { get { return _n2BlanketPressure; } set { SetProperty(ref _n2BlanketPressure, value); } }
        
        public double N2OverflowPressure { get { return _n2OverflowPressure; } set { SetProperty(ref _n2OverflowPressure, value); } }
        
        public double ClamshellCylinderPressure { get { return _clamshellCylinderPressure; } set { SetProperty(ref _clamshellCylinderPressure, value); } }
        
        public double TiltCylinderPressure { get { return _tiltCylinderPressure; } set { SetProperty(ref _tiltCylinderPressure, value); } }
        #region FFU
        public bool PlateCellFFUPressureError { get { return _plateCellFFUPressureError; } set { SetProperty(ref _plateCellFFUPressureError, value); } }
        public bool CorridorFFUPressureError { get { return _corridorFFUPressureError; } set { SetProperty(ref _corridorFFUPressureError, value); } }
        public double PlateCellFFUPressure { get { return _plateCellFFUPressure; } set { SetProperty(ref _plateCellFFUPressure, value); } }
        public double CorridorFFUPressure { get { return _corridorFFUPressure; } set { SetProperty(ref _corridorFFUPressure, value); } }
        #endregion
        #region Other Module
        public bool VpwDiWEnable { get { return _vpwDiWEnable; } set { SetProperty(ref _vpwDiWEnable, value); } }
        #endregion
        #endregion
        #region 指令
        public ICommand NitrogenOnCommand{get;private set;}
        
        public ICommand NitrogenOffCommand{ get;private set;}
        public ICommand CDAOnCommand { get; private set; }
        public ICommand CDAOffCommand { get; private set; }
        public ICommand ExternalCDAOnCommand { get;private set; }
        public ICommand ExternalCDAOffCommand { get;private set; }
        public ICommand DiWaterPressureOnCommand { get; private set; }
        public ICommand DiWaterPressureOffCommand { get; private set; }
        public ICommand HouseChilledWaferFlowOnCommand {  get; private set; }   
        public ICommand HouseChilledWaferFlowOffCommand { get; private set; }
        public ICommand VpwDiwEnableCommand { get; private set; }
        public ICommand VpwDiwDisableCommand { get; private set; }
        public ICommand DiwFillEnableCommand { get; private set; }   
        public ICommand DiwFillDisableCommand { get; private set; }
        public ICommand DiwReplenEnableCommand { get; private set; }
        public ICommand DiwReplenDisableCommand { get; private set; }
        public ICommand SrdDiwEnableCommand { get; private set; }
        public ICommand SrdDiwDisableCommand { get; private set; }
        public ICommand SampleStationEnableCommand { get; private set; }
        public ICommand SampleStationDisableCommand { get; private set; }
        public ICommand FilterPurgeEnableCommand { get; private set; }
        public ICommand FilterPurgeDisableCommand { get; private set; }
        #endregion
        /// 
        /// 构造函数
        /// 
        public SystemFacilitiesViewModel()
        {
           
            NitrogenOnCommand = new DelegateCommand