fix(pgxl): draw the amplifier card's meters from the amp when there is no Flex
The PowerGenius XL card gated its whole meter row on flex.amp_available, so on any station without a FlexRadio it rendered OPERATE and the fan selector over an otherwise empty two-column card — reported from a TS-590 station. Nothing was missing from the backend. internal/powergenius already parses forward power, drain current, VSWR and temperature out of the GSCP status frame, and the docked AmpWidget already prefers the radio's meter stream and falls back to those. Only the full card never learnt the fallback. Same source preference as the widget, and the same two exclusions: peakfwd and peakid are latched maxima that are never reset and survive in the last-known status after the amp disconnects, so the plain readings are used and gated on the transmit state instead of freezing on the last over.
This commit is contained in:
@@ -174,6 +174,41 @@ export function AmpCard({ amp, flex, t }: { amp: Amp; flex: any; t: (k: string,
|
||||
const operate = viaFlex ? !!flex?.amp_operate : !!pg.operate;
|
||||
const connected = !!pg.connected || viaFlex;
|
||||
const fault = flex?.amp_fault;
|
||||
|
||||
// Meters built from the amplifier's own GSCP status frame, for when the radio
|
||||
// is not feeding a meter stream.
|
||||
//
|
||||
// Whether there is power is the amp's state field; how much is the plain
|
||||
// forward figure. NOT "peakfwd" — that is a latched maximum which is never
|
||||
// reset and survives in the last-known status after the amp disconnects, so it
|
||||
// once claimed 1350 W from an old transmission while 10 W was going out. Same
|
||||
// reason peak_id is left alone. Both readings are gated on transmit so they
|
||||
// fall back to zero between overs instead of freezing on the last one.
|
||||
const pgxlMeters = () => {
|
||||
if (!pg.connected) return null;
|
||||
const txing = typeof flex?.transmitting === 'boolean' ? flex.transmitting : /TRANSMIT/i.test(pg.state || '');
|
||||
const fwdW = peakHold('pgfwd', txing ? Number(pg.fwd_w) || 0 : 0);
|
||||
const idA = peakHold('pgid', txing ? Number(pg.id) || 0 : 0);
|
||||
const swr = peakHold('pgswr', txing ? Number(pg.vswr) || 0 : 0);
|
||||
const tempC = Number(pg.temperature) || 0;
|
||||
return (
|
||||
<div className="grid grid-cols-2 sm:grid-cols-4 gap-2 mt-2 pt-2 border-t border-border/50">
|
||||
<MeterBar label={t('flxp.outputPower')} value={fwdW} unit="W" lo={0} hi={2000}
|
||||
display={`${Math.round(fwdW)} W`}
|
||||
segColor={(f) => (f > 0.9 ? '#dc2626' : f > 0.75 ? '#f59e0b' : '#ea580c')} />
|
||||
<MeterBar label={t('ampw.id')} value={idA} lo={0} hi={25} display={`${idA.toFixed(1)} A`} accent="#16a34a" />
|
||||
{/* Below 1:1 the reading is meaningless, so an idle amp shows a flat bar
|
||||
rather than a zero that looks like a perfect match. */}
|
||||
<MeterBar label={t('ampw.swr')} value={swr >= 1 ? swr : 1} lo={1} hi={3}
|
||||
display={swr >= 1 ? swr.toFixed(1) : '—'}
|
||||
segColor={(f) => (f > 0.75 ? '#dc2626' : f > 0.4 ? '#f59e0b' : '#16a34a')} />
|
||||
<MeterBar label={t('ampw.temp')} value={tempC} unit="°C" lo={0} hi={100}
|
||||
display={tempC > 0 ? `${Math.round(tempC)} °C` : '—'}
|
||||
segColor={(f) => (f > 0.8 ? '#dc2626' : f > 0.6 ? '#f59e0b' : '#ea580c')} />
|
||||
</div>
|
||||
);
|
||||
};
|
||||
|
||||
return (
|
||||
<Card icon={Flame} ckey="amplifier" title={`${t('flxp.amplifier')}${flex?.amp_model ? ' · ' + flex.amp_model : (pg.model ? ' · ' + pg.model : '')} · ${amp.name}`} accent="#ea580c">
|
||||
<div className="flex items-center gap-3 flex-wrap">
|
||||
@@ -204,13 +239,20 @@ export function AmpCard({ amp, flex, t }: { amp: Amp; flex: any; t: (k: string,
|
||||
<span className="px-2 py-1 rounded bg-danger-muted text-danger-muted-foreground text-xs font-bold">{t('flxp.fault')}: {fault}</span>
|
||||
)}
|
||||
</div>
|
||||
{/* Amplifier meters (FWD / ID / TEMP …) from the FlexRadio UDP stream. */}
|
||||
{viaFlex && (() => {
|
||||
{/* Amplifier meters (FWD / ID / TEMP …).
|
||||
The FlexRadio UDP stream is the preferred source — it is fast and reads
|
||||
the same as SmartSDR. When there is no Flex, or it is not streaming,
|
||||
the amplifier's OWN link carries the same figures; falling back to them
|
||||
is what the docked widget already does. Without that fallback this card
|
||||
showed an operator on a Kenwood nothing but OPERATE and the fan mode,
|
||||
while the amplifier was reporting power, current and temperature all
|
||||
along. */}
|
||||
{(() => {
|
||||
const meters = (flex?.meters as any[]) || [];
|
||||
const dbmToW = (d: number) => Math.pow(10, (d - 30) / 10);
|
||||
const amps = meters.filter((m) => (m.src || '').toUpperCase().includes('AMP')
|
||||
&& !/^(RL|DRV)$/i.test((m.name || '').trim()));
|
||||
if (amps.length === 0) return null;
|
||||
if (!viaFlex || amps.length === 0) return pgxlMeters();
|
||||
// Power comes from the radio's meter stream and nothing else. The
|
||||
// amplifier also reports a "peakfwd", and using it was a mistake twice
|
||||
// over: it is a latched maximum that is never reset, and it survives in
|
||||
|
||||
Reference in New Issue
Block a user