fix(relays): let the HTTP board's channel count be chosen

The selector offered 1, 2, 4, 8 and 16 and none of them took: the board stayed
at four relays.

The count is decided in three places — deviceRelayCount in Go, chanCount in the
Station Control panel, relayCountUI in Settings. The new type was added to the
first and the dropdown, and to neither of the others, so the panel resized the
labels from a helper that had never heard of it and fell straight through to
its fixed default. The Go side was right the whole time, which is why the
driver would have been built correctly for a count the operator could not set.

All three now know the type. A test pins the Go side against every count the
dropdown offers, and against the fixed boards, whose hardware decides and which
must keep ignoring the field.
This commit is contained in:
2026-08-15 02:35:14 +02:00
parent 26b8dade20
commit 5c958572dc
4 changed files with 46 additions and 4 deletions
+7 -1
View File
@@ -701,7 +701,13 @@ const MOTOR_BAND_DEFAULT_KHZ: Record<string, number> = {
'40m': 7100, '30m': 10125, '20m': 14150, '17m': 18110,
'15m': 21150, '12m': 24930, '10m': 28400, '6m': 50150,
};
const relayCountUI = (type: string) => (type === 'kmtronic' || type === 'denkovi' ? 8 : 5);
// Fallback only: the rule editor sizes itself from the device's labels, which
// SaveStationDevices already normalises to the real relay count. This is what it
// falls back to when a device somehow has none, so it only needs to be in the
// right neighbourhood — but it is the third place that counts relays, and the
// first two disagreeing is what pinned the HTTP board at four.
const relayCountUI = (type: string) =>
type === 'kmtronic' || type === 'denkovi' ? 8 : type === 'httpgen' ? 4 : 5;
// Live status + OPERATE/STANDBY toggle for ONE configured amplifier (by config
// id) — SPE / ACOM / PGXL alike. Module-scoped (not a nested component) so it
@@ -44,10 +44,16 @@ const TYPE_LABEL: Record<string, string> = { webswitch: 'WebSwitch 1216H', kmtro
// Relay count for a configured device: fixed by type, except Denkovi (4/8) and
// the generic USB-serial board, whose channel count the user picks.
// chanCount is the relay count for a device. It MUST agree with
// deviceRelayCount in app.go: the two decide how many labels and URL rows the
// editor shows and how many relays the driver is built for, and a type known to
// one and not the other silently pins the count to its fixed default — which is
// exactly what happened when the HTTP board was added here and not below.
const chanCount = (d: Device): number =>
(d.type === 'denkovi' || d.type === 'usbrelay') ? (d.channels && d.channels >= 1 ? d.channels : 8)
: d.type === 'dingtian' ? (d.channels && d.channels >= 1 ? d.channels : 2)
: (RELAY_COUNT[d.type] ?? 5);
: d.type === 'httpgen' ? (d.channels && d.channels >= 1 ? d.channels : 4)
: (RELAY_COUNT[d.type] ?? 5);
function blankDevice(): Device {
return { id: '', type: 'webswitch', name: '', host: '', user: '', pass: '', labels: Array(5).fill('') };