rs485

package
v0.0.0-...-33463eb Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 11, 2024 License: BSD-3-Clause Imports: 8 Imported by: 27

Documentation

Index

Constants

View Source
const (
	ReadHoldingReg = 3
	ReadInputReg   = 4
)

Variables

View Source
var Producers = make(map[string]func() Producer)

Producers is the registry of Producer factory functions

Functions

func RTUFloat64ToFloat64

func RTUFloat64ToFloat64(b []byte) float64

RTUFloat64ToFloat64 converts 64 bit float readings

func RTUIeee754SolaredgeToFloat64

func RTUIeee754SolaredgeToFloat64(b []byte) float64

RTUIeee754SolaredgeToFloat64 converts 32 bit IEEE 754 solar edge big endian float readings The wire protocol seems to have some strange byte ordering (?)

func RTUIeee754ToFloat64

func RTUIeee754ToFloat64(b []byte) float64

RTUIeee754ToFloat64 converts 32 bit IEEE 754 float readings

func RTUIeee754ToFloat64Swapped

func RTUIeee754ToFloat64Swapped(b []byte) float64

RTUIeee754ToFloat64Swapped converts 32 bit IEEE 754 float readings

func RTUInt16ToFloat64

func RTUInt16ToFloat64(b []byte) float64

RTUInt16ToFloat64 converts 16 bit signed integer readings

func RTUInt32ToFloat64

func RTUInt32ToFloat64(b []byte) float64

RTUInt32ToFloat64 converts 32 bit signed integer readings

func RTUInt32ToFloat64Swapped

func RTUInt32ToFloat64Swapped(b []byte) float64

RTUInt32ToFloat64Swapped converts 32 bit unsigned integer readings with swapped word order

func RTUInt64ToFloat64

func RTUInt64ToFloat64(b []byte) float64

RTUInt64ToFloat64 converts 64 bit signed integer readings

func RTUUint16ToFloat64

func RTUUint16ToFloat64(b []byte) float64

RTUUint16ToFloat64 converts 16 bit unsigned integer readings

func RTUUint32ToFloat64

func RTUUint32ToFloat64(b []byte) float64

RTUUint32ToFloat64 converts 32 bit unsigned integer readings

func RTUUint32ToFloat64Swapped

func RTUUint32ToFloat64Swapped(b []byte) float64

RTUUint32ToFloat64Swapped converts 32 bit unsigned integer readings with swapped word order

func RTUUint64ToFloat64

func RTUUint64ToFloat64(b []byte) float64

RTUUint64ToFloat64 converts 64 bit unsigned integer readings

func Register

func Register(typ string, factory func() Producer)

Register registers a producer implementation

Types

type ABBProducer

type ABBProducer struct {
	Opcodes
}

func (*ABBProducer) Description

func (p *ABBProducer) Description() string

Description implements Producer interface

func (*ABBProducer) Probe

func (p *ABBProducer) Probe() Operation

Probe implements Producer interface

func (*ABBProducer) Produce

func (p *ABBProducer) Produce() (res []Operation)

Produce implements Producer interface

type CarloGavazziEM24Producer

type CarloGavazziEM24Producer struct {
	Opcodes
}

func (*CarloGavazziEM24Producer) Description

func (p *CarloGavazziEM24Producer) Description() string

Description implements Producer interface

func (*CarloGavazziEM24Producer) Probe

Probe implements Producer interface

func (*CarloGavazziEM24Producer) Produce

func (p *CarloGavazziEM24Producer) Produce() (res []Operation)

Produce implements Producer interface

type CarloGavazziEx3xProducer

type CarloGavazziEx3xProducer struct {
	Opcodes
}

func (*CarloGavazziEx3xProducer) Description

func (p *CarloGavazziEx3xProducer) Description() string

Description implements Producer interface

func (*CarloGavazziEx3xProducer) Probe

Probe implements Producer interface

func (*CarloGavazziEx3xProducer) Produce

func (p *CarloGavazziEx3xProducer) Produce() (res []Operation)

Produce implements Producer interface

type DDMProducer

type DDMProducer struct {
	Opcodes
}

func (*DDMProducer) Description

func (p *DDMProducer) Description() string

func (*DDMProducer) Probe

func (p *DDMProducer) Probe() Operation

func (*DDMProducer) Produce

func (p *DDMProducer) Produce() (res []Operation)

type DMG610Producer

type DMG610Producer struct {
	Opcodes
}

func (*DMG610Producer) Description

func (p *DMG610Producer) Description() string

func (*DMG610Producer) Probe

func (p *DMG610Producer) Probe() Operation

func (*DMG610Producer) Produce

func (p *DMG610Producer) Produce() (res []Operation)

type DZGProducer

type DZGProducer struct {
	Opcodes
}

func (*DZGProducer) Description

func (p *DZGProducer) Description() string

Description implements Producer interface

func (*DZGProducer) Probe

func (p *DZGProducer) Probe() Operation

Probe implements Producer interface

func (*DZGProducer) Produce

func (p *DZGProducer) Produce() (res []Operation)

Produce implements Producer interface

type IEM3000Producer

type IEM3000Producer struct {
	Opcodes
}

func (*IEM3000Producer) Description

func (p *IEM3000Producer) Description() string

Description implements Producer interface

func (*IEM3000Producer) Probe

func (p *IEM3000Producer) Probe() Operation

Probe implements Producer interface

func (*IEM3000Producer) Produce

func (p *IEM3000Producer) Produce() (res []Operation)

Produce implements Producer interface

type IneproProducer

type IneproProducer struct {
	Opcodes
}

func (*IneproProducer) Description

func (p *IneproProducer) Description() string

Description implements Producer interface

func (*IneproProducer) Probe

func (p *IneproProducer) Probe() Operation

Probe implements Producer interface

func (*IneproProducer) Produce

func (p *IneproProducer) Produce() (res []Operation)

Produce implements Producer interface

type JanitzaProducer

type JanitzaProducer struct {
	Opcodes
}

func (*JanitzaProducer) Description

func (p *JanitzaProducer) Description() string

Description implements Producer interface

func (*JanitzaProducer) Probe

func (p *JanitzaProducer) Probe() Operation

Probe implements Producer interface

func (*JanitzaProducer) Produce

func (p *JanitzaProducer) Produce() (res []Operation)

Produce implements Producer interface

type MPM3MPProducer

type MPM3MPProducer struct {
	Opcodes
}

func (*MPM3MPProducer) Description

func (p *MPM3MPProducer) Description() string

Description implements Producer interface

func (*MPM3MPProducer) Probe

func (p *MPM3MPProducer) Probe() Operation

Probe implements Producer interface

func (*MPM3MPProducer) Produce

func (p *MPM3MPProducer) Produce() (res []Operation)

Produce implements Producer interface

type ORNO1P504Producer

type ORNO1P504Producer struct {
	Opcodes
}

func (*ORNO1P504Producer) Description

func (p *ORNO1P504Producer) Description() string

Description implements Producer interface

func (*ORNO1P504Producer) Probe

func (p *ORNO1P504Producer) Probe() Operation

func (*ORNO1P504Producer) Produce

func (p *ORNO1P504Producer) Produce() (res []Operation)

Produce implements Producer interface

type ORNO1PProducer

type ORNO1PProducer struct {
	Opcodes
}

func (*ORNO1PProducer) Description

func (p *ORNO1PProducer) Description() string

Description implements Producer interface

func (*ORNO1PProducer) Probe

func (p *ORNO1PProducer) Probe() Operation

func (*ORNO1PProducer) Produce

func (p *ORNO1PProducer) Produce() (res []Operation)

Produce implements Producer interface

type ORNO3PProducer

type ORNO3PProducer struct {
	Opcodes
}

func (*ORNO3PProducer) Description

func (p *ORNO3PProducer) Description() string

Description implements Producer interface

func (*ORNO3PProducer) Probe

func (p *ORNO3PProducer) Probe() Operation

func (*ORNO3PProducer) Produce

func (p *ORNO3PProducer) Produce() (res []Operation)

Produce implements Producer interface

type Opcodes

type Opcodes map[meters.Measurement]uint16

Opcodes map measurements to physical registers

func (*Opcodes) Opcode

func (o *Opcodes) Opcode(iec meters.Measurement) uint16

Opcode returns physical register for measurement type

type Operation

type Operation struct {
	FuncCode  uint8
	OpCode    uint16
	ReadLen   uint16
	IEC61850  meters.Measurement
	Transform RTUTransform
}

Operation describes a physical bus operation and its result

type PacProducer

type PacProducer struct {
	Opcodes
}

func (*PacProducer) Description

func (p *PacProducer) Description() string

func (*PacProducer) Probe

func (p *PacProducer) Probe() Operation

func (*PacProducer) Produce

func (p *PacProducer) Produce() (res []Operation)

type Producer

type Producer interface {
	// Type returns device description, typically static
	Description() string

	// Produce creates a slice of possible device operations
	Produce() []Operation

	// Produce creates a device operation suited to detect the device during
	// scanning, typically a L1 voltage read operation
	Probe() Operation
}

Producer is the interface that produces query snips which represent modbus operations

func NewABBProducer

func NewABBProducer() Producer

func NewCarloGavazziEM24Producer

func NewCarloGavazziEM24Producer() Producer

func NewCarloGavazziEx3xProducer

func NewCarloGavazziEx3xProducer() Producer

func NewDDMProducer

func NewDDMProducer() Producer

func NewDMG610Producer

func NewDMG610Producer() Producer

func NewDZGProducer

func NewDZGProducer() Producer

func NewIEM3000Producer

func NewIEM3000Producer() Producer

func NewIneproProducer

func NewIneproProducer() Producer

func NewJanitzaProducer

func NewJanitzaProducer() Producer

func NewMPM3MPProducer

func NewMPM3MPProducer() Producer

func NewORNO1P504Producer

func NewORNO1P504Producer() Producer

func NewORNO1PProducer

func NewORNO1PProducer() Producer

func NewORNO3PProducer

func NewORNO3PProducer() Producer

func NewPacProducer

func NewPacProducer() Producer

func NewSBCProducer

func NewSBCProducer() Producer

func NewSDM220Producer

func NewSDM220Producer() Producer

func NewSDM230Producer

func NewSDM230Producer() Producer

func NewSDM72Producer

func NewSDM72Producer() Producer

func NewSDMProducer

func NewSDMProducer() Producer

func NewSEMTRProducer

func NewSEMTRProducer() Producer

func NewX961AProducer

func NewX961AProducer() Producer

type RS485

type RS485 struct {
	// contains filtered or unexported fields
}

RS485 implements meters.Device

func NewDevice

func NewDevice(typ string) (*RS485, error)

NewDevice creates a device who's type must exist in the producer registry

func (*RS485) Descriptor

func (d *RS485) Descriptor() meters.DeviceDescriptor

Descriptor returns the device descriptor. Since this method does not have bus access the descriptor should be prepared during initialization.

func (*RS485) Initialize

func (d *RS485) Initialize(client modbus.Client) error

Initialize prepares the device for usage. Any setup or initialization should be done here.

func (*RS485) Probe

func (d *RS485) Probe(client modbus.Client) (res meters.MeasurementResult, err error)

Probe is called by the handler after preparing the bus by setting the device id

func (*RS485) Producer

func (d *RS485) Producer() Producer

Producer returns the underlying producer. The producer can be used to understand which operations the device supports.

func (*RS485) Query

func (d *RS485) Query(client modbus.Client) (res []meters.MeasurementResult, err error)

Query is called by the handler after preparing the bus by setting the device id and waiting for rate limit

func (*RS485) QueryOp

func (d *RS485) QueryOp(client modbus.Client, op Operation) (res meters.MeasurementResult, err error)

QueryOp executes a single query operation on the bus

type RTUTransform

type RTUTransform func([]byte) float64

RTUTransform functions convert RTU bytes to meaningful data types.

func MakeScaledTransform

func MakeScaledTransform(transform RTUTransform, scaler float64) RTUTransform

MakeScaledTransform creates an RTUTransform with applied scaler

type SBCProducer

type SBCProducer struct {
	Opcodes
}

func (*SBCProducer) Description

func (p *SBCProducer) Description() string

Description implements Producer interface

func (*SBCProducer) Probe

func (p *SBCProducer) Probe() Operation

func (*SBCProducer) Produce

func (p *SBCProducer) Produce() (res []Operation)

Produce implements Producer interface

type SDM220Producer

type SDM220Producer struct {
	Opcodes
}

func (*SDM220Producer) Description

func (p *SDM220Producer) Description() string

func (*SDM220Producer) Probe

func (p *SDM220Producer) Probe() Operation

func (*SDM220Producer) Produce

func (p *SDM220Producer) Produce() (res []Operation)

type SDM230Producer

type SDM230Producer struct {
	Opcodes
}

func (*SDM230Producer) Description

func (p *SDM230Producer) Description() string

func (*SDM230Producer) Probe

func (p *SDM230Producer) Probe() Operation

func (*SDM230Producer) Produce

func (p *SDM230Producer) Produce() (res []Operation)

type SDM72Producer

type SDM72Producer struct {
	Opcodes
}

func (*SDM72Producer) Description

func (p *SDM72Producer) Description() string

func (*SDM72Producer) Probe

func (p *SDM72Producer) Probe() Operation

This device does not provide voltage data so it is not possible to automatically detect the device

func (*SDM72Producer) Produce

func (p *SDM72Producer) Produce() (res []Operation)

type SDMProducer

type SDMProducer struct {
	Opcodes
}

func (*SDMProducer) Description

func (p *SDMProducer) Description() string

func (*SDMProducer) Probe

func (p *SDMProducer) Probe() Operation

func (*SDMProducer) Produce

func (p *SDMProducer) Produce() (res []Operation)

type SEMTRProducer

type SEMTRProducer struct {
	Opcodes
}

func (*SEMTRProducer) Description

func (p *SEMTRProducer) Description() string

func (*SEMTRProducer) Probe

func (p *SEMTRProducer) Probe() Operation

func (*SEMTRProducer) Produce

func (p *SEMTRProducer) Produce() (res []Operation)

type X961AProducer

type X961AProducer struct {
	Opcodes
}

func (*X961AProducer) Description

func (p *X961AProducer) Description() string

func (*X961AProducer) Probe

func (p *X961AProducer) Probe() Operation

func (*X961AProducer) Produce

func (p *X961AProducer) Produce() (res []Operation)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL