-
Notifications
You must be signed in to change notification settings - Fork 83
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Differentiate SDM220/230 meters (#74)
Co-authored-by: joekokker <59933882+joekokker@users.noreply.github.com>
- Loading branch information
Showing
9 changed files
with
208 additions
and
59 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
package rs485 | ||
|
||
import . "github.com/volkszaehler/mbmd/meters" | ||
|
||
func init() { | ||
Register(NewSDM220Producer) | ||
} | ||
|
||
const ( | ||
METERTYPE_SDM220 = "SDM220" | ||
) | ||
|
||
type SDM220Producer struct { | ||
Opcodes | ||
} | ||
|
||
func NewSDM220Producer() Producer { | ||
/** | ||
* Opcodes as defined by Eastron SDM220. | ||
* See https://bg-etech.de/download/manual/SDM220StandardDE.pdf | ||
*/ | ||
ops := Opcodes{ | ||
Voltage: 0x0000, // 220, 230 | ||
Current: 0x0006, // 220, 230 | ||
Import: 0x0048, // 220, 230 | ||
Export: 0x004a, // 220, 230 | ||
Sum: 0x0156, // 220, 230 | ||
ReactiveSum: 0x0158, // 220 | ||
ReactiveImport: 0x4C, // 220, 230 | ||
ReactiveExport: 0x4E, // 220, 230 | ||
} | ||
return &SDM220Producer{Opcodes: ops} | ||
} | ||
|
||
func (p *SDM220Producer) Type() string { | ||
return METERTYPE_SDM220 | ||
} | ||
|
||
func (p *SDM220Producer) Description() string { | ||
return "Eastron SDM220" | ||
} | ||
|
||
func (p *SDM220Producer) snip(iec Measurement) Operation { | ||
operation := Operation{ | ||
FuncCode: ReadInputReg, | ||
OpCode: p.Opcode(iec), | ||
ReadLen: 2, | ||
IEC61850: iec, | ||
Transform: RTUIeee754ToFloat64, | ||
} | ||
return operation | ||
} | ||
|
||
func (p *SDM220Producer) Probe() Operation { | ||
return p.snip(Voltage) | ||
} | ||
|
||
func (p *SDM220Producer) Produce() (res []Operation) { | ||
for op := range p.Opcodes { | ||
res = append(res, p.snip(op)) | ||
} | ||
|
||
return res | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
package rs485 | ||
|
||
import . "github.com/volkszaehler/mbmd/meters" | ||
|
||
func init() { | ||
Register(NewSDM230Producer) | ||
} | ||
|
||
const ( | ||
METERTYPE_SDM230 = "SDM230" | ||
) | ||
|
||
type SDM230Producer struct { | ||
Opcodes | ||
} | ||
|
||
func NewSDM230Producer() Producer { | ||
/** | ||
* Opcodes as defined by Eastron SDM230. | ||
* See https://bg-etech.de/download/manual/SDM230-register.pdf | ||
*/ | ||
ops := Opcodes{ | ||
Voltage: 0x0000, // 220, 230 | ||
Current: 0x0006, // 220, 230 | ||
Power: 0x000C, // 230 | ||
Import: 0x0048, // 220, 230 | ||
Export: 0x004a, // 220, 230 | ||
Cosphi: 0x001e, // 230 | ||
Frequency: 0x0046, // 230 | ||
ReactiveImport: 0x4C, // 220, 230 | ||
ReactiveExport: 0x4E, // 220, 230 | ||
ApparentPower: 0x0012, // 230 | ||
ReactivePower: 0x0018, // 230 | ||
Sum: 0x0156, // 230 | ||
PhaseAngle: 0x0024, // 230 | ||
} | ||
return &SDM230Producer{Opcodes: ops} | ||
} | ||
|
||
func (p *SDM230Producer) Type() string { | ||
return METERTYPE_SDM230 | ||
} | ||
|
||
func (p *SDM230Producer) Description() string { | ||
return "Eastron SDM230" | ||
} | ||
|
||
func (p *SDM230Producer) snip(iec Measurement) Operation { | ||
operation := Operation{ | ||
FuncCode: ReadInputReg, | ||
OpCode: p.Opcode(iec), | ||
ReadLen: 2, | ||
IEC61850: iec, | ||
Transform: RTUIeee754ToFloat64, | ||
} | ||
return operation | ||
} | ||
|
||
func (p *SDM230Producer) Probe() Operation { | ||
return p.snip(Voltage) | ||
} | ||
|
||
func (p *SDM230Producer) Produce() (res []Operation) { | ||
for op := range p.Opcodes { | ||
res = append(res, p.snip(op)) | ||
} | ||
|
||
return res | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.