-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.go
33 lines (30 loc) · 889 Bytes
/
main.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
package main
import (
"log"
"github.com/AspenWare/ardrinko-server/keg"
"github.com/AspenWare/ardrinko-server/service"
. "github.com/AspenWare/ardrinko-server/config"
)
var config Config
func main() {
if err := ReadConfig("config.ini", &config); err != nil {
log.Fatal(err)
}
log.Println("Loaded config.ini")
log.Println("Spinning up Ardrinko server...")
status, err := keg.Initialize(&config)
if err != nil {
log.Fatal(err)
}
eventPipe := make(chan int)
statusPipe := make(chan keg.KegStatus)
go keg.Monitor(&status, eventPipe)
go service.Run(statusPipe)
log.Println("Listening for keg on " + status.Connection.LocalAddr().String())
for {
<-eventPipe
statusPipe<-status
log.Printf("Temperature: %f deg, current flow: %f, capacity: %f, available: %f, door: %d\n",
status.Temperature, status.CurrentFlow, status.Capacity, status.Available, status.Door)
}
}