150 lines
5.5 KiB
Plaintext
150 lines
5.5 KiB
Plaintext
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);
|
|
}
|
|
}
|
|
}
|