Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
7a892c1
Add comprehensive README.md — architecture diagram, plugin list, data…
billmallard Apr 18, 2026
1779b11
Revert README: Remove MAOS-specific ecosystem sections for upstream P…
billmallard Apr 18, 2026
3d53cf1
Merge remote-tracking branch 'upstream/master'
billmallard Apr 23, 2026
e94bfd0
xplane plugin: Py3, data-driven recv/send mapping, full SVS data set
billmallard Jun 1, 2026
e8e5d32
xplane: HEAD maps to idx 17 slot 4 (magnetic heading)
billmallard Jun 1, 2026
c591fe0
xplane: filter -999 sentinel + publish MAGVAR
billmallard Jun 1, 2026
6032d62
ahrs db: register MAGVAR key for true-heading correction
billmallard Jun 1, 2026
097b74f
xplane: publish VPATH (idx 18 slot 3) for use by FPM rendering
billmallard Jun 2, 2026
7bc7a1b
xplane: subscribe to nav-radio datarefs (RREF) for HSI COURSE/CDI
billmallard Jun 17, 2026
e7bc77c
xplane: fix RREF requests — pad dref to 400 bytes, send to 49000
billmallard Jun 17, 2026
4237a23
Merge upstream/master into xplane-data-driven
billmallard Jun 17, 2026
e82a68c
xplane config: disable FIX->X-Plane send (throttle/mixture) by default
billmallard Jun 17, 2026
26a14cc
database: add HEADBUG (Selected Heading Bug) key
billmallard Jun 29, 2026
fc5542a
gitignore: anchor config/ to repo root
billmallard Jun 29, 2026
1e8688e
tools: dump_fix_keys.py -- FIX key catalog for the configurator
billmallard Jun 29, 2026
73b620b
xplane: COURSE from GPS course, add HEADBUG from autopilot heading bug
billmallard Jun 29, 2026
8d8133a
xplane: CDI from GPS deviation (match the GPS course)
billmallard Jun 29, 2026
996bb25
nav-source selector: compute "select" + NAVSRC routing
billmallard Jun 29, 2026
fef1bd8
nav-source selector: add NAV2 + glideslope (GSI)
billmallard Jun 29, 2026
55613a4
xplane: DREF write + nav-source AP-follow (HSI_source_select)
billmallard Jun 29, 2026
c8fdb9b
doc: rewrite X-Plane plugin doc (data-driven) + add compute plugin doc
billmallard Jun 29, 2026
e0e26aa
nav: migrate NAVSRC to bus-native ordering (0=NAV1, 1=NAV2, 2=GPS)
billmallard Jun 30, 2026
c33ff8f
nav: derive magnetic ground track (TRACKM) for the HSI rose
billmallard Jun 30, 2026
df8545f
nav: derive GSV (glideslope-valid) + TOFROM per source for the HSI
billmallard Jun 30, 2026
949c9b7
xplane: flip GS vertical deviation sense (below glideslope -> diamond…
billmallard Jul 1, 2026
972c0d6
nav: GS validity from glideslope flag (flag/hide until in the cone)
billmallard Jul 1, 2026
a7001bd
compute: select flags the canonical output when the source is absent/…
billmallard Jul 5, 2026
1eac772
state_persist: persist pilot selections (NAVSRC) across restarts (#84)
billmallard Jul 5, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,10 @@
doc/_*
.ropeproject/*
.directory
config/
# Anchored to the repo root: ignore a runtime ./config/, NOT the tracked
# package config under src/fixgw/config/ (so new database/connection yaml is
# tracked normally without git add -f).
/config/
init.marker
venv.marker

Expand Down
152 changes: 152 additions & 0 deletions doc/plugins/compute.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,152 @@
=================
Compute Plugin
=================

The compute plugin derives new FIX database keys from existing ones. It is how
FIX-Gateway produces values that are not measured directly but calculated from
other points -- averages and maxima across a bank of cylinders, density
altitude from pressure and temperature, cross-track error from position and a
flight plan, and so on. It also hosts the small *routing* primitives that
implement an EFIS nav-source selector (see `Nav-source selection`_).

The plugin watches the ``inputs`` of each configured function; whenever an input
changes it recomputes and writes the function's ``output`` key. Most functions
propagate the input quality flags (``old`` / ``bad`` / ``fail``) to the output
and force the output to ``0`` when an input has failed.

Configuration
=============

The plugin is configured with a list of ``functions``. Each function names a
``function`` type, its ``inputs`` (a list of FIX keys), and its ``output`` key.

::

compute:
load: COMPUTE
module: fixgw.plugins.compute
functions:
- function: max
inputs: ["CHT11", "CHT12", "CHT13", "CHT14"]
output: CHTMAX1

- function: altd
inputs: ["PALT", "TALT", "OAT"]
output: DALT

Every function also accepts an optional ``require_leader`` flag:

* ``require_leader: true`` (the default) -- the function only computes on the
node that is the current *quorum leader*. Use this in a redundant,
multi-node installation so a derived key has a single writer.
* ``require_leader: false`` -- the function always computes. Use this on a
single-node system (and for the nav-source routing below, which must run
regardless of quorum).

A few function types take an extra configuration key (``multiplier``, ``value``
or ``table``) noted in the catalog.

Function catalog
================

``average``
Arithmetic mean of all ``inputs`` written to ``output``.

``sum``
Sum of all ``inputs``.

``max``
Largest of the ``inputs`` (e.g. hottest CHT).

``min``
Smallest of the ``inputs``.

``span``
Difference between the largest and smallest input (e.g. EGT spread).

``altp``
Pressure altitude from ``inputs: [BARO, ALT_MSL]``::

PALT = ALT_MSL + 145442.2 * (1 - (BARO / 29.92126) ** 0.190261)

``altd``
Density altitude from ``inputs: [PALT, ALT_MSL, OAT]`` (OAT in degrees C)::

std_temp = 15 - 1.98 * ALT_MSL / 1000
DALT = PALT + 120 * (OAT - std_temp)

``xte``
Signed cross-track error in nautical miles from
``inputs: [ac_lat, ac_lon, wp_lat, wp_lon, desired_course]`` (course in
degrees true). Positive = right of the desired course.

``aoa``
Angle-of-attack estimator. ``inputs`` are
``[PITCH, IAS, ANORM, VS, HEAD, <tuning ...>]`` followed by nine tuning
constants; it learns a lift constant during steady, straight-and-level
flight and derives alpha from normal acceleration and airspeed. See the
source for the full input list and constants.

``encoder``
Adds ``input * multiplier`` to ``output`` (an accumulator driven by a
rotary encoder). Requires an extra ``multiplier`` key.

``set``
When an input is truthy, writes a fixed ``value`` to ``output``. Requires
an extra ``value`` key.

``select``
Routes one of several source keys to a single output, chosen by a selector
key. ``inputs[0]`` is the selector; ``inputs[1:]`` are the sources. The
selector value is rounded and clamped to pick a source, whose value (and its
``bad`` / ``fail`` flags) is copied to ``output``. This is the heart of the
nav-source selector -- one canonical key always carries the *selected*
source.

``remap``
Emits ``table[round(index)]`` (clamped to the table) to ``output``, where
``inputs[0]`` is the index. Requires an extra ``table`` key (a list).
Translates one selector numbering into another.

Nav-source selection
====================

``select`` and ``remap`` together implement an EFIS navigation-source selector,
so the EFIS can both *display* the selected source and *publish* its guidance to
the keys the autopilot reads -- and, with the :doc:`xplane` plugin, drive a
simulator's autopilot to match.

A single selector key, ``NAVSRC`` (``0`` = NAV1, ``1`` = NAV2, ``2`` = GPS), is
cycled by a button on the EFIS. ``select`` routes the chosen source's
per-source keys into the canonical ``COURSE`` / ``CDI`` / ``GSI`` keys that the
HSI and autopilot consume::

functions:
- function: select
inputs: ["NAVSRC", "NAV1CRS", "NAV2CRS", "GPSCRS"]
output: COURSE
require_leader: false
- function: select
inputs: ["NAVSRC", "NAV1CDI", "NAV2CDI", "GPSCDI"]
output: CDI
require_leader: false
- function: select
inputs: ["NAVSRC", "NAV1GSI", "NAV2GSI", "GPSGSI"]
output: GSI
require_leader: false

``NAVSRC`` already uses X-Plane's HSI source numbering (``0`` = NAV1,
``1`` = NAV2, ``2`` = GPS), so the ``remap`` to ``XPHSISRC`` is an identity map;
the table is kept as the seam that collapses an optional second GPS (``3`` =
GPS2) onto X-Plane's single GPS, for the :doc:`xplane` plugin's
``dataref_writes`` to send out::

- function: remap
inputs: ["NAVSRC"]
output: XPHSISRC
table: [0, 1, 2]
require_leader: false

The per-source keys (``GPSCRS``, ``NAV1CRS``, ...) are populated by the
:doc:`xplane` plugin's ``datarefs`` subscriptions; on a real aircraft they would
come from the GPS / nav-radio source plugins instead.
190 changes: 170 additions & 20 deletions doc/plugins/xplane.rst
Original file line number Diff line number Diff line change
@@ -1,32 +1,182 @@
===================================
XPlane Flight Simulator Plugin
X-Plane Flight Simulator Plugin
===================================

This plugin allows FIX-Gateway to be used to communicate to the very popular *X-Plane
Flight Simulator*
This plugin connects FIX-Gateway to the
`X-Plane <https://www.x-plane.com>`_ flight simulator over UDP. It lets
X-Plane act as a data *source* -- so a pyEfis display (or any other FIX client)
can be developed and exercised against the simulator -- and as a data *sink*,
so the EFIS can write selected values back into X-Plane. The headline use of
the write path is **nav-source follow**: when the pilot selects GPS / NAV1 /
NAV2 on the EFIS, the plugin tells X-Plane which source to drive its HSI from,
and X-Plane's own autopilot follows the EFIS (see `Nav-source selection and
autopilot follow`_ below).

**This plugin lacks a lot of work and is not really usable in it's current state**
The plugin is **data-driven**. The mapping between X-Plane's data and FIX
database keys is declared entirely in the plugin's configuration block -- new
values are wired up by editing YAML, with no code changes. The shipped
``connections/xplane.yaml`` is heavily commented and is the best line-by-line
reference; this page explains the concepts and each configuration section.

Data paths
==========

Data moves in four ways, each its own configuration section:

* ``recv`` -- *X-Plane to FIX* via X-Plane's indexed *Data Output* UDP stream.
* ``datarefs`` -- *X-Plane to FIX* via named datarefs requested with the
``RREF`` protocol (for values the indexed Data Output rows do not carry).
* ``dataref_writes`` -- *FIX to X-Plane* via named-dataref ``DREF`` writes,
transmitted on change.
* ``send`` -- *FIX to X-Plane* via the indexed Data Output control stream
(disabled by default; see the warning below).

Setting up X-Plane
==================

In X-Plane open **Settings -> Data Output** (named *Net Connections* in older
versions) and:

#. Enable **Send network data output** to the IP of the machine running
FIX-Gateway, at the port you set as ``udp_in`` below.
#. Check the *Data Set* rows you intend to map. The index numbers used in the
``recv`` section correspond to these rows, and the eight columns of each row
map to the eight slots of that index.
#. In **Settings -> Network -> UDP Ports**, note the **legacy** receive port
(default ``49000``). FIX-Gateway sends control writes and both ``RREF`` and
``DREF`` dataref traffic there as ``udp_out``. The newer "Port we receive
on" (default ``49010``) does **not** accept the ``RREF`` protocol, so the
legacy port must be used.

.. note::

X-Plane must allow inbound UDP on ``udp_out`` through the host firewall, or
the requests are silently dropped. (X-Plane's outbound Data Output still
flows, so ``recv`` can appear to work while ``datarefs`` / ``dataref_writes``
do nothing -- check the firewall first.)

Configuration
--------------
=============

::

xplane:
load: yes
module: plugins.xplane
# IP address where the X-Plane simulator is running
load: XPLANE
module: fixgw.plugins.xplane

# IP of the machine running X-Plane -- the destination for FIX -> X-Plane
# writes and for RREF/DREF dataref requests.
ipaddress: 127.0.0.1
# UDP Ports to use for sending and receiving data
# These should match the configuration in the
# "Net Connections" Menu of X-Plane
udp_in: 49001 # Port to received data from X-Plane
udp_out: 49002 # Port to send data to X-Plane

# These are the X-Plane data indexes that we will write. These
# would match the
#idx8 : CTLPTCH, CTLROLL, CTLYAW, x, x, x, x, x
idx25: THR1, THR2, x, x, x, x, x, x
#idx28: PROP1, PROP2, x, x, x, x, x, x
idx29: MIX1, MIX2, x, x, x, x, x, x

# Local UDP port FIX-Gateway BINDS to receive X-Plane's Data Output.
udp_in: 49001
# X-Plane's LEGACY receive port -- where FIX-Gateway SENDS data, RREF and
# DREF. Must be the legacy port (default 49000), not the newer 49010.
udp_out: 49000

# Seconds between FIX -> X-Plane control bursts (0.1 = 10 Hz).
send_interval: 0.1

# RREF stream rate, Hz (how often X-Plane sends subscribed datarefs back).
dataref_hz: 10

recv -- indexed Data Output (X-Plane to FIX)
--------------------------------------------

Each key under ``recv`` is an X-Plane Data Output *index*; its value is a list
of up to eight FIX keys, one per slot, in the same order X-Plane lists that
row's columns. Use ``_`` (or ``x`` / blank) to skip a slot.

::

recv:
# idx 3 -- Speeds: [Vind_kias, Vind_keas, Vtrue_ktas, Vtrue_ktgs, ...]
3: [IAS, _, TAS, GS, _, _, _, _]
# idx 17 -- Pitch, roll, headings: [Pitch, Roll, Hdg_true, _, Hdg_mag, MagVar, _, Track]
17: [PITCH, ROLL, _, _, HEAD, MAGVAR, _, _]
# idx 20 -- Position: [lat, lon, alt_ft_msl, alt_ft_agl, ...]
20: [LAT, LONG, ALT, AGL, _, _, _, _]

datarefs -- RREF subscriptions (X-Plane to FIX)
-----------------------------------------------

For values the indexed rows do not carry -- notably the nav-radio OBS course and
lateral/vertical deflection the HSI needs -- subscribe to X-Plane datarefs by
name. FIX-Gateway issues an ``RREF`` request for each, so X-Plane needs no
extra Data Output checkboxes. Two forms are accepted:

* ``FIX_KEY: dataref`` -- written to the key as-is.
* ``FIX_KEY: [dataref, scale]`` -- written multiplied by ``scale``.

::

datarefs:
# X-Plane hdef is +/-2.5 dots full scale; the HSI needle is +/-1.0, so
# scale by 0.4 (use -0.4 to flip the deflection sense).
GPSCRS: sim/cockpit/radios/gps_course_degtm
GPSCDI: [sim/cockpit/radios/gps_hdef_dot, 0.4]
NAV1CRS: sim/cockpit/radios/nav1_obs_degm
NAV1CDI: [sim/cockpit/radios/nav1_hdef_dot, 0.4]
HEADBUG: sim/cockpit/autopilot/heading_mag

dataref_writes -- DREF writes (FIX to X-Plane)
----------------------------------------------

Each ``FIX_KEY: dataref`` entry sends the FIX key's current value to a named
X-Plane dataref as a ``DREF`` packet, **on change** (the plugin tracks the last
value sent and only transmits when it differs). This reuses the same UDP
socket as the rest of the plugin.

::

dataref_writes:
XPHSISRC: sim/cockpit2/radios/actuators/HSI_source_select_pilot

send -- indexed control output (FIX to X-Plane)
-----------------------------------------------

The mirror of ``recv``: each index maps FIX keys onto the eight slots of an
X-Plane Data Output control row, so hardware (a throttle/mixture quadrant, an
autopilot, etc.) publishing those FIX keys can *drive* the simulator.

.. warning::

``send`` is **disabled by default** and should stay that way for an ordinary
X-Plane -> pyEfis test. These rows are transmitted every ``send_interval``;
if the mapped FIX keys are not actively driven by real hardware they read
``0`` and will command X-Plane's throttle **closed** and mixture to
**cutoff**, killing the engine. Only enable it when genuine hardware is
publishing those keys.

Nav-source selection and autopilot follow
=========================================

In a real panel the EFIS is an active node in the navigation system: the pilot
selects which navigation source (GPS, NAV1, NAV2) the HSI displays, and the EFIS
publishes *that selected source's* guidance onto canonical FIX keys
(``COURSE`` / ``CDI`` / ``GSI``) that both the HSI **and the autopilot** read.
This plugin lets the same selection drive X-Plane so the simulator's native
autopilot tracks whatever the EFIS has selected.

The mechanism uses this plugin together with the :doc:`compute` plugin:

#. A button on the EFIS cycles the ``NAVSRC`` selector key
(``0`` = NAV1, ``1`` = NAV2, ``2`` = GPS).
#. The compute plugin's ``select`` function routes the chosen source's
per-source keys (``NAV1CRS`` / ``NAV2CRS`` / ``GPSCRS``, etc., populated by
the ``datarefs`` section above) into the canonical ``COURSE`` / ``CDI`` /
``GSI`` keys.
#. ``NAVSRC`` already matches X-Plane's own source ordering (``0`` = NAV1,
``1`` = NAV2, ``2`` = GPS), so the compute plugin's ``remap`` copies it to
``XPHSISRC`` unchanged (an identity map).
#. ``dataref_writes`` sends ``XPHSISRC`` out to
``sim/cockpit2/radios/actuators/HSI_source_select_pilot``, so X-Plane
switches its HSI source and its autopilot follows.

::

EFIS button -> NAVSRC --select--> COURSE/CDI/GSI (HSI + autopilot read these)
\--remap---> XPHSISRC --DREF--> X-Plane HSI source + AP

See the :doc:`compute` plugin page for the ``select`` and ``remap`` function
definitions, and ``connections/compute.yaml`` for the shipped rules.
Loading
Loading