summaryrefslogtreecommitdiff
path: root/src/rhctl
diff options
context:
space:
mode:
authorChristian Pointner <equinox@helsinki.at>2016-04-18 22:06:30 (GMT)
committerChristian Pointner <equinox@helsinki.at>2016-04-18 22:07:07 (GMT)
commit3e407753f61cba0431312511998f31972caaa744 (patch)
tree6124b0e9fe677cb2298279a8909a1a6e601180f4 /src/rhctl
parent7b6cc0eb1d6d8e2a7fa22ade10e79eb06f0d6bbf (diff)
added startup timer
Diffstat (limited to 'src/rhctl')
-rw-r--r--src/rhctl/switch_control.go9
1 files changed, 8 insertions, 1 deletions
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)