diff options
author | Christian Pointner <equinox@helsinki.at> | 2016-04-18 21:58:07 (GMT) |
---|---|---|
committer | Christian Pointner <equinox@helsinki.at> | 2016-04-18 21:58:07 (GMT) |
commit | 7b6cc0eb1d6d8e2a7fa22ade10e79eb06f0d6bbf (patch) | |
tree | 8ca432868a62409237eae4493291bc91c337c0d3 /src/rhctl/switch_control.go | |
parent | 0174146eb468888ac27bc5ae78b7a20dcd06f565 (diff) |
fetch state from switch and server if they are stale/missing
Diffstat (limited to 'src/rhctl/switch_control.go')
-rw-r--r-- | src/rhctl/switch_control.go | 18 |
1 files changed, 17 insertions, 1 deletions
diff --git a/src/rhctl/switch_control.go b/src/rhctl/switch_control.go index 2864cc9..caee99b 100644 --- a/src/rhctl/switch_control.go +++ b/src/rhctl/switch_control.go @@ -23,6 +23,7 @@ package main import ( "fmt" + "time" "github.com/btittelbach/pubsub" ) @@ -125,7 +126,20 @@ 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) - // TODO: set mood dependent on overall-state + 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} + ctrl.sw.Commands <- &SwitchCommand{SwitchCmdStateOC, nil, nil} + ctrl.sw.Commands <- &SwitchCommand{SwitchCmdStateRelay, nil, nil} + ctrl.sw.Commands <- &SwitchCommand{SwitchCmdStateSilence, nil, nil} + } + + for _, server := range ctrl.servers { + s, exists := ctrl.state.Server[server.name] + if !exists || time.Since(s.Changed) > (2*time.Hour) { // TODO: hardcoded value + server.UpdateRequest <- true + } + } // TODO: send out commands to switch and/or server to get missing infos @@ -133,6 +147,8 @@ func (ctrl *SwitchControl) reconcile(requestedServer string) (result bool) { // return true if requested server got selected // TODO: change switch output mappings if servers change channels or fail + + // TODO: set mood dependent on overall-state return } |