1
0
mirror of https://github.com/DarthAffe/RGB.NET.git synced 2025-12-12 17:48:31 +00:00

Removed SyncBack

This commit is contained in:
Darth Affe 2020-12-25 19:45:08 +01:00
parent 5243cdc6ee
commit 04f07d76a2
41 changed files with 34 additions and 978 deletions

View File

@ -149,11 +149,7 @@ namespace RGB.NET.Core
}
protected virtual IEnumerable<Led> GetLedsToUpdate(bool flushLeds) => ((RequiresFlush || flushLeds) ? LedMapping.Values : LedMapping.Values.Where(x => x.IsDirty));
/// <inheritdoc />
public virtual void SyncBack()
{ }
/// <inheritdoc />
public virtual void Dispose()
{
@ -200,20 +196,7 @@ namespace RGB.NET.Core
LedMapping.Add(ledId, led);
return led;
}
/// <summary>
/// Applies the give <see cref="Color"/> to the <see cref="Led"/> ignoring internal workflows regarding locks and update-requests.
/// This should be only used for syncbacks!
/// </summary>
/// <param name="led">The <see cref="Led"/> the <see cref="Color"/> should be aplied to.</param>
/// <param name="color">The <see cref="Color"/> to apply.</param>
protected virtual void SetLedColorWithoutRequest(Led led, Color color)
{
if (led == null) return;
led.InternalColor = color;
}
/// <summary>
/// Applies the given layout.
/// </summary>

View File

@ -17,13 +17,7 @@ namespace RGB.NET.Core
/// Represents a mode which updates the leds of the device.
/// </summary>
Sync = 1 << 0,
/// <summary>
/// Represents a mode which reads the color of the leds of the device.
/// This isn't supported by all devices!
/// </summary>
SyncBack = 1 << 1,
/// <summary>
/// Represents all update modes.
/// </summary>

View File

@ -89,13 +89,7 @@ namespace RGB.NET.Core
/// </summary>
/// <param name="flushLeds">Specifies whether all <see cref="Led"/> (including clean ones) should be updated.</param>
void Update(bool flushLeds = false);
/// <summary>
/// Synchronizes the internal state of the device to the real (physical) state.
/// This isn't supported by all devices! Check <see cref="IRGBDeviceInfo.SupportsSyncBack"/> to see if it's supported or not.
/// </summary>
void SyncBack();
/// <summary>
/// Adds the given <see cref="IRGBDeviceSpecialPart"/> to the device.
/// This will override existing <see cref="IRGBDeviceSpecialPart"/> of the same type.

View File

@ -33,12 +33,7 @@ namespace RGB.NET.Core
/// Gets the lighting capability of the <see cref="IRGBDevice"/>
/// </summary>
RGBDeviceLighting Lighting { get; }
/// <summary>
/// Gets a bool indicating, if the <see cref="IRGBDevice"/> supports SynBacks or not.
/// </summary>
bool SupportsSyncBack { get; }
/// <summary>
/// Gets the URI of an image of the <see cref="IRGBDevice"/> or null if there is no image.
/// </summary>

View File

@ -101,7 +101,6 @@ namespace RGB.NET.Core
try
{
bool flushLeds = customData["flushLeds"] as bool? ?? false;
bool syncBack = customData["syncBack"] as bool? ?? true;
bool render = customData["render"] as bool? ?? true;
bool updateDevices = customData["updateDevices"] as bool? ?? true;
@ -109,13 +108,7 @@ namespace RGB.NET.Core
lock (_devices)
{
OnUpdating(updateTrigger, customData);
if (syncBack)
foreach (IRGBDevice device in _devices)
if (device.UpdateMode.HasFlag(DeviceUpdateMode.SyncBack) && device.DeviceInfo.SupportsSyncBack)
try { device.SyncBack(); }
catch (Exception ex) { OnException(ex); }
if (render)
lock (_ledGroups)
{

View File

@ -67,19 +67,7 @@ namespace RGB.NET.Devices.Asus
/// <inheritdoc />
protected override void UpdateLeds(IEnumerable<Led> ledsToUpdate) => UpdateQueue.SetData(ledsToUpdate.Where(x => x.Color.A > 0));
/// <inheritdoc />
public override void SyncBack()
{
// DarthAffe 16.06.2019: This doesn't work since the SDK only returns the colors we set.
//foreach (Led led in LedMapping.Values)
//{
// int index = (int)led.CustomData;
// IAuraRgbLight light = DeviceInfo.Device.Lights[index];
// SetLedColorWithoutRequest(led, new Color(light.Red, light.Green, light.Blue));
//}
}
/// <inheritdoc />
public override void Dispose()
{

View File

@ -29,10 +29,7 @@ namespace RGB.NET.Devices.Asus
/// <inheritdoc />
public RGBDeviceLighting Lighting => RGBDeviceLighting.Key;
/// <inheritdoc />
public bool SupportsSyncBack => false;
public IAuraSyncDevice Device { get; }
#endregion

View File

@ -29,10 +29,7 @@ namespace RGB.NET.Devices.CoolerMaster
/// <inheritdoc />
public RGBDeviceLighting Lighting => RGBDeviceLighting.Key;
/// <inheritdoc />
public bool SupportsSyncBack => false;
/// <summary>
/// Gets the <see cref="CoolerMasterDevicesIndexes"/> of the <see cref="CoolerMasterRGBDevice{TDeviceInfo}"/>.
/// </summary>

View File

@ -96,32 +96,6 @@ namespace RGB.NET.Devices.Corsair
protected override void UpdateLeds(IEnumerable<Led> ledsToUpdate)
=> DeviceUpdateQueue.SetData(ledsToUpdate.Where(x => (x.Color.A > 0) && (x.CustomData is CorsairLedId ledId && (ledId != CorsairLedId.Invalid))));
/// <inheritdoc cref="IRGBDevice.SyncBack" />
public override void SyncBack()
{
int structSize = Marshal.SizeOf(typeof(_CorsairLedColor));
IntPtr ptr = Marshal.AllocHGlobal(structSize * LedMapping.Count);
IntPtr addPtr = new IntPtr(ptr.ToInt64());
foreach (Led led in this)
{
_CorsairLedColor color = new _CorsairLedColor { ledId = (int)led.CustomData };
Marshal.StructureToPtr(color, addPtr, false);
addPtr = new IntPtr(addPtr.ToInt64() + structSize);
}
_CUESDK.CorsairGetLedsColorsByDeviceIndex(DeviceInfo.CorsairDeviceIndex, LedMapping.Count, ptr);
IntPtr readPtr = ptr;
for (int i = 0; i < LedMapping.Count; i++)
{
_CorsairLedColor ledColor = (_CorsairLedColor)Marshal.PtrToStructure(readPtr, typeof(_CorsairLedColor));
SetLedColorWithoutRequest(this[(CorsairLedId)ledColor.ledId], new Color(ledColor.r, ledColor.g, ledColor.b));
readPtr = new IntPtr(readPtr.ToInt64() + structSize);
}
Marshal.FreeHGlobal(ptr);
}
/// <inheritdoc />
public override void Dispose()
{

View File

@ -39,10 +39,7 @@ namespace RGB.NET.Devices.Corsair
/// <inheritdoc />
public Uri Image { get; set; }
/// <inheritdoc />
public bool SupportsSyncBack => true;
/// <inheritdoc />
public RGBDeviceLighting Lighting => RGBDeviceLighting.Key;

View File

@ -35,10 +35,7 @@ namespace RGB.NET.Devices.DMX.E131
/// <inheritdoc />
public RGBDeviceLighting Lighting => RGBDeviceLighting.Key;
/// <inheritdoc />
public bool SupportsSyncBack => false;
/// <inheritdoc />
public Uri Image { get; set; }

View File

@ -31,8 +31,8 @@ namespace RGB.NET.Devices.Debug
/// <inheritdoc />
public bool HasExclusiveAccess { get; private set; }
private List<(string layout, string imageLayout, Func<Dictionary<LedId, Color>> syncBackFunc, Action<IEnumerable<Led>> updateLedsAction)> _fakeDeviceDefinitions
= new List<(string layout, string imageLayout, Func<Dictionary<LedId, Color>> syncBackFunc, Action<IEnumerable<Led>> updateLedsAction)>();
private List<(string layout, string imageLayout, Action<IEnumerable<Led>> updateLedsAction)> _fakeDeviceDefinitions
= new List<(string layout, string imageLayout, Action<IEnumerable<Led>> updateLedsAction)>();
#endregion
@ -57,10 +57,9 @@ namespace RGB.NET.Devices.Debug
/// </summary>
/// <param name="layout">The path of the layout file to be used.</param>
/// <param name="imageLayout">The image-layout to load.</param>
/// <param name="syncBackFunc">A function emulating device syncback.</param>
/// <param name="updateLedsAction">A action emulating led-updates.</param>
public void AddFakeDeviceDefinition(string layout, string imageLayout, Func<Dictionary<LedId, Color>> syncBackFunc = null, Action<IEnumerable<Led>> updateLedsAction = null)
=> _fakeDeviceDefinitions.Add((layout, imageLayout, syncBackFunc, updateLedsAction));
public void AddFakeDeviceDefinition(string layout, string imageLayout, Action<IEnumerable<Led>> updateLedsAction = null)
=> _fakeDeviceDefinitions.Add((layout, imageLayout, updateLedsAction));
/// <summary>
/// Removes all previously added fake device definitions.
@ -76,9 +75,9 @@ namespace RGB.NET.Devices.Debug
HasExclusiveAccess = exclusiveAccessIfPossible;
List<IRGBDevice> devices = new List<IRGBDevice>();
foreach ((string layout, string imageLayout, Func<Dictionary<LedId, Color>> syncBackFunc, Action<IEnumerable<Led>> updateLedsAction) in _fakeDeviceDefinitions)
foreach ((string layout, string imageLayout, Action<IEnumerable<Led>> updateLedsAction) in _fakeDeviceDefinitions)
{
DebugRGBDevice device = new DebugRGBDevice(layout, syncBackFunc, updateLedsAction);
DebugRGBDevice device = new DebugRGBDevice(layout, updateLedsAction);
device.Initialize(layout, imageLayout);
devices.Add(device);
}

View File

@ -20,8 +20,7 @@ namespace RGB.NET.Devices.Debug
/// Gets the path of the layout used to mock this <see cref="DebugRGBDevice"/>
/// </summary>
public string LayoutPath { get; }
private Func<Dictionary<LedId, Color>> _syncBackFunc;
private Action<IEnumerable<Led>> _updateLedsAction;
#endregion
@ -30,14 +29,13 @@ namespace RGB.NET.Devices.Debug
/// <summary>
/// Internal constructor of <see cref="DebugRGBDeviceInfo"/>.
/// </summary>
internal DebugRGBDevice(string layoutPath, Func<Dictionary<LedId, Color>> syncBackFunc = null, Action<IEnumerable<Led>> updateLedsAction = null)
internal DebugRGBDevice(string layoutPath, Action<IEnumerable<Led>> updateLedsAction = null)
{
this.LayoutPath = layoutPath;
this._syncBackFunc = syncBackFunc;
this._updateLedsAction = updateLedsAction;
DeviceLayout layout = DeviceLayout.Load(layoutPath);
DeviceInfo = new DebugRGBDeviceInfo(layout.Type, layout.Vendor, layout.Model, layout.Lighting, syncBackFunc != null);
DeviceInfo = new DebugRGBDeviceInfo(layout.Type, layout.Vendor, layout.Model, layout.Lighting);
}
#endregion
@ -46,23 +44,6 @@ namespace RGB.NET.Devices.Debug
internal void Initialize(string layoutPath, string imageLayout) => ApplyLayoutFromFile(layoutPath, imageLayout, true);
/// <inheritdoc />
public override void SyncBack()
{
try
{
Dictionary<LedId, Color> syncBackValues = _syncBackFunc?.Invoke();
if (syncBackValues == null) return;
foreach (KeyValuePair<LedId, Color> value in syncBackValues)
{
Led led = ((IRGBDevice)this)[value.Key];
SetLedColorWithoutRequest(led, value.Value);
}
}
catch {/* idc that's not my fault ... */}
}
/// <inheritdoc />
protected override void UpdateLeds(IEnumerable<Led> ledsToUpdate) => _updateLedsAction?.Invoke(ledsToUpdate);

View File

@ -25,10 +25,7 @@ namespace RGB.NET.Devices.Debug
/// <inheritdoc />
public RGBDeviceLighting Lighting { get; }
/// <inheritdoc />
public bool SupportsSyncBack { get; }
/// <inheritdoc />
public Uri Image { get; set; }
@ -43,14 +40,12 @@ namespace RGB.NET.Devices.Debug
/// <param name="manufacturer">The manufacturer of the device.</param>
/// <param name="model">The model of the device.</param>
/// <param name="lighting">The <see cref="RGBDeviceLighting"/> of the device.</param>
/// <param name="supportsSyncBack">True if the device supports syncback; false if not.</param>
internal DebugRGBDeviceInfo(RGBDeviceType deviceType, string manufacturer, string model, RGBDeviceLighting lighting, bool supportsSyncBack, string deviceName = null)
internal DebugRGBDeviceInfo(RGBDeviceType deviceType, string manufacturer, string model, RGBDeviceLighting lighting, string deviceName = null)
{
this.DeviceType = deviceType;
this.Manufacturer = manufacturer;
this.Model = model;
this.Lighting = lighting;
this.SupportsSyncBack = supportsSyncBack;
DeviceName = deviceName ?? $"{Manufacturer} {Model}";
}

View File

@ -40,10 +40,7 @@ namespace RGB.NET.Devices.Logitech
return RGBDeviceLighting.None;
}
}
/// <inheritdoc />
public bool SupportsSyncBack => false;
/// <summary>
/// Gets a flag that describes device capabilities. (<see cref="LogitechDeviceCaps" />)
/// </summary>

View File

@ -30,10 +30,7 @@ namespace RGB.NET.Devices.Msi
/// <inheritdoc />
public Uri Image { get; set; }
/// <inheritdoc />
public bool SupportsSyncBack => false;
/// <inheritdoc />
public RGBDeviceLighting Lighting => RGBDeviceLighting.Key;

View File

@ -46,11 +46,7 @@ namespace RGB.NET.Devices.Msi
/// <inheritdoc />
protected override object CreateLedCustomData(LedId ledId) => (int)ledId - (int)LedId.GraphicsCard1;
/// <inheritdoc />
public override void SyncBack()
{ }
#endregion
}
}

View File

@ -44,11 +44,7 @@ namespace RGB.NET.Devices.Msi
/// <inheritdoc />
protected override object CreateLedCustomData(LedId ledId) => (int)ledId - (int)LedId.Mainboard1;
/// <inheritdoc />
public override void SyncBack()
{ }
#endregion
}
}

View File

@ -44,11 +44,7 @@ namespace RGB.NET.Devices.Msi
/// <inheritdoc />
protected override object CreateLedCustomData(LedId ledId) => (int)ledId - (int)LedId.Mouse1;
/// <inheritdoc />
public override void SyncBack()
{ }
#endregion
}
}

View File

@ -28,10 +28,7 @@ namespace RGB.NET.Devices.Novation
/// <inheritdoc />
public RGBDeviceLighting Lighting => RGBDeviceLighting.Key;
/// <inheritdoc />
public bool SupportsSyncBack => false;
/// <summary>
/// Gets the <see cref="NovationColorCapabilities"/> of the <see cref="IRGBDevice"/>.
/// </summary>

View File

@ -30,10 +30,7 @@ namespace RGB.NET.Devices.Razer
/// <inheritdoc />
public Uri Image { get; set; }
/// <inheritdoc />
public bool SupportsSyncBack => false;
/// <inheritdoc />
public RGBDeviceLighting Lighting => RGBDeviceLighting.Key;

View File

@ -1,41 +0,0 @@
using RGB.NET.Devices.SoIP.Generic;
namespace RGB.NET.Devices.SoIP.Client
{
public class SoIPClientDeviceDefinition : ISoIPDeviceDefinition
{
#region Properties & Fields
/// <summary>
/// Gets or sets the hostname of the device.
/// </summary>
public string Hostname { get; set; }
/// <summary>
/// Gets or sets the port to device is listening to.
/// </summary>
public int Port { get; set; }
/// <summary>
/// Gets or sets the manufacturer of the device.
/// </summary>
public string Manufacturer { get; set; } = "Unknown";
/// <summary>
/// Gets or sets the model name of the device.
/// </summary>
public string Model { get; set; } = "Generic SoIP-Device";
#endregion
#region Constructors
public SoIPClientDeviceDefinition(string hostname, int port)
{
this.Hostname = hostname;
this.Port = port;
}
#endregion
}
}

View File

@ -1,87 +0,0 @@
using System;
using System.Collections.Generic;
using System.Linq;
using RGB.NET.Core;
using RGB.NET.Devices.SoIP.Generic;
using SimpleTCP;
namespace RGB.NET.Devices.SoIP.Client
{
public class SoIPClientRGBDevice : AbstractRGBDevice<SoIPClientRGBDeviceInfo>, ISoIPRGBDevice, IUnknownDevice
{
#region Properties & Fields
private readonly Dictionary<LedId, Color> _syncbackCache = new Dictionary<LedId, Color>();
private readonly SimpleTcpClient _tcpClient;
public override SoIPClientRGBDeviceInfo DeviceInfo { get; }
#endregion
#region Constructors
public SoIPClientRGBDevice(SoIPClientRGBDeviceInfo deviceInfo)
{
this.DeviceInfo = deviceInfo;
_tcpClient = new SimpleTcpClient();
_tcpClient.DelimiterDataReceived += TcpClientOnDelimiterDataReceived;
}
#endregion
#region Methods
void ISoIPRGBDevice.Initialize(IDeviceUpdateTrigger updateTrigger)
{
_tcpClient.Connect(DeviceInfo.Hostname, DeviceInfo.Port);
}
/// <inheritdoc />
protected override void UpdateLeds(IEnumerable<Led> ledsToUpdate)
{ }
/// <inheritdoc />
public override void SyncBack()
{
lock (_syncbackCache)
{
foreach (KeyValuePair<LedId, Color> cacheEntry in _syncbackCache)
{
LedId ledId = cacheEntry.Key;
Color color = cacheEntry.Value;
if (!LedMapping.TryGetValue(ledId, out Led led))
led = InitializeLed(cacheEntry.Key, new Rectangle(0, 0, 10, 10)); //TODO DarthAffe 10.06.2018: Send layout with initial package
SetLedColorWithoutRequest(led, color);
}
_syncbackCache.Clear();
}
}
private void TcpClientOnDelimiterDataReceived(object sender, Message message)
{
List<(LedId, Color)> leds = message.MessageString.Split(';').Select(x =>
{
string[] led = x.Split('|');
return ((LedId)Enum.Parse(typeof(LedId), led[0]), RGBColor.FromHexString(led[1]));
}).ToList();
lock (_syncbackCache)
foreach ((LedId ledId, Color color) in leds)
_syncbackCache[ledId] = color;
}
/// <inheritdoc />
public override void Dispose()
{
base.Dispose();
_tcpClient.Disconnect();
_tcpClient.Dispose();
}
#endregion
}
}

View File

@ -1,61 +0,0 @@
using System;
using RGB.NET.Core;
namespace RGB.NET.Devices.SoIP.Client
{
/// <inheritdoc />
/// <summary>
/// Represents device information for a <see cref="SoIPClientRGBDevice"/> />.
/// </summary>
public class SoIPClientRGBDeviceInfo : IRGBDeviceInfo
{
#region Properties & Fields
/// <inheritdoc />
public RGBDeviceType DeviceType => RGBDeviceType.Unknown;
/// <inheritdoc />
public string DeviceName { get; }
/// <inheritdoc />
public string Manufacturer { get; }
/// <inheritdoc />
public string Model { get; }
/// <inheritdoc />
public RGBDeviceLighting Lighting => RGBDeviceLighting.None;
/// <inheritdoc />
public bool SupportsSyncBack => true;
/// <inheritdoc />
public Uri Image { get; set; }
/// <summary>
/// The hostname of the device.
/// </summary>
public string Hostname { get; }
/// <summary>
/// The port of the device.
/// </summary>
public int Port { get; }
#endregion
#region Constructors
internal SoIPClientRGBDeviceInfo(SoIPClientDeviceDefinition deviceDefinition)
{
this.Manufacturer = deviceDefinition.Manufacturer;
this.Model = deviceDefinition.Model;
this.Hostname = deviceDefinition.Hostname;
this.Port = deviceDefinition.Port;
DeviceName = $"{Manufacturer} {Model}";
}
#endregion
}
}

View File

@ -1,4 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<Weavers xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="FodyWeavers.xsd">
<Costura IncludeDebugSymbols="false" IncludeAssemblies="SimpleTCP" />
</Weavers>

View File

@ -1,111 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
<!-- This file was generated by Fody. Manual changes to this file will be lost when your project is rebuilt. -->
<xs:element name="Weavers">
<xs:complexType>
<xs:all>
<xs:element name="Costura" minOccurs="0" maxOccurs="1">
<xs:complexType>
<xs:all>
<xs:element minOccurs="0" maxOccurs="1" name="ExcludeAssemblies" type="xs:string">
<xs:annotation>
<xs:documentation>A list of assembly names to exclude from the default action of "embed all Copy Local references", delimited with line breaks</xs:documentation>
</xs:annotation>
</xs:element>
<xs:element minOccurs="0" maxOccurs="1" name="IncludeAssemblies" type="xs:string">
<xs:annotation>
<xs:documentation>A list of assembly names to include from the default action of "embed all Copy Local references", delimited with line breaks.</xs:documentation>
</xs:annotation>
</xs:element>
<xs:element minOccurs="0" maxOccurs="1" name="Unmanaged32Assemblies" type="xs:string">
<xs:annotation>
<xs:documentation>A list of unmanaged 32 bit assembly names to include, delimited with line breaks.</xs:documentation>
</xs:annotation>
</xs:element>
<xs:element minOccurs="0" maxOccurs="1" name="Unmanaged64Assemblies" type="xs:string">
<xs:annotation>
<xs:documentation>A list of unmanaged 64 bit assembly names to include, delimited with line breaks.</xs:documentation>
</xs:annotation>
</xs:element>
<xs:element minOccurs="0" maxOccurs="1" name="PreloadOrder" type="xs:string">
<xs:annotation>
<xs:documentation>The order of preloaded assemblies, delimited with line breaks.</xs:documentation>
</xs:annotation>
</xs:element>
</xs:all>
<xs:attribute name="CreateTemporaryAssemblies" type="xs:boolean">
<xs:annotation>
<xs:documentation>This will copy embedded files to disk before loading them into memory. This is helpful for some scenarios that expected an assembly to be loaded from a physical file.</xs:documentation>
</xs:annotation>
</xs:attribute>
<xs:attribute name="IncludeDebugSymbols" type="xs:boolean">
<xs:annotation>
<xs:documentation>Controls if .pdbs for reference assemblies are also embedded.</xs:documentation>
</xs:annotation>
</xs:attribute>
<xs:attribute name="DisableCompression" type="xs:boolean">
<xs:annotation>
<xs:documentation>Embedded assemblies are compressed by default, and uncompressed when they are loaded. You can turn compression off with this option.</xs:documentation>
</xs:annotation>
</xs:attribute>
<xs:attribute name="DisableCleanup" type="xs:boolean">
<xs:annotation>
<xs:documentation>As part of Costura, embedded assemblies are no longer included as part of the build. This cleanup can be turned off.</xs:documentation>
</xs:annotation>
</xs:attribute>
<xs:attribute name="LoadAtModuleInit" type="xs:boolean">
<xs:annotation>
<xs:documentation>Costura by default will load as part of the module initialization. This flag disables that behavior. Make sure you call CosturaUtility.Initialize() somewhere in your code.</xs:documentation>
</xs:annotation>
</xs:attribute>
<xs:attribute name="IgnoreSatelliteAssemblies" type="xs:boolean">
<xs:annotation>
<xs:documentation>Costura will by default use assemblies with a name like 'resources.dll' as a satellite resource and prepend the output path. This flag disables that behavior.</xs:documentation>
</xs:annotation>
</xs:attribute>
<xs:attribute name="ExcludeAssemblies" type="xs:string">
<xs:annotation>
<xs:documentation>A list of assembly names to exclude from the default action of "embed all Copy Local references", delimited with |</xs:documentation>
</xs:annotation>
</xs:attribute>
<xs:attribute name="IncludeAssemblies" type="xs:string">
<xs:annotation>
<xs:documentation>A list of assembly names to include from the default action of "embed all Copy Local references", delimited with |.</xs:documentation>
</xs:annotation>
</xs:attribute>
<xs:attribute name="Unmanaged32Assemblies" type="xs:string">
<xs:annotation>
<xs:documentation>A list of unmanaged 32 bit assembly names to include, delimited with |.</xs:documentation>
</xs:annotation>
</xs:attribute>
<xs:attribute name="Unmanaged64Assemblies" type="xs:string">
<xs:annotation>
<xs:documentation>A list of unmanaged 64 bit assembly names to include, delimited with |.</xs:documentation>
</xs:annotation>
</xs:attribute>
<xs:attribute name="PreloadOrder" type="xs:string">
<xs:annotation>
<xs:documentation>The order of preloaded assemblies, delimited with |.</xs:documentation>
</xs:annotation>
</xs:attribute>
</xs:complexType>
</xs:element>
</xs:all>
<xs:attribute name="VerifyAssembly" type="xs:boolean">
<xs:annotation>
<xs:documentation>'true' to run assembly verification (PEVerify) on the target assembly after all weavers have been executed.</xs:documentation>
</xs:annotation>
</xs:attribute>
<xs:attribute name="VerifyIgnoreCodes" type="xs:string">
<xs:annotation>
<xs:documentation>A comma-separated list of error codes that can be safely ignored in assembly verification.</xs:documentation>
</xs:annotation>
</xs:attribute>
<xs:attribute name="GenerateXsd" type="xs:boolean">
<xs:annotation>
<xs:documentation>'false' to turn off automatic generation of the XML Schema file.</xs:documentation>
</xs:annotation>
</xs:attribute>
</xs:complexType>
</xs:element>
</xs:schema>

View File

@ -1,8 +0,0 @@
namespace RGB.NET.Devices.SoIP.Generic
{
/// <summary>
/// Marker interface for SoIP device definitions.
/// </summary>
public interface ISoIPDeviceDefinition
{ }
}

View File

@ -1,11 +0,0 @@
using System;
using RGB.NET.Core;
namespace RGB.NET.Devices.SoIP.Generic
{
// ReSharper disable once InconsistentNaming
internal interface ISoIPRGBDevice : IRGBDevice, IDisposable
{
void Initialize(IDeviceUpdateTrigger updateTrigger);
}
}

View File

@ -1,65 +0,0 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFrameworks>net5.0</TargetFrameworks>
<LangVersion>latest</LangVersion>
<Nullable>enable</Nullable>
<Authors>Darth Affe</Authors>
<Company>Wyrez</Company>
<Language>en-US</Language>
<NeutralLanguage>en-US</NeutralLanguage>
<Title>RGB.NET.Devices.SoIP</Title>
<AssemblyName>RGB.NET.Devices.SoIP</AssemblyName>
<AssemblyTitle>RGB.NET.Devices.SoIP</AssemblyTitle>
<PackageId>RGB.NET.Devices.SoIP</PackageId>
<RootNamespace>RGB.NET.Devices.SoIP</RootNamespace>
<Description>SoIP-Device-Implementations of RGB.NET</Description>
<Summary>SoIP-Device-Implementations of RGB.NET, a C# (.NET) library</Summary>
<Copyright>Copyright © Darth Affe 2020</Copyright>
<PackageCopyright>Copyright © Darth Affe 2020</PackageCopyright>
<PackageIconUrl>http://lib.arge.be/icon.png</PackageIconUrl>
<PackageProjectUrl>https://github.com/DarthAffe/RGB.NET</PackageProjectUrl>
<PackageLicenseUrl>https://raw.githubusercontent.com/DarthAffe/RGB.NET/master/LICENSE</PackageLicenseUrl>
<RepositoryType>Github</RepositoryType>
<RepositoryUrl>https://github.com/DarthAffe/RGB.NET</RepositoryUrl>
<GeneratePackageOnBuild>True</GeneratePackageOnBuild>
<PackageReleaseNotes></PackageReleaseNotes>
<Version>0.0.1</Version>
<AssemblyVersion>0.0.1</AssemblyVersion>
<FileVersion>0.0.1</FileVersion>
<OutputPath>..\bin\</OutputPath>
<GenerateDocumentationFile>true</GenerateDocumentationFile>
<IncludeSource>True</IncludeSource>
<IncludeSymbols>True</IncludeSymbols>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)'=='Debug'">
<DefineConstants>$(DefineConstants);TRACE;DEBUG</DefineConstants>
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)' == 'Release'">
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<NoWarn>$(NoWarn);CS1591;CS1572;CS1573</NoWarn>
<DefineConstants>$(DefineConstants);RELEASE</DefineConstants>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Costura.Fody" Version="4.1" />
<PackageReference Include="Fody" Version="6.3.0">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets>
</PackageReference>
<PackageReference Include="SimpleTCP" Version="1.0.24" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\RGB.NET.Core\RGB.NET.Core.csproj" />
</ItemGroup>
</Project>

View File

@ -1,44 +0,0 @@
using System.Collections.Generic;
using System.Linq;
using RGB.NET.Core;
using RGB.NET.Devices.SoIP.Generic;
namespace RGB.NET.Devices.SoIP.Server
{
public class SoIPServerDeviceDefinition : ISoIPDeviceDefinition
{
#region Properties & Fields
/// <summary>
/// Gets or sets the port to device is listening to.
/// </summary>
public int Port { get; set; }
/// <summary>
/// Gets or sets the manufacturer of the device.
/// </summary>
public string Manufacturer { get; set; } = "Unknown";
/// <summary>
/// Gets or sets the model name of the device.
/// </summary>
public string Model { get; set; } = "Generic SoIP-Device";
/// <summary>
/// Gets the IDs of the leds represented by this device.
/// </summary>
public List<LedId> Leds { get; }
#endregion
#region Constructors
public SoIPServerDeviceDefinition(int port, params LedId[] ledIds)
{
this.Port = port;
this.Leds = ledIds.ToList();
}
#endregion
}
}

View File

@ -1,79 +0,0 @@
using System.Collections.Generic;
using System.Linq;
using System.Net.Sockets;
using RGB.NET.Core;
using RGB.NET.Devices.SoIP.Generic;
using SimpleTCP;
namespace RGB.NET.Devices.SoIP.Server
{
public class SoIPServerRGBDevice : AbstractRGBDevice<SoIPServerRGBDeviceInfo>, ISoIPRGBDevice, IUnknownDevice
{
#region Properties & Fields
private readonly List<LedId> _leds;
private readonly SimpleTcpServer _tcpServer;
private SoIPServerUpdateQueue _updateQueue;
public override SoIPServerRGBDeviceInfo DeviceInfo { get; }
#endregion
#region Constructors
public SoIPServerRGBDevice(SoIPServerRGBDeviceInfo deviceInfo, List<LedId> leds)
{
this.DeviceInfo = deviceInfo;
this._leds = leds;
_tcpServer = new SimpleTcpServer();
_tcpServer.ClientConnected += TcpServerOnClientConnected;
}
#endregion
#region Methods
void ISoIPRGBDevice.Initialize(IDeviceUpdateTrigger updateTrigger)
{
int count = 0;
foreach (LedId id in _leds)
InitializeLed(id, new Rectangle((count++) * 10, 0, 10, 10));
//TODO DarthAffe 10.06.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);
}
_tcpServer.Start(DeviceInfo.Port);
_updateQueue = new SoIPServerUpdateQueue(updateTrigger, _tcpServer);
}
protected override void UpdateLeds(IEnumerable<Led> ledsToUpdate) => _updateQueue.SetData(ledsToUpdate);
private void TcpServerOnClientConnected(object sender, TcpClient tcpClient)
{
string message = GetLedString(LedMapping.Values);
byte[] messageData = _tcpServer.StringEncoder.GetBytes(message + _tcpServer.StringEncoder.GetString(new[] { _tcpServer.Delimiter }));
tcpClient.GetStream().WriteAsync(messageData, 0, messageData.Length);
}
private string GetLedString(IEnumerable<Led> leds) => string.Join(";", leds.Select(x => x.Id.ToString() + "|" + x.Color.AsARGBHexString(false)));
/// <inheritdoc />
public override void Dispose()
{
try { _updateQueue?.Dispose(); }
catch { /* at least we tried */ }
base.Dispose();
_tcpServer.Stop();
}
#endregion
}
}

View File

@ -1,55 +0,0 @@
using System;
using RGB.NET.Core;
namespace RGB.NET.Devices.SoIP.Server
{
/// <inheritdoc />
/// <summary>
/// Represents device information for a <see cref="SoIPServerRGBDevice"/> />.
/// </summary>
public class SoIPServerRGBDeviceInfo : IRGBDeviceInfo
{
#region Properties & Fields
/// <inheritdoc />
public RGBDeviceType DeviceType => RGBDeviceType.Unknown;
/// <inheritdoc />
public string DeviceName { get; }
/// <inheritdoc />
public string Manufacturer { get; }
/// <inheritdoc />
public string Model { get; }
/// <inheritdoc />
public RGBDeviceLighting Lighting => RGBDeviceLighting.Key;
/// <inheritdoc />
public bool SupportsSyncBack => false;
/// <inheritdoc />
public Uri Image { get; set; }
/// <summary>
/// The port of the device.
/// </summary>
public int Port { get; }
#endregion
#region Constructors
internal SoIPServerRGBDeviceInfo(SoIPServerDeviceDefinition deviceDefinition)
{
this.Manufacturer = deviceDefinition.Manufacturer;
this.Model = deviceDefinition.Model;
this.Port = deviceDefinition.Port;
DeviceName = $"{Manufacturer} {Model}";
}
#endregion
}
}

View File

@ -1,53 +0,0 @@
using System;
using System.Collections.Generic;
using System.Linq;
using RGB.NET.Core;
using SimpleTCP;
namespace RGB.NET.Devices.SoIP.Server
{
/// <inheritdoc />
/// <summary>
/// Represents the update-queue performing updates for E131-DMX devices.
/// </summary>
public class SoIPServerUpdateQueue : UpdateQueue
{
#region Properties & Fields
private readonly SimpleTcpServer _tcpServer;
#endregion
#region Constructors
/// <inheritdoc />
/// <summary>
/// Initializes a new instance of the <see cref="T:RGB.NET.Devices.SoIP.Server.SoIPServerUpdateQueue" /> class.
/// </summary>
/// <param name="updateTrigger">The update trigger used by this queue.</param>
/// <param name="tcpServer">The hostname of the device this queue is performing updates for.</param>
public SoIPServerUpdateQueue(IDeviceUpdateTrigger updateTrigger, SimpleTcpServer tcpServer)
: base(updateTrigger)
{
this._tcpServer = tcpServer;
}
#endregion
#region Methods
/// <inheritdoc />
protected override void Update(Dictionary<object, Color> dataSet)
{
if ((dataSet != null) && (dataSet.Count > 0))
{
string m = GetLedString(dataSet);
_tcpServer.BroadcastLine(m);
}
}
private string GetLedString(Dictionary<object, Color> dataSet) => string.Join(";", dataSet.Select(x => x.Key.ToString() + "|" + x.Value.AsARGBHexString(false)));
#endregion
}
}

View File

@ -1,139 +0,0 @@
// 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.SoIP.Client;
using RGB.NET.Devices.SoIP.Generic;
using RGB.NET.Devices.SoIP.Server;
namespace RGB.NET.Devices.SoIP
{
/// <inheritdoc />
/// <summary>
/// Represents a device provider responsible for debug devices.
/// </summary>
public class SoIPDeviceProvider : IRGBDeviceProvider
{
#region Properties & Fields
private static SoIPDeviceProvider _instance;
/// <summary>
/// Gets the singleton <see cref="SoIPDeviceProvider"/> instance.
/// </summary>
public static SoIPDeviceProvider Instance => _instance ?? new SoIPDeviceProvider();
/// <inheritdoc />
public bool IsInitialized { get; private set; }
/// <inheritdoc />
public IEnumerable<IRGBDevice> Devices { get; private set; }
/// <inheritdoc />
public bool HasExclusiveAccess => false;
/// <summary>
/// Gets a list of all defined device-definitions.
/// </summary>
public List<ISoIPDeviceDefinition> DeviceDefinitions { get; } = new List<ISoIPDeviceDefinition>();
/// <summary>
/// The <see cref="DeviceUpdateTrigger"/> used to trigger the updates for dmx devices.
/// </summary>
public DeviceUpdateTrigger UpdateTrigger { get; private set; }
#endregion
#region Constructors
/// <summary>
/// Initializes a new instance of the <see cref="SoIPDeviceProvider"/> class.
/// </summary>
/// <exception cref="InvalidOperationException">Thrown if this constructor is called even if there is already an instance of this class.</exception>
public SoIPDeviceProvider()
{
if (_instance != null) throw new InvalidOperationException($"There can be only one instance of type {nameof(SoIPDeviceProvider)}");
_instance = this;
UpdateTrigger = new DeviceUpdateTrigger();
}
#endregion
#region Methods
/// <summary>
/// Adds the given <see cref="ISoIPDeviceDefinition" /> to this device-provider.
/// </summary>
/// <param name="deviceDefinition">The <see cref="ISoIPDeviceDefinition"/> to add.</param>
public void AddDeviceDefinition(ISoIPDeviceDefinition deviceDefinition) => DeviceDefinitions.Add(deviceDefinition);
/// <inheritdoc />
public bool Initialize(RGBDeviceType loadFilter = RGBDeviceType.Unknown, bool exclusiveAccessIfPossible = false, bool throwExceptions = false)
{
IsInitialized = false;
try
{
UpdateTrigger.Stop();
IList<IRGBDevice> devices = new List<IRGBDevice>();
foreach (ISoIPDeviceDefinition deviceDefinition in DeviceDefinitions)
{
try
{
ISoIPRGBDevice device = null;
switch (deviceDefinition)
{
case SoIPServerDeviceDefinition serverDeviceDefinition:
if (serverDeviceDefinition.Leds.Count > 0)
device = new SoIPServerRGBDevice(new SoIPServerRGBDeviceInfo(serverDeviceDefinition), serverDeviceDefinition.Leds);
break;
case SoIPClientDeviceDefinition clientDeviceDefinition:
device = new SoIPClientRGBDevice(new SoIPClientRGBDeviceInfo(clientDeviceDefinition));
break;
}
if (device != null)
{
device.Initialize(UpdateTrigger);
devices.Add(device);
}
}
catch { if (throwExceptions) throw; }
}
UpdateTrigger.Start();
Devices = new ReadOnlyCollection<IRGBDevice>(devices);
IsInitialized = true;
}
catch
{
if (throwExceptions) throw;
return false;
}
return true;
}
/// <inheritdoc />
public void ResetDevices()
{ }
/// <inheritdoc />
public void Dispose()
{
try { UpdateTrigger?.Dispose(); }
catch { /* at least we tried */ }
}
#endregion
}
}

View File

@ -1,24 +0,0 @@
using RGB.NET.Core;
namespace RGB.NET.Devices.SoIP
{
/// <summary>
/// Represents a device provider loaded used to dynamically load SoIP (syncback over IP) devices into an application.
/// </summary>
public class SoIPDeviceProviderLoader : IRGBDeviceProviderLoader
{
#region Properties & Fields
/// <inheritdoc />
public bool RequiresInitialization => true;
#endregion
#region Methods
/// <inheritdoc />
public IRGBDeviceProvider GetDeviceProvider() => SoIPDeviceProvider.Instance;
#endregion
}
}

View File

@ -28,10 +28,7 @@ namespace RGB.NET.Devices.SteelSeries
/// <inheritdoc />
public RGBDeviceLighting Lighting => RGBDeviceLighting.Key;
/// <inheritdoc />
public bool SupportsSyncBack => false;
public SteelSeriesDeviceType SteelSeriesDeviceType { get; }
/// <summary>

View File

@ -26,10 +26,7 @@ namespace RGB.NET.Devices.WS281X.Arduino
/// <inheritdoc />
public RGBDeviceLighting Lighting => RGBDeviceLighting.Key;
/// <inheritdoc />
public bool SupportsSyncBack => false;
/// <inheritdoc />
public Uri Image { get; set; }

View File

@ -26,10 +26,7 @@ namespace RGB.NET.Devices.WS281X.Bitwizard
/// <inheritdoc />
public RGBDeviceLighting Lighting => RGBDeviceLighting.Key;
/// <inheritdoc />
public bool SupportsSyncBack => false;
/// <inheritdoc />
public Uri Image { get; set; }

View File

@ -26,10 +26,7 @@ namespace RGB.NET.Devices.WS281X.NodeMCU
/// <inheritdoc />
public RGBDeviceLighting Lighting => RGBDeviceLighting.Key;
/// <inheritdoc />
public bool SupportsSyncBack => false;
/// <inheritdoc />
public Uri Image { get; set; }

View File

@ -30,10 +30,7 @@ namespace RGB.NET.Devices.Wooting.Generic
/// <inheritdoc />
public RGBDeviceLighting Lighting => RGBDeviceLighting.Key;
/// <inheritdoc />
public bool SupportsSyncBack => false;
/// <summary>
/// Gets the <see cref="WootingDevicesIndexes"/> of the <see cref="WootingRGBDevice{TDeviceInfo}"/>.
/// </summary>

View File

@ -27,8 +27,6 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "RGB.NET.Devices.Razer", "RG
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "RGB.NET.Devices.Roccat", "RGB.NET.Devices.Roccat\RGB.NET.Devices.Roccat.csproj", "{9DF256B9-1AB7-4D5B-B2E5-94AF6691DC9E}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "RGB.NET.Devices.SoIP", "RGB.NET.Devices.SoIP\RGB.NET.Devices.SoIP.csproj", "{14FF7ECF-2E58-4B11-97A2-C5801E1BC696}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "RGB.NET.Brushes", "RGB.NET.Brushes\RGB.NET.Brushes.csproj", "{B159FB51-5939-490E-A1BA-FB55D4D7ADDF}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "RGB.NET.Decorators", "RGB.NET.Decorators\RGB.NET.Decorators.csproj", "{8725C448-818C-41F7-B23F-F97E062BF233}"
@ -93,10 +91,6 @@ Global
{9DF256B9-1AB7-4D5B-B2E5-94AF6691DC9E}.Debug|Any CPU.Build.0 = Debug|Any CPU
{9DF256B9-1AB7-4D5B-B2E5-94AF6691DC9E}.Release|Any CPU.ActiveCfg = Release|Any CPU
{9DF256B9-1AB7-4D5B-B2E5-94AF6691DC9E}.Release|Any CPU.Build.0 = Release|Any CPU
{14FF7ECF-2E58-4B11-97A2-C5801E1BC696}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{14FF7ECF-2E58-4B11-97A2-C5801E1BC696}.Debug|Any CPU.Build.0 = Debug|Any CPU
{14FF7ECF-2E58-4B11-97A2-C5801E1BC696}.Release|Any CPU.ActiveCfg = Release|Any CPU
{14FF7ECF-2E58-4B11-97A2-C5801E1BC696}.Release|Any CPU.Build.0 = Release|Any CPU
{B159FB51-5939-490E-A1BA-FB55D4D7ADDF}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{B159FB51-5939-490E-A1BA-FB55D4D7ADDF}.Debug|Any CPU.Build.0 = Debug|Any CPU
{B159FB51-5939-490E-A1BA-FB55D4D7ADDF}.Release|Any CPU.ActiveCfg = Release|Any CPU
@ -143,7 +137,6 @@ Global
{19F701FD-5577-4873-9BE6-6775676FA185} = {D13032C6-432E-4F43-8A32-071133C22B16}
{2E162CB7-2C6C-4069-8356-06162F7BE0AA} = {D13032C6-432E-4F43-8A32-071133C22B16}
{9DF256B9-1AB7-4D5B-B2E5-94AF6691DC9E} = {D13032C6-432E-4F43-8A32-071133C22B16}
{14FF7ECF-2E58-4B11-97A2-C5801E1BC696} = {D13032C6-432E-4F43-8A32-071133C22B16}
{B159FB51-5939-490E-A1BA-FB55D4D7ADDF} = {EBC33090-8494-4DF4-B4B6-64D0E531E93F}
{8725C448-818C-41F7-B23F-F97E062BF233} = {EBC33090-8494-4DF4-B4B6-64D0E531E93F}
{6FEBDC9E-909D-4EE2-B003-EDFBEF5FFF40} = {EBC33090-8494-4DF4-B4B6-64D0E531E93F}