using DTS.Common.Base; using DTS.Common.Interface.TestSetups; using System.Data; using System.Globalization; using System.Linq; namespace DTS.Common.Classes.TestSetups { /// /// describes Calculated Channel record in the db /// /// 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; /// /// Database Id for record /// public int Id { get => _id; set => SetProperty(ref _id, value, "Id"); } private Operations _operation = Operations.SUM; /// /// operation to apply to input channels /// public Operations Operation { get => _operation; set => SetProperty(ref _operation, value, "Operation"); } private string _calculatedChannelValueCode = ""; /// /// Single code (ISO or user) to associate with calculated channel /// public string CalculatedValueCode { get => _calculatedChannelValueCode; set => SetProperty(ref _calculatedChannelValueCode, value, "CalculatedValueCode"); } protected string[] _inputChannelIds = new[] { "-1" }; /// /// CSV separated list of channel ids that are inputs for the calculation /// public string[] InputChannelIds { get => _inputChannelIds; set => SetProperty(ref _inputChannelIds, value, "InputChannelIds"); } private string _cfcForInputChannels = ""; /// /// CFC to apply to input channels prior to calculation /// public string CFCForInputChannels { get => _cfcForInputChannels; set => SetProperty(ref _cfcForInputChannels, value, "CFCForInputChannels"); } private string _cfcForOutput = ""; /// /// CFC to apply to output of calculation /// public string ChannelFilterClassForOutput { get => _cfcForOutput; set => SetProperty(ref _cfcForOutput, value, "ChannelFilterClassForOutput"); } private int _testSetupId; /// /// Database Id for test setup record /// public int TestSetupId { get => _testSetupId; set => SetProperty(ref _testSetupId, value, "TestSetupId"); } private bool _viewInRealtime; /// /// Whether channel can be viewed in realtime or not /// public bool ViewInRealtime { get => _viewInRealtime; set => SetProperty(ref _viewInRealtime, value, "ViewInRealtime"); } private int _clipLength; /// /// Clip length to apply to calculation if relevant /// some calculations are a max over an clip for example /// 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); } } }