Skip to content

Commit

Permalink
Move ArtData to AbstractInstance
Browse files Browse the repository at this point in the history
Add BinaryTests for:
Obsidian RDM10 FW 2.9.2 & 2.9.4
ENTEC DIN Ethergate 2 FW 2.1 & FW 2.5
  • Loading branch information
patrick-dmxc committed May 16, 2024
1 parent 3eacda1 commit 19aeb4a
Show file tree
Hide file tree
Showing 8 changed files with 305 additions and 56 deletions.
48 changes: 48 additions & 0 deletions ArtNetSharp/Communication/AbstractInstance.cs
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,12 @@ public abstract class AbstractInstance : IInstance
protected virtual bool SendArtData { get; } = false;
protected virtual bool SupportRDM { get; } = false;

protected virtual string UrlProduct { get; }
protected virtual string UrlUserGuid { get; }
protected virtual string UrlSupport { get; }
protected virtual string UrlPersonalityUDR { get; }
protected virtual string UrlPersonalityGDTF { get; }

private readonly ConcurrentDictionary<RDMUID, ControllerRDMUID_Bag> knownControllerRDMUIDs = new ConcurrentDictionary<RDMUID, ControllerRDMUID_Bag>();
public virtual RDMUID UID { get; } = RDMUID.Empty;

Expand Down Expand Up @@ -307,6 +313,9 @@ void IInstance.PacketReceived(AbstractArtPacketCore packet, IPv4Address localIp,
case ArtPollReply artPollReply:
processArtPollReply(artPollReply, localIp, sourceIp);
break;
case ArtData artData:
_ = processArtData(artData, sourceIp);
break;

case ArtDMX artDMX:
processArtDMX(artDMX, sourceIp);
Expand Down Expand Up @@ -836,6 +845,45 @@ private void processArtDMX(ArtDMX artDMX, IPv4Address sourceIp)
port.GoodOutput |= EGoodOutput.DataTransmitted;
}
}
protected async Task processArtData(ArtData artData, IPv4Address source)
{
if (this.IsDisposing || this.IsDisposed || this.IsDeactivated || !this.SendArtData)
return;

try
{
if (artData.Request == EDataRequest.Poll)
{
await TrySendPacket(new ArtDataReply(OEMProductCode, ESTAManufacturerCode, data: null), source);
return;
}
ArtDataReply packet = null;
string str = null;
switch (artData.Request)
{
case EDataRequest.UrlProduct: str = UrlProduct; break;
case EDataRequest.UrlUserGuide: str = UrlUserGuid; break;
case EDataRequest.UrlSupport: str = UrlSupport; break;
case EDataRequest.UrlPersUdr: str = UrlPersonalityUDR; break;
case EDataRequest.UrlPersGdtf: str = UrlPersonalityGDTF; break;
}
if (!string.IsNullOrWhiteSpace(str))
packet = new ArtDataReply(OEMProductCode, ESTAManufacturerCode, artData.Request, str);

if (packet == null)
packet = buildArtDataReply(artData);

if (packet != null)
await TrySendPacket(packet, source);
}
catch (Exception ex) { Logger.LogError(ex); }
}

protected virtual ArtDataReply buildArtDataReply(ArtData artData)
{

return new ArtDataReply(OEMProductCode, ESTAManufacturerCode, artData.Request, data: null);
}


protected async Task processArtTodRequest(ArtTodRequest artTodRequest, IPv4Address source)
Expand Down
1 change: 0 additions & 1 deletion ArtNetSharp/Communication/ConfigInstance.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ protected override async void OnPacketReceived(AbstractArtPacketCore packet, IPv
{
switch (packet)
{

case ArtDataReply artDataReply:
await processArtDataReply(artDataReply, sourceIp);
break;
Expand Down
57 changes: 4 additions & 53 deletions ArtNetSharp/Communication/NodeInstance.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,64 +14,15 @@ public NodeInstance(ArtNet _artnet) : base(_artnet)
protected sealed override bool SendArtPollBroadcast => false;
protected sealed override bool SendArtPollTargeted => true;

protected virtual string UrlProduct { get; }
protected virtual string UrlUserGuid { get; }
protected virtual string UrlSupport { get; }
protected virtual string UrlPersonalityUDR { get; }
protected virtual string UrlPersonalityGDTF { get; }

protected override void OnPacketReceived(AbstractArtPacketCore packet, IPv4Address localIp, IPv4Address sourceIp)
{
switch (packet)
{
case ArtData artData:
_ = processArtData(artData, sourceIp);
break;
}
//switch (packet)
//{
//}
}
public async Task PerformRDMDiscovery(PortAddress? portAddress = null, bool flush = false)
{
await base.PerformRDMDiscovery(portAddress, flush, true); // As per spec Broadcast 1.4dh 19/7/2023 - 82 -
}

protected async Task processArtData(ArtData artData, IPv4Address source)
{
if (this.IsDisposing || this.IsDisposed || this.IsDeactivated || !this.SendArtData)
return;

try
{
if (artData.Request == EDataRequest.Poll)
{
await TrySendPacket(new ArtDataReply(OEMProductCode, ESTAManufacturerCode, data: null), source);
return;
}
ArtDataReply packet = null;
string str = null;
switch (artData.Request)
{
case EDataRequest.UrlProduct: str = UrlProduct; break;
case EDataRequest.UrlUserGuide: str = UrlUserGuid; break;
case EDataRequest.UrlSupport: str = UrlSupport; break;
case EDataRequest.UrlPersUdr: str = UrlPersonalityUDR; break;
case EDataRequest.UrlPersGdtf: str = UrlPersonalityGDTF; break;
}
if (!string.IsNullOrWhiteSpace(str))
packet = new ArtDataReply(OEMProductCode, ESTAManufacturerCode, artData.Request, str);

if (packet == null)
packet = buildArtDataReply(artData);

if (packet != null)
await TrySendPacket(packet, source);
}
catch (Exception ex) { Logger.LogError(ex); }
}

protected virtual ArtDataReply buildArtDataReply(ArtData artData)
{

return new ArtDataReply(OEMProductCode, ESTAManufacturerCode, artData.Request, data: null);
}
}
}
}
3 changes: 1 addition & 2 deletions ArtNetSharp/Messages/Abstract/AbstractArtPacketNet.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,7 @@ public abstract class AbstractArtPacketNet : AbstractArtPacket
/// </summary>
public readonly Net Net;

public AbstractArtPacketNet(in Net net,
in ushort protocolVersion = Constants.PROTOCOL_VERSION) : base(protocolVersion)
public AbstractArtPacketNet(in Net net, in ushort protocolVersion = Constants.PROTOCOL_VERSION) : base(protocolVersion)
{
Net = net;
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
using ArtNetSharp;
using RDMSharp;

namespace ArtNetTests.Binary_Tests.Luminex
{
internal class Elation_Obisdian_RDM10_2_9_2 : AbstractArtPollReplyBinaryTestSubject
{
private static readonly byte[] DATA= [
0x41, 0x72, 0x74, 0x2d, 0x4e, 0x65, 0x74, 0x00,
0x00, 0x21, 0x02, 0x6a, 0x4e, 0x13, 0x36, 0x19,
0x02, 0x5e, 0x00, 0x00, 0x2a, 0x1e, 0x00, 0xe2,
0xa6, 0x22, 0x50, 0x6f, 0x72, 0x74, 0x20, 0x31,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x4e, 0x45, 0x54, 0x52,
0x4f, 0x4e, 0x20, 0x52, 0x44, 0x4d, 0x31, 0x30,
0x28, 0x34, 0x32, 0x3a, 0x34, 0x43, 0x3a, 0x41,
0x32, 0x3a, 0x32, 0x32, 0x3a, 0x34, 0x45, 0x3a,
0x31, 0x33, 0x29, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x40, 0x00,
0x00, 0x00, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x64, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x42, 0x4c, 0xa2, 0x22, 0x4e, 0x13, 0x02,
0x6a, 0x4e, 0x13, 0x01, 0xdd, 0xc0, 0x00, 0x00,
0x00, 0x3c, 0x22, 0xa6, 0x06, 0xd3, 0x02, 0x28,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 ];

private static readonly PortTestSubject[] PORTS =
[
new PortTestSubject(EPortType.InputToArtNet,(Universe)0,(Universe)0)
];
public Elation_Obisdian_RDM10_2_9_2() : base(
"Elation Obsidian RDM10 (FW 2.9.2)",
DATA,
0,
"Port 1",
"NETRON RDM10(42:4C:A2:22:4E:13)",
new MACAddress("42:4c:a2:22:4e:13"),
new IPv4Address("2.106.78.19"),
new IPv4Address("2.106.78.19"),
0x2a1e,
0x22a6,
EStCodes.StNode,
PORTS,
true,
majorVersion: 2,
minorVersion: 92)
{
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
using ArtNetSharp;
using RDMSharp;

namespace ArtNetTests.Binary_Tests.Luminex
{
internal class Elation_Obisdian_RDM10_2_9_4 : AbstractArtPollReplyBinaryTestSubject
{
private static readonly byte[] DATA= [
0x41, 0x72, 0x74, 0x2d, 0x4e, 0x65, 0x74, 0x00,
0x00, 0x21, 0x02, 0x5e, 0x4a, 0x67, 0x36, 0x19,
0x02, 0x5c, 0x00, 0x00, 0x2a, 0x1e, 0x00, 0xe2,
0xa6, 0x22, 0x50, 0x6f, 0x72, 0x74, 0x20, 0x31,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x4e, 0x45, 0x54, 0x52,
0x4f, 0x4e, 0x20, 0x52, 0x44, 0x4d, 0x31, 0x30,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x80, 0x00,
0x00, 0x00, 0x08, 0x00, 0x00, 0x00, 0x80, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x64, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x42, 0x4c, 0x4a, 0x16, 0x4a, 0x67, 0x02,
0x5e, 0x4a, 0x67, 0x01, 0xdd, 0xc0, 0x00, 0x00,
0x00, 0x3c, 0x22, 0xa6, 0x06, 0xd3, 0x01, 0x67,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 ];

private static readonly PortTestSubject[] PORTS =
[
new PortTestSubject(EPortType.OutputFromArtNet,(Universe)0,(Universe)0)
];
public Elation_Obisdian_RDM10_2_9_4() : base(
"Elation Obsidian RDM10 (FW 2.9.4)",
DATA,
0,
"Port 1",
"NETRON RDM10",
new MACAddress("42:4c:4a:16:4a:67"),
new IPv4Address("2.94.74.103"),
new IPv4Address("2.94.74.103"),
0x2a1e,
0x22a6,
EStCodes.StNode,
PORTS,
true,
majorVersion:2,
minorVersion:94)
{
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
using ArtNetSharp;
using RDMSharp;

namespace ArtNetTests.Binary_Tests.Luminex
{
internal class Entec_Din_Ethergate_2_FW_2_1 : AbstractArtPollReplyBinaryTestSubject
{
private static readonly byte[] DATA= [
0x41, 0x72, 0x74, 0x2d, 0x4e, 0x65, 0x74, 0x00,
0x00, 0x21, 0x02, 0x00, 0x00, 0x55, 0x36, 0x19,
0x02, 0x01, 0x00, 0x00, 0x01, 0x90, 0x00, 0x02,
0x4e, 0x45, 0x45, 0x74, 0x68, 0x65, 0x72, 0x67,
0x61, 0x74, 0x65, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x44, 0x49, 0x4e, 0x20,
0x45, 0x74, 0x68, 0x65, 0x72, 0x67, 0x61, 0x74,
0x65, 0x20, 0x32, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x80, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x82, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0xd0, 0x9f, 0xd9, 0x90, 0x45, 0x16, 0x02,
0x00, 0x00, 0x55, 0x01, 0x0d, 0x00, 0x00, 0x80,
0x80, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 ];

private static readonly PortTestSubject[] PORTS =
[
new PortTestSubject(EPortType.OutputFromArtNet,(Universe)0,(Universe)0)
];
public Entec_Din_Ethergate_2_FW_2_1() : base(
"ENTEC DIN Ethergate 2 (FW 2.1)",
DATA,
0,
"Ethergate",
"DIN Ethergate 2",
new MACAddress("d0:9f:d9:90:45:16"),
new IPv4Address("2.0.0.85"),
new IPv4Address("2.0.0.85"),
0x0190,
0x454e,
EStCodes.StNode,
PORTS,
false, //[215] GoodOutputB RDM Flag on port 3 & 4 set, but should be 0
majorVersion: 2,
minorVersion: 1)
{
}
}
}
Loading

0 comments on commit 19aeb4a

Please sign in to comment.