public record ObisCode : System.ValueType, System.IEquatable<SharpMeter.Dlms.Enums.ObisCode>
Namespace: SharpMeter.Dlms.Enums
Inheritance
Inherits from: System.ValueType
Implements: System.IEquatable<SharpMeter.Dlms.Enums.ObisCode>
Constructors
| Name | Description |
|---|---|
ObisCode(…) |
Represents an OBIS (Object Identification System) code per IEC 62056-61. Format: A-B:C.D.E*F where each field is a byte value. |
ObisCode(byte A, byte B, byte C, byte D, byte E, byte F)
ObisCode.ObisCode(byte A, byte B, byte C, byte D, byte E, byte F = 255)
Represents an OBIS (Object Identification System) code per IEC 62056-61. Format: A-B:C.D.E*F where each field is a byte value.
Parameters
| Name | Type | Description |
|---|---|---|
A | byte | Value group A — medium (0=abstract, 1=electricity, 7=gas, 8=water). |
B | byte | Value group B — channel. |
C | byte | Value group C — physical quantity. |
D | byte | Value group D — processing/measurement algorithm. |
E | byte | Value group E — further classification. |
F | byte | Value group F — storage/billing period (255=not used). |
Properties
| Name | Description |
|---|---|
A |
Value group A — medium (0=abstract, 1=electricity, 7=gas, 8=water). |
B |
Value group B — channel. |
C |
Value group C — physical quantity. |
D |
Value group D — processing/measurement algorithm. |
E |
Value group E — further classification. |
F |
Value group F — storage/billing period (255=not used). |
A
byte ObisCode.A { get; init; }
Value group A — medium (0=abstract, 1=electricity, 7=gas, 8=water).
B
byte ObisCode.B { get; init; }
Value group B — channel.
C
byte ObisCode.C { get; init; }
Value group C — physical quantity.
D
byte ObisCode.D { get; init; }
Value group D — processing/measurement algorithm.
E
byte ObisCode.E { get; init; }
Value group E — further classification.
F
byte ObisCode.F { get; init; }
Value group F — storage/billing period (255=not used).
Methods
| Name | Description |
|---|---|
FromBytes(ReadOnlySpan<byte> bytes) static |
Decodes an OBIS code from a 6-byte span. |
Parse(string value) static |
Parses an OBIS code from string format "A-B:C.D.E*F" or "A.B.C.D.E.F". |
ToBytes() |
Encodes the OBIS code as a 6-byte array. |
ToString() override |
FromBytes(ReadOnlySpan bytes)
ObisCode ObisCode.FromBytes(ReadOnlySpan<byte> bytes)
Decodes an OBIS code from a 6-byte span.
Parse(string value)
ObisCode ObisCode.Parse(string value)
Parses an OBIS code from string format "A-B:C.D.E*F" or "A.B.C.D.E.F".
ToBytes()
byte[] ObisCode.ToBytes()
Encodes the OBIS code as a 6-byte array.
Fields
| Name | Description |
|---|---|
ActiveEnergyExportTotal static |
Active energy export total (1.0.2.8.0.255). |
ActiveEnergyImportTotal static |
Active energy import total (1.0.1.8.0.255). |
ActivePowerTotal static |
Instantaneous active power total (1.0.1.7.0.255). |
AssociationLn static |
Association LN (0.0.40.0.0.255). |
Clock static |
Clock object (0.0.1.0.0.255). |
CurrentL1 static |
Instantaneous current L1 (1.0.31.7.0.255). |
CurrentL2 static |
Instantaneous current L2 (1.0.51.7.0.255). |
CurrentL3 static |
Instantaneous current L3 (1.0.71.7.0.255). |
EventLog static |
Event log (0.0.99.98.0.255). |
FirmwareVersion static |
Firmware version (1.0.0.2.0.255). |
Frequency static |
Frequency (1.0.14.7.0.255). |
LoadProfile static |
Load profile (1.0.99.1.0.255). |
PowerFactorTotal static |
Power factor total (1.0.13.7.0.255). |
ReactiveEnergyExportTotal static |
Reactive energy export total (1.0.4.8.0.255). |
ReactiveEnergyImportTotal static |
Reactive energy import total (1.0.3.8.0.255). |
SerialNumber static |
Meter serial number (0.0.96.1.0.255). |
VoltageL1 static |
Instantaneous voltage L1 (1.0.32.7.0.255). |
VoltageL2 static |
Instantaneous voltage L2 (1.0.52.7.0.255). |
VoltageL3 static |
Instantaneous voltage L3 (1.0.72.7.0.255). |
ActiveEnergyExportTotal
SharpMeter.Dlms.Enums.ObisCode ActiveEnergyExportTotal
Active energy export total (1.0.2.8.0.255).
ActiveEnergyImportTotal
SharpMeter.Dlms.Enums.ObisCode ActiveEnergyImportTotal
Active energy import total (1.0.1.8.0.255).
ActivePowerTotal
SharpMeter.Dlms.Enums.ObisCode ActivePowerTotal
Instantaneous active power total (1.0.1.7.0.255).
AssociationLn
SharpMeter.Dlms.Enums.ObisCode AssociationLn
Association LN (0.0.40.0.0.255).
Clock
SharpMeter.Dlms.Enums.ObisCode Clock
Clock object (0.0.1.0.0.255).
CurrentL1
SharpMeter.Dlms.Enums.ObisCode CurrentL1
Instantaneous current L1 (1.0.31.7.0.255).
CurrentL2
SharpMeter.Dlms.Enums.ObisCode CurrentL2
Instantaneous current L2 (1.0.51.7.0.255).
CurrentL3
SharpMeter.Dlms.Enums.ObisCode CurrentL3
Instantaneous current L3 (1.0.71.7.0.255).
EventLog
SharpMeter.Dlms.Enums.ObisCode EventLog
Event log (0.0.99.98.0.255).
FirmwareVersion
SharpMeter.Dlms.Enums.ObisCode FirmwareVersion
Firmware version (1.0.0.2.0.255).
Frequency
SharpMeter.Dlms.Enums.ObisCode Frequency
Frequency (1.0.14.7.0.255).
LoadProfile
SharpMeter.Dlms.Enums.ObisCode LoadProfile
Load profile (1.0.99.1.0.255).
PowerFactorTotal
SharpMeter.Dlms.Enums.ObisCode PowerFactorTotal
Power factor total (1.0.13.7.0.255).
ReactiveEnergyExportTotal
SharpMeter.Dlms.Enums.ObisCode ReactiveEnergyExportTotal
Reactive energy export total (1.0.4.8.0.255).
ReactiveEnergyImportTotal
SharpMeter.Dlms.Enums.ObisCode ReactiveEnergyImportTotal
Reactive energy import total (1.0.3.8.0.255).
SerialNumber
SharpMeter.Dlms.Enums.ObisCode SerialNumber
Meter serial number (0.0.96.1.0.255).
VoltageL1
SharpMeter.Dlms.Enums.ObisCode VoltageL1
Instantaneous voltage L1 (1.0.32.7.0.255).
VoltageL2
SharpMeter.Dlms.Enums.ObisCode VoltageL2
Instantaneous voltage L2 (1.0.52.7.0.255).
VoltageL3
SharpMeter.Dlms.Enums.ObisCode VoltageL3
Instantaneous voltage L3 (1.0.72.7.0.255).
Type Relationships
classDiagram
style ObisCode fill:#f9f,stroke:#333,stroke-width:2px
ObisCode --|> ValueType : inherits
ObisCode ..|> ObisCode~ : implements
View Source
/// <summary>
/// Represents an OBIS (Object Identification System) code per IEC 62056-61.
/// Format: A-B:C.D.E*F where each field is a byte value.
/// </summary>
/// <param name = "A">Value group A — medium (0=abstract, 1=electricity, 7=gas, 8=water).</param>
/// <param name = "B">Value group B — channel.</param>
/// <param name = "C">Value group C — physical quantity.</param>
/// <param name = "D">Value group D — processing/measurement algorithm.</param>
/// <param name = "E">Value group E — further classification.</param>
/// <param name = "F">Value group F — storage/billing period (255=not used).</param>
public readonly record struct ObisCode(byte A, byte B, byte C, byte D, byte E, byte F = 255)
{
#region Well-Known Codes
/// <summary>Active energy import total (1.0.1.8.0.255).</summary>
public static readonly ObisCode ActiveEnergyImportTotal = new(1, 0, 1, 8, 0);
/// <summary>Active energy export total (1.0.2.8.0.255).</summary>
public static readonly ObisCode ActiveEnergyExportTotal = new(1, 0, 2, 8, 0);
/// <summary>Reactive energy import total (1.0.3.8.0.255).</summary>
public static readonly ObisCode ReactiveEnergyImportTotal = new(1, 0, 3, 8, 0);
/// <summary>Reactive energy export total (1.0.4.8.0.255).</summary>
public static readonly ObisCode ReactiveEnergyExportTotal = new(1, 0, 4, 8, 0);
/// <summary>Instantaneous voltage L1 (1.0.32.7.0.255).</summary>
public static readonly ObisCode VoltageL1 = new(1, 0, 32, 7, 0);
/// <summary>Instantaneous voltage L2 (1.0.52.7.0.255).</summary>
public static readonly ObisCode VoltageL2 = new(1, 0, 52, 7, 0);
/// <summary>Instantaneous voltage L3 (1.0.72.7.0.255).</summary>
public static readonly ObisCode VoltageL3 = new(1, 0, 72, 7, 0);
/// <summary>Instantaneous current L1 (1.0.31.7.0.255).</summary>
public static readonly ObisCode CurrentL1 = new(1, 0, 31, 7, 0);
/// <summary>Instantaneous current L2 (1.0.51.7.0.255).</summary>
public static readonly ObisCode CurrentL2 = new(1, 0, 51, 7, 0);
/// <summary>Instantaneous current L3 (1.0.71.7.0.255).</summary>
public static readonly ObisCode CurrentL3 = new(1, 0, 71, 7, 0);
/// <summary>Instantaneous active power total (1.0.1.7.0.255).</summary>
public static readonly ObisCode ActivePowerTotal = new(1, 0, 1, 7, 0);
/// <summary>Frequency (1.0.14.7.0.255).</summary>
public static readonly ObisCode Frequency = new(1, 0, 14, 7, 0);
/// <summary>Power factor total (1.0.13.7.0.255).</summary>
public static readonly ObisCode PowerFactorTotal = new(1, 0, 13, 7, 0);
/// <summary>Clock object (0.0.1.0.0.255).</summary>
public static readonly ObisCode Clock = new(0, 0, 1, 0, 0);
/// <summary>Meter serial number (0.0.96.1.0.255).</summary>
public static readonly ObisCode SerialNumber = new(0, 0, 96, 1, 0);
/// <summary>Firmware version (1.0.0.2.0.255).</summary>
public static readonly ObisCode FirmwareVersion = new(1, 0, 0, 2, 0);
/// <summary>Association LN (0.0.40.0.0.255).</summary>
public static readonly ObisCode AssociationLn = new(0, 0, 40, 0, 0);
/// <summary>Load profile (1.0.99.1.0.255).</summary>
public static readonly ObisCode LoadProfile = new(1, 0, 99, 1, 0);
/// <summary>Event log (0.0.99.98.0.255).</summary>
public static readonly ObisCode EventLog = new(0, 0, 99, 98, 0);
#endregion
#region Methods
/// <summary>Encodes the OBIS code as a 6-byte array.</summary>
public byte[] ToBytes() => [A, B, C, D, E, F];
/// <summary>Decodes an OBIS code from a 6-byte span.</summary>
public static ObisCode FromBytes(ReadOnlySpan<byte> bytes)
{
if (bytes.Length < 6)
throw new ArgumentException("OBIS code requires 6 bytes", nameof(bytes));
return new ObisCode(bytes[0], bytes[1], bytes[2], bytes[3], bytes[4], bytes[5]);
}
/// <inheritdoc/>
public override string ToString() => $"{A}-{B}:{C}.{D}.{E}*{F}";
/// <summary>Parses an OBIS code from string format "A-B:C.D.E*F" or "A.B.C.D.E.F".</summary>
public static ObisCode Parse(string value)
{
ArgumentNullException.ThrowIfNull(value);
// Try "A-B:C.D.E*F" format
var parts = value.Replace("-", ".", StringComparison.Ordinal).Replace(":", ".", StringComparison.Ordinal).Replace("*", ".", StringComparison.Ordinal).Split('.');
if (parts.Length < 5)
throw new FormatException($"Invalid OBIS code format: {value}");
return new ObisCode(byte.Parse(parts[0], CultureInfo.InvariantCulture), byte.Parse(parts[1], CultureInfo.InvariantCulture), byte.Parse(parts[2], CultureInfo.InvariantCulture), byte.Parse(parts[3], CultureInfo.InvariantCulture), byte.Parse(parts[4], CultureInfo.InvariantCulture), parts.Length > 5 ? byte.Parse(parts[5], CultureInfo.InvariantCulture) : (byte)255);
}
#endregion
}