/
Program.cs
38 lines (28 loc) · 1.28 KB
/
Program.cs
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
using ArtNetSharp;
using ArtNetSharp.Communication;
using System.Net;
Console.WriteLine("Node Output Exampler!");
//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);
nodeInstance.Name = nodeInstance.ShortName = "Node Output Example";
// Configure Output Ports
for (byte i = 1; i <= 32; i++)
nodeInstance.AddPortConfig(new PortConfig(i, new PortAddress((ushort)(i - 1)), true, false) { PortNumber = (byte)i, Type = EPortType.OutputFromArtNet, GoodOutput = EGoodOutput.ContiniuousOutput | EGoodOutput.DataTransmitted });
// Listen for new Data
nodeInstance.DMXReceived += (sender, e) =>
{
if (!(sender is NodeInstance ni))
return;
// Can be called from anywere anytime without listen to the Event!!!
var data = ni.GetReceivedDMX(e);
Console.WriteLine($"Received date for {e}: {data.Length} bytes");
};
// Add Instance
ArtNet.Instance.AddInstance(nodeInstance);
Console.WriteLine("Press any key to Exit!");
Console.ReadLine();