embedded

package
v0.0.0-...-27e653a Latest Latest
Warning

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

Go to latest
Published: Aug 6, 2023 License: MIT Imports: 17 Imported by: 3

Documentation

Index

Constants

View Source
const (
	RoutesGetHeaters             = "/api/heater"
	RoutesConfigHeater           = "/api/heater"
	RoutesGetOnewireSensors      = "/api/onewire"
	RoutesGetOnewireTemperatures = "/api/onewire/temperatures"
	RoutesConfigOnewireSensor    = "/api/onewire"
	RoutesGetPT100Sensors        = "/api/pt100"
	RoutesGetPT100Temperatures   = "/api/pt100/temperatures"
	RoutesConfigPT100Sensor      = "/api/pt100"
	RoutesGetGPIOs               = "/api/gpio"
	RoutesConfigGPIO             = "/api/gpio"
)

Variables

View Source
var (
	ErrNoSuchID       = errors.New("specified ID doesnt' exist")
	ErrNotImplemented = errors.New("not implemented")
)

Functions

This section is empty.

Types

type Config

type Config struct {
	Heaters []ConfigHeater  `mapstructure:"heaters"`
	DS18B20 []ConfigDS18B20 `mapstructure:"ds18b20"`
	PT100   []ConfigPT100   `mapstructure:"pt_100"`
	GPIO    []ConfigGPIO    `mapstructure:"gpio"`
}

type ConfigDS18B20

type ConfigDS18B20 struct {
	Path           string             `mapstructure:"path"`
	BusName        string             `mapstructure:"bus_name"`
	PollTimeMillis uint               `mapstructure:"poll_time_millis"`
	Resolution     ds18b20.Resolution `mapstructure:"resolution"`
	Samples        uint               `mapstructure:"samples"`
}

type ConfigGPIO

type ConfigGPIO struct {
	ID          string           `mapstructure:"id"`
	Pin         gpio.Pin         `mapstructure:"pin"`
	ActiveLevel gpio.ActiveLevel `mapstructure:"active_level"`
	Direction   gpio.Direction   `mapstructure:"direction"`
	Value       bool             `mapstructure:"value"`
}

type ConfigHeater

type ConfigHeater struct {
	ID          string           `mapstructure:"hardware_id"`
	Pin         gpio.Pin         `mapstructure:"gpio_pin"`
	ActiveLevel gpio.ActiveLevel `mapstructure:"active_level"`
}

type ConfigPT100

type ConfigPT100 struct {
	Path     string          `mapstructure:"path"`
	Name     string          `mapstructure:"name"`
	RNominal float64         `mapstructure:"r_nominal"`
	RRef     float64         `mapstructure:"r_ref"`
	Wiring   max31865.Wiring `mapstructure:"wiring"`
	ReadyPin gpio.Pin        `mapstructure:"ready_pin"`
}

type DS18B20Client

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

func NewDS18B20Client

func NewDS18B20Client(addr string, timeout time.Duration) *DS18B20Client

func (*DS18B20Client) Configure

func (p *DS18B20Client) Configure(setConfig DSSensorConfig) (DSSensorConfig, error)

func (*DS18B20Client) Get

func (p *DS18B20Client) Get() ([]DSSensorConfig, error)

func (*DS18B20Client) Temperatures

func (p *DS18B20Client) Temperatures() ([]DSTemperature, error)

type DSError

type DSError struct {
	ID  string `json:"ID"`
	Op  string `json:"op"`
	Err string `json:"error"`
}

func (*DSError) Error

func (d *DSError) Error() string

type DSHandler

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

func (*DSHandler) Close

func (d *DSHandler) Close()

func (*DSHandler) GetConfig

func (d *DSHandler) GetConfig(id string) (DSSensorConfig, error)

func (*DSHandler) GetSensors

func (d *DSHandler) GetSensors() []DSSensorConfig

func (*DSHandler) GetTemperatures

func (d *DSHandler) GetTemperatures() []DSTemperature

func (*DSHandler) Open

func (d *DSHandler) Open()

func (*DSHandler) SetConfig

func (d *DSHandler) SetConfig(cfg DSSensorConfig) (newConfig DSSensorConfig, err error)

func (*DSHandler) Temperature

func (d *DSHandler) Temperature(cfg ds18b20.SensorConfig) (float64, float64, error)

type DSRPCClient

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

func NewDSRPCClient

func NewDSRPCClient(addr string, timeout time.Duration) (*DSRPCClient, error)

func (*DSRPCClient) Close

func (g *DSRPCClient) Close()

func (*DSRPCClient) Configure

func (g *DSRPCClient) Configure(setConfig DSSensorConfig) (DSSensorConfig, error)

func (*DSRPCClient) Get

func (g *DSRPCClient) Get() ([]DSSensorConfig, error)

func (*DSRPCClient) Temperatures

func (g *DSRPCClient) Temperatures() ([]DSTemperature, error)

type DSSensor

type DSSensor interface {
	ID() (id string)
	Poll()
	Temperature() (actual, average float64, err error)
	GetReadings() []ds18b20.Readings
	Average() float64
	Configure(config ds18b20.SensorConfig) error
	GetConfig() ds18b20.SensorConfig
	Close()
}

type DSSensorConfig

type DSSensorConfig struct {
	Enabled bool `json:"enabled"`
	ds18b20.SensorConfig
}

type DSTemperature

type DSTemperature struct {
	Readings []ds18b20.Readings `json:"readings"`
}

type Embedded

type Embedded struct {
	Heaters *HeaterHandler
	DS      *DSHandler
	PT      *PTHandler
	GPIO    *GPIOHandler
}

func New

func New(options ...Option) (*Embedded, error)

type Error

type Error struct {
	Title     string    `json:"title"`
	Detail    string    `json:"detail"`
	Instance  string    `json:"instance"`
	Timestamp time.Time `json:"timestamp"`
}

Error is common struct returned via rest api

func (*Error) Error

func (e *Error) Error() string

type GPIO

type GPIO interface {
	ID() string
	Get() (bool, error)
	Configure(config gpio.Config) error
	GetConfig() (gpio.Config, error)
}

type GPIOClient

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

func NewGPIOClient

func NewGPIOClient(addr string, timeout time.Duration) *GPIOClient

func (*GPIOClient) Configure

func (p *GPIOClient) Configure(setConfig GPIOConfig) (GPIOConfig, error)

func (*GPIOClient) Get

func (p *GPIOClient) Get() ([]GPIOConfig, error)

type GPIOConfig

type GPIOConfig struct {
	gpio.Config
}

type GPIOError

type GPIOError struct {
	ID  string `json:"ID"`
	Op  string `json:"op"`
	Err string `json:"error"`
}

func (*GPIOError) Error

func (e *GPIOError) Error() string

type GPIOHandler

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

func (*GPIOHandler) Close

func (g *GPIOHandler) Close()

func (*GPIOHandler) GetConfig

func (g *GPIOHandler) GetConfig(id string) (GPIOConfig, error)

func (*GPIOHandler) GetConfigAll

func (g *GPIOHandler) GetConfigAll() ([]GPIOConfig, error)

func (*GPIOHandler) Open

func (g *GPIOHandler) Open()

func (*GPIOHandler) SetConfig

func (g *GPIOHandler) SetConfig(cfg GPIOConfig) error

type GPIORPCClient

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

func NewGPIORPCClient

func NewGPIORPCClient(addr string, timeout time.Duration) (*GPIORPCClient, error)

func (*GPIORPCClient) Close

func (g *GPIORPCClient) Close()

func (*GPIORPCClient) Configure

func (g *GPIORPCClient) Configure(setConfig GPIOConfig) (GPIOConfig, error)

func (*GPIORPCClient) Get

func (g *GPIORPCClient) Get() ([]GPIOConfig, error)

type Heater

type Heater interface {
	Enable(chan error)
	Disable()
	SetPower(pwr uint) error
	Enabled() bool
	Power() uint
}

type HeaterClient

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

func NewHeaterClient

func NewHeaterClient(addr string, timeout time.Duration) *HeaterClient

func (*HeaterClient) Configure

func (p *HeaterClient) Configure(setConfig HeaterConfig) (HeaterConfig, error)

func (*HeaterClient) Get

func (p *HeaterClient) Get() ([]HeaterConfig, error)

type HeaterConfig

type HeaterConfig struct {
	ID      string `json:"id"`
	Enabled bool   `json:"enabled"`
	Power   uint   `json:"power"`
}

type HeaterError

type HeaterError struct {
	ID  string `json:"ID"`
	Op  string `json:"op"`
	Err string `json:"error"`
}

func (*HeaterError) Error

func (e *HeaterError) Error() string

type HeaterHandler

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

func (*HeaterHandler) Close

func (h *HeaterHandler) Close()

func (*HeaterHandler) ConfigBy

func (h *HeaterHandler) ConfigBy(id string) (HeaterConfig, error)

func (*HeaterHandler) Enable

func (h *HeaterHandler) Enable(id string, ena bool) error

func (*HeaterHandler) Get

func (h *HeaterHandler) Get() []HeaterConfig

func (*HeaterHandler) Open

func (h *HeaterHandler) Open()

func (*HeaterHandler) Power

func (h *HeaterHandler) Power(id string, pwr uint) error

func (*HeaterHandler) SetConfig

func (h *HeaterHandler) SetConfig(cfg HeaterConfig) error

type HeaterRPCClient

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

func NewHeaterRPCCLient

func NewHeaterRPCCLient(addr string, timeout time.Duration) (*HeaterRPCClient, error)

func (*HeaterRPCClient) Close

func (g *HeaterRPCClient) Close()

func (*HeaterRPCClient) Configure

func (g *HeaterRPCClient) Configure(setConfig HeaterConfig) (HeaterConfig, error)

func (*HeaterRPCClient) Get

func (g *HeaterRPCClient) Get() ([]HeaterConfig, error)

type Option

type Option func(e *Embedded) error

func Parse

func Parse(c Config) ([]Option, []error)

func WithDS18B20

func WithDS18B20(ds []DSSensor) Option

func WithGPIOs

func WithGPIOs(gpios []GPIO) Option

func WithHeaters

func WithHeaters(heaters map[string]Heater) Option

func WithPT

func WithPT(pt []PTSensor) Option

type PTClient

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

func NewPTClient

func NewPTClient(addr string, timeout time.Duration) *PTClient

func (*PTClient) Configure

func (p *PTClient) Configure(setConfig PTSensorConfig) (PTSensorConfig, error)

func (*PTClient) Get

func (p *PTClient) Get() ([]PTSensorConfig, error)

func (*PTClient) Temperatures

func (p *PTClient) Temperatures() ([]PTTemperature, error)

type PTError

type PTError struct {
	ID  string `json:"ID"`
	Op  string `json:"op"`
	Err string `json:"error"`
}

func (*PTError) Error

func (e *PTError) Error() string

type PTHandler

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

PTHandler is responsible for handling models.PTSensors

func (*PTHandler) Close

func (p *PTHandler) Close() []error

func (*PTHandler) GetConfig

func (p *PTHandler) GetConfig(id string) (PTSensorConfig, error)

func (*PTHandler) GetSensors

func (p *PTHandler) GetSensors() []PTSensorConfig

func (*PTHandler) GetTemperatures

func (p *PTHandler) GetTemperatures() []PTTemperature

func (*PTHandler) Open

func (p *PTHandler) Open()

func (*PTHandler) SetConfig

func (p *PTHandler) SetConfig(cfg PTSensorConfig) (newCfg PTSensorConfig, err error)

type PTRPCClient

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

func NewPTRPCClient

func NewPTRPCClient(addr string, timeout time.Duration) (*PTRPCClient, error)

func (*PTRPCClient) Close

func (g *PTRPCClient) Close()

func (*PTRPCClient) Configure

func (g *PTRPCClient) Configure(setConfig PTSensorConfig) (PTSensorConfig, error)

func (*PTRPCClient) Get

func (g *PTRPCClient) Get() ([]PTSensorConfig, error)

func (*PTRPCClient) Temperatures

func (g *PTRPCClient) Temperatures() ([]PTTemperature, error)

type PTSensor

type PTSensor interface {
	ID() string
	Poll() (err error)
	Configure(config max31865.SensorConfig) error
	GetConfig() max31865.SensorConfig
	Average() float64
	Temperature() (actual float64, average float64, err error)
	GetReadings() []max31865.Readings
	Close() error
}

type PTSensorConfig

type PTSensorConfig struct {
	Enabled bool `json:"enabled"`
	max31865.SensorConfig
}

type PTTemperature

type PTTemperature struct {
	Readings []max31865.Readings
}

type RPC

func NewRPC

func NewRPC(url string, options ...Option) (*RPC, error)

func (*RPC) Close

func (r *RPC) Close()

func (*RPC) DSConfigure

func (r *RPC) DSConfigure(ctx context.Context, config *embeddedproto.DSConfig) (*embeddedproto.DSConfig, error)

func (*RPC) DSGet

func (r *RPC) DSGet(ctx context.Context, e *empty.Empty) (*embeddedproto.DSConfigs, error)

func (*RPC) DSGetTemperatures

func (r *RPC) DSGetTemperatures(ctx context.Context, e *empty.Empty) (*embeddedproto.DSTemperatures, error)

func (*RPC) GPIOConfigure

func (r *RPC) GPIOConfigure(c context.Context, cfg *embeddedproto.GPIOConfig) (*embeddedproto.GPIOConfig, error)

func (*RPC) GPIOGet

func (r *RPC) GPIOGet(ctx context.Context, empty *empty.Empty) (*embeddedproto.GPIOConfigs, error)

func (*RPC) HeaterConfigure

func (r *RPC) HeaterConfigure(ctx context.Context, config *embeddedproto.HeaterConfig) (*embeddedproto.HeaterConfig, error)

func (*RPC) HeaterGet

func (*RPC) PTConfigure

func (r *RPC) PTConfigure(ctx context.Context, config *embeddedproto.PTConfig) (*embeddedproto.PTConfig, error)

func (*RPC) PTGet

func (r *RPC) PTGet(ctx context.Context, e *empty.Empty) (*embeddedproto.PTConfigs, error)

func (*RPC) PTGetTemperatures

func (r *RPC) PTGetTemperatures(ctx context.Context, e *empty.Empty) (*embeddedproto.PTTemperatures, error)

func (*RPC) Run

func (r *RPC) Run() error

type Rest

type Rest struct {
	Router *restRouter

	*Embedded
	// contains filtered or unexported fields
}

func NewRest

func NewRest(url string, options ...Option) (*Rest, error)

func (*Rest) Close

func (r *Rest) Close()

func (*Rest) Run

func (r *Rest) Run() error

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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