From 3e407753f61cba0431312511998f31972caaa744 Mon Sep 17 00:00:00 2001 From: Christian Pointner Date: Tue, 19 Apr 2016 00:06:30 +0200 Subject: added startup timer diff --git a/src/rhctl/switch_control.go b/src/rhctl/switch_control.go index caee99b..4211d9d 100644 --- a/src/rhctl/switch_control.go +++ b/src/rhctl/switch_control.go @@ -88,6 +88,7 @@ type SwitchControl struct { sw *AudioSwitch servers []*PlayoutServer state State + startup time.Time Updates *pubsub.PubSub Commands chan *Command } @@ -126,6 +127,8 @@ func handleServer(in <-chan ServerState, out chan<- ServerState) { func (ctrl *SwitchControl) reconcile(requestedServer string) (result bool) { rhdl.Printf("SwitchCTRL: reconciling state... (requested server: '%s')", requestedServer) + + // send out commands to switch and/or server to get missing infos if time.Since(ctrl.state.Switch.Changed) > (2 * time.Hour) { // TODO: hardcoded value ctrl.sw.Commands <- &SwitchCommand{SwitchCmdStateAudio, nil, nil} ctrl.sw.Commands <- &SwitchCommand{SwitchCmdStateGPIAll, nil, nil} @@ -141,7 +144,10 @@ func (ctrl *SwitchControl) reconcile(requestedServer string) (result bool) { } } - // TODO: send out commands to switch and/or server to get missing infos + if ctrl.state.Mood == MoodAwakening && time.Since(ctrl.startup) < (time.Minute) { // TODO: hardcoded value + // it's to early to take actions - let's learn i little bit more about current state + return + } // TODO: change active server if it fails or on request // return true if requested server got selected @@ -155,6 +161,7 @@ func (ctrl *SwitchControl) reconcile(requestedServer string) (result bool) { func (ctrl *SwitchControl) Run() { rhdl.Printf("SwitchCTRL: handler running...") + ctrl.startup = time.Now() serverStateChanges := make(chan ServerState, 8) for _, srv := range ctrl.servers { go handleServer(srv.StateChanges, serverStateChanges) -- cgit v0.10.2