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 CyberX8_Core;
using CyberX8_MainPages.PMs;
using Prism.Commands;
using Prism.Mvvm;
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Windows.Input;
using System.Windows.Threading;
using MECF.Framework.Common.CommonData.TemperatureControl;
using MECF.Framework.Common.CommonData.PowerSupplier;
using MECF.Framework.Common.Device.Safety;
using MECF.Framework.Common.ProcessCell;
namespace CyberX8_MainPages.ViewModels
{
public class StandardHotReservoirsViewModel : BindableBase
{
#region 常量
private const string RESERVOIRS_DATA = "ReservoirsData";
private const string RESERVOIRS = "reservoirs";
private const string PERSISTENT_VALUE = "PersistentValue";
private const string METALDEVICEDATA = "MetalDeviceData";
private const string RESERVOIRDEVICEDATA = "ReservoirDeviceData";
private const string REPLEN_PERSISTENT_VALUE = "ReplenPersistentValue";
#endregion
#region 内部变量
#region system
///
/// rt查询key
///
private List _rtDataKeys = new List();
///
/// 时钟
///
DispatcherTimer _timer;
///
/// rt查询数据
///
private Dictionary _rtDataValueDic = new Dictionary();
#endregion
#region Common
private double _avgLevel;
///
/// Module
///
private string _module;
///
/// Operation Mode
///
private string _operatingMode;
///
/// 状态
///
private string _state;
///
/// Reservoirs Persistent数据
///
private ReservoirsPersistentValue _reservoirsPersistent;
///
/// Reservoir数据
///
private StandardHotReservoirData _reservoirData;
///
/// Metal数据集合
///
private ObservableCollection _metalDataCollection = new ObservableCollection();
///
/// CellModuleName集合
///
private ObservableCollection _cellModuleNameCollection = new ObservableCollection();
///
/// Cells数量
///
private int _cellsCount;
///
/// 手动注水时长(秒)
///
private int _manualFillSeconds;
///
/// 是否正在手动注水
///
private bool _isManualReplen;
///
/// DIValveMaxOnTime
///
private double _diValveMaxOnTime;
///
/// 是否超过PH值下限
///
private bool _isPHLowLimit;
///
/// 是否超过PH值下限
///
private bool _isPHHighLimit;
///
/// TemperatureControl Module Name
///
private TemperatureControllerData _temperatureControlData;
///
/// PowerSupply Module Name
///
private PowerSupplierData _cmmPowerSupplierData;
///
/// 是否超过HighLevel
///
private bool _isHighLevel;
///
/// 是否超过LowLevel
///
private bool _isLowLevel;
///
/// 是否触发highsafety
///
private bool _isHighSafety;
///
/// HED Flow
///
private bool _hedFlowIsOn;
///
/// DiReplen是否报错
///
private bool _isDiReplenFault;
///
/// Safety Data
///
private SafetyData _safetyData;
///
/// 页面功能启用
///
private bool _isEnabled;
///
/// AutoMode页面功能启用
///
private bool _isAutoEnabled;
///
/// DosingSystem是否启用
///
private bool _isDosingSystemEnabled;
///
/// TC Enable状态
///
private string _tcEnableStatus;
///
/// 是否error状态
///
private bool _isError;
#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 CMM
///
/// Flow High 状态(Warning:黄色,Error:红色)
///
private string _flowHighStatus = "";
///
/// Flow Low 状态(Warning:黄色,Error:红色)
///
private string _flowLowStatus = "";
///
/// PowerSupplier High电流状态
///
private string _currentHighStatus = "";
///
/// PowerSupplier Low电流状态
///
private string _currentLowStatus = "";
///
/// 是否低于最小电压
///
private bool _isBelowMinVoltage = false;
///
/// CMM Anode AHrs
///
private double _reservoirCMMAnodeAHrs;
///
/// CMM Cathode AHrs
///
private double _reservoirCMMCathodeAHrs;
///
/// CMM Anode用电量
///
private double _cmmAnodeUsage;
///
/// CMM Cathode用电量
///
private double _cmmCathodeUsage;
///
/// CMM Flow High Warning
///
private double _reservoirCMMFlowHighWarning;
///
/// CMM Flow High Error
///
private double _reservoirCMMFlowHighError;
///
/// CMM Flow Low Warning
///
private double _reservoirCMMFlowLowWarning;
///
/// CMM Flow Low Error
///
private double _reservoirCMMFlowLowError;
///
/// CMM Anode LifeTime AHrs
///
private double _reservoirCMMAnodeLifeTimeAHrs;
///
/// CMM Cathode LifeTime AHrs
///
private double _reservoirCMMCathodeLifeTimeAHrs;
///
/// HighLevel
///
private double _reservoirHighLevel;
///
/// LowLevel
///
private double _reservoirLowLevel;
///
/// CMM电量limit
///
private double _cmmAnodeTotalAmpHoursWarningLimit;
private double _cmmAnodeTotalAmpHoursFaultLimit;
private double _cmmCathodeTotalAmpHoursWarningLimit;
private double _cmmCathodeTotalAmpHoursFaultLimit;
///
/// CMM电量报警灯
///
private bool _isCMMAnodeTotalAmpHoursWarning;
private bool _isCMMAnodeTotalAmpHoursFault;
private bool _isCMMCathodeTotalAmpHoursWarning;
private bool _isCMMCathodeTotalAmpHoursFault;
#endregion
#endregion
#region 属性
#region Common
public double AvgLevel
{
get { return _avgLevel; }
set { SetProperty(ref _avgLevel, value); }
}
///
/// 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); }
}
///
/// Reservoir数据
///
public StandardHotReservoirData ReservoirData
{
get { return _reservoirData; }
set { SetProperty(ref _reservoirData, value); }
}
///
/// Metal数据集合
///
public ObservableCollection MetalDataCollection
{
get { return _metalDataCollection; }
set { SetProperty(ref _metalDataCollection, value); }
}
///
/// CellModuleName集合
///
public ObservableCollection CellModuleNameCollection
{
get { return _cellModuleNameCollection; }
set { SetProperty(ref _cellModuleNameCollection, value); }
}
///
/// Cells数量
///
public int CellsCount
{
get { return _cellsCount; }
set { SetProperty(ref _cellsCount, value); }
}
///
/// 是否超过PH值下限
///
public bool IsPHLowLimit
{
get { return _isPHLowLimit; }
set { SetProperty(ref _isPHLowLimit, value); }
}
///
/// 是否超过PH值下限
///
public bool IsPHHighLimit
{
get { return _isPHHighLimit; }
set { SetProperty(ref _isPHHighLimit, value); }
}
///
/// 手动注水时长(秒)
///
public int ManualFillSeconds
{
get { return _manualFillSeconds; }
set { SetProperty(ref _manualFillSeconds, value); }
}
///
/// 是否正在手动注水
///
public bool IsManualReplen
{
get { return _isManualReplen; }
set { SetProperty(ref _isManualReplen, value); }
}
///
/// DIValveMaxOnTime
///
public double DIValveMaxOnTime
{
get { return _diValveMaxOnTime; }
set { SetProperty(ref _diValveMaxOnTime, value);}
}
///
/// TemperatureControl Module Name
///
public TemperatureControllerData TemperatureControlData
{
get { return _temperatureControlData; }
set { SetProperty(ref _temperatureControlData, value); }
}
///
/// PowerSupply Module Name
///
public PowerSupplierData CmmPowerSupplierData
{
get { return _cmmPowerSupplierData; }
set { SetProperty(ref _cmmPowerSupplierData, value); }
}
///
/// 是否超过HighLevel
///
public bool IsHighLevel
{
get { return _isHighLevel; }
set { SetProperty(ref _isHighLevel, value); }
}
///
/// 是否超过LowLevel
///
public bool IsLowLevel
{
get { return _isLowLevel; }
set { SetProperty(ref _isLowLevel, value); }
}
///
/// 是否触发Highsafety
///
public bool IsHighSafety
{
get { return _isHighSafety; }
set { SetProperty(ref _isHighSafety, value); }
}
///
/// HED Flow
///
public bool HEDFlowIsOn
{
get { return _hedFlowIsOn; }
set { SetProperty(ref _hedFlowIsOn, value); }
}
///
/// DI Replen是否报错
///
public bool IsDiReplenFault
{
get { return _isDiReplenFault; }
set { SetProperty(ref _hedFlowIsOn, value); }
}
///
/// Safety数据
///
public SafetyData CommonSafetyData
{
get { return _safetyData; }
set { SetProperty(ref _safetyData, value); }
}
///
/// 页面功能启用
///
public bool IsEnabled
{
get { return _isEnabled; }
set { SetProperty(ref _isEnabled, value); }
}
///
/// AutoMode页面功能启用
///
public bool IsAutoEnabled
{
get { return _isAutoEnabled; }
set { SetProperty(ref _isAutoEnabled, value); }
}
///
/// DosingSystem是否启用
///
public bool IsDosingSystemEnabled
{
get { return _isDosingSystemEnabled; }
set { SetProperty(ref _isDosingSystemEnabled, value); }
}
///
/// TC Enable状态
///
public string TCEnableStatus
{
get { return _tcEnableStatus; }
set { SetProperty(ref _tcEnableStatus, value); }
}
///
/// 是否Error
///
public bool IsError
{
get { return _isError; }
set { SetProperty(ref _isError, 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 CMM
///
/// Flow High 状态(Warning:黄色,Error:红色)
///
public string FlowHighStatus
{
get { return _flowHighStatus; }
set { SetProperty(ref _flowHighStatus, value); }
}
///
/// Flow Low 状态(Warning:黄色,Error:红色)
///
public string FlowLowStatus
{
get { return _flowLowStatus; }
set { SetProperty(ref _flowLowStatus, value); }
}
///
/// PowerSupplier High电流状态
///
public string CurrentHighStatus
{
get { return _currentHighStatus; }
set { SetProperty(ref _currentHighStatus, value); }
}
///
/// PowerSupplier Low电流状态
///
public string CurrentLowStatus
{
get { return _currentLowStatus; }
set { SetProperty(ref _currentLowStatus, value); }
}
///
/// 是否低于最小电压
///
public bool IsBelowMinVoltage
{
get { return _isBelowMinVoltage; }
set { SetProperty(ref _isBelowMinVoltage, value); }
}
///
/// CMM Anode 用电量
///
public double CMMAnodeAHrs
{
get { return _reservoirCMMAnodeAHrs; ; }
set { SetProperty(ref _reservoirCMMAnodeAHrs, value); }
}
///
/// CMM Cathode 用电量
///
public double CMMCathodeAHrs
{
get { return _reservoirCMMCathodeAHrs; ; }
set { SetProperty(ref _reservoirCMMCathodeAHrs, value); }
}
#endregion
#region Config
///
/// CMM Anode LifeTime用电量
///
public double CMMAnodeLifeTimeAHrs
{
get { return _reservoirCMMAnodeLifeTimeAHrs; ; }
set { SetProperty(ref _reservoirCMMAnodeLifeTimeAHrs, value); }
}
///
/// CMM Cathode LifeTime用电量
///
public double CMMCathodeLifeTimeAHrs
{
get { return _reservoirCMMCathodeLifeTimeAHrs; ; }
set { SetProperty(ref _reservoirCMMCathodeLifeTimeAHrs, value); }
}
///
/// CMM Anode用电量
///
public double CMMAnodeUsage
{
get { return _cmmAnodeUsage; ; }
set { SetProperty(ref _cmmAnodeUsage, value); }
}
///
/// CMM Cathode用电量
///
public double CMMCathodeUsage
{
get { return _cmmCathodeUsage; ; }
set { SetProperty(ref _cmmCathodeUsage, value); }
}
///
/// CMM电量报警灯
///
public bool IsCMMAnodeTotalAmpHoursWarning
{
get { return _isCMMAnodeTotalAmpHoursWarning; }
set { SetProperty(ref _isCMMAnodeTotalAmpHoursWarning, value); }
}
public bool IsCMMAnodeTotalAmpHoursFault
{
get { return _isCMMAnodeTotalAmpHoursFault; }
set { SetProperty(ref _isCMMAnodeTotalAmpHoursFault, value); }
}
public bool IsCMMCathodeTotalAmpHoursWarning
{
get { return _isCMMCathodeTotalAmpHoursWarning; }
set { SetProperty(ref _isCMMCathodeTotalAmpHoursWarning, value); }
}
public bool IsCMMCathodeTotalAmpHoursFault
{
get { return _isCMMCathodeTotalAmpHoursFault; }
set { SetProperty(ref _isCMMCathodeTotalAmpHoursFault, value); }
}
#endregion
#endregion
#region 命令
public ICommand InitializeCommand { get; set; }
public ICommand OpenDIReplenValveCommand { get; set; }
public ICommand CloseDIReplenValveCommand { get; set; }
public ICommand OpenCellFlow1Command { get; set; }
public ICommand OpenCellBypass1Command { get; set; }
public ICommand OpenCellFlow2Command { get; set; }
public ICommand OpenCellBypass2Command { get; set; }
public ICommand OpenClampValve1Command { get; set; }
public ICommand CloseClampValve1Command { get; set; }
public ICommand OpenClampValve2Command { get; set; }
public ICommand CloseClampValve2Command { get; set; }
public ICommand ManualDireplenCommand { get; set; }
public ICommand ResetTotalCommand { get; set; }
public ICommand GotoPMCounterCommand { get; set; }
public ICommand JumpDosingSystemCommand { get; set; }
#endregion
///
/// 构造函数
///
public StandardHotReservoirsViewModel()
{
InitializeCommand = new DelegateCommand