Strip, Bus now interface slices.

t_strip, t_bus implemented.

parameter getter/setters added to custom strip, bus types.
This commit is contained in:
onyx-and-iris 2022-06-23 10:42:11 +01:00
parent 9d16f4c534
commit 694494e8d0
3 changed files with 225 additions and 34 deletions

View File

@ -4,15 +4,23 @@ import (
"fmt" "fmt"
) )
// custom bus type, struct forwarding channel type t_bus interface {
type bus struct { GetMute() bool
channel SetMute(val bool)
GetEq() bool
SetEq(val bool)
GetMono() bool
SetMono(val bool)
GetLabel() string
SetLabel(val string)
GetGain() float64
SetGain(val float32)
} }
// newBus returns a strip type // bus represents a bus channel
// it also initializes embedded channel type // embeds channel struct
func newBus(i int, k *kind) bus { type bus struct {
return bus{channel{"bus", i, *k}} channel
} }
// String implements the stringer interface // String implements the stringer interface
@ -42,3 +50,51 @@ func (b *bus) GetEq() bool {
func (b *bus) SetEq(val bool) { func (b *bus) SetEq(val bool) {
b.setter_bool("Eq.On", val) b.setter_bool("Eq.On", val)
} }
// GetMono returns the value of the Mute parameter
func (b *bus) GetMono() bool {
return b.getter_bool("Mono")
}
// SetMono sets the value of the Mute parameter
func (b *bus) SetMono(val bool) {
b.setter_bool("Mono", val)
}
// GetLabel returns the value of the MC parameter
func (b *bus) GetLabel() string {
return b.getter_string("Label")
}
// SetLabel sets the value of the MC parameter
func (b *bus) SetLabel(val string) {
b.setter_string("Label", val)
}
// GetGain returns the value of the Gain parameter
func (b *bus) GetGain() float64 {
return b.getter_float("Gain")
}
// SetGain sets the value of the Gain parameter
func (b *bus) SetGain(val float32) {
b.setter_float("Gain", val)
}
type physicalBus struct {
bus
}
func newPhysicalBus(i int, k *kind) t_bus {
pb := physicalBus{bus{channel{"bus", i, *k}}}
return t_bus(&pb)
}
type virtualBus struct {
bus
}
func newVirtualBus(i int, k *kind) t_bus {
vb := virtualBus{bus{channel{"bus", i, *k}}}
return t_bus(&vb)
}

View File

@ -9,8 +9,8 @@ import (
// comprised of slices representing each member // comprised of slices representing each member
type remote struct { type remote struct {
kind *kind kind *kind
Strip []strip Strip []t_strip
Bus []bus Bus []t_bus
Button []button Button []button
} }
@ -40,8 +40,8 @@ func (r *remote) SendText(script string) {
} }
// NewRemote returns a remote type of a kind, // NewRemote returns a remote type of a kind,
// this exported method is the interface entry point. // this is the interface entry point.
func NewRemote(kind_id string) remote { func NewRemote(kind_id string) *remote {
kindMap := map[string]*kind{ kindMap := map[string]*kind{
"basic": newBasicKind(), "basic": newBasicKind(),
"banana": newBananaKind(), "banana": newBananaKind(),
@ -55,20 +55,28 @@ func NewRemote(kind_id string) remote {
os.Exit(1) os.Exit(1)
} }
_strip := make([]strip, _kind.numStrip()) _strip := make([]t_strip, _kind.numStrip())
for i := 0; i < _kind.physIn+_kind.virtIn; i++ { for i := 0; i < _kind.physIn+_kind.virtIn; i++ {
_strip[i] = newStrip(i, _kind) if i < _kind.physIn {
_strip[i] = newPhysicalStrip(i, _kind)
} else {
_strip[i] = newVirtualStrip(i, _kind)
} }
_bus := make([]bus, _kind.numBus()) }
_bus := make([]t_bus, _kind.numBus())
for i := 0; i < _kind.physOut+_kind.virtOut; i++ { for i := 0; i < _kind.physOut+_kind.virtOut; i++ {
_bus[i] = newBus(i, _kind) if i < _kind.physIn {
_bus[i] = newPhysicalBus(i, _kind)
} else {
_bus[i] = newVirtualBus(i, _kind)
}
} }
_button := make([]button, 80) _button := make([]button, 80)
for i := 0; i < 80; i++ { for i := 0; i < 80; i++ {
_button[i] = newButton(i) _button[i] = newButton(i)
} }
return remote{ return &remote{
kind: _kind, kind: _kind,
Strip: _strip, Strip: _strip,
Bus: _bus, Bus: _bus,

View File

@ -4,14 +4,33 @@ import (
"fmt" "fmt"
) )
// custom strip type, struct forwarding channel type t_strip interface {
type strip struct { GetMute() bool
channel SetMute(val bool)
GetMono() bool
SetMono(val bool)
GetSolo() bool
SetSolo(val bool)
GetLimit() int
SetLimit(val int)
GetLabel() string
SetLabel(val string)
GetGain() float64
SetGain(val float32)
GetMc() bool
SetMc(val bool)
GetComp() bool
SetComp(val bool)
GetGate() bool
SetGate(val bool)
GetAudibility() bool
SetAudibility(val bool)
} }
// constructor method for strip // strip represents a strip channel
func newStrip(i int, k *kind) strip { // embeds channel struct
return strip{channel{"strip", i, *k}} type strip struct {
channel
} }
// implement stringer interface in fmt // implement stringer interface in fmt
@ -32,6 +51,26 @@ func (s *strip) SetMute(val bool) {
s.setter_bool("Mute", val) s.setter_bool("Mute", val)
} }
// GetMono returns the value of the Mute parameter
func (s *strip) GetMono() bool {
return s.getter_bool("Mono")
}
// SetMono sets the value of the Mute parameter
func (s *strip) SetMono(val bool) {
s.setter_bool("Mono", val)
}
// GetSolo returns the value of the Mute parameter
func (s *strip) GetSolo() bool {
return s.getter_bool("Solo")
}
// SetSolo sets the value of the Mute parameter
func (s *strip) SetSolo(val bool) {
s.setter_bool("Solo", val)
}
// GetLimit returns the value of the Limit parameter // GetLimit returns the value of the Limit parameter
func (s *strip) GetLimit() int { func (s *strip) GetLimit() int {
return s.getter_int("Limit") return s.getter_int("Limit")
@ -42,22 +81,12 @@ func (s *strip) SetLimit(val int) {
s.setter_int("Limit", val) s.setter_int("Limit", val)
} }
// GetMc returns the value of the MC parameter // GetLabel returns the value of the MC parameter
func (s *strip) GetMc() bool {
return s.getter_bool("MC")
}
// SetMc sets the value of the MC parameter
func (s *strip) SetMc(val bool) {
s.setter_bool("MC", val)
}
// GetMc returns the value of the MC parameter
func (s *strip) GetLabel() string { func (s *strip) GetLabel() string {
return s.getter_string("Label") return s.getter_string("Label")
} }
// SetMc sets the value of the MC parameter // SetLabel sets the value of the MC parameter
func (s *strip) SetLabel(val string) { func (s *strip) SetLabel(val string) {
s.setter_string("Label", val) s.setter_string("Label", val)
} }
@ -71,3 +100,101 @@ func (s *strip) GetGain() float64 {
func (s *strip) SetGain(val float32) { func (s *strip) SetGain(val float32) {
s.setter_float("Gain", val) s.setter_float("Gain", val)
} }
type physicalStrip struct {
strip
}
func newPhysicalStrip(i int, k *kind) t_strip {
ps := physicalStrip{strip{channel{"strip", i, *k}}}
return t_strip(&ps)
}
// GetComp returns the value of the Mute parameter
func (p *physicalStrip) GetComp() bool {
return p.getter_bool("Comp")
}
// SetComp sets the value of the Mute parameter
func (p *physicalStrip) SetComp(val bool) {
p.setter_bool("Comp", val)
}
// GetGate returns the value of the Mute parameter
func (p *physicalStrip) GetGate() bool {
return p.getter_bool("Gate")
}
// SetGate sets the value of the Mute parameter
func (p *physicalStrip) SetGate(val bool) {
p.setter_bool("Gate", val)
}
// GetAudibility returns the value of the Mute parameter
func (p *physicalStrip) GetAudibility() bool {
return p.getter_bool("Audibility")
}
// SetAudibility sets the value of the Mute parameter
func (p *physicalStrip) SetAudibility(val bool) {
p.setter_bool("Audibility", val)
}
// GetMc panics reason invalid parameter
func (p *physicalStrip) GetMc() bool {
panic("invalid parameter MC for physicalStrip")
}
// SetMc panics reason invalid parameter
func (p *physicalStrip) SetMc(val bool) {
panic("invalid parameter MC for physicalStrip")
}
type virtualStrip struct {
strip
}
func newVirtualStrip(i int, k *kind) t_strip {
vs := virtualStrip{strip{channel{"strip", i, *k}}}
return t_strip(&vs)
}
// GetMc returns the value of the MC parameter
func (v *virtualStrip) GetMc() bool {
return v.getter_bool("MC")
}
// SetMc sets the value of the MC parameter
func (v *virtualStrip) SetMc(val bool) {
v.setter_bool("MC", val)
}
// GetComp panics reason invalid parameter
func (v *virtualStrip) GetComp() bool {
panic("invalid parameter Comp for virtualStrip")
}
// SetComp panics reason invalid parameter
func (v *virtualStrip) SetComp(val bool) {
panic("invalid parameter Comp for virtualStrip")
}
// GetGate panics reason invalid parameter
func (v *virtualStrip) GetGate() bool {
panic("invalid parameter Gate for virtualStrip")
}
// SetGate panics reason invalid parameter
func (v *virtualStrip) SetGate(val bool) {
panic("invalid parameter Gate for virtualStrip")
}
// GetAudibility panics reason invalid parameter
func (v *virtualStrip) GetAudibility() bool {
panic("invalid parameter Audibility for virtualStrip")
}
// SetAudibility panics reason invalid parameter
func (v *virtualStrip) SetAudibility(val bool) {
panic("invalid parameter Audibility for virtualStrip")
}