using System;
using System.Collections.Generic;
using System.Linq;
using System.Reflection;
using System.Text;
using System.Threading.Tasks;
using MECF.Framework.Common.DataCenter;
using MECF.Framework.Common.Utilities;
using System.Windows.Threading;
using Prism.Commands;
using Prism.Mvvm;
using MECF.Framework.Common.RecipeCenter;
using CyberX8_Core;
using CyberX8_MainPages.PMs;
using MECF.Framework.Common.OperationCenter;
using System.Windows.Input;
using MECF.Framework.Common.Persistent.Reservoirs;
using MECF.Framework.Common.CommonData.Reservoir;
using CyberX8_MainPages.Model;
using System.Collections.ObjectModel;
using OpenSEMI.ClientBase.Command;
namespace CyberX8_MainPages.ViewModels
{
    internal class DosingSystemViewModel : BindableBase
    {
        #region 常量
        private const int MAX_REPLEN_NUM = 4;
        #endregion
        #region 内部变量
        #region system
        /// 
        /// rt查询key
        /// 
        private List _rtDataKeys = new List();
        /// 
        /// 时钟
        /// 
        DispatcherTimer _timer;
        /// 
        /// rt查询数据
        /// 
        private Dictionary _rtDataValueDic = new Dictionary();
        #endregion
        #region Common
        /// 
        /// Module
        /// 
        private string _module;
        /// 
        /// Operation Mode
        /// 
        private string _operatingMode;
        /// 
        /// 状态
        /// 
        private string _state;
        /// 
        /// Reservoirs Persistent数据
        /// 
        private ReservoirsPersistentValue _reservoirsPersistent;
        /// 
        /// Replens Persistent数据
        /// 
        private Dictionary _replensPersistent = new Dictionary();
        /// 
        /// 页面功能启用
        /// 
        private bool _isEnabled;
        /// 
        /// AutoMode页面功能启用
        /// 
        private bool _isAutoEnabled;
        /// 
        /// IsManualorAuto
        /// 
        private bool _isManualorAuto;
        /// 
        /// Reservoir数据
        /// 
        private StandardHotReservoirData _reservoirData;
        #endregion
        #region recipe
        /// 
        /// 当前的recipe
        /// 
        private ResRecipe _currentRecipe;
        /// 
        /// Recipe Mode
        /// 
        private string _recipeMode;
        /// 
        /// Selected Recipe Node
        /// 
        private RecipeNode _selectedRecipeNode;
        /// 
        /// Recipe Type
        /// 
        private string _recipeType;
        /// 
        /// Recipe Manager
        /// 
        private UiRecipeManager _uiRecipeManager = new UiRecipeManager();
        #endregion
        #region DosingSystem      
        /// 
        /// Replen Datas
        /// 
        private ReplenData[] _replenDatas;
        /// 
        /// Replen Data Collection
        /// 
        private ObservableCollection _replenDataCollection;
        /// 
        /// Replen Items
        /// 
        private ObservableCollection _replenEnable = new ObservableCollection(new bool[MAX_REPLEN_NUM]);
        /// 
        /// Replen数量
        /// 
        private int _replenNum;
        /// 
        /// Replen Persistent数据集合
        /// 
        private ObservableCollection _replensPersistentCollection;
        #endregion
        #endregion
        #region 属性
        #region Common
        /// 
        /// Module
        /// 
        public string Module
        {
            get { return _module; }
            set { SetProperty(ref _module, value); }
        }
        /// 
        /// Operation Mode
        /// 
        public string OperatingMode
        {
            get { return _operatingMode; }
            set { SetProperty(ref _operatingMode, value); }
        }
        /// 
        /// 状态
        /// 
        public string State
        {
            get { return _state; }
            set { SetProperty(ref _state, value); }
        }
        /// 
        /// Reservoirs Persistent数据
        /// 
        public ReservoirsPersistentValue ReservoirsPersistent
        {
            get { return _reservoirsPersistent; }
            set { SetProperty(ref _reservoirsPersistent, value); }
        }
        /// 
        /// Replen Persistent数据集合
        /// 
        public ObservableCollection ReplensPersistentCollection
        {
            get { return _replensPersistentCollection; }
            set { SetProperty(ref _replensPersistentCollection, value); }
        }
        /// 
        /// 页面功能启用
        /// 
        public bool IsEnabled
        {
            get { return _isEnabled; }
            set { SetProperty(ref _isEnabled, value); }
        }
        /// 
        /// AutoMode页面功能启用
        /// 
        public bool IsAutoEnabled
        {
            get { return _isAutoEnabled; }
            set { SetProperty(ref _isAutoEnabled, value); }
        }
        /// 
        /// IsManualorAuto
        /// 
        public bool IsManualorAuto
        {
            get { return _isManualorAuto; }
            set { SetProperty(ref _isManualorAuto, value); }
        }
        /// 
        /// Reservoir数据
        /// 
        public StandardHotReservoirData ReservoirData
        {
            get { return _reservoirData; }
            set { SetProperty(ref _reservoirData, value); }
        }
        #endregion
        #region recipe
        /// 
        /// Recipe内容
        /// 
        public ResRecipe CurrentRecipe
        {
            get { return _currentRecipe; }
            set { SetProperty(ref _currentRecipe, value); }
        }
        /// 
        /// Selected Recipe Node
        /// 
        public RecipeNode SelectedRecipeNode
        {
            get { return _selectedRecipeNode; }
            set { SetProperty(ref _selectedRecipeNode, value); }
        }
        /// 
        /// Recipe Mode
        /// 
        public string RecipeMode
        {
            get { return _recipeMode; }
            set { SetProperty(ref _recipeMode, value); }
        }
        /// 
        /// Recipe Type
        /// 
        public string RecipeType
        {
            get { return _recipeType; }
            set { SetProperty(ref _recipeType, value); }
        }
        #endregion
        #region DosingSystem               
        /// 
        /// Replen 数据
        /// 
        public ReplenData[] ReplenDatas
        {
            get { return _replenDatas; }
            set { SetProperty(ref _replenDatas, value); }
        }
        /// 
        /// Replen Data集合
        /// 
        public ObservableCollection ReplenDataCollection
        {
            get { return _replenDataCollection; }
            set { SetProperty(ref _replenDataCollection, value); }
        }
        /// 
        /// Replen Enable列表
        /// 
        public ObservableCollection ReplenEnable
        {
            get { return _replenEnable; }
            set { SetProperty(ref _replenEnable, value); }
        }
        /// 
        /// Replen 数量
        /// 
        public int ReplenNum
        {
            get { return _replenNum; }
            set { SetProperty(ref _replenNum, value); }
        }
        #endregion
        #endregion
        #region 命令
        public ICommand InitializeCommand { get; set; }
        public ICommand BackCommand { get; set; }
        #endregion
        /// 
        /// 构造函数
        /// 
        public DosingSystemViewModel()
        {
            InitializeCommand = new DelegateCommand