dataflow

package
v3.3.1 Latest Latest
Warning

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

Go to latest
Published: Dec 8, 2024 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var EmptyFilter = func(Value) bool { return true }

Functions

func FilterRegisters

func FilterRegisters[R Register](input []R, filterConf RegisterFilterConf) (output []R)

func SinkLog

func SinkLog(prefix string, input <-chan Value)

func SortRegisterStructs

func SortRegisterStructs(input []RegisterStruct)

Types

type EnumRegisterValue

type EnumRegisterValue struct {
	RegisterValue
	// contains filtered or unexported fields
}

func NewEnumRegisterValue

func NewEnumRegisterValue(deviceName string, register Register, value int) EnumRegisterValue

func (EnumRegisterValue) EnumIdx

func (v EnumRegisterValue) EnumIdx() int

func (EnumRegisterValue) Equals

func (v EnumRegisterValue) Equals(comp Value) bool

func (EnumRegisterValue) GenericValue

func (v EnumRegisterValue) GenericValue() interface{}

func (EnumRegisterValue) String

func (v EnumRegisterValue) String() string

func (EnumRegisterValue) Value

func (v EnumRegisterValue) Value() string

type Fillable

type Fillable interface {
	Fill(value Value)
}

type Filterable added in v3.2.0

type Filterable interface {
	Name() string
	Category() string
	Writable() bool
}

type NullRegisterValue

type NullRegisterValue struct {
	RegisterValue
}

func NewNullRegisterValue

func NewNullRegisterValue(deviceName string, register Register) NullRegisterValue

func (NullRegisterValue) Equals

func (v NullRegisterValue) Equals(comp Value) bool

func (NullRegisterValue) GenericValue

func (v NullRegisterValue) GenericValue() interface{}

func (NullRegisterValue) String

func (v NullRegisterValue) String() string

type NumericRegisterValue

type NumericRegisterValue struct {
	RegisterValue
	// contains filtered or unexported fields
}

func NewNumericRegisterValue

func NewNumericRegisterValue(deviceName string, register Register, value float64) NumericRegisterValue

func (NumericRegisterValue) Equals

func (v NumericRegisterValue) Equals(comp Value) bool

func (NumericRegisterValue) GenericValue

func (v NumericRegisterValue) GenericValue() interface{}

func (NumericRegisterValue) String

func (v NumericRegisterValue) String() string

func (NumericRegisterValue) Value

func (v NumericRegisterValue) Value() float64

type Register

type Register interface {
	Category() string
	Name() string
	Description() string
	RegisterType() RegisterType
	Enum() map[int]string
	Unit() string
	Sort() int
	Writable() bool
}

type RegisterDb

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

func NewRegisterDb

func NewRegisterDb() (registerDb *RegisterDb)

func (*RegisterDb) Add

func (rdb *RegisterDb) Add(registers ...Register)

func (*RegisterDb) AddStruct

func (rdb *RegisterDb) AddStruct(registerStructs ...RegisterStruct)

func (*RegisterDb) GetAll

func (rdb *RegisterDb) GetAll() []RegisterStruct

func (*RegisterDb) GetByName

func (rdb *RegisterDb) GetByName(registerName string) (reg RegisterStruct, ok bool)

func (*RegisterDb) GetFiltered

func (rdb *RegisterDb) GetFiltered(filter RegisterFilterFunc) []RegisterStruct

func (*RegisterDb) Subscribe

func (rdb *RegisterDb) Subscribe(ctx context.Context, filter RegisterFilterFunc) <-chan RegisterStruct

type RegisterFilterConf

type RegisterFilterConf interface {
	IncludeRegisters() []string
	SkipRegisters() []string
	IncludeCategories() []string
	SkipCategories() []string
	DefaultInclude() bool
}

type RegisterFilterFunc

type RegisterFilterFunc func(Filterable) bool
var AllRegisterFilter RegisterFilterFunc = func(Filterable) bool {
	return true
}

func RegisterFilter

func RegisterFilter(registerFilter RegisterFilterConf) RegisterFilterFunc

type RegisterStruct

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

func NewRegisterStruct

func NewRegisterStruct(
	category, name, description string,
	registerType RegisterType,
	enum map[int]string,
	unit string,
	sort int,
	writable bool,
) RegisterStruct

func NewRegisterStructByInterface

func NewRegisterStructByInterface(reg Register) RegisterStruct

func (RegisterStruct) Category

func (r RegisterStruct) Category() string

func (RegisterStruct) Description

func (r RegisterStruct) Description() string

func (RegisterStruct) Enum

func (r RegisterStruct) Enum() map[int]string

func (RegisterStruct) Equals

func (r RegisterStruct) Equals(b RegisterStruct) bool

func (RegisterStruct) Name

func (r RegisterStruct) Name() string

func (RegisterStruct) RegisterType

func (r RegisterStruct) RegisterType() RegisterType

func (RegisterStruct) Sort

func (r RegisterStruct) Sort() int

func (RegisterStruct) Unit

func (r RegisterStruct) Unit() string

func (RegisterStruct) Writable added in v3.2.0

func (r RegisterStruct) Writable() bool

type RegisterSubscription

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

type RegisterType

type RegisterType int
const (
	UndefinedRegister RegisterType = iota
	NumberRegister
	TextRegister
	EnumRegister
)

func RegisterTypeFromString

func RegisterTypeFromString(s string) RegisterType

func (RegisterType) String

func (rt RegisterType) String() string

type RegisterValue

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

func (RegisterValue) DeviceName

func (v RegisterValue) DeviceName() string

func (RegisterValue) Register

func (v RegisterValue) Register() Register

type StateKey

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

type TextRegisterValue

type TextRegisterValue struct {
	RegisterValue
	// contains filtered or unexported fields
}

func NewTextRegisterValue

func NewTextRegisterValue(deviceName string, register Register, value string) TextRegisterValue

func (TextRegisterValue) Equals

func (v TextRegisterValue) Equals(comp Value) bool

func (TextRegisterValue) GenericValue

func (v TextRegisterValue) GenericValue() interface{}

func (TextRegisterValue) String

func (v TextRegisterValue) String() string

func (TextRegisterValue) Value

func (v TextRegisterValue) Value() string

type Value

type Value interface {
	DeviceName() string
	Register() Register
	String() string
	GenericValue() interface{}
	Equals(comp Value) bool
}

type ValueFilterFunc

type ValueFilterFunc func(Value) bool
var AllValueFilter ValueFilterFunc = func(Value) bool {
	return true
}
var NonNullValueFilter ValueFilterFunc = func(value Value) bool {
	_, isNullValue := value.(NullRegisterValue)
	return !isNullValue
}

func DeviceNameValueFilter

func DeviceNameValueFilter(deviceName string) ValueFilterFunc

func DeviceNonNullValueFilter

func DeviceNonNullValueFilter(deviceName string) ValueFilterFunc

func RegisterValueFilter

func RegisterValueFilter(registerFilter RegisterFilterConf) ValueFilterFunc

type ValueStorage

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

func NewValueStorage

func NewValueStorage() (valueStorage *ValueStorage)

func (*ValueStorage) Fill

func (vs *ValueStorage) Fill(value Value)

func (*ValueStorage) GetState

func (vs *ValueStorage) GetState() (result []Value)

func (*ValueStorage) GetStateFiltered

func (vs *ValueStorage) GetStateFiltered(filter ValueFilterFunc) (result []Value)

func (*ValueStorage) Shutdown

func (vs *ValueStorage) Shutdown()

func (*ValueStorage) SubscribeReturnInitial

func (vs *ValueStorage) SubscribeReturnInitial(ctx context.Context, filter ValueFilterFunc) (initial []Value, subscription ValueSubscription)

func (*ValueStorage) SubscribeSendInitial

func (vs *ValueStorage) SubscribeSendInitial(ctx context.Context, filter ValueFilterFunc) (subscription ValueSubscription)

func (*ValueStorage) Wait

func (vs *ValueStorage) Wait()

Wait until all inputs are processed (useful for testing)

type ValueSubscription

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

func (*ValueSubscription) Drain

func (s *ValueSubscription) Drain() <-chan Value

Jump to

Keyboard shortcuts

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