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 *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")
|
log.Log(logger.Debug, "initialising netsender client")
|
||||||
ns, err := netsender.New(log, nil, readPin(p, rv, log), nil, createVarMap())
|
ns, err := netsender.New(log, nil, readPin(p, rv, log), nil, createVarMap())
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -163,6 +158,11 @@ func main() {
|
||||||
log.Log(logger.Fatal, pkg+"could not initialise revid", "error", err.Error())
|
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)
|
err = rv.SetProbe(p)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Log(logger.Error, pkg+"could not set probe", "error", err.Error())
|
log.Log(logger.Error, pkg+"could not set probe", "error", err.Error())
|
||||||
|
@ -175,12 +175,12 @@ func main() {
|
||||||
time.Sleep(runPreDelay)
|
time.Sleep(runPreDelay)
|
||||||
|
|
||||||
log.Log(logger.Debug, "beginning main loop")
|
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
|
// 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.
|
// (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
|
var vs int
|
||||||
for {
|
for {
|
||||||
l.Log(logger.Debug, "running netsender")
|
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")
|
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")
|
l.Log(logger.Debug, "checking mode")
|
||||||
switch ns.Mode() {
|
switch ns.Mode() {
|
||||||
case modePaused:
|
case modePaused:
|
||||||
|
|
|
@ -127,7 +127,6 @@ func (tp *turbidityProbe) Write(p []byte) (int, error) {
|
||||||
select {
|
select {
|
||||||
case <-tp.ticker.C:
|
case <-tp.ticker.C:
|
||||||
tp.log.Log(logger.Debug, "beginning turbidity calculation")
|
tp.log.Log(logger.Debug, "beginning turbidity calculation")
|
||||||
tp.log.Log(logger.Debug, "transformation matrix", tp.transform[0])
|
|
||||||
startTime := time.Now()
|
startTime := time.Now()
|
||||||
err := tp.turbidityCalculation()
|
err := tp.turbidityCalculation()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
Loading…
Reference in New Issue