From f323f6206dcbdba9505c023006feab02b401bc68 Mon Sep 17 00:00:00 2001 From: Darth Affe Date: Sun, 18 Feb 2018 17:15:55 +0100 Subject: [PATCH] Added a device-provider for DMX devices (currently only E1.31 [sACN] is implemented) --- NuGet/RGB.NET.Devices.DMX.nuspec | 28 +++++ RGB.NET.Devices.DMX/DMXDeviceProvider.cs | 112 ++++++++++++++++++ .../DMXDeviceProviderLoader.cs | 24 ++++ .../E131/E131DMXDeviceDefinition.cs | 92 ++++++++++++++ .../E131/E131DataPacketExtension.cs | 25 ++++ RGB.NET.Devices.DMX/E131/E131Device.cs | 112 ++++++++++++++++++ RGB.NET.Devices.DMX/E131/E131DeviceInfo.cs | 85 +++++++++++++ .../Generic/IDMXDeviceDefinition.cs | 8 ++ .../Generic/LedChannelMapping.cs | 32 +++++ .../Properties/AssemblyInfo.cs | 35 ++++++ .../RGB.NET.Devices.DMX.csproj | 69 +++++++++++ .../RGB.NET.Devices.DMX.csproj.DotSettings | 2 + RGB.NET.Devices.DMX/packages.config | 4 + RGB.NET.sln | 10 +- RGB.NET.sln.DotSettings | 1 + 15 files changed, 638 insertions(+), 1 deletion(-) create mode 100644 NuGet/RGB.NET.Devices.DMX.nuspec create mode 100644 RGB.NET.Devices.DMX/DMXDeviceProvider.cs create mode 100644 RGB.NET.Devices.DMX/DMXDeviceProviderLoader.cs create mode 100644 RGB.NET.Devices.DMX/E131/E131DMXDeviceDefinition.cs create mode 100644 RGB.NET.Devices.DMX/E131/E131DataPacketExtension.cs create mode 100644 RGB.NET.Devices.DMX/E131/E131Device.cs create mode 100644 RGB.NET.Devices.DMX/E131/E131DeviceInfo.cs create mode 100644 RGB.NET.Devices.DMX/Generic/IDMXDeviceDefinition.cs create mode 100644 RGB.NET.Devices.DMX/Generic/LedChannelMapping.cs create mode 100644 RGB.NET.Devices.DMX/Properties/AssemblyInfo.cs create mode 100644 RGB.NET.Devices.DMX/RGB.NET.Devices.DMX.csproj create mode 100644 RGB.NET.Devices.DMX/RGB.NET.Devices.DMX.csproj.DotSettings create mode 100644 RGB.NET.Devices.DMX/packages.config diff --git a/NuGet/RGB.NET.Devices.DMX.nuspec b/NuGet/RGB.NET.Devices.DMX.nuspec new file mode 100644 index 0000000..87bcc54 --- /dev/null +++ b/NuGet/RGB.NET.Devices.DMX.nuspec @@ -0,0 +1,28 @@ + + + + RGB.NET.Devices.DMX + RGB.NET.Devices.DMX + 0.0.1 + Darth Affe + Darth Affe + https://github.com/DarthAffe/RGB.NET + https://raw.githubusercontent.com/DarthAffe/RGB.NET/master/LICENSE + true + DMX-Device-Implementations of RGB.NET + + DMX-Device-Implementations of RGB.NET, a C# (.NET) library for accessing various RGB-peripherals + Copyright © Wyrez 2018 + en-US + + + + + + + + + + + + \ No newline at end of file diff --git a/RGB.NET.Devices.DMX/DMXDeviceProvider.cs b/RGB.NET.Devices.DMX/DMXDeviceProvider.cs new file mode 100644 index 0000000..804b9b8 --- /dev/null +++ b/RGB.NET.Devices.DMX/DMXDeviceProvider.cs @@ -0,0 +1,112 @@ +// ReSharper disable MemberCanBePrivate.Global +// ReSharper disable UnusedMember.Global + +using System; +using System.Collections.Generic; +using System.Collections.ObjectModel; +using RGB.NET.Core; +using RGB.NET.Devices.DMX.E131; + +namespace RGB.NET.Devices.DMX +{ + /// + /// + /// Represents a device provider responsible for DMX devices. + /// + public class DMXDeviceProvider : IRGBDeviceProvider + { + #region Properties & Fields + + private static DMXDeviceProvider _instance; + /// + /// Gets the singleton instance. + /// + public static DMXDeviceProvider Instance => _instance ?? new DMXDeviceProvider(); + + /// + public bool IsInitialized { get; private set; } + + /// + public IEnumerable Devices { get; private set; } + + /// + public bool HasExclusiveAccess => false; + + /// + /// Gets a list of all defined device-definitions. + /// + public List DeviceDefinitions { get; } = new List(); + + #endregion + + #region Constructors + + /// + /// Initializes a new instance of the class. + /// + /// Thrown if this constructor is called even if there is already an instance of this class. + public DMXDeviceProvider() + { + if (_instance != null) throw new InvalidOperationException($"There can be only one instance of type {nameof(DMXDeviceProvider)}"); + _instance = this; + } + + #endregion + + #region Methods + + /// + /// Adds the given to this device-provider. + /// + /// The to add. + public void AddDeviceDefinition(IDMXDeviceDefinition deviceDefinition) => DeviceDefinitions.Add(deviceDefinition); + + /// + public bool Initialize(RGBDeviceType loadFilter = RGBDeviceType.All, bool exclusiveAccessIfPossible = false, bool throwExceptions = false) + { + IsInitialized = false; + + try + { + IList devices = new List(); + + foreach (IDMXDeviceDefinition dmxDeviceDefinition in DeviceDefinitions) + { + try + { + if (dmxDeviceDefinition is E131DMXDeviceDefinition e131DMXDeviceDefinition) + { + if (e131DMXDeviceDefinition.Leds.Count > 0) + { + E131Device device = new E131Device(new E131DeviceInfo(e131DMXDeviceDefinition), e131DMXDeviceDefinition.Leds); + device.Initialize(); + devices.Add(device); + } + } + } + catch { if (throwExceptions) throw; } + } + + Devices = new ReadOnlyCollection(devices); + IsInitialized = true; + } + catch + { + if (throwExceptions) throw; + return false; + } + + return true; + } + + /// + public void ResetDevices() + { } + + /// + public void Dispose() + { } + + #endregion + } +} diff --git a/RGB.NET.Devices.DMX/DMXDeviceProviderLoader.cs b/RGB.NET.Devices.DMX/DMXDeviceProviderLoader.cs new file mode 100644 index 0000000..ca11e1b --- /dev/null +++ b/RGB.NET.Devices.DMX/DMXDeviceProviderLoader.cs @@ -0,0 +1,24 @@ +using RGB.NET.Core; + +namespace RGB.NET.Devices.DMX +{ + /// + /// Represents a device provider loaded used to dynamically load DMX devices into an application. + /// + public class DMXDeviceProviderLoader : IRGBDeviceProviderLoader + { + #region Properties & Fields + + /// + public bool RequiresInitialization => true; + + #endregion + + #region Methods + + /// + public IRGBDeviceProvider GetDeviceProvider() => DMXDeviceProvider.Instance; + + #endregion + } +} diff --git a/RGB.NET.Devices.DMX/E131/E131DMXDeviceDefinition.cs b/RGB.NET.Devices.DMX/E131/E131DMXDeviceDefinition.cs new file mode 100644 index 0000000..8e7fb9b --- /dev/null +++ b/RGB.NET.Devices.DMX/E131/E131DMXDeviceDefinition.cs @@ -0,0 +1,92 @@ +// ReSharper disable AutoPropertyCanBeMadeGetOnly.Global +// ReSharper disable UnusedMember.Global +// ReSharper disable MemberCanBePrivate.Global + +using System; +using System.Collections.Generic; +using System.Linq; +using RGB.NET.Core; + +namespace RGB.NET.Devices.DMX.E131 +{ + /// + /// Represents the data used to create a E1.31 DMX-device. + /// + public class E131DMXDeviceDefinition : IDMXDeviceDefinition + { + #region Properties & Fields + + /// + /// Gets or sets the hostname of the device. + /// + public string Hostname { get; set; } + + /// + /// Gets or sets the port to device is listening to. + /// + public int Port { get; set; } = 5568; + + /// + /// Gets or sets the of the device. + /// + public RGBDeviceType DeviceType { get; set; } = RGBDeviceType.Unknown; + + /// + /// Gets or sets the manufacturer of the device. + /// + public string Manufacturer { get; set; } = "Unknown"; + + /// + /// Gets or sets the model name of the device. + /// + public string Model { get; set; } = "Generic DMX-Device"; + + /// + /// Gets or sets the CID of the device (null will generate a random CID) + /// + // ReSharper disable once InconsistentNaming + public byte[] CID { get; set; } + + /// + /// Gets or sets the universe the device belongs to. + /// + public short Universe { get; set; } = 1; + + /// + /// Gets or sets the led-mappings used to create the device. + /// + public Dictionary getValueFunc)>> Leds { get; } = new Dictionary getValueFunc)>>(); + + #endregion + + #region Constructors + + /// + /// + /// + /// + public E131DMXDeviceDefinition(string hostname) + { + this.Hostname = hostname; + } + + #endregion + + #region Methods + + /// + /// Adds a led-mapping to the device. + /// + /// The used to identify the led. + /// The channels the led is using and a function mapping parts of the color to them. + public void AddLed(LedId id, params (int channel, Func getValueFunc)[] channels) => Leds[id] = channels.ToList(); + + #endregion + + #region Factory + + //TODO DarthAffe 18.02.2018: Add factory-methods. + + #endregion + } +} diff --git a/RGB.NET.Devices.DMX/E131/E131DataPacketExtension.cs b/RGB.NET.Devices.DMX/E131/E131DataPacketExtension.cs new file mode 100644 index 0000000..aa76741 --- /dev/null +++ b/RGB.NET.Devices.DMX/E131/E131DataPacketExtension.cs @@ -0,0 +1,25 @@ +using System; +using System.Linq; + +namespace RGB.NET.Devices.DMX.E131 +{ + internal static class E131DataPacketExtension + { + #region Methods + + // ReSharper disable once InconsistentNaming + internal static void SetCID(this byte[] data, byte[] cid) => Array.Copy(cid, 0, data, 22, 16); + + internal static void SetSequenceNumber(this byte[] data, byte sequenceNumber) => data[111] = sequenceNumber; + + internal static void SetUniverse(this byte[] data, short universe) => Array.Copy(ToBigEndian(BitConverter.GetBytes(universe)), 0, data, 113, 2); + + internal static void ClearColors(this byte[] data) => Array.Clear(data, 126, 512); + + internal static void SetChannel(this byte[] data, int channel, byte value) => data[126 + channel] = value; + + private static byte[] ToBigEndian(byte[] data) => BitConverter.IsLittleEndian ? data.Reverse().ToArray() : data; + + #endregion + } +} diff --git a/RGB.NET.Devices.DMX/E131/E131Device.cs b/RGB.NET.Devices.DMX/E131/E131Device.cs new file mode 100644 index 0000000..9ca1f1a --- /dev/null +++ b/RGB.NET.Devices.DMX/E131/E131Device.cs @@ -0,0 +1,112 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Net.Sockets; +using RGB.NET.Core; + +namespace RGB.NET.Devices.DMX.E131 +{ + /// + /// Represents a E1.31-DXM-device. + /// + public class E131Device : AbstractRGBDevice + { + #region Properties & Fields + + /// + /// Gets the UDP-Connection used to send data. + /// + private UdpClient _socket; + + /// + /// Gets the byte-representation of a E1.31 packet as described in http://tsp.esta.org/tsp/documents/docs/E1-31-2016.pdf. + /// CID, SequenceNumber, Universe and PropertyValues needs to be updated before use! + /// + private byte[] _dataPacket = { 0x00, 0x10, 0x00, 0x00, 0x41, 0x53, 0x43, 0x2D, 0x45, 0x31, 0x2E, 0x31, 0x37, 0x00, 0x00, 0x00, 0x72, 0x6E, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x72, 0x58, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x64, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x72, 0x0B, 0x02, 0xA1, 0x00, 0x00, 0x00, 0x01, 0x02, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }; + + /// + /// Gets or sets the Sequence number used to detect the order in which packages where sent. + /// + private byte _sequenceNumber = 0; + + /// + public override E131DeviceInfo DeviceInfo { get; } + + private readonly Dictionary getValueFunc)>> _ledMappings; + + #endregion + + #region Constructors + + /// + internal E131Device(E131DeviceInfo deviceInfo, Dictionary getValueFunc)>> ledMappings) + { + this.DeviceInfo = deviceInfo; + this._ledMappings = ledMappings; + } + + #endregion + + #region Methods + + internal void Initialize() + { + int count = 0; + foreach (LedId id in _ledMappings.Keys) + InitializeLed(id, new Rectangle((count++) * 10, 0, 10, 10)); + + _socket = new UdpClient(); + _socket.Connect(DeviceInfo.Hostname, DeviceInfo.Port); + + _dataPacket.SetCID(DeviceInfo.CID); + _dataPacket.SetUniverse(DeviceInfo.Universe); + + //TODO DarthAffe 18.02.2018: Allow to load a layout. + + if (Size == Size.Invalid) + { + Rectangle ledRectangle = new Rectangle(this.Select(x => x.LedRectangle)); + Size = ledRectangle.Size + new Size(ledRectangle.Location.X, ledRectangle.Location.Y); + } + } + + /// + protected override object CreateLedCustomData(LedId ledId) => new LedChannelMapping(_ledMappings[ledId]); + + /// + protected override void UpdateLeds(IEnumerable ledsToUpdate) + { + List leds = ledsToUpdate.Where(x => x.Color.A > 0).ToList(); + if (leds.Count > 0) + { + _dataPacket.SetSequenceNumber(GetNextSequenceNumber()); + + foreach (Led led in leds) + { + LedChannelMapping mapping = (LedChannelMapping)led.CustomData; + foreach ((int channel, Func getValue) in mapping) + _dataPacket.SetChannel(channel, getValue(led.Color)); + } + + _socket.Send(_dataPacket, _dataPacket.Length); + } + } + + /// + /// Increments the sequence number and wraps it if neded. + /// + /// The next usable sequence number. + private byte GetNextSequenceNumber() + { + if (_sequenceNumber == byte.MaxValue) + { + _sequenceNumber = byte.MinValue; + return byte.MaxValue; + } + + return _sequenceNumber++; + } + + #endregion + } +} diff --git a/RGB.NET.Devices.DMX/E131/E131DeviceInfo.cs b/RGB.NET.Devices.DMX/E131/E131DeviceInfo.cs new file mode 100644 index 0000000..8da933e --- /dev/null +++ b/RGB.NET.Devices.DMX/E131/E131DeviceInfo.cs @@ -0,0 +1,85 @@ +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 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); + } + } + + #endregion + } +} diff --git a/RGB.NET.Devices.DMX/Generic/IDMXDeviceDefinition.cs b/RGB.NET.Devices.DMX/Generic/IDMXDeviceDefinition.cs new file mode 100644 index 0000000..5750c2f --- /dev/null +++ b/RGB.NET.Devices.DMX/Generic/IDMXDeviceDefinition.cs @@ -0,0 +1,8 @@ +namespace RGB.NET.Devices.DMX +{ + /// + /// Marker interface for DMX device definitions. + /// + public interface IDMXDeviceDefinition + { } +} diff --git a/RGB.NET.Devices.DMX/Generic/LedChannelMapping.cs b/RGB.NET.Devices.DMX/Generic/LedChannelMapping.cs new file mode 100644 index 0000000..63b5b76 --- /dev/null +++ b/RGB.NET.Devices.DMX/Generic/LedChannelMapping.cs @@ -0,0 +1,32 @@ +using System; +using System.Collections; +using System.Collections.Generic; +using RGB.NET.Core; + +namespace RGB.NET.Devices.DMX +{ + internal class LedChannelMapping : IEnumerable<(int channel, Func getValue)> + { + #region Properties & Fields + + private readonly List<(int channel, Func getValue)> _mappings; + + #endregion + + #region Constructors + + public LedChannelMapping(List<(int channel, Func getValue)> mappings) + { + this._mappings = new List<(int channel, Func getValue)>(mappings); + } + + #endregion + + #region Methods + + public IEnumerator<(int channel, Func getValue)> GetEnumerator() => _mappings.GetEnumerator(); + IEnumerator IEnumerable.GetEnumerator() => GetEnumerator(); + + #endregion + } +} diff --git a/RGB.NET.Devices.DMX/Properties/AssemblyInfo.cs b/RGB.NET.Devices.DMX/Properties/AssemblyInfo.cs new file mode 100644 index 0000000..700280b --- /dev/null +++ b/RGB.NET.Devices.DMX/Properties/AssemblyInfo.cs @@ -0,0 +1,35 @@ +using System.Reflection; +using System.Runtime.InteropServices; + +// General Information about an assembly is controlled through the following +// set of attributes. Change these attribute values to modify the information +// associated with an assembly. +[assembly: AssemblyTitle("RGB.NET.Devices.DMX")] +[assembly: AssemblyDescription("DMX-Device-Implementations of RGB.NET")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("Wyrez")] +[assembly: AssemblyProduct("RGB.NET.Devices.DMX")] +[assembly: AssemblyCopyright("Copyright © Wyrez 2018")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] + +// Setting ComVisible to false makes the types in this assembly not visible +// to COM components. If you need to access a type in this assembly from +// COM, set the ComVisible attribute to true on that type. +[assembly: ComVisible(false)] + +// The following GUID is for the ID of the typelib if this project is exposed to COM +[assembly: Guid("725abfa2-b360-4d3a-82d5-1ac502f5e10f")] + +// Version information for an assembly consists of the following four values: +// +// Major Version +// Minor Version +// Build Number +// Revision +// +// You can specify all the values or you can default the Build and Revision Numbers +// by using the '*' as shown below: +// [assembly: AssemblyVersion("1.0.*")] +[assembly: AssemblyVersion("1.0.0.0")] +[assembly: AssemblyFileVersion("1.0.0.0")] diff --git a/RGB.NET.Devices.DMX/RGB.NET.Devices.DMX.csproj b/RGB.NET.Devices.DMX/RGB.NET.Devices.DMX.csproj new file mode 100644 index 0000000..7c005c2 --- /dev/null +++ b/RGB.NET.Devices.DMX/RGB.NET.Devices.DMX.csproj @@ -0,0 +1,69 @@ + + + + + Debug + AnyCPU + {725ABFA2-B360-4D3A-82D5-1AC502F5E10F} + Library + Properties + RGB.NET.Devices.DMX + RGB.NET.Devices.DMX + v4.5 + 512 + + + true + full + false + ..\bin\ + DEBUG;TRACE + prompt + 4 + ..\bin\RGB.NET.Devices.DMX.xml + + + pdbonly + true + ..\bin\ + TRACE + prompt + 4 + ..\bin\RGB.NET.Devices.DMX.xml + + + + + + ..\packages\System.ValueTuple.4.4.0\lib\netstandard1.0\System.ValueTuple.dll + + + + + + + + + + + + + + + + + + + + + + {5a4f9a75-75fe-47cd-90e5-914d5b20d232} + RGB.NET.Core + + + + + + + + \ No newline at end of file diff --git a/RGB.NET.Devices.DMX/RGB.NET.Devices.DMX.csproj.DotSettings b/RGB.NET.Devices.DMX/RGB.NET.Devices.DMX.csproj.DotSettings new file mode 100644 index 0000000..acc5fca --- /dev/null +++ b/RGB.NET.Devices.DMX/RGB.NET.Devices.DMX.csproj.DotSettings @@ -0,0 +1,2 @@ + + True \ No newline at end of file diff --git a/RGB.NET.Devices.DMX/packages.config b/RGB.NET.Devices.DMX/packages.config new file mode 100644 index 0000000..a59695c --- /dev/null +++ b/RGB.NET.Devices.DMX/packages.config @@ -0,0 +1,4 @@ + + + + \ No newline at end of file diff --git a/RGB.NET.sln b/RGB.NET.sln index 19fb685..16ccddb 100644 --- a/RGB.NET.sln +++ b/RGB.NET.sln @@ -1,7 +1,7 @@  Microsoft Visual Studio Solution File, Format Version 12.00 # Visual Studio 15 -VisualStudioVersion = 15.0.27130.2024 +VisualStudioVersion = 15.0.27130.2027 MinimumVisualStudioVersion = 10.0.40219.1 Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "RGB.NET.Core", "RGB.NET.Core\RGB.NET.Core.csproj", "{5A4F9A75-75FE-47CD-90E5-914D5B20D232}" EndProject @@ -32,6 +32,7 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "NuGet", "NuGet", "{06416566 NuGet\RGB.NET.Devices.CoolerMaster.nuspec = NuGet\RGB.NET.Devices.CoolerMaster.nuspec NuGet\RGB.NET.Devices.Corsair.nuspec = NuGet\RGB.NET.Devices.Corsair.nuspec NuGet\RGB.NET.Devices.Debug.nuspec = NuGet\RGB.NET.Devices.Debug.nuspec + NuGet\RGB.NET.Devices.DMX.nuspec = NuGet\RGB.NET.Devices.DMX.nuspec NuGet\RGB.NET.Devices.Logitech.nuspec = NuGet\RGB.NET.Devices.Logitech.nuspec NuGet\RGB.NET.Devices.Msi.nuspec = NuGet\RGB.NET.Devices.Msi.nuspec NuGet\RGB.NET.Devices.Novation.nuspec = NuGet\RGB.NET.Devices.Novation.nuspec @@ -70,6 +71,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "RGB.NET.Devices.Debug", "RG EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "RGB.NET.Devices.Roccat", "RGB.NET.Devices.Roccat\RGB.NET.Devices.Roccat.csproj", "{01803E4A-36B8-4675-AFB3-7C8968AC4A13}" EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "RGB.NET.Devices.DMX", "RGB.NET.Devices.DMX\RGB.NET.Devices.DMX.csproj", "{725ABFA2-B360-4D3A-82D5-1AC502F5E10F}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -136,6 +139,10 @@ Global {01803E4A-36B8-4675-AFB3-7C8968AC4A13}.Debug|Any CPU.Build.0 = Debug|Any CPU {01803E4A-36B8-4675-AFB3-7C8968AC4A13}.Release|Any CPU.ActiveCfg = Release|Any CPU {01803E4A-36B8-4675-AFB3-7C8968AC4A13}.Release|Any CPU.Build.0 = Release|Any CPU + {725ABFA2-B360-4D3A-82D5-1AC502F5E10F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {725ABFA2-B360-4D3A-82D5-1AC502F5E10F}.Debug|Any CPU.Build.0 = Debug|Any CPU + {725ABFA2-B360-4D3A-82D5-1AC502F5E10F}.Release|Any CPU.ActiveCfg = Release|Any CPU + {725ABFA2-B360-4D3A-82D5-1AC502F5E10F}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE @@ -156,6 +163,7 @@ Global {24FF4ACB-D679-4B2D-86D4-50AB6C02D816} = {33D5E279-1C4E-4AB6-9D1E-6D18109A6C25} {D013040E-1931-4F0D-9CCA-0F4AE74A507E} = {33D5E279-1C4E-4AB6-9D1E-6D18109A6C25} {01803E4A-36B8-4675-AFB3-7C8968AC4A13} = {33D5E279-1C4E-4AB6-9D1E-6D18109A6C25} + {725ABFA2-B360-4D3A-82D5-1AC502F5E10F} = {33D5E279-1C4E-4AB6-9D1E-6D18109A6C25} EndGlobalSection GlobalSection(ExtensibilityGlobals) = postSolution SolutionGuid = {CDECA6C7-8D18-4AF3-94F7-C70A69B8571B} diff --git a/RGB.NET.sln.DotSettings b/RGB.NET.sln.DotSettings index 2e73024..f4aa028 100644 --- a/RGB.NET.sln.DotSettings +++ b/RGB.NET.sln.DotSettings @@ -265,6 +265,7 @@ CUESDK DB DG + DMX EK FM GEZ