Documentation
¶
Index ¶
- type ChecksumError
- type DSTIndicator
- type Data
- type Entry
- type Error
- type Event
- type EventLog
- type Footer
- type Header
- type LastCapture
- type LegacyLastCapture
- type LegacyMeasurement
- type MBusDevice
- type Measurement
- type Node
- type Number
- type OBIS
- type Object
- type Option
- type ParseError
- type String
- type Telegram
- type Timestamp
- type Value
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type ChecksumError ¶
func (*ChecksumError) Error ¶
func (e *ChecksumError) Error() string
type DSTIndicator ¶
type DSTIndicator int
DSTIndicator represents daylight saving time indicator.
const ( DSTUnknown DSTIndicator = iota DSTWinter DSTSummer )
func (DSTIndicator) Bool ¶
func (d DSTIndicator) Bool() bool
Bool reports whether daylight saving time is active (summer time).
func (*DSTIndicator) Capture ¶
func (d *DSTIndicator) Capture(values []string) error
Capture implements participle capture for DSTIndicator.
type Event ¶
type Event struct {
Pos lexer.Position `parser:""`
Timestamp *Timestamp `parser:"'(' @@ ')'"`
Value *Measurement `parser:"'(' @@ ( ')' (?='(') )?"`
}
Event represents a timestamp+duration pair.
type EventLog ¶
type EventLog struct {
Pos lexer.Position `parser:""`
Count *Number `parser:"@@ ')'"`
OBIS *OBIS `parser:"'(' @@ ( ')' (?='(') )?"`
Value []*Event `parser:"@@*"`
}
EventLog represents a log of events.
type LastCapture ¶
type LastCapture struct {
Pos lexer.Position `parser:""`
Timestamp *Timestamp `parser:"@@ ')'"`
Value *Measurement `parser:"'(' @@ ( ?!')' '(' )"`
}
LastCapture represents the last 5-minute capture of a MBus device.
func (*LastCapture) Position ¶
func (l *LastCapture) Position() lexer.Position
type LegacyLastCapture ¶
type LegacyLastCapture struct {
Pos lexer.Position `parser:""`
// We ignore any extraneous values between timestamp and OBIS as specs are unclear about their purpose.
Timestamp *String `parser:"@@ ')' ( '(' ~(')' | OBIS) ')' (?='(') )+ '('"`
OBIS *OBIS `parser:"@@ ')' '('"`
Value *LegacyMeasurement `parser:"@@"`
}
LegacyLastCapture represents the last 5-minute capture of an older MBus device (DSMR v2.2 or v3.0).
func (*LegacyLastCapture) Position ¶
func (l *LegacyLastCapture) Position() lexer.Position
type LegacyMeasurement ¶
type LegacyMeasurement struct {
Pos lexer.Position `parser:""`
Unit *String `parser:"@@ ')' '('"`
Value *Number `parser:"@@"`
}
LegacyMeasurement represents a number+unit of a LegacyLastCapture.
func (*LegacyMeasurement) Position ¶
func (m *LegacyMeasurement) Position() lexer.Position
type MBusDevice ¶
MBusDevice groups OBIS objects that belong to the same M-Bus channel.
func (*MBusDevice) Key ¶
func (m *MBusDevice) Key() string
func (*MBusDevice) Position ¶
func (m *MBusDevice) Position() lexer.Position
type Measurement ¶
type Measurement struct {
Pos lexer.Position `parser:""`
Value *Number `parser:"@@"`
Unit *String `parser:"'*' @@"`
}
Measurement represents a number+unit.
func (*Measurement) Position ¶
func (m *Measurement) Position() lexer.Position
type Node ¶
Grammar overview (simplified EBNF):
Telegram = Header Entry* Footer ;
Entry = Header | Footer | Object | MBusDevice ;
Object = OBIS "(" Value* ")" ;
MBusDevice = Object { Object } // same channel, leading OBIS 0-<channel>:*
Value = EventLog | LastCapture | LegacyLastCapture | Measurement | Timestamp | String ;
EventLog = Number ")" "(" OBIS ")" Event* ;
Event = "(" Timestamp ")" "(" Measurement [")"] ;
LastCapture = Timestamp ")" "(" Measurement ;
Measurement = Number "*" String ;
Timestamp = <12 digit datetime> ["S" | "W"] ;
String = <any chars except ')' or EOL> ;
Number = ["+" | "-"] digit+ ["." digit+] ;
Header/Footer tokens reuse String rules for their payloads.
Node expresses the common behaviour for every AST node in a telegram.
type Object ¶
type Object struct {
Pos lexer.Position `parser:""`
OBIS *OBIS `parser:"@@"`
Value Value `parser:"'(' @@* ')' (?=EOL)"`
// contains filtered or unexported fields
}
Object represents a COSEM object with one or more values.
type ParseError ¶
ParseError wraps errors returned by participle with position information and context.
func (*ParseError) Error ¶
func (e *ParseError) Error() string
func (*ParseError) Unwrap ¶
func (e *ParseError) Unwrap() error
type String ¶
type String struct {
Pos lexer.Position `parser:""`
// Also check for `EOL` token so both Header and Footer can use this Value struct as well.
Value string `parser:"@(~(')' | EOL)+)"`
}
String represents a literal string segment.
type Telegram ¶
type Telegram struct {
Pos lexer.Position `parser:""`
Header *Header `parser:"@@"`
Data Data `parser:"@@*"`
}
Telegram is the root node produced for every parsed message.