Flash an aircraft's ring red when it is actually heard

The rings travelling out from each aircraft on the live map kept their own
slow rhythm and said only that something was somewhere about.  Now a ring
turns bright red, and thicker, the moment a frame from that aircraft
arrives, held for a few repaints and then cooling back to its own colour
over half a second.  An aeroplane that is flashing is one being heard right
now rather than one that was.

The receiver is read a block at a time, so frames reach the window in
bursts.  Flashing each on arrival would flash every aeroplane at once, once
a block, which says when the block ended rather than when anything was
heard.  So frames are replayed at their own times, late by however late
they have been turning up over the last ten seconds (believed up to three):
the rhythm is the real one, a beat behind.  A listener that does not report
frames one at a time still counts, through each mark's last-heard time.

Four tests: the flash's shape over time, the replay at a lag, a mark
updated without frames, and red pixels actually drawn round a fresh
aircraft and none round a stale one.

Full suite 2901 passed, 4 skipped.  Built as 2026-11-25_01.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
The Dust Council 2026-11-25 00:42:32 -07:00
commit 3a253d918f
6 changed files with 181 additions and 13 deletions

View file

@ -2137,6 +2137,66 @@ def test_a_ring_leaves_an_aircraft_and_grows(app):
assert late > early, f"the ring did not grow: {early} then {late}"
def test_a_heard_flash_is_full_on_arrival_and_gone_soon_after():
from bandsaunter.livemap import (ECHO_HEARD_HOLD_S, ECHO_HEARD_S,
heard_flash)
assert heard_flash(0.0) == 1.0
assert heard_flash(-0.05) == 1.0, "a clock a hair behind is still now"
assert heard_flash(ECHO_HEARD_HOLD_S) == 1.0, "not held at full red"
middle = (ECHO_HEARD_HOLD_S + ECHO_HEARD_S) / 2
assert 0.0 < heard_flash(middle) < 1.0
assert heard_flash(middle + 0.05) < heard_flash(middle)
assert heard_flash(ECHO_HEARD_S) == 0.0
assert heard_flash(float("inf")) == 0.0
def test_frames_are_played_back_at_their_own_rhythm_a_beat_late():
"""Frames reach the window a block at a time. Flashing each on arrival
would flash everything at once; they are replayed at their own times,
late by however late they have been turning up."""
sky = a_sky()
t = time.time()
# Heard over the last second, told about only now.
for when in (t - 1.0, t - 0.6, t - 0.2):
sky.heard("A76154", when, told=t)
# The lag is a second: the first frame is due now, the others are not.
assert sky.heard_ago("A76154", t) == pytest.approx(0.0, abs=0.05)
assert sky.heard_ago("A76154", t + 0.3) == pytest.approx(0.3, abs=0.05)
assert sky.heard_ago("A76154", t + 0.45) == pytest.approx(0.05, abs=0.05)
assert sky.heard_ago("ABCDEF", t) == float("inf")
def test_a_mark_updated_without_frames_still_counts_as_heard():
sky = a_sky()
sky.update([a_blip(last_seen=time.time())], 1, 1)
assert sky.heard_ago("A76154") < 0.1
@qt
def test_a_ring_flashes_red_when_a_frame_arrives(app):
from bandsaunter.livemap import SkyView
def red_near(heard_ago):
sky = a_sky(a_blip(last_seen=time.time() - heard_ago),
echo=3.0, echo_reach=60)
_at_own_peak(sky, "A76154", 0.4)
view = SkyView(sky)
view.show_ground = False
view.detail = 0
with_it = _rendered(view).astype(int)
sky.echo = 0.0
without = _rendered(view).astype(int)
x, y = view.projection().xy(a_blip().latitude, a_blip().longitude)
near = slice(max(0, y - 90), y + 90), slice(max(0, x - 90), x + 90)
b, g, r = (with_it[near][:, :, i] for i in range(3))
changed = (with_it[near] != without[near]).any(axis=2)
return int((changed & (r > 180) & (g < 100) & (b < 100)).sum())
assert red_near(0.0) > 20, "a frame just in, and no red ring"
assert red_near(30.0) == 0, "red with nothing heard for half a minute"
@qt
def test_the_window_keeps_asking_for_frames_while_anything_is_alive(app):
"""A pulse and an echo are never finished, so the window has to keep