using System;
using RGB.NET.Core;
namespace RGB.NET.Devices.DMX.E131
{
///
///
/// Represents device information for a />.
///
public 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 RGBDeviceLighting Lighting => RGBDeviceLighting.Key;
///
public bool SupportsSyncBack => false;
///
public Uri Image { 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.CID = deviceDefinition.CID;
this.Universe = deviceDefinition.Universe;
if ((CID == null) || (CID.Length != CID_LENGTH))
{
CID = new byte[CID_LENGTH];
new Random().NextBytes(CID);
}
DeviceName = $"{Manufacturer} {Model}";
}
#endregion
}
}