gh-10 Background updates for data

This commit is contained in:
Jarno Rankinen 2023-02-19 12:28:26 +02:00
parent f36c2b4f17
commit e30c83c96a
2 changed files with 8 additions and 0 deletions

View File

@ -64,5 +64,6 @@ func main() {
log.Println("enervent-ctrl version", version)
pingvin = pingvinKL.New()
pingvin.Update()
go pingvin.Monitor(15)
listen()
}

View File

@ -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{}