From 70bbc29cfca242027fc05e7571d29ae75fb1717d Mon Sep 17 00:00:00 2001 From: andig Date: Tue, 21 Jan 2020 19:31:27 +0100 Subject: [PATCH] Consistent naming --- meters/rs485/abb.go | 2 +- meters/rs485/dzg.go | 2 +- meters/rs485/janitza.go | 2 +- meters/rs485/mpm3pm.go | 2 +- meters/rs485/sbc.go | 32 +++++++++++++++++++++++++------- meters/rs485/sdm.go | 2 +- 6 files changed, 30 insertions(+), 12 deletions(-) diff --git a/meters/rs485/abb.go b/meters/rs485/abb.go index 22d81ddf..9c1dcde2 100644 --- a/meters/rs485/abb.go +++ b/meters/rs485/abb.go @@ -67,7 +67,7 @@ func (p *ABBProducer) Type() string { // Description implements Producer interface func (p *ABBProducer) Description() string { - return "ABB A/B-Series meters" + return "ABB A/B-Series" } // wrapTransform validates if reading result is undefined and returns NaN in that case diff --git a/meters/rs485/dzg.go b/meters/rs485/dzg.go index 6511af70..69f7f18f 100644 --- a/meters/rs485/dzg.go +++ b/meters/rs485/dzg.go @@ -59,7 +59,7 @@ func (p *DZGProducer) Type() string { // Description implements Producer interface func (p *DZGProducer) Description() string { - return "DZG Metering GmbH DVH4013 meters" + return "DZG Metering GmbH DVH4013" } func (p *DZGProducer) snip(iec Measurement, scaler ...float64) Operation { diff --git a/meters/rs485/janitza.go b/meters/rs485/janitza.go index 87bb6a48..56d84902 100644 --- a/meters/rs485/janitza.go +++ b/meters/rs485/janitza.go @@ -51,7 +51,7 @@ func (p *JanitzaProducer) Type() string { // Description implements Producer interface func (p *JanitzaProducer) Description() string { - return "Janitza B-Series meters" + return "Janitza B-Series" } func (p *JanitzaProducer) snip(iec Measurement) Operation { diff --git a/meters/rs485/mpm3pm.go b/meters/rs485/mpm3pm.go index b1dd500c..5fffb610 100644 --- a/meters/rs485/mpm3pm.go +++ b/meters/rs485/mpm3pm.go @@ -55,7 +55,7 @@ func (p *MPM3MPProducer) Type() string { // Description implements Producer interface func (p *MPM3MPProducer) Description() string { - return "Bernecker Engineering MPM3PM meters" + return "Bernecker Engineering MPM3PM" } func (p *MPM3MPProducer) snip(iec Measurement, readlen uint16, transform RTUTransform, scaler ...float64) Operation { diff --git a/meters/rs485/sbc.go b/meters/rs485/sbc.go index 397c5695..e7a25cd4 100644 --- a/meters/rs485/sbc.go +++ b/meters/rs485/sbc.go @@ -11,6 +11,8 @@ const ( ) type SBCProducer struct { + typ string + phases int Opcodes } @@ -47,7 +49,11 @@ func NewSBCProducer() Producer { Power: 51, // scaler 100 ReactivePower: 52, // scaler 100 } - return &SBCProducer{Opcodes: ops} + return &SBCProducer{ + typ: "ALE3", // assume ALE3 + phases: 3, // assume 3 phase device + Opcodes: ops, + } } // Type implements Producer interface @@ -57,7 +63,7 @@ func (p *SBCProducer) Type() string { // Description implements Producer interface func (p *SBCProducer) Description() string { - return "Saia Burgess Controls ALE3 meters" + return "Saia Burgess " + p.typ } // snip creates modbus operation @@ -96,11 +102,23 @@ func (p *SBCProducer) snip32(iec Measurement, scaler ...float64) Operation { // Identify implements Identifier interface func (p *SBCProducer) Identify(bytes []byte) bool { - const b = "ALD1" // single phase - const b = "ALE3" // three phase direct - const b = "AWE3" // three phase converter - "D5" // oneway - "W5" // twoway + if len(bytes) < 4 { + return false + } + + switch string(bytes[:4]) { + case "ALD1": + // single phase + p.phases = 1 + case "ALE3", "AWE3": + // three phase direct/ converter + p.phases = 3 + default: + return false + } + + p.typ = string(bytes[:4]) + return true } // Probe implements Producer interface diff --git a/meters/rs485/sdm.go b/meters/rs485/sdm.go index 2c284f81..e877cf7f 100644 --- a/meters/rs485/sdm.go +++ b/meters/rs485/sdm.go @@ -70,7 +70,7 @@ func (p *SDMProducer) Type() string { } func (p *SDMProducer) Description() string { - return "Eastron SDM meters" + return "Eastron SDM" } func (p *SDMProducer) snip(iec Measurement) Operation {