From 9d5a2f9870e52bfc0fe6db8c27981f29d91dcb55 Mon Sep 17 00:00:00 2001 From: xengineering Date: Sun, 13 Jun 2021 12:54:28 +0200 Subject: Implement working State Machine --- src/main.go | 25 ++++++++++++++++++++----- 1 file changed, 20 insertions(+), 5 deletions(-) (limited to 'src/main.go') diff --git a/src/main.go b/src/main.go index dfcf706..af82e8f 100644 --- a/src/main.go +++ b/src/main.go @@ -5,25 +5,40 @@ package main import ( "flag" "log" - "time" "os" "io/ioutil" "encoding/json" ) +var ( + camera Machine +) + type config struct { WebConfig webConfig `json:"webserver"` } func main() { + + // read command line arguments configPath := readFlags() + + // set up log and print startup message log.SetFlags(0) // disable timestamp because systemd takes care of that log.Println("Starting birdscan") + + // read config file cfg := readConfig(configPath) - go runServer(&cfg.WebConfig) - for { - time.Sleep(1 * time.Second) - } + + // setup camera state machine + camera = newCamStateMachine() + + // start goroutines + server := NewWebServer(&cfg.WebConfig) + go server.run() // http server + + // run camera state machine + camera.run() } func readFlags() string { -- cgit v1.2.3-70-g09d2