feat: generalize Settings 'Power Genius' into 'Amplifier' (type + serial/IP transport) for SPE Expert
Renames the Hardware section to Amplifier and adds an amplifier-type selector (4O3A PowerGenius XL, SPE Expert 1.3K-FA / 1.5K-FA / 2K-FA) plus a transport choice for the SPE amps: USB (serial COM + baud) or Network (RS232-to-Ethernet IP:port). PGXLSettings gains Type/Transport/ComPort/Baud (keys keep the pgxl.* prefix for back-compat). PowerGenius still drives over TCP; SPE settings are stored but control is not wired yet (needs the SPE serial protocol).
This commit is contained in:
@@ -182,10 +182,16 @@ const (
|
||||
keyAntGeniusHost = "antgenius.host"
|
||||
keyAntGeniusPassword = "antgenius.password" // remote/AUTH password (blank on LAN)
|
||||
|
||||
// PowerGenius XL (4O3A) amplifier fan-mode control — Hardware → PowerGenius.
|
||||
keyPGXLEnabled = "pgxl.enabled"
|
||||
keyPGXLHost = "pgxl.host"
|
||||
keyPGXLPort = "pgxl.port"
|
||||
// Amplifier control — Hardware → Amplifier (PowerGenius XL over TCP; SPE Expert
|
||||
// over USB serial or an RS232-to-Ethernet bridge). Keys keep the pgxl.* prefix
|
||||
// for backward compatibility with existing saved settings.
|
||||
keyPGXLEnabled = "pgxl.enabled"
|
||||
keyPGXLHost = "pgxl.host"
|
||||
keyPGXLPort = "pgxl.port"
|
||||
keyPGXLType = "pgxl.type" // "pgxl" | "spe13" | "spe15" | "spe2k"
|
||||
keyPGXLTransport = "pgxl.transport" // "tcp" | "serial"
|
||||
keyPGXLComPort = "pgxl.com_port"
|
||||
keyPGXLBaud = "pgxl.baud"
|
||||
|
||||
// WinKeyer CW keyer (serial) — Hardware → CW Keyer.
|
||||
keyWKEnabled = "winkeyer.enabled"
|
||||
@@ -12131,19 +12137,25 @@ func (a *App) AntGeniusDeselect(port int) error {
|
||||
|
||||
// ── PowerGenius XL (4O3A) amplifier fan control (TCP, default port 9008) ─────
|
||||
|
||||
// PGXLSettings is the JSON shape for the Hardware → PowerGenius panel.
|
||||
// PGXLSettings is the JSON shape for the Hardware → Amplifier panel. It covers
|
||||
// the 4O3A PowerGenius XL (TCP) and the SPE Expert amps (USB serial or an
|
||||
// RS232-to-Ethernet bridge). The type name is kept for binding compatibility.
|
||||
type PGXLSettings struct {
|
||||
Enabled bool `json:"enabled"`
|
||||
Host string `json:"host"`
|
||||
Port int `json:"port"`
|
||||
Enabled bool `json:"enabled"`
|
||||
Type string `json:"type"` // "pgxl" | "spe13" | "spe15" | "spe2k"
|
||||
Transport string `json:"transport"` // "tcp" | "serial"
|
||||
Host string `json:"host"` // TCP transport
|
||||
Port int `json:"port"` // TCP transport
|
||||
ComPort string `json:"com_port"` // serial transport
|
||||
Baud int `json:"baud"` // serial transport
|
||||
}
|
||||
|
||||
func (a *App) GetPGXLSettings() (PGXLSettings, error) {
|
||||
out := PGXLSettings{Port: 9008}
|
||||
out := PGXLSettings{Type: "pgxl", Transport: "tcp", Port: 9008, Baud: 115200}
|
||||
if a.settings == nil {
|
||||
return out, fmt.Errorf("db not initialized")
|
||||
}
|
||||
m, err := a.settings.GetMany(a.ctx, keyPGXLEnabled, keyPGXLHost, keyPGXLPort)
|
||||
m, err := a.settings.GetMany(a.ctx, keyPGXLEnabled, keyPGXLHost, keyPGXLPort, keyPGXLType, keyPGXLTransport, keyPGXLComPort, keyPGXLBaud)
|
||||
if err != nil {
|
||||
return out, err
|
||||
}
|
||||
@@ -12152,6 +12164,16 @@ func (a *App) GetPGXLSettings() (PGXLSettings, error) {
|
||||
if p, _ := strconv.Atoi(m[keyPGXLPort]); p > 0 && p <= 65535 {
|
||||
out.Port = p
|
||||
}
|
||||
if t := strings.TrimSpace(m[keyPGXLType]); t != "" {
|
||||
out.Type = t
|
||||
}
|
||||
if tr := strings.TrimSpace(m[keyPGXLTransport]); tr != "" {
|
||||
out.Transport = tr
|
||||
}
|
||||
out.ComPort = m[keyPGXLComPort]
|
||||
if b, _ := strconv.Atoi(m[keyPGXLBaud]); b > 0 {
|
||||
out.Baud = b
|
||||
}
|
||||
return out, nil
|
||||
}
|
||||
|
||||
@@ -12162,10 +12184,23 @@ func (a *App) SavePGXLSettings(s PGXLSettings) error {
|
||||
if s.Port <= 0 || s.Port > 65535 {
|
||||
s.Port = 9008
|
||||
}
|
||||
if s.Baud <= 0 {
|
||||
s.Baud = 115200
|
||||
}
|
||||
if s.Type == "" {
|
||||
s.Type = "pgxl"
|
||||
}
|
||||
if s.Transport == "" {
|
||||
s.Transport = "tcp"
|
||||
}
|
||||
for k, v := range map[string]string{
|
||||
keyPGXLEnabled: boolStr(s.Enabled),
|
||||
keyPGXLHost: strings.TrimSpace(s.Host),
|
||||
keyPGXLPort: strconv.Itoa(s.Port),
|
||||
keyPGXLEnabled: boolStr(s.Enabled),
|
||||
keyPGXLHost: strings.TrimSpace(s.Host),
|
||||
keyPGXLPort: strconv.Itoa(s.Port),
|
||||
keyPGXLType: s.Type,
|
||||
keyPGXLTransport: s.Transport,
|
||||
keyPGXLComPort: strings.TrimSpace(s.ComPort),
|
||||
keyPGXLBaud: strconv.Itoa(s.Baud),
|
||||
} {
|
||||
if err := a.settings.Set(a.ctx, k, v); err != nil {
|
||||
return err
|
||||
@@ -12185,7 +12220,17 @@ func (a *App) startPGXL() {
|
||||
a.pgxl = nil
|
||||
}
|
||||
s, err := a.GetPGXLSettings()
|
||||
if err != nil || !s.Enabled || strings.TrimSpace(s.Host) == "" {
|
||||
if err != nil || !s.Enabled {
|
||||
return
|
||||
}
|
||||
// Only the PowerGenius XL (TCP) is driven for now. SPE Expert control (serial /
|
||||
// RS232-to-Ethernet) is a separate protocol, not yet implemented — its settings
|
||||
// are stored but no client is started.
|
||||
if s.Type != "" && s.Type != "pgxl" {
|
||||
applog.Printf("amplifier: type %q selected — control not implemented yet (settings saved)", s.Type)
|
||||
return
|
||||
}
|
||||
if strings.TrimSpace(s.Host) == "" {
|
||||
return
|
||||
}
|
||||
a.pgxl = powergenius.New(s.Host, s.Port)
|
||||
|
||||
Reference in New Issue
Block a user