123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333 |
- using Aitex.Core.UI.MVVM;
- using MECF.Framework.Common.CommonData.Metal;
- using MECF.Framework.Common.CommonData.Reservoir;
- using MECF.Framework.Common.CommonData.TemperatureControl;
- using MECF.Framework.Common.DataCenter;
- using MECF.Framework.Common.Device.Safety;
- using MECF.Framework.Common.OperationCenter;
- using MECF.Framework.Common.Persistent.Reservoirs;
- using MECF.Framework.Common.RecipeCenter;
- using MECF.Framework.Common.Utilities;
- using Prism.Mvvm;
- using PunkHPX8_MainPages.Model;
- using System;
- using System.Collections.Generic;
- using System.Collections.ObjectModel;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- using System.Windows.Input;
- using System.Windows.Threading;
- namespace PunkHPX8_MainPages.ViewModels
- {
- public class DMReservoirViewModel : BindableBase
- {
- #region 常量
- private const string RESERVOIRS_DATA = "ReservoirsData";
- private const string RESERVOIRS = "reservoirs";
- private const string PERSISTENT_VALUE = "PersistentValue";
- #endregion
- #region 内部变量
- private List<string> _rtDataKeys = new List<string>();
- private Dictionary<string, object> _rtDataValueDic = new Dictionary<string, object>();
- DispatcherTimer _timer;
- private bool _isEnabled;
- private bool _isError;
- private bool _isAutoEnabled;
- private SafetyData _commonSafetyData;
- private string _module;
- private string _state;
- private ResRecipe _currentRecipe;
- private ReservoirsPersistentValue _reservoirsPersistent;
- private string _recipeType;
- private int _inputCAPumpSpeed;
- private int _inputANPumpSpeed;
- private int _inputReturnFlowOpenPercent;
- private TemperatureControllerData _temperatureControlData;
- private string _tcEnableStatus;
- private string _tcName;
- private ReservoirData _reservoirData;
- private ObservableCollection<RecipeNode> _recipeNodes;
- private string _currentRecipeFileName;
-
- private double _returnValveOpenPerccent;
- private bool _isCADIReplenFault;
- private bool _isANDIReplenFault;
- private double _flowAdjustDelta;
- private double _maxFlowDelta;
- private bool _isFolwDeltaUnBlance = false;
- private bool _isHighLevel;
- private bool _isLowLevel;
- private bool _isLeakDetected;
- private bool _cdaOn;
- /// <summary>
- /// 是否配置Exhaust
- /// </summary>
- private bool _isEvaporatorConfig;
- /// <summary>
- /// 是否正在手动注水
- /// </summary>
- private bool _isManualReplen;
- /// <summary>
- /// 手动注水时长(秒)
- /// </summary>
- private int _manualFillSeconds;
- /// <summary>
- /// DIValveMaxOnTime
- /// </summary>
- private double _diValveMaxOnTime;
- /// <summary>
- /// CellModuleName集合
- /// </summary>
- private ObservableCollection<string> _cellModuleNameCollection = new ObservableCollection<string>();
- /// <summary>
- /// Cell A面Flow集合
- /// </summary>
- private ObservableCollection<double> _cellModuleNameFlowCollection = new ObservableCollection<double>();
- /// <summary>
- /// MetalData
- /// </summary>
- private ObservableCollection<CompactMembranMetalDeviceData> _metalDatas = new ObservableCollection<CompactMembranMetalDeviceData>();
- /// <summary>
- /// MetalData的CellFlow集合
- /// </summary>
- private ObservableCollection<double> _metalCellFlowDatas = new ObservableCollection<double>();
- /// <summary>
- /// Meatl UI数据
- /// </summary>
- private ObservableCollection<ReservoirsUIData> _reservoirsUIDatas = new ObservableCollection<ReservoirsUIData>();
- #endregion
- #region 属性
- public string Module
- {
- get { return _module; }
- set { SetProperty(ref _module, value); }
- }
- public bool IsEnabled
- {
- get { return _isEnabled; }
- set { SetProperty(ref _isEnabled, value); }
- }
- public bool IsError
- {
- get { return _isError; }
- set { SetProperty(ref _isError, value); }
- }
- public bool IsAutoEnabled
- {
- get { return _isAutoEnabled; }
- set { SetProperty(ref _isAutoEnabled, value); }
- }
- public SafetyData CommonSafetyData
- {
- get { return _commonSafetyData; }
- set { SetProperty(ref _commonSafetyData, value); }
- }
- public string State
- {
- get { return _state; }
- set { SetProperty(ref _state, value); }
- }
- public ResRecipe CurrentRecipe
- {
- get { return _currentRecipe; }
- set { SetProperty(ref _currentRecipe, value); }
- }
- public ReservoirsPersistentValue ReservoirsPersistent
- {
- get { return _reservoirsPersistent; }
- set { SetProperty(ref _reservoirsPersistent, value); }
- }
- public string RecipeType
- {
- get { return _recipeType; }
- set { SetProperty(ref _recipeType, value); }
- }
- public int InputCAPumpSpeed
- {
- get { return _inputCAPumpSpeed; }
- set
- {
- SetProperty(ref _inputCAPumpSpeed, value);
- }
- }
- public int InputANPumpSpeed
- {
- get { return _inputANPumpSpeed; }
- set
- {
- SetProperty(ref _inputANPumpSpeed, value);
- }
- }
- public int InputRetrunFlowOpenPercent
- {
- get { return _inputReturnFlowOpenPercent; }
- set
- {
- SetProperty(ref _inputReturnFlowOpenPercent, value);
- }
- }
-
- public TemperatureControllerData TemperatureControlData
- {
- get { return _temperatureControlData; }
- set { SetProperty(ref _temperatureControlData, value); }
- }
- public string TCEnableStatus
- {
- get { return _tcEnableStatus; }
- set { SetProperty(ref _tcEnableStatus, value); }
- }
-
-
- public ReservoirData ReservoirData
- {
- get { return _reservoirData; }
- set { SetProperty(ref _reservoirData, value); }
- }
- #endregion
- #region 指令
- public ICommand InitializeCommand { get; set; }
- public ICommand CAPumpSpeedSetCommand { get; set; }
- public ICommand ANPumpSpeedSetCommand { get; set; }
- public ICommand ReturnFlowOpenPercentSetCommand { get; set; }
- #endregion
- public DMReservoirViewModel()
- {
- InitializeCommand = new DelegateCommand<object>(InitializeAction);
- CAPumpSpeedSetCommand = new DelegateCommand<object>(CAPumpSpeedSetAction);
- ANPumpSpeedSetCommand = new DelegateCommand<object>(ANPumpSpeedSetAction);
- ReturnFlowOpenPercentSetCommand = new DelegateCommand<object>(ReturnFlowOpenPercentSetAction);
- }
- #region 命令方法
- /// <summary>
- /// 初始化
- /// </summary>
- /// <param name="param"></param>
- private void InitializeAction(object param)
- {
- InvokeClient.Instance.Service.DoOperation($"{Module}.InitializeAll");
- }
- /// <summary>
- /// 设置CA pump泵速
- /// </summary>
- /// <param name="param"></param>
- private void CAPumpSpeedSetAction(object param)
- {
- InvokeClient.Instance.Service.DoOperation($"{Module}.CAPumpSpeed",InputCAPumpSpeed);
- }
- /// <summary>
- /// 设置AN pump泵速
- /// </summary>
- /// <param name="param"></param>
- private void ANPumpSpeedSetAction(object param)
- {
- InvokeClient.Instance.Service.DoOperation($"{Module}.ANPumpSpeed", InputANPumpSpeed);
- }
- /// <summary>
- /// 设置return flow valve开闭的程度
- /// </summary>
- /// <param name="param"></param>
- private void ReturnFlowOpenPercentSetAction(object param)
- {
- InvokeClient.Instance.Service.DoOperation($"{Module}.InitializeAll");
- }
- #endregion
- public void LoadData(string systemName)
- {
- RecipeType = "res";
- Module = systemName;
- _rtDataKeys.Clear();
- _rtDataKeys.Add($"{Module}.{PERSISTENT_VALUE}");
- _rtDataKeys.Add($"{Module}.CurrentRecipe");
- _rtDataKeys.Add($"{Module}.FsmState");
- _rtDataKeys.Add($"Safety.SafetyData");
- _rtDataKeys.Add($"{Module}.ReservoirData");
- //_rtDataKeys.Add($"{Module}.TemperatureControllerData");
- 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)
- {
- State = CommonFunction.GetValue<string>(_rtDataValueDic, $"{Module}.FsmState");
- ReservoirData = CommonFunction.GetValue<ReservoirData>(_rtDataValueDic, $"{Module}.ReservoirData");
- CommonSafetyData = CommonFunction.GetValue<SafetyData>(_rtDataValueDic, $"Safety.SafetyData");
- ReservoirsPersistent = CommonFunction.GetValue<ReservoirsPersistentValue>(_rtDataValueDic, $"{Module}.{PERSISTENT_VALUE}");
- if (ReservoirsPersistent!= null && "Manual".Equals(ReservoirsPersistent.OperatingMode))
- {
- IsEnabled = true;
- IsAutoEnabled = true;
- }
- else if (ReservoirsPersistent != null && "Auto".Equals(ReservoirsPersistent.OperatingMode))
- {
- IsAutoEnabled = true;
- IsEnabled = false;
- }
- else
- {
- State = "Stopped";
- IsEnabled = false;
- IsAutoEnabled = false;
- }
- CurrentRecipe = CommonFunction.GetValue<ResRecipe>(_rtDataValueDic, $"{Module}.CurrentRecipe");
- //TemperatureControlData = CommonFunction.GetValue<TemperatureControllerData>(_rtDataValueDic, $"{Module}.TemperatureControllerData");
- //TCEnableStatus = TemperatureControlData.ControlOperationModel == 0 ? "Disable" : "Enable";
- //_tcName = TemperatureControlData.Name;
- }
- }
- }
- /// <summary>
- /// 隐藏
- /// </summary>
- public void Hide()
- {
- if (_timer != null)
- {
- _timer.Stop();
- }
- }
- }
- }
|