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
- func DateTime(t time.Time, loc *time.Location) []byte
- func LNOctets(ln string) ([]byte, error)
- func LNString(b []byte) string
- func ObjectListEntryLN(class uint16, version uint8, ln string, attrAccess []AttributeAccess, ...) *axdr.DlmsData
- func ObjectListEntrySN(baseName int16, class uint16, version uint8, ln string) *axdr.DlmsData
- func ParseDateTime(b []byte, loc *time.Location) (time.Time, bool)
- type ActivityCalendar
- func (o *ActivityCalendar) Action(m int8, _ *axdr.DlmsData) (*axdr.DlmsData, error)
- func (o *ActivityCalendar) ActivatePassive()
- func (o *ActivityCalendar) ClassID() uint16
- func (o *ActivityCalendar) Get(a int8, sel *Selector) (*axdr.DlmsData, error)
- func (o *ActivityCalendar) LogicalName() string
- func (o *ActivityCalendar) Set(a int8, v *axdr.DlmsData, sel *Selector) error
- func (o *ActivityCalendar) Version() uint8
- type AssociationLN
- func (o *AssociationLN) Action(m int8, _ *axdr.DlmsData) (*axdr.DlmsData, error)
- func (o *AssociationLN) ClassID() uint16
- func (o *AssociationLN) Get(a int8, sel *Selector) (*axdr.DlmsData, error)
- func (o *AssociationLN) LogicalName() string
- func (o *AssociationLN) Set(a int8, v *axdr.DlmsData, sel *Selector) error
- func (o *AssociationLN) Version() uint8
- type AssociationSN
- func (o *AssociationSN) Action(m int8, _ *axdr.DlmsData) (*axdr.DlmsData, error)
- func (o *AssociationSN) ClassID() uint16
- func (o *AssociationSN) Get(a int8, sel *Selector) (*axdr.DlmsData, error)
- func (o *AssociationSN) LogicalName() string
- func (o *AssociationSN) Set(a int8, v *axdr.DlmsData, sel *Selector) error
- func (o *AssociationSN) Version() uint8
- type Attribute
- type AttributeAccess
- type Binder
- type CaptureObject
- type Class
- type Clock
- func (o *Clock) Action(m int8, p *axdr.DlmsData) (*axdr.DlmsData, error)
- func (o *Clock) ClassID() uint16
- func (o *Clock) Get(a int8, sel *Selector) (*axdr.DlmsData, error)
- func (o *Clock) LogicalName() string
- func (o *Clock) Set(a int8, v *axdr.DlmsData, sel *Selector) error
- func (o *Clock) SetTime(t time.Time)
- func (o *Clock) Time() time.Time
- func (o *Clock) Version() uint8
- type Data
- func (o *Data) Action(m int8, p *axdr.DlmsData) (*axdr.DlmsData, error)
- func (o *Data) ClassID() uint16
- func (o *Data) Get(a int8, sel *Selector) (*axdr.DlmsData, error)
- func (o *Data) LogicalName() string
- func (o *Data) Set(a int8, v *axdr.DlmsData, sel *Selector) error
- func (o *Data) Version() uint8
- type DemandRegister
- func (o *DemandRegister) Action(m int8, _ *axdr.DlmsData) (*axdr.DlmsData, error)
- func (o *DemandRegister) ClassID() uint16
- func (o *DemandRegister) Get(a int8, sel *Selector) (*axdr.DlmsData, error)
- func (o *DemandRegister) LogicalName() string
- func (o *DemandRegister) Set(a int8, v *axdr.DlmsData, sel *Selector) error
- func (o *DemandRegister) Version() uint8
- type DisconnectControl
- func (o *DisconnectControl) Action(m int8, _ *axdr.DlmsData) (*axdr.DlmsData, error)
- func (o *DisconnectControl) ClassID() uint16
- func (o *DisconnectControl) Get(a int8, sel *Selector) (*axdr.DlmsData, error)
- func (o *DisconnectControl) LocalDisconnect() error
- func (o *DisconnectControl) LocalReconnect() error
- func (o *DisconnectControl) LogicalName() string
- func (o *DisconnectControl) ManualDisconnect() error
- func (o *DisconnectControl) ManualReconnect() error
- func (o *DisconnectControl) RemoteDisconnect() error
- func (o *DisconnectControl) RemoteReconnect() error
- func (o *DisconnectControl) Set(a int8, v *axdr.DlmsData, sel *Selector) error
- func (o *DisconnectControl) Version() uint8
- type ExtendedRegister
- func (o *ExtendedRegister) Action(m int8, _ *axdr.DlmsData) (*axdr.DlmsData, error)
- func (o *ExtendedRegister) ClassID() uint16
- func (o *ExtendedRegister) Get(a int8, sel *Selector) (*axdr.DlmsData, error)
- func (o *ExtendedRegister) LogicalName() string
- func (o *ExtendedRegister) Set(a int8, v *axdr.DlmsData, sel *Selector) error
- func (o *ExtendedRegister) Version() uint8
- type Generic
- func (o *Generic) Action(m int8, p *axdr.DlmsData) (*axdr.DlmsData, error)
- func (o *Generic) ClassID() uint16
- func (o *Generic) Get(a int8, sel *Selector) (*axdr.DlmsData, error)
- func (o *Generic) LogicalName() string
- func (o *Generic) Set(a int8, v *axdr.DlmsData, sel *Selector) error
- func (o *Generic) Version() uint8
- type IECHDLCSetup
- func (o *IECHDLCSetup) Action(m int8, p *axdr.DlmsData) (*axdr.DlmsData, error)
- func (o *IECHDLCSetup) ClassID() uint16
- func (o *IECHDLCSetup) Get(a int8, sel *Selector) (*axdr.DlmsData, error)
- func (o *IECHDLCSetup) LogicalName() string
- func (o *IECHDLCSetup) Set(a int8, v *axdr.DlmsData, sel *Selector) error
- func (o *IECHDLCSetup) Version() uint8
- type IECLocalPortSetup
- func (o *IECLocalPortSetup) Action(m int8, p *axdr.DlmsData) (*axdr.DlmsData, error)
- func (o *IECLocalPortSetup) ClassID() uint16
- func (o *IECLocalPortSetup) Get(a int8, sel *Selector) (*axdr.DlmsData, error)
- func (o *IECLocalPortSetup) LogicalName() string
- func (o *IECLocalPortSetup) Set(a int8, v *axdr.DlmsData, sel *Selector) error
- func (o *IECLocalPortSetup) Version() uint8
- type IPv4Setup
- func (o *IPv4Setup) Action(m int8, p *axdr.DlmsData) (*axdr.DlmsData, error)
- func (o *IPv4Setup) ClassID() uint16
- func (o *IPv4Setup) Get(a int8, sel *Selector) (*axdr.DlmsData, error)
- func (o *IPv4Setup) LogicalName() string
- func (o *IPv4Setup) Set(a int8, v *axdr.DlmsData, sel *Selector) error
- func (o *IPv4Setup) Version() uint8
- type ImageTransfer
- func (o *ImageTransfer) Action(m int8, p *axdr.DlmsData) (*axdr.DlmsData, error)
- func (o *ImageTransfer) ClassID() uint16
- func (o *ImageTransfer) Get(a int8, sel *Selector) (*axdr.DlmsData, error)
- func (o *ImageTransfer) Image() (id, image []byte)
- func (o *ImageTransfer) LogicalName() string
- func (o *ImageTransfer) Set(a int8, v *axdr.DlmsData, sel *Selector) error
- func (o *ImageTransfer) Version() uint8
- type Limiter
- func (o *Limiter) Action(m int8, p *axdr.DlmsData) (*axdr.DlmsData, error)
- func (o *Limiter) ClassID() uint16
- func (o *Limiter) Get(a int8, sel *Selector) (*axdr.DlmsData, error)
- func (o *Limiter) LogicalName() string
- func (o *Limiter) Set(a int8, v *axdr.DlmsData, sel *Selector) error
- func (o *Limiter) Version() uint8
- type Method
- type MethodAccess
- type MonitorAction
- type Object
- type ObjectListItem
- type ProfileGeneric
- func (o *ProfileGeneric) Action(m int8, _ *axdr.DlmsData) (*axdr.DlmsData, error)
- func (o *ProfileGeneric) Bind(r Resolver)
- func (o *ProfileGeneric) Capture() error
- func (o *ProfileGeneric) ClassID() uint16
- func (o *ProfileGeneric) Get(a int8, sel *Selector) (*axdr.DlmsData, error)
- func (o *ProfileGeneric) LogicalName() string
- func (o *ProfileGeneric) Set(a int8, v *axdr.DlmsData, sel *Selector) error
- func (o *ProfileGeneric) Version() uint8
- type PushDestination
- type PushSetup
- func (o *PushSetup) Action(m int8, _ *axdr.DlmsData) (*axdr.DlmsData, error)
- func (o *PushSetup) Bind(r Resolver)
- func (o *PushSetup) ClassID() uint16
- func (o *PushSetup) Get(a int8, sel *Selector) (*axdr.DlmsData, error)
- func (o *PushSetup) LogicalName() string
- func (o *PushSetup) Set(a int8, v *axdr.DlmsData, sel *Selector) error
- func (o *PushSetup) Values() ([]*axdr.DlmsData, error)
- func (o *PushSetup) Version() uint8
- type Register
- func (o *Register) Action(m int8, _ *axdr.DlmsData) (*axdr.DlmsData, error)
- func (o *Register) ClassID() uint16
- func (o *Register) Get(a int8, sel *Selector) (*axdr.DlmsData, error)
- func (o *Register) LogicalName() string
- func (o *Register) Set(a int8, v *axdr.DlmsData, sel *Selector) error
- func (o *Register) Version() uint8
- type RegisterActivation
- func (o *RegisterActivation) Action(m int8, p *axdr.DlmsData) (*axdr.DlmsData, error)
- func (o *RegisterActivation) ClassID() uint16
- func (o *RegisterActivation) Get(a int8, sel *Selector) (*axdr.DlmsData, error)
- func (o *RegisterActivation) LogicalName() string
- func (o *RegisterActivation) Set(a int8, v *axdr.DlmsData, sel *Selector) error
- func (o *RegisterActivation) Version() uint8
- type RegisterMonitor
- func (o *RegisterMonitor) Action(m int8, p *axdr.DlmsData) (*axdr.DlmsData, error)
- func (o *RegisterMonitor) Bind(r Resolver)
- func (o *RegisterMonitor) Check() error
- func (o *RegisterMonitor) ClassID() uint16
- func (o *RegisterMonitor) Get(a int8, sel *Selector) (*axdr.DlmsData, error)
- func (o *RegisterMonitor) LogicalName() string
- func (o *RegisterMonitor) Set(a int8, v *axdr.DlmsData, sel *Selector) error
- func (o *RegisterMonitor) Version() uint8
- type Resolver
- type Result
- type SAPAssignment
- func (o *SAPAssignment) Action(m int8, p *axdr.DlmsData) (*axdr.DlmsData, error)
- func (o *SAPAssignment) ClassID() uint16
- func (o *SAPAssignment) Get(a int8, sel *Selector) (*axdr.DlmsData, error)
- func (o *SAPAssignment) LogicalName() string
- func (o *SAPAssignment) Set(a int8, v *axdr.DlmsData, sel *Selector) error
- func (o *SAPAssignment) Version() uint8
- type SAPEntry
- type Schedule
- func (o *Schedule) Action(m int8, p *axdr.DlmsData) (*axdr.DlmsData, error)
- func (o *Schedule) ClassID() uint16
- func (o *Schedule) Get(a int8, sel *Selector) (*axdr.DlmsData, error)
- func (o *Schedule) LogicalName() string
- func (o *Schedule) Set(a int8, v *axdr.DlmsData, sel *Selector) error
- func (o *Schedule) Version() uint8
- type ScriptRef
- type ScriptTable
- func (o *ScriptTable) Action(m int8, p *axdr.DlmsData) (*axdr.DlmsData, error)
- func (o *ScriptTable) ClassID() uint16
- func (o *ScriptTable) Get(a int8, sel *Selector) (*axdr.DlmsData, error)
- func (o *ScriptTable) LogicalName() string
- func (o *ScriptTable) Set(a int8, v *axdr.DlmsData, sel *Selector) error
- func (o *ScriptTable) Version() uint8
- type SecuritySetup
- func (o *SecuritySetup) Action(m int8, p *axdr.DlmsData) (*axdr.DlmsData, error)
- func (o *SecuritySetup) ClassID() uint16
- func (o *SecuritySetup) Get(a int8, sel *Selector) (*axdr.DlmsData, error)
- func (o *SecuritySetup) LogicalName() string
- func (o *SecuritySetup) Set(a int8, v *axdr.DlmsData, sel *Selector) error
- func (o *SecuritySetup) Version() uint8
- type Selector
- type SingleActionSchedule
- func (o *SingleActionSchedule) Action(m int8, p *axdr.DlmsData) (*axdr.DlmsData, error)
- func (o *SingleActionSchedule) ClassID() uint16
- func (o *SingleActionSchedule) Get(a int8, sel *Selector) (*axdr.DlmsData, error)
- func (o *SingleActionSchedule) LogicalName() string
- func (o *SingleActionSchedule) Set(a int8, v *axdr.DlmsData, sel *Selector) error
- func (o *SingleActionSchedule) Version() uint8
- type SpecialDay
- type SpecialDaysTable
- func (o *SpecialDaysTable) Action(m int8, p *axdr.DlmsData) (*axdr.DlmsData, error)
- func (o *SpecialDaysTable) ClassID() uint16
- func (o *SpecialDaysTable) Get(a int8, sel *Selector) (*axdr.DlmsData, error)
- func (o *SpecialDaysTable) LogicalName() string
- func (o *SpecialDaysTable) Set(a int8, v *axdr.DlmsData, sel *Selector) error
- func (o *SpecialDaysTable) Version() uint8
- type TCPUDPSetup
- func (o *TCPUDPSetup) Action(m int8, p *axdr.DlmsData) (*axdr.DlmsData, error)
- func (o *TCPUDPSetup) ClassID() uint16
- func (o *TCPUDPSetup) Get(a int8, sel *Selector) (*axdr.DlmsData, error)
- func (o *TCPUDPSetup) LogicalName() string
- func (o *TCPUDPSetup) Set(a int8, v *axdr.DlmsData, sel *Selector) error
- func (o *TCPUDPSetup) Version() uint8
- type ValueRef
Constants ¶
const ( Disconnected uint8 = 0 Connected uint8 = 1 ReadyForReconnection uint8 = 2 )
Disconnect control states (attribute 3 of class 70).
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 ¶
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 ¶
LNOctets turns a logical name written "a.b.c.d.e.f" (each 0 to 255) into its six octets.
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 ¶
ObjectListEntrySN is one entry of an Association SN object list: {base name, class, version, logical name}.
func ParseDateTime ¶
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) 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) LogicalName ¶
func (o *ActivityCalendar) LogicalName() string
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) ClassID ¶
func (o *AssociationLN) ClassID() uint16
func (*AssociationLN) LogicalName ¶
func (o *AssociationLN) LogicalName() string
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) ClassID ¶
func (o *AssociationSN) ClassID() uint16
func (*AssociationSN) LogicalName ¶
func (o *AssociationSN) LogicalName() string
func (*AssociationSN) Version ¶
func (o *AssociationSN) Version() uint8
type Attribute ¶
Attribute is one attribute of a class. Static attributes are configuration that rarely changes; the others are values that move.
type AttributeAccess ¶
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 ¶
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 (*Class) AttributeSN ¶
AttributeSN is the short-name offset of attribute i from the base name.
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 ¶
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) LogicalName ¶
type Data ¶
Data is class 1: one value of any type. ReadOnly refuses SETs of it.
func (*Data) LogicalName ¶
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 ¶
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) LogicalName ¶
func (o *DemandRegister) LogicalName() string
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 6) 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 6; remote reconnect leads to ready in modes 1, 3 and 5 and straight to connected in 2, 4 and 6; manual reconnect (ready to connected) works in 1 to 6, manual disconnect in 1, 2 and 5, local disconnect in 1 to 6 and local reconnect in 5 and 6.
func (*DisconnectControl) ClassID ¶
func (o *DisconnectControl) ClassID() uint16
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) or closes (modes 2, 4, 6) the switch.
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 ¶
Action runs reset (1): the value becomes zero and the capture time now.
func (*ExtendedRegister) ClassID ¶
func (o *ExtendedRegister) ClassID() uint16
func (*ExtendedRegister) LogicalName ¶
func (o *ExtendedRegister) LogicalName() string
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 ¶
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) LogicalName ¶
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) ClassID ¶
func (o *IECHDLCSetup) ClassID() uint16
func (*IECHDLCSetup) LogicalName ¶
func (o *IECHDLCSetup) LogicalName() string
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) ClassID ¶
func (o *IECLocalPortSetup) ClassID() uint16
func (*IECLocalPortSetup) LogicalName ¶
func (o *IECLocalPortSetup) LogicalName() string
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 ¶
Action adds (1) or deletes (2) a multicast address and returns the number of them (3).
func (*IPv4Setup) LogicalName ¶
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 ¶
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) 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) 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) LogicalName ¶
type MethodAccess ¶
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) 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) LogicalName ¶
func (o *ProfileGeneric) LogicalName() string
func (*ProfileGeneric) Version ¶
func (o *ProfileGeneric) Version() uint8
type PushDestination ¶
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) LogicalName ¶
type Register ¶
Register is class 3: a value with its scaler and unit.
func (*Register) LogicalName ¶
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 ¶
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) LogicalName ¶
func (o *RegisterActivation) LogicalName() string
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) 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) LogicalName ¶
func (o *RegisterMonitor) LogicalName() string
func (*RegisterMonitor) Version ¶
func (o *RegisterMonitor) Version() uint8
type Resolver ¶
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 TypeUnmatched Result = 12 ScopeViolated Result = 13 LongAborted Result = 15 NoLongInProgress Result = 16 LongSetAborted Result = 17 NoLongSetProgress Result = 18 BlockNumberInvalid Result = 19 OtherReason Result = 250 )
Results.
type SAPAssignment ¶
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) ClassID ¶
func (o *SAPAssignment) ClassID() uint16
func (*SAPAssignment) LogicalName ¶
func (o *SAPAssignment) LogicalName() string
func (*SAPAssignment) Version ¶
func (o *SAPAssignment) Version() uint8
type SAPEntry ¶
SAPEntry is one logical device of a SAP assignment: its address and its name (an octet string, usually printable text).
type Schedule ¶
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) LogicalName ¶
type ScriptRef ¶
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) ClassID ¶
func (o *ScriptTable) ClassID() uint16
func (*ScriptTable) LogicalName ¶
func (o *ScriptTable) LogicalName() string
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) ClassID ¶
func (o *SecuritySetup) ClassID() uint16
func (*SecuritySetup) LogicalName ¶
func (o *SecuritySetup) LogicalName() string
func (*SecuritySetup) Version ¶
func (o *SecuritySetup) Version() uint8
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) ClassID ¶
func (o *SingleActionSchedule) ClassID() uint16
func (*SingleActionSchedule) LogicalName ¶
func (o *SingleActionSchedule) LogicalName() string
func (*SingleActionSchedule) Version ¶
func (o *SingleActionSchedule) Version() uint8
type SpecialDay ¶
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) ClassID ¶
func (o *SpecialDaysTable) ClassID() uint16
func (*SpecialDaysTable) LogicalName ¶
func (o *SpecialDaysTable) LogicalName() string
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) ClassID ¶
func (o *TCPUDPSetup) ClassID() uint16
func (*TCPUDPSetup) LogicalName ¶
func (o *TCPUDPSetup) LogicalName() string
func (*TCPUDPSetup) Version ¶
func (o *TCPUDPSetup) Version() uint8