Skip to content

Commit be10b92

Browse files
committed
Move over to WellKnownDataTyes Lib
Bump to v0.0.9
1 parent 3a57f5e commit be10b92

39 files changed

+727
-723
lines changed

RDMSharp/RDM/Device/AbstractGeneratedRDMDevice.cs

+2-2
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ public byte? CurrentPersonality
115115
}
116116
}
117117

118-
protected AbstractGeneratedRDMDevice(RDMUID uid, ERDM_Parameter[] parameters, string manufacturer = null) : base(uid)
118+
protected AbstractGeneratedRDMDevice(UID uid, ERDM_Parameter[] parameters, string manufacturer = null) : base(uid)
119119
{
120120
if (!((ushort)ManufacturerID).Equals(uid.ManufacturerID))
121121
throw new Exception($"{uid.ManufacturerID} not match the {ManufacturerID}");
@@ -148,7 +148,7 @@ protected AbstractGeneratedRDMDevice(RDMUID uid, ERDM_Parameter[] parameters, st
148148
#endregion
149149

150150
#region ManufacturerLabel
151-
string _manufacturer = Enum.GetName(typeof(EManufacturer), uid.Manufacturer);
151+
string _manufacturer = Enum.GetName(typeof(EManufacturer), (EManufacturer)uid.ManufacturerID);
152152

153153
if (string.IsNullOrWhiteSpace(_manufacturer))
154154
_manufacturer = manufacturer;

RDMSharp/RDM/Device/AbstractRDMDevice.cs

+4-4
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ public abstract class AbstractRDMDevice : IRDMDevice
2525

2626
public event PropertyChangedEventHandler PropertyChanged;
2727

28-
public RDMUID UID { get; private set; }
28+
public UID UID { get; private set; }
2929
public DateTime LastSeen { get; private set; }
3030
public bool Present { get; internal set; }
3131
public bool DiscoveryMuted { get; private set; }
@@ -53,7 +53,7 @@ public abstract class AbstractRDMDevice : IRDMDevice
5353
public virtual bool IsGenerated { get; private protected set; }
5454
public bool AllDataPulled { get; private set; }
5555

56-
public AbstractRDMDevice(RDMUID uid)
56+
public AbstractRDMDevice(UID uid)
5757
{
5858
asyncRDMRequestHelper = new AsyncRDMRequestHelper(sendRDMRequestMessage);
5959
UID = uid;
@@ -219,7 +219,7 @@ protected RDMMessage processRequestMessage(RDMMessage rdmMessage)
219219
DestUID = rdmMessage.SourceUID,
220220
ParameterData = new DiscMuteUnmuteResponse().ToPayloadData()
221221
};
222-
return rdmMessage.DestUID != RDMUID.Broadcast ? response : null;
222+
return rdmMessage.DestUID != UID.Broadcast ? response : null;
223223
case ERDM_Parameter.DISC_UN_MUTE:
224224
DiscoveryMuted = false;
225225
response = new RDMMessage
@@ -230,7 +230,7 @@ protected RDMMessage processRequestMessage(RDMMessage rdmMessage)
230230
DestUID = rdmMessage.SourceUID,
231231
ParameterData = new DiscMuteUnmuteResponse().ToPayloadData()
232232
};
233-
return rdmMessage.DestUID != RDMUID.Broadcast ? response : null;
233+
return rdmMessage.DestUID != UID.Broadcast ? response : null;
234234
case ERDM_Parameter.DISC_UNIQUE_BRANCH when !DiscoveryMuted && rdmMessage.Value is DiscUniqueBranchRequest discUniqueBranchRequest:
235235
if (UID >= discUniqueBranchRequest.StartUid && UID <= discUniqueBranchRequest.EndUid)
236236
{

RDMSharp/RDM/Device/RDMDeviceModel.cs

+4-4
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ public sealed class RDMDeviceModel : IRDMDeviceModel
1313
{
1414
private static ConcurrentDictionary<int, RDMDeviceModel> knownDeviceModels;
1515
public static IReadOnlyCollection<RDMDeviceModel> KnownDeviceModels => knownDeviceModels.Values.ToList();
16-
internal static RDMDeviceModel getDeviceModel(RDMUID uid, RDMDeviceInfo deviceInfo, Func<RDMMessage, Task> sendRdmFunktion)
16+
internal static RDMDeviceModel getDeviceModel(UID uid, RDMDeviceInfo deviceInfo, Func<RDMMessage, Task> sendRdmFunktion)
1717
{
1818
knownDeviceModels ??= new ConcurrentDictionary<int, RDMDeviceModel>();
1919
var kdm = knownDeviceModels.Values.FirstOrDefault(dm => dm.IsModelOf(uid, deviceInfo));
@@ -35,7 +35,7 @@ internal static RDMDeviceModel getDeviceModel(RDMUID uid, RDMDeviceInfo deviceIn
3535

3636
public ushort ManufacturerID { get; private set; }
3737
public EManufacturer Manufacturer { get; private set; }
38-
public RDMUID CurrentUsedUID { get; private set; }
38+
public UID CurrentUsedUID { get; private set; }
3939

4040
public event EventHandler Initialized;
4141
public bool IsInitialized { get; private set; } = false;
@@ -92,7 +92,7 @@ public IReadOnlyCollection<ERDM_Parameter> KnownNotSupportedParameters
9292
public event PropertyChangedEventHandler PropertyChanged;
9393
private readonly Func<RDMMessage, Task> sendRdmFunktion;
9494

95-
internal RDMDeviceModel(RDMUID uid, RDMDeviceInfo deviceInfo, Func<RDMMessage, Task> sendRdmFunktion)
95+
internal RDMDeviceModel(UID uid, RDMDeviceInfo deviceInfo, Func<RDMMessage, Task> sendRdmFunktion)
9696
{
9797
this.sendRdmFunktion = sendRdmFunktion;
9898
DeviceInfo = deviceInfo;
@@ -346,7 +346,7 @@ private async Task processMessage(RDMMessage rdmMessage)
346346
}
347347
}
348348

349-
public bool IsModelOf(RDMUID uid, RDMDeviceInfo other)
349+
public bool IsModelOf(UID uid, RDMDeviceInfo other)
350350
{
351351
var deviceInfo = this.DeviceInfo;
352352
if (this.ManufacturerID != uid.ManufacturerID)

RDMSharp/RDM/Discovery/AbstractDiscoveryTool.cs

+9-9
Original file line numberDiff line numberDiff line change
@@ -37,9 +37,9 @@ protected void ReceiveRDMMessage(RDMMessage rdmMessage)
3737
asyncRDMRequestHelper.ReceiveMethode(rdmMessage);
3838
}
3939

40-
public async Task<IReadOnlyCollection<RDMUID>> PerformDiscovery(IProgress<RDMDiscoveryStatus> progress = null, bool full = true)
40+
public async Task<IReadOnlyCollection<UID>> PerformDiscovery(IProgress<RDMDiscoveryStatus> progress = null, bool full = true)
4141
{
42-
if (DiscoveryInProgress) return new List<RDMUID>();
42+
if (DiscoveryInProgress) return new List<UID>();
4343
DiscoveryInProgress = true;
4444

4545
//Send DISC_UN_MUTE
@@ -52,7 +52,7 @@ public async Task<IReadOnlyCollection<RDMUID>> PerformDiscovery(IProgress<RDMDis
5252
{
5353
Command = ERDM_Command.DISCOVERY_COMMAND,
5454
Parameter = ERDM_Parameter.DISC_UN_MUTE,
55-
DestUID = RDMUID.Broadcast,
55+
DestUID = UID.Broadcast,
5656
};
5757
unmuted = await SendRDMMessage(m);
5858
}
@@ -64,14 +64,14 @@ public async Task<IReadOnlyCollection<RDMUID>> PerformDiscovery(IProgress<RDMDis
6464
}
6565
//Start Binary Search for each
6666
var erg = new RDMDiscoveryContext(progress);
67-
await DiscoverDevicesBinarySearch(RDMUID.Empty, RDMUID.Broadcast - 1, erg);
67+
await DiscoverDevicesBinarySearch(UID.Empty, UID.Broadcast - 1, erg);
6868

6969
DiscoveryInProgress = false;
7070
return erg.FoundUIDs.ToList();
7171
}
7272

7373

74-
private async Task DiscoverDevicesBinarySearch(RDMUID uidStart, RDMUID uidEnd, RDMDiscoveryContext context)
74+
private async Task DiscoverDevicesBinarySearch(UID uidStart, UID uidEnd, RDMDiscoveryContext context)
7575
{
7676
//Robust Code Check
7777
if (uidStart > uidEnd) return;
@@ -94,7 +94,7 @@ private async Task DiscoverDevicesBinarySearch(RDMUID uidStart, RDMUID uidEnd, R
9494
{
9595
Command = ERDM_Command.DISCOVERY_COMMAND,
9696
Parameter = ERDM_Parameter.DISC_UNIQUE_BRANCH,
97-
DestUID = RDMUID.Broadcast,
97+
DestUID = UID.Broadcast,
9898
SubDevice = SubDevice.Root,
9999
ParameterData = new DiscUniqueBranchRequest(uidStart, uidEnd).ToPayloadData()
100100
};
@@ -130,7 +130,7 @@ private async Task DiscoverDevicesBinarySearch(RDMUID uidStart, RDMUID uidEnd, R
130130
else if (muted == null) //An already muted Device answered again! We try to fix by carving out the UID
131131
{
132132
//Split Range at number of Device
133-
RDMUID shittyDevice = response.SourceUID;
133+
UID shittyDevice = response.SourceUID;
134134
if (shittyDevice == uidStart) await DiscoverDevicesBinarySearch(uidStart + 1, uidEnd, context);
135135
else if (shittyDevice == uidEnd) await DiscoverDevicesBinarySearch(uidStart, uidEnd - 1, context);
136136
else if (shittyDevice > uidStart && shittyDevice < uidEnd)
@@ -165,7 +165,7 @@ private async Task DiscoverDevicesBinarySearch(RDMUID uidStart, RDMUID uidEnd, R
165165
var offByOneContext = new RDMDiscoveryContext();
166166

167167
//AL 2020-12-08: Not sure whether usefull
168-
//msg = String.Format("Doing OffByOne Check for Range {0} - {1}", RDMUID.FromULong(uidStart), RDMUID.FromULong(uidEnd));
168+
//msg = String.Format("Doing OffByOne Check for Range {0} - {1}", UID.FromULong(uidStart), UID.FromULong(uidEnd));
169169
//context.Status = msg;
170170

171171
await DiscoverDevicesBinarySearch(uidStart, uidStart + mid3, offByOneContext);
@@ -183,7 +183,7 @@ private async Task DiscoverDevicesBinarySearch(RDMUID uidStart, RDMUID uidEnd, R
183183
}
184184
}
185185

186-
private async Task<bool?> TryMuteSingleDeviceAndAdd(RDMUID uid, RDMDiscoveryContext context)
186+
private async Task<bool?> TryMuteSingleDeviceAndAdd(UID uid, RDMDiscoveryContext context)
187187
{
188188
if (context.AlreadyFound(uid))
189189
{

RDMSharp/RDM/Discovery/RDMDiscoveryContext.cs

+18-18
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,13 @@ namespace RDMSharp
77
{
88
internal class RDMDiscoveryContext
99
{
10-
private readonly HashSet<RDMUID> _foundUids = new HashSet<RDMUID>();
11-
private readonly HashSet<RDMUID> _falseOnUids = new HashSet<RDMUID>();
10+
private readonly HashSet<UID> _foundUids = new HashSet<UID>();
11+
private readonly HashSet<UID> _falseOnUids = new HashSet<UID>();
1212
private readonly ConcurrentDictionary<ulong, RemovedUIDRange> removedRange = new ConcurrentDictionary<ulong, RemovedUIDRange>();
13-
private ulong rangeToSearch = (ulong)(RDMUID.Broadcast - 1);
13+
private ulong rangeToSearch = (ulong)(UID.Broadcast - 1);
1414
private string _statusString;
1515
private RDMDiscoveryStatus _status = new RDMDiscoveryStatus();
16-
private RDMUID? lastFoundUid;
16+
private UID? lastFoundUid;
1717
private ulong messageCount;
1818

1919

@@ -24,35 +24,35 @@ public RDMDiscoveryContext(IProgress<RDMDiscoveryStatus> progress = null)
2424
this._progress = progress;
2525
}
2626

27-
internal bool AlreadyFound(RDMUID uid) => _foundUids.Contains(uid);
27+
internal bool AlreadyFound(UID uid) => _foundUids.Contains(uid);
2828

29-
internal void AddFound(RDMUID uid)
29+
internal void AddFound(UID uid)
3030
{
3131
_foundUids.Add(uid);
3232
lastFoundUid = uid;
3333
UpdateReport();
3434
}
3535

36-
internal void AddFound(IEnumerable<RDMUID> uid)
36+
internal void AddFound(IEnumerable<UID> uid)
3737
{
3838
_foundUids.UnionWith(uid);
3939
lastFoundUid = uid.LastOrDefault();
4040
UpdateReport();
4141
}
42-
internal void AddFalseOn(RDMUID uid)
42+
internal void AddFalseOn(UID uid)
4343
{
4444
_falseOnUids.Add(uid);
4545
}
46-
internal bool IsFalseOn(RDMUID uid)
46+
internal bool IsFalseOn(UID uid)
4747
{
4848
return _falseOnUids.Contains(uid);
4949
}
5050

5151
internal int FoundCount => _foundUids.Count;
5252

53-
internal IReadOnlyCollection<RDMUID> FoundUIDs => _foundUids.ToList();
53+
internal IReadOnlyCollection<UID> FoundUIDs => _foundUids.ToList();
5454

55-
internal void RemoveRange(RDMUID uidStart, RDMUID uidEnd)
55+
internal void RemoveRange(UID uidStart, UID uidEnd)
5656
{
5757
var newRemovedRange = new RemovedUIDRange(uidStart, uidEnd);
5858
var overlap = removedRange.FirstOrDefault(r => areRangesOverlapping(r.Value.StartUID, r.Value.EndUID, newRemovedRange.StartUID, newRemovedRange.EndUID));
@@ -90,10 +90,10 @@ internal void RemoveRange(RDMUID uidStart, RDMUID uidEnd)
9090
foreach (var r in removedRange)
9191
sumDelta += (ulong)r.Value.Delta;
9292

93-
rangeToSearch = (ulong)(RDMUID.Broadcast - 1) - sumDelta;
93+
rangeToSearch = (ulong)(UID.Broadcast - 1) - sumDelta;
9494
UpdateReport();
9595

96-
static bool areRangesOverlapping(RDMUID start1, RDMUID end1, RDMUID start2, RDMUID end2)
96+
static bool areRangesOverlapping(UID start1, UID end1, UID start2, UID end2)
9797
{
9898
if (start1 <= end2 && end1 >= start2)// Check for overlap
9999
return true;
@@ -144,19 +144,19 @@ private RDMDiscoveryStatus GetStatus()
144144
}
145145
internal class RemovedUIDRange
146146
{
147-
public readonly RDMUID StartUID;
148-
public readonly RDMUID EndUID;
149-
public readonly RDMUID Delta;
147+
public readonly UID StartUID;
148+
public readonly UID EndUID;
149+
public readonly UID Delta;
150150

151-
public RemovedUIDRange(in RDMUID startUID, in RDMUID endUID)
151+
public RemovedUIDRange(in UID startUID, in UID endUID)
152152
{
153153
StartUID = startUID;
154154
EndUID = endUID;
155155
Delta = EndUID - StartUID;
156156
}
157157
public static RemovedUIDRange Merge(RemovedUIDRange one, RemovedUIDRange other)
158158
{
159-
return new RemovedUIDRange(new RDMUID(Math.Min((ulong)one.StartUID, (ulong)other.StartUID)), new RDMUID(Math.Max((ulong)one.EndUID, (ulong)other.EndUID)));
159+
return new RemovedUIDRange(new UID(Math.Min((ulong)one.StartUID, (ulong)other.StartUID)), new UID(Math.Max((ulong)one.EndUID, (ulong)other.EndUID)));
160160
}
161161
public override string ToString()
162162
{

RDMSharp/RDM/Discovery/RDMDiscoveryStatus.cs

+4-4
Original file line numberDiff line numberDiff line change
@@ -9,14 +9,14 @@ namespace RDMSharp
99
public readonly ulong RangeLeftToSearch;
1010
public readonly double RangeDoneInPercent = 0;
1111
public readonly string CurrentStatus;
12-
public readonly RDMUID? LastFoundUid;
12+
public readonly UID? LastFoundUid;
1313
public readonly ulong MessageCount;
1414

15-
public RDMDiscoveryStatus(in int found, in ulong left2search, in string status, RDMUID? lastFoundUid, ulong messageCount)
15+
public RDMDiscoveryStatus(in int found, in ulong left2search, in string status, UID? lastFoundUid, ulong messageCount)
1616
{
1717
this.FoundDevices = found;
1818
this.RangeLeftToSearch = left2search;
19-
var rangeLeftToSearchInPercent = left2search / (double)(ulong)(RDMUID.Broadcast - 1);
19+
var rangeLeftToSearchInPercent = left2search / (double)(ulong)(UID.Broadcast - 1);
2020
this.RangeDoneInPercent = 1 - rangeLeftToSearchInPercent;
2121
this.CurrentStatus = status;
2222
this.LastFoundUid = lastFoundUid;
@@ -33,7 +33,7 @@ public bool Equals(RDMDiscoveryStatus other)
3333
return FoundDevices == other.FoundDevices &&
3434
RangeLeftToSearch == other.RangeLeftToSearch &&
3535
CurrentStatus == other.CurrentStatus &&
36-
EqualityComparer<RDMUID?>.Default.Equals(LastFoundUid, other.LastFoundUid) &&
36+
EqualityComparer<UID?>.Default.Equals(LastFoundUid, other.LastFoundUid) &&
3737
MessageCount == other.MessageCount;
3838
}
3939

0 commit comments

Comments
 (0)