init
This commit is contained in:
@@ -0,0 +1,14 @@
|
||||
using DTS.Common.Interface.TestSetups.Imports.TTS.ReadFile;
|
||||
using Prism.Events;
|
||||
|
||||
namespace DTS.Common.Events.TTSImport
|
||||
{
|
||||
|
||||
/// <summary>
|
||||
/// The AssignedChannelsChangedEvent event.
|
||||
/// </summary>
|
||||
///
|
||||
/// <remarks>This event is published whenever the assigned channels are changed.</remarks>
|
||||
///
|
||||
public class AssignedChannelsChangedEvent : PubSubEvent<ITTSSetup> { }
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
using DTS.Common.Base;
|
||||
using DTS.Common.Interface.TestSetups.Imports.TTS.ReadFile;
|
||||
|
||||
namespace DTS.Common.Interface.TestSetups.Imports.TTS
|
||||
{
|
||||
public interface IEditFileViewModel : IBaseViewModel
|
||||
{
|
||||
IEditFileView View { get; set; }
|
||||
bool Validate();
|
||||
/// <summary>
|
||||
/// validates changes on page
|
||||
/// if record is passed in, also makes sure there are no
|
||||
/// RequiredChannels with identical channel codes
|
||||
/// </summary>
|
||||
/// <param name="record">null, or record being changed</param>
|
||||
/// <returns></returns>
|
||||
bool ValidateChange(ITTSChannelRecord record = null);
|
||||
bool ChangeValidationIsNeeded { get; set; }
|
||||
/// <summary>
|
||||
/// Initializes components in View UI
|
||||
/// </summary>
|
||||
void InitializeView();
|
||||
/// <summary>
|
||||
/// filters the available sensors by the given text
|
||||
/// </summary>
|
||||
/// <param name="text"></param>
|
||||
void Search(string text);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,200 @@
|
||||
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;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,130 @@
|
||||
using DTS.Common.Interface.Sensors;
|
||||
using DTS.Common.Interface.Tags;
|
||||
using DTS.Common.Utilities.Logging;
|
||||
using System;
|
||||
using DTS.Common.Constant;
|
||||
using System.Data;
|
||||
|
||||
namespace DTS.Common.Classes.Sensors
|
||||
{
|
||||
#pragma warning disable S101 // Types should be named in PascalCase
|
||||
public class CANRecord : TagAwareBase, ICANRecord
|
||||
#pragma warning restore S101 // Types should be named in PascalCase
|
||||
{
|
||||
public override TagTypes TagType { get => TagTypes.Sensors; }
|
||||
private int _id;
|
||||
public int Id
|
||||
{
|
||||
get => _id;
|
||||
set => SetProperty(ref _id, value, "Id");
|
||||
}
|
||||
private string _serialNumber;
|
||||
public string SerialNumber
|
||||
{
|
||||
get => _serialNumber;
|
||||
set => SetProperty(ref _serialNumber, value, "SerialNumber");
|
||||
}
|
||||
private DateTime _lastModified;
|
||||
public DateTime LastModified
|
||||
{
|
||||
get => _lastModified;
|
||||
set => SetProperty(ref _lastModified, value, "LastModified");
|
||||
}
|
||||
private string _lastUpdatedBy;
|
||||
public string LastUpdatedBy
|
||||
{
|
||||
get => _lastUpdatedBy;
|
||||
set => SetProperty(ref _lastUpdatedBy, value, "LastUpdatedBy");
|
||||
}
|
||||
|
||||
private bool _doNotUse;
|
||||
public bool DoNotUse
|
||||
{
|
||||
get => _doNotUse;
|
||||
set => SetProperty(ref _doNotUse, value, "DoNotUse");
|
||||
}
|
||||
private bool _broken;
|
||||
public bool Broken
|
||||
{
|
||||
get => _broken;
|
||||
set => SetProperty(ref _broken, value, "Broken");
|
||||
}
|
||||
private bool _canIsFD = EmbeddedSensors.CANISFD_DEFAULT;
|
||||
public bool CanIsFD
|
||||
{
|
||||
get => _canIsFD;
|
||||
set => SetProperty(ref _canIsFD, value, "CanIsFD");
|
||||
}
|
||||
private int _canArbBaseBitrate = EmbeddedSensors.CANFD_ARB_BASE_BITRATE_DEFAULT;
|
||||
public int CanArbBaseBitrate
|
||||
{
|
||||
get => _canArbBaseBitrate;
|
||||
set => SetProperty(ref _canArbBaseBitrate, value, "CanArbBaseBitrate");
|
||||
}
|
||||
private int _canArbBaseSJW = EmbeddedSensors.CANFD_1000000_ARB_BASE_SJW_MAX;
|
||||
public int CanArbBaseSJW
|
||||
{
|
||||
get => _canArbBaseSJW;
|
||||
set => SetProperty(ref _canArbBaseSJW, value, "CanArbBaseSJW");
|
||||
}
|
||||
private int _canDataBitrate = EmbeddedSensors.DATA_BITRATE_DEFAULT;
|
||||
public int CanDataBitrate
|
||||
{
|
||||
get => _canDataBitrate;
|
||||
set => SetProperty(ref _canDataBitrate, value, "CanDataBitrate");
|
||||
}
|
||||
private int _canDataSJW = EmbeddedSensors.DATA_SJW_DEFAULT;
|
||||
public int CanDataSJW
|
||||
{
|
||||
get => _canDataSJW;
|
||||
set => SetProperty(ref _canDataSJW, value, "CanDataSJW");
|
||||
}
|
||||
private string _canFileType = EmbeddedSensors.FILETYPE_DEFAULT;
|
||||
public string CanFileType
|
||||
{
|
||||
get => _canFileType;
|
||||
set => SetProperty(ref _canFileType, value, "CanFileType");
|
||||
}
|
||||
public CANRecord(ISensorData sensor)
|
||||
{
|
||||
Id = sensor.DatabaseId;
|
||||
SerialNumber = sensor.SerialNumber;
|
||||
|
||||
CanIsFD = sensor.CanIsFD;
|
||||
CanArbBaseBitrate = sensor.CanArbBaseBitrate;
|
||||
CanArbBaseSJW = sensor.CanArbBaseSJW;
|
||||
CanDataBitrate = sensor.CanDataBitrate;
|
||||
CanDataSJW = sensor.CanDataSJW;
|
||||
CanFileType = sensor.CanFileType;
|
||||
|
||||
Broken = sensor.Broken;
|
||||
DoNotUse = sensor.DoNotUse;
|
||||
LastModified = sensor.LastModified;
|
||||
LastUpdatedBy = sensor.LastUpdatedBy;
|
||||
}
|
||||
public CANRecord(IDataReader reader)
|
||||
{
|
||||
try
|
||||
{
|
||||
Id = Utility.GetInt(reader, "Id");
|
||||
SerialNumber = Utility.GetString(reader, "SerialNumber");
|
||||
|
||||
CanIsFD = Utility.GetBool(reader, "IsFD");
|
||||
CanArbBaseBitrate = Utility.GetInt(reader, "ArbBaseBitrate");
|
||||
CanArbBaseSJW = Utility.GetInt(reader, "ArbBaseSJW");
|
||||
CanDataBitrate = Utility.GetInt(reader, "DataBitrate");
|
||||
CanDataSJW = Utility.GetInt(reader, "DataSJW");
|
||||
CanFileType = Utility.GetString(reader, "FileType");
|
||||
|
||||
Broken = Utility.GetBool(reader, "Broken");
|
||||
DoNotUse = Utility.GetBool(reader, "DoNotUse");
|
||||
LastModified = Utility.GetDateTime(reader, "LastModified", DateTime.MinValue);
|
||||
LastUpdatedBy = Utility.GetString(reader, "LastModifiedBy");
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
APILogger.Log("Failed to process: ", ex);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user