This commit is contained in:
2026-04-17 14:55:32 -04:00
commit bc3ac1d4c9
18017 changed files with 4371742 additions and 0 deletions

View File

@@ -0,0 +1,113 @@
using System;
using System.Collections.Generic;
using System.Linq;
namespace DatabaseImport
{
public class DASHardware : DbTimeStampBase, IComparable<DASHardware>, IDASHardware
{
/// <summary>
/// returns whether in the UI this device should be represented as a rack even though it isn't (SLICE6Db, ECM, SLE)
/// </summary>
/// <returns></returns>
public bool IsPseudoRack()
{
switch (GetHardwareTypeEnum())
{
case HardwareTypes.SLICE_LabEthernet:
case HardwareTypes.SLICE_EthernetController:
case HardwareTypes.SLICE6DB: return true;
default: return false;
}
}
public string ParentDAS
{
get => _hardware.ParentDAS;
set => _hardware.ParentDAS = value;
}
public int PositionOnDistributor
{
get => _hardware.PositionOnDistributor;
set => _hardware.PositionOnDistributor = value;
}
public int CompareTo(DASHardware right)
{
if (null == right) { return 1; }
if (this == right) { return 0; }
if (SerialNumber == right.SerialNumber)
{
return 0;
}
//ensure that children of a das are sorted behind their parents
if (!string.IsNullOrWhiteSpace(ParentDAS) && right.SerialNumber == ParentDAS)
{
return 1;
}
if (!string.IsNullOrWhiteSpace(right.ParentDAS) && right.ParentDAS == SerialNumber)
{
return -1;
}
if (!string.IsNullOrWhiteSpace(right.ParentDAS) && right.ParentDAS == ParentDAS)
{
if (PositionOnDistributor != right.PositionOnDistributor)
{
return PositionOnDistributor.CompareTo(right.PositionOnDistributor);
}
}
return string.Compare(SerialNumber, right.SerialNumber, StringComparison.Ordinal);
}
private List<HardwareChannel> _channels = new List<HardwareChannel>();
public HardwareChannel[] Channels
{
get => _channels.ToArray();
set
{
var channels = new List<HardwareChannel>(value);
channels.Sort();
_channels = channels;
//OnPropertyChanged(Tags.ChannelCount.ToString());
}
}
public string SerialNumber
{
get => _hardware.SerialNumber;
set => _hardware.SerialNumber = value;
}
public int GetHardwareTypeInt() { return _hardware.DASType; }
public HardwareTypes GetHardwareTypeEnum() { return (HardwareTypes)GetHardwareTypeInt(); }
public long GetMaxMemoryLong() { return _hardware.MaxMemory; }
public DASHardware(DASHardware copy, DASHardware parentDAS)
{
if (null != copy.Channels)
{
Channels = copy.Channels.Select(ch => new HardwareChannel(ch)).ToArray();
}
_hardware = new Hardware(copy.GetHardware());
DbTimeStamp = copy.DbTimeStamp;
}
public string[] LinkedDASSerials { get; set; }
private Hardware _hardware = new Hardware();
public Hardware GetHardware() { return _hardware; }
/// <summary>
/// note that if you use this constructor, you should set
/// TimeStampDb explicitly
/// </summary>
/// <param name="hardware"></param>
public DASHardware(Hardware hardware)
{
_hardware = new Hardware(hardware);
Channels = hardware.ISOChannels.Select(channel => new HardwareChannel(channel, this)).ToArray();
}
public bool IsDummy()
{
return SerialNumber.Contains("Dummy");
}
}
}

View File

@@ -0,0 +1,83 @@
using System;
using System.Linq;
namespace DatabaseImport
{
public class DASHardwareList //: BasePropertyChanged
{
private static DASHardwareList _list;
public static DASHardwareList GetList()
{
if (null != _list) return _list;
_list = new DASHardwareList();
//_list.PopulateHardware();
return _list;
}
public void ReloadAll()
{
//_list = new DASHardwareList();
//_list.PopulateHardware();
}
private ICachedContainer _cachedHardware = null;
public DASHardware GetHardware(string id, bool bUseCache = true)
{
return GetHardware(id, true, out var bNotUsed, bUseCache);
}
public DASHardware GetHardware(string id, bool bThrowExceptionIfChanged, out bool changed, bool bUseCache = true)
{
if (null != _cachedHardware && bUseCache)
{
var tokens = id.Split('_');
var h = _cachedHardware.GetCachedHardware(tokens[0]);
if (null != h)
{
changed = false;
return h;
}
}
var hardware = Hardware.GetAllDAS(id, null);
changed = false;
if (null != hardware && hardware.Any())
{
return new DASHardware(hardware[0]);
}
return null;
/*if (_hardware.ContainsKey(id))
{
return _hardware[id];
}
var matchingSerial = from h in _hardware where h.Value.SerialNumber == id select h.Value;
var dasHardwares = matchingSerial as DASHardware[] ?? matchingSerial.ToArray();
if (dasHardwares.Any())
{
return dasHardwares.First();
}
//check to see if the type changed?
var index = id.IndexOf('_');
if (index >= 0)
{
id = id.Substring(0, index);
}
var match2 = from h in _hardware where h.Value.SerialNumber == id select h.Value;
if (match2.Any())
{
if (bThrowExceptionIfChanged)
{
throw new HardwareTypeChangedException();
}
changed = true;
}return null;*/
}
public class HardwareTypeChangedException : Exception
{
}
}
}

View File

@@ -0,0 +1,39 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
//using DTS.Common.Base;
namespace DatabaseImport
{
/// <summary>
/// this is a class for holding das specific settings in a test, for example sample rate or aaf
/// it is serialized into tblTestSetupDASSettings
/// </summary>
public class DASSettings //: BasePropertyChanged
{
public string DASSerialNumber { get; set; }
public double SampleRate { get; set; }
public int ExcitationWarmupTimeMS { get; set; }
public double HardwareAAF { get; set; }
public double PreTriggerSeconds { get; set; }
public double PostTriggerSeconds { get; set; }
public bool StatusLineCheck { get; set; }
public bool BatteryCheck { get; set; }
public double InputVoltageMin { get; set; }
public double InputVoltageMax { get; set; }
public double BatteryVoltageMin { get; set; }
public double BatteryVoltageMax { get; set; }
}
}

View File

@@ -0,0 +1,47 @@
using System;
namespace DatabaseImport
{
public class HardwareChannel : /*BasePropertyChanged,*/ IComparable<HardwareChannel>, IHardwareChannel
{
private readonly ISO.HardwareChannel _isoChannel;
public ISO.HardwareChannel GetISOChannel() { return _isoChannel; }
public int CompareTo(HardwareChannel right)
{
if (this == right) { return 0; }
if (null == right) { return 0; }
var order = GetISOChannel().DASDisplayOrder.CompareTo(right.GetISOChannel().DASDisplayOrder);
return 0 != order ? order : GetISOChannel().ChannelIdx.CompareTo(right.GetISOChannel().ChannelIdx);
}
public string GetId()
{
return $"{Hardware.GetHardware().GetId()}x{1 + ChannelNumber}";
}
private TestObjectChannel _testObjectChannel;
public HardwareChannel(HardwareChannel copy)
{
ChannelNumber = copy.ChannelNumber;
if (null != copy.Sensor) { Sensor = new SensorData(copy.Sensor); }
_testObjectChannel = copy._testObjectChannel;
Hardware = copy.Hardware;
_isoChannel = copy._isoChannel;
}
public HardwareChannel(ISO.HardwareChannel channel, DASHardware hardware)
{
ChannelNumber = channel.ChannelIdx;
Hardware = hardware;
_isoChannel = channel;
}
public DASHardware Hardware { get; }
public int ChannelNumber { get; } = 0;
public SensorData Sensor { get; set; } = null;
public bool IsSupportedBridgeType(Test.Module.Channel.Sensor.BridgeType bridgeType)
{
return (GetISOChannel().SupportedBridges & (int)bridgeType) == (int)bridgeType;
}
}
}