Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
147 commits
Select commit Hold shift + click to select a range
edfb3ec
WIP
patrick-dmxc Jul 8, 2025
50dbd17
WIP
patrick-dmxc Jul 8, 2025
f3e2da3
WIP
patrick-dmxc Jul 8, 2025
5aa551b
WIP
patrick-dmxc Jul 8, 2025
58f3050
WIP
patrick-dmxc Jul 8, 2025
a9bbf6a
WIP
patrick-dmxc Jul 8, 2025
4459ab0
WIP
patrick-dmxc Jul 8, 2025
05c7813
Refactor Slots implementation to Modules
patrick-dmxc Jul 15, 2025
464eb2e
CleanUp
patrick-dmxc Jul 15, 2025
a37b4b7
Refactor Sensor-Implementation to Modules
patrick-dmxc Jul 15, 2025
4f2ac22
CleanUp
patrick-dmxc Jul 15, 2025
16571bc
CleanUp
patrick-dmxc Jul 15, 2025
96befa2
Refactor StatusMessage-Implementation to Modules
patrick-dmxc Jul 15, 2025
2fe1565
CleanUp
patrick-dmxc Jul 15, 2025
14547e9
WIP
patrick-dmxc Jul 15, 2025
d6d2465
Implement TagsModule
patrick-dmxc Jul 22, 2025
2a4446b
Seperate Testes for Modules
patrick-dmxc Jul 29, 2025
242109f
WIP InterfaceModule Stuff
patrick-dmxc Jul 29, 2025
cd0feb3
Minor fixes
patrick-dmxc Sep 25, 2025
d94b13e
Minor
patrick-dmxc Oct 26, 2025
ebb69bf
Minor
patrick-dmxc Oct 26, 2025
12d78fd
Update Nuget-Packages
patrick-dmxc Oct 27, 2025
80ad371
Fix Type
patrick-dmxc Nov 18, 2025
594659e
Update to .NET 10
patrick-dmxc Nov 18, 2025
7a6a06c
Update Tests to .NET10
patrick-dmxc Dec 2, 2025
dda3039
Start implement Communication History and some Refactoring
patrick-dmxc Dec 3, 2025
f8fb40c
Add Controller Flags Enum
patrick-dmxc Dec 3, 2025
58633ca
Minor improvements
patrick-dmxc Dec 3, 2025
d4baea1
Add ProxiedDevicesModule
patrick-dmxc Dec 3, 2025
a592ea5
Update Nuget-Packages
patrick-dmxc Dec 16, 2025
a8f1586
Fix NPE
patrick-dmxc Dec 16, 2025
a9ff3c0
Fix some Typos
patrick-dmxc Dec 16, 2025
451050c
Some Optimizations and revert JSON-Lib update, cassues Issues with JS…
patrick-dmxc Dec 16, 2025
9a5dd4d
Some minor additions
patrick-dmxc Dec 16, 2025
7d2965f
Optimice Paramter Update Intervalls
patrick-dmxc Dec 30, 2025
c6faf87
Minor
patrick-dmxc Dec 30, 2025
ef3db83
More logging, and some optimization
patrick-dmxc Jan 14, 2026
7d9a60a
Refactor BytesType Parser
patrick-dmxc Jan 22, 2026
f30b264
Add missing E1.20 - 2025 Defines
patrick-dmxc Jan 29, 2026
cc810ec
WIP
patrick-dmxc Feb 2, 2026
22a80fb
WIP
patrick-dmxc Feb 3, 2026
aef6103
WIP
patrick-dmxc Feb 4, 2026
ac19234
WIP
patrick-dmxc Feb 5, 2026
1960977
WIP
patrick-dmxc Feb 5, 2026
742439c
Minor oprimication
patrick-dmxc Feb 5, 2026
d57e38d
Some refactoring
patrick-dmxc Feb 9, 2026
b3f63fb
More Tests
patrick-dmxc Feb 9, 2026
2d3cd5b
More Tests
patrick-dmxc Feb 10, 2026
e358501
Try fix linux Test fails
patrick-dmxc Feb 10, 2026
865bcb8
Grr
patrick-dmxc Feb 10, 2026
f95ea93
Grrr
patrick-dmxc Feb 10, 2026
6375eb4
Grrr
patrick-dmxc Feb 10, 2026
0585eaf
Grrrg
patrick-dmxc Feb 10, 2026
0955ff0
Revert all
patrick-dmxc Feb 10, 2026
e390f40
Som refactoring, cleanup and more tests
patrick-dmxc Feb 10, 2026
2d8e126
More Tests
patrick-dmxc Feb 11, 2026
8707e35
More Tests!!!
patrick-dmxc Feb 11, 2026
022bc5c
WIP Modules-Tests and refactoring
patrick-dmxc Feb 18, 2026
1c53c5f
Minor fixes
patrick-dmxc Mar 2, 2026
b6b5ffb
Implement fast update of Proxied Devices
patrick-dmxc Mar 2, 2026
9351187
Fix DataTreeObjectAttribute Manufacturer was not used
patrick-dmxc Mar 4, 2026
039f840
MInor
patrick-dmxc Mar 5, 2026
a937ec4
Minor
patrick-dmxc Mar 5, 2026
54312ea
WIP
patrick-dmxc Mar 10, 2026
ea97628
Some FIxes
patrick-dmxc Mar 15, 2026
4ec41b8
Add Resiliance in RDMMessage for Wrong-PortID_ResponseType
patrick-dmxc Mar 18, 2026
8dbe973
Fix NPE
patrick-dmxc Mar 19, 2026
7f9640a
Add functionality for RealTimeClockModule
patrick-dmxc Mar 19, 2026
88b58be
Minor treaks
patrick-dmxc Mar 23, 2026
db79263
Some Refactoring
patrick-dmxc Mar 26, 2026
da24851
Minor
patrick-dmxc Mar 26, 2026
58d1b9d
Improved handling of *_DESCRIPTION parameters
patrick-dmxc Apr 10, 2026
bb9b1ef
Add CurveModule and improve NACK/command handling
patrick-dmxc Apr 12, 2026
51e7565
Add RDM modules, add OutputResponseTime & Modulation
patrick-dmxc Apr 12, 2026
b7aa969
Add ETC Inc. to EManufacturer enum
patrick-dmxc Apr 14, 2026
beda6eb
Fix Typo
patrick-dmxc Apr 14, 2026
fc696d5
Add EndpointModule
patrick-dmxc Apr 18, 2026
235f603
Grrr
patrick-dmxc Apr 18, 2026
af09089
Minor
patrick-dmxc Apr 18, 2026
71987a6
Add FactoryDefaultsModule and refactor Interface handling
patrick-dmxc May 12, 2026
ac234ac
Work on EndpointModule
patrick-dmxc May 15, 2026
aefde53
Minor
patrick-dmxc May 15, 2026
514ef84
Work on EndpointModule Timings
patrick-dmxc May 15, 2026
337fe90
WIP
patrick-dmxc May 15, 2026
f9b1e05
Add PowerState Module Fix Tests
patrick-dmxc May 16, 2026
4d1223a
Implement LockModule
patrick-dmxc May 16, 2026
85356c8
Minor
patrick-dmxc May 16, 2026
5aa820f
Some Fixes
patrick-dmxc May 16, 2026
f77a7a7
Minor
patrick-dmxc Jul 17, 2026
5fc8d02
Add ARRI ManufacturerID
patrick-dmxc Aug 31, 2026
80a2fb3
Update JSONShema.Net and fix error-Handling
patrick-dmxc Aug 31, 2026
9fa2e09
Update Nuget-PAckages
patrick-dmxc Aug 31, 2026
51d9bc7
Minor
patrick-dmxc Sep 7, 2026
ecf0cb0
Add Additional MACAddressByteParser for String Format
patrick-dmxc Oct 22, 2026
4be73f5
Merge main into feature/modulizedGeneratedDevicesParameters
patrick-dmxc Nov 10, 2026
6437b41
Fix Merge
patrick-dmxc Nov 10, 2026
1a57507
Merge main ->
patrick-dmxc Nov 11, 2026
e719a74
Fix ProxiedDevices get DeviceUIDs
patrick-dmxc Nov 11, 2026
ba36ff8
WIP
patrick-dmxc Nov 12, 2026
0838170
WIP
patrick-dmxc Nov 13, 2026
44b7d78
WIP
patrick-dmxc Nov 13, 2026
5fefd9f
Cleanup
patrick-dmxc Nov 13, 2026
f395d81
Cleanup
patrick-dmxc Nov 13, 2026
a0af91e
Cleanup
patrick-dmxc Nov 15, 2026
7564fa1
WIP
patrick-dmxc Nov 15, 2026
e74b6d5
Fix Typo
patrick-dmxc Nov 19, 2026
903c265
WIP
patrick-dmxc Nov 20, 2026
2c50ef8
WIP
patrick-dmxc Nov 20, 2026
7b62b07
More Tests für PresetModules
patrick-dmxc Nov 20, 2026
eede73c
Add Missing Parameter Defines
patrick-dmxc Nov 20, 2026
9d0d9dd
Optimice Test
patrick-dmxc Nov 20, 2026
4dd5b17
Try Fix tests
patrick-dmxc Nov 20, 2026
ce1cec8
Increase Perfomance in Tests
patrick-dmxc Nov 20, 2026
c81375d
FAAAASSSSTERRRRR!
patrick-dmxc Nov 20, 2026
34368ae
More Modules
patrick-dmxc Nov 20, 2026
e51fbd9
More Modules and Fixes
patrick-dmxc Nov 20, 2026
c6cc3d0
More Modules
patrick-dmxc Nov 20, 2026
f37414f
More Coverage
patrick-dmxc Nov 20, 2026
6893635
Add More Tests
patrick-dmxc Nov 20, 2026
3b89d77
More Tests
patrick-dmxc Nov 21, 2026
4fe4536
More Tests for more edge cases
patrick-dmxc Nov 21, 2026
7b0806e
Some Fixes
patrick-dmxc Nov 21, 2026
9720c4c
More Tests
patrick-dmxc Nov 21, 2026
a9a26f8
Add METADATA_JSON module and fix first-access races in MetadataFactory
patrick-dmxc Nov 21, 2026
ffaea9b
More Coverage
patrick-dmxc Nov 21, 2026
6234400
More Coverage
patrick-dmxc Nov 21, 2026
2a042a1
More Coverage
patrick-dmxc Nov 21, 2026
1cf55b3
Bump v0.0.18
patrick-dmxc Nov 22, 2026
3533ac1
Classify requests without an answer, keep the model complete, fix the…
patrick-dmxc Nov 22, 2026
bbe9910
More Tests
patrick-dmxc Nov 22, 2026
9d1360b
Handle PIDs without a define, make ExtensionsManager thread safe on f…
patrick-dmxc Nov 22, 2026
811a88f
Fix Log Message
patrick-dmxc Nov 22, 2026
bb00dc2
Implement and fix edge cases
patrick-dmxc Nov 22, 2026
e62d1b0
Raise value events only for real changes, hand cached values to new m…
patrick-dmxc Nov 22, 2026
a77806f
Catch exceptions of async void handlers, clean up a generated device …
patrick-dmxc Nov 22, 2026
cb6b751
Keep the ESTA update times for ESTA parameters, repair an empty ENDPO…
patrick-dmxc Nov 22, 2026
eedea94
Add generic modules built from the define for simple parameters witho…
patrick-dmxc Nov 23, 2026
3d71018
Add the missing modules once all data is pulled, replace generic modu…
patrick-dmxc Nov 23, 2026
ab651b2
WIP
patrick-dmxc Nov 23, 2026
73765bb
feat(manufacturer): add LSC entry
patrick-dmxc Nov 23, 2026
ab2f5fb
feat(rdm): add manufacturer IDs
patrick-dmxc Nov 23, 2026
81fbc7e
feat(rdm): add manufacturer identifiers
patrick-dmxc Nov 23, 2026
ab5ed34
fix(rdm): detect silently ignored parameters
patrick-dmxc Nov 24, 2026
c69c058
Add Unit to DataTree toString
patrick-dmxc Nov 24, 2026
54a8657
Refactoring and splitt IModule in two
patrick-dmxc Nov 25, 2026
2cb3a56
WIP
patrick-dmxc Nov 28, 2026
627f493
Name the state fields of the defines after what they hold
patrick-dmxc Nov 28, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
26 changes: 26 additions & 0 deletions .github/copilot-instructions.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@

# Git Commit Instructions

When generating Git commit messages, follow these rules:

- Write all commit messages in English.
- Use Conventional Commits.
- The first line must contain no more than 50 characters.
- Use the format: type(scope): description
- Use the imperative mood.
- Leave the second line empty.
- Starting on the third line, describe the changes in detail.
- Explain what was changed and why.
- Use bullet points for multiple changes.
- Do not use emojis.
- Do not invent changes that are not present.

Allowed types:
- feat: New feature
- fix: Bug fix
- refactor: Code restructuring
- docs: Documentation
- style: Formatting
- test: Tests
- chore: Maintenance
- perf: Performance improvement
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -398,4 +398,6 @@ FodyWeavers.xsd
*.sln.iml

# Notepad++
*.bak
*.bak
# RDM dump tests: extracted RDM messages of the captures
tools/RdmDumpTests/.cache/
139 changes: 117 additions & 22 deletions RDMSharp/EManufacturer.cs
Original file line number Diff line number Diff line change
@@ -1,26 +1,121 @@
using System.ComponentModel;

namespace RDMSharp
namespace RDMSharp;

public enum EManufacturer : ushort
{
public enum EManufacturer : ushort
{
[Description("ESTA")]
ESTA = 0x0000,
[Description("DMXControl-Projects e.V.")]
DMXControlProjects_eV = 0x02b0,
[Description("Martin Professional A/S")]
Martin_Professional_AS = 0x4D50,
[Description("SGM Technology For Lighting SPA")]
SGM_Technology_For_Lighting_SPA = 0x5347,
[Description("Wireless Solution Sweden AB")]
Wireless_Solution_Sweden_AB = 0x5753,
[Description("Robe Show Lighting s.r.o.")]
Robe_Show_Lighting_sro = 0x5253,
[Description("Swisson AG")]
Swisson_AG = 0x5777,
[Description("GLP German Light Products GmbH")]
GLP_German_Light_Products_GmbH = 0x676C,
[Description("Steinigke Showtechnic GmbH")]
Steinigke_Showtechnic_GmbH = 0x29aa,
}
[Description("ESTA")]
ESTA = 0x0000,
[Description("GEE")]
GEE = 0x0001,
[Description("Wattle IT")]
Wattle_IT = 0x0020,
[Description("CHAMP Licht")]
CHAMP_Licht = 0x0077,
[Description("Creative Lighting And Sound Systems Pty Ltd.")]
Creative_Lighting_And_Sound_Systems = 0x00A1,
[Description("Constell8 NV")]
Constell8_NV = 0x00C8,
[Description("Inventronics (Hangzhou), Inc.")]
Inventronics = 0x0107,
[Description("Videndum Production Solutions Inc. (Litepanels)")]
Videndum_Production_Solutions = 0x01AA,
[Description("Big Bang Lightning (KLSTR)")]
Big_Bang_Lightning = 0x02A3,
[Description("DMXControl-Projects e.V.")]
DMXControlProjects_eV = 0x02b0,
[Description("CLF Lighting BV.")]
CLF_Lighting_BV = 0x02E2,
[Description("ImageCue LLC")]
ImageCue_LLC = 0x0308,
[Description("D.T.S. Illuminazione srl")]
DTS_Illuminazione_srl = 0x0710,
[Description("QubiCast GmbH")]
QubiCast_GmbH = 0x082E,
[Description("Adam Hall GmbH")]
Adam_Hall = 0x08A4,
[Description("LMP Lichttechnik Vertriebsgesellschaft GmbH & Co KG")]
LMP_Lichttechnik_Vertriebsgesellschaft = 0x08E4,
[Description("Music & Lights S.r.l.")]
Music_and_Lights_Srl = 0x15D0,
[Description("HBZZ (not registered at ESTA)")]
HBZZ = 0x1DD6,
[Description("ARRI")]
ARRI = 0x20B9,
[Description("CHAUVET Lighting")]
CHAUVET_Lighting = 0x21A4,
[Description("Elation Lighting Inc.")]
Elation_Lighting_Inc = 0x22A6,
[Description("Litecraft (not registered at ESTA)")]
Litecraft = 0x2353,
[Description("Steinigke Showtechnic GmbH")]
Steinigke_Showtechnic_GmbH = 0x29aa,
[Description("Global Design Solutions, Ltd.")]
Global_Design_Solutions = 0x3434,
[Description("ACME EFFECTS LTD.")]
ACME_Effects_Ltd = 0x3806,
[Description("Altman Stage Lighting")]
Altman_Stage_Lighting = 0x4131,
[Description("Astera")]
Astera = 0x4173,
[Description("AYRTON")]
AYRTON = 0x4179,
[Description("Coemar Spa")]
Coemar_Spa = 0x434D,
[Description("CLAY PAKY S.p.A")]
CLAY_PAKY_SpA = 0x4350,
[Description("City Theatrical, Inc.")]
City_Theatrical = 0x4354,
[Description("ENTTEC Pty Ltd")]
ENTTEC = 0x454E,
[Description("Magic FX B.V.")]
Magic_FX_bv = 0x4658,
[Description("Howard Eaton Lighting Ltd.")]
Howard_Eaton_Lighting = 0x4845,
[Description("JB-lighting GmbH")]
JB_lighting_GmbH = 0x4A42,
[Description("Jands Pty Ltd.")]
Jands = 0x4A61,
[Description("Luminex")]
LUMINEX_Lighting_Control_Equipment_bvba = 0x4C4C,
[Description("LumenRadio AB")]
LumenRadio_AB = 0x4C55,
[Description("LSC Control Systems Pty Ltd")]
LSC = 0x4C73,
[Description("MDG")]
MDG = 0x4D44,
[Description("Martin Professional A/S")]
Martin_Professional_AS = 0x4D50,
[Description("Philips Entertainment Lighting Asia")]
Philips_Entertainment_Lighting_Asia = 0x5041,
[Description("Production Resource Group")]
Production_Resource_Group = 0x5052,
[Description("Robe Show Lighting s.r.o.")]
Robe_Show_Lighting_sro = 0x5253,
[Description("SGM Technology For Lighting SPA")]
SGM_Technology_For_Lighting_SPA = 0x5347,
[Description("Chroma-Q")]
Chroma_Q = 0x5370,
[Description("Swisson AG")]
Swisson_AG = 0x5377,
[Description("Singularity (UK) Ltd.")]
Singularity_UK_Ltd = 0x5379,
[Description("SOUNDLIGHT")]
SOUNDLIGHT = 0x534C,
[Description("Wireless Solution Sweden AB")]
Wireless_Solution_Sweden_AB = 0x5753,
[Description("ELC lighting")]
ELC_lighting = 0x656C,
[Description("Electronic Theatre Controls Inc.")]
Electronic_Theatre_Controls_Inc = 0x6574,
[Description("GLP German Light Products GmbH")]
GLP_German_Light_Products_GmbH = 0x676C,
[Description("Roxx")]
Roxx = 0x6a6a,
[Description("Explorentis (Lucenti)")]
Explorentis = 0x6FED,
[Description("Open Lighting")]
Open_Lighting = 0x7A70,
[Description("Look Solutions GmbH & Co. KG")]
Look_Solutions_GmbH_and_Co_KG = 0x7EED
}
32 changes: 32 additions & 0 deletions RDMSharp/Extensions/BytesParser/DoubleBytesParser.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
using RDMSharp.RDM;
using System;
using System.Linq;

namespace RDMSharp.Extensions.BytesParser;

public class DoubleBytesParser : IBytesParser
{
private static readonly byte _bytesLength = 8;
private static readonly string _formatIdentifyer = "double";
private static readonly PDL _payloadDataLength = new PDL(_bytesLength);
public string FormatIdentifyer => _formatIdentifyer;
public PDL? PayloadDataLength => _payloadDataLength;

public object ParseToObject(ref byte[] data)
{
if (data.Length < _bytesLength)
throw new ArgumentException("Data length is less than required for Double parsing.", nameof(data));

double _double = BitConverter.ToDouble(data.Take(_bytesLength).ToArray(), 0);
data = data.Skip(_bytesLength).ToArray();

return _double;
}

public byte[] ParseToData(object obj)
{
if (obj is double _double)
return BitConverter.GetBytes(_double);
throw new ArgumentException($"Object is not of type Double", nameof(obj));
}
}
32 changes: 32 additions & 0 deletions RDMSharp/Extensions/BytesParser/FloatBytesParser.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
using RDMSharp.RDM;
using System;
using System.Linq;

namespace RDMSharp.Extensions.BytesParser;

public class FloatBytesParser : IBytesParser
{
private static readonly byte _bytesLength = 4;
private static readonly string _formatIdentifyer = "float";
private static readonly PDL _payloadDataLength = new PDL(_bytesLength);
public string FormatIdentifyer => _formatIdentifyer;
public PDL? PayloadDataLength => _payloadDataLength;

public object ParseToObject(ref byte[] data)
{
if (data.Length < _bytesLength)
throw new ArgumentException("Data length is less than required for Float parsing.", nameof(data));

float _float = BitConverter.ToSingle(data.Take(_bytesLength).ToArray(), 0);
data = data.Skip(_bytesLength).ToArray();

return _float;
}

public byte[] ParseToData(object obj)
{
if (obj is float _float)
return BitConverter.GetBytes(_float);
throw new ArgumentException($"Object is not of type Float", nameof(obj));
}
}
32 changes: 32 additions & 0 deletions RDMSharp/Extensions/BytesParser/GuidBytesParser.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
using RDMSharp.RDM;
using System;
using System.Linq;

namespace RDMSharp.Extensions.BytesParser;

public class GuidBytesParser : IBytesParser
{
private static readonly byte _bytesLength = 16;
private static readonly string _formatIdentifyer = "guid";
private static readonly PDL _payloadDataLength = new PDL(_bytesLength);
public string FormatIdentifyer => _formatIdentifyer;
public PDL? PayloadDataLength => _payloadDataLength;

public object ParseToObject(ref byte[] data)
{
if (data.Length < _bytesLength)
throw new ArgumentException("Data length is less than required for Guid parsing.", nameof(data));

Guid guid = new Guid(data.Take(_bytesLength).ToArray());
data = data.Skip(_bytesLength).ToArray();

return guid;
}

public byte[] ParseToData(object obj)
{
if (obj is Guid guid)
return guid.ToByteArray();
throw new ArgumentException($"Object is not of type {nameof(Guid)}", nameof(obj));
}
}
32 changes: 32 additions & 0 deletions RDMSharp/Extensions/BytesParser/IPv4AddressBytesParser.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
using RDMSharp.RDM;
using System;
using System.Linq;

namespace RDMSharp.Extensions.BytesParser;

public class IPv4AddressBytesParser : IBytesParser
{
private static readonly byte _bytesLength = 4;
private static readonly string _formatIdentifyer = "ipv4";
private static readonly PDL _payloadDataLength = new PDL(_bytesLength);
public string FormatIdentifyer => _formatIdentifyer;
public PDL? PayloadDataLength => _payloadDataLength;

public object ParseToObject(ref byte[] data)
{
if (data.Length < _bytesLength)
throw new ArgumentException("Data length is less than required for IPv4 parsing.", nameof(data));

IPv4Address ipv4Address = new IPv4Address(data.Take(_bytesLength));
data = data.Skip(_bytesLength).ToArray();

return ipv4Address;
}

public byte[] ParseToData(object obj)
{
if (obj is IPv4Address ipv4Address)
return ipv4Address;
throw new ArgumentException($"Object is not of type {nameof(IPv4Address)}", nameof(obj));
}
}
32 changes: 32 additions & 0 deletions RDMSharp/Extensions/BytesParser/IPv6AddressBytesParser.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
using RDMSharp.RDM;
using System;
using System.Linq;

namespace RDMSharp.Extensions.BytesParser;

public class IPv6AddressBytesParser : IBytesParser
{
private static readonly byte _bytesLength = 16;
private static readonly string _formatIdentifyer = "ipv6";
private static readonly PDL _payloadDataLength = new PDL(_bytesLength);
public string FormatIdentifyer => _formatIdentifyer;
public PDL? PayloadDataLength => _payloadDataLength;

public object ParseToObject(ref byte[] data)
{
if (data.Length < _bytesLength)
throw new ArgumentException("Data length is less than required for IPv6 parsing.", nameof(data));

IPv6Address ipv6Address = new IPv6Address(data.Take(_bytesLength));
data = data.Skip(_bytesLength).ToArray();

return ipv6Address;
}

public byte[] ParseToData(object obj)
{
if (obj is IPv6Address ipv6Address)
return ipv6Address;
throw new ArgumentException($"Object is not of type {nameof(IPv6Address)}", nameof(obj));
}
}
32 changes: 32 additions & 0 deletions RDMSharp/Extensions/BytesParser/MACAddressBytesParser.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
using RDMSharp.RDM;
using System;
using System.Linq;

namespace RDMSharp.Extensions.BytesParser;

public class MACAddressBytesParser : IBytesParser
{
private static readonly byte _bytesLength = 6;
private static readonly string _formatIdentifyer = "mac-address";
private static readonly PDL _payloadDataLength = new PDL(_bytesLength);
public string FormatIdentifyer => _formatIdentifyer;
public PDL? PayloadDataLength => _payloadDataLength;

public object ParseToObject(ref byte[] data)
{
if (data.Length < _bytesLength)
throw new ArgumentException("Data length is less than required for MAC-Address parsing.", nameof(data));

MACAddress macAddress = new MACAddress(data.Take(_bytesLength));
data = data.Skip(_bytesLength).ToArray();

return macAddress;
}

public byte[] ParseToData(object obj)
{
if (obj is MACAddress macAddress)
return macAddress;
throw new ArgumentException($"Object is not of type {nameof(MACAddress)}", nameof(obj));
}
}
Loading
Loading