fix: PGXL status-bar chip and Station Control widget read OPERATE from the Flex when it reports the amp (the direct GSCP status doesn't carry operate state) — toggle then goes through FlexAmpOperate like the Flex panel; direct TCP link stays as fallback; log distinct raw PGXL status payloads to map unknown fields
This commit is contained in:
@@ -13,7 +13,7 @@ import {
|
||||
GetRotatorHeading, RotatorGoTo, RotatorStop,
|
||||
GetUltrabeamStatus, SetUltrabeamDirection, UltrabeamRetract, MotorSetElement, MotorReadElements,
|
||||
ListDenkoviDevices, ListSerialPorts, TestStationDevice,
|
||||
GetPGXLSettings, GetPGXLStatus, PGXLSetFanMode, PGXLSetOperate,
|
||||
GetPGXLSettings, GetPGXLStatus, PGXLSetFanMode, PGXLSetOperate, GetFlexState, FlexAmpOperate,
|
||||
GetSPEStatus, SPESetOperate, SPESetPower, SPESetPowerLevel,
|
||||
GetACOMStatus, ACOMSetOperate, ACOMSetPower,
|
||||
} from '../../wailsjs/go/main/App';
|
||||
@@ -259,8 +259,24 @@ function AmplifierWidget({ ampType, t }: { ampType: string; t: (k: string, v?: a
|
||||
const [st, setSt] = useState<any>({ connected: false });
|
||||
useEffect(() => {
|
||||
let alive = true;
|
||||
const get = isPGXL ? GetPGXLStatus : isACOM ? GetACOMStatus : GetSPEStatus;
|
||||
const tick = () => get().then((s: any) => alive && setSt(s || { connected: false })).catch(() => {});
|
||||
// PGXL: the Flex reports the amp's OPERATE state authoritatively (the direct
|
||||
// GSCP status doesn't carry it) — merge it in when a Flex sees the amp.
|
||||
const tick = isPGXL
|
||||
? () => Promise.all([
|
||||
GetPGXLStatus().catch(() => ({ connected: false })),
|
||||
GetFlexState().catch(() => null),
|
||||
]).then(([pg, fx]: any[]) => {
|
||||
if (!alive) return;
|
||||
const viaFlex = !!fx?.amp_available;
|
||||
setSt({
|
||||
...(pg || {}),
|
||||
connected: !!pg?.connected || viaFlex,
|
||||
operate: viaFlex ? !!fx.amp_operate : !!pg?.operate,
|
||||
via_flex: viaFlex,
|
||||
});
|
||||
})
|
||||
: () => (isACOM ? GetACOMStatus : GetSPEStatus)()
|
||||
.then((s: any) => alive && setSt(s || { connected: false })).catch(() => {});
|
||||
tick();
|
||||
const id = window.setInterval(tick, 1500);
|
||||
return () => { alive = false; window.clearInterval(id); };
|
||||
@@ -285,7 +301,7 @@ function AmplifierWidget({ ampType, t }: { ampType: string; t: (k: string, v?: a
|
||||
{isPGXL ? (
|
||||
<div className="flex items-center gap-2 flex-wrap">
|
||||
<button type="button" disabled={!st.connected}
|
||||
onClick={() => { const want = !st.operate; setSt((s: any) => ({ ...s, operate: want })); PGXLSetOperate(want).catch(() => {}); }}
|
||||
onClick={() => { const want = !st.operate; setSt((s: any) => ({ ...s, operate: want })); (st.via_flex ? FlexAmpOperate(want) : PGXLSetOperate(want)).catch(() => {}); }}
|
||||
className={cn('px-3 py-1.5 rounded-lg text-xs font-extrabold tracking-wide border-2 transition-all disabled:opacity-40',
|
||||
st.operate ? 'bg-warning text-warning-foreground border-warning' : 'bg-card text-warning border-warning hover:bg-warning-muted')}>
|
||||
{st.operate ? 'OPERATE' : 'STANDBY'}
|
||||
|
||||
Reference in New Issue
Block a user