gh-10 Background updates for data
This commit is contained in:
parent
f36c2b4f17
commit
e30c83c96a
|
@ -64,5 +64,6 @@ func main() {
|
|||
log.Println("enervent-ctrl version", version)
|
||||
pingvin = pingvinKL.New()
|
||||
pingvin.Update()
|
||||
go pingvin.Monitor(15)
|
||||
listen()
|
||||
}
|
||||
|
|
|
@ -272,6 +272,13 @@ func (p *PingvinKL) populateStatus() {
|
|||
json.NewEncoder(log.Writer()).Encode(p.Status)
|
||||
}
|
||||
|
||||
func (p *PingvinKL) Monitor(interval int) {
|
||||
for {
|
||||
time.Sleep(time.Duration(interval) * time.Second)
|
||||
p.Update()
|
||||
}
|
||||
}
|
||||
|
||||
// create a PingvinKL struct, read coils and registers from CSVs
|
||||
func New() PingvinKL {
|
||||
pingvin := PingvinKL{}
|
||||
|
|
Loading…
Reference in New Issue