diff options
-rw-r--r-- | src/rhctl/audio_switch.go | 12 | ||||
-rw-r--r-- | src/rhctl/telnet.go | 31 |
2 files changed, 32 insertions, 11 deletions
diff --git a/src/rhctl/audio_switch.go b/src/rhctl/audio_switch.go index f3821d8..3bb4abb 100644 --- a/src/rhctl/audio_switch.go +++ b/src/rhctl/audio_switch.go @@ -80,13 +80,13 @@ type SwitchUpdate struct { } type SwitchState struct { - audio [SwitchOutputNumMax]struct { - inputs [SwitchInputNumMax]bool - silence bool + Audio [SwitchOutputNumMax]struct { + Inputs [SwitchInputNumMax]bool + Silence bool } - gpi [SwitchGPINumMax]bool - relay [SwitchRelayNumMax]bool - oc [SwitchOCNumMax]bool + GPI [SwitchGPINumMax]bool + Relay [SwitchRelayNumMax]bool + OC [SwitchOCNumMax]bool } type AudioSwitch struct { diff --git a/src/rhctl/telnet.go b/src/rhctl/telnet.go index a6a53fe..4735956 100644 --- a/src/rhctl/telnet.go +++ b/src/rhctl/telnet.go @@ -23,6 +23,7 @@ package main import ( "sort" + "strings" "github.com/spreadspace/telgo" ) @@ -31,6 +32,18 @@ type TelnetInterface struct { server *telgo.Server } +func genStateString(values []bool) string { + var states []string + for _, val := range values { + if val { + states = append(states, "1") + } else { + states = append(states, "0") + } + } + return strings.Join(states, ",") +} + func telnetCmdState(c *telgo.Client, args []string, ctrl *SwitchControl) bool { resp := make(chan interface{}) ctrl.Commands <- &Command{Type: CmdState, Response: resp} @@ -44,11 +57,19 @@ func telnetCmdState(c *telgo.Client, args []string, ctrl *SwitchControl) bool { c.Sayln("Mood: %v", s.Mood) c.Sayln("Switch:") - c.Sayln(" audio:") // - c.Sayln(" output 1: ? (silence!!)?") // - c.Sayln(" output 2: ? (silence!!)?") // TODO: fill this with actual data - c.Sayln(" relays: ?") // - c.Sayln(" oc: ?") // + c.Sayln(" audio:") + for num, out := range s.Switch.Audio { + c.Say(" out %d: ", num+1) + + if out.Silence { + c.Sayln("%s (silence!!!)", genStateString(out.Inputs[:])) + } else { + c.Sayln("%s", genStateString(out.Inputs[:])) + } + } + c.Sayln(" gpi: %s", genStateString(s.Switch.GPI[:])) + c.Sayln(" relay: %s", genStateString(s.Switch.Relay[:])) + c.Sayln(" oc: %s", genStateString(s.Switch.OC[:])) c.Sayln("Server:") var names []string |