using Aitex.Core.RT.Log; using Aitex.Core.RT.RecipeCenter; using Aitex.Core.UI.MVVM; using MECF.Framework.Common.CommonData; using MECF.Framework.Common.CommonData.Dryer; using MECF.Framework.Common.DataCenter; using MECF.Framework.Common.Device.Rinse; using MECF.Framework.Common.OperationCenter; using MECF.Framework.Common.Persistent.Dryer; using MECF.Framework.Common.Persistent.Rinse; using MECF.Framework.Common.RecipeCenter; using MECF.Framework.Common.Utilities; using MECF.Framework.Common.WaferHolder; using CyberX8_Core; 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 CyberX8_MainPages.ViewModels { internal class DryerHomePageViewModel:BindableBase { #region 常量 private const string COMMON_DATA = "CommonData"; private const string DRYER = "dryer"; private const string PERSISTENT_VALUE = "PersistentValue"; private const string EXHAUST_LIMIT_DATA = "ExhaustLimitData"; #endregion #region 内部变量 #region Common /// /// 模块名称 /// private string _module; /// /// 数据 /// private DryerCommonData _dryerCommonData; /// /// 当前选择Recipe节点 /// private RecipeNode _selectedRecipeNode; /// /// Persistent /// private DryerPersistentValue _dryerPersistent; #endregion #region Wafer Holder /// /// Wafer Holder属性 /// private WaferHolderInfo _waferHolderInfo; /// /// SeqRecipe /// private string _seqRecipe; /// /// Interlocks /// private bool _interlocks; /// /// ExhaustData /// private CommonLimitData _exhaustData; #endregion #region 系统数据 /// /// 定时器 /// DispatcherTimer _timer; /// /// 查询后台数据集合 /// private List _rtDataKeys = new List(); /// /// rt查询key数值字典 /// private Dictionary _rtDataValueDic = new Dictionary(); #endregion #region Dryer1 /// /// RecipeContent /// private string _recipeContent; /// /// TimeRemaining /// private int _timeRemaining; /// /// OfTotalTime /// private int _totalTime; /// /// OperatingMode /// private string _operatingMode; /// /// State /// private string _state; /// /// RecipeMode /// private string _recipeMode; #endregion #region HVD recipe /// /// RecipeModuleName /// private string _recipeModuleName; /// /// RecipeType /// private string _recipeType; /// /// AchievedRunRecipeCycle /// private int _achievedRunRecipeCycle; /// /// 当前Recipe /// private string _currentRecipe; #endregion #region UI Related /// /// InterLock /// private bool _interLock; /// /// IsErrorState 用于腔体变红 /// private bool _isErrorState; /// /// 用于Exhaust warning时灯变黄 /// private int _isExhaustWarning = 0; /// /// 倒计时 /// private int _countDownSecond = 0; /// /// 页面功能启用 /// private bool _isEnabled; /// /// AutoMode页面功能启用 /// private bool _isAutoEnabled; /// /// 是否存在WaferHolder /// private bool _isWaferHolder; #endregion #endregion #region 属性 #region Common /// /// 模块名称 /// public string Module { get { return _module; } set { SetProperty(ref _module, value); } } /// /// Interlocks /// public bool InterLocks { get { return _interlocks; } set { SetProperty(ref _interlocks, value); } } /// /// ExhaustData /// public CommonLimitData ExhaustData { get { return _exhaustData; } set { SetProperty(ref _exhaustData, value); } } /// /// Commondata /// public DryerCommonData DryerCommonData { get { return _dryerCommonData; } set { SetProperty(ref _dryerCommonData, value); } } /// /// Threshold /// public DryerPersistentValue DryerPersistent { get { return _dryerPersistent; } set { SetProperty(ref _dryerPersistent, value); } } public RecipeNode SelectedRecipeNode { get { return _selectedRecipeNode; } set { SetProperty(ref _selectedRecipeNode, value); } } #endregion #region Dryer1 /// /// 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); } } #endregion #region HVD 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); } } #endregion #region Wafer Holder /// /// Wafer Holder属性 /// public WaferHolderInfo WaferHolderInfo { get { return _waferHolderInfo; } set { SetProperty(ref _waferHolderInfo, value); } } /// /// SeqRecipe /// public string SeqRecipe { get { return _seqRecipe; } set { SetProperty(ref _seqRecipe, value); } } #endregion #region UI Related /// /// IsErrorState /// public bool IsErrorState { get { return _isErrorState; } set { SetProperty(ref _isErrorState, value); } } /// /// ClampStatus /// public bool InterLock { get { return _interLock; } set { SetProperty(ref _interLock, value); } } /// /// IsErrorState /// public int IsExhaustWarning { get { return _isExhaustWarning; } set { SetProperty(ref _isExhaustWarning, value); } } /// /// 倒计时 /// public int CountDownSecond { get { return _countDownSecond; } set { SetProperty(ref _countDownSecond , value); } } /// /// 页面功能启用 /// public bool IsEnabled { get { return _isEnabled; } set { SetProperty(ref _isEnabled, value); } } /// /// AutoMode页面功能启用 /// public bool IsAutoEnabled { get { return _isAutoEnabled; } set { SetProperty(ref _isAutoEnabled, value); } } /// /// 是否存在WaferHolder /// public bool IsWaferHolder { get { return _isWaferHolder; } set { SetProperty(ref _isWaferHolder, value); } } #endregion #endregion #region Command指令 public ICommand InitializeCommand { get; set; } public ICommand PowerOnCommand { get; set; } public ICommand PowerOffCommand { get; set; } public ICommand BlowerHighCommand { get; set; } public ICommand BlowerLowCommand { get; set; } public ICommand BypassCommand { get; set; } #endregion /// /// 构造函数 /// public DryerHomePageViewModel() { InitializeCommand = new DelegateCommand(InitializeAction); PowerOnCommand = new DelegateCommand(PowerOnAction); PowerOffCommand = new DelegateCommand(PowerOffAction); BlowerHighCommand = new DelegateCommand(BlowerHighAction); BlowerLowCommand = new DelegateCommand(BlowerLowAction); BypassCommand = new DelegateCommand(UnlockAction); } /// /// 加载数据 /// public void LoadData(string systemName) { Module = systemName; RecipeModuleName = "HVD Recipe"; RecipeType = "hvd"; _rtDataKeys.Clear(); _rtDataKeys.Add($"{Module}.{COMMON_DATA}"); _rtDataKeys.Add($"{Module}.{PERSISTENT_VALUE}"); _rtDataKeys.Add($"{Module}.WaferHolder"); _rtDataKeys.Add($"{Module}.SequenceRecipe"); _rtDataKeys.Add($"{Module}.AchievedCycle"); _rtDataKeys.Add($"{Module}.FsmState"); _rtDataKeys.Add($"{Module}.{EXHAUST_LIMIT_DATA}"); _rtDataKeys.Add("Dryer.CountDownSecond"); _rtDataKeys.Add($"{Module}.DryTime"); _rtDataKeys.Add($"{Module}.TimeRemain"); _rtDataKeys.Add($"{Module}.CurrentRecipe"); if (_timer == null) { _timer = new DispatcherTimer(); _timer.Interval = TimeSpan.FromMilliseconds(200); _timer.Tick += Timer_Tick; } _timer.Start(); } /// /// 定时器执行 /// /// /// private void Timer_Tick(object sender, EventArgs e) { if (_rtDataKeys.Count != 0) { _rtDataValueDic = QueryDataClient.Instance.Service.PollData(_rtDataKeys); if (_rtDataValueDic != null) { DryerCommonData = CommonFunction.GetValue(_rtDataValueDic, $"{Module}.{COMMON_DATA}"); DryerPersistent = CommonFunction.GetValue(_rtDataValueDic, $"{Module}.{PERSISTENT_VALUE}"); WaferHolderInfo = CommonFunction.GetValue(_rtDataValueDic, $"{Module}.WaferHolder"); if (WaferHolderInfo != null) { IsWaferHolder = true; } else { IsWaferHolder = false; } SeqRecipe = CommonFunction.GetValue(_rtDataValueDic, $"{Module}.SequenceRecipe"); AchievedRunRecipeCycle = CommonFunction.GetValue(_rtDataValueDic, $"{Module}.AchievedCycle"); State = CommonFunction.GetValue(_rtDataValueDic, $"{Module}.FsmState"); if ("Manual".Equals(DryerPersistent.OperatingMode)) { IsEnabled = true; IsAutoEnabled = true; } else if ("Auto".Equals(DryerPersistent.OperatingMode)) { IsAutoEnabled = true; IsEnabled = false; } else { State = "Stopped"; IsEnabled = false; IsAutoEnabled = false; } CountDownSecond = CommonFunction.GetValue(_rtDataValueDic, "Dryer.CountDownSecond"); ExhaustData = CommonFunction.GetValue(_rtDataValueDic, $"{Module}.{EXHAUST_LIMIT_DATA}"); TotalTime = CommonFunction.GetValue(_rtDataValueDic, $"{Module}.DryTime"); TimeRemaining = CommonFunction.GetValue(_rtDataValueDic, $"{Module}.TimeRemain"); TimeRemaining = TimeRemaining < 0 ? 0 : TimeRemaining; if (State == "Idle") { TimeRemaining = 0; } //Error时腔体UI变红 IsErrorState = "Error".Equals(State) ? true : false; //Exhasut warning时灯变黄,绿灯红灯的panel.zindex属性是1 IsExhaustWarning = ExhaustData.IsWarning ? 2 : 0; CurrentRecipe = CommonFunction.GetValue(_rtDataValueDic, $"{Module}.CurrentRecipe"); } } } /// /// 隐藏 /// public void Hide() { if (_timer != null) { _timer.Stop(); } } #region 指令Action /// /// Initialize Action /// /// private void InitializeAction(object param) { InvokeClient.Instance.Service.DoOperation($"{Module}.InitializeAll"); } private void PowerOnAction(object param) { InvokeClient.Instance.Service.DoOperation($"{Module}.PowerControlOn"); } private void PowerOffAction(object param) { InvokeClient.Instance.Service.DoOperation($"{Module}.PowerControlOff"); } private void BlowerHighAction(object param) { InvokeClient.Instance.Service.DoOperation($"{Module}.BlowerHigh"); } private void BlowerLowAction(object param) { InvokeClient.Instance.Service.DoOperation($"{Module}.BlowerLow"); } private void UnlockAction(object param) { InvokeClient.Instance.Service.DoOperation($"{Module}.ByPass", InterLocks); } #endregion } }