summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristian Pointner <equinox@helsinki.at>2016-04-19 00:43:04 (GMT)
committerChristian Pointner <equinox@helsinki.at>2016-04-19 00:43:04 (GMT)
commitd2c51030a017133dd51d208dbe6954b070fb9cb9 (patch)
treee2b70e1d665af4602e5226227ef917ea6f7cbc4a
parentdf0caeadd4412bc25573665cad3e6e49551a7163 (diff)
rename switch ports to switch inputs @ config
-rw-r--r--sample-config.toml8
-rw-r--r--src/rhctl/conf.go24
2 files changed, 16 insertions, 16 deletions
diff --git a/sample-config.toml b/sample-config.toml
index 33403a4..8d2e2df 100644
--- a/sample-config.toml
+++ b/sample-config.toml
@@ -3,10 +3,10 @@ dev = "/dev/ttyUSB0"
baud = 19200
timeout = "500ms"
unit = 0
-ports = [ { number = 1, server = "master", channel = "main" },
- { number = 2, server = "master", channel = "music" },
- { number = 3, server = "standby", channel = "main" },
- { number = 4, server = "standby", channel = "music" } ]
+inputs = [ { number = 1, server = "master", channel = "main" },
+ { number = 2, server = "master", channel = "music" },
+ { number = 3, server = "standby", channel = "main" },
+ { number = 4, server = "standby", channel = "music" } ]
[servers]
diff --git a/src/rhctl/conf.go b/src/rhctl/conf.go
index bbf546c..36a3b5a 100644
--- a/src/rhctl/conf.go
+++ b/src/rhctl/conf.go
@@ -31,23 +31,23 @@ import (
"github.com/naoina/toml"
)
-type ConfigSwitchPorts []struct {
+type ConfigSwitchInputs []struct {
Number SwitchInputNum `toml:"number"`
Server string `toml:"server"`
Channel string `toml:"channel"`
}
-func (p ConfigSwitchPorts) Len() int { return len(p) }
-func (p ConfigSwitchPorts) Swap(i, j int) { p[i], p[j] = p[j], p[i] }
-func (p ConfigSwitchPorts) Less(i, j int) bool { return p[i].Number < p[j].Number }
+func (p ConfigSwitchInputs) Len() int { return len(p) }
+func (p ConfigSwitchInputs) Swap(i, j int) { p[i], p[j] = p[j], p[i] }
+func (p ConfigSwitchInputs) Less(i, j int) bool { return p[i].Number < p[j].Number }
type Config struct {
Audioswitch struct {
- Device string `toml:"dev"`
- Baudrate Baudrate `toml:"baud"`
- Timeout Duration `toml:"timeout"`
- Unit SwitchUnitID `toml:"unit"`
- Ports ConfigSwitchPorts `toml:"ports"`
+ Device string `toml:"dev"`
+ Baudrate Baudrate `toml:"baud"`
+ Timeout Duration `toml:"timeout"`
+ Unit SwitchUnitID `toml:"unit"`
+ Inputs ConfigSwitchInputs `toml:"inputs"`
}
Servers map[string]struct {
@@ -93,9 +93,9 @@ func ReadConfig(configfile string) (conf *Config, err error) {
return
}
- sort.Sort(conf.Audioswitch.Ports)
- for i := 1; i < len(conf.Audioswitch.Ports); i++ {
- if conf.Audioswitch.Ports[i].Number == conf.Audioswitch.Ports[i-1].Number {
+ sort.Sort(conf.Audioswitch.Inputs)
+ for i := 1; i < len(conf.Audioswitch.Inputs); i++ {
+ if conf.Audioswitch.Inputs[i].Number == conf.Audioswitch.Inputs[i-1].Number {
return nil, errors.New("audioswitch port assignments must be unique")
}
}