Read split from the radio, and read two of them
Split. RadioState carries a transmit frequency, zero meaning the radio transmits where it listens, so split is not a second flag that can disagree with it. The contact stores it in N1MM's QSX column, the entry window shows 14008.00 followed by the transmit frequency, and the bandmap draws a red bar there. SetSplitAsync sets the frequency before turning split on, or a radio last split somewhere else transmits there. Every command now goes out with a + in front, asking rigctld for its extended answer: named fields ended by an RPRT line. The raw answer is bare values with no terminator, so the client had to know how many lines each command returns — there was a `command == "m"` special case for the one that returns two. Add a third such command and get the count wrong once, and every later answer is read against the wrong command for the rest of the session. RigctldReply parses the extended form and is tested on its own. A radio that cannot do split answers RPRT -11. That is an answer, not a broken connection, so the frequency and mode it did report still count. Two radios. Settings hold a list rather than one host and port, with the single radio an older settings file holds carried into it. Both radios are read and both show on the bandmap, the active one green and the other orange, but only the active one drives the entry window: the second radio moving must not drag the operator off the station being worked. Ctrl+Tab swaps, and a contact records which radio made it. This is not a full two-radio operating position — no second entry window, no alternating CQ, no audio switching. It is two radios read and logged correctly. Tested against a stand-in for rigctld over a real socket, and looked at under Xvfb with two fake radios, one of them split. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
@@ -18,7 +18,8 @@ namespace Nonemm.App;
|
||||
public sealed class AppSession : IDisposable
|
||||
{
|
||||
private LogStore? store;
|
||||
private RigctldRadio? radio;
|
||||
private readonly List<RigctldRadio> radios = [];
|
||||
private int activeRadio;
|
||||
private ClusterClient? cluster;
|
||||
private StationNetwork? network;
|
||||
private MessageSender? keyer;
|
||||
@@ -52,7 +53,14 @@ public sealed class AppSession : IDisposable
|
||||
|
||||
public CheckWindowSources? Check { get; private set; }
|
||||
|
||||
public Radio? Radio => radio;
|
||||
/// One entry per configured radio, in radio-number order.
|
||||
public IReadOnlyList<Radio> Radios => radios;
|
||||
|
||||
/// The radio the operator is on. Null when none is configured, and then
|
||||
/// frequency and mode stay wherever they were last typed.
|
||||
public Radio? Radio => activeRadio < radios.Count ? radios[activeRadio] : null;
|
||||
|
||||
public int ActiveRadioNumber => Radio?.Number ?? 1;
|
||||
|
||||
public ClusterClient? Cluster => cluster;
|
||||
|
||||
@@ -107,7 +115,10 @@ public sealed class AppSession : IDisposable
|
||||
?? throw new InvalidOperationException($"no contest numbered {contestNumber} in the log");
|
||||
Contest contest = Registry.Create(instance.ContestName, ModeCategoryOf(instance));
|
||||
SaveDefinition(contest);
|
||||
Logging = new LoggingSession(Store, contest, instance, Settings.Station.ToStationInfo(), Countries);
|
||||
Logging = new LoggingSession(Store, contest, instance, Settings.Station.ToStationInfo(), Countries)
|
||||
{
|
||||
RadioNumber = ActiveRadioNumber,
|
||||
};
|
||||
Logging.Changed += (_, _) => Changed?.Invoke(this, EventArgs.Empty);
|
||||
Logging.Logged += (_, qso) => Bandmap.Add(new Spot(
|
||||
qso.Call, qso.Frequency, qso.TimestampUtc, SpotSource.Log));
|
||||
@@ -214,22 +225,74 @@ public sealed class AppSession : IDisposable
|
||||
Changed?.Invoke(this, EventArgs.Empty);
|
||||
}
|
||||
|
||||
public void ConnectRadio()
|
||||
/// Opens a connection per enabled radio. A second one makes the station
|
||||
/// SO2R: both are read, but only the one the operator is on drives the
|
||||
/// entry window.
|
||||
public void ConnectRadios()
|
||||
{
|
||||
radio?.Dispose();
|
||||
radio = new RigctldRadio(Settings.RigctldHost, Settings.RigctldPort);
|
||||
radio.Moved += (_, state) => Logging?.Tune(state.Frequency, state.Mode);
|
||||
radio.ConnectionChanged += (_, _) => Changed?.Invoke(this, EventArgs.Empty);
|
||||
radio.Start();
|
||||
DisposeRadios();
|
||||
int number = 1;
|
||||
foreach (StoredRadio configured in Settings.Radios.Where(r => r.IsEnabled))
|
||||
{
|
||||
RigctldRadio opened = new(configured.Host, configured.Port, number++);
|
||||
opened.Moved += (_, state) => RadioMoved(opened, state);
|
||||
opened.ConnectionChanged += (_, _) => Changed?.Invoke(this, EventArgs.Empty);
|
||||
radios.Add(opened);
|
||||
opened.Start();
|
||||
}
|
||||
activeRadio = Math.Min(activeRadio, Math.Max(0, radios.Count - 1));
|
||||
Changed?.Invoke(this, EventArgs.Empty);
|
||||
}
|
||||
|
||||
public void DisconnectRadio()
|
||||
public void DisconnectRadios()
|
||||
{
|
||||
radio?.Dispose();
|
||||
radio = null;
|
||||
DisposeRadios();
|
||||
Changed?.Invoke(this, EventArgs.Empty);
|
||||
}
|
||||
|
||||
/// Moves the operator to the other radio. The entry window follows where
|
||||
/// that radio is sitting, and contacts are logged against its number.
|
||||
public void SwapRadio()
|
||||
{
|
||||
if (radios.Count < 2)
|
||||
{
|
||||
return;
|
||||
}
|
||||
activeRadio = (activeRadio + 1) % radios.Count;
|
||||
if (Logging is not null)
|
||||
{
|
||||
Logging.RadioNumber = ActiveRadioNumber;
|
||||
if (Radio?.State is { } state)
|
||||
{
|
||||
Logging.Tune(state.Frequency, state.Mode, state.TransmitFrequency);
|
||||
}
|
||||
}
|
||||
Changed?.Invoke(this, EventArgs.Empty);
|
||||
}
|
||||
|
||||
/// The radio the operator is not on still moves, and the bandmap shows it,
|
||||
/// but it must not drag the entry window off the contact being worked.
|
||||
private void RadioMoved(Radio moved, RadioState state)
|
||||
{
|
||||
if (moved.Number == ActiveRadioNumber)
|
||||
{
|
||||
Logging?.Tune(state.Frequency, state.Mode, state.TransmitFrequency);
|
||||
}
|
||||
else
|
||||
{
|
||||
Changed?.Invoke(this, EventArgs.Empty);
|
||||
}
|
||||
}
|
||||
|
||||
private void DisposeRadios()
|
||||
{
|
||||
foreach (RigctldRadio open in radios)
|
||||
{
|
||||
open.Dispose();
|
||||
}
|
||||
radios.Clear();
|
||||
}
|
||||
|
||||
public void ConnectCluster()
|
||||
{
|
||||
cluster?.Dispose();
|
||||
@@ -265,7 +328,7 @@ public sealed class AppSession : IDisposable
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
radio?.Dispose();
|
||||
DisposeRadios();
|
||||
cluster?.Dispose();
|
||||
network?.Dispose();
|
||||
keyer?.Dispose();
|
||||
|
||||
Reference in New Issue
Block a user