Skip to content

Commit

Permalink
Bump to v0.0.7
Browse files Browse the repository at this point in the history
  • Loading branch information
patrick-dmxc committed Feb 15, 2024
1 parent c0b6353 commit 3a94f63
Show file tree
Hide file tree
Showing 6 changed files with 42 additions and 26 deletions.
7 changes: 3 additions & 4 deletions RDMSharp/RDM/Device/AbstractRDMDevice.cs
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ private async Task collectAllParameters()
await UpdateSlotDescriptions();
AllDataPulled = true;
}
private async Task processRequestMessage(RDMMessage rdmMessage)
protected async Task<RDMMessage> processRequestMessage(RDMMessage rdmMessage)

Check warning on line 156 in RDMSharp/RDM/Device/AbstractRDMDevice.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.

Check warning on line 156 in RDMSharp/RDM/Device/AbstractRDMDevice.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.
{
//await Task.Delay(200);
var pm = pmManager.GetRDMParameterWrapperByID(rdmMessage.Parameter);
Expand Down Expand Up @@ -380,15 +380,14 @@ when setParameterWrapperRequestContravarianceFloat.SetRequestParameterDataToObje
}
}
if (rdmMessage.DestUID.IsBroadcast) // no Response on Broadcast
return;
return null;
if (response == null)
response = new RDMMessage(ERDM_NackReason.UNKNOWN_PID) { Parameter = rdmMessage.Parameter, Command = rdmMessage.Command | ERDM_Command.RESPONSE };

response.TransactionCounter = rdmMessage.TransactionCounter;
response.SourceUID = rdmMessage.DestUID;
response.DestUID = rdmMessage.SourceUID;
//await Task.Delay(33);
await SendRDMMessage(response);
return response;
}

private async Task processResponseMessage(RequestResult result)
Expand Down
16 changes: 13 additions & 3 deletions RDMSharp/RDM/RDMUID.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

namespace RDMSharp
{
public readonly struct RDMUID : IEquatable<RDMUID>
public readonly struct RDMUID : IEquatable<RDMUID>, IComparer<RDMUID>, IComparable<RDMUID>
{
public static readonly RDMUID Empty = new RDMUID(0, 0);
public static readonly RDMUID Broadcast = new RDMUID(0xFFFF, 0xFFFFFFFF);
Expand Down Expand Up @@ -118,8 +118,18 @@ public override bool Equals(object obj)
public override int GetHashCode()
{
return ManufacturerID.GetHashCode() + 17 * DeviceID.GetHashCode();
}

}


public int CompareTo(RDMUID other)
{
return ((ulong)this).CompareTo((ulong)other);
}
public int Compare(RDMUID x, RDMUID y)
{
return x.CompareTo(y);
}

public bool IsBroadcast
{
get
Expand Down
2 changes: 1 addition & 1 deletion RDMSharp/RDMSharp.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<PropertyGroup>
<TargetFrameworks>netstandard2.0;net6.0;net7.0;net8.0</TargetFrameworks>
<PackageLicenseFile>LICENSE</PackageLicenseFile>
<Version>0.0.6</Version>
<Version>0.0.7</Version>
<RepositoryUrl>https://github.com/DMXControl/RDMSharp</RepositoryUrl>
<PackageProjectUrl>$(RepositoryUrl)</PackageProjectUrl>
<PackageTags>RDM; RDMnet; ArtNet; E1.20; E1.33; E1.37-1; E1.37-2; E1.37-7</PackageTags>
Expand Down
6 changes: 0 additions & 6 deletions RDMSharpTests/Devices/Mock/AbstractMockDevice.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,6 @@

namespace RDMSharpTests.Devices.Mock
{
internal sealed class MockDevice1 : AbstractMockDevice
{
public MockDevice1(RDMUID uid) : base(uid)
{
}
}
internal abstract class AbstractMockDevice : AbstractRDMDevice
{
private ConcurrentDictionary<long, RDMMessage> identifyer = new ConcurrentDictionary<long, RDMMessage>();
Expand Down
9 changes: 9 additions & 0 deletions RDMSharpTests/Devices/Mock/MockDevice.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
namespace RDMSharpTests.Devices.Mock
{
internal sealed class MockDevice : AbstractMockDevice
{
public MockDevice(RDMUID uid) : base(uid)
{
}
}
}
28 changes: 16 additions & 12 deletions RDMSharpTests/Devices/TestRDMSendReceive.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ public async Task TestDevice1()
sw.Start();
var uid = new RDMUID(0x9fff, 1);
var generated = new MockGeneratedDevice1(uid);
var remote = new MockDevice1(uid);
var remote = new MockDevice(uid);
while (remote.DeviceModel?.IsInitialized != true || !remote.AllDataPulled)
{
await Task.Delay(10);
Expand All @@ -30,20 +30,24 @@ public async Task TestDevice1()
Assert.Fail("Timeouted because AllDataPulled not true");
}
}
testAllValues();

var parameterValuesRemote = remote.GetAllParameterValues();
var parameterValuesGenerated = generated.GetAllParameterValues();
foreach (var parameter in parameterValuesGenerated.Keys)
void testAllValues()
{
Assert.That(parameterValuesRemote.Keys, Contains.Item(parameter));
Assert.That(parameterValuesGenerated[parameter], Is.EqualTo(parameterValuesRemote[parameter]));
}
foreach (var parameter in parameterValuesRemote.Keys)
{
Assert.That(parameterValuesGenerated.Keys, Contains.Item(parameter));
Assert.That(parameterValuesRemote[parameter], Is.EqualTo(parameterValuesGenerated[parameter]));
var parameterValuesRemote = remote.GetAllParameterValues();
var parameterValuesGenerated = generated.GetAllParameterValues();
foreach (var parameter in parameterValuesGenerated.Keys)
{
Assert.That(parameterValuesRemote.Keys, Contains.Item(parameter));
Assert.That(parameterValuesGenerated[parameter], Is.EqualTo(parameterValuesRemote[parameter]));
}
foreach (var parameter in parameterValuesRemote.Keys)
{
Assert.That(parameterValuesGenerated.Keys, Contains.Item(parameter));
Assert.That(parameterValuesRemote[parameter], Is.EqualTo(parameterValuesGenerated[parameter]));
}
Assert.That(parameterValuesRemote.Count, Is.EqualTo(parameterValuesGenerated.Count));
}
Assert.That(parameterValuesRemote.Count, Is.EqualTo(parameterValuesGenerated.Count));
}
}
}

0 comments on commit 3a94f63

Please sign in to comment.