mirror of
https://github.com/DarthAffe/RGB.NET.git
synced 2025-12-13 01:58:30 +00:00
Addded heartbeats to dmx devices
This commit is contained in:
parent
c6cfe35124
commit
15c056f11b
@ -57,14 +57,15 @@ public class DMXDeviceProvider : AbstractRGBDeviceProvider
|
|||||||
/// <inheritdoc />
|
/// <inheritdoc />
|
||||||
protected override IEnumerable<IRGBDevice> LoadDevices()
|
protected override IEnumerable<IRGBDevice> LoadDevices()
|
||||||
{
|
{
|
||||||
foreach (IDMXDeviceDefinition dmxDeviceDefinition in DeviceDefinitions)
|
for (int i = 0; i < DeviceDefinitions.Count; i++)
|
||||||
{
|
{
|
||||||
|
IDMXDeviceDefinition dmxDeviceDefinition = DeviceDefinitions[i];
|
||||||
IRGBDevice? device = null;
|
IRGBDevice? device = null;
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
if (dmxDeviceDefinition is E131DMXDeviceDefinition e131DMXDeviceDefinition)
|
if (dmxDeviceDefinition is E131DMXDeviceDefinition e131DMXDeviceDefinition)
|
||||||
if (e131DMXDeviceDefinition.Leds.Count > 0)
|
if (e131DMXDeviceDefinition.Leds.Count > 0)
|
||||||
device = new E131Device(new E131DeviceInfo(e131DMXDeviceDefinition), e131DMXDeviceDefinition.Leds, GetUpdateTrigger(0));
|
device = new E131Device(new E131DeviceInfo(e131DMXDeviceDefinition), e131DMXDeviceDefinition.Leds, GetUpdateTrigger(i));
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
@ -76,5 +77,14 @@ public class DMXDeviceProvider : AbstractRGBDeviceProvider
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected override IDeviceUpdateTrigger CreateUpdateTrigger(int id, double updateRateHardLimit)
|
||||||
|
{
|
||||||
|
DeviceUpdateTrigger updateTrigger = new(updateRateHardLimit);
|
||||||
|
if ((DeviceDefinitions[id] is E131DMXDeviceDefinition e131DMXDeviceDefinition))
|
||||||
|
updateTrigger.HeartbeatTimer = e131DMXDeviceDefinition.HeartbeatTimer;
|
||||||
|
|
||||||
|
return updateTrigger;
|
||||||
|
}
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
}
|
}
|
||||||
@ -57,6 +57,12 @@ public class E131DMXDeviceDefinition : IDMXDeviceDefinition
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public Dictionary<LedId, List<(int channel, Func<Color, byte> getValueFunc)>> Leds { get; } = new();
|
public Dictionary<LedId, List<(int channel, Func<Color, byte> getValueFunc)>> Leds { get; } = new();
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// The time in ms after which the device is updated even if no changes are made in the meantime to prevent the target from timing out or similar problems.
|
||||||
|
/// To disable heartbeats leave it at 0.
|
||||||
|
/// </summary>
|
||||||
|
public int HeartbeatTimer { get; set; } = 0;
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
#region Constructors
|
#region Constructors
|
||||||
|
|||||||
@ -50,6 +50,14 @@ public class E131UpdateQueue : UpdateQueue
|
|||||||
|
|
||||||
#region Methods
|
#region Methods
|
||||||
|
|
||||||
|
protected override void OnUpdate(object? sender, CustomUpdateData customData)
|
||||||
|
{
|
||||||
|
if (customData[CustomUpdateDataIndex.HEARTBEAT] as bool? == true)
|
||||||
|
Update(Array.Empty<(object key, Color color)>());
|
||||||
|
else
|
||||||
|
base.OnUpdate(sender, customData);
|
||||||
|
}
|
||||||
|
|
||||||
/// <inheritdoc />
|
/// <inheritdoc />
|
||||||
protected override void Update(in ReadOnlySpan<(object key, Color color)> dataSet)
|
protected override void Update(in ReadOnlySpan<(object key, Color color)> dataSet)
|
||||||
{
|
{
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user