distillation

package
v0.0.0-...-89c8f47 Latest Latest
Warning

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

Go to latest
Published: Aug 6, 2023 License: MIT Imports: 23 Imported by: 10

Documentation

Index

Constants

View Source
const (
	RoutesEnableHeater          = "/api/heater"
	RoutesGetAllHeaters         = "/api/heater"
	RoutesGetEnabledHeaters     = "/api/heater/enabled"
	RoutesConfigureHeater       = "/api/heater/enabled"
	RoutesGetDS                 = "/api/onewire"
	RoutesConfigureDS           = "/api/onewire"
	RoutesGetDSTemperatures     = "/api/onewire/temperatures"
	RoutesGetPT                 = "/api/pt100"
	RoutesConfigurePT           = "/api/pt100"
	RoutesGetPTTemperatures     = "/api/pt100/temperatures"
	RoutesGetGPIO               = "/api/gpio"
	RoutesConfigureGPIO         = "/api/gpio"
	RoutesProcessPhases         = "/api/phases"
	RoutesProcessConfigPhase    = "/api/phases/:id"
	RoutesProcessConfigValidate = "/api/process/validate"
	RoutesProcess               = "/api/process"
	RoutesProcessStatus         = "/api/process/status"
	RoutesProcessComponents     = "/api/process/components"
)

Variables

View Source
var (
	ErrNoSuchID      = errors.New("doesn't exist")
	ErrNoTemps       = errors.New("temperature buffer is empty")
	ErrUnexpectedID  = errors.New("unexpected ID")
	ErrNoDSInterface = errors.New("no ds interface")
)
View Source
var (
	ErrNoGPIOInterface = errors.New("no GPIO interface")
)
View Source
var (
	ErrNoPTInterface = errors.New("no pt interface")
)
View Source
var (
	ErrNotImplemented = errors.New("not implemented")
)

Functions

This section is empty.

Types

type DS

type DS interface {
	Get() ([]embedded.DSSensorConfig, error)
	Configure(s embedded.DSSensorConfig) (embedded.DSSensorConfig, error)
	Temperatures() ([]embedded.DSTemperature, error)
}

DS access to on-board DS18B20 sensors

type DSClient

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

func NewDSClient

func NewDSClient(addr string, timeout time.Duration) *DSClient

func (*DSClient) Configure

func (d *DSClient) Configure(setConfig DSConfig) (DSConfig, error)

func (*DSClient) GetSensors

func (d *DSClient) GetSensors() ([]DSConfig, error)

func (*DSClient) Temperatures

func (d *DSClient) Temperatures() ([]Temperature, error)

type DSConfig

type DSConfig struct {
	embedded.DSSensorConfig
	// contains filtered or unexported fields
}

DSConfig simple wrapper for sensor configuration

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 {
	DS DS
	// contains filtered or unexported fields
}

DSHandler main struct used to handle number of DS sensors

func NewDSHandler

func NewDSHandler(ds DS) (*DSHandler, error)

NewDSHandler creates new DSHandler with provided DS interface

func (*DSHandler) ConfigureSensor

func (d *DSHandler) ConfigureSensor(cfg DSConfig) (DSConfig, error)

func (*DSHandler) GetConfig

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

func (*DSHandler) GetSensors

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

func (*DSHandler) History

func (d *DSHandler) History() []embedded.DSTemperature

History returns historical temperatures, but it also CLEARS all history data but last

func (*DSHandler) Temperature

func (d *DSHandler) Temperature(id string) Temperature

Temperature returns last read temperature

func (*DSHandler) Temperatures

func (d *DSHandler) Temperatures() []Temperature

Temperatures returns last read temperature for all sensors

func (*DSHandler) Update

func (d *DSHandler) Update() (errs []error)

Update updates temperatures in sensors

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 DSConfig) (DSConfig, error)

func (*DSRPCClient) Get

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

func (*DSRPCClient) Temperatures

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

type Distillation

type Distillation struct {
	HeatersHandler *HeatersHandler
	DSHandler      *DSHandler
	PTHandler      *PTHandler
	GPIOHandler    *GPIOHandler

	Process *process.Process
	// contains filtered or unexported fields
}

func New

func New(opts ...Option) (*Distillation, error)

func (*Distillation) Close

func (d *Distillation) Close()

func (*Distillation) ConfigureProcess

func (d *Distillation) ConfigureProcess(cfg ProcessConfig) error

func (*Distillation) Run

func (d *Distillation) Run()

func (*Distillation) Status

func (d *Distillation) Status() ProcessStatus

func (*Distillation) ValidateConfig

func (d *Distillation) ValidateConfig() ProcessConfigValidation

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 ErrorCode

type ErrorCode int
const (
	ErrorCodeEmptyBuffer ErrorCode = -iota - 1
	ErrorCodeWrongID
	ErrorCodeInternal
)

type GPIO

type GPIO interface {
	Get() ([]embedded.GPIOConfig, error)
	Configure(c embedded.GPIOConfig) (embedded.GPIOConfig, 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 (h *GPIOClient) Configure(setConfig GPIOConfig) (GPIOConfig, error)

func (*GPIOClient) Get

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

type GPIOConfig

type GPIOConfig struct {
	embedded.GPIOConfig
}

type GPIOError

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

func (*GPIOError) Error

func (g *GPIOError) Error() string

type GPIOHandler

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

func NewGPIOHandler

func NewGPIOHandler(io GPIO) (*GPIOHandler, error)

func (*GPIOHandler) Config

func (g *GPIOHandler) Config() []GPIOConfig

func (*GPIOHandler) Configure

func (g *GPIOHandler) Configure(cfg GPIOConfig) (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 HeaterClient

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

func NewHeaterClient

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

func (*HeaterClient) Configure

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

func (*HeaterClient) Enable

func (h *HeaterClient) Enable(setConfig HeaterConfigGlobal) (HeaterConfigGlobal, error)

func (*HeaterClient) GetAll

func (h *HeaterClient) GetAll() ([]HeaterConfigGlobal, error)

func (*HeaterClient) GetEnabled

func (h *HeaterClient) GetEnabled() ([]HeaterConfig, error)

type HeaterConfig

type HeaterConfig struct {
	embedded.HeaterConfig
	// contains filtered or unexported fields
}

type HeaterConfigGlobal

type HeaterConfigGlobal struct {
	ID      string `json:"id"`
	Enabled bool   `json:"enabled"`
}

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 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 HeaterConfigGlobal) (HeaterConfigGlobal, error)

func (*HeaterRPCClient) Get

type Heaters

type Heaters interface {
	Get() ([]embedded.HeaterConfig, error)
	Configure(heater embedded.HeaterConfig) (embedded.HeaterConfig, error)
}

type HeatersHandler

type HeatersHandler struct {
	Heaters Heaters
	// contains filtered or unexported fields
}

func NewHandlerHeaters

func NewHandlerHeaters(heaters Heaters) (*HeatersHandler, error)

func (*HeatersHandler) Config

func (h *HeatersHandler) Config(id string) (embedded.HeaterConfig, error)

func (*HeatersHandler) ConfigGlobal

func (h *HeatersHandler) ConfigGlobal(id string) (HeaterConfigGlobal, error)

func (*HeatersHandler) Configs

func (h *HeatersHandler) Configs() []HeaterConfig

func (*HeatersHandler) ConfigsGlobal

func (h *HeatersHandler) ConfigsGlobal() []HeaterConfigGlobal

func (*HeatersHandler) Configure

func (h *HeatersHandler) Configure(cfg HeaterConfig) (HeaterConfig, error)

func (*HeatersHandler) ConfigureGlobal

func (h *HeatersHandler) ConfigureGlobal(cfg HeaterConfigGlobal) (HeaterConfigGlobal, error)

type Option

type Option func(*Distillation) error

func WithDS

func WithDS(ds DS) Option

func WithGPIO

func WithGPIO(gpio GPIO) Option

func WithHeaters

func WithHeaters(heaters Heaters) Option

func WithInterval

func WithInterval(interval time.Duration) Option

func WithPT

func WithPT(pt PT) Option

type PT

type PT interface {
	Get() ([]embedded.PTSensorConfig, error)
	Configure(s embedded.PTSensorConfig) (embedded.PTSensorConfig, error)
	Temperatures() ([]embedded.PTTemperature, error)
}

PT access to on-board PT100 sensors

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 PTConfig) (PTConfig, error)

func (*PTClient) GetSensors

func (p *PTClient) GetSensors() ([]PTConfig, error)

func (*PTClient) Temperatures

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

type PTConfig

type PTConfig struct {
	embedded.PTSensorConfig
	// contains filtered or unexported fields
}

PTConfig simple wrapper for sensor configuration

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 {
	PT PT
	// contains filtered or unexported fields
}

PTHandler main struct used to handle number of PT sensors

func NewPTHandler

func NewPTHandler(pt PT) (*PTHandler, error)

NewPTHandler creates new PTHandler with provided PT interface

func (*PTHandler) Configure

func (p *PTHandler) Configure(cfg PTConfig) (PTConfig, error)

func (*PTHandler) GetConfig

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

func (*PTHandler) GetSensors

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

func (*PTHandler) History

func (p *PTHandler) History() []embedded.PTTemperature

History returns historical temperatures, but it also CLEARS all history data but last

func (*PTHandler) Temperature

func (p *PTHandler) Temperature(id string) Temperature

Temperature returns last read temperature

func (*PTHandler) Temperatures

func (p *PTHandler) Temperatures() []Temperature

Temperatures returns last read temperature for all sensors

func (*PTHandler) Update

func (p *PTHandler) Update() (errs []error)

Update updates temperatures in sensors

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 PTConfig) (PTConfig, error)

func (*PTRPCClient) Get

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

func (*PTRPCClient) Temperatures

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

type ProcessClient

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

func NewProcessClient

func NewProcessClient(addr string, timeout time.Duration) *ProcessClient

func (*ProcessClient) ConfigurePhase

func (h *ProcessClient) ConfigurePhase(phaseNumber int, setConfig ProcessPhaseConfig) (ProcessPhaseConfig, error)

func (*ProcessClient) ConfigurePhaseCount

func (h *ProcessClient) ConfigurePhaseCount(count ProcessPhaseCount) (ProcessPhaseCount, error)

func (*ProcessClient) ConfigureProcess

func (h *ProcessClient) ConfigureProcess(cfg ProcessConfig) (ProcessConfig, error)

func (*ProcessClient) GetPhaseConfig

func (h *ProcessClient) GetPhaseConfig(phaseNumber int) (ProcessPhaseConfig, error)

func (*ProcessClient) GetPhaseCount

func (h *ProcessClient) GetPhaseCount() (ProcessPhaseCount, error)

func (*ProcessClient) Status

func (h *ProcessClient) Status() (ProcessStatus, error)

func (*ProcessClient) ValidateConfig

func (h *ProcessClient) ValidateConfig() (ProcessConfigValidation, error)

type ProcessConfig

type ProcessConfig struct {
	Enable     bool `json:"enable"`
	MoveToNext bool `json:"move_to_next"`
	Disable    bool `json:"disable"`
}

ProcessConfig serves as a way to enable or disable processing

type ProcessConfigValidation

type ProcessConfigValidation struct {
	Valid bool   `json:"valid"`
	Error string `json:"error,omitempty"`
}

ProcessConfigValidation returns whether Process configuration is valid

type ProcessPhaseConfig

type ProcessPhaseConfig struct {
	process.PhaseConfig
}

ProcessPhaseConfig is package wrapper for process.PhaseConfig

type ProcessPhaseCount

type ProcessPhaseCount struct {
	PhaseNumber uint `json:"phase_number"`
}

ProcessPhaseCount is JSON wrapper for process.PhaseNumber

type ProcessRPCClient

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

func NewProcessRPCClient

func NewProcessRPCClient(addr string, timeout time.Duration) (*ProcessRPCClient, error)

func (*ProcessRPCClient) ConfigureGlobalGPIO

func (p *ProcessRPCClient) ConfigureGlobalGPIO(gpios []process.GPIOConfig) ([]process.GPIOConfig, error)

func (*ProcessRPCClient) ConfigurePhase

func (p *ProcessRPCClient) ConfigurePhase(phaseNumber int, setConfig ProcessPhaseConfig) (ProcessPhaseConfig, error)

func (*ProcessRPCClient) ConfigurePhaseCount

func (p *ProcessRPCClient) ConfigurePhaseCount(count ProcessPhaseCount) (ProcessPhaseCount, error)

func (*ProcessRPCClient) ConfigureProcess

func (p *ProcessRPCClient) ConfigureProcess(cfg ProcessConfig) (ProcessConfig, error)

func (*ProcessRPCClient) GetPhaseConfig

func (p *ProcessRPCClient) GetPhaseConfig(phaseNumber int) (ProcessPhaseConfig, error)

func (*ProcessRPCClient) GetPhaseCount

func (p *ProcessRPCClient) GetPhaseCount() (ProcessPhaseCount, error)

func (*ProcessRPCClient) GlobalConfig

func (p *ProcessRPCClient) GlobalConfig() (process.Config, error)

func (*ProcessRPCClient) Status

func (p *ProcessRPCClient) Status() (ProcessStatus, error)

func (*ProcessRPCClient) ValidateConfig

func (p *ProcessRPCClient) ValidateConfig() (ProcessConfigValidation, error)

type ProcessStatus

type ProcessStatus struct {
	process.Status
}

ProcessStatus is just wrapper for process.Status

type RPC

func NewRPC

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

func (*RPC) Close

func (r *RPC) Close()

func (*RPC) ConfigureProcess

func (*RPC) DSConfigure

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

func (*RPC) DSGet

func (*RPC) DSGetTemperatures

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

func (*RPC) GPIOConfigure

func (*RPC) GPIOGet

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

func (*RPC) GetPhaseCount

func (r *RPC) GetPhaseCount(ctx context.Context, e *empty.Empty) (*distillationproto.ProcessPhaseCount, error)

func (*RPC) HeaterConfigure

func (*RPC) HeaterGet

func (r *RPC) HeaterGet(ctx context.Context, e *empty.Empty) (*distillationproto.HeaterConfigs, error)

func (*RPC) PTConfigure

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

func (*RPC) PTGet

func (*RPC) PTGetTemperatures

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

func (*RPC) Run

func (r *RPC) Run() error

func (*RPC) Status

func (*RPC) ValidateConfig

type Rest

type Rest struct {
	*gin.Engine
	*Distillation
	// contains filtered or unexported fields
}

func NewRest

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

func (*Rest) Run

func (r *Rest) Run() error

type Temperature

type Temperature struct {
	ID          string    `json:"ID"`
	Temperature float64   `json:"temperature"`
	Stamp       int64     `json:"unix_seconds"`
	Error       ErrorCode `json:"error_code"`
}

Temperature - json returned from rest API

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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