spi

package
v0.0.0-...-8248196 Latest Latest
Warning

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

Go to latest
Published: Dec 11, 2019 License: BSD-3-Clause Imports: 1 Imported by: 0

Documentation

Overview

spi is a package used by physical implementations or drivers. It provides additional interfaces to each implementation object that allow drivers to efficiently map the abstract API entities onto the underlying physical substrate such as a byte slice, a Modbus link or an XML document.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func WithBlockSPI

func WithBlockSPI(f func(BlockSPI)) func(sunspec.Block)

WithBlockSPI answers a function that will apply the specified function, f, to the function's argument if, and only if, the argument is a Block which also implements BlockSPI.

func WithDeviceSPI

func WithDeviceSPI(f func(DeviceSPI)) func(sunspec.Device)

WithDeviceSPI answers a function that will apply the specified function, f, to the function's argument if, and only if, the argument is a Device which also implements DeviceSPI.

func WithModelSPI

func WithModelSPI(f func(ModelSPI)) func(sunspec.Model)

WithModelSPI answers a function that will apply the specified function, f, to the function's argument if, and only if, the argument is a Model which also implements ModelSPI.

func WithPointSPI

func WithPointSPI(f func(PointSPI)) func(sunspec.Point)

WithPointSPI answers a function that will apply the specified function, f, to the function's argument if, and only if, the argument is a Point which also implements PointSPI.

Types

type Anchor

type Anchor interface{}

An anchor is a driver specific anchor to information that pertains to the physical implementation of an API object. So, for example, in an address space based driver the anchor is the offset of a block or a model from the start of the physical address space. In an XML implementation the anchor is a reference to correponding element of the XML representation.

The purpose it to allow navigation back to the physical implementation from the "canonical" representation.

type Anchored

type Anchored interface {
	Anchor() Anchor
	SetAnchor(a Anchor)
}

type ArraySPI

type ArraySPI interface {
	Anchored
	sunspec.Array
	AddDevice(m DeviceSPI) error // Add a new model to the device
}

ArraySPI provides additional interfaces that the physical implementation needs to support the public interface of an array.

type BlockSPI

type BlockSPI interface {
	Anchored
	sunspec.Block
	Length() uint16
	SetLength(l uint16) // in cases where actual length differs from the spec length

	// Plan takes a set of pointIds to be read and returns a slice of points to
	// be read in the order they should be applied to the model
	//
	// The algorithm ensures that:
	//    - if no points are specified, then all are read
	//    - if a point is read, then the related scale factor point (if any) is also read.
	//    - if a scale factor point is read, then any other point dependent on the scale factor
	//      is also read.
	//    - scale factors are applied to the model before any related points
	Plan(pointIds ...string) ([]PointSPI, error)
}

BlockSPI provides additional interfaces that the physical implementation needs to support the public interface of a block.

type DeviceSPI

type DeviceSPI interface {
	Anchored
	sunspec.Device
	AddModel(m ModelSPI) error // Add a new model to the device
}

DeviceSPI provides additional interfaces that the physical implementation needs to support the public interface of a device.

type Driver

type Driver interface {
	Write(block BlockSPI, pointIds ...string) error
	Read(block BlockSPI, pointIds ...string) error
}

Driver is the interface implemented by components that can map the abstract API implementations onto a physical substrate. Each Driver implementation knows about a different kind of physical substrate, for example: byte slices, Modbus links or XML documents.

type ModelSPI

type ModelSPI interface {
	Anchored
	sunspec.Model
	Length() uint16
	AddRepeat() error // Add one repeat to the model
}

ModelSPI provides additional interfaces that the physical implementation needs to support the public interface of a model.

type PointSPI

type PointSPI interface {
	Anchored
	sunspec.Point
	Length() uint16
	Offset() uint16
	Unmarshal([]byte) error
	Marshal([]byte) error
	SetError(err error) // SetError clears the value and sets the error to the specified error
	ScaleFactorPoint() PointSPI
	MarshalXML() string
	UnmarshalXML(s string) error
}

PointSPI provides additional interfaces that the physical implementation needs to support the public interface of the point.

Jump to

Keyboard shortcuts

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