-
Notifications
You must be signed in to change notification settings - Fork 84
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add Eastron SDM54 #352
Merged
Merged
Add Eastron SDM54 #352
Changes from 1 commit
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
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,90 @@ | ||
package rs485 | ||
|
||
import . "github.com/volkszaehler/mbmd/meters" | ||
|
||
func init() { | ||
Register("SDM54", NewSDM54Producer) | ||
} | ||
|
||
type SDM54Producer struct { | ||
Opcodes | ||
} | ||
|
||
func NewSDM54Producer() Producer { | ||
/** | ||
* Opcodes as defined by Eastron SDM54. | ||
* See https://www.eastrongroup.com/eastrongroup/2024/08/21/eastronsdm54seriesusermanualv1.2.pdf | ||
* This is to a large extent a superset of all SDM devices, however there are | ||
* subtle differences (see 220, 230). Some opcodes might not work on some devices. | ||
*/ | ||
ops := Opcodes{ | ||
VoltageL1: 0x0000, // 220, 230 | ||
VoltageL2: 0x0002, | ||
VoltageL3: 0x0004, | ||
CurrentL1: 0x0006, // 220, 230 | ||
CurrentL2: 0x0008, | ||
CurrentL3: 0x000A, | ||
PowerL1: 0x000C, // 230 | ||
PowerL2: 0x000E, | ||
PowerL3: 0x0010, | ||
ApparentPowerL1: 0x0012, | ||
ApparentPowerL2: 0x0014, | ||
ApparentPowerL3: 0x0016, | ||
ReactivePowerL1: 0x0018, | ||
ReactivePowerL2: 0x001A, | ||
ReactivePowerL3: 0x001C, | ||
CosphiL1: 0x001e, // 230 | ||
CosphiL2: 0x0020, | ||
CosphiL3: 0x0022, | ||
Power: 0x0034, | ||
ApparentPower: 0x0038, | ||
ReactivePower: 0x003C, | ||
ImportPower: 0x0054, | ||
ImportL1: 0x015a, | ||
ImportL2: 0x015c, | ||
ImportL3: 0x015e, | ||
Import: 0x0048, // 220, 230 | ||
ExportL1: 0x0160, | ||
ExportL2: 0x0162, | ||
ExportL3: 0x0164, | ||
Export: 0x004a, // 220, 230 | ||
SumL1: 0x0166, | ||
SumL2: 0x0168, | ||
SumL3: 0x016a, | ||
Sum: 0x0156, // 220 | ||
Cosphi: 0x003e, | ||
THDL1: 0x00ea, // voltage | ||
THDL2: 0x00ec, // voltage | ||
THDL3: 0x00ee, // voltage | ||
THD: 0x00F8, // voltage | ||
Frequency: 0x0046, // 230 | ||
} | ||
return &SDM54Producer{Opcodes: ops} | ||
} | ||
|
||
func (p *SDM54Producer) Description() string { | ||
return "Eastron SDM54" | ||
} | ||
|
||
func (p *SDM54Producer) snip(iec Measurement) Operation { | ||
operation := Operation{ | ||
FuncCode: ReadInputReg, | ||
OpCode: p.Opcode(iec), | ||
ReadLen: 2, | ||
IEC61850: iec, | ||
Transform: RTUIeee754ToFloat64, | ||
} | ||
return operation | ||
} | ||
|
||
func (p *SDM54Producer) Probe() Operation { | ||
return p.snip(VoltageL1) | ||
} | ||
|
||
func (p *SDM54Producer) Produce() (res []Operation) { | ||
for op := range p.Opcodes { | ||
res = append(res, p.snip(op)) | ||
} | ||
|
||
return res | ||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please
gofmt
the code (or use VScode with Go plugin)There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for your comment, I have done that. As this is my first time adapting go code I would need some support: I have really no clue why the porcelain test fails. Could you please help me out?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OK, I figured it out. Is there anything else?