201 lines
8.0 KiB
Plaintext
201 lines
8.0 KiB
Plaintext
using DTS.Common.Base;
|
|
using DTS.Common.Enums.DASFactory;
|
|
using DTS.Common.Interface.DataRecorders;
|
|
using System;
|
|
using System.ComponentModel.DataAnnotations;
|
|
using System.ComponentModel.DataAnnotations.Schema;
|
|
using System.Data;
|
|
using System.Linq;
|
|
|
|
namespace DTS.Common.Classes.Hardware
|
|
{
|
|
[Table("DAS")]
|
|
/// <summary>
|
|
/// Implementation of <seealso cref="IDASDBRecord"/>
|
|
/// <inheritdoc cref="IDASDBRecord"/>
|
|
/// </summary>
|
|
public class DASDBRecord : BasePropertyChanged, IDASDBRecord
|
|
{
|
|
public static DateTime INVALID_DATE => new DateTime(1970, 1, 1);
|
|
public DASDBRecord()
|
|
{
|
|
}
|
|
|
|
public DASDBRecord(IDASDBRecord copy)
|
|
{
|
|
CalDate = copy.CalDate;
|
|
Connection = copy.Connection;
|
|
Channels = copy.Channels;
|
|
FirmwareVersion = copy.FirmwareVersion;
|
|
LastModified = copy.LastModified;
|
|
LastModifiedBy = copy.LastModifiedBy;
|
|
LastUsed = copy.LastUsed;
|
|
LastUsedBy = copy.LastUsedBy;
|
|
LocalOnly = copy.LocalOnly;
|
|
MaxMemory = copy.MaxMemory;
|
|
MaxModules = copy.MaxModules;
|
|
MaxSampleRate = copy.MaxSampleRate;
|
|
MinSampleRate = copy.MinSampleRate;
|
|
Position = copy.Position;
|
|
IsReconfigurable = copy.IsReconfigurable;
|
|
IsModule = copy.IsModule;
|
|
IsProgrammable = copy.IsProgrammable;
|
|
ProtocolVersion = copy.ProtocolVersion;
|
|
SerialNumber = copy.SerialNumber;
|
|
DASType = copy.DASType;
|
|
DASId = copy.DASId;
|
|
|
|
var channelTypes = new int[copy.ChannelTypes.Length];
|
|
Array.Copy(copy.ChannelTypes, channelTypes, copy.ChannelTypes.Length);
|
|
ChannelTypes = channelTypes;
|
|
|
|
Version = copy.Version;
|
|
ParentDAS = copy.ParentDAS;
|
|
|
|
Port = copy.Port;
|
|
|
|
PositionOnChain = copy.PositionOnChain;
|
|
PositionOnDistributor = copy.PositionOnDistributor;
|
|
|
|
FirstUseDate = copy.FirstUseDate;
|
|
IsFirstUseValid = copy.IsFirstUseValid;
|
|
|
|
StandIn = copy.StandIn;
|
|
|
|
TestId = copy.TestId;
|
|
|
|
GroupId = copy.GroupId;
|
|
|
|
MaxAAFRate = copy.MaxAAFRate;
|
|
}
|
|
public DASDBRecord(IDataReader reader)
|
|
{
|
|
CalDate = Utility.GetDateTime(reader, "CalDate", DateTime.MinValue);
|
|
Connection = Utility.GetString(reader, "Connection", string.Empty);
|
|
Channels = Utility.GetInt(reader, "Channels", 0);
|
|
FirmwareVersion = Utility.GetString(reader, "FirmwareVersion", string.Empty);
|
|
LastModified = Utility.GetDateTime(reader, "LastModified", DateTime.MinValue);
|
|
LastModifiedBy = Utility.GetString(reader, "LastModifiedBy", string.Empty);
|
|
LastUsed = Utility.GetDateTime(reader, "LastUsed", DateTime.MinValue);
|
|
LastUsedBy = Utility.GetString(reader, "LastUsedBy", string.Empty);
|
|
LocalOnly = Utility.GetBool(reader, "LocalOnly", false);
|
|
MaxMemory = Utility.GetLong(reader, "MaxMemory", 0);
|
|
MaxModules = Utility.GetInt(reader, "MaxModules", 0);
|
|
MaxSampleRate = Utility.GetDouble(reader, "MaxSampleRate", 0);
|
|
MinSampleRate = Utility.GetDouble(reader, "MinSampleRate", 0);
|
|
Position = Utility.GetString(reader, "Position", string.Empty);
|
|
IsReconfigurable = Utility.GetBool(reader, "Reconfigurable", false);
|
|
IsModule = Utility.GetBool(reader, "IsModule", false);
|
|
IsProgrammable = Utility.GetBool(reader, "Reprogramable", false);
|
|
ProtocolVersion = Utility.GetInt(reader, "ProtocolVersion", 0);
|
|
SerialNumber = Utility.GetString(reader, "SerialNumber", string.Empty);
|
|
DASType = Utility.GetInt(reader, "Type", -1);
|
|
DASId = Utility.GetInt(reader, "DASId", -1);
|
|
|
|
var o = reader["ChannelTypes"];
|
|
if (null != o && !DBNull.Value.Equals(o))
|
|
{
|
|
var s = Utility.GetString(reader, "ChannelTypes", string.Empty);
|
|
var tokens = s.Split(new char[] { ',' });
|
|
var itemp = 0;
|
|
ChannelTypes = (from token in tokens where int.TryParse(token, out itemp) select itemp).ToArray();
|
|
}
|
|
|
|
Version = Utility.GetInt(reader, "Version", 0);
|
|
ParentDAS = Utility.GetString(reader, "ParentDAS", string.Empty);
|
|
|
|
Port = Utility.GetInt(reader, "Port", 0);
|
|
|
|
PositionOnChain = Utility.GetInt(reader, "PositionOnChain", 0);
|
|
PositionOnDistributor = Utility.GetInt(reader, "PositionOnDistributor", 0);
|
|
|
|
o = reader["FirstUseDate"];
|
|
if (DBNull.Value.Equals(o))
|
|
{
|
|
FirstUseDate = null;
|
|
IsFirstUseValid = false;
|
|
}
|
|
else
|
|
{
|
|
var dt = Convert.ToDateTime(o);
|
|
if (dt.Year.Equals(DFConstantsAndEnums.FIRST_USE_DATE_NOT_SET.Year))
|
|
{
|
|
FirstUseDate = null;
|
|
}
|
|
else
|
|
{
|
|
FirstUseDate = dt;
|
|
}
|
|
|
|
IsFirstUseValid = true;
|
|
}
|
|
|
|
StandIn = Utility.GetBool(reader, "StandIn", false);
|
|
|
|
TestId = Utility.GetNullableInt(reader, "TestId");
|
|
|
|
GroupId = Utility.GetNullableInt(reader, "GroupId");
|
|
|
|
MaxAAFRate = Utility.GetDouble(reader, "MaxAAFRate", double.NaN);
|
|
}
|
|
[Key]
|
|
[Column("DASId")]
|
|
public int DASId { get; set; }
|
|
[Required]
|
|
[StringLength(50)]
|
|
public string SerialNumber { get; set; }
|
|
public int DASType { get; set; }
|
|
public int MaxModules { get; set; }
|
|
public long MaxMemory { get; set; }
|
|
[Column(TypeName = "decimal(18, 0)")]
|
|
public double MaxSampleRate { get; set; }
|
|
[Column(TypeName = "decimal(18, 0)")]
|
|
public double MinSampleRate { get; set; }
|
|
[StringLength(50)]
|
|
public string FirmwareVersion { get; set; } = "";
|
|
[Column(TypeName = "datetime")]
|
|
public DateTime CalDate { get; set; } = INVALID_DATE;
|
|
public int ProtocolVersion { get; set; }
|
|
[Column(TypeName = "datetime")]
|
|
public DateTime LastModified { get; set; }
|
|
[StringLength(50)]
|
|
public string LastModifiedBy { get; set; } = "";
|
|
public int Version { get; set; }
|
|
public bool LocalOnly { get; set; }
|
|
[Column(TypeName = "datetime")]
|
|
public DateTime LastUsed { get; set; } = INVALID_DATE;
|
|
[StringLength(50)]
|
|
public string LastUsedBy { get; set; } = "";
|
|
[StringLength(50)]
|
|
public string Connection { get; set; } = "";
|
|
public int Channels { get; set; }
|
|
[Required]
|
|
[StringLength(50)]
|
|
public string Position { get; set; } = "";
|
|
[StringLength(255)]
|
|
public int[] ChannelTypes { get; set; }
|
|
public bool IsProgrammable { get; set; }
|
|
public bool IsReconfigurable { get; set; }
|
|
public bool IsModule { get; set; }
|
|
public int PositionOnDistributor { get; set; }
|
|
public int PositionOnChain { get; set; }
|
|
public int Port { get; set; }
|
|
[Column("ParentDAS")]
|
|
[StringLength(50)]
|
|
public string ParentDAS { get; set; } = "";
|
|
[Column(TypeName = "datetime")]
|
|
public DateTime? FirstUseDate { get; set; }
|
|
public int? TestId { get; set; }
|
|
public int? GroupId { get; set; }
|
|
public bool StandIn { get; set; }
|
|
[Column("MaxAAFRate", TypeName = "decimal(18, 0)")]
|
|
public double MaxAAFRate { get; set; }
|
|
|
|
/// <summary>
|
|
/// whether hardware supports and is using first use date
|
|
/// 15524 DAS "First Use Date"
|
|
/// </summary>
|
|
public bool IsFirstUseValid { get; set; } = false;
|
|
}
|
|
}
|