data

package
v0.0.8 Latest Latest
Warning

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

Go to latest
Published: Feb 16, 2025 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Truncate time.Duration

Functions

func SetTruncateValue added in v0.0.5

func SetTruncateValue(d time.Duration)

Types

type Data

type Data struct {
	Value     any           `json:"value"`
	Timestamp time.Duration `json:"time-increment"`
}

Data is an array of timestamps and values representing the same source of data over a period of time

func NewData added in v0.0.5

func NewData(dat any, dur time.Duration) *Data

func (*Data) Float

func (d *Data) Float() float64

Return the float64 representation of the data. If the data is not represented by a float64 value a panic will follow

func (*Data) Int

func (d *Data) Int() int

Int returns the integer value of the data. If the data is not an integer a panic will result.

func (*Data) String

func (d *Data) String() string

type DataManager

type DataManager struct {
	DataMap map[string]map[string]*Timeseries `json:"datamap"`
	Subs    []string
}

DataManager is a map of Timeseries data that belongs to a specific station. The timeseries for each station are differentiated by the timeseries labels.

func GetDataManager

func GetDataManager() *DataManager

func NewDataManager

func NewDataManager() (dm *DataManager)

NewDataManager creates a new DataManager typically called by NewStation()

func (*DataManager) Add

func (dm *DataManager) Add(station, label string, data any)

Add will add data according to station and label

func (*DataManager) Callback

func (dm *DataManager) Callback(msg *messanger.Msg)

Callback is the callback used by the DataManager to receive MQTT messangers. TODO: move this call back to the stations because the stations will have a better understanding of the data they are subscribing to.

func (*DataManager) Dump

func (dm *DataManager) Dump(w io.Writer)

func (DataManager) ServeHTTP

func (dm DataManager) ServeHTTP(w http.ResponseWriter, r *http.Request)

ServeHTTP provides a REST interface to the config structure

func (*DataManager) Subscribe added in v0.0.7

func (dm *DataManager) Subscribe(topic string, c func(msg *messanger.Msg))

type Store

type Store struct {
	Filename string
	Source   map[string]map[string]float64
	StoreQ   chan *messanger.Msg
	// contains filtered or unexported fields
}

func GetStore

func GetStore() *Store

func NewStore

func NewStore() *Store

func (*Store) Store

func (s *Store) Store(msg *messanger.Msg) error

type Timeseries

type Timeseries struct {
	Station   string        `json:"station"`
	Label     string        `json:"label"`
	Timestamp time.Duration `json:"start"`
	Data      []*Data       `json:"data"`
}

Timeseries represents a single source of data over a time period

func NewTimeseries

func NewTimeseries(station, label string) *Timeseries

NewTimeseries will start a new data timeseries with the given label

func (*Timeseries) Add

func (ts *Timeseries) Add(d any) *Data

Add a new Data point to the given Timeseries

func (*Timeseries) Len

func (ts *Timeseries) Len() int

Len returns the number of data points contained in this timeseries

func (*Timeseries) String

func (ts *Timeseries) String() string

Jump to

Keyboard shortcuts

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