chamber

package
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: Jul 4, 2023 License: Apache-2.0 Imports: 17 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ErrNotFound       = Error("chamber not found")
	ErrNoCurrentBatch = Error("chamber does not have a current batch")
	ErrInvalidStep    = Error("invalid step")
	ErrNotFermenting  = Error("fermentation has not started")
	ErrFermenting     = Error("fermentation has started")
	ErrDeviceIsNil    = Error("device is nil")
	ErrMetricsIsNil   = Error("metrics provider nil")
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Chamber

type Chamber struct {
	ID                      string        `json:"id,omitempty"`
	Name                    string        `json:"name"`
	DeviceConfig            DeviceConfig  `json:"deviceConfig"`
	ChillingDifferential    float64       `json:"chillingDifferential"`
	HeatingDifferential     float64       `json:"heatingDifferential"`
	CurrentBatch            *batch.Detail `json:"currentBatch,omitempty"`
	CurrentFermentationStep string        `json:"currentFermentationStep,omitempty"`
	ModTime                 time.Time     `json:"modTime"`
	Readings                *Readings     `json:"readings,omitempty"`
	// contains filtered or unexported fields
}

Chamber represents an insulated box (fridge) with internal heating/cooling elements that reacts to changes in monitored temperatures, by correcting small deviations from your desired fermentation temperature.

func (*Chamber) Configure

func (c *Chamber) Configure(configurator Configurator, service brewfather.Service,
	logger *logrus.Logger, metrics metrics.Metrics, readingsUpdateInterval time.Duration,
) error

func (*Chamber) IsFermenting

func (c *Chamber) IsFermenting() bool

func (*Chamber) RefreshReadings

func (c *Chamber) RefreshReadings()

func (*Chamber) StartFermentation

func (c *Chamber) StartFermentation(ctx context.Context, stepID string) error

StartFermentation signals the chamber to start the given fermentation step.

func (*Chamber) StopFermentation

func (c *Chamber) StopFermentation() error

type Configurator

type Configurator interface {
	CreateDs18b20(thermometerID string) (device.Thermometer, error)
	CreateTilt(color tilt.Color) (device.ThermometerAndHydrometer, error)
	CreateGPIOActuator(pin string) (device.Actuator, error)
}

type Controller

type Controller interface {
	Repo
	StartFermentation(ctx context.Context, chamberID string, step string) error
	StopFermentation(chamberID string) error
}

type DefaultConfigurator

type DefaultConfigurator struct {
	TiltMonitor *tilt.Monitor
}

func (*DefaultConfigurator) CreateDs18b20

func (c *DefaultConfigurator) CreateDs18b20(id string) (device.Thermometer, error)

func (*DefaultConfigurator) CreateGPIOActuator

func (c *DefaultConfigurator) CreateGPIOActuator(pin string) (device.Actuator, error)

func (*DefaultConfigurator) CreateTilt

type DeviceConfig

type DeviceConfig struct {
	ChillerGPIO              string `json:"chillerGpio"`
	HeaterGPIO               string `json:"heaterGpio"`
	BeerThermometerType      string `json:"beerThermometerType"`
	BeerThermometerID        string `json:"beerThermometerId"`
	AuxiliaryThermometerType string `json:"auxiliaryThermometerType,omitempty"`
	AuxiliaryThermometerID   string `json:"auxiliaryThermometerId,omitempty"`
	ExternalThermometerType  string `json:"externalThermometerType,omitempty"`
	ExternalThermometerID    string `json:"externalThermometerId,omitempty"`
	HydrometerType           string `json:"hydrometerType,omitempty"`
	HydrometerID             string `json:"hydrometerId,omitempty"`
}

type Error

type Error string

func (Error) Error

func (e Error) Error() string

type InvalidConfigurationError

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

func (InvalidConfigurationError) Error

func (InvalidConfigurationError) Problems

func (e InvalidConfigurationError) Problems() []error

type Manager

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

func NewManager

func NewManager(repo Repo, configurator Configurator, service brewfather.Service,
	logger *logrus.Logger, metrics metrics.Metrics, readingsUpdateInterval time.Duration,
) (*Manager, error)

func (*Manager) Delete

func (m *Manager) Delete(id string) error

func (*Manager) Get

func (m *Manager) Get(id string) (*Chamber, error)

func (*Manager) GetAll

func (m *Manager) GetAll() ([]*Chamber, error)

func (*Manager) Save

func (m *Manager) Save(chamber *Chamber) error

func (*Manager) StartFermentation

func (m *Manager) StartFermentation(ctx context.Context, chamberID string, step string) error

StartFermentation signals the given chamber to start the given fermentation step.

func (*Manager) StopFermentation

func (m *Manager) StopFermentation(chamberID string) error

type Readings

type Readings struct {
	BeerTemperature      *float64 `json:"beerTemperature,omitempty"`
	AuxiliaryTemperature *float64 `json:"auxiliaryTemperature,omitempty"`
	ExternalTemperature  *float64 `json:"externalTemperature,omitempty"`
	HydrometerGravity    *float64 `json:"hydrometerGravity,omitempty"`
}

type Repo

type Repo interface {
	GetAll() ([]*Chamber, error)
	Get(id string) (*Chamber, error)
	Save(c *Chamber) error
	Delete(id string) error
}

Jump to

Keyboard shortcuts

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