db

package
v0.0.0-...-a0f3f1a Latest Latest
Warning

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

Go to latest
Published: May 17, 2016 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Account

type Account struct {
	ID    string `json:"id"`
	Name  string `json:"name"`
	State string `json:"state"`
}

Account has account details

type DeviceManager

type DeviceManager interface {
	GetRelay(string) (*Relay, error)
	GetSensor(string) (*Sensor, error)
	GetSensors(string, string) ([]*Sensor, error)
	UpdateSensor(string, *Sensor) (*Sensor, error)
}

DeviceManager provides functions for updating and retrieving sensor and relay devices

func NewDeviceDatabase

func NewDeviceDatabase(dynamoDBService *dynamodb.DynamoDB, geoLookup *geo.GoogleGeoLookup) DeviceManager

NewDeviceDatabase constructs a new Database instance

type InfluxDAO

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

InfluxDAO represents a DAO capable of interacting with InfluxDB

func NewInfluxDAO

func NewInfluxDAO(address string, username string, password string, databaseName string, deviceManager DeviceManager) (*InfluxDAO, error)

NewInfluxDAO creates a new DAO for interacting with InfluxDB

func (*InfluxDAO) GetLastSensorReadings

func (i *InfluxDAO) GetLastSensorReadings(accountID string, state string) (*LatestSensorReadings, error)

GetLastSensorReadings returns the latest sensor readings for the given account

func (*InfluxDAO) QueryForSensorReadings

func (i *InfluxDAO) QueryForSensorReadings(accountID, sensorID string, startTime, endTime int64) (*QueryForSensorReadingsResults, error)

QueryForSensorReadings returns sensor readings within an account

type LatestSensorReadings

type LatestSensorReadings struct {
	Sensors map[string]*SensorReading `json:"sensors"`
}

LatestSensorReadings contains the latest readings for a set of sensors

type Measurement

type Measurement struct {
	Name  string  `json:"name"`
	Value float64 `json:"value"`
	Unit  string  `json:"unit"`
}

Measurement represents a single measurement's details

type MeasurementsDatabase

type MeasurementsDatabase interface {
	GetLastSensorReadings(string, string) (*LatestSensorReadings, error)
	QueryForSensorReadings(string, string, int64, int64) (*QueryForSensorReadingsResults, error)
}

MeasurementsDatabase provides functions for retrieving sensor measurements

type MinMaxMeasurement

type MinMaxMeasurement struct {
	Name string      `json:"name"`
	Min  Measurement `json:"min"`
	Max  Measurement `json:"max"`
}

MinMaxMeasurement has the minimum and maximum values for a measurement

type MinimalReading

type MinimalReading struct {
	Timestamp    int64         `json:"timestamp"`
	Measurements []Measurement `json:"measurements"`
}

MinimalReading represents a single reading

type QueryForSensorReadingsResults

type QueryForSensorReadingsResults struct {
	AccountID string            `json:"account_id"`
	SensorID  string            `json:"sensor_id"`
	Readings  []*MinimalReading `json:"readings"`
}

QueryForSensorReadingsResults has results for a sensor-readings query

type Relay

type Relay struct {
	ID        string `json:"id"`
	AccountID string `json:"account_id"`
	Name      string `json:"name"`
	State     string `json:"state"`
}

Relay has details for a StreamMarker relay

type Sensor

type Sensor struct {
	ID              string  `json:"id"`
	AccountID       string  `json:"account_id"`
	Name            string  `json:"name"`
	State           string  `json:"state"`
	LocationEnabled bool    `json:"location_enabled"`
	Latitude        float64 `json:"latitude,omitempty"`
	Longitude       float64 `json:"longitude,omitempty"`
	TimeZoneID      string  `json:"timezone_id,omitempty"`
	TimeZoneName    string  `json:"timezone_name,omitempty"`
	SampleFrequency int64   `json:"sample_frequency,omitempty"`
}

Sensor represents a sensor capable of producing measurements

func (*Sensor) FieldMap

func (s *Sensor) FieldMap(req *http.Request) binding.FieldMap

FieldMap binds Sensor value for JSON mapping

type SensorReading

type SensorReading struct {
	SensorID     string        `json:"sensor_id"`
	AccountID    string        `json:"account_id"`
	Name         string        `json:"name"`
	State        string        `json:"state"`
	Timestamp    int64         `json:"timestamp"`
	Measurements []Measurement `json:"measurements"`
}

SensorReading has details for a single reading

Jump to

Keyboard shortcuts

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