fix(pgxl): read the amplifier's real state instead of assuming standby

Reported: OpsLog shows STANDBY on a PowerGenius XL that is operating, and
pressing the button 'puts it in Operate' — because it was already there.

The amplifier's status frame has no operate= field. The direct GSCP
client only looked for one, so Operate stayed at its zero value until the
operator pressed the button: at startup OpsLog was not reading the state
wrongly, it was not reading it at all.

The live state is in the frame under 'state', and the FlexRadio side of
this same amplifier has been reading it that way all along — anything but
STANDBY/OFF means the amp is in line, with IDLE meaning in line but not
keyed. The GSCP client now does the same when no operate= is present.

An unknown state leaves the flag alone rather than guessing: claiming
STANDBY on an amp that is in line is precisely the error being fixed, and
it invites the operator to switch on what is already on.
This commit is contained in:
2026-08-25 14:59:50 +02:00
parent 6536d140ba
commit ed099a660e
3 changed files with 78 additions and 2 deletions
+4 -2
View File
@@ -6,13 +6,15 @@
"Elecraft console: the transmit meters are read whenever the RADIO says it is transmitting, not only when OpsLog keyed it. Keying with the front-panel PTT, a footswitch or the mic button left the panel showing a receiver — and the power and SWR bars are read only while transmitting, so for anyone keying by hand they were never read at all.",
"Cluster: the list holds still while it is being read. Scrolled away from the top it stops redrawing and shows how many spots are waiting; scrolling back to the top, or clicking the notice, releases it. On a busy evening a spot lands every second or two and the callsign under the pointer had moved by the time the click arrived.",
"Cluster command buttons take 500 characters instead of 120. A DXSpider filter listing wanted prefixes runs past a hundred easily, and the field simply stopped accepting keystrokes — saving the command truncated, with nothing to say so.",
"Multi-monitor: the saved window position is now checked against the monitors themselves, not the rectangle that spans them. Monitors rarely fill that rectangle, and a window in one of the leftover gaps passed the old test while being invisible. A position that is genuinely lost is moved onto the nearest screen — keeping the window size — instead of being handed back to Windows, and the screen layout is written to the log at every start."
"Multi-monitor: the saved window position is now checked against the monitors themselves, not the rectangle that spans them. Monitors rarely fill that rectangle, and a window in one of the leftover gaps passed the old test while being invisible. A position that is genuinely lost is moved onto the nearest screen — keeping the window size — instead of being handed back to Windows, and the screen layout is written to the log at every start.",
"PowerGenius XL: the amplifier's real state is read at startup. Its status frame carries no 'operate' field — the state is in 'state' — so on the direct GSCP link the flag was never read at all and OpsLog opened claiming STANDBY on an amp that was in line, with the first press of the button then commanding the state it was already in. IDLE means in line, not keyed."
],
"fr": [
"Console Elecraft : les mesures d'émission sont lues dès que la RADIO se déclare en émission, et plus seulement quand OpsLog l'a mise en émission. Passer en émission par le PTT de façade, une pédale ou le bouton du micro laissait le panneau croire à une réception — et comme les barres de puissance et de ROS ne sont lues qu'en émission, elles ne l'étaient jamais pour qui manipule à la main.",
"Cluster : la liste se fige pendant qu'on la lit. Dès qu'on quitte le haut, elle cesse de se redessiner et indique combien de spots attendent ; revenir en haut, ou cliquer sur l'avis, la relâche. Un soir chargé, un spot tombe toutes les une ou deux secondes et l'indicatif sous le pointeur avait bougé avant que le clic n'arrive.",
"Les boutons de commande du cluster acceptent 500 caractères au lieu de 120. Un filtre DXSpider qui énumère des préfixes dépasse la centaine sans peine, et le champ cessait simplement d'accepter les frappes — la commande était enregistrée tronquée, sans un mot.",
"Multi-écrans : la position enregistrée est désormais vérifiée contre les écrans eux-mêmes, et non contre le rectangle qui les englobe. Les écrans remplissent rarement ce rectangle, et une fenêtre tombée dans un des trous passait l'ancien test tout en étant invisible. Une position réellement perdue est déplacée sur l'écran le plus proche — en conservant la taille de la fenêtre — au lieu d'être rendue à Windows, et la disposition des écrans est écrite dans le journal à chaque démarrage."
"Multi-écrans : la position enregistrée est désormais vérifiée contre les écrans eux-mêmes, et non contre le rectangle qui les englobe. Les écrans remplissent rarement ce rectangle, et une fenêtre tombée dans un des trous passait l'ancien test tout en étant invisible. Une position réellement perdue est déplacée sur l'écran le plus proche — en conservant la taille de la fenêtre — au lieu d'être rendue à Windows, et la disposition des écrans est écrite dans le journal à chaque démarrage.",
"Power Genius XL : l'état réel de l'amplificateur est lu au démarrage. Sa trame d'état ne contient pas de champ « operate » — l'état est dans « state » — si bien que sur la liaison GSCP directe l'indicateur n'était jamais lu : OpsLog s'ouvrait en annonçant STANDBY sur un ampli en ligne, et le premier appui commandait l'état dans lequel il se trouvait déjà. IDLE veut dire en ligne, pas en émission."
]
},
{
+39
View File
@@ -0,0 +1,39 @@
package powergenius
import "testing"
// The amplifier's status frame has no "operate=" field: its live state is in
// "state", and that is what says whether the amp is in line. Reading only
// operate= meant the flag was never read at all — OpsLog opened claiming
// STANDBY on an amp that was operating, and the first press of the button
// commanded the state it was already in.
func TestOperateIsReadFromTheStateField(t *testing.T) {
cases := []struct {
state string
operate bool
known bool
}{
{"STANDBY", false, true},
{"OFF", false, true},
{"OPERATE", true, true},
// IDLE is the one that matters: the amp is IN LINE, simply not keyed.
// Reading it as standby is how the wrong state got on screen.
{"IDLE", true, true},
{"TRANSMIT_A", true, true},
{"idle", true, true}, // case is the firmware's business, not ours
// A state nobody has seen leaves the flag alone rather than guessing:
// claiming STANDBY on an amp that is in line is the error that matters.
{"WARMING_UP", false, false},
{"", false, false},
}
for _, c := range cases {
op, known := operateFromState(c.state)
if known != c.known {
t.Errorf("state %q: known = %v, want %v", c.state, known, c.known)
continue
}
if known && op != c.operate {
t.Errorf("state %q: operate = %v, want %v", c.state, op, c.operate)
}
}
}
+35
View File
@@ -159,6 +159,22 @@ func replyCode(reply string) string {
return strings.TrimSpace(p[1])
}
// operateFromState maps the amplifier's live state to "in line or not".
//
// Unknown states leave the flag alone rather than guessing: a state nobody has
// seen is not evidence that the amp is standing by, and claiming STANDBY on an
// amplifier that is in line is the error that matters here — it invites the
// operator to "switch it on" and command the state it is already in.
func operateFromState(state string) (operate, known bool) {
switch strings.ToUpper(strings.TrimSpace(state)) {
case "STANDBY", "OFF", "POWERED_OFF", "DISCONNECTED":
return false, true
case "OPERATE", "OPERATING", "IDLE", "RECEIVE", "RX", "TRANSMIT", "TRANSMIT_A", "TRANSMIT_B", "TX", "KEYED":
return true, true
}
return false, false
}
// SetOperate puts the amp in OPERATE (1) or STANDBY (0).
func (c *Client) SetOperate(on bool) error {
v := "0"
@@ -349,6 +365,7 @@ func (c *Client) parse(resp string) {
c.lastRaw = data
applog.Printf("pgxl: status raw=%q", data)
}
sawOperate := false
for _, pair := range strings.Fields(data) {
kv := strings.SplitN(pair, "=", 2)
if len(kv) != 2 {
@@ -358,6 +375,7 @@ func (c *Client) parse(resp string) {
case "state":
c.status.State = kv[1]
case "operate":
sawOperate = true
c.status.Operate = kv[1] == "1"
case "fanmode":
dev := strings.ToUpper(kv[1])
@@ -387,6 +405,23 @@ func (c *Client) parse(resp string) {
c.status.PeakId, _ = strconv.ParseFloat(kv[1], 64)
}
}
// THE AMP DOES NOT SEND "operate=".
//
// Operate was therefore never read at all on this link: it stayed at the
// zero value until the operator pressed the button, so OpsLog opened
// claiming STANDBY on an amplifier that was in line — and the first press
// then commanded the state it was already in. Reported from a real PGXL.
//
// The live state IS in the frame, under "state", and the FlexRadio side of
// this same amplifier has been reading it that way all along (see
// flexAmp): anything but STANDBY/OFF means the amp is IN LINE. IDLE is
// operate — in line, not keyed.
if !sawOperate && c.status.State != "" {
if op, known := operateFromState(c.status.State); known {
c.status.Operate = op
}
}
c.statusMu.Unlock()
}