Pace the pump on what MMTTY says it has left

The engine probe answered two questions on the air, and they point opposite
ways.

TxBufLen is the number of characters left to transmit. Seventeen characters
pushed, five decoded back, and it read 12, counting down to 0 as the message
went out. So the pump no longer counts character times off the clock: it asks
the engine, feeds while the answer is under Lead, and asks again. The baud rate
is now only the fallback for an engine that will not answer.

A backspace is not an edit. Pushed in as a character it made the count go up by
four and the text went out unchanged, so text the engine has been given cannot
be taken back, only aborted. EngineTypeAhead was built on the opposite belief
and is gone, along with the setting that chose it and the interface that existed
to switch between the two.

A count that stops going down means the engine is holding what it has: MMTTY set
to Word out keeps a word until the space after it. The pump feeds one character
per look while that lasts, so the space arrives and the word goes out rather
than the message sitting there.

The probe kept two bugs of its own that this run showed: it read the count a
millisecond after pushing, saw 0 and called the message finished, and it started
a step while the previous unkey was still in flight, so that step ran with the
engine down. It now needs two empty answers in a row and waits for the engine to
say it has stopped. It also asks what {RX} does to a word the engine is holding,
which decides whether a macro without a trailing space loses its last word.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01RtspmWmS7f8kUvcyaHpRWZ
This commit is contained in:
2026-09-01 23:02:00 +00:00
parent 917a05b898
commit 4118cd6d33
14 changed files with 403 additions and 896 deletions

View File

@@ -6,27 +6,22 @@ namespace Nonemm.Digital;
/// through the same expander, the same `{END}` handling and the same ESM as a
/// CW message does.
///
/// A message goes into the transmit buffer rather than to the engine whole, so
/// the part that has not been transmitted can still be rewritten. `Finished` is
/// A message goes into the type-ahead buffer rather than to the engine whole,
/// so the part that has not gone out can still be rewritten. `Finished` is
/// raised when the buffer has run dry and the engine has transmitted what it
/// was given.
///
/// Which buffer depends on `engineHoldsBuffer`: `EngineTypeAhead` pushes
/// everything to the engine and takes it back with backspaces, `TypeAhead`
/// holds it here and feeds the engine a couple of characters at a time. Only an
/// engine that has a buffer of its own can hold one.
/// An engine that can say how much it still has to transmit paces the buffer;
/// the rest are paced by the clock at `baud`.
public sealed class DigitalEngineSender : MessageSender
{
private readonly DigitalEngine engine;
public DigitalEngineSender(
DigitalEngine engine,
double baud = TypeAhead.DefaultBaud,
bool engineHoldsBuffer = false)
public DigitalEngineSender(DigitalEngine engine, double baud = TypeAhead.DefaultBaud)
{
this.engine = engine;
Buffer = engineHoldsBuffer && engine is EngineBuffer holder
? new EngineTypeAhead(holder)
Buffer = engine is EngineBuffer counter
? new TypeAhead(counter, baud)
: new TypeAhead(
(character, cancellation) => engine.SendAsync(character.ToString(), cancellation),
baud);
@@ -35,7 +30,7 @@ public sealed class DigitalEngineSender : MessageSender
}
/// What is waiting to go out, which the digital window shows and edits.
public TransmitBuffer Buffer { get; }
public TypeAhead Buffer { get; }
public bool IsReady => engine.IsConnected;
@@ -73,19 +68,16 @@ public sealed class DigitalEngineSender : MessageSender
private void WhenDrained(object? sender, EventArgs e) => Finished?.Invoke(this, EventArgs.Empty);
/// The engine dropping the transmitter empties its buffer, which the
/// type-ahead buffer is told so it stops waiting for characters that have
/// already gone. It ends the message only when there is nothing left to
/// send: an engine that keys itself off what it is given drops between two
/// characters of a message the pump is still feeding, and that is not the
/// end of anything.
/// The engine dropping the transmitter ends the message, but only when
/// there is nothing left to send: an engine that keys itself off what it is
/// given drops between two characters of a message the pump is still
/// feeding, and that is not the end of anything.
private void WhenTransmitChanged(object? sender, bool transmitting)
{
if (transmitting)
{
return;
}
Buffer.EngineIdle();
if (!Buffer.IsSending)
{
Finished?.Invoke(this, EventArgs.Empty);