Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Context ¶
type Context struct { context.Context SensorID string Pipe ReadingsPipe }
Context defines structure for the sensor.Sensor reading context.
func NewReaderContext ¶
NewReaderContext constructs new Context instance based on given `parent` context for the given sensor.Sensor.
type FactoryFunc ¶
FactoryFunc builds sensor.Sensor.
func (FactoryFunc) Build ¶
func (f FactoryFunc) Build(bus int) Sensor
Build calls FactoryFunc to build sensor.Sensor on specified peripheral bus.
type MetricWriter ¶
type MetricWriter struct {
// contains filtered or unexported fields
}
MetricWriter defines object capable of dumping reading results from sensor.Sensor to a specific ReadingsPipe for models.Metric data.
func (*MetricWriter) Write ¶
func (w *MetricWriter) Write(v interface{})
Write writes reading results from sensor.Sensor with required type conversation.
func (*MetricWriter) WriteWithError ¶
func (w *MetricWriter) WriteWithError(value interface{}, err error)
WriteWithError allows to Write reading results and logged potential error at the same time.
type ReadingResult ¶
ReadingResult defines structure for storing readings result from a single sensor.Sensor device.
type ReadingsPipe ¶
type ReadingsPipe map[models.Metric]chan ReadingResult
ReadingsPipe maps where to dump sensor.Sensor ReadingResult for concrete models.Metric.
type Sensor ¶
type Sensor interface { // ID returns unique Sensor identifier key. ID() string // Init performers initialization sequence of the Sensor device. Init() error // Harvest collects all available models.Metric from Sensor device and dumps them into the context. Harvest(ctx *Context) // Metrics return all available models.Metric to reads from Sensor device. Metrics() []models.Metric // Verify checks whether the driver is compatible with Sensor device. Verify() bool // Active checks whether the Sensor device is connected and active. Active() bool // Close closes connection to Sensor device and clears allocated resources. Close() error }
Sensor defines base methods for controlling sensor device.
type SensorsRegister ¶
SensorsRegister represents pool of the multiply sensor.Sensor devices.
func (SensorsRegister) Exists ¶
func (sr SensorsRegister) Exists(id string) bool
Exists determines whether the sensor.Sensor exists in SensorsRegister by given `id`.
func (SensorsRegister) NotEmpty ¶
func (sr SensorsRegister) NotEmpty() bool
NotEmpty determines whether SensorsRegister contains at least one sensor.Sensor.
func (SensorsRegister) SupportedMetrics ¶
func (sr SensorsRegister) SupportedMetrics() models.Metrics
SupportedMetrics aggregates all supported by sensors models.Metric devices.
func (SensorsRegister) ToList ¶
func (sr SensorsRegister) ToList() []Sensor
ToList returns slice of all sensor.Sensor devices presented in SensorsRegister.
func (SensorsRegister) Union ¶
func (sr SensorsRegister) Union(sr2 SensorsRegister) SensorsRegister
Union produces new SensorsRegister combining sensors from original and `sr2`.