data

package
v0.0.0-...-30fef9d Latest Latest
Warning

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

Go to latest
Published: Mar 30, 2018 License: GPL-3.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetDeviceData

func GetDeviceData(ctx *gin.Context)

GetDeviceData returns a data set for the given device ID and sensor type.

func GetHumidityData

func GetHumidityData(ctx *gin.Context, deviceID int64, rangeMin float64, rangeMax float64)

GetHumidityData returns nil, since humidity sensors are not (yet) supported.

func GetHumidityDevices

func GetHumidityDevices(ctx *gin.Context)

GetHumidityDevices returns all humidity devices in the database.

func GetLatestHumidity

func GetLatestHumidity(ctx *gin.Context)

GetLatestHumidity gets the latest humidity data from all the sensors.

func GetLatestTemperature

func GetLatestTemperature(ctx *gin.Context)

GetLatestTemperature gets the latest temperature from all the devices.

func GetTemperatureData

func GetTemperatureData(ctx *gin.Context, deviceID int64, rangeMin float64, rangeMax float64)

GetTemperatureData returns temperature data for the given time range.

func GetTemperatureDevices

func GetTemperatureDevices(ctx *gin.Context)

GetTemperatureDevices returns all temperature devices in the database.

func GetTimestampRange

func GetTimestampRange() (int, int)

GetTimestampRange gets the oldest and most recent timestamp from the data set in the database.

func Round

func Round(f float64) float64

func RoundPlus

func RoundPlus(f float64, places int) float64

Types

type Device

type Device struct {
	DeviceID uint   `gorm:"primary_key;index:devices_pkey;column:deviceid"`
	Type     string `gorm:"column:type"`
	SerialID string `gorm:"column:serialid"`
	Label    string `gorm:"column:label"`
}

func (Device) TableName

func (Device) TableName() string

type Flag

type Flag struct {
	ID        uint   `gorm:"primary_key;index:flag_pkey;column:id"`
	DeviceID  uint   `gorm:"column:deviceid"`
	Timestamp int    `gorm:"index:flag_dt;column:Timestamp"`
	Value     string `gorm:"column:value"`
}

func (Flag) TableName

func (Flag) TableName() string

type Humidity

type Humidity struct {
	ID        uint    `gorm:"primary_key;index:humidity_pkey;column:id"`
	DeviceID  uint    `gorm:"column:deviceid"`
	Timestamp int     `gorm:"index:humidity_dt;column:timestamp"`
	H         float64 `gorm:"column:h"`
}

func (Humidity) TableName

func (Humidity) TableName() string

type Temperature

type Temperature struct {
	ID        uint    `gorm:"primary_key;index:temperature_pkey;column:id"`
	DeviceID  uint    `gorm:"column:deviceid"`
	Timestamp int     `gorm:"index:temperature_dt;column:timestamp"`
	C         float64 `gorm:"column:c"`
	F         float64 `gorm:"column:f"`
}

func (Temperature) TableName

func (Temperature) TableName() string

type TimedTemperature

type TimedTemperature struct {
	Timestamp   int     `json:"timestamp"`
	Temperature float64 `json:"temperature"`
}

TimedTemperature is a struct for timestamp and temperature pairs.

func FromTemperature

func FromTemperature(temperature Temperature) *TimedTemperature

FromTemperatureC converts a Celsius Temperature into a TimedTemperature.

func (*TimedTemperature) MarshalJSON

func (tt *TimedTemperature) MarshalJSON() ([]byte, error)

MarshalJSON converts a TimedTemperature into a JSON.

Jump to

Keyboard shortcuts

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