obis

package
v0.1.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 11, 2026 License: Apache-2.0 Imports: 7 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package obis is the Object Identification System of IEC 62056-6-1:2023 (EN IEC 62056-6-1:2024 is the same text) as a model: it validates an OBIS code, says which range each value group is in (standard, manufacturer, utility, consortia, country, reserved), describes what a standard code identifies, and derives a point name for it. The tables are data (obis.yaml) with clause and table references; the wording is ours.

SigmaM2M's DLMS adapter names configured objects with it, and its IEC 62056-21 and Wireless M-Bus adapters name readout addresses (reduced ID codes, annex A.1) and data records with it.

Index

Examples

Constants

This section is empty.

Variables

View Source
var ErrReserved = errors.New("reserved OBIS code")

ErrReserved is returned by Validate for codes in reserved ranges.

Functions

func Name

func Name(c Code) string

Name returns the derived point name of a code, "" when it has none.

func NameFor

func NameFor(c Code, class uint16) string

NameFor returns the derived point name of an object of an interface class: where one code names objects of different classes (IEC 62056-6-2:2023 6.2.19: 0.b.21.0.e is a readout profile of class 7 and a parameter of class 1), the row for the class decides.

func Validate

func Validate(c Code) error

Validate returns an error wrapping ErrReserved for a code no range of IEC 62056-6-1:2023 allocates.

Types

type Code

type Code [6]byte

Code is an OBIS code, value groups A to F.

func MustParse

func MustParse(s string) Code

MustParse is Parse for constants; it panics on a bad code.

func Parse

func Parse(s string) (Code, error)

Parse reads a six-group code: "1.0.1.8.0.255", or the delimited form of annex A.1 with all groups ("1-0:1.8.0*255", "1-0:1.8.0.255"). Reduced codes with groups left out are read by ParseReduced.

func ParseAny

func ParseAny(s string) (Code, error)

ParseAny reads a six-group code or a reduced one.

func (Code) A

func (c Code) A() byte

A returns value group A (the medium).

func (Code) B

func (c Code) B() byte

B returns value group B (the channel).

func (Code) C

func (c Code) C() byte

C returns value group C (the quantity).

func (Code) D

func (c Code) D() byte

D returns value group D (the processing).

func (Code) E

func (c Code) E() byte

E returns value group E (further classification).

func (Code) F

func (c Code) F() byte

F returns value group F (the billing period).

func (Code) String

func (c Code) String() string

String is the dotted form "a.b.c.d.e.f".

type Counts

type Counts struct {
	Media        int // allocated A values (Table 3)
	Countries    int // Table 7 rows
	Consortia    int // Table 6 rows
	ElectricityC int // quantity C values (Table 13)
	ElectricityD int // D values (Table 14)
	Harmonics    int // E values of Table 16 other than 0
	AngleCodes   int // E values of Table 17
	LossCodes    int // E values of Table 18
	DipClasses   int // E values of Table 19
	ObjectRows   int // rows of Tables 8 to 12 and 20 to 24, 6-2 clause 6 and EN 13757-1 clause 11.3
	MediaC       int // quantity C codes of media 4 to 9 (EN 13757-1:2021), per A
	MediaD       int // D codes of the EN 13757-1:2021 D tables
}

Counts is the size of the model, for tests and the report.

func Stats

func Stats() Counts

Stats counts the model.

type Info

type Info struct {
	Code Code
	Kind Kind
	// Medium (A), Channel (B), Quantity (C), Processing (D), Class (E) and
	// Period (F) say what each value group means, in our words; empty when
	// the group carries no meaning of its own.
	Medium, Channel, Quantity, Processing, Class, Period string
	// Owner is the country or consortium of a country or consortia code.
	Owner string
	// Name is the derived point name; empty when the code has no standard
	// meaning (manufacturer, utility, consortia, country, context codes and
	// reserved ones).
	Name string
	// Classes are the interface classes IEC 62056-6-2:2023 clause 6 gives
	// the object (class_id), in the order the standard lists them; empty
	// when it gives none.
	Classes []uint16
	// Ref is the clause and table the meaning comes from.
	Ref string
	// Problem says why a reserved code is reserved.
	Problem string
}

Info describes a code.

func Describe

func Describe(c Code) Info

Describe classifies and describes a code, taking the first matching row where rows of several classes share it.

Example

What OBIS codes mean, and the point names derived from them.

package main

import (
	"fmt"

	"github.com/cB-Sigma/dlms/obis"
)

func main() {
	for _, s := range []string{"1.0.1.8.0.255", "1.0.32.7.0.255", "1.0.1.8.0.3", "7.0.13.2.0.255"} {
		i := obis.Describe(obis.MustParse(s))
		fmt.Println(s, i.Kind, i.Name)
	}
	// A reduced code as an IEC 62056-21 readout writes it.
	c, _ := obis.ParseAny("1.8.0")
	fmt.Println(obis.Name(c))
}
Output:
1.0.1.8.0.255 standard activeEnergyImport
1.0.32.7.0.255 standard voltageL1
1.0.1.8.0.3 standard activeEnergyImport_b03
7.0.13.2.0.255 standard gasConverterVolumeFwdBase
activeEnergyImport

func DescribeClass

func DescribeClass(c Code, class uint16) Info

DescribeClass is Describe for an object of a known interface class.

func (Info) Valid

func (i Info) Valid() bool

Valid reports whether the code is not in a reserved range.

type Kind

type Kind string

Kind is the range a code falls in (clause 4, Table 2).

const (
	Standard     Kind = "standard"     // a meaning this document defines
	Media        Kind = "media"        // A = 4-9: defined for those media elsewhere (clause 1, EN 13757-1)
	Manufacturer Kind = "manufacturer" // 4.2, Tables 2, 8, 20
	Utility      Kind = "utility"      // 5.2, B = 65-127
	Consortia    Kind = "consortia"    // 5.4.2, C = 93
	Country      Kind = "country"      // 5.4.3, C = 94, or reserved for one country in a table
	Inactive     Kind = "inactive"     // A = 0, C = 127 (Table 5)
	Reserved     Kind = "reserved"     // 4.3: not allocated
)

Kinds.

type Reduced

type Reduced struct {
	A, B, C, D, E, F int
	// Manual is set when "&" rather than "*" comes before F: the reset
	// was made by hand (A.1).
	Manual bool
}

Reduced is an ID code in the presentation of annex A.1, "A-B:C.D.E*F", as IEC 62056-21 readouts and displays use it: C and D are mandatory; A, B, E and F may be left out (-1 here); every group is 0 to 99, and C and D may be the letters C, F, L, P for 96 to 99 (A.2 Table A.1).

func ParseReduced

func ParseReduced(s string) (Reduced, error)

ParseReduced reads a reduced ID code: "1.8.0", "1.8.0*03", "C.1.0", "F.F", "1-0:1.8.0&12", "1-0:1.8.0". A trailing ".255" or "*255" (F not used, 5.6.1) is accepted and read as F left out.

func (Reduced) Code

func (r Reduced) Code() Code

Code completes a reduced code (finding F-264, A.1 does not say what groups left out mean): A left out is 0 (abstract) when C is 96 to 99, the letters C, F, L, P, and 1 (electricity) otherwise, as electricity meter readouts print them; B left out is 0 (no channel, 5.2); E left out is 0 (the only or total object, 4.5); F left out is 255 (not used, 5.6.1).

func (Reduced) String

func (r Reduced) String() string

String prints the code back in reduced form, with the groups it has.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL