2022-01-05 07:52:29 +03:00
|
|
|
//go:build !nocv
|
2022-01-05 05:46:08 +03:00
|
|
|
// +build !nocv
|
|
|
|
|
2022-01-05 07:52:29 +03:00
|
|
|
/*
|
|
|
|
DESCRIPTION
|
2022-01-06 06:25:40 +03:00
|
|
|
Results struct used to store results from the turbidity sensor.
|
2022-01-05 07:52:29 +03:00
|
|
|
|
|
|
|
AUTHORS
|
2022-01-06 06:25:40 +03:00
|
|
|
Russell Stanley <russell@ausocean.org>
|
2022-01-05 07:52:29 +03:00
|
|
|
|
|
|
|
LICENSE
|
2022-01-07 04:10:20 +03:00
|
|
|
Copyright (C) 2021-2022 the Australian Ocean Lab (AusOcean)
|
2022-01-05 07:52:29 +03:00
|
|
|
|
|
|
|
It is free software: you can redistribute it and/or modify them
|
|
|
|
under the terms of the GNU General Public License as published by the
|
|
|
|
Free Software Foundation, either version 3 of the License, or (at your
|
|
|
|
option) any later version.
|
|
|
|
|
|
|
|
It is distributed in the hope that it will be useful, but WITHOUT
|
|
|
|
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
|
|
|
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
|
|
|
for more details.
|
|
|
|
|
|
|
|
You should have received a copy of the GNU General Public License
|
|
|
|
in gpl.txt. If not, see http://www.gnu.org/licenses.
|
|
|
|
*/
|
|
|
|
|
2022-01-07 04:10:20 +03:00
|
|
|
package turbidity
|
2021-12-17 09:03:31 +03:00
|
|
|
|
2022-01-06 06:25:40 +03:00
|
|
|
import "fmt"
|
|
|
|
|
2022-01-06 07:11:35 +03:00
|
|
|
// Results holds the results of the turbidity sensor.
|
2021-12-17 09:03:31 +03:00
|
|
|
type Results struct {
|
2022-01-07 04:10:20 +03:00
|
|
|
Turbidity []float64
|
|
|
|
Sharpness []float64
|
|
|
|
Contrast []float64
|
2021-12-17 09:03:31 +03:00
|
|
|
}
|
|
|
|
|
2022-01-10 07:41:21 +03:00
|
|
|
// NewResults returns a new Results.
|
2022-01-06 06:25:40 +03:00
|
|
|
func NewResults(n int) (*Results, error) {
|
|
|
|
if n <= 0 {
|
2022-01-07 04:10:20 +03:00
|
|
|
return nil, fmt.Errorf("invalid result size: %v", n)
|
2022-01-06 06:25:40 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
r := new(Results)
|
|
|
|
r.Turbidity = make([]float64, n)
|
2022-01-07 04:10:20 +03:00
|
|
|
r.Sharpness = make([]float64, n)
|
2022-01-06 06:25:40 +03:00
|
|
|
r.Contrast = make([]float64, n)
|
|
|
|
|
|
|
|
return r, nil
|
2021-12-17 09:03:31 +03:00
|
|
|
}
|
|
|
|
|
2022-01-06 07:11:35 +03:00
|
|
|
// Update adds new values to slice at specified index.
|
2022-01-06 06:25:40 +03:00
|
|
|
func (r *Results) Update(newSat, newCont, newTurb float64, index int) {
|
2022-01-07 04:10:20 +03:00
|
|
|
r.Sharpness[index] = newSat
|
2022-01-06 06:25:40 +03:00
|
|
|
r.Contrast[index] = newCont
|
|
|
|
r.Turbidity[index] = newTurb
|
2021-12-21 04:43:05 +03:00
|
|
|
}
|