import React, { useState } from 'react'; import { num } from '../../api/useXplane.js'; // ============================================================================ // Citation X — Honeywell Primus 2000 Autopilot / Flight Guidance Controller. // Exact button layout per the manual (pages 26-28): // col1: HDG NAV APP BC col2: ALT VNAV BANK STBY // col3: FLC C/O VS center: PITCH WHEEL (NOSE DN / NOSE UP) // col4: AP YD M TRIM PFD SEL // Mode lamps read the per-mode *_status datarefs (0 off · 1 armed · 2 active), // the same reliable source the PFD uses. Buttons fire X-Plane AP commands. // ============================================================================ export default function CitAP({ xp }) { const V = xp.values || {}; const cmd = xp.command; const stat = (k) => num(V[k]); // 0 off · 1 armed · 2 active const apOn = num(V.apEngaged) > 0 || num(V.apMode) >= 2; const ydOn = num(V.ydOn) > 0 || apOn; const [bank, setBank] = useState(false); // BANK (low-bank 17°) — annunc only const [mtrim, setMtrim] = useState(true); // M TRIM (mach trim) — annunc only const [pfdSel, setPfdSel] = useState('PILOT'); // PFD SEL — pilot/copilot guidance // active mode strings for the annunciator bar (matches the PFD) const lateral = stat('aprStatus') ? ['APP', stat('aprStatus')] : stat('navStatus') ? ['NAV', stat('navStatus')] : stat('bcStatus') ? ['BC', stat('bcStatus')] : stat('hdgStatus') ? ['HDG', stat('hdgStatus')] : ['ROL', 2]; const vertical = stat('gsStatus') ? ['GS', stat('gsStatus')] : stat('vnavStatus') ? ['VNAV', stat('vnavStatus')] : stat('flcStatus') ? ['FLC', stat('flcStatus')] : stat('vsStatus') ? ['VS', stat('vsStatus')] : stat('altStatus') ? ['ALT', stat('altStatus')] : ['PIT', 2]; // A mode button: green lamp when its status is active(2), amber when armed(1). const lamp = (k) => (stat(k) >= 2 ? 'active' : stat(k) === 1 ? 'armed' : ''); const Btn = ({ label, cmd: c, on, cls = '', onClick }) => ( ); const sel = num(V.apAltBug); return (