using System; using System.Linq; using System.Windows.Media; using DTS.Common.Base; using DTS.Common.Enums.Sensors; using DTS.Common.Interface; // ReSharper disable CheckNamespace // ReSharper disable RedundantDefaultMemberInitializer // ReSharper disable RedundantCast namespace DTS.Common.Classes.Viewer.TestMetadata { [Serializable] public class TestChannel : BasePropertyChanged, ITestChannel { public string Group { get; set; } public string SubGroup { get; set; } private bool _isGraphChannel = false; public bool IsGraphChannel { get => _isGraphChannel; set { _isGraphChannel = value; OnPropertyChanged("IsGraphChannel"); } } public string GraphName { get; set; } public string TestId { get; set; } public string TestSetupName { get; set; } public string ModuleSerialNumber { get; set; } public string SerialNumber { get; set; } public string ChannelId { get; set; } private string _channelDisplayName = string.Empty; public string ChannelDisplayName { get => _channelDisplayName; set => SetProperty(ref _channelDisplayName, value, "ChannelDisplayName"); } public string Description { get; set; } public string IsoCode { get; set; } public string IsoChannelName { get; set; } public string UserCode { get; set; } public string UserChannelName { get; set; } public string ChannelGroupName { get; set; } public string ChannelType { get; set; } private bool _isCalculatedChannel = false; public bool IsCalculatedChannel { get => _isCalculatedChannel; set => SetProperty(ref _isCalculatedChannel, value, "IsCalculatedChannel"); } public int Number { get; set; } public string DigitalMultiplier { get; set; } public string DigitalMode { get; set; } public DateTime Start { get; set; } public string Bridge { get; set; } public double BridgeResistanceOhms { get; set; } public double ZeroPoint { get; set; } private string _channelDescriptionString; public ulong T1Sample { get; set; } = 0; public ulong T2Sample { get; set; } = 0; public double HIC { get; set; } = 0D; public bool UseEUScaler { get; set; } public double ScaleFactorEU { get; set; } = 0D; public string ChannelDescriptionString { get => _channelDescriptionString; set => SetProperty(ref _channelDescriptionString, value, "ChannelDescriptionString"); } public void SetChannelDescriptionAndDisplayName(string channelDescription) { ChannelDescriptionString = channelDescription; ChannelDisplayName = $"{ChannelName2} {ChannelDescriptionString}"; } public string ChannelName2 { get; set; } public string HardwareChannelName { get; set; } public double DesiredRange { get; set; } public double ActualMaxRangeEu { get; set; } public double ActualMinRangeEu { get; set; } public double ActualMaxRangeAdc => short.MaxValue; public double ActualMinRangeAdc => short.MinValue; public double ActualMaxRangeMv { get; set; } public double ActualMinRangeMv { get; set; } public double Sensitivity { get; set; } public string SoftwareFilter { get; set; } public bool ProportionalToExcitation { get; set; } public bool IsInverted { get; set; } public string LinearizationFormula { get; set; } public bool IsSubsampled { get; set; } public int AbsoluteDisplayOrder { get; set; } public DateTime LastCalibrationDate { get; set; } public string SensorId { get; set; } public int OffsetToleranceLowMv { get; set; } public int OffsetToleranceHighMv { get; set; } public int DataFlag { get; set; } public string ExcitationVoltage { get; set; } public string Eu { get; set; } public bool CalSignalEnabled { get; set; } public bool ShuntEnabled { get; set; } public bool VoltageInsertionCheckEnabled { get; set; } public bool RemoveOffset { get; set; } public string ZeroMethod { get; set; } public double ZeroAverageWindowBegin { get; set; } public double ZeroAverageWindowEnd { get; set; } public int InitialEu { get; set; } public string InitialOffset { get; set; } public int UnsubsampledSampleRateHz { get; set; } public double MeasuredShuntDeflectionMv { get; set; } public double TargetShuntDeflectionMv { get; set; } public double MeasuredExcitationVoltage { get; set; } public double FactoryExcitationVoltage { get; set; } public double TimeOfFirstSample { get; set; } public double Multiplier { get; set; } public double UserOffsetEu { get; set; } public int UnitConversion { get; set; } public bool AtCapacity { get; set; } public int CapacityOutputIsBasedOn { get; set; } public string SourceChannelNumber { get; set; } public string SourceModuleNumber { get; set; } public string SourceModuleSerialNumber { get; set; } public string Calculation { get; set; } public int SampleRateHz { get; set; } public string SensitivityUnits { get; set; } public int SensorCapacity { get; set; } public string SensorPolarity { get; set; } public int ChannelNumber { get; set; } public string BinaryFileName { get; set; } public string BinaryFilePath { get; set; } public double Xmax { get; set; } public double Xmin { get; set; } public int SequentialNumbers { get; set; } public ITestSetupMetadata ParentTestSetup { get; set; } public ITestModule ParentModule { get; set; } public IBaseViewModel Parent { get; set; } private Color _channelColor = Colors.Transparent; public Color ChannelColor { get => _channelColor; set => SetProperty(ref _channelColor, value, "ChannelColor"); } private string _errorMessage = string.Empty; public string ErrorMessage { get => _errorMessage; set { _errorMessage = value; _isError = !string.IsNullOrEmpty(_errorMessage); OnPropertyChanged("ErrorMessage"); } } private bool _isError = false; public bool IsError { get => _isError; set => SetProperty(ref _isError, value, "IsError"); } private Color? _errorColor = Colors.Black; public Color? ErrorColor { get { _errorColor = _isError ? Colors.Red : Colors.Black; return _errorColor; } set => SetProperty(ref _errorColor, value, "ErrorColor"); } private bool _isLocked = false; public bool IsLocked { get => _isLocked; set { _isLocked = value; if (!_isLocked && !_isSelected && !_isGraphChannel) { ChannelColor = Colors.Transparent; } if (CanSelectChannel) { var parent = Parent; if (parent.GetType().GetInterfaces().Contains(typeof(IGraphMainViewModel))) { ((IGraphMainViewModel)parent).AddLockedChannel(this, _isLocked); } } OnPropertyChanged("IsLocked"); } } private bool _bCanLock = true; public bool CanLock { get => _bCanLock; set => SetProperty(ref _bCanLock, !IsError && value, "CanLock"); } private bool _canSelectChannel = true; public bool CanSelectChannel { get => _canSelectChannel; set => SetProperty(ref _canSelectChannel, !IsError && value, "CanSelectChannel"); } private bool _isExpanded = true; public bool IsExpanded { get => _isExpanded; set => SetProperty(ref _isExpanded, value, "IsExpanded"); } private bool _isSelected = false; public bool IsSelected { get => _isSelected; set { var parent = Parent; _isSelected = value; if (!_isLocked && !_isSelected && !_isGraphChannel) { ChannelColor = Colors.Transparent; } if (_isSelected && CanSelectChannel) { if (parent.GetType().GetInterfaces().Contains(typeof(IGraphMainViewModel))) { ((IGraphMainViewModel)parent).AddSelectedChannel(this); } OnPropertyChanged("IsSelected"); } } } public ITestChannel Copy() { return (TestChannel)MemberwiseClone(); } public override string ToString() { if (SensorConstants.IsTestSpecificEmbedded(ChannelDescriptionString) && !string.IsNullOrWhiteSpace(ChannelName2)) { return ChannelName2; } return ChannelDescriptionString; } private double _minADC = double.NaN; /// /// Min value of ADC for entire dataset /// public double MinADC { get => _minADC; set => SetProperty(ref _minADC, value, "MinADC"); } private double _maxADC = double.NaN; /// /// Max value in ADC for entire dataset /// public double MaxADC { get => _maxADC; set => SetProperty(ref _maxADC, value, "MaxADC"); } private double _aveADC = double.NaN; /// /// Average value in ADC for entire dataset /// public double AveADC { get => _aveADC; set => SetProperty(ref _aveADC, value, "AveADC"); } private double _stdDevADC = double.NaN; /// /// STD DEV in ADC for entire dataset /// public double StdDevADC { get => _stdDevADC; set => SetProperty(ref _stdDevADC, value, "StdDevADC"); } private double _t0ADC = double.NaN; /// /// Value @ T0 in ADC /// public double T0ADC { get => _t0ADC; set => SetProperty(ref _t0ADC, value, "T0ADC"); } private double _minMV = double.NaN; /// /// Minimum value in mV for entire dataset /// public double MinMV { get => _minMV; set => SetProperty(ref _minMV, value, "MinMV"); } private double _maxMV = double.NaN; /// /// Maximum value in mV for entire dataset /// public double MaxMV { get => _maxMV; set => SetProperty(ref _maxMV, value, "MaxMV"); } private double _aveMV = double.NaN; /// /// average value in mV for entire dataset /// public double AveMV { get => _aveMV; set => SetProperty(ref _aveMV, value, "AveMV"); } private double _stdDevMV = double.NaN; /// /// std dev in mV for entire dataset /// public double StdDevMV { get => _stdDevMV; set => SetProperty(ref _stdDevMV, value, "StdDevMV"); } private double _t0MV = double.NaN; /// /// value in mV at T0 /// public double T0MV { get => _t0MV; set => SetProperty(ref _t0MV, value, "T0MV"); } private double _minEU = double.NaN; /// /// minimum value in EU for entire dataset /// public double MinEU { get => _minEU; set => SetProperty(ref _minEU, value, "MinEU"); } private double _maxEU = double.NaN; /// /// maximum value in EU for entire dataset /// public double MaxEU { get => _maxEU; set => SetProperty(ref _maxEU, value, "MaxEU"); } private double _aveEU = double.NaN; /// /// average value in EU for entire dataset /// public double AveEU { get => _aveEU; set => SetProperty(ref _aveEU, value, "AveEU"); } private double _stdDevEU = double.NaN; /// /// std dev in EU /// public double StdDevEU { get => _stdDevEU; set => SetProperty(ref _stdDevEU, value, "StdDevEU"); } private double _t0EU = double.NaN; /// /// value at T0 in EU /// public double T0EU { get => _t0EU; set => SetProperty(ref _t0EU, value, "T0EU"); } private double _minY = double.NaN; /// /// minimum value for whatever current units are for entire dataset /// public double MinY { get => _minY; set => SetProperty(ref _minY, value, "MinY"); } private double _maxY = double.NaN; /// /// maximum value for whatever current units are for entire dataset /// public double MaxY { get => _maxY; set => SetProperty(ref _maxY, value, "MaxY"); } private double _aveY = double.NaN; /// /// average value for whatever current units are for entire dataset /// public double AveY { get => _aveY; set => SetProperty(ref _aveY, value, "AveY"); } private double _stdDevY = double.NaN; /// /// std deviation for whatever current units are /// public double StdDevY { get => _stdDevY; set => SetProperty(ref _stdDevY, value, "StdDevY"); } private double _T0Value = double.NaN; /// /// Value at T0 in whatever current units are /// public double T0Value { get => _T0Value; set => SetProperty(ref _T0Value, value, "T0Value"); } private string _setupEID = string.Empty; /// /// EID channel was originally set up with /// public string SetupEID { get => _setupEID; set => SetProperty(ref _setupEID, value, "SetupEID"); } private string _dataCollectionEID = string.Empty; /// /// EID present on channel when data was collected /// public string DataCollectionEID { get => _dataCollectionEID; set => SetProperty(ref _dataCollectionEID, value, "DataCollectionEID"); } } }