gas

package
v0.0.0-...-6da897e Latest Latest
Warning

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

Go to latest
Published: Aug 30, 2022 License: MIT Imports: 2 Imported by: 5

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Concentration

type Concentration struct {
	// Gas is a descriptive string identifying the gas or group of gasses included in the concentration
	Gas string
	// Amount is the mass concentration of gas in a volume of air
	Amount units.Concentration
}

Concentration is a measurement of gas concentrations

type ConcentrationSpec

type ConcentrationSpec struct {
	// Gas is a descriptive string identifying the gas or group of gasses included in the concentration
	Gas string
	// Resolution is the smallest increment of measurement from the sensor
	Resolution units.Concentration
	// MinConcentration is the minimum valid measurement from the sensor
	MinConcentration units.Concentration
	// MaxConcentration is the maximum valid measurement from the sensor
	MaxConcentration units.Concentration
}

ConcentrationSpec is a specification of valid measurement ranges supported by the sensor

type Consumer

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

Consumer is a consumer of gas concentrations

func NewConsumer

func NewConsumer(sensor GasSensor, handlers ...Handler) *Consumer

NewConsumer returns a new Consumer with the configured handlers

func (*Consumer) Run

func (c *Consumer) Run(ctx context.Context) error

Run begins consuming from the sensor and handling each measurement. Blocks until either an error occurs or the context is completed.

type GasSensor

type GasSensor interface {
	// Run begins reading from the sensor and blocks until either an error occurs or the context is completed
	Run(context.Context) error
	// Concentrations returns a channel of gas concentration readings as they become available from the sensor
	Concentrations() <-chan *Concentration
	// ConcentrationSpecs returns a collection of specified measurement ranges supported by the sensor
	ConcentrationSpecs() []*ConcentrationSpec
}

GasSensor defines a sensor for measuring concentrations of gas in air

type Handler

type Handler interface {
	// Handles an individual concentration measurement
	HandleGasConcentration(context.Context, *Concentration) error
}

Handler defines a handler of gas concentrations

Directories

Path Synopsis
Package mocks is a generated GoMock package.
Package mocks is a generated GoMock package.

Jump to

Keyboard shortcuts

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