using System; using RGB.NET.Core; namespace RGB.NET.Devices.DMX.E131; /// /// /// Represents device information for a />. /// public sealed class E131DeviceInfo : IRGBDeviceInfo { #region Constants /// /// The length of the CID; /// // ReSharper disable once MemberCanBePrivate.Global public const int CID_LENGTH = 16; #endregion #region Properties & Fields /// public RGBDeviceType DeviceType { get; } /// public string DeviceName { get; } /// public string Manufacturer { get; } /// public string Model { get; } /// public object? LayoutMetadata { get; set; } /// /// The hostname of the device. /// public string Hostname { get; } /// /// The port of the device. /// public int Port { get; } /// /// The CID used to identify against the device. /// public byte[] CID { get; } /// /// The Universe this device belongs to. /// public short Universe { get; } #endregion #region Constructors internal E131DeviceInfo(E131DMXDeviceDefinition deviceDefinition) { this.DeviceType = deviceDefinition.DeviceType; this.Manufacturer = deviceDefinition.Manufacturer; this.Model = deviceDefinition.Model; this.Hostname = deviceDefinition.Hostname; this.Port = deviceDefinition.Port; this.Universe = deviceDefinition.Universe; byte[]? cid = deviceDefinition.CID; if ((cid == null) || (cid.Length != CID_LENGTH)) { cid = new byte[CID_LENGTH]; new Random().NextBytes(cid); } CID = cid; DeviceName = DeviceHelper.CreateDeviceName(Manufacturer, Model); } #endregion }