init
This commit is contained in:
@@ -0,0 +1,425 @@
|
||||
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)) { return Strings.Strings.Table_NA; }
|
||||
return ChannelDescriptionString;
|
||||
}
|
||||
|
||||
|
||||
private double _minADC = double.NaN;
|
||||
/// <summary>
|
||||
/// Min value of ADC for entire dataset
|
||||
/// </summary>
|
||||
public double MinADC
|
||||
{
|
||||
get => _minADC;
|
||||
set => SetProperty(ref _minADC, value, "MinADC");
|
||||
}
|
||||
private double _maxADC = double.NaN;
|
||||
/// <summary>
|
||||
/// Max value in ADC for entire dataset
|
||||
/// </summary>
|
||||
public double MaxADC
|
||||
{
|
||||
get => _maxADC;
|
||||
set => SetProperty(ref _maxADC, value, "MaxADC");
|
||||
}
|
||||
private double _aveADC = double.NaN;
|
||||
/// <summary>
|
||||
/// Average value in ADC for entire dataset
|
||||
/// </summary>
|
||||
public double AveADC
|
||||
{
|
||||
get => _aveADC;
|
||||
set => SetProperty(ref _aveADC, value, "AveADC");
|
||||
}
|
||||
private double _stdDevADC = double.NaN;
|
||||
/// <summary>
|
||||
/// STD DEV in ADC for entire dataset
|
||||
/// </summary>
|
||||
public double StdDevADC
|
||||
{
|
||||
get => _stdDevADC;
|
||||
set => SetProperty(ref _stdDevADC, value, "StdDevADC");
|
||||
}
|
||||
private double _t0ADC = double.NaN;
|
||||
/// <summary>
|
||||
/// Value @ T0 in ADC
|
||||
/// </summary>
|
||||
public double T0ADC
|
||||
{
|
||||
get => _t0ADC;
|
||||
set => SetProperty(ref _t0ADC, value, "T0ADC");
|
||||
}
|
||||
private double _minMV = double.NaN;
|
||||
/// <summary>
|
||||
/// Minimum value in mV for entire dataset
|
||||
/// </summary>
|
||||
public double MinMV
|
||||
{
|
||||
get => _minMV;
|
||||
set => SetProperty(ref _minMV, value, "MinMV");
|
||||
}
|
||||
private double _maxMV = double.NaN;
|
||||
/// <summary>
|
||||
/// Maximum value in mV for entire dataset
|
||||
/// </summary>
|
||||
public double MaxMV
|
||||
{
|
||||
get => _maxMV;
|
||||
set => SetProperty(ref _maxMV, value, "MaxMV");
|
||||
}
|
||||
private double _aveMV = double.NaN;
|
||||
/// <summary>
|
||||
/// average value in mV for entire dataset
|
||||
/// </summary>
|
||||
public double AveMV
|
||||
{
|
||||
get => _aveMV;
|
||||
set => SetProperty(ref _aveMV, value, "AveMV");
|
||||
}
|
||||
private double _stdDevMV = double.NaN;
|
||||
/// <summary>
|
||||
/// std dev in mV for entire dataset
|
||||
/// </summary>
|
||||
public double StdDevMV
|
||||
{
|
||||
get => _stdDevMV;
|
||||
set => SetProperty(ref _stdDevMV, value, "StdDevMV");
|
||||
}
|
||||
private double _t0MV = double.NaN;
|
||||
/// <summary>
|
||||
/// value in mV at T0
|
||||
/// </summary>
|
||||
public double T0MV
|
||||
{
|
||||
get => _t0MV;
|
||||
set => SetProperty(ref _t0MV, value, "T0MV");
|
||||
}
|
||||
|
||||
private double _minEU = double.NaN;
|
||||
/// <summary>
|
||||
/// minimum value in EU for entire dataset
|
||||
/// </summary>
|
||||
public double MinEU
|
||||
{
|
||||
get => _minEU;
|
||||
set => SetProperty(ref _minEU, value, "MinEU");
|
||||
}
|
||||
private double _maxEU = double.NaN;
|
||||
/// <summary>
|
||||
/// maximum value in EU for entire dataset
|
||||
/// </summary>
|
||||
public double MaxEU
|
||||
{
|
||||
get => _maxEU;
|
||||
set => SetProperty(ref _maxEU, value, "MaxEU");
|
||||
}
|
||||
private double _aveEU = double.NaN;
|
||||
/// <summary>
|
||||
/// average value in EU for entire dataset
|
||||
/// </summary>
|
||||
public double AveEU
|
||||
{
|
||||
get => _aveEU;
|
||||
set => SetProperty(ref _aveEU, value, "AveEU");
|
||||
}
|
||||
private double _stdDevEU = double.NaN;
|
||||
/// <summary>
|
||||
/// std dev in EU
|
||||
/// </summary>
|
||||
public double StdDevEU
|
||||
{
|
||||
get => _stdDevEU;
|
||||
set => SetProperty(ref _stdDevEU, value, "StdDevEU");
|
||||
}
|
||||
private double _t0EU = double.NaN;
|
||||
/// <summary>
|
||||
/// value at T0 in EU
|
||||
/// </summary>
|
||||
public double T0EU
|
||||
{
|
||||
get => _t0EU;
|
||||
set => SetProperty(ref _t0EU, value, "T0EU");
|
||||
}
|
||||
|
||||
private double _minY = double.NaN;
|
||||
/// <summary>
|
||||
/// minimum value for whatever current units are for entire dataset
|
||||
/// </summary>
|
||||
public double MinY
|
||||
{
|
||||
get => _minY;
|
||||
set => SetProperty(ref _minY, value, "MinY");
|
||||
}
|
||||
private double _maxY = double.NaN;
|
||||
/// <summary>
|
||||
/// maximum value for whatever current units are for entire dataset
|
||||
/// </summary>
|
||||
public double MaxY
|
||||
{
|
||||
get => _maxY;
|
||||
set => SetProperty(ref _maxY, value, "MaxY");
|
||||
}
|
||||
private double _aveY = double.NaN;
|
||||
/// <summary>
|
||||
/// average value for whatever current units are for entire dataset
|
||||
/// </summary>
|
||||
public double AveY
|
||||
{
|
||||
get => _aveY;
|
||||
set => SetProperty(ref _aveY, value, "AveY");
|
||||
}
|
||||
private double _stdDevY = double.NaN;
|
||||
/// <summary>
|
||||
/// std deviation for whatever current units are
|
||||
/// </summary>
|
||||
public double StdDevY
|
||||
{
|
||||
get => _stdDevY;
|
||||
set => SetProperty(ref _stdDevY, value, "StdDevY");
|
||||
}
|
||||
|
||||
private double _T0Value = double.NaN;
|
||||
/// <summary>
|
||||
/// Value at T0 in whatever current units are
|
||||
/// </summary>
|
||||
public double T0Value
|
||||
{
|
||||
get => _T0Value;
|
||||
set => SetProperty(ref _T0Value, value, "T0Value");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
using System.Collections.Generic;
|
||||
using DTS.Common.Interface;
|
||||
// ReSharper disable CheckNamespace
|
||||
|
||||
namespace DTS.Common.Classes.Viewer.TestMetadata
|
||||
{
|
||||
public class TestGraphs: ITestGraphs
|
||||
{
|
||||
public string Name { get; set; }
|
||||
public string HardwareChannelName { get; set; }
|
||||
public List<string> ChannelIds { get; set; }
|
||||
public List<ITestChannel> Channels { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
using DTS.Common.Interface;
|
||||
using DTS.Common.Interface.TestDefinition;
|
||||
// ReSharper disable CheckNamespace
|
||||
|
||||
namespace DTS.Common.Classes.Viewer.TestMetadata
|
||||
{
|
||||
public class TestMetadata: ITestMetadata
|
||||
{
|
||||
public ITestRunMetadata TestRun { get; set; }
|
||||
public ITestSetupMetadata TestSetup { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,684 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.ObjectModel;
|
||||
using System.Globalization;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using System.Xml.Linq;
|
||||
using DTS.Common.Base;
|
||||
using DTS.Common.Enums.Sensors;
|
||||
using DTS.Common.Enums.Viewer;
|
||||
using DTS.Common.Interface;
|
||||
using DTS.Common.Interface.TestDefinition;
|
||||
using DTS.Common.Utilities;
|
||||
using DTS.Common.Utils;
|
||||
using DTS.Common.XMLUtils;
|
||||
using Microsoft.Practices.Prism.Events;
|
||||
using Microsoft.Practices.ServiceLocation;
|
||||
// ReSharper disable UnusedVariable
|
||||
// ReSharper disable UnusedMember.Local
|
||||
// ReSharper disable SuggestBaseTypeForParameter
|
||||
// ReSharper disable RedundantAssignment
|
||||
// ReSharper disable CheckNamespace
|
||||
|
||||
namespace DTS.Common.Classes.Viewer.TestMetadata
|
||||
{
|
||||
public class TestMetadataList
|
||||
{
|
||||
#pragma warning disable 1998
|
||||
public async Task<ObservableCollection<ITestSummary>> GetTestSummaryListAsync(IBaseViewModel parent, string path, string file, string pattern = "")
|
||||
#pragma warning restore 1998
|
||||
{
|
||||
return GetTestSummaryList(parent, path, file, pattern);
|
||||
}
|
||||
public ObservableCollection<ITestSummary> GetTestSummaryList(IBaseViewModel parent, string path, string file = "", string pattern = "")
|
||||
{
|
||||
return new ObservableCollection<ITestSummary>(BuildITestSummary(GetTestMetadataList(TestMetadataXml.GetTestMetadataXml(path, file, string.IsNullOrEmpty(pattern) ? ".dts" : pattern), path, file), parent));
|
||||
}
|
||||
public ObservableCollection<ITestSummary> GetTestSummaryList(string path, string file = "", string pattern = "")
|
||||
{
|
||||
return new ObservableCollection<ITestSummary>(BuildITestSummary(GetTestMetadataList(TestMetadataXml.GetTestMetadataXml(path, file, string.IsNullOrEmpty(pattern) ? ".dts" : pattern), path, file)));
|
||||
}
|
||||
private static string ParseEventNumber(string path)
|
||||
{
|
||||
var segments = path.Split('\\');
|
||||
return segments.FirstOrDefault(p => p.StartsWith($"{DTS.Common.Constants.EventNumber}"));
|
||||
}
|
||||
private static List<ITestSummary> BuildITestSummary(IEnumerable<ITestMetadata> metadata, IBaseViewModel parent)
|
||||
{
|
||||
List<ITestSummary> ts;
|
||||
try
|
||||
{
|
||||
ts = metadata.Select(md => new TestSummary
|
||||
{
|
||||
TestMetadata = md,
|
||||
SetupName = md.TestSetup.SetupName,
|
||||
Id = md.TestRun.Id + ParseEventNumber(md.TestRun.FilePath),
|
||||
Description = md.TestRun.Description,
|
||||
FileDate = md.TestRun.FileDate,
|
||||
TimeStamp = GetTimestamp(md),
|
||||
ChannelCount = md.TestRun.Channels.Count,
|
||||
DataType = md.TestRun.DataType,
|
||||
IsSelected = false,
|
||||
Parent = parent,
|
||||
Graphs = md.TestSetup.TestGraphs,
|
||||
Channels = md.TestRun.Channels,
|
||||
CalculatedChannels = md.TestRun.CalculatedChannels,
|
||||
CalibrationBehavior = md.TestSetup.CalibrationBehavior
|
||||
}).Cast<ITestSummary>().OrderByDescending(x=> x.TimeStamp.Ticks).ToList();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
var error = ex.Message;
|
||||
ts = new List<ITestSummary>();
|
||||
}
|
||||
return ts;
|
||||
}
|
||||
//FB 29410 Get DateTime with milli seconds if the date is before 1/1/1990 then use the TimeStamp from testsetup
|
||||
private static DateTime GetTimestamp(ITestMetadata md)
|
||||
{
|
||||
var basemodules = md.TestRun.Modules.GroupBy(module => module.BaseSerialNumber).Select(group => group.First());
|
||||
|
||||
List<TestModuleTimeStamp> testModuleTimeStamps = new List<TestModuleTimeStamp>();
|
||||
foreach (var module in basemodules)
|
||||
{
|
||||
TestModuleTimeStamp testModuleTimeStamp =
|
||||
new TestModuleTimeStamp { TriggerTimestampSec = module.TriggerTimestampSec, TriggerTimestampNanoSec = module.TriggerTimestampNanoSec };
|
||||
|
||||
testModuleTimeStamps.Add(testModuleTimeStamp);
|
||||
}
|
||||
|
||||
var tuplesTime = TestUtils.MinUnixTime(testModuleTimeStamps);
|
||||
if (null != tuplesTime && PTP1588Timestamps.IsValidTimeStamp(tuplesTime.Item1))
|
||||
{
|
||||
var time = PTP1588Timestamps.UnixTimeStampToDateTimeLocal(tuplesTime.Item1);
|
||||
double ticks = tuplesTime.Item2 / 100.00;
|
||||
var timeWithTicks = time.AddTicks((long)ticks);
|
||||
return timeWithTicks;
|
||||
}
|
||||
|
||||
return md.TestSetup.TimeStamp;
|
||||
}
|
||||
|
||||
private static List<ITestSummary> BuildITestSummary(IEnumerable<ITestMetadata> metadata)
|
||||
{
|
||||
List<ITestSummary> ts;
|
||||
try
|
||||
{
|
||||
ts = metadata.Select(md => new TestSummary
|
||||
{
|
||||
TestMetadata = md,
|
||||
SetupName = md.TestSetup.SetupName,
|
||||
Id = md.TestRun.Id + ParseEventNumber(md.TestRun.FilePath),
|
||||
Description = md.TestRun.Description,
|
||||
FileDate = md.TestRun.FileDate,
|
||||
TimeStamp = GetTimestamp(md),
|
||||
ChannelCount = md.TestRun.Channels.Count,
|
||||
DataType = md.TestRun.DataType,
|
||||
IsSelected = false,
|
||||
//Parent = parent,
|
||||
Graphs = md.TestSetup.TestGraphs,
|
||||
Channels = md.TestRun.Channels,
|
||||
CalculatedChannels = md.TestRun.CalculatedChannels,
|
||||
CalibrationBehavior = md.TestSetup.CalibrationBehavior
|
||||
}).Cast<ITestSummary>().OrderByDescending(x => x.TimeStamp.Ticks).ToList();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
var error = ex.Message;
|
||||
ts = new List<ITestSummary>();
|
||||
}
|
||||
return ts;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Return list of files
|
||||
/// </summary>
|
||||
/// <param name="xDoc">.dts file in xml format</param>
|
||||
/// <param name="path">.dts file path</param>
|
||||
/// <param name="file">.dts file name</param>
|
||||
/// <returns></returns>
|
||||
public List<ITestMetadata> GetTestMetadataList(XDocument xDoc, string path, string file)
|
||||
{
|
||||
List<ITestMetadata> tm;
|
||||
//keep track of any tests that fail to load and warn of them
|
||||
List<ITestMetadata> tmToRemove = new List<ITestMetadata>();
|
||||
try
|
||||
{
|
||||
tm = xDoc.Elements("Tests").Elements("TestMetadata")
|
||||
.Select(x => new TestMetadata
|
||||
{
|
||||
TestRun = GetTestRunMetadata(x),
|
||||
TestSetup = GetTestSetupMetadata(x)
|
||||
})
|
||||
.Cast<ITestMetadata>()
|
||||
.ToList();
|
||||
var errors = new List<string>();
|
||||
foreach (var testMetadata in tm)
|
||||
{
|
||||
|
||||
try
|
||||
{
|
||||
testMetadata.TestRun.Channels =
|
||||
new ITestChannel[testMetadata.TestRun.Modules.Select(x => x.NumberOfChannels).ToList()
|
||||
.Sum()].ToList();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
errors.Add($"Failed to load channels from {testMetadata.TestSetup.SetupName} - {ex.Message}");
|
||||
tmToRemove.Add(testMetadata);
|
||||
}
|
||||
}
|
||||
|
||||
if (errors.Any())
|
||||
{
|
||||
var eventAggregator = ServiceLocator.Current.GetInstance<IEventAggregator>();
|
||||
eventAggregator.GetEvent<Events.PageErrorEvent>()
|
||||
.Publish(new Events.PageErrorArg(errors.ToArray(), null));
|
||||
}
|
||||
|
||||
foreach (var metaData in tmToRemove)
|
||||
{
|
||||
tm.Remove(metaData);
|
||||
}
|
||||
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
var error = ex.Message;
|
||||
tm = new List<ITestMetadata>();
|
||||
}
|
||||
return tm;
|
||||
}
|
||||
|
||||
#region TestMetadata
|
||||
|
||||
private static DateTime GetDateTime(string dataString)
|
||||
{
|
||||
if (string.Equals("NOVALUE", dataString)) return DateTime.MinValue;
|
||||
return Convert.ToDateTime(dataString, CultureInfo.InvariantCulture);
|
||||
}
|
||||
|
||||
#region TestSetupMetadata
|
||||
/// <summary>
|
||||
/// Returns Test setup metadata
|
||||
/// </summary>
|
||||
/// <param name="x"></param>
|
||||
/// <returns></returns>
|
||||
private TestSetupMetadata GetTestSetupMetadata(XElement x)
|
||||
{
|
||||
|
||||
TestSetupMetadata ts;
|
||||
try
|
||||
{
|
||||
if (x.Element("TestSetup") != null)
|
||||
{
|
||||
ts = (from c in x.Descendants("TestSetup")
|
||||
select new TestSetupMetadata
|
||||
{
|
||||
SetupName = c.Element(TestSetupMetadataFields.Name.ToString())?.Value,
|
||||
TimeStamp = GetDateTime(c.Element(TestSetupMetadataFields.Timestamp.ToString())?.Value),
|
||||
TestGraphs = GetTestSetupGraphs(c.Element(TestSetupMetadataFields.Graphs.ToString())),
|
||||
CalibrationBehavior = (CalibrationBehaviors)Enum.Parse(typeof(CalibrationBehaviors), c.Element(TestSetupMetadataFields.CalibrationBehavior.ToString())?.Value ?? CalibrationBehaviors.NonLinearIfAvailable.ToString())
|
||||
}).FirstOrDefault();
|
||||
}
|
||||
else
|
||||
{
|
||||
ts = new TestSetupMetadata
|
||||
{
|
||||
SetupName = "N/A",
|
||||
TimeStamp = DateTime.MinValue,
|
||||
TestGraphs = new List<ITestGraphs>(),
|
||||
CalibrationBehavior = CalibrationBehaviors.NonLinearIfAvailable
|
||||
};
|
||||
}
|
||||
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
var error = ex.Message;
|
||||
ts = new TestSetupMetadata();
|
||||
}
|
||||
return ts;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns graphs
|
||||
/// </summary>
|
||||
/// <param name="xTestGraphs"></param>
|
||||
/// <returns></returns>
|
||||
private List<ITestGraphs> GetTestSetupGraphs(XElement xTestGraphs)
|
||||
{
|
||||
List<ITestGraphs> tg;
|
||||
try
|
||||
{
|
||||
tg = (from c in xTestGraphs.Descendants("Graph")
|
||||
select new TestGraphs
|
||||
{
|
||||
Name = c.Element(TestGraphsFields.Name.ToString())?.Value,
|
||||
HardwareChannelName = c.Element(TestGraphsFields.HardwareChannelName.ToString())?.Value,
|
||||
ChannelIds = GetChannelIds(c.Element(TestGraphsFields.Channels.ToString()))
|
||||
}).Cast<ITestGraphs>().ToList();
|
||||
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
var error = ex.Message;
|
||||
tg = new List<ITestGraphs>();
|
||||
}
|
||||
return tg;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns graph's list of ChannelIds
|
||||
/// </summary>
|
||||
/// <param name="xChannelIds"></param>
|
||||
/// <returns></returns>
|
||||
private List<string> GetChannelIds(XElement xChannelIds)
|
||||
{
|
||||
try
|
||||
{
|
||||
return (from c in xChannelIds.Descendants(TestGraphsFields.Channel.ToString()) select c.Element(TestGraphsFields.ChannelId.ToString())?.Value).ToList();
|
||||
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
var error = ex.Message;
|
||||
return new List<string>();
|
||||
}
|
||||
}
|
||||
|
||||
#endregion TestSetupMetadata
|
||||
|
||||
#region TestRunMetadata
|
||||
|
||||
/// <summary>
|
||||
/// returns TestRun Metadata
|
||||
/// </summary>
|
||||
/// <param name="x">DataPRO data folder</param>
|
||||
/// <returns></returns>
|
||||
private TestRunMetadata GetTestRunMetadata(XElement x)
|
||||
{
|
||||
TestRunMetadata td;
|
||||
try
|
||||
{
|
||||
td = (from c in x.Descendants("Test")
|
||||
select new TestRunMetadata
|
||||
{
|
||||
/* Name is id in DTS file, id is a file name */
|
||||
|
||||
Id = Path.GetFileNameWithoutExtension(c.Attribute(TestRunMetadataFields.FilePath.ToString())?.Value),
|
||||
Name = c.Attribute(TestRunMetadataFields.Id.ToString())?.Value,
|
||||
|
||||
Description = c.Attribute(TestRunMetadataFields.Description.ToString())?.Value,
|
||||
InlineSerializedData = ParseBoolean(c.Attribute(TestRunMetadataFields.InlineSerializedData.ToString())?.Value),
|
||||
TestGuid = c.Attribute(TestRunMetadataFields.Guid.ToString())?.Value,
|
||||
FaultFlags = ParseInt(c.Attribute(TestRunMetadataFields.FaultFlags.ToString())?.Value),
|
||||
Software = c.Attribute(TestRunMetadataFields.Software.ToString())?.Value,
|
||||
SoftwareVersion = c.Attribute(TestRunMetadataFields.SoftwareVersion.ToString())?.Value,
|
||||
DataType = c.Attribute(TestRunMetadataFields.DataType.ToString())?.Value,
|
||||
FilePath = c.Attribute(TestRunMetadataFields.FilePath.ToString())?.Value,
|
||||
FileDate = ParseDateTime(c.Attribute(TestRunMetadataFields.FileDate.ToString())?.Value),
|
||||
Modules = LoadTestModules(c.Element(TestRunMetadataFields.Modules.ToString()), c.Attribute(TestRunMetadataFields.Id.ToString())?.Value, Path.GetFileNameWithoutExtension(c.Attribute(TestRunMetadataFields.FilePath.ToString())?.Value)),
|
||||
//Channels = LoadTestChannels(c.Elements(TestRunMetadataFields.Modules.ToString()).Elements(TestRunMetadataFields.Module.ToString()).Elements(TestRunMetadataFields.Channels.ToString())),
|
||||
//CalculatedChannels = LoadTestCalculatedChannel(c.Elements(TestRunMetadataFields.Modules.ToString()).Elements(TestRunMetadataFields.Module.ToString()).Elements(TestRunMetadataFields.CalculatedChannels.ToString())),
|
||||
}).FirstOrDefault();
|
||||
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
var error = ex.Message;
|
||||
td = new TestRunMetadata();
|
||||
}
|
||||
return td;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns list of all Test Modules
|
||||
/// </summary>
|
||||
/// <param name="xTestModules">Modules xml node</param>
|
||||
/// <param name="testSetupName"></param>
|
||||
/// <param name="testId"></param>
|
||||
/// <returns></returns>
|
||||
private List<ITestModule> LoadTestModules(XElement xTestModules, string testSetupName, string testId)
|
||||
{
|
||||
List<ITestModule> tm;
|
||||
try
|
||||
{
|
||||
tm = (from m in xTestModules.Descendants("Module")
|
||||
select new TestModule
|
||||
{
|
||||
SerialNumber = m.Attribute(TestModuleFields.SerialNumber.ToString())?.Value,
|
||||
BaseSerialNumber = m.Attribute(TestModuleFields.BaseSerialNumber.ToString())?.Value,
|
||||
AaFilterRateHz = ParseInt(m.Attribute(TestModuleFields.AaFilterRateHz.ToString())?.Value),
|
||||
Number = ParseInt(m.Attribute(TestModuleFields.Number.ToString())?.Value),
|
||||
NumberOfSamples = ParseInt(m.Attribute(TestModuleFields.NumberOfSamples.ToString())?.Value),
|
||||
UnsubsampledNumberOfSamples = ParseInt(m.Attribute(TestModuleFields.UnsubsampledNumberOfSamples.ToString())?.Value),
|
||||
RequestedPostTriggerSeconds = ParseDouble(m.Attribute(TestModuleFields.RequestedPostTriggerSeconds.ToString())?.Value),
|
||||
RequestedPreTriggerSeconds = ParseDouble(m.Attribute(TestModuleFields.RequestedPreTriggerSeconds.ToString())?.Value),
|
||||
PostTriggerSeconds = ParseDouble(m.Attribute(TestModuleFields.PostTriggerSeconds.ToString())?.Value),
|
||||
PreTriggerSeconds = ParseDouble(m.Attribute(TestModuleFields.PreTriggerSeconds.ToString())?.Value),
|
||||
RecordingMode = m.Attribute(TestModuleFields.RecordingMode.ToString())?.Value,
|
||||
SampleRateHz = ParseInt(m.Attribute(TestModuleFields.SampleRateHz.ToString())?.Value),
|
||||
StartRecordSampleNumber = ParseInt(m.Attribute(TestModuleFields.StartRecordSampleNumber.ToString())?.Value),
|
||||
NumberOfChannels = ParseInt(m.Attribute(TestModuleFields.NumberOfChannels.ToString())?.Value),
|
||||
InlineSerializedData = ParseBoolean(m.Attribute(TestModuleFields.InlineSerializedData.ToString())?.Value),
|
||||
StartRecordTimestampSec = ParseInt(m.Attribute(TestModuleFields.StartRecordTimestampSec.ToString())?.Value),
|
||||
StartRecordTimestampNanoSec = ParseInt(m.Attribute(TestModuleFields.StartRecordTimestampNanoSec.ToString())?.Value),
|
||||
TriggerTimestampSec = ParseInt(m.Attribute(TestModuleFields.TriggerTimestampSec.ToString())?.Value),
|
||||
TriggerTimestampNanoSec = ParseInt(m.Attribute(TestModuleFields.TriggerTimestampNanoSec.ToString())?.Value),
|
||||
|
||||
TriggerSampleNumbers = LoadTriggerSampleNumbers(m.Elements("TriggerSampleNumbers")),
|
||||
|
||||
|
||||
PTPMasterSync = ParseBoolean(m.Attribute(TestModuleFields.PTPMasterSync.ToString())?.Value),
|
||||
TiltSensorAxisXDegreesPre = ParseInt(m.Attribute(TestModuleFields.TiltSensorAxisXDegreesPre.ToString())?.Value),
|
||||
TiltSensorAxisYDegreesPre = ParseInt(m.Attribute(TestModuleFields.TiltSensorAxisYDegreesPre.ToString())?.Value),
|
||||
TiltSensorAxisZDegreesPre = ParseInt(m.Attribute(TestModuleFields.TiltSensorAxisZDegreesPre.ToString())?.Value),
|
||||
TiltSensorAxisXDegreesPost = ParseInt(m.Attribute(TestModuleFields.TiltSensorAxisXDegreesPost.ToString())?.Value),
|
||||
TiltSensorAxisYDegreesPost = ParseInt(m.Attribute(TestModuleFields.TiltSensorAxisYDegreesPost.ToString())?.Value),
|
||||
TiltSensorAxisZDegreesPost = ParseInt(m.Attribute(TestModuleFields.TiltSensorAxisZDegreesPost.ToString())?.Value),
|
||||
TemperatureLocation1Pre = ParseInt(m.Attribute(TestModuleFields.TemperatureLocation1Pre.ToString())?.Value),
|
||||
TemperatureLocation2Pre = ParseInt(m.Attribute(TestModuleFields.TemperatureLocation2Pre.ToString())?.Value),
|
||||
TemperatureLocation3Pre = ParseInt(m.Attribute(TestModuleFields.TemperatureLocation3Pre.ToString())?.Value),
|
||||
TemperatureLocation4Pre = ParseInt(m.Attribute(TestModuleFields.TemperatureLocation4Pre.ToString())?.Value),
|
||||
TemperatureLocation1Post = ParseInt(m.Attribute(TestModuleFields.TemperatureLocation1Post.ToString())?.Value),
|
||||
TemperatureLocation2Post = ParseInt(m.Attribute(TestModuleFields.TemperatureLocation2Post.ToString())?.Value),
|
||||
TemperatureLocation3Post = ParseInt(m.Attribute(TestModuleFields.TemperatureLocation3Post.ToString())?.Value),
|
||||
TemperatureLocation4Post = ParseInt(m.Attribute(TestModuleFields.TemperatureLocation4Post.ToString())?.Value),
|
||||
Channels = LoadTestChannels(m.Elements("Channels"), m.Attribute(TestModuleFields.SerialNumber.ToString())?.Value, testSetupName, testId),
|
||||
CalculatedChannels = LoadTestCalculatedChannels(m.Elements("CalculatedChannels"), testSetupName, testId)
|
||||
}).Cast<ITestModule>().ToList();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
var error = ex.Message;
|
||||
tm = new List<ITestModule>();
|
||||
}
|
||||
return tm;
|
||||
}
|
||||
/// <summary>
|
||||
/// ?
|
||||
/// </summary>
|
||||
/// <param name="xTriggerSampleNumbers"></param>
|
||||
/// <returns></returns>
|
||||
// ReSharper disable once UnusedParameter.Local
|
||||
private List<ulong> LoadTriggerSampleNumbers(IEnumerable<XElement> xTriggerSampleNumbers)
|
||||
{
|
||||
return new List<ulong>();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns list (IEnumerable) of all test channels
|
||||
/// </summary>
|
||||
/// <param name="xTestChannels">Channels xml node</param>
|
||||
/// <param name="moduleId"></param>
|
||||
/// <param name="testSetupName"></param>
|
||||
/// <param name="testId"></param>
|
||||
/// <returns></returns>
|
||||
private List<ITestChannel> LoadTestChannels(IEnumerable<XElement> xTestChannels, string moduleId, string testSetupName, string testId)
|
||||
{
|
||||
List<ITestChannel> tc;
|
||||
try
|
||||
{
|
||||
tc = (from m in xTestChannels.Descendants("AnalogInputChanel")
|
||||
select new TestChannel
|
||||
{
|
||||
TestId = testId,
|
||||
TestSetupName = testSetupName,
|
||||
ModuleSerialNumber = moduleId,
|
||||
SerialNumber = m.Attribute(TestChannelFields.SerialNumber.ToString())?.Value,
|
||||
ChannelId = m.Attribute(TestChannelFields.ChannelId.ToString()) == null || ParseInt(m.Attribute(TestChannelFields.ChannelId.ToString())?.Value) == -1 ? m.GetHashCode().ToString() : m.Attribute(TestChannelFields.ChannelId.ToString())?.Value,
|
||||
Description = m.Attribute(TestChannelFields.Description.ToString())?.Value,
|
||||
ChannelType = m.Attribute(TestChannelFields.ChannelType.ToString())?.Value,
|
||||
Number = ParseInt(m.Attribute(TestChannelFields.Number.ToString())?.Value),
|
||||
DigitalMultiplier = m.Attribute(TestChannelFields.DigitalMultiplier.ToString())?.Value,
|
||||
DigitalMode = m.Attribute(TestChannelFields.DigitalMode.ToString())?.Value,
|
||||
Start = GetDateTime(m.Attribute(TestChannelFields.Start.ToString())?.Value),
|
||||
Bridge = m.Attribute(TestChannelFields.Bridge.ToString())?.Value,
|
||||
BridgeResistanceOhms = ParseDouble(m.Attribute(TestChannelFields.BridgeResistanceOhms.ToString())?.Value),
|
||||
ZeroPoint = ParseDouble(m.Attribute(TestChannelFields.ZeroPoint.ToString())?.Value),
|
||||
ChannelDescriptionString = m.Attribute(TestChannelFields.ChannelDescriptionString.ToString())?.Value,
|
||||
ChannelName2 = m.Attribute(TestChannelFields.ChannelName2.ToString())?.Value,
|
||||
HardwareChannelName = m.Attribute(TestChannelFields.HardwareChannelName.ToString())?.Value,
|
||||
DesiredRange = ParseDouble(m.Attribute(TestChannelFields.DesiredRange.ToString())?.Value),
|
||||
Sensitivity = ParseDouble(m.Attribute(TestChannelFields.Sensitivity.ToString())?.Value),
|
||||
SoftwareFilter = m.Attribute(TestChannelFields.SoftwareFilter.ToString())?.Value,
|
||||
ProportionalToExcitation = ParseBoolean(m.Attribute(TestChannelFields.ProportionalToExcitation.ToString())?.Value),
|
||||
IsInverted = ParseBoolean(m.Attribute(TestChannelFields.IsInverted.ToString())?.Value),
|
||||
LinearizationFormula = m.Attribute(TestChannelFields.LinearizationFormula.ToString())?.Value,
|
||||
IsSubsampled = ParseBoolean(m.Attribute(TestChannelFields.IsSubsampled.ToString())?.Value),
|
||||
AbsoluteDisplayOrder = ParseInt(m.Attribute(TestChannelFields.AbsoluteDisplayOrder.ToString())?.Value),
|
||||
LastCalibrationDate = GetDateTime(m.Attribute(TestChannelFields.LastCalibrationDate.ToString())?.Value),
|
||||
SensorId = m.Attribute(TestChannelFields.SensorId.ToString())?.Value,
|
||||
OffsetToleranceLowMv = ParseInt(m.Attribute(TestChannelFields.OffsetToleranceLowMv.ToString())?.Value),
|
||||
OffsetToleranceHighMv = ParseInt(m.Attribute(TestChannelFields.OffsetToleranceHighMv.ToString())?.Value),
|
||||
DataFlag = ParseInt(m.Attribute(TestChannelFields.DataFlag.ToString())?.Value),
|
||||
ExcitationVoltage = m.Attribute(TestChannelFields.ExcitationVoltage.ToString())?.Value,
|
||||
Eu = m.Attribute(TestChannelFields.Eu.ToString())?.Value,
|
||||
CalSignalEnabled = ParseBoolean(m.Attribute(TestChannelFields.CalSignalEnabled.ToString())?.Value),
|
||||
ShuntEnabled = ParseBoolean(m.Attribute(TestChannelFields.ShuntEnabled.ToString())?.Value),
|
||||
VoltageInsertionCheckEnabled = ParseBoolean(m.Attribute(TestChannelFields.VoltageInsertionCheckEnabled.ToString())?.Value),
|
||||
RemoveOffset = ParseBoolean(m.Attribute(TestChannelFields.RemoveOffset.ToString())?.Value),
|
||||
ZeroMethod = m.Attribute(TestChannelFields.ZeroMethod.ToString())?.Value,
|
||||
ZeroAverageWindowBegin = ParseDouble(m.Attribute(TestChannelFields.ZeroAverageWindowBegin.ToString())?.Value),
|
||||
ZeroAverageWindowEnd = ParseDouble(m.Attribute(TestChannelFields.ZeroAverageWindowEnd.ToString())?.Value),
|
||||
InitialEu = ParseInt(m.Attribute(TestChannelFields.InitialEu.ToString())?.Value),
|
||||
InitialOffset = m.Attribute(TestChannelFields.InitialOffset.ToString())?.Value,
|
||||
UnsubsampledSampleRateHz = ParseInt(m.Attribute(TestChannelFields.UnsubsampledSampleRateHz.ToString())?.Value),
|
||||
MeasuredShuntDeflectionMv = ParseDouble(m.Attribute(TestChannelFields.MeasuredShuntDeflectionMv.ToString())?.Value),
|
||||
TargetShuntDeflectionMv = ParseDouble(m.Attribute(TestChannelFields.TargetShuntDeflectionMv.ToString())?.Value),
|
||||
MeasuredExcitationVoltage = ParseDouble(m.Attribute(TestChannelFields.MeasuredExcitationVoltage.ToString())?.Value),
|
||||
FactoryExcitationVoltage = ParseDouble(m.Attribute(TestChannelFields.FactoryExcitationVoltage.ToString())?.Value),
|
||||
TimeOfFirstSample = ParseDouble(m.Attribute(TestChannelFields.TimeOfFirstSample.ToString())?.Value),
|
||||
Multiplier = m.Attribute(TestChannelFields.Multiplier.ToString()) == null ? 1 : ParseDouble(m.Attribute(TestChannelFields.Multiplier.ToString())?.Value),
|
||||
UserOffsetEu = ParseDouble(m.Attribute(TestChannelFields.UserOffsetEU.ToString())?.Value),
|
||||
UnitConversion = m.Attribute(TestChannelFields.UnitConversion.ToString()) == null ? 1 : ParseInt(m.Attribute(TestChannelFields.UnitConversion.ToString())?.Value),
|
||||
AtCapacity = ParseBoolean(m.Attribute(TestChannelFields.AtCapacity.ToString())?.Value),
|
||||
CapacityOutputIsBasedOn = ParseInt(m.Attribute(TestChannelFields.CapacityOutputIsBasedOn.ToString())?.Value),
|
||||
SensitivityUnits = m.Attribute(TestChannelFields.SensitivityUnits.ToString())?.Value,
|
||||
SensorCapacity = ParseInt(m.Attribute(TestChannelFields.SensorCapacity.ToString())?.Value),
|
||||
SensorPolarity = m.Attribute(TestChannelFields.SensorPolarity.ToString())?.Value,
|
||||
IsoCode = m.Attribute(TestChannelFields.IsoCode.ToString())?.Value ?? string.Empty,
|
||||
IsoChannelName = m.Attribute(TestChannelFields.IsoChannelName.ToString())?.Value ?? string.Empty,
|
||||
UserCode = m.Attribute(TestChannelFields.UserCode.ToString())?.Value ?? string.Empty,
|
||||
UserChannelName = m.Attribute(TestChannelFields.UserChannelName.ToString())?.Value ?? string.Empty,
|
||||
UseEUScaler = ParseBoolean(m.Attribute(TestChannelFields.UseEUScaler.ToString())?.Value),
|
||||
ScaleFactorEU = ParseDouble(m.Attribute(TestChannelFields.ScaleFactorEU.ToString())?.Value),
|
||||
}).Cast<ITestChannel>().ToList();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
var error = ex.Message;
|
||||
tc = new List<ITestChannel>();
|
||||
}
|
||||
return tc;
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Load Calculated Channels
|
||||
/// </summary>
|
||||
/// <param name="xTestCalculatedChannel"></param>
|
||||
/// <param name="testSetupName"></param>
|
||||
/// <param name="testId"></param>
|
||||
/// <returns></returns>
|
||||
private List<ITestChannel> LoadTestCalculatedChannels(IEnumerable<XElement> xTestCalculatedChannel, string testSetupName, string testId)
|
||||
{
|
||||
List<ITestChannel> list = new List<ITestChannel>();
|
||||
try
|
||||
{
|
||||
var calculatedChannelsPart = xTestCalculatedChannel.Descendants("CalculatedChannel");
|
||||
foreach (var m in calculatedChannelsPart)
|
||||
{
|
||||
var tc = new TestChannel()
|
||||
{
|
||||
TestId = testId,
|
||||
TestSetupName = testSetupName,
|
||||
IsCalculatedChannel = true,
|
||||
ChannelId =
|
||||
m.Attribute(TestChannelFields.ChannelId.ToString()) == null ||
|
||||
ParseInt(m.Attribute(TestChannelFields.ChannelId.ToString())?.Value) == -1
|
||||
? m.GetHashCode().ToString()
|
||||
: m.Attribute(TestChannelFields.ChannelId.ToString())?.Value,
|
||||
//37943, wipe info for calculated channels that's just the first channel's info
|
||||
SerialNumber = Strings.Strings.Table_NA,
|
||||
Description = m.Attribute(TestChannelFields.Description.ToString())?.Value,
|
||||
ChannelType = m.Attribute(TestChannelFields.ChannelType.ToString())?.Value,
|
||||
Number = ParseInt(m.Attribute(TestChannelFields.Number.ToString())?.Value),
|
||||
DigitalMultiplier = m.Attribute(TestChannelFields.DigitalMultiplier.ToString())?.Value,
|
||||
DigitalMode = m.Attribute(TestChannelFields.DigitalMode.ToString())?.Value,
|
||||
Start = GetDateTime(m.Attribute(TestChannelFields.Start.ToString())?.Value),
|
||||
Bridge = m.Attribute(TestChannelFields.Bridge.ToString())?.Value,
|
||||
BridgeResistanceOhms =
|
||||
ParseDouble(m.Attribute(TestChannelFields.BridgeResistanceOhms.ToString())?.Value),
|
||||
ChannelDescriptionString =
|
||||
m.Attribute(TestChannelFields.ChannelDescriptionString.ToString())?.Value,
|
||||
ChannelName2 = m.Attribute(TestChannelFields.ChannelName2.ToString())?.Value,
|
||||
HardwareChannelName = Strings.Strings.Table_NA,
|
||||
DesiredRange = ParseDouble(m.Attribute(TestChannelFields.DesiredRange.ToString())?.Value),
|
||||
Sensitivity = ParseDouble(m.Attribute(TestChannelFields.Sensitivity.ToString())?.Value),
|
||||
SoftwareFilter = m.Attribute(TestChannelFields.SoftwareFilter.ToString())?.Value,
|
||||
ProportionalToExcitation =
|
||||
ParseBoolean(m.Attribute(TestChannelFields.ProportionalToExcitation.ToString())?.Value),
|
||||
IsInverted = ParseBoolean(m.Attribute(TestChannelFields.IsInverted.ToString())?.Value),
|
||||
LinearizationFormula = m.Attribute(TestChannelFields.LinearizationFormula.ToString())?.Value,
|
||||
IsSubsampled = ParseBoolean(m.Attribute(TestChannelFields.IsSubsampled.ToString())?.Value),
|
||||
AbsoluteDisplayOrder =
|
||||
ParseInt(m.Attribute(TestChannelFields.AbsoluteDisplayOrder.ToString())?.Value),
|
||||
LastCalibrationDate =
|
||||
GetDateTime(m.Attribute(TestChannelFields.LastCalibrationDate.ToString())?.Value),
|
||||
SensorId = m.Attribute(TestChannelFields.SensorId.ToString())?.Value,
|
||||
OffsetToleranceLowMv =
|
||||
ParseInt(m.Attribute(TestChannelFields.OffsetToleranceLowMv.ToString())?.Value),
|
||||
OffsetToleranceHighMv =
|
||||
ParseInt(m.Attribute(TestChannelFields.OffsetToleranceHighMv.ToString())?.Value),
|
||||
DataFlag = ParseInt(m.Attribute(TestChannelFields.DataFlag.ToString())?.Value),
|
||||
ExcitationVoltage = m.Attribute(TestChannelFields.ExcitationVoltage.ToString())?.Value,
|
||||
Eu = m.Attribute(TestChannelFields.Eu.ToString())?.Value,
|
||||
CalSignalEnabled =
|
||||
ParseBoolean(m.Attribute(TestChannelFields.CalSignalEnabled.ToString())?.Value),
|
||||
ShuntEnabled = ParseBoolean(m.Attribute(TestChannelFields.ShuntEnabled.ToString())?.Value),
|
||||
VoltageInsertionCheckEnabled =
|
||||
ParseBoolean(m.Attribute(TestChannelFields.VoltageInsertionCheckEnabled.ToString())?.Value),
|
||||
RemoveOffset = ParseBoolean(m.Attribute(TestChannelFields.RemoveOffset.ToString())?.Value),
|
||||
ZeroMethod = m.Attribute(TestChannelFields.ZeroMethod.ToString())?.Value,
|
||||
ZeroAverageWindowBegin =
|
||||
ParseDouble(m.Attribute(TestChannelFields.ZeroAverageWindowBegin.ToString())?.Value),
|
||||
ZeroAverageWindowEnd =
|
||||
ParseDouble(m.Attribute(TestChannelFields.ZeroAverageWindowEnd.ToString())?.Value),
|
||||
InitialEu = ParseInt(m.Attribute(TestChannelFields.InitialEu.ToString())?.Value),
|
||||
InitialOffset = m.Attribute(TestChannelFields.InitialOffset.ToString())?.Value,
|
||||
UnsubsampledSampleRateHz =
|
||||
ParseInt(m.Attribute(TestChannelFields.UnsubsampledSampleRateHz.ToString())?.Value),
|
||||
MeasuredShuntDeflectionMv =
|
||||
ParseDouble(m.Attribute(TestChannelFields.MeasuredShuntDeflectionMv.ToString())?.Value),
|
||||
MeasuredExcitationVoltage =
|
||||
ParseDouble(m.Attribute(TestChannelFields.MeasuredExcitationVoltage.ToString())?.Value),
|
||||
|
||||
FactoryExcitationVoltage =
|
||||
ParseInt(m.Attribute(TestChannelFields.UnsubsampledSampleRateHz.ToString())?.Value),
|
||||
TimeOfFirstSample =
|
||||
ParseDouble(m.Attribute(TestChannelFields.MeasuredShuntDeflectionMv.ToString())?.Value),
|
||||
|
||||
Multiplier = m.Attribute(TestChannelFields.Multiplier.ToString()) == null
|
||||
? 1
|
||||
: ParseDouble(m.Attribute(TestChannelFields.Multiplier.ToString())?.Value),
|
||||
UserOffsetEu = ParseDouble(m.Attribute(TestChannelFields.UserOffsetEU.ToString())?.Value),
|
||||
UnitConversion = m.Attribute(TestChannelFields.UnitConversion.ToString()) == null
|
||||
? 1
|
||||
: ParseInt(m.Attribute(TestChannelFields.UnitConversion.ToString())?.Value),
|
||||
AtCapacity = ParseBoolean(m.Attribute(TestChannelFields.AtCapacity.ToString())?.Value),
|
||||
CapacityOutputIsBasedOn =
|
||||
ParseInt(m.Attribute(TestChannelFields.CapacityOutputIsBasedOn.ToString())?.Value),
|
||||
|
||||
SourceChannelNumber = m.Attribute(TestChannelFields.SourceChannelNumber.ToString())?.Value,
|
||||
SourceModuleNumber = m.Attribute(TestChannelFields.SourceModuleNumber.ToString())?.Value,
|
||||
SourceModuleSerialNumber =
|
||||
m.Attribute(TestChannelFields.SourceModuleSerialNumber.ToString())?.Value,
|
||||
Calculation = m.Attribute(TestChannelFields.Calculation.ToString())?.Value,
|
||||
SampleRateHz = ParseInt(m.Attribute(TestChannelFields.SampleRateHz.ToString())?.Value),
|
||||
//37943, wipe info for calculated channels that's just the first channel's info
|
||||
IsoCode = Strings.Strings.Table_NA,
|
||||
//37943, wipe info for calculated channels that's just the first channel's info
|
||||
IsoChannelName = Strings.Strings.Table_NA,
|
||||
//37943, wipe info for calculated channels that's just the first channel's info
|
||||
UserCode = Strings.Strings.Table_NA,
|
||||
//37943, wipe info for calculated channels that's just the first channel's info
|
||||
UserChannelName = Strings.Strings.Table_NA,
|
||||
UseEUScaler = ParseBoolean(m.Attribute(TestChannelFields.UseEUScaler.ToString())?.Value),
|
||||
ScaleFactorEU = ParseDouble(m.Attribute(TestChannelFields.ScaleFactorEU.ToString())?.Value),
|
||||
};
|
||||
var hic = m.Attribute("HIC");
|
||||
if (null != hic)
|
||||
{
|
||||
if (double.TryParse(hic.Value, out var d))
|
||||
{
|
||||
tc.HIC = d;
|
||||
tc.T1Sample = ulong.Parse(m.Attribute("T1").Value);
|
||||
tc.T2Sample = ulong.Parse(m.Attribute("T2").Value);
|
||||
}
|
||||
}
|
||||
|
||||
list.Add(tc);
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
var error = ex.Message;
|
||||
list = new List<ITestChannel>();
|
||||
}
|
||||
return list;
|
||||
}
|
||||
#endregion TestRunMetadata
|
||||
|
||||
#endregion TestMetadata
|
||||
|
||||
#region Support functions
|
||||
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Safer way to parse
|
||||
/// </summary>
|
||||
/// <param name="param"></param>
|
||||
/// <returns></returns>
|
||||
private int ParseInt(string param)
|
||||
{
|
||||
var result = 0;
|
||||
int.TryParse(param, out result);
|
||||
return result;
|
||||
}
|
||||
/// <summary>
|
||||
/// Safer way to parse
|
||||
/// </summary>
|
||||
/// <param name="param"></param>
|
||||
/// <returns></returns>
|
||||
private double ParseDouble(string param)
|
||||
{
|
||||
double.TryParse(param, NumberStyles.Any, CultureInfo.InvariantCulture, out var result);
|
||||
return result;
|
||||
}
|
||||
/// <summary>
|
||||
/// Safer way to parse
|
||||
/// </summary>
|
||||
/// <param name="param"></param>
|
||||
/// <returns></returns>
|
||||
private bool ParseBoolean(string param)
|
||||
{
|
||||
bool.TryParse(param, out var result);
|
||||
return result;
|
||||
}
|
||||
|
||||
private DateTime ParseDateTime(string param)
|
||||
{
|
||||
DateTime.TryParse(param, out var result);
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
|
||||
#endregion Support functions
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,57 @@
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Runtime.CompilerServices;
|
||||
using DTS.Common.Interface;
|
||||
// ReSharper disable CheckNamespace
|
||||
|
||||
namespace DTS.Common.Classes.Viewer.TestMetadata
|
||||
{
|
||||
public class TestModule : ITestModule
|
||||
{
|
||||
public string SerialNumber { get; set; }
|
||||
public string BaseSerialNumber { get; set; }
|
||||
public int AaFilterRateHz { get; set; }
|
||||
public int Number { get; set; }
|
||||
public int NumberOfSamples { get; set; }
|
||||
public int UnsubsampledNumberOfSamples { get; set; }
|
||||
public double RequestedPostTriggerSeconds { get; set; }
|
||||
public double RequestedPreTriggerSeconds { get; set; }
|
||||
public double PostTriggerSeconds { get; set; }
|
||||
public double PreTriggerSeconds { get; set; }
|
||||
public string RecordingMode { get; set; }
|
||||
public int SampleRateHz { get; set; }
|
||||
public int StartRecordSampleNumber { get; set; }
|
||||
public int NumberOfChannels { get; set; }
|
||||
public bool InlineSerializedData { get; set; }
|
||||
public int StartRecordTimestampSec { get; set; }
|
||||
public int StartRecordTimestampNanoSec { get; set; }
|
||||
public int TriggerTimestampSec { get; set; }
|
||||
public int TriggerTimestampNanoSec { get; set; }
|
||||
public List<ulong> TriggerSampleNumbers { get; set; }
|
||||
public bool PTPMasterSync { get; set; }
|
||||
public int TiltSensorAxisXDegreesPre { get; set; }
|
||||
public int TiltSensorAxisYDegreesPre { get; set; }
|
||||
public int TiltSensorAxisZDegreesPre { get; set; }
|
||||
public int TiltSensorAxisXDegreesPost { get; set; }
|
||||
public int TiltSensorAxisYDegreesPost { get; set; }
|
||||
public int TiltSensorAxisZDegreesPost { get; set; }
|
||||
public int TemperatureLocation1Pre { get; set; }
|
||||
public int TemperatureLocation2Pre { get; set; }
|
||||
public int TemperatureLocation3Pre { get; set; }
|
||||
public int TemperatureLocation4Pre { get; set; }
|
||||
public int TemperatureLocation1Post { get; set; }
|
||||
public int TemperatureLocation2Post { get; set; }
|
||||
public int TemperatureLocation3Post { get; set; }
|
||||
public int TemperatureLocation4Post { get; set; }
|
||||
public List<ITestChannel> Channels { get; set; }
|
||||
public List<ITestChannel> CalculatedChannels { get; set; }
|
||||
public bool IsSelected { get; set; }
|
||||
|
||||
public event PropertyChangedEventHandler PropertyChanged;
|
||||
|
||||
protected virtual void OnPropertyChanged([CallerMemberName] string propertyName = null)
|
||||
{
|
||||
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,34 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Runtime.CompilerServices;
|
||||
using DTS.Common.Interface;
|
||||
// ReSharper disable CheckNamespace
|
||||
|
||||
namespace DTS.Common.Classes.Viewer.TestMetadata
|
||||
{
|
||||
public class TestRunMetadata : ITestRunMetadata
|
||||
{
|
||||
public string Name { get; set; }
|
||||
public string Id { get; set; }
|
||||
public string Description { get; set; }
|
||||
public bool InlineSerializedData { get; set; }
|
||||
public string TestGuid { get; set; }
|
||||
public int FaultFlags { get; set; }
|
||||
public string Software { get; set; }
|
||||
public string SoftwareVersion { get; set; }
|
||||
public string DataType { get; set; }
|
||||
public DateTime FileDate { get; set; }
|
||||
public string FilePath { get; set; }
|
||||
public List<ITestModule> Modules { get; set; }
|
||||
public List<ITestChannel> Channels { get; set; }
|
||||
public List<ITestChannel> CalculatedChannels { get; set; }
|
||||
public bool IsSelected { get; set; }
|
||||
|
||||
public event PropertyChangedEventHandler PropertyChanged;
|
||||
protected virtual void OnPropertyChanged([CallerMemberName] string propertyName = null)
|
||||
{
|
||||
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using DTS.Common.Enums.Sensors;
|
||||
using DTS.Common.Interface;
|
||||
// ReSharper disable CheckNamespace
|
||||
|
||||
namespace DTS.Common.Classes.Viewer.TestMetadata
|
||||
{
|
||||
public class TestSetupMetadata : ITestSetupMetadata
|
||||
{
|
||||
public string SetupName { get; set; }
|
||||
public DateTime TimeStamp { get; set; }
|
||||
public List<ITestGraphs> TestGraphs { get; set; }
|
||||
public CalibrationBehaviors CalibrationBehavior { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,72 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using DTS.Common.Base;
|
||||
using DTS.Common.Enums.Sensors;
|
||||
using DTS.Common.Interface;
|
||||
using DTS.Common.Interface.TestDefinition;
|
||||
using Microsoft.Practices.Prism.Commands;
|
||||
// ReSharper disable CheckNamespace
|
||||
// ReSharper disable RedundantDefaultMemberInitializer
|
||||
|
||||
namespace DTS.Common.Classes.Viewer.TestMetadata
|
||||
{
|
||||
public class TestSummary : ITestSummary
|
||||
{
|
||||
/// <summary>
|
||||
/// the _ROI Period x folder name if present
|
||||
/// 18411 Data will not export [CSV Unfiltered]
|
||||
/// </summary>
|
||||
public const string ROI_SUFFIX = @"_ROI Period";
|
||||
public string Id { get; set; }
|
||||
public string SetupName { get; set; }
|
||||
public string Description { get; set; }
|
||||
public int ChannelCount { get; set; }
|
||||
public DateTime FileDate { get; set; }
|
||||
public DateTime TimeStamp { get; set; }
|
||||
public string DataType { get; set; }
|
||||
private bool _isSelected = false;
|
||||
public bool IsSelected { get => _isSelected; set { if (value != IsSelected) { _isSelected = value; SelectionChanged(); OnPropertyChanged("IsSelected"); } } }
|
||||
public List<ITestGraphs> Graphs { get; set; }
|
||||
public List<ITestChannel> Channels { get; set; }
|
||||
public List<ITestChannel> CalculatedChannels { get; set; }
|
||||
public IBaseViewModel Parent { get; set; }
|
||||
public CalibrationBehaviors CalibrationBehavior { get; set; } = CalibrationBehaviors.NonLinearIfAvailable;
|
||||
public ITestMetadata TestMetadata { get; set; }
|
||||
|
||||
#region Commands
|
||||
|
||||
private DelegateCommand _isSelectedCommand;
|
||||
public DelegateCommand IsSelectedCommand
|
||||
{
|
||||
get => _isSelectedCommand ?? (_isSelectedCommand = new DelegateCommand(SelectionChanged));
|
||||
set => _isSelectedCommand = value;
|
||||
}
|
||||
public void SelectionChanged()
|
||||
{
|
||||
var parent = (ITestSummaryListViewModel) Parent;
|
||||
|
||||
if (parent == null) return;
|
||||
|
||||
var list = parent.SelectedTestSummaryList;
|
||||
|
||||
if (IsSelected) { if (!list.Contains(this)) list.Add(this); }
|
||||
else { if (list.Contains(this)) list.Remove(this); }
|
||||
|
||||
parent.PublishSelectedTestSummaryList();
|
||||
|
||||
}
|
||||
#endregion Commands
|
||||
|
||||
///<summary>
|
||||
///Occurs when a property value changes.
|
||||
///</summary>
|
||||
public event PropertyChangedEventHandler PropertyChanged;
|
||||
|
||||
public void OnPropertyChanged(string propertyName)
|
||||
{
|
||||
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user