fix(pkg/daemon): use measuredValue interface instead of different structs

This commit is contained in:
2019-06-25 22:22:34 +02:00
parent 30603e348c
commit 08c2cbbf57
20 changed files with 682 additions and 860 deletions

View File

@ -12,3 +12,15 @@ type Humidity struct {
CreationDate *time.Time `json:"creation_date" xml:"creation_date"`
UpdateDate *time.Time `json:"update_date" xml:"update_date"`
}
func (h *Humidity) GetID() string {
return h.HumidityID
}
func (h *Humidity) GetSensorID() string {
return h.SensorID
}
func (h *Humidity) GetValue() float64 {
return h.HumidityValue
}

View File

@ -0,0 +1,7 @@
package types
type MeasuredValue interface {
GetID() string
GetSensorID() string
GetValue() float64
}

View File

@ -1,31 +1,26 @@
package types
import (
"time"
)
import "time"
// Temperature ...
type Temperature struct {
TemperatureID string `json:"temperature_id" xml:"temperature_id"`
TemperatureValue float64 `json:"temperature_value,string" xml:"temperature_value,string"`
TemperatureUnit TemperatureUnit `json:"temperature_unit" xml:"temperature_unit"`
TemperatureFromDate time.Time `json:"temperature_from_date" xml:"temperature_from_date"`
TemperatureTillDate time.Time `json:"temperature_till_date" xml:"temperature_till_date"`
SensorID string `json:"sensor_id" xml:"sensor_id"`
CreationDate *time.Time `json:"creation_date" xml:"creation_date"`
UpdateDate *time.Time `json:"update_date" xml:"update_date"`
TemperatureID string `json:"temperature_id" xml:"temperature_id"`
TemperatureValue float64 `json:"temperature_value,string" xml:"temperature_value,string"`
TemperatureFromDate time.Time `json:"temperature_from_date" xml:"temperature_from_date"`
TemperatureTillDate time.Time `json:"temperature_till_date" xml:"temperature_till_date"`
SensorID string `json:"sensor_id" xml:"sensor_id"`
CreationDate *time.Time `json:"creation_date" xml:"creation_date"`
UpdateDate *time.Time `json:"update_date" xml:"update_date"`
}
// TemperatureUnit of measurement for temperature
type TemperatureUnit string
func (t *Temperature) GetID() string {
return t.TemperatureID
}
const (
// TemperatureUnitCelsius indicates the temperature in Celsius
TemperatureUnitCelsius TemperatureUnit = "celsius"
func (t *Temperature) GetSensorID() string {
return t.SensorID
}
// TemperatureUnitFahrenheit indicates the temperature in Fahrenheit
TemperatureUnitFahrenheit = "fahrenheit"
// TemperatureUnitKelvin indicates the temperature in Kelvin
TemperatureUnitKelvin = "kelvin"
)
func (t *Temperature) GetValue() float64 {
return t.TemperatureValue
}