123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866 |
- using Aitex.Core.RT.Log;
- using Aitex.Core.RT.Routine;
- using Aitex.Core.UI.MVVM;
- using CyberX8_Core;
- using CyberX8_MainPages.Model;
- using CyberX8_Themes.CustomControls;
- using MECF.Framework.Common.CommonData.Metal;
- using MECF.Framework.Common.CommonData.Reservoir;
- using MECF.Framework.Common.DataCenter;
- 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 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 CyberX8_MainPages.ViewModels
- {
- public class ReservoirsAnolyteViewModel : BindableBase
- {
- #region 常量
- private const string RESERVOIRS_DATA = "ReservoirsData";
- private const string RESERVOIRS = "reservoirs";
- private const string PERSISTENT_VALUE = "PersistentValue";
- #endregion
- #region 变量
- private bool m_IsAutoMode;
- private bool m_IsManualMode;
- private string _module;
- private string _recipeContent;
- private string _operatingMode;
- private string _state;
- private string _recipeMode;
- private List<string> _rtDataKeys = new List<string>();
- DispatcherTimer _timer;
- private Dictionary<string, object> _rtDataValueDic = new Dictionary<string, object>();
- private ObservableCollection<RecipeNode> _recipeNodes;
- private string _currentRecipeFileName;
- private string _recipeType;
- private bool _aNpumpEnable = false;
- private bool _aNADrainpumpEnable = false;
- private bool _aNBDrainpumpEnable = false;
- private double _maxFlowDelta;
- private bool _isHighLevel;
- private bool _isLowLevel;
- private double _avgANLevel;
- private double _inputANBaselineLevel;
- private double _flowAdjustDelta;
- private bool _isFolwDeltaUnBlance = false;
- private double _inputCrossDoseRequest;
- private bool _isLeakDetected;
- private bool _isDIReplenFault;
- private bool _isError;
- //用于当作参数传给device判断是否进行leaktest(reservoir是否初始化,阳极是否有flow)
- private bool _isInitialized = false;
- private bool _isHasANFlow = false;
- /// <summary>
- /// 是否正在手动注水
- /// </summary>
- private bool _isManualReplen;
- /// <summary>
- /// 手动注水时长(秒)
- /// </summary>
- private int _manualFillSeconds;
- /// <summary>
- /// DIValveMaxOnTime
- /// </summary>
- private double _diValveMaxOnTime;
- /// CellModuleName集合
- /// </summary>
- private ObservableCollection<string> _cellModuleNameCollection = new ObservableCollection<string>();
- /// <summary>
- /// Cell A面Flow集合
- /// </summary>
- private ObservableCollection<double> _cellModuleNameSideAFlowCollection = new ObservableCollection<double>();
- /// <summary>
- /// Cell A面Flow状态集合
- /// </summary>
- private ObservableCollection<string> _cellModuleNameSideAFlowStatusCollection = new ObservableCollection<string>();
- /// <summary>
- /// Cell B面Flow集合
- /// </summary>
- private ObservableCollection<double> _cellModuleNameSideBFlowCollection = new ObservableCollection<double>();
- /// <summary>
- /// Cell B面Flow状态集合
- /// </summary>
- private ObservableCollection<string> _cellModuleNameSideBFlowStatusCollection = new ObservableCollection<string>();
- /// <summary>
- /// Persistent
- /// </summary>
- private ReservoirsPersistentValue _reservoirsPersistent;
- /// <summary>
- /// Reservoir数据
- /// </summary>
- private CompactMembranReservoirData _reservoirData;
- #region Valve Flag
- /// <summary>
- /// ANDiReplenValveIsOpen
- /// </summary>
- private bool _ANDiReplenValveIsOpen;
- /// <summary>
- /// AN Pump Speed
- /// </summary>
- private double _anPumpSpped;
- /// <summary>
- /// MetalData
- /// </summary>
- private ObservableCollection<CompactMembranMetalDeviceData> _metalDatas = new ObservableCollection<CompactMembranMetalDeviceData>();
- /// <summary>
- /// MetalData的CellFlow集合
- /// </summary>
- private ObservableCollection<double> _metalCellFlowDatas = new ObservableCollection<double>();
- /// <summary>
- /// 页面功能启用
- /// </summary>
- private bool _isEnabled;
- /// <summary>
- /// AutoMode页面功能启用
- /// </summary>
- private bool _isAutoEnabled;
- /// <summary>
- /// Meatl UI数据
- /// </summary>
- private ObservableCollection<ReservoirsUIData> _reservoirsUIDatas = new ObservableCollection<ReservoirsUIData>();
- #endregion
- /// <summary>
- /// CrossDose是否Enabled
- /// </summary>
- private bool _isCrossDoseEnabled;
- #region CrossDose
- /// <summary>
- /// AN Transfer Flow
- /// </summary>
- private double _anTransferFlow;
- /// <summary>
- /// Calibrate是否启用
- /// </summary>
- private bool _isCalibrateEnable;
- /// <summary>
- /// 是否有CrossDoseType
- /// </summary>
- private bool _isCroseDoseTypeConfig;
- #endregion
- #endregion
- #region 属性
- /// <summary>
- /// 是否有CrossDoseType
- /// </summary>
- public bool IsCrossDoseTypeConfig
- {
- get { return _isCroseDoseTypeConfig; }
- set { SetProperty(ref _isCroseDoseTypeConfig, value); }
- }
- public double AvgANLevel
- {
- get { return _avgANLevel; }
- set { SetProperty(ref _avgANLevel, value); }
- }
- public bool IsAutoMode
- {
- get { return m_IsAutoMode; }
- set { SetProperty(ref m_IsAutoMode, value); }
- }
- public bool IsManualMode
- {
- get { return m_IsManualMode; }
- set { SetProperty(ref m_IsManualMode, value); }
- }
- public bool IsError
- {
- get { return _isError; }
- set { SetProperty(ref _isError, value); }
- }
- public bool ANPumpEnable
- {
- get { return _aNpumpEnable; }
- set { SetProperty(ref _aNpumpEnable, value); }
- }
- public bool ANADrainPumpEnable
- {
- get { return _aNADrainpumpEnable; }
- set { SetProperty(ref _aNADrainpumpEnable, value); }
- }
- public bool ANBDrainPumpEnable
- {
- get { return _aNBDrainpumpEnable; }
- set { SetProperty(ref _aNBDrainpumpEnable, value); }
- }
- public string CurrentRecipeFileName
- {
- get { return _currentRecipeFileName; }
- set { SetProperty(ref _currentRecipeFileName, value); }
- }
- public ObservableCollection<RecipeNode> RecipeNodes
- {
- get { return _recipeNodes; }
- set { SetProperty(ref _recipeNodes, value); }
- }
- public string Module { get { return _module; } set { SetProperty(ref _module, value); } }
- public string ReservoirRecipeContent
- {
- get { return _recipeContent; }
- set { SetProperty(ref _recipeContent, value); }
- }
- public string OperatingMode
- {
- get { return _operatingMode; }
- set { SetProperty(ref _operatingMode, value); }
- }
- public string State
- {
- get { return _state; }
- set { SetProperty(ref _state, value); }
- }
- public string RecipeMode
- {
- get { return _recipeMode; }
- set { SetProperty(ref _recipeMode, value); }
- }
- public string RecipeType
- {
- get { return _recipeType; }
- set { SetProperty(ref _recipeType, value); }
- }
- /// <summary>
- /// CellModuleName集合
- /// </summary>
- public ObservableCollection<string> CellModuleNameCollection
- {
- get { return _cellModuleNameCollection; }
- set { SetProperty(ref _cellModuleNameCollection, value); }
- }
- /// <summary>
- /// 模块A面Flow集合
- /// </summary>
- public ObservableCollection<double> CellModuleNameSideAFlowCollection
- {
- get { return _cellModuleNameSideAFlowCollection; }
- set { SetProperty(ref _cellModuleNameSideAFlowCollection, value); }
- }
- /// <summary>
- /// 模块A面Flow状态集合
- /// </summary>
- public ObservableCollection<string> CellModuleNameSideAFlowStatusCollection
- {
- get { return _cellModuleNameSideAFlowStatusCollection; }
- set { SetProperty(ref _cellModuleNameSideAFlowStatusCollection, value); }
- }
- /// <summary>
- /// 模块B面Flow集合
- /// </summary>
- public ObservableCollection<double> CellModuleNameSideBFlowCollection
- {
- get { return _cellModuleNameSideBFlowCollection; }
- set { SetProperty(ref _cellModuleNameSideBFlowCollection, value); }
- }
- /// <summary>
- /// 模块B面Flow状态集合
- /// </summary>
- public ObservableCollection<string> CellModuleNameSideBFlowStatusCollection
- {
- get { return _cellModuleNameSideBFlowStatusCollection; }
- set { SetProperty(ref _cellModuleNameSideBFlowStatusCollection, value); }
- }
- /// <summary>
- /// Threshold
- /// </summary>
- public ReservoirsPersistentValue ReservoirsPersistent
- {
- get { return _reservoirsPersistent; }
- set { SetProperty(ref _reservoirsPersistent, value); }
- }
- /// <summary>
- /// Reservoir 数据
- /// </summary>
- public CompactMembranReservoirData ReservoirData
- {
- get { return _reservoirData; }
- set { SetProperty(ref _reservoirData, value); }
- }
- public double ANPumpSpeed
- {
- get { return _anPumpSpped; }
- set
- {
- SetProperty(ref _anPumpSpped, value);
- }
- }
- public bool IsHighLevel
- {
- get { return _isHighLevel; }
- set { SetProperty(ref _isHighLevel, value); }
- }
- public bool IsLowLevel
- {
- get { return _isLowLevel; }
- set { SetProperty(ref _isLowLevel, value); }
- }
- #region Valve Flag
- public bool ANDiReplenValveIsOpen
- {
- get { return _ANDiReplenValveIsOpen; }
- set { SetProperty(ref _ANDiReplenValveIsOpen, value); }
- }
- #endregion
- /// <summary>
- /// MetalData
- /// </summary>
- public ObservableCollection<CompactMembranMetalDeviceData> MetalDatas
- {
- get { return _metalDatas; }
- set { SetProperty(ref _metalDatas, value); }
- }
- /// <summary>
- /// MetalDataCellFlow
- /// </summary>
- public ObservableCollection<double> MetalCellFlowDatas
- {
- get { return _metalCellFlowDatas; }
- set { SetProperty(ref _metalCellFlowDatas, value); }
- }
- /// <summary>
- /// 正在手动注水
- /// </summary>
- public bool IsManualReplen
- {
- get { return _isManualReplen; }
- set { SetProperty(ref _isManualReplen, value); }
- }
- /// <summary>
- /// 手动注水时长
- /// </summary>
- public int ManualFillSeconds
- {
- get { return _manualFillSeconds; }
- set { SetProperty(ref _manualFillSeconds, value); }
- }
- /// <summary>
- /// 单次注水最大时长
- /// </summary>
- public double DIValveMaxOnTime
- {
- get { return _diValveMaxOnTime; }
- set { SetProperty(ref _diValveMaxOnTime, value); }
- }
- /// <summary>
- /// Input Fast Leak test Baseline
- /// </summary>
- public double InputANBaselineLevel
- {
- get { return _inputANBaselineLevel; }
- set { SetProperty(ref _inputANBaselineLevel, value); }
- }
- /// <summary>
- /// 不同cell流量差值
- /// </summary>
- public double FlowAdjustDelta
- {
- get { return _flowAdjustDelta; }
- set { SetProperty(ref _flowAdjustDelta, value); }
- }
- /// <summary>
- /// 流量误差是否超过0.5
- /// </summary>
- public bool IsFolwDeltaUnBlance
- {
- get { return _isFolwDeltaUnBlance; }
- set { SetProperty(ref _isFolwDeltaUnBlance, value); }
- }
- /// <summary>
- /// Input Cross Dose Request
- /// </summary>
- public double InputCrossDoseRequest
- {
- get { return _inputCrossDoseRequest; }
- set { SetProperty(ref _inputCrossDoseRequest, value); }
- }
- /// <summary>
- /// 是否检测到泄露
- /// </summary>
- public bool IsLeakDetected
- {
- get { return _isLeakDetected; }
- set { SetProperty(ref _isLeakDetected, value); }
- }
- /// <summary>
- /// 是否补水异常
- /// </summary>
- public bool IsDIReplenFault
- {
- get { return _isDIReplenFault; }
- set { SetProperty(ref _isDIReplenFault, 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); }
- }
- /// <summary>
- /// metal ui数据
- /// </summary>
- public ObservableCollection<ReservoirsUIData> ReservoirsUIDatas
- {
- get { return _reservoirsUIDatas; }
- set { SetProperty(ref _reservoirsUIDatas, value); }
- }
- /// <summary>
- /// CrossDose是否Enabled
- /// </summary>
- public bool IsCrossDoseEnabled
- {
- get { return _isCrossDoseEnabled; }
- set { SetProperty(ref _isCrossDoseEnabled, value); }
- }
- #region CrossDose
- /// <summary>
- /// AN Transfer Flow
- /// </summary>
- public double ANTransferFlow
- {
- get { return _anTransferFlow; }
- set { SetProperty(ref _anTransferFlow, value); }
- }
- /// <summary>
- /// Calibrate是否启用
- /// </summary>
- public bool IsCalibrateEnable
- {
- get { return _isCalibrateEnable; }
- set { SetProperty(ref _isCalibrateEnable, value); }
- }
-
- #endregion
- #endregion
- #region 命令
- public ICommand ControlValveCommand { get; private set; }
- public ICommand AnPumpSpeedCommand { get; private set; }
- public ICommand ManualDireplenCommand { get; set; }
- public ICommand ResetTotalCommand { get; set; }
- public ICommand ClearSlowLeakCommand { get; set; }
- public ICommand NavigatetoPumpCartCommand { get; set; }
- public ICommand CrossDoseStartCommand { get; set; }
- public ICommand CrossDoseHaltCommand { get; set; }
- public ICommand CalibrateCommand { get; set; }
- public ICommand BaseLineKeyDownCommand { get; set; }
- public ICommand StartLeakTestCommand { get; set; }
- public ICommand BackCommand { get; set; }
- #endregion
- #region 构造函数
- /// <summary>
- /// 构造函数
- /// </summary>
- public ReservoirsAnolyteViewModel()
- {
- IsAutoMode = false;
- ControlValveCommand = new DelegateCommand<object>(OnControlValve);
- AnPumpSpeedCommand = new DelegateCommand<object>(AnPumpSpeedAction);
- ManualDireplenCommand = new DelegateCommand<object>(ManualDireplenAction);
- ResetTotalCommand = new DelegateCommand<object>(ResetTotalAction);
- ClearSlowLeakCommand = new DelegateCommand<object>(ClearSlowLeakAction);
- NavigatetoPumpCartCommand = new DelegateCommand<object>(NavigatetoPumpCartAction);
- BaseLineKeyDownCommand = new DelegateCommand<object[]>(BaseLineKeyDownAction);
- StartLeakTestCommand = new DelegateCommand<object[]>(StartLeakTestAction);
- BackCommand = new DelegateCommand<object>(BackAction);
- }
- #endregion
- #region 命令方法
- /// <summary>
- /// 回到Reservoir主页面
- /// </summary>
- /// <param name="param"></param>
- private void BackAction(object param)
- {
- GlobalEvents.OnSwitchFixedChildSubItem(Module, Module);
- }
- /// <summary>
- /// Control Valve
- /// </summary>
- /// <param name="obj"></param>
- private void OnControlValve(object obj)
- {
- CommonValveControl commonValveControl = (CommonValveControl)obj;
- if (commonValveControl.IsCanEdit == true)
- {
- string cmd = commonValveControl.OperationName;
- if (!commonValveControl.Status)
- {
- commonValveControl.Status = !commonValveControl.Status;
- InvokeClient.Instance.Service.DoOperation($"{cmd}On");
- }
- else
- {
- commonValveControl.Status = !commonValveControl.Status;
- InvokeClient.Instance.Service.DoOperation($"{cmd}Off");
- }
- }
- }
- /// <summary>
- /// AN Pump调速
- /// </summary>
- /// <param name="obj"></param>
- private void AnPumpSpeedAction(object obj)
- {
- object[] objects = (object[])obj;
- if (objects.Length >= 2)
- {
- InvokeClient.Instance.Service.DoOperation($"{Module}.ANPumpSpeed", objects[1]);
- }
- }
- /// <summary>
- /// 手动注水
- /// </summary>
- /// <param name="param"></param>
- private void ManualDireplenAction(object param)
- {
- InvokeClient.Instance.Service.DoOperation($"{Module}.ManualANDiReplen", ManualFillSeconds);
- }
- /// <summary>
- /// 重置TotalTime
- /// </summary>
- private void ResetTotalAction(object param)
- {
- InvokeClient.Instance.Service.DoOperation($"{Module}.ResetTotalTime");
- }
- /// <summary>
- /// clear slow leak
- /// </summary>
- private void ClearSlowLeakAction(object param)
- {
- InvokeClient.Instance.Service.DoOperation($"{Module}.ClearSlowLeak");
- }
- private void NavigatetoPumpCartAction(object param)
- {
- }
-
- private void BaseLineKeyDownAction(object[] param)
- {
- if (param.Length >= 2)
- {
- if (double.TryParse(param[1].ToString(), out double result))
- {
- InvokeClient.Instance.Service.DoOperation($"{Module}.BaseLineKeyDown", param[0].ToString(), result);
- }
- }
- }
- private void StartLeakTestAction(object[] param)
- {
- InvokeClient.Instance.Service.DoOperation($"{Module}.StartLeakTest",_isInitialized, _isHasANFlow);
- }
- #endregion
- /// <summary>
- /// 进入UI加载数据
- /// </summary>
- /// <param name="systemName"></param>
- public void LoadData(string systemName)
- {
- RecipeType = "res";
- Module = systemName;
- _isHasANFlow = false;
- _rtDataKeys.Clear();
- CellModuleNameSideAFlowCollection.Clear();
- CellModuleNameSideBFlowCollection.Clear();
- CellModuleNameSideAFlowStatusCollection.Clear();
- CellModuleNameSideBFlowStatusCollection.Clear();
- MetalDatas.Clear();
- MetalCellFlowDatas.Clear();
- ReservoirsUIDatas.Clear();
- _rtDataKeys.Add($"{Module}.Metals");
- Dictionary<string, object> tmpMetals = QueryDataClient.Instance.Service.PollData(_rtDataKeys);
- if (tmpMetals != null)
- {
- List<string> strMetals = CommonFunction.GetValue<List<string>>(tmpMetals, $"{Module}.Metals");
- int cellsCount = strMetals.Count;
- if (strMetals != null)
- {
- CellModuleNameCollection.Clear();
- for (int i = 0; i < cellsCount; i++)
- {
- CellModuleNameCollection.Add(strMetals[i]);
- CellModuleNameSideAFlowCollection.Add(0);
- CellModuleNameSideBFlowCollection.Add(0);
- CellModuleNameSideAFlowStatusCollection.Add("");
- CellModuleNameSideBFlowStatusCollection.Add("");
- MetalDatas.Add(null);
- MetalCellFlowDatas.Add(0);
- ReservoirsUIData reservoirsUIData = new ReservoirsUIData();
- reservoirsUIData.Name = strMetals[i];
- ReservoirsUIDatas.Add(reservoirsUIData);
- }
- }
- }
- _rtDataKeys.Clear();
- for (int i = 0; i < CellModuleNameCollection.Count; i++)
- {
- _rtDataKeys.Add($"{CellModuleNameCollection[i]}.SideAFlow");
- _rtDataKeys.Add($"{CellModuleNameCollection[i]}.SideAFlowStatus");
- _rtDataKeys.Add($"{CellModuleNameCollection[i]}.SideBFlow");
- _rtDataKeys.Add($"{CellModuleNameCollection[i]}.SideBFlowStatus");
- _rtDataKeys.Add($"{CellModuleNameCollection[i]}.MetalData");
- }
- _rtDataKeys.Add($"{Module}.{PERSISTENT_VALUE}");
- _rtDataKeys.Add($"{Module}.ReservoirData");
- _rtDataKeys.Add($"{Module}.ANPumpSpeed");
- _rtDataKeys.Add($"{Module}.IsManualANReplen");
- _rtDataKeys.Add($"{Module}.DIValveMaxOnTime");
- _rtDataKeys.Add($"{Module}.IsANHighLevel");
- _rtDataKeys.Add($"{Module}.IsANLowLevel");
- _rtDataKeys.Add($"{Module}.IsLeakDetected");
- _rtDataKeys.Add($"{Module}.FsmState");
- _rtDataKeys.Add($"{Module}.IsCrossDoseInstalled");
- _rtDataKeys.Add($"{Module}.ANTransferFlow");
- _rtDataKeys.Add($"{Module}.ANBypassCounterFlow");
- _rtDataKeys.Add($"{Module}.IsCalibrateEnable");
- _rtDataKeys.Add($"{Module}.ReservoirAverageANLevel");
- _rtDataKeys.Add($"{Module}.CroseDoseType");
- 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)
- {
- ReservoirData = CommonFunction.GetValue<CompactMembranReservoirData>(_rtDataValueDic, $"{Module}.ReservoirData");
- if(ReservoirData.ANBypassFlow == 0)
- {
- ReservoirData.ANBypassFlow = CommonFunction.GetValue<double>(_rtDataValueDic, $"{Module}.ANBypassCounterFlow");
- }
- AvgANLevel = CommonFunction.GetValue<double>(_rtDataValueDic, $"{Module}.ReservoirAverageANLevel");
- IsCrossDoseEnabled = CommonFunction.GetValue<bool>(_rtDataValueDic, $"{Module}.IsCrossDoseInstalled");
- IsCrossDoseTypeConfig = CommonFunction.GetValue<bool>(_rtDataValueDic, $"{Module}.CroseDoseType");
- IsCalibrateEnable = CommonFunction.GetValue<bool>(_rtDataValueDic, $"{Module}.IsCalibrateEnable");
- State = CommonFunction.GetValue<string>(_rtDataValueDic, $"{Module}.FsmState");
- if ("Idle".Equals(State))
- {
- _isInitialized = true;
- }
- IsError = "Error".Equals(State) ? true : false;
- if (ReservoirData != null)
- {
- //ANPump状态
- ANPumpEnable = ReservoirData.ANPump > 0 ? true : false;
- //ANADrainPump状态
- ANADrainPumpEnable = ReservoirData.ANADrainPump > 0 ? true : false;
- //ANBDrainPump状态
- ANBDrainPumpEnable = ReservoirData.ANBDrainPump > 0 ? true : false;
- }
- IsManualReplen = CommonFunction.GetValue<bool>(_rtDataValueDic, $"{Module}.IsManualANReplen");
- DIValveMaxOnTime = CommonFunction.GetValue<double>(_rtDataValueDic, $"{Module}.DIValveMaxOnTime");
- ANPumpSpeed = CommonFunction.GetValue<double>(_rtDataValueDic, $"{Module}.ANPumpSpeed");
- ReservoirsPersistent = CommonFunction.GetValue<ReservoirsPersistentValue>(_rtDataValueDic, $"{Module}.{PERSISTENT_VALUE}");
- InputANBaselineLevel = ReservoirsPersistent.ANBaseLineLevel;
- IsManualMode = "Manual".Equals(ReservoirsPersistent.OperatingMode) ? true : false;
- for (int i = 0; i < CellModuleNameCollection.Count; i++)
- {
- CellModuleNameSideAFlowCollection[i] = CommonFunction.GetValue<double>(_rtDataValueDic, $"{CellModuleNameCollection[i]}.SideAFlow");
- CellModuleNameSideAFlowStatusCollection[i] = CommonFunction.GetValue<string>(_rtDataValueDic, $"{CellModuleNameCollection[i]}.SideAFlowStatus");
- CellModuleNameSideBFlowCollection[i] = CommonFunction.GetValue<double>(_rtDataValueDic, $"{CellModuleNameCollection[i]}.SideBFlow");
- CellModuleNameSideBFlowStatusCollection[i] = CommonFunction.GetValue<string>(_rtDataValueDic, $"{CellModuleNameCollection[i]}.SideBFlowStatus");
- MetalDatas[i] = CommonFunction.GetValue<CompactMembranMetalDeviceData>(_rtDataValueDic, $"{CellModuleNameCollection[i]}.MetalData");
- MetalCellFlowDatas[i] = MetalDatas[i].CellFlow;
- if (CellModuleNameSideAFlowCollection[i] > 0 || CellModuleNameSideBFlowCollection[i] > 0)
- {
- _isHasANFlow = true;
- }
- ReservoirsUIDatas[i].IsEnable = IsEnabled;
- ReservoirsUIDatas[i].ANPumpEnable = ANPumpEnable;
- ReservoirsUIDatas[i].MetalSideAFlow = CellModuleNameSideAFlowCollection[i];
- ReservoirsUIDatas[i].MetalSideBFlow = CellModuleNameSideBFlowCollection[i];
- ReservoirsUIDatas[i].MetalSideAStatus = CellModuleNameSideAFlowStatusCollection[i];
- ReservoirsUIDatas[i].MetalSideBStatus = CellModuleNameSideBFlowStatusCollection[i];
- ReservoirsUIDatas[i].MetalDatas = MetalDatas[i];
- if ("Full".Equals(CellModuleNameSideAFlowStatusCollection[i]) && MetalDatas[i].ANAPinEnable)
- {
- ReservoirsUIDatas[i].IsSideAFull = true;
- }
- else
- {
- ReservoirsUIDatas[i].IsSideAFull = false;
- }
- if ("Full".Equals(CellModuleNameSideBFlowStatusCollection[i]) && MetalDatas[i].ANBPinEnable)
- {
- ReservoirsUIDatas[i].IsSideBFull = true;
- }
- else
- {
- ReservoirsUIDatas[i].IsSideBFull = false;
- }
- ReservoirsUIDatas[i].IsManualOperationMode = IsManualMode;
- }
- //list记录参与循环的metal的A/B面的流量情况
- List<double> list = new List<double>();
- for (int i = 0; i < CellModuleNameSideAFlowCollection.Count; i++)
- {
- if (MetalDatas[i].ANAPinEnable)
- {
- list.Add(CellModuleNameSideAFlowCollection[i]);
- }
- }
- for (int i = 0; i < CellModuleNameSideBFlowCollection.Count; i++)
- {
- if (MetalDatas[i].ANBPinEnable)
- {
- list.Add(CellModuleNameSideBFlowCollection[i]);
- }
- }
- //如果参与循环的流量全是0或者没有参与循环的metal,直接跳过流量差相关判断逻辑
- if (list.All(num => num == 0) || list.Count == 0)
- {
- for (int i = 0; i < CellModuleNameCollection.Count; i++)
- {
- ReservoirsUIDatas[i].IsMetalCellSideAHigh = false;
- ReservoirsUIDatas[i].IsMetalCellSideALow = false;
- ReservoirsUIDatas[i].IsMetalCellSideBHigh = false;
- ReservoirsUIDatas[i].IsMetalCellSideBLow = false;
- }
- }
- else
- {
- FlowAdjustDelta = list.Max() - list.Min();
- IsFolwDeltaUnBlance = FlowAdjustDelta > 0.3 ? true : false;
- if (IsFolwDeltaUnBlance)
- {
- for (int i = 0; i < CellModuleNameSideAFlowCollection.Count; i++)
- {
- if (ReservoirsUIDatas[i].MetalSideAFlow == list.Max() && MetalDatas[i].ANAPinEnable)
- {
- ReservoirsUIDatas[i].IsMetalCellSideAHigh = true;
- }
- else
- {
- ReservoirsUIDatas[i].IsMetalCellSideAHigh = false;
- }
-
- if (ReservoirsUIDatas[i].MetalSideAFlow == list.Min() && MetalDatas[i].ANAPinEnable)
- {
- ReservoirsUIDatas[i].IsMetalCellSideALow = true;
- }
- else
- {
- ReservoirsUIDatas[i].IsMetalCellSideALow = false;
- }
- }
- for (int i = 0; i < CellModuleNameSideBFlowCollection.Count; i++)
- {
- if (ReservoirsUIDatas[i].MetalSideBFlow == list.Max() && MetalDatas[i].ANBPinEnable)
- {
- ReservoirsUIDatas[i].IsMetalCellSideBHigh = true;
- }
- else
- {
- ReservoirsUIDatas[i].IsMetalCellSideBHigh = false;
- }
- if (ReservoirsUIDatas[i].MetalSideBFlow == list.Min() && MetalDatas[i].ANBPinEnable)
- {
- ReservoirsUIDatas[i].IsMetalCellSideBLow = true;
- }
- else
- {
- ReservoirsUIDatas[i].IsMetalCellSideBLow = false;
- }
- }
- }
- else
- {
- for (int i = 0; i < CellModuleNameCollection.Count; i++)
- {
- ReservoirsUIDatas[i].IsMetalCellSideAHigh = false;
- ReservoirsUIDatas[i].IsMetalCellSideALow = false;
- ReservoirsUIDatas[i].IsMetalCellSideBHigh = false;
- ReservoirsUIDatas[i].IsMetalCellSideBLow = false;
- }
- }
- }
- list.Clear();
- IsHighLevel = CommonFunction.GetValue<bool>(_rtDataValueDic, $"{Module}.IsANHighLevel");
- IsLowLevel = CommonFunction.GetValue<bool>(_rtDataValueDic, $"{Module}.IsANLowLevel");
- IsLeakDetected = CommonFunction.GetValue<bool>(_rtDataValueDic, $"{Module}.IsLeakDetected");
- if ("Manual".Equals(ReservoirsPersistent.OperatingMode))
- {
- IsEnabled = true;
- IsAutoEnabled = true;
- IsAutoMode = false;
- }
- else if ("Auto".Equals(ReservoirsPersistent.OperatingMode))
- {
- IsAutoEnabled = true;
- IsEnabled = false;
- IsAutoMode = true;
- }
- else
- {
- State = "Stopped";
- IsEnabled = false;
- IsAutoEnabled = false;
- IsAutoMode = false;
- }
- //CrossDose
- ANTransferFlow = CommonFunction.GetValue<double>(_rtDataValueDic, $"{Module}.ANTransferFlow");
- }
- }
- }
- }
- }
|