using Aitex.Core.Common;
using Aitex.Core.RT.DataCenter;
using Aitex.Core.UI.MVVM;
using MECF.Framework.Common.CommonData.Metal;
using MECF.Framework.Common.CommonData.PlatingCell;
using MECF.Framework.Common.CommonData.PowerSupplier;
using MECF.Framework.Common.CommonData.Reservoir;
using MECF.Framework.Common.CommonData.SRD;
using MECF.Framework.Common.DataCenter;
using MECF.Framework.Common.OperationCenter;
using MECF.Framework.Common.Persistent.Reservoirs;
using MECF.Framework.Common.Persistent.SRD;
using MECF.Framework.Common.RecipeCenter;
using MECF.Framework.Common.ToolLayout;
using MECF.Framework.Common.Utilities;
using Prism.Mvvm;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Input;
using System.Windows.Threading;
namespace PunkHPX8_MainPages.ViewModels
{
    public class PlatingCellHomePageViewModel : BindableBase
    {
        #region 常量
        private const string PERSISTENT_VALUE = "PersistentValue";
        private const string PLATINGCELLDATA = "PlatingCellData";
        #endregion
        #region 内部变量
        #region Common
        /// 
        /// 模块名称
        /// 
        private string _module;
        /// 
        /// 当前选择Recipe节点
        /// 
        private RecipeNode _selectedRecipeNode;
        /// 
        /// PlatingCellData
        /// 
        private PlatingCellData _platingCellCommonData;
        /// 
        /// ReservoirData
        /// 
        private ReservoirData _reservoirCommonData;
        /// 
        /// Persistent
        /// 
        private PlatingCellPersistentValue _platingCellPersistent;
        /// 
        /// platingCellItem
        /// 
        private PlatingCellItem _metalItem;
        /// 
        /// WaferSize
        /// 
        private int _selectedWaferSize = 0;
        /// 
        /// Wafer Size List
        /// 
        private List _waferSizeList = new List();
        /// 
        /// 页面功能启用
        /// 
        private bool _isEnabled;
        /// 
        /// AutoMode页面功能启用
        /// 
        private bool _isAutoEnabled;
        /// 
        /// 对应reservoir的name
        /// 
        private string _reservoirName;
        #endregion
    
        /// 
        /// SeqRecipe
        /// 
        private string _seqRecipe;
        #region 系统数据
        /// 
        /// 定时器
        /// 
        DispatcherTimer _timer;
        /// 
        /// 查询后台数据集合
        /// 
        private List _rtDataKeys = new List();
        /// 
        /// rt查询key数值字典
        /// 
        private Dictionary _rtDataValueDic = new Dictionary();
        #endregion
        #region platingCell
        /// 
        /// RecipeContent
        /// 
        private string _recipeContent;
        /// 
        /// TimeRemaining 
        /// 
        private double _timeRemaining;
        /// 
        /// OfTotalTime 
        /// 
        private double _totalTime;
        /// 
        /// OperatingMode 
        /// 
        private string _operatingMode;
        /// 
        /// State
        /// 
        private string _state;
        /// 
        /// RecipeMode 
        /// 
        private string _recipeMode;
        #endregion
        #region dep recipe
        /// 
        /// RecipeModuleName
        /// 
        private string _recipeModuleName;
        /// 
        /// RecipeType
        /// 
        private string _recipeType;
        /// 
        /// AchievedRunRecipeCycle
        /// 
        private int _achievedRunRecipeCycle;
        /// 
        /// 当前Recipe
        /// 
        private string _currentRecipe;
        /// 
        /// 当前Recipe的化学液
        /// 
        private string _chemistry;
        #endregion
        #region UI Related
        /// 
        /// IsErrorState
        /// 
        private bool _isErrorState;
        #endregion
        #region PowerSupplier
        /// 
        /// PowerSuplier数据
        /// 
        private PowerSupplierData _powerSupplierData;
        #endregion
        #region 属性
        #region Common
        /// 
        /// PlatingCellData
        /// 
        public PlatingCellData PlatingCellCommonData
        {
            get { return _platingCellCommonData; }
            set { SetProperty(ref _platingCellCommonData, value); }
            
        }
        /// 
        /// PlatingCellData
        /// 
        public ReservoirData ReservoirCommonData
        {
            get { return _reservoirCommonData; }
            set { SetProperty(ref _reservoirCommonData, value); }
        }
        /// 
        /// Persistent
        /// 
        public PlatingCellPersistentValue PlatingCellPersistent
        {
            get { return _platingCellPersistent; }
            set { SetProperty(ref _platingCellPersistent, value); }
        }
        /// 
        /// 模块名称
        ///        
        public string Module
        {
            get { return _module; }
            set { SetProperty(ref _module, value); }
        }
        /// 
        /// 当前选择Recipe节点
        /// 
        public RecipeNode SelectedRecipeNode
        {
            get { return _selectedRecipeNode; }
            set { SetProperty(ref _selectedRecipeNode, 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); }
        }
        /// 
        /// 页面功能启用
        /// 
        public bool IsEnabled
        {
            get { return _isEnabled; }
            set { SetProperty(ref _isEnabled, value); }
        }
        /// 
        /// AutoMode页面功能启用
        /// 
        public bool IsAutoEnabled
        {
            get { return _isAutoEnabled; }
            set { SetProperty(ref _isAutoEnabled, value); }
        }
        /// 
        /// Reservoir Name
        /// 
        public string ReservoirName
        {
            get { return _reservoirName; }
            set { SetProperty(ref _reservoirName, value); }
        }
        #endregion
        /// SeqRecipe
        /// 
        public string SeqRecipe
        {
            get { return _seqRecipe; }
            set { SetProperty(ref _seqRecipe, value); }
        }
        #region PlatingCell
        /// 
        /// RecipeContent
        /// 
        public string RecipeContent
        {
            get { return _recipeContent; }
            set { SetProperty(ref _recipeContent, value); }
        }
        /// 
        /// TimeRemaining 
        /// 
        public double TimeRemaining
        {
            get { return _timeRemaining; }
            set { SetProperty(ref _timeRemaining, value); }
        }
        /// 
        /// TotalTime  
        /// 
        public double 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); }
        }
        #endregion
        #region Metal 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); }
        }
        /// 
        /// Run Recipe已经完成的次数
        /// 
        public int AchievedRunRecipeCycle
        {
            get { return _achievedRunRecipeCycle; }
            set { SetProperty(ref _achievedRunRecipeCycle, value); }
        }
        /// 
        /// 当前Recipe
        /// 
        public string CurrentRecipe
        {
            get { return _currentRecipe; }
            set { SetProperty(ref _currentRecipe, value); }
        }
        /// 
        /// 当前Recipe
        /// 
        public string Chemistry
        {
            get { return _chemistry; }
            set { SetProperty(ref _chemistry, value); }
        }
        #endregion
        #region UI Related
        /// 
        /// IsErrorState
        /// 
        public bool IsErrorState
        {
            get { return _isErrorState; }
            set { SetProperty(ref _isErrorState, value); }
        }
        #endregion
        /// 
        /// SidA PowerSuplier数据
        /// 
        public PowerSupplierData PowerSupplierData
        {
            get { return _powerSupplierData; }
            set { SetProperty(ref _powerSupplierData, value); }
        }
        #endregion
        
        #endregion
        #region Command指令
        public ICommand InitializeCommand { get; set; }
        #endregion
        /// 
        /// 构造函数
        /// 
        public PlatingCellHomePageViewModel()
        {
            InitializeCommand = new DelegateCommand