device

package
v1.8.0 Latest Latest
Warning

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

Go to latest
Published: Dec 20, 2023 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func RegisterCreator

func RegisterCreator(kind config.DeviceKind, creator Creator)

Types

type Config

type Config interface {
	Name() string
	Kind() config.DeviceKind
	Device() string
	SkipFields() []string
	SkipCategories() []string
	LogDebug() bool
	LogComDebug() bool
}

type Creator

type Creator func(deviceStruct DeviceStruct, output chan dataflow.Value) (device Device, err error)

func CreateRandomDeviceFactory

func CreateRandomDeviceFactory(registers dataflow.Registers) Creator

type Device

type Device interface {
	Config() Config
	GetRegisters() dataflow.Registers
	SetRegisters(registers dataflow.Registers)
	SetLastUpdatedNow()
	GetLastUpdated() time.Time
	SetModel(model string)
	GetModel() string
	Shutdown()
}

func RunDevice

func RunDevice(cfg Config, target dataflow.Fillable) (device Device, err error)

type DevicePool

type DevicePool struct {
	Devices      map[string]Device
	DevicesMutex sync.RWMutex
}

func RunPool

func RunPool() (pool *DevicePool)

func (*DevicePool) AddDevice

func (p *DevicePool) AddDevice(device Device)

func (*DevicePool) GetDevice

func (p *DevicePool) GetDevice(deviceName string) Device

func (*DevicePool) GetDevices added in v1.3.0

func (p *DevicePool) GetDevices() map[string]Device

func (*DevicePool) RemoveDevice

func (p *DevicePool) RemoveDevice(device Device)

func (*DevicePool) Shutdown

func (p *DevicePool) Shutdown()

type DeviceStruct

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

func (*DeviceStruct) Config

func (c *DeviceStruct) Config() Config

func (*DeviceStruct) GetClosedChan

func (c *DeviceStruct) GetClosedChan() chan struct{}

func (*DeviceStruct) GetLastUpdated added in v1.3.0

func (c *DeviceStruct) GetLastUpdated() time.Time

func (*DeviceStruct) GetModel added in v1.3.0

func (c *DeviceStruct) GetModel() string

func (*DeviceStruct) GetRegisters added in v1.3.0

func (c *DeviceStruct) GetRegisters() dataflow.Registers

func (*DeviceStruct) GetShutdownChan

func (c *DeviceStruct) GetShutdownChan() chan struct{}

func (*DeviceStruct) SetLastUpdatedNow added in v1.3.0

func (c *DeviceStruct) SetLastUpdatedNow()

func (*DeviceStruct) SetModel added in v1.3.0

func (c *DeviceStruct) SetModel(model string)

func (*DeviceStruct) SetRegisters

func (c *DeviceStruct) SetRegisters(registers dataflow.Registers)

func (*DeviceStruct) Shutdown

func (c *DeviceStruct) Shutdown()

Jump to

Keyboard shortcuts

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