Skip to content

Commit

Permalink
Move Example to correct Folder
Browse files Browse the repository at this point in the history
  • Loading branch information
patrick-dmxc committed Mar 28, 2024
1 parent 07710ed commit 1285813
Show file tree
Hide file tree
Showing 4 changed files with 139 additions and 139 deletions.
10 changes: 5 additions & 5 deletions ArtNetSharp.sln
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "NodeOutputExample", "Exampl
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "NodeInputExample", "Examples\NodeInputExample\NodeInputExample.csproj", "{9CCE08DE-6ED6-4A19-AB0D-C01413A2E5D3}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ControlerRDMExample", "ControlerRDMExample\ControlerRDMExample.csproj", "{E3B7C3EE-12BE-40F7-B992-28D07FBE1D21}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ControlerRDMExample", "Examples\ControlerRDMExample\ControlerRDMExample.csproj", "{90BF6833-7425-4D6B-A8F9-8487A60F1B78}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Expand Down Expand Up @@ -41,10 +41,10 @@ Global
{9CCE08DE-6ED6-4A19-AB0D-C01413A2E5D3}.Debug|Any CPU.Build.0 = Debug|Any CPU
{9CCE08DE-6ED6-4A19-AB0D-C01413A2E5D3}.Release|Any CPU.ActiveCfg = Release|Any CPU
{9CCE08DE-6ED6-4A19-AB0D-C01413A2E5D3}.Release|Any CPU.Build.0 = Release|Any CPU
{E3B7C3EE-12BE-40F7-B992-28D07FBE1D21}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{E3B7C3EE-12BE-40F7-B992-28D07FBE1D21}.Debug|Any CPU.Build.0 = Debug|Any CPU
{E3B7C3EE-12BE-40F7-B992-28D07FBE1D21}.Release|Any CPU.ActiveCfg = Release|Any CPU
{E3B7C3EE-12BE-40F7-B992-28D07FBE1D21}.Release|Any CPU.Build.0 = Release|Any CPU
{90BF6833-7425-4D6B-A8F9-8487A60F1B78}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{90BF6833-7425-4D6B-A8F9-8487A60F1B78}.Debug|Any CPU.Build.0 = Debug|Any CPU
{90BF6833-7425-4D6B-A8F9-8487A60F1B78}.Release|Any CPU.ActiveCfg = Release|Any CPU
{90BF6833-7425-4D6B-A8F9-8487A60F1B78}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net8.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>

<ItemGroup>
<ProjectReference Include="..\ArtNetSharp\ArtNetSharp.csproj" />
</ItemGroup>

</Project>
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net8.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>

<ItemGroup>
<ProjectReference Include="..\..\ArtNetSharp\ArtNetSharp.csproj" />
</ItemGroup>

</Project>
Original file line number Diff line number Diff line change
@@ -1,54 +1,54 @@
using ArtNetSharp;
using ArtNetSharp.Communication;
using ControlerRDMExample;
using RDMSharp;
using System.Collections.Concurrent;
using System.Collections.Generic;
using System.Net;

Console.WriteLine("Controller 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
ControllerInstance controllerInstance = new ControllerInstance();
controllerInstance.Name = controllerInstance.ShortName = "Controller RDM Example";
ConcurrentDictionary<RDMUID, TestRDMDevice> devices = new();


// Add Instance
ArtNet.Instance.AddInstance(controllerInstance);

// Configure Ports
for (ushort i = 1; i <= 4; i++)
{
try
{
var outputConfig = new PortConfig((byte)i, new PortAddress((ushort)(i - 1)), true, false) { PortNumber = (byte)i, Type = EPortType.OutputFromArtNet, GoodOutput = EGoodOutput.ContiniuousOutput | EGoodOutput.DataTransmitted, };
outputConfig.AddAdditionalRdmUIDs(generateUIDs());
controllerInstance.AddPortConfig(outputConfig);
controllerInstance.AddPortConfig(new PortConfig((byte)(i+4), new PortAddress((ushort)(i - 1)), false, true) { PortNumber = (byte)i, Type = EPortType.InputToArtNet | EPortType.ArtNet });
}
catch (Exception ex)
{

}
}

RDMUID[] generateUIDs()
{
RDMUID[] uids = new RDMUID[30];
for (int i = 0; i < uids.Length; i++)
{
var uid = new RDMUID(0x9fff, (uint)devices.Count + 1);
devices.TryAdd(uid, new TestRDMDevice(uid));
uids[i] = uid;
}
return uids;
}
using ArtNetSharp;
using ArtNetSharp.Communication;
using ControlerRDMExample;
using RDMSharp;
using System.Collections.Concurrent;
using System.Collections.Generic;
using System.Net;

Console.WriteLine("Controller 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
ControllerInstance controllerInstance = new ControllerInstance();
controllerInstance.Name = controllerInstance.ShortName = "Controller RDM Example";
ConcurrentDictionary<RDMUID, TestRDMDevice> devices = new();


// Add Instance
ArtNet.Instance.AddInstance(controllerInstance);

// Configure Ports
for (ushort i = 1; i <= 4; i++)
{
try
{
var outputConfig = new PortConfig((byte)i, new PortAddress((ushort)(i - 1)), true, false) { PortNumber = (byte)i, Type = EPortType.OutputFromArtNet, GoodOutput = EGoodOutput.ContiniuousOutput | EGoodOutput.DataTransmitted, };
outputConfig.AddAdditionalRdmUIDs(generateUIDs());
controllerInstance.AddPortConfig(outputConfig);
controllerInstance.AddPortConfig(new PortConfig((byte)(i+4), new PortAddress((ushort)(i - 1)), false, true) { PortNumber = (byte)i, Type = EPortType.InputToArtNet | EPortType.ArtNet });
}
catch (Exception ex)

Check warning on line 37 in Examples/ControlerRDMExample/Program.cs

View workflow job for this annotation

GitHub Actions / build

The variable 'ex' is declared but never used
{

}
}

RDMUID[] generateUIDs()
{
RDMUID[] uids = new RDMUID[30];
for (int i = 0; i < uids.Length; i++)
{
var uid = new RDMUID(0x9fff, (uint)devices.Count + 1);
devices.TryAdd(uid, new TestRDMDevice(uid));
uids[i] = uid;
}
return uids;
}
Console.ReadLine();
Original file line number Diff line number Diff line change
@@ -1,67 +1,67 @@
using ArtNetSharp;
using ArtNetSharp.Communication;
using RDMSharp;
using RDMSharp.ParameterWrapper;

namespace ControlerRDMExample
{
public abstract class AbstractRDMDeviceGeneratedMock : AbstractGeneratedRDMDevice
{
internal static ControllerInstance Controller = ArtNet.Instance.Instances.OfType<ControllerInstance>().First();
public AbstractRDMDeviceGeneratedMock(RDMUID uid, ERDM_Parameter[] parameters, string manufacturer = null) : base(uid, parameters, manufacturer)
{
Controller.ControllerRDMMessageReceived += Controller_ControllerRDMMessageReceived;
}

protected override async Task SendRDMMessage(RDMMessage rdmMessage)
{
if (this.UID == rdmMessage.DestUID || this.UID == rdmMessage.SourceUID)
{
Console.WriteLine("S:" + rdmMessage);
await Controller.SendArtRDM(rdmMessage);
}
}

private async void Controller_ControllerRDMMessageReceived(object? sender, ArtNetSharp.Misc.ControllerRDMMessageReceivedEventArgs e)
{
if (e.Handled)
return;
if (e.Request.DestUID.IsBroadcast || this.UID == e.Request.DestUID || this.UID == e.Request.SourceUID)
{
RDMMessage response = null;
try
{
response = processRequestMessage(e.Request);
}
catch (Exception ex)
{
}
if (response != null)
e.SetResponse(response);

Console.WriteLine($"Request:{Environment.NewLine}{e.Request}");
if (e.Handled)
Console.WriteLine($"Response:{Environment.NewLine}{e.Response}");
}
}
}
public class TestRDMDevice : AbstractRDMDeviceGeneratedMock
{
public override EManufacturer ManufacturerID => (EManufacturer)0x9fff;
public override ushort DeviceModelID => 20;
public override ERDM_ProductCategoryCoarse ProductCategoryCoarse => ERDM_ProductCategoryCoarse.CONTROL;
public override ERDM_ProductCategoryFine ProductCategoryFine => ERDM_ProductCategoryFine.DATA_CONVERSION;
public override uint SoftwareVersionID => 0x1234;
public override string DeviceModelDescription => "Test Model Description";
public override bool SupportDMXAddress => true;

private static GeneratedPersonality[] PERSONALITYS = [new GeneratedPersonality(1, 5, "5CH RGB"), new GeneratedPersonality(2, 8, "8CH RGBAWY"), new GeneratedPersonality(3, 9, "9CH RGB 16-Bit")];
public override GeneratedPersonality[] Personalities => PERSONALITYS;
public TestRDMDevice(RDMUID uid) : base(uid, [ERDM_Parameter.IDENTIFY_DEVICE, ERDM_Parameter.BOOT_SOFTWARE_VERSION_LABEL], "Dummy Manufacturer 9FFF")
{
this.DeviceLabel = "Dummy Device 1";
this.TrySetParameter(ERDM_Parameter.IDENTIFY_DEVICE, false);
this.TrySetParameter(ERDM_Parameter.BOOT_SOFTWARE_VERSION_LABEL, $"Dummy Software");
}
}
}
using ArtNetSharp;
using ArtNetSharp.Communication;
using RDMSharp;
using RDMSharp.ParameterWrapper;

namespace ControlerRDMExample
{
public abstract class AbstractRDMDeviceGeneratedMock : AbstractGeneratedRDMDevice
{
internal static ControllerInstance Controller = ArtNet.Instance.Instances.OfType<ControllerInstance>().First();
public AbstractRDMDeviceGeneratedMock(RDMUID uid, ERDM_Parameter[] parameters, string manufacturer = null) : base(uid, parameters, manufacturer)

Check warning on line 11 in Examples/ControlerRDMExample/RDMDeviceMock.cs

View workflow job for this annotation

GitHub Actions / build

Cannot convert null literal to non-nullable reference type.
{
Controller.ControllerRDMMessageReceived += Controller_ControllerRDMMessageReceived;
}

protected override async Task SendRDMMessage(RDMMessage rdmMessage)
{
if (this.UID == rdmMessage.DestUID || this.UID == rdmMessage.SourceUID)
{
Console.WriteLine("S:" + rdmMessage);
await Controller.SendArtRDM(rdmMessage);
}
}

private async void Controller_ControllerRDMMessageReceived(object? sender, ArtNetSharp.Misc.ControllerRDMMessageReceivedEventArgs e)

Check warning on line 25 in Examples/ControlerRDMExample/RDMDeviceMock.cs

View workflow job for this annotation

GitHub Actions / build

This async method lacks 'await' operators and will run synchronously. Consider using the 'await' operator to await non-blocking API calls, or 'await Task.Run(...)' to do CPU-bound work on a background thread.
{
if (e.Handled)
return;
if (e.Request.DestUID.IsBroadcast || this.UID == e.Request.DestUID || this.UID == e.Request.SourceUID)
{
RDMMessage response = null;

Check warning on line 31 in Examples/ControlerRDMExample/RDMDeviceMock.cs

View workflow job for this annotation

GitHub Actions / build

Converting null literal or possible null value to non-nullable type.
try
{
response = processRequestMessage(e.Request);
}
catch (Exception ex)

Check warning on line 36 in Examples/ControlerRDMExample/RDMDeviceMock.cs

View workflow job for this annotation

GitHub Actions / build

The variable 'ex' is declared but never used
{
}
if (response != null)
e.SetResponse(response);

Console.WriteLine($"Request:{Environment.NewLine}{e.Request}");
if (e.Handled)
Console.WriteLine($"Response:{Environment.NewLine}{e.Response}");
}
}
}
public class TestRDMDevice : AbstractRDMDeviceGeneratedMock
{
public override EManufacturer ManufacturerID => (EManufacturer)0x9fff;
public override ushort DeviceModelID => 20;
public override ERDM_ProductCategoryCoarse ProductCategoryCoarse => ERDM_ProductCategoryCoarse.CONTROL;
public override ERDM_ProductCategoryFine ProductCategoryFine => ERDM_ProductCategoryFine.DATA_CONVERSION;
public override uint SoftwareVersionID => 0x1234;
public override string DeviceModelDescription => "Test Model Description";
public override bool SupportDMXAddress => true;

private static GeneratedPersonality[] PERSONALITYS = [new GeneratedPersonality(1, 5, "5CH RGB"), new GeneratedPersonality(2, 8, "8CH RGBAWY"), new GeneratedPersonality(3, 9, "9CH RGB 16-Bit")];
public override GeneratedPersonality[] Personalities => PERSONALITYS;
public TestRDMDevice(RDMUID uid) : base(uid, [ERDM_Parameter.IDENTIFY_DEVICE, ERDM_Parameter.BOOT_SOFTWARE_VERSION_LABEL], "Dummy Manufacturer 9FFF")
{
this.DeviceLabel = "Dummy Device 1";
this.TrySetParameter(ERDM_Parameter.IDENTIFY_DEVICE, false);
this.TrySetParameter(ERDM_Parameter.BOOT_SOFTWARE_VERSION_LABEL, $"Dummy Software");
}
}
}

0 comments on commit 1285813

Please sign in to comment.