orm

package module
v0.0.0-...-7096621 Latest Latest
Warning

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

Go to latest
Published: Jul 17, 2016 License: MIT Imports: 2 Imported by: 0

README

raspberry-datalogger-dataservice-orm

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetNow

func GetNow() uint64

func GetOrderedWindowedQuery

func GetOrderedWindowedQuery(db *gorm.DB, idfield string, id uint, start uint64, end uint64) *gorm.DB

Types

type Counter

type Counter struct {
	gorm.Model
	Code       string `sql:"index"`
	Name       string `sql:"index"`
	Unit       string
	TickAmount uint64 // Tick amount multiplied by 1000
	Reading    uint64 // Reading multiplied by 1000
	LastTick   uint64 // Timestamp of last tick
}

type CounterEvent

type CounterEvent struct {
	ID        uint      `gorm:"primary_key"` // primary key
	CounterID uint      `sql:"index"`        // foreign key of the counter
	Timestamp uint64    `sql:"index`         // timestamp of the event
	EventType EventType // see above
	Delta     int64     // delta multiplied by 1000
	Reading   uint64    // reading multiplied by 1000
}

func NewAbsCorrCounterEvent

func NewAbsCorrCounterEvent(counter Counter, delta int64) CounterEvent

func NewLastCounterEvent

func NewLastCounterEvent(counter Counter) CounterEvent

func NewTickCounterEvent

func NewTickCounterEvent(counter Counter) CounterEvent

type EventType

type EventType uint8
const (
	TICK     EventType = 1 + iota // Tick of counter
	ABS_CORR                      // Absolute correction of reading
	ABS_READ                      // Absolute reading
	LAST                          // Automatically appendend event with current time
)

type Flag

type Flag struct {
	gorm.Model
	Code       string `sql:"index"`
	Name       string `sql:"index"`
	State      uint8
	LastChange uint64 // Timestamp of last change
}

type FlagState

type FlagState struct {
	ID        uint   `gorm:"primary_key"` // primary key
	FlagID    uint   `sql:"index"`        // foreign key of the flag
	Timestamp uint64 `sql:"index`         // timestamp of the event
	State     uint8
}

func NewFlagState

func NewFlagState(flag Flag, state uint8) FlagState

type Thermometer

type Thermometer struct {
	gorm.Model
	Code        string `sql:"index"`
	Name        string `sql:"index"`
	Reading     uint64 // Reading multiplied by 1000
	LastReading uint64 // Timestamp of last tick
}

type ThermometerReading

type ThermometerReading struct {
	ID            uint   `gorm:"primary_key"` // primary key
	ThermometerID uint   `sql:"index"`        // foreign key of the thermometer
	Timestamp     uint64 `sql:"index`         // timestamp of the event
	Reading       uint64 // reading multiplied by 1000
}

func NewThermometerReading

func NewThermometerReading(thermometer Thermometer, reading uint64) ThermometerReading

Jump to

Keyboard shortcuts

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