Add the digital interface, running MMTTY under Wine
MMTTY and 2Tone have no socket or pipe interface: N1MM hosts XMMT.ocx and exchanges window messages with the engine. A Linux process cannot load that control, so bridge/nonemm-mmtty-bridge.exe hosts it under Wine and passes lines over its standard input and output. docs/digital-bridge.md states the protocol and what the control needs. The window is N1MM's: receive pane with coloured callsigns, grab list, call stacking, twenty-four macro buttons and the engine controls. One left click copies what is under it — a callsign to the callsign box, anything else to the exchange box the contest keeps for that kind of value. Config > Digital registers XMMT.ocx in the Wine prefix on its own, making the prefix first if it is not there. The engine, the bridge and the control start at the copies shipped beside the program. The bridge reads the control's own events. OnTranslateMessage carries only the messages the control has no event for, so nothing was ever decoded through it. hamlib's data mode names read as digital modes now, and a mode typed into the callsign box changes mode the way a frequency changes band, so a station with no radio can reach RTTY at all. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01RoGtneMQaz4M9w7Kk49AVD
This commit is contained in:
@@ -81,4 +81,37 @@ public class CallStackTests
|
||||
|
||||
Assert.Equal(["DL1ABC"], stack.Calls);
|
||||
}
|
||||
|
||||
/// The digital window's call stacking modes.
|
||||
[Fact]
|
||||
public void FirstInFirstOutKeepsTheOrderTheyArrivedIn()
|
||||
{
|
||||
CallStack stack = new() { Order = StackOrder.FirstIn };
|
||||
|
||||
stack.Add("OM5M", isMultiplier: false);
|
||||
stack.Add("S53M", isMultiplier: true);
|
||||
|
||||
Assert.Equal(["OM5M", "S53M"], stack.Calls);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void LastInFirstOutTakesTheNewestFirst()
|
||||
{
|
||||
CallStack stack = new() { Order = StackOrder.LastIn };
|
||||
|
||||
stack.Add("OM5M", isMultiplier: false);
|
||||
stack.Add("S53M", isMultiplier: false);
|
||||
|
||||
Assert.Equal(["S53M", "OM5M"], stack.Calls);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void NothingIsStackedWhenStackingIsOff()
|
||||
{
|
||||
CallStack stack = new() { Order = StackOrder.Disabled };
|
||||
|
||||
stack.Add("OM5M", isMultiplier: true);
|
||||
|
||||
Assert.True(stack.IsEmpty);
|
||||
}
|
||||
}
|
||||
|
||||
124
tests/Nonemm.Session.Tests/DigitalElementTests.cs
Normal file
124
tests/Nonemm.Session.Tests/DigitalElementTests.cs
Normal file
@@ -0,0 +1,124 @@
|
||||
using Nonemm.Contests;
|
||||
using Nonemm.Session;
|
||||
|
||||
namespace Nonemm.Session.Tests;
|
||||
|
||||
/// Where a word clicked in the receive pane goes.
|
||||
public class DigitalElementTests
|
||||
{
|
||||
private static readonly ExchangeField[] SweepstakesLike =
|
||||
[
|
||||
new ExchangeField("Nr", ExchangeSlot.SerialNumber, ExchangeFieldKind.Number),
|
||||
new ExchangeField("Prec", ExchangeSlot.Precedence, ExchangeFieldKind.Precedence),
|
||||
new ExchangeField("Ck", ExchangeSlot.Check, ExchangeFieldKind.Check),
|
||||
new ExchangeField("Sect", ExchangeSlot.Section, ExchangeFieldKind.ArrlSection),
|
||||
];
|
||||
|
||||
private static readonly ExchangeField[] NameAndState =
|
||||
[
|
||||
new ExchangeField("RST", ExchangeSlot.ReceivedReport, ExchangeFieldKind.Report),
|
||||
new ExchangeField("Name", ExchangeSlot.Name, ExchangeFieldKind.Text),
|
||||
new ExchangeField("S/P", ExchangeSlot.Exchange1, ExchangeFieldKind.UsStateOrCanadianProvince),
|
||||
];
|
||||
|
||||
[Fact]
|
||||
public void EachKindOfValueFindsItsOwnBox()
|
||||
{
|
||||
EntryFields fields = new(SweepstakesLike);
|
||||
|
||||
Assert.Equal(1, DigitalElement.FieldFor(fields, "123"));
|
||||
Assert.Equal(2, DigitalElement.FieldFor(fields, "A"));
|
||||
Assert.Equal(3, DigitalElement.FieldFor(fields, "72"));
|
||||
Assert.Equal(4, DigitalElement.FieldFor(fields, "STX"));
|
||||
}
|
||||
|
||||
/// A state is not put in the name box just because that box comes first.
|
||||
[Fact]
|
||||
public void ABoxWithAListBehindItComesBeforeAPlainTextBox()
|
||||
{
|
||||
EntryFields fields = new(NameAndState);
|
||||
|
||||
Assert.Equal(3, DigitalElement.FieldFor(fields, "OH"));
|
||||
Assert.Equal(2, DigitalElement.FieldFor(fields, "PETER"));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void TheReportBoxIsNeverClickedInto()
|
||||
{
|
||||
EntryFields fields = new(NameAndState);
|
||||
|
||||
Assert.False(DigitalElement.Fits(NameAndState[0], "599"));
|
||||
Assert.NotEqual(1, DigitalElement.FieldFor(fields, "599"));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void AnEmptyBoxIsFilledBeforeOneThatAlreadyHasAValue()
|
||||
{
|
||||
EntryFields fields = new(NameAndState);
|
||||
fields[2] = "JOE";
|
||||
|
||||
Assert.Equal(2, DigitalElement.FieldFor(fields, "MIKE"));
|
||||
}
|
||||
|
||||
/// Every box that takes the word is full, so the first one is written over
|
||||
/// rather than the click doing nothing.
|
||||
[Fact]
|
||||
public void AFullBoxIsWrittenOverWhenNoOtherBoxTakesIt()
|
||||
{
|
||||
EntryFields fields = new(SweepstakesLike);
|
||||
fields[4] = "EMA";
|
||||
|
||||
Assert.Equal(4, DigitalElement.FieldFor(fields, "STX"));
|
||||
}
|
||||
|
||||
/// N1MM puts a clicked word in the box the cursor is in, and so does this
|
||||
/// where that box takes the word: a two-figure serial number typed into the
|
||||
/// serial box is not moved to the check box behind the operator's back.
|
||||
[Fact]
|
||||
public void TheBoxWithTheCursorComesFirst()
|
||||
{
|
||||
EntryFields fields = new(SweepstakesLike);
|
||||
fields.FocusOn(1);
|
||||
|
||||
Assert.Equal(1, DigitalElement.FieldFor(fields, "72"));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void NothingTakesAWordTheContestDoesNotExchange()
|
||||
{
|
||||
EntryFields fields = new(SweepstakesLike);
|
||||
|
||||
Assert.Null(DigitalElement.FieldFor(fields, "TU"));
|
||||
}
|
||||
|
||||
[Theory]
|
||||
[InlineData("599123", "123")]
|
||||
[InlineData("599", "599")]
|
||||
[InlineData("OH:", "OH")]
|
||||
[InlineData("1234Z", "1234")]
|
||||
[InlineData(" om5m ", "OM5M")]
|
||||
public void WhatRttyCarriesAroundAValueIsCutOff(string clicked, string expected) =>
|
||||
Assert.Equal(expected, DigitalElement.Trim(clicked));
|
||||
|
||||
[Fact]
|
||||
public void APowerIsTakenWithOrWithoutItsUnit()
|
||||
{
|
||||
ExchangeField power = new("Pwr", ExchangeSlot.Section, ExchangeFieldKind.Power);
|
||||
|
||||
Assert.True(DigitalElement.Fits(power, "100"));
|
||||
Assert.True(DigitalElement.Fits(power, "5W"));
|
||||
Assert.True(DigitalElement.Fits(power, "1KW"));
|
||||
Assert.False(DigitalElement.Fits(power, "KILOWATT"));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void AGridIsFourOrSixCharacters()
|
||||
{
|
||||
ExchangeField grid = new("Grid", ExchangeSlot.GridSquare, ExchangeFieldKind.Grid);
|
||||
|
||||
Assert.True(DigitalElement.Fits(grid, "JN88"));
|
||||
Assert.True(DigitalElement.Fits(grid, "JN88DS"));
|
||||
Assert.False(DigitalElement.Fits(grid, "JN8"));
|
||||
Assert.False(DigitalElement.Fits(grid, "8888"));
|
||||
}
|
||||
}
|
||||
30
tests/Nonemm.Session.Tests/DigitalMacrosTests.cs
Normal file
30
tests/Nonemm.Session.Tests/DigitalMacrosTests.cs
Normal file
@@ -0,0 +1,30 @@
|
||||
using Nonemm.Session;
|
||||
|
||||
namespace Nonemm.Session.Tests;
|
||||
|
||||
public class DigitalMacrosTests
|
||||
{
|
||||
[Fact]
|
||||
public void EveryButtonHasAPlaceEvenWhenTheFileIsShort()
|
||||
{
|
||||
DigitalMacros macros = DigitalMacros.Parse("CQ,{TX}CQ DE {MYCALL} K{RX}");
|
||||
|
||||
Assert.Equal(DigitalMacros.ButtonCount, macros.Buttons.Count);
|
||||
Assert.Equal("CQ", macros[0].Label);
|
||||
Assert.Equal("", macros[23].Message);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void ACommentLineIsNotAButton()
|
||||
{
|
||||
DigitalMacros macros = DigitalMacros.Parse("# the first row\nCQ,CQ DE {MYCALL}");
|
||||
|
||||
Assert.Equal("CQ", macros[0].Label);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void TwoAmpersandsInALabelStandForOne()
|
||||
{
|
||||
Assert.Equal("S&P", DigitalMacros.Parse("S&&P,{S&P}")[0].Label);
|
||||
}
|
||||
}
|
||||
76
tests/Nonemm.Session.Tests/DigitalReceiverTests.cs
Normal file
76
tests/Nonemm.Session.Tests/DigitalReceiverTests.cs
Normal file
@@ -0,0 +1,76 @@
|
||||
using Nonemm.Session;
|
||||
|
||||
namespace Nonemm.Session.Tests;
|
||||
|
||||
/// The decoded text as the modem sends it, one character at a time.
|
||||
public class DigitalReceiverTests
|
||||
{
|
||||
private static List<string> CallsIn(string text)
|
||||
{
|
||||
DigitalReceiver receiver = new();
|
||||
List<string> heard = [];
|
||||
receiver.CallHeard += (_, call) => heard.Add(call);
|
||||
foreach (char c in text)
|
||||
{
|
||||
receiver.Receive(c.ToString());
|
||||
}
|
||||
return heard;
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void ACallsignIsReportedWhenTheWordEnds()
|
||||
{
|
||||
Assert.Equal(["OM5M"], CallsIn("CQ DE OM5M "));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void AWordThatIsStillBeingSentIsNotReportedYet()
|
||||
{
|
||||
Assert.Empty(CallsIn("CQ DE OM5"));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void ALineBreakEndsAWordTheSameWayASpaceDoes()
|
||||
{
|
||||
Assert.Equal(["OM5M"], CallsIn("DE OM5M\r\n"));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void NoiseThatIsNotShapedLikeACallIsPassedOver()
|
||||
{
|
||||
Assert.Empty(CallsIn("RYRY ????? +.+. \r\n"));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void TheTextIsKeptAsItArrived()
|
||||
{
|
||||
DigitalReceiver receiver = new();
|
||||
|
||||
receiver.Receive("CQ TEST ");
|
||||
receiver.Receive("OM5M");
|
||||
|
||||
Assert.Equal("CQ TEST OM5M", receiver.Text);
|
||||
}
|
||||
|
||||
/// A callsign has at most three characters after its number, so that is
|
||||
/// where a word that ran into the next one is cut.
|
||||
[Fact]
|
||||
public void AWordRunTogetherWithTheNextIsCutBackToTheCall()
|
||||
{
|
||||
Assert.Equal("OM5MTE", DigitalReceiver.TrimToCall("OM5MTESTTEST"));
|
||||
Assert.Equal("OM5M", DigitalReceiver.TrimToCall("OM5M"));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void APortableCallIsLeftAlone()
|
||||
{
|
||||
Assert.Equal("OM5M/P", DigitalReceiver.TrimToCall("OM5M/P"));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void TheWordUnderThePointerIsTheOneAroundIt()
|
||||
{
|
||||
Assert.Equal("OM5M", DigitalReceiver.WordAt("CQ DE OM5M K", 7));
|
||||
Assert.Equal("", DigitalReceiver.WordAt("CQ DE OM5M K", 5));
|
||||
}
|
||||
}
|
||||
50
tests/Nonemm.Session.Tests/GrabListTests.cs
Normal file
50
tests/Nonemm.Session.Tests/GrabListTests.cs
Normal file
@@ -0,0 +1,50 @@
|
||||
using Nonemm.Session;
|
||||
|
||||
namespace Nonemm.Session.Tests;
|
||||
|
||||
public class GrabListTests
|
||||
{
|
||||
[Fact]
|
||||
public void TheNewestCallIsAtTheTop()
|
||||
{
|
||||
GrabList list = new();
|
||||
|
||||
list.Add("OM5M");
|
||||
list.Add("S53M");
|
||||
|
||||
Assert.Equal(["S53M", "OM5M"], list.Calls);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void ACallHeardAgainMovesRatherThanRepeating()
|
||||
{
|
||||
GrabList list = new();
|
||||
list.Add("OM5M");
|
||||
list.Add("S53M");
|
||||
|
||||
list.Add("OM5M");
|
||||
|
||||
Assert.Equal(["OM5M", "S53M"], list.Calls);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void TheOldestFallsOffTheEnd()
|
||||
{
|
||||
GrabList list = new(capacity: 2);
|
||||
|
||||
list.Add("OM5M");
|
||||
list.Add("S53M");
|
||||
list.Add("9A1A");
|
||||
|
||||
Assert.Equal(["9A1A", "S53M"], list.Calls);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void OurOwnCallAndTheOneBeingTypedAreNotWanted()
|
||||
{
|
||||
Assert.False(GrabList.Wanted("OM5M", "OM5M", ""));
|
||||
Assert.False(GrabList.Wanted("S53M", "OM5M", "S53M"));
|
||||
Assert.False(GrabList.Wanted("OM5", "OM5M", ""));
|
||||
Assert.True(GrabList.Wanted("S53M", "OM5M", "9A1A"));
|
||||
}
|
||||
}
|
||||
@@ -109,4 +109,16 @@ public class MessagePlanTests
|
||||
Assert.Equal("CQ TEST", plan.Text);
|
||||
Assert.Empty(plan.Before);
|
||||
}
|
||||
|
||||
/// The digital window's transmit macros, and the carriage return that
|
||||
/// starts a new line on the other station's screen.
|
||||
[Fact]
|
||||
public void TheDigitalMacrosAreReadAsActionsAndText()
|
||||
{
|
||||
MessagePlan plan = MessagePlan.Read("{TX}CQ DE {MYCALL}{ENTER}{RX}", Session());
|
||||
|
||||
Assert.Equal([MessageCommand.StartTransmit, MessageCommand.ReturnToReceive],
|
||||
plan.Before.Select(a => a.Command));
|
||||
Assert.Equal("CQ DE DL1ABC\r", plan.Text);
|
||||
}
|
||||
}
|
||||
|
||||
38
tests/Nonemm.Session.Tests/ModeEntryTests.cs
Normal file
38
tests/Nonemm.Session.Tests/ModeEntryTests.cs
Normal file
@@ -0,0 +1,38 @@
|
||||
using Nonemm.Core;
|
||||
using Nonemm.Session;
|
||||
|
||||
namespace Nonemm.Session.Tests;
|
||||
|
||||
/// A mode typed into the callsign box.
|
||||
public class ModeEntryTests
|
||||
{
|
||||
private static readonly Frequency Twenty = Frequency.FromKilohertz(14_080);
|
||||
private static readonly Frequency Forty = Frequency.FromKilohertz(7_040);
|
||||
|
||||
[Theory]
|
||||
[InlineData("CW", "CW")]
|
||||
[InlineData("rtty", "RTTY")]
|
||||
[InlineData("FT8", "FT8")]
|
||||
[InlineData("USB", "USB")]
|
||||
public void AModeNameIsTakenWhateverItsCase(string typed, string expected) =>
|
||||
Assert.Equal(expected, ModeEntry.Parse(typed, Twenty)?.Name);
|
||||
|
||||
/// SSB names no sideband, so the band decides, the way the band panel does.
|
||||
[Theory]
|
||||
[InlineData("SSB")]
|
||||
[InlineData("PH")]
|
||||
[InlineData("PHONE")]
|
||||
public void PhoneTakesTheSidebandTheBandCallsFor(string typed)
|
||||
{
|
||||
Assert.Equal("USB", ModeEntry.Parse(typed, Twenty)?.Name);
|
||||
Assert.Equal("LSB", ModeEntry.Parse(typed, Forty)?.Name);
|
||||
}
|
||||
|
||||
[Theory]
|
||||
[InlineData("OM5M")]
|
||||
[InlineData("14080")]
|
||||
[InlineData("")]
|
||||
[InlineData(" ")]
|
||||
public void AnythingThatIsNotAModeIsLeftAlone(string typed) =>
|
||||
Assert.Null(ModeEntry.Parse(typed, Twenty));
|
||||
}
|
||||
Reference in New Issue
Block a user