fix(cmd/temperature/read): use measured values instaed own type

This commit is contained in:
2019-06-25 22:56:09 +02:00
parent 08c2cbbf57
commit 003fe8ab9e
9 changed files with 112 additions and 241 deletions

View File

@ -11,15 +11,15 @@ import (
)
// Read measured values from sensors
func Read(ctx context.Context, sensors []Sensor) ([]types.MeasuredValue, error) {
measuredValueChannel := make(chan types.MeasuredValue, len(sensors))
errorChannel := make(chan error, len(sensors))
func Read(sensors []Sensor) ([]types.MeasuredValue, error) {
measuredValueChannel := make(chan types.MeasuredValue, 0)
errorChannel := make(chan error, 0)
wg := new(sync.WaitGroup)
wg.Add(len(sensors))
for _, sensor := range sensors {
go sensor.ReadContinously(ctx, measuredValueChannel, errorChannel)
go sensor.ReadChannel(measuredValueChannel, errorChannel, wg)
}
wg.Wait()