classes

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: 10 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 classes is the COSEM object model: the interface classes of IEC 62056-6-2 (the DLMS UA Blue Book) as data (class, version, attributes, methods, short name offsets) and as Go types a server holds and a client reads into. Class, attribute and method numbers are facts of the standard; the names and descriptions are our own wording.

A server (package server) serves any Object; the typed objects here (Register, Clock, ProfileGeneric, ...) keep their attributes as Go values and encode them on GET, decode them on SET and run their methods on ACTION. Generic holds the attributes of a class this package has no type for.

Index

Constants

View Source
const (
	Disconnected         uint8 = 0
	Connected            uint8 = 1
	ReadyForReconnection uint8 = 2
)

Disconnect control states (attribute 3 of class 70).

View Source
const (
	ImageNotInitiated          uint8 = 0
	ImageInitiated             uint8 = 1
	ImageVerificationInitiated uint8 = 2
	ImageVerificationOK        uint8 = 3
	ImageVerificationFailed    uint8 = 4
	ImageActivationInitiated   uint8 = 5
	ImageActivationOK          uint8 = 6
	ImageActivationFailed      uint8 = 7
)

Image transfer status values (attribute 6 of class 18).

Variables

This section is empty.

Functions

func DateTime

func DateTime(t time.Time, loc *time.Location) []byte

DateTime is the 12-octet COSEM date-time of t: t is shown in loc (t's own location when loc is nil), the deviation is the minutes to add to that local time to reach UTC, and the clock status has its daylight saving bit (0x80) set when loc is on summer time at t. The zero time gives the "not specified" form (every field 0xFF, deviation 0x8000).

func LNOctets

func LNOctets(ln string) ([]byte, error)

LNOctets turns a logical name written "a.b.c.d.e.f" (each 0 to 255) into its six octets.

func LNString

func LNString(b []byte) string

LNString writes six octets as "a.b.c.d.e.f". Any other length gives "".

func ObjectListEntryLN

func ObjectListEntryLN(class uint16, version uint8, ln string, attrAccess []AttributeAccess, methodAccess []MethodAccess) *axdr.DlmsData

ObjectListEntryLN is one entry of an Association LN object list: {class, version, logical name, {attribute accesses, method accesses}}.

func ObjectListEntrySN

func ObjectListEntrySN(baseName int16, class uint16, version uint8, ln string) *axdr.DlmsData

ObjectListEntrySN is one entry of an Association SN object list: {base name, class, version, logical name}.

func ParseDateTime

func ParseDateTime(b []byte, loc *time.Location) (time.Time, bool)

ParseDateTime reads a 12-octet COSEM date-time. A deviation of 0x8000 (not specified) means local time in loc (UTC when loc is nil); any other deviation fixes the instant. Unspecified hundredths count as 0. It reports false for another length or for a year, month, day, hour, minute or second that is not specified or out of range.

Types

type ActivityCalendar

type ActivityCalendar struct {
	sync.Mutex
	LN                  string
	NameActive          []byte
	SeasonActive        *axdr.DlmsData
	WeekActive          *axdr.DlmsData
	DayActive           *axdr.DlmsData
	NamePassive         []byte
	SeasonPassive       *axdr.DlmsData
	WeekPassive         *axdr.DlmsData
	DayPassive          *axdr.DlmsData
	ActivatePassiveTime []byte
}

ActivityCalendar is class 20. The profiles are kept as A-XDR arrays; the active calendar is read-only and changes only by activate_passive_calendar (1), which copies the passive one over it. ActivatePassiveTime is a 12-octet date-time (wildcards allowed).

func (*ActivityCalendar) Action

func (o *ActivityCalendar) Action(m int8, _ *axdr.DlmsData) (*axdr.DlmsData, error)

func (*ActivityCalendar) ActivatePassive

func (o *ActivityCalendar) ActivatePassive()

ActivatePassive copies the passive calendar over the active one (the caller holds the lock; the meter calls it when ActivatePassiveTime comes).

func (*ActivityCalendar) ClassID

func (o *ActivityCalendar) ClassID() uint16

func (*ActivityCalendar) Get

func (o *ActivityCalendar) Get(a int8, sel *Selector) (*axdr.DlmsData, error)

func (*ActivityCalendar) LogicalName

func (o *ActivityCalendar) LogicalName() string

func (*ActivityCalendar) Set

func (o *ActivityCalendar) Set(a int8, v *axdr.DlmsData, sel *Selector) error

func (*ActivityCalendar) Version

func (o *ActivityCalendar) Version() uint8

type AssociationLN

type AssociationLN struct {
	sync.Mutex
	LN                          string
	ObjectList                  *axdr.DlmsData
	ObjectListFunc              func() *axdr.DlmsData
	ClientSAP                   int8
	ServerSAP                   uint16
	ApplicationContextName      *axdr.DlmsData
	XDLMSContextInfo            *axdr.DlmsData
	AuthenticationMechanismName *axdr.DlmsData
	Secret                      []byte
	Status                      uint8 // 0 non-associated, 1 pending, 2 associated
	SecuritySetupReference      string
	UserList                    *axdr.DlmsData
	CurrentUser                 *axdr.DlmsData
}

AssociationLN is class 15 (version 3) as data the server fills: the server answers its methods itself, so Action is refused here. GET of the object list uses ObjectListFunc when set (the server lists what the current association may see), else ObjectList. The secret is never read back; a SET of it is allowed (a low-level-security password change). Everything else is read-only to clients.

func (*AssociationLN) Action

func (o *AssociationLN) Action(m int8, _ *axdr.DlmsData) (*axdr.DlmsData, error)

Action is refused: the server runs the association's methods.

func (*AssociationLN) ClassID

func (o *AssociationLN) ClassID() uint16

func (*AssociationLN) Get

func (o *AssociationLN) Get(a int8, sel *Selector) (*axdr.DlmsData, error)

func (*AssociationLN) LogicalName

func (o *AssociationLN) LogicalName() string

func (*AssociationLN) Set

func (o *AssociationLN) Set(a int8, v *axdr.DlmsData, sel *Selector) error

func (*AssociationLN) Version

func (o *AssociationLN) Version() uint8

type AssociationSN

type AssociationSN struct {
	sync.Mutex
	LN                     string
	ObjectList             *axdr.DlmsData
	ObjectListFunc         func() *axdr.DlmsData
	AccessRightsList       *axdr.DlmsData
	SecuritySetupReference string
	UserList               *axdr.DlmsData
	CurrentUser            *axdr.DlmsData
}

AssociationSN is class 12 (version 4) as data the server fills, like AssociationLN.

func (*AssociationSN) Action

func (o *AssociationSN) Action(m int8, _ *axdr.DlmsData) (*axdr.DlmsData, error)

Action is refused: the server runs the association's methods.

func (*AssociationSN) ClassID

func (o *AssociationSN) ClassID() uint16

func (*AssociationSN) Get

func (o *AssociationSN) Get(a int8, sel *Selector) (*axdr.DlmsData, error)

func (*AssociationSN) LogicalName

func (o *AssociationSN) LogicalName() string

func (*AssociationSN) Set

func (o *AssociationSN) Set(a int8, v *axdr.DlmsData, sel *Selector) error

func (*AssociationSN) Version

func (o *AssociationSN) Version() uint8

type Attribute

type Attribute struct {
	Index  int8
	Name   string
	Static bool
}

Attribute is one attribute of a class. Static attributes are configuration that rarely changes; the others are values that move.

type AttributeAccess

type AttributeAccess struct {
	Index     int8
	Mode      uint8
	Selectors []int8
}

AttributeAccess is the access an association has to one attribute: Mode is the attribute access mode enumeration (0 none, 1 read, 2 write, 3 read and write, higher values add authentication and ciphering requirements); Selectors lists the selective access selectors the attribute takes (nil: none, encoded as null-data).

type Binder

type Binder interface {
	Bind(r Resolver)
}

Binder is an Object that needs the other objects of its server; the server calls Bind when the object is added.

type CaptureObject

type CaptureObject struct {
	Class     uint16
	LN        string
	Attr      int8
	DataIndex uint16
}

CaptureObject is one column of a profile (or one value of a push): an attribute of another object, and with DataIndex above 0 only that element (1-based) of it.

type Class

type Class struct {
	ID         uint16
	Version    uint8
	Name       string
	Attributes []Attribute
	Methods    []Method
	// FirstMethodSN is the short-name offset of method 1 from the object's base
	// name; 0 when the class has no methods or the offset is not known
	// here (see the comment on each such class).
	FirstMethodSN uint16
}

Class is one interface class as data: its number, the version this package implements, its attributes and methods, and the short-name offset of its first method.

func All

func All() []*Class

All returns every class of the catalogue in ascending class order.

func Lookup

func Lookup(id uint16) (*Class, bool)

Lookup returns class id from the catalogue.

func (*Class) Attribute

func (c *Class) Attribute(i int8) (Attribute, bool)

Attribute returns attribute i of the class.

func (*Class) AttributeSN

func (c *Class) AttributeSN(i int8) uint16

AttributeSN is the short-name offset of attribute i from the base name.

func (*Class) Method

func (c *Class) Method(i int8) (Method, bool)

Method returns method i of the class.

func (*Class) MethodSN

func (c *Class) MethodSN(i int8) (uint16, bool)

MethodSN is the short-name offset of method i from the base name; false when the class has no such method or its method offset is not known.

type Clock

type Clock struct {
	sync.Mutex
	LN       string
	Now      func() time.Time
	Location *time.Location
	// TimeZone is the zone's distance from UTC in minutes, as the class
	// carries it; it is reported as set and does not move the time.
	TimeZone int16
	// Status is OR-ed into the clock status octet of the time (the
	// daylight saving bit comes from Location).
	Status uint8
	// DSTBegin and DSTEnd are 12-octet date-times, wildcards allowed.
	DSTBegin     []byte
	DSTEnd       []byte
	DSTDeviation int8 // minutes
	DSTEnabled   bool
	ClockBase    uint8
	// MeasuringPeriod is the period adjust_to_measuring_period rounds to;
	// that method is refused while it is 0.
	MeasuringPeriod time.Duration
	// contains filtered or unexported fields
}

Clock is class 8. Its time runs from Now (time.Now when nil) plus an offset that SETs of the time and the adjusting methods move, so a meter simulator or gateway can keep its own clock without touching the host's. The time is shown in Location (time.Local when nil).

func (*Clock) Action

func (o *Clock) Action(m int8, p *axdr.DlmsData) (*axdr.DlmsData, error)

Action runs adjust_to_quarter (1), adjust_to_measuring_period (2), adjust_to_minute (3), adjust_to_preset_time (4), preset_adjusting_time (5: {preset time, valid from, valid to}) and shift_time (6: seconds, -900 to 900).

func (*Clock) ClassID

func (o *Clock) ClassID() uint16

func (*Clock) Get

func (o *Clock) Get(a int8, sel *Selector) (*axdr.DlmsData, error)

func (*Clock) LogicalName

func (o *Clock) LogicalName() string

func (*Clock) Set

func (o *Clock) Set(a int8, v *axdr.DlmsData, sel *Selector) error

func (*Clock) SetTime

func (o *Clock) SetTime(t time.Time)

SetTime moves the clock to t.

func (*Clock) Time

func (o *Clock) Time() time.Time

Time is the clock's current time.

func (*Clock) Version

func (o *Clock) Version() uint8

type Data

type Data struct {
	sync.Mutex
	LN       string
	Value    *axdr.DlmsData
	ReadOnly bool
}

Data is class 1: one value of any type. ReadOnly refuses SETs of it.

func (*Data) Action

func (o *Data) Action(m int8, p *axdr.DlmsData) (*axdr.DlmsData, error)

func (*Data) ClassID

func (o *Data) ClassID() uint16

func (*Data) Get

func (o *Data) Get(a int8, sel *Selector) (*axdr.DlmsData, error)

func (*Data) LogicalName

func (o *Data) LogicalName() string

func (*Data) Set

func (o *Data) Set(a int8, v *axdr.DlmsData, sel *Selector) error

func (*Data) Version

func (o *Data) Version() uint8

type DemandRegister

type DemandRegister struct {
	sync.Mutex
	LN               string
	CurrentAverage   *axdr.DlmsData
	LastAverage      *axdr.DlmsData
	Scaler           int8
	Unit             uint8
	Status           *axdr.DlmsData
	CaptureTime      time.Time
	StartTimeCurrent time.Time
	Period           uint32 // seconds
	NumberOfPeriods  uint16
	Location         *time.Location
	Now              func() time.Time
}

DemandRegister is class 5: an average over a sliding period.

func (*DemandRegister) Action

func (o *DemandRegister) Action(m int8, _ *axdr.DlmsData) (*axdr.DlmsData, error)

Action runs reset (1: both averages zero, times now) and next_period (2: the current average becomes the last one and a new period starts).

func (*DemandRegister) ClassID

func (o *DemandRegister) ClassID() uint16

func (*DemandRegister) Get

func (o *DemandRegister) Get(a int8, sel *Selector) (*axdr.DlmsData, error)

func (*DemandRegister) LogicalName

func (o *DemandRegister) LogicalName() string

func (*DemandRegister) Set

func (o *DemandRegister) Set(a int8, v *axdr.DlmsData, sel *Selector) error

func (*DemandRegister) Version

func (o *DemandRegister) Version() uint8

type DisconnectControl

type DisconnectControl struct {
	sync.Mutex
	LN           string
	OutputState  bool
	ControlState uint8
	ControlMode  uint8
	OnChange     func(output bool) error
}

DisconnectControl is class 70: the supply switch. ControlMode (0 to 7) says which transitions are allowed; mode 0 keeps the switch connected and refuses the remote methods. OutputState follows the state (connected means the supply is on). OnChange, when set, is told the new output state after each change, and may refuse it (the state is then restored and the method answers with the error).

Our reading of the modes: remote disconnect works from connected and from ready in modes 1 to 7; remote reconnect leads to ready in modes 1, 3, 5 and 6 and straight to connected in 2, 4 and 7, and in mode 7 it also closes the switch from ready; manual reconnect (ready to connected) works in 1 to 7, manual disconnect in 1, 2 and 5, local disconnect in 1 to 7 and local reconnect in 5, 6 and 7. The grouping of the remote reconnect transitions per mode was checked against the control mode lists in Gurux's sources (ControlMode in Gurux.DLMS.Python and .Net), which put mode 6 with 1, 3 and 5 and define mode 7.

func (*DisconnectControl) Action

func (o *DisconnectControl) Action(m int8, _ *axdr.DlmsData) (*axdr.DlmsData, error)

Action runs remote_disconnect (1) and remote_reconnect (2).

func (*DisconnectControl) ClassID

func (o *DisconnectControl) ClassID() uint16

func (*DisconnectControl) Get

func (o *DisconnectControl) Get(a int8, sel *Selector) (*axdr.DlmsData, error)

func (*DisconnectControl) LocalDisconnect

func (o *DisconnectControl) LocalDisconnect() error

LocalDisconnect is the meter opening the switch itself (a limiter, say).

func (*DisconnectControl) LocalReconnect

func (o *DisconnectControl) LocalReconnect() error

LocalReconnect is the meter closing the switch itself.

func (*DisconnectControl) LogicalName

func (o *DisconnectControl) LogicalName() string

func (*DisconnectControl) ManualDisconnect

func (o *DisconnectControl) ManualDisconnect() error

ManualDisconnect is the customer opening the switch.

func (*DisconnectControl) ManualReconnect

func (o *DisconnectControl) ManualReconnect() error

ManualReconnect is the customer closing an armed switch.

func (*DisconnectControl) RemoteDisconnect

func (o *DisconnectControl) RemoteDisconnect() error

RemoteDisconnect opens the switch from connected or ready.

func (*DisconnectControl) RemoteReconnect

func (o *DisconnectControl) RemoteReconnect() error

RemoteReconnect arms (modes 1, 3, 5, 6) or closes (modes 2, 4, 7) the switch; in mode 7 it closes an armed switch too.

func (*DisconnectControl) Set

func (o *DisconnectControl) Set(a int8, v *axdr.DlmsData, sel *Selector) error

func (*DisconnectControl) Version

func (o *DisconnectControl) Version() uint8

type ExtendedRegister

type ExtendedRegister struct {
	sync.Mutex
	LN          string
	Value       *axdr.DlmsData
	Scaler      int8
	Unit        uint8
	Status      *axdr.DlmsData
	CaptureTime time.Time
	// Location is the meter's local time zone (time.Local when nil); Now
	// is the time source (time.Now when nil).
	Location *time.Location
	Now      func() time.Time
}

ExtendedRegister is class 4: a register with a status and the time the value was captured.

func (*ExtendedRegister) Action

func (o *ExtendedRegister) Action(m int8, _ *axdr.DlmsData) (*axdr.DlmsData, error)

Action runs reset (1): the value becomes zero and the capture time now.

func (*ExtendedRegister) ClassID

func (o *ExtendedRegister) ClassID() uint16

func (*ExtendedRegister) Get

func (o *ExtendedRegister) Get(a int8, sel *Selector) (*axdr.DlmsData, error)

func (*ExtendedRegister) LogicalName

func (o *ExtendedRegister) LogicalName() string

func (*ExtendedRegister) Set

func (o *ExtendedRegister) Set(a int8, v *axdr.DlmsData, sel *Selector) error

func (*ExtendedRegister) Version

func (o *ExtendedRegister) Version() uint8

type Generic

type Generic struct {
	sync.Mutex
	Class    uint16
	Ver      uint8
	LN       string
	Attrs    map[int8]*axdr.DlmsData
	Writable map[int8]bool
	Methods  map[int8]func(param *axdr.DlmsData) (*axdr.DlmsData, error)
}

Generic is an object of any class held as A-XDR data: Attrs by index (attribute 1 always comes from LN), Writable naming the attributes a SET may change (keeping their type), and Methods running the methods. An attribute the class has (by the catalogue) but Attrs lacks reads as null-data; one it does not have is undefined. Selective access is refused.

func (*Generic) Action

func (o *Generic) Action(m int8, p *axdr.DlmsData) (*axdr.DlmsData, error)

Action runs Methods[m]; a method the class has but Methods lacks is refused (read-write denied), one it does not have is undefined.

func (*Generic) ClassID

func (o *Generic) ClassID() uint16

func (*Generic) Get

func (o *Generic) Get(a int8, sel *Selector) (*axdr.DlmsData, error)

func (*Generic) LogicalName

func (o *Generic) LogicalName() string

func (*Generic) Set

func (o *Generic) Set(a int8, v *axdr.DlmsData, sel *Selector) error

func (*Generic) Version

func (o *Generic) Version() uint8

type IECHDLCSetup

type IECHDLCSetup struct {
	sync.Mutex
	LN                string
	CommSpeed         uint8
	WindowTransmit    uint8
	WindowReceive     uint8
	MaxInfoTransmit   uint16
	MaxInfoReceive    uint16
	InterOctetTimeout uint16 // milliseconds
	InactivityTimeout uint16 // seconds
	DeviceAddress     uint16
}

IECHDLCSetup is class 23 (version 1): the HDLC parameters of a port.

func (*IECHDLCSetup) Action

func (o *IECHDLCSetup) Action(m int8, p *axdr.DlmsData) (*axdr.DlmsData, error)

func (*IECHDLCSetup) ClassID

func (o *IECHDLCSetup) ClassID() uint16

func (*IECHDLCSetup) Get

func (o *IECHDLCSetup) Get(a int8, sel *Selector) (*axdr.DlmsData, error)

func (*IECHDLCSetup) LogicalName

func (o *IECHDLCSetup) LogicalName() string

func (*IECHDLCSetup) Set

func (o *IECHDLCSetup) Set(a int8, v *axdr.DlmsData, sel *Selector) error

func (*IECHDLCSetup) Version

func (o *IECHDLCSetup) Version() uint8

type IECLocalPortSetup

type IECLocalPortSetup struct {
	sync.Mutex
	LN            string
	DefaultMode   uint8
	DefaultBaud   uint8
	ProposedBaud  uint8
	ResponseTime  uint8
	DeviceAddress []byte
	PasswordP1    []byte
	PasswordP2    []byte
	PasswordW5    []byte
}

IECLocalPortSetup is class 19 (version 1): the optical or serial port of IEC 62056-21. Modes and baud rates are the class's enumerations.

func (*IECLocalPortSetup) Action

func (o *IECLocalPortSetup) Action(m int8, p *axdr.DlmsData) (*axdr.DlmsData, error)

func (*IECLocalPortSetup) ClassID

func (o *IECLocalPortSetup) ClassID() uint16

func (*IECLocalPortSetup) Get

func (o *IECLocalPortSetup) Get(a int8, sel *Selector) (*axdr.DlmsData, error)

func (*IECLocalPortSetup) LogicalName

func (o *IECLocalPortSetup) LogicalName() string

func (*IECLocalPortSetup) Set

func (o *IECLocalPortSetup) Set(a int8, v *axdr.DlmsData, sel *Selector) error

func (*IECLocalPortSetup) Version

func (o *IECLocalPortSetup) Version() uint8

type IPv4Setup

type IPv4Setup struct {
	sync.Mutex
	LN                string
	DataLinkReference string
	IPAddress         uint32
	Multicast         []uint32
	IPOptions         *axdr.DlmsData
	SubnetMask        uint32
	Gateway           uint32
	UseDHCP           bool
	PrimaryDNS        uint32
	SecondaryDNS      uint32
}

IPv4Setup is class 42. Addresses are 32-bit numbers, most significant octet first (192.0.2.1 is 0xC0000201). IPOptions is kept as A-XDR data.

func (*IPv4Setup) Action

func (o *IPv4Setup) Action(m int8, p *axdr.DlmsData) (*axdr.DlmsData, error)

Action adds (1) or deletes (2) a multicast address and returns the number of them (3).

func (*IPv4Setup) ClassID

func (o *IPv4Setup) ClassID() uint16

func (*IPv4Setup) Get

func (o *IPv4Setup) Get(a int8, sel *Selector) (*axdr.DlmsData, error)

func (*IPv4Setup) LogicalName

func (o *IPv4Setup) LogicalName() string

func (*IPv4Setup) Set

func (o *IPv4Setup) Set(a int8, v *axdr.DlmsData, sel *Selector) error

func (*IPv4Setup) Version

func (o *IPv4Setup) Version() uint8

type ImageTransfer

type ImageTransfer struct {
	sync.Mutex
	LN        string
	BlockSize uint32
	Enabled   bool
	Status    uint8
	// Signature is reported in to_activate_info with the image.
	Signature  []byte
	OnVerify   func(id, image []byte) error
	OnActivate func(id, image []byte) error
	// contains filtered or unexported fields
}

ImageTransfer is class 18: a firmware or other image sent in blocks, then verified and activated. The image is assembled in memory; OnVerify and OnActivate (when set) decide whether verification and activation succeed. Verification is done at once, so a verify answers with the final status rather than "in progress".

func (*ImageTransfer) Action

func (o *ImageTransfer) Action(m int8, p *axdr.DlmsData) (*axdr.DlmsData, error)

Action runs image_transfer_initiate (1: {identifier, size}), image_block_transfer (2: {block number, block}), image_verify (3) and image_activate (4; a complete image not yet verified is verified first).

func (*ImageTransfer) ClassID

func (o *ImageTransfer) ClassID() uint16

func (*ImageTransfer) Get

func (o *ImageTransfer) Get(a int8, sel *Selector) (*axdr.DlmsData, error)

func (*ImageTransfer) Image

func (o *ImageTransfer) Image() (id, image []byte)

Image returns the identifier and the bytes received so far.

func (*ImageTransfer) LogicalName

func (o *ImageTransfer) LogicalName() string

func (*ImageTransfer) Set

func (o *ImageTransfer) Set(a int8, v *axdr.DlmsData, sel *Selector) error

func (*ImageTransfer) Version

func (o *ImageTransfer) Version() uint8

type Limiter

type Limiter struct {
	sync.Mutex
	LN                     string
	MonitoredValue         ValueRef
	ThresholdActive        *axdr.DlmsData
	ThresholdNormal        *axdr.DlmsData
	ThresholdEmergency     *axdr.DlmsData
	MinOverDuration        uint32 // seconds
	MinUnderDuration       uint32 // seconds
	EmergencyProfile       *axdr.DlmsData
	EmergencyGroupIDs      *axdr.DlmsData
	EmergencyProfileActive bool
	Actions                *axdr.DlmsData
}

Limiter is class 71: thresholds on a monitored value with scripts for going over and under. The structured attributes are kept as A-XDR data; EmergencyProfileActive is the meter's to set.

func (*Limiter) Action

func (o *Limiter) Action(m int8, p *axdr.DlmsData) (*axdr.DlmsData, error)

func (*Limiter) ClassID

func (o *Limiter) ClassID() uint16

func (*Limiter) Get

func (o *Limiter) Get(a int8, sel *Selector) (*axdr.DlmsData, error)

func (*Limiter) LogicalName

func (o *Limiter) LogicalName() string

func (*Limiter) Set

func (o *Limiter) Set(a int8, v *axdr.DlmsData, sel *Selector) error

func (*Limiter) Version

func (o *Limiter) Version() uint8

type Method

type Method struct {
	Index int8
	Name  string
}

Method is one method of a class.

type MethodAccess

type MethodAccess struct {
	Index int8
	Mode  uint8
}

MethodAccess is the access an association has to one method: Mode 0 is no access, 1 access, higher values add security requirements.

type MonitorAction

type MonitorAction struct {
	Up, Down ScriptRef
}

MonitorAction is the pair of scripts of one threshold.

type Object

type Object interface {
	// ClassID and Version name the interface class; LogicalName is the
	// object's OBIS code as "a.b.c.d.e.f".
	ClassID() uint16
	Version() uint8
	LogicalName() string
	// Get returns attribute attr; sel, when not nil, is the selective
	// access the client asked for. Errors are Result values (other errors
	// are answered as other-reason).
	Get(attr int8, sel *Selector) (*axdr.DlmsData, error)
	// Set writes attribute attr.
	Set(attr int8, v *axdr.DlmsData, sel *Selector) error
	// Action runs method m with its parameter (nil: none) and returns the
	// method's return parameter (nil: none).
	Action(m int8, param *axdr.DlmsData) (*axdr.DlmsData, error)
}

Object is one COSEM object (an instance of an interface class).

type ObjectListItem

type ObjectListItem struct {
	Class      uint16
	Version    uint8
	LN         string
	BaseName   int16
	Attributes []AttributeAccess
	Methods    []MethodAccess
}

ObjectListItem is one decoded entry of an object list. BaseName is set for short name lists; the access lists for logical name lists.

func ParseObjectListLN

func ParseObjectListLN(d axdr.DlmsData) ([]ObjectListItem, error)

ParseObjectListLN decodes an Association LN object list (attribute 2).

func ParseObjectListSN

func ParseObjectListSN(d axdr.DlmsData) ([]ObjectListItem, error)

ParseObjectListSN decodes an Association SN object list (attribute 2).

type ProfileGeneric

type ProfileGeneric struct {
	sync.Mutex
	LN             string
	Buffer         [][]*axdr.DlmsData
	CaptureObjects []CaptureObject
	CapturePeriod  uint32 // seconds; 0: captured only on request
	SortMethod     uint8
	SortObject     CaptureObject
	ProfileEntries uint32
	// Location is the meter's time zone for date-times without a
	// deviation (time.Local when nil).
	Location *time.Location
	// contains filtered or unexported fields
}

ProfileGeneric is class 7: a buffer of rows, each row one capture of the capture objects. Rows are kept oldest first; once ProfileEntries (when above 0) is reached a capture drops the oldest row. Only that first-in first-out order is implemented; SortMethod and SortObject are kept and reported but do not reorder the buffer.

Reading the buffer takes selective access by range (selector 1: rows whose restricting column lies between two values, date-times or numbers) and by entry (selector 2: a window of rows and columns, 1-based, 0 meaning "to the last").

func (*ProfileGeneric) Action

func (o *ProfileGeneric) Action(m int8, _ *axdr.DlmsData) (*axdr.DlmsData, error)

Action runs reset (1: the buffer is emptied) and capture (2).

func (*ProfileGeneric) Bind

func (o *ProfileGeneric) Bind(r Resolver)

Bind keeps the server's resolver for captures.

func (*ProfileGeneric) Capture

func (o *ProfileGeneric) Capture() error

Capture reads every capture object through the server and appends the row. It reports TemporaryFailure before Bind, and the first error of a read (no row is added then).

func (*ProfileGeneric) ClassID

func (o *ProfileGeneric) ClassID() uint16

func (*ProfileGeneric) Get

func (o *ProfileGeneric) Get(a int8, sel *Selector) (*axdr.DlmsData, error)

func (*ProfileGeneric) LogicalName

func (o *ProfileGeneric) LogicalName() string

func (*ProfileGeneric) Set

func (o *ProfileGeneric) Set(a int8, v *axdr.DlmsData, sel *Selector) error

func (*ProfileGeneric) Version

func (o *ProfileGeneric) Version() uint8

type PushDestination

type PushDestination struct {
	Transport uint8
	Address   []byte
	Message   uint8
}

PushDestination is where and how a push goes: the transport service and message type are the class's enumerations, Address the destination (for TCP, "host:port" as octets).

type PushSetup

type PushSetup struct {
	sync.Mutex
	LN                         string
	PushObjectList             []CaptureObject
	Destination                PushDestination
	CommunicationWindow        *axdr.DlmsData
	RandomisationStartInterval uint16 // seconds
	NumberOfRetries            uint8
	RepetitionDelay            uint16 // seconds
	OnPush                     func(values []*axdr.DlmsData) error
	// contains filtered or unexported fields
}

PushSetup is class 40 (version 0). push (1) reads the push object list through the server and hands the values to OnPush, which sends them. CommunicationWindow is kept as A-XDR data (an array of {start, end}).

func (*PushSetup) Action

func (o *PushSetup) Action(m int8, _ *axdr.DlmsData) (*axdr.DlmsData, error)

Action runs push (1).

func (*PushSetup) Bind

func (o *PushSetup) Bind(r Resolver)

Bind keeps the server's resolver for pushes.

func (*PushSetup) ClassID

func (o *PushSetup) ClassID() uint16

func (*PushSetup) Get

func (o *PushSetup) Get(a int8, sel *Selector) (*axdr.DlmsData, error)

func (*PushSetup) LogicalName

func (o *PushSetup) LogicalName() string

func (*PushSetup) Set

func (o *PushSetup) Set(a int8, v *axdr.DlmsData, sel *Selector) error

func (*PushSetup) Values

func (o *PushSetup) Values() ([]*axdr.DlmsData, error)

Values reads the push object list through the server.

func (*PushSetup) Version

func (o *PushSetup) Version() uint8

type Register

type Register struct {
	sync.Mutex
	LN     string
	Value  *axdr.DlmsData
	Scaler int8
	Unit   uint8
}

Register is class 3: a value with its scaler and unit.

func (*Register) Action

func (o *Register) Action(m int8, _ *axdr.DlmsData) (*axdr.DlmsData, error)

Action runs reset (1): the value becomes zero of its type.

func (*Register) ClassID

func (o *Register) ClassID() uint16

func (*Register) Get

func (o *Register) Get(a int8, sel *Selector) (*axdr.DlmsData, error)

func (*Register) LogicalName

func (o *Register) LogicalName() string

func (*Register) Set

func (o *Register) Set(a int8, v *axdr.DlmsData, sel *Selector) error

func (*Register) Version

func (o *Register) Version() uint8

type RegisterActivation

type RegisterActivation struct {
	sync.Mutex
	LN                 string
	RegisterAssignment *axdr.DlmsData
	MaskList           *axdr.DlmsData
	ActiveMask         []byte
}

RegisterActivation is class 6: register assignments and masks of them. RegisterAssignment is an array of {class, logical name}; MaskList an array of {mask name, array of indexes}.

func (*RegisterActivation) Action

func (o *RegisterActivation) Action(m int8, p *axdr.DlmsData) (*axdr.DlmsData, error)

Action runs add_register (1), add_mask (2, replacing a mask of the same name) and delete_mask (3).

func (*RegisterActivation) ClassID

func (o *RegisterActivation) ClassID() uint16

func (*RegisterActivation) Get

func (o *RegisterActivation) Get(a int8, sel *Selector) (*axdr.DlmsData, error)

func (*RegisterActivation) LogicalName

func (o *RegisterActivation) LogicalName() string

func (*RegisterActivation) Set

func (o *RegisterActivation) Set(a int8, v *axdr.DlmsData, sel *Selector) error

func (*RegisterActivation) Version

func (o *RegisterActivation) Version() uint8

type RegisterMonitor

type RegisterMonitor struct {
	sync.Mutex
	LN             string
	Thresholds     *axdr.DlmsData // array of values
	MonitoredValue ValueRef
	Actions        []MonitorAction
	OnScript       func(s ScriptRef) error
	// contains filtered or unexported fields
}

RegisterMonitor is class 21: thresholds on another object's value, with a script to run when the value crosses each one upwards or downwards. Check reads the value through the server and calls OnScript on each crossing.

func (*RegisterMonitor) Action

func (o *RegisterMonitor) Action(m int8, p *axdr.DlmsData) (*axdr.DlmsData, error)

func (*RegisterMonitor) Bind

func (o *RegisterMonitor) Bind(r Resolver)

Bind keeps the server's resolver for Check.

func (*RegisterMonitor) Check

func (o *RegisterMonitor) Check() error

Check reads the monitored value and runs the up script of every threshold it has risen above and the down script of every threshold it has fallen to or below since the last Check (the first Check compares with "below every threshold").

func (*RegisterMonitor) ClassID

func (o *RegisterMonitor) ClassID() uint16

func (*RegisterMonitor) Get

func (o *RegisterMonitor) Get(a int8, sel *Selector) (*axdr.DlmsData, error)

func (*RegisterMonitor) LogicalName

func (o *RegisterMonitor) LogicalName() string

func (*RegisterMonitor) Set

func (o *RegisterMonitor) Set(a int8, v *axdr.DlmsData, sel *Selector) error

func (*RegisterMonitor) Version

func (o *RegisterMonitor) Version() uint8

type Resolver

type Resolver interface {
	Resolve(class uint16, ln string, attr int8) (*axdr.DlmsData, error)
}

Resolver reads attributes of other objects of the same server (a profile capturing registers, a register monitor watching a value).

type Result

type Result uint8

Result is a data access result or action result (the two share their codes): an error an Object returns to have the server answer with that code.

const (
	Success            Result = 0
	HardwareFault      Result = 1
	TemporaryFailure   Result = 2
	ReadWriteDenied    Result = 3
	ObjectUndefined    Result = 4
	ClassInconsistent  Result = 9
	ObjectUnavailable  Result = 11
	TypeUnmatched      Result = 12
	ScopeViolated      Result = 13
	BlockUnavailable   Result = 14
	LongAborted        Result = 15
	NoLongInProgress   Result = 16
	LongSetAborted     Result = 17
	NoLongSetProgress  Result = 18
	BlockNumberInvalid Result = 19
	OtherReason        Result = 250
)

Results.

func ResultOf

func ResultOf(err error) Result

ResultOf is the result code an error from an Object stands for.

func (Result) Error

func (r Result) Error() string

type SAPAssignment

type SAPAssignment struct {
	sync.Mutex
	LN   string
	List []SAPEntry
}

SAPAssignment is class 17: the logical devices of a physical device. connect_logical_device (1) adds or renames one by SAP, and removes it when the name is empty.

func (*SAPAssignment) Action

func (o *SAPAssignment) Action(m int8, p *axdr.DlmsData) (*axdr.DlmsData, error)

func (*SAPAssignment) ClassID

func (o *SAPAssignment) ClassID() uint16

func (*SAPAssignment) Get

func (o *SAPAssignment) Get(a int8, sel *Selector) (*axdr.DlmsData, error)

func (*SAPAssignment) LogicalName

func (o *SAPAssignment) LogicalName() string

func (*SAPAssignment) Set

func (o *SAPAssignment) Set(a int8, v *axdr.DlmsData, sel *Selector) error

func (*SAPAssignment) Version

func (o *SAPAssignment) Version() uint8

type SAPEntry

type SAPEntry struct {
	SAP  uint16
	Name []byte
}

SAPEntry is one logical device of a SAP assignment: its address and its name (an octet string, usually printable text).

type Schedule

type Schedule struct {
	sync.Mutex
	LN      string
	Entries *axdr.DlmsData
}

Schedule is class 10. Entries is an array of entry structures whose first element is the entry's index (long-unsigned). insert (2) adds or replaces an entry; delete (3, {first, last}) removes a range of indexes. enable_disable (1) is refused: it is not implemented here.

func (*Schedule) Action

func (o *Schedule) Action(m int8, p *axdr.DlmsData) (*axdr.DlmsData, error)

func (*Schedule) ClassID

func (o *Schedule) ClassID() uint16

func (*Schedule) Get

func (o *Schedule) Get(a int8, sel *Selector) (*axdr.DlmsData, error)

func (*Schedule) LogicalName

func (o *Schedule) LogicalName() string

func (*Schedule) Set

func (o *Schedule) Set(a int8, v *axdr.DlmsData, sel *Selector) error

func (*Schedule) Version

func (o *Schedule) Version() uint8

type ScriptRef

type ScriptRef struct {
	LN       string
	Selector uint16
}

ScriptRef names a script: the script table's logical name and the script's number in it.

type ScriptTable

type ScriptTable struct {
	sync.Mutex
	LN        string
	Scripts   *axdr.DlmsData
	OnExecute func(id uint16) error
}

ScriptTable is class 9. Scripts is kept as A-XDR data (an array of {script id, actions}); execute (1) calls OnExecute with the script id.

func (*ScriptTable) Action

func (o *ScriptTable) Action(m int8, p *axdr.DlmsData) (*axdr.DlmsData, error)

Action runs execute (1, the script id as long-unsigned).

func (*ScriptTable) ClassID

func (o *ScriptTable) ClassID() uint16

func (*ScriptTable) Get

func (o *ScriptTable) Get(a int8, sel *Selector) (*axdr.DlmsData, error)

func (*ScriptTable) LogicalName

func (o *ScriptTable) LogicalName() string

func (*ScriptTable) Set

func (o *ScriptTable) Set(a int8, v *axdr.DlmsData, sel *Selector) error

func (*ScriptTable) Version

func (o *ScriptTable) Version() uint8

type SecuritySetup

type SecuritySetup struct {
	sync.Mutex
	LN                string
	SecurityPolicy    uint8
	SecuritySuite     uint8
	ClientSystemTitle []byte
	ServerSystemTitle []byte
	Certificates      *axdr.DlmsData

	// OnActivate approves a new security policy (security_activate, 1);
	// nil accepts it.
	OnActivate func(policy uint8) error
	// OnKeyTransfer receives the wrapped keys of key_transfer (2).
	OnKeyTransfer func(param *axdr.DlmsData) error
	// OnKeyAgreement runs key_agreement (3) and returns its answer.
	OnKeyAgreement func(param *axdr.DlmsData) (*axdr.DlmsData, error)
	// OnCertificate runs methods 4 to 8 (key pair generation, certificate
	// request, import, export, removal).
	OnCertificate func(method int8, param *axdr.DlmsData) (*axdr.DlmsData, error)
}

SecuritySetup is class 64 (version 1). Its methods hand their parameters to the func fields, which hold the keys and certificates; a method whose func is nil is refused (read-write denied). Certificates is kept as A-XDR data and is the meter's to fill.

func (*SecuritySetup) Action

func (o *SecuritySetup) Action(m int8, p *axdr.DlmsData) (*axdr.DlmsData, error)

func (*SecuritySetup) ClassID

func (o *SecuritySetup) ClassID() uint16

func (*SecuritySetup) Get

func (o *SecuritySetup) Get(a int8, sel *Selector) (*axdr.DlmsData, error)

func (*SecuritySetup) LogicalName

func (o *SecuritySetup) LogicalName() string

func (*SecuritySetup) Set

func (o *SecuritySetup) Set(a int8, v *axdr.DlmsData, sel *Selector) error

func (*SecuritySetup) Version

func (o *SecuritySetup) Version() uint8

type Selector

type Selector struct {
	ID         uint8
	Parameters *axdr.DlmsData
}

Selector is a selective access descriptor: the access selector and its parameters.

type SingleActionSchedule

type SingleActionSchedule struct {
	sync.Mutex
	LN             string
	ExecutedScript ScriptRef
	Type           uint8
	ExecutionTime  *axdr.DlmsData
}

SingleActionSchedule is class 22: a script run at given times. ExecutionTime is an array of {time, date} octet strings.

func (*SingleActionSchedule) Action

func (o *SingleActionSchedule) Action(m int8, p *axdr.DlmsData) (*axdr.DlmsData, error)

func (*SingleActionSchedule) ClassID

func (o *SingleActionSchedule) ClassID() uint16

func (*SingleActionSchedule) Get

func (o *SingleActionSchedule) Get(a int8, sel *Selector) (*axdr.DlmsData, error)

func (*SingleActionSchedule) LogicalName

func (o *SingleActionSchedule) LogicalName() string

func (*SingleActionSchedule) Set

func (o *SingleActionSchedule) Set(a int8, v *axdr.DlmsData, sel *Selector) error

func (*SingleActionSchedule) Version

func (o *SingleActionSchedule) Version() uint8

type SpecialDay

type SpecialDay struct {
	Index uint16
	Date  []byte
	DayID uint8
}

SpecialDay is one entry of a special days table: Date is the 5-octet COSEM date (wildcards allowed), DayID the day profile to use.

type SpecialDaysTable

type SpecialDaysTable struct {
	sync.Mutex
	LN      string
	Entries []SpecialDay
}

SpecialDaysTable is class 11: insert (1) adds or replaces an entry by index, delete (2) removes one by index.

func (*SpecialDaysTable) Action

func (o *SpecialDaysTable) Action(m int8, p *axdr.DlmsData) (*axdr.DlmsData, error)

func (*SpecialDaysTable) ClassID

func (o *SpecialDaysTable) ClassID() uint16

func (*SpecialDaysTable) Get

func (o *SpecialDaysTable) Get(a int8, sel *Selector) (*axdr.DlmsData, error)

func (*SpecialDaysTable) LogicalName

func (o *SpecialDaysTable) LogicalName() string

func (*SpecialDaysTable) Set

func (o *SpecialDaysTable) Set(a int8, v *axdr.DlmsData, sel *Selector) error

func (*SpecialDaysTable) Version

func (o *SpecialDaysTable) Version() uint8

type TCPUDPSetup

type TCPUDPSetup struct {
	sync.Mutex
	LN                string
	Port              uint16
	IPReference       string
	MSS               uint16
	MaxConnections    uint8
	InactivityTimeout uint16 // seconds
}

TCPUDPSetup is class 41.

func (*TCPUDPSetup) Action

func (o *TCPUDPSetup) Action(m int8, p *axdr.DlmsData) (*axdr.DlmsData, error)

func (*TCPUDPSetup) ClassID

func (o *TCPUDPSetup) ClassID() uint16

func (*TCPUDPSetup) Get

func (o *TCPUDPSetup) Get(a int8, sel *Selector) (*axdr.DlmsData, error)

func (*TCPUDPSetup) LogicalName

func (o *TCPUDPSetup) LogicalName() string

func (*TCPUDPSetup) Set

func (o *TCPUDPSetup) Set(a int8, v *axdr.DlmsData, sel *Selector) error

func (*TCPUDPSetup) Version

func (o *TCPUDPSetup) Version() uint8

type ValueRef

type ValueRef struct {
	Class uint16
	LN    string
	Attr  int8
}

ValueRef points at one attribute of another object (a monitored or captured value).

Jump to

Keyboard shortcuts

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