Skip to content

Commit c92314a

Browse files
committed
Some rework
1 parent 1188e23 commit c92314a

File tree

9 files changed

+141
-138
lines changed

9 files changed

+141
-138
lines changed

ArtNetSharp.sln

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "NodeOutputExample", "Exampl
1313
EndProject
1414
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "NodeInputExample", "Examples\NodeInputExample\NodeInputExample.csproj", "{9CCE08DE-6ED6-4A19-AB0D-C01413A2E5D3}"
1515
EndProject
16-
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ControlerRDMExample", "Examples\ControlerRDMExample\ControlerRDMExample.csproj", "{90BF6833-7425-4D6B-A8F9-8487A60F1B78}"
16+
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "NodeOutputRDMExample", "Examples\NodeOutputRDMExample\NodeOutputRDMExample.csproj", "{90BF6833-7425-4D6B-A8F9-8487A60F1B78}"
1717
EndProject
1818
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ConfigExample", "Examples\ConfigExample\ConfigExample.csproj", "{DF3AFD9A-0629-43C9-AAC6-5EF22728C5E8}"
1919
EndProject

ArtNetSharp/Communication/AbstractInstance.cs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -250,8 +250,8 @@ public void Dispose()
250250
private readonly ConcurrentDictionary<UID, RDMUID_ReceivedBag> knownRDMUIDs = new ConcurrentDictionary<UID, RDMUID_ReceivedBag>();
251251
public IReadOnlyCollection<RDMUID_ReceivedBag> KnownRDMUIDs;
252252
public event EventHandler<RDMUID_ReceivedBag> RDMUIDReceived;
253-
public event EventHandler<ResponderRDMMessageReceivedEventArgs> ResponderRDMMessageReceived;
254-
public event EventHandler<ControllerRDMMessageReceivedEventArgs> ControllerRDMMessageReceived;
253+
public event EventHandler<ResponseRDMMessageReceivedEventArgs> ResponseRDMMessageReceived;
254+
public event EventHandler<RequestRDMMessageReceivedEventArgs> RequestRDMMessageReceived;
255255

256256
internal static readonly SendPollThreadBag sendPollThreadBag = new SendPollThreadBag();
257257

@@ -1027,16 +1027,16 @@ private async void processArtRDM(ArtRDM artRDM, IPv4Address source)
10271027
{
10281028
if (!artRDM.RDMMessage.Command.HasFlag(ERDM_Command.RESPONSE))
10291029
{
1030-
var eventArgs = new ControllerRDMMessageReceivedEventArgs(artRDM.RDMMessage, artRDM.PortAddress);
1031-
ControllerRDMMessageReceived?.InvokeFailSafe(this, eventArgs);
1030+
var eventArgs = new RequestRDMMessageReceivedEventArgs(artRDM.RDMMessage, artRDM.PortAddress);
1031+
RequestRDMMessageReceived?.InvokeFailSafe(this, eventArgs);
10321032
if (eventArgs.Handled)
10331033
await sendArtRDM(eventArgs.Response, artRDM.PortAddress, source);
10341034
}
10351035
else
10361036
{
1037-
var eventArgs = new ResponderRDMMessageReceivedEventArgs(artRDM.RDMMessage, artRDM.PortAddress);
1037+
var eventArgs = new ResponseRDMMessageReceivedEventArgs(artRDM.RDMMessage, artRDM.PortAddress);
10381038

1039-
ResponderRDMMessageReceived?.InvokeFailSafe(this, eventArgs);
1039+
ResponseRDMMessageReceived?.InvokeFailSafe(this, eventArgs);
10401040
}
10411041
}
10421042
catch (Exception ex) { Logger.LogError(ex); }

ArtNetSharp/Communication/NodeInstance.cs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,16 @@ namespace ArtNetSharp.Communication
44
{
55
public class NodeInstance : AbstractInstance
66
{
7-
public NodeInstance(ArtNet _artnet) : base(_artnet)
7+
public NodeInstance(ArtNet _artnet, bool supportRDM = false) : base(_artnet)
88
{
9+
this.supportRDM = supportRDM;
910
}
1011

1112
public sealed override EStCodes EstCodes => EStCodes.StNode;
1213
protected sealed override bool SendArtPollBroadcast => false;
1314
protected sealed override bool SendArtPollTargeted => true;
15+
private bool supportRDM = false;
16+
protected override bool SupportRDM => supportRDM;
1417

1518
protected override void OnPacketReceived(AbstractArtPacketCore packet, IPv4Address localIp, IPv4Address sourceIp)
1619
{

ArtNetSharp/Misc/RDMMessageReceivedEventArgs.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,13 @@
33

44
namespace ArtNetSharp.Misc
55
{
6-
public class ControllerRDMMessageReceivedEventArgs : EventArgs
6+
public class RequestRDMMessageReceivedEventArgs : EventArgs
77
{
88
public readonly RDMMessage Request;
99
public bool Handled { get => Response != null; }
1010
public RDMMessage Response;
1111
public readonly PortAddress PortAddress;
12-
public ControllerRDMMessageReceivedEventArgs(in RDMMessage request, in PortAddress portAddress)
12+
public RequestRDMMessageReceivedEventArgs(in RDMMessage request, in PortAddress portAddress)
1313
{
1414
this.Request = request;
1515
this.PortAddress = portAddress;
@@ -25,11 +25,11 @@ public void SetResponse(RDMMessage response)
2525
}
2626
}
2727
}
28-
public class ResponderRDMMessageReceivedEventArgs : EventArgs
28+
public class ResponseRDMMessageReceivedEventArgs : EventArgs
2929
{
3030
public readonly RDMMessage Response;
3131
public readonly PortAddress PortAddress;
32-
public ResponderRDMMessageReceivedEventArgs(RDMMessage response, in PortAddress portAddress)
32+
public ResponseRDMMessageReceivedEventArgs(RDMMessage response, in PortAddress portAddress)
3333
{
3434
this.Response = response;
3535
this.PortAddress = portAddress;

ArtNetTests/ObjectTypesTests.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -480,9 +480,9 @@ public void TestGoodInput()
480480
Assert.That(c, Is.EqualTo(b));
481481
}
482482
[Test]
483-
public void TestControllerRDMMessageReceivedEventArgs()
483+
public void TestRequestRDMMessageReceivedEventArgs()
484484
{
485-
var e = new ControllerRDMMessageReceivedEventArgs(new RDMMessage() { Command = ERDM_Command.SET_COMMAND, Parameter = ERDM_Parameter.CURVE }, new PortAddress(123));
485+
var e = new RequestRDMMessageReceivedEventArgs(new RDMMessage() { Command = ERDM_Command.SET_COMMAND, Parameter = ERDM_Parameter.CURVE }, new PortAddress(123));
486486

487487
Assert.That(e.Handled, Is.False);
488488
e.SetResponse(new RDMMessage() { Command = ERDM_Command.SET_COMMAND_RESPONSE, Parameter = ERDM_Parameter.CURVE });

Examples/ControlerRDMExample/ControlerRDMExample.csproj renamed to Examples/NodeOutputRDMExample/NodeOutputRDMExample.csproj

File renamed without changes.
Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
using org.dmxc.wkdt.Light.RDM;
55
using System.Collections.Concurrent;
66

7-
Console.WriteLine("Controller RDM Example!");
7+
Console.WriteLine("Node RDM Example!");
88

99
//Add Logging
1010
//ArtNet.SetLoggerFectory(YOUR_LOGGER_FACTORY);
@@ -14,13 +14,13 @@
1414
//ArtNet.Instance.NetworkClients.ToList().ForEach(ncb => ncb.Enabled = IPAddress.Equals(broadcastIp, ncb.BroadcastIpAddress));
1515

1616
// Create Instance
17-
ControllerInstance controllerInstance = new ControllerInstance(ArtNet.Instance);
18-
controllerInstance.Name = controllerInstance.ShortName = "Controller RDM Example";
17+
NodeInstance nodeInstance = new NodeInstance(ArtNet.Instance, true);
18+
nodeInstance.Name = nodeInstance.ShortName = "Node RDM Example";
1919
ConcurrentDictionary<UID, TestRDMDevice> devices = new();
2020

2121

2222
// Add Instance
23-
ArtNet.Instance.AddInstance(controllerInstance);
23+
ArtNet.Instance.AddInstance(nodeInstance);
2424

2525
// Configure Ports
2626
for (ushort i = 1; i <= 1; i++)
@@ -29,8 +29,8 @@
2929
{
3030
var outputConfig = new PortConfig((byte)i, new PortAddress((ushort)(i - 1)), true, false) { PortNumber = (byte)i, Type = EPortType.OutputFromArtNet, GoodOutput = new GoodOutput(outputStyle: GoodOutput.EOutputStyle.Continuous, isBeingOutputAsDMX: true), };
3131
outputConfig.AddAdditionalRdmUIDs(generateUIDs(i));
32-
controllerInstance.AddPortConfig(outputConfig);
33-
controllerInstance.AddPortConfig(new PortConfig((byte)(i + 4), new PortAddress((ushort)(i - 1)), false, true) { PortNumber = (byte)i, Type = EPortType.InputToArtNet | EPortType.ArtNet });
32+
nodeInstance.AddPortConfig(outputConfig);
33+
nodeInstance.AddPortConfig(new PortConfig((byte)(i + 4), new PortAddress((ushort)(i - 1)), false, true) { PortNumber = (byte)i, Type = EPortType.InputToArtNet | EPortType.ArtNet });
3434
}
3535
catch (Exception ex)
3636
{

0 commit comments

Comments
 (0)