mirror of https://bitbucket.org/ausocean/av.git
cmd/rv/main.go: add probe update after revid variable update
This commit is contained in:
parent
175cfc4925
commit
798e691c06
|
@ -146,11 +146,6 @@ func main() {
|
|||
p *turbidityProbe
|
||||
)
|
||||
|
||||
p, err := NewTurbidityProbe(*log, 60*time.Second, rv.Config().TransformMatrix)
|
||||
if err != nil {
|
||||
log.Log(logger.Fatal, "could not create new turbidity probe", "error", err.Error())
|
||||
}
|
||||
|
||||
log.Log(logger.Debug, "initialising netsender client")
|
||||
ns, err := netsender.New(log, nil, readPin(p, rv, log), nil, createVarMap())
|
||||
if err != nil {
|
||||
|
@ -163,6 +158,11 @@ func main() {
|
|||
log.Log(logger.Fatal, pkg+"could not initialise revid", "error", err.Error())
|
||||
}
|
||||
|
||||
p, err = NewTurbidityProbe(*log, 60*time.Second, rv.Config().TransformMatrix)
|
||||
if err != nil {
|
||||
log.Log(logger.Fatal, "could not create new turbidity probe", "error", err.Error())
|
||||
}
|
||||
|
||||
err = rv.SetProbe(p)
|
||||
if err != nil {
|
||||
log.Log(logger.Error, pkg+"could not set probe", "error", err.Error())
|
||||
|
@ -175,12 +175,12 @@ func main() {
|
|||
time.Sleep(runPreDelay)
|
||||
|
||||
log.Log(logger.Debug, "beginning main loop")
|
||||
run(rv, ns, log, netLog)
|
||||
run(rv, ns, log, netLog, p)
|
||||
}
|
||||
|
||||
// run starts the main loop. This will run netsender on every pass of the loop
|
||||
// (sleeping inbetween), check vars, and if changed, update revid as appropriate.
|
||||
func run(rv *revid.Revid, ns *netsender.Sender, l *logger.Logger, nl *netlogger.Logger) {
|
||||
func run(rv *revid.Revid, ns *netsender.Sender, l *logger.Logger, nl *netlogger.Logger, p *turbidityProbe) {
|
||||
var vs int
|
||||
for {
|
||||
l.Log(logger.Debug, "running netsender")
|
||||
|
@ -225,6 +225,9 @@ func run(rv *revid.Revid, ns *netsender.Sender, l *logger.Logger, nl *netlogger.
|
|||
}
|
||||
l.Log(logger.Info, "revid successfully reconfigured")
|
||||
|
||||
// Update transform matrix based on new revid variables.
|
||||
p.transform = rv.Config().TransformMatrix
|
||||
|
||||
l.Log(logger.Debug, "checking mode")
|
||||
switch ns.Mode() {
|
||||
case modePaused:
|
||||
|
|
|
@ -127,7 +127,6 @@ func (tp *turbidityProbe) Write(p []byte) (int, error) {
|
|||
select {
|
||||
case <-tp.ticker.C:
|
||||
tp.log.Log(logger.Debug, "beginning turbidity calculation")
|
||||
tp.log.Log(logger.Debug, "transformation matrix", tp.transform[0])
|
||||
startTime := time.Now()
|
||||
err := tp.turbidityCalculation()
|
||||
if err != nil {
|
||||
|
|
Loading…
Reference in New Issue