is15959

package
v0.3.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: 6 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 is15959 is the object catalogue of the Indian DLMS/COSEM companion standards, as data: IS 15959 Part 1:2011 (meter categories), Part 2:2016 with Amendments 1 and 2 (2017) for single- and three-phase whole-current smart meters, and Part 3:2017 for CT and CT/PT operated smart meters. Each profile (a Spec) lists the objects the standard requires with their OBIS code, interface class, attribute, value type, unit and access rights per association, the profile generic objects with their capture objects and periods, the event logs with their event codes, the push setups and the methods commands use. Clause and table references are to the standard; the wording is ours.

The package has no dependencies, so that a head end (SigmaM2M's DLMS adapter) and the meter simulator (package sim) can share it.

Index

Examples

Constants

View Source
const (
	CategoryVoltage     = "voltage"
	CategoryCurrent     = "current"
	CategoryPower       = "power"
	CategoryTransaction = "transaction"
	CategoryOther       = "other"
	CategoryNonRollover = "nonRollover"
	CategoryControl     = "control"
)

Event categories: the IS 15959 event log compartments.

View Source
const (
	KindOccurrence  = "occurrence"
	KindRestoration = "restoration"
	KindSingle      = "single"
)

Event kinds.

View Source
const (
	KeyLoadSwitchChanged = "loadSwitchChanged"
	KeyLastGasp          = "lastGasp"
	KeyFirstBreath       = "firstBreath"
	KeyBillingReset      = "billingReset"
)

Keys of the event status word bits that are not an event code's occurrence (Part 2 table 10 as amended, bits 84 to 87).

View Source
const (
	GroupNameplate     = "nameplate"
	GroupInstantaneous = "instantaneous"
	GroupEnergy        = "energy"
	GroupBlockLoad     = "blockload"
	GroupDailyLoad     = "dailyload"
	GroupBilling       = "billing"
	GroupEvents        = "events"
	GroupProgrammable  = "programmable"
	GroupScalers       = "scalers"
	GroupPush          = "push"
	GroupSecurity      = "security"
	GroupCommunication = "communication"
)

Object groups.

View Source
const (
	ClassData             = 1
	ClassRegister         = 3
	ClassExtendedRegister = 4
	ClassDemandRegister   = 5
	ClassProfileGeneric   = 7
	ClassClock            = 8
	ClassScriptTable      = 9
	ClassSpecialDays      = 11
	ClassAssociationLN    = 15
	ClassImageTransfer    = 18
	ClassActivityCalendar = 20
	ClassRegisterMonitor  = 21
	ClassSingleAction     = 22
	ClassHDLCSetup        = 23
	ClassPushSetup        = 40
	ClassTCPUDPSetup      = 41
	ClassIPv4Setup        = 42
	ClassIPv6Setup        = 48
	ClassSecuritySetup    = 64
	ClassDisconnect       = 70
	ClassLimiter          = 71
)

Interface classes.

View Source
const (
	ClockOBIS         = "0.0.1.0.0.255"
	DisconnectControl = "0.0.96.3.10.255"
	EventStatusWord   = "0.0.94.91.18.255"
)

Well-known objects.

View Source
const (
	PushPeriodic     = "0.0.25.9.0.255" // meter to head end, periodic (table 4)
	PushToDisplay    = "0.1.25.9.0.255" // head end to IHD (table 5)
	PushFromDisplay  = "0.2.25.9.0.255" // IHD to head end (table 6)
	PushMeterDisplay = "0.3.25.9.0.255" // meter to IHD (table 7)
	PushEvent        = "0.4.25.9.0.255" // meter to head end on events (table 8)
)

Push setups (clause 6, table 3 and figure 2 as amended by Amd 1 items 7 to 17: 0.b.25.9.0.255 with b = 0..4). The periodic push carries up to ten instantaneous parameters the buyer selects (clause 6.1.1): a head end reads push_object_list from the meter (Amd 1 item 6) and falls back to the first ten instantaneous parameters listed here.

View Source
const (
	BitLastGasp    = 85
	BitFirstBreath = 86
)

ESW bits (table 10 as amended by Amd 1 item 18): bit, occurrence and restoration codes. Bits not listed are reserved and sent as 0.

View Source
const SpecialDaysTable = "0.0.11.0.0.255"

SpecialDaysTable is the special days table (class 11), which names the day profile of the activity calendar to use on given dates instead of the week's.

Variables

Groups is every group name.

Functions

func AttrName

func AttrName(base, obis string, class uint16, attr int8) string

AttrName names an attribute of an object whose value (or primary attribute) is called base: base itself, or base with the class's attribute suffix ("Scaler", "Time", ...), or "<base>Attr<n>". SigmaM2M's DLMS adapter uses it with the names the OBIS model (package obis) derives for objects the catalogue does not list.

func CodeName

func CodeName(code int) string

CodeName names an event code from any part.

func ESWKey

func ESWKey(b ESWBit) string

ESWKey is the key of an event status word bit: its occurrence's condition, or one of the Key constants for bits 84 to 87.

func IDs

func IDs() []string

IDs lists the profile IDs.

func IsTimeAttr

func IsTimeAttr(class uint16, attr int8) bool

IsTimeAttr reports the date-time attributes of the register classes: the extended register's capture_time (5), the demand register's capture_time (6) and start_time_current (7).

func LabelKeys

func LabelKeys() []string

LabelKeys lists every key the console labels (event codes and event status word bits), sorted.

func NameOf

func NameOf(obis string, class uint16, attr int8) string

NameOf returns the point name of an attribute: the OBIS code's name (with a suffix for attributes other than the value), or the OBIS code when it has none.

func ScalerAttr

func ScalerAttr(class uint16) int8

ScalerAttr is the scaler_unit attribute of a class (IEC 62056-6-2:2023 4.3.2 to 4.3.4): 3 for the register and extended register, 4 for the demand register, whose attribute 3 is last_average_value; 0 otherwise.

Types

type Association

type Association struct {
	Role     Role
	Client   uint16 // client SAP
	OBIS     string // association LN object
	Auth     string // "none", "low" or an HLS mechanism name ("hls-gmac")
	Security string // APDU protection: none, authenticated, encrypted, authenticated-encrypted
	Setup    string // security setup object (class 64), "" without
	Ref      string
}

Association is one client association.

type Column

type Column struct {
	Name  string // filled from Names when empty
	OBIS  string
	Class uint16
	Attr  int8 // 2 when zero
}

Column is one capture object of a profile generic or push setup.

type ESWBit

type ESWBit struct {
	Bit         int
	Name        string
	Occurrence  int // event code of the occurrence (0: none)
	Restoration int // event code of the restoration (0: none)
}

ESWBit is one bit of the event status word pushed by the event push.

type Event

type Event struct {
	Code int
	Name string
}

Event is one event code.

type EventInfo

type EventInfo struct {
	Code      int
	Key       string // camel case; codes with the same meaning share a key (177 and 213)
	Name      string // CodeName
	Category  string // voltage, current, power, transaction, other, nonRollover, control
	Kind      string // occurrence, restoration or single
	Condition string // the occurrence's key for both codes of a pair; Key otherwise
	Pair      int    // the other code of an occurrence and restoration pair (0: none)
	Tamper    bool
}

EventInfo describes an event code for the readers of the logs (the console, the reports, IS 16444 checks): a stable key the console and the reports label it by, the log compartment it belongs to, whether it marks a condition starting or ending, and our tamper classification.

Neither IS 16444 nor IS 15959 says which codes are tampers (IS 15959 keeps a tamper count without listing what it counts; finding F-1921). Ours: supply and wiring interference and access to the meter (missing potential, voltage and current unbalance, current reversal, CT open, current bypass, earth loading, magnet, neutral disturbance, single-wire operation, communication module removal, cover open). Supply quality (over and low voltage, over-current, low power factor, overload), power, transaction and control events are not tampers.

func EventInfos

func EventInfos() []EventInfo

EventInfos lists every event code the three parts define, by code.

func Info

func Info(code int) (EventInfo, bool)

Info describes an event code; false for a code no part defines.

type EventLog

type EventLog struct {
	Profile
	CodeOBIS string // the event code object (class 1) of this log
	Codes    []Event
}

EventLog is an event log profile with its event code object and codes.

type Method

type Method struct {
	Name   string
	OBIS   string
	Class  uint16
	Method int8 // method id (0: a write of Attr)
	Attr   int8
	Type   string // parameter or value type
	Access Rights
	Ref    string
}

Method is a command the standard provides: a method invocation, or an attribute write when Method is zero.

type Object

type Object struct {
	Name   string // point name; filled from Names when empty
	OBIS   string
	Class  uint16
	Attr   int8   // attribute read or written (2 when zero)
	Type   string // A-XDR type of the value, e.g. "long-unsigned"
	Unit   string // unit of the scaled value when the standard fixes one
	Group  string
	Access Rights
	Ref    string // clause or table
}

Object is one COSEM attribute a profile requires.

type Profile

type Profile struct {
	Name    string
	OBIS    string
	Group   string
	Period  time.Duration // capture period; 0 for asynchronous or triggered capture
	Entries int           // entries the standard asks for (0: not stated)
	Capture []Column
	Scaler  string // OBIS of the profile's scaler profile, if any
	Access  Rights
	Ref     string
}

Profile is a profile generic object (class 7).

type PushSetup

type PushSetup struct {
	Name    string
	OBIS    string
	Capture []Column
	Ref     string
}

PushSetup is a push setup object (class 40) and what it pushes.

type Right uint8

Right is what one association may do with an attribute or method.

const (
	None  Right = 0
	Read  Right = 1
	Write Right = 2
	Exec  Right = 4 // method invocation
	RW          = Read | Write
)

Rights bits.

func (Right) String

func (r Right) String() string

String writes the right as R, W, X or a combination, or - for none.

type Rights

type Rights [numRoles]Right

Rights holds one Right per role.

func A

func A(s string) Rights

A parses compact access text such as "PC:R MR:R US:RW PUSH:R" (roles not named have no access). It panics on bad text: it is used for package data only, which a test checks.

func (Rights) Of

func (a Rights) Of(r Role) Right

Of returns a role's right.

func (Rights) String

func (a Rights) String() string

String lists the rights by role, as A reads them.

type Role

type Role uint8

Role is an association (client) a standard defines.

const (
	PC   Role = iota // public client
	MR               // meter reader
	US               // utility settings
	Push             // push (pre-established)
	FW               // firmware upgrade
	IHD              // in-home display

)

Roles, in the order of IS 15959 Part 2 table 2.

func RoleNamed

func RoleNamed(s string) (Role, bool)

RoleNamed returns the role for a settings name.

func (Role) String

func (r Role) String() string

String is the role's short name (PC, MR, US, PUSH, FW, IHD).

type Spec

type Spec struct {
	ID       string // settings value, e.g. "part2-3ph"
	Title    string
	Part     int
	Category string
	Phases   int
	Ref      string

	Associations []Association
	Suite        int // security suite (0: AES-GCM-128, AES-128 key wrap)
	Ciphering    string

	Objects  []Object
	Profiles []Profile
	Events   []EventLog
	ESW      []ESWBit
	Push     []PushSetup
	Methods  []Method
}

Spec is one selectable profile.

func Get

func Get(id string) (*Spec, bool)

Get returns a profile by its settings ID.

Example

The IS 15959 Part 2 single-phase smart meter profile: its size, the meter reader association and one object's point name.

package main

import (
	"fmt"

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

func main() {
	sp, ok := is15959.Get("part2-1ph")
	if !ok {
		panic("no profile")
	}
	objects, profiles, logs, codes, push, methods := sp.Count()
	fmt.Println(sp.ID, objects > 0, profiles, logs, codes > 0, push, methods > 0)
	a, _ := sp.Association(is15959.MR)
	fmt.Println(a.Client, a.OBIS, a.Auth)
	fmt.Println(is15959.NameOf("1.0.1.8.0.255", is15959.ClassRegister, 2))
	fmt.Println(is15959.CodeName(201))
}
Output:
part2-1ph true 10 7 true 5 true
32 0.0.40.0.2.255 low
activeEnergyImport
magnetic influence

func (*Spec) Access

func (s *Spec) Access(class uint16, obis string, id int8, method bool) (Rights, bool)

Access returns the rights on an attribute (method false) or a method (method true) of an object, from the objects, profiles, event logs and methods of the profile; ok is false when the profile does not list it.

func (*Spec) Association

func (s *Spec) Association(r Role) (Association, bool)

Association returns the association of a role.

func (*Spec) Count

func (s *Spec) Count() (objects, profiles, logs, codes, push, methods int)

Count reports the catalogue size: objects (attributes), profiles, event logs, event codes, push setups and methods.

func (*Spec) ESWBit

func (s *Spec) ESWBit(bit int) (ESWBit, bool)

ESWBit returns an event status word bit.

func (*Spec) EventLog

func (s *Spec) EventLog(obis string) *EventLog

EventLog returns the event log with an OBIS code.

func (*Spec) EventName

func (s *Spec) EventName(code int) (string, bool)

EventName names an event code of any of the profile's logs.

func (*Spec) Groups

func (s *Spec) Groups() []string

Groups lists the groups the profile has objects in, in Groups order.

func (*Spec) Method

func (s *Spec) Method(name string) *Method

Method returns a command by name.

func (*Spec) Object

func (s *Spec) Object(obis string, attr int8) *Object

Object returns the object with an OBIS code and attribute.

func (*Spec) Profile

func (s *Spec) Profile(obis string) *Profile

Profile returns the profile generic object (profiles and event logs) with an OBIS code.

func (*Spec) PushSetup

func (s *Spec) PushSetup(obis string) *PushSetup

PushSetup returns the push setup with an OBIS code.

func (*Spec) RoleOf

func (s *Spec) RoleOf(client uint16) (Role, bool)

RoleOf returns the role of a client SAP.

Directories

Path Synopsis
Package meter builds an IS 15959 meter from a profile of package is15959: every object, profile, event log and push setup of the profile with values a meter of that kind could show, the associations the profile defines (public client, meter reader, utility settings, firmware, push, in-home display) with their keys and access rights, and the methods that act on the meter (disconnect control with its events, the billing script, image transfer, event logs).
Package meter builds an IS 15959 meter from a profile of package is15959: every object, profile, event log and push setup of the profile with values a meter of that kind could show, the associations the profile defines (public client, meter reader, utility settings, firmware, push, in-home display) with their keys and access rights, and the methods that act on the meter (disconnect control with its events, the billing script, image transfer, event logs).

Jump to

Keyboard shortcuts

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