271 lines
11 KiB
C#
271 lines
11 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.ComponentModel;
|
|
using DTS.Common;
|
|
using DTS.Common.Classes.Sensors;
|
|
using DTS.Common.Enums.Viewer;
|
|
using DTS.Common.Interface;
|
|
using DTS.Common.Interface.Sensors.SoftwareFilters;
|
|
using Prism.Commands;
|
|
// ReSharper disable EmptyConstructor
|
|
|
|
// ReSharper disable RedundantDefaultMemberInitializer
|
|
// ReSharper disable UnassignedGetOnlyAutoProperty
|
|
|
|
namespace DTS.Viewer.ChartOptions.Model
|
|
{
|
|
public class ChartOptionsModel : Common.Base.BasePropertyChanged, IChartOptionsModel
|
|
{
|
|
private bool _bDisplayingVolts = false;
|
|
/// <summary>
|
|
/// indicates if current mV option is for Volts or mV
|
|
/// </summary>
|
|
public bool DisplayingVolts
|
|
{
|
|
get => _bDisplayingVolts;
|
|
set
|
|
{
|
|
SetProperty(ref _bDisplayingVolts, value, "DisplayingVolts");
|
|
OnPropertyChanged("MVOrV");
|
|
OnPropertyChanged("UnitTypeDescription");
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// returns mV or V depending on DisplayingVolts value
|
|
/// </summary>
|
|
public string MVOrV => DisplayingVolts ? "V" : "mV";
|
|
|
|
public ChartOptionsModel()
|
|
{
|
|
|
|
}
|
|
|
|
#region Properties
|
|
private bool _isDigitalChannel = false;
|
|
public bool IsDigitalChannel { get { return _isDigitalChannel; } set { SetProperty(ref _isDigitalChannel, value, "IsDigitalChannel"); } }
|
|
private bool _supportsADC = true;
|
|
public bool SupportsADC
|
|
{
|
|
get => _supportsADC;
|
|
set
|
|
{
|
|
SetProperty(ref _supportsADC, value, "SupportsADC");
|
|
}
|
|
}
|
|
|
|
private bool _supportsMV = true;
|
|
public bool SupportsMV
|
|
{
|
|
get => _supportsMV;
|
|
set
|
|
{
|
|
SetProperty(ref _supportsMV, value, "SupportsMV");
|
|
}
|
|
}
|
|
|
|
private ChartUnitTypeEnum _unitType = ChartUnitTypeEnum.EU;
|
|
|
|
public ChartUnitTypeEnum UnitType
|
|
{
|
|
get => _unitType;
|
|
set
|
|
{
|
|
if (_unitType.Equals(value)) return;
|
|
_unitType = value;
|
|
ReadData = true;
|
|
// FB 13120 does not need to set SelectedFilter any more since it's not using enum
|
|
if (_unitType != ChartUnitTypeEnum.EU && _unitType != ChartUnitTypeEnum.PSD) { Filter = FilterOptionEnum.Unfiltered; }
|
|
else { Filter = FilterOptionEnum.TestSetupDefault; }
|
|
OnPropertyChanged("UnitType");
|
|
OnPropertyChanged("UnitTypeDescription");
|
|
}
|
|
}
|
|
private string _unitTypeDescription = ChartUnitTypeEnum.EU.ToString();
|
|
|
|
public string UnitTypeDescription
|
|
{
|
|
get
|
|
{
|
|
if (UnitType == ChartUnitTypeEnum.mV)
|
|
{
|
|
return DisplayingVolts ? "V" : "mV";
|
|
}
|
|
return UnitType.ToString();
|
|
}
|
|
}
|
|
|
|
private TimeUnitTypeEnum _timeUnitType = TimeUnitTypeEnum.MS;
|
|
|
|
public TimeUnitTypeEnum TimeUnitType
|
|
{
|
|
get => _timeUnitType;
|
|
set
|
|
{
|
|
if (_timeUnitType.Equals(value)) return;
|
|
_timeUnitType = value;
|
|
ReadData = true;
|
|
TimeUnitTypeDescription = _timeUnitType.ToString();
|
|
OnPropertyChanged("TimeUnitType");
|
|
}
|
|
}
|
|
|
|
private string _timeUnitTypeDescription = TimeUnitTypeEnum.MS.ToString();
|
|
public string TimeUnitTypeDescription
|
|
{
|
|
get => _timeUnitTypeDescription;
|
|
set
|
|
{
|
|
if (_timeUnitTypeDescription.Equals(value)) return;
|
|
_timeUnitTypeDescription = value;
|
|
OnPropertyChanged("TimeUnitTypeDescription");
|
|
}
|
|
}
|
|
//FB 13120 use filter class instead of cfc filter enum
|
|
private IFilterClass _selectedFilter = new FilterClass(Common.Enums.Sensors.FilterClassType.Unfiltered);
|
|
public IFilterClass SelectedFilter { get => _selectedFilter; set { _selectedFilter = value; ReadData = true; OnPropertyChanged("SelectedFilter"); } }
|
|
|
|
public void SetSelectedFilterToUnfilteredNoRead()
|
|
{
|
|
_selectedFilter = new FilterClass(Common.Enums.Sensors.FilterClassType.Unfiltered);
|
|
ReadData = false;
|
|
OnPropertyChanged("SelectedFilter");
|
|
}
|
|
|
|
#region Min/Max Fixed Y
|
|
private double _minFixedY = 0.00;
|
|
public double MinFixedY { get => _minFixedY; set { if (_minFixedY.Equals(value)) return; _minFixedY = value; OnPropertyChanged("MinFixedY"); } }
|
|
|
|
private double _maxFixedY = 0.00;
|
|
public double MaxFixedY { get => _maxFixedY; set { if (_maxFixedY.Equals(value)) return; _maxFixedY = value; OnPropertyChanged("MaxFixedY"); } }
|
|
#endregion Min/Max Fixed Y
|
|
|
|
#region Min/Max Fixed X
|
|
private double _minFixedT = 0.00;
|
|
public double MinFixedT { get => _minFixedT; set { if (_minFixedT.Equals(value)) return; _minFixedT = value; OnPropertyChanged("MinFixedT"); } }
|
|
|
|
private double _maxFixedT = 0.00;
|
|
public double MaxFixedT { get => _maxFixedT; set { if (_maxFixedT.Equals(value)) return; _maxFixedT = value; OnPropertyChanged("MaxFixedT"); } }
|
|
#endregion Min/Max Fixed X
|
|
|
|
private List<double> _fullScaleValues = new List<double> { 200D, 100D, 50D, 20D, 10D, 5D, 1D, 0.1D };
|
|
private readonly List<double> _euValues = new List<double> { 5000, 2500, 1000, 500, 100, 50, 10, 5 };
|
|
|
|
public List<double> FullScaleValues { get => UnitType == ChartUnitTypeEnum.EU || UnitType == ChartUnitTypeEnum.PSD ? _euValues : _fullScaleValues; set { _fullScaleValues = value; OnPropertyChanged("FullScaleValues"); } }
|
|
|
|
private double _selectedFullScaleValue = 100;
|
|
public double SelectedFullScaleValue { get => _selectedFullScaleValue; set { _selectedFullScaleValue = value; OnPropertyChanged("SelectedFullScaleValue"); } }
|
|
|
|
private bool _lockedT = false;
|
|
public bool LockedT { get => _lockedT; set { if (_lockedT.Equals(value)) return; _lockedT = value; OnPropertyChanged("LockedT"); } }
|
|
|
|
private bool _lockedY = false;
|
|
public bool LockedY { get => _lockedY; set { if (_lockedY.Equals(value)) return; _lockedY = value; OnPropertyChanged("LockedY"); } }
|
|
|
|
private bool _showCursor = false;
|
|
|
|
public bool ShowCursor
|
|
{
|
|
get => _showCursor;
|
|
set
|
|
{
|
|
if (_showCursor.Equals(value)) return;
|
|
_showCursor = value; Parent?.ShowCusor(_showCursor); OnPropertyChanged("ShowCursor");
|
|
}
|
|
}
|
|
private string _currentCursorValues = string.Empty;
|
|
|
|
public string CurrentCursorValues
|
|
{
|
|
get => _currentCursorValues;
|
|
set { _currentCursorValues = value; OnPropertyChanged("CurrentCursorValues"); }
|
|
}
|
|
private YRangeScaleEnum _yRange = YRangeScaleEnum.AutoRange;
|
|
|
|
public YRangeScaleEnum YRange
|
|
{
|
|
get => _yRange;
|
|
set { if (_yRange.Equals(value)) return; _yRange = value; LockedY = _yRange == YRangeScaleEnum.Fixed; OnPropertyChanged("YRange"); }
|
|
}
|
|
|
|
private FilterOptionEnum _filter = FilterOptionEnum.TestSetupDefault;
|
|
public FilterOptionEnum Filter { get => _filter; set { if (_filter.Equals(value)) return; _filter = value; ReadData = true; OnPropertyChanged("Filter"); } }
|
|
|
|
|
|
private IChartOptionsViewModel _parent;
|
|
public IChartOptionsViewModel Parent { get => _parent; set { if (_parent != null && _parent.Equals(value)) return; _parent = value; OnPropertyChanged("Parent"); } }
|
|
|
|
private bool _canPublishChanges = true;
|
|
public bool CanPublishChanges { get => _canPublishChanges; set { _canPublishChanges = value; OnPropertyChanged("CanPublishChanges"); } }
|
|
|
|
private bool _isCursorsAvailable = false;
|
|
public bool IsCursorsAvailable { get => _isCursorsAvailable; set { _isCursorsAvailable = value; OnPropertyChanged("IsCursorsAvailable"); } }
|
|
|
|
private bool _t0Cursor = false;
|
|
public bool T0Cursor { get => _t0Cursor; set { _t0Cursor = value; OnPropertyChanged("T0Cursor"); } }
|
|
|
|
private bool _minMaxCursors = false;
|
|
public bool MinMaxCursors { get => _minMaxCursors; set { _minMaxCursors = value; OnPropertyChanged("MinMaxCursors"); } }
|
|
|
|
private bool _readData = false;
|
|
public bool ReadData { get => _readData; set { _readData = value; OnPropertyChanged("ReadData"); } }
|
|
private DelegateCommand _resetZoomCommand;
|
|
public DelegateCommand ResetZoomCommand => _resetZoomCommand ?? (_resetZoomCommand = new DelegateCommand(ResetZoomMethod));
|
|
|
|
private void ResetZoomMethod()
|
|
{
|
|
Parent.ResetZoomMethod();
|
|
}
|
|
private DelegateCommand _resetTCommand;
|
|
public DelegateCommand ResetTCommand => _resetTCommand ?? (_resetTCommand = new DelegateCommand(ResetTMethod));
|
|
|
|
private void ResetTMethod()
|
|
{
|
|
Parent.ResetTMethod();
|
|
}
|
|
private DelegateCommand _saveToPDFCommand;
|
|
public DelegateCommand SaveToPDFCommand => _saveToPDFCommand ?? (_saveToPDFCommand = new DelegateCommand(SaveToPDFMethod));
|
|
|
|
private void SaveToPDFMethod()
|
|
{
|
|
Parent.SaveToPDFMethod();
|
|
}
|
|
///<summary>
|
|
///Occurs when a property value changes.
|
|
///</summary>
|
|
public event PropertyChangedEventHandler PropertyChanged;
|
|
|
|
public void OnPropertyChanged(string propertyName)
|
|
{
|
|
var handler = PropertyChanged;
|
|
|
|
handler?.Invoke(this, new PropertyChangedEventArgs(propertyName));
|
|
|
|
if (propertyName == "CanPublishChanges"
|
|
|| propertyName == "Parent"
|
|
|| propertyName == "ReadData"
|
|
|| propertyName == "UnitTypeDescription"
|
|
|| propertyName == "ShowCursor"
|
|
|| propertyName == "LockedT"
|
|
|| propertyName == "LockedY"
|
|
|| propertyName == "MVOrV"
|
|
|| propertyName == "DisplayingVolts"
|
|
|| propertyName == "DecimateData"
|
|
|| propertyName == "WidthPoints") return;
|
|
|
|
if (CanPublishChanges) { Parent?.PublishChanges(); }
|
|
}
|
|
|
|
|
|
public bool IsSaved { get; }
|
|
|
|
private bool _decimateData = false;
|
|
public bool DecimateData { get => _unitType != ChartUnitTypeEnum.PSD && _unitType != ChartUnitTypeEnum.FFT && _decimateData; set { _decimateData = value; OnPropertyChanged("DecimateData"); } }
|
|
|
|
private long _widthPoints = 0;
|
|
public long WidthPoints { get => _widthPoints; set { _widthPoints = value; OnPropertyChanged("WidthPoints"); } }
|
|
|
|
#endregion Properties
|
|
}
|
|
}
|