DSMRParser.Net
2.0.0
dotnet add package DSMRParser.Net --version 2.0.0
NuGet\Install-Package DSMRParser.Net -Version 2.0.0
<PackageReference Include="DSMRParser.Net" Version="2.0.0" />
<PackageVersion Include="DSMRParser.Net" Version="2.0.0" />
<PackageReference Include="DSMRParser.Net" />
paket add DSMRParser.Net --version 2.0.0
#r "nuget: DSMRParser.Net, 2.0.0"
#addin nuget:?package=DSMRParser.Net&version=2.0.0
#tool nuget:?package=DSMRParser.Net&version=2.0.0
DSMRParser.Net
DSMR Parser for .Net. Available as NuGet package.
Quickstart
var parser = new DSMRTelegramParser();
var telegram = parser.Parse(File.ReadAllText(@"mytelegram.txt"));
// Do stuff with the telegram
Console.WriteLine(telegram.VoltageL1?.ToString());
Console.WriteLine(telegram.VoltageL1?.Value);
Console.WriteLine(telegram.VoltageL1?.Unit);
Output:
230.1V
230.1
V
API
The IDSMRTelegramParser
interface has the following methods:
Telegram Parse(Span<byte> telegram);
However, the default implementation provides a few useful additional methods, show (simplified) below:
public Telegram Parse(Span<byte> telegram, bool ignoreCrc = false)
public Telegram Parse(string telegram, bool ignoreCrc = false)
public bool TryParse(Span<byte> telegram, bool ignoreCrc = false, out Telegram? result)
public bool TryParse(string telegram, bool ignoreCrc = false, out Telegram? result)
Since this API follows .Net conventions, usage shouldn't be a surprise. The Parse
method will throw an exception if the telegram is invalid, while TryParse
will return a boolean indicating success or failure and provide the result in the out
argument. The telegram
can be provided as string or as Span<byte>
and the ignoreCrc
does what it says on the tin: it ignores issues with the CRC.
As for a Telegram object, it has a number of properties that are mostly nullable. The reason for this is that the telegram may not contain all values, depending on the type of meter and the configuration. For example, a gas meter will not have any voltage values. The properties are all strongly typed, so you can use them directly in your code without having to parse them yourself.
A telegram may contain 'unknown' values. These are values that are not defined in the DSMR standard, but may be present in some meters. You can get to these values by using the GetByDescriptor(...)
, GetMultiByDescriptor(...)
, GetByObisID(...)
and GetMultiByObisID(...)
methods. You can use the OBISRegistry
and/or OBISId
classes to get the OBIS IDs and descriptors for documented values.
var value = telegram.GetByDescriptor(OBISRegistry.CurrentL1);
// or..
var value = telegram.GetByObisID(OBISRegistry.CurrentL1.Id);
// or..
var value = telegram.GetByObisID(OBISId.FromString("1-0:31.7.0"));
This library is locale aware (you can set a timezone for the DSMRTelegramParser
in it's constructor. All UnitValue<T>
values have .ToString(...)
overrides that allow you to specify an IFormatProvider
and format
.
CRC's
The library will automatically check the CRC of the telegram. If you want to ignore the CRC, you can set the ignoreCrc
parameter to true
in the Parse
and TryParse
methods. The library will still parse the telegram, but it will not check the CRC. This is useful for testing or if you are sure that the telegram is valid. You can also provide the DSMRTelegramParser
with a custom ICRCVerifier
implementation if you want to use a different CRC algorithm. This library provides a default CRC16Verifier
implementation that uses the CRC16 algorithm.
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net5.0 was computed. net5.0-windows was computed. net6.0 was computed. net6.0-android was computed. net6.0-ios was computed. net6.0-maccatalyst was computed. net6.0-macos was computed. net6.0-tvos was computed. net6.0-windows was computed. net7.0 was computed. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. net8.0 was computed. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. net9.0 was computed. net9.0-android was computed. net9.0-browser was computed. net9.0-ios was computed. net9.0-maccatalyst was computed. net9.0-macos was computed. net9.0-tvos was computed. net9.0-windows was computed. net10.0 was computed. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
.NET Core | netcoreapp3.0 was computed. netcoreapp3.1 was computed. |
.NET Standard | netstandard2.1 is compatible. |
MonoAndroid | monoandroid was computed. |
MonoMac | monomac was computed. |
MonoTouch | monotouch was computed. |
Tizen | tizen60 was computed. |
Xamarin.iOS | xamarinios was computed. |
Xamarin.Mac | xamarinmac was computed. |
Xamarin.TVOS | xamarintvos was computed. |
Xamarin.WatchOS | xamarinwatchos was computed. |
-
.NETStandard 2.1
- No dependencies.
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.