model

package
v0.0.0-...-d8ac9bd Latest Latest
Warning

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

Go to latest
Published: May 18, 2024 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Http

type Http struct {
	// Path under /api/http/
	Path string `json:"path" xml:"path,attr" yaml:"path"`
	// PassKey unique to the unit. "" to allow all
	PassKey string `json:"passKey,omitempty" xml:"passKey,attr,omitempty" yaml:"passKey,omitempty"`
}

type Loader

type Loader interface {
	Accept(v Visitor) error
	Stations() *Stations
}

Loader provides access to the Stations loader

type Location

type Location struct {
	// Name of the location, optional.
	Name string `yaml:"name,omitempty"`
	// Latitude of the Location.
	// This can be in decimal degrees, or in dd:mm.mm or dd:mm:ss formats.
	// North is positive.
	Latitude string `yaml:"latitude"`
	// Longitude of the Location.
	// This can be in decimal degrees, or in dd:mm.mm or dd:mm:ss formats.
	// East is positive, West negative.
	Longitude string `yaml:"longitude"`
	// Altitude of the Location in meters.
	Altitude float64 `yaml:"altitude,omitempty"`
	// Notes of the location, optional.
	Notes string `yaml:"notes,omitempty"`
}

Location represents a location on the Earth's surface.

type Reading

type Reading struct {
	ID string `yaml:"-"`
	// Source the source within the received data for a reading
	Source string `yaml:"source"`
	// Type of the reading. This must match the case-insensitive id of a Unit.
	// If absent or not a valid Unit id, then this is taken as a placeholder and the reading/graphs are ignored.
	Type string `yaml:"type,omitempty"`
	// If set, use is the case-insensitive id of the Unit that is required for the Reading.
	// If not set then Type is the unit used.
	//
	// e.g. the device might provide temperature in Fahrenheit, but we want Celsius.
	// In that instance Type is "Fahrenheit" and Use is "Celsius".
	Use string `yaml:"use,omitempty"`
	// contains filtered or unexported fields
}

Reading defines a sensor available within a collection

func ReadingFromContext

func ReadingFromContext(ctx context.Context) *Reading

func (*Reading) Accept

func (s *Reading) Accept(v Visitor) error

func (*Reading) GetID

func (s *Reading) GetID() string

func (*Reading) Sensors

func (s *Reading) Sensors() *Sensors

func (*Reading) Unit

func (s *Reading) Unit() *value.Unit

func (*Reading) Value

func (s *Reading) Value(f float64) (value.Value, error)

Value returns f in the Type unit and returns the Value in the Use unit.

func (*Reading) WithContext

func (s *Reading) WithContext(ctx context.Context) (context.Context, error)

type Sensors

type Sensors struct {
	ID string `yaml:"-"`
	// Name of the Readings collection
	Name string `yaml:"name"`
	// Source of data for this collection
	Source Source `yaml:"source"`
	// Format of the message, default is json
	Format string
	// Timestamp Path to timestamp, "" for none
	Timestamp string
	// Reading's provided by this collection
	Readings map[string]*Reading `yaml:"readings"`
	// contains filtered or unexported fields
}

Sensors define a Reading collection within the Station. A Reading collection is

func SensorsFromContext

func SensorsFromContext(ctx context.Context) *Sensors

func (*Sensors) Accept

func (s *Sensors) Accept(v Visitor) error

func (*Sensors) ReadingsKeys

func (s *Sensors) ReadingsKeys() []string

ReadingsKeys returns a slice containing the keys for each Reading

func (*Sensors) Station

func (s *Sensors) Station() *Station

func (*Sensors) WithContext

func (s *Sensors) WithContext(ctx context.Context) (context.Context, error)

type Source

type Source struct {
	WUnderground string      `yaml:"wunderground,omitempty"`
	Http         *Http       `yaml:"ecowitt,omitempty"`
	Amqp         *amqp.Queue `yaml:"amqp,omitempty"`
	Mqtt         *mqtt.Queue `yaml:"mqtt,omitempty"`
}

Source defines the source of data for a Sensors collection. You must define one of these, otherwise no data will be received. You can define multiple entries here

type Station

type Station struct {
	ID string `yaml:"-"`
	// Name of the station
	Name string `yaml:"name"`
	// Location of the station
	Location Location `yaml:"location,omitempty"`
	// One or more Sensors collection
	Sensors map[string]*Sensors `yaml:"sensors"`
	// contains filtered or unexported fields
}

Station defines a Weather Station at a specific location. It consists of one or more Reading's

func StationFromContext

func StationFromContext(ctx context.Context) *Station

func (*Station) Accept

func (s *Station) Accept(v Visitor) error

func (*Station) LatLong

func (s *Station) LatLong() *coord.LatLong

func (*Station) WithContext

func (s *Station) WithContext(ctx context.Context) context.Context

type Stations

type Stations map[string]*Station

Stations Map of all defined Station's

func StationsFromContext

func StationsFromContext(ctx context.Context) *Stations

func (*Stations) Accept

func (s *Stations) Accept(v Visitor) error

func (*Stations) Init

func (s *Stations) Init() error

func (*Stations) WithContext

func (s *Stations) WithContext(ctx context.Context) context.Context

type Visitable

type Visitable interface {
	Accept(v Visitor) error
}

type Visitor

type Visitor interface {
	VisitStations(s *Stations) error
	VisitStation(s *Station) error
	VisitSensors(s *Sensors) error
	VisitReading(s *Reading) error
}

func FromContext

func FromContext(ctx context.Context) Visitor

type VisitorBuilder

type VisitorBuilder interface {
	Stations(t task.Task) VisitorBuilder
	Station(t task.Task) VisitorBuilder
	Sensors(t task.Task) VisitorBuilder
	Reading(t task.Task) VisitorBuilder
	WithContext(context.Context) Visitor
}

func NewVisitor

func NewVisitor() VisitorBuilder

Jump to

Keyboard shortcuts

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