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");
}
}
}