init
This commit is contained in:
218
Common/DTS.CommonCore/Classes/Hardware/DASChannelDBRecord.cs
Normal file
218
Common/DTS.CommonCore/Classes/Hardware/DASChannelDBRecord.cs
Normal file
@@ -0,0 +1,218 @@
|
||||
using DTS.Common.Interface.DataRecorders;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
using System.Data;
|
||||
|
||||
namespace DTS.Common.Classes.Hardware
|
||||
{
|
||||
/// <summary>
|
||||
/// representation of a DASChannel in the db
|
||||
/// <inheritdoc cref="IDASChannelDBRecord"/>
|
||||
/// </summary>
|
||||
public class DASChannelDBRecord : Common.Base.BasePropertyChanged, IDASChannelDBRecord
|
||||
{
|
||||
/// <summary>
|
||||
/// a string id for the hardware the channel belongs to
|
||||
/// (serialnumber_dastype)
|
||||
/// </summary>
|
||||
public string HardwareId { get; set; }
|
||||
[Key]
|
||||
[Column("DASChannelId")]
|
||||
/// <summary>
|
||||
/// the id/key of the DAS channel record in the db
|
||||
/// </summary>
|
||||
public int DaschannelId { get; set; }
|
||||
[Column("DASId")]
|
||||
/// <summary>
|
||||
/// the das db id of the Hardware this channel belongs to
|
||||
/// </summary>
|
||||
public int? Dasid { get; set; }
|
||||
|
||||
private int _channelIdx;
|
||||
/// <summary>
|
||||
/// the physical channel index of the channel among channels on the DAS
|
||||
/// </summary>
|
||||
public int ChannelIdx
|
||||
{
|
||||
get => _channelIdx;
|
||||
set => SetProperty(ref _channelIdx, value, "ChannelIdx");
|
||||
}
|
||||
/// <summary>
|
||||
/// BitMask indicating the supported bridges on a das by default (half (4) + full (8))bridge
|
||||
/// </summary>
|
||||
public const int DEFAULT_SUPPORTED_BRIDGES = 12;
|
||||
private int _supportedBridges = DEFAULT_SUPPORTED_BRIDGES;
|
||||
/// <summary>
|
||||
/// BitMask for bridges supported by the channel
|
||||
/// Bit 0 indicates IEPE
|
||||
/// Bit 1 indicates quarter bridge
|
||||
/// Bit 2 indicates half bridge
|
||||
/// Bit 3 indicates full bridge
|
||||
/// Bit 4 indicates digital input
|
||||
/// Bit 5 indicates squib fire
|
||||
/// Bit 6 indicates digital output
|
||||
/// Bit 7 indicates Half bridge signal plus (G5 signal plus)
|
||||
/// Bit 8 indicates RealTime Clock
|
||||
/// Bit 9 indicates UART
|
||||
/// </summary>
|
||||
public int SupportedBridges
|
||||
{
|
||||
get => _supportedBridges;
|
||||
set => SetProperty(ref _supportedBridges, value, "SupportedBridges");
|
||||
}
|
||||
/// <summary>
|
||||
/// BitMask indicating the supported excitations for a das channel by default
|
||||
/// (5V by default)
|
||||
/// </summary>
|
||||
public const int DEFAULT_SUPPORTED_EXCITATIONS = 16;
|
||||
private int _supporedExcitations = DEFAULT_SUPPORTED_EXCITATIONS;
|
||||
/// <summary>
|
||||
/// BitMask indicating what excitation options the channel supports
|
||||
/// Bit 0 indicates an invalid excitation (undefined)
|
||||
/// Bit 1 indicates 2V
|
||||
/// Bit 2 indicates 2.5V
|
||||
/// Bit 3 indicates 3V
|
||||
/// Bit 4 indicates 5V
|
||||
/// Bit 5 indicates 10V
|
||||
/// Bit 6 indicates 1V
|
||||
/// </summary>
|
||||
public int SupportedExcitations
|
||||
{
|
||||
get => _supporedExcitations;
|
||||
set => SetProperty(ref _supporedExcitations, value, "SupportedExcitations");
|
||||
}
|
||||
[Column("DASDisplayOrder")]
|
||||
private int _dasDisplayOrder;
|
||||
/// <summary>
|
||||
/// The display order of the channel among channels on the DAS
|
||||
/// note that the physical order of channels and the display order may not match for
|
||||
/// some hardware
|
||||
/// </summary>
|
||||
public int DASDisplayOrder
|
||||
{
|
||||
get => _dasDisplayOrder;
|
||||
set => SetProperty(ref _dasDisplayOrder, value, "DASDisplayOrder");
|
||||
}
|
||||
private bool _bLocalOnly;
|
||||
/// <summary>
|
||||
/// Indicates that record should be stored only in the local db and not propagated to a central db
|
||||
/// deprecated
|
||||
/// </summary>
|
||||
public bool LocalOnly
|
||||
{
|
||||
get => _bLocalOnly;
|
||||
set => SetProperty(ref _bLocalOnly, value, "LocalOnly");
|
||||
}
|
||||
/// <summary>
|
||||
/// Bitmask indicating the default supported digital input modes for a channel (CCNC)
|
||||
/// </summary>
|
||||
public const int DEFAULT_SUPPORTED_DI_MODES = 16;
|
||||
private int _supportedDigitalInputModes = DEFAULT_SUPPORTED_DI_MODES;
|
||||
/// <summary>
|
||||
/// BitMask indicating what Digital input modes are supported on the channel (if channel supports digital input bridge type)
|
||||
/// Bit 0 indicates an invalid mode
|
||||
/// Bit 1 indicates Transition low to high (TLH)
|
||||
/// Bit 2 indicates Transition high to low (THL)
|
||||
/// Bit 3 indicates Contact closure normally open (CCNO)
|
||||
/// Bit 4 indicates Contact closure normally closed (CCNC)
|
||||
/// </summary>
|
||||
public int SupportedDigitalInputModes
|
||||
{
|
||||
get => _supportedDigitalInputModes;
|
||||
set => SetProperty(ref _supportedDigitalInputModes, value, "SupportedDigitalInputModes");
|
||||
}
|
||||
/// <summary>
|
||||
/// BitMask indicating the default squib fire modes supported by a channel (note that 16 is invalid, but
|
||||
/// I'm preserving what is in the existing code)
|
||||
/// </summary>
|
||||
public const int DEFAULT_SQUIB_FIRE_MODES = 16;
|
||||
private int _supportedSquibFireModes = DEFAULT_SQUIB_FIRE_MODES;
|
||||
/// <summary>
|
||||
/// BitMask indicating what Squib fire modes are supported on the channel (if the channel supports squib fire bridge type)
|
||||
/// Bit 0 indicates an invalid mode (fire mode not set)
|
||||
/// Bit 1 indicates capacitor discharge
|
||||
/// Bit 2 indicates constant current
|
||||
/// Bit 3 indicates AC discharge
|
||||
/// </summary>
|
||||
public int SupportedSquibFireModes
|
||||
{
|
||||
get => _supportedSquibFireModes;
|
||||
set => SetProperty(ref _supportedSquibFireModes, value, "SupportedSquibFireModes");
|
||||
}
|
||||
/// <summary>
|
||||
/// Default digital output mode for channels 16 doesn't exist, but I'm preserving the existing behavior values
|
||||
/// </summary>
|
||||
public const int DEFAULT_SUPPORTED_DO_MODES = 16;
|
||||
private int _supportedDigitalOutputModes = DEFAULT_SUPPORTED_DO_MODES;
|
||||
|
||||
/// <summary>
|
||||
/// BitMask indicating what digital output modes are supported on the channel (if the channel supports digital output bridge type)
|
||||
/// Bit 0 indicates 5V low to high (FVLH)
|
||||
/// Bit 1 indicates 5V high to low transition (FVHL)
|
||||
/// Bit 2 indicates contact closure normally open (CCNO)
|
||||
/// Bit 3 indicates contact closure normally closed (CCNC)
|
||||
/// </summary>
|
||||
public int SupportedDigitalOutputModes
|
||||
{
|
||||
get => _supportedDigitalOutputModes;
|
||||
set => SetProperty(ref _supportedDigitalOutputModes, value, "SupportedDigitalOutputModes");
|
||||
}
|
||||
[StringLength(16)]
|
||||
protected string _moduleSerialNumber = "";
|
||||
/// <summary>
|
||||
/// Serial number of module channel belongs to
|
||||
/// </summary>
|
||||
public string ModuleSerialNumber
|
||||
{
|
||||
get => _moduleSerialNumber;
|
||||
set => SetProperty(ref _moduleSerialNumber, value, "ModuleSerialNumber");
|
||||
}
|
||||
public int SettingId { get; set; }
|
||||
protected int _moduleArrayIndex;
|
||||
/// <summary>
|
||||
/// Array index of module among modules on a DAS or Rack
|
||||
/// </summary>
|
||||
public int ModuleArrayIndex
|
||||
{
|
||||
get => _moduleArrayIndex;
|
||||
set => _moduleArrayIndex = value;
|
||||
}
|
||||
public DASChannelDBRecord() { }
|
||||
/// <summary>
|
||||
/// constructor using a datareader to retrieve values
|
||||
/// </summary>
|
||||
/// <param name="reader"></param>
|
||||
public DASChannelDBRecord(IDataReader reader)
|
||||
{
|
||||
HardwareId = Utility.GetString(reader, "HardwareId", string.Empty);
|
||||
ChannelIdx = Utility.GetInt(reader, "ChannelIdx", -1);
|
||||
SupportedBridges = Utility.GetInt(reader, "SupportedBridges", DEFAULT_SUPPORTED_BRIDGES);
|
||||
SupportedExcitations = Utility.GetInt(reader, "SupportedExcitations", DEFAULT_SUPPORTED_EXCITATIONS);
|
||||
SupportedDigitalInputModes = Utility.GetInt(reader, "SupportedDigitalInputModes", DEFAULT_SUPPORTED_DI_MODES);
|
||||
SupportedDigitalOutputModes = Utility.GetInt(reader, "SupportedDigitalOutputModes", DEFAULT_SUPPORTED_DO_MODES);
|
||||
SupportedSquibFireModes = Utility.GetInt(reader, "SupportedSquibFireModes", DEFAULT_SQUIB_FIRE_MODES);
|
||||
DASDisplayOrder = Utility.GetInt(reader, "DASDisplayOrder", 0);
|
||||
ModuleSerialNumber = Utility.GetString(reader, "ModuleSerialNumber", string.Empty);
|
||||
LocalOnly = Utility.GetBool(reader, "LocalOnly", false);
|
||||
ModuleArrayIndex = Utility.GetInt(reader, "ModuleArrayIndex", -1);
|
||||
}
|
||||
/// <summary>
|
||||
/// copy constructor
|
||||
/// </summary>
|
||||
/// <param name="copy"></param>
|
||||
public DASChannelDBRecord(IDASChannelDBRecord copy)
|
||||
{
|
||||
HardwareId = copy.HardwareId;
|
||||
ChannelIdx = copy.ChannelIdx;
|
||||
SupportedBridges = copy.SupportedBridges;
|
||||
SupportedExcitations = copy.SupportedExcitations;
|
||||
SupportedDigitalInputModes = copy.SupportedDigitalInputModes;
|
||||
SupportedDigitalOutputModes = copy.SupportedDigitalOutputModes;
|
||||
SupportedSquibFireModes = copy.SupportedSquibFireModes;
|
||||
DASDisplayOrder = copy.DASDisplayOrder;
|
||||
ModuleSerialNumber = copy.ModuleSerialNumber;
|
||||
LocalOnly = copy.LocalOnly;
|
||||
ModuleArrayIndex = copy.ModuleArrayIndex;
|
||||
}
|
||||
}
|
||||
}
|
||||
200
Common/DTS.CommonCore/Classes/Hardware/DASDBRecord.cs
Normal file
200
Common/DTS.CommonCore/Classes/Hardware/DASDBRecord.cs
Normal file
@@ -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;
|
||||
}
|
||||
}
|
||||
359
Common/DTS.CommonCore/Classes/Hardware/DASMonitorInfo.cs
Normal file
359
Common/DTS.CommonCore/Classes/Hardware/DASMonitorInfo.cs
Normal file
@@ -0,0 +1,359 @@
|
||||
using DTS.Common.Enums;
|
||||
using DTS.Common.Enums.DASFactory;
|
||||
using DTS.Common.Interface.DASFactory;
|
||||
using DTS.Common.Interface.Hardware;
|
||||
using DTS.Common.Utilities.Logging;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Globalization;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
|
||||
namespace DTS.Common.Classes.Hardware
|
||||
{
|
||||
public class DASMonitorInfo : IDASMonitorInfo
|
||||
{
|
||||
public string SerialNumber { get; private set; }
|
||||
|
||||
public double[] TiltSensorCals { get; private set; } = new double[18];
|
||||
|
||||
public short[] TiltSensorDataPre { get; private set; } = new short[3];
|
||||
|
||||
public DFConstantsAndEnums.TiltAxes TiltAxes { get; private set; } = DFConstantsAndEnums.TiltAxes.IXIYIZ;
|
||||
|
||||
public int AxisIgnored { get; private set; }
|
||||
|
||||
public double MountOffsetAxisOne { get; private set; } = double.NaN;
|
||||
|
||||
public double MountOffsetAxisTwo { get; private set; } = double.NaN;
|
||||
|
||||
private string[] _channelNames = new string[0];
|
||||
|
||||
public string GetChannelName(int index)
|
||||
{
|
||||
if (index >= _channelNames.Length) { return $"{Strings.Strings.Ch}#{1 + index:00}"; }
|
||||
return _channelNames[index];
|
||||
}
|
||||
|
||||
private double[] _offsetTolerancesHigh = new double[6];
|
||||
public double GetOffsetTolerancemVHigh(int index)
|
||||
{
|
||||
if (index >= _offsetTolerancesHigh.Length) { return 0D; }
|
||||
return _offsetTolerancesHigh[index];
|
||||
}
|
||||
|
||||
private double[] _offsetTolerancesLow = new double[6];
|
||||
public double GetOffsetTolerancemVLow(int index)
|
||||
{
|
||||
if (index >= _offsetTolerancesLow.Length) { return 0D; }
|
||||
return _offsetTolerancesLow[index];
|
||||
}
|
||||
|
||||
public void ReadFromFile(string path)
|
||||
{
|
||||
if(!File.Exists(path)) { return; }
|
||||
try
|
||||
{
|
||||
var lines = File.ReadAllLines(path);
|
||||
var keys = Enum.GetValues(typeof(Fields)).Cast<Fields>().ToArray();
|
||||
for (var i = 0; i < lines.Length && i < keys.Length; i++)
|
||||
{
|
||||
var line = lines[i];
|
||||
var key = keys[i];
|
||||
switch (key)
|
||||
{
|
||||
case Fields.SerialNumber:
|
||||
SerialNumber = line;
|
||||
break;
|
||||
case Fields.TiltSensorCals:
|
||||
TiltSensorCals = ToDoubleArray(line);
|
||||
break;
|
||||
case Fields.TiltSensorDataPre:
|
||||
TiltSensorDataPre = ToShortArray(line);
|
||||
break;
|
||||
case Fields.TiltAxes:
|
||||
TiltAxes = (DFConstantsAndEnums.TiltAxes)Enum.Parse(typeof(DFConstantsAndEnums.TiltAxes), line);
|
||||
break;
|
||||
case Fields.AxesIgnored:
|
||||
AxisIgnored = int.Parse(line, CultureInfo.InvariantCulture);
|
||||
break;
|
||||
case Fields.MountOffsetAxisOne:
|
||||
MountOffsetAxisOne = double.Parse(line, CultureInfo.InvariantCulture);
|
||||
break;
|
||||
case Fields.MountOffsetAxisTwo:
|
||||
MountOffsetAxisTwo = double.Parse(line, CultureInfo.InvariantCulture);
|
||||
break;
|
||||
case Fields.ChannelNames:
|
||||
_channelNames = ToStringArray(line);
|
||||
break;
|
||||
case Fields.OffsetTolerancesLow:
|
||||
_offsetTolerancesLow = ToDoubleArray(line);
|
||||
break;
|
||||
case Fields.OffsetTolerancesHigh:
|
||||
_offsetTolerancesHigh = ToDoubleArray(line);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
catch( Exception ex)
|
||||
{
|
||||
APILogger.Log(ex);
|
||||
}
|
||||
}
|
||||
private short [] ToShortArray(string line)
|
||||
{
|
||||
var shorts = new List<short>();
|
||||
var tokens = line.Split(new[] { SEPARATOR }, StringSplitOptions.None);
|
||||
foreach (var token in tokens)
|
||||
{
|
||||
if (short.TryParse(line, NumberStyles.Any, CultureInfo.InvariantCulture, out var s))
|
||||
{
|
||||
shorts.Add(s);
|
||||
}
|
||||
}
|
||||
return shorts.ToArray();
|
||||
}
|
||||
private string [] ToStringArray(string line)
|
||||
{
|
||||
return line.Split(new[] { SEPARATOR }, StringSplitOptions.None);
|
||||
}
|
||||
private double [] ToDoubleArray(string line)
|
||||
{
|
||||
var doubles = new List<double>();
|
||||
var tokens = line.Split(new[] { SEPARATOR }, StringSplitOptions.None);
|
||||
foreach (var token in tokens)
|
||||
{
|
||||
if (double.TryParse(token, NumberStyles.Any, CultureInfo.InvariantCulture, out double d))
|
||||
{
|
||||
doubles.Add(d);
|
||||
}
|
||||
}
|
||||
return doubles.ToArray();
|
||||
}
|
||||
private const string SEPARATOR = ",";
|
||||
public void WriteToFile(string path)
|
||||
{
|
||||
try
|
||||
{
|
||||
var lines = new List<string>();
|
||||
var keys = Enum.GetValues(typeof(Fields)).Cast<Fields>().ToArray();
|
||||
foreach (var key in keys)
|
||||
{
|
||||
switch (key)
|
||||
{
|
||||
case Fields.SerialNumber:
|
||||
lines.Add(SerialNumber);
|
||||
break;
|
||||
case Fields.TiltSensorCals:
|
||||
lines.Add(ToString(TiltSensorCals));
|
||||
break;
|
||||
case Fields.TiltSensorDataPre:
|
||||
lines.Add(ToString(TiltSensorDataPre));
|
||||
break;
|
||||
case Fields.TiltAxes:
|
||||
lines.Add(TiltAxes.ToString());
|
||||
break;
|
||||
case Fields.AxesIgnored:
|
||||
lines.Add(AxisIgnored.ToString());
|
||||
break;
|
||||
case Fields.MountOffsetAxisOne:
|
||||
lines.Add(MountOffsetAxisOne.ToString(CultureInfo.InvariantCulture));
|
||||
break;
|
||||
case Fields.MountOffsetAxisTwo:
|
||||
lines.Add(MountOffsetAxisTwo.ToString(CultureInfo.InvariantCulture));
|
||||
break;
|
||||
case Fields.ChannelNames:
|
||||
lines.Add(ToString(_channelNames));
|
||||
break;
|
||||
case Fields.OffsetTolerancesLow:
|
||||
lines.Add(ToString(_offsetTolerancesLow));
|
||||
break;
|
||||
case Fields.OffsetTolerancesHigh:
|
||||
lines.Add(ToString(_offsetTolerancesHigh));
|
||||
break;
|
||||
}
|
||||
}
|
||||
File.WriteAllLines(path, lines.ToArray());
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
APILogger.Log(ex);
|
||||
}
|
||||
}
|
||||
private string ToString(string[] values)
|
||||
{
|
||||
return string.Join(SEPARATOR, values);
|
||||
}
|
||||
private string ToString(double[] values)
|
||||
{
|
||||
var l = new List<string>();
|
||||
foreach (var val in values)
|
||||
{
|
||||
l.Add(val.ToString(CultureInfo.InvariantCulture));
|
||||
}
|
||||
return ToString(l.ToArray());
|
||||
}
|
||||
private string ToString(short[] values)
|
||||
{
|
||||
var l = new List<string>();
|
||||
foreach (var val in values)
|
||||
{
|
||||
l.Add(val.ToString(CultureInfo.InvariantCulture));
|
||||
}
|
||||
return ToString(l.ToArray());
|
||||
}
|
||||
private enum Fields
|
||||
{
|
||||
SerialNumber,
|
||||
TiltSensorCals,
|
||||
TiltSensorDataPre,
|
||||
TiltAxes,
|
||||
AxesIgnored,
|
||||
MountOffsetAxisOne,
|
||||
MountOffsetAxisTwo,
|
||||
ChannelNames,
|
||||
OffsetTolerancesLow,
|
||||
OffsetTolerancesHigh
|
||||
}
|
||||
private double [] GetTiltSensorCals(IDASCommunication das)
|
||||
{
|
||||
return das is ITiltSensorCalAware iTiltAware ? iTiltAware.TiltSensorCals : (new double[0]);
|
||||
}
|
||||
private short [] GetTiltSensorData(IDASCommunication das)
|
||||
{
|
||||
return new short[] { 0, 0, 0 };
|
||||
}
|
||||
public DASMonitorInfo(IDASCommunication das, IsoViewMode mode)
|
||||
{
|
||||
var keys = Enum.GetValues(typeof(Fields)).Cast<Fields>().ToArray();
|
||||
foreach (var key in keys)
|
||||
{
|
||||
switch (key)
|
||||
{
|
||||
case Fields.SerialNumber:
|
||||
SerialNumber = das.SerialNumber;
|
||||
break;
|
||||
case Fields.TiltSensorCals:
|
||||
TiltSensorCals = GetTiltSensorCals(das);
|
||||
break;
|
||||
case Fields.TiltSensorDataPre:
|
||||
TiltSensorDataPre = GetTiltSensorData(das);
|
||||
break;
|
||||
case Fields.TiltAxes:
|
||||
TiltAxes = GetTiltAxes(das);
|
||||
break;
|
||||
case Fields.AxesIgnored:
|
||||
AxisIgnored = GetAxisIgnored(das);
|
||||
break;
|
||||
case Fields.MountOffsetAxisOne:
|
||||
MountOffsetAxisOne = GetMountOffsetAxisOne(das);
|
||||
break;
|
||||
case Fields.MountOffsetAxisTwo:
|
||||
MountOffsetAxisTwo = GetMountOffsetAxisTwo(das);
|
||||
break;
|
||||
case Fields.ChannelNames:
|
||||
_channelNames = GetChannelNames(das, mode);
|
||||
break;
|
||||
case Fields.OffsetTolerancesLow:
|
||||
_offsetTolerancesLow = GetOffsetTolerancemVLow(das);
|
||||
break;
|
||||
case Fields.OffsetTolerancesHigh:
|
||||
_offsetTolerancesHigh = GetOffsetTolerancemVHigh(das);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
private double [] GetOffsetTolerancemVHigh(IDASCommunication das)
|
||||
{
|
||||
if (NoModules(das)) { return new double[0]; }
|
||||
var list = new List<double>();
|
||||
foreach (var module in das.ConfigData.Modules)
|
||||
{
|
||||
foreach (var ch in module.Channels)
|
||||
{
|
||||
if (ch is IAnalogInputDASChannel aic)
|
||||
{
|
||||
list.Add(aic.OffsetToleranceHighMilliVolts);
|
||||
}
|
||||
else { list.Add(0); }
|
||||
}
|
||||
}
|
||||
return list.ToArray();
|
||||
}
|
||||
private double [] GetOffsetTolerancemVLow(IDASCommunication das)
|
||||
{
|
||||
if (NoModules(das)) { return new double[0]; }
|
||||
var list = new List<double>();
|
||||
foreach (var module in das.ConfigData.Modules)
|
||||
{
|
||||
foreach (var ch in module.Channels)
|
||||
{
|
||||
if (ch is IAnalogInputDASChannel aic)
|
||||
{
|
||||
list.Add(aic.OffsetToleranceLowMilliVolts);
|
||||
}
|
||||
else { list.Add(0); }
|
||||
}
|
||||
}
|
||||
return list.ToArray();
|
||||
}
|
||||
private bool NoModules(IDASCommunication das)
|
||||
{
|
||||
return null == das.ConfigData || null == das.ConfigData.Modules || 0 == das.ConfigData.Modules.Length;
|
||||
}
|
||||
private double GetMountOffsetAxisTwo(IDASCommunication das)
|
||||
{
|
||||
return NoModules(das) ? float.NaN : das.ConfigData.Modules[0].MountOffsetAxisTwo;
|
||||
}
|
||||
private double GetMountOffsetAxisOne(IDASCommunication das)
|
||||
{
|
||||
return NoModules(das) ? float.NaN : das.ConfigData.Modules[0].MountOffsetAxisOne;
|
||||
}
|
||||
private int GetAxisIgnored(IDASCommunication das)
|
||||
{
|
||||
return NoModules(das) ? 0 : das.ConfigData.Modules[0].AxisIgnored;
|
||||
}
|
||||
private DFConstantsAndEnums.TiltAxes GetTiltAxes(IDASCommunication das)
|
||||
{
|
||||
return NoModules(das) ? DFConstantsAndEnums.TiltAxes.IXIYIZ : das.ConfigData.Modules[0].TiltAxes;
|
||||
}
|
||||
private string [] GetChannelNames(IDASCommunication das, IsoViewMode viewMode)
|
||||
{
|
||||
if(NoModules(das)) { return new string[0]; }
|
||||
var list = new List<string>();
|
||||
foreach (var mod in das.ConfigData.Modules)
|
||||
{
|
||||
foreach (var ch in mod.Channels)
|
||||
{
|
||||
switch (viewMode)
|
||||
{
|
||||
case IsoViewMode.ISOOnly:
|
||||
list.Add(ch.IsoChannelName);
|
||||
break;
|
||||
case IsoViewMode.ISOAndUserCode:
|
||||
list.Add($"{ ch.IsoChannelName}\\{ch.UserChannelName}");
|
||||
break;
|
||||
case IsoViewMode.UserCodeOnly:
|
||||
list.Add(ch.UserCode);
|
||||
break;
|
||||
case IsoViewMode.ChannelNameOnly:
|
||||
list.Add(ch.UserChannelName);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
return list.ToArray();
|
||||
}
|
||||
public DASMonitorInfo(string path)
|
||||
{
|
||||
try
|
||||
{
|
||||
ReadFromFile(path);
|
||||
}
|
||||
catch(Exception ex)
|
||||
{
|
||||
APILogger.Log(ex);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
namespace DTS.Common.Classes.Hardware
|
||||
{
|
||||
public class DragAndDropPayload
|
||||
{
|
||||
public const string FORMAT = "RESOLVECHANNELS_HARDWARETABLE";
|
||||
public const string ALT_FORMAT = "ALT_RESOLVECHANNELS_HARDWARETABLE";
|
||||
public const string CTRL_FORMAT = "CTRL_RESOLVECHANNELS_HARDWARETABLE";
|
||||
}
|
||||
}
|
||||
11
Common/DTS.CommonCore/Classes/Hardware/ExternalTilt.cs
Normal file
11
Common/DTS.CommonCore/Classes/Hardware/ExternalTilt.cs
Normal file
@@ -0,0 +1,11 @@
|
||||
namespace DTS.Common.Classes.Hardware
|
||||
{
|
||||
public class ExternalTilt
|
||||
{
|
||||
public ExternalTilt() { }
|
||||
public string SerialNumber { get; set; }
|
||||
public byte TiltID { get; set; }
|
||||
public string SystemID { get; set; }
|
||||
public string SystemLocation { get; set; }
|
||||
}
|
||||
}
|
||||
45
Common/DTS.CommonCore/Classes/Hardware/SerializableAAF.cs
Normal file
45
Common/DTS.CommonCore/Classes/Hardware/SerializableAAF.cs
Normal file
@@ -0,0 +1,45 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
|
||||
namespace DTS.Common.Classes.Hardware
|
||||
{
|
||||
public class SerializableAAF
|
||||
{
|
||||
public enum DAS_TYPE { TDAS = 0, SLICE = 1 };
|
||||
|
||||
/*private DAS_TYPE _type = DAS_TYPE.TDAS;
|
||||
public DAS_TYPE DasType { get { return _type; } }
|
||||
|
||||
private UInt64 _sampleRate = 0;
|
||||
public UInt64 SampleRate { get { return _sampleRate; } }
|
||||
|
||||
private float _aaf = 0F;
|
||||
public float AAF { get { return _aaf; } }
|
||||
|
||||
public SerializableAAF(DAS_TYPE type, ulong sps, float aaf)
|
||||
{
|
||||
_type = type;
|
||||
_sampleRate = sps;
|
||||
_aaf = aaf;
|
||||
}
|
||||
private const string SEPARATOR = "_x_";
|
||||
public string GetSerializedKey()
|
||||
{
|
||||
return string.Format("{0}{1}{2}", (int)DasType, SEPARATOR, SampleRate);
|
||||
}
|
||||
public string GetSerializedValue()
|
||||
{
|
||||
return AAF.ToString(System.Globalization.CultureInfo.InvariantCulture);
|
||||
}
|
||||
public void FromSerializedStrings(string key, string value)
|
||||
{
|
||||
string[] tokens = key.Split(new string[] { SEPARATOR }, StringSplitOptions.None);
|
||||
if (2 != tokens.Length) { throw new NotSupportedException("Invalid Format AAF key: " + key.ToArray()); }
|
||||
_type = (DAS_TYPE)Convert.ToInt32(tokens[0]);
|
||||
_sampleRate = Convert.ToUInt64(tokens[1]);
|
||||
_aaf = Convert.ToSingle(value);
|
||||
}*/
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user