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

@ -7,18 +7,9 @@ import (
"github.com/go-flucky/flucky/pkg/types"
)
// HumiditySensor is a interface to describe required functions to measure humidities
type HumiditySensor interface {
type Sensor interface {
GetSensorModel() types.SensorModel
ReadHumidity(round float64) (*types.Humidity, error)
ReadHumidityWriteIntoChannel(round float64, humidityChannel chan<- *types.Humidity, errorChannel chan<- error, wg *sync.WaitGroup)
ReadHumidityContinously(ctx context.Context, round float64, humidityChannel chan<- *types.Humidity, errorChannel chan<- error)
}
// TemperatureSensor is a interface to describe required functions to measure temperatures
type TemperatureSensor interface {
GetSensorModel() types.SensorModel
ReadTemperature(degree types.TemperatureUnit, round float64) (*types.Temperature, error)
ReadTemperatureWriteIntoChannel(degree types.TemperatureUnit, round float64, temperatureChannel chan<- *types.Temperature, errorChannel chan<- error, wg *sync.WaitGroup)
ReadTemperatureContinously(ctx context.Context, degree types.TemperatureUnit, round float64, temperatureChannel chan<- *types.Temperature, errorChannel chan<- error)
Read() ([]types.MeasuredValue, error)
ReadChannel(measuredValueChannel chan<- types.MeasuredValue, errorChannel chan<- error, wg *sync.WaitGroup)
ReadContinously(ctx context.Context, measuredValueChannel chan<- types.MeasuredValue, errorChannel chan<- error)
}