summaryrefslogtreecommitdiff
path: root/src/rhctl/switch_control.go
diff options
context:
space:
mode:
Diffstat (limited to 'src/rhctl/switch_control.go')
-rw-r--r--src/rhctl/switch_control.go18
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
}