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 ¶
- Constants
- Variables
- func AttrName(base, obis string, class uint16, attr int8) string
- func CodeName(code int) string
- func ESWKey(b ESWBit) string
- func IDs() []string
- func IsTimeAttr(class uint16, attr int8) bool
- func LabelKeys() []string
- func NameOf(obis string, class uint16, attr int8) string
- func ScalerAttr(class uint16) int8
- type Association
- type Column
- type ESWBit
- type Event
- type EventInfo
- type EventLog
- type Method
- type Object
- type Profile
- type PushSetup
- type Right
- type Rights
- type Role
- type Spec
- func (s *Spec) Access(class uint16, obis string, id int8, method bool) (Rights, bool)
- func (s *Spec) Association(r Role) (Association, bool)
- func (s *Spec) Count() (objects, profiles, logs, codes, push, methods int)
- func (s *Spec) ESWBit(bit int) (ESWBit, bool)
- func (s *Spec) EventLog(obis string) *EventLog
- func (s *Spec) EventName(code int) (string, bool)
- func (s *Spec) Groups() []string
- func (s *Spec) Method(name string) *Method
- func (s *Spec) Object(obis string, attr int8) *Object
- func (s *Spec) Profile(obis string) *Profile
- func (s *Spec) PushSetup(obis string) *PushSetup
- func (s *Spec) RoleOf(client uint16) (Role, bool)
Examples ¶
Constants ¶
const ( CategoryVoltage = "voltage" CategoryCurrent = "current" CategoryPower = "power" CategoryTransaction = "transaction" CategoryOther = "other" CategoryNonRollover = "nonRollover" CategoryControl = "control" )
Event categories: the IS 15959 event log compartments.
const ( KindOccurrence = "occurrence" KindRestoration = "restoration" KindSingle = "single" )
Event kinds.
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).
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.
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.
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.
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.
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.
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 ¶
var Groups = []string{GroupNameplate, GroupInstantaneous, GroupEnergy, GroupBlockLoad, GroupDailyLoad, GroupBilling, GroupEvents, GroupProgrammable, GroupScalers, GroupPush, GroupSecurity, GroupCommunication}
Groups is every group name.
Functions ¶
func AttrName ¶
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 ESWKey ¶
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 IsTimeAttr ¶
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 ¶
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 ¶
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 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.
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 Right ¶
type Right uint8
Right is what one association may do with an attribute or method.
type Rights ¶
type Rights [numRoles]Right
Rights holds one Right per role.
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.
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 ¶
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 ¶
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 ¶
Count reports the catalogue size: objects (attributes), profiles, event logs, event codes, push setups and methods.
func (*Spec) Profile ¶
Profile returns the profile generic object (profiles and event logs) with an OBIS code.
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). |