-
-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathProgram.cs
More file actions
52 lines (44 loc) · 1.73 KB
/
Copy pathProgram.cs
File metadata and controls
52 lines (44 loc) · 1.73 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
using ArtNetSharp;
using ArtNetSharp.Communication;
using ControlerRDMExample;
using org.dmxc.wkdt.Light.RDM;
using System.Collections.Concurrent;
Console.WriteLine("Node RDM Example!");
//Add Logging
//ArtNet.SetLoggerFectory(YOUR_LOGGER_FACTORY);
//Set Networkinterfaces
//var broadcastIp = new IPAddress(new byte[] { 2, 255, 255, 255 });
//ArtNet.Instance.NetworkClients.ToList().ForEach(ncb => ncb.Enabled = IPAddress.Equals(broadcastIp, ncb.BroadcastIpAddress));
// Create Instance
NodeInstance nodeInstance = new NodeInstance(ArtNet.Instance, true);
nodeInstance.Name = nodeInstance.ShortName = "Node RDM Example";
ConcurrentDictionary<UID, TestRDMDevice> devices = new();
// Add Instance
ArtNet.Instance.AddInstance(nodeInstance);
// Configure Ports
for (ushort i = 1; i <= 1; i++)
{
try
{
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), };
outputConfig.AddAdditionalRdmUIDs(generateUIDs(i));
nodeInstance.AddPortConfig(outputConfig);
nodeInstance.AddPortConfig(new PortConfig((byte)(i + 4), new PortAddress((ushort)(i - 1)), false, true) { PortNumber = (byte)i, Type = EPortType.InputToArtNet | EPortType.ArtNet });
}
catch (Exception ex)
{
Console.WriteLine(ex.ToString());
}
}
UID[] generateUIDs(ushort port)
{
UID[] uids = new UID[5];
for (int i = 0; i < uids.Length; i++)
{
var uid = new UID(0x9fff, (uint)(devices.Count + 1 + (1000 * port)));
devices.TryAdd(uid, new TestRDMDevice(uid));
uids[i] = uid;
}
return uids;
}
Console.ReadLine();