using Aitex.Core.Common;
using Aitex.Core.UI.MVVM;
using MECF.Framework.Common.CommonData.Vpw;
using MECF.Framework.Common.DataCenter;
using MECF.Framework.Common.OperationCenter;
using MECF.Framework.Common.Persistent.VpwCell;
using MECF.Framework.Common.Persistent.VpwMain;
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 VPWCellViewModel: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 VpwCellCommonData _vpwCellCommonData;
        /// 
        /// VPW Main数据
        /// 
        private VpwMainCommonData _vpwMainCommonData;
        /// 
        /// Threshold
        /// 
        private VpwCellPersistentValue _vpwCellPersistent;
        /// 
        /// 是否是Manual模式
        /// 
        private bool _isManualOperationMode;
        /// 
        /// WaferSize
        /// 
        private int _selectedWaferSize = 0;
        /// 
        /// Wafer Size List
        /// 
        private List _waferSizeList = new List();
        #endregion
        #region VPW recipe
        /// 
        /// RecipeModuleName
        /// 
        private string _recipeModuleName;
        /// 
        /// RecipeType
        /// 
        private string _recipeType;
        /// 
        /// AchievedRunRecipeCycle
        /// 
        private int _achievedRunRecipeCycle;
        /// 
        /// 当前Recipe
        /// 
        private string _currentRecipe;
        /// 
        /// RecipeContent
        /// 
        private string _recipeContent;
        /// 
        /// TimeRemaining 
        /// 
        private int _timeRemaining;
        /// 
        /// OfTotalTime 
        /// 
        private int _totalTime;
        /// 
        /// OperatingMode 
        /// 
        private string _operatingMode;
        /// 
        /// State Machine
        /// 
        private string _state;
        /// 
        /// RecipeMode 
        /// 
        private string _recipeMode;
        #endregion
       
        #region UI
        /// 
        /// IsErrorState 用于腔体变红
        /// 
        private bool _isErrorState;
        /// 
        /// 页面功能启用
        /// 
        private bool _isEnabled;
        /// 
        /// AutoMode页面功能启用
        /// 
        private bool _isAutoEnabled;
        /// 
        /// 水阻值
        /// 
        private double _diwLoopDo;
        #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); }
        }
        /// 
        /// Commondata
        /// 
        public VpwCellCommonData VpwCellCommonData
        {
            get { return _vpwCellCommonData; }
            set { SetProperty(ref _vpwCellCommonData, value); }
        }
        /// 
        /// Persistent
        /// 
        public VpwCellPersistentValue VpwCellPersistent
        {
            get { return _vpwCellPersistent; }
            set { SetProperty(ref _vpwCellPersistent, value); }
        }
        /// 
        /// 是否是Manual模式
        /// 
        public bool IsManualOperationMode { get { return _isManualOperationMode; } set { SetProperty(ref _isManualOperationMode, value); } }
        #endregion
        #region VPW recipe
        /// 
        /// RecipeModuleName
        /// 
        public string RecipeModuleName
        {
            get { return _recipeModuleName; }
            set { SetProperty(ref _recipeModuleName, value); }
        }
        /// 
        /// RecipeType
        /// 
        public string RecipeType
        {
            get { return _recipeType; }
            set { SetProperty(ref _recipeType, value); }
        }
        public int AchievedRunRecipeCycle
        {
            get { return _achievedRunRecipeCycle; }
            set { SetProperty(ref _achievedRunRecipeCycle, value); }
        }
        /// 
        /// 当前运行的Recipe
        /// 
        public string CurrentRecipe
        {
            get { return _currentRecipe; }
            set { SetProperty(ref _currentRecipe, value); }
        }
        /// 
        /// RecipeContent
        /// 
        public string RecipeContent
        {
            get { return _recipeContent; }
            set { SetProperty(ref _recipeContent, value); }
        }
        /// 
        /// TimeRemaining 
        /// 
        public int TimeRemaining
        {
            get { return _timeRemaining; }
            set { SetProperty(ref _timeRemaining, value); }
        }
        /// 
        /// TotalTime  
        /// 
        public int TotalTime
        {
            get { return _totalTime; }
            set { SetProperty(ref _totalTime, value); }
        }
        /// 
        /// OperatingMode
        /// 
        public string OperatingMode
        {
            get { return _operatingMode; }
            set { SetProperty(ref _operatingMode, value); }
        }
        /// 
        /// State
        /// 
        public string State
        {
            get { return _state; }
            set { SetProperty(ref _state, value); }
        }
        /// 
        /// RecipeMode
        /// 
        public string RecipeMode
        {
            get { return _recipeMode; }
            set { SetProperty(ref _recipeMode, value); }
        }
        /// 
        /// WaferSize
        /// 
        public int SelectedWaferSize
        {
            get { return _selectedWaferSize; }
            set { SetProperty(ref _selectedWaferSize, value); }
        }
        /// 
        /// WaferSizeList
        /// 
        public List WaferSizeList
        {
            get { return _waferSizeList; }
            set { SetProperty(ref _waferSizeList, 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); }
        }
        /// 
        /// 水阻值
        /// 
        public double DiwLoopDo
        {
            get { return _diwLoopDo; }
            set { SetProperty(ref _diwLoopDo, value); }
        }
        #endregion
        #region wafer
        /// 
        /// WaferID
        /// 
        private string _waferID = "";
        /// 
        /// SeqRecipe
        /// 
        private string _seqRecipe;
        /// 
        /// Wafer信息
        /// 
        private WaferInfo _waferInfo;
        #endregion
        #region wafer
        /// 
        /// WaferID
        /// 
        public string WaferID
        {
            get { return _waferID; }
            set { SetProperty(ref _waferID, value); }
        }
        /// 
        /// SeqRecipe
        /// 
        public string SeqRecipe
        {
            get { return _seqRecipe; }
            set { SetProperty(ref _seqRecipe, value); }
        }
        /// 
        /// Wafer信息
        /// 
        public WaferInfo WaferInfo
        {
            get { return _waferInfo; }
            set { SetProperty(ref _waferInfo, value); }
        }
        #endregion
        #endregion
        #region Command指令
        public ICommand InitializeCommand { get; set; }
        public ICommand HomeCommand { get; set; }
        #endregion
        public VPWCellViewModel()
        {
            InitializeCommand = new DelegateCommand