Skip to content

Commit 0422761

Browse files
committed
Minor
1 parent e8ab8f9 commit 0422761

File tree

3 files changed

+88
-22
lines changed

3 files changed

+88
-22
lines changed

RDMSharp/ParameterWrapper/EManufacturer.cs

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,18 @@ public enum EManufacturer : ushort
66
{
77
[Description("DMXControl-Projects e.V.")]
88
DMXControlProjects_eV = 0x02b0,
9+
[Description("Martin Professional A/S")]
10+
Martin_Professional_AS = 0x4D50,
911
[Description("SGM Technology For Lighting SPA")]
10-
SGM_Technology_For_Lighting_SPA = 5347,
12+
SGM_Technology_For_Lighting_SPA = 0x5347,
1113
[Description("Wireless Solution Sweden AB")]
12-
Wireless_Solution_Sweden_AB = 5753,
14+
Wireless_Solution_Sweden_AB = 0x5753,
15+
[Description("Robe Show Lighting s.r.o.")]
16+
Robe_Show_Lighting_sro = 0x5253,
17+
[Description("Swisson AG")]
18+
Swisson_AG = 0x5777,
19+
[Description("GLP German Light Products GmbH")]
20+
GLP_German_Light_Products_GmbH = 0x676C,
1321
[Description("Steinigke Showtechnic GmbH")]
1422
Steinigke_Showtechnic_GmbH = 0x29aa,
1523
}

RDMSharp/RDM/AsyncRDMRequestHelper.cs

Lines changed: 28 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
using System;
1+
using Microsoft.Extensions.Logging;
2+
using System;
23
using System.Collections.Concurrent;
34
using System.Linq;
45
using System.Threading.Tasks;
@@ -7,6 +8,7 @@ namespace RDMSharp
78
{
89
public class AsyncRDMRequestHelper
910
{
11+
private static ILogger Logger = null;
1012
private static Random random = new Random();
1113
ConcurrentDictionary<RDMMessage, RDMMessage> buffer = new ConcurrentDictionary<RDMMessage, RDMMessage>();
1214
Func<RDMMessage, Task> _sendMethode;
@@ -30,27 +32,35 @@ public bool ReceiveMethode(RDMMessage rdmMessage)
3032

3133
public async Task<RequestResult> RequestParameter(RDMMessage requerst)
3234
{
33-
buffer.TryAdd(requerst, null);
34-
RDMMessage resopnse = null;
35-
await _sendMethode.Invoke(requerst);
36-
int count = 0;
37-
do
35+
try
3836
{
39-
buffer.TryGetValue(requerst, out resopnse);
40-
await Task.Delay(10);
41-
count++;
42-
if (count % 300 == 299)
37+
buffer.TryAdd(requerst, null);
38+
RDMMessage resopnse = null;
39+
await _sendMethode.Invoke(requerst);
40+
int count = 0;
41+
do
4342
{
44-
await Task.Delay(TimeSpan.FromTicks(random.Next(33,777)));
45-
await _sendMethode.Invoke(requerst);
46-
await Task.Delay(TimeSpan.FromTicks(random.Next(33, 777)));
43+
buffer.TryGetValue(requerst, out resopnse);
44+
await Task.Delay(10);
45+
count++;
46+
if (count % 300 == 299)
47+
{
48+
await Task.Delay(TimeSpan.FromTicks(random.Next(33, 777)));
49+
await _sendMethode.Invoke(requerst);
50+
await Task.Delay(TimeSpan.FromTicks(random.Next(33, 777)));
51+
}
52+
if (count == 3000)
53+
return new RequestResult(requerst);
4754
}
48-
if (count == 3000)
49-
return new RequestResult(requerst);
55+
while (resopnse == null);
56+
buffer.TryRemove(requerst, out resopnse);
57+
return new RequestResult(requerst, resopnse);
5058
}
51-
while (resopnse == null);
52-
buffer.TryRemove(requerst, out resopnse);
53-
return new RequestResult(requerst, resopnse);
59+
catch( Exception ex)
60+
{
61+
Logger?.LogError(string.Empty, ex);
62+
}
63+
return new RequestResult(requerst);
5464
}
5565
}
5666
}

RDMSharp/RDM/RDMMessage.cs

Lines changed: 50 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
namespace RDMSharp
88
{
9-
public class RDMMessage
9+
public class RDMMessage : IEquatable<RDMMessage>
1010
{
1111
private byte[] _parameterData = new byte[0];
1212

@@ -185,6 +185,54 @@ public override string ToString()
185185
//Add More if required
186186

187187
return b.ToString();
188-
}
188+
}
189+
190+
public override bool Equals(object obj)
191+
{
192+
return Equals(obj as RDMMessage);
193+
}
194+
195+
public bool Equals(RDMMessage other)
196+
{
197+
return other is not null &&
198+
MessageLength == other.MessageLength &&
199+
SourceUID.Equals(other.SourceUID) &&
200+
DestUID.Equals(other.DestUID) &&
201+
TransactionCounter == other.TransactionCounter &&
202+
PortID_or_Responsetype == other.PortID_or_Responsetype &&
203+
MessageCounter == other.MessageCounter &&
204+
SubDevice.Equals(other.SubDevice) &&
205+
Command == other.Command &&
206+
Parameter == other.Parameter &&
207+
EqualityComparer<ERDM_NackReason[]>.Default.Equals(NackReason, other.NackReason) &&
208+
PDL == other.PDL &&
209+
EqualityComparer<byte[]>.Default.Equals(ParameterData, other.ParameterData) &&
210+
Checksum == other.Checksum &&
211+
ResponseType == other.ResponseType &&
212+
IsAck == other.IsAck &&
213+
EqualityComparer<object>.Default.Equals(Value, other.Value);
214+
}
215+
216+
public override int GetHashCode()
217+
{
218+
int hashCode = 1518318531;
219+
hashCode = hashCode * -1521134295 + MessageLength.GetHashCode();
220+
hashCode = hashCode * -1521134295 + SourceUID.GetHashCode();
221+
hashCode = hashCode * -1521134295 + DestUID.GetHashCode();
222+
hashCode = hashCode * -1521134295 + TransactionCounter.GetHashCode();
223+
hashCode = hashCode * -1521134295 + PortID_or_Responsetype.GetHashCode();
224+
hashCode = hashCode * -1521134295 + MessageCounter.GetHashCode();
225+
hashCode = hashCode * -1521134295 + SubDevice.GetHashCode();
226+
hashCode = hashCode * -1521134295 + Command.GetHashCode();
227+
hashCode = hashCode * -1521134295 + Parameter.GetHashCode();
228+
hashCode = hashCode * -1521134295 + EqualityComparer<ERDM_NackReason[]>.Default.GetHashCode(NackReason);
229+
hashCode = hashCode * -1521134295 + PDL.GetHashCode();
230+
hashCode = hashCode * -1521134295 + EqualityComparer<byte[]>.Default.GetHashCode(ParameterData);
231+
hashCode = hashCode * -1521134295 + Checksum.GetHashCode();
232+
hashCode = hashCode * -1521134295 + ResponseType.GetHashCode();
233+
hashCode = hashCode * -1521134295 + IsAck.GetHashCode();
234+
hashCode = hashCode * -1521134295 + EqualityComparer<object>.Default.GetHashCode(Value);
235+
return hashCode;
236+
}
189237
}
190238
}

0 commit comments

Comments
 (0)