fix(pkg/types): use measured values as struct instead interface

This commit is contained in:
2019-07-02 22:33:01 +02:00
parent d703d33e08
commit 825511c3b5
23 changed files with 218 additions and 659 deletions

View File

@ -12,9 +12,9 @@ import (
)
// Read measured values from sensors
func Read(ctx context.Context, sensors []Sensor) ([]types.MeasuredValue, error) {
func Read(ctx context.Context, sensors []Sensor) ([]*types.MeasuredValue, error) {
measuredValuesChannel := make(chan []types.MeasuredValue, len(sensors))
measuredValuesChannel := make(chan []*types.MeasuredValue, len(sensors))
errorChannel := make(chan error, len(sensors))
ReadChannel(ctx, sensors, measuredValuesChannel, errorChannel)
@ -31,7 +31,7 @@ func Read(ctx context.Context, sensors []Sensor) ([]types.MeasuredValue, error)
// ReadChannel reads the measured values from sensors and writes them to a
// channel.
func ReadChannel(ctx context.Context, sensors []Sensor, measuredValuesChannel chan<- []types.MeasuredValue, errorChannel chan<- error) {
func ReadChannel(ctx context.Context, sensors []Sensor, measuredValuesChannel chan<- []*types.MeasuredValue, errorChannel chan<- error) {
wg := new(sync.WaitGroup)
wg.Add(len(sensors))
@ -45,7 +45,7 @@ func ReadChannel(ctx context.Context, sensors []Sensor, measuredValuesChannel ch
// ReadContinuously reads the measured values continously from sensors and writes
// them to a channel.
func ReadContinuously(ctx context.Context, sensors []Sensor, measuredValuesChannel chan<- []types.MeasuredValue, errorChannel chan<- error) {
func ReadContinuously(ctx context.Context, sensors []Sensor, measuredValuesChannel chan<- []*types.MeasuredValue, errorChannel chan<- error) {
for {
select {
case <-ctx.Done():