Documentation ¶
Overview ¶
(C) 2014 Mathias Dalheimer <md@gonium.net>. Use of this source code is governed by a BSD-style license that can be found in the LICENSE file.
(C) 2014 Mathias Dalheimer <md@gonium.net>. See LICENSE file for license.
(C) 2014 Mathias Dalheimer <md@gonium.net>. See LICENSE file for license.
Index ¶
- Constants
- Variables
- func MkSubmitReadingHandler(dbchannel chan MeterReading, serverConfig *ServerConfiguration) http.HandlerFunc
- func ServeWs(w http.ResponseWriter, r *http.Request)
- func ServerStatus(w http.ResponseWriter, r *http.Request)
- type APIClientErrorMessage
- type AssetConfig
- type ByLastUpdate
- type ByName
- type ByRank
- type ByTimestamp
- type DBClient
- func (dbc DBClient) GetFrequenciesBetween(meterID string, start time.Time, end time.Time) (retval []MeterReading, err error)
- func (dbc DBClient) GetLastFrequencies(meterID string, amount int) ([]MeterReading, error)
- func (dbc DBClient) GetLastFrequency(meterID string) (MeterReading, error)
- func (dbc DBClient) MkDBPusher(dbchannel chan MeterReading) (func(), error)
- type DeviceConfig
- type ExporterConfiguration
- type InfluxDBConfig
- type LicenseData
- type Meter
- type MeterReading
- type Meters
- type NetworkConfig
- type ProviderConfiguration
- type Reading
- type ReadingCache
- type ServerConfiguration
- type ServerStatusData
- type StatusCode
- type TsvExporter
- type ValidationConfig
Constants ¶
const ( STATUS_OK StatusCode = 200 STATUS_INTERNAL_ERROR = 500 STATUS_NO_DB_CONNECTION = 501 // TODO: Implement keepalive STATUS_NO_UPDATES = 502 )
Variables ¶
var H = hub{ // contains filtered or unexported fields }
Functions ¶
func MkSubmitReadingHandler ¶
func MkSubmitReadingHandler(dbchannel chan MeterReading, serverConfig *ServerConfiguration) http.HandlerFunc
Accepts a new reading. Format: {"Timestamp":<ISO8601>,"Value":342.2}
func ServeWs ¶
func ServeWs(w http.ResponseWriter, r *http.Request)
serverWs handles webocket requests from the peer.
func ServerStatus ¶
func ServerStatus(w http.ResponseWriter, r *http.Request)
Types ¶
type APIClientErrorMessage ¶
type AssetConfig ¶
type ByLastUpdate ¶
type ByLastUpdate struct{ Meters }
func (ByLastUpdate) Less ¶
func (s ByLastUpdate) Less(i, j int) bool
type ByTimestamp ¶
type ByTimestamp []MeterReading
ByTimestamp implements sort.Interface for []MeterReading based on the timestamp field of a reading.
func (ByTimestamp) Len ¶
func (a ByTimestamp) Len() int
func (ByTimestamp) Less ¶
func (a ByTimestamp) Less(i, j int) bool
func (ByTimestamp) Swap ¶
func (a ByTimestamp) Swap(i, j int)
type DBClient ¶
type DBClient struct {
// contains filtered or unexported fields
}
func NewDBClient ¶
func NewDBClient(serverConfig *InfluxDBConfig) (*DBClient, error)
func (DBClient) GetFrequenciesBetween ¶
func (DBClient) GetLastFrequencies ¶
func (dbc DBClient) GetLastFrequencies(meterID string, amount int) ([]MeterReading, error)
func (DBClient) GetLastFrequency ¶
func (dbc DBClient) GetLastFrequency(meterID string) (MeterReading, error)
func (DBClient) MkDBPusher ¶
func (dbc DBClient) MkDBPusher(dbchannel chan MeterReading) (func(), error)
type DeviceConfig ¶
type ExporterConfiguration ¶
type ExporterConfiguration struct {
InfluxDB InfluxDBConfig
}
func LoadExporterConfiguration ¶
func LoadExporterConfiguration(configFile string) (cfg *ExporterConfiguration, err error)
func MkDefaultExporterConfiguration ¶
func MkDefaultExporterConfiguration() (cfg ExporterConfiguration)
func (*ExporterConfiguration) Save ¶
func (pc *ExporterConfiguration) Save(configFile string) (err error)
type InfluxDBConfig ¶
type LicenseData ¶
type LicenseData struct {
GenerationDate string
}
type Meter ¶
type Meter struct { Rank uint16 ID string Key string Name string Location string Cache *ReadingCache `json:"-"` // do not export CacheSize uint32 }
var BestMeter *Meter
func (*Meter) ActiveWithinLast ¶
func (*Meter) AppendReading ¶
type MeterReading ¶
TODO: Move MeterID out of MeterReading - too much duplication of the meter name. New type "MeterTimeseries?"
type NetworkConfig ¶
type ProviderConfiguration ¶
type ProviderConfiguration struct { Meter Meter Network NetworkConfig Device DeviceConfig Validation ValidationConfig }
func LoadProviderConfiguration ¶
func LoadProviderConfiguration(configFile string) (cfg *ProviderConfiguration, err error)
func MkDefaultProviderConfiguration ¶
func MkDefaultProviderConfiguration() (cfg ProviderConfiguration)
func (*ProviderConfiguration) Save ¶
func (pc *ProviderConfiguration) Save(configFile string) (err error)
*
- Provider Configuration methods
type ReadingCache ¶
The cache implements a cache of readings for a single meter.
func MakeReadingCache ¶
func MakeReadingCache(size uint32) (r *ReadingCache)
func (*ReadingCache) AddReading ¶
func (c *ReadingCache) AddReading(r Reading)
func (*ReadingCache) AllReadings ¶
func (c *ReadingCache) AllReadings() (r []Reading)
func (*ReadingCache) LastReading ¶
func (c *ReadingCache) LastReading() (r Reading, err error)
func (*ReadingCache) NumElements ¶
func (c *ReadingCache) NumElements() (retval int)
func (ReadingCache) String ¶
func (c ReadingCache) String() (retval string)
type ServerConfiguration ¶
type ServerConfiguration struct { Meters Meters MeterTimeout time.Duration Assets AssetConfig Network NetworkConfig InfluxDB InfluxDBConfig }
func LoadServerConfiguration ¶
func LoadServerConfiguration(configFile string) (cfg *ServerConfiguration, err error)
func MkDefaultServerConfiguration ¶
func MkDefaultServerConfiguration() (cfg ServerConfiguration)
func (*ServerConfiguration) Save ¶
func (sc *ServerConfiguration) Save(configFile string) (err error)
* * Server Configuration methods
type ServerStatusData ¶
type ServerStatusData struct { Code StatusCode LastValueAdded time.Time Message string }
type StatusCode ¶
type StatusCode int32
type TsvExporter ¶
type TsvExporter struct {
Path string
}
func NewTsvExporter ¶
func NewTsvExporter(path string) (*TsvExporter, error)
func (*TsvExporter) ExportDataset ¶
func (tsve *TsvExporter) ExportDataset(timeReadings []MeterReading) error
type ValidationConfig ¶
type ValidationConfig struct {
SpikeThreshold float64
}