implement dca commands:

- DCA added to Client struct
- dca command added to both CLIs

help mds updated
This commit is contained in:
2026-02-10 01:16:44 +00:00
parent 873ff87429
commit cf470181a1
9 changed files with 247 additions and 1 deletions

View File

@@ -3,9 +3,10 @@ package xair
var xairAddressMap = map[string]string{
"main": "/lr",
"strip": "/ch/%02d",
"bus": "/bus/%01d",
"bus": "/bus/%d",
"headamp": "/headamp/%02d",
"snapshot": "/-snap",
"dca": "/dca/%d",
}
var x32AddressMap = map[string]string{
@@ -16,6 +17,7 @@ var x32AddressMap = map[string]string{
"bus": "/bus/%02d",
"headamp": "/headamp/%03d",
"snapshot": "/-snap",
"dca": "/dca/%d",
}
func addressMapFromMixerKind(kind mixerKind) map[string]string {

View File

@@ -21,6 +21,7 @@ type XAirClient struct {
Bus *Bus
HeadAmp *HeadAmp
Snapshot *Snapshot
DCA *DCA
}
// X32Client is a client for controlling X32 mixers
@@ -33,6 +34,7 @@ type X32Client struct {
Bus *Bus
HeadAmp *HeadAmp
Snapshot *Snapshot
DCA *DCA
}
// NewX32Client creates a new X32Client instance with optional engine configuration
@@ -52,6 +54,7 @@ func NewX32Client(mixerIP string, mixerPort int, opts ...EngineOption) (*X32Clie
c.Bus = newBus(&c.Client)
c.HeadAmp = newHeadAmp(&c.Client)
c.Snapshot = newSnapshot(&c.Client)
c.DCA = newDCA(&c.Client)
return c, nil
}
@@ -71,6 +74,7 @@ func NewXAirClient(mixerIP string, mixerPort int, opts ...EngineOption) (*XAirCl
c.Bus = newBus(&c.Client)
c.HeadAmp = newHeadAmp(&c.Client)
c.Snapshot = newSnapshot(&c.Client)
c.DCA = newDCA(&c.Client)
return c, nil
}

95
internal/xair/dca.go Normal file
View File

@@ -0,0 +1,95 @@
package xair
import "fmt"
type DCA struct {
client *Client
baseAddress string
}
// newDCA creates a new DCA instance
func newDCA(c *Client) *DCA {
return &DCA{
client: c,
baseAddress: c.addressMap["dca"],
}
}
// Mute requests the current mute status for a DCA group
func (d *DCA) Mute(group int) (bool, error) {
address := fmt.Sprintf(d.baseAddress, group) + "/on"
err := d.client.SendMessage(address)
if err != nil {
return false, err
}
msg, err := d.client.ReceiveMessage()
if err != nil {
return false, err
}
val, ok := msg.Arguments[0].(int32)
if !ok {
return false, fmt.Errorf("unexpected argument type for DCA mute value")
}
return val == 0, nil
}
// SetMute sets the mute status for a specific DCA group (1-based indexing)
func (d *DCA) SetMute(group int, muted bool) error {
address := fmt.Sprintf(d.baseAddress, group) + "/on"
var value int32
if !muted {
value = 1
}
return d.client.SendMessage(address, value)
}
// Name requests the current name for a DCA group
func (d *DCA) Name(group int) (string, error) {
address := fmt.Sprintf(d.baseAddress, group) + "/config/name"
err := d.client.SendMessage(address)
if err != nil {
return "", err
}
msg, err := d.client.ReceiveMessage()
if err != nil {
return "", err
}
name, ok := msg.Arguments[0].(string)
if !ok {
return "", fmt.Errorf("unexpected argument type for DCA name value")
}
return name, nil
}
// SetName sets the name for a specific DCA group (1-based indexing)
func (d *DCA) SetName(group int, name string) error {
address := fmt.Sprintf(d.baseAddress, group) + "/config/name"
return d.client.SendMessage(address, name)
}
// Color requests the current color for a DCA group
func (d *DCA) Color(group int) (int32, error) {
address := fmt.Sprintf(d.baseAddress, group) + "/config/color"
err := d.client.SendMessage(address)
if err != nil {
return 0, err
}
msg, err := d.client.ReceiveMessage()
if err != nil {
return 0, err
}
color, ok := msg.Arguments[0].(int32)
if !ok {
return 0, fmt.Errorf("unexpected argument type for DCA color value")
}
return color, nil
}
// SetColor sets the color for a specific DCA group (1-based indexing)
func (d *DCA) SetColor(group int, color int32) error {
address := fmt.Sprintf(d.baseAddress, group) + "/config/color"
return d.client.SendMessage(address, color)
}