using Aitex.Core.UI.MVVM;
using MECF.Framework.Common.CommonData.Prewet;
using MECF.Framework.Common.CommonData.PUF;
using MECF.Framework.Common.CommonData.Vpw;
using MECF.Framework.Common.DataCenter;
using MECF.Framework.Common.Device.LinMot;
using MECF.Framework.Common.OperationCenter;
using MECF.Framework.Common.Persistent.Prewet;
using MECF.Framework.Common.Persistent.VpwMain;
using MECF.Framework.Common.RecipeCenter;
using MECF.Framework.Common.Utilities;
using Prism.Mvvm;
using PunkHPX8_MainPages.Unity;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Input;
using System.Windows.Threading;
using WaferInfo = OpenSEMI.ClientBase.WaferInfo;
namespace PunkHPX8_MainPages.ViewModels
{
    public class VPWMainViewModel : BindableBase
    {
        #region 常量
        private const string COMMONDATA = "CommonData";
        private const string VPW = "vpw";
        private const string PERSISTENT_VALUE = "PersistentValue";
        #endregion
        #region 内部变量
        #region Common
        /// 
        /// 模块名称
        /// 
        private string _module;
        /// 
        /// StateMachine
        /// 
        private string _stateMachine;
        /// 
        /// Status
        /// 
        private string _status;
        /// 
        /// 数据
        /// 
        private VpwMainCommonData _vpwMainCommonData;
        /// 
        /// Threshold
        /// 
        private VpwMainPersistentValue _vpwMainPersistent;
        /// 
        /// 是否是Manual模式
        /// 
        private bool _isManualOperationMode;
        /// 
        /// 是否在purge
        /// 
        private bool _isPurge;
        #endregion
        #region UI
        /// 
        /// IsErrorState 用于腔体变红
        /// 
        private bool _isErrorState;
        /// 
        /// 页面功能启用
        /// 
        private bool _isEnabled;
        /// 
        /// AutoMode页面功能启用
        /// 
        private bool _isAutoEnabled;
        /// 
        /// cell 1 flow
        /// 
        private double _vpw1CellFlow;
        /// 
        /// cell 2 flow
        /// 
        private double _vpw2CellFlow;
        /// 
        /// cell 1 vacuum valve
        /// 
        private bool _vpw1VacuumValve;
        /// 
        /// cell 2 vacuum valve
        /// 
        private bool _vpw2VacuumValve;
        /// 
        /// VPW1Wafer信息
        /// 
        private WaferInfo _vPW1WaferInfo;
        /// 
        /// VPW2Wafer信息
        /// 
        private WaferInfo _vPW2WaferInfo;
        #endregion
        #endregion
        #region 系统数据
        /// 
        /// 定时器
        /// 
        DispatcherTimer _timer;
        /// 
        /// 查询后台数据集合
        /// 
        private List _rtDataKeys = new List();
        /// 
        /// rt查询key数值字典
        /// 
        private Dictionary _rtDataValueDic = new Dictionary();
        #endregion
        #region 属性
        #region Common
        /// 
        /// 模块名称
        /// 
        public string Module { get { return _module; } set { SetProperty(ref _module, value); } }
        /// 
        /// StateMachine
        /// 
        public string StateMachine { get { return _stateMachine; } set { SetProperty(ref _stateMachine, value); } }
        /// 
        /// Status
        /// 
        public string Status { get { return _status; } set { SetProperty(ref _status, value); } }
        /// 
        /// Commondata
        /// 
        public VpwMainCommonData VpwMainCommonData
        {
            get { return _vpwMainCommonData; }
            set { SetProperty(ref _vpwMainCommonData, value); }
        }
        /// 
        /// Persistent
        /// 
        public VpwMainPersistentValue VpwMainPersistent
        {
            get { return _vpwMainPersistent; }
            set { SetProperty(ref _vpwMainPersistent, value); }
        }
        /// 
        /// 是否是Manual模式
        /// 
        public bool IsManualOperationMode { get { return _isManualOperationMode; } set { SetProperty(ref _isManualOperationMode, value); } }
        /// 
        /// 是否在purge
        /// 
        public bool IsPurge { get { return _isPurge; } set { SetProperty(ref _isPurge, value); } }
        #endregion
        #region UI
        /// 
        /// IsErrorState
        /// 
        public bool IsErrorState { get { return _isErrorState; } set { SetProperty(ref _isErrorState, value); } }
        /// 
        /// 页面功能启用
        /// 
        public bool IsEnabled
        {
            get { return _isEnabled; }
            set { SetProperty(ref _isEnabled, value); }
        }
        /// 
        /// AutoMode页面功能启用
        /// 
        public bool IsAutoEnabled
        {
            get { return _isAutoEnabled; }
            set { SetProperty(ref _isAutoEnabled, value); }
        }
        /// 
        ///cell 1 flow
        /// 
        public double Vpw1CellFlow
        {
            get { return _vpw1CellFlow; }
            set { SetProperty(ref _vpw1CellFlow, value); }
        }
        /// 
        ///cell 2 flow
        /// 
        public double Vpw2CellFlow
        {
            get { return _vpw2CellFlow; }
            set { SetProperty(ref _vpw2CellFlow, value); }
        }
        /// 
        ///cell 1 vacuum valve
        /// 
        public bool Vpw1VacuumValve
        {
            get { return _vpw1VacuumValve; }
            set { SetProperty(ref _vpw1VacuumValve, value); }
        }
        /// 
        ///cell 2 vacuum valve
        /// 
        public bool Vpw2VacuumValve
        {
            get { return _vpw2VacuumValve; }
            set { SetProperty(ref _vpw2VacuumValve, value); }
        }
        /// 
        /// VPW1Wafer
        /// 
        public WaferInfo VPW1WaferInfo
        {
            get { return _vPW1WaferInfo; }
            set { SetProperty(ref _vPW1WaferInfo, value); }
        }
        /// 
        /// VPW2Wafer
        /// 
        public WaferInfo VPW2WaferInfo
        {
            get { return _vPW2WaferInfo; }
            set { SetProperty(ref _vPW2WaferInfo, value); }
        }
        #endregion
        #endregion
        #region Command指令
        public ICommand InitializeCommand { get; set; }
        public ICommand HomeCommand { get; set; }
        #endregion
        public VPWMainViewModel()
        {
            InitializeCommand = new DelegateCommand