123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388 |
- 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 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 VPWCellViewModel:BindableBase
- {
- #region 常量
- private const string COMMONDATA = "CommonData";
- private const string VPW = "vpw";
- private const string PERSISTENT_VALUE = "PersistentValue";
- #endregion
- #region 内部变量
- #region Common
- /// <summary>
- /// 模块名称
- /// </summary>
- private string _module;
- /// <summary>
- /// StateMachine
- /// </summary>
- private string _stateMachine;
- /// <summary>
- /// Status
- /// </summary>
- private string _status;
- /// <summary>
- /// 数据
- /// </summary>
- private VpwCellCommonData _vpwCellCommonData;
- /// <summary>
- /// VPW Main数据
- /// </summary>
- private VpwMainCommonData _vpwMainCommonData;
- /// <summary>
- /// Threshold
- /// </summary>
- private VpwCellPersistentValue _vpwCellPersistent;
- /// <summary>
- /// 是否是Manual模式
- /// </summary>
- private bool _isManualOperationMode;
- #endregion
- #region VPW recipe
- /// <summary>
- /// RecipeModuleName
- /// </summary>
- private string _recipeModuleName;
- /// <summary>
- /// RecipeType
- /// </summary>
- private string _recipeType;
- /// <summary>
- /// AchievedRunRecipeCycle
- /// </summary>
- private int _achievedRunRecipeCycle;
- /// <summary>
- /// 当前Recipe
- /// </summary>
- private string _currentRecipe;
- /// <summary>
- /// RecipeContent
- /// </summary>
- private string _recipeContent;
- /// <summary>
- /// TimeRemaining
- /// </summary>
- private int _timeRemaining;
- /// <summary>
- /// OfTotalTime
- /// </summary>
- private int _totalTime;
- /// <summary>
- /// OperatingMode
- /// </summary>
- private string _operatingMode;
- /// <summary>
- /// State Machine
- /// </summary>
- private string _state;
- /// <summary>
- /// RecipeMode
- /// </summary>
- private string _recipeMode;
- #endregion
- #region UI
- /// <summary>
- /// IsErrorState 用于腔体变红
- /// </summary>
- private bool _isErrorState;
- /// <summary>
- /// 页面功能启用
- /// </summary>
- private bool _isEnabled;
- /// <summary>
- /// AutoMode页面功能启用
- /// </summary>
- private bool _isAutoEnabled;
- #endregion
- #endregion
- #region 系统数据
- /// <summary>
- /// 定时器
- /// </summary>
- DispatcherTimer _timer;
- /// <summary>
- /// 查询后台数据集合
- /// </summary>
- private List<string> _rtDataKeys = new List<string>();
- /// <summary>
- /// rt查询key数值字典
- /// </summary>
- private Dictionary<string, object> _rtDataValueDic = new Dictionary<string, object>();
- #endregion
- #region 属性
- #region Common
- /// <summary>
- /// 模块名称
- /// </summary>
- public string Module { get { return _module; } set { SetProperty(ref _module, value); } }
- /// <summary>
- /// StateMachine
- /// </summary>
- public string StateMachine { get { return _stateMachine; } set { SetProperty(ref _stateMachine, value); } }
- /// <summary>
- /// Status
- /// </summary>
- public string Status { get { return _status; } set { SetProperty(ref _status, value); } }
- /// <summary>
- /// Commondata
- /// </summary>
- public VpwMainCommonData VpwMainCommonData
- {
- get { return _vpwMainCommonData; }
- set { SetProperty(ref _vpwMainCommonData, value); }
- }
- /// <summary>
- /// Commondata
- /// </summary>
- public VpwCellCommonData VpwCellCommonData
- {
- get { return _vpwCellCommonData; }
- set { SetProperty(ref _vpwCellCommonData, value); }
- }
- /// <summary>
- /// Persistent
- /// </summary>
- public VpwCellPersistentValue VpwCellPersistent
- {
- get { return _vpwCellPersistent; }
- set { SetProperty(ref _vpwCellPersistent, value); }
- }
- /// <summary>
- /// 是否是Manual模式
- /// </summary>
- public bool IsManualOperationMode { get { return _isManualOperationMode; } set { SetProperty(ref _isManualOperationMode, value); } }
- #endregion
- #region VPW recipe
- /// <summary>
- /// RecipeModuleName
- /// </summary>
- public string RecipeModuleName
- {
- get { return _recipeModuleName; }
- set { SetProperty(ref _recipeModuleName, value); }
- }
- /// <summary>
- /// RecipeType
- /// </summary>
- public string RecipeType
- {
- get { return _recipeType; }
- set { SetProperty(ref _recipeType, value); }
- }
- public int AchievedRunRecipeCycle
- {
- get { return _achievedRunRecipeCycle; }
- set { SetProperty(ref _achievedRunRecipeCycle, value); }
- }
- /// <summary>
- /// 当前运行的Recipe
- /// </summary>
- public string CurrentRecipe
- {
- get { return _currentRecipe; }
- set { SetProperty(ref _currentRecipe, value); }
- }
- /// <summary>
- /// RecipeContent
- /// </summary>
- public string RecipeContent
- {
- get { return _recipeContent; }
- set { SetProperty(ref _recipeContent, value); }
- }
- /// <summary>
- /// TimeRemaining
- /// </summary>
- public int TimeRemaining
- {
- get { return _timeRemaining; }
- set { SetProperty(ref _timeRemaining, value); }
- }
- /// <summary>
- /// TotalTime
- /// </summary>
- public int TotalTime
- {
- get { return _totalTime; }
- set { SetProperty(ref _totalTime, value); }
- }
- /// <summary>
- /// OperatingMode
- /// </summary>
- public string OperatingMode
- {
- get { return _operatingMode; }
- set { SetProperty(ref _operatingMode, value); }
- }
- /// <summary>
- /// State
- /// </summary>
- public string State
- {
- get { return _state; }
- set { SetProperty(ref _state, value); }
- }
- /// <summary>
- /// RecipeMode
- /// </summary>
- public string RecipeMode
- {
- get { return _recipeMode; }
- set { SetProperty(ref _recipeMode, value); }
- }
- #endregion
- #region UI
- /// <summary>
- /// IsErrorState
- /// </summary>
- public bool IsErrorState { get { return _isErrorState; } set { SetProperty(ref _isErrorState, value); } }
- /// <summary>
- /// 页面功能启用
- /// </summary>
- public bool IsEnabled
- {
- get { return _isEnabled; }
- set { SetProperty(ref _isEnabled, value); }
- }
- /// <summary>
- /// AutoMode页面功能启用
- /// </summary>
- public bool IsAutoEnabled
- {
- get { return _isAutoEnabled; }
- set { SetProperty(ref _isAutoEnabled, value); }
- }
- #endregion
- #endregion
- #region Command指令
- public ICommand InitializeCommand { get; set; }
- public ICommand HomeCommand { get; set; }
- #endregion
- public VPWCellViewModel()
- {
- InitializeCommand = new DelegateCommand<object>(InitializeAction);
- HomeCommand = new DelegateCommand<object>(HomeAction);
- }
- /// <summary>
- /// 加载数据
- /// </summary>
- public void LoadData(string systemName)
- {
- Module = systemName;
- _rtDataKeys.Clear();
- List<string> lst = new List<string>();
- _rtDataValueDic = QueryDataClient.Instance.Service.PollData(lst);
- _rtDataKeys.Add($"{Module}.{PERSISTENT_VALUE}");
- _rtDataKeys.Add($"{Module}.{COMMONDATA}");
- _rtDataKeys.Add($"{Module}.FsmState");
- _rtDataKeys.Add($"VPWMain1.{COMMONDATA}");
- if (_timer == null)
- {
- _timer = new DispatcherTimer();
- _timer.Interval = TimeSpan.FromMilliseconds(200);
- _timer.Tick += Timer_Tick;
- }
- _timer.Start();
- }
- /// <summary>
- /// 定时器执行
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void Timer_Tick(object sender, EventArgs e)
- {
- if (_rtDataKeys.Count != 0)
- {
- _rtDataValueDic = QueryDataClient.Instance.Service.PollData(_rtDataKeys);
- if (_rtDataValueDic != null)
- {
- VpwCellCommonData = CommonFunction.GetValue<VpwCellCommonData>(_rtDataValueDic, $"{Module}.{COMMONDATA}");
- VpwMainCommonData = CommonFunction.GetValue<VpwMainCommonData>(_rtDataValueDic, $"VPWMain1.{COMMONDATA}");
- VpwCellPersistent = CommonFunction.GetValue<VpwCellPersistentValue>(_rtDataValueDic, $"{Module}.{PERSISTENT_VALUE}");
- StateMachine = CommonFunction.GetValue<string>(_rtDataValueDic, $"{Module}.FsmState");
- }
- }
- }
- /// <summary>
- /// 隐藏
- /// </summary>
- public void Hide()
- {
- if (_timer != null)
- {
- _timer.Stop();
- }
- }
- #region 指令Action
- /// <summary>
- /// Initialize Action
- /// </summary>
- /// <param name="param"></param>
- private void InitializeAction(object param)
- {
- InvokeClient.Instance.Service.DoOperation($"{Module}.InitializeAll");
- }
- /// <summary>
- /// Home Action
- /// </summary>
- /// <param name="param"></param>
- private void HomeAction(object param)
- {
- InvokeClient.Instance.Service.DoOperation($"{Module}.Home");
- }
- #endregion
- }
- }
|