init
This commit is contained in:
149
Common/DTS.Common/Classes/TestSetups/CalculatedChannelRecord.cs
Normal file
149
Common/DTS.Common/Classes/TestSetups/CalculatedChannelRecord.cs
Normal file
@@ -0,0 +1,149 @@
|
||||
using DTS.Common.Base;
|
||||
using DTS.Common.Interface.TestSetups;
|
||||
using System.Data;
|
||||
using System.Globalization;
|
||||
using System.Linq;
|
||||
|
||||
namespace DTS.Common.Classes.TestSetups
|
||||
{
|
||||
/// <summary>
|
||||
/// describes Calculated Channel record in the db
|
||||
/// <inheritdoc cref="ICalculatedChannelRecord"/>
|
||||
/// </summary>
|
||||
public class CalculatedChannelRecord : BasePropertyChanged, ICalculatedChannelRecord
|
||||
{
|
||||
private string _name = "";
|
||||
public string Name
|
||||
{
|
||||
get => _name;
|
||||
set => SetProperty(ref _name, value, "Name");
|
||||
}
|
||||
|
||||
private string _testSetupName = "";
|
||||
public string TestSetupName
|
||||
{
|
||||
get => _testSetupName;
|
||||
set => SetProperty(ref _testSetupName, value, "TestSetupName");
|
||||
}
|
||||
|
||||
private int _id = -1;
|
||||
/// <summary>
|
||||
/// Database Id for record
|
||||
/// </summary>
|
||||
public int Id
|
||||
{
|
||||
get => _id;
|
||||
set => SetProperty(ref _id, value, "Id");
|
||||
}
|
||||
|
||||
private Operations _operation = Operations.SUM;
|
||||
/// <summary>
|
||||
/// operation to apply to input channels
|
||||
/// </summary>
|
||||
public Operations Operation
|
||||
{
|
||||
get => _operation;
|
||||
set => SetProperty(ref _operation, value, "Operation");
|
||||
}
|
||||
private string _calculatedChannelValueCode = "";
|
||||
/// <summary>
|
||||
/// Single code (ISO or user) to associate with calculated channel
|
||||
/// </summary>
|
||||
public string CalculatedValueCode
|
||||
{
|
||||
get => _calculatedChannelValueCode;
|
||||
set => SetProperty(ref _calculatedChannelValueCode, value, "CalculatedValueCode");
|
||||
}
|
||||
|
||||
protected string[] _inputChannelIds = new[] { "-1" };
|
||||
/// <summary>
|
||||
/// CSV separated list of channel ids that are inputs for the calculation
|
||||
/// </summary>
|
||||
public string[] InputChannelIds
|
||||
{
|
||||
get => _inputChannelIds;
|
||||
set => SetProperty(ref _inputChannelIds, value, "InputChannelIds");
|
||||
}
|
||||
private string _cfcForInputChannels = "";
|
||||
/// <summary>
|
||||
/// CFC to apply to input channels prior to calculation
|
||||
/// </summary>
|
||||
public string CFCForInputChannels
|
||||
{
|
||||
get => _cfcForInputChannels;
|
||||
set => SetProperty(ref _cfcForInputChannels, value, "CFCForInputChannels");
|
||||
}
|
||||
private string _cfcForOutput = "";
|
||||
/// <summary>
|
||||
/// CFC to apply to output of calculation
|
||||
/// </summary>
|
||||
public string ChannelFilterClassForOutput
|
||||
{
|
||||
get => _cfcForOutput;
|
||||
set => SetProperty(ref _cfcForOutput, value, "ChannelFilterClassForOutput");
|
||||
}
|
||||
private int _testSetupId;
|
||||
/// <summary>
|
||||
/// Database Id for test setup record
|
||||
/// </summary>
|
||||
public int TestSetupId
|
||||
{
|
||||
get => _testSetupId;
|
||||
set => SetProperty(ref _testSetupId, value, "TestSetupId");
|
||||
}
|
||||
private bool _viewInRealtime;
|
||||
/// <summary>
|
||||
/// Whether channel can be viewed in realtime or not
|
||||
/// </summary>
|
||||
public bool ViewInRealtime
|
||||
{
|
||||
get => _viewInRealtime;
|
||||
set => SetProperty(ref _viewInRealtime, value, "ViewInRealtime");
|
||||
}
|
||||
private int _clipLength;
|
||||
/// <summary>
|
||||
/// Clip length to apply to calculation if relevant
|
||||
/// some calculations are a max over an clip for example
|
||||
/// </summary>
|
||||
public int ClipLength
|
||||
{
|
||||
get => _clipLength;
|
||||
set => SetProperty(ref _clipLength, value, "ClipLength");
|
||||
}
|
||||
public CalculatedChannelRecord() { }
|
||||
public CalculatedChannelRecord(ICalculatedChannelRecord record)
|
||||
{
|
||||
TestSetupName = record.TestSetupName;
|
||||
Operation = record.Operation;
|
||||
InputChannelIds = new string[0];
|
||||
if (null != record.InputChannelIds && record.InputChannelIds.Any())
|
||||
{
|
||||
InputChannelIds = new string[record.InputChannelIds.Length];
|
||||
record.InputChannelIds.CopyTo(_inputChannelIds, 0);
|
||||
}
|
||||
Id = record.Id;
|
||||
ChannelFilterClassForOutput = record.ChannelFilterClassForOutput;
|
||||
CFCForInputChannels = record.CFCForInputChannels;
|
||||
Name = record.Name;
|
||||
CalculatedValueCode = record.CalculatedValueCode;
|
||||
ViewInRealtime = record.ViewInRealtime;
|
||||
ClipLength = record.ClipLength;
|
||||
}
|
||||
|
||||
public CalculatedChannelRecord(IDataReader reader)
|
||||
{
|
||||
TestSetupName = Utility.GetString(reader, "TestSetupName");
|
||||
Operation = (Operations)Utility.GetInt(reader, "Operation", 0);
|
||||
InputChannelIds = Utility.GetStringArray(reader, "InputChannelIds",
|
||||
new string[0],
|
||||
CultureInfo.InvariantCulture.TextInfo.ListSeparator);
|
||||
Id = Utility.GetInt(reader, "Id", -1);
|
||||
ChannelFilterClassForOutput = Utility.GetString(reader, "CFCForOutput");
|
||||
CFCForInputChannels = Utility.GetString(reader, "CFCForInputChannels");
|
||||
Name = Utility.GetString(reader, "CCName");
|
||||
CalculatedValueCode = Utility.GetString(reader, "CalculatedChannelValueCode");
|
||||
ViewInRealtime = Utility.GetBool(reader, "ViewInRealtime");
|
||||
ClipLength = Utility.GetInt(reader, "ClipLength", 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
67
Common/DTS.Common/Classes/TestSetups/ExtraProperties.cs
Normal file
67
Common/DTS.Common/Classes/TestSetups/ExtraProperties.cs
Normal file
@@ -0,0 +1,67 @@
|
||||
using System;
|
||||
using System.ComponentModel;
|
||||
using System.Web.Script.Serialization;
|
||||
using System.Windows.Input;
|
||||
using DTS.Common.Enums;
|
||||
using DTS.Common.Interface.ISO.ExtraProperties;
|
||||
|
||||
namespace DTS.Common.Classes.TestSetups
|
||||
{
|
||||
[Serializable]
|
||||
public class ExtraProperty : IExtraProperty
|
||||
{
|
||||
public ExtraProperty(IExtraProperty iep)
|
||||
: this()
|
||||
{
|
||||
_key = iep.Key;
|
||||
_value = iep.Value;
|
||||
}
|
||||
public ExtraProperty(string key, string value)
|
||||
: this()
|
||||
{
|
||||
_key = key;
|
||||
_value = value;
|
||||
}
|
||||
public ExtraProperty()
|
||||
{
|
||||
_key = string.Empty;
|
||||
_value = string.Empty;
|
||||
}
|
||||
|
||||
private string _key;
|
||||
public string Key
|
||||
{
|
||||
get => _key;
|
||||
set { _key = value; OnPropertyChanged("Key"); }
|
||||
}
|
||||
|
||||
private string _value;
|
||||
public string Value
|
||||
{
|
||||
get => _value;
|
||||
set { _value = value; OnPropertyChanged("Value"); }
|
||||
}
|
||||
|
||||
private ICommand _pasteCommand;
|
||||
[ScriptIgnore]
|
||||
public ICommand PasteCommand
|
||||
{
|
||||
get => _pasteCommand;
|
||||
set { _pasteCommand = value; OnPropertyChanged("PasteCommand"); }
|
||||
}
|
||||
|
||||
private UIItemStatus _itemStatus;
|
||||
[ScriptIgnore]
|
||||
public UIItemStatus ItemStatus
|
||||
{
|
||||
get => _itemStatus;
|
||||
set { _itemStatus = value; OnPropertyChanged("ItemStatus"); }
|
||||
}
|
||||
|
||||
public event PropertyChangedEventHandler PropertyChanged;
|
||||
private void OnPropertyChanged(string propertyName = null)
|
||||
{
|
||||
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
|
||||
}
|
||||
}
|
||||
}
|
||||
194
Common/DTS.Common/Classes/TestSetups/GraphRecord.cs
Normal file
194
Common/DTS.Common/Classes/TestSetups/GraphRecord.cs
Normal file
@@ -0,0 +1,194 @@
|
||||
using DTS.Common.Base;
|
||||
using DTS.Common.Interface.Graphs;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.Data;
|
||||
|
||||
namespace DTS.Common.Classes.TestSetups
|
||||
{
|
||||
/// <summary>
|
||||
/// Implementation of a graph record in the database
|
||||
/// <inheritdoc cref="IGraphRecord"/>
|
||||
/// </summary>
|
||||
public class GraphRecord : BasePropertyChanged, IGraphRecord
|
||||
{
|
||||
private int _graphId;
|
||||
/// <summary>
|
||||
/// database key for graph
|
||||
/// </summary>
|
||||
public int GraphId
|
||||
{
|
||||
get => _graphId;
|
||||
set => SetProperty(ref _graphId, value, "GraphId");
|
||||
}
|
||||
private int _testSetupId;
|
||||
/// <summary>
|
||||
/// test setup key for graph
|
||||
/// </summary>
|
||||
public int TestSetupId
|
||||
{
|
||||
get => _testSetupId;
|
||||
set => SetProperty(ref _testSetupId, value, "TestSetupId");
|
||||
}
|
||||
private string _graphName;
|
||||
/// <summary>
|
||||
/// name of graph
|
||||
/// </summary>
|
||||
[MaxLength(50)]
|
||||
public string GraphName
|
||||
{
|
||||
get => _graphName;
|
||||
set => SetProperty(ref _graphName, value, "GraphName");
|
||||
}
|
||||
private string _graphDescription;
|
||||
/// <summary>
|
||||
/// description of graph
|
||||
/// </summary>
|
||||
[MaxLength(50)]
|
||||
public string GraphDescription
|
||||
{
|
||||
get => _graphDescription;
|
||||
set => SetProperty(ref _graphDescription, value, "GraphDescription");
|
||||
}
|
||||
private string _channelsString;
|
||||
/// <summary>
|
||||
/// all the channels in the graph
|
||||
/// </summary>
|
||||
[MaxLength(2048)]
|
||||
public string ChannelsString
|
||||
{
|
||||
get => _channelsString;
|
||||
set => SetProperty(ref _channelsString, value, "ChannelsString");
|
||||
}
|
||||
private bool _useDomainMin;
|
||||
/// <summary>
|
||||
/// whether to restrict domain axis to a min value
|
||||
/// </summary>
|
||||
public bool UseDomainMin
|
||||
{
|
||||
get => _useDomainMin;
|
||||
set => SetProperty(ref _useDomainMin, value, "UseDomainMin");
|
||||
}
|
||||
private double _domainMin = double.MinValue;
|
||||
/// <summary>
|
||||
/// the minimum value to show on domain axis
|
||||
/// (only valid when UseDomainMin is true)
|
||||
/// </summary>
|
||||
public double DomainMin
|
||||
{
|
||||
get => _domainMin;
|
||||
set => SetProperty(ref _domainMin, value, "DomainMin");
|
||||
}
|
||||
private bool _useDomainMax;
|
||||
/// <summary>
|
||||
/// whether to restrict domain axis to a max value
|
||||
/// </summary>
|
||||
public bool UseDomainMax
|
||||
{
|
||||
get => _useDomainMax;
|
||||
set => SetProperty(ref _useDomainMax, value, "UseDomainMax");
|
||||
}
|
||||
private double _domainMax = double.MaxValue;
|
||||
/// <summary>
|
||||
/// maximum value to show on domain axis
|
||||
/// (only valid when UseDomainMax is true)
|
||||
/// </summary>
|
||||
public double DomainMax
|
||||
{
|
||||
get => _domainMax;
|
||||
set => SetProperty(ref _domainMax, value, "DomainMax");
|
||||
}
|
||||
private bool _useRangeMin;
|
||||
/// <summary>
|
||||
/// whether to restrict range axis to a min value
|
||||
/// </summary>
|
||||
public bool UseRangeMin
|
||||
{
|
||||
get => _useRangeMin;
|
||||
set => SetProperty(ref _useRangeMin, value, "UseRangeMin");
|
||||
}
|
||||
private double _rangeMin = double.MinValue;
|
||||
/// <summary>
|
||||
/// minimum value to show on range axis
|
||||
/// (only valid when UseRangeMin is true)
|
||||
/// </summary>
|
||||
public double RangeMin
|
||||
{
|
||||
get => _rangeMin;
|
||||
set => SetProperty(ref _rangeMin, value, "RangeMin");
|
||||
}
|
||||
private bool _useRangeMax;
|
||||
/// <summary>
|
||||
/// whether to restrict range axis to a max value
|
||||
/// </summary>
|
||||
public bool UseRangeMax
|
||||
{
|
||||
get => _useRangeMax;
|
||||
set => SetProperty(ref _useRangeMax, value, "UseRangeMax");
|
||||
}
|
||||
private double _rangeMax = double.MaxValue;
|
||||
/// <summary>
|
||||
/// the maximum value to show on the range axis
|
||||
/// (only valid when UseRangeMax is true)
|
||||
/// </summary>
|
||||
public double RangeMax
|
||||
{
|
||||
get => _rangeMax;
|
||||
set => SetProperty(ref _rangeMax, value, "RangeMax");
|
||||
}
|
||||
private string _thresholdsString;
|
||||
/// <summary>
|
||||
/// any thresholds/lines to show on the graph
|
||||
/// </summary>
|
||||
[MaxLength(2048)]
|
||||
public string ThresholdsString
|
||||
{
|
||||
get => _thresholdsString;
|
||||
set => SetProperty(ref _thresholdsString, value, "ThresholdsString");
|
||||
}
|
||||
private bool _localOnly = false;
|
||||
/// <summary>
|
||||
/// whether to synchronize record with central db
|
||||
/// [deprecated]
|
||||
/// </summary>
|
||||
public bool LocalOnly
|
||||
{
|
||||
get => _localOnly;
|
||||
set => SetProperty(ref _localOnly, value, "LocalOnly");
|
||||
}
|
||||
public GraphRecord() { }
|
||||
public GraphRecord(IGraphRecord copy)
|
||||
{
|
||||
DomainMax = copy.DomainMax;
|
||||
DomainMin = copy.DomainMin;
|
||||
ChannelsString = copy.ChannelsString;
|
||||
ThresholdsString = copy.ThresholdsString;
|
||||
GraphDescription = copy.GraphDescription;
|
||||
GraphId = copy.GraphId;
|
||||
GraphName = copy.GraphName;
|
||||
RangeMax = copy.RangeMax;
|
||||
RangeMin = copy.RangeMin;
|
||||
TestSetupId = copy.TestSetupId;
|
||||
UseDomainMax = copy.UseDomainMax;
|
||||
UseDomainMin = copy.UseDomainMin;
|
||||
UseRangeMax = copy.UseRangeMax;
|
||||
UseRangeMin = copy.UseRangeMin;
|
||||
}
|
||||
public GraphRecord(IDataReader reader)
|
||||
{
|
||||
GraphId = Utility.GetInt(reader, "GraphId", -1);
|
||||
TestSetupId = Utility.GetInt(reader, "TestSetupId", -1);
|
||||
GraphName = Utility.GetString(reader, "GraphName");
|
||||
GraphDescription = Utility.GetString(reader, "GraphDescription");
|
||||
ChannelsString = Utility.GetString(reader, "Channels");
|
||||
DomainMax = Utility.GetDouble(reader, "DomainMax", double.MaxValue);
|
||||
DomainMin = Utility.GetDouble(reader, "DomainMin", double.MinValue);
|
||||
RangeMax = Utility.GetDouble(reader, "RangeMax", double.MaxValue);
|
||||
RangeMin = Utility.GetDouble(reader, "RangeMin", double.MinValue);
|
||||
ThresholdsString = Utility.GetString(reader, "Thresholds");
|
||||
UseDomainMax = Utility.GetBool(reader, "UseDomainMax");
|
||||
UseDomainMin = Utility.GetBool(reader, "UseDomainMin");
|
||||
UseRangeMax = Utility.GetBool(reader, "UseRangeMax");
|
||||
UseRangeMin = Utility.GetBool(reader, "UseRangeMin");
|
||||
}
|
||||
}
|
||||
}
|
||||
179
Common/DTS.Common/Classes/TestSetups/ISFFile.cs
Normal file
179
Common/DTS.Common/Classes/TestSetups/ISFFile.cs
Normal file
@@ -0,0 +1,179 @@
|
||||
using DTS.Common.Interface.Sensors;
|
||||
using DTS.Common.Interface.TestSetups;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace DTS.Common.Classes.TestSetups
|
||||
{
|
||||
public static class ArrayExtensions
|
||||
{
|
||||
public static void Fill<T>(this T[] sourceArray, T with)
|
||||
{
|
||||
for (var i = 0; i < sourceArray.Length; i++)
|
||||
{
|
||||
sourceArray[i] = with;
|
||||
}
|
||||
}
|
||||
|
||||
public static void SubFill<T>(this T[] source, T with, int startIndex, int finalIndex)
|
||||
{
|
||||
for (var i = startIndex; i < source.Length && i < finalIndex; i++)
|
||||
{
|
||||
source[i] = with;
|
||||
}
|
||||
}
|
||||
|
||||
public static void SetValues<T>(this T[] source, T[] with, int startIndex, int length, T pad)
|
||||
{
|
||||
source.SubFill(pad, startIndex, startIndex + length);
|
||||
Array.Copy(with, 0, source, startIndex, Math.Min(length, with.Length));
|
||||
}
|
||||
|
||||
public static T[] GetValues<T>(this T[] source, int startIndex, int length)
|
||||
{
|
||||
var ret = new T[length];
|
||||
Array.Copy(source, startIndex, ret, 0, length);
|
||||
return ret;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// handles writing, reading from an ISF file
|
||||
/// </summary>
|
||||
public class ISFFile
|
||||
{
|
||||
private char[] _HeaderLine1 = new char[ConstantsAndEnums.RECORD_LENGTH];
|
||||
|
||||
/// <summary>
|
||||
/// RECORD_LENGTH bytes (80)
|
||||
/// </summary>
|
||||
public char[] HeaderLine1
|
||||
{
|
||||
get => _HeaderLine1;
|
||||
set
|
||||
{
|
||||
_HeaderLine1.Fill(' ');
|
||||
Array.Copy(value, _HeaderLine1, Math.Min(value.Length, _HeaderLine1.Length));
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 8 characters, starting at character 7
|
||||
/// </summary>
|
||||
public char[] TestSetupName
|
||||
{
|
||||
get => _HeaderLine1.GetValues(7, 8);
|
||||
set => _HeaderLine1.SetValues(value, 7, 8, ' ');
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// starts at character 15, 5 characters long
|
||||
/// </summary>
|
||||
public char[] NumberOfRecords
|
||||
{
|
||||
get => _HeaderLine1.GetValues(15, 5);
|
||||
private set => _HeaderLine1.SetValues(value, 15, 5, ' ');
|
||||
}
|
||||
|
||||
private void SetNumberOfRecords(int i)
|
||||
{
|
||||
var s = i.ToString();
|
||||
NumberOfRecords = s.ToCharArray();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 22 characters, starting at character 20
|
||||
/// </summary>
|
||||
public char[] TestType
|
||||
{
|
||||
get => _HeaderLine1.GetValues(20, 22);
|
||||
set => _HeaderLine1.SetValues(value, 20, 22, ' ');
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 30 characters, starting at character 42
|
||||
/// </summary>
|
||||
public char[] TestDivision
|
||||
{
|
||||
get => _HeaderLine1.GetValues(42, 30);
|
||||
set => _HeaderLine1.SetValues(value, 42, 30, ' ');
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 8 characters start at character 72, without .TCF extension
|
||||
/// </summary>
|
||||
public char[] TCFile
|
||||
{
|
||||
get => _HeaderLine1.GetValues(72, 8);
|
||||
set => _HeaderLine1.SetValues(value, 72, 8, ' ');
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// RECORD_LENGTH, we don't use anything from it currently...
|
||||
/// </summary>
|
||||
private char[] HeaderLine2 { get; set; } = new char[ConstantsAndEnums.RECORD_LENGTH];
|
||||
|
||||
/// <summary>
|
||||
/// RECORD_LENGTH, we don't use anything from it currently
|
||||
/// </summary>
|
||||
private char[] HeaderLine3 { get; set; } = new char[ConstantsAndEnums.RECORD_LENGTH];
|
||||
|
||||
private List<IISFSensorRecord> _records = new List<IISFSensorRecord>();
|
||||
public IISFSensorRecord[] Records => _records.ToArray();
|
||||
|
||||
/// <summary>
|
||||
/// adds a record, updates record count
|
||||
/// </summary>
|
||||
/// <param name="record"></param>
|
||||
public void AddRecord(IISFSensorRecord record)
|
||||
{
|
||||
record.SetDataChannelNumber(Convert.ToInt16(1 + _records.Count));
|
||||
_records.Add(record);
|
||||
SetNumberOfRecords(Records.Length * 4); //4 "records" per record
|
||||
}
|
||||
/// <summary>
|
||||
/// writes file to path
|
||||
/// </summary>
|
||||
/// <param name="pathToFile"></param>
|
||||
public void WriteToFile(string pathToFile)
|
||||
{
|
||||
if (System.IO.File.Exists(pathToFile))
|
||||
{
|
||||
Utils.FileUtils.DeleteFileOrMove(pathToFile, LogFunction);
|
||||
}
|
||||
using (var fs = new System.IO.FileStream(pathToFile, System.IO.FileMode.CreateNew))
|
||||
{
|
||||
using (var bw = new System.IO.BinaryWriter(fs))
|
||||
{
|
||||
bw.Write(HeaderLine1);
|
||||
bw.Write(HeaderLine2);
|
||||
bw.Write(HeaderLine3);
|
||||
foreach (var record in Records)
|
||||
{
|
||||
record.Write(bw);
|
||||
bw.Flush();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void AddSensors(ISensorData[] sensors)
|
||||
{
|
||||
foreach (var sensor in sensors)
|
||||
{
|
||||
var record = new ISFSensorRecord();
|
||||
record.SetSensor(sensor);
|
||||
AddRecord(record);
|
||||
}
|
||||
}
|
||||
private void LogFunction(params object[] paramlist)
|
||||
{
|
||||
}
|
||||
|
||||
public ISFFile()
|
||||
{
|
||||
_HeaderLine1.Fill(' ');
|
||||
}
|
||||
}
|
||||
}
|
||||
380
Common/DTS.Common/Classes/TestSetups/ISFSensorRecord.cs
Normal file
380
Common/DTS.Common/Classes/TestSetups/ISFSensorRecord.cs
Normal file
@@ -0,0 +1,380 @@
|
||||
using DTS.Common.Interface.Sensors;
|
||||
using DTS.Common.Interface.TestSetups;
|
||||
using System;
|
||||
using System.Linq;
|
||||
|
||||
namespace DTS.Common.Classes.TestSetups
|
||||
{
|
||||
public class ISFSensorRecord : IISFSensorRecord
|
||||
{
|
||||
private char[] _record1 = new char[ConstantsAndEnums.RECORD_LENGTH];
|
||||
|
||||
/// <summary>
|
||||
/// RECORD_LENGTH the whole first record
|
||||
/// </summary>
|
||||
public char[] Record1
|
||||
{
|
||||
get => _record1;
|
||||
set
|
||||
{
|
||||
_record1.Fill(' ');
|
||||
Array.Copy(value, 0, _record1, 0, Math.Min(ConstantsAndEnums.RECORD_LENGTH, value.Length));
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 2 characters, starting at character 75
|
||||
/// </summary>
|
||||
public char[] Tag
|
||||
{
|
||||
get => _record1.GetValues(75, 2);
|
||||
set => _record1.SetValues(value, 75, 2, ' ');
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 5 characters start at character 7
|
||||
/// </summary>
|
||||
public char[] DataChannelNumber
|
||||
{
|
||||
get => _record1.GetValues(7, 5);
|
||||
set => _record1.SetValues(value, 7, 5, ' ');
|
||||
}
|
||||
|
||||
public void SetDataChannelNumber(short value)
|
||||
{
|
||||
DataChannelNumber = value.ToString().ToCharArray();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 1 character, starting at character 15
|
||||
/// </summary>
|
||||
public bool UserIdSensorIDIsNotSpecified
|
||||
{
|
||||
get => _record1[15] == '1';
|
||||
set => _record1[15] = value ? '1' : '0';
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 11 characters start at 19
|
||||
/// </summary>
|
||||
public char[] CapacityCharacters
|
||||
{
|
||||
get => _record1.GetValues(19, 11);
|
||||
set => _record1.SetValues(value, 19, 11, ' ');
|
||||
}
|
||||
|
||||
public void SetCapacity(double capacity)
|
||||
{
|
||||
CapacityCharacters = capacity.ToString(System.Globalization.CultureInfo.InvariantCulture).ToCharArray();
|
||||
}
|
||||
|
||||
public double GetCapacity()
|
||||
{
|
||||
var s = CapacityCharacters.ToString();
|
||||
s = s.Trim();
|
||||
if (double.TryParse(s, out var d))
|
||||
{
|
||||
return d;
|
||||
}
|
||||
return double.NaN;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 12 characters, starting at 30
|
||||
/// </summary>
|
||||
public char[] SerialNumber
|
||||
{
|
||||
get => _record1.GetValues(30, 12);
|
||||
set => _record1.SetValues(value, 30, 12, ' ');
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 11 characters, start at 42
|
||||
/// is Sensitivity/1000 (V)
|
||||
/// can also be c0 if polynomial
|
||||
/// </summary>
|
||||
public char[] Sensitivity
|
||||
{
|
||||
get => _record1.GetValues(42, 11);
|
||||
set => _record1.SetValues(value, 42, 11, ' ');
|
||||
}
|
||||
|
||||
public void SetSensitivity(double sensitivity)
|
||||
{
|
||||
Sensitivity = sensitivity.ToString(System.Globalization.CultureInfo.InvariantCulture).ToCharArray();
|
||||
}
|
||||
|
||||
public double GetSensitivity()
|
||||
{
|
||||
var s = Sensitivity.ToString().Trim();
|
||||
if (double.TryParse(s, out var d))
|
||||
{
|
||||
return d;
|
||||
}
|
||||
return double.NaN;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 11 characters starting at 53
|
||||
/// </summary>
|
||||
public char[] BridgeResistance
|
||||
{
|
||||
get => _record1.GetValues(53, 11);
|
||||
set => _record1.SetValues(value, 53, 11, ' ');
|
||||
}
|
||||
|
||||
public void SetBridgeResistance(double resistance)
|
||||
{
|
||||
BridgeResistance = resistance.ToString(System.Globalization.CultureInfo.InvariantCulture).ToCharArray();
|
||||
}
|
||||
|
||||
private char[] _record2 = new char[ConstantsAndEnums.RECORD_LENGTH];
|
||||
|
||||
/// <summary>
|
||||
/// RECORD_LENGTH
|
||||
/// </summary>
|
||||
public char[] Record2
|
||||
{
|
||||
get => _record2;
|
||||
set
|
||||
{
|
||||
_record2.Fill(' ');
|
||||
Array.Copy(value, 0, _record2, 0, ConstantsAndEnums.RECORD_LENGTH);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 12 characters, starting at character 7 (of record 2)
|
||||
/// </summary>
|
||||
public char[] EngineeringUnits
|
||||
{
|
||||
get => _record2.GetValues(7, 12);
|
||||
set => _record2.SetValues(value, 7, 12, ' ');
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 11 characters, starting at character 20
|
||||
/// </summary>
|
||||
public char[] C1
|
||||
{
|
||||
get => _record2.GetValues(20, 11);
|
||||
set => _record2.SetValues(value, 20, 11, ' ');
|
||||
}
|
||||
public void SetC1(double c1)
|
||||
{
|
||||
C1 = c1.ToString(System.Globalization.CultureInfo.InvariantCulture).ToCharArray();
|
||||
}
|
||||
|
||||
public double GetC1()
|
||||
{
|
||||
var s = C1.ToString().Trim();
|
||||
if (double.TryParse(s, out var d))
|
||||
{
|
||||
return d;
|
||||
}
|
||||
return double.NaN;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 17 characters, starting at character 31
|
||||
/// </summary>
|
||||
public char[] EID
|
||||
{
|
||||
get => _record2.GetValues(31, 17);
|
||||
set => _record2.SetValues(value, 31, 17, ' ');
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 4 characters, starting at 49
|
||||
/// </summary>
|
||||
public char[] Unknown1
|
||||
{
|
||||
get => _record2.GetValues(49, 4);
|
||||
set => _record2.SetValues(value, 49, 4, ' ');
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 2 characters, starting at 53
|
||||
/// </summary>
|
||||
public char[] Unknown2
|
||||
{
|
||||
get => _record2.GetValues(53, 2);
|
||||
set => _record2.SetValues(value, 53, 2, ' ');
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 11 characters starting at 55 (TOM ONLY [sensortype TI])
|
||||
/// is /1000 of ordinary
|
||||
/// </summary>
|
||||
public char[] FireDelay
|
||||
{
|
||||
get => _record2.GetValues(55, 11);
|
||||
set => _record2.SetValues(value, 55, 11, ' ');
|
||||
}
|
||||
|
||||
public void SetFireDelay(double fireDelay)
|
||||
{
|
||||
FireDelay = fireDelay.ToString(System.Globalization.CultureInfo.InvariantCulture).ToCharArray();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 8 characters, starting at 66
|
||||
/// STANDARD is the default value, we don't really support anything else currently
|
||||
/// </summary>
|
||||
public char[] TOMConfigurationName
|
||||
{
|
||||
get => _record2.GetValues(66, 8);
|
||||
set => _record2.SetValues(value, 66, 8, ' ');
|
||||
}
|
||||
|
||||
private char[] _record3 = new char[ConstantsAndEnums.RECORD_LENGTH];
|
||||
|
||||
/// <summary>
|
||||
/// RECORD_LENGTH, third record of 4
|
||||
/// </summary>
|
||||
public char[] Record3
|
||||
{
|
||||
get => _record3;
|
||||
set
|
||||
{
|
||||
_record3.Fill(' ');
|
||||
Array.Copy(value, 0, _record3, 0, Math.Min(ConstantsAndEnums.RECORD_LENGTH, value.Length));
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 15 characters start at 14 of record 3
|
||||
/// </summary>
|
||||
public char[] CommentPart1
|
||||
{
|
||||
get => _record3.GetValues(14, 15);
|
||||
set => _record3.SetValues(value, 14, 15, ' ');
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 40 characters starting at 33
|
||||
/// </summary>
|
||||
public char[] CommentPart2
|
||||
{
|
||||
get => _record3.GetValues(33, 40);
|
||||
set => _record3.SetValues(value, 33, 40, ' ');
|
||||
}
|
||||
|
||||
private char[] _record4 = new char[ConstantsAndEnums.RECORD_LENGTH];
|
||||
|
||||
/// <summary>
|
||||
/// RECORD_LENGTH, the 4th record of 4
|
||||
/// </summary>
|
||||
public char[] Record4
|
||||
{
|
||||
get => _record4;
|
||||
set
|
||||
{
|
||||
_record4.Fill(' ');
|
||||
Array.Copy(value, 0, _record4, 0, Math.Min(ConstantsAndEnums.RECORD_LENGTH, value.Length));
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 15 characters, starting at character 12
|
||||
/// </summary>
|
||||
public char[] CommentPart3
|
||||
{
|
||||
get => _record4.GetValues(12, 15);
|
||||
set => _record4.SetValues(value, 12, 15, ' ');
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// sets CommentPart1, CommentPart2, CommentPart3
|
||||
/// </summary>
|
||||
/// <param name="s"></param>
|
||||
public void SetSensorComment(string s)
|
||||
{
|
||||
var newBuffer = new char[15 + 40 + 15];
|
||||
newBuffer.SetValues(s.ToCharArray(), 0, newBuffer.Length, ' ');
|
||||
//comment1 - 15 chars
|
||||
CommentPart1 = newBuffer.GetValues(0, 15);
|
||||
//comment2 - 40chars
|
||||
CommentPart2 = newBuffer.GetValues(15, 40);
|
||||
//comment3 - 15chars
|
||||
CommentPart3 = newBuffer.GetValues(55, 15);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 20 characters starting at 30
|
||||
/// checked for digital inputs (should contain N/O or N/C)
|
||||
/// </summary>
|
||||
public char[] SensorType
|
||||
{
|
||||
get => _record4.GetValues(30, 20);
|
||||
set => _record4.SetValues(value, 30, 20, ' ');
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 11 characters starting at 50
|
||||
/// </summary>
|
||||
public char[] C2
|
||||
{
|
||||
get => _record4.GetValues(50, 11);
|
||||
set => _record4.SetValues(value, 50, 11, ' ');
|
||||
}
|
||||
|
||||
public void SetC2(double c2)
|
||||
{
|
||||
C2 = c2.ToString(System.Globalization.CultureInfo.InvariantCulture).ToCharArray();
|
||||
}
|
||||
/// <summary>
|
||||
/// 11 characters starting at 61
|
||||
/// notice for poly's we should be multiplying by 1000D?
|
||||
/// calibration.Records.Records.First().Poly.SetCoefficient(0, calibration.Records.Records[0].Sensitivity / 1000.0D);
|
||||
/// calibration.Records.Records.First().Poly.SetCoefficient(1, c1 / 1000.0D);
|
||||
/// calibration.Records.Records.First().Poly.SetCoefficient(2, c2 / 1000.0D);
|
||||
/// calibration.Records.Records.First().Poly.SetCoefficient(3, c3 / 1000.0D);
|
||||
/// </summary>
|
||||
public char[] C3
|
||||
{
|
||||
get => _record4.GetValues(61, 11);
|
||||
set => _record4.SetValues(value, 61, 11, ' ');
|
||||
}
|
||||
|
||||
public void SetC3(double c3)
|
||||
{
|
||||
C3 = c3.ToString(System.Globalization.CultureInfo.InvariantCulture).ToCharArray();
|
||||
}
|
||||
/// <summary>
|
||||
/// writes record to stream
|
||||
/// </summary>
|
||||
/// <param name="writer"></param>
|
||||
public void Write(System.IO.BinaryWriter writer)
|
||||
{
|
||||
writer.Write(Record1);
|
||||
writer.Write(Record2);
|
||||
writer.Write(Record3);
|
||||
writer.Write(Record4);
|
||||
}
|
||||
|
||||
public ISFSensorRecord()
|
||||
{
|
||||
_record1.Fill(' ');
|
||||
_record2.Fill(' ');
|
||||
_record3.Fill(' ');
|
||||
_record4.Fill(' ');
|
||||
TOMConfigurationName = "STANDARD".ToCharArray();
|
||||
}
|
||||
|
||||
public void SetSensor(ISensorData sensor)
|
||||
{
|
||||
SerialNumber = sensor.SerialNumber.ToCharArray();
|
||||
var sc = sensor.GetLatestCalibration();
|
||||
SetSensitivity(sc.Records.Records[0].Sensitivity);
|
||||
SetBridgeResistance(sensor.BridgeResistance);
|
||||
SetCapacity(sensor.Capacity);
|
||||
SetSensorComment(sensor.Comment);
|
||||
Tag = "VS".ToCharArray();
|
||||
UserIdSensorIDIsNotSpecified = true;
|
||||
EID = sensor.EID.ToCharArray();
|
||||
EngineeringUnits = sc.EngineeringUnits.ToCharArray();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,57 @@
|
||||
using DTS.Common.Base;
|
||||
using DTS.Common.Interface.TestSetups;
|
||||
using System.Data;
|
||||
|
||||
namespace DTS.Common.Classes.TestSetups
|
||||
{
|
||||
/// <summary>
|
||||
/// Describes a record in the ROIPeriodChannels table
|
||||
/// </summary>
|
||||
public class ROIPeriodChannelRecord : BasePropertyChanged, IROIPeriodChannelRecord
|
||||
{
|
||||
/// <summary>
|
||||
/// The field that matches the same field in the TestSetupROIs table
|
||||
/// </summary>
|
||||
private int _testSetupROIId;
|
||||
public int TestSetupROIId
|
||||
{
|
||||
get => _testSetupROIId;
|
||||
set => SetProperty(ref _testSetupROIId, value, "TestSetupROIId");
|
||||
}
|
||||
/// <summary>
|
||||
/// The name of a channel in a ROI period.
|
||||
/// </summary>
|
||||
private string _channelName;
|
||||
public string ChannelName
|
||||
{
|
||||
get => _channelName;
|
||||
set => SetProperty(ref _channelName, value, "ChannelName");
|
||||
}
|
||||
/// <summary>
|
||||
/// The id of a channel in a ROI period.
|
||||
/// </summary>
|
||||
private long _channelId;
|
||||
public long ChannelId
|
||||
{
|
||||
get => _channelId;
|
||||
set => SetProperty(ref _channelId, value, "ChannelId");
|
||||
}
|
||||
/// <summary>
|
||||
/// Builds a ROIPeriodChannel record after a call to sp_ROIPeriodChannelsGet
|
||||
/// </summary>
|
||||
/// <param name="reader"></param>
|
||||
public ROIPeriodChannelRecord(IDataReader reader, int storedProcedureVersionToUse)
|
||||
{
|
||||
TestSetupROIId = Utility.GetInt(reader, "TestSetupROIId");
|
||||
ChannelName = Utility.GetString(reader, "ChannelName", "");
|
||||
if (storedProcedureVersionToUse >= Constants.ROIPERIODCHANNELS_CHANNELID_DB_VERSION)
|
||||
{
|
||||
ChannelId = Utility.GetLong(reader, "ChannelId");
|
||||
}
|
||||
else
|
||||
{
|
||||
ChannelId = -1; //So we know the database doesn't have a ChannelId field in the ROIPeriodChannels table
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
308
Common/DTS.Common/Classes/TestSetups/RegionOfInterest.cs
Normal file
308
Common/DTS.Common/Classes/TestSetups/RegionOfInterest.cs
Normal file
@@ -0,0 +1,308 @@
|
||||
using System;
|
||||
using System.ComponentModel;
|
||||
using DTS.Common.Events.RegionOfInterest;
|
||||
using System.Linq;
|
||||
using DTS.Common.Interface.RegionOfInterest;
|
||||
using Prism.Events;
|
||||
using Prism.Ioc;
|
||||
using DTS.Common.Enums.Sensors;
|
||||
|
||||
namespace DTS.Common.Classes.TestSetups
|
||||
{
|
||||
[Serializable]
|
||||
public class RegionOfInterest : IRegionOfInterest
|
||||
{
|
||||
/// <summary>
|
||||
/// holds whether a test setup is currently deserializing ROIs or not
|
||||
/// this was necessary to prevent deserialization from firing property changed notifications on construction
|
||||
/// 27034 ROI channel assignments are not saved when modifying and clicking save in test setup
|
||||
/// </summary>
|
||||
public static bool Deserializing { get; set; } = false;
|
||||
public RegionOfInterest()
|
||||
{
|
||||
Suffix = string.Empty;
|
||||
_start = double.NegativeInfinity;
|
||||
_end = double.PositiveInfinity;
|
||||
IsEnabled = true;
|
||||
IsDefault = true;
|
||||
_channelNames = null;
|
||||
_channelIds = null;
|
||||
}
|
||||
|
||||
public RegionOfInterest(bool isDefault = false)
|
||||
: this()
|
||||
{
|
||||
IsDefault = isDefault;
|
||||
}
|
||||
public RegionOfInterest(string suffix = "", bool isDefault = false, double start = -1D, double end = 1D)
|
||||
: this(isDefault)
|
||||
{
|
||||
Suffix = suffix;
|
||||
_start = start;
|
||||
_end = end;
|
||||
_channelNames = new string[0];
|
||||
_channelIds = new long[0];
|
||||
}
|
||||
|
||||
private string _suffix = string.Empty;
|
||||
public string Suffix
|
||||
{
|
||||
get => _suffix;
|
||||
set
|
||||
{
|
||||
if (!string.IsNullOrWhiteSpace(value) && !(value.StartsWith("_") && string.IsNullOrWhiteSpace(value.Substring(1))))
|
||||
{
|
||||
_suffix = value.StartsWith("_") ? value : "_" + value;
|
||||
}
|
||||
OnPropertyChanged("Suffix");
|
||||
}
|
||||
}
|
||||
|
||||
private double _start = double.MinValue;
|
||||
public double Start
|
||||
{
|
||||
get => _start;
|
||||
set
|
||||
{
|
||||
if (value >= End)
|
||||
{
|
||||
value = End - 0.01;
|
||||
}
|
||||
|
||||
if (value != _start)
|
||||
{
|
||||
//FB 43462 Infinity is not a valid value don't notify
|
||||
var notify = !double.IsInfinity(_start);
|
||||
_start = value;
|
||||
OnPropertyChanged("Start");
|
||||
if (notify)
|
||||
{
|
||||
NotifyChanged();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private double _end = double.MaxValue;
|
||||
public double End
|
||||
{
|
||||
get => _end;
|
||||
set
|
||||
{
|
||||
if (value <= Start)
|
||||
{
|
||||
value = Start + 0.01;
|
||||
}
|
||||
|
||||
if (value != _end)
|
||||
{
|
||||
//FB 43462 Infinity is not a valid value don't notify
|
||||
var notify = !double.IsInfinity(_end);
|
||||
_end = value;
|
||||
OnPropertyChanged("End");
|
||||
if (notify)
|
||||
{
|
||||
NotifyChanged();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// notifies any consumers that ROI has changed (if it should notify)
|
||||
/// 27034 ROI channel assignments are not saved when modifying and clicking save in test setup
|
||||
/// </summary>
|
||||
private void NotifyChanged()
|
||||
{
|
||||
try
|
||||
{
|
||||
if (Deserializing) { return; }
|
||||
if (null == ContainerLocator.Container) { return; }
|
||||
var eventAggregator = ContainerLocator.Container.Resolve<IEventAggregator>();
|
||||
eventAggregator.GetEvent<RegionOfInterestChangedEvent>().Publish(this);
|
||||
}
|
||||
catch (Exception) { }
|
||||
}
|
||||
|
||||
private bool _isEnabled = true;
|
||||
public bool IsEnabled
|
||||
{
|
||||
get => _isEnabled;
|
||||
set { _isEnabled = value; OnPropertyChanged("IsEnabled"); }
|
||||
}
|
||||
|
||||
//17954 Modify ROI does not show in UI
|
||||
//deserialize wasn't setting this, seems like it should
|
||||
public bool IsDefault { get; set; }
|
||||
|
||||
public event PropertyChangedEventHandler PropertyChanged;
|
||||
|
||||
private void OnPropertyChanged(string propertyName = null)
|
||||
{
|
||||
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
|
||||
}
|
||||
|
||||
public void ResetSuffix()
|
||||
{
|
||||
_suffix = string.Empty;
|
||||
}
|
||||
|
||||
private string[] _channelNames = new string[0];
|
||||
public string[] ChannelNames
|
||||
{
|
||||
get => _channelNames;
|
||||
set
|
||||
{
|
||||
//FB 43462 if the value is null first initialize it to empty array
|
||||
if (_channelNames == null)
|
||||
{
|
||||
_channelNames = value ?? new string[] { };
|
||||
OnPropertyChanged("ChannelNames");
|
||||
}
|
||||
//FB 43462 check all elements to determeine equal
|
||||
if (!_channelNames.SequenceEqual(value))
|
||||
{
|
||||
_channelNames = value ?? new string[] { };
|
||||
OnPropertyChanged("ChannelNames");
|
||||
NotifyChanged();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private long[] _channelIds;
|
||||
public long[] ChannelIds
|
||||
{
|
||||
get => _channelIds;
|
||||
set
|
||||
{
|
||||
//FB 43462 if the value is null first initialize it to empty array
|
||||
if (_channelIds == null)
|
||||
{
|
||||
_channelIds = value ?? new long[] { };
|
||||
OnPropertyChanged("ChannelIds");
|
||||
}
|
||||
//FB 43462 check all elements to determeine equal
|
||||
if (!_channelIds.SequenceEqual(value))
|
||||
{
|
||||
_channelIds = value ?? new long[] { };
|
||||
OnPropertyChanged("ChannelIds");
|
||||
NotifyChanged();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// return a TSA_Embedded channel on a TSR AIR differently than a TSA_Embedded channel
|
||||
/// on other DAS (it's a Voltage input channel if on non-TSR AIR DAS).
|
||||
/// </summary>
|
||||
/// <param name="serialNumber"></param>
|
||||
/// <param name="hardwareChannelName"></param>
|
||||
/// <param name="startOfHardware"></param>
|
||||
/// <param name="originalChannelName"></param>
|
||||
/// <returns></returns>
|
||||
public static string GetAnalogChanName(string serialNumber, string hardwareChannelName, string startOfHardware, string originalChannelName = "")
|
||||
{
|
||||
var chanName = string.Empty;
|
||||
|
||||
if ((serialNumber == SensorConstants.TEST_SPECIFIC_ANALOG_SERIAL) &&
|
||||
!hardwareChannelName.StartsWith($"[{startOfHardware}") ||
|
||||
(serialNumber == SensorConstants.VOLTAGE_INPUT))
|
||||
{
|
||||
//34350 This is a Voltage input channel, so parse it differently
|
||||
chanName = GetChanName(SensorConstants.VOLTAGE_INPUT, hardwareChannelName, originalChannelName);
|
||||
}
|
||||
else
|
||||
{
|
||||
chanName = GetChanName(serialNumber, hardwareChannelName, originalChannelName);
|
||||
}
|
||||
|
||||
return chanName;
|
||||
}
|
||||
/// <summary>
|
||||
/// Takes a Serial Number, Hardware Channel Name, and Original Channel Name and prepends the hardware channel
|
||||
/// based on whether or not it's an embedded (TSR AIR channel), or has a parent DAS.
|
||||
/// </summary>
|
||||
/// <param name="aic"></param>
|
||||
/// <returns></returns>
|
||||
public static string GetChanName(string serialNumber, string hardwareChannelName, string originalChannelName = "")
|
||||
{
|
||||
var chanName = string.Empty;
|
||||
|
||||
if (serialNumber == SensorConstants.TEST_SPECIFIC_ANALOG_SERIAL)
|
||||
{
|
||||
chanName = hardwareChannelName + "\\" + originalChannelName;
|
||||
}
|
||||
else
|
||||
{
|
||||
var indexOfColon = hardwareChannelName.IndexOf(":");
|
||||
if (indexOfColon == -1)
|
||||
{
|
||||
chanName = hardwareChannelName + "\\" + serialNumber;
|
||||
}
|
||||
else
|
||||
{
|
||||
var dasSerialNumber = hardwareChannelName.Substring(indexOfColon).Replace(':', '[');
|
||||
chanName = dasSerialNumber + "\\" + serialNumber;
|
||||
}
|
||||
}
|
||||
|
||||
return chanName;
|
||||
}
|
||||
public static string RemoveParentDASName(string entireChannelName)
|
||||
{
|
||||
var chanName = entireChannelName;
|
||||
|
||||
var indexOfColon = entireChannelName.IndexOf(":");
|
||||
if (indexOfColon > -1)
|
||||
{
|
||||
chanName = entireChannelName.Substring(indexOfColon).Replace(':', '[');
|
||||
}
|
||||
|
||||
return chanName;
|
||||
}
|
||||
/// <summary>
|
||||
/// sets the channel names without notifying of a change
|
||||
/// allows a constructor to bypass notifications
|
||||
/// 27034 ROI channel assignments are not saved when modifying and clicking save in test setup
|
||||
/// </summary>
|
||||
/// <param name="names"></param>
|
||||
public void SetChannelNamesNoNotify(string[] names)
|
||||
{
|
||||
_channelNames = names;
|
||||
}
|
||||
/// <summary>
|
||||
/// sets the channel ids without notifying of a change
|
||||
/// allows a constructor to bypass notifications
|
||||
/// </summary>
|
||||
/// <param name="names"></param>
|
||||
public void SetChannelIdsNoNotify(long[] ids)
|
||||
{
|
||||
_channelIds = ids;
|
||||
}
|
||||
/// <summary>
|
||||
/// returns string after "Assigned by ID"
|
||||
/// </summary>
|
||||
/// <param name="chHardware"></param>
|
||||
/// <returns></returns>
|
||||
public static string RemoveAssignedByIDFromHardwareString(string chHardware)
|
||||
{
|
||||
var newChHardware = string.Empty;
|
||||
|
||||
if (!string.IsNullOrWhiteSpace(chHardware))
|
||||
{
|
||||
newChHardware = chHardware.TrimStart();
|
||||
if (chHardware.StartsWith("Assigned by ID"))
|
||||
{
|
||||
newChHardware = chHardware.Replace("Assigned by ID", "");
|
||||
newChHardware = newChHardware.TrimStart();
|
||||
}
|
||||
if (newChHardware.Contains("["))
|
||||
{
|
||||
newChHardware = newChHardware.TrimStart();
|
||||
newChHardware = newChHardware.TrimStart('\\').Trim();
|
||||
}
|
||||
}
|
||||
|
||||
return newChHardware;
|
||||
}
|
||||
}
|
||||
}
|
||||
15
Common/DTS.Common/Classes/TestSetups/SimpleHardware.cs
Normal file
15
Common/DTS.Common/Classes/TestSetups/SimpleHardware.cs
Normal file
@@ -0,0 +1,15 @@
|
||||
using System;
|
||||
|
||||
namespace DTS.Common.Classes.TestSetups
|
||||
{
|
||||
public class SimpleHardware : Tuple<string, string, int, int>
|
||||
{
|
||||
public SimpleHardware(string serialNumber, string parentDAS, int dasId, int dasType) : base(serialNumber, parentDAS, dasId, dasType)
|
||||
{
|
||||
}
|
||||
public string SerialNumber => Item1;
|
||||
public string ParentDAS => Item2;
|
||||
public int DASId => Item3;
|
||||
public int DASType => Item4;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,79 @@
|
||||
using DTS.Common.Interface.TestSetups;
|
||||
using System.Data;
|
||||
|
||||
namespace DTS.Common.Classes.TestSetups
|
||||
{
|
||||
/// <summary>
|
||||
/// implements a record for test setup hardware
|
||||
/// <inheritdoc cref="ITestSetupHardwareRecord"/>
|
||||
/// </summary>
|
||||
public class TestSetupHardwareRecord : Base.BasePropertyChanged, ITestSetupHardwareRecord
|
||||
{
|
||||
private int _dasId = -1;
|
||||
public int DASId
|
||||
{
|
||||
get => _dasId;
|
||||
set => SetProperty(ref _dasId, value, "DASId");
|
||||
}
|
||||
private int _testSetupId;
|
||||
public int TestSetupId
|
||||
{
|
||||
get => _testSetupId;
|
||||
set => SetProperty(ref _testSetupId, value, "TestSetupId");
|
||||
}
|
||||
private bool _addDAS = true;
|
||||
public bool AddDAS
|
||||
{
|
||||
get => _addDAS;
|
||||
set => SetProperty(ref _addDAS, value, "AddDAS");
|
||||
}
|
||||
private int _samplesPerSecond;
|
||||
public int SamplesPerSecond
|
||||
{
|
||||
get => _samplesPerSecond;
|
||||
set => SetProperty(ref _samplesPerSecond, value, "SamplesPerSecond");
|
||||
}
|
||||
private bool _isClockMaster = false;
|
||||
public bool IsClockMaster
|
||||
{
|
||||
get => _isClockMaster;
|
||||
set => SetProperty(ref _isClockMaster, value, "IsClockMaster");
|
||||
}
|
||||
private byte _ptpDomainId = 0;
|
||||
public byte PTPDomainId
|
||||
{
|
||||
get => _ptpDomainId;
|
||||
set => SetProperty(ref _ptpDomainId, value, "PTPDomainId");
|
||||
}
|
||||
private int _antiAliasFilterRate;
|
||||
public int AntiAliasFilterRate
|
||||
{
|
||||
get => _antiAliasFilterRate;
|
||||
set => SetProperty(ref _antiAliasFilterRate, value, "AntiAliasFilterRate");
|
||||
}
|
||||
public TestSetupHardwareRecord() { }
|
||||
public TestSetupHardwareRecord(IDataReader reader, int storedProcedureVersionToUse)
|
||||
{
|
||||
DASId = Utility.GetInt(reader, "DASId");
|
||||
TestSetupId = Utility.GetInt(reader, "TestSetupId");
|
||||
AddDAS = Utility.GetBool(reader, "AddOrRemove");
|
||||
SamplesPerSecond = Utility.GetInt(reader, "SamplesPerSecond");
|
||||
IsClockMaster = Utility.GetBool(reader, "IsClockMaster");
|
||||
AntiAliasFilterRate = Utility.GetInt(reader, "AntiAliasFilterRate");
|
||||
if (storedProcedureVersionToUse >= DTS.Common.Constants.PTP_DOMAIN_ID_DB_VERSION)
|
||||
{
|
||||
PTPDomainId = (byte)Utility.GetInt(reader, "PTPDomainID");
|
||||
}
|
||||
}
|
||||
public TestSetupHardwareRecord(ITestSetupHardwareRecord copy)
|
||||
{
|
||||
DASId = copy.DASId;
|
||||
TestSetupId = copy.TestSetupId;
|
||||
AddDAS = copy.AddDAS;
|
||||
SamplesPerSecond = copy.SamplesPerSecond;
|
||||
IsClockMaster = copy.IsClockMaster;
|
||||
AntiAliasFilterRate = copy.AntiAliasFilterRate;
|
||||
PTPDomainId = copy.PTPDomainId;
|
||||
}
|
||||
}
|
||||
}
|
||||
34
Common/DTS.Common/Classes/TestSetups/TestSetupHelper.cs
Normal file
34
Common/DTS.Common/Classes/TestSetups/TestSetupHelper.cs
Normal file
@@ -0,0 +1,34 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace DTS.Common.Classes.TestSetups
|
||||
{
|
||||
public abstract class TestSetupHelper
|
||||
{
|
||||
#region TestSetupNames
|
||||
private static Dictionary<int, string> TestSetupNames = new Dictionary<int, string>();
|
||||
public static void ClearTestSetupNames()
|
||||
{
|
||||
TestSetupNames.Clear();
|
||||
}
|
||||
public static void SetTestSetupName(int id, string name)
|
||||
{
|
||||
TestSetupNames[id] = name;
|
||||
}
|
||||
public static string GetTestSetupName(int Id)
|
||||
{
|
||||
var name = string.Empty;
|
||||
|
||||
if (TestSetupNames.ContainsKey(Id))
|
||||
{
|
||||
name = TestSetupNames[Id];
|
||||
}
|
||||
|
||||
return name;
|
||||
}
|
||||
#endregion TestSetupNames
|
||||
}
|
||||
}
|
||||
91
Common/DTS.Common/Classes/TestSetups/TestSetupROIsRecord.cs
Normal file
91
Common/DTS.Common/Classes/TestSetups/TestSetupROIsRecord.cs
Normal file
@@ -0,0 +1,91 @@
|
||||
using DTS.Common.Base;
|
||||
using DTS.Common.Interface.TestSetups;
|
||||
using System.Data;
|
||||
|
||||
namespace DTS.Common.Classes.TestSetups
|
||||
{
|
||||
/// <summary>
|
||||
/// Describes a record in the TestSetupROIs table
|
||||
/// </summary>
|
||||
public class TestSetupROIsRecord : BasePropertyChanged, ITestSetupROIRecord
|
||||
{
|
||||
/// <summary>
|
||||
/// The field that matches the same field in the ROIPeriodChannels table
|
||||
/// </summary>
|
||||
private int _testSetupROIId;
|
||||
public int TestSetupROIId
|
||||
{
|
||||
get => _testSetupROIId;
|
||||
set => SetProperty(ref _testSetupROIId, value, "TestSetupROIId");
|
||||
}
|
||||
/// <summary>
|
||||
/// The field that matches the same field in the TestSetups table
|
||||
/// </summary>
|
||||
private int _testSetupId;
|
||||
public int TestSetupId
|
||||
{
|
||||
get => _testSetupId;
|
||||
set => SetProperty(ref _testSetupId, value, "TestSetupId");
|
||||
}
|
||||
/// <summary>
|
||||
/// e.g. "_ROI Period 1", "_ROI Period 2", etc.
|
||||
/// </summary>
|
||||
private string _suffix = "";
|
||||
public string Suffix
|
||||
{
|
||||
get => _suffix;
|
||||
set => SetProperty(ref _suffix, value, "Suffix");
|
||||
}
|
||||
/// <summary>
|
||||
/// The starting time of the ROI period.
|
||||
/// </summary>
|
||||
private double _roiStart = -1.0D;
|
||||
public double ROIStart
|
||||
{
|
||||
get => _roiStart;
|
||||
set => SetProperty(ref _roiStart, value, "ROIStart");
|
||||
}
|
||||
/// <summary>
|
||||
/// The ending time of the ROI period.
|
||||
/// </summary>
|
||||
private double _roiEnd = 1.0D;
|
||||
public double ROIEnd
|
||||
{
|
||||
get => _roiEnd;
|
||||
set => SetProperty(ref _roiEnd, value, "ROIEnd");
|
||||
}
|
||||
/// <summary>
|
||||
/// Whether or not the period is enabled.
|
||||
/// </summary>
|
||||
private bool _isEnabled = true;
|
||||
public bool IsEnabled
|
||||
{
|
||||
get => _isEnabled;
|
||||
set => SetProperty(ref _isEnabled, value, "IsEnabled");
|
||||
}
|
||||
/// <summary>
|
||||
/// Whether or not the period is the default
|
||||
/// </summary>
|
||||
private bool _isDefault = true;
|
||||
public bool IsDefault
|
||||
{
|
||||
get => _isDefault;
|
||||
set => SetProperty(ref _isDefault, value, "IsDefault");
|
||||
}
|
||||
/// <summary>
|
||||
/// Builds a TestSetupROIs record after a call to sp_TestSetupROIsGet
|
||||
/// </summary>
|
||||
/// <param name="reader"></param>
|
||||
|
||||
public TestSetupROIsRecord(IDataReader reader)
|
||||
{
|
||||
TestSetupROIId = Utility.GetInt(reader, "TestSetupROIId");
|
||||
TestSetupId = Utility.GetInt(reader, "TestSetupROIId");
|
||||
Suffix = Utility.GetString(reader, "Suffix");
|
||||
ROIStart = Utility.GetDouble(reader, "ROIStart", -1);
|
||||
ROIEnd = Utility.GetDouble(reader, "ROIEnd", 1);
|
||||
IsEnabled = Utility.GetBool(reader, "IsEnabled");
|
||||
IsDefault = Utility.GetBool(reader, "IsDefault");
|
||||
}
|
||||
}
|
||||
}
|
||||
1404
Common/DTS.Common/Classes/TestSetups/TestSetupRecord.cs
Normal file
1404
Common/DTS.Common/Classes/TestSetups/TestSetupRecord.cs
Normal file
File diff suppressed because it is too large
Load Diff
1004
Common/DTS.Common/Classes/TestSetups/TestTemplateBase.cs
Normal file
1004
Common/DTS.Common/Classes/TestSetups/TestTemplateBase.cs
Normal file
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user