Documentation ¶
Index ¶
- type DBEntry
- type DBQuery
- type EventEntries
- type EventEntry
- type PGConnector
- func (pg *PGConnector) AddRainMMEvent(amount float64, gwTimestamp time.Time) error
- func (pg *PGConnector) AddStatusUpdate(asset int, gwTimestamp time.Time) error
- func (pg *PGConnector) AddTagValue(tag int, value int, gwTimestamp time.Time) error
- func (pg *PGConnector) AddTempCValue(tempC int, gwTimestamp time.Time) error
- func (pg *PGConnector) Close()
- func (pg *PGConnector) GetEventMessagesFrom(tag int, from, to time.Time) (*EventEntries, error)
- func (pg *PGConnector) GetEventMessagesSince(tag int, since time.Time) (*EventEntries, error)
- func (pg *PGConnector) GetLastRainTime() (time.Time, error)
- func (pg *PGConnector) GetLastTempC() (int, error)
- func (pg *PGConnector) GetRainMMFrom(from, to time.Time) (*RainEntriesMm, error)
- func (pg *PGConnector) GetRainMMSince(since time.Time) (*RainEntriesMm, error)
- func (pg *PGConnector) GetTempDataCFrom(from time.Time, to time.Time) (*TempEntriesC, error)
- func (pg *PGConnector) GetTempDataCSince(since time.Time) (*TempEntriesC, error)
- func (pg *PGConnector) Insert(cmd string) error
- func (pg *PGConnector) IsGatewayUp(since time.Duration) (bool, error)
- func (pg *PGConnector) IsSensorUp(since time.Duration) (bool, error)
- func (pg *PGConnector) Select(cmd string) (interface{}, error)
- func (pg *PGConnector) TotalRainMMFrom(from, to time.Time) (float64, error)
- func (pg *PGConnector) TotalRainMMSince(since time.Time) (float64, error)
- type RainEntriesMm
- type RainEntryMm
- type TempEntriesC
- type TempEntryC
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type DBEntry ¶
type DBEntry interface { // Insert runs arbitrary sql INSERT commands Insert(cmd string) error // AddTagValue puts a single tag and value in the database AddTagValue(tag int, value int, gwTimestamp time.Time) error // AddTempCValue puts a Celsius temperature value in the database AddTempCValue(tempC int, gwTimestamp time.Time) error // AddStatusUpdate adds a status message for an asset with an integer ID AddStatusUpdate(asset int, gwTimeamp time.Time) error // AddRainMMEvent puts a rain event with a timestamp from the sensor AddRainMMEvent(amount float64, gwTimestamp time.Time) error // Close closes the connection with the database. Necessary for pooled connections Close() }
DBEntry enters data into the database
type DBQuery ¶
type DBQuery interface { // Select runs arbitary sql SELECT commands Select(cmd string) (interface{}, error) // TotalRainMMSince gets total rain from a time in the past to present TotalRainMMSince(since time.Time) (float64, error) // TotalRainMMFrom gets total rain between two timestamps TotalRainMMFrom(from time.Time, to time.Time) (float64, error) // GetRainMMSince gets a RainEntriesMm from a time in the past to present GetRainMMSince(since time.Time) (*RainEntriesMm, error) // GetRainMMFrom gets a RainEntriesMm between two timestamps GetRainMMFrom(from time.Time, to time.Time) (*RainEntriesMm, error) // GetLastRainTime shows the date of the last rain GetLastRainTime() (time.Time, error) // GetTempDataCSince gets a TempEntriesC from a time in the past to the present GetTempDataCSince(since time.Time) (*TempEntriesC, error) // GetTempDataCFrom gets a TempEntriesC between two timestamps GetTempDataCFrom(from time.Time, to time.Time) (*TempEntriesC, error) // GetLastTempC shows the most recent temperature GetLastTempC() (int, error) // IsGatewayUp tells whether the gateway has published a status message in a certain time IsGatewayUp(since time.Duration) (bool, error) // IsSensorUp tells whether the sensor has published a status message in a certain time IsSensorUp(since time.Duration) (bool, error) // GetEventMessagesSince gets an EventEntries from a time in the past to present. Specify tag or -1 for all tags GetEventMessagesSince(tag int, since time.Time) (*EventEntries, error) // GetEventMessagesFrom gets an EventEntries between two timestamps. Specify tag or -1 for all tags GetEventMessagesFrom(tag int, from time.Time, to time.Time) (*EventEntries, error) // Close closes the connection with the database. Necessary for pooled connections Close() }
DBQuery retreives data from the database
type EventEntry ¶
type EventEntry struct { Timestamp time.Time // timestamp on the gateway that the event was recorded Tag int // type of event Value int // value of the event, basically 1 for all events Longname string // human-comprehensible name, matches 1-to-1 with Tag }
EventEntry is a single sensor event
type PGConnector ¶
type PGConnector struct {
// contains filtered or unexported fields
}
func NewPGConnector ¶
func NewPGConnector() *PGConnector
func (*PGConnector) AddRainMMEvent ¶
func (pg *PGConnector) AddRainMMEvent(amount float64, gwTimestamp time.Time) error
func (*PGConnector) AddStatusUpdate ¶
func (pg *PGConnector) AddStatusUpdate(asset int, gwTimestamp time.Time) error
func (*PGConnector) AddTagValue ¶
func (*PGConnector) AddTempCValue ¶
func (pg *PGConnector) AddTempCValue(tempC int, gwTimestamp time.Time) error
func (*PGConnector) Close ¶
func (pg *PGConnector) Close()
func (*PGConnector) GetEventMessagesFrom ¶
func (pg *PGConnector) GetEventMessagesFrom(tag int, from, to time.Time) (*EventEntries, error)
func (*PGConnector) GetEventMessagesSince ¶
func (pg *PGConnector) GetEventMessagesSince(tag int, since time.Time) (*EventEntries, error)
func (*PGConnector) GetLastRainTime ¶
func (pg *PGConnector) GetLastRainTime() (time.Time, error)
func (*PGConnector) GetLastTempC ¶
func (pg *PGConnector) GetLastTempC() (int, error)
func (*PGConnector) GetRainMMFrom ¶
func (pg *PGConnector) GetRainMMFrom(from, to time.Time) (*RainEntriesMm, error)
func (*PGConnector) GetRainMMSince ¶
func (pg *PGConnector) GetRainMMSince(since time.Time) (*RainEntriesMm, error)
func (*PGConnector) GetTempDataCFrom ¶
func (pg *PGConnector) GetTempDataCFrom(from time.Time, to time.Time) (*TempEntriesC, error)
func (*PGConnector) GetTempDataCSince ¶
func (pg *PGConnector) GetTempDataCSince(since time.Time) (*TempEntriesC, error)
func (*PGConnector) Insert ¶
func (pg *PGConnector) Insert(cmd string) error
func (*PGConnector) IsGatewayUp ¶
func (pg *PGConnector) IsGatewayUp(since time.Duration) (bool, error)
func (*PGConnector) IsSensorUp ¶
func (pg *PGConnector) IsSensorUp(since time.Duration) (bool, error)
func (*PGConnector) Select ¶
func (pg *PGConnector) Select(cmd string) (interface{}, error)
func (*PGConnector) TotalRainMMFrom ¶
func (pg *PGConnector) TotalRainMMFrom(from, to time.Time) (float64, error)
func (*PGConnector) TotalRainMMSince ¶
func (pg *PGConnector) TotalRainMMSince(since time.Time) (float64, error)
type RainEntriesMm ¶
type RainEntriesMm []RainEntryMm
RainEntriesMm is a simple array of RainEntryMm values
type RainEntryMm ¶
type RainEntryMm struct { Timestamp time.Time // timestamp on the gateway that the event was recorded Millimeters float64 // amount of rain in millimeters }
RainEntryMm is a single timestamp/mm of rain entry
type TempEntriesC ¶
type TempEntriesC []TempEntryC
TempEntriesC is an ordered slice of TempEntryC values
type TempEntryC ¶
type TempEntryC struct { Timestamp time.Time // timestamp on the gateway that the measurement was recorded TempC int // temperature value in Celsius }
TempEntryC is a single temperature/timestamp entry
Click to show internal directories.
Click to hide internal directories.