forked from volkszaehler/mbmd
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathjanitza.go
More file actions
80 lines (69 loc) · 1.6 KB
/
Copy pathjanitza.go
File metadata and controls
80 lines (69 loc) · 1.6 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
package rs485
import . "github.com/volkszaehler/mbmd/meters"
func init() {
Register(NewJanitzaProducer)
}
const (
METERTYPE_JANITZA = "JANITZA"
)
type JanitzaProducer struct {
Opcodes
}
func NewJanitzaProducer() Producer {
/**
* Opcodes for Janitza B23.
* See https://www.janitza.de/betriebsanleitungen.html?file=files/download/manuals/current/B-Series/MID-Energy-Meters-Product-Manual.pdf
*/
ops := Opcodes{
VoltageL1: 0x4A38,
VoltageL2: 0x4A3A,
VoltageL3: 0x4A3C,
CurrentL1: 0x4A44,
CurrentL2: 0x4A46,
CurrentL3: 0x4A48,
PowerL1: 0x4A4C,
PowerL2: 0x4A4E,
PowerL3: 0x4A50,
ImportL1: 0x4A76,
ImportL2: 0x4A78,
ImportL3: 0x4A7A,
Import: 0x4A7C,
ExportL1: 0x4A7E,
ExportL2: 0x4A80,
ExportL3: 0x4A82,
Export: 0x4A84,
CosphiL1: 0x4A64,
CosphiL2: 0x4A66,
CosphiL3: 0x4A68,
}
return &JanitzaProducer{Opcodes: ops}
}
// Type implements Producer interface
func (p *JanitzaProducer) Type() string {
return METERTYPE_JANITZA
}
// Description implements Producer interface
func (p *JanitzaProducer) Description() string {
return "Janitza B-Series"
}
func (p *JanitzaProducer) snip(iec Measurement) Operation {
snip := Operation{
FuncCode: ReadHoldingReg,
OpCode: p.Opcode(iec),
ReadLen: 2,
IEC61850: iec,
Transform: RTUIeee754ToFloat64,
}
return snip
}
// Probe implements Producer interface
func (p *JanitzaProducer) Probe() Operation {
return p.snip(VoltageL1)
}
// Produce implements Producer interface
func (p *JanitzaProducer) Produce() (res []Operation) {
for op := range p.Opcodes {
res = append(res, p.snip(op))
}
return res
}