Compare commits
102
Commits
6f2f39768c
...
012b0cdc8b
@@ -7,3 +7,4 @@ obj/
|
||||
/mmtty/
|
||||
/bridge/XMMT.ocx
|
||||
engine-probe.log
|
||||
/dist/
|
||||
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 40 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 37 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 30 KiB |
@@ -10,6 +10,8 @@
|
||||
<Project Path="src/Nonemm.Keying/Nonemm.Keying.csproj" />
|
||||
<Project Path="src/Nonemm.Digital/Nonemm.Digital.csproj" />
|
||||
<Project Path="src/Nonemm.Session/Nonemm.Session.csproj" />
|
||||
<Project Path="src/Nonemm.Recorder/Nonemm.Recorder.csproj" />
|
||||
<Project Path="src/Nonemm.Recorder.App/Nonemm.Recorder.App.csproj" />
|
||||
<Project Path="src/Nonemm.App/Nonemm.App.csproj" />
|
||||
</Folder>
|
||||
<Folder Name="/tools/">
|
||||
@@ -26,6 +28,7 @@
|
||||
<Project Path="tests/Nonemm.Digital.Tests/Nonemm.Digital.Tests.csproj" />
|
||||
<Project Path="tests/Nonemm.Rig.Tests/Nonemm.Rig.Tests.csproj" />
|
||||
<Project Path="tests/Nonemm.Network.Tests/Nonemm.Network.Tests.csproj" />
|
||||
<Project Path="tests/Nonemm.Recorder.Tests/Nonemm.Recorder.Tests.csproj" />
|
||||
<Project Path="tests/Nonemm.App.Tests/Nonemm.App.Tests.csproj" />
|
||||
</Folder>
|
||||
</Solution>
|
||||
|
||||
@@ -40,6 +40,47 @@ Everything that judges a station — the bar under the callsign box, a row in th
|
||||
check window, a spot on the bandmap, a line in the log — is coloured by the same
|
||||
scorer: red for a dupe, green for a new multiplier, blue for points.
|
||||
|
||||
## Sound recorder
|
||||
|
||||
`nonemm-recorder` is a small separate program that records channels of several
|
||||
audio devices into one Opus file. See [docs/recorder.md](docs/recorder.md).
|
||||
|
||||
## Windows
|
||||
|
||||
Build the Windows copy on any machine that has the .NET 10 SDK:
|
||||
|
||||
```sh
|
||||
./publish-windows.sh # dist/nonemm-win-x64.zip
|
||||
./publish-linux.sh # dist/nonemm-linux-x64.tar.gz
|
||||
```
|
||||
|
||||
Each archive holds the logger (`Nonemm.App`) and the recorder
|
||||
(`nonemm-recorder`) as two programs in one folder. Both scripts call
|
||||
`publish.sh`, which takes any runtime id, for example `./publish.sh win-arm64`.
|
||||
|
||||
On Windows itself, run this from PowerShell instead:
|
||||
|
||||
```powershell
|
||||
dotnet publish src\Nonemm.App -c Release -r win-x64 --self-contained -o dist\nonemm-win-x64
|
||||
dotnet publish src\Nonemm.Recorder.App -c Release -r win-x64 --self-contained -o dist\nonemm-win-x64
|
||||
```
|
||||
|
||||
The result needs no .NET install. Unzip it anywhere you can write to and run
|
||||
`Nonemm.App.exe`. Files go in `Documents\N1MM Logger+` and `Documents\Nonemm`,
|
||||
or in the folder `NONEMM_HOME` names.
|
||||
|
||||
What differs from Linux:
|
||||
|
||||
| Part | On Windows |
|
||||
| --- | --- |
|
||||
| MMTTY and 2Tone | The bridge starts directly, with no Wine. Register `bridge\XMMT.ocx` once with the **Register** button in the digital settings. Windows asks for administrator rights, because the control is written to the registry. Keep the file where it is afterwards. See `docs/digital-bridge.md` |
|
||||
| CW | `cwdaemon` has no Windows build. Use a WinKeyer on its COM port |
|
||||
| Radio | Start `rigctld` from the Windows hamlib build, with a COM port: `rigctld -m 2028 -r COM3` |
|
||||
| Voice playback | Plays through PowerShell's `Media.SoundPlayer`. The command is a setting |
|
||||
| Voice recording | Windows has no recorder to call. Install `sox` or `ffmpeg` and put its command in the keyer settings |
|
||||
|
||||
No part of this has been run on Windows yet. The tests pass on Linux only.
|
||||
|
||||
## What it does
|
||||
|
||||
| | |
|
||||
@@ -48,20 +89,21 @@ scorer: red for a dupe, green for a new multiplier, blue for points.
|
||||
| Log | N1MM `.s3db`, Cabrillo 3.0 out, ADIF in and out |
|
||||
| While typing | dupe check, multiplier check, points, country and zone from the country file, exchange filled from a call history file |
|
||||
| While transmitting | a digital message is held in the transmit pane and fed to the engine a character at a time, so what has not gone out can still be rewritten; what has gone out is red, and the engine idles when it catches up with the cursor |
|
||||
| Windows | entry, log, check, bandmap, available mults and Qs, score summary, grey line, telnet, digital interface |
|
||||
| Windows | entry, log, check, bandmap, available mults and Qs, score summary, statistics, grey line, telnet, digital interface, voice keyer |
|
||||
| Statistics | the log counted under any two of its fields, as N1MM's table with its `Tot` and `Accum` columns or as a stacked column graph; either one copies to the clipboard, as spaced text or as a picture |
|
||||
| Editing | double-click a cell in the log, or open the whole contact with Ctrl+Y; Delete removes it. All of it goes out to the other stations |
|
||||
| Radio | one or two radios over hamlib `rigctld`, split, reconnecting on its own |
|
||||
| Cluster | DX cluster over telnet: a telnet window with the node's traffic, the published list of nodes, command buttons and spot filters, spots feeding the bandmap, Alt+P to spot a station |
|
||||
| Bandmap | drawn like N1MM's: a frequency scale with the receiver on it and callsigns beside it, joined by leader lines |
|
||||
| Network | contacts shared with the other stations of a multi-operator entry, in N1MM's own contact message |
|
||||
| Keying | CW through `cwdaemon` or a WinKeyer, with N1MM's message macros |
|
||||
| Digital | N1MM's digital interface window, running MMTTY or 2Tone under Wine through the same `XMMT.ocx` N1MM drives them with |
|
||||
| Keying | CW through `cwdaemon` or a WinKeyer, with N1MM's message macros; phone through the voice keyer, which plays each operator's own recordings |
|
||||
| Digital | N1MM's digital interface window, running MMTTY or 2Tone (under Wine on Linux, directly on Windows) through the same `XMMT.ocx` N1MM drives them with |
|
||||
|
||||
### The digital window
|
||||
|
||||
**Window ▸ Digital Interface** opens N1MM's digital interface. **Engine ▸
|
||||
Settings** says where MMTTY or 2Tone is; **Engine ▸ Start** runs it under Wine.
|
||||
`docs/digital-bridge.md` covers setting the Wine prefix up.
|
||||
Settings** says where MMTTY or 2Tone is; **Engine ▸ Start** runs it: under Wine on Linux, directly on Windows.
|
||||
`docs/digital-bridge.md` covers setting up the Wine prefix or, on Windows, registering the control.
|
||||
|
||||
What the window does, and what each part of it is for:
|
||||
|
||||
@@ -127,9 +169,10 @@ mode stay where they were last typed.
|
||||
**Config → Keyer and messages** picks `cwdaemon` (a UDP port, usually 6789) or a
|
||||
WinKeyer (a serial port) and sets the speed. Escape stops sending.
|
||||
|
||||
The messages are edited as their file, in a plain text editor: right-click any
|
||||
of the function key buttons under the entry window, or use the two buttons in
|
||||
Config → Keyer and messages. One line per key — the button label, a comma, then
|
||||
The messages are edited as their file, in a plain text editor: **Alt+K**,
|
||||
right-click any of the function key buttons under the entry window, or use the
|
||||
two buttons in Config → Keyer and messages. Alt+K and the right-click open the
|
||||
file for the mode the radio is on. One line per key — the button label, a comma, then
|
||||
the message — and a line starting with `#` is a comment. Which key a line
|
||||
belongs to is decided by where it is in the file: the first twelve lines are F1
|
||||
to F12 while running, and twelve more give the same keys while searching, with
|
||||
@@ -154,7 +197,7 @@ macros that are filled in:
|
||||
| `*`, `{MYCALL}` | your callsign |
|
||||
| `!`, `{CALL}` | the call being worked, or the last one logged when the box is empty |
|
||||
| `#` | the serial number for this contact, or the last one when the box is empty |
|
||||
| `{LASTCALL}`, `{PREVNR}` | the call and the serial of the contact just logged |
|
||||
| `{LASTCALL}`, `{PREVNR}`, `{LASTEXCH}` | the call, the serial and the exchange of the contact just logged |
|
||||
| `{EXCH}` | the sent exchange from the contest setup |
|
||||
| `{SENTRST}`, `{SENTRSTCUT}` | the report you send, plain or in cut numbers |
|
||||
| `{NAME}`, `{NAMEANDSPACE}`, `{CHNAME}` | the other operator's name, from the entry window or the call history file |
|
||||
@@ -162,12 +205,20 @@ macros that are filled in:
|
||||
| `{GRIDBEARING}`, `{REVGRIDBEARING}`, `{KMGRIDDISTANCE}` | bearing and distance between the two |
|
||||
| `{FREQ}`, `{FREQROUND}` | this radio's frequency in kilohertz, with `R` for the decimal point on CW |
|
||||
| `{OTHERFREQ}`, `{OTHERFREQROUND}`, `{OTHERMHZ}`, `{OTHERBAND}`, `{LRMHZ}`, `{RRMHZ}` | the other radio, for passing a station |
|
||||
| `{TIMESTAMP}`, `{TIME2}` | the time now |
|
||||
| `{TIMESTAMP}`, `{TIME2}` | the time now, as `2026-09-11 07:45` and as `0745` |
|
||||
| `{TIME}`, `{DATE}`, `{TIMEGMT}`, `{DATEGMT}` | the clock and the calendar the way this machine writes them, local or UTC |
|
||||
| `{ROVERQTH}` | where a rover is now, from the station data |
|
||||
| `{ESC}`, `{CTRL-A}` to `{CTRL-Z}` | the control characters a TNC reads as commands |
|
||||
| `{WAVDIR}` | the folder the voice keyer plays from, which is named after whoever is at the microphone |
|
||||
|
||||
The action macros run rather than standing for text: `{WIPE}`, `{LOG}`,
|
||||
`{RUN}`, `{S&P}`, `{SPACE}`, `{SPOTME}`, `{STOPTX}`, `{FREQUP}`, `{FREQDN}`,
|
||||
`{PGUP}`, `{PGDN}`, `{JUMPRX}`, `{JUMPRXTX}`, `{STACKANOTHER}`, `{SOCALLSTACK}`,
|
||||
`{LOGTHENPOP}`, `{LOGTHENNEXT}`, `{CLRSTACK}`, `{CTRLF1}` to `{CTRLF12}` to send
|
||||
`{LOGTHENPOP}`, `{LOGTHENNEXT}`, `{CLRSTACK}`, `{CTRLHOME}` to put the cursor
|
||||
back in the callsign box, `{CLEARRIT}` to put the receive offset back to zero,
|
||||
`{FORCELOG}` to log a contact the checks refuse, `{CQ}` to make a key a CQ key,
|
||||
`{DIGQTCS}` and `{DIGQTCR}` to open the WAE QTC window, `{F1}` to `{F12}` to
|
||||
send another of this radio's keys, `{CTRLF1}` to `{CTRLF12}` to send
|
||||
on the other radio, `{TELNET sh/dx}` to put a command on the cluster, and
|
||||
`{OTRSP TX2}` to send one to the SO2R box. An action runs before the message
|
||||
goes out, unless it stands after `{END}`, and then it runs once the message has
|
||||
@@ -179,9 +230,70 @@ How far `{FREQUP}` and the rest move the radio is `FrequencyStepHertz` and
|
||||
`PageStepHertz` in `settings.json`, 100 Hz and 1 kHz out of the box; N1MM asks
|
||||
for the same two numbers in its Configurer.
|
||||
|
||||
The rest of N1MM's action macros — the CAT families, audio, rotators, stereo,
|
||||
the digital TNC macros — are read and passed over, so a message that holds one
|
||||
still sends the right characters.
|
||||
`{CQ}` is for a station whose CQ is not on F1: the key it stands in starts
|
||||
running and carries alternating CQ on, which F1 does by itself. `{FORCELOG}`
|
||||
logs whatever is in the boxes, holes and all — it still needs a callsign, and
|
||||
the status line says the row will need fixing before the log goes in.
|
||||
|
||||
The rest of N1MM's macros — the CAT families, audio, rotators, stereo,
|
||||
`{SETWAVDIR}`, `{SwapContests}`, `{VARYMSG1}` and `{VARYMSG2}`, `{COMMENT}`,
|
||||
`{FORCELOGNOTE}`, `{CONDJUMP}`, `{QSYCQ}`, `{CLUSTER}` and the two needed-QSO
|
||||
macros — are read and passed over, so a message that holds one still sends the right
|
||||
characters. So are `{TIME1}`, `{DATE1}` and `{DAYTIME}`, which are packet BBS
|
||||
date formats this has no way to check.
|
||||
|
||||
### The voice keyer
|
||||
|
||||
On phone a function key plays a recording, which is what N1MM does. The message
|
||||
is the name of a wav file rather than words:
|
||||
|
||||
F1 CQ,{WAVDIR}\Cq.wav
|
||||
|
||||
`{WAVDIR}` is the folder named after whoever is at the microphone, so each
|
||||
operator calls CQ in his own voice without anything being edited when the radio
|
||||
changes hands. A name is taken relative to `Wav`, so `WAEQRV.wav` is the one
|
||||
file the whole station shares and `OM3KFF\Cq.wav` is one operator's. Several
|
||||
files separated by commas play one after the other. All of this is N1MM's, so
|
||||
an SSB `.mc` file written for N1MM plays here.
|
||||
|
||||
**Window → Voice Keyer** lists every recording the messages name, says which
|
||||
ones are there, and records the ones that are not:
|
||||
|
||||
| Column | |
|
||||
|---|---|
|
||||
| Where | the keys that play it — `F1 run, F1 S&P` — or `QTC window` |
|
||||
| Says | what the key's label says, which is what the recording has to say |
|
||||
| File | the file name, in the folder named at the top |
|
||||
| Recorded | whether it is there, for the operator picked at the top |
|
||||
|
||||
**Play** auditions a recording. It does not key the transmitter, so what goes
|
||||
out on the air is only what a function key sends — unless the radio is on VOX,
|
||||
which hears the audio and keys itself either way. **Record** replaces the file,
|
||||
and the button becomes **Stop**; nothing is written over until the recorder has
|
||||
finished, so a recording that goes wrong leaves the old one playable.
|
||||
|
||||
**Ctrl+Shift+F1** to **Ctrl+Shift+F12** record from the entry window, which is
|
||||
N1MM's on-the-fly recording: the key names the file, so Ctrl+Shift+F1 records
|
||||
over the CQ. The same pair again stops it, and so do Escape and sending
|
||||
anything — there is one microphone, and it cannot be recorded and transmitted
|
||||
at once. The status line says what is being recorded and what was saved. A key
|
||||
that names several files records the first, as N1MM's does.
|
||||
|
||||
Playing and recording are `aplay` and `arecord` out of the box, and the two
|
||||
commands are boxes at the bottom of the window: `{file}` in a command stands
|
||||
for the file. A station on JACK, or one on Windows, writes its own. Why it runs
|
||||
a program rather than driving the sound card itself is in
|
||||
[`docs/keying.md`](docs/keying.md).
|
||||
|
||||
The transmitter is keyed through the same `cwdaemon` that keys CW — its
|
||||
`<ESC>a` — for as long as the recording plays. The tick box turns that off for
|
||||
a station whose radio keys itself on VOX. A WinKeyer station has no PTT path
|
||||
from here and needs VOX.
|
||||
|
||||
What is not here is N1MM's advanced voicing: the recording per letter and per
|
||||
number in `LettersFiles` that N1MM strings together to say a callsign or a
|
||||
serial. So F5 (his call) is empty, as it is in N1MM's own default file, and a
|
||||
serial number is read out by the operator.
|
||||
|
||||
### ESM — Enter sends the message
|
||||
|
||||
@@ -208,28 +320,37 @@ in again while you are running, and `EsmSendsCorrectedCall` sends the call again
|
||||
in front of the last message when you have corrected it — copy `SM3AB`, fix it
|
||||
to `SM3ABC`, and the key sends `SM3ABC TU DL1ABC`.
|
||||
|
||||
### Name, comment, and the two lights
|
||||
### The boxes a contest shows, and the two lights
|
||||
|
||||
Beside the exchange are a Name box and a Comment box, as N1MM has them. Neither
|
||||
is part of the exchange, so neither holds up a contact: they fill the log's Name
|
||||
and Comment columns, and a contest that exchanges a name uses that instead.
|
||||
Neither is in the space walk, as neither is in N1MM's; tab reaches both. The name is filled from the call history file when there is one,
|
||||
and what the call history says in its UserText column appears under the entry
|
||||
boxes.
|
||||
The entry window shows the boxes N1MM's entry window shows for that contest and
|
||||
no others. General logging has a Name box and a Comment box; a contest has the
|
||||
boxes it exchanges. Two of them are for what this station sends — the report and
|
||||
the serial number — and both are filled in and stepped over, as they are in
|
||||
N1MM.
|
||||
|
||||
Where the other station sends a serial number or a district code depending on
|
||||
where it is, there is one box for both, again as in N1MM: what is typed goes in
|
||||
the exchange column, and the number, section or zone column as well, so the
|
||||
score and the Cabrillo file read it from the same place N1MM does. Sweepstakes
|
||||
takes its whole exchange in one box — `72 A 74 SCV`, in any order — and logs it
|
||||
in four columns.
|
||||
|
||||
What the call history says in its UserText column appears under the entry boxes.
|
||||
|
||||
### Space and tab
|
||||
|
||||
They are not the same key, and N1MM does not treat them as one.
|
||||
|
||||
Space moves between the callsign box and the exchange boxes and round again,
|
||||
stepping over the report boxes, because nobody types 599: leaving the callsign
|
||||
box fills them with the report for the mode, 599 on CW and digital, 59 on phone.
|
||||
stepping over the report boxes and the sent serial, because nobody types 599 or
|
||||
the number going out: leaving the callsign box fills the reports in for the
|
||||
mode, 599 on CW and digital, 59 on phone.
|
||||
It also steps over a box this station is not asked for, such as the state in
|
||||
CQ WW RTTY for a station outside the US and Canada. So in CQ WW, space takes you
|
||||
from the callsign straight to the zone, and space again brings you back.
|
||||
|
||||
Tab walks every box in turn — callsign, the exchange including the reports, the
|
||||
name and the comment — and round again; shift and tab go the other way. N1MM
|
||||
Tab walks every box in turn — the callsign and the exchange, the reports
|
||||
included — and round again; shift and tab go the other way. N1MM
|
||||
does not touch the tab key at all, so tab there walks its boxes in the order
|
||||
they are laid out, which is what this does.
|
||||
|
||||
@@ -445,16 +566,13 @@ pressing at a multi-operator station:
|
||||
|---|---|
|
||||
| Window positions | where every open window sits is stored against the operator leaving, and the operator taking over gets his own back. A window opened later is placed as it appears |
|
||||
| Colours | the theme he last had |
|
||||
| Recordings folder | the folder his wav files are in, since a voice keyer plays the recordings of whoever is at the microphone. It starts at `Wav/<his callsign>`, which is where N1MM looks, and the folder is made when he takes the radio |
|
||||
| Recordings folder | the folder his wav files are in: the voice keyer plays the recordings of whoever is at the microphone. It is `Wav/<his callsign>`, which is where N1MM looks, and the folder is made when he takes the radio |
|
||||
|
||||
An operator whose callsign is not in the list is made by typing it, and starts
|
||||
with the windows and colours on the screen. **Remove** drops one from the list;
|
||||
the contacts he logged keep his callsign, because those are in the log rather
|
||||
than in the settings.
|
||||
|
||||
Nothing plays the recordings yet — there is no voice keyer — so the folder is
|
||||
stored and passed on rather than used.
|
||||
|
||||
### The log window
|
||||
|
||||
The pane under the log lists what has already been worked with the call being
|
||||
@@ -485,6 +603,18 @@ save first. Points and the multiplier flags are shown but cannot be typed in —
|
||||
they are worked out from the rules every time the log changes, so anything typed
|
||||
there would be overwritten on the next edit.
|
||||
|
||||
The dialog also has the checkbox that takes a contact out of the claimed score.
|
||||
An unclaimed contact scores no points and holds no multiplier, and the search
|
||||
for dupes and multipliers passes over it, so a later contact with the same call
|
||||
or the same multiplier counts in full. It still goes into the Cabrillo file,
|
||||
under `X-QSO:` rather than `QSO:` — that is what N1MM writes, and the sponsors
|
||||
read it as a contact the entrant is not claiming.
|
||||
|
||||
Every Cabrillo line starts with its record name padded to seven characters, so
|
||||
`QSO:`, `QTC:` and `X-QSO:` all put the frequency in the same column. That is
|
||||
the width N1MM pads it to, and `X-QSO:` is the reason: six characters and one
|
||||
space.
|
||||
|
||||
Correcting the country prefix by hand changes the score. The country file is a
|
||||
best guess for calls it has no rule for, so what the contact says now wins over
|
||||
what the file says.
|
||||
@@ -533,11 +663,49 @@ rather than guessing.
|
||||
|
||||
### Available mults and Qs
|
||||
|
||||
**View → Available Mults and Qs** lists what is spotted and not worked yet, a
|
||||
column per band, multipliers first and then the stations that are only points.
|
||||
Clicking one puts the radio there with the call in the entry window, the same as
|
||||
clicking a spot on the bandmap. **Mults only** hides everything that brings no
|
||||
multiplier.
|
||||
**View → Available Mults and Qs** lists what is spotted and not worked yet. The
|
||||
top shows a table with the multipliers, the Qs and the total on each band.
|
||||
Under it is one line per station, sorted on frequency until you click another
|
||||
header. Click a header to sort on that column, and
|
||||
shift-click a second header to add a second sort key. The line is coloured the
|
||||
same as in the entry window, and the one the radio is on is drawn in reverse.
|
||||
|
||||
| Column | Shows |
|
||||
| --- | --- |
|
||||
| Call, Freq, Mode | the spot; `»` after the frequency marks a split |
|
||||
| Dir | beam heading from the grid in call history, or the country file |
|
||||
| Mlt | how many multipliers the station would bring |
|
||||
| SN | decibels from a Skimmer spot's comment |
|
||||
| TS | spot time in UTC; `◴` when the spot is within 3 minutes of dropping off the bandmap |
|
||||
| Spotter | `(#)` after a Skimmer or beacon spotter |
|
||||
| Grid | grid square from call history |
|
||||
| Sun | `▲` or `▼` and the minutes to (+) or since (-) sunrise or sunset at the station, within one hour |
|
||||
| Pts | points the contact would bring |
|
||||
| ★ | the spotter is in the telnet window's preferred spotters |
|
||||
|
||||
Right-click a header to show or hide a column, or to resize the columns to their
|
||||
contents. Drag a header to move a column.
|
||||
|
||||
- Click a line to put the radio there with the call in the entry window. Click
|
||||
with the middle button, or right-click ▸ **Delete Spot**, to remove the spot
|
||||
from the bandmap. **Blacklist callsign** and **Blacklist spotter** add the
|
||||
name to the telnet window's blocked lists and remove its spots.
|
||||
- Alt+A picks the next line and tunes to it, Shift+Alt+A the previous one and
|
||||
Ctrl+Alt+A the first. Nothing happens until a line is picked.
|
||||
- While the mouse is over the list the list stops re-sorting for six seconds, so
|
||||
the line being aimed at stays put. The window says "Scrolling Pausing".
|
||||
- Click a band in the table to show only that band. Shift-click adds more bands.
|
||||
Click a number in the Mults row to show that band's multipliers, or in the Qs
|
||||
row to show its multipliers and Qs. Click Mults, Qs or Total at the left to
|
||||
show every band.
|
||||
- The **Mults** / **Mults & Qs** button shows what the list holds now, and a
|
||||
click switches it. **Bands & Modes** opens a window with a tick for each band and for CW,
|
||||
Phone, Digital and Contest modes; it limits the list without touching the
|
||||
telnet filters. Both are kept between runs.
|
||||
- The right-click menu also holds **Summary Panel Band Selection**, **Show
|
||||
Summary Panel** and **Help**. With the list sorted on TS, newest first,
|
||||
**QSY to top spot after logging QSO** tunes to the newest spot after each
|
||||
contact logged while searching and pouncing.
|
||||
|
||||
A spot carries no exchange, so a station is only known to be a multiplier where
|
||||
the multiplier follows from the callsign — a DXCC entity — or where the call
|
||||
@@ -639,7 +807,9 @@ cannot drive alternating CQ, and says so rather than keying the second radio
|
||||
while the first is still sending. **Config → Keyer and messages** sets the gap
|
||||
between the two, which is 100 ms by default because an SO2R box works relays.
|
||||
|
||||
CW only for now: it sends the F1 message, and there is no voice keyer.
|
||||
It sends the F1 message for the mode the radio is on, so it duels on phone as
|
||||
well as on CW: the voice keyer says when a recording has finished playing the
|
||||
same way `cwdaemon` says when a CW message has gone out.
|
||||
|
||||
Why the keying is `cwdaemon`'s job rather than the logger's, and what it would
|
||||
take to key the port directly as N1MM does, is in
|
||||
@@ -692,7 +862,9 @@ them — `Exchange1` says `SQTC` or `RQTC`, the time, callsign and serial number
|
||||
of the contact being reported go in the sent report, received report and sent
|
||||
number columns, and the series such as `9/10` goes in the misc text column. A
|
||||
log written by either program therefore opens in the other with its QTCs
|
||||
intact, and a QTC row is written to the Cabrillo file as a `QTC:` record.
|
||||
intact, and a QTC row is written to the Cabrillo file as a `QTC:` record. The
|
||||
log window shows both columns under N1MM's headers for them, `Series` and
|
||||
`QTC?`, so a QTC row can be told from a contact at a glance.
|
||||
|
||||
**Ctrl+Z** opens the QTC window for the station being worked, which is the key
|
||||
N1MM uses. The window is laid out the same way: the header, ten lines of time,
|
||||
@@ -707,9 +879,30 @@ being worked, and never more than the ten any station may have — and cannot be
|
||||
edited. On CW and SSB the direction is fixed by the rules; on RTTY traffic goes
|
||||
both ways and the window has a switch.
|
||||
|
||||
Tab, enter and space all move to the next box the operator types in, and shift
|
||||
and tab move back. The walk covers those boxes and nothing else: N1MM handles
|
||||
the three keys itself in every box rather than leaving them to the tab order,
|
||||
so the cursor never lands on a switched-off line or on a button beside one.
|
||||
|
||||
The header says how many lines take traffic. `4/5` is series 4 with five QTCs
|
||||
in it, so five lines are live and the other five are switched off; a station
|
||||
with fewer than five of its ten left gets that many instead. Nothing already
|
||||
typed is cleared when the header changes.
|
||||
|
||||
A time typed short is filled in from the line above as the cursor leaves the
|
||||
box: `52` under `1148` reads as `1152`. As many characters are taken off the
|
||||
front of the line above as the typed part is missing, which is N1MM's rule, and
|
||||
a colon is dropped whatever the length.
|
||||
|
||||
One thing here that N1MM does not do: while the cursor is in a QTC callsign
|
||||
box, the check window answers for that call rather than for the one in the
|
||||
entry window, so a call taken down in traffic is checked the same way one being
|
||||
worked is.
|
||||
|
||||
Right-click the window for **Setup**: how many QTCs a series carries, whether
|
||||
the RX Ready and Cfm steps are stopped at, whether Hdr Agn and Agn clear what
|
||||
they ask for again, and the CW messages below. The defaults are N1MM's — both
|
||||
they ask for again, and the CW and RTTY messages. The SSB recordings are named
|
||||
by N1MM and are not settings. The defaults are N1MM's — both
|
||||
steps skipped, the header cleared, the line left alone.
|
||||
|
||||
On CW the window puts the traffic on the air itself, through the same keyer a
|
||||
@@ -743,17 +936,39 @@ out as it stands. All of it is edited in Setup, with N1MM's defaults. The serial
|
||||
number goes out as digits: N1MM can send cut numbers, and nothing here does, for
|
||||
any message.
|
||||
|
||||
Nothing is sent on SSB or RTTY. N1MM plays four recordings on SSB — QRV, Agn,
|
||||
Cfm and TU — and sends RTTY through its digital window; this program has no
|
||||
voice keyer and no digital window, so on those two modes the buttons move the
|
||||
cursor as they did before. N1MM's RTTY window also has a Send All button that
|
||||
keys the whole series at once; there is nothing to send it with here.
|
||||
On RTTY the traffic goes out through the digital window's engine, with N1MM's
|
||||
messages and N1MM's defaults on both sides: R U QRV and Save for the station
|
||||
reading a series out, RX Ready, All Agn, Agn n and Save for the station taking
|
||||
it down. Send All is there too — the heading, every line with the operator's
|
||||
spacing between them, then the ending, all as one message with `{TX}` and
|
||||
`{RX}` around it. Clicking a line in the digital window fills the next row,
|
||||
which is how a series is copied.
|
||||
|
||||
In a WAE contest the log window has N1MM's **QTC?** column, which holds the
|
||||
series a QTC row belongs to and is empty for an ordinary contact.
|
||||
On SSB the buttons play N1MM's four recordings — `WAEQRV.wav`, `WAEAgain.wav`,
|
||||
`WAEConfirm.wav` and `WAETu.wav`, in the `Wav` folder rather than an operator's,
|
||||
which is where N1MM keeps them. RX Ready and R U QRV play the QRV one, Hdr Agn
|
||||
and every Agn play the again one, Cfm plays the confirm one, and Close plays the
|
||||
TU. The lines themselves are read out by the operator: a QTC line is a time, a
|
||||
callsign and a serial number, and no recording can say one. Record the four in
|
||||
Window ▸ Voice Keyer.
|
||||
|
||||
In a WAE contest the log window has N1MM's two columns, whose names do not read
|
||||
the way they sound: **Series** says whether the row is a contact or traffic —
|
||||
`QSO`, `SQTC` or `RQTC` — and **QTC?** holds the series a QTC row belongs to,
|
||||
such as `3/10`.
|
||||
|
||||
The score summary splits the same way N1MM's does: contacts, traffic sent and
|
||||
traffic received get a row each on every band, under a **Q/QTC** column, and a
|
||||
band row carries that band's weight, so 80 metres reads 4 for one multiplier.
|
||||
The band rows add up to the total.
|
||||
|
||||
The scoring was checked against six real WAE logs, and agrees with N1MM on
|
||||
points and on weighted multipliers to the contact.
|
||||
points and on weighted multipliers to the contact. The Cabrillo layouts are
|
||||
N1MM's, from `CWAE.CabrilloString`: a contact leaves three spaces after the sent
|
||||
serial rather than the one every other column gets, a QTC line is written as a
|
||||
`QTC:` record carrying the receiver, the series, the sender and then the time,
|
||||
callsign and serial number being reported, and the transmitter column is written
|
||||
only for a multi-operator entry.
|
||||
|
||||
### Band edges
|
||||
|
||||
@@ -776,12 +991,18 @@ tabs, the ones N1MM has:
|
||||
spot line, or "Jump to this spot" on the right-click menu, puts the radio
|
||||
there with the call in the entry window. Scrolling stops while the pointer is
|
||||
over the traffic, so a line can be read while the node keeps sending.
|
||||
- **Clusters** keeps a list of nodes with their names, ports, passwords and the
|
||||
commands to send after login. Connect and Disconnect are there, with automatic
|
||||
logon, the call to log on with, and the keep-alive interval. **Download** under
|
||||
it fetches the published list of nodes from
|
||||
- **Clusters** keeps a list of favourite nodes: the callsign in bold, the
|
||||
address and, under them, the sysop's note. Each favourite has its own password,
|
||||
its own commands to send after login and its own call to log on with (empty
|
||||
means the one on the Login & Spots tab). Clicking a favourite fills the boxes
|
||||
so it can be edited, and **Save** writes the change back. **Autoconnect** marks
|
||||
one favourite as the node to connect to when the program starts and moves it to
|
||||
the top; on that favourite the button reads **Don't connect**, and with no
|
||||
favourite marked nothing connects at start. **Download**, across the bottom,
|
||||
fetches the published list of nodes from
|
||||
[NG3K](https://www.ng3k.com/misc/cluster.html) — around fifty nodes with the
|
||||
sysop's call, the address and a note about each — and clicking one fills the
|
||||
sysop's call, the address and a note about each — and refreshes the notes of the
|
||||
favourites that are in it. Clicking a node in the list fills the
|
||||
boxes in. N1MM downloads its list from its own web service, which asks the
|
||||
operator to opt in to data collection; this reads a public page instead.
|
||||
- **Filters** says which spots reach the bandmap: bands, modes, beacons, busted
|
||||
@@ -793,7 +1014,8 @@ tabs, the ones N1MM has:
|
||||
sends.
|
||||
- **Buttons** edits the twelve command buttons: a label and its commands, or
|
||||
back to the defaults.
|
||||
- **Spot comment** is what goes out with the spots you send.
|
||||
- **Login & Spots** holds the call to log on with, the keep-alive interval and the
|
||||
comment that goes out with the spots you send.
|
||||
|
||||
The buttons come from the settings; without any, they are `sh/dx`, `sh/dx/20`,
|
||||
`sh/wwv`, `sh/users`, `sh/c/n`, `help` and `bye`. A button holds what N1MM's
|
||||
@@ -843,7 +1065,7 @@ retried. The last two hundred lines are kept, so a window opened mid-contest is
|
||||
not blank.
|
||||
|
||||
Alt+P, or **Edit → Spot It**, puts the call being typed on the cluster at the
|
||||
current frequency, with the comment from the Spot comment tab — which takes the
|
||||
current frequency, with the comment from the Login & Spots tab — which takes the
|
||||
message macros too; with nothing
|
||||
typed it spots the last contact logged. The spot also goes straight onto our own
|
||||
bandmap rather than waiting to come back round from the node.
|
||||
@@ -853,17 +1075,58 @@ at the node as well, because that is less traffic on the wire.
|
||||
|
||||
### Networked stations
|
||||
|
||||
**Config → Network** names this station and lists the others. Each contact is
|
||||
sent to them as it is logged, in N1MM's `contactinfo` message, so an N1MM
|
||||
station on the same network sees them too. Editing a contact sends
|
||||
`contactreplace` and deleting one sends `contactdelete`, the same as N1MM. With
|
||||
no addresses listed the messages are broadcast. A contact that arrives is scored
|
||||
The **Stations Configuration** button on the Options tab of Network Status
|
||||
names this station, sets the port it listens on and lists the stations to
|
||||
reach by address. The station number, link
|
||||
port and version to claim are on the Options tab of Network Status. **Config → Configure Broadcast Data** is N1MM's Broadcast
|
||||
Data tab: seven kinds of data, each with an on/off box and a list of
|
||||
`address:port` pairs separated by spaces. An empty list sends to `127.0.0.1` on
|
||||
N1MM's port for that kind: 12060, except the score on 12050 and the rotor on
|
||||
12040.
|
||||
|
||||
| Row | What goes out | When |
|
||||
| --- | --- | --- |
|
||||
| Application Info | `AppInfo`: database, contest number and name | a contest is opened |
|
||||
| Radio | `RadioInfo`: frequency, mode, run/search, split, connection | something in it changes |
|
||||
| Contacts | `contactinfo`, `contactreplace`, `contactdelete` | a contact is logged, edited or deleted |
|
||||
| Contacts, All Computers | the contacts the other logging computers make | one arrives on port 12070 |
|
||||
| Spots | `spot` with N1MM's status (`new qso`, `dupe`, `single mult`, `double mult`) | a spot reaches the bandmap |
|
||||
| Rotor | nothing yet: this program has no rotor control | |
|
||||
| Score | `dynamicresults`: a row per band and mode, and a total, in N1MM's layout | every ten seconds |
|
||||
| External Callsign Lookup | `lookupinfo`: the contact being typed | Tab leaves the callsign box on a new call |
|
||||
|
||||
Contacts with no address listed are broadcast to the whole network, and each
|
||||
contact is sent in N1MM's `contactinfo` message, so an N1MM station on the same
|
||||
network sees them too. Editing a contact sends `contactreplace` and deleting
|
||||
one sends `contactdelete`, the same as N1MM. A contact that arrives is scored
|
||||
again here from the rules rather than trusted.
|
||||
|
||||
An incoming edit or delete is matched by contact id first. N1MM does not know
|
||||
our ids, so the call and the timestamp are the fallback — that is the pair N1MM
|
||||
itself keys a contact on.
|
||||
|
||||
**Every station of the entry counts serial numbers from the same list.** Each
|
||||
station holds the highest number taken on each band. A number is taken at the
|
||||
first character of the callsign rather than when the contact is logged, and the
|
||||
`ReserveNr` message tells the other stations at once, so two operators typing at
|
||||
the same moment do not send the same number.
|
||||
|
||||
A station that claims a number this one has already used is sent a `QSONRS`
|
||||
message, which holds the highest number for each band. Both ends keep the higher
|
||||
of the two numbers for each band, so the station that was behind counts on from
|
||||
the right number. The same message is sent when a contest is opened, so a
|
||||
station that joins a contest already under way starts where the others are.
|
||||
|
||||
Most contests run one sequence for the whole station. CQ WPX runs one per band
|
||||
for a multi-two and a multi-multi, which is the class the entry declares in
|
||||
contest setup, and N1MM decides it the same way.
|
||||
|
||||
**Reset Serial Numbers at all Stations** is for numbers that have gone wrong —
|
||||
a station that was logging another contest, or numbers claimed and never used.
|
||||
Every station counts from its own log again, so the next number is the highest
|
||||
one in the log plus one and no number already sent is sent a second time. The
|
||||
contacts already logged keep the numbers they were sent with.
|
||||
|
||||
A contact that arrives is put into the log where its timestamp says it belongs
|
||||
and the log is scored again, so of two stations that worked the same multiplier
|
||||
the one that worked it first keeps it, however late the message turns up.
|
||||
@@ -881,8 +1144,8 @@ windows redraw where they stand.
|
||||
| `Nonemm.Rig` | Radio control over `rigctld`, and the SO2R box |
|
||||
| `Nonemm.Spotting` | Spots, the bandmap, the DX cluster client |
|
||||
| `Nonemm.Network` | Contacts shared between the stations of a multi-operator entry |
|
||||
| `Nonemm.Keying` | CW through `cwdaemon` or a WinKeyer |
|
||||
| `Nonemm.Digital` | MMTTY and 2Tone, over the Wine bridge in `bridge/` |
|
||||
| `Nonemm.Keying` | CW through `cwdaemon` or a WinKeyer, and the voice keyer's recordings |
|
||||
| `Nonemm.Digital` | MMTTY and 2Tone, over the bridge in `bridge/` |
|
||||
| `Nonemm.Session` | The contest in progress, and one entry position per radio — no UI toolkit |
|
||||
| `Nonemm.App` | The Avalonia windows |
|
||||
|
||||
@@ -892,11 +1155,11 @@ covered by plain unit tests.
|
||||
|
||||
## Where it stands
|
||||
|
||||
Working: logging a contest end to end, live dupe and multiplier checking, eight
|
||||
built-in contests plus user-defined ones, Cabrillo and ADIF export, ADIF import,
|
||||
the log, check, graphical bandmap, score and telnet windows, editing and deleting logged
|
||||
contacts, radio control, DX cluster spots, contacts shared between networked
|
||||
stations, and CW keying.
|
||||
Working: logging a contest end to end, live dupe and multiplier checking,
|
||||
twenty-six built-in contest families plus user-defined ones, Cabrillo and ADIF
|
||||
export, ADIF import, the log, check, graphical bandmap, score and telnet
|
||||
windows, editing and deleting logged contacts, radio control, DX cluster spots,
|
||||
contacts shared between networked stations, CW keying and the voice keyer.
|
||||
|
||||
Checked against N1MM 1.0.11031: a log this program wrote opens in N1MM, which
|
||||
reads the contest, its categories and the contacts. See
|
||||
|
||||
@@ -0,0 +1,118 @@
|
||||
683 ms > open RTTY Engine 1 "Z:\\home\\erik\\cs2server\\claude\\nonemm_again\\src\\Nonemm.App\\bin\\Debug\\net10.0\\mmtty\\mmtty.exe" -r -Z
|
||||
910 ms < ready
|
||||
1346 ms < mark 1420
|
||||
1346 ms < space 1590
|
||||
1346 ms < switch 74765
|
||||
1346 ms < view 80
|
||||
1347 ms < connected Ver1.70
|
||||
1347 ms < mark 1420
|
||||
1347 ms < space 1590
|
||||
1347 ms < switch 74765
|
||||
1347 ms < view 80
|
||||
1347 ms < tx 0
|
||||
2158 ms < rx 65
|
||||
2359 ms < rx 75
|
||||
2758 ms < rx 86
|
||||
2758 ms < rx 81
|
||||
3558 ms < rx 86
|
||||
4158 ms < rx 71
|
||||
4158 ms < rx 86
|
||||
4358 ms < rx 81
|
||||
4558 ms < rx 73
|
||||
5958 ms < rx 40
|
||||
6159 ms < rx 59
|
||||
6759 ms < rx 47
|
||||
6958 ms < rx 47
|
||||
7157 ms < rx 36
|
||||
7357 ms < rx 49
|
||||
7758 ms < rx 59
|
||||
8158 ms < rx 71
|
||||
8758 ms < rx 88
|
||||
8958 ms < rx 86
|
||||
9358 ms < rx 81
|
||||
9358 ms < rx 65
|
||||
10158 ms < rx 88
|
||||
10358 ms < rx 71
|
||||
10558 ms < rx 70
|
||||
11358 ms < rx 74
|
||||
11358 ms < rx 81
|
||||
11758 ms < rx 86
|
||||
12358 ms < rx 67
|
||||
12758 ms < rx 81
|
||||
13558 ms < rx 88
|
||||
13758 ms < rx 67
|
||||
14158 ms < rx 34
|
||||
14558 ms < rx 81
|
||||
14758 ms < rx 85
|
||||
15758 ms < rx 55
|
||||
15958 ms < rx 104
|
||||
16758 ms < rx 88
|
||||
17358 ms < rx 80
|
||||
17758 ms < rx 81
|
||||
18158 ms < rx 85
|
||||
18358 ms < rx 85
|
||||
18558 ms < rx 76
|
||||
18958 ms < rx 66
|
||||
19758 ms < rx 87
|
||||
20091 ms > key 1
|
||||
20092 ms < tx 1
|
||||
20092 ms > ptt 1
|
||||
20093 ms > send C
|
||||
20094 ms > send Q
|
||||
20295 ms > send
|
||||
20353 ms < tx 0
|
||||
20354 ms > key 1
|
||||
20354 ms < tx 1
|
||||
20445 ms > send C
|
||||
20596 ms > send Q
|
||||
20796 ms > send
|
||||
20947 ms > send D
|
||||
20958 ms < rx 67
|
||||
21097 ms > send E
|
||||
21158 ms < rx 81
|
||||
21298 ms > send
|
||||
21357 ms < rx 32
|
||||
21447 ms > send O
|
||||
21558 ms < rx 68
|
||||
21598 ms > send M
|
||||
21747 ms > send 2
|
||||
21758 ms < rx 69
|
||||
21948 ms > send L
|
||||
21958 ms < rx 32
|
||||
22098 ms > send T
|
||||
22158 ms < rx 79
|
||||
22249 ms > send
|
||||
22358 ms < rx 77
|
||||
22449 ms > send O
|
||||
22558 ms < rx 50
|
||||
22599 ms > send M
|
||||
22750 ms > send 2
|
||||
22900 ms > send L
|
||||
22958 ms < rx 76
|
||||
22958 ms < rx 84
|
||||
23101 ms > send T
|
||||
23158 ms < rx 32
|
||||
23251 ms > send
|
||||
23358 ms < rx 79
|
||||
23401 ms > send C
|
||||
23558 ms < rx 77
|
||||
23602 ms > send Q
|
||||
23752 ms > send
|
||||
23757 ms < rx 50
|
||||
23901 ms > send K
|
||||
24102 ms > send \r
|
||||
24157 ms < rx 76
|
||||
24358 ms < rx 84
|
||||
24558 ms < rx 32
|
||||
24758 ms < rx 67
|
||||
24958 ms < rx 81
|
||||
24958 ms < rx 32
|
||||
25158 ms < rx 75
|
||||
25358 ms < rx 13
|
||||
29757 ms > ptt 0
|
||||
29757 ms > ptt 0
|
||||
29819 ms < tx 0
|
||||
30958 ms < rx 85
|
||||
31158 ms < rx 13
|
||||
31958 ms < rx 81
|
||||
32358 ms < rx 75
|
||||
@@ -0,0 +1,91 @@
|
||||
741 ms > open RTTY Engine 1 "Z:\\home\\erik\\cs2server\\claude\\nonemm_again\\src\\Nonemm.App\\bin\\Debug\\net10.0\\mmtty\\mmtty.exe" -r -Z
|
||||
997 ms < ready
|
||||
1440 ms < mark 1420
|
||||
1440 ms < space 1590
|
||||
1440 ms < switch 74765
|
||||
1440 ms < view 80
|
||||
1441 ms < connected Ver1.70
|
||||
1441 ms < mark 1420
|
||||
1441 ms < space 1590
|
||||
1441 ms < switch 74765
|
||||
1441 ms < view 80
|
||||
1441 ms < tx 0
|
||||
2252 ms < rx 66
|
||||
2450 ms < rx 75
|
||||
3050 ms < rx 83
|
||||
3450 ms < rx 75
|
||||
3850 ms < rx 85
|
||||
4050 ms < rx 75
|
||||
4249 ms < rx 67
|
||||
4449 ms < rx 86
|
||||
4559 ms > key 1
|
||||
4559 ms < tx 1
|
||||
4561 ms > send C
|
||||
4561 ms > send Q
|
||||
4762 ms > send
|
||||
4912 ms > send C
|
||||
5063 ms > send Q
|
||||
5249 ms < rx 67
|
||||
5264 ms > send
|
||||
5414 ms > send D
|
||||
5449 ms < rx 81
|
||||
5565 ms > send E
|
||||
5649 ms < rx 32
|
||||
5649 ms < rx 67
|
||||
5715 ms > send
|
||||
5849 ms < rx 81
|
||||
5915 ms > send O
|
||||
6049 ms < rx 32
|
||||
6065 ms > send M
|
||||
6216 ms > send 2
|
||||
6249 ms < rx 68
|
||||
6416 ms > send L
|
||||
6449 ms < rx 69
|
||||
6449 ms < rx 32
|
||||
6567 ms > send T
|
||||
6649 ms < rx 79
|
||||
6717 ms > send
|
||||
6849 ms < rx 77
|
||||
6918 ms > send O
|
||||
7049 ms < rx 50
|
||||
7068 ms > send M
|
||||
7219 ms > send 2
|
||||
7369 ms > send L
|
||||
7449 ms < rx 76
|
||||
7569 ms > send T
|
||||
7649 ms < rx 84
|
||||
7719 ms > send
|
||||
7849 ms < rx 32
|
||||
7869 ms > send C
|
||||
8049 ms < rx 79
|
||||
8070 ms > send Q
|
||||
8220 ms > send
|
||||
8249 ms < rx 77
|
||||
8370 ms > send K
|
||||
8450 ms < rx 50
|
||||
8521 ms > send \r
|
||||
8522 ms > ptt 1
|
||||
8849 ms < rx 76
|
||||
9049 ms < rx 84
|
||||
9249 ms < rx 32
|
||||
9449 ms < rx 67
|
||||
9449 ms < rx 81
|
||||
9649 ms < rx 32
|
||||
9849 ms < rx 75
|
||||
10023 ms > ptt 0
|
||||
10023 ms < rx 13
|
||||
10145 ms < tx 0
|
||||
10850 ms < rx 33
|
||||
11049 ms < rx 56
|
||||
12249 ms < rx 87
|
||||
12249 ms < rx 78
|
||||
12449 ms < rx 71
|
||||
12650 ms < rx 81
|
||||
13049 ms < rx 83
|
||||
13249 ms < rx 72
|
||||
13449 ms < rx 85
|
||||
13650 ms < rx 79
|
||||
14249 ms < rx 66
|
||||
14449 ms < rx 66
|
||||
14649 ms < rx 88
|
||||
14649 ms < rx 82
|
||||
@@ -0,0 +1,260 @@
|
||||
815 ms > open RTTY Engine 1 "Z:\\home\\erik\\cs2server\\claude\\nonemm_again\\src\\Nonemm.App\\bin\\Debug\\net10.0\\mmtty\\mmtty.exe" -r -Z
|
||||
1150 ms < ready
|
||||
1608 ms < mark 1420
|
||||
1608 ms < space 1590
|
||||
1608 ms < switch 74765
|
||||
1608 ms < view 80
|
||||
1608 ms < connected Ver1.70
|
||||
1608 ms < mark 1420
|
||||
1608 ms < space 1590
|
||||
1608 ms < switch 74765
|
||||
1608 ms < view 80
|
||||
1608 ms < tx 0
|
||||
3025 ms < rx 89
|
||||
4026 ms < rx 80
|
||||
4226 ms < rx 88
|
||||
4426 ms < rx 81
|
||||
4426 ms < rx 71
|
||||
4626 ms < rx 74
|
||||
4826 ms < rx 84
|
||||
5625 ms < rx 87
|
||||
5648 ms > key 1
|
||||
5649 ms < tx 1
|
||||
5650 ms < buffer 0
|
||||
5650 ms > post 4 67
|
||||
5650 ms > post 4 81
|
||||
5851 ms < buffer 1
|
||||
5851 ms > post 4 32
|
||||
6000 ms > post 4 67
|
||||
6026 ms < rx 67
|
||||
6051 ms < buffer 2
|
||||
6151 ms > post 4 81
|
||||
6226 ms < rx 81
|
||||
6352 ms > post 4 32
|
||||
6425 ms < rx 32
|
||||
6453 ms < buffer 1
|
||||
6503 ms > post 4 68
|
||||
6625 ms < rx 67
|
||||
6654 ms > post 4 69
|
||||
6825 ms < rx 81
|
||||
6856 ms > post 4 32
|
||||
7007 ms > post 4 79
|
||||
7025 ms < rx 32
|
||||
7057 ms < buffer 2
|
||||
7158 ms > post 4 77
|
||||
7226 ms < rx 68
|
||||
7308 ms > post 4 50
|
||||
7426 ms < rx 69
|
||||
7426 ms < rx 32
|
||||
7509 ms > post 4 76
|
||||
7626 ms < rx 79
|
||||
7660 ms > post 4 84
|
||||
7660 ms < buffer 3
|
||||
7810 ms > post 4 32
|
||||
7825 ms < rx 77
|
||||
7860 ms < buffer 4
|
||||
7961 ms > post 4 79
|
||||
8026 ms < rx 50
|
||||
8161 ms > post 4 77
|
||||
8312 ms > post 4 50
|
||||
8426 ms < rx 76
|
||||
8463 ms > post 4 76
|
||||
8463 ms < buffer 5
|
||||
8626 ms < rx 84
|
||||
8664 ms > post 4 84
|
||||
8664 ms < buffer 6
|
||||
8814 ms > post 4 32
|
||||
8825 ms < rx 32
|
||||
8826 ms < rx 79
|
||||
8965 ms > post 4 67
|
||||
9026 ms < rx 77
|
||||
9165 ms > post 4 81
|
||||
9316 ms > post 4 32
|
||||
9425 ms < rx 50
|
||||
9465 ms > post 4 75
|
||||
9465 ms < buffer 5
|
||||
9616 ms > post 4 13
|
||||
9617 ms > ptt 1
|
||||
9667 ms < buffer 6
|
||||
9825 ms < rx 76
|
||||
9867 ms < buffer 5
|
||||
10026 ms < rx 84
|
||||
10068 ms < buffer 4
|
||||
10225 ms < rx 32
|
||||
10225 ms < rx 67
|
||||
10268 ms < buffer 2
|
||||
10426 ms < rx 81
|
||||
10469 ms < buffer 1
|
||||
10625 ms < rx 32
|
||||
10670 ms < buffer 0
|
||||
10825 ms < rx 75
|
||||
11026 ms < rx 13
|
||||
11119 ms > ptt 0
|
||||
11549 ms < tx 0
|
||||
12026 ms < rx 75
|
||||
12026 ms < rx 65
|
||||
13026 ms < rx 66
|
||||
13626 ms < rx 86
|
||||
13826 ms < rx 81
|
||||
14228 ms < rx 86
|
||||
14228 ms < rx 87
|
||||
15225 ms < rx 89
|
||||
16026 ms < rx 86
|
||||
16426 ms < rx 89
|
||||
17026 ms < rx 76
|
||||
17443 ms > key 1
|
||||
17444 ms < tx 1
|
||||
17445 ms > post 4 67
|
||||
17445 ms > post 4 65
|
||||
17646 ms > post 4 76
|
||||
17646 ms < buffer 2
|
||||
17797 ms > post 4 76
|
||||
17847 ms < buffer 3
|
||||
17947 ms > post 4 63
|
||||
18026 ms < rx 67
|
||||
18048 ms < buffer 4
|
||||
18148 ms > post 4 32
|
||||
18226 ms < rx 65
|
||||
18298 ms > post 4 67
|
||||
18425 ms < rx 76
|
||||
18449 ms > post 4 65
|
||||
18626 ms < rx 76
|
||||
18649 ms > post 4 76
|
||||
18800 ms > post 4 76
|
||||
18850 ms < buffer 5
|
||||
18951 ms > post 4 63
|
||||
19026 ms < rx 63
|
||||
19026 ms < rx 32
|
||||
19051 ms < buffer 6
|
||||
19101 ms > post 4 32
|
||||
19251 ms < buffer 5
|
||||
19302 ms > post 4 68
|
||||
19425 ms < rx 67
|
||||
19452 ms > post 4 69
|
||||
19452 ms < buffer 6
|
||||
19603 ms > post 4 32
|
||||
19625 ms < rx 65
|
||||
19653 ms < buffer 7
|
||||
19804 ms > post 4 79
|
||||
19825 ms < rx 76
|
||||
19954 ms > post 4 77
|
||||
20026 ms < rx 76
|
||||
20105 ms > post 4 50
|
||||
20225 ms < rx 63
|
||||
20255 ms > post 4 76
|
||||
20425 ms < rx 32
|
||||
20457 ms > post 4 84
|
||||
20457 ms < buffer 8
|
||||
20607 ms > post 4 32
|
||||
20657 ms < buffer 9
|
||||
20757 ms > post 4 75
|
||||
20826 ms < rx 68
|
||||
20826 ms < rx 69
|
||||
20958 ms > post 4 13
|
||||
20958 ms > ptt 1
|
||||
21026 ms < rx 32
|
||||
21225 ms < rx 79
|
||||
21258 ms < buffer 8
|
||||
21426 ms < rx 77
|
||||
21459 ms < buffer 6
|
||||
21625 ms < rx 50
|
||||
21659 ms < buffer 5
|
||||
21861 ms < buffer 4
|
||||
22026 ms < rx 76
|
||||
22062 ms < buffer 3
|
||||
22225 ms < rx 84
|
||||
22263 ms < buffer 1
|
||||
22425 ms < rx 32
|
||||
22458 ms > ptt 0
|
||||
22462 ms < buffer 0
|
||||
22479 ms < rx 75
|
||||
22581 ms < tx 0
|
||||
23826 ms < rx 78
|
||||
24226 ms < rx 67
|
||||
24426 ms < rx 81
|
||||
25026 ms < rx 88
|
||||
25426 ms < rx 82
|
||||
25626 ms < rx 77
|
||||
25826 ms < rx 75
|
||||
26225 ms < rx 83
|
||||
26426 ms < rx 66
|
||||
26625 ms < rx 88
|
||||
26828 ms < rx 75
|
||||
27280 ms > key 1
|
||||
27280 ms > post 4 67
|
||||
27280 ms > post 4 81
|
||||
27281 ms < tx 1
|
||||
27432 ms < buffer 3
|
||||
27481 ms > post 4 32
|
||||
27632 ms > post 4 67
|
||||
27632 ms < buffer 2
|
||||
27782 ms > post 4 81
|
||||
27826 ms < rx 67
|
||||
27833 ms < buffer 3
|
||||
27984 ms > post 4 32
|
||||
28026 ms < rx 81
|
||||
28135 ms > post 4 68
|
||||
28226 ms < rx 32
|
||||
28235 ms < buffer 2
|
||||
28285 ms > post 4 69
|
||||
28426 ms < rx 67
|
||||
28436 ms > post 4 32
|
||||
28626 ms < rx 81
|
||||
28636 ms > post 4 79
|
||||
28787 ms > post 4 77
|
||||
28825 ms < rx 32
|
||||
28837 ms < buffer 3
|
||||
28937 ms > post 4 50
|
||||
29026 ms < rx 68
|
||||
29038 ms < buffer 4
|
||||
29138 ms > post 4 76
|
||||
29225 ms < rx 69
|
||||
29225 ms < rx 32
|
||||
29288 ms > post 4 84
|
||||
29427 ms < rx 79
|
||||
29439 ms > post 4 32
|
||||
29626 ms < rx 77
|
||||
29639 ms > post 4 79
|
||||
29790 ms > post 4 77
|
||||
29826 ms < rx 50
|
||||
29842 ms < buffer 5
|
||||
29941 ms > post 4 50
|
||||
30041 ms < buffer 6
|
||||
30090 ms > post 4 76
|
||||
30226 ms < rx 76
|
||||
30241 ms < buffer 7
|
||||
30291 ms > post 4 84
|
||||
30426 ms < rx 84
|
||||
30441 ms > post 4 32
|
||||
30592 ms > post 4 67
|
||||
30625 ms < rx 32
|
||||
30626 ms < rx 79
|
||||
30793 ms > post 4 81
|
||||
30827 ms < rx 77
|
||||
30943 ms > post 4 32
|
||||
31094 ms > post 4 75
|
||||
31226 ms < rx 50
|
||||
31244 ms > post 4 13
|
||||
31245 ms < buffer 6
|
||||
31245 ms > ptt 1
|
||||
31626 ms < rx 76
|
||||
31646 ms < buffer 5
|
||||
31826 ms < rx 84
|
||||
31826 ms < rx 32
|
||||
31847 ms < buffer 4
|
||||
32026 ms < rx 67
|
||||
32047 ms < buffer 2
|
||||
32227 ms < rx 81
|
||||
32248 ms < buffer 1
|
||||
32425 ms < rx 32
|
||||
32449 ms < buffer 0
|
||||
32625 ms < rx 75
|
||||
32745 ms > ptt 0
|
||||
32745 ms < rx 13
|
||||
32786 ms < tx 0
|
||||
33425 ms < rx 90
|
||||
33826 ms < rx 81
|
||||
34226 ms < rx 75
|
||||
34425 ms < rx 67
|
||||
34825 ms < rx 78
|
||||
35025 ms < rx 77
|
||||
@@ -0,0 +1,133 @@
|
||||
1093 ms > open RTTY Engine 1 "Z:\\home\\erik\\cs2server\\claude\\nonemm_again\\src\\Nonemm.App\\bin\\Debug\\net10.0\\mmtty\\mmtty.exe" -r -Z
|
||||
1636 ms < ready
|
||||
1993 ms < mark 1420
|
||||
1994 ms < space 1590
|
||||
1994 ms < switch 74765
|
||||
1994 ms < view 80
|
||||
1994 ms < connected Ver1.70
|
||||
1994 ms < mark 1420
|
||||
1994 ms < space 1590
|
||||
1994 ms < switch 74765
|
||||
1994 ms < view 80
|
||||
1994 ms < tx 0
|
||||
2859 ms < rx 78
|
||||
2859 ms < rx 81
|
||||
3659 ms < rx 75
|
||||
3659 ms < rx 87
|
||||
3859 ms < rx 69
|
||||
4459 ms < rx 87
|
||||
4658 ms < rx 81
|
||||
4859 ms < rx 89
|
||||
5059 ms < rx 82
|
||||
5859 ms < rx 76
|
||||
5859 ms < rx 32
|
||||
5954 ms > key 1
|
||||
5954 ms < tx 1
|
||||
5955 ms < buffer 0
|
||||
5955 ms > send Q CQ DE OM2LT OM2LT CQ K\r
|
||||
5955 ms > post 4 67
|
||||
6106 ms < buffer 31
|
||||
6157 ms > ptt 1
|
||||
6308 ms < buffer 29
|
||||
6508 ms < buffer 28
|
||||
6658 ms < rx 81
|
||||
6659 ms < buffer 27
|
||||
6859 ms < rx 32
|
||||
6859 ms < buffer 26
|
||||
7058 ms < rx 67
|
||||
7058 ms < rx 81
|
||||
7060 ms < buffer 25
|
||||
7259 ms < rx 32
|
||||
7260 ms < buffer 24
|
||||
7459 ms < rx 68
|
||||
7461 ms < buffer 22
|
||||
7659 ms < rx 69
|
||||
7661 ms < buffer 21
|
||||
7822 ms > key 0
|
||||
7822 ms < rx 32
|
||||
7822 ms < rx 79
|
||||
7943 ms < tx 0
|
||||
7962 ms < buffer 0
|
||||
8659 ms < rx 78
|
||||
8659 ms < rx 70
|
||||
9248 ms > key 1
|
||||
9248 ms > send CQ CQ DE OM2LT OM2LT CQ K\r
|
||||
9249 ms < tx 1
|
||||
9314 ms < buffer 31
|
||||
9349 ms > ptt 1
|
||||
9464 ms < buffer 29
|
||||
9658 ms < rx 67
|
||||
9665 ms < buffer 27
|
||||
9859 ms < rx 81
|
||||
9865 ms < buffer 26
|
||||
10058 ms < rx 32
|
||||
10058 ms < rx 67
|
||||
10066 ms < buffer 25
|
||||
10259 ms < rx 81
|
||||
10266 ms < buffer 24
|
||||
10459 ms < rx 32
|
||||
10466 ms < buffer 23
|
||||
10659 ms < rx 68
|
||||
10667 ms < buffer 22
|
||||
10859 ms < rx 69
|
||||
10867 ms < buffer 20
|
||||
11014 ms > key 0
|
||||
11014 ms < rx 32
|
||||
11075 ms < tx 0
|
||||
11118 ms < buffer 0
|
||||
11459 ms < rx 83
|
||||
11659 ms < rx 87
|
||||
11965 ms > key 1
|
||||
11966 ms < tx 1
|
||||
11966 ms > send W3ZGD DE OM2LT 599 15 599 15 K\r
|
||||
12071 ms < buffer 41
|
||||
12117 ms > ptt 1
|
||||
12271 ms < buffer 39
|
||||
12472 ms < buffer 38
|
||||
12659 ms < rx 87
|
||||
12672 ms < buffer 37
|
||||
12873 ms < buffer 36
|
||||
13059 ms < rx 51
|
||||
13073 ms < buffer 35
|
||||
13258 ms < rx 90
|
||||
13274 ms < buffer 33
|
||||
13458 ms < rx 71
|
||||
13476 ms < buffer 32
|
||||
13659 ms < rx 68
|
||||
13676 ms < buffer 31
|
||||
13782 ms > key 0
|
||||
13782 ms < rx 32
|
||||
13844 ms < tx 0
|
||||
13877 ms < buffer 0
|
||||
14059 ms < rx 86
|
||||
14259 ms < rx 76
|
||||
14659 ms < rx 32
|
||||
14859 ms < rx 50
|
||||
14859 ms < rx 52
|
||||
15059 ms < rx 46
|
||||
15459 ms < rx 104
|
||||
15620 ms > key 1
|
||||
15621 ms < tx 1
|
||||
15621 ms > send W3ZGD TU DE OM2LT QRZ\r
|
||||
15733 ms < buffer 27
|
||||
15772 ms > ptt 1
|
||||
15883 ms < buffer 26
|
||||
16084 ms < buffer 25
|
||||
16259 ms < rx 87
|
||||
16284 ms < buffer 24
|
||||
16485 ms < buffer 23
|
||||
16659 ms < rx 51
|
||||
16685 ms < buffer 21
|
||||
16859 ms < rx 90
|
||||
16885 ms < buffer 20
|
||||
17059 ms < rx 71
|
||||
17086 ms < buffer 19
|
||||
17259 ms < rx 68
|
||||
17286 ms < buffer 18
|
||||
17437 ms > key 0
|
||||
17437 ms < rx 32
|
||||
17518 ms < tx 0
|
||||
17537 ms < buffer 0
|
||||
18459 ms < rx 40
|
||||
18659 ms < rx 56
|
||||
18859 ms < rx 63
|
||||
+21
-3
@@ -1,9 +1,9 @@
|
||||
# MMTTY and 2Tone through Wine
|
||||
# MMTTY and 2Tone through the bridge
|
||||
|
||||
MMTTY is a Windows program with no socket, pipe or file interface. N1MM does not
|
||||
talk to it directly either: it hosts `XMMT.ocx`, a 32-bit ActiveX control that
|
||||
starts `MMTTY.EXE` and exchanges window messages with it. A Linux process cannot
|
||||
load that control, so Nonemm runs a small Windows program under Wine —
|
||||
load that control, so Nonemm runs a small Windows program (under Wine on Linux) —
|
||||
`bridge/nonemm-mmtty-bridge.exe` — which hosts the control and passes lines over
|
||||
its standard input and output.
|
||||
|
||||
@@ -98,7 +98,25 @@ Three things cost a day between them, so they are written down:
|
||||
message, closes the engine's windows, and kills the process if it is still
|
||||
there five seconds later.
|
||||
|
||||
## Setting it up
|
||||
## Setting it up on Windows
|
||||
|
||||
There is no Wine. `ProcessBridgeChannel` starts `nonemm-mmtty-bridge.exe`
|
||||
directly, and the engine path goes to the bridge as it is.
|
||||
|
||||
The control must be registered once. The Register button in Config > Digital
|
||||
does it with `WindowsControlSetup`, which runs the 32-bit `regsvr32` (the one in
|
||||
`SysWOW64` on 64-bit Windows) on `XMMT.ocx` in place. Windows shows the
|
||||
administrator prompt, because registering writes to `HKEY_CLASSES_ROOT`. The same
|
||||
by hand, from an administrator prompt:
|
||||
|
||||
```bat
|
||||
%WINDIR%\SysWOW64\regsvr32.exe bridge\XMMT.ocx
|
||||
```
|
||||
|
||||
Do not move `XMMT.ocx` after that, or register it again. Nothing in this path
|
||||
has been run on Windows.
|
||||
|
||||
## Setting it up under Wine
|
||||
|
||||
Config > Digital has a Register button. It does what the next paragraph
|
||||
describes, in the prefix named in the same dialog, and writes the result under
|
||||
|
||||
+39
-1
@@ -1,6 +1,6 @@
|
||||
# How CW gets on the air, and why
|
||||
|
||||
Written 2026-08-27.
|
||||
Written 2026-08-27. The voice keyer was added 2026-09-11.
|
||||
|
||||
Nonemm has two keying paths and neither of them times the Morse itself:
|
||||
|
||||
@@ -85,3 +85,41 @@ Alternating CQ needs the end of a message, and both paths report it:
|
||||
Timing the message from the length of its text was rejected. The guess runs
|
||||
short exactly when the operator has turned the speed up, and a short guess keys
|
||||
the second radio while the first is still sending.
|
||||
|
||||
## The voice keyer
|
||||
|
||||
A phone message is a recording rather than characters, so nothing has to be
|
||||
timed: the file is played, and the transmitter stays keyed until it has been.
|
||||
Two decisions are worth writing down.
|
||||
|
||||
**The sound card is a program, not a library.** `CommandSoundCard` runs
|
||||
`aplay` and `arecord`, and both commands are settings. The reason is the reason
|
||||
above: the audio path belongs to whatever the station runs — ALSA, PulseAudio,
|
||||
PipeWire, JACK — and a library picks one of them for the operator. A station
|
||||
that routes its audio some other way writes its own command with `{file}` in
|
||||
it, and a station on Windows, which has no player on the path, gets a
|
||||
PowerShell line that plays through .NET's own `SoundPlayer`.
|
||||
|
||||
The cost is a process per message. It is a few milliseconds at the front of a
|
||||
recording that runs for seconds, and no part of a voice message needs the
|
||||
timing that CW needs.
|
||||
|
||||
**A recorder is stopped with an interrupt, not a kill.** `arecord` closes the
|
||||
wav file and writes its header when it is interrupted; killed outright it
|
||||
leaves a file with a header that says nothing was recorded, which nothing can
|
||||
play. So the stop is `SIGINT`, and the kill is only what follows two seconds
|
||||
later for a command that ignores it. The recording is written beside the wanted
|
||||
file and moved over it at the end, so a recorder that will not start takes
|
||||
nothing away.
|
||||
|
||||
**PTT is cwdaemon's `<ESC>a`**, which keys the transmitter and leaves it keyed.
|
||||
That is the only way into the keying port from here, so a station with a
|
||||
WinKeyer, or with no CW keyer at all, runs the voice keyer on VOX. The
|
||||
`<ESC>b` request, which tells cwdaemon whether the SSB audio comes from the
|
||||
microphone or the sound card, is not sent: what it switches is the daemon's own
|
||||
wiring, and a station that needs it has already set it.
|
||||
|
||||
None of this has been run against a radio. This machine has no sound card, so
|
||||
what has been exercised is the program being run, the file being filled in, the
|
||||
exit code and the interrupt — with ordinary shell commands standing in for
|
||||
`aplay` and `arecord`.
|
||||
|
||||
@@ -135,3 +135,14 @@ a log has to score the same in both programs:
|
||||
- A maritime mobile counts for the country of the call it signs. CQ WW says it
|
||||
counts for the zone alone.
|
||||
- A callsign that places nowhere counts as a multiplier with an empty value.
|
||||
|
||||
## The Contest table
|
||||
|
||||
N1MM reads the `Contest` table when it opens a log. For the built-in contests
|
||||
the row we write is N1MM's own (`N1mmContestRows`, taken from `om5m.s3db`):
|
||||
display name, Cabrillo name, mode, dupe type, multiplier names, period, points
|
||||
per contact and Cabrillo version. A contest that is not in that table, such as
|
||||
a user-defined one, gets a row worked out from its rules.
|
||||
|
||||
The Cabrillo name in that row is not always the one our Cabrillo export uses.
|
||||
For WAE the table says `DARC-WAEDC-CW`, and the export writes `WAE-CW`.
|
||||
|
||||
@@ -0,0 +1,74 @@
|
||||
# Sound recorder
|
||||
|
||||
`nonemm-recorder` is a separate program (`src/Nonemm.Recorder.App`). It records
|
||||
channels of several audio devices into one Opus file. The code that does the
|
||||
work is in `src/Nonemm.Recorder`, and the window is a thin layer over it.
|
||||
|
||||
Run it with `./build.sh run --project src/Nonemm.Recorder.App`.
|
||||
|
||||
## The file
|
||||
|
||||
- Ogg Opus, one channel in the file for each row in the list, in list order.
|
||||
- Mapping family 255: each channel is its own mono stream, so a player does
|
||||
not mix them as speakers. A file with one row is plain mono.
|
||||
- 48 kHz, 60 ms frames, complexity 9. The bitrate is for each channel and
|
||||
defaults to 32 kbps, so a file of four rows is about 128 kbps.
|
||||
- A new file is named `recording-yyyyMMdd-HHmmss.opus` in the chosen folder.
|
||||
- Pause leaves no gap: the audio after Resume follows directly on the audio
|
||||
before Pause.
|
||||
|
||||
## Channels
|
||||
|
||||
- Each row picks one channel of one device: `Line In L`, `Line In R`, or just
|
||||
`Microphone` for a mono device. The list of choices is the same in every row.
|
||||
- Output devices are listed as `Speakers (output) L`. They record what that
|
||||
device plays (see "Output devices").
|
||||
- A device that is not there keeps its row, in red, and writes silence. The
|
||||
program lists the devices every 2 seconds. When the device returns, its
|
||||
channel is recorded from that moment, also during a recording.
|
||||
- Rows cannot be added, removed or changed during a recording, as they would
|
||||
change the channel count of the file.
|
||||
- The headphone button plays that channel, in mono, on the default playback
|
||||
device. If it monitors an output device that is also the default one, it
|
||||
feeds back.
|
||||
|
||||
## Configuration
|
||||
|
||||
One file, written when the window closes: `nonemm-recorder/config.json` in the
|
||||
user's application data folder (`%APPDATA%` on Windows, `~/.config` on Linux).
|
||||
It holds the rows, the bitrate and the folder. Rows of devices that were not
|
||||
connected stay in it.
|
||||
|
||||
## Output devices
|
||||
|
||||
| System | How an output is recorded | Tested |
|
||||
| --- | --- | --- |
|
||||
| Windows | WASAPI loopback of that playback device | no |
|
||||
| Linux | the PulseAudio or PipeWire "Monitor of ..." source | no |
|
||||
|
||||
Neither was tested on real hardware: the machine this was written on has no
|
||||
sound device. The tests in `tests/Nonemm.Recorder.Tests` use a fake sound
|
||||
system and check the file by decoding it again.
|
||||
|
||||
On Windows, SoundFlow only loopback-records the default output through its
|
||||
public API. `SoundFlowBackend.MarkLoopback` sets an internal setting by
|
||||
reflection to pick any output, so it is tied to SoundFlow 1.4.2.
|
||||
|
||||
## Sound system
|
||||
|
||||
On Linux the program asks for PulseAudio (PipeWire serves it) and falls back to
|
||||
ALSA only if that fails. The window shows which one is in use, and the reason
|
||||
in red when it is the fallback. ALSA lists sound cards and plugins, not the
|
||||
devices a PipeWire desktop shows, and has no "Monitor of ..." sources.
|
||||
|
||||
SoundFlow 1.4.2 numbers its backend enum one higher than the miniaudio library
|
||||
it ships, so asking for `PulseAudio` gives ALSA and `Wasapi` gives DirectSound.
|
||||
`SoundFlowBackend.Start` lowers the value by one and checks the result. If a
|
||||
later SoundFlow fixes the numbering, that check fails with a message.
|
||||
|
||||
## Timing
|
||||
|
||||
The devices do not share a clock, so the file is cut by the system clock, not by
|
||||
how much each device delivered. The encoder runs 120 ms behind the clock. A
|
||||
device that delivers too little is padded with zeros. One that delivers too
|
||||
much loses its oldest samples once it is 240 ms ahead.
|
||||
@@ -0,0 +1,80 @@
|
||||
Scoring and N1MM compatibility review, 2026-09-06. Code reviewed: `6e24e00`.
|
||||
|
||||
**Nonemm does not yet match N1MM Logger+ well enough to claim general contest compatibility.** Many ordinary QSOs agree, including large WPX and WAE logs, but there are confirmed failures in entry completion, excluded QSOs, exports, and several contest rules. This review changed documentation only.
|
||||
|
||||
**Status on 2026-09-10.** Findings 1, 2, 3, 4 and 7 are fixed, each with tests, and finding 14 turned out to be what N1MM does. Findings 5, 6, 8, 9, 10, 11, 12 and 13 are open. The fix notes sit under the findings themselves; the numbering and the original text are kept so a finding can be looked up by its number.
|
||||
|
||||
The review covered the shared scoring engine, the 26 built-in contest families, contest-name resolution, selected UDC implementation paths, entry completion, score display, storage updates and Cabrillo generation. Specific behavior was compared with the local decompiled N1MM reference and published sponsor rules. N1MM was not executed. This is not a certification of every feature, contest category, UDC option or historical rule version.
|
||||
|
||||
**Verification.** `./build.sh test Nonemm.slnx --no-restore` passed all 1,058 tests in 11 projects, including 245 contest tests. There were build warnings, including Avalonia runtime-loader warnings. An independent console program in `/tmp/nonemm-scoring-audit` exercised the findings below against the actual project assemblies. It used synthetic QSOs and the existing test country file; it did not invoke N1MM. Results are in `results.txt`. These reproductions are separate from the passing test suite.
|
||||
|
||||
The supplied `om5m.s3db` was read through a read-only SQLite connection and backed up to a temporary file before opening it with Nonemm's storage code. Its 56,284 rows cover 66 nonempty instances, including deleted contacts. Using OM5M in Slovakia, CQ zone 15 and ITU zone 28, the original stored country/continent fields, and each instance's entry settings:
|
||||
|
||||
| Historical comparison | Result |
|
||||
|---|---:|
|
||||
| Instances with built-in rules available | 62 |
|
||||
| Rows in those instances | 55,415 |
|
||||
| Instances with identical points and all three multiplier flags on every row | 45 |
|
||||
| Rows with different points | 316 |
|
||||
| Rows with different multiplier flags | 141 |
|
||||
|
||||
The complete comparison is in [scoring-audit-history.csv](scoring-audit-history.csv). Stored points and multiplier flags were read directly from SQLite, because `QsoColumns.Read` deliberately discards those cached values. The comparison is against stored caches, not a fresh N1MM rescore. No external country or call-history file was supplied, and original per-instance station settings and cache freshness were not independently established. Therefore differences in this table are investigation targets, not automatically bugs.
|
||||
|
||||
Notable examples: all six WAE RTTY instances matched every compared field. Field Day instance 20 changed from 41 to 181 QSO points, with all 41 rows different. IARU instances 16 and 71 changed from 663 to 563 and from 636 to 594 points; those IARU differences need further investigation. The built-in registry could not resolve `OKOMDXS`, `OKOMDXS_DX`, or `SA10_DX`; those require their UDC files. `DELETEDQS` was excluded.
|
||||
|
||||
**Confirmed findings, ordered by impact.** P1 means an ordinary operating or submission path is broken. P2 means incorrect scoring, compatibility or display in a more specific case.
|
||||
|
||||
1. **P1 — Valid exchanges cannot be logged in seven contest definitions.** [EntryFields.cs](../src/Nonemm.Session/EntryFields.cs), line 90, requires every field marked required. `OperatingPosition.MoveFocus` skips fields according to `Contest.SkipsField`, but `LogContact` and the ESM window still use that unconditional completeness check. In OK/OM DX, a Japanese station sends a serial; the county field is skipped but its emptiness prevents logging. The same problem affects CQ 160, ARRL 10M, REF, Ukrainian DX, YO DX HF and Mexico RTTY. Filling every applicable field produced `IsComplete == false` in all seven reproductions. Completion must use the same applicability rules as cursor movement. Do not fix this by requiring fabricated values in skipped boxes.
|
||||
|
||||
**Fixed 2026-09-10.** `bae40bb` gave each of these contests the boxes N1MM shows, and none of them now marks a box required that the walk steps over: fifteen reproductions across all seven contests and both station types log cleanly. `EntryFields.IsComplete` takes the applicability rule as well, so the cursor and the completeness check read the same answer and this cannot come back; see `SkippedFieldTests`.
|
||||
|
||||
2. **P1 — Excluded contacts still score.** [ContestLog.cs](../src/Nonemm.Contests/ContestLog.cs), line 48, does not inspect `Qso.IsClaimed`. A CQ WW JA contact with `IsClaimed=false` still received 3 points and two multipliers, producing a score of 6. The edit dialog exposes this flag, statistics filter it, and Cabrillo omits the contact, so the user sees inconsistent results. The local N1MM `Contest.ComputePoints`, line 437, explicitly returns zero for an unclaimed QSO. Apply the exclusion consistently to points and multiplier eligibility, and verify N1MM's duplicate treatment separately.
|
||||
|
||||
**Fixed.** `ContestLog.Judge` returns nothing for an unclaimed contact, and `Index` leaves it out of the dupe and multiplier searches; see `ExcludedContactTests`.
|
||||
|
||||
3. **P1 — Three Cabrillo exporters replace actual serials with `001`.** [Arrl10Metre.cs](../src/Nonemm.Contests/Rules/Arrl10Metre.cs), line 68; [UkrainianDx.cs](../src/Nonemm.Contests/Rules/UkrainianDx.cs), line 80; [YoDxHf.cs](../src/Nonemm.Contests/Rules/YoDxHf.cs), line 75. Each calls `SentExchangeFor(me)` when formatting a contact. For a DX entrant that method returns the initial serial, not `qso.SentNumber`. All three exported `001` for a QSO whose sent serial was 42. The actual serial must be used where the entrant sends serial numbers. ARRL explicitly requires sequential DX serials in its [10M rules](https://contests.arrl.org/ContestRules/10M-Rules.pdf).
|
||||
|
||||
**Fixed.** All three write `qso.SentNumber` where the entrant sends serial numbers.
|
||||
|
||||
4. **P1 — All Asian implements the wrong rules for Asian entrants.** [AllAsian.cs](../src/Nonemm.Contests/Rules/AllAsian.cs), lines 37 and 46, multiplies every Asian entrant's band points by three and always uses WPX prefixes. Reproductions: JA-to-JA on 20M scored 3 instead of 0; JA-to-UA9 scored 3 instead of 1; JA-to-K1 produced prefix `K1` instead of country `K`. Asian entrants count DXCC entities, same-entity QSOs do not score, and the threefold factor applies to non-Asian contacts. Both the local N1MM `CAA` implementation and the [2026 JARL rules](https://www.jarl.org/English/4_Library/A-4-3_Contests/aadx_eng.html) distinguish these cases. The existing tests only cover a non-Asian entrant.
|
||||
|
||||
**Fixed 2026-09-10.** `AllAsian` now asks which side the entrant is on. An Asian entrant cannot work its own country, is paid the band table once for Asia and three times for everywhere else, and counts DXCC entities; everybody else works Asia only and counts WPX prefixes. Maritime mobiles follow the published rule, which N1MM gets half right: a station at sea makes a valid contact with Asian stations alone, pays the Asian rate wherever it is, and never brings a multiplier. `AllAsianTests` covers both entrant sides, all four point values and every band. `Contest.MultiplierNames` became `MultiplierNamesFor(StationInfo me)`, like `ExchangeFieldsFor`, so the score window and the stored `Contest.Multiplier1Name` row both say "Countries" for an Asian entrant and "Prefixes" for everybody else.
|
||||
|
||||
5. **P1 — BARTG HF and Sprint are merged into one incompatible definition.** [BartgSprint.cs](../src/Nonemm.Contests/Rules/BartgSprint.cs) uses report, serial and time, and countries/areas per band, but advertises `BARTGRTTYS` and `BARTG-SPRINT`. [N1mmContestNames.cs](../src/Nonemm.Contests/N1mmContestNames.cs) also maps `BARTGSRTTY` to this class. N1MM has separate `CBARTGSpring` and `CBARTGSprint` classes. The January Sprint exchanges a serial only and counts countries/areas once across bands, as specified in the [BARTG Sprint rules](https://bartg.org.uk/wp-content/uploads/2025/05/bartg-sprint-rules-2025-v3.pdf). Split the definitions and preserve each one's identity, exchange, multiplier scope and export format. Agreement on the supplied March HF log does not validate Sprint support.
|
||||
|
||||
6. **P2 — ARRL 10M uses the wrong state multiplier list.** [Arrl10Metre.cs](../src/Nonemm.Contests/Rules/Arrl10Metre.cs), line 69, uses the ARRL DX list. A Mexican `JAL` exchange became country multiplier `XE`; another Mexican state would therefore not add its own multiplier. The code also lacks the contest's maritime ITU-region multiplier treatment, and its send-state decision omits Alaska and Hawaii. Use the actual 10M rules and [ARRL's 32 Mexican multipliers](https://contests.arrl.org/contestmultipliers.php?a=xe), rather than sharing the ARRL DX eligibility list.
|
||||
|
||||
7. **P2 — Oceania undercounts 15M and 10M.** [OceaniaDx.cs](../src/Nonemm.Contests/Rules/OceaniaDx.cs), `PointsOn`, returns 1 for both bands. The local N1MM `COceania.ComputePoints` returns 2 and 3 respectively, also documented by the [WIA contest scoring table](https://www.wia.org.au/members/contests/oceania/). Both incorrect values were reproduced. The four supplied Oceania contacts do not exercise these bands, so their matching points do not cover this defect.
|
||||
|
||||
**Fixed 2026-09-10.** The whole table is written out as N1MM writes it — 20, 10, 5, 1, 2, 3 — and it ends where N1MM's ends, so a band that is not in the contest scores nothing rather than one point.
|
||||
|
||||
8. **P2 — New SARTG and BARTG contacts miss call-area multipliers.** [SartgRtty.cs](../src/Nonemm.Contests/Rules/SartgRtty.cs), line 45, and [BartgSprint.cs](../src/Nonemm.Contests/Rules/BartgSprint.cs), line 59, obtain call areas from `Qso.Section`. Neither entry definition includes that field, and `OperatingPosition.BuildQso` does not derive it from the call. A new SARTG `K1ABC` QSO returned only country `K`. N1MM's `CSARTGRTTY.MultSqlString2` fills an empty section from its call-area lookup for K, VE, JA and VK. Imported rows with cached sections can pass comparison while newly logged contacts fail. Add call-area derivation and test both fresh and imported contacts.
|
||||
|
||||
9. **P2 — IOTA cannot score an island entrant correctly.** [Iota.cs](../src/Nonemm.Contests/Rules/Iota.cs), line 42, depends only on the received reference. It gives 2 for a world station and 15 for any island. An island entrant should receive 5 for a world station or its own island group, and 15 for another group. The station's own reference needs to participate in scoring. This limitation is acknowledged in a comment, but that comment misses the island-to-world case. See the [2026 RSGB rules](https://www.rsgbcc.org/hf/rules/2026/riota.shtml).
|
||||
|
||||
10. **P2 — IARU zones can be counted twice through formatting.** [IaruHf.cs](../src/Nonemm.Contests/Rules/IaruHf.cs), line 59, uses the exchange text as the multiplier value. Working zone `8`, then `08`, awarded two zone multipliers in the reproduction. N1MM's `CIaru.MultSqlString` formats numeric zones consistently. Parse and normalize zones before producing multiplier keys; validate zone versus HQ exchanges separately. This finding does not explain all historical IARU point differences above.
|
||||
|
||||
11. **P2 — CQ 160 maritime mobiles receive incorrect points and countries.** [CqOneSixty.cs](../src/Nonemm.Contests/Rules/CqOneSixty.cs), line 62, has no maritime exception. Through the shared country fallback, JA1XYZ/MM from Germany scored 10 and could claim Japan. The [CQ 160 rules](https://cq160.com/rules/index.htm) specify 5 points and no multiplier for a maritime mobile. Similar country fallback behavior exists in CQ WW; review it against each contest's rules rather than changing the common fallback indiscriminately. Some existing tests deliberately assert N1MM-like fallback behavior; the project objective explicitly says to follow published rules where N1MM is wrong.
|
||||
|
||||
12. **P2 — Field Day is an unconditional approximation of one rules variant.** [FieldDayRegionOne.cs](../src/Nonemm.Contests/Rules/FieldDayRegionOne.cs), line 40, always uses portable=5, EU/AF fixed=2, other fixed=3. N1MM's `CFdReg1.ComputePoints` branches on the contest variant and the entrant's country; its generic fallback is 1. For the supplied Slovak FDREG1 instance, all 41 stored one-point QSOs were changed, raising the points to 181. Continent alone also cannot determine IARU Region 1. Identify the intended national/contest variant and its published rules before replacing these tables; there is no single safe universal table here.
|
||||
|
||||
13. **P2 — Rescoring after edits does not persist all changed cached scores.** [ContestSession.cs](../src/Nonemm.Session/ContestSession.cs), `Delete` and `DeleteFromNetwork`, rebuilds the in-memory log after deletion or replacement but does not update every affected stored row. Deleting the first of two Japanese CQ WW contacts made the second contact a multiplier in memory while its stored flag remained false. Incoming network inserts have the same cache consistency concern. Explicit `Rescore` repairs these columns. N1MM itself documents manual rescoring after some edits, so this is principally a limitation of automatic interoperability: reopening the file in N1MM without a rescore can show stale totals. See [N1MM's log-window instructions](https://n1mm.hamdocs.com/manual-windows/log-window/).
|
||||
|
||||
14. **P2 — The score window mixes unweighted and weighted multiplier counts.** [ScoreWindow.axaml.cs](../src/Nonemm.App/Windows/ScoreWindow.axaml.cs) sums Boolean flags for each band but uses `Tally.TotalMultipliers` for the total. A single WAE multiplier on 80M appears as 1 in the band row and contributes 4 to the total. QTC rows are also counted in the QSO column even though `Contest.IsContact` identifies them as traffic. Display raw multipliers, weights and QTC counts consistently. This does not by itself change WAE's correctly weighted total score.
|
||||
|
||||
**Not a fault; this is what N1MM does.** `ScoreTally.AddMultiplier` adds the weight of a WAE multiplier, four on 80M and so on, and the band row and the total are both a `ScoreTally`, so both have counted it that way since `d4d0375`. N1MM counts QTC rows as Qs too — `ValidQs` counts every row that reaches the score — and keeps them readable by splitting each WAE band into a row per kind under `Q/QTC`, which the score window here does as well. Taking the QTC rows out of the QSO column would leave N1MM's numbers behind.
|
||||
|
||||
**Coverage and remaining limits.** The 26 built-in families are CQ WW, CQ WPX, ARRL DX, IARU, Sweepstakes, WAE, ARRL RTTY Roundup, NAQP, OK/OM DX CW, YOTA, IOTA, EU DX, CQ 160, Mexico RTTY, REF, BARTG, ARRL 10M, Russian DX RTTY, RDAC, YO DX HF, Oceania, Region 1 Field Day, SARTG, All Asian and general logging. CW/SSB/RTTY variants share classes where the registry supplies a mode. This is a subset of [N1MM's supported contests](https://n1mm.hamdocs.com/manual-supported/contests-list/).
|
||||
|
||||
The shared engine correctly centralizes incremental dupe/multiplier checks and performs chronological rebuilds for edits and network inserts. However, test success and matching existing rows do not establish correctness for entrant countries, new-entry field generation, excluded contacts, or bands absent from those logs.
|
||||
|
||||
The following require further work before claiming full compatibility:
|
||||
|
||||
- UDC support is explicitly a subset. Unrecognized settings are silently ignored. A successfully loaded file is not proof that all its scoring options work. Validate against a collection of actual UDC files and report unsupported scoring directives.
|
||||
- No built-in rule overrides `BandChangesFor`; all use the category fallback. The interface comments describe contest-specific overrides that are absent. Multi-station band-change rules therefore need contest-by-contest verification.
|
||||
- There is no shared contest-band eligibility model. `ShowsWarcBands` controls presentation, not scoring. Several rules award points outside their contest bands; WAE has an explicit band check. Separate band validity from N1MM's permissive frequency-to-band mapping.
|
||||
- The core score types use `int`, including products. Very large scores or UDC bonuses can overflow. Establish supported bounds and use a wider score type if needed.
|
||||
- The historical YOTA, EU DX, CQ WW and IARU differences need individual row analysis with the original station setup and country/history files. Do not change rules merely to force agreement with potentially stale caches.
|
||||
- Rig, keying, digital, cluster and network transport behavior was not certified by this scoring review. Existing limitations are documented in [unfinished.md](unfinished.md).
|
||||
|
||||
Of what is left, finding 5 comes first: BARTG HF and Sprint are two contests under one name, so a Sprint log is scored by the wrong rules and a log started here is written with the other contest's name. Then findings 8, 10 and 11, which are wrong scores in ordinary contacts, then 6, 9 and 12, which need the published multiplier lists and rule variants read out first, then 13. Add targeted regression tests from these reproductions, including fresh entry through `OperatingPosition`, followed by database and Cabrillo checks. For each contest, cover both entrant sides and every scoring band before describing it as compatible.
|
||||
@@ -0,0 +1,63 @@
|
||||
contest,instance,rows,stored_points,recomputed_points,rows_with_point_differences,rows_with_multiplier_flag_differences
|
||||
CQWWSSB,1,1205,1818,2145,181,50
|
||||
UKRAINDX,2,52,312,312,0,0
|
||||
UKRAINDX,3,40,66,66,0,0
|
||||
CQWWSSB,7,1,1,1,0,1
|
||||
CQWWSSB,8,3026,4279,4281,1,0
|
||||
WAERTTY,9,2890,2887,2887,0,0
|
||||
CQWPXRTTY,10,1886,7121,7121,0,0
|
||||
ARRLDXCW,11,429,1287,1287,0,0
|
||||
CQWPXSSB,12,2534,5968,5968,0,0
|
||||
YOTA,15,255,623,635,1,47
|
||||
IARU,16,248,663,563,50,2
|
||||
IOTA,17,500,3739,3739,0,0
|
||||
RDAC,18,29,280,280,0,1
|
||||
SARTGRTTY,19,111,1480,1480,0,0
|
||||
FDREG1,20,41,41,181,41,22
|
||||
ALLASIASSB,21,6,6,6,0,0
|
||||
RUSDXRTTY,22,36,315,315,0,0
|
||||
WAESSB,23,514,514,514,0,0
|
||||
CQWWRTTY,25,1992,4966,4966,0,0
|
||||
CQWWSSB,26,2692,4922,4922,2,0
|
||||
WAERTTY,27,2855,2838,2838,0,0
|
||||
XERTTY,28,139,417,417,0,0
|
||||
EU_DXC,29,88,811,814,3,4
|
||||
CQWPXRTTY,30,1236,4173,4173,0,0
|
||||
ARRLDXCW,31,158,474,474,0,0
|
||||
ARRLDXSSB,33,49,147,147,0,0
|
||||
BARTGSRTTY,34,74,74,74,0,0
|
||||
CQWPXSSB,35,300,695,695,0,0
|
||||
YOTA,36,324,787,787,0,1
|
||||
YOTA,39,94,186,196,1,0
|
||||
YOHFDX,40,4,12,12,0,0
|
||||
CQWWRTTY,41,1983,4803,4803,0,0
|
||||
CQWWSSB,42,3021,5320,5320,4,0
|
||||
WAERTTY,43,1848,1844,1844,0,0
|
||||
CQWPXRTTY,44,901,3092,3092,0,0
|
||||
REFSSB,45,55,55,55,0,0
|
||||
ARRLDXSSB,46,657,1965,1965,0,0
|
||||
CQWPXSSB,50,748,1295,1295,0,0
|
||||
CQWWSSB,52,2368,3962,3962,0,0
|
||||
WAERTTY,53,710,709,709,0,0
|
||||
CQ160SSB,54,169,842,842,0,0
|
||||
ARRLDXSSB,55,152,456,456,0,0
|
||||
CQWPXSSB,56,315,684,684,0,0
|
||||
WAESSB,57,389,388,388,0,1
|
||||
CQWWRTTY,58,810,1980,1980,0,0
|
||||
OCEANIASSB,62,4,4,4,0,0
|
||||
CQWWSSB,63,3775,7568,7568,0,0
|
||||
WAERTTY,64,3215,3201,3201,0,0
|
||||
YOTA,65,420,1958,1958,0,0
|
||||
CQWPXRTTY,66,176,564,570,5,0
|
||||
REFSSB,67,76,80,80,0,0
|
||||
ARRLDXSSB,68,1024,3069,3069,0,0
|
||||
CQWPXSSB,70,1931,4397,4397,0,0
|
||||
IARU,71,196,636,594,21,0
|
||||
YOTA,72,863,2513,2525,1,0
|
||||
CQWWRTTY,73,873,2180,2180,0,0
|
||||
CQWWSSB,75,3016,5362,5362,0,0
|
||||
WAERTTY,76,1373,1370,1370,0,0
|
||||
ARRL10M,77,61,222,222,0,0
|
||||
XERTTY,78,28,84,84,0,0
|
||||
EU_DXC,79,264,2275,2274,5,12
|
||||
YOTA,83,186,536,536,0,0
|
||||
|
+336
-43
@@ -1,7 +1,7 @@
|
||||
# What is not finished, and what has not been tested
|
||||
|
||||
Two separate lists. A feature can be finished and untested, or half-built and
|
||||
exercised every day. Written 2026-08-27, updated 2026-08-31.
|
||||
exercised every day. Written 2026-08-27, updated 2026-09-11.
|
||||
|
||||
## Never run against the real thing
|
||||
|
||||
@@ -20,11 +20,32 @@ is still sitting there undiscovered.
|
||||
| `CwDaemonSender` | the UDP messages, and a fake daemon that answers the `<ESC>h` reply request | no `cwdaemon`, no radio keyed. |
|
||||
| `MmttyEngine` and the Wine bridge | MMTTY 1.70 under Wine 10 on a machine with a sound card: started, keyed, a message transmitted and decoded back off the air, and stopped | no radio. No FSK through EXTFSK, no PTT on a serial port, and 2Tone has never been run. Keying was wrong until 2026-09-01: `SetMmttyPTT` stops a transmission and does not start one, which is why nothing ever went out before then. `docs/digital-bridge.md` |
|
||||
| `WinkeyerSender` | the status-byte reader, on its own | no test of the serial side, and no WinKeyer. The host-mode open sequence is from the WinKeyer datasheet; the status bits are from N1MM's `Winkey.cs`. |
|
||||
| `CommandSoundCard` and the voice keyer | shell commands standing in for `aplay` and `arecord`: the program being run, the file filled in, the exit code, the interrupt that ends a recording | no sound card on this machine, so nothing has been played or recorded, and nothing has gone on the air. cwdaemon's `<ESC>a` PTT is from its published protocol and has never keyed a radio. |
|
||||
|
||||
The Cabrillo output has not been put in front of a contest sponsor's robot.
|
||||
|
||||
## Half-built
|
||||
|
||||
**The info window: what N1MM has and this does not.** The window follows
|
||||
`InfoWindow.cs` from the decompiled source: the caption, the call-frame spot,
|
||||
the country, bearing and sun lines, the WWV line, the message area, both graphs
|
||||
with goals, the QSO timer in all seven modes, the band timer, the band-change
|
||||
count and the Run/Mult box. Goals use N1MM's `dhh goal` file format and its
|
||||
Import Goals rules, including the statistics and CSV files. Left out:
|
||||
|
||||
- the multi-op category mismatch message and the CPU-load advisory for heavy
|
||||
spot traffic;
|
||||
- goals kept per contest in the Admin database, and the goal file that a
|
||||
contest's Associated Files tab loads when the contest starts. Goals are one
|
||||
list in `settings.json` that stays until it is replaced;
|
||||
- the highlight on a spot from a preferred spotter;
|
||||
- N1MM's time-since-last-QSO options 4 to 6, which its code limits by radio
|
||||
number in a way that does not match their menu labels. This program follows
|
||||
the labels;
|
||||
- the hourly graph's slots end on the minute they start, where N1MM's end a
|
||||
minute early (:19, :39, :59);
|
||||
- a real check of the RBN link. It is N1MM's URL, and has not been opened.
|
||||
|
||||
**The digital window: what N1MM has and this does not.** The window is here —
|
||||
receive pane in both of N1MM's scroll modes, the Letters/Figs and MouseOver
|
||||
readouts, the pause bar, coloured callsigns with N1MM's validity routines, grab
|
||||
@@ -34,10 +55,9 @@ through the engine on a digital mode. Left out: the waterfall, the spectrum and
|
||||
the XY scope, which the engine reports and nothing draws; more than one receive
|
||||
pane, which is MMVARI's multi-channel decoding rather than MMTTY's; N1MM's
|
||||
AutoTRXUpdate, which offsets the frequency the entry window and the log record
|
||||
rather than only the one in the title bar; and N1MM's Send All, which keys a
|
||||
whole QTC series at once. The other interfaces N1MM offers — fldigi, MMVARI, the
|
||||
hardware TNCs — are not here either, though `DigitalEngine` is the place to add
|
||||
them.
|
||||
rather than only the one in the title bar. The other interfaces N1MM offers —
|
||||
fldigi, MMVARI, the hardware TNCs — are not here either, though `DigitalEngine`
|
||||
is the place to add them.
|
||||
|
||||
The receive pane has been driven with a stand-in bridge that prints prepared
|
||||
text, which is how the printing, the colouring, the Letters/Figs box and the
|
||||
@@ -99,10 +119,11 @@ the third, the macro buttons (`:21553`). The sleep is not the mechanism — a fu
|
||||
buffer is — and as a wait it is both too long on a long message and wrong on a
|
||||
short one: `TU` is 330 ms of air at 45.45 baud, so 400 ms of sleeping puts the
|
||||
stop after the buffer has emptied, which is where it does nothing. This program
|
||||
asks instead. `TypeAhead.WhenHoldingAsync` sends the stop as soon as the count
|
||||
says the engine holds something, and gives up after N1MM's 400 ms.
|
||||
asks instead. `DigitalEngineSender.WaitUntilHoldingAsync` sends the stop as soon
|
||||
as the count says the engine holds something, and gives up after N1MM's 400 ms,
|
||||
which is `StopDelay`.
|
||||
|
||||
So `{RX}` stops feeding: `TypeAhead.TakePending` hands over everything that is
|
||||
So `{RX}` stops feeding: `TypeAhead.FlushAsync` hands over everything that is
|
||||
left in one piece, and the stop goes out 400 ms behind it. Nothing after that
|
||||
can be rewritten, which is what `{RX}` means. The feeder still paces the middle
|
||||
of a message, which is what makes type-ahead work; only the ending is N1MM's.
|
||||
@@ -146,9 +167,9 @@ And what the engine holds is counted across feeders rather than reset when one
|
||||
starts: a feeder that started after a flush forgot a whole message the engine
|
||||
was still holding, called the transmission over and put the key down in the
|
||||
middle of it.
|
||||
`TypeAhead.WhenEmptyAsync` waits for `Aired` first, which is two things at
|
||||
once: the engine's own count at 0, and the clock saying the characters the
|
||||
engine held have had time to go out. `StopPatience` caps the wait for an engine
|
||||
`DigitalEngineSender.WaitUntilAiredAsync` waits for `Aired` first, which is two
|
||||
things at once: the engine's own count at 0, and the clock saying the characters
|
||||
the engine held have had time to go out. `StopPatience` caps the wait for an engine
|
||||
that never reports itself empty.
|
||||
|
||||
One character time is held after that and no more, because the count reaching 0
|
||||
@@ -364,10 +385,11 @@ DATA__07%SHACK-PC%QSO%2026-09-03 12:34:56%DL1ABC%…~__DATA
|
||||
which is the sending station's number, its computer name, the message type and
|
||||
the fields of that type. `%` and `~` cannot appear in a field, so N1MM writes
|
||||
`!` in their place. What is read and sent: contacts, edits, deletes, resyncs,
|
||||
`IAM`, the echo pair, chat, the pass frequency, transmit on and off, and where a
|
||||
station is. The rest of N1MM's forty-odd types — the score and sked windows, the
|
||||
log check, the spot lists, the serial-number pool — are passed over, which
|
||||
N1MM's own reader also does for a type it does not know.
|
||||
`IAM`, the echo pair, chat, the pass frequency, transmit on and off, where a
|
||||
station is tuned, the time of a station's last contact, the two serial number
|
||||
messages, and the four messages a resync is made of. The rest of N1MM's
|
||||
forty-odd types — the score and sked windows, the log check, the spot lists —
|
||||
are passed over, which N1MM's own reader also does for a type it does not know.
|
||||
|
||||
**The version has to match.** N1MM compares the version in the beacon with its
|
||||
own and, when they differ, puts up "Software versions must match. Update N1MM+."
|
||||
@@ -380,7 +402,95 @@ nothing arrives.
|
||||
|
||||
Where a station is goes out once a second when it has changed, rather than from
|
||||
each of the dozen places it can change from. In a multi-single entry that is
|
||||
what the other operators watch.
|
||||
what the other operators watch. The frequency goes on its own in N1MM's `FREQ`,
|
||||
in hundredths of a kilohertz; the mode, run and the rest ride in the `STATUS`
|
||||
that follows it.
|
||||
|
||||
**The status message.** `STATUS` goes out every five seconds whether anything
|
||||
has changed or not, and it is what fills the other operators' windows: the pass
|
||||
frequency, the frequency, run or search and pounce, the operator, the rates over
|
||||
the last ten and the last hundred contacts, the mode, the categories and the
|
||||
version. `Rates.PerHour` reads the two rates out of the log the way N1MM does —
|
||||
counting back over the last N contacts, stopping at a gap longer than the
|
||||
contest's minimum off time, and treating a span under a minute as a minute so a
|
||||
burst of three does not read as thousands an hour. The five transmit-interlock
|
||||
flags in the message are sent as false: this program does not block a
|
||||
transmitter.
|
||||
|
||||
**The network status window** has all seven of N1MM's tabs — Stations,
|
||||
Resynchronize, Rescore, Options, Call Stack Targets, Actions and Messages — and
|
||||
its columns — Computer, IP Address, Pass, Run, 10, 100, Freq, Op, Msg, Send,
|
||||
Receive, Band, R/M, Mode. Right-click a row to pass the contact being worked to
|
||||
that station, to talk, or to close and open its connection; a connection closed
|
||||
by hand stays closed until it is opened again, because the next beacon would
|
||||
otherwise open it within ten seconds. The Resynchronize and Rescore tabs work
|
||||
on a period — the contest, since a time, or the last few hours. Options holds
|
||||
what there is something behind: Log QSOs at all Stations, the message trace, and
|
||||
Run1/Run2. Left out are the two telnet options, which wait on the master relaying cluster
|
||||
spots.
|
||||
|
||||
**Two signals at once.** N1MM blocks the transmitter when the entry is about to
|
||||
break its own class. This program does not touch the transmitter — a logger that
|
||||
decides for itself when the operator may not send loses a contact every time it
|
||||
is wrong — so the entry window puts a red box across its top instead, naming the
|
||||
other station and the band. `TransmitRules` holds what is allowed: one signal in
|
||||
a one-transmitter entry, two on different bands in a two-transmitter entry, and
|
||||
never two on one band whatever the class. A station that has not said which band
|
||||
it is on counts as somewhere else, because a guess there puts the box in front of
|
||||
an operator doing nothing wrong.
|
||||
|
||||
**What the entry agrees on.** Four things have to match across the stations of
|
||||
an entry, and each is now checked rather than assumed:
|
||||
|
||||
| What | How it is checked |
|
||||
|---|---|
|
||||
| the program version | the beacon, which N1MM refuses to talk past |
|
||||
| the contest | `CONTESTNAME` as soon as a connection opens, and again in every `CHECKSUM` |
|
||||
| the callsign | `CHECKSUM` |
|
||||
| the country file | its issue date rides in `STATUS`; two issues score the same contact differently |
|
||||
|
||||
A computer name longer than the fifteen characters N1MM allows is named at
|
||||
startup, a second computer answering to this one's name is named when its
|
||||
beacon arrives, and two stations that have taken the same station number are
|
||||
named when the second one says so.
|
||||
|
||||
**The clock.** `TIME` carries a station's clock and Force Time Sync sends it.
|
||||
N1MM sets the clock from it when it is running as an administrator and says how
|
||||
far out it is when it is not; this program always does the second, because
|
||||
setting the clock needs root and a contest logger has no business asking for it.
|
||||
Anything over two seconds is called out.
|
||||
|
||||
**The master** is the station the entry follows for cluster spots and the time,
|
||||
set from the station list and told to everybody, so the `Master` column agrees
|
||||
everywhere. What it does not do yet is relay: N1MM's master passes its cluster
|
||||
spots to the others over the link, and `PACKET` is not written. `ADDSPOT` is
|
||||
written and read, but only for a local spot made on a QSY (see below); the
|
||||
master does not relay its cluster spots with it.
|
||||
|
||||
**Local spot on a QSY.** With a callsign in the entry window, the radio moving
|
||||
more than `QsySpotHertz` (default 2 kHz, N1MM's value) on the same band puts the
|
||||
call on the bandmap where it was heard and wipes the boxes. It sends `ADDSPOT`
|
||||
to the other stations and a Spots broadcast, never a cluster spot. Nothing
|
||||
happens while running, in quick edit, with a complete exchange, with a number in
|
||||
the box, or when the bandmap already has the call there. N1MM's other
|
||||
trigger, a dupe left behind by a move of 0.1 kHz or more, is not done. There is
|
||||
no dialog for the distance; it is in the settings file.
|
||||
|
||||
**Call stacking.** A callsign heard at one station and handed to the position
|
||||
that will work it: `STACKANOTHERCALL` with the call alone, `STACKCALL` with the
|
||||
contact behind it. The target is picked from the Call Stack Targets tab or from
|
||||
the station list, and what arrives goes on the call stack of the radio the
|
||||
operator is on, sorted by whether it is a multiplier here.
|
||||
|
||||
**Serial numbers.** Reset Serial Numbers at all Stations sends `RESETQSONRS`
|
||||
and every station counts from its own log again: the next number is the highest
|
||||
one in it plus one, which is what the N1MM manual says the button does. The
|
||||
contacts already logged keep the numbers they were sent with.
|
||||
|
||||
The shared pool is written: `ReserveNr` claims a number at the first character
|
||||
of the callsign and `QSONRS` carries the whole pool when a station has fallen
|
||||
behind. `RejectNr` is not — N1MM sends it and reads nothing, so there is
|
||||
nothing on the other end to agree with.
|
||||
|
||||
**The ten-minute rule.** `BandChangeRules` counts band changes and the stay on a
|
||||
band, and the entry window shows the countdown. What was missing was the rule
|
||||
@@ -392,22 +502,68 @@ the changes per hour overrides `Contest.BandChangesFor`. N1MM's per-contest tabl
|
||||
is not repeated: it is a few hundred cases in a decompiled hash switch, and the
|
||||
contests this station enters are the ones worth reading out of it one at a time.
|
||||
|
||||
What the link does not do yet: N1MM's resync, where a station that has been
|
||||
away asks another for the contacts it missed, and the log check that compares
|
||||
two stations' logs row by row. Both are message types this program can already
|
||||
frame; neither is written. There is also no guard against two stations taking
|
||||
the same station number.
|
||||
**Resync.** A station that was away asks the others for the hours it missed.
|
||||
The walk is N1MM's, an hour at a time:
|
||||
|
||||
**Voice keying.** `MessageSender` was written to cover a voice keyer playing a
|
||||
recording, and nothing implements it. Each operator's recordings folder is
|
||||
stored with the rest of his settings and waits on the same thing. No DVK support either, so the second radio
|
||||
of an SO2R station cannot call CQ by voice. Alternating CQ therefore works on CW
|
||||
only, though nothing in it is CW-specific: a voice keyer that reports when the
|
||||
recording has finished would drive it as it stands.
|
||||
| Message | What it says |
|
||||
|---|---|
|
||||
| `CHECKSUM` | here is what I hold for your contacts in this hour, and the contest and callsign I am logging |
|
||||
| `DELETEQS` | drop your copies of my contacts in that hour, I am sending them again |
|
||||
| `RESYNCQSO` | one of those contacts |
|
||||
| `CONFIRMED` | here is what the hour hashes to at my end — which also asks for the next hour |
|
||||
|
||||
**The QTC window sends on CW and RTTY, not on SSB.** On CW the header, the
|
||||
lines, the QRV, the TU and the again messages go out through the keyer, with
|
||||
N1MM's messages and N1MM's defaults.
|
||||
Each station is the authority on the contacts it made, so the answer replaces
|
||||
the block rather than merging into it. The walk ends when the block being asked
|
||||
about starts after the end of the period.
|
||||
|
||||
`LogChecksum` is N1MM's: a CRC32 over the `DXLOG` columns of the block, ordered
|
||||
by time and then callsign, leaving out the columns each station works out for
|
||||
itself — points, the three multiplier flags, the country prefix, the continent,
|
||||
the WPX prefix and `IsOriginal`. Two stations are allowed to disagree about
|
||||
those and still hold the same log. A checksum that disagrees for any other
|
||||
reason costs one block of traffic, which is what a resync is for.
|
||||
|
||||
Every contact logged here now carries the computer that made it —
|
||||
`NetBiosName`, which N1MM stamps and this program did not — because that is what
|
||||
a resync asks for a block of contacts by.
|
||||
|
||||
A station that reconnects resynchronises by itself. N1MM sends `LASTQAT` — when
|
||||
I last worked anybody — as soon as a connection opens, and a station that holds
|
||||
nothing of that station's that late starts a resync from where its own copy
|
||||
stops. An empty log asks for nothing: a program that has just been started has
|
||||
no business pulling the whole contest across, and N1MM suppresses it the same
|
||||
way.
|
||||
|
||||
**Rescore** writes the points and multiplier flags of a period back to the
|
||||
database. The log in memory scores itself whenever it changes, so this is for
|
||||
the stored rows: N1MM reads those columns rather than working them out, and a
|
||||
contact that arrives from another station after the one that took a multiplier
|
||||
leaves them behind. A station can also ask the others to rescore when its resync
|
||||
finishes, which is the flag on the end of `CHECKSUM`.
|
||||
|
||||
What the link does not do yet: the log check that compares two stations' logs
|
||||
row by row. It is a message type this program can already frame; it is not
|
||||
written.
|
||||
|
||||
**Voice keying.** The keyer is written: a phone function key names a wav file,
|
||||
`VoiceKeyer` plays it out of the sound card and keys the transmitter through
|
||||
cwdaemon while it plays, and the voice keyer window lists every recording the
|
||||
messages name, says which are there and records the rest. Alternating CQ duels
|
||||
on phone as well as on CW, because the voice keyer says when a recording has
|
||||
finished.
|
||||
|
||||
What is not written: N1MM's advanced voicing, which says a callsign or a serial
|
||||
number by stringing together a recording per letter and per number out of
|
||||
`LettersFiles`. That is why F5 sends nothing on phone, as it does in N1MM's own
|
||||
default file. There is no DVK support either — the recordings are played on the
|
||||
station's own sound card, so two radios transmitting at once share one card and
|
||||
the second radio is what an SO2R station adds a box for. `{SETWAVDIR}`, which
|
||||
points the folder somewhere else in the middle of a contest, is read and passed
|
||||
over.
|
||||
|
||||
**The QTC window sends on all three modes.** On CW the header, the lines, the
|
||||
QRV, the TU and the again messages go out through the keyer, with N1MM's
|
||||
messages and N1MM's defaults.
|
||||
|
||||
On RTTY the station reading traffic out has Send All, which is N1MM's: the whole
|
||||
series as one message, the heading, then every line with the operator's spacing
|
||||
@@ -424,10 +580,21 @@ why it is one message rather than a button per line: the type-ahead buffer holds
|
||||
it and paces the engine, and the operator presses one button. This has been
|
||||
tested as text — what the message comes out as — and not on the air.
|
||||
|
||||
What is not here: N1MM's four SSB recordings — QRV, Agn, Cfm and TU — which need
|
||||
a voice keyer, and its RTTY messages for the station taking traffic down, which
|
||||
are `WAERXReadyText`, `WAEAllAgnText`, `WAEAGNText` and `WAESaveQTCText`. Those
|
||||
four are typed into the digital window's transmit pane here.
|
||||
The station taking traffic down has N1MM's messages too — RX Ready, All Agn,
|
||||
Agn n and Save, its `WAERXReadyText`, `WAEAllAgnText`, `WAEAGNText` and
|
||||
`WAESaveQTCText` — and so has the station reading it out: R U QRV and Save,
|
||||
`WAERUQRVText` and `WAESSaveQTCText`. All of them are settings in the window's
|
||||
setup area, with N1MM's defaults. Clicking a line in the digital window fills
|
||||
the next row, which is how a series is copied on RTTY.
|
||||
|
||||
On SSB the four buttons N1MM has recordings for play them — `WAEQRV.wav`,
|
||||
`WAEAgain.wav`, `WAEConfirm.wav` and `WAETu.wav`, out of the `Wav` folder
|
||||
rather than an operator's, which is where N1MM plays them from. The lines
|
||||
themselves are read out by the operator: a line is a time, a callsign and a
|
||||
serial number, and advanced voicing is what N1MM says those with.
|
||||
|
||||
What is not here: the green mark N1MM puts on each line as Send All reads it
|
||||
out, which this sends as one message and cannot follow line by line.
|
||||
|
||||
**Cut numbers are not sent.** N1MM can key a serial number as letters — `N` for
|
||||
9, `T` for 0 — and offers several styles. Nothing here does, in a QTC line or in
|
||||
@@ -455,9 +622,22 @@ when a download brings back something unreadable.
|
||||
**Not every action macro is acted on.** The text macros and the action macros
|
||||
that this program can carry out are listed in the README. What is read and
|
||||
passed over: the `{CAT…}` and radio-hex families, the audio and rotator macros,
|
||||
`{STEREOON}` and `{STEREOOFF}`, `{CONDJUMP}`,
|
||||
`{QSYCQ}`, `{FORCELOG}`, `{SwapContests}`, the digital TNC macros (`{ENTER}`,
|
||||
`{ESC}`, `{CTRL-A}`…), and the wav-directory macros, which wait on voice keying.
|
||||
`{STEREOON}` and `{STEREOOFF}`, `{CONDJUMP}`, `{QSYCQ}`, `{FORCELOGNOTE}`,
|
||||
`{COMMENT}`, `{SwapContests}`, `{VARYMSG1}` and `{VARYMSG2}`, the two
|
||||
needed-QSO macros, and `{SETWAVDIR}`, which moves the voice keyer's folder in
|
||||
the middle of a contest.
|
||||
|
||||
`{TIME1}`, `{DATE1}` and `{DAYTIME}` are passed over as well. They are the
|
||||
Nordlink-TF, WA8DED and TAPR packet date formats, and there is nothing here to
|
||||
check a guess at them against; the ordinary `{TIME}`, `{DATE}`, `{TIMEGMT}`,
|
||||
`{DATEGMT}`, `{TIMESTAMP}` and `{TIME2}` are all filled in.
|
||||
|
||||
**Advanced voicing is not written.** N1MM says a callsign or a serial number by
|
||||
playing a recording per letter and per number out of `LettersFiles` — `A.wav`
|
||||
to `Z.wav`, `0.wav` to `19.wav`, the tens, `HUNDRED.wav`, `THOUSAND.wav`,
|
||||
`STROKE.wav`, `QUERY.wav` and `POINT.wav`. Without it `!`, `#` and `@` in a
|
||||
phone message have nothing to say, which is why F5 is empty in N1MM's own
|
||||
default SSB file and in this program's.
|
||||
A message holding any of them still sends the right characters.
|
||||
|
||||
The CW keyer macros are not read either: `<` and `>` for speed, `~` for a half
|
||||
@@ -483,7 +663,7 @@ decodes and transmits through MMTTY over the Wine bridge. What is not here:
|
||||
fldigi, MMVARI, 2Tone and the hardware TNCs, all of which N1MM drives.
|
||||
`DigitalEngine` is the place to add them.
|
||||
|
||||
**Contest coverage.** Twenty-five families are built in, plus whatever `.udc` files
|
||||
**Contest coverage.** Twenty-six families are built in, plus whatever `.udc` files
|
||||
are in the user-defined folder. N1MM ships well over a hundred. Opening a log
|
||||
from a contest that is in neither place fails with the contest name, which is
|
||||
the right answer but it is still a wall.
|
||||
@@ -528,10 +708,18 @@ a county from OK and OM stations and a serial number from everyone else — and
|
||||
Ukrainian DX contest and the Russian DX RTTY contest ask their exchange the same
|
||||
way, and are written in code for the same reason.
|
||||
|
||||
Every contest in the station's own logs can now be opened, and its 78 contest
|
||||
instances score contact for contact as N1MM did apart from the cases below.
|
||||
Every contest in the station's own logs can now be opened. The replay of
|
||||
2026-09-06 read 62 of its instances with built-in rules, 55,415 contacts, and 45
|
||||
of those instances scored contact for contact as N1MM did; 316 contacts differ
|
||||
in points and 141 in a multiplier flag. The comparison is against the points and
|
||||
flags N1MM left in the file, which may themselves be stale, so a difference is
|
||||
something to look at rather than a fault. The counts and the row-by-row list are
|
||||
in [scoring-audit-2026-09-06.md](scoring-audit-2026-09-06.md) and
|
||||
[scoring-audit-history.csv](scoring-audit-history.csv).
|
||||
|
||||
What still differs, and why:
|
||||
What still differs, and why. The IARU, YOTA and CQ WW differences are not in
|
||||
this list: they are in the audit, and each needs the station settings and the
|
||||
country file of the day before it can be said what happened.
|
||||
|
||||
- **The EU DX Contest** is written from N1MM's own class. The station's logs
|
||||
were made with the `EU_DXC.udc` file instead, which scores a contact inside
|
||||
@@ -540,7 +728,10 @@ What still differs, and why:
|
||||
- **Field Day Region 1**: every contact in that log holds 1 point and no
|
||||
multiplier, which is not what N1MM's own class works out, so the log looks
|
||||
like it was never scored. The rules here follow the class: 5 points for a
|
||||
portable station, 2 for one in Region 1 at home and 3 from outside it.
|
||||
portable station, 2 for one in Region 1 at home and 3 from outside it. That
|
||||
table is applied to every running of the contest, which finding 12 of the
|
||||
audit says is wrong: N1MM branches on the running and on the entrant's
|
||||
country, and continent alone does not say whether a station is in Region 1.
|
||||
- **SA 10 and OK/OM DX on SSB** are not written in code at all: both are
|
||||
published as `.udc` files, and with those files in the user-defined contests
|
||||
folder the station's logs score to the contact. N1MM's OK/OM DX class is the CW running only and says so; the SSB
|
||||
@@ -551,6 +742,65 @@ What still differs, and why:
|
||||
nothing and counts no multiplier; the code is trimmed here and counts. Both
|
||||
contacts are the same station in the 2026 log.
|
||||
|
||||
**The statistics window: what N1MM has and this does not.** The window counts
|
||||
the log under any two of its fields, in N1MM's own two lists — 29 fields down
|
||||
the rows, 20 of them across the columns — with N1MM's `Tot` and `Accum` columns,
|
||||
its `Total` line, its "Include Dupes & X-QSOs" box and its stacked column graph.
|
||||
Copy All takes whichever tab is open, as N1MM's does: the table as spaced text
|
||||
off the table tab, a picture of the graph off the graph tab. File ▸ Copy Table
|
||||
as Text and File ▸ Copy Graph as Image do either from either tab, and File ▸
|
||||
Save Graph writes the picture to a PNG. Left out: printing to a printer, which
|
||||
needs a print dialog this program has nowhere else, and N1MM's font size
|
||||
spinner, because the theme dialog sets the fonts here.
|
||||
|
||||
X11 hands over a picture only when the other program pastes, not when it is
|
||||
copied, so `StatisticsWindow` holds the bitmap it gave the clipboard until it
|
||||
gives it a different one. Disposing it at the end of the copy killed the
|
||||
program on the next paste.
|
||||
|
||||
The palette names are N1MM's twelve, which are the .NET chart control's. The
|
||||
colours are not: they are chosen to match the name, because the control's own
|
||||
values are not published anywhere this could read them from. Berry is purple
|
||||
through magenta, Fire is red through yellow, and so on.
|
||||
|
||||
**The statistics graph is drawn here rather than by a chart library.**
|
||||
`StatisticsChart` draws the axis, the stacked columns, the labels and the
|
||||
legend. It has no tooltips, no zoom and no 3-D, all of which N1MM's chart
|
||||
control gives it for free. A column label that will not fit under its column is
|
||||
turned on its side, and one that will not fit even then is left out.
|
||||
|
||||
## Broadcast data
|
||||
|
||||
What the Broadcast Data dialog saves but does not send yet, or sends in less
|
||||
detail than N1MM:
|
||||
|
||||
- **Rotor.** The row is saved. Nothing sends `N1MMRotor` messages, because this
|
||||
program has no rotor control.
|
||||
- **Spots.** Only `add` goes out. N1MM also sends `delete` when a spot leaves the
|
||||
bandmap. Spots that expire are not reported.
|
||||
- **Score.** The rows, their order, the band and mode labels and the layout
|
||||
follow N1MM's query and writer. The row set and order were checked against the
|
||||
query on `om5m.s3db` for 62 contests. Points and multiplier flags come from our
|
||||
own scoring, so they carry the differences listed in `n1mm-interop.md`. The
|
||||
multiplier types come from a table of N1MM's names (`N1mmMultiplierNames`)
|
||||
for the built-in contests; a user-defined contest uses the names its rules
|
||||
give. N1MM writes text values unescaped and we escape them. The bands' wavelength
|
||||
labels were read from N1MM's code and not compared with its output.
|
||||
- **Radio.** `RadioName`, `Antenna`, `Rotors`, `FocusEntry`, `EntryWindowHwnd`
|
||||
and the aux antenna fields are sent as 0 or empty, and `IsTransmitting` is
|
||||
always `False`.
|
||||
- **Contacts, All Computers.** Only logged contacts are passed on, not edits or
|
||||
deletes.
|
||||
|
||||
## Radio mirror
|
||||
|
||||
Config ▸ Radio Mirror copies the frequency, mode and split of a radio on another
|
||||
computer, for a station whose radio port is used up. The listener applies
|
||||
`RadioInfo` to the entry position of one local radio and commands no radio. Nothing is checked against a real N1MM or two
|
||||
real stations; the test sends our own message over loopback. A mode name other
|
||||
than `CW-R` and `FSK` that this program has no mode for leaves the mode
|
||||
unchanged. `IsTransmitting` is read but not used.
|
||||
|
||||
## Known rough edges
|
||||
|
||||
**The band plan covers 160M to 2M only.** 60M and everything above 2M get no
|
||||
@@ -559,7 +809,50 @@ those bands contradict themselves — its CW top for 1.25M is below its phone
|
||||
start, and its 70CM CW top is above the band. Config ▸ Sub bands cannot add a
|
||||
band that has no default.
|
||||
|
||||
**Available mults and Qs is only as good as the bandmap.** It lists what is
|
||||
**Available Mults and Qs differs from N1MM's window.** Reference:
|
||||
https://n1mmwp.hamdocs.com/manual-windows/available-mults-and-qs-window/
|
||||
|
||||
Needs SO2R, which has two radio positions and two entry windows already:
|
||||
|
||||
- the window judges and tunes with the first radio's position only;
|
||||
- Focus Radio, Non-Focus Radio and Only Radio 1/2 filters;
|
||||
- Shift-click sends a spot to the other radio;
|
||||
- Spot to Associated Radio, with the warning when the window opens;
|
||||
- Focus Follows Spot, which moves focus to the radio the spot went to;
|
||||
- a second Available window, one per radio;
|
||||
- Enable Right-click QSY on Spot, which sends the spot to the non-focus radio;
|
||||
- Alt+B, Shift+Alt+B and Ctrl+Alt+B for the second window.
|
||||
|
||||
Needs SO2V, which is not implemented at all (the program has split transmit
|
||||
through rigctld `S 1 VFOB` and a bandmap bar for the second radio, nothing else):
|
||||
|
||||
- reading the sub-receiver or VFO B from the rig, and a position for it;
|
||||
- Basic and Advanced SO2V VFO control, where a spot goes to the VFO already on
|
||||
its band, otherwise the active VFO (Basic always uses VFO A);
|
||||
- the Basic or Advanced label in the title bar.
|
||||
|
||||
Needs something the program does not have:
|
||||
|
||||
- the ♥ column, because there is no Special Calls list in the telnet window;
|
||||
- the heard column, because there is no spectrum display;
|
||||
- Turn Rotor, because there is no rotator control;
|
||||
- the `(!)` marker for a local Skimmer, because a spot does not say whether the
|
||||
Skimmer is ours.
|
||||
|
||||
Smaller differences:
|
||||
|
||||
- the TS header does not change colour while QSY after logging is on;
|
||||
- the last picked line has the grid's own selection, not N1MM's light green
|
||||
frame;
|
||||
- a left click does both the QSY and the call load, where N1MM loads the call
|
||||
only on a double click;
|
||||
- the title bar shows the Qs, Mults and total counts, where N1MM also shows the
|
||||
VFO or focus mode;
|
||||
- there is no option to turn off the Pts column's calculation to save CPU;
|
||||
- tooltips are always on, not tied to a setting;
|
||||
- the column order is not kept between runs, only which columns are hidden.
|
||||
|
||||
**Available Mults and Qs is only as good as the bandmap.** It lists what is
|
||||
spotted, so a multiplier nobody has spotted is not there. N1MM's window also
|
||||
shows the mults a contest has and nobody has worked, which needs a list of every
|
||||
multiplier the contest counts. Only the section and state lists are held here,
|
||||
|
||||
Executable
+3
@@ -0,0 +1,3 @@
|
||||
#!/bin/sh
|
||||
# Linux x64 by default; pass another runtime id such as linux-arm64.
|
||||
exec "$(dirname "$0")/publish.sh" "${1:-linux-x64}"
|
||||
Executable
+77
@@ -0,0 +1,77 @@
|
||||
#!/usr/bin/env python3
|
||||
"""Archives the files of a publish folder that differ from the previous archive.
|
||||
|
||||
usage: publish-update.py <previous archive> <folder> <output archive>
|
||||
|
||||
The previous archive is the full one the last publish left behind (.zip or
|
||||
.tar.gz). A file goes into the output when it is new or its content changed;
|
||||
files the new publish no longer has are listed but cannot be removed by
|
||||
unpacking over the old install. The archive keeps the folder name as its top
|
||||
directory, like the full one. Prints nothing and writes nothing when no file
|
||||
changed.
|
||||
"""
|
||||
import hashlib
|
||||
import os
|
||||
import sys
|
||||
import tarfile
|
||||
import zipfile
|
||||
|
||||
|
||||
def digest(data):
|
||||
return hashlib.sha256(data).hexdigest()
|
||||
|
||||
|
||||
def read_previous(path):
|
||||
"""Maps each file's path inside the archive to a hash of its content."""
|
||||
hashes = {}
|
||||
if path.endswith(".zip"):
|
||||
with zipfile.ZipFile(path) as archive:
|
||||
for info in archive.infolist():
|
||||
if not info.is_dir():
|
||||
hashes[info.filename] = digest(archive.read(info))
|
||||
else:
|
||||
with tarfile.open(path) as archive:
|
||||
for member in archive.getmembers():
|
||||
if member.isfile():
|
||||
hashes[member.name] = digest(archive.extractfile(member).read())
|
||||
return hashes
|
||||
|
||||
|
||||
def main(previous, folder, output):
|
||||
root = os.path.basename(os.path.normpath(folder))
|
||||
old = read_previous(previous)
|
||||
changed = []
|
||||
current = set()
|
||||
for directory, _, names in os.walk(folder):
|
||||
for name in sorted(names):
|
||||
full = os.path.join(directory, name)
|
||||
inside = root + "/" + os.path.relpath(full, folder).replace(os.sep, "/")
|
||||
current.add(inside)
|
||||
with open(full, "rb") as file:
|
||||
if old.get(inside) != digest(file.read()):
|
||||
changed.append((full, inside))
|
||||
removed = sorted(set(old) - current)
|
||||
|
||||
if os.path.exists(output):
|
||||
os.remove(output)
|
||||
if not changed:
|
||||
print("no file changed since the previous archive")
|
||||
return
|
||||
changed.sort(key=lambda pair: pair[1])
|
||||
if output.endswith(".zip"):
|
||||
with zipfile.ZipFile(output, "w", zipfile.ZIP_DEFLATED) as archive:
|
||||
for full, inside in changed:
|
||||
archive.write(full, inside)
|
||||
else:
|
||||
with tarfile.open(output, "w:gz") as archive:
|
||||
for full, inside in changed:
|
||||
archive.add(full, inside, recursive=False)
|
||||
print(f"{output}: {len(changed)} changed of {len(current)} files")
|
||||
for gone in removed:
|
||||
print(f" no longer in the publish: {gone}")
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
if len(sys.argv) != 4:
|
||||
sys.exit(__doc__)
|
||||
main(*sys.argv[1:])
|
||||
Executable
+3
@@ -0,0 +1,3 @@
|
||||
#!/bin/sh
|
||||
# Windows x64 by default; pass another runtime id such as win-arm64.
|
||||
exec "$(dirname "$0")/publish.sh" "${1:-win-x64}"
|
||||
Executable
+52
@@ -0,0 +1,52 @@
|
||||
#!/bin/sh
|
||||
# Builds self-contained copies of the logger and the recorder for one runtime
|
||||
# id into one folder, dist/nonemm-<rid>, and archives it: a zip for Windows, a
|
||||
# tar.gz for the rest. The two programs share the runtime and the Avalonia
|
||||
# files, so the second publish only adds what the first lacks. The target
|
||||
# machine needs no .NET install. Use publish-windows.sh or publish-linux.sh, or
|
||||
# pass the runtime id, for example win-arm64 (the bridge and XMMT.ocx are 32
|
||||
# bit x86 either way). When an archive from an earlier run exists, a second
|
||||
# archive, dist/nonemm-<rid>-update, holds only the files that are new or
|
||||
# changed since then, for unpacking over the old install.
|
||||
rid="${1:?usage: publish.sh <runtime id>}"
|
||||
cd "$(dirname "$0")" || exit 1
|
||||
name="nonemm-$rid"
|
||||
out="dist/$name"
|
||||
mkdir -p dist
|
||||
rm -rf "$out"
|
||||
|
||||
case "$rid" in
|
||||
win-*) extension=zip ;;
|
||||
*) extension=tar.gz ;;
|
||||
esac
|
||||
archive="dist/$name.$extension"
|
||||
update="dist/$name-update.$extension"
|
||||
|
||||
# the full archive is replaced below, so keep the old one to compare against
|
||||
previous=""
|
||||
if [ -f "$archive" ]; then
|
||||
previous="dist/$name.previous.$extension"
|
||||
cp "$archive" "$previous" || exit 1
|
||||
fi
|
||||
|
||||
for project in Nonemm.App Nonemm.Recorder.App; do
|
||||
./build.sh publish "src/$project" -c Release -r "$rid" --self-contained -p:PublishReadyToRun=true -o "$out" || exit 1
|
||||
done
|
||||
rm -f "$out"/*.pdb
|
||||
|
||||
case "$extension" in
|
||||
zip)
|
||||
python3 -c 'import shutil, sys; shutil.make_archive(sys.argv[1], "zip", "dist", sys.argv[2])' \
|
||||
"$out" "$name" || exit 1
|
||||
;;
|
||||
*)
|
||||
tar -C dist -czf "$archive" "$name" || exit 1
|
||||
;;
|
||||
esac
|
||||
echo "$archive"
|
||||
|
||||
rm -f "$update"
|
||||
if [ -n "$previous" ]; then
|
||||
python3 "$(dirname "$0")/publish-update.py" "$previous" "$out" "$update" || exit 1
|
||||
rm -f "$previous"
|
||||
fi
|
||||
@@ -16,10 +16,57 @@
|
||||
<FluentTheme />
|
||||
<StyleInclude Source="avares://Avalonia.Controls.DataGrid/Themes/Fluent.xaml" />
|
||||
|
||||
<!-- the Fluent scroll bar shrinks to a thin line until the pointer is
|
||||
over it -->
|
||||
<Style Selector="ScrollBar">
|
||||
<Setter Property="AllowAutoHide" Value="False" />
|
||||
</Style>
|
||||
<Style Selector="ScrollViewer">
|
||||
<Setter Property="AllowAutoHide" Value="False" />
|
||||
</Style>
|
||||
<Style Selector="DataGrid">
|
||||
<Setter Property="ScrollViewer.AllowAutoHide" Value="False" />
|
||||
</Style>
|
||||
<!-- the Fluent tool tip fades in and out; show it at once -->
|
||||
<Style Selector="ToolTip">
|
||||
<Setter Property="Transitions" Value="{x:Null}" />
|
||||
</Style>
|
||||
<Style Selector="Window">
|
||||
<Setter Property="Background" Value="{DynamicResource FormBackground}" />
|
||||
<Setter Property="Foreground" Value="{DynamicResource FormForeground}" />
|
||||
</Style>
|
||||
<!-- the Fluent tab header is 28 pt and 48 px tall -->
|
||||
<Style Selector="TabItem">
|
||||
<Setter Property="FontSize" Value="12" />
|
||||
<Setter Property="Foreground" Value="{DynamicResource FormForeground}" />
|
||||
<Setter Property="MinHeight" Value="26" />
|
||||
<Setter Property="Padding" Value="10,0" />
|
||||
</Style>
|
||||
<Style Selector="TabItem:selected">
|
||||
<Setter Property="FontWeight" Value="SemiBold" />
|
||||
</Style>
|
||||
<Style Selector="TabItem /template/ Rectangle#PART_SelectedPipe">
|
||||
<Setter Property="Height" Value="3" />
|
||||
</Style>
|
||||
<!-- the Fluent list rows are 32 px tall with 9 px above and below the
|
||||
text -->
|
||||
<Style Selector="ListBoxItem">
|
||||
<Setter Property="MinHeight" Value="0" />
|
||||
<Setter Property="Padding" Value="6,1" />
|
||||
</Style>
|
||||
<Style Selector="ComboBoxItem">
|
||||
<Setter Property="MinHeight" Value="0" />
|
||||
<Setter Property="Padding" Value="6,2" />
|
||||
</Style>
|
||||
<Style Selector="TreeViewItem">
|
||||
<Setter Property="MinHeight" Value="0" />
|
||||
</Style>
|
||||
<Style Selector="DataGridRow">
|
||||
<Setter Property="MinHeight" Value="0" />
|
||||
</Style>
|
||||
<Style Selector="DataGridCell">
|
||||
<Setter Property="MinHeight" Value="0" />
|
||||
</Style>
|
||||
<Style Selector="Menu">
|
||||
<Setter Property="Background" Value="{DynamicResource FormBackground}" />
|
||||
</Style>
|
||||
|
||||
@@ -66,6 +66,8 @@ public partial class App : Application
|
||||
{
|
||||
Set(key, theme.FieldForeground);
|
||||
}
|
||||
// the line under the selected tab, which the Fluent blue leaves faint on a dark form
|
||||
Set("TabItemHeaderSelectedPipeFill", theme.FormForeground);
|
||||
Set("ButtonBackground", theme.ButtonBackground);
|
||||
Set("ButtonBackgroundPointerOver", Lighter(theme.ButtonBackground));
|
||||
Set("ButtonBackgroundPressed", Darker(theme.ButtonBackground));
|
||||
|
||||
@@ -0,0 +1,218 @@
|
||||
using Avalonia.Threading;
|
||||
using Nonemm.Contests;
|
||||
using Nonemm.Core;
|
||||
using Nonemm.Network;
|
||||
using Nonemm.Rig;
|
||||
using Nonemm.Session;
|
||||
using Nonemm.Spotting;
|
||||
using Nonemm.Storage;
|
||||
|
||||
namespace Nonemm.App;
|
||||
|
||||
/// The data N1MM sends to other programs besides the contacts: what the
|
||||
/// Broadcast Data tab turns on.
|
||||
public sealed partial class AppSession
|
||||
{
|
||||
/// N1MM sends the score from the timer of the first entry window, every ten
|
||||
/// seconds.
|
||||
private static readonly TimeSpan ScoreInterval = TimeSpan.FromSeconds(10);
|
||||
|
||||
private DataBroadcaster? data;
|
||||
private DispatcherTimer? broadcasting;
|
||||
private readonly Dictionary<int, RadioReport> radiosSent = [];
|
||||
private DateTime scoreSent;
|
||||
private string lookupSent = "";
|
||||
|
||||
/// Starts, restarts or stops the broadcasts, following what the settings
|
||||
/// now say. Rows whose addresses cannot be read are reported and left off.
|
||||
public void ApplyBroadcastSettings()
|
||||
{
|
||||
broadcasting?.Stop();
|
||||
data?.Dispose();
|
||||
data = new DataBroadcaster(Settings.BroadcastChannels());
|
||||
data.Failed += (_, problem) => Reported?.Invoke(this, problem);
|
||||
foreach (string problem in data.Problems)
|
||||
{
|
||||
Reported?.Invoke(this, problem);
|
||||
}
|
||||
radiosSent.Clear();
|
||||
scoreSent = DateTime.UtcNow;
|
||||
lookupSent = "";
|
||||
SendAppInfo();
|
||||
broadcasting = new DispatcherTimer { Interval = TimeSpan.FromSeconds(1) };
|
||||
broadcasting.Tick += (_, _) =>
|
||||
{
|
||||
SendRadios();
|
||||
SendScore();
|
||||
};
|
||||
broadcasting.Start();
|
||||
}
|
||||
|
||||
/// Which database and contest this station has open. It goes out when a
|
||||
/// contest is opened.
|
||||
private void SendAppInfo()
|
||||
{
|
||||
if (data is null || !data.IsSending(BroadcastKind.AppInfo) || Logging is null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
data.Send(
|
||||
BroadcastKind.AppInfo,
|
||||
BroadcastMessages.AppInfo(
|
||||
Settings.DatabasePath,
|
||||
Logging.Instance.ContestNumber,
|
||||
Logging.Contest.Name,
|
||||
ComputerName,
|
||||
Settings.Station.Callsign));
|
||||
}
|
||||
|
||||
/// Each radio, when something about it has changed since the last time.
|
||||
private void SendRadios()
|
||||
{
|
||||
if (data is null || !data.IsSending(BroadcastKind.Radio))
|
||||
{
|
||||
return;
|
||||
}
|
||||
foreach (OperatingPosition position in positions)
|
||||
{
|
||||
Radio? radio = radios.FirstOrDefault(r => r.Number == position.RadioNumber);
|
||||
long transmit = position.TransmitFrequency.Hertz > 0
|
||||
? position.TransmitFrequency.Hertz
|
||||
: position.Frequency.Hertz;
|
||||
RadioReport report = new(
|
||||
position.RadioNumber,
|
||||
position.Frequency.Hertz,
|
||||
transmit,
|
||||
position.Mode.Name,
|
||||
Settings.Station.Callsign,
|
||||
Settings.CurrentOperator,
|
||||
position.IsRunning,
|
||||
ActiveRadioNumber,
|
||||
position.TransmitFrequency.Hertz > 0,
|
||||
ActiveRadioNumber,
|
||||
false,
|
||||
"",
|
||||
radio?.IsConnected ?? false);
|
||||
if (!radiosSent.TryGetValue(position.RadioNumber, out RadioReport? last) || last != report)
|
||||
{
|
||||
radiosSent[position.RadioNumber] = report;
|
||||
data.Send(BroadcastKind.Radio, BroadcastMessages.Radio(report, ComputerName));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void SendSpots(IEnumerable<Spot> spots)
|
||||
{
|
||||
if (data is null || !data.IsSending(BroadcastKind.Spots))
|
||||
{
|
||||
return;
|
||||
}
|
||||
foreach (Spot spot in spots.Where(s => s.IsStation))
|
||||
{
|
||||
data.Send(
|
||||
BroadcastKind.Spots,
|
||||
BroadcastMessages.Spot(
|
||||
new SpotReport(
|
||||
spot.Call.Text,
|
||||
spot.Frequency.Hertz,
|
||||
spot.Spotter,
|
||||
spot.AtUtc,
|
||||
SpotMode(spot.Frequency),
|
||||
spot.Comment,
|
||||
SpotStatus(spot)),
|
||||
"add",
|
||||
ComputerName));
|
||||
}
|
||||
}
|
||||
|
||||
/// The colour the bandmap would give the station, as N1MM names it.
|
||||
private string SpotStatus(Spot spot) => JudgeSpot(spot) switch
|
||||
{
|
||||
{ IsDupe: true } => "dupe",
|
||||
{ NewMultipliers.Count: 1 } => "single mult",
|
||||
{ NewMultipliers.Count: > 1 } => "double mult",
|
||||
_ => "new qso",
|
||||
};
|
||||
|
||||
private string SpotMode(Frequency frequency) => BandPlan.ModeAt(frequency) switch
|
||||
{
|
||||
ModeCategory.Phone => frequency.Megahertz < 10 ? "LSB" : "USB",
|
||||
ModeCategory.Digital => "RTTY",
|
||||
_ => "CW",
|
||||
};
|
||||
|
||||
private void SendScore()
|
||||
{
|
||||
if (data is null
|
||||
|| !data.IsSending(BroadcastKind.Score)
|
||||
|| Logging is null
|
||||
|| DateTime.UtcNow - scoreSent < ScoreInterval)
|
||||
{
|
||||
return;
|
||||
}
|
||||
scoreSent = DateTime.UtcNow;
|
||||
ContestInstance instance = Logging.Instance;
|
||||
StationInfo me = Settings.Station.ToStationInfo();
|
||||
IReadOnlyList<string> multiplierNames = N1mmContestRows.MultiplierNames(Logging.Contest, me);
|
||||
List<ScoreReportRow> rows = ScoreBreakdown.For(Logging.Log.Qsos, Logging.Contest)
|
||||
.Select(r => new ScoreReportRow(r.Band, r.Mode, r.Qsos, r.Multipliers, r.Points))
|
||||
.ToList();
|
||||
data.Send(
|
||||
BroadcastKind.Score,
|
||||
BroadcastMessages.Score(new ScoreReport(
|
||||
ScoreContestName(instance),
|
||||
Settings.Station.Callsign,
|
||||
instance.Operators,
|
||||
instance.PowerCategory,
|
||||
instance.AssistedCategory,
|
||||
instance.TransmitterCategory,
|
||||
instance.OperatorCategory,
|
||||
instance.BandCategory,
|
||||
instance.ModeCategory,
|
||||
instance.OverlayCategory,
|
||||
instance.StationCategory,
|
||||
Settings.Station.Club,
|
||||
Settings.Station.CountryPrefix,
|
||||
Settings.Station.CqZone,
|
||||
Settings.Station.ItuZone,
|
||||
Settings.Station.ArrlSection,
|
||||
Settings.Station.State.Length > 0 ? Settings.Station.State : Settings.Station.Province,
|
||||
Settings.Station.GridSquare,
|
||||
multiplierNames,
|
||||
rows,
|
||||
Logging.Log.TotalScore,
|
||||
DateTime.UtcNow)));
|
||||
}
|
||||
|
||||
/// The state QSO parties carry the state in front of the Cabrillo name.
|
||||
private string ScoreContestName(ContestInstance instance) =>
|
||||
Logging!.Contest.Name == "QSOPARTY"
|
||||
? $"{instance.SubType}-{Logging.Contest.CabrilloName}"
|
||||
: Logging.Contest.CabrilloName;
|
||||
|
||||
/// The callsign being typed, for a program that looks it up. It goes out
|
||||
/// when the operator leaves the callsign box with a call that has not been
|
||||
/// sent yet.
|
||||
public void SendLookup(OperatingPosition position)
|
||||
{
|
||||
string call = position.Entry.Call.Trim();
|
||||
if (data is null || !data.IsSending(BroadcastKind.Lookup) || call.Length == 0 || call == lookupSent)
|
||||
{
|
||||
return;
|
||||
}
|
||||
lookupSent = call;
|
||||
data.Send(
|
||||
BroadcastKind.Lookup,
|
||||
ContactMessage.WriteLookup(position.InProgress(), Settings.Station.Callsign, ComputerName));
|
||||
}
|
||||
|
||||
/// A contact another logging computer made, passed on to the programs that
|
||||
/// read the contact broadcast. Edits and deletes are not passed on.
|
||||
private void ForwardToPrograms(ContactUpdate update)
|
||||
{
|
||||
if (Settings.BroadcastAllComputers && update is ContactLogged logged)
|
||||
{
|
||||
_ = network?.SendForwardedAsync(logged.Qso, Settings.Station.Callsign);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,80 @@
|
||||
using System.Net.Sockets;
|
||||
using Avalonia.Threading;
|
||||
using Nonemm.Core;
|
||||
using Nonemm.Network;
|
||||
using Nonemm.Session;
|
||||
|
||||
namespace Nonemm.App;
|
||||
|
||||
/// Records the frequency, mode and split of a radio that another computer
|
||||
/// broadcasts as this station's own, for a station whose radio port is taken.
|
||||
/// Only the log's idea of the radio changes; no radio is commanded.
|
||||
/// Config > Configure Radios.
|
||||
public sealed partial class AppSession
|
||||
{
|
||||
private RadioMirror? mirror;
|
||||
|
||||
/// Starts, restarts or stops the listener, following what the settings now
|
||||
/// say. A port that cannot be opened is reported and the listener stays off.
|
||||
public void ApplyMirrorRadioSettings()
|
||||
{
|
||||
mirror?.Dispose();
|
||||
mirror = null;
|
||||
if (!Settings.MirrorRadioEnabled)
|
||||
{
|
||||
return;
|
||||
}
|
||||
try
|
||||
{
|
||||
mirror = new RadioMirror(Settings.MirrorRadioPort);
|
||||
}
|
||||
catch (SocketException e)
|
||||
{
|
||||
Reported?.Invoke(this, $"could not listen for radio data on port {Settings.MirrorRadioPort}: {e.Message}");
|
||||
return;
|
||||
}
|
||||
mirror.Failed += (_, problem) => Reported?.Invoke(this, problem);
|
||||
mirror.Received += (_, message) => Dispatcher.UIThread.Post(() => Mirror(message));
|
||||
}
|
||||
|
||||
/// Sets the target position to where the message says. This computer's own
|
||||
/// messages are skipped, because the radio data goes to this port too when
|
||||
/// the default address is used.
|
||||
private void Mirror(RadioBroadcast message)
|
||||
{
|
||||
RadioReport source = message.Radio;
|
||||
if (message.StationName == ComputerName
|
||||
|| source.RadioNumber != Settings.MirrorRadioSource
|
||||
|| (Settings.MirrorRadioStation.Length > 0
|
||||
&& !string.Equals(message.StationName, Settings.MirrorRadioStation, StringComparison.OrdinalIgnoreCase)))
|
||||
{
|
||||
return;
|
||||
}
|
||||
OperatingPosition? position = positions.FirstOrDefault(p => p.RadioNumber == Settings.MirrorRadioTarget);
|
||||
if (position is null || source.Frequency <= 0)
|
||||
{
|
||||
return;
|
||||
}
|
||||
Frequency frequency = Frequency.FromHertz(source.Frequency);
|
||||
Frequency transmit = source.IsSplit ? Frequency.FromHertz(source.TransmitFrequency) : Frequency.Zero;
|
||||
Mode? mode = MirroredMode(source.Mode);
|
||||
|
||||
bool frequencyChanged = frequency != position.Frequency;
|
||||
bool modeChanged = mode is not null && mode != position.Mode;
|
||||
bool splitChanged = transmit != position.TransmitFrequency;
|
||||
if (!frequencyChanged && !modeChanged && !splitChanged)
|
||||
{
|
||||
return;
|
||||
}
|
||||
TuneAndSpot(position, frequency, mode, transmit);
|
||||
}
|
||||
|
||||
/// N1MM names reverse CW and FSK differently from our modes. Null for a
|
||||
/// mode we have no name for, which leaves the mode where it is.
|
||||
private static Mode? MirroredMode(string name) => name.Trim().ToUpperInvariant() switch
|
||||
{
|
||||
"CW-R" or "CWR" => Modes.Cw,
|
||||
"FSK" or "RTTY-R" or "RTTYR" => Modes.Rtty,
|
||||
var other => Modes.Parse(other),
|
||||
};
|
||||
}
|
||||
@@ -0,0 +1,68 @@
|
||||
using Nonemm.Spotting;
|
||||
|
||||
namespace Nonemm.App;
|
||||
|
||||
/// A line for the info window's message area.
|
||||
/// `IsAlert` marks one the operator should see, such as a spot of their own call.
|
||||
public sealed record Notice(DateTime AtUtc, string Text, bool IsAlert = false);
|
||||
|
||||
public sealed partial class AppSession
|
||||
{
|
||||
private const int NoticesKept = 50;
|
||||
|
||||
private readonly List<Notice> notices = [];
|
||||
private readonly Lock noticesGuard = new();
|
||||
|
||||
/// The latest program messages, oldest first: what the keyers reported and
|
||||
/// the spots of this station's own call.
|
||||
public IReadOnlyList<Notice> Notices
|
||||
{
|
||||
get
|
||||
{
|
||||
lock (noticesGuard)
|
||||
{
|
||||
return [.. notices];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// Raised on whatever thread posted the notice.
|
||||
public event EventHandler? NoticesChanged;
|
||||
|
||||
public void PostNotice(string text, bool isAlert = false)
|
||||
{
|
||||
lock (noticesGuard)
|
||||
{
|
||||
notices.Add(new Notice(DateTime.UtcNow, text, isAlert));
|
||||
if (notices.Count > NoticesKept)
|
||||
{
|
||||
notices.RemoveAt(0);
|
||||
}
|
||||
}
|
||||
NoticesChanged?.Invoke(this, EventArgs.Empty);
|
||||
}
|
||||
|
||||
public void ClearNotices()
|
||||
{
|
||||
lock (noticesGuard)
|
||||
{
|
||||
notices.Clear();
|
||||
}
|
||||
NoticesChanged?.Invoke(this, EventArgs.Empty);
|
||||
}
|
||||
|
||||
/// Posts a notice for each spot of our own call in a batch from the cluster.
|
||||
private void NoticeOwnSpots(IEnumerable<Spot> batch)
|
||||
{
|
||||
string mine = Settings.Station.Callsign.Trim();
|
||||
if (mine.Length == 0)
|
||||
{
|
||||
return;
|
||||
}
|
||||
foreach (Spot spot in batch.Where(s => s.IsStation
|
||||
&& string.Equals(s.Call.Text, mine, StringComparison.OrdinalIgnoreCase)))
|
||||
{
|
||||
PostNotice($"{spot.Spotter} spotted {spot.Call.Text} on {spot.Frequency.Kilohertz:0.0} {spot.Comment}".TrimEnd(), isAlert: true);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,131 @@
|
||||
using Avalonia.Threading;
|
||||
using Nonemm.Core;
|
||||
using Nonemm.Network;
|
||||
using Nonemm.Session;
|
||||
using Nonemm.Spotting;
|
||||
|
||||
namespace Nonemm.App;
|
||||
|
||||
/// N1MM's local spot on a QSY: a callsign left in the entry window while the
|
||||
/// radio moves a long way on the same band is put on the bandmap where it was
|
||||
/// heard, and the boxes are wiped. The spot goes to the other stations on the
|
||||
/// network and to the programs listening for broadcast data. It is never sent
|
||||
/// to the cluster.
|
||||
public sealed partial class AppSession
|
||||
{
|
||||
private const int ShortestCallToSpot = 3;
|
||||
|
||||
/// Raised after the boxes of a position were wiped here, so the window
|
||||
/// showing it can read them again.
|
||||
public event EventHandler<OperatingPosition>? EntryWiped;
|
||||
|
||||
private void TuneAndSpot(OperatingPosition position, Frequency frequency, Mode? mode, Frequency? transmit)
|
||||
{
|
||||
Frequency before = position.Frequency;
|
||||
position.Tune(frequency, mode, transmit);
|
||||
// the radio reports from its own thread, and the boxes belong to the
|
||||
// window's thread
|
||||
Dispatcher.UIThread.Post(() => SpotOnQsy(position, before));
|
||||
}
|
||||
|
||||
/// A tune made in the program itself (frequency step, band button, bandmap
|
||||
/// click). It spots the call at once, before the caller changes the boxes.
|
||||
/// The radio then reports the same frequency back, which moves nothing.
|
||||
public void TuneHere(OperatingPosition position, Frequency frequency, Mode? mode = null)
|
||||
{
|
||||
Frequency before = position.Frequency;
|
||||
position.Tune(frequency, mode);
|
||||
SpotOnQsy(position, before);
|
||||
}
|
||||
|
||||
/// Where the radio was when the call in each entry window was first seen.
|
||||
/// A radio reports every few hundred hertz as the knob turns, so the move
|
||||
/// is measured from here and not from the previous report.
|
||||
private readonly Dictionary<OperatingPosition, (string Call, Frequency At)> heardAt = [];
|
||||
|
||||
private void SpotOnQsy(OperatingPosition position, Frequency reported)
|
||||
{
|
||||
string call = position.Entry.Call.Trim().ToUpperInvariant();
|
||||
Frequency now = position.Frequency;
|
||||
if (call.Length == 0)
|
||||
{
|
||||
heardAt.Remove(position);
|
||||
return;
|
||||
}
|
||||
if (!heardAt.TryGetValue(position, out var anchor) || anchor.Call != call)
|
||||
{
|
||||
anchor = (call, reported);
|
||||
heardAt[position] = anchor;
|
||||
}
|
||||
if (Bands.ForFrequency(anchor.At) != Bands.ForFrequency(now))
|
||||
{
|
||||
// a band change starts again from the new band
|
||||
heardAt[position] = (call, now);
|
||||
return;
|
||||
}
|
||||
Frequency before = anchor.At;
|
||||
Band? band = Bands.ForFrequency(before);
|
||||
if (call.Length < ShortestCallToSpot
|
||||
|| call.All(char.IsAsciiDigit)
|
||||
|| position.IsRunning
|
||||
|| position.Editing is not null
|
||||
|| band is null
|
||||
|| band != Bands.ForFrequency(now)
|
||||
|| Math.Abs(now.Hertz - before.Hertz) <= Settings.QsySpotHertz
|
||||
|| position.PendingQsy() is not null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
Frequency tolerance = Frequency.FromHertz(Settings.TuningToleranceFor(position.Mode.Category));
|
||||
if (Bandmap.Near(before, tolerance) is { IsStation: true } there
|
||||
&& there.Call.Text.Equals(call, StringComparison.OrdinalIgnoreCase))
|
||||
{
|
||||
return;
|
||||
}
|
||||
Spot spot = new(
|
||||
Callsign.Parse(call),
|
||||
before,
|
||||
DateTime.UtcNow,
|
||||
SpotSource.Operator,
|
||||
position.Me.Callsign,
|
||||
$"Local spot by {Settings.CurrentOperator}")
|
||||
{
|
||||
Computer = ComputerName,
|
||||
};
|
||||
heardAt.Remove(position);
|
||||
Bandmap.Add(spot);
|
||||
SendSpots([spot]);
|
||||
_ = link?.SendSpotAsync(new SharedSpot(
|
||||
call,
|
||||
spot.AtUtc,
|
||||
before,
|
||||
spot.Comment,
|
||||
Frequency.Zero,
|
||||
spot.Spotter,
|
||||
IsWorked: false));
|
||||
position.Wipe();
|
||||
EntryWiped?.Invoke(this, position);
|
||||
Reported?.Invoke(this, $"{call} spotted at {before.Kilohertz:0.0}");
|
||||
}
|
||||
|
||||
/// A spot another station on the network put on its bandmap. It is shown
|
||||
/// as it arrived, and is not passed on again.
|
||||
private void TakeSharedSpot(SharedSpot shared)
|
||||
{
|
||||
if (shared.Call.Length == 0 || shared.Frequency.Hertz <= 0)
|
||||
{
|
||||
return;
|
||||
}
|
||||
Bandmap.Add(new Spot(
|
||||
Callsign.Parse(shared.Call),
|
||||
shared.Frequency,
|
||||
shared.AtUtc == default ? DateTime.UtcNow : shared.AtUtc,
|
||||
SpotSource.Operator,
|
||||
shared.Spotter,
|
||||
shared.Comment)
|
||||
{
|
||||
Qsx = shared.Qsx,
|
||||
Computer = shared.Computer,
|
||||
});
|
||||
}
|
||||
}
|
||||
+454
-44
@@ -1,3 +1,4 @@
|
||||
using System.Collections.Concurrent;
|
||||
using Avalonia.Threading;
|
||||
using Nonemm.App.Configuration;
|
||||
using Nonemm.Contests;
|
||||
@@ -17,8 +18,13 @@ namespace Nonemm.App;
|
||||
/// Everything the running program owns: the log store, the contest in progress,
|
||||
/// the bandmap, the radio and the cluster. The windows read from this and one
|
||||
/// `Changed` event tells them all to redraw.
|
||||
public sealed class AppSession : IDisposable
|
||||
public sealed partial class AppSession : IDisposable
|
||||
{
|
||||
/// How often this station tells the others how it is doing. N1MM sends its
|
||||
/// status on the same sort of interval; every second would read the log
|
||||
/// sixty times a minute for two numbers that barely move.
|
||||
private static readonly TimeSpan StatusInterval = TimeSpan.FromSeconds(5);
|
||||
|
||||
private LogStore? store;
|
||||
private readonly List<RigctldRadio> radios = [];
|
||||
private readonly List<OperatingPosition> positions = [];
|
||||
@@ -30,8 +36,16 @@ public sealed class AppSession : IDisposable
|
||||
/// What was last said to the other stations about where this one is, so it
|
||||
/// is said again only when it changes.
|
||||
private (Frequency Where, string Mode, bool Running, int Radio) announced;
|
||||
/// When the last `STATUS` went out. It is not sent every second: it carries
|
||||
/// the rates, which are read out of the log.
|
||||
private DateTime statusSent;
|
||||
private DispatcherTimer? announcing;
|
||||
private MessageSender? keyer;
|
||||
private VoiceKeyer? voice;
|
||||
private CancellationTokenSource? recordingStop;
|
||||
private SoundCard sound = new CommandSoundCard(
|
||||
CommandSoundCard.DefaultPlay,
|
||||
CommandSoundCard.DefaultRecord);
|
||||
private AlternatingCq? alternating;
|
||||
private MmttyEngine? digital;
|
||||
private DigitalEngineSender? digitalSender;
|
||||
@@ -55,6 +69,7 @@ public sealed class AppSession : IDisposable
|
||||
Paths = paths;
|
||||
Settings = settings;
|
||||
paths.CreateFolders();
|
||||
Recordings = new VoiceFiles(paths.Wav);
|
||||
Countries = LoadCountryFile(paths.CountryFile);
|
||||
Calls = LoadCallDatabase(paths.CallDatabaseFile);
|
||||
History = LoadCallHistory(settings.CallHistoryFile);
|
||||
@@ -66,6 +81,7 @@ public sealed class AppSession : IDisposable
|
||||
BandPlan = settings.ToBandPlan();
|
||||
ApplySpotSettings();
|
||||
spotFlush = new Timer(_ => FlushSpots(), null, SpotFlushInterval, SpotFlushInterval);
|
||||
Reported += (_, text) => PostNotice(text);
|
||||
}
|
||||
|
||||
/// How often the spots that have arrived go onto the bandmap. N1MM's own
|
||||
@@ -114,6 +130,14 @@ public sealed class AppSession : IDisposable
|
||||
|
||||
public CheckWindowSources? Check { get; private set; }
|
||||
|
||||
/// Where a line of received text goes while the QTC window is taking
|
||||
/// traffic down on RTTY. The other station sends the header and the whole
|
||||
/// series in one transmission, and the operator clicks each line in the
|
||||
/// digital window rather than typing it, which is how N1MM works. The QTC
|
||||
/// window sets this while it is open and returns whether the line went
|
||||
/// into it.
|
||||
public Func<string, bool>? QtcLines { get; set; }
|
||||
|
||||
/// What is spotted and not worked yet.
|
||||
public AvailableStations? Available { get; private set; }
|
||||
|
||||
@@ -136,6 +160,69 @@ public sealed class AppSession : IDisposable
|
||||
|
||||
public MessageSender? Keyer => keyer;
|
||||
|
||||
/// What sends a message on that mode: the digital engine on a digital
|
||||
/// mode, the voice keyer on phone, the CW keyer otherwise. Everything that
|
||||
/// sends asks here, so a message always goes out the way the mode needs.
|
||||
public MessageSender? SenderFor(ModeCategory mode) => mode switch
|
||||
{
|
||||
ModeCategory.Digital when digitalSender is { IsReady: true } engine => engine,
|
||||
ModeCategory.Phone when voice is { IsReady: true } speaking => speaking,
|
||||
_ => keyer,
|
||||
};
|
||||
|
||||
/// What plays the recordings on phone. It is there whether or not there is
|
||||
/// a CW keyer: the recordings go out of the sound card, not the keying
|
||||
/// port.
|
||||
public VoiceKeyer? Voice => voice;
|
||||
|
||||
/// The recordings under the `Wav` folder, for the voice keyer and for the
|
||||
/// window that records them.
|
||||
public VoiceFiles Recordings { get; }
|
||||
|
||||
/// What plays and records a wav file. The voice keyer sends through it and
|
||||
/// the voice keyer window auditions through it.
|
||||
public SoundCard Sound => sound;
|
||||
|
||||
/// The recording being made, or null. It is here rather than in the window
|
||||
/// that started it because there is one microphone: the voice keyer window
|
||||
/// and the entry window's Ctrl+Shift+F keys record into the same one.
|
||||
public string? Recording { get; private set; }
|
||||
|
||||
/// Records over the file named under `Wav` until `StopRecording`, and
|
||||
/// answers with what to tell the operator: the file recorded, or why
|
||||
/// nothing was.
|
||||
public async Task<string> RecordAsync(string name)
|
||||
{
|
||||
if (Recording is { } already)
|
||||
{
|
||||
return $"{already} is being recorded — stop that first";
|
||||
}
|
||||
recordingStop = new CancellationTokenSource();
|
||||
Recording = name;
|
||||
Changed?.Invoke(this, EventArgs.Empty);
|
||||
try
|
||||
{
|
||||
await sound.RecordAsync(Recordings.PathOf(name), recordingStop.Token)
|
||||
.ConfigureAwait(false);
|
||||
return $"recorded {name}";
|
||||
}
|
||||
catch (Exception failure) when (failure is InvalidOperationException or IOException)
|
||||
{
|
||||
return failure.Message;
|
||||
}
|
||||
finally
|
||||
{
|
||||
recordingStop.Dispose();
|
||||
recordingStop = null;
|
||||
Recording = null;
|
||||
Changed?.Invoke(this, EventArgs.Empty);
|
||||
}
|
||||
}
|
||||
|
||||
/// Ends the recording, which is what saves it: the recorder is asked to
|
||||
/// stop so it can close the file it is writing.
|
||||
public void StopRecording() => recordingStop?.Cancel();
|
||||
|
||||
/// The digital modem, started by the digital window rather than at startup:
|
||||
/// it runs an engine under Wine, which is not something to do to an
|
||||
/// operator who is working CW.
|
||||
@@ -159,6 +246,12 @@ public sealed class AppSession : IDisposable
|
||||
|
||||
public event EventHandler? ContestChanged;
|
||||
|
||||
/// What a keyer had to say while a message was going out — a recording
|
||||
/// that would not play, most of the time. The entry window puts it in the
|
||||
/// status line: by then the caller has been answered and there is nothing
|
||||
/// left to throw at.
|
||||
public event EventHandler<string>? Reported;
|
||||
|
||||
public void Save(Settings settings)
|
||||
{
|
||||
Settings = settings;
|
||||
@@ -197,7 +290,8 @@ public sealed class AppSession : IDisposable
|
||||
/// N1MM reads the `Contest` table when it opens a log, so the definition is
|
||||
/// written again whenever a contest is opened, not only when it is created.
|
||||
private void SaveDefinition(Contest contest) =>
|
||||
Store.SaveContestDefinition(ContestDefinitions.For(contest));
|
||||
Store.SaveContestDefinition(
|
||||
ContestDefinitions.For(contest, Settings.Station.ToStationInfo()));
|
||||
|
||||
public void OpenContest(int contestNumber)
|
||||
{
|
||||
@@ -211,18 +305,31 @@ public sealed class AppSession : IDisposable
|
||||
// whoever was at the radio when the last contest was open is still
|
||||
// there, and every contact he logs carries his callsign
|
||||
Operator = Settings.CurrentOperator,
|
||||
// N1MM stamps every contact with the computer that made it and the
|
||||
// station number of that computer, and a resync asks for the
|
||||
// contacts of one computer by name
|
||||
StationName = ComputerName,
|
||||
StationNumber = Settings.StationNumber,
|
||||
};
|
||||
positions.Clear();
|
||||
for (int number = 1; number <= PositionCount; number++)
|
||||
{
|
||||
positions.Add(new OperatingPosition(Logging, number));
|
||||
positions.Add(new OperatingPosition(Logging, number) { CqLeaveHertz = Settings.CqLeaveHertz });
|
||||
}
|
||||
activeRadio = Math.Min(activeRadio, positions.Count - 1);
|
||||
// the other stations refuse to resynchronise with a station on another
|
||||
// contest, and say so, which is only any use if they are told
|
||||
_ = link?.SendContestNameAsync();
|
||||
// and the highest serial number taken on each band, so a station that
|
||||
// joins a contest already under way starts where the others are. N1MM
|
||||
// sends the same message at the same point
|
||||
_ = link?.SendSerialNumbersAsync(Logging.Numbers.Snapshot());
|
||||
Logging.Changed += (_, _) => Changed?.Invoke(this, EventArgs.Empty);
|
||||
Logging.Logged += (_, qso) =>
|
||||
{
|
||||
// a WAE QTC row is traffic about a station, not a station on the air
|
||||
if (contest.IsContact(qso))
|
||||
// a WAE QTC row is traffic about a station, not a station on the air;
|
||||
// a Run QSO is a station that called us, so it is not a spot to work
|
||||
if (contest.IsContact(qso) && !qso.IsRunQso)
|
||||
{
|
||||
Bandmap.Add(new Spot(qso.Call, qso.Frequency, qso.TimestampUtc, SpotSource.Log));
|
||||
}
|
||||
@@ -234,15 +341,26 @@ public sealed class AppSession : IDisposable
|
||||
// and the same three to the other logging computers, which is a
|
||||
// different protocol on a different port
|
||||
Logging.Logged += (_, qso) => _ = link?.SendLoggedAsync(qso);
|
||||
// the number is announced when it is taken rather than when the contact
|
||||
// is logged, which is what keeps two operators off the same number
|
||||
Logging.Numbers.Reserved += (_, taken) =>
|
||||
_ = link?.SendReservedNumberAsync(taken.Number, SomewhereOn(taken.Band));
|
||||
Logging.Edited += (_, change) =>
|
||||
_ = link?.SendEditedAsync(change.Qso, change.OldCall, change.OldTimestampUtc);
|
||||
Logging.Deleted += (_, qso) => _ = link?.SendDeletedAsync(qso);
|
||||
SpotRecentContacts(Logging.Log.Qsos);
|
||||
Check = new CheckWindowSources(positions[0], Calls, Bandmap);
|
||||
Available = new AvailableStations(positions[0], Bandmap);
|
||||
Save(Settings with { ContestNumber = contestNumber });
|
||||
ContestChanged?.Invoke(this, EventArgs.Empty);
|
||||
SendAppInfo();
|
||||
}
|
||||
|
||||
/// A frequency on the band a number was taken on. The message carries a
|
||||
/// frequency because N1MM's does, and both ends read nothing off it but the
|
||||
/// band.
|
||||
private static Frequency SomewhereOn(Band? band) => band?.Low ?? Frequency.Zero;
|
||||
|
||||
/// One entry position per radio, and one when there is no radio at all.
|
||||
private int PositionCount => Math.Max(1, Settings.Radios.Count(r => r.IsEnabled));
|
||||
|
||||
@@ -250,9 +368,7 @@ public sealed class AppSession : IDisposable
|
||||
/// multi-operator entry, following what the settings now say.
|
||||
public void ApplyNetworkSettings()
|
||||
{
|
||||
announcing?.Stop();
|
||||
network?.Dispose();
|
||||
link?.Dispose();
|
||||
network = null;
|
||||
if (!Settings.NetworkEnabled)
|
||||
{
|
||||
@@ -265,8 +381,7 @@ public sealed class AppSession : IDisposable
|
||||
Settings.NetworkPeers);
|
||||
// the socket thread must not touch the log: every other change to it is
|
||||
// made where the windows read it
|
||||
network.UpdateArrived += (_, update) =>
|
||||
Dispatcher.UIThread.Post(() => TakeFromNetwork(update));
|
||||
network.UpdateArrived += (_, update) => QueueFromNetwork(update);
|
||||
network.Start();
|
||||
Changed?.Invoke(this, EventArgs.Empty);
|
||||
}
|
||||
@@ -275,8 +390,14 @@ public sealed class AppSession : IDisposable
|
||||
/// separate from `ApplyNetworkSettings` because the two are separate
|
||||
/// networks: one carries XML to other programs, the other carries contacts
|
||||
/// to the other computers of this entry.
|
||||
/// What this computer is called on the network of the entry, which is also
|
||||
/// what every contact it logs is stamped with.
|
||||
public string ComputerName =>
|
||||
Settings.NetworkStationName.Length > 0 ? Settings.NetworkStationName : Environment.MachineName;
|
||||
|
||||
public void ApplyStationLinkSettings()
|
||||
{
|
||||
announcing?.Stop();
|
||||
link?.Dispose();
|
||||
link = null;
|
||||
if (!Settings.StationLinkEnabled)
|
||||
@@ -285,7 +406,7 @@ public sealed class AppSession : IDisposable
|
||||
return;
|
||||
}
|
||||
link = new StationLink(
|
||||
Settings.NetworkStationName.Length > 0 ? Settings.NetworkStationName : Environment.MachineName,
|
||||
ComputerName,
|
||||
Settings.StationLinkVersion,
|
||||
Settings.StationNumber,
|
||||
Settings.StationLinkPort)
|
||||
@@ -294,8 +415,23 @@ public sealed class AppSession : IDisposable
|
||||
};
|
||||
// the socket thread must not touch the log: every other change to it is
|
||||
// made where the windows read it
|
||||
link.UpdateArrived += (_, update) =>
|
||||
Dispatcher.UIThread.Post(() => TakeFromNetwork(update));
|
||||
link.UpdateArrived += (_, update) => QueueFromNetwork(update);
|
||||
link.UpdateArrived += (_, update) => ForwardToPrograms(update);
|
||||
// the resync reads the log rather than being handed it, and another
|
||||
// station can ask for a rescore when its resync is done
|
||||
link.Log = new SessionContactLog(this);
|
||||
link.RescoreRequested += (_, _) =>
|
||||
Dispatcher.UIThread.Post(() => Rescore(DateTime.MinValue));
|
||||
link.SerialNumbersReset += (_, _) =>
|
||||
Dispatcher.UIThread.Post(ResetSerialNumbers);
|
||||
link.SpotArrived += (_, shared) =>
|
||||
Dispatcher.UIThread.Post(() => TakeSharedSpot(shared));
|
||||
link.CallStacked += (_, stacked) =>
|
||||
Dispatcher.UIThread.Post(() => TakeStackedCall(stacked));
|
||||
link.NumberReserved += (_, taken) =>
|
||||
Dispatcher.UIThread.Post(() => TakeReservedNumber(taken));
|
||||
link.SerialNumbersArrived += (_, numbers) =>
|
||||
Dispatcher.UIThread.Post(() => Logging?.Numbers.Merge(numbers));
|
||||
foreach (string peer in Settings.StationLinkPeers)
|
||||
{
|
||||
if (Peer(peer) is var (name, address, port))
|
||||
@@ -310,13 +446,20 @@ public sealed class AppSession : IDisposable
|
||||
// changed, rather than announced from each of them
|
||||
announcing?.Stop();
|
||||
announced = default;
|
||||
statusSent = default;
|
||||
announcing = new DispatcherTimer { Interval = TimeSpan.FromSeconds(1) };
|
||||
announcing.Tick += (_, _) => AnnounceWhereIAm();
|
||||
announcing.Tick += (_, _) =>
|
||||
{
|
||||
AnnounceWhereIAm();
|
||||
SayHowIAmDoing();
|
||||
};
|
||||
announcing.Start();
|
||||
Changed?.Invoke(this, EventArgs.Empty);
|
||||
}
|
||||
|
||||
/// Tells the other stations where this one is, if it has moved. In a
|
||||
/// Tells the other stations where this one is, if it has moved. The
|
||||
/// frequency goes out on its own — N1MM's `FREQ` — and everything else
|
||||
/// about the position rides in the `STATUS` that follows it. In a
|
||||
/// multi-single entry this is what the other operators watch: two stations
|
||||
/// on one band is a contact nobody can make.
|
||||
private void AnnounceWhereIAm()
|
||||
@@ -331,8 +474,125 @@ public sealed class AppSession : IDisposable
|
||||
{
|
||||
return;
|
||||
}
|
||||
bool moved = announced.Where != position.Frequency;
|
||||
announced = now;
|
||||
_ = link.SendBandAsync(position.Frequency, position.Mode, position.IsRunning, position.RadioNumber);
|
||||
if (moved)
|
||||
{
|
||||
_ = link.SendFrequencyAsync(position.Frequency);
|
||||
}
|
||||
// the mode, run and the rest of it ride in `STATUS`, which is sent
|
||||
// again now rather than waiting out the rest of its interval
|
||||
statusSent = default;
|
||||
}
|
||||
|
||||
/// True while this station is the second run radio of a two-radio
|
||||
/// position, which is N1MM's Run1/Run2 switch on the network status window.
|
||||
/// It goes out in every `STATUS` and is what the other stations read in
|
||||
/// their `R/M` column.
|
||||
public bool IsRun2
|
||||
{
|
||||
get;
|
||||
set
|
||||
{
|
||||
field = value;
|
||||
statusSent = default;
|
||||
Changed?.Invoke(this, EventArgs.Empty);
|
||||
}
|
||||
}
|
||||
|
||||
/// Starts the serial numbers again from the log: the next number becomes
|
||||
/// the highest one in it plus one. The contacts already logged keep the
|
||||
/// numbers they were sent with. Nothing is sent but `RESETQSONRS`, as in
|
||||
/// N1MM: each station works the same number out of its own copy of the log.
|
||||
public void ResetSerialNumbers()
|
||||
{
|
||||
if (Logging is not null)
|
||||
{
|
||||
Logging.RestartNumbers();
|
||||
Changed?.Invoke(this, EventArgs.Empty);
|
||||
}
|
||||
}
|
||||
|
||||
/// A serial number another station has taken. It is noted here so this
|
||||
/// station counts past it. A number at or below one this station has
|
||||
/// already used says the sender is behind, and it is sent the highest
|
||||
/// number for each band so it can count on from the right one, which is
|
||||
/// what N1MM answers with.
|
||||
private void TakeReservedNumber(ReservedNumberMessage taken)
|
||||
{
|
||||
if (Logging is not { } logging)
|
||||
{
|
||||
return;
|
||||
}
|
||||
if (!logging.Numbers.Note(taken.Number, Bands.ForFrequency(taken.Frequency)))
|
||||
{
|
||||
_ = link?.SendSerialNumbersAsync(logging.Numbers.Snapshot());
|
||||
}
|
||||
Changed?.Invoke(this, EventArgs.Empty);
|
||||
}
|
||||
|
||||
/// A callsign another station handed to this one. It goes on the call stack
|
||||
/// of the radio the operator is on, which is where the entry window takes
|
||||
/// them from.
|
||||
private void TakeStackedCall(StackedCall stacked)
|
||||
{
|
||||
if (Position is not { } position || stacked.Call.Length == 0)
|
||||
{
|
||||
return;
|
||||
}
|
||||
position.Stack.Add(stacked.Call, IsNewMultiplier(stacked));
|
||||
Changed?.Invoke(this, EventArgs.Empty);
|
||||
}
|
||||
|
||||
/// Whether a stacked call is worth a multiplier here, which is what decides
|
||||
/// where it goes in the stack. A call with no contact behind it is judged
|
||||
/// on the callsign alone.
|
||||
private bool IsNewMultiplier(StackedCall stacked) =>
|
||||
Logging is not null
|
||||
&& (stacked.Contact is { } contact
|
||||
? Logging.Log.Judge(contact).NewMultipliers.Count > 0
|
||||
: Logging.Log.Judge(new Qso
|
||||
{
|
||||
Id = "",
|
||||
TimestampUtc = DateTime.UtcNow,
|
||||
Call = Callsign.Parse(stacked.Call),
|
||||
Frequency = Position?.Frequency ?? Frequency.Zero,
|
||||
Mode = Position?.Mode ?? Modes.Cw,
|
||||
ContestName = Logging.Contest.Name,
|
||||
}).NewMultipliers.Count > 0);
|
||||
|
||||
/// Scores the log again and writes the points and multiplier flags from
|
||||
/// `fromUtc` on back to the database. Returns how many rows were written.
|
||||
/// Another station asks for this at the end of a resync, and the rescore
|
||||
/// tab of the network status window asks for it by hand.
|
||||
public int Rescore(DateTime fromUtc) => Logging?.Rescore(fromUtc) ?? 0;
|
||||
|
||||
/// The `STATUS` message: everything the other operators' network status
|
||||
/// windows show about this station, whether anything has changed or not. It
|
||||
/// goes out on N1MM's own interval, and the rates in it are read out of the
|
||||
/// log each time.
|
||||
private void SayHowIAmDoing()
|
||||
{
|
||||
if (link is null || Position is not { } position
|
||||
|| DateTime.UtcNow - statusSent < StatusInterval)
|
||||
{
|
||||
return;
|
||||
}
|
||||
statusSent = DateTime.UtcNow;
|
||||
TimeSpan off = Logging?.Contest.MinimumOffTime ?? TimeSpan.FromMinutes(30);
|
||||
IReadOnlyList<Qso> qsos = Logging?.Log.Qsos ?? [];
|
||||
_ = link.SendStatusAsync(new StationStatus(
|
||||
link.Me.PassFrequency,
|
||||
position.Frequency,
|
||||
position.IsRunning,
|
||||
link.Operator,
|
||||
position.Mode,
|
||||
Rates.PerHour(qsos, 10, DateTime.UtcNow, off),
|
||||
Rates.PerHour(qsos, 100, DateTime.UtcNow, off),
|
||||
Logging?.Instance.OperatorCategory ?? "",
|
||||
Logging?.Instance.TransmitterCategory ?? "",
|
||||
Countries?.Version ?? "",
|
||||
IsRun2));
|
||||
}
|
||||
|
||||
/// A station named by hand, written `RUN-PC@192.168.1.5` with `:port` on
|
||||
@@ -352,26 +612,103 @@ public sealed class AppSession : IDisposable
|
||||
host.Length > 1 && int.TryParse(host[1], out int given) ? given : Settings.StationLinkPort);
|
||||
}
|
||||
|
||||
/// What another station did to its log, applied to ours. Nothing goes back
|
||||
/// out to the network, and the contact is scored here from the rules
|
||||
/// instead of trusting what the sender put in the message.
|
||||
private void TakeFromNetwork(ContactUpdate update)
|
||||
/// Updates that have arrived from the network and not yet been applied.
|
||||
/// They are applied together on the window thread, so a resync that sends
|
||||
/// a few hundred contacts rescores the log and redraws the windows once
|
||||
/// per batch rather than once per contact.
|
||||
private readonly ConcurrentQueue<ContactUpdate> fromNetwork = new();
|
||||
|
||||
private int networkDrainPosted;
|
||||
|
||||
private void QueueFromNetwork(ContactUpdate update)
|
||||
{
|
||||
fromNetwork.Enqueue(update);
|
||||
if (Interlocked.Exchange(ref networkDrainPosted, 1) == 0)
|
||||
{
|
||||
Dispatcher.UIThread.Post(TakeQueuedFromNetwork);
|
||||
}
|
||||
}
|
||||
|
||||
private void TakeQueuedFromNetwork()
|
||||
{
|
||||
// cleared first: an update that arrives while this runs posts a new drain
|
||||
Interlocked.Exchange(ref networkDrainPosted, 0);
|
||||
List<ContactUpdate> batch = [];
|
||||
while (fromNetwork.TryDequeue(out ContactUpdate? update))
|
||||
{
|
||||
batch.Add(update);
|
||||
}
|
||||
TakeFromNetwork(batch);
|
||||
}
|
||||
|
||||
/// What other stations did to their logs, applied to ours in the order it
|
||||
/// arrived. Nothing goes back out to the network, and the contacts are
|
||||
/// scored here from the rules instead of trusting what the sender put in
|
||||
/// the message.
|
||||
private void TakeFromNetwork(IReadOnlyList<ContactUpdate> updates)
|
||||
{
|
||||
if (Logging is null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
switch (update)
|
||||
List<Qso> logged = [];
|
||||
foreach (ContactUpdate update in updates)
|
||||
{
|
||||
case ContactLogged logged:
|
||||
Logging.AddFromNetwork(logged.Qso);
|
||||
break;
|
||||
case ContactReplaced replaced:
|
||||
Logging.ReplaceFromNetwork(replaced.Qso, replaced.OldCall, replaced.OldTimestampUtc);
|
||||
break;
|
||||
case ContactDeleted deleted:
|
||||
Logging.DeleteFromNetwork(deleted.Id, deleted.Call, deleted.TimestampUtc);
|
||||
break;
|
||||
if (!Settings.LogQsosAtAllStations && update is not ContactsCleared)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
if (update is ContactLogged contact)
|
||||
{
|
||||
logged.Add(contact.Qso);
|
||||
continue;
|
||||
}
|
||||
// a run of new contacts is applied before the update that follows
|
||||
// it, because that update may be a clear or an edit of one of them
|
||||
Logging.AddRangeFromNetwork(logged);
|
||||
SpotRecentContacts(logged);
|
||||
logged.Clear();
|
||||
switch (update)
|
||||
{
|
||||
case ContactReplaced replaced:
|
||||
Logging.ReplaceFromNetwork(replaced.Qso, replaced.OldCall, replaced.OldTimestampUtc);
|
||||
break;
|
||||
case ContactDeleted deleted:
|
||||
Logging.DeleteFromNetwork(deleted.Id, deleted.Call, deleted.TimestampUtc);
|
||||
break;
|
||||
case ContactsCleared cleared:
|
||||
Logging.ClearFromNetwork(cleared.StationName, cleared.FromUtc, cleared.Length);
|
||||
break;
|
||||
}
|
||||
}
|
||||
Logging.AddRangeFromNetwork(logged);
|
||||
SpotRecentContacts(logged);
|
||||
}
|
||||
|
||||
/// Puts the contacts of the last few minutes on the bandmap as local spots,
|
||||
/// so a restart does not lose the stations just worked. A station the
|
||||
/// bandmap already holds on that band keeps its spot. Nothing is sent to
|
||||
/// the other stations or the cluster.
|
||||
private void SpotRecentContacts(IEnumerable<Qso> contacts)
|
||||
{
|
||||
if (Settings.RecentContactSpotMinutes <= 0)
|
||||
{
|
||||
return;
|
||||
}
|
||||
DateTime since = DateTime.UtcNow - TimeSpan.FromMinutes(Settings.RecentContactSpotMinutes);
|
||||
HashSet<(string, Band?)> held = [.. Bandmap.All().Select(s => (s.Call.Text, s.Band))];
|
||||
List<Spot> spots = [];
|
||||
foreach (Qso qso in contacts.Where(q => q.TimestampUtc >= since && !q.IsRunQso && Logging!.Contest.IsContact(q)))
|
||||
{
|
||||
Spot spot = new(qso.Call, qso.Frequency, qso.TimestampUtc, SpotSource.Log);
|
||||
if (held.Add((spot.Call.Text, spot.Band)))
|
||||
{
|
||||
spots.Add(spot);
|
||||
}
|
||||
}
|
||||
if (spots.Count > 0)
|
||||
{
|
||||
Bandmap.AddRange(spots);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -384,6 +721,8 @@ public sealed class AppSession : IDisposable
|
||||
alternating = null;
|
||||
keyer?.Dispose();
|
||||
keyer = null;
|
||||
voice?.Dispose();
|
||||
voice = null;
|
||||
switch (Settings.KeyerKind.ToLowerInvariant())
|
||||
{
|
||||
case "cwdaemon":
|
||||
@@ -398,11 +737,21 @@ public sealed class AppSession : IDisposable
|
||||
if (keyer is not null)
|
||||
{
|
||||
_ = keyer.SetSpeedAsync(Settings.KeyerSpeed);
|
||||
alternating = new AlternatingCq(
|
||||
keyer,
|
||||
CallCqOnAsync,
|
||||
TimeSpan.FromMilliseconds(Settings.AlternatingCqGapMs));
|
||||
}
|
||||
sound = new CommandSoundCard(Settings.VoicePlayCommand, Settings.VoiceRecordCommand);
|
||||
voice = new VoiceKeyer(
|
||||
sound,
|
||||
Recordings,
|
||||
// only cwdaemon has a way in to the keying port from here, and
|
||||
// only when the operator has not said the radio keys itself
|
||||
Settings.VoiceKeysPtt && keyer is CwDaemonSender daemon ? daemon.SetPttAsync : null);
|
||||
voice.Reported += (_, what) => Reported?.Invoke(this, what);
|
||||
// a CQ goes out through the keyer the radio's mode calls for, so
|
||||
// alternating CQ listens to both of them
|
||||
alternating = new AlternatingCq(
|
||||
keyer is null ? [voice] : [keyer, voice],
|
||||
CallCqOnAsync,
|
||||
TimeSpan.FromMilliseconds(Settings.AlternatingCqGapMs));
|
||||
Changed?.Invoke(this, EventArgs.Empty);
|
||||
}
|
||||
|
||||
@@ -425,10 +774,12 @@ public sealed class AppSession : IDisposable
|
||||
OnTop = Settings.DigitalEngineOnTop,
|
||||
PttPort = Settings.DigitalPttPort.Trim().Length > 0 ? Settings.DigitalPttPort : null,
|
||||
};
|
||||
WineBridgeChannel channel = new(
|
||||
ProcessBridgeChannel channel = new(
|
||||
Settings.DigitalBridgePath,
|
||||
Settings.DigitalWinePrefix.Trim().Length > 0 ? Settings.DigitalWinePrefix : null,
|
||||
Settings.DigitalWineCommand.Trim().Length > 0 ? Settings.DigitalWineCommand : "wine",
|
||||
OperatingSystem.IsWindows()
|
||||
? null
|
||||
: Settings.DigitalWineCommand.Trim().Length > 0 ? Settings.DigitalWineCommand : "wine",
|
||||
Paths.Diagnostics);
|
||||
MmttyEngine started = new(channel, options);
|
||||
await started.StartAsync();
|
||||
@@ -509,9 +860,9 @@ public sealed class AppSession : IDisposable
|
||||
{
|
||||
OperatingPosition position = positions.FirstOrDefault(p => p.RadioNumber == radioNumber)
|
||||
?? throw new InvalidOperationException($"there is no radio {radioNumber}");
|
||||
if (keyer is null)
|
||||
if (SenderFor(position.Mode.Category) is not { } sender)
|
||||
{
|
||||
throw new InvalidOperationException("there is no keyer");
|
||||
throw new InvalidOperationException($"there is no keyer for {position.Mode.Name}");
|
||||
}
|
||||
string template = Messages
|
||||
.For(position.Mode.Category, Settings.CwMessageFile, Settings.PhoneMessageFile)
|
||||
@@ -523,7 +874,7 @@ public sealed class AppSession : IDisposable
|
||||
}
|
||||
MoveToRadio(radioNumber);
|
||||
await PointTransmitAtAsync(radioNumber).ConfigureAwait(false);
|
||||
await keyer.SendAsync(MessageExpander.Expand(template, position, Other(position))).ConfigureAwait(false);
|
||||
await sender.SendAsync(MessageExpander.Expand(template, position, Other(position))).ConfigureAwait(false);
|
||||
}
|
||||
|
||||
/// Puts both radios in the headphones, or goes back to one. An operator
|
||||
@@ -580,7 +931,7 @@ public sealed class AppSession : IDisposable
|
||||
{
|
||||
return;
|
||||
}
|
||||
position.Tune(state.Frequency, state.Mode, state.TransmitFrequency);
|
||||
TuneAndSpot(position, state.Frequency, state.Mode, state.TransmitFrequency);
|
||||
}
|
||||
|
||||
private void DisposeRadios()
|
||||
@@ -592,26 +943,65 @@ public sealed class AppSession : IDisposable
|
||||
radios.Clear();
|
||||
}
|
||||
|
||||
private static string FirstNonEmpty(params string[] values) =>
|
||||
values.FirstOrDefault(v => v.Length > 0) ?? "";
|
||||
|
||||
/// The favourite the program connects to when it starts, if one is marked.
|
||||
public StoredClusterNode? AutoConnectNode => Settings.ClusterNodes.FirstOrDefault(n => n.AutoConnect);
|
||||
|
||||
/// Connects to the favourite marked for it. Without one, nothing connects.
|
||||
public void ConnectAutoCluster()
|
||||
{
|
||||
if (AutoConnectNode is not { } node)
|
||||
{
|
||||
return;
|
||||
}
|
||||
Save(Settings with
|
||||
{
|
||||
ClusterHost = node.Host,
|
||||
ClusterPort = node.Port,
|
||||
ClusterPassword = node.Password,
|
||||
ClusterCommands = node.Commands,
|
||||
ClusterNodeLogonCall = node.LogonCall,
|
||||
});
|
||||
ConnectCluster();
|
||||
}
|
||||
|
||||
public void ConnectCluster()
|
||||
{
|
||||
cluster?.Dispose();
|
||||
SetSolar(null);
|
||||
cluster = new ClusterClient(
|
||||
Settings.ClusterHost,
|
||||
Settings.ClusterPort,
|
||||
Settings.ClusterLogonCall.Length > 0 ? Settings.ClusterLogonCall : Settings.Station.Callsign,
|
||||
FirstNonEmpty(Settings.ClusterNodeLogonCall, Settings.ClusterLogonCall, Settings.Station.Callsign),
|
||||
Settings.ClusterCommands,
|
||||
Settings.ClusterPassword,
|
||||
autoLogon: Settings.ClusterAutoLogon,
|
||||
keepAliveInterval: TimeSpan.FromMinutes(Math.Max(1, Settings.ClusterKeepAliveMinutes)));
|
||||
cluster.SpotArrived += (_, spot) => TakeSpot(spot);
|
||||
cluster.SolarArrived += (_, report) => SetSolar(report);
|
||||
cluster.ConnectionChanged += (_, _) => Changed?.Invoke(this, EventArgs.Empty);
|
||||
cluster.Start();
|
||||
}
|
||||
|
||||
/// The latest solar weather the cluster sent, or null when it has sent
|
||||
/// none on this connection.
|
||||
public SolarReport? Solar { get; private set; }
|
||||
|
||||
public event EventHandler? SolarChanged;
|
||||
|
||||
private void SetSolar(SolarReport? report)
|
||||
{
|
||||
Solar = report;
|
||||
SolarChanged?.Invoke(this, EventArgs.Empty);
|
||||
}
|
||||
|
||||
public void DisconnectCluster()
|
||||
{
|
||||
cluster?.Dispose();
|
||||
cluster = null;
|
||||
SetSolar(null);
|
||||
Changed?.Invoke(this, EventArgs.Empty);
|
||||
}
|
||||
|
||||
@@ -629,6 +1019,9 @@ public sealed class AppSession : IDisposable
|
||||
/// put on the bandmap in one go.
|
||||
private void FlushSpots()
|
||||
{
|
||||
// here and not in the windows: it scans every spot, and it only has to
|
||||
// happen as often as this timer
|
||||
Bandmap.DropOlderThan(DateTime.UtcNow);
|
||||
List<Spot> batch;
|
||||
lock (arrivingGuard)
|
||||
{
|
||||
@@ -639,6 +1032,7 @@ public sealed class AppSession : IDisposable
|
||||
batch = [.. arriving];
|
||||
arriving.Clear();
|
||||
}
|
||||
NoticeOwnSpots(batch);
|
||||
List<Spot> keeping = [];
|
||||
foreach (Spot spot in batch)
|
||||
{
|
||||
@@ -652,13 +1046,17 @@ public sealed class AppSession : IDisposable
|
||||
if (keeping.Count > 0)
|
||||
{
|
||||
Bandmap.AddRange(keeping);
|
||||
SendSpots(keeping);
|
||||
}
|
||||
}
|
||||
|
||||
/// Whether the station has already been worked, which decides whether a
|
||||
/// spot is moved about: N1MM leaves a dupe where it is.
|
||||
private bool IsDupe(Spot spot) =>
|
||||
Logging is not null && Logging.Log.Judge(new Qso
|
||||
private bool IsDupe(Spot spot) => JudgeSpot(spot) is { IsDupe: true };
|
||||
|
||||
/// What logging the station of a spot would do, or null with no contest open.
|
||||
private Verdict? JudgeSpot(Spot spot) =>
|
||||
Logging?.Log.Judge(new Qso
|
||||
{
|
||||
Id = "",
|
||||
TimestampUtc = spot.AtUtc,
|
||||
@@ -666,12 +1064,20 @@ public sealed class AppSession : IDisposable
|
||||
Frequency = spot.Frequency,
|
||||
Mode = Position?.Mode ?? Modes.Cw,
|
||||
ContestName = Logging.Contest.Name,
|
||||
}) is { IsDupe: true };
|
||||
});
|
||||
|
||||
private void ApplySpotSettings()
|
||||
{
|
||||
spotFilter = Settings.SpotFilter.ToFilter(BandPlan, Settings.Station, Countries, Calls, History);
|
||||
Bandmap.Lifetime = TimeSpan.FromMinutes(Math.Max(1, Settings.SpotTimeoutMinutes));
|
||||
Bandmap.LifetimeFor = spot => TimeSpan.FromMinutes(Math.Max(
|
||||
1,
|
||||
BandPlan.ModeAt(spot.Frequency) is ModeCategory.Cw or ModeCategory.Digital
|
||||
? Settings.CwDigitalSpotTimeoutMinutes
|
||||
: Settings.PhoneSpotTimeoutMinutes));
|
||||
foreach (OperatingPosition position in positions)
|
||||
{
|
||||
position.CqLeaveHertz = Settings.CqLeaveHertz;
|
||||
}
|
||||
}
|
||||
|
||||
public void ReloadSupportFiles()
|
||||
@@ -695,10 +1101,14 @@ public sealed class AppSession : IDisposable
|
||||
DisposeRadios();
|
||||
cluster?.Dispose();
|
||||
announcing?.Stop();
|
||||
broadcasting?.Stop();
|
||||
data?.Dispose();
|
||||
mirror?.Dispose();
|
||||
network?.Dispose();
|
||||
link?.Dispose();
|
||||
alternating?.Dispose();
|
||||
keyer?.Dispose();
|
||||
voice?.Dispose();
|
||||
box?.Dispose();
|
||||
store?.Dispose();
|
||||
}
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
using System.Reflection;
|
||||
using System.Text.Json;
|
||||
using Nonemm.Core;
|
||||
using Nonemm.Keying;
|
||||
using Nonemm.Network;
|
||||
using Nonemm.Session;
|
||||
|
||||
@@ -15,6 +16,12 @@ public sealed record Settings
|
||||
/// dark screen. Config > Manage Skins, Colors and Fonts picks one.
|
||||
public string Theme { get; init; } = "light";
|
||||
|
||||
/// Minimize and restore the other windows with the entry window.
|
||||
public bool MinimizeWindowsTogether { get; init; } = true;
|
||||
|
||||
/// Raise the other windows that are not minimized when one is activated.
|
||||
public bool RaiseWindowsTogether { get; init; } = true;
|
||||
|
||||
public int ContestNumber { get; init; }
|
||||
|
||||
public StoredStation Station { get; init; } = new();
|
||||
@@ -32,12 +39,15 @@ public sealed record Settings
|
||||
/// tab. Connecting to one copies it into `ClusterHost` and the rest.
|
||||
public IReadOnlyList<StoredClusterNode> ClusterNodes { get; init; } = [];
|
||||
|
||||
/// Off for a node that wants the call typed in by hand.
|
||||
/// Always on now; the telnet window no longer has a switch for it.
|
||||
public bool ClusterAutoLogon { get; init; } = true;
|
||||
|
||||
/// The call sent at login, or empty for the station callsign.
|
||||
public string ClusterLogonCall { get; init; } = "";
|
||||
|
||||
/// The call the node being used wants instead of that one, or empty.
|
||||
public string ClusterNodeLogonCall { get; init; } = "";
|
||||
|
||||
/// How often to send an empty line to a node that has said nothing. Nodes
|
||||
/// drop a connection that has been quiet for a quarter of an hour.
|
||||
public int ClusterKeepAliveMinutes { get; init; } = 4;
|
||||
@@ -49,8 +59,55 @@ public sealed record Settings
|
||||
/// Which cluster spots reach the bandmap.
|
||||
public StoredSpotFilter SpotFilter { get; init; } = new();
|
||||
|
||||
/// How long a spot stays on the bandmap. N1MM's own default is 60.
|
||||
public int SpotTimeoutMinutes { get; init; } = 60;
|
||||
public StoredInfoWindow Info { get; init; } = new();
|
||||
|
||||
/// How long a CW or digital spot stays on the bandmap.
|
||||
public int CwDigitalSpotTimeoutMinutes { get; init; } = 10;
|
||||
|
||||
/// How long a phone spot stays on the bandmap. A frequency with no
|
||||
/// boundaries in the band plan counts as phone.
|
||||
public int PhoneSpotTimeoutMinutes { get; init; } = 30;
|
||||
|
||||
/// The width of the slice the bandmap shows, in hertz. Zero is the whole band
|
||||
/// and minus one is the CW, digital or phone part the receiver is in.
|
||||
public int BandmapSpanHertz { get; init; } = 40_000;
|
||||
|
||||
/// The bandmap keeps the receiver in the middle instead of moving only when
|
||||
/// the receiver nears an edge.
|
||||
public bool BandmapCentred { get; init; }
|
||||
|
||||
/// The height of the callsigns on the bandmap, in points.
|
||||
public int BandmapTextSize { get; init; } = 12;
|
||||
|
||||
/// The text size of the log, check and available windows, in points. Ctrl
|
||||
/// with the mouse wheel or plus and minus changes the one in front.
|
||||
public int LogFontSize { get; init; } = 12;
|
||||
|
||||
public int CheckFontSize { get; init; } = 14;
|
||||
|
||||
public int AvailableFontSize { get; init; } = 13;
|
||||
|
||||
/// The Available Mults and Qs window lists only the stations that bring a
|
||||
/// multiplier. Off lists the stations that are only points as well.
|
||||
public bool AvailableMultsOnly { get; init; }
|
||||
|
||||
/// Headers of the columns the window hides. Call cannot be hidden.
|
||||
public IReadOnlyList<string> AvailableHiddenColumns { get; init; } = [];
|
||||
|
||||
/// Band names the window is limited to. Empty is every band.
|
||||
public IReadOnlyList<string> AvailableBands { get; init; } = [];
|
||||
|
||||
/// `CW`, `PHONE` or `DIGITAL`. Empty is every mode.
|
||||
public IReadOnlyList<string> AvailableModes { get; init; } = [];
|
||||
|
||||
/// Band names in the summary table. Empty is the contest's bands.
|
||||
public IReadOnlyList<string> AvailableSummaryBands { get; init; } = [];
|
||||
|
||||
public bool AvailableShowsSummary { get; init; } = true;
|
||||
|
||||
/// After a contact is logged while searching and pounce, the radio goes to
|
||||
/// the newest spot. Needs the list sorted on TS, newest first.
|
||||
public bool AvailableQsyAfterLogging { get; init; }
|
||||
|
||||
/// Moves each incoming CW spot by a few tens of hertz, so the operator has
|
||||
/// to find the station by ear. N1MM calls it randomising.
|
||||
@@ -80,6 +137,20 @@ public sealed record Settings
|
||||
|
||||
public int DigitalTuningToleranceHertz { get; init; } = 300;
|
||||
|
||||
/// How far the radio has to move on the band, in hertz, with a callsign
|
||||
/// left in the entry window, before the call is spotted locally and the
|
||||
/// boxes are wiped. N1MM uses 2 kHz.
|
||||
public int QsySpotHertz { get; init; } = 2000;
|
||||
|
||||
/// Contacts logged in the last this many minutes are put on the bandmap
|
||||
/// when a contest is opened and when contacts arrive from the other
|
||||
/// stations, as local spots. Zero turns it off.
|
||||
public int RecentContactSpotMinutes { get; init; } = 20;
|
||||
|
||||
/// How far the radio can move off the CQ frequency, in hertz, before a
|
||||
/// running position goes back to searching.
|
||||
public int CqLeaveHertz { get; init; } = 3000;
|
||||
|
||||
public int TuningToleranceFor(ModeCategory mode) => mode switch
|
||||
{
|
||||
ModeCategory.Phone => PhoneTuningToleranceHertz,
|
||||
@@ -109,8 +180,6 @@ public sealed record Settings
|
||||
|
||||
public bool RadioEnabled { get; init; }
|
||||
|
||||
public bool ClusterEnabled { get; init; }
|
||||
|
||||
public string NetworkStationName { get; init; } = "";
|
||||
|
||||
public int NetworkPort { get; init; } = 12060;
|
||||
@@ -119,6 +188,52 @@ public sealed record Settings
|
||||
|
||||
public IReadOnlyList<string> NetworkPeers { get; init; } = [];
|
||||
|
||||
/// Also send the contacts the other logging computers make to the programs
|
||||
/// that read the contact broadcast. N1MM's All Computers.
|
||||
public bool BroadcastAllComputers { get; init; }
|
||||
|
||||
/// The other rows of Config > Broadcast Data. The contacts row is
|
||||
/// `NetworkEnabled` and `NetworkPeers`.
|
||||
public BroadcastChannel BroadcastAppInfo { get; init; } = new();
|
||||
|
||||
public BroadcastChannel BroadcastRadio { get; init; } = new();
|
||||
|
||||
public BroadcastChannel BroadcastSpots { get; init; } = new();
|
||||
|
||||
public BroadcastChannel BroadcastRotor { get; init; } = new();
|
||||
|
||||
public BroadcastChannel BroadcastScore { get; init; } = new();
|
||||
|
||||
public BroadcastChannel BroadcastLookup { get; init; } = new();
|
||||
|
||||
/// Copy the frequency, mode and split of a radio that another computer
|
||||
/// broadcasts. The data comes one way: this station never sends anything
|
||||
/// back to it.
|
||||
public bool MirrorRadioEnabled { get; init; }
|
||||
|
||||
/// The UDP port the radio data arrives on.
|
||||
public int MirrorRadioPort { get; init; } = BroadcastTargets.DefaultPort;
|
||||
|
||||
/// Only mirror the computer with this name. Empty follows any computer.
|
||||
public string MirrorRadioStation { get; init; } = "";
|
||||
|
||||
/// The radio number on the computer being mirrored.
|
||||
public int MirrorRadioSource { get; init; } = 1;
|
||||
|
||||
/// The radio on this computer that does the mirroring.
|
||||
public int MirrorRadioTarget { get; init; } = 1;
|
||||
|
||||
public IReadOnlyDictionary<BroadcastKind, BroadcastChannel> BroadcastChannels() =>
|
||||
new Dictionary<BroadcastKind, BroadcastChannel>
|
||||
{
|
||||
[BroadcastKind.AppInfo] = BroadcastAppInfo,
|
||||
[BroadcastKind.Radio] = BroadcastRadio,
|
||||
[BroadcastKind.Spots] = BroadcastSpots,
|
||||
[BroadcastKind.Rotor] = BroadcastRotor,
|
||||
[BroadcastKind.Score] = BroadcastScore,
|
||||
[BroadcastKind.Lookup] = BroadcastLookup,
|
||||
};
|
||||
|
||||
/// The link to the other logging computers of a multi-operator entry, on
|
||||
/// N1MM's port 12070. It is not the same thing as `NetworkEnabled`, which
|
||||
/// is the XML broadcast on 12060 that other programs read; a station can
|
||||
@@ -142,6 +257,11 @@ public sealed record Settings
|
||||
/// with `:port` on the end when that station is not on the usual port.
|
||||
public IReadOnlyList<string> StationLinkPeers { get; init; } = [];
|
||||
|
||||
/// Whether the contacts the other stations log are kept here. N1MM calls it
|
||||
/// Log QSOs at all Stations and every station of an entry normally has it
|
||||
/// on: a log per station is a log the sponsor has to be sent in pieces.
|
||||
public bool LogQsosAtAllStations { get; init; } = true;
|
||||
|
||||
/// The call history file for this contest, or empty for none. They are
|
||||
/// published per contest, so this is not a fixed name.
|
||||
public string CallHistoryFile { get; init; } = "";
|
||||
@@ -166,6 +286,18 @@ public sealed record Settings
|
||||
/// 100 ms, because an SO2R box works relays.
|
||||
public int AlternatingCqGapMs { get; init; } = 100;
|
||||
|
||||
/// What the voice keyer plays and records with. `{file}` in each command
|
||||
/// stands for the file. Empty means the program has nothing to play or
|
||||
/// record with, and the voice keyer window says so.
|
||||
public string VoicePlayCommand { get; init; } = CommandSoundCard.DefaultPlay;
|
||||
|
||||
public string VoiceRecordCommand { get; init; } = CommandSoundCard.DefaultRecord;
|
||||
|
||||
/// Whether the voice keyer keys the transmitter itself, through the same
|
||||
/// cwdaemon that keys CW. Turned off at a station whose radio hears the
|
||||
/// audio and keys itself on VOX.
|
||||
public bool VoiceKeysPtt { get; init; } = true;
|
||||
|
||||
/// How the WAE QTC window behaves. The names and the defaults are N1MM's:
|
||||
/// it skips the confirm and ready steps out of the box, clears the header
|
||||
/// when the header is asked for again, and leaves a line alone when the
|
||||
@@ -203,6 +335,45 @@ public sealed record Settings
|
||||
|
||||
public string QtcRttySendAllEnding { get; init; } = QtcMessages.DefaultSendAllEnding;
|
||||
|
||||
/// What goes out when the station reading traffic out closes the window,
|
||||
/// which is N1MM's `WAESSaveQTCText`.
|
||||
public string QtcRttySendSave { get; init; } = QtcMessages.DefaultRttySendSave;
|
||||
|
||||
/// What the station reading traffic out asks before it starts, N1MM's
|
||||
/// `WAERUQRVText`.
|
||||
public string QtcRttyAreYouReady { get; init; } = QtcMessages.DefaultRttyAreYouReady;
|
||||
|
||||
/// The four messages of the station taking traffic down, N1MM's
|
||||
/// `WAERXReadyText`, `WAEAllAgnText`, `WAEAGNText` and `WAESaveQTCText`.
|
||||
/// `$` in the line message stands for the line being asked for.
|
||||
public string QtcRttyReady { get; init; } = QtcMessages.DefaultRttyReady;
|
||||
|
||||
public string QtcRttyAllAgain { get; init; } = QtcMessages.DefaultRttyAllAgain;
|
||||
|
||||
public string QtcRttyLineAgain { get; init; } = QtcMessages.DefaultRttyLineAgain;
|
||||
|
||||
public string QtcRttySave { get; init; } = QtcMessages.DefaultRttySave;
|
||||
|
||||
/// The log window's columns, as `QsoField` names left to right. Empty means
|
||||
/// the set the contest opens with.
|
||||
public IReadOnlyList<string> LogColumns { get; init; } = [];
|
||||
|
||||
/// What the statistics window counts down the rows and across the columns.
|
||||
/// N1MM opens on the contacts per hand per hour, so this program does too.
|
||||
public string StatsRow { get; init; } = "Hour";
|
||||
|
||||
public string StatsColumn { get; init; } = "Band";
|
||||
|
||||
public string StatsPalette { get; init; } = "Berry";
|
||||
|
||||
/// N1MM's "Include Dupes & X-QSOs".
|
||||
public bool StatsIncludeDupes { get; init; }
|
||||
|
||||
public bool StatsShowTitle { get; init; } = true;
|
||||
|
||||
/// Which of the statistics window's two tabs was last open.
|
||||
public bool StatsOnGraph { get; init; }
|
||||
|
||||
/// Sub-band boundaries the operator has changed. Empty means the defaults
|
||||
/// in `BandPlan.Default`; an entry replaces one band's boundaries.
|
||||
public IReadOnlyList<StoredSubBand> SubBands { get; init; } = [];
|
||||
@@ -228,6 +399,12 @@ public sealed record Settings
|
||||
/// Whoever is at the radio now, or empty at a station with one operator.
|
||||
public string CurrentOperator { get; init; } = "";
|
||||
|
||||
/// The operators who were last at the radio, newest first. `Operators` is
|
||||
/// kept in the order they took it, so the end of the list is the most
|
||||
/// recent.
|
||||
public IEnumerable<StoredOperator> RecentOperators(int count) =>
|
||||
Operators.Reverse().Take(count);
|
||||
|
||||
/// The digital window's twenty-four macro buttons, in the same
|
||||
/// `label,message` lines as a function key file. Empty means the built-in
|
||||
/// set.
|
||||
@@ -285,7 +462,7 @@ public sealed record Settings
|
||||
/// afterwards. N1MM's "don't drop call".
|
||||
public bool DigitalRightClickKeepsCall { get; init; }
|
||||
|
||||
/// A grabbed call is followed by a space, which moves to the exchange and
|
||||
/// A grabbed call is mirrored by a space, which moves to the exchange and
|
||||
/// fills the report in, the way typing one does.
|
||||
public bool DigitalGrabSendsSpace { get; init; } = true;
|
||||
|
||||
@@ -305,7 +482,7 @@ public sealed record Settings
|
||||
/// underlines the line being printed to; true scrolls old text off the top.
|
||||
public bool DigitalScrolling { get; init; } = true;
|
||||
|
||||
/// A click on a callsign is followed by a space, so the cursor moves to
|
||||
/// A click on a callsign is mirrored by a space, so the cursor moves to
|
||||
/// the exchange the way it does after a grab.
|
||||
public bool DigitalClickSendsSpace { get; init; }
|
||||
|
||||
@@ -652,6 +829,7 @@ public sealed record StoredStation
|
||||
Name = Name,
|
||||
Power = Power,
|
||||
Club = Club,
|
||||
RoverQth = RoverQth,
|
||||
Check = Check,
|
||||
Precedence = Precedence,
|
||||
Latitude = Latitude,
|
||||
|
||||
@@ -18,7 +18,26 @@ public sealed record StoredClusterNode
|
||||
/// Sent to this node after login, one command per entry.
|
||||
public IReadOnlyList<string> Commands { get; init; } = [];
|
||||
|
||||
/// How the node reads in the favourites list.
|
||||
/// The call sent at login to this node, or empty for the one set on the
|
||||
/// Login & Spots tab.
|
||||
public string LogonCall { get; init; } = "";
|
||||
|
||||
/// What the published list says about the node. It is refreshed when a new
|
||||
/// list is downloaded.
|
||||
public string Description { get; init; } = "";
|
||||
|
||||
/// The node the program connects to when it starts. At most one favourite
|
||||
/// has it.
|
||||
public bool AutoConnect { get; init; }
|
||||
|
||||
[JsonIgnore]
|
||||
public string Label => Name.Length > 0 ? $"{Name} — {Host}:{Port}" : $"{Host}:{Port}";
|
||||
public string Address => $"{Host}:{Port}";
|
||||
|
||||
/// The first line of the favourites list: the node's callsign, or its host
|
||||
/// when it has none.
|
||||
[JsonIgnore]
|
||||
public string Title => Name.Length > 0 ? Name : Host;
|
||||
|
||||
[JsonIgnore]
|
||||
public bool HasDescription => Description.Length > 0;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,38 @@
|
||||
using Nonemm.Contests;
|
||||
|
||||
namespace Nonemm.App.Configuration;
|
||||
|
||||
/// What the info window shows. Each flag is one item on its right-click menu.
|
||||
public sealed record StoredInfoWindow
|
||||
{
|
||||
public bool CallFrameSpot { get; init; } = true;
|
||||
|
||||
public bool CountryInfo { get; init; } = true;
|
||||
|
||||
public bool SunTimes { get; init; } = true;
|
||||
|
||||
public bool Wwv { get; init; } = true;
|
||||
|
||||
public bool Messages { get; init; } = true;
|
||||
|
||||
public bool QsoTimers { get; init; } = true;
|
||||
|
||||
public bool ShowGoals { get; init; } = true;
|
||||
|
||||
/// Count the rates of every computer on the network rather than this one.
|
||||
public bool NetworkedRate { get; init; }
|
||||
|
||||
/// Count only the contacts on the band the radio is on.
|
||||
public bool BandRate { get; init; }
|
||||
|
||||
/// Show points on the left graph instead of contacts.
|
||||
public bool ShowPoints { get; init; }
|
||||
|
||||
/// The length of one bar on the hourly graph: 20, 30 or 60.
|
||||
public int HourlyMinutes { get; init; } = 30;
|
||||
|
||||
public QsoTimerOption TimerOption { get; init; } = QsoTimerOption.AllStations;
|
||||
|
||||
/// The goals in `Goals.ToText` form. Empty means none are set.
|
||||
public string Goals { get; init; } = "";
|
||||
}
|
||||
@@ -12,10 +12,5 @@ public sealed record StoredOperator
|
||||
/// until he changes them.
|
||||
public string Theme { get; init; } = "";
|
||||
|
||||
/// The folder this operator's recordings are in. A voice keyer plays the
|
||||
/// recordings of whoever is at the microphone, so the path is the
|
||||
/// operator's rather than the station's.
|
||||
public string WavPath { get; init; } = "";
|
||||
|
||||
public IReadOnlyList<StoredWindow> Windows { get; init; } = [];
|
||||
}
|
||||
|
||||
@@ -0,0 +1,11 @@
|
||||
<Window xmlns="https://github.com/avaloniaui"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
x:Class="Nonemm.App.Dialogs.AlertDialog"
|
||||
Width="380" SizeToContent="Height"
|
||||
WindowStartupLocation="CenterOwner" CanResize="False">
|
||||
<DockPanel Margin="14">
|
||||
<Button DockPanel.Dock="Bottom" Content="OK" HorizontalAlignment="Right" Margin="0,12,0,0"
|
||||
Click="OnClose" IsDefault="True" IsCancel="True" />
|
||||
<TextBlock Name="MessageText" TextWrapping="Wrap" />
|
||||
</DockPanel>
|
||||
</Window>
|
||||
@@ -0,0 +1,16 @@
|
||||
using Avalonia.Controls;
|
||||
using Avalonia.Interactivity;
|
||||
|
||||
namespace Nonemm.App.Dialogs;
|
||||
|
||||
public sealed partial class AlertDialog : Window
|
||||
{
|
||||
public AlertDialog(string title, string message)
|
||||
{
|
||||
InitializeComponent();
|
||||
Title = title;
|
||||
MessageText.Text = message;
|
||||
}
|
||||
|
||||
private void OnClose(object? sender, RoutedEventArgs e) => Close();
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
<Window xmlns="https://github.com/avaloniaui"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
x:Class="Nonemm.App.Dialogs.AvailableFilterDialog"
|
||||
Title="Available Window Spot Display Filters" Width="500" SizeToContent="Height"
|
||||
WindowStartupLocation="CenterOwner" CanResize="False">
|
||||
<Grid ColumnDefinitions="*,Auto" RowDefinitions="Auto,Auto" Margin="12">
|
||||
<Border Grid.Row="0" Grid.Column="0" BorderThickness="1" BorderBrush="Gray" Padding="8" Margin="0,0,8,8">
|
||||
<StackPanel Spacing="4">
|
||||
<TextBlock Text="Bands" />
|
||||
<StackPanel Name="BandGroups" Orientation="Horizontal" Spacing="12" />
|
||||
</StackPanel>
|
||||
</Border>
|
||||
<Border Grid.Row="0" Grid.Column="1" BorderThickness="1" BorderBrush="Gray" Padding="8" Margin="0,0,0,8">
|
||||
<StackPanel Name="ModeList" Spacing="4">
|
||||
<TextBlock Text="Modes" />
|
||||
</StackPanel>
|
||||
</Border>
|
||||
<Button Grid.Row="1" Grid.Column="1" Content="Close" HorizontalAlignment="Right" Click="OnClose" IsDefault="True" />
|
||||
</Grid>
|
||||
</Window>
|
||||
@@ -0,0 +1,119 @@
|
||||
using Avalonia;
|
||||
using Avalonia.Controls;
|
||||
using Avalonia.Interactivity;
|
||||
using Nonemm.Core;
|
||||
|
||||
namespace Nonemm.App.Dialogs;
|
||||
|
||||
/// The bands and modes the available window lists, as N1MM's "Spot Display
|
||||
/// Filters" window has them. Each tick takes effect at once, through `changed`,
|
||||
/// and nothing is ticked for every band or mode.
|
||||
public sealed partial class AvailableFilterDialog : Window
|
||||
{
|
||||
public const string ContestMode = "CONTEST";
|
||||
|
||||
private static readonly (string Heading, string[] Bands)[] Groups =
|
||||
[
|
||||
("HF", ["160M", "80M", "60M", "40M", "30M", "20M", "17M", "15M", "12M", "10M"]),
|
||||
("VHF", ["6M", "4M", "2M", "1.25M"]),
|
||||
("UHF", ["70CM", "33CM", "23CM", "13CM"]),
|
||||
("Mw", ["9CM", "6CM", "3CM", "1.25CM", "6MM", "4MM", "2.5MM", "2MM", "1MM"]),
|
||||
];
|
||||
|
||||
private static readonly (string Label, string Key)[] ModeChoices =
|
||||
[
|
||||
("CW", "CW"),
|
||||
("Phone", "PHONE"),
|
||||
("Digital", "DIGITAL"),
|
||||
("Contest", ContestMode),
|
||||
];
|
||||
|
||||
private readonly HashSet<string> bands;
|
||||
private readonly HashSet<string> modes;
|
||||
private readonly Action<IReadOnlyList<string>, IReadOnlyList<string>> changed;
|
||||
private readonly Dictionary<string, CheckBox> bandBoxes = [];
|
||||
private readonly Dictionary<string, CheckBox> modeBoxes = [];
|
||||
|
||||
public AvailableFilterDialog(
|
||||
IReadOnlyList<string> bands,
|
||||
IReadOnlyList<string> modes,
|
||||
Action<IReadOnlyList<string>, IReadOnlyList<string>> changed)
|
||||
{
|
||||
this.bands = new HashSet<string>(bands, StringComparer.OrdinalIgnoreCase);
|
||||
this.modes = new HashSet<string>(modes, StringComparer.OrdinalIgnoreCase);
|
||||
this.changed = changed;
|
||||
InitializeComponent();
|
||||
foreach ((string heading, string[] names) in Groups)
|
||||
{
|
||||
BandGroups.Children.Add(Group(heading, names));
|
||||
}
|
||||
ModeList.Children.Add(AllModes());
|
||||
foreach ((string label, string key) in ModeChoices)
|
||||
{
|
||||
CheckBox box = new() { Content = label, IsChecked = this.modes.Contains(key) };
|
||||
box.IsCheckedChanged += (_, _) => Toggle(modes: true, key, box.IsChecked == true);
|
||||
modeBoxes[key] = box;
|
||||
ModeList.Children.Add(box);
|
||||
}
|
||||
}
|
||||
|
||||
private Control Group(string heading, string[] names)
|
||||
{
|
||||
StackPanel panel = new() { Spacing = 2 };
|
||||
Button all = new() { Content = heading, HorizontalAlignment = Avalonia.Layout.HorizontalAlignment.Left };
|
||||
all.Click += (_, _) =>
|
||||
{
|
||||
bool everyOne = names.All(bands.Contains);
|
||||
foreach (string name in names)
|
||||
{
|
||||
bandBoxes[name].IsChecked = !everyOne;
|
||||
}
|
||||
};
|
||||
panel.Children.Add(all);
|
||||
foreach (string name in names)
|
||||
{
|
||||
Band band = Bands.Named(name)!;
|
||||
CheckBox box = new() { Content = Label(band), IsChecked = bands.Contains(name) };
|
||||
box.IsCheckedChanged += (_, _) => Toggle(modes: false, name, box.IsChecked == true);
|
||||
bandBoxes[name] = box;
|
||||
panel.Children.Add(box);
|
||||
}
|
||||
return panel;
|
||||
}
|
||||
|
||||
private Control AllModes()
|
||||
{
|
||||
Button all = new() { Content = "All", HorizontalAlignment = Avalonia.Layout.HorizontalAlignment.Left };
|
||||
all.Click += (_, _) =>
|
||||
{
|
||||
foreach (CheckBox box in modeBoxes.Values)
|
||||
{
|
||||
box.IsChecked = false;
|
||||
}
|
||||
};
|
||||
return all;
|
||||
}
|
||||
|
||||
/// The megahertz for the bands up to 2.3 GHz, as N1MM labels them, and the
|
||||
/// wavelength for the ones above.
|
||||
private static string Label(Band band) =>
|
||||
band.MegahertzLabel < 3_000
|
||||
? band.MegahertzLabel.ToString("0.###", System.Globalization.CultureInfo.InvariantCulture)
|
||||
: band.Name.ToLowerInvariant();
|
||||
|
||||
private void Toggle(bool modes, string name, bool on)
|
||||
{
|
||||
HashSet<string> set = modes ? this.modes : bands;
|
||||
if (on)
|
||||
{
|
||||
set.Add(name);
|
||||
}
|
||||
else
|
||||
{
|
||||
set.Remove(name);
|
||||
}
|
||||
changed([.. bands], [.. this.modes]);
|
||||
}
|
||||
|
||||
private void OnClose(object? sender, RoutedEventArgs e) => Close();
|
||||
}
|
||||
@@ -0,0 +1,36 @@
|
||||
<Window xmlns="https://github.com/avaloniaui"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
x:Class="Nonemm.App.Dialogs.BandmapDialog"
|
||||
Title="Configure Bandmap" Width="580" SizeToContent="Height"
|
||||
WindowStartupLocation="CenterOwner" CanResize="False">
|
||||
<StackPanel Margin="14" Spacing="6">
|
||||
<TextBlock Text="Spots stay on the bandmap for" FontWeight="SemiBold" />
|
||||
<Grid ColumnDefinitions="*,8,200" RowDefinitions="Auto,Auto" RowSpacing="6">
|
||||
<TextBlock Text="CW and digital" VerticalAlignment="Center" />
|
||||
<NumericUpDown Name="CwDigitalTimeoutBox" Grid.Column="2" Minimum="1" Maximum="600"
|
||||
Increment="1" FormatString="0 "min"" />
|
||||
<TextBlock Grid.Row="1" Text="Phone" VerticalAlignment="Center" />
|
||||
<NumericUpDown Name="PhoneTimeoutBox" Grid.Row="1" Grid.Column="2" Minimum="1" Maximum="600"
|
||||
Increment="1" FormatString="0 "min"" />
|
||||
</Grid>
|
||||
<TextBlock Text="Local spots" FontWeight="SemiBold" Margin="0,8,0,0" />
|
||||
<Grid ColumnDefinitions="*,8,200" RowDefinitions="Auto,Auto,Auto" RowSpacing="6">
|
||||
<TextBlock Text="Spot the call in the entry window when the radio moves more than"
|
||||
TextWrapping="Wrap" VerticalAlignment="Center" />
|
||||
<NumericUpDown Name="QsySpotBox" Grid.Column="2" Minimum="100" Maximum="50000"
|
||||
Increment="100" FormatString="0 "Hz"" />
|
||||
<TextBlock Grid.Row="1" Text="Go back to search and pounce when the radio moves off the CQ frequency by more than"
|
||||
TextWrapping="Wrap" VerticalAlignment="Center" />
|
||||
<NumericUpDown Name="CqLeaveBox" Grid.Row="1" Grid.Column="2" Minimum="100" Maximum="50000"
|
||||
Increment="100" FormatString="0 "Hz"" />
|
||||
<TextBlock Grid.Row="2" Text="On opening and resync, spot the contacts logged in the last (0 for none)"
|
||||
TextWrapping="Wrap" VerticalAlignment="Center" />
|
||||
<NumericUpDown Name="RecentSpotBox" Grid.Row="2" Grid.Column="2" Minimum="0" Maximum="600"
|
||||
Increment="1" FormatString="0 "min"" />
|
||||
</Grid>
|
||||
<StackPanel Orientation="Horizontal" HorizontalAlignment="Right" Spacing="6" Margin="0,8,0,0">
|
||||
<Button Content="Cancel" Click="OnCancel" />
|
||||
<Button Content="Save" Click="OnSave" IsDefault="True" />
|
||||
</StackPanel>
|
||||
</StackPanel>
|
||||
</Window>
|
||||
@@ -0,0 +1,39 @@
|
||||
using Avalonia.Controls;
|
||||
using Avalonia.Interactivity;
|
||||
using Nonemm.App.Configuration;
|
||||
|
||||
namespace Nonemm.App.Dialogs;
|
||||
|
||||
/// How long spots stay on the bandmap, and when the program puts a station on
|
||||
/// it by itself.
|
||||
public sealed partial class BandmapDialog : Window
|
||||
{
|
||||
private readonly Settings settings;
|
||||
|
||||
public BandmapDialog(Settings settings)
|
||||
{
|
||||
this.settings = settings;
|
||||
InitializeComponent();
|
||||
CwDigitalTimeoutBox.Value = settings.CwDigitalSpotTimeoutMinutes;
|
||||
PhoneTimeoutBox.Value = settings.PhoneSpotTimeoutMinutes;
|
||||
QsySpotBox.Value = settings.QsySpotHertz;
|
||||
CqLeaveBox.Value = settings.CqLeaveHertz;
|
||||
RecentSpotBox.Value = settings.RecentContactSpotMinutes;
|
||||
}
|
||||
|
||||
private void OnSave(object? sender, RoutedEventArgs e) =>
|
||||
Close(settings with
|
||||
{
|
||||
CwDigitalSpotTimeoutMinutes = Read(CwDigitalTimeoutBox, settings.CwDigitalSpotTimeoutMinutes),
|
||||
PhoneSpotTimeoutMinutes = Read(PhoneTimeoutBox, settings.PhoneSpotTimeoutMinutes),
|
||||
QsySpotHertz = Read(QsySpotBox, settings.QsySpotHertz),
|
||||
CqLeaveHertz = Read(CqLeaveBox, settings.CqLeaveHertz),
|
||||
RecentContactSpotMinutes = Read(RecentSpotBox, settings.RecentContactSpotMinutes),
|
||||
});
|
||||
|
||||
/// A box the operator emptied keeps the setting it had.
|
||||
private static int Read(NumericUpDown box, int fallback) =>
|
||||
box.Value is { } value ? (int)value : fallback;
|
||||
|
||||
private void OnCancel(object? sender, RoutedEventArgs e) => Close(null);
|
||||
}
|
||||
@@ -0,0 +1,35 @@
|
||||
<Window xmlns="https://github.com/avaloniaui"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
x:Class="Nonemm.App.Dialogs.BroadcastDataDialog"
|
||||
Title="Broadcast Data" Width="680" SizeToContent="Height"
|
||||
WindowStartupLocation="CenterOwner" CanResize="False">
|
||||
<StackPanel Margin="14" Spacing="6">
|
||||
<TextBlock TextWrapping="Wrap" FontSize="11" Opacity="0.75"
|
||||
Text="Select the type of data you wish to broadcast, and the IP address(es) and port(s) for the receiver(s) of the data. Use 127.0.0.1 for the local machine. Use 12060 as the port unless the receiving application requires a different port. 255 in the low order octet will broadcast to your current subnet." />
|
||||
<TextBlock Text="Type of data IP Addr:Port IP Addr:Port..."
|
||||
FontSize="11" Opacity="0.7" Margin="0,6,0,0" />
|
||||
<Grid ColumnDefinitions="150,8,*" RowDefinitions="Auto,Auto,Auto,Auto,Auto,Auto,Auto,Auto" RowSpacing="6">
|
||||
<CheckBox Name="AppInfoCheck" Content="Application Info" />
|
||||
<TextBox Name="AppInfoBox" Grid.Column="2" />
|
||||
<CheckBox Name="RadioCheck" Grid.Row="1" Content="Radio" />
|
||||
<TextBox Name="RadioBox" Grid.Row="1" Grid.Column="2" />
|
||||
<CheckBox Name="ContactsCheck" Grid.Row="2" Content="Contacts" />
|
||||
<TextBox Name="ContactsBox" Grid.Row="2" Grid.Column="2"
|
||||
PlaceholderText="empty: broadcast to the whole network" />
|
||||
<CheckBox Name="AllComputersCheck" Grid.Row="3" Content="All Computers" Margin="20,0,0,0" />
|
||||
<CheckBox Name="SpotsCheck" Grid.Row="4" Content="Spots" />
|
||||
<TextBox Name="SpotsBox" Grid.Row="4" Grid.Column="2" />
|
||||
<CheckBox Name="RotorCheck" Grid.Row="5" Content="Rotor" />
|
||||
<TextBox Name="RotorBox" Grid.Row="5" Grid.Column="2" />
|
||||
<CheckBox Name="ScoreCheck" Grid.Row="6" Content="Score" />
|
||||
<TextBox Name="ScoreBox" Grid.Row="6" Grid.Column="2" />
|
||||
<CheckBox Name="LookupCheck" Grid.Row="7" Content="External Callsign Lookup" />
|
||||
<TextBox Name="LookupBox" Grid.Row="7" Grid.Column="2" />
|
||||
</Grid>
|
||||
<TextBlock Name="ProblemText" TextWrapping="Wrap" Foreground="OrangeRed" IsVisible="False" />
|
||||
<StackPanel Orientation="Horizontal" HorizontalAlignment="Right" Spacing="6" Margin="0,8,0,0">
|
||||
<Button Content="Cancel" Click="OnCancel" />
|
||||
<Button Content="Save" Click="OnSave" IsDefault="True" />
|
||||
</StackPanel>
|
||||
</StackPanel>
|
||||
</Window>
|
||||
@@ -0,0 +1,82 @@
|
||||
using Avalonia.Controls;
|
||||
using Avalonia.Interactivity;
|
||||
using Nonemm.App.Configuration;
|
||||
using Nonemm.Network;
|
||||
|
||||
namespace Nonemm.App.Dialogs;
|
||||
|
||||
/// N1MM's Broadcast Data tab: what is sent to other programs, and where.
|
||||
public sealed partial class BroadcastDataDialog : Window
|
||||
{
|
||||
private readonly Settings settings;
|
||||
|
||||
public BroadcastDataDialog(Settings settings)
|
||||
{
|
||||
this.settings = settings;
|
||||
InitializeComponent();
|
||||
Fill(AppInfoCheck, AppInfoBox, BroadcastKind.AppInfo, settings.BroadcastAppInfo);
|
||||
Fill(RadioCheck, RadioBox, BroadcastKind.Radio, settings.BroadcastRadio);
|
||||
Fill(SpotsCheck, SpotsBox, BroadcastKind.Spots, settings.BroadcastSpots);
|
||||
Fill(RotorCheck, RotorBox, BroadcastKind.Rotor, settings.BroadcastRotor);
|
||||
Fill(ScoreCheck, ScoreBox, BroadcastKind.Score, settings.BroadcastScore);
|
||||
Fill(LookupCheck, LookupBox, BroadcastKind.Lookup, settings.BroadcastLookup);
|
||||
ContactsCheck.IsChecked = settings.NetworkEnabled;
|
||||
ContactsBox.Text = string.Join(' ', settings.NetworkPeers);
|
||||
AllComputersCheck.IsChecked = settings.BroadcastAllComputers;
|
||||
}
|
||||
|
||||
/// An empty list shows the default, as N1MM does.
|
||||
private static void Fill(CheckBox check, TextBox box, BroadcastKind kind, BroadcastChannel channel)
|
||||
{
|
||||
check.IsChecked = channel.IsEnabled;
|
||||
box.Text = channel.Addresses.Count > 0
|
||||
? string.Join(' ', channel.Addresses)
|
||||
: BroadcastTargets.DefaultFor(kind).ToString();
|
||||
}
|
||||
|
||||
private void OnSave(object? sender, RoutedEventArgs e)
|
||||
{
|
||||
List<string> problems = [];
|
||||
BroadcastChannel Read(string name, CheckBox check, TextBox box, int defaultPort)
|
||||
{
|
||||
string text = (box.Text ?? "").Trim();
|
||||
if (BroadcastTargets.Parse(text, defaultPort, out string problem) is null)
|
||||
{
|
||||
problems.Add($"{name}: {problem}");
|
||||
}
|
||||
return new BroadcastChannel
|
||||
{
|
||||
IsEnabled = check.IsChecked == true,
|
||||
Addresses = text.Split([' ', ',', ';', '\t', '\r', '\n'], StringSplitOptions.RemoveEmptyEntries),
|
||||
};
|
||||
}
|
||||
|
||||
BroadcastChannel appInfo = Read("Application Info", AppInfoCheck, AppInfoBox, BroadcastTargets.DefaultPort);
|
||||
BroadcastChannel radio = Read("Radio", RadioCheck, RadioBox, BroadcastTargets.DefaultPort);
|
||||
BroadcastChannel contacts = Read("Contacts", ContactsCheck, ContactsBox, settings.NetworkPort);
|
||||
BroadcastChannel spots = Read("Spots", SpotsCheck, SpotsBox, BroadcastTargets.DefaultPort);
|
||||
BroadcastChannel rotor = Read("Rotor", RotorCheck, RotorBox, BroadcastTargets.RotorPort);
|
||||
BroadcastChannel score = Read("Score", ScoreCheck, ScoreBox, BroadcastTargets.ScorePort);
|
||||
BroadcastChannel lookup = Read("External Callsign Lookup", LookupCheck, LookupBox, BroadcastTargets.DefaultPort);
|
||||
if (problems.Count > 0)
|
||||
{
|
||||
ProblemText.Text = string.Join("\n", problems);
|
||||
ProblemText.IsVisible = true;
|
||||
return;
|
||||
}
|
||||
Close(settings with
|
||||
{
|
||||
BroadcastAppInfo = appInfo,
|
||||
BroadcastRadio = radio,
|
||||
NetworkEnabled = contacts.IsEnabled,
|
||||
NetworkPeers = contacts.Addresses,
|
||||
BroadcastAllComputers = AllComputersCheck.IsChecked == true,
|
||||
BroadcastSpots = spots,
|
||||
BroadcastRotor = rotor,
|
||||
BroadcastScore = score,
|
||||
BroadcastLookup = lookup,
|
||||
});
|
||||
}
|
||||
|
||||
private void OnCancel(object? sender, RoutedEventArgs e) => Close(null);
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
<Window xmlns="https://github.com/avaloniaui"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
x:Class="Nonemm.App.Dialogs.ChangeOperatorDialog"
|
||||
Title="Change Operator" Width="380" SizeToContent="Height"
|
||||
WindowStartupLocation="CenterOwner" CanResize="False">
|
||||
<DockPanel Margin="14">
|
||||
<StackPanel DockPanel.Dock="Bottom" Orientation="Horizontal" HorizontalAlignment="Right"
|
||||
Spacing="6" Margin="0,12,0,0">
|
||||
<Button Content="Cancel" Click="OnCancel" IsCancel="True" />
|
||||
<Button Content="Ok" Click="OnOk" IsDefault="True" />
|
||||
</StackPanel>
|
||||
<StackPanel Spacing="6">
|
||||
<TextBlock Name="AboutText" TextWrapping="Wrap" />
|
||||
<Grid ColumnDefinitions="*,6,150">
|
||||
<TextBox Name="CallBox" />
|
||||
<ComboBox Name="KnownBox" Grid.Column="2" HorizontalAlignment="Stretch"
|
||||
SelectionChanged="OnPickedKnown" PlaceholderText="known" />
|
||||
</Grid>
|
||||
</StackPanel>
|
||||
</DockPanel>
|
||||
</Window>
|
||||
@@ -0,0 +1,49 @@
|
||||
using Avalonia.Controls;
|
||||
using Avalonia.Interactivity;
|
||||
|
||||
namespace Nonemm.App.Dialogs;
|
||||
|
||||
/// Which callsign to write against the contacts picked in the log. It closes
|
||||
/// with the callsign, or with null when nothing is to change. The operators
|
||||
/// already known to the program are in the drop-down; any other callsign is
|
||||
/// typed.
|
||||
public sealed partial class ChangeOperatorDialog : Window
|
||||
{
|
||||
public ChangeOperatorDialog(int contacts, string callsign, IReadOnlyList<string> known)
|
||||
{
|
||||
InitializeComponent();
|
||||
AboutText.Text = contacts == 1
|
||||
? "Operator callsign for the contact picked in the log"
|
||||
: $"Operator callsign for the {contacts} contacts picked in the log";
|
||||
CallBox.Text = callsign;
|
||||
KnownBox.ItemsSource = known;
|
||||
// the callsign is all this dialog asks for, so the cursor starts in it
|
||||
// and the operator types over what is there
|
||||
Opened += (_, _) =>
|
||||
{
|
||||
CallBox.Focus();
|
||||
CallBox.SelectAll();
|
||||
};
|
||||
}
|
||||
|
||||
private void OnPickedKnown(object? sender, SelectionChangedEventArgs e)
|
||||
{
|
||||
if (KnownBox.SelectedItem is string callsign)
|
||||
{
|
||||
CallBox.Text = callsign;
|
||||
}
|
||||
}
|
||||
|
||||
/// An empty box leaves the dialog open: clearing the operator of a contact
|
||||
/// is not what this dialog is for.
|
||||
private void OnOk(object? sender, RoutedEventArgs e)
|
||||
{
|
||||
string callsign = (CallBox.Text ?? "").Trim().ToUpperInvariant();
|
||||
if (callsign.Length > 0)
|
||||
{
|
||||
Close(callsign);
|
||||
}
|
||||
}
|
||||
|
||||
private void OnCancel(object? sender, RoutedEventArgs e) => Close(null);
|
||||
}
|
||||
@@ -124,7 +124,7 @@
|
||||
<TabItem Header="Engine">
|
||||
<ScrollViewer>
|
||||
<StackPanel Margin="4,8,10,4">
|
||||
<TextBlock TextWrapping="Wrap" FontSize="11" Opacity="0.75"
|
||||
<TextBlock Name="EngineNote" TextWrapping="Wrap" FontSize="11" Opacity="0.75"
|
||||
Text="MMTTY and 2Tone are Windows programs. They run under Wine, driven through the same XMMT.ocx control N1MM uses, with a small bridge program in between. See docs/digital-bridge.md for setting the Wine prefix up." />
|
||||
<TextBlock Classes="label" Text="Engine program (mmtty.exe or 2Tone.exe)" />
|
||||
<Grid ColumnDefinitions="*,6,Auto">
|
||||
@@ -136,13 +136,13 @@
|
||||
<TextBox Name="BridgeBox" />
|
||||
<Button Grid.Column="2" Content="Browse…" Click="OnBrowseBridge" />
|
||||
</Grid>
|
||||
<Grid ColumnDefinitions="*,8,160" RowDefinitions="Auto,Auto">
|
||||
<Grid Name="WineRow" ColumnDefinitions="*,8,160" RowDefinitions="Auto,Auto">
|
||||
<TextBlock Classes="label" Text="Wine prefix (empty for Wine's own)" />
|
||||
<TextBox Name="PrefixBox" Grid.Row="1" />
|
||||
<TextBlock Grid.Column="2" Classes="label" Text="Wine command" />
|
||||
<TextBox Name="WineBox" Grid.Row="1" Grid.Column="2" />
|
||||
</Grid>
|
||||
<TextBlock Classes="label" Text="Control (XMMT.ocx), registered in the prefix above" />
|
||||
<TextBlock Name="ControlLabel" Classes="label" Text="Control (XMMT.ocx), registered in the prefix above" />
|
||||
<Grid ColumnDefinitions="*,6,Auto,6,Auto">
|
||||
<TextBox Name="ControlBox" />
|
||||
<Button Grid.Column="2" Content="Browse…" Click="OnBrowseControl" />
|
||||
|
||||
@@ -106,6 +106,14 @@ public sealed partial class DigitalDialog : Window
|
||||
ControlBox.Text = settings.DigitalControlPath;
|
||||
PrefixBox.Text = settings.DigitalWinePrefix;
|
||||
WineBox.Text = settings.DigitalWineCommand;
|
||||
if (OperatingSystem.IsWindows())
|
||||
{
|
||||
WineRow.IsVisible = false;
|
||||
EngineNote.Text = "MMTTY and 2Tone are driven through the same XMMT.ocx control N1MM uses, "
|
||||
+ "with a small bridge program in between. Register the control once, before the first start. "
|
||||
+ "See docs/digital-bridge.md.";
|
||||
ControlLabel.Text = "Control (XMMT.ocx), registered where it is. Keep the file there";
|
||||
}
|
||||
PttBox.Text = settings.DigitalPttPort;
|
||||
}
|
||||
|
||||
@@ -251,12 +259,20 @@ public sealed partial class DigitalDialog : Window
|
||||
{
|
||||
RegisterButton.IsEnabled = false;
|
||||
Say("Registering…");
|
||||
WinePrefixSetup setup = new(
|
||||
PrefixBox.Text?.Trim() is { Length: > 0 } prefix ? prefix : null,
|
||||
WineBox.Text?.Trim() is { Length: > 0 } wine ? wine : "wine");
|
||||
string control = ControlBox.Text?.Trim() ?? "";
|
||||
try
|
||||
{
|
||||
Say(await setup.RegisterAsync(ControlBox.Text?.Trim() ?? ""));
|
||||
if (OperatingSystem.IsWindows())
|
||||
{
|
||||
Say(await new WindowsControlSetup().RegisterAsync(control));
|
||||
}
|
||||
else
|
||||
{
|
||||
WinePrefixSetup setup = new(
|
||||
PrefixBox.Text?.Trim() is { Length: > 0 } prefix ? prefix : null,
|
||||
WineBox.Text?.Trim() is { Length: > 0 } wine ? wine : "wine");
|
||||
Say(await setup.RegisterAsync(control));
|
||||
}
|
||||
}
|
||||
catch (Exception failure) when (failure is IOException or InvalidOperationException)
|
||||
{
|
||||
|
||||
@@ -0,0 +1,19 @@
|
||||
<Window xmlns="https://github.com/avaloniaui"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
x:Class="Nonemm.App.Dialogs.GoalsDialog"
|
||||
Title="Change QSO Goals by Hour" Width="340" Height="440"
|
||||
WindowStartupLocation="CenterOwner">
|
||||
<DockPanel Margin="14">
|
||||
<StackPanel DockPanel.Dock="Bottom" Orientation="Horizontal" HorizontalAlignment="Right"
|
||||
Spacing="6" Margin="0,12,0,0">
|
||||
<Button Content="Export…" Click="OnExport" />
|
||||
<Button Content="Cancel" Click="OnCancel" IsCancel="True" />
|
||||
<Button Content="Ok" Click="OnOk" IsDefault="True" />
|
||||
</StackPanel>
|
||||
<TextBlock DockPanel.Dock="Bottom" Name="ProblemText" Foreground="OrangeRed" Margin="0,6,0,0"
|
||||
TextWrapping="Wrap" />
|
||||
<TextBlock DockPanel.Dock="Top" Margin="0,0,0,6" TextWrapping="Wrap" FontSize="11" Opacity="0.75"
|
||||
Text="One goal per line: Hour (dhh), then Goal (Q's). dhh is the contest day, starting at 1, and the UTC clock hour: 112 is day 1, 12:00Z. A goal holds until the next line." />
|
||||
<TextBox Name="GoalsBox" AcceptsReturn="True" FontFamily="monospace" />
|
||||
</DockPanel>
|
||||
</Window>
|
||||
@@ -0,0 +1,73 @@
|
||||
using Avalonia.Controls;
|
||||
using Avalonia.Interactivity;
|
||||
using Avalonia.Platform.Storage;
|
||||
using Nonemm.Contests;
|
||||
|
||||
namespace Nonemm.App.Dialogs;
|
||||
|
||||
/// N1MM's goals editor, as the text the goals are kept in. It returns the
|
||||
/// goals in `Goals.ToText` form, or null when cancelled.
|
||||
public sealed partial class GoalsDialog : Window
|
||||
{
|
||||
private readonly string exportFolder;
|
||||
|
||||
public GoalsDialog(string goals, string exportFolder)
|
||||
{
|
||||
this.exportFolder = exportFolder;
|
||||
InitializeComponent();
|
||||
GoalsBox.Text = goals;
|
||||
}
|
||||
|
||||
private void OnOk(object? sender, RoutedEventArgs e)
|
||||
{
|
||||
if (Checked() is { } text)
|
||||
{
|
||||
Close(text);
|
||||
}
|
||||
}
|
||||
|
||||
private void OnCancel(object? sender, RoutedEventArgs e) => Close(null);
|
||||
|
||||
/// Writes the goals to a file N1MM's Import Goals reads, keeping the
|
||||
/// dialog open.
|
||||
private async void OnExport(object? sender, RoutedEventArgs e)
|
||||
{
|
||||
if (Checked() is not { } text)
|
||||
{
|
||||
return;
|
||||
}
|
||||
IStorageFile? file = await StorageProvider.SaveFilePickerAsync(new FilePickerSaveOptions
|
||||
{
|
||||
Title = "Export goals",
|
||||
SuggestedFileName = "goals.txt",
|
||||
SuggestedStartLocation = await StorageProvider.TryGetFolderFromPathAsync(exportFolder),
|
||||
});
|
||||
if (file?.TryGetLocalPath() is not { } path)
|
||||
{
|
||||
return;
|
||||
}
|
||||
try
|
||||
{
|
||||
await File.WriteAllTextAsync(path, text);
|
||||
ProblemText.Text = $"{Path.GetFileName(path)} written.";
|
||||
}
|
||||
catch (IOException problem)
|
||||
{
|
||||
ProblemText.Text = $"could not write {path}: {problem.Message}";
|
||||
}
|
||||
}
|
||||
|
||||
private string? Checked()
|
||||
{
|
||||
try
|
||||
{
|
||||
ProblemText.Text = "";
|
||||
return Goals.Parse(GoalsBox.Text ?? "").ToText();
|
||||
}
|
||||
catch (FormatException problem)
|
||||
{
|
||||
ProblemText.Text = problem.Message;
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
<Window xmlns="https://github.com/avaloniaui"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
x:Class="Nonemm.App.Dialogs.ImportGoalsDialog"
|
||||
Title="Import Goals" Width="320" SizeToContent="Height"
|
||||
WindowStartupLocation="CenterOwner" CanResize="False">
|
||||
<DockPanel Margin="14">
|
||||
<StackPanel DockPanel.Dock="Bottom" Orientation="Horizontal" HorizontalAlignment="Right"
|
||||
Spacing="6" Margin="0,12,0,0">
|
||||
<Button Content="Cancel" Click="OnCancel" IsCancel="True" />
|
||||
<Button Content="Choose File…" Click="OnChoose" IsDefault="True" />
|
||||
</StackPanel>
|
||||
<StackPanel Spacing="6">
|
||||
<TextBlock TextWrapping="Wrap" FontSize="11" Opacity="0.75"
|
||||
Text="Goals come from a goal file or from the Statistics window's text export. For a statistics file, pick the band whose column is used." />
|
||||
<ComboBox Name="BandBox" SelectedIndex="0" HorizontalAlignment="Stretch">
|
||||
<ComboBoxItem Content="All bands (total)" />
|
||||
<ComboBoxItem Content="160 m" />
|
||||
<ComboBoxItem Content="80 m" />
|
||||
<ComboBoxItem Content="40 m" />
|
||||
<ComboBoxItem Content="20 m" />
|
||||
<ComboBoxItem Content="15 m" />
|
||||
<ComboBoxItem Content="10 m" />
|
||||
</ComboBox>
|
||||
</StackPanel>
|
||||
</DockPanel>
|
||||
</Window>
|
||||
@@ -0,0 +1,23 @@
|
||||
using Avalonia.Controls;
|
||||
using Avalonia.Interactivity;
|
||||
|
||||
namespace Nonemm.App.Dialogs;
|
||||
|
||||
/// The first half of N1MM's Import Goals: which band's column of a statistics
|
||||
/// file to read. It returns the column counted back from the total, as
|
||||
/// `Goals.Parse` takes it, or null when cancelled.
|
||||
public sealed partial class ImportGoalsDialog : Window
|
||||
{
|
||||
/// The columns of a statistics file run from 160 m to 10 m and then the
|
||||
/// total, so 160 m is six from the end.
|
||||
private static readonly int[] FromEnd = [0, 6, 5, 4, 3, 2, 1];
|
||||
|
||||
public ImportGoalsDialog()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
|
||||
private void OnChoose(object? sender, RoutedEventArgs e) => Close(FromEnd[Math.Max(0, BandBox.SelectedIndex)]);
|
||||
|
||||
private void OnCancel(object? sender, RoutedEventArgs e) => Close(null);
|
||||
}
|
||||
@@ -1,5 +1,6 @@
|
||||
<Window xmlns="https://github.com/avaloniaui"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:theming="using:Nonemm.App.Theming"
|
||||
x:Class="Nonemm.App.Dialogs.MessagesDialog"
|
||||
Title="Function key messages" Width="620" Height="520"
|
||||
WindowStartupLocation="CenterOwner" KeyDown="OnKeyDown">
|
||||
@@ -31,7 +32,7 @@
|
||||
<ScrollViewer HorizontalScrollBarVisibility="Auto" VerticalScrollBarVisibility="Auto">
|
||||
<Grid>
|
||||
<StackPanel Name="Highlight" Margin="6,4" IsHitTestVisible="False" ZIndex="1" />
|
||||
<TextBox Name="TextArea" AcceptsReturn="True" AcceptsTab="False" FontFamily="monospace"
|
||||
<TextBox Name="TextArea" AcceptsReturn="True" AcceptsTab="False" FontFamily="{x:Static theming:Fonts.Mono}"
|
||||
FontSize="12" Padding="6,4" TextWrapping="NoWrap" BorderThickness="0"
|
||||
Background="Transparent" Foreground="Transparent"
|
||||
VerticalContentAlignment="Top" />
|
||||
|
||||
@@ -1,39 +0,0 @@
|
||||
<Window xmlns="https://github.com/avaloniaui"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
x:Class="Nonemm.App.Dialogs.NetworkDialog"
|
||||
Title="Networked stations" Width="440" SizeToContent="Height"
|
||||
WindowStartupLocation="CenterOwner" CanResize="False">
|
||||
<StackPanel Margin="14" Spacing="6">
|
||||
<TextBlock TextWrapping="Wrap" FontSize="11" Opacity="0.75"
|
||||
Text="Each contact is sent to the other stations of the entry as it is logged, in N1MM's contact message, so an N1MM station on the same network sees them too. With no addresses listed the contacts are broadcast." />
|
||||
<Grid ColumnDefinitions="*,8,110" RowDefinitions="Auto,Auto">
|
||||
<TextBlock Text="This station's name" FontSize="11" Opacity="0.7" Margin="0,6,0,1" />
|
||||
<TextBox Name="NameBox" Grid.Row="1" />
|
||||
<TextBlock Grid.Column="2" Text="Port" FontSize="11" Opacity="0.7" Margin="0,6,0,1" />
|
||||
<TextBox Name="PortBox" Grid.Row="1" Grid.Column="2" />
|
||||
</Grid>
|
||||
<TextBlock Text="Other stations, one address per line" FontSize="11" Opacity="0.7" Margin="0,6,0,1" />
|
||||
<TextBox Name="PeersBox" AcceptsReturn="True" Height="90" PlaceholderText="192.168.1.11" />
|
||||
<CheckBox Name="EnabledBox" Content="Broadcast contacts to other programs (port 12060)" Margin="0,6,0,0" />
|
||||
<TextBlock Text="The other logging computers" FontWeight="Bold" Margin="0,12,0,0" />
|
||||
<TextBlock TextWrapping="Wrap" FontSize="11" Opacity="0.75"
|
||||
Text="This is N1MM's own link between the computers of one entry, on port 12070: contacts, edits, deletes and chat, over a connection to each station. Stations are found by broadcast, so nothing has to be listed." />
|
||||
<Grid ColumnDefinitions="90,8,110,8,*" RowDefinitions="Auto,Auto">
|
||||
<TextBlock Text="Station number" FontSize="11" Opacity="0.7" Margin="0,6,0,1" />
|
||||
<TextBox Name="StationNumberBox" Grid.Row="1" />
|
||||
<TextBlock Grid.Column="2" Text="Port" FontSize="11" Opacity="0.7" Margin="0,6,0,1" />
|
||||
<TextBox Name="LinkPortBox" Grid.Row="1" Grid.Column="2" />
|
||||
<TextBlock Grid.Column="4" Text="Version to claim" FontSize="11" Opacity="0.7" Margin="0,6,0,1" />
|
||||
<TextBox Name="VersionBox" Grid.Row="1" Grid.Column="4" />
|
||||
</Grid>
|
||||
<TextBlock TextWrapping="Wrap" FontSize="11" Opacity="0.75"
|
||||
Text="N1MM turns away a station whose version is not its own, so this has to be the version the N1MM copies beside it are running. Help ▸ About in N1MM says which." />
|
||||
<TextBlock Text="Stations to reach by address, one per line, as NAME@address" FontSize="11" Opacity="0.7" Margin="0,6,0,1" />
|
||||
<TextBox Name="LinkPeersBox" AcceptsReturn="True" Height="60" PlaceholderText="RUN-PC@192.168.1.11" />
|
||||
<CheckBox Name="LinkEnabledBox" Content="Share contacts with the other logging computers (port 12070)" Margin="0,6,0,0" />
|
||||
<StackPanel Orientation="Horizontal" HorizontalAlignment="Right" Spacing="6" Margin="0,8,0,0">
|
||||
<Button Content="Cancel" Click="OnCancel" />
|
||||
<Button Content="Save" Click="OnSave" IsDefault="True" />
|
||||
</StackPanel>
|
||||
</StackPanel>
|
||||
</Window>
|
||||
@@ -20,19 +20,14 @@
|
||||
Click="OnCancel" IsCancel="True" />
|
||||
</StackPanel>
|
||||
<StackPanel Spacing="2">
|
||||
<TextBlock TextWrapping="Wrap" FontSize="11" Opacity="0.75"
|
||||
Text="Whoever is at the radio. The callsign goes against every contact logged from now on, and the windows, colours and recordings are this operator's own." />
|
||||
<TextBlock Name="RecentLabel" Classes="label" Text="Recent" />
|
||||
<UniformGrid Name="RecentPanel" Columns="3" />
|
||||
<TextBlock Classes="label" Text="Operator callsign" />
|
||||
<Grid ColumnDefinitions="*,6,150">
|
||||
<TextBox Name="CallBox" />
|
||||
<ComboBox Name="KnownBox" Grid.Column="2" HorizontalAlignment="Stretch"
|
||||
SelectionChanged="OnPickedKnown" PlaceholderText="known" />
|
||||
</Grid>
|
||||
<TextBlock Classes="label" Text="Recordings folder (the voice keyer's wav files)" />
|
||||
<Grid ColumnDefinitions="*,6,Auto">
|
||||
<TextBox Name="WavBox" />
|
||||
<Button Grid.Column="2" Content="Browse…" Click="OnBrowseWav" />
|
||||
</Grid>
|
||||
<TextBlock Name="AboutText" FontSize="11" Opacity="0.75" Margin="0,10,0,0"
|
||||
TextWrapping="Wrap" />
|
||||
</StackPanel>
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
using Avalonia;
|
||||
using Avalonia.Controls;
|
||||
using Avalonia.Interactivity;
|
||||
using Avalonia.Platform.Storage;
|
||||
using Avalonia.Layout;
|
||||
using Nonemm.App.Configuration;
|
||||
|
||||
namespace Nonemm.App.Dialogs;
|
||||
@@ -14,15 +15,19 @@ public sealed record OperatorChoice(StoredOperator Operator, bool IsRemoval);
|
||||
/// callsign is not in the list yet is made by typing it.
|
||||
public sealed partial class OperatorDialog : Window
|
||||
{
|
||||
private readonly IReadOnlyList<StoredOperator> known;
|
||||
/// How many of the operators who were last at the radio get a button. Six
|
||||
/// fits two rows of three, which covers a weekend's shift roster.
|
||||
private const int RecentCount = 6;
|
||||
|
||||
private readonly Settings settings;
|
||||
|
||||
public OperatorDialog(Settings settings)
|
||||
{
|
||||
known = settings.Operators;
|
||||
this.settings = settings;
|
||||
InitializeComponent();
|
||||
KnownBox.ItemsSource = known.Select(o => o.Callsign).ToList();
|
||||
KnownBox.ItemsSource = settings.Operators.Select(o => o.Callsign).ToList();
|
||||
CallBox.Text = settings.CurrentOperator;
|
||||
WavBox.Text = Find(settings.CurrentOperator)?.WavPath ?? "";
|
||||
ShowRecent();
|
||||
ShowWhatIsKept();
|
||||
// the callsign is all most operators type here, so the cursor starts in
|
||||
// it and Enter closes the dialog
|
||||
@@ -35,6 +40,26 @@ public sealed partial class OperatorDialog : Window
|
||||
};
|
||||
}
|
||||
|
||||
/// A button for each of the last few operators at the radio, newest first.
|
||||
/// One click changes to that operator.
|
||||
private void ShowRecent()
|
||||
{
|
||||
StoredOperator[] recent = [.. settings.RecentOperators(RecentCount)];
|
||||
RecentLabel.IsVisible = recent.Length > 0;
|
||||
foreach (StoredOperator stored in recent)
|
||||
{
|
||||
Button button = new()
|
||||
{
|
||||
Content = stored.Callsign,
|
||||
Margin = new Thickness(0, 2, 4, 2),
|
||||
HorizontalAlignment = HorizontalAlignment.Stretch,
|
||||
HorizontalContentAlignment = HorizontalAlignment.Center,
|
||||
};
|
||||
button.Click += (_, _) => Close(new OperatorChoice(stored, IsRemoval: false));
|
||||
RecentPanel.Children.Add(button);
|
||||
}
|
||||
}
|
||||
|
||||
/// The operator as the dialog leaves him: the callsign typed, keeping
|
||||
/// whatever was stored for him before.
|
||||
private StoredOperator Picked
|
||||
@@ -43,12 +68,12 @@ public sealed partial class OperatorDialog : Window
|
||||
{
|
||||
string callsign = (CallBox.Text ?? "").Trim().ToUpperInvariant();
|
||||
StoredOperator stored = Find(callsign) ?? new StoredOperator();
|
||||
return stored with { Callsign = callsign, WavPath = (WavBox.Text ?? "").Trim() };
|
||||
return stored with { Callsign = callsign };
|
||||
}
|
||||
}
|
||||
|
||||
private StoredOperator? Find(string callsign) =>
|
||||
known.FirstOrDefault(o => string.Equals(o.Callsign, callsign.Trim(), StringComparison.OrdinalIgnoreCase));
|
||||
settings.Operators.FirstOrDefault(o => string.Equals(o.Callsign, callsign.Trim(), StringComparison.OrdinalIgnoreCase));
|
||||
|
||||
private void OnPickedKnown(object? sender, SelectionChangedEventArgs e)
|
||||
{
|
||||
@@ -57,7 +82,6 @@ public sealed partial class OperatorDialog : Window
|
||||
return;
|
||||
}
|
||||
CallBox.Text = callsign;
|
||||
WavBox.Text = Find(callsign)?.WavPath ?? "";
|
||||
ShowWhatIsKept();
|
||||
}
|
||||
|
||||
@@ -65,21 +89,11 @@ public sealed partial class OperatorDialog : Window
|
||||
{
|
||||
StoredOperator? stored = Find(CallBox.Text ?? "");
|
||||
AboutText.Text = stored is null
|
||||
? "A new operator: the windows and colours on the screen now become his."
|
||||
? "new operator"
|
||||
: $"{stored.Windows.Count} window positions kept"
|
||||
+ (stored.Theme.Length > 0 ? $", {stored.Theme} colours" : ", the colours as they are");
|
||||
}
|
||||
|
||||
private async void OnBrowseWav(object? sender, RoutedEventArgs e)
|
||||
{
|
||||
IReadOnlyList<IStorageFolder> picked = await StorageProvider.OpenFolderPickerAsync(
|
||||
new FolderPickerOpenOptions { Title = "The operator's recordings", AllowMultiple = false });
|
||||
if (picked.Count > 0)
|
||||
{
|
||||
WavBox.Text = picked[0].Path.LocalPath;
|
||||
}
|
||||
}
|
||||
|
||||
private void OnOk(object? sender, RoutedEventArgs e)
|
||||
{
|
||||
if (Picked.Callsign.Length > 0)
|
||||
|
||||
@@ -33,19 +33,36 @@
|
||||
</Grid>
|
||||
<TextBlock Text="The spacing goes between the fields of a QTC line, written N1MM's way with S for a space. The three again messages go out on shift and Enter in that box while taking traffic down. TU goes out when the window closes after reading a series out; empty sends nothing."
|
||||
FontSize="11" Opacity="0.7" TextWrapping="Wrap" Margin="0,-2,0,0" />
|
||||
<TextBlock Text="RTTY messages" FontWeight="Bold" Margin="0,10,0,0" />
|
||||
<Grid ColumnDefinitions="Auto,*" RowDefinitions="Auto,Auto,Auto">
|
||||
<TextBlock Text="Line spacing" VerticalAlignment="Center" Margin="0,2,8,2" />
|
||||
<TextBox Grid.Column="1" Name="RttySpacingBox" Margin="0,2" />
|
||||
<TextBlock Text="RTTY messages, reading traffic out" FontWeight="Bold" Margin="0,10,0,0" />
|
||||
<Grid ColumnDefinitions="Auto,*" RowDefinitions="Auto,Auto,Auto,Auto,Auto">
|
||||
<TextBlock Text="R U QRV" VerticalAlignment="Center" Margin="0,2,8,2" />
|
||||
<TextBox Grid.Column="1" Name="RttyAreYouReadyBox" Margin="0,2" />
|
||||
<TextBlock Grid.Row="1" Text="Send All heading" VerticalAlignment="Center" Margin="0,2,8,2" />
|
||||
<TextBox Grid.Row="1" Grid.Column="1" Name="SendAllHeadingBox" Margin="0,2" />
|
||||
<TextBlock Grid.Row="2" Text="Send All ending" VerticalAlignment="Center" Margin="0,2,8,2" />
|
||||
<TextBox Grid.Row="2" Grid.Column="1" Name="SendAllEndingBox" Margin="0,2" />
|
||||
<TextBlock Grid.Row="3" Text="Save" VerticalAlignment="Center" Margin="0,2,8,2" />
|
||||
<TextBox Grid.Row="3" Grid.Column="1" Name="RttySendSaveBox" Margin="0,2" />
|
||||
<TextBlock Grid.Row="4" Text="Line spacing" VerticalAlignment="Center" Margin="0,2,8,2" />
|
||||
<TextBox Grid.Row="4" Grid.Column="1" Name="RttySpacingBox" Margin="0,2" />
|
||||
</Grid>
|
||||
<TextBlock Text="These go out when the All button reads a whole series out on RTTY. The spacing goes between the lines, not between the fields of one — use {ENTER} or {ENTERLF} for a carriage return. {QTC} stands for the header of the series, and the other function key macros work as well."
|
||||
<TextBlock Text="The spacing goes between the lines of a series, not between the fields of one — use {ENTER} or {ENTERLF} for a carriage return. {QTC} stands for the header of the series, and the other function key macros work as well."
|
||||
FontSize="11" Opacity="0.7" TextWrapping="Wrap" Margin="0,-2,0,0" />
|
||||
<TextBlock Text="RTTY messages, taking traffic down" FontWeight="Bold" Margin="0,10,0,0" />
|
||||
<Grid ColumnDefinitions="Auto,*" RowDefinitions="Auto,Auto,Auto,Auto">
|
||||
<TextBlock Text="RX Ready" VerticalAlignment="Center" Margin="0,2,8,2" />
|
||||
<TextBox Grid.Column="1" Name="RttyReadyBox" Margin="0,2" />
|
||||
<TextBlock Grid.Row="1" Text="All Agn" VerticalAlignment="Center" Margin="0,2,8,2" />
|
||||
<TextBox Grid.Row="1" Grid.Column="1" Name="RttyAllAgainBox" Margin="0,2" />
|
||||
<TextBlock Grid.Row="2" Text="Agn n" VerticalAlignment="Center" Margin="0,2,8,2" />
|
||||
<TextBox Grid.Row="2" Grid.Column="1" Name="RttyLineAgainBox" Margin="0,2" />
|
||||
<TextBlock Grid.Row="3" Text="Save" VerticalAlignment="Center" Margin="0,2,8,2" />
|
||||
<TextBox Grid.Row="3" Grid.Column="1" Name="RttySaveBox" Margin="0,2" />
|
||||
</Grid>
|
||||
<TextBlock Text="$ in the Agn n message stands for the line being asked for, so AGN QTC: $ $ $ goes out as AGN QTC: 5 5 5. Each of these keys the transmitter, sends the message and drops it again; an empty one sends nothing."
|
||||
FontSize="11" Opacity="0.7" TextWrapping="Wrap" Margin="0,-2,0,0" />
|
||||
<TextBlock Name="MissingText" FontSize="11" Opacity="0.7" TextWrapping="Wrap" Margin="0,6,0,0"
|
||||
Text="N1MM's SSB recordings are left out: playing those needs a voice keyer, and this program has none. So are its RTTY messages for the station taking traffic down — RX Ready, All Agn, Agn and Save — which are typed into the digital window's transmit pane here." />
|
||||
Text="N1MM's SSB recordings are left out: playing those needs a voice keyer, and this program has none." />
|
||||
<StackPanel Orientation="Horizontal" HorizontalAlignment="Right" Spacing="6" Margin="0,8,0,0">
|
||||
<Button Content="Cancel" Click="OnCancel" />
|
||||
<Button Content="Save" Click="OnSave" IsDefault="True" />
|
||||
|
||||
@@ -27,6 +27,12 @@ public sealed partial class QtcSetupDialog : Window
|
||||
RttySpacingBox.Text = settings.QtcRttySpacing;
|
||||
SendAllHeadingBox.Text = settings.QtcRttySendAllHeading;
|
||||
SendAllEndingBox.Text = settings.QtcRttySendAllEnding;
|
||||
RttyAreYouReadyBox.Text = settings.QtcRttyAreYouReady;
|
||||
RttySendSaveBox.Text = settings.QtcRttySendSave;
|
||||
RttyReadyBox.Text = settings.QtcRttyReady;
|
||||
RttyAllAgainBox.Text = settings.QtcRttyAllAgain;
|
||||
RttyLineAgainBox.Text = settings.QtcRttyLineAgain;
|
||||
RttySaveBox.Text = settings.QtcRttySave;
|
||||
}
|
||||
|
||||
private void OnSave(object? sender, RoutedEventArgs e) => Close(settings with
|
||||
@@ -46,6 +52,12 @@ public sealed partial class QtcSetupDialog : Window
|
||||
QtcRttySpacing = RttySpacingBox.Text ?? "",
|
||||
QtcRttySendAllHeading = SendAllHeadingBox.Text ?? "",
|
||||
QtcRttySendAllEnding = SendAllEndingBox.Text ?? "",
|
||||
QtcRttyAreYouReady = RttyAreYouReadyBox.Text ?? "",
|
||||
QtcRttySendSave = RttySendSaveBox.Text ?? "",
|
||||
QtcRttyReady = RttyReadyBox.Text ?? "",
|
||||
QtcRttyAllAgain = RttyAllAgainBox.Text ?? "",
|
||||
QtcRttyLineAgain = RttyLineAgainBox.Text ?? "",
|
||||
QtcRttySave = RttySaveBox.Text ?? "",
|
||||
});
|
||||
|
||||
private void OnCancel(object? sender, RoutedEventArgs e) => Close(null);
|
||||
|
||||
@@ -28,6 +28,21 @@
|
||||
<TextBox Name="BoxPortBox" />
|
||||
<TextBlock TextWrapping="Wrap" FontSize="11" Opacity="0.75" Margin="0,8,0,0"
|
||||
Text="With a second radio the station is SO2R: both are read and both show on the bandmap, but only the one you are on drives the entry window. Ctrl+Tab moves you to the other, and Ctrl+Shift+Tab puts both in the headphones. An OTRSP box follows, routing the key and the headphones." />
|
||||
<Separator Margin="0,10,0,4" />
|
||||
<TextBlock TextWrapping="Wrap" FontSize="11" Opacity="0.75"
|
||||
Text="Mirror a radio: record the frequency, mode and split of a radio on another Nonemm or N1MM computer as this computer's own, when this computer has no port to the radio. The other computer must send Radio data to this computer (Config > Broadcast Data). Nothing is sent back, and no radio is controlled." />
|
||||
<CheckBox Name="MirrorEnabledCheck" Content="Mirror a radio from another computer" />
|
||||
<Grid ColumnDefinitions="200,*" RowDefinitions="Auto,Auto,Auto,Auto" RowSpacing="6">
|
||||
<TextBlock Text="UDP port to listen on" VerticalAlignment="Center" />
|
||||
<TextBox Name="MirrorPortBox" Grid.Column="1" />
|
||||
<TextBlock Grid.Row="1" Text="Computer name (empty: any)" VerticalAlignment="Center" />
|
||||
<TextBox Name="MirrorStationBox" Grid.Row="1" Grid.Column="1" />
|
||||
<TextBlock Grid.Row="2" Text="Radio on the other computer" VerticalAlignment="Center" />
|
||||
<TextBox Name="MirrorSourceBox" Grid.Row="2" Grid.Column="1" />
|
||||
<TextBlock Grid.Row="3" Text="Radio on this computer" VerticalAlignment="Center" />
|
||||
<TextBox Name="MirrorTargetBox" Grid.Row="3" Grid.Column="1" />
|
||||
</Grid>
|
||||
<TextBlock Name="ProblemText" TextWrapping="Wrap" Foreground="OrangeRed" IsVisible="False" />
|
||||
<StackPanel Orientation="Horizontal" HorizontalAlignment="Right" Spacing="6" Margin="0,8,0,0">
|
||||
<Button Content="Cancel" Click="OnCancel" />
|
||||
<Button Content="Save" Click="OnSave" IsDefault="True" />
|
||||
|
||||
@@ -4,7 +4,7 @@ using Nonemm.App.Configuration;
|
||||
|
||||
namespace Nonemm.App.Dialogs;
|
||||
|
||||
/// The radios on the desk, one rigctld each.
|
||||
/// The radios on the desk, one rigctld each, and the radio mirror.
|
||||
public sealed partial class RadioDialog : Window
|
||||
{
|
||||
private const int DefaultPort = 4532;
|
||||
@@ -18,6 +18,11 @@ public sealed partial class RadioDialog : Window
|
||||
Show(0, HostBox, PortBox, EnabledBox);
|
||||
Show(1, SecondHostBox, SecondPortBox, SecondEnabledBox);
|
||||
BoxPortBox.Text = settings.So2rBoxPort;
|
||||
MirrorEnabledCheck.IsChecked = settings.MirrorRadioEnabled;
|
||||
MirrorPortBox.Text = settings.MirrorRadioPort.ToString();
|
||||
MirrorStationBox.Text = settings.MirrorRadioStation;
|
||||
MirrorSourceBox.Text = settings.MirrorRadioSource.ToString();
|
||||
MirrorTargetBox.Text = settings.MirrorRadioTarget.ToString();
|
||||
}
|
||||
|
||||
private void Show(int at, TextBox host, TextBox port, CheckBox enabled)
|
||||
@@ -30,15 +35,40 @@ public sealed partial class RadioDialog : Window
|
||||
enabled.IsChecked = radio.IsEnabled;
|
||||
}
|
||||
|
||||
private void OnSave(object? sender, RoutedEventArgs e) => Close(settings with
|
||||
private void OnSave(object? sender, RoutedEventArgs e)
|
||||
{
|
||||
Radios =
|
||||
[
|
||||
Read(HostBox, PortBox, EnabledBox),
|
||||
Read(SecondHostBox, SecondPortBox, SecondEnabledBox),
|
||||
],
|
||||
So2rBoxPort = (BoxPortBox.Text ?? "").Trim(),
|
||||
});
|
||||
List<string> problems = [];
|
||||
if (!int.TryParse(MirrorPortBox.Text, out int mirrorPort) || mirrorPort is < 1 or > 65535)
|
||||
{
|
||||
problems.Add("The mirror port must be a number from 1 to 65535.");
|
||||
}
|
||||
bool isSourceValid = int.TryParse(MirrorSourceBox.Text, out int source) && source is 1 or 2;
|
||||
bool isTargetValid = int.TryParse(MirrorTargetBox.Text, out int target) && target is 1 or 2;
|
||||
if (!isSourceValid || !isTargetValid)
|
||||
{
|
||||
problems.Add("The mirror radio numbers must be 1 or 2.");
|
||||
}
|
||||
if (problems.Count > 0)
|
||||
{
|
||||
ProblemText.Text = string.Join("\n", problems);
|
||||
ProblemText.IsVisible = true;
|
||||
return;
|
||||
}
|
||||
Close(settings with
|
||||
{
|
||||
Radios =
|
||||
[
|
||||
Read(HostBox, PortBox, EnabledBox),
|
||||
Read(SecondHostBox, SecondPortBox, SecondEnabledBox),
|
||||
],
|
||||
So2rBoxPort = (BoxPortBox.Text ?? "").Trim(),
|
||||
MirrorRadioEnabled = MirrorEnabledCheck.IsChecked == true,
|
||||
MirrorRadioPort = mirrorPort,
|
||||
MirrorRadioStation = (MirrorStationBox.Text ?? "").Trim(),
|
||||
MirrorRadioSource = source,
|
||||
MirrorRadioTarget = target,
|
||||
});
|
||||
}
|
||||
|
||||
private static StoredRadio Read(TextBox host, TextBox port, CheckBox enabled) => new()
|
||||
{
|
||||
|
||||
@@ -0,0 +1,21 @@
|
||||
<Window xmlns="https://github.com/avaloniaui"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
x:Class="Nonemm.App.Dialogs.StationsConfigDialog"
|
||||
Title="Stations Configuration" Width="440" SizeToContent="Height"
|
||||
WindowStartupLocation="CenterOwner" CanResize="False">
|
||||
<StackPanel Margin="14" Spacing="6">
|
||||
<Grid ColumnDefinitions="*,8,110" RowDefinitions="Auto,Auto">
|
||||
<TextBlock Text="This station's name" FontSize="11" Opacity="0.7" Margin="0,6,0,1" />
|
||||
<TextBox Name="NameBox" Grid.Row="1" />
|
||||
<TextBlock Grid.Column="2" Text="Port" FontSize="11" Opacity="0.7" Margin="0,6,0,1" />
|
||||
<TextBox Name="PortBox" Grid.Row="1" Grid.Column="2" />
|
||||
</Grid>
|
||||
<TextBlock Text="Stations to reach by address, one per line, as NAME@address" FontSize="11" Opacity="0.7" Margin="0,6,0,1" />
|
||||
<TextBox Name="LinkPeersBox" AcceptsReturn="True" Height="60" PlaceholderText="RUN-PC@192.168.1.11" />
|
||||
<CheckBox Name="LinkEnabledBox" Content="Share contacts with the other logging computers" Margin="0,6,0,0" />
|
||||
<StackPanel Orientation="Horizontal" HorizontalAlignment="Right" Spacing="6" Margin="0,8,0,0">
|
||||
<Button Content="Cancel" Click="OnCancel" />
|
||||
<Button Content="Save" Click="OnSave" IsDefault="True" />
|
||||
</StackPanel>
|
||||
</StackPanel>
|
||||
</Window>
|
||||
+2
-21
@@ -4,11 +4,11 @@ using Nonemm.App.Configuration;
|
||||
|
||||
namespace Nonemm.App.Dialogs;
|
||||
|
||||
public sealed partial class NetworkDialog : Window
|
||||
public sealed partial class StationsConfigDialog : Window
|
||||
{
|
||||
private readonly Settings settings;
|
||||
|
||||
public NetworkDialog(Settings settings)
|
||||
public StationsConfigDialog(Settings settings)
|
||||
{
|
||||
this.settings = settings;
|
||||
InitializeComponent();
|
||||
@@ -16,33 +16,14 @@ public sealed partial class NetworkDialog : Window
|
||||
? settings.NetworkStationName
|
||||
: Environment.MachineName;
|
||||
PortBox.Text = settings.NetworkPort.ToString();
|
||||
PeersBox.Text = string.Join("\n", settings.NetworkPeers);
|
||||
EnabledBox.IsChecked = settings.NetworkEnabled;
|
||||
StationNumberBox.Text = settings.StationNumber.ToString();
|
||||
LinkPortBox.Text = settings.StationLinkPort.ToString();
|
||||
VersionBox.Text = settings.StationLinkVersion;
|
||||
LinkPeersBox.Text = string.Join("\n", settings.StationLinkPeers);
|
||||
LinkEnabledBox.IsChecked = settings.StationLinkEnabled;
|
||||
}
|
||||
|
||||
|
||||
private void OnSave(object? sender, RoutedEventArgs e) => Close(settings with
|
||||
{
|
||||
NetworkStationName = (NameBox.Text ?? "").Trim(),
|
||||
NetworkPort = int.TryParse(PortBox.Text, out int port) ? port : 12060,
|
||||
NetworkPeers = (PeersBox.Text ?? "")
|
||||
.Split('\n', StringSplitOptions.RemoveEmptyEntries)
|
||||
.Select(l => l.Trim())
|
||||
.Where(l => l.Length > 0)
|
||||
.ToList(),
|
||||
NetworkEnabled = EnabledBox.IsChecked == true,
|
||||
StationNumber = int.TryParse(StationNumberBox.Text, out int number)
|
||||
? Math.Clamp(number, 1, 99)
|
||||
: settings.StationNumber,
|
||||
StationLinkPort = int.TryParse(LinkPortBox.Text, out int linkPort)
|
||||
? linkPort
|
||||
: settings.StationLinkPort,
|
||||
StationLinkVersion = (VersionBox.Text ?? "").Trim(),
|
||||
StationLinkPeers = Lines(LinkPeersBox.Text),
|
||||
StationLinkEnabled = LinkEnabledBox.IsChecked == true,
|
||||
});
|
||||
@@ -22,6 +22,8 @@
|
||||
</ItemsPanelTemplate>
|
||||
</ItemsControl.ItemsPanel>
|
||||
</ItemsControl>
|
||||
<CheckBox Name="MinimizeBox" Content="Minimize and restore all windows with the entry window" Margin="0,8,0,0" />
|
||||
<CheckBox Name="RaiseBox" Content="Raise all windows together when one is activated" />
|
||||
</StackPanel>
|
||||
</DockPanel>
|
||||
</Window>
|
||||
|
||||
@@ -2,6 +2,7 @@ using Avalonia.Controls;
|
||||
using Avalonia.Interactivity;
|
||||
using Avalonia.Layout;
|
||||
using Avalonia.Media;
|
||||
using Nonemm.App.Configuration;
|
||||
using Nonemm.App.Theming;
|
||||
|
||||
namespace Nonemm.App.Dialogs;
|
||||
@@ -11,9 +12,15 @@ namespace Nonemm.App.Dialogs;
|
||||
/// shows what each one paints a station.
|
||||
public sealed partial class ThemeDialog : Window
|
||||
{
|
||||
public ThemeDialog(string current)
|
||||
private readonly Settings settings;
|
||||
|
||||
public ThemeDialog(Settings settings)
|
||||
{
|
||||
this.settings = settings;
|
||||
string current = settings.Theme;
|
||||
InitializeComponent();
|
||||
MinimizeBox.IsChecked = settings.MinimizeWindowsTogether;
|
||||
RaiseBox.IsChecked = settings.RaiseWindowsTogether;
|
||||
ThemeBox.ItemsSource = Themes.All.Select(Label).ToList();
|
||||
ThemeBox.SelectedIndex = Math.Max(0, Themes.All.ToList().FindIndex(t => t.Name == Themes.Find(current).Name));
|
||||
}
|
||||
@@ -33,13 +40,15 @@ public sealed partial class ThemeDialog : Window
|
||||
{
|
||||
Theme theme = Picked;
|
||||
AboutText.Text = "What a station is painted in the callsign box, left to right: worth " +
|
||||
"working, one new multiplier, more than one, a dupe.";
|
||||
"working, one new multiplier, more than one, a dupe, and in WAE a dupe " +
|
||||
"with QTC traffic still to exchange.";
|
||||
Swatches.ItemsSource = new[]
|
||||
{
|
||||
Swatch(theme.Worth, theme.FieldBackground),
|
||||
Swatch(theme.Multiplier, theme.FieldBackground),
|
||||
Swatch(theme.Multipliers, theme.FieldBackground),
|
||||
Swatch(theme.Dupe, theme.FieldBackground),
|
||||
Swatch(theme.QtcCallsign, theme.FieldBackground),
|
||||
};
|
||||
}
|
||||
|
||||
@@ -59,7 +68,12 @@ public sealed partial class ThemeDialog : Window
|
||||
},
|
||||
};
|
||||
|
||||
private void OnOk(object? sender, RoutedEventArgs e) => Close(Picked.Name);
|
||||
private void OnOk(object? sender, RoutedEventArgs e) => Close(settings with
|
||||
{
|
||||
Theme = Picked.Name,
|
||||
MinimizeWindowsTogether = MinimizeBox.IsChecked == true,
|
||||
RaiseWindowsTogether = RaiseBox.IsChecked == true,
|
||||
});
|
||||
|
||||
private void OnCancel(object? sender, RoutedEventArgs e) => Close(null);
|
||||
}
|
||||
|
||||
+19
-12
@@ -28,20 +28,27 @@ public static class Messages
|
||||
F12 Wipe,
|
||||
""";
|
||||
|
||||
/// Phone messages name a recording to play; the text is what would be said.
|
||||
/// Phone messages name a recording to play, which is what N1MM's own SSB
|
||||
/// file holds. `{WAVDIR}` is the folder named after whoever is at the
|
||||
/// microphone, so each operator's own voice goes out. The recordings are
|
||||
/// made in the voice keyer window, which lists these names.
|
||||
///
|
||||
/// F5 is empty, as it is in N1MM's file: sending the other station's call
|
||||
/// needs a recording per letter, which this program does not play.
|
||||
public const string DefaultPhone =
|
||||
"""
|
||||
# Phone function keys.
|
||||
F1 CQ,CQ CONTEST {MYCALL}
|
||||
F2 Exch,{EXCH}
|
||||
F3 TU,THANK YOU {MYCALL}
|
||||
F4 MyCall,{MYCALL}
|
||||
F5 HisCall,!
|
||||
F6 QSO B4,QSO BEFORE
|
||||
F7 ?,PLEASE REPEAT
|
||||
F8 Agn,AGAIN
|
||||
F9 Nr?,NUMBER PLEASE
|
||||
F10 Call?,YOUR CALL PLEASE
|
||||
# Phone function keys. Each one names a recording under the Wav folder;
|
||||
# {WAVDIR} is the folder of whoever is at the microphone.
|
||||
F1 CQ,{WAVDIR}\Cq.wav
|
||||
F2 Exch,{WAVDIR}\Exchange.wav
|
||||
F3 TU,{WAVDIR}\Thanks.wav
|
||||
F4 MyCall,{WAVDIR}\MyCall.wav
|
||||
F5 HisCall,
|
||||
F6 QSO B4,{WAVDIR}\QsoB4.wav
|
||||
F7 ?,{WAVDIR}\Repeat.wav
|
||||
F8 Agn,{WAVDIR}\AllAgain.wav
|
||||
F9 Nr?,{WAVDIR}\NumberAgain.wav
|
||||
F10 Call?,{WAVDIR}\CallAgain.wav
|
||||
F11 Spot,
|
||||
F12 Wipe,
|
||||
""";
|
||||
|
||||
@@ -0,0 +1,56 @@
|
||||
using Avalonia.Threading;
|
||||
using Nonemm.Core;
|
||||
using Nonemm.Network;
|
||||
|
||||
namespace Nonemm.App;
|
||||
|
||||
/// The log as a resync reads it. The link asks these questions on a socket
|
||||
/// thread and the log is only touched where the windows are, so every answer is
|
||||
/// fetched on the window thread and waited for.
|
||||
///
|
||||
/// The wait is short — a block is an hour of contacts out of a list already in
|
||||
/// memory — and nothing on the window thread waits on the socket thread, so
|
||||
/// there is nothing here for the two to deadlock over.
|
||||
internal sealed class SessionContactLog : ContactLog
|
||||
{
|
||||
private readonly AppSession session;
|
||||
|
||||
internal SessionContactLog(AppSession session) => this.session = session;
|
||||
|
||||
public string ContestName => Ask(() => session.Logging?.Contest.Name ?? "");
|
||||
|
||||
public string MyCall => Ask(() => session.Settings.Station.Callsign);
|
||||
|
||||
public string ContestSubType => Ask(() => session.Logging?.Instance.SubType ?? "");
|
||||
|
||||
public string CountryFileVersion => Ask(() => session.Countries?.Version ?? "");
|
||||
|
||||
public IReadOnlyList<Qso> Contacts(string computerName, DateTime fromUtc, TimeSpan length) =>
|
||||
Ask(() => session.Logging is not { } logging
|
||||
? []
|
||||
: logging.Log.Qsos
|
||||
.Where(q =>
|
||||
string.Equals(q.StationName, computerName, StringComparison.OrdinalIgnoreCase)
|
||||
&& q.TimestampUtc >= fromUtc
|
||||
&& q.TimestampUtc < fromUtc + length)
|
||||
.OrderBy(q => q.TimestampUtc)
|
||||
.ThenBy(q => q.Call.Text, StringComparer.Ordinal)
|
||||
.ToList());
|
||||
|
||||
public DateTime LastContactUtc(string computerName) =>
|
||||
Ask(() => session.Logging is not { } logging
|
||||
? default
|
||||
: logging.Log.Qsos
|
||||
.Where(q => string.Equals(q.StationName, computerName, StringComparison.OrdinalIgnoreCase))
|
||||
.Select(q => q.TimestampUtc)
|
||||
.DefaultIfEmpty(default)
|
||||
.Max());
|
||||
|
||||
public DateTime FirstContactUtc =>
|
||||
Ask(() => session.Logging is not { } logging
|
||||
? default
|
||||
: logging.Log.Qsos.Select(q => q.TimestampUtc).DefaultIfEmpty(default).Min());
|
||||
|
||||
private static T Ask<T>(Func<T> question) =>
|
||||
Dispatcher.UIThread.CheckAccess() ? question() : Dispatcher.UIThread.Invoke(question);
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
using Avalonia.Media;
|
||||
|
||||
namespace Nonemm.App.Theming;
|
||||
|
||||
public static class Fonts
|
||||
{
|
||||
/// The generic name `monospace` only resolves through fontconfig, so on
|
||||
/// Windows it falls back to the proportional default. Each family listed is
|
||||
/// tried in order.
|
||||
public static readonly FontFamily Mono = new(
|
||||
"Cascadia Mono, Consolas, DejaVu Sans Mono, Liberation Mono, Courier New, monospace");
|
||||
}
|
||||
@@ -50,6 +50,10 @@ public sealed record Theme
|
||||
|
||||
public required Color DupeBackground { get; init; }
|
||||
|
||||
/// A station in WAE that still has QTC traffic to exchange, which N1MM
|
||||
/// calls "Color of a QTC callsign in the WAE contest" and paints black.
|
||||
public required Color QtcCallsign { get; init; }
|
||||
|
||||
/// The frequency we are calling CQ on.
|
||||
public required Color Cq { get; init; }
|
||||
|
||||
@@ -91,6 +95,7 @@ public sealed record Theme
|
||||
MultipliersBackground = Color.FromRgb(0x5F, 0xF1, 0x5F),
|
||||
Dupe = Color.FromRgb(0x80, 0x80, 0x80),
|
||||
DupeBackground = Color.FromRgb(0xD4, 0xD4, 0xD4),
|
||||
QtcCallsign = Color.FromRgb(0x00, 0x00, 0x00),
|
||||
Cq = Color.FromRgb(0xFF, 0x00, 0x00),
|
||||
GoodBackground = Color.FromRgb(0xD4, 0xF5, 0xD4),
|
||||
EmptyBackground = Color.FromRgb(0xFF, 0xE4, 0xE1),
|
||||
@@ -121,6 +126,9 @@ public sealed record Theme
|
||||
MultipliersBackground = Color.FromRgb(0x1B, 0x5E, 0x36),
|
||||
Dupe = Color.FromRgb(0x7F, 0x8C, 0x8D),
|
||||
DupeBackground = Color.FromRgb(0x3A, 0x40, 0x40),
|
||||
// black on a dark background cannot be read, so the dark theme takes
|
||||
// the other end of the same idea: a plain, bright callsign
|
||||
QtcCallsign = Color.FromRgb(0xEC, 0xF0, 0xF1),
|
||||
Cq = Color.FromRgb(0xE7, 0x4C, 0x3C),
|
||||
GoodBackground = Color.FromRgb(0x1E, 0x38, 0x24),
|
||||
EmptyBackground = Color.FromRgb(0x3A, 0x24, 0x24),
|
||||
|
||||
@@ -17,6 +17,10 @@ public static class Verdicts
|
||||
|
||||
public static IBrush Dupe => Themes.Brush(Themes.Current.Dupe);
|
||||
|
||||
/// A station with QTC traffic still to exchange, which is worth working in
|
||||
/// WAE even when it is a dupe.
|
||||
public static IBrush Traffic => Themes.Brush(Themes.Current.QtcCallsign);
|
||||
|
||||
public static IBrush Nothing => Dupe;
|
||||
|
||||
/// The frequency we are calling CQ on.
|
||||
@@ -28,11 +32,19 @@ public static class Verdicts
|
||||
|
||||
/// Nothing typed yet is the same colour as a station worth working: that is
|
||||
/// what N1MM leaves the callsign box.
|
||||
///
|
||||
/// WAE has two states the other contests do not, and N1MM paints them in
|
||||
/// colours it already has: a new station with QTC traffic still to
|
||||
/// exchange takes the more-than-one-multiplier colour, green, because WAE
|
||||
/// has no second multiplier to use it; a dupe with traffic left takes the
|
||||
/// QTC colour, black, rather than the grey of a dupe worth nothing. A new
|
||||
/// multiplier still wins over both.
|
||||
public static IBrush Colour(Verdict? verdict) =>
|
||||
verdict is null ? Worth
|
||||
: verdict.IsDupe ? Dupe
|
||||
: verdict.IsDupe ? verdict.TrafficLeft > 0 ? Traffic : Dupe
|
||||
: verdict.NewMultipliers.Count > 1 ? NewMultipliers
|
||||
: verdict.NewMultipliers.Count == 1 ? NewMultiplier
|
||||
: verdict.TrafficLeft > 0 ? NewMultipliers
|
||||
: Worth;
|
||||
|
||||
/// The same four states as backgrounds, which is what N1MM paints behind a
|
||||
@@ -54,13 +66,16 @@ public static class Verdicts
|
||||
{
|
||||
return "";
|
||||
}
|
||||
// a dupe in WAE is still worth working while it has traffic left, so
|
||||
// the line says how much rather than only that the station is worked
|
||||
string traffic = verdict.TrafficLeft > 0 ? $" · {verdict.TrafficLeft} QTCs left" : "";
|
||||
if (verdict.IsDupe)
|
||||
{
|
||||
return "dupe";
|
||||
return $"dupe{traffic}";
|
||||
}
|
||||
string points = $"{verdict.Points} {(verdict.Points == 1 ? "point" : "points")}";
|
||||
return verdict.IsNewMultiplier
|
||||
? $"{points} · new {string.Join(", ", verdict.NewMultipliers.Select(m => m.Value))}"
|
||||
: points;
|
||||
? $"{points} · new {string.Join(", ", verdict.NewMultipliers.Select(m => m.Value))}{traffic}"
|
||||
: $"{points}{traffic}";
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,162 @@
|
||||
using System.Globalization;
|
||||
using Avalonia.Media;
|
||||
using Nonemm.Core;
|
||||
using Nonemm.Session;
|
||||
using Nonemm.Spotting;
|
||||
|
||||
namespace Nonemm.App.Windows;
|
||||
|
||||
/// One line of the available window. The text properties are what the cells
|
||||
/// show; the typed ones are what the columns sort on, so 9 comes before 10.
|
||||
public sealed class AvailableRow
|
||||
{
|
||||
/// A spot this close to dropping off the bandmap gets a clock beside its
|
||||
/// time.
|
||||
private static readonly TimeSpan ExpiringWithin = TimeSpan.FromMinutes(3);
|
||||
|
||||
/// The sun marker shows from this long before sunrise or sunset until this
|
||||
/// long after.
|
||||
private static readonly TimeSpan SunWindow = TimeSpan.FromHours(1);
|
||||
|
||||
private readonly DateTime nowUtc;
|
||||
|
||||
public AvailableRow(
|
||||
AvailableStation station,
|
||||
string mode,
|
||||
DateTime nowUtc,
|
||||
TimeSpan? remaining,
|
||||
bool isPreferred,
|
||||
bool isTuned)
|
||||
{
|
||||
Station = station;
|
||||
Mode = mode;
|
||||
this.nowUtc = nowUtc;
|
||||
Remaining = remaining;
|
||||
IsPreferred = isPreferred;
|
||||
IsTuned = isTuned;
|
||||
SunMinutes = SunMinutesFor(station, nowUtc);
|
||||
}
|
||||
|
||||
public AvailableStation Station { get; }
|
||||
|
||||
public TimeSpan? Remaining { get; }
|
||||
|
||||
public bool IsPreferred { get; }
|
||||
|
||||
/// The radio is on this spot, which the window paints in reverse.
|
||||
public bool IsTuned { get; }
|
||||
|
||||
public string Call => Station.Spot.Call.Text;
|
||||
|
||||
public double Kilohertz => Station.Spot.Frequency.Kilohertz;
|
||||
|
||||
public string Frequency => Kilohertz.ToString("0.0", CultureInfo.InvariantCulture) + (Station.Spot.IsSplit ? " »" : "");
|
||||
|
||||
public string Mode { get; }
|
||||
|
||||
public int? Heading => Station.Heading is { } heading ? (int)Math.Round(heading) % 360 : null;
|
||||
|
||||
public string Direction => Heading is { } heading ? $"{heading}°" : "";
|
||||
|
||||
public int Multipliers => Station.NewMultipliers.Count;
|
||||
|
||||
/// A tick for a station that brings one multiplier and the number for one
|
||||
/// that brings more, which is what N1MM's Mlt column shows.
|
||||
public string Mark => Multipliers switch
|
||||
{
|
||||
0 => "",
|
||||
1 => "✔",
|
||||
_ => Multipliers.ToString(CultureInfo.InvariantCulture),
|
||||
};
|
||||
|
||||
public int? Snr => Station.Spot.Snr;
|
||||
|
||||
public string Noise => Snr?.ToString(CultureInfo.InvariantCulture) ?? "";
|
||||
|
||||
public DateTime AtUtc => Station.Spot.AtUtc;
|
||||
|
||||
public bool IsExpiring => Remaining is { } left && left <= ExpiringWithin;
|
||||
|
||||
public string Time => AtUtc.ToString("HH:mm", CultureInfo.InvariantCulture) + (IsExpiring ? " ◴" : "");
|
||||
|
||||
public string Spotter => Station.Spot.Spotter + (Station.Spot.IsSkimmer ? " (#)" : "");
|
||||
|
||||
public string Grid => Station.Grid;
|
||||
|
||||
/// Minutes to the next sunrise or sunset at the station, negative once it
|
||||
/// has passed, or `int.MaxValue` when the sun is not within the hour.
|
||||
public int SunMinutes { get; }
|
||||
|
||||
public string Sun => SunMinutes == int.MaxValue ? "" : SunText;
|
||||
|
||||
public int Points => Station.Verdict.Points;
|
||||
|
||||
public string Star => IsPreferred ? "★" : "";
|
||||
|
||||
public IBrush Colour => Verdicts.Colour(Station.Verdict);
|
||||
|
||||
public IBrush Background => Verdicts.Background(Station.Verdict);
|
||||
|
||||
/// What a refresh compares to see whether the list changed.
|
||||
public string Key =>
|
||||
$"{Call}|{Station.Band.Name}|{Frequency}|{Multipliers}|{Points}|{Spotter}|{Time}|{Sun}|{Star}|{IsTuned}";
|
||||
|
||||
/// The same hover text as the bandmap, with the split and the sun added.
|
||||
public string Tip
|
||||
{
|
||||
get
|
||||
{
|
||||
List<string> lines = [SpotDescription.Of(Station.Spot, nowUtc)];
|
||||
if (Station.Spot.IsSplit)
|
||||
{
|
||||
lines.Add($"listening on {Station.Spot.Qsx.Kilohertz:0.0}");
|
||||
}
|
||||
if (Sun.Length > 0)
|
||||
{
|
||||
lines.Add(SunNote);
|
||||
}
|
||||
return string.Join('\n', lines);
|
||||
}
|
||||
}
|
||||
|
||||
private string SunText
|
||||
{
|
||||
get
|
||||
{
|
||||
(bool isRise, int minutes) = Nearest(Station, nowUtc)!.Value;
|
||||
return $"{(isRise ? "▲" : "▼")}{minutes:+0;-0;0}";
|
||||
}
|
||||
}
|
||||
|
||||
private string SunNote
|
||||
{
|
||||
get
|
||||
{
|
||||
(bool isRise, int minutes) = Nearest(Station, nowUtc)!.Value;
|
||||
string when = minutes >= 0 ? $"in {minutes} min" : $"{-minutes} min ago";
|
||||
return $"{(isRise ? "sunrise" : "sunset")} at the station {when}";
|
||||
}
|
||||
}
|
||||
|
||||
private static int SunMinutesFor(AvailableStation station, DateTime nowUtc) =>
|
||||
Nearest(station, nowUtc) is { } near ? near.Minutes : int.MaxValue;
|
||||
|
||||
/// The sunrise or sunset within the hour either side, whichever is nearer.
|
||||
private static (bool IsRise, int Minutes)? Nearest(AvailableStation station, DateTime nowUtc)
|
||||
{
|
||||
(bool IsRise, int Minutes)? best = null;
|
||||
foreach ((bool isRise, DateTime? at) in new[] { (true, station.Path?.Sunrise), (false, station.Path?.Sunset) })
|
||||
{
|
||||
if (at is not { } time || (time - nowUtc).Duration() > SunWindow)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
int minutes = (int)Math.Round((time - nowUtc).TotalMinutes);
|
||||
if (best is null || Math.Abs(minutes) < Math.Abs(best.Value.Minutes))
|
||||
{
|
||||
best = (isRise, minutes);
|
||||
}
|
||||
}
|
||||
return best;
|
||||
}
|
||||
}
|
||||
@@ -1,15 +1,64 @@
|
||||
<local:RefreshableWindow xmlns="https://github.com/avaloniaui"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:local="using:Nonemm.App.Windows"
|
||||
xmlns:theming="using:Nonemm.App.Theming"
|
||||
x:Class="Nonemm.App.Windows.AvailableWindow"
|
||||
Title="Available mults and Qs" Width="620" Height="340">
|
||||
<DockPanel Margin="6">
|
||||
<StackPanel DockPanel.Dock="Top" Orientation="Horizontal" Spacing="10" Margin="0,0,0,6">
|
||||
<CheckBox Name="MultsOnlyBox" Content="Mults only" />
|
||||
<TextBlock Name="StatusText" FontSize="11" Opacity="0.7" VerticalAlignment="Center" />
|
||||
</StackPanel>
|
||||
<ScrollViewer>
|
||||
<Grid Name="Columns" />
|
||||
</ScrollViewer>
|
||||
Title="Available Mults and Qs" Width="900" Height="440">
|
||||
<DockPanel>
|
||||
<Grid DockPanel.Dock="Top" ColumnDefinitions="Auto,*,Auto" Margin="6,6,6,4">
|
||||
<Button Name="ModeButton" Grid.Column="0" VerticalAlignment="Top" MinWidth="60"
|
||||
HorizontalContentAlignment="Center" FontWeight="Bold"
|
||||
ToolTip.Tip="Mults shows only multipliers. Mults and Qs shows the stations that are only points as well. Click to switch." />
|
||||
<Grid Name="Summary" Grid.Column="1" HorizontalAlignment="Center" />
|
||||
<Button Name="FilterButton" Grid.Column="2" VerticalAlignment="Top" MinWidth="60"
|
||||
HorizontalContentAlignment="Center" FontWeight="Bold" Content="Bands Modes" />
|
||||
</Grid>
|
||||
<Grid>
|
||||
<DataGrid Name="Spots" IsReadOnly="True" GridLinesVisibility="None" CanUserSortColumns="True"
|
||||
CanUserReorderColumns="True" CanUserResizeColumns="True" SelectionMode="Single"
|
||||
FontFamily="{x:Static theming:Fonts.Mono}">
|
||||
<DataGrid.Styles>
|
||||
<Style Selector="DataGridCell TextBlock">
|
||||
<Setter Property="FontFamily" Value="{x:Static theming:Fonts.Mono}" />
|
||||
<Setter Property="FontSize" Value="{DynamicResource AvailableFontSize}" />
|
||||
<Setter Property="FontWeight" Value="Bold" />
|
||||
<Setter Property="Margin" Value="6,0" />
|
||||
</Style>
|
||||
<Style Selector="DataGridRow">
|
||||
<Setter Property="MinHeight" Value="0" />
|
||||
</Style>
|
||||
<Style Selector="DataGridCell">
|
||||
<Setter Property="MinHeight" Value="0" />
|
||||
<Setter Property="Padding" Value="0,2" />
|
||||
</Style>
|
||||
<Style Selector="DataGridColumnHeader">
|
||||
<Setter Property="MinHeight" Value="0" />
|
||||
<Setter Property="Padding" Value="6,0" />
|
||||
</Style>
|
||||
<Style Selector="DataGridColumnHeader /template/ Path#SortIcon">
|
||||
<Setter Property="Margin" Value="2,0,0,0" />
|
||||
</Style>
|
||||
<Style Selector="DataGridColumnHeader /template/ ContentPresenter">
|
||||
<Setter Property="FontWeight" Value="Bold" />
|
||||
<Setter Property="FontSize" Value="{DynamicResource AvailableFontSize}" />
|
||||
</Style>
|
||||
<!-- the picked line is ringed, not filled, so the colour that says
|
||||
what the station is worth stays readable -->
|
||||
<Style Selector="DataGridRow:selected /template/ Rectangle#BackgroundRectangle">
|
||||
<Setter Property="Fill" Value="Transparent" />
|
||||
<Setter Property="Stroke" Value="#40B8B8" />
|
||||
<Setter Property="StrokeThickness" Value="2" />
|
||||
</Style>
|
||||
<Style Selector="DataGridRow:pointerover /template/ Rectangle#BackgroundRectangle">
|
||||
<Setter Property="Opacity" Value="0.4" />
|
||||
</Style>
|
||||
<Style Selector="DataGridCell:current /template/ Rectangle">
|
||||
<Setter Property="IsVisible" Value="False" />
|
||||
</Style>
|
||||
</DataGrid.Styles>
|
||||
</DataGrid>
|
||||
<TextBlock Name="EmptyText" IsVisible="False" TextWrapping="Wrap" TextAlignment="Center"
|
||||
HorizontalAlignment="Center" VerticalAlignment="Center" Margin="40" IsHitTestVisible="False" />
|
||||
</Grid>
|
||||
</DockPanel>
|
||||
</local:RefreshableWindow>
|
||||
|
||||
@@ -1,110 +1,803 @@
|
||||
using System.ComponentModel;
|
||||
using Avalonia;
|
||||
using Avalonia.Collections;
|
||||
using Avalonia.Controls;
|
||||
using Avalonia.Data;
|
||||
using Avalonia.Input;
|
||||
using Avalonia.Interactivity;
|
||||
using Avalonia.Layout;
|
||||
using Avalonia.Media;
|
||||
using Avalonia.Threading;
|
||||
using Avalonia.VisualTree;
|
||||
using Nonemm.App.Configuration;
|
||||
using Nonemm.App.Dialogs;
|
||||
using Nonemm.Core;
|
||||
using Nonemm.Session;
|
||||
using Nonemm.Spotting;
|
||||
|
||||
namespace Nonemm.App.Windows;
|
||||
|
||||
/// What is left to work, a column per band: the multipliers at the top of each
|
||||
/// column, then the stations that are only points. Clicking one puts the radio
|
||||
/// there with the call in the entry window, the same as clicking a spot on the
|
||||
/// bandmap.
|
||||
/// The spotted stations that are not worked yet, as N1MM lays them out: a
|
||||
/// summary of how many multipliers and Qs each band holds, and under it one
|
||||
/// line per station that can be sorted on any column. Clicking a line puts the
|
||||
/// radio there with the call in the entry window, the same as clicking a spot
|
||||
/// on the bandmap.
|
||||
public sealed partial class AvailableWindow : RefreshableWindow
|
||||
{
|
||||
private const string HelpUrl = "https://n1mmwp.hamdocs.com/manual-windows/available-mults-and-qs-window/";
|
||||
|
||||
/// The list stops re-sorting for this long after the mouse touches it, so
|
||||
/// the line being aimed at does not move.
|
||||
private static readonly TimeSpan PauseFor = TimeSpan.FromSeconds(6);
|
||||
|
||||
/// The list is rebuilt this often with nothing else to cause it, so the sun
|
||||
/// times and the expiry clocks stay right.
|
||||
private const int RefreshEveryTicks = 15;
|
||||
|
||||
private readonly AppSession session;
|
||||
private readonly Action<Frequency, string> tune;
|
||||
private readonly DispatcherTimer timer = new() { Interval = TimeSpan.FromSeconds(1) };
|
||||
private readonly RateLimited limited;
|
||||
|
||||
/// What the entry window's changes ask for. The window's own controls and
|
||||
/// its timer call `Refresh` directly.
|
||||
public override void RefreshFromSession() => limited.Request();
|
||||
|
||||
/// The bands a click in the summary table limits the list to. Empty is
|
||||
/// every band.
|
||||
private readonly HashSet<Band> clicked = [];
|
||||
|
||||
private AvailableRow? menuRow;
|
||||
private bool menuOnHeader;
|
||||
private string shownKey = "";
|
||||
private string heading = "Available Mults and Qs";
|
||||
private string summaryKey = "";
|
||||
private DateTime pausedUntil = DateTime.MinValue;
|
||||
private bool refreshPending;
|
||||
private int ticks;
|
||||
|
||||
public AvailableWindow(AppSession session, Action<Frequency, string> tune)
|
||||
{
|
||||
this.session = session;
|
||||
this.tune = tune;
|
||||
InitializeComponent();
|
||||
MultsOnlyBox.IsCheckedChanged += (_, _) => Refresh();
|
||||
session.Bandmap.Changed += (_, _) => Dispatcher.UIThread.Post(Refresh);
|
||||
BuildColumns();
|
||||
ApplyColumns();
|
||||
ApplyFontSize();
|
||||
ColumnWidths.KeepHeadersReadable(Spots);
|
||||
DataGridColumn mlt = Spots.Columns.First(c => Header(c) == "Mlt");
|
||||
mlt.Width = new DataGridLength(mlt.MinWidth);
|
||||
_ = new FontZoom(this, new Settings().AvailableFontSize, () => session.Settings.AvailableFontSize, size =>
|
||||
{
|
||||
session.Save(session.Settings with { AvailableFontSize = size });
|
||||
ApplyFontSize();
|
||||
ColumnWidths.KeepHeadersReadable(Spots);
|
||||
Refresh();
|
||||
});
|
||||
ModeButton.Click += (_, _) => SetMultsOnly(!session.Settings.AvailableMultsOnly);
|
||||
FilterButton.Click += (_, _) => OpenFilterMenu();
|
||||
Spots.AddHandler(PointerPressedEvent, OnSpotPressed, RoutingStrategies.Tunnel);
|
||||
Spots.PointerMoved += (_, _) => Pause();
|
||||
Spots.PointerWheelChanged += (_, _) => Pause();
|
||||
Spots.PointerExited += (_, _) => Resume();
|
||||
Spots.LoadingRow += (_, e) => Paint(e.Row);
|
||||
Spots.ContextMenu = BuildMenu();
|
||||
// replacing the grid's rows is the dearest thing this window does, and
|
||||
// spots arrive and the radio moves many times a second
|
||||
limited = new RateLimited(TimeSpan.FromSeconds(2), Refresh, holdWhileTyping: true);
|
||||
EventHandler spotsChanged = (_, _) => limited.Request();
|
||||
session.Bandmap.Changed += spotsChanged;
|
||||
Closed += (_, _) =>
|
||||
{
|
||||
session.Bandmap.Changed -= spotsChanged;
|
||||
limited.Cancel();
|
||||
};
|
||||
timer.Tick += (_, _) => OnTick();
|
||||
timer.Start();
|
||||
Closed += (_, _) => timer.Stop();
|
||||
Refresh();
|
||||
}
|
||||
|
||||
private void ApplyFontSize()
|
||||
{
|
||||
Resources["AvailableFontSize"] = (double)session.Settings.AvailableFontSize;
|
||||
Spots.FontSize = session.Settings.AvailableFontSize;
|
||||
}
|
||||
|
||||
// ---- paused sorting
|
||||
|
||||
private bool IsPaused => DateTime.UtcNow < pausedUntil;
|
||||
|
||||
private void Pause()
|
||||
{
|
||||
pausedUntil = DateTime.UtcNow + PauseFor;
|
||||
ShowNotice();
|
||||
}
|
||||
|
||||
private void Resume()
|
||||
{
|
||||
pausedUntil = DateTime.MinValue;
|
||||
ShowNotice();
|
||||
if (refreshPending)
|
||||
{
|
||||
Refresh();
|
||||
}
|
||||
}
|
||||
|
||||
private void ShowNotice() => Title = IsPaused
|
||||
? $"{heading} Scrolling Pausing {Math.Max(1, (int)Math.Ceiling((pausedUntil - DateTime.UtcNow).TotalSeconds))} secs"
|
||||
: heading;
|
||||
|
||||
private void OnTick()
|
||||
{
|
||||
ShowNotice();
|
||||
if (IsPaused || OperatorActivity.IsTyping)
|
||||
{
|
||||
return;
|
||||
}
|
||||
if (refreshPending || ++ticks >= RefreshEveryTicks)
|
||||
{
|
||||
Refresh();
|
||||
}
|
||||
}
|
||||
|
||||
// ---- columns
|
||||
|
||||
private void BuildColumns()
|
||||
{
|
||||
Column("Call", nameof(AvailableRow.Call), r => r.Call);
|
||||
Column("Freq", nameof(AvailableRow.Frequency), r => r.Kilohertz);
|
||||
Column("Mode", nameof(AvailableRow.Mode), r => r.Mode);
|
||||
Column("Dir", nameof(AvailableRow.Direction), r => r.Heading ?? -1);
|
||||
Column("Mlt", nameof(AvailableRow.Mark), r => r.Multipliers);
|
||||
Column("SN", nameof(AvailableRow.Noise), r => r.Snr ?? int.MinValue);
|
||||
Column("TS", nameof(AvailableRow.Time), r => r.AtUtc);
|
||||
Column("Spotter", nameof(AvailableRow.Spotter), r => r.Spotter);
|
||||
Column("Grid", nameof(AvailableRow.Grid), r => r.Grid);
|
||||
Column("Sun", nameof(AvailableRow.Sun), r => r.SunMinutes);
|
||||
Column("Pts", nameof(AvailableRow.Points), r => r.Points);
|
||||
Column("★", nameof(AvailableRow.Star), r => r.IsPreferred ? 1 : 0);
|
||||
}
|
||||
|
||||
/// The grid sorts on the typed value behind the cell, not on its text.
|
||||
private void Column<T>(string header, string path, Func<AvailableRow, T> key)
|
||||
where T : IComparable<T>
|
||||
{
|
||||
Spots.Columns.Add(new DataGridTextColumn
|
||||
{
|
||||
Header = header,
|
||||
Width = DataGridLength.Auto,
|
||||
Binding = new Binding(path) { Mode = BindingMode.OneWay },
|
||||
CustomSortComparer = Comparer<AvailableRow>.Create((left, right) => key(left).CompareTo(key(right))),
|
||||
});
|
||||
}
|
||||
|
||||
private void ApplyColumns()
|
||||
{
|
||||
foreach (DataGridColumn column in Spots.Columns)
|
||||
{
|
||||
column.IsVisible = Header(column) == "Call" || !session.Settings.AvailableHiddenColumns.Contains(Header(column));
|
||||
}
|
||||
}
|
||||
|
||||
private static string Header(DataGridColumn column) => (string)column.Header!;
|
||||
|
||||
private void SetColumnShown(string header, bool shown)
|
||||
{
|
||||
List<string> hidden = [.. session.Settings.AvailableHiddenColumns.Where(h => h != header)];
|
||||
if (!shown)
|
||||
{
|
||||
hidden.Add(header);
|
||||
}
|
||||
session.Save(session.Settings with { AvailableHiddenColumns = hidden });
|
||||
ApplyColumns();
|
||||
}
|
||||
|
||||
private void AutoResizeColumns()
|
||||
{
|
||||
foreach (DataGridColumn column in Spots.Columns)
|
||||
{
|
||||
column.Width = DataGridLength.SizeToCells;
|
||||
}
|
||||
}
|
||||
|
||||
/// The list is sorted newest first on TS, which is the only order the
|
||||
/// QSY-after-logging option works in.
|
||||
private bool IsNewestFirst =>
|
||||
Spots.ItemsSource is DataGridCollectionView { SortDescriptions: [{ } first, ..] }
|
||||
&& first is DataGridComparerSortDescription comparer
|
||||
&& comparer.SourceComparer == Spots.Columns.First(c => Header(c) == "TS").CustomSortComparer
|
||||
&& first.Direction == ListSortDirection.Descending;
|
||||
|
||||
// ---- refresh
|
||||
|
||||
private bool running;
|
||||
private bool again;
|
||||
|
||||
/// Judging every spot and building the lines is done on other threads, so
|
||||
/// a refresh never holds up a key press. A request that comes in while one
|
||||
/// is running is answered by one more run afterwards, and the run it
|
||||
/// replaces is not drawn.
|
||||
public override void Refresh()
|
||||
{
|
||||
Columns.Children.Clear();
|
||||
Columns.ColumnDefinitions.Clear();
|
||||
if (session.Available is null)
|
||||
refreshPending = false;
|
||||
ticks = 0;
|
||||
if (running)
|
||||
{
|
||||
StatusText.Text = "no contest is open";
|
||||
again = true;
|
||||
return;
|
||||
}
|
||||
_ = RunAsync();
|
||||
}
|
||||
|
||||
private async Task RunAsync()
|
||||
{
|
||||
running = true;
|
||||
try
|
||||
{
|
||||
do
|
||||
{
|
||||
again = false;
|
||||
await Update();
|
||||
}
|
||||
while (again);
|
||||
}
|
||||
finally
|
||||
{
|
||||
running = false;
|
||||
}
|
||||
}
|
||||
|
||||
/// What the other threads work out, so the UI thread only has to draw it.
|
||||
private sealed record SummaryData(
|
||||
IReadOnlyList<Band> Columns,
|
||||
Dictionary<Band, int> Mults,
|
||||
Dictionary<Band, int> Qs,
|
||||
int MostMults,
|
||||
int MostQs);
|
||||
|
||||
private sealed record Computed(int Mults, int Total, SummaryData? Summary, List<AvailableRow> Rows, string RowsKey);
|
||||
|
||||
private async Task Update()
|
||||
{
|
||||
Summary.IsVisible = session.Settings.AvailableShowsSummary;
|
||||
bool multsOnly = session.Settings.AvailableMultsOnly;
|
||||
ModeButton.Content = multsOnly ? "Mults" : "Mults\nQs";
|
||||
ModeButton.Background = multsOnly ? Verdicts.NewMultiplier : Verdicts.Worth;
|
||||
ModeButton.Foreground = Brushes.White;
|
||||
if (session.Available is not { } available)
|
||||
{
|
||||
heading = "Available Mults and Qs";
|
||||
ShowNotice();
|
||||
EmptyText.Text = "No contest is open.";
|
||||
EmptyText.Foreground = Verdicts.Worth;
|
||||
EmptyText.IsVisible = true;
|
||||
Spots.ItemsSource = Array.Empty<AvailableRow>();
|
||||
shownKey = "";
|
||||
summaryKey = "";
|
||||
Summary.Children.Clear();
|
||||
return;
|
||||
}
|
||||
|
||||
session.Bandmap.DropOlderThan(DateTime.UtcNow);
|
||||
bool multsOnly = MultsOnlyBox.IsChecked == true;
|
||||
List<AvailableStation> stations = session.Available.All()
|
||||
.Where(s => !multsOnly || s.IsMultiplier)
|
||||
.ToList();
|
||||
List<Band> bands = stations
|
||||
.Select(s => s.Band)
|
||||
.Distinct()
|
||||
.OrderBy(b => b.Low.Hertz)
|
||||
.ToList();
|
||||
|
||||
int at = 0;
|
||||
foreach (Band band in bands)
|
||||
// everything the other threads read is taken here
|
||||
DateTime now = DateTime.UtcNow;
|
||||
Settings settings = session.Settings;
|
||||
BandPlan plan = session.BandPlan;
|
||||
Bandmap bandmap = session.Bandmap;
|
||||
HashSet<Band> picked = [.. clicked];
|
||||
Frequency? tuned = session.Position?.Frequency;
|
||||
IReadOnlyList<ModeCategory> contestModes = session.Position?.Contest.Modes ?? [];
|
||||
bool summaryShown = Summary.IsVisible;
|
||||
IReadOnlyList<AvailableStation> all = await available.AllAsync();
|
||||
Computed computed = await Task.Run(() => Compute(all, now, settings, plan, bandmap, picked, tuned, contestModes, summaryShown));
|
||||
if (again)
|
||||
{
|
||||
Columns.ColumnDefinitions.Add(new ColumnDefinition(GridLength.Star));
|
||||
Control column = BuildColumn(band, stations.Where(s => s.Band == band).ToList());
|
||||
Grid.SetColumn(column, at++);
|
||||
Columns.Children.Add(column);
|
||||
return;
|
||||
}
|
||||
|
||||
int mults = stations.Count(s => s.IsMultiplier);
|
||||
StatusText.Text = stations.Count == 0
|
||||
? "nothing spotted that is not worked"
|
||||
: $"{stations.Count} to work · {mults} multipliers";
|
||||
}
|
||||
|
||||
private Control BuildColumn(Band band, IReadOnlyList<AvailableStation> stations)
|
||||
{
|
||||
StackPanel panel = new() { Margin = new Avalonia.Thickness(0, 0, 8, 0) };
|
||||
panel.Children.Add(new TextBlock
|
||||
if (computed.Summary is { } summary)
|
||||
{
|
||||
Text = $"{band.Name} {stations.Count}",
|
||||
FontSize = 11,
|
||||
Opacity = 0.7,
|
||||
Margin = new Avalonia.Thickness(0, 0, 0, 4),
|
||||
});
|
||||
foreach (AvailableStation station in stations)
|
||||
{
|
||||
panel.Children.Add(Row(station));
|
||||
BuildSummary(summary, settings, picked);
|
||||
}
|
||||
return panel;
|
||||
heading = $"Available Mults and Qs - {computed.Mults} Mults {computed.Total - computed.Mults} Qs of {computed.Total} total spots";
|
||||
ShowNotice();
|
||||
EmptyText.Text = "No workable local nor Telnet spots available to display. "
|
||||
+ "Check contest, cluster filters, Bands & Modes button, and Telnet window filters.";
|
||||
EmptyText.Foreground = Verdicts.Worth;
|
||||
EmptyText.IsVisible = computed.Rows.Count == 0;
|
||||
if (IsPaused)
|
||||
{
|
||||
refreshPending = true;
|
||||
return;
|
||||
}
|
||||
Show(computed.Rows, computed.RowsKey);
|
||||
}
|
||||
|
||||
private Control Row(AvailableStation station)
|
||||
private Computed Compute(
|
||||
IReadOnlyList<AvailableStation> all,
|
||||
DateTime now,
|
||||
Settings settings,
|
||||
BandPlan plan,
|
||||
Bandmap bandmap,
|
||||
HashSet<Band> picked,
|
||||
Frequency? tuned,
|
||||
IReadOnlyList<ModeCategory> contestModes,
|
||||
bool summaryShown)
|
||||
{
|
||||
TextBlock text = new()
|
||||
int mults = all.Count(s => s.IsMultiplier);
|
||||
IReadOnlyList<string> preferred = settings.SpotFilter.PreferredSpotters;
|
||||
List<AvailableRow> rows = all
|
||||
.Where(s => (!settings.AvailableMultsOnly || s.IsMultiplier) && IsShown(s, settings, plan, picked, contestModes))
|
||||
.Select(s => new AvailableRow(
|
||||
s,
|
||||
ModeName(plan, s.Spot.Frequency),
|
||||
now,
|
||||
bandmap.Remaining(s.Spot),
|
||||
preferred.Contains(s.Spot.Spotter, StringComparer.OrdinalIgnoreCase),
|
||||
tuned is { } at && Math.Abs(at.Hertz - s.Spot.Frequency.Hertz) <= 100))
|
||||
.ToList();
|
||||
return new Computed(
|
||||
mults,
|
||||
all.Count,
|
||||
summaryShown ? SummaryOf(all, settings) : null,
|
||||
rows,
|
||||
string.Join(';', rows.Select(r => r.Key)));
|
||||
}
|
||||
|
||||
private static bool IsShown(
|
||||
AvailableStation station,
|
||||
Settings settings,
|
||||
BandPlan plan,
|
||||
HashSet<Band> picked,
|
||||
IReadOnlyList<ModeCategory> contestModes)
|
||||
{
|
||||
IReadOnlyList<string> bands = settings.AvailableBands;
|
||||
ModeCategory? category = plan.ModeAt(station.Spot.Frequency);
|
||||
return (picked.Count == 0 || picked.Contains(station.Band))
|
||||
&& (bands.Count == 0 || bands.Contains(station.Band.Name, StringComparer.OrdinalIgnoreCase))
|
||||
&& (category is null || ModeAllowed(settings.AvailableModes, category.Value, contestModes));
|
||||
}
|
||||
|
||||
/// Modes ticked in the filter window. Contest alone keeps the modes the
|
||||
/// contest runs; with others ticked a spot must be in one of them as well.
|
||||
private static bool ModeAllowed(IReadOnlyList<string> modes, ModeCategory category, IReadOnlyList<ModeCategory> contestModes)
|
||||
{
|
||||
bool contest = modes.Contains(AvailableFilterDialog.ContestMode, StringComparer.OrdinalIgnoreCase);
|
||||
List<string> named = [.. modes.Where(m => !m.Equals(AvailableFilterDialog.ContestMode, StringComparison.OrdinalIgnoreCase))];
|
||||
bool inContest = !contest || contestModes.Count == 0 || contestModes.Contains(category);
|
||||
bool inNamed = named.Count == 0 || named.Contains(ModeKey(category), StringComparer.OrdinalIgnoreCase);
|
||||
return inContest && inNamed;
|
||||
}
|
||||
|
||||
private static string ModeKey(ModeCategory category) => category switch
|
||||
{
|
||||
ModeCategory.Phone => "PHONE",
|
||||
ModeCategory.Digital => "DIGITAL",
|
||||
_ => "CW",
|
||||
};
|
||||
|
||||
/// A refresh that changes nothing leaves the list alone, so the scroll
|
||||
/// position and the picked line stay where the operator left them.
|
||||
private void Show(List<AvailableRow> rows, string key)
|
||||
{
|
||||
if (key == shownKey && Spots.ItemsSource is not null)
|
||||
{
|
||||
Text = Label(station),
|
||||
FontFamily = new FontFamily("monospace"),
|
||||
FontSize = 13,
|
||||
Foreground = Verdicts.Colour(station.Verdict),
|
||||
HorizontalAlignment = HorizontalAlignment.Left,
|
||||
return;
|
||||
}
|
||||
shownKey = key;
|
||||
DataGridCollectionView view = new(rows);
|
||||
if (Spots.ItemsSource is DataGridCollectionView old)
|
||||
{
|
||||
foreach (DataGridSortDescription sort in old.SortDescriptions)
|
||||
{
|
||||
view.SortDescriptions.Add(sort);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// N1MM opens sorted on frequency, lowest first
|
||||
DataGridColumn freq = Spots.Columns.First(c => Header(c) == "Freq");
|
||||
view.SortDescriptions.Add(DataGridSortDescription.FromComparer(freq.CustomSortComparer!, ListSortDirection.Ascending));
|
||||
}
|
||||
string? picked = (Spots.SelectedItem as AvailableRow)?.Call;
|
||||
// the grid picks the first line of a new view unless told not to
|
||||
view.MoveCurrentToPosition(-1);
|
||||
Spots.ItemsSource = view;
|
||||
Spots.SelectedItem = null;
|
||||
if (picked is not null && rows.FirstOrDefault(r => r.Call == picked) is { } same)
|
||||
{
|
||||
Spots.SelectedItem = same;
|
||||
}
|
||||
}
|
||||
|
||||
private static string ModeName(BandPlan plan, Frequency frequency) => plan.ModeAt(frequency) switch
|
||||
{
|
||||
ModeCategory.Cw => "CW",
|
||||
ModeCategory.Phone => "SSB",
|
||||
ModeCategory.Digital => "DIG",
|
||||
_ => "",
|
||||
};
|
||||
|
||||
/// A line is painted in the colour of what it would bring. The one the
|
||||
/// radio is on is painted in reverse.
|
||||
private static void Paint(DataGridRow line)
|
||||
{
|
||||
if (line.DataContext is not AvailableRow row)
|
||||
{
|
||||
return;
|
||||
}
|
||||
line.Foreground = row.IsTuned ? row.Background : row.Colour;
|
||||
line.Background = row.IsTuned ? row.Colour : Brushes.Transparent;
|
||||
ToolTip.SetTip(line, row.Tip);
|
||||
}
|
||||
|
||||
// ---- summary table
|
||||
|
||||
private IReadOnlyList<Band> SummaryBands(IReadOnlyList<AvailableStation> all) =>
|
||||
SummaryBands(all, session.Settings);
|
||||
|
||||
private static IReadOnlyList<Band> SummaryBands(IReadOnlyList<AvailableStation> all, Settings settings)
|
||||
{
|
||||
IReadOnlyList<string> chosen = settings.AvailableSummaryBands;
|
||||
IEnumerable<Band> basis = chosen.Count > 0
|
||||
? chosen.Select(Bands.Named).OfType<Band>()
|
||||
: Bands.Contest;
|
||||
return [.. basis.Concat(all.Select(s => s.Band)).Distinct().OrderBy(b => b.Low.Hertz)];
|
||||
}
|
||||
|
||||
private static SummaryData SummaryOf(IReadOnlyList<AvailableStation> all, Settings settings)
|
||||
{
|
||||
IReadOnlyList<Band> columns = SummaryBands(all, settings);
|
||||
Dictionary<Band, int> mults = columns.ToDictionary(b => b, b => all.Count(s => s.Band == b && s.IsMultiplier));
|
||||
Dictionary<Band, int> qs = columns.ToDictionary(b => b, b => all.Count(s => s.Band == b && !s.IsMultiplier));
|
||||
return new SummaryData(columns, mults, qs, mults.Values.Max(), qs.Values.Max());
|
||||
}
|
||||
|
||||
private void BuildSummary(SummaryData data, Settings settings, HashSet<Band> picked)
|
||||
{
|
||||
(IReadOnlyList<Band> columns, Dictionary<Band, int> mults, Dictionary<Band, int> qs, int mostMults, int mostQs) = data;
|
||||
|
||||
// the table is built again only when a number, a highlight or the
|
||||
// font size is different from what it shows
|
||||
string key = string.Join(
|
||||
';',
|
||||
columns.Select(b => $"{b.Name}:{mults[b]}:{qs[b]}:{picked.Contains(b)}"))
|
||||
+ $"|{mostMults}|{mostQs}|{settings.AvailableFontSize}";
|
||||
if (key == summaryKey)
|
||||
{
|
||||
return;
|
||||
}
|
||||
summaryKey = key;
|
||||
Summary.Children.Clear();
|
||||
Summary.RowDefinitions.Clear();
|
||||
Summary.ColumnDefinitions.Clear();
|
||||
|
||||
for (int row = 0; row < 4; row++)
|
||||
{
|
||||
Summary.RowDefinitions.Add(new RowDefinition(GridLength.Auto));
|
||||
}
|
||||
Summary.ColumnDefinitions.Add(new ColumnDefinition(GridLength.Auto));
|
||||
foreach (Band _ in columns)
|
||||
{
|
||||
Summary.ColumnDefinitions.Add(new ColumnDefinition(GridLength.Auto));
|
||||
}
|
||||
|
||||
Label(1, 0, "Mults", true, false, e => ShowBands([], null, e));
|
||||
Label(2, 0, "Qs", true, false, e => ShowBands([], null, e));
|
||||
Label(3, 0, "Total", true, false, e => ShowBands([], null, e));
|
||||
for (int at = 0; at < columns.Count; at++)
|
||||
{
|
||||
Band band = columns[at];
|
||||
int column = at + 1;
|
||||
Label(0, column, BandLabel(band), true, picked.Contains(band), e => ShowBands([band], null, e));
|
||||
Label(1, column, mults[band].ToString(), false, mults[band] > 0 && mults[band] == mostMults, e => ShowBands([band], true, e));
|
||||
Label(2, column, qs[band].ToString(), false, qs[band] > 0 && qs[band] == mostQs, e => ShowBands([band], false, e));
|
||||
Label(3, column, (mults[band] + qs[band]).ToString(), false, false, e => ShowBands([band], null, e));
|
||||
}
|
||||
}
|
||||
|
||||
/// The metres for the HF bands and the band's own name above that: 160, 80
|
||||
/// … 10, 6m, 2m, 70cm.
|
||||
private static string BandLabel(Band band) =>
|
||||
band.MegahertzLabel < 30 ? band.Name[..^1] : band.Name.ToLowerInvariant();
|
||||
|
||||
private void Label(int row, int column, string text, bool bold, bool highlight, Action<PointerPressedEventArgs> click)
|
||||
{
|
||||
TextBlock block = new()
|
||||
{
|
||||
Text = text,
|
||||
FontSize = session.Settings.AvailableFontSize,
|
||||
Margin = new Thickness(column == 0 ? 0 : 9, 0),
|
||||
MinWidth = column == 0 ? 0 : 22,
|
||||
TextAlignment = column == 0 ? TextAlignment.Left : TextAlignment.Center,
|
||||
FontWeight = bold || highlight ? FontWeight.Bold : FontWeight.Normal,
|
||||
Cursor = new Cursor(StandardCursorType.Hand),
|
||||
};
|
||||
ToolTip.SetTip(text, Tip(station));
|
||||
text.PointerPressed += (_, _) => tune(station.Spot.Frequency, station.Spot.Call.Text);
|
||||
return text;
|
||||
if (highlight)
|
||||
{
|
||||
block.Foreground = Verdicts.NewMultiplier;
|
||||
}
|
||||
block.PointerPressed += (_, e) => click(e);
|
||||
Grid.SetRow(block, row);
|
||||
Grid.SetColumn(block, column);
|
||||
Summary.Children.Add(block);
|
||||
}
|
||||
|
||||
private static string Label(AvailableStation station)
|
||||
/// A click on a band shows that band alone and shift adds it to the ones
|
||||
/// shown. `multsOnly` is null when the click does not say. No bands is all
|
||||
/// of them.
|
||||
private void ShowBands(IReadOnlyList<Band> picked, bool? multsOnly, PointerPressedEventArgs e)
|
||||
{
|
||||
string call = $"{station.Spot.Frequency.Kilohertz,9:0.0} {station.Spot.Call.Text}";
|
||||
return station.IsMultiplier ? $"{call} · {station.MultiplierText}" : call;
|
||||
if (!e.KeyModifiers.HasFlag(KeyModifiers.Shift) || picked.Count == 0)
|
||||
{
|
||||
clicked.Clear();
|
||||
}
|
||||
foreach (Band band in picked)
|
||||
{
|
||||
clicked.Add(band);
|
||||
}
|
||||
pausedUntil = DateTime.MinValue;
|
||||
if (multsOnly is { } only && only != session.Settings.AvailableMultsOnly)
|
||||
{
|
||||
session.Save(session.Settings with { AvailableMultsOnly = only });
|
||||
}
|
||||
Refresh();
|
||||
}
|
||||
|
||||
private static string Tip(AvailableStation station)
|
||||
private void SetMultsOnly(bool multsOnly)
|
||||
{
|
||||
string who = station.Spot.Spotter.Length > 0 ? $" de {station.Spot.Spotter}" : "";
|
||||
return $"{Verdicts.Describe(station.Verdict)}{who}";
|
||||
pausedUntil = DateTime.MinValue;
|
||||
session.Save(session.Settings with { AvailableMultsOnly = multsOnly });
|
||||
Refresh();
|
||||
}
|
||||
|
||||
// ---- clicks and keys
|
||||
|
||||
private void OnSpotPressed(object? sender, PointerPressedEventArgs e)
|
||||
{
|
||||
Visual? source = e.Source as Visual;
|
||||
menuOnHeader = source?.GetSelfAndVisualAncestors().OfType<DataGridColumnHeader>().Any() == true;
|
||||
menuRow = source?.GetSelfAndVisualAncestors().OfType<DataGridRow>().FirstOrDefault()?.DataContext as AvailableRow;
|
||||
Pause();
|
||||
if (menuRow is null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
PointerPointProperties point = e.GetCurrentPoint(Spots).Properties;
|
||||
if (point.IsLeftButtonPressed)
|
||||
{
|
||||
Pick(menuRow);
|
||||
}
|
||||
else if (point.IsMiddleButtonPressed)
|
||||
{
|
||||
Delete(menuRow);
|
||||
}
|
||||
}
|
||||
|
||||
private void Pick(AvailableRow row)
|
||||
{
|
||||
Spots.SelectedItem = row;
|
||||
tune(row.Station.Spot.Frequency, row.Call);
|
||||
}
|
||||
|
||||
protected override void OnKeyDown(KeyEventArgs e)
|
||||
{
|
||||
base.OnKeyDown(e);
|
||||
if (e.Key == Key.A && e.KeyModifiers.HasFlag(KeyModifiers.Alt))
|
||||
{
|
||||
e.Handled = true;
|
||||
Step(e.KeyModifiers);
|
||||
}
|
||||
}
|
||||
|
||||
/// Alt+A moves down the list and QSYs, Shift+Alt+A moves up and Ctrl+Alt+A
|
||||
/// goes to the top. The list wraps. With no line picked nothing happens.
|
||||
public void Step(KeyModifiers modifiers)
|
||||
{
|
||||
if (Spots.SelectedItem is not AvailableRow current || Spots.ItemsSource is not DataGridCollectionView view)
|
||||
{
|
||||
return;
|
||||
}
|
||||
List<AvailableRow> rows = [.. view.Cast<AvailableRow>()];
|
||||
if (rows.Count == 0)
|
||||
{
|
||||
return;
|
||||
}
|
||||
int at = rows.FindIndex(r => r.Call == current.Call);
|
||||
int next = modifiers.HasFlag(KeyModifiers.Control) ? 0
|
||||
: modifiers.HasFlag(KeyModifiers.Shift) ? (at - 1 + rows.Count) % rows.Count
|
||||
: (at + 1) % rows.Count;
|
||||
Spots.ScrollIntoView(rows[next], null);
|
||||
Pick(rows[next]);
|
||||
}
|
||||
|
||||
/// Called after a contact is logged. When the option is on, the list is
|
||||
/// sorted newest first and the operator is not running, the radio goes to
|
||||
/// the top spot that is not the station just worked.
|
||||
public void QsyToTopSpot(string loggedCall)
|
||||
{
|
||||
if (!session.Settings.AvailableQsyAfterLogging || !IsNewestFirst)
|
||||
{
|
||||
return;
|
||||
}
|
||||
pausedUntil = DateTime.MinValue;
|
||||
Refresh();
|
||||
if (Spots.ItemsSource is not DataGridCollectionView view)
|
||||
{
|
||||
return;
|
||||
}
|
||||
AvailableRow? top = view.Cast<AvailableRow>().FirstOrDefault(r => r.Call != loggedCall);
|
||||
if (top is not null)
|
||||
{
|
||||
Pick(top);
|
||||
}
|
||||
}
|
||||
|
||||
// ---- menus
|
||||
|
||||
private ContextMenu BuildMenu()
|
||||
{
|
||||
ContextMenu menu = new();
|
||||
menu.Opening += (_, _) => menu.ItemsSource = menuOnHeader ? HeaderItems() : SpotItems();
|
||||
return menu;
|
||||
}
|
||||
|
||||
private List<Control> HeaderItems()
|
||||
{
|
||||
List<Control> items = [];
|
||||
foreach (DataGridColumn column in Spots.Columns.Where(c => Header(c) != "Call"))
|
||||
{
|
||||
string header = Header(column);
|
||||
MenuItem item = new()
|
||||
{
|
||||
Header = header == "★" ? "★ preferred spotter" : header,
|
||||
ToggleType = MenuItemToggleType.CheckBox,
|
||||
IsChecked = column.IsVisible,
|
||||
StaysOpenOnClick = true,
|
||||
};
|
||||
item.Click += (_, _) => SetColumnShown(header, !column.IsVisible);
|
||||
items.Add(item);
|
||||
}
|
||||
items.Add(new Separator());
|
||||
items.Add(Action("Auto Resize Columns", AutoResizeColumns));
|
||||
return items;
|
||||
}
|
||||
|
||||
private List<Control> SpotItems()
|
||||
{
|
||||
AvailableRow? row = menuRow;
|
||||
MenuItem delete = Action("Delete Spot", () => Delete(row!));
|
||||
MenuItem callBlacklist = Action("Blacklist Callsign", () => Blacklist(row!, spotter: false));
|
||||
MenuItem spotterBlacklist = Action("Blacklist Spotter", () => Blacklist(row!, spotter: true));
|
||||
delete.IsEnabled = callBlacklist.IsEnabled = spotterBlacklist.IsEnabled = row is not null;
|
||||
|
||||
MenuItem qs = Check("Show Qs && Mults", !session.Settings.AvailableMultsOnly, () => SetMultsOnly(!session.Settings.AvailableMultsOnly));
|
||||
MenuItem qsyAfter = Check(
|
||||
"QSY to top spot after logging QSO",
|
||||
session.Settings.AvailableQsyAfterLogging,
|
||||
() => session.Save(session.Settings with { AvailableQsyAfterLogging = !session.Settings.AvailableQsyAfterLogging }));
|
||||
qsyAfter.IsEnabled = IsNewestFirst;
|
||||
MenuItem summaryShown = Check(
|
||||
"Show Summary Panel",
|
||||
session.Settings.AvailableShowsSummary,
|
||||
() =>
|
||||
{
|
||||
session.Save(session.Settings with { AvailableShowsSummary = !session.Settings.AvailableShowsSummary });
|
||||
Refresh();
|
||||
});
|
||||
return
|
||||
[
|
||||
delete,
|
||||
new Separator(),
|
||||
callBlacklist,
|
||||
spotterBlacklist,
|
||||
new Separator(),
|
||||
Action("Set Band && Mode Filter Options....", OpenFilterMenu),
|
||||
new Separator(),
|
||||
qs,
|
||||
new Separator(),
|
||||
qsyAfter,
|
||||
new Separator(),
|
||||
SummaryBandMenu(),
|
||||
Action("Auto Resize Columns", AutoResizeColumns),
|
||||
summaryShown,
|
||||
Action("Help", OpenHelp),
|
||||
];
|
||||
}
|
||||
|
||||
private static MenuItem Action(string header, Action run)
|
||||
{
|
||||
MenuItem item = new() { Header = header };
|
||||
item.Click += (_, _) => run();
|
||||
return item;
|
||||
}
|
||||
|
||||
private static MenuItem Check(string header, bool isChecked, Action run)
|
||||
{
|
||||
MenuItem item = new() { Header = header, ToggleType = MenuItemToggleType.CheckBox, IsChecked = isChecked };
|
||||
item.Click += (_, _) => run();
|
||||
return item;
|
||||
}
|
||||
|
||||
/// Any mix of bands for the summary table, from the contest's own to the
|
||||
/// microwave bands.
|
||||
private MenuItem SummaryBandMenu()
|
||||
{
|
||||
IReadOnlyList<Band> shown = SummaryBands(session.Available?.All() ?? []);
|
||||
List<Control> items = [];
|
||||
foreach (Band band in Bands.All)
|
||||
{
|
||||
MenuItem item = new()
|
||||
{
|
||||
Header = band.Name,
|
||||
ToggleType = MenuItemToggleType.CheckBox,
|
||||
IsChecked = shown.Contains(band),
|
||||
StaysOpenOnClick = true,
|
||||
};
|
||||
item.Click += (_, _) =>
|
||||
{
|
||||
session.Save(session.Settings with
|
||||
{
|
||||
AvailableSummaryBands =
|
||||
[
|
||||
.. shown.Where(b => b != band).Concat(shown.Contains(band) ? [] : [band]).Select(b => b.Name),
|
||||
],
|
||||
});
|
||||
Refresh();
|
||||
};
|
||||
items.Add(item);
|
||||
}
|
||||
return new MenuItem { Header = "Summary Panel Band Selection", ItemsSource = items };
|
||||
}
|
||||
|
||||
/// The bands and modes the list is limited to. It does not touch the
|
||||
/// telnet window's filters.
|
||||
private void OpenFilterMenu() =>
|
||||
_ = new AvailableFilterDialog(
|
||||
session.Settings.AvailableBands,
|
||||
session.Settings.AvailableModes,
|
||||
(bands, modes) =>
|
||||
{
|
||||
session.Save(session.Settings with { AvailableBands = bands, AvailableModes = modes });
|
||||
pausedUntil = DateTime.MinValue;
|
||||
Refresh();
|
||||
}).ShowDialog(this);
|
||||
|
||||
private void OpenHelp() => _ = TopLevel.GetTopLevel(this)?.Launcher.LaunchUriAsync(new Uri(HelpUrl));
|
||||
|
||||
// ---- changing the bandmap
|
||||
|
||||
private void Delete(AvailableRow row)
|
||||
{
|
||||
pausedUntil = DateTime.MinValue;
|
||||
session.Bandmap.Remove(row.Station.Spot.Call, row.Station.Band);
|
||||
}
|
||||
|
||||
/// Adds the call, or the spotter, to the telnet window's blocked lists and
|
||||
/// takes what it already put on the map off.
|
||||
private void Blacklist(AvailableRow row, bool spotter)
|
||||
{
|
||||
StoredSpotFilter filter = session.Settings.SpotFilter;
|
||||
string name = spotter ? row.Station.Spot.Spotter : row.Call;
|
||||
if (name.Length == 0)
|
||||
{
|
||||
return;
|
||||
}
|
||||
session.Save(session.Settings with
|
||||
{
|
||||
SpotFilter = spotter
|
||||
? filter with { BlockedSpotters = [.. filter.BlockedSpotters, name] }
|
||||
: filter with { BlockedCalls = [.. filter.BlockedCalls, name] },
|
||||
});
|
||||
pausedUntil = DateTime.MinValue;
|
||||
IEnumerable<Spot> doomed = session.Bandmap.All().Where(s =>
|
||||
spotter ? s.Spotter.Equals(name, StringComparison.OrdinalIgnoreCase) : s.Call.Text.Equals(name, StringComparison.OrdinalIgnoreCase));
|
||||
foreach (Spot spot in doomed.ToList())
|
||||
{
|
||||
if (spot.Band is { } band)
|
||||
{
|
||||
session.Bandmap.Remove(spot.Call, band);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
using Nonemm.App.Theming;
|
||||
using System.Globalization;
|
||||
using Avalonia;
|
||||
using Avalonia.Controls;
|
||||
@@ -11,15 +12,27 @@ namespace Nonemm.App.Windows;
|
||||
/// Draws the band: a frequency scale down the left, the receiver and
|
||||
/// transmitter as bars on it, and the stations as callsigns on the right with a
|
||||
/// leader line back to where each one really is.
|
||||
public sealed record BandmapZoom(bool In, Frequency At);
|
||||
|
||||
public sealed class BandmapView : Control
|
||||
{
|
||||
private const double ScaleX = 52;
|
||||
private const double LabelX = 96;
|
||||
private const double TickLength = 6;
|
||||
private const double LabelHeight = 15;
|
||||
private const double TextSize = 12;
|
||||
private const double ScaleTextSize = 12;
|
||||
|
||||
/// Callsigns are drawn this much taller than their text, so the lines of
|
||||
/// two neighbours do not touch.
|
||||
private const double LabelPadding = 3;
|
||||
private const double VfoWidth = 4;
|
||||
|
||||
/// How far the carrier tick reaches past each side of the bar.
|
||||
private const double CarrierOverhang = 3;
|
||||
|
||||
/// How much further the carrier tick reaches to the right, so it can be
|
||||
/// seen beside the callsign labels.
|
||||
private const double CarrierExtraRight = 15;
|
||||
|
||||
/// The scale stops short of the top and bottom edges so the first and last
|
||||
/// frequency numbers are not cut in half.
|
||||
private const double Inset = 9;
|
||||
@@ -35,7 +48,9 @@ public sealed class BandmapView : Control
|
||||
/// Past the band edge. The slice can reach there when the radio does.
|
||||
private static readonly IBrush OutsideBrush = new SolidColorBrush(Color.FromRgb(0xC0, 0x39, 0x2B), 0.13);
|
||||
|
||||
private readonly Typeface typeface = new(new FontFamily("monospace"));
|
||||
private readonly Typeface typeface = new(Fonts.Mono);
|
||||
private readonly Typeface boldTypeface = new(Fonts.Mono, FontStyle.Normal, FontWeight.Bold);
|
||||
private readonly Typeface italicTypeface = new(Fonts.Mono, FontStyle.Italic);
|
||||
private IReadOnlyList<BandmapLabel> placed = [];
|
||||
private BandmapScale scale = new(Bands.Band20M.Low, Bands.Band20M.High, 1);
|
||||
|
||||
@@ -43,6 +58,11 @@ public sealed class BandmapView : Control
|
||||
|
||||
public IReadOnlyList<Spot> Spots { get; set; } = [];
|
||||
|
||||
/// The height of the callsigns, in points.
|
||||
public double TextSize { get; set; } = 12;
|
||||
|
||||
private double LabelHeight => TextSize + LabelPadding;
|
||||
|
||||
public IReadOnlyList<VfoMarker> Vfos { get; set; } = [];
|
||||
|
||||
public Frequency Low { get; set; } = Bands.Band20M.Low;
|
||||
@@ -59,11 +79,18 @@ public sealed class BandmapView : Control
|
||||
/// The step between the frequency numbers down the scale.
|
||||
public Frequency TickStep { get; set; } = Frequency.FromKilohertz(5);
|
||||
|
||||
/// Sets the step from the height of the window instead: as many ticks as
|
||||
/// fit with room for three lines of text between them.
|
||||
public bool DenseTicks { get; set; }
|
||||
|
||||
public event EventHandler<Spot>? SpotPicked;
|
||||
|
||||
/// Clicking where no station is asks for the radio, not a callsign.
|
||||
public event EventHandler<Frequency>? FrequencyPicked;
|
||||
|
||||
/// The wheel was turned: forward zooms in on the frequency under the pointer.
|
||||
public event EventHandler<BandmapZoom>? Zoomed;
|
||||
|
||||
public override void Render(DrawingContext context)
|
||||
{
|
||||
scale = new BandmapScale(Low, High, Math.Max(1, Bounds.Height - (2 * Inset)));
|
||||
@@ -72,14 +99,41 @@ public sealed class BandmapView : Control
|
||||
DrawSegments(context);
|
||||
DrawScale(context, ink);
|
||||
DrawVfos(context);
|
||||
placed = [.. BandmapLayout.Place(Spots, scale, LabelHeight)
|
||||
.Select(l => l with { MarkY = l.MarkY + Inset, LabelY = l.LabelY + Inset })];
|
||||
PlaceLabels();
|
||||
foreach (BandmapLabel label in placed)
|
||||
{
|
||||
// the labels are in order down the scale, so the rest are below
|
||||
// the edge as well
|
||||
if (label.LabelY > Bounds.Height)
|
||||
{
|
||||
break;
|
||||
}
|
||||
DrawLabel(context, label, ink);
|
||||
}
|
||||
}
|
||||
|
||||
private IReadOnlyList<Spot> placedSpots = [];
|
||||
private BandmapScale? placedScale;
|
||||
private double placedHeight;
|
||||
|
||||
/// Lays the callsigns out again only when the spots, the scale or the text
|
||||
/// size are not what the last layout used. Redraws for any other reason, a
|
||||
/// moving receiver bar for one, reuse it.
|
||||
private void PlaceLabels()
|
||||
{
|
||||
if (placedScale == scale
|
||||
&& placedHeight == LabelHeight
|
||||
&& (ReferenceEquals(placedSpots, Spots) || placedSpots.SequenceEqual(Spots)))
|
||||
{
|
||||
return;
|
||||
}
|
||||
placedSpots = Spots;
|
||||
placedScale = scale;
|
||||
placedHeight = LabelHeight;
|
||||
placed = [.. BandmapLayout.Place(Spots, scale, LabelHeight)
|
||||
.Select(l => l with { MarkY = l.MarkY + Inset, LabelY = l.LabelY + Inset })];
|
||||
}
|
||||
|
||||
/// N1MM paints the CW, digital and phone parts of the band behind the
|
||||
/// scale, the digital block over the other two.
|
||||
/// Anything past a band edge is painted as out of band, which is the only
|
||||
@@ -115,15 +169,16 @@ public sealed class BandmapView : Control
|
||||
|
||||
private void DrawScale(DrawingContext context, IBrush ink)
|
||||
{
|
||||
Pen line = new(Opaque(ink, 0.5), 1);
|
||||
Pen line = new(Opaque(ink, 0.7), 1);
|
||||
context.DrawLine(line, new Point(ScaleX, Inset), new Point(ScaleX, Inset + scale.Height));
|
||||
foreach (Frequency tick in BandmapLayout.Ticks(scale, TickStep))
|
||||
foreach (Frequency tick in BandmapLayout.Ticks(scale, DenseTicks ? BandmapLayout.StepFor(scale, 3 * LabelHeight) : TickStep))
|
||||
{
|
||||
double y = Math.Round(scale.YFor(tick) + Inset) + 0.5;
|
||||
context.DrawLine(line, new Point(ScaleX - TickLength, y), new Point(ScaleX, y));
|
||||
FormattedText text = Text(
|
||||
tick.Kilohertz.ToString("0.#", CultureInfo.InvariantCulture),
|
||||
Opaque(ink, 0.6));
|
||||
Opaque(ink, 0.8),
|
||||
ScaleTextSize);
|
||||
context.DrawText(text, new Point(ScaleX - TickLength - 4 - text.Width, y - (text.Height / 2)));
|
||||
}
|
||||
}
|
||||
@@ -136,9 +191,13 @@ public sealed class BandmapView : Control
|
||||
double bottom = scale.YFor(vfo.High) + Inset;
|
||||
// a narrow mode would be less than a pixel tall
|
||||
double height = Math.Max(3, bottom - top);
|
||||
IBrush brush = BrushFor(vfo.Role);
|
||||
context.FillRectangle(brush, new Rect(ScaleX - (VfoWidth / 2), top, VfoWidth, height));
|
||||
// the carrier, which is not in the middle of a sideband
|
||||
double carrier = Math.Round(scale.YFor(vfo.Carrier) + Inset);
|
||||
context.FillRectangle(
|
||||
BrushFor(vfo.Role),
|
||||
new Rect(ScaleX - (VfoWidth / 2), top, VfoWidth, height));
|
||||
brush,
|
||||
new Rect(ScaleX - (VfoWidth / 2) - CarrierOverhang, carrier - 1, VfoWidth + (2 * CarrierOverhang) + CarrierExtraRight, 2));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -146,37 +205,127 @@ public sealed class BandmapView : Control
|
||||
{
|
||||
IBrush colour = ColourOf(label.Spot);
|
||||
context.DrawLine(
|
||||
new Pen(Opaque(ink, 0.35), 1),
|
||||
LeaderPen(ink),
|
||||
new Point(ScaleX + 2, label.MarkY),
|
||||
new Point(LabelX - 2, label.LabelY + (LabelHeight / 2)));
|
||||
context.DrawText(Text(label.Spot.Call.Text, colour), new Point(LabelX, label.LabelY));
|
||||
context.DrawText(
|
||||
Text(
|
||||
label.Spot.Call.Text,
|
||||
colour,
|
||||
TextSize,
|
||||
label.Spot.IsLocal || label.Spot.IsCqFrequency,
|
||||
label.Spot.Source == SpotSource.Log),
|
||||
new Point(LabelX, label.LabelY + (LabelPadding / 2)));
|
||||
}
|
||||
|
||||
protected override void OnPointerWheelChanged(PointerWheelEventArgs e)
|
||||
{
|
||||
base.OnPointerWheelChanged(e);
|
||||
if (e.Delta.Y != 0)
|
||||
{
|
||||
Zoomed?.Invoke(this, new BandmapZoom(e.Delta.Y > 0, scale.At(e.GetPosition(this).Y - Inset)));
|
||||
e.Handled = true;
|
||||
}
|
||||
}
|
||||
|
||||
private BandmapLabel? LabelAt(Point at) =>
|
||||
at.X < LabelX
|
||||
? null
|
||||
: placed.FirstOrDefault(l => at.Y >= l.LabelY && at.Y <= l.LabelY + LabelHeight);
|
||||
|
||||
protected override void OnPointerMoved(PointerEventArgs e)
|
||||
{
|
||||
base.OnPointerMoved(e);
|
||||
Spot? under = LabelAt(e.GetPosition(this))?.Spot;
|
||||
if (Equals(under, tipFor))
|
||||
{
|
||||
return;
|
||||
}
|
||||
tipFor = under;
|
||||
ToolTip.SetShowDelay(this, 0);
|
||||
ToolTip.SetTip(this, under is null ? null : SpotDescription.Of(under));
|
||||
}
|
||||
|
||||
/// The spot the tool tip describes, so moving the pointer along a callsign
|
||||
/// does not build the text again.
|
||||
private Spot? tipFor;
|
||||
|
||||
protected override void OnPointerPressed(PointerPressedEventArgs e)
|
||||
{
|
||||
base.OnPointerPressed(e);
|
||||
Point at = e.GetPosition(this);
|
||||
foreach (BandmapLabel label in placed)
|
||||
if (LabelAt(at) is { } label)
|
||||
{
|
||||
if (at.X >= LabelX && at.Y >= label.LabelY && at.Y <= label.LabelY + LabelHeight)
|
||||
{
|
||||
SpotPicked?.Invoke(this, label.Spot);
|
||||
return;
|
||||
}
|
||||
SpotPicked?.Invoke(this, label.Spot);
|
||||
return;
|
||||
}
|
||||
FrequencyPicked?.Invoke(this, scale.At(at.Y - Inset));
|
||||
}
|
||||
|
||||
private FormattedText Text(string text, IBrush brush) =>
|
||||
new(text, CultureInfo.InvariantCulture, FlowDirection.LeftToRight, typeface, TextSize, brush);
|
||||
/// Shaping text is the dearest part of a redraw, and the same few hundred
|
||||
/// callsigns and frequency numbers are drawn every time, so each is kept.
|
||||
private readonly Dictionary<(string Text, IBrush Brush, double Size, bool Bold, bool Italic), FormattedText> texts = [];
|
||||
|
||||
private FormattedText Text(string text, IBrush brush, double size, bool bold = false, bool italic = false)
|
||||
{
|
||||
if (texts.TryGetValue((text, brush, size, bold, italic), out FormattedText? kept))
|
||||
{
|
||||
return kept;
|
||||
}
|
||||
if (texts.Count > 2000)
|
||||
{
|
||||
texts.Clear();
|
||||
}
|
||||
FormattedText made = new(
|
||||
text,
|
||||
CultureInfo.InvariantCulture,
|
||||
FlowDirection.LeftToRight,
|
||||
bold ? boldTypeface : italic ? italicTypeface : typeface,
|
||||
size,
|
||||
brush);
|
||||
texts[(text, brush, size, bold, italic)] = made;
|
||||
return made;
|
||||
}
|
||||
|
||||
/// The form's text colour, which the theme sets in both light and dark.
|
||||
private IBrush Foreground() =>
|
||||
this.FindResource("SystemControlForegroundBaseHighBrush") as IBrush ?? Brushes.Gray;
|
||||
this.FindResource("FormForeground") as IBrush ?? Brushes.Gray;
|
||||
|
||||
private static IBrush Opaque(IBrush ink, double opacity) =>
|
||||
ink is ISolidColorBrush solid
|
||||
? new SolidColorBrush(solid.Color, opacity)
|
||||
: ink;
|
||||
private Pen? leaderPen;
|
||||
private IBrush? leaderInk;
|
||||
|
||||
/// The line from the scale to a callsign. Every label has the same one.
|
||||
private Pen LeaderPen(IBrush ink)
|
||||
{
|
||||
if (leaderPen is null || !ReferenceEquals(leaderInk, ink))
|
||||
{
|
||||
leaderPen = new Pen(Opaque(ink, 0.55), 1);
|
||||
leaderInk = ink;
|
||||
}
|
||||
return leaderPen;
|
||||
}
|
||||
|
||||
private readonly Dictionary<(IBrush Ink, double Opacity), IBrush> faded = [];
|
||||
|
||||
/// Kept, so the same brush comes back each time and the text drawn with it
|
||||
/// is found in `texts`.
|
||||
private IBrush Opaque(IBrush ink, double opacity)
|
||||
{
|
||||
if (ink is not ISolidColorBrush solid)
|
||||
{
|
||||
return ink;
|
||||
}
|
||||
if (!faded.TryGetValue((ink, opacity), out IBrush? brush))
|
||||
{
|
||||
if (faded.Count > 50)
|
||||
{
|
||||
faded.Clear();
|
||||
}
|
||||
brush = new SolidColorBrush(solid.Color, opacity);
|
||||
faded[(ink, opacity)] = brush;
|
||||
}
|
||||
return brush;
|
||||
}
|
||||
|
||||
private static IBrush BrushFor(VfoRole role) => role switch
|
||||
{
|
||||
|
||||
@@ -2,14 +2,16 @@
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:local="using:Nonemm.App.Windows"
|
||||
x:Class="Nonemm.App.Windows.BandmapWindow"
|
||||
Title="Bandmap" Width="280" Height="620">
|
||||
Title="Bandmap" Width="320" Height="620">
|
||||
<DockPanel>
|
||||
<StackPanel DockPanel.Dock="Top" Orientation="Horizontal" Margin="6,6,6,4" Spacing="8">
|
||||
<TextBlock Name="BandText" FontSize="12" VerticalAlignment="Center" />
|
||||
<DockPanel DockPanel.Dock="Top" Margin="6,6,6,4" LastChildFill="False">
|
||||
<ComboBox Name="SpanBox" FontSize="11" Width="96" />
|
||||
</StackPanel>
|
||||
<TextBlock DockPanel.Dock="Bottom" Name="StatusText" Margin="6,2,6,6"
|
||||
FontSize="11" Opacity="0.7" />
|
||||
<CheckBox Name="CentreBox" Content="Centre on VFO" FontSize="11" Margin="8,0,0,0" />
|
||||
</DockPanel>
|
||||
<Border Name="SolarBar" DockPanel.Dock="Bottom" IsVisible="False" Padding="6,2"
|
||||
BorderThickness="0,1,0,0" BorderBrush="Gray">
|
||||
<TextBlock Name="SolarText" FontSize="11" TextWrapping="Wrap" />
|
||||
</Border>
|
||||
<local:BandmapView Name="View" />
|
||||
</DockPanel>
|
||||
</local:RefreshableWindow>
|
||||
|
||||
@@ -1,8 +1,11 @@
|
||||
using Avalonia.Controls;
|
||||
using Nonemm.App.Configuration;
|
||||
using Avalonia.Media;
|
||||
using Avalonia.Threading;
|
||||
using Nonemm.Contests;
|
||||
using Nonemm.Core;
|
||||
using Nonemm.Rig;
|
||||
using Nonemm.Session;
|
||||
using Nonemm.Spotting;
|
||||
|
||||
namespace Nonemm.App.Windows;
|
||||
@@ -13,44 +16,106 @@ namespace Nonemm.App.Windows;
|
||||
/// moves the radio.
|
||||
public sealed partial class BandmapWindow : RefreshableWindow
|
||||
{
|
||||
private static readonly (string Label, Frequency Span)[] Spans =
|
||||
/// Stands in the span list for the CW, digital or phone part of the band
|
||||
/// the receiver is in.
|
||||
private const long PartOfBand = -1;
|
||||
|
||||
private static readonly (string Label, long Hertz)[] Spans =
|
||||
[
|
||||
("10 kHz", Frequency.FromKilohertz(10)),
|
||||
("20 kHz", Frequency.FromKilohertz(20)),
|
||||
("40 kHz", Frequency.FromKilohertz(40)),
|
||||
("100 kHz", Frequency.FromKilohertz(100)),
|
||||
("whole band", Frequency.Zero),
|
||||
("5 kHz", 5_000),
|
||||
("10 kHz", 10_000),
|
||||
("20 kHz", 20_000),
|
||||
("40 kHz", 40_000),
|
||||
("60 kHz", 60_000),
|
||||
("75 kHz", 75_000),
|
||||
("100 kHz", 100_000),
|
||||
("150 kHz", 150_000),
|
||||
("mode", PartOfBand),
|
||||
("band", 0),
|
||||
];
|
||||
|
||||
private readonly AppSession session;
|
||||
private readonly Action<Frequency, string> tune;
|
||||
private readonly Action<Frequency> returnToCq;
|
||||
|
||||
public BandmapWindow(AppSession session, Action<Frequency, string> tune)
|
||||
/// Where the slice was last drawn from, so it stays put until the receiver
|
||||
/// nears an edge.
|
||||
private Frequency? sliceLow;
|
||||
|
||||
private static readonly IBrush CqBrush = new SolidColorBrush(Color.FromRgb(0x9B, 0x59, 0xB6));
|
||||
|
||||
public BandmapWindow(AppSession session, Action<Frequency, string> tune, Action<Frequency> returnToCq)
|
||||
{
|
||||
this.session = session;
|
||||
this.tune = tune;
|
||||
this.returnToCq = returnToCq;
|
||||
InitializeComponent();
|
||||
SpanBox.ItemsSource = Spans.Select(s => s.Label).ToList();
|
||||
SpanBox.SelectedIndex = 2;
|
||||
SpanBox.SelectionChanged += (_, _) => Refresh();
|
||||
SpanBox.SelectedIndex = Math.Max(
|
||||
0,
|
||||
Array.FindIndex(Spans, s => s.Hertz == session.Settings.BandmapSpanHertz));
|
||||
CentreBox.IsChecked = session.Settings.BandmapCentred;
|
||||
View.TextSize = session.Settings.BandmapTextSize;
|
||||
_ = new FontZoom(this, new Settings().BandmapTextSize, () => (int)View.TextSize, size =>
|
||||
{
|
||||
View.TextSize = size;
|
||||
SaveView();
|
||||
});
|
||||
SpanBox.SelectionChanged += (_, _) => SaveView();
|
||||
CentreBox.IsCheckedChanged += (_, _) => SaveView();
|
||||
View.Zoomed += (_, zoom) => Zoom(zoom);
|
||||
View.ColourOf = Colour;
|
||||
View.SpotPicked += (_, spot) => tune(spot.Frequency, spot.Call.Text);
|
||||
View.SpotPicked += (_, spot) =>
|
||||
{
|
||||
if (spot.IsCqFrequency)
|
||||
{
|
||||
returnToCq(spot.Frequency);
|
||||
}
|
||||
else
|
||||
{
|
||||
tune(spot.Frequency, spot.Call.Text);
|
||||
}
|
||||
};
|
||||
View.FrequencyPicked += (_, frequency) => tune(frequency, "");
|
||||
session.Bandmap.Changed += (_, _) => Dispatcher.UIThread.Post(Refresh);
|
||||
Coalesced changed = new(Refresh);
|
||||
EventHandler spotsChanged = (_, _) => changed.Request();
|
||||
session.Bandmap.Changed += spotsChanged;
|
||||
Closed += (_, _) => session.Bandmap.Changed -= spotsChanged;
|
||||
EventHandler solarChanged = (_, _) => Dispatcher.UIThread.Post(ShowSolar);
|
||||
session.SolarChanged += solarChanged;
|
||||
Closed += (_, _) => session.SolarChanged -= solarChanged;
|
||||
ShowSolar();
|
||||
Refresh();
|
||||
}
|
||||
|
||||
/// The status bar holds the solar weather the cluster sent, and is hidden
|
||||
/// while there is none. The line the node sent is its tool tip.
|
||||
private void ShowSolar()
|
||||
{
|
||||
SolarText.Text = session.Solar?.Text ?? "";
|
||||
ToolTip.SetTip(SolarBar, session.Solar?.Original);
|
||||
SolarBar.IsVisible = session.Solar is not null;
|
||||
}
|
||||
|
||||
private void SaveView()
|
||||
{
|
||||
session.Save(session.Settings with
|
||||
{
|
||||
BandmapTextSize = (int)View.TextSize,
|
||||
BandmapSpanHertz = (int)Spans[Math.Max(0, SpanBox.SelectedIndex)].Hertz,
|
||||
BandmapCentred = CentreBox.IsChecked == true,
|
||||
});
|
||||
Refresh();
|
||||
}
|
||||
|
||||
public override void Refresh()
|
||||
{
|
||||
session.Bandmap.DropOlderThan(DateTime.UtcNow);
|
||||
Band? band = session.Position is null ? null : Bands.ForFrequency(session.Position.Frequency);
|
||||
BandText.Text = band?.Name ?? "no band";
|
||||
if (session.Position is null || band is null)
|
||||
{
|
||||
View.Spots = [];
|
||||
View.Vfos = [];
|
||||
View.Segments = null;
|
||||
StatusText.Text = session.Position is null ? "no contest is open" : "off band";
|
||||
View.InvalidateVisual();
|
||||
return;
|
||||
}
|
||||
@@ -58,21 +123,76 @@ public sealed partial class BandmapWindow : RefreshableWindow
|
||||
(Frequency low, Frequency high) = Window(band, session.Position.Frequency);
|
||||
View.Low = low;
|
||||
View.High = high;
|
||||
View.TickStep = StepFor(high.Hertz - low.Hertz);
|
||||
View.Spots = session.Bandmap.On(band);
|
||||
long shown = high.Hertz - low.Hertz;
|
||||
View.TickStep = StepFor(shown);
|
||||
View.DenseTicks = shown is > 40_000 and <= 200_000;
|
||||
View.Spots = WithCqFrequency(session.Bandmap.On(band), band);
|
||||
View.Vfos = Vfos();
|
||||
View.Segments = session.BandPlan.For(band);
|
||||
StatusText.Text =
|
||||
$"{View.Spots.Count(s => s.IsStation)} stations · " +
|
||||
$"{low.Kilohertz:0.#} to {high.Kilohertz:0.#} kHz{Split(band)}";
|
||||
View.InvalidateVisual();
|
||||
_ = JudgeAsync();
|
||||
}
|
||||
|
||||
/// The band plan boundary, so the two shades behind the scale have a name.
|
||||
private string Split(Band band) =>
|
||||
session.BandPlan.For(band) is { HasPhone: true } segments
|
||||
? $" · CW/phone {segments.CwHigh.Kilohertz:0.#}"
|
||||
: "";
|
||||
/// What each callsign is worth, as of the last pass. The colours are looked
|
||||
/// up when the view draws, so the log is never searched on the UI thread.
|
||||
private Dictionary<Spot, Verdict?> verdicts = new(ReferenceEqualityComparer.Instance);
|
||||
private bool judging;
|
||||
private bool judgeAgain;
|
||||
|
||||
/// Judges every spot on another thread and draws again when that is done.
|
||||
/// A request made while a pass is running is answered by one more pass.
|
||||
private async Task JudgeAsync()
|
||||
{
|
||||
if (judging)
|
||||
{
|
||||
judgeAgain = true;
|
||||
return;
|
||||
}
|
||||
judging = true;
|
||||
try
|
||||
{
|
||||
do
|
||||
{
|
||||
judgeAgain = false;
|
||||
OperatingPosition? position = session.Position;
|
||||
Mode? mode = position?.Mode;
|
||||
string contest = position?.Contest.Name ?? "";
|
||||
IReadOnlyList<Spot> asked = View.Spots;
|
||||
Dictionary<Spot, Verdict?> judged = await Task.Run(() =>
|
||||
{
|
||||
Dictionary<Spot, Verdict?> found = new(ReferenceEqualityComparer.Instance);
|
||||
foreach (Spot spot in asked)
|
||||
{
|
||||
found[spot] = VerdictFor(position, mode, contest, spot);
|
||||
}
|
||||
return found;
|
||||
});
|
||||
if (judgeAgain)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
verdicts = judged;
|
||||
View.InvalidateVisual();
|
||||
}
|
||||
while (judgeAgain);
|
||||
}
|
||||
finally
|
||||
{
|
||||
judging = false;
|
||||
}
|
||||
}
|
||||
|
||||
/// The bandmap's spots with the pseudospot for the CQ frequency, when the
|
||||
/// position has one on this band. It is added here and not to the bandmap,
|
||||
/// so it does not age out and the other windows do not list it.
|
||||
private IReadOnlyList<Spot> WithCqFrequency(IReadOnlyList<Spot> spots, Band band)
|
||||
{
|
||||
if (session.Position?.CqFrequency is not { } cq || Bands.ForFrequency(cq) != band)
|
||||
{
|
||||
return spots;
|
||||
}
|
||||
return [.. spots.Append(Spot.CqFrequency(cq, DateTime.UtcNow)).OrderBy(s => s.Frequency.Hertz)];
|
||||
}
|
||||
|
||||
/// Green for where the operator is listening, red for where the radio
|
||||
/// transmits when working split, orange for the other radio of a two-radio
|
||||
@@ -83,42 +203,51 @@ public sealed partial class BandmapWindow : RefreshableWindow
|
||||
{
|
||||
return [];
|
||||
}
|
||||
Frequency width = Modes.Bandwidth(session.Position.Mode);
|
||||
List<VfoMarker> markers =
|
||||
[
|
||||
VfoMarker.Centred(session.Position.Frequency, width, VfoRole.Receive),
|
||||
VfoMarker.For(session.Position.Frequency, session.Position.Mode, VfoRole.Receive),
|
||||
];
|
||||
if (session.Position.TransmitFrequency.Hertz > 0)
|
||||
{
|
||||
markers.Add(VfoMarker.Centred(
|
||||
session.Position.TransmitFrequency, width, VfoRole.Transmit));
|
||||
markers.Add(VfoMarker.For(
|
||||
session.Position.TransmitFrequency, session.Position.Mode, VfoRole.Transmit));
|
||||
}
|
||||
foreach (Radio other in session.Radios.Where(r => r.Number != session.ActiveRadioNumber))
|
||||
{
|
||||
if (other.State is { } state)
|
||||
{
|
||||
markers.Add(VfoMarker.Centred(
|
||||
state.Frequency, Modes.Bandwidth(state.Mode), VfoRole.Second));
|
||||
markers.Add(VfoMarker.For(state.Frequency, state.Mode, VfoRole.Second));
|
||||
}
|
||||
}
|
||||
return markers;
|
||||
}
|
||||
|
||||
/// The slice to show, centred on the receiver. Contest operating goes
|
||||
/// outside the band edges, so the slice stretches to wherever the receiver
|
||||
/// is rather than leaving it off the top of the scale.
|
||||
private (Frequency Low, Frequency High) Window(Band band, Frequency centre)
|
||||
private (Frequency Low, Frequency High) Window(Band band, Frequency receiver)
|
||||
{
|
||||
long lowEdge = Math.Min(band.Low.Hertz, centre.Hertz);
|
||||
long highEdge = Math.Max(band.High.Hertz, centre.Hertz);
|
||||
Frequency span = Spans[Math.Max(0, SpanBox.SelectedIndex)].Span;
|
||||
if (span.Hertz == 0 || span.Hertz >= highEdge - lowEdge)
|
||||
long span = Spans[Math.Max(0, SpanBox.SelectedIndex)].Hertz;
|
||||
(Frequency low, Frequency high) = span == PartOfBand
|
||||
? BandmapSlice.Part(band, session.BandPlan.For(band), receiver)
|
||||
: BandmapSlice.Choose(band, receiver, span, CentreBox.IsChecked == true, sliceLow);
|
||||
sliceLow = low;
|
||||
return (low, high);
|
||||
}
|
||||
|
||||
/// One wheel notch moves one step along the span list. Unless the slice
|
||||
/// follows the receiver, the frequency under the pointer stays where it is.
|
||||
private void Zoom(BandmapZoom zoom)
|
||||
{
|
||||
int next = Math.Clamp(SpanBox.SelectedIndex + (zoom.In ? -1 : 1), 0, Spans.Length - 1);
|
||||
if (next == SpanBox.SelectedIndex)
|
||||
{
|
||||
return (Frequency.FromHertz(lowEdge), Frequency.FromHertz(highEdge));
|
||||
return;
|
||||
}
|
||||
long half = span.Hertz / 2;
|
||||
long low = Math.Clamp(centre.Hertz - half, lowEdge, highEdge - span.Hertz);
|
||||
return (Frequency.FromHertz(low), Frequency.FromHertz(low + span.Hertz));
|
||||
long shown = View.High.Hertz - View.Low.Hertz;
|
||||
long span = Spans[next].Hertz;
|
||||
if (span > 0)
|
||||
{
|
||||
sliceLow = BandmapSlice.Zoom(View.Low, shown, span, zoom.At);
|
||||
}
|
||||
SpanBox.SelectedIndex = next;
|
||||
}
|
||||
|
||||
private static Frequency StepFor(long span) => span switch
|
||||
@@ -129,11 +258,14 @@ public sealed partial class BandmapWindow : RefreshableWindow
|
||||
_ => Frequency.FromKilohertz(50),
|
||||
};
|
||||
|
||||
private IBrush Colour(Spot spot) => Verdicts.Colour(VerdictFor(spot));
|
||||
private IBrush Colour(Spot spot) =>
|
||||
spot.IsCqFrequency
|
||||
? CqBrush
|
||||
: Verdicts.Colour(verdicts.GetValueOrDefault(spot));
|
||||
|
||||
private Verdict? VerdictFor(Spot spot)
|
||||
private static Verdict? VerdictFor(OperatingPosition? position, Mode? mode, string contest, Spot spot)
|
||||
{
|
||||
if (session.Position is null)
|
||||
if (position is null || mode is null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
@@ -142,14 +274,14 @@ public sealed partial class BandmapWindow : RefreshableWindow
|
||||
// N1MM marks a busy frequency as worked, so it is painted like one
|
||||
return Verdict.Dupe;
|
||||
}
|
||||
return session.Position.Log.Judge(new Qso
|
||||
return position.Log.Judge(new Qso
|
||||
{
|
||||
Id = "",
|
||||
TimestampUtc = DateTime.UtcNow,
|
||||
Call = spot.Call,
|
||||
Frequency = spot.Frequency,
|
||||
Mode = session.Position.Mode,
|
||||
ContestName = session.Position.Contest.Name,
|
||||
Mode = mode,
|
||||
ContestName = contest,
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
using Nonemm.App.Theming;
|
||||
using Avalonia;
|
||||
using Avalonia.Controls;
|
||||
using Avalonia.Input;
|
||||
@@ -45,7 +46,7 @@ public sealed partial class CallStackWindow : RefreshableWindow
|
||||
TextBlock text = new()
|
||||
{
|
||||
Text = call,
|
||||
FontFamily = new FontFamily("monospace"),
|
||||
FontFamily = Fonts.Mono,
|
||||
FontSize = 14,
|
||||
Foreground = Verdicts.Colour(position.JudgeCall(call)),
|
||||
};
|
||||
|
||||
@@ -0,0 +1,45 @@
|
||||
using Avalonia.Media;
|
||||
|
||||
namespace Nonemm.App.Windows;
|
||||
|
||||
/// The twelve palettes N1MM's statistics graph offers. The names are the ones
|
||||
/// in N1MM's box, which are the .NET chart control's palettes; the colours are
|
||||
/// chosen to match the name, not copied out of that control.
|
||||
public static class ChartPalettes
|
||||
{
|
||||
public static readonly IReadOnlyList<string> Names =
|
||||
[
|
||||
"Berry", "Bright", "Bright Pastel", "Chocolate", "Earth Tones", "Excel",
|
||||
"Fire", "Gray Scale", "Light", "Pastel", "Sea Green", "Semi Transparent",
|
||||
];
|
||||
|
||||
private static readonly Dictionary<string, uint[]> Colours = new()
|
||||
{
|
||||
["Berry"] = [0x8A2BE2, 0xBA55D3, 0xC71585, 0xDA70D6, 0x7B68EE, 0x9370DB, 0xFF69B4, 0x4B0082],
|
||||
["Bright"] = [0x1F77B4, 0xFF7F0E, 0x2CA02C, 0xD62728, 0x9467BD, 0x8C564B, 0xE377C2, 0x17BECF],
|
||||
["Bright Pastel"] = [0x418CF0, 0xFCB441, 0xE0400A, 0x056492, 0xBFBFBF, 0x1A3B69, 0xFFE382, 0x129CDD],
|
||||
["Chocolate"] = [0x5B3A29, 0x8B4513, 0xA0522D, 0xCD853F, 0xD2B48C, 0x6B4226, 0xB87333, 0xE3C6A0],
|
||||
["Earth Tones"] = [0x6B8E23, 0x808000, 0xBDB76B, 0x8B7355, 0x556B2F, 0xA0522D, 0xC0A16B, 0x4F5D2F],
|
||||
["Excel"] = [0x4472C4, 0xED7D31, 0xA5A5A5, 0xFFC000, 0x5B9BD5, 0x70AD47, 0x264478, 0x9E480E],
|
||||
["Fire"] = [0xB22222, 0xE34A00, 0xFF8C00, 0xFFC000, 0xFFE873, 0x8B0000, 0xFF4500, 0xFFA07A],
|
||||
["Gray Scale"] = [0x2B2B2B, 0x4D4D4D, 0x6E6E6E, 0x8F8F8F, 0xB0B0B0, 0xC9C9C9, 0xE0E0E0, 0xF2F2F2],
|
||||
["Light"] = [0xA6CEE3, 0xB2DF8A, 0xFDBF6F, 0xCAB2D6, 0xFB9A99, 0xFFFF99, 0xB3E2CD, 0xD9D9D9],
|
||||
["Pastel"] = [0xAEC7E8, 0xFFBB78, 0x98DF8A, 0xFF9896, 0xC5B0D5, 0xC49C94, 0xF7B6D2, 0x9EDAE5],
|
||||
["Sea Green"] = [0x2E8B57, 0x3CB371, 0x20B2AA, 0x66CDAA, 0x008B8B, 0x5F9EA0, 0x8FBC8F, 0x006400],
|
||||
["Semi Transparent"] = [0x1F77B4, 0xFF7F0E, 0x2CA02C, 0xD62728, 0x9467BD, 0x8C564B, 0xE377C2, 0x17BECF],
|
||||
};
|
||||
|
||||
/// The palette of that name, or the first one when there is no such name.
|
||||
/// A series past the end of the list takes a colour again from the start,
|
||||
/// as the chart control does.
|
||||
public static IReadOnlyList<Color> Of(string name)
|
||||
{
|
||||
uint[] values = Colours.TryGetValue(name, out uint[]? found) ? found : Colours["Berry"];
|
||||
byte alpha = name == "Semi Transparent" ? (byte)0xA0 : (byte)0xFF;
|
||||
return [.. values.Select(v => Color.FromArgb(
|
||||
alpha,
|
||||
(byte)(v >> 16),
|
||||
(byte)(v >> 8),
|
||||
(byte)v))];
|
||||
}
|
||||
}
|
||||
@@ -1,3 +1,5 @@
|
||||
using Nonemm.App.Configuration;
|
||||
using Nonemm.App.Theming;
|
||||
using Avalonia.Controls;
|
||||
using Avalonia.Layout;
|
||||
using Avalonia.Media;
|
||||
@@ -16,39 +18,105 @@ public sealed partial class CheckWindow : RefreshableWindow
|
||||
{
|
||||
this.session = session;
|
||||
InitializeComponent();
|
||||
_ = new FontZoom(this, new Settings().CheckFontSize, () => session.Settings.CheckFontSize, size =>
|
||||
{
|
||||
session.Save(session.Settings with { CheckFontSize = size });
|
||||
Refresh();
|
||||
});
|
||||
Refresh();
|
||||
}
|
||||
|
||||
|
||||
public override void RefreshForEntry() => Refresh();
|
||||
|
||||
private bool running;
|
||||
private bool again;
|
||||
|
||||
/// The search runs on another thread, so a key press never waits for it.
|
||||
/// A request that comes in while one is running is answered by one more
|
||||
/// run afterwards, which sees the latest call.
|
||||
public override void Refresh()
|
||||
{
|
||||
Columns.Children.Clear();
|
||||
if (session.Check is null)
|
||||
if (running)
|
||||
{
|
||||
again = true;
|
||||
return;
|
||||
}
|
||||
IReadOnlyList<CheckColumn> columns = session.Check.Columns();
|
||||
Columns.ColumnDefinitions.Clear();
|
||||
foreach (CheckColumn _ in columns)
|
||||
_ = RunAsync();
|
||||
}
|
||||
|
||||
private async Task RunAsync()
|
||||
{
|
||||
running = true;
|
||||
try
|
||||
{
|
||||
Columns.ColumnDefinitions.Add(new ColumnDefinition(GridLength.Star));
|
||||
do
|
||||
{
|
||||
again = false;
|
||||
await ShowColumns();
|
||||
}
|
||||
while (again);
|
||||
}
|
||||
int at = 0;
|
||||
foreach (CheckColumn column in columns)
|
||||
finally
|
||||
{
|
||||
Control panel = BuildColumn(column);
|
||||
Grid.SetColumn(panel, at++);
|
||||
Columns.Children.Add(panel);
|
||||
running = false;
|
||||
}
|
||||
}
|
||||
|
||||
private static Control BuildColumn(CheckColumn column)
|
||||
private async Task ShowColumns()
|
||||
{
|
||||
if (session.Check is null)
|
||||
{
|
||||
shown.Clear();
|
||||
Columns.Children.Clear();
|
||||
return;
|
||||
}
|
||||
IReadOnlyList<CheckColumn> columns = await session.Check.ColumnsAsync();
|
||||
int fontSize = session.Settings.CheckFontSize;
|
||||
// a column is built again only when what it shows is different: most
|
||||
// key presses change one or two of the five
|
||||
if (shown.Count != columns.Count || Columns.Children.Count != columns.Count)
|
||||
{
|
||||
shown.Clear();
|
||||
Columns.Children.Clear();
|
||||
Columns.ColumnDefinitions.Clear();
|
||||
foreach (CheckColumn _ in columns)
|
||||
{
|
||||
Columns.ColumnDefinitions.Add(new ColumnDefinition(GridLength.Star));
|
||||
shown.Add("");
|
||||
Columns.Children.Add(new Panel());
|
||||
}
|
||||
}
|
||||
for (int at = 0; at < columns.Count; at++)
|
||||
{
|
||||
string signature = Signature(columns[at], fontSize);
|
||||
if (signature == shown[at])
|
||||
{
|
||||
continue;
|
||||
}
|
||||
shown[at] = signature;
|
||||
Control panel = BuildColumn(columns[at], fontSize);
|
||||
Grid.SetColumn(panel, at);
|
||||
Columns.Children[at] = panel;
|
||||
}
|
||||
}
|
||||
|
||||
/// What the column shows, as text.
|
||||
private readonly List<string> shown = [];
|
||||
|
||||
private static string Signature(CheckColumn column, int fontSize) =>
|
||||
$"{fontSize}|{column.Source}|{column.Held}|" + string.Join(
|
||||
';',
|
||||
column.Candidates.Select(c =>
|
||||
$"{c.Text}:{c.Quality}:{c.Verdict?.IsDupe}:{c.Verdict?.Points}:{c.Verdict?.NewMultipliers.Count}"));
|
||||
|
||||
private static Control BuildColumn(CheckColumn column, int fontSize)
|
||||
{
|
||||
StackPanel panel = new() { Margin = new Avalonia.Thickness(0, 0, 8, 0) };
|
||||
panel.Children.Add(new TextBlock
|
||||
{
|
||||
Text = $"{Heading(column.Source)} {Count(column)}",
|
||||
FontSize = 11,
|
||||
FontSize = fontSize - 3,
|
||||
Opacity = 0.7,
|
||||
Margin = new Avalonia.Thickness(0, 0, 0, 4),
|
||||
});
|
||||
@@ -57,8 +125,8 @@ public sealed partial class CheckWindow : RefreshableWindow
|
||||
panel.Children.Add(new TextBlock
|
||||
{
|
||||
Text = candidate.Text,
|
||||
FontFamily = new FontFamily("monospace"),
|
||||
FontSize = 14,
|
||||
FontFamily = Fonts.Mono,
|
||||
FontSize = fontSize,
|
||||
Foreground = Verdicts.Colour(candidate.Verdict),
|
||||
HorizontalAlignment = HorizontalAlignment.Left,
|
||||
});
|
||||
|
||||
@@ -0,0 +1,28 @@
|
||||
using Avalonia.Threading;
|
||||
|
||||
namespace Nonemm.App.Windows;
|
||||
|
||||
/// Runs an action on the UI thread once for any number of requests made before
|
||||
/// it runs. A radio turning its dial or a busy cluster raises an event many
|
||||
/// times a second, and each window only needs to redraw once the burst has been
|
||||
/// handled.
|
||||
public sealed class Coalesced(Action action)
|
||||
{
|
||||
private int pending;
|
||||
|
||||
/// Safe to call from any thread.
|
||||
public void Request()
|
||||
{
|
||||
if (Interlocked.Exchange(ref pending, 1) == 1)
|
||||
{
|
||||
return;
|
||||
}
|
||||
Dispatcher.UIThread.Post(
|
||||
() =>
|
||||
{
|
||||
Volatile.Write(ref pending, 0);
|
||||
action();
|
||||
},
|
||||
DispatcherPriority.Background);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,36 @@
|
||||
using System.Globalization;
|
||||
using Avalonia.Controls;
|
||||
using Avalonia.Media;
|
||||
|
||||
namespace Nonemm.App.Windows;
|
||||
|
||||
/// Stops a grid column being dragged, or sized to its cells, narrower than its
|
||||
/// own heading.
|
||||
public static class ColumnWidths
|
||||
{
|
||||
/// What a header takes besides its text: its padding and the room the theme
|
||||
/// keeps for the sort arrow.
|
||||
private const double HeaderPadding = 40;
|
||||
|
||||
/// The width of the heading in the grid's font, with the room the arrow
|
||||
/// needs.
|
||||
public static double ForHeader(DataGrid grid, string heading) =>
|
||||
new FormattedText(
|
||||
heading,
|
||||
CultureInfo.InvariantCulture,
|
||||
FlowDirection.LeftToRight,
|
||||
new Typeface(grid.FontFamily, FontStyle.Normal, FontWeight.Bold),
|
||||
grid.FontSize,
|
||||
null).Width + HeaderPadding;
|
||||
|
||||
public static void KeepHeadersReadable(DataGrid grid)
|
||||
{
|
||||
foreach (DataGridColumn column in grid.Columns)
|
||||
{
|
||||
if (column.Header is string heading)
|
||||
{
|
||||
column.MinWidth = ForHeader(grid, heading);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -3,7 +3,9 @@ using Avalonia.Controls;
|
||||
using Avalonia.Input;
|
||||
using Avalonia.Interactivity;
|
||||
using Avalonia.Media;
|
||||
using Avalonia.Threading;
|
||||
using Avalonia.VisualTree;
|
||||
using Nonemm.App.Theming;
|
||||
using Nonemm.Session;
|
||||
|
||||
namespace Nonemm.App.Windows;
|
||||
@@ -59,7 +61,7 @@ public sealed partial class DigitalWindow
|
||||
TextBlock text = new()
|
||||
{
|
||||
Text = call,
|
||||
FontFamily = new FontFamily("monospace"),
|
||||
FontFamily = Fonts.Mono,
|
||||
FontSize = Settings.DigitalFontSize,
|
||||
Foreground = Verdicts.Colour(position.JudgeCall(call)),
|
||||
};
|
||||
@@ -229,6 +231,10 @@ public sealed partial class DigitalWindow
|
||||
RightClick(e);
|
||||
return;
|
||||
}
|
||||
if (TakenAsQtc(e))
|
||||
{
|
||||
return;
|
||||
}
|
||||
string clicked = e.Source is TextBlock block ? DigitalReceiver.Scrub(block.Text ?? "") : "";
|
||||
if (clicked.Length == 0)
|
||||
{
|
||||
@@ -250,6 +256,51 @@ public sealed partial class DigitalWindow
|
||||
Copy(clicked, keys.HasFlag(KeyModifiers.Alt), e.ClickCount > 1);
|
||||
}
|
||||
|
||||
/// While the QTC window is taking traffic down on RTTY, a click anywhere in
|
||||
/// a line hands the whole line to it rather than picking the word out: the
|
||||
/// other station sends the header and the whole series in one
|
||||
/// transmission, and the operator clicks each line as it prints. The line
|
||||
/// flashes to show which one was taken, which is what N1MM does with it.
|
||||
/// False when there is no QTC window, or the line is not a QTC, and then
|
||||
/// the click means what it always means.
|
||||
private bool TakenAsQtc(PointerPressedEventArgs e)
|
||||
{
|
||||
if (session.QtcLines is not { } take || LineUnder(e.Source as Visual) is not { } border)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
string text = DigitalReceiver.Scrub(string.Concat(
|
||||
Body(border).Children.OfType<TextBlock>().Select(b => b.Text ?? "")));
|
||||
if (text.Trim().Length == 0 || !take(text))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
Flash(border);
|
||||
return true;
|
||||
}
|
||||
|
||||
/// The line a clicked control belongs to: the border a printed line lives
|
||||
/// in, walking up from whatever was under the pointer.
|
||||
private static Border? LineUnder(Visual? clicked)
|
||||
{
|
||||
for (Visual? at = clicked; at is not null; at = at.GetVisualParent())
|
||||
{
|
||||
if (at is Border border && border.Child is WrapPanel)
|
||||
{
|
||||
return border;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/// A moment of colour behind the line that was taken.
|
||||
private static void Flash(Border border)
|
||||
{
|
||||
IBrush was = border.Background ?? Brushes.Transparent;
|
||||
border.Background = Themes.Brush(Themes.Current.QuickEdit);
|
||||
DispatcherTimer.RunOnce(() => border.Background = was, TimeSpan.FromMilliseconds(400));
|
||||
}
|
||||
|
||||
/// Where a clicked word goes. N1MM's order: an empty callsign box takes a
|
||||
/// call, a callsign box that already holds one takes another only onto the
|
||||
/// call stack or on a double click, and everything else is an exchange
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
<local:RefreshableWindow xmlns="https://github.com/avaloniaui"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:local="using:Nonemm.App.Windows"
|
||||
xmlns:theming="using:Nonemm.App.Theming"
|
||||
xmlns:controls="using:Nonemm.App.Controls"
|
||||
x:Class="Nonemm.App.Windows.DigitalWindow"
|
||||
Title="Digital Interface" Width="900" Height="640">
|
||||
@@ -29,7 +30,7 @@
|
||||
<Setter Property="Margin" Value="6,0,4,0" />
|
||||
</Style>
|
||||
<Style Selector="TextBlock.readout">
|
||||
<Setter Property="FontFamily" Value="monospace" />
|
||||
<Setter Property="FontFamily" Value="{x:Static theming:Fonts.Mono}" />
|
||||
<Setter Property="FontSize" Value="12" />
|
||||
<Setter Property="VerticalAlignment" Value="Center" />
|
||||
<Setter Property="Margin" Value="4,2" />
|
||||
@@ -173,7 +174,7 @@
|
||||
text, so the two wrap together and neither takes width from the
|
||||
other -->
|
||||
<controls:TransmitPane Name="TransmitBox" AcceptsReturn="True" TextWrapping="Wrap"
|
||||
FontFamily="monospace"
|
||||
FontFamily="{x:Static theming:Fonts.Mono}"
|
||||
KeyDown="OnTransmitKeyDown"
|
||||
TextChanged="OnTransmitTextChanged" />
|
||||
</Border>
|
||||
|
||||
@@ -437,7 +437,7 @@ public sealed partial class DigitalWindow : RefreshableWindow
|
||||
private TextBlock NewBlock(string text) => new()
|
||||
{
|
||||
Text = text,
|
||||
FontFamily = new FontFamily("monospace"),
|
||||
FontFamily = Fonts.Mono,
|
||||
FontSize = Settings.DigitalFontSize,
|
||||
};
|
||||
|
||||
|
||||
@@ -130,7 +130,7 @@ public sealed partial class EntryWindow
|
||||
ModeCategory.Digital => Modes.Rtty,
|
||||
_ => Modes.Cw,
|
||||
};
|
||||
Logging.Tune(where, wanted);
|
||||
session.TuneHere(Logging, where, wanted);
|
||||
_ = session.Radio?.TuneAsync(where);
|
||||
boxes[0].Focus();
|
||||
Refresh();
|
||||
|
||||
@@ -12,10 +12,6 @@ namespace Nonemm.App.Windows;
|
||||
/// which is how a station is worked without typing its call.
|
||||
public sealed partial class EntryWindow
|
||||
{
|
||||
/// Where we last called CQ, so the frame can say so when the radio comes
|
||||
/// back to it.
|
||||
private Frequency cqFrequency;
|
||||
|
||||
/// What the frame holds, when it holds a callsign. `CQ-Frequency` is not
|
||||
/// one, and neither is nothing.
|
||||
private string framedCall = "";
|
||||
@@ -35,7 +31,7 @@ public sealed partial class EntryWindow
|
||||
CallFrameText.Text = "";
|
||||
return;
|
||||
}
|
||||
if (cqFrequency.Hertz > 0
|
||||
if (Logging.CqFrequency is { } cqFrequency
|
||||
&& Math.Abs(Logging.Frequency.Hertz - cqFrequency.Hertz) <= TuningTolerance.Hertz)
|
||||
{
|
||||
CallFrameText.Text = "CQ-Frequency";
|
||||
@@ -86,7 +82,7 @@ public sealed partial class EntryWindow
|
||||
{
|
||||
if (Logging is not null)
|
||||
{
|
||||
cqFrequency = Logging.Frequency;
|
||||
Logging.CqFrequency = Logging.Frequency;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -32,7 +32,7 @@ public sealed partial class EntryWindow
|
||||
IsRunning = Logging.IsRunning,
|
||||
HasCall = Logging.Entry.Call.Trim().Length > 0,
|
||||
IsDupe = Logging.Verdict()?.IsDupe == true,
|
||||
HasExchange = Logging.Entry.IsComplete,
|
||||
HasExchange = Logging.IsEntryComplete,
|
||||
CallSent = callSent,
|
||||
ExchangeSent = exchangeSent,
|
||||
SendsCallOnce = session.Settings.EsmSendsCallOnce,
|
||||
|
||||
@@ -16,13 +16,10 @@ public sealed partial class EntryWindow
|
||||
/// actions after `{END}` still run.
|
||||
private static readonly TimeSpan SendingPatience = TimeSpan.FromMinutes(2);
|
||||
|
||||
/// What sends this radio's messages: the digital engine on a digital mode,
|
||||
/// and the CW or voice keyer otherwise. A message therefore goes out the
|
||||
/// way the mode needs without the caller choosing.
|
||||
/// What sends this radio's messages, which the mode decides: a message
|
||||
/// therefore goes out the way the mode needs without the caller choosing.
|
||||
private MessageSender? Sender =>
|
||||
Logging?.Mode.Category == ModeCategory.Digital && session.DigitalKeyer is { IsReady: true } engine
|
||||
? engine
|
||||
: session.Keyer;
|
||||
session.SenderFor(Logging?.Mode.Category ?? ModeCategory.Cw);
|
||||
|
||||
/// What to say when a message has nowhere to go. The mode decides which
|
||||
/// keyer a message uses, so the mode is part of the answer: an operator on
|
||||
@@ -83,6 +80,11 @@ public sealed partial class EntryWindow
|
||||
Refresh();
|
||||
}
|
||||
|
||||
/// True while a key is sending another key's message, so a message that
|
||||
/// names its own key — or two that name each other — stops there instead
|
||||
/// of going round for ever.
|
||||
private bool sendingAnotherKey;
|
||||
|
||||
private void SendMessage(int index) => _ = SendKeyAsync(index);
|
||||
|
||||
/// Sends one function key's message. The task finishes when the text has
|
||||
@@ -100,6 +102,9 @@ public sealed partial class EntryWindow
|
||||
{
|
||||
return;
|
||||
}
|
||||
// the microphone cannot be recorded and transmitted at the same time,
|
||||
// and N1MM ends a recording on anything that sends as well
|
||||
StopRecording();
|
||||
MessagePlan plan = MessagePlan.Read(template, Logging, session.Other(Logging));
|
||||
foreach (MessageAction action in plan.Before)
|
||||
{
|
||||
@@ -185,6 +190,8 @@ public sealed partial class EntryWindow
|
||||
{
|
||||
try
|
||||
{
|
||||
// what the other operators read in their network status window
|
||||
sendingWhat = text.Length > 40 ? text[..40] : text;
|
||||
sending = true;
|
||||
Refresh();
|
||||
await keyer.SendAsync(text);
|
||||
@@ -357,6 +364,45 @@ public sealed partial class EntryWindow
|
||||
_ = session.Digital?.ReturnToReceiveAsync();
|
||||
}
|
||||
break;
|
||||
case MessageCommand.CursorToCall:
|
||||
boxes[0].Focus();
|
||||
break;
|
||||
case MessageCommand.SendKey:
|
||||
if (!sendingAnotherKey
|
||||
&& int.TryParse(action.Argument, out int key)
|
||||
&& key is >= 1 and <= MessageFile.KeyCount)
|
||||
{
|
||||
sendingAnotherKey = true;
|
||||
try
|
||||
{
|
||||
SendMessage(key - 1);
|
||||
}
|
||||
finally
|
||||
{
|
||||
sendingAnotherKey = false;
|
||||
}
|
||||
}
|
||||
break;
|
||||
case MessageCommand.CallCq:
|
||||
// what F1 does by itself: a CQ puts the station in run mode and
|
||||
// carries alternating CQ on to the other radio
|
||||
Logging.IsRunning = true;
|
||||
RememberCqFrequency();
|
||||
session.Alternating?.CarryOn();
|
||||
CqSent?.Invoke(this, EventArgs.Empty);
|
||||
break;
|
||||
case MessageCommand.SendQtc:
|
||||
_ = OpenQtcWindow(QtcDirection.Send);
|
||||
break;
|
||||
case MessageCommand.ReceiveQtc:
|
||||
_ = OpenQtcWindow(QtcDirection.Receive);
|
||||
break;
|
||||
case MessageCommand.ClearRit:
|
||||
_ = session.Radio?.ClearRitAsync();
|
||||
break;
|
||||
case MessageCommand.LogAnyway:
|
||||
LogContactAnyway();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -430,7 +476,7 @@ public sealed partial class EntryWindow
|
||||
return;
|
||||
}
|
||||
Frequency moved = Frequency.FromHertz(Logging.Frequency.Hertz + hertz);
|
||||
Logging.Tune(moved);
|
||||
session.TuneHere(Logging, moved);
|
||||
_ = session.Radio?.TuneAsync(moved);
|
||||
Refresh();
|
||||
}
|
||||
@@ -453,7 +499,7 @@ public sealed partial class EntryWindow
|
||||
string comment = MessageExpander.Expand(
|
||||
session.Settings.SpotComment, Logging, session.Other(Logging));
|
||||
_ = cluster.SendSpotAsync(Logging.Frequency, me, comment);
|
||||
session.Bandmap.Add(new Spot(me, Logging.Frequency, DateTime.UtcNow, SpotSource.Operator));
|
||||
session.Bandmap.Add(new Spot(me, Logging.Frequency, DateTime.UtcNow, SpotSource.Operator) { Computer = session.ComputerName });
|
||||
Status($"spotted {me.Text} on {Logging.Frequency.Kilohertz:0.0}");
|
||||
}
|
||||
|
||||
|
||||
@@ -122,6 +122,7 @@ public sealed partial class EntryWindow
|
||||
TransmitterCategory = Logging.Instance.TransmitterCategory,
|
||||
OverlayCategory = Logging.Instance.OverlayCategory,
|
||||
TimeCategory = Logging.Instance.TimeCategory,
|
||||
Location = CabrilloLocation(Logging.Me),
|
||||
ClaimedScore = Logging.Log.TotalScore,
|
||||
Club = Logging.Me.Club,
|
||||
Name = Logging.Me.Name,
|
||||
@@ -132,25 +133,58 @@ public sealed partial class EntryWindow
|
||||
Status($"{Logging.Log.Qsos.Count} contacts written to {Path.GetFileName(path)}");
|
||||
}
|
||||
|
||||
private async void OnExportAdif(object? sender, RoutedEventArgs e)
|
||||
/// The section, state or province for a station in the US or Canada, and
|
||||
/// `DX` for any other station.
|
||||
private static string CabrilloLocation(StationInfo me)
|
||||
{
|
||||
foreach (string place in new[] { me.ArrlSection, me.State, me.Province })
|
||||
{
|
||||
if (place.Trim().Length > 0)
|
||||
{
|
||||
return place.Trim().ToUpperInvariant();
|
||||
}
|
||||
}
|
||||
return "DX";
|
||||
}
|
||||
|
||||
/// The contacts alone, which is the file to hand to another program. ADIF
|
||||
/// has no QTC record, and N1MM leaves the traffic out for that reason.
|
||||
private void OnExportAdif(object? sender, RoutedEventArgs e) =>
|
||||
_ = ExportAdif(withQtcTraffic: false);
|
||||
|
||||
/// The whole log, traffic included, which is the file to read back into
|
||||
/// this program. The QTC rows carry their traffic in fields of our own;
|
||||
/// another program reads each of them as a contact with the station the
|
||||
/// traffic was exchanged with.
|
||||
private void OnExportAdifWithQtcs(object? sender, RoutedEventArgs e) =>
|
||||
_ = ExportAdif(withQtcTraffic: true);
|
||||
|
||||
private async Task ExportAdif(bool withQtcTraffic)
|
||||
{
|
||||
if (Logging is null)
|
||||
{
|
||||
Status("no contest is open");
|
||||
return;
|
||||
}
|
||||
string suffix = withQtcTraffic ? "-with-qtcs" : "";
|
||||
IStorageFile? file = await StorageProvider.SaveFilePickerAsync(new FilePickerSaveOptions
|
||||
{
|
||||
Title = "Export ADIF",
|
||||
SuggestedFileName = $"{session.Settings.Station.Callsign}.adi",
|
||||
Title = withQtcTraffic ? "Export ADIF with QTC traffic" : "Export ADIF",
|
||||
SuggestedFileName = $"{session.Settings.Station.Callsign}{suffix}.adi",
|
||||
SuggestedStartLocation = await Folder(session.Paths.ExportFiles),
|
||||
});
|
||||
if (file?.TryGetLocalPath() is not { } path)
|
||||
{
|
||||
return;
|
||||
}
|
||||
await File.WriteAllTextAsync(path, new AdifWriter(Logging.Me).Write(Logging.Log.Qsos));
|
||||
Status($"{Logging.Log.Qsos.Count} contacts written to {Path.GetFileName(path)}");
|
||||
List<Qso> written = [.. withQtcTraffic ? Logging.Log.Qsos : Logging.Log.Contacts];
|
||||
await File.WriteAllTextAsync(
|
||||
path, new AdifWriter(Logging.Me).Write(written, withQtcTraffic));
|
||||
int traffic = written.Count(q => !Logging.Contest.IsContact(q));
|
||||
string what = traffic > 0
|
||||
? $"{written.Count - traffic} contacts and {traffic} QTCs"
|
||||
: $"{written.Count} contacts";
|
||||
Status($"{what} written to {Path.GetFileName(path)}");
|
||||
}
|
||||
|
||||
private async void OnImportAdif(object? sender, RoutedEventArgs e)
|
||||
@@ -286,7 +320,8 @@ public sealed partial class EntryWindow
|
||||
for (int at = 0; at < Logging.Entry.Exchange.Count; at++)
|
||||
{
|
||||
ExchangeField field = Logging.Entry.Exchange[at];
|
||||
if ((field.Kind != ExchangeFieldKind.Number && field.Slot != ExchangeSlot.Exchange1) ||
|
||||
if (field.IsSent ||
|
||||
(field.Kind != ExchangeFieldKind.Number && field.Slot != ExchangeSlot.Exchange1) ||
|
||||
!int.TryParse(Logging.Entry[at + 1].Trim(), out int number) || number <= 0)
|
||||
{
|
||||
continue;
|
||||
@@ -350,7 +385,7 @@ public sealed partial class EntryWindow
|
||||
return;
|
||||
}
|
||||
await cluster.SendSpotAsync(where, call, MessageExpander.Expand(session.Settings.SpotComment, Logging, session.Other(Logging)));
|
||||
session.Bandmap.Add(new Spot(call, where, DateTime.UtcNow, SpotSource.Operator));
|
||||
session.Bandmap.Add(new Spot(call, where, DateTime.UtcNow, SpotSource.Operator) { Computer = session.ComputerName });
|
||||
Status($"{call.Text} spotted on {where.Kilohertz:0.0}");
|
||||
}
|
||||
|
||||
@@ -393,7 +428,10 @@ public sealed partial class EntryWindow
|
||||
DateTime.UtcNow,
|
||||
SpotSource.Operator,
|
||||
session.Settings.Station.Callsign,
|
||||
"Local spot"));
|
||||
"Local spot")
|
||||
{
|
||||
Computer = session.ComputerName,
|
||||
});
|
||||
Status($"{call.Text} stored on {Logging.Frequency.Kilohertz:0.0}");
|
||||
boxes[0].Focus();
|
||||
}
|
||||
@@ -424,13 +462,17 @@ public sealed partial class EntryWindow
|
||||
|
||||
private void OnShowCheck(object? sender, RoutedEventArgs e) => Show(() => new CheckWindow(session));
|
||||
|
||||
private void OnShowBandmap(object? sender, RoutedEventArgs e) => Show(() => new BandmapWindow(session, Tune));
|
||||
private void OnShowBandmap(object? sender, RoutedEventArgs e) => Show(() => new BandmapWindow(session, Tune, ReturnToCq));
|
||||
|
||||
private void OnShowAvailable(object? sender, RoutedEventArgs e) =>
|
||||
Show(() => new AvailableWindow(session, Tune));
|
||||
|
||||
private void OnShowScore(object? sender, RoutedEventArgs e) => Show(() => new ScoreWindow(session));
|
||||
|
||||
/// N1MM's statistics window: the log counted under any two of its fields.
|
||||
private void OnShowStatistics(object? sender, RoutedEventArgs e) =>
|
||||
Show(() => new StatisticsWindow(session));
|
||||
|
||||
private void OnShowNetworkStatus(object? sender, RoutedEventArgs e) =>
|
||||
Show(() => new NetworkStatusWindow(session));
|
||||
|
||||
@@ -438,8 +480,16 @@ public sealed partial class EntryWindow
|
||||
private void OnShowGrayline(object? sender, RoutedEventArgs e) =>
|
||||
Show(() => new GraylineWindow(session));
|
||||
|
||||
/// N1MM's info window: the operator, the station in the call box, the rate
|
||||
/// graphs and the contest timers.
|
||||
private void OnShowInfo(object? sender, RoutedEventArgs e) =>
|
||||
Show(() => new InfoWindow(session));
|
||||
|
||||
private void OnShowTelnet(object? sender, RoutedEventArgs e) => Show(() => new TelnetWindow(session, Tune));
|
||||
|
||||
private void OnShowVoiceKeyer(object? sender, RoutedEventArgs e) =>
|
||||
Show(() => new VoiceKeyerWindow(session));
|
||||
|
||||
/// N1MM's digital interface window, which is where RTTY is worked from.
|
||||
private void OnShowDigital(object? sender, RoutedEventArgs e) =>
|
||||
Show(() => new DigitalWindow(session, this, radioNumber));
|
||||
@@ -480,6 +530,7 @@ public sealed partial class EntryWindow
|
||||
}
|
||||
session.Save(updated);
|
||||
session.ConnectRadios();
|
||||
session.ApplyMirrorRadioSettings();
|
||||
try
|
||||
{
|
||||
session.ApplySo2rSettings();
|
||||
@@ -513,29 +564,30 @@ public sealed partial class EntryWindow
|
||||
Refresh();
|
||||
}
|
||||
|
||||
private async void OnNetworkSettings(object? sender, RoutedEventArgs e)
|
||||
private async void OnBandmapSettings(object? sender, RoutedEventArgs e)
|
||||
{
|
||||
NetworkDialog dialog = new(session.Settings);
|
||||
BandmapDialog dialog = new(session.Settings);
|
||||
Settings? updated = await dialog.ShowDialog<Settings?>(this);
|
||||
if (updated is not null)
|
||||
{
|
||||
session.Save(updated);
|
||||
Status("bandmap settings saved");
|
||||
}
|
||||
}
|
||||
|
||||
private async void OnBroadcastSettings(object? sender, RoutedEventArgs e)
|
||||
{
|
||||
BroadcastDataDialog dialog = new(session.Settings);
|
||||
Settings? updated = await dialog.ShowDialog<Settings?>(this);
|
||||
if (updated is not null)
|
||||
{
|
||||
session.Save(updated);
|
||||
session.ApplyNetworkSettings();
|
||||
session.ApplyStationLinkSettings();
|
||||
Status(Networking(updated));
|
||||
session.ApplyBroadcastSettings();
|
||||
Status("broadcast data saved");
|
||||
}
|
||||
}
|
||||
|
||||
/// What the two networks are now doing, for the status line.
|
||||
private static string Networking(Settings settings) =>
|
||||
(settings.NetworkEnabled, settings.StationLinkEnabled) switch
|
||||
{
|
||||
(true, true) => "broadcasting contacts and linked to the other computers",
|
||||
(true, false) => "broadcasting contacts to other programs",
|
||||
(false, true) => "linked to the other logging computers",
|
||||
_ => "networking off",
|
||||
};
|
||||
|
||||
private async void OnKeyerSettings(object? sender, RoutedEventArgs e)
|
||||
{
|
||||
KeyerDialog dialog = new(session.Settings);
|
||||
@@ -563,14 +615,14 @@ public sealed partial class EntryWindow
|
||||
|
||||
private async void OnThemeSettings(object? sender, RoutedEventArgs e)
|
||||
{
|
||||
ThemeDialog dialog = new(session.Settings.Theme);
|
||||
if (await dialog.ShowDialog<string?>(this) is not { } picked)
|
||||
ThemeDialog dialog = new(session.Settings);
|
||||
if (await dialog.ShowDialog<Settings?>(this) is not { } updated)
|
||||
{
|
||||
return;
|
||||
}
|
||||
session.Save(session.Settings with { Theme = picked });
|
||||
Themes.Use(picked);
|
||||
Status($"{picked} colours");
|
||||
session.Save(updated);
|
||||
Themes.Use(updated.Theme);
|
||||
Status($"{updated.Theme} colours");
|
||||
}
|
||||
|
||||
private async void OnQtcSetup(object? sender, RoutedEventArgs e)
|
||||
@@ -653,13 +705,21 @@ public sealed partial class EntryWindow
|
||||
}
|
||||
}
|
||||
|
||||
/// A click on the CQ frequency on the bandmap: back to where the CQs went
|
||||
/// out, and running again.
|
||||
private void ReturnToCq(Frequency frequency)
|
||||
{
|
||||
Tune(frequency, "");
|
||||
SetRunning(true);
|
||||
}
|
||||
|
||||
private void Tune(Frequency frequency, string call)
|
||||
{
|
||||
if (Logging is null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
Logging.Tune(frequency);
|
||||
session.TuneHere(Logging, frequency);
|
||||
_ = session.Radio?.TuneAsync(frequency);
|
||||
Logging.Entry.Call = call;
|
||||
SyncBoxes();
|
||||
@@ -694,7 +754,11 @@ public sealed partial class EntryWindow
|
||||
Place(window);
|
||||
openWindows[typeof(T)] = window;
|
||||
window.Closed += (_, _) => openWindows.Remove(typeof(T));
|
||||
window.Show(this);
|
||||
// No owner: an owned window is transient-for the entry window, so the
|
||||
// window manager keeps it above the entry window and it cannot be
|
||||
// lowered. Closing the entry window closes these (see the Closed handler in the constructor).
|
||||
window.Activated += (_, _) => RaiseTogether(window);
|
||||
window.Show();
|
||||
return window;
|
||||
}
|
||||
|
||||
|
||||
@@ -37,11 +37,10 @@ public sealed partial class EntryWindow
|
||||
|
||||
private void ChangeTo(Settings settings, StoredOperator wanted)
|
||||
{
|
||||
StoredOperator stored = settings.Operators.FirstOrDefault(o => Is(o, wanted.Callsign)) is { } known
|
||||
? known with { WavPath = wanted.WavPath }
|
||||
StoredOperator stored = settings.Operators.FirstOrDefault(o => Is(o, wanted.Callsign))
|
||||
// a new operator starts with the windows and colours on the screen
|
||||
: wanted with { Theme = settings.Theme, Windows = Layout() };
|
||||
stored = stored with { WavPath = WavFolder(stored) };
|
||||
?? wanted with { Theme = settings.Theme, Windows = Layout() };
|
||||
MakeWavFolder(stored.Callsign);
|
||||
session.Save(settings with
|
||||
{
|
||||
Operators = [.. settings.Operators.Where(o => !Is(o, stored.Callsign)), stored],
|
||||
@@ -56,35 +55,72 @@ public sealed partial class EntryWindow
|
||||
{
|
||||
logging.Operator = stored.Callsign;
|
||||
}
|
||||
foreach (Window window in Placed())
|
||||
{
|
||||
Place(window, stored);
|
||||
}
|
||||
Restore(stored);
|
||||
Status($"operator {stored.Callsign}");
|
||||
}
|
||||
|
||||
/// The operator's recordings folder: the one he named, or `Wav/<callsign>`
|
||||
/// beside the rest of the files, which is where N1MM keeps them. The folder
|
||||
/// is made, so there is somewhere to put the files rather than a path that
|
||||
/// is not there.
|
||||
private string WavFolder(StoredOperator stored)
|
||||
/// Makes `Wav/<callsign>` beside the rest of the files, which is where N1MM
|
||||
/// plays an operator's recordings from, so there is somewhere to put them.
|
||||
private void MakeWavFolder(string callsign)
|
||||
{
|
||||
string folder = stored.WavPath.Trim().Length > 0
|
||||
? stored.WavPath.Trim()
|
||||
: session.Paths.WavFor(stored.Callsign);
|
||||
string folder = session.Paths.WavFor(callsign);
|
||||
try
|
||||
{
|
||||
Directory.CreateDirectory(folder);
|
||||
}
|
||||
catch (Exception failure) when (failure is IOException or UnauthorizedAccessException)
|
||||
{
|
||||
// a folder on a drive that is not there is still worth keeping: it
|
||||
// is the operator's own setting, and he is the one who fixes it
|
||||
Status($"{folder} could not be made: {failure.Message}");
|
||||
}
|
||||
return folder;
|
||||
}
|
||||
|
||||
/// Puts the screen back the way this operator left it: the windows he had
|
||||
/// open, where he had them, and the ones he did not have closed. The second
|
||||
/// radio's window is another view of the same screen, so it restores
|
||||
/// nothing.
|
||||
private void Restore(StoredOperator? stored)
|
||||
{
|
||||
if (radioNumber > 1 || stored is null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
HashSet<string> wanted = [.. stored.Windows.Select(w => w.Name)];
|
||||
foreach ((string name, Action open) in Openable())
|
||||
{
|
||||
if (wanted.Contains(name))
|
||||
{
|
||||
open();
|
||||
}
|
||||
}
|
||||
foreach (Window window in openWindows.Values.Where(w => !wanted.Contains(w.GetType().Name)).ToList())
|
||||
{
|
||||
window.Close();
|
||||
}
|
||||
foreach (Window window in Placed())
|
||||
{
|
||||
Place(window, stored);
|
||||
}
|
||||
}
|
||||
|
||||
/// The windows an operator can have open, under the names they are stored
|
||||
/// as. The call stack window is not one of them: the program opens and
|
||||
/// closes that itself as calls go on and off the stack.
|
||||
private (string Name, Action Open)[] Openable() =>
|
||||
[
|
||||
(nameof(LogWindow), () => _ = Show(() => new LogWindow(session), activate: false)),
|
||||
(nameof(CheckWindow), () => _ = Show(() => new CheckWindow(session), activate: false)),
|
||||
(nameof(BandmapWindow), () => _ = Show(() => new BandmapWindow(session, Tune, ReturnToCq), activate: false)),
|
||||
(nameof(AvailableWindow), () => _ = Show(() => new AvailableWindow(session, Tune), activate: false)),
|
||||
(nameof(ScoreWindow), () => _ = Show(() => new ScoreWindow(session), activate: false)),
|
||||
(nameof(StatisticsWindow), () => _ = Show(() => new StatisticsWindow(session), activate: false)),
|
||||
(nameof(NetworkStatusWindow), () => _ = Show(() => new NetworkStatusWindow(session), activate: false)),
|
||||
(nameof(GraylineWindow), () => _ = Show(() => new GraylineWindow(session), activate: false)),
|
||||
(nameof(InfoWindow), () => _ = Show(() => new InfoWindow(session), activate: false)),
|
||||
(nameof(TelnetWindow), () => _ = Show(() => new TelnetWindow(session, Tune), activate: false)),
|
||||
(nameof(DigitalWindow), () => _ = Show(() => new DigitalWindow(session, this, radioNumber), activate: false)),
|
||||
(nameof(VoiceKeyerWindow), () => _ = Show(() => new VoiceKeyerWindow(session), activate: false)),
|
||||
];
|
||||
|
||||
/// Puts a window where this operator last had it. Windows are opened one at
|
||||
/// a time, so each one is placed as it appears rather than all at once.
|
||||
private void Place(Window window, StoredOperator? stored = null)
|
||||
@@ -95,11 +131,17 @@ public sealed partial class EntryWindow
|
||||
return;
|
||||
}
|
||||
window.Position = new PixelPoint(where.X, where.Y);
|
||||
// a window that sizes itself to what is in it is left the size it wants
|
||||
if (window.CanResize && window.SizeToContent == SizeToContent.Manual
|
||||
&& where.Width > 0 && where.Height > 0)
|
||||
// a side that sizes itself to what is in it is left the size it wants
|
||||
if (!window.CanResize)
|
||||
{
|
||||
return;
|
||||
}
|
||||
if (!window.SizeToContent.HasFlag(SizeToContent.Width) && where.Width > 0)
|
||||
{
|
||||
window.Width = where.Width;
|
||||
}
|
||||
if (!window.SizeToContent.HasFlag(SizeToContent.Height) && where.Height > 0)
|
||||
{
|
||||
window.Height = where.Height;
|
||||
}
|
||||
}
|
||||
@@ -108,7 +150,9 @@ public sealed partial class EntryWindow
|
||||
/// at the radio. With nobody named there is nowhere to keep them.
|
||||
private Settings WithLayout(Settings settings)
|
||||
{
|
||||
if (Current() is not { } stored)
|
||||
// the second radio's window has none of the others open, so saving from
|
||||
// it would drop every window the first one has
|
||||
if (radioNumber > 1 || Current() is not { } stored)
|
||||
{
|
||||
return settings;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,55 @@
|
||||
using Nonemm.Keying;
|
||||
using Nonemm.Session;
|
||||
|
||||
namespace Nonemm.App.Windows;
|
||||
|
||||
/// Recording a function key's message from the entry window, which is N1MM's
|
||||
/// Ctrl+Shift+F1 to F12. The key already names the file it plays, so the key
|
||||
/// says where the recording goes: an operator who has just heard his CQ come
|
||||
/// back badly records it again without leaving the radio.
|
||||
public sealed partial class EntryWindow
|
||||
{
|
||||
/// Starts recording what this key plays, or ends the recording that is
|
||||
/// running. N1MM ends one on any of the pair, on Escape, and on sending
|
||||
/// anything, and so does this.
|
||||
private void RecordFunctionKey(int index)
|
||||
{
|
||||
if (session.Recording is not null)
|
||||
{
|
||||
session.StopRecording();
|
||||
return;
|
||||
}
|
||||
if (Logging is null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
string template = Keys()[index].Message;
|
||||
MessagePlan plan = MessagePlan.Read(template, Logging, session.Other(Logging));
|
||||
// the first file, because that is the one the key plays first. A key
|
||||
// that names none is a CW message or an empty key
|
||||
if (VoiceFiles.NamesIn(plan.Text).FirstOrDefault() is not { } name)
|
||||
{
|
||||
Status($"F{index + 1} names no recording — Config ▸ Change SSB Function Key Definitions");
|
||||
return;
|
||||
}
|
||||
_ = RecordAsync(index, name);
|
||||
}
|
||||
|
||||
private async Task RecordAsync(int index, string name)
|
||||
{
|
||||
Status($"recording {name} — Ctrl+Shift+F{index + 1} again, or Escape, to stop");
|
||||
Refresh();
|
||||
Status(await session.RecordAsync(name));
|
||||
Refresh();
|
||||
}
|
||||
|
||||
/// Ends a recording that is running, for the keys that end one without
|
||||
/// being about recording at all.
|
||||
private void StopRecording()
|
||||
{
|
||||
if (session.Recording is not null)
|
||||
{
|
||||
session.StopRecording();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,5 +1,6 @@
|
||||
<Window xmlns="https://github.com/avaloniaui"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:theming="using:Nonemm.App.Theming"
|
||||
x:Class="Nonemm.App.Windows.EntryWindow"
|
||||
Title="Nonemm"
|
||||
Width="820" SizeToContent="Height"
|
||||
@@ -12,7 +13,7 @@
|
||||
<Setter Property="Margin" Value="2,0,0,1" />
|
||||
</Style>
|
||||
<Style Selector="TextBox.entry">
|
||||
<Setter Property="FontFamily" Value="monospace" />
|
||||
<Setter Property="FontFamily" Value="{x:Static theming:Fonts.Mono}" />
|
||||
<Setter Property="FontSize" Value="20" />
|
||||
<Setter Property="Padding" Value="6,2" />
|
||||
<Setter Property="VerticalContentAlignment" Value="Center" />
|
||||
@@ -65,12 +66,16 @@
|
||||
</MenuItem>
|
||||
<MenuItem Header="Export">
|
||||
<MenuItem Header="Export ADIF to file…" Click="OnExportAdif" />
|
||||
<!-- only WAE has traffic to export, so the item is hidden elsewhere -->
|
||||
<MenuItem Name="QtcExportItem" IsVisible="False"
|
||||
Header="Export ADIF with QTC traffic…" Click="OnExportAdifWithQtcs" />
|
||||
</MenuItem>
|
||||
<Separator />
|
||||
<MenuItem Header="E_xit" Click="OnExit" InputGesture="Alt+F4" />
|
||||
</MenuItem>
|
||||
<MenuItem Header="_Edit">
|
||||
<MenuItem Header="Wipe Out Entry Fields" Click="OnWipe" InputGesture="Ctrl+W" />
|
||||
<MenuItem Header="Wipe Out or Restore Entry Fields" Click="OnWipeOrRestore" InputGesture="Alt+W" />
|
||||
<Separator />
|
||||
<MenuItem Header="Edit Last Contact" Click="OnEditLastContact" InputGesture="Ctrl+Y" />
|
||||
<MenuItem Header="Add a Note to Last/Current Contact" Click="OnAddNote" InputGesture="Ctrl+N" />
|
||||
@@ -96,6 +101,7 @@
|
||||
<MenuItem Header="Configure Ports, Mode Control, Winkey, etc…" Click="OnKeyerSettings" />
|
||||
<MenuItem Header="Configure Radios…" Click="OnRadioSettings" />
|
||||
<MenuItem Header="Configure Cluster…" Click="OnClusterSettings" />
|
||||
<MenuItem Header="Configure Bandmap…" Click="OnBandmapSettings" />
|
||||
<MenuItem Header="Change Your Station Data…" Click="OnStationSettings" />
|
||||
<MenuItem Header="Change Operator…" Click="OnChangeOperator" InputGesture="Ctrl+O" />
|
||||
<Separator />
|
||||
@@ -108,25 +114,37 @@
|
||||
</MenuItem>
|
||||
<MenuItem Header="Change Band Plan…" Click="OnSubBandSettings" />
|
||||
<MenuItem Header="Manage Skins, Colors and Fonts…" Click="OnThemeSettings" />
|
||||
<MenuItem Header="Edit Networked-Computer Names…" Click="OnNetworkSettings" />
|
||||
<MenuItem Header="Configure Broadcast Data…" Click="OnBroadcastSettings" />
|
||||
<MenuItem Header="WAE">
|
||||
<MenuItem Header="Open QTC Window setup area" Click="OnQtcSetup" />
|
||||
</MenuItem>
|
||||
</MenuItem>
|
||||
<MenuItem Header="Wi_ndow">
|
||||
<MenuItem Header="Available Mult's and Q's" Click="OnShowAvailable" />
|
||||
<MenuItem Header="Available Mults and Qs" Click="OnShowAvailable" />
|
||||
<MenuItem Header="_Bandmap" Click="OnShowBandmap" />
|
||||
<MenuItem Header="Call Stack" Click="OnShowCallStack" />
|
||||
<MenuItem Header="Check" Click="OnShowCheck" />
|
||||
<MenuItem Header="Log" Click="OnShowLog" InputGesture="Ctrl+L" />
|
||||
<MenuItem Header="Network Status" Click="OnShowNetworkStatus" />
|
||||
<MenuItem Header="Grey Line" Click="OnShowGrayline" />
|
||||
<MenuItem Header="Info" Click="OnShowInfo" />
|
||||
<MenuItem Header="Score Summary" Click="OnShowScore" />
|
||||
<MenuItem Header="Statistics" Click="OnShowStatistics" />
|
||||
<MenuItem Header="Telnet" Click="OnShowTelnet" />
|
||||
<MenuItem Header="Digital Interface" Click="OnShowDigital" />
|
||||
<MenuItem Header="Voice Keyer" Click="OnShowVoiceKeyer" />
|
||||
</MenuItem>
|
||||
</Menu>
|
||||
|
||||
<!-- Two signals where the entry may have one. N1MM blocks the
|
||||
transmitter; this says so instead, loudly enough to be read from
|
||||
across the room, and leaves the operator to stop -->
|
||||
<Border DockPanel.Dock="Top" Name="TransmitWarning" IsVisible="False"
|
||||
Background="#C0392B" Padding="10,8">
|
||||
<TextBlock Name="TransmitWarningText" FontSize="22" FontWeight="Bold"
|
||||
Foreground="White" TextWrapping="Wrap" Text="" />
|
||||
</Border>
|
||||
|
||||
<!-- N1MM's status strip: what just happened on the left, then the band
|
||||
change timer, the contacts and multipliers, and the score -->
|
||||
<Border DockPanel.Dock="Bottom" Padding="6,3" BorderThickness="0,1,0,0"
|
||||
@@ -150,8 +168,8 @@
|
||||
|
||||
<StackPanel Margin="6">
|
||||
<Grid ColumnDefinitions="Auto,Auto,Auto,*,Auto" Margin="0,0,0,6">
|
||||
<TextBlock Name="FrequencyText" FontFamily="monospace" FontSize="20" Text="14025.00" />
|
||||
<TextBlock Grid.Column="1" Name="ModeText" FontFamily="monospace" FontSize="20"
|
||||
<TextBlock Name="FrequencyText" FontFamily="{x:Static theming:Fonts.Mono}" FontSize="20" Text="14025.00" />
|
||||
<TextBlock Grid.Column="1" Name="ModeText" FontFamily="{x:Static theming:Fonts.Mono}" FontSize="20"
|
||||
Margin="10,0,0,0" Text="CW" />
|
||||
<StackPanel Grid.Column="2" Orientation="Horizontal" Spacing="4" Margin="10,2,0,2"
|
||||
VerticalAlignment="Center">
|
||||
@@ -165,11 +183,11 @@
|
||||
<TextBlock Grid.Column="3" Name="ContestText" FontSize="12" Opacity="0.75"
|
||||
VerticalAlignment="Center" Margin="12,0,12,0" Text="no contest"
|
||||
TextTrimming="CharacterEllipsis" ClipToBounds="True" />
|
||||
<TextBlock Grid.Column="4" Name="ClockText" FontFamily="monospace" FontSize="20"
|
||||
<TextBlock Grid.Column="4" Name="ClockText" FontFamily="{x:Static theming:Fonts.Mono}" FontSize="20"
|
||||
Text="00:00:00Z" />
|
||||
</Grid>
|
||||
|
||||
<TextBlock Name="CallFrameText" FontFamily="monospace" FontSize="13" Height="18"
|
||||
<TextBlock Name="CallFrameText" FontFamily="{x:Static theming:Fonts.Mono}" FontSize="13" Height="18"
|
||||
Margin="2,0,0,1" Text="" />
|
||||
|
||||
<Grid Name="EntryGrid" ColumnDefinitions="Auto" RowDefinitions="Auto,Auto" />
|
||||
@@ -200,6 +218,11 @@
|
||||
<TextBlock Name="PathText" FontSize="11" Opacity="0.75" Margin="2,8,0,0" Text=""
|
||||
TextTrimming="CharacterEllipsis" />
|
||||
|
||||
<!-- WAE only: N1MM's QTCinfo label, which says how much traffic may
|
||||
still be exchanged with the station being worked -->
|
||||
<TextBlock Name="QtcInfoText" FontSize="11" Margin="2,2,0,0" Text="" IsVisible="False"
|
||||
Foreground="#2980B9" TextTrimming="CharacterEllipsis" />
|
||||
|
||||
<TextBlock Name="UserTextText" FontSize="11" Margin="2,2,0,0" Text=""
|
||||
Foreground="#2980B9" TextTrimming="CharacterEllipsis" />
|
||||
|
||||
|
||||
@@ -6,6 +6,7 @@ using Avalonia.Layout;
|
||||
using Avalonia.Media;
|
||||
using Avalonia.Threading;
|
||||
using Nonemm.Contests;
|
||||
using Nonemm.Contests.Rules;
|
||||
using Nonemm.Core;
|
||||
using Nonemm.App.Theming;
|
||||
using Nonemm.Session;
|
||||
@@ -29,10 +30,28 @@ public sealed partial class EntryWindow : Window
|
||||
|
||||
private static readonly IBrush Dark = new SolidColorBrush(Color.FromArgb(0x33, 0x80, 0x80, 0x80));
|
||||
|
||||
private bool sending;
|
||||
/// True while this station has its key down. Every station of the entry is
|
||||
/// told, because two signals where the entry may have one is a contact the
|
||||
/// sponsor takes back off both of them.
|
||||
private bool sending
|
||||
{
|
||||
get;
|
||||
set
|
||||
{
|
||||
if (field == value)
|
||||
{
|
||||
return;
|
||||
}
|
||||
field = value;
|
||||
_ = session.Link?.SendTransmittingAsync(value, sendingWhat, session.IsRun2);
|
||||
ShowTransmitWarning();
|
||||
}
|
||||
}
|
||||
|
||||
/// What is going out, which is what the other operators read in the
|
||||
/// network status window.
|
||||
private string sendingWhat = "";
|
||||
private TextBlock? callMark;
|
||||
private TextBox? nameBox;
|
||||
private TextBox? commentBox;
|
||||
private readonly DispatcherTimer clock = new() { Interval = TimeSpan.FromSeconds(1) };
|
||||
private readonly Dictionary<Type, Window> openWindows = [];
|
||||
private bool updating;
|
||||
@@ -48,7 +67,12 @@ public sealed partial class EntryWindow : Window
|
||||
this.radioNumber = radioNumber;
|
||||
InitializeComponent();
|
||||
BuildFunctionKeys();
|
||||
session.Changed += (_, _) => Dispatcher.UIThread.Post(Refresh);
|
||||
// a radio being tuned raises this many times a second
|
||||
Coalesced changed = new(Refresh);
|
||||
session.Changed += (_, _) => changed.Request();
|
||||
// a keyer speaks on its own thread, and a recording that would not
|
||||
// play has nowhere else to be said
|
||||
session.Reported += (_, what) => Dispatcher.UIThread.Post(() => Status(what));
|
||||
session.ContestChanged += (_, _) => Dispatcher.UIThread.Post(() =>
|
||||
{
|
||||
BuildEntryBoxes();
|
||||
@@ -59,8 +83,43 @@ public sealed partial class EntryWindow : Window
|
||||
// the windows are where this operator left them, and that is what he
|
||||
// gets back next time he takes the radio
|
||||
Closing += (_, _) => session.Save(WithLayout(session.Settings));
|
||||
PropertyChanged += (_, e) =>
|
||||
{
|
||||
if (e.Property != WindowStateProperty)
|
||||
{
|
||||
return;
|
||||
}
|
||||
lastStateChange = Environment.TickCount64;
|
||||
if (WindowState == WindowState.Normal)
|
||||
{
|
||||
Dispatcher.UIThread.Post(() => boxes.ElementAtOrDefault(0)?.Focus(), DispatcherPriority.Background);
|
||||
}
|
||||
if (session.Settings.MinimizeWindowsTogether
|
||||
&& WindowState is WindowState.Minimized or WindowState.Normal)
|
||||
{
|
||||
FollowWindowState(WindowState);
|
||||
}
|
||||
};
|
||||
Activated += (_, _) => RaiseTogether(this);
|
||||
Closed += (_, _) =>
|
||||
{
|
||||
foreach (Window window in openWindows.Values.ToList())
|
||||
{
|
||||
window.Close();
|
||||
}
|
||||
secondRadio?.Close();
|
||||
};
|
||||
clock.Tick += (_, _) => UpdateClock();
|
||||
clock.Start();
|
||||
session.EntryWiped += (_, wiped) => Dispatcher.UIThread.Post(() =>
|
||||
{
|
||||
if (wiped == Logging)
|
||||
{
|
||||
ResetEsm();
|
||||
SyncBoxes();
|
||||
Refresh();
|
||||
}
|
||||
});
|
||||
session.ActiveRadioChanged += (_, number) =>
|
||||
Dispatcher.UIThread.Post(() => FollowActiveRadio(number));
|
||||
// only the window for radio 1 opens the log and the connections; the
|
||||
@@ -71,6 +130,7 @@ public sealed partial class EntryWindow : Window
|
||||
MainMenu.IsVisible = false;
|
||||
}
|
||||
AddHandler(KeyDownEvent, OnWindowKeyDown, RoutingStrategies.Tunnel);
|
||||
AddHandler(KeyUpEvent, OnWindowKeyUp, RoutingStrategies.Tunnel);
|
||||
}
|
||||
|
||||
|
||||
@@ -108,6 +168,7 @@ public sealed partial class EntryWindow : Window
|
||||
StartConnections();
|
||||
BuildEntryBoxes();
|
||||
ShowSecondRadio();
|
||||
Restore(Current());
|
||||
}
|
||||
|
||||
/// A second radio gets its own entry window: the two share one log and one
|
||||
@@ -123,7 +184,7 @@ public sealed partial class EntryWindow : Window
|
||||
{
|
||||
secondRadio = new EntryWindow(session, 2);
|
||||
secondRadio.Closed += (_, _) => secondRadio = null;
|
||||
secondRadio.Show(this);
|
||||
secondRadio.Show();
|
||||
}
|
||||
else if (!wanted && secondRadio is not null)
|
||||
{
|
||||
@@ -133,6 +194,43 @@ public sealed partial class EntryWindow : Window
|
||||
}
|
||||
}
|
||||
|
||||
/// The tool windows have no owner, so the window manager does not minimize
|
||||
/// or restore them with the entry window. This does it.
|
||||
private void FollowWindowState(WindowState state)
|
||||
{
|
||||
foreach (Window window in openWindows.Values.Concat(secondRadio is null ? [] : [secondRadio]))
|
||||
{
|
||||
window.WindowState = state;
|
||||
}
|
||||
}
|
||||
|
||||
private long lastRaise;
|
||||
private long lastStateChange;
|
||||
|
||||
/// Brings the other windows that are not minimized above whatever else is
|
||||
/// on screen, then puts `front` back on top. Activating them fires their
|
||||
/// own Activated events, so raises within half a second are ignored.
|
||||
private void RaiseTogether(Window front)
|
||||
{
|
||||
// The window manager activates another window when the entry window
|
||||
// minimizes. Raising then would restore the entry window.
|
||||
if (!session.Settings.RaiseWindowsTogether
|
||||
|| Environment.TickCount64 - lastRaise < 500
|
||||
|| Environment.TickCount64 - lastStateChange < 1000
|
||||
|| WindowState == WindowState.Minimized)
|
||||
{
|
||||
return;
|
||||
}
|
||||
lastRaise = Environment.TickCount64;
|
||||
IEnumerable<Window> others = Placed().Concat(secondRadio is null ? [] : [secondRadio])
|
||||
.Where(w => w != front && w.WindowState != WindowState.Minimized);
|
||||
foreach (Window window in others)
|
||||
{
|
||||
window.Activate();
|
||||
}
|
||||
front.Activate();
|
||||
}
|
||||
|
||||
/// The keyboard follows the operator to the other radio.
|
||||
private void FollowActiveRadio(int number)
|
||||
{
|
||||
@@ -167,18 +265,29 @@ public sealed partial class EntryWindow : Window
|
||||
{
|
||||
yield return ("radios", session.ConnectRadios);
|
||||
}
|
||||
if (session.Settings.ClusterEnabled)
|
||||
if (session.AutoConnectNode is not null)
|
||||
{
|
||||
yield return ("cluster", session.ConnectCluster);
|
||||
yield return ("cluster", session.ConnectAutoCluster);
|
||||
}
|
||||
if (session.Settings.NetworkEnabled)
|
||||
{
|
||||
yield return ("station network", session.ApplyNetworkSettings);
|
||||
}
|
||||
if (session.Settings.KeyerKind != "none")
|
||||
if (session.Settings.StationLinkEnabled)
|
||||
{
|
||||
yield return ("keyer", session.ApplyKeyerSettings);
|
||||
yield return ("station link", session.ApplyStationLinkSettings);
|
||||
}
|
||||
if (session.Settings.BroadcastChannels().Values.Any(c => c.IsEnabled))
|
||||
{
|
||||
yield return ("data broadcast", session.ApplyBroadcastSettings);
|
||||
}
|
||||
if (session.Settings.MirrorRadioEnabled)
|
||||
{
|
||||
yield return ("radio mirror", session.ApplyMirrorRadioSettings);
|
||||
}
|
||||
// always, whatever the CW keyer is: this is also what builds the voice
|
||||
// keyer, which plays out of the sound card rather than a keying port
|
||||
yield return ("keyer", session.ApplyKeyerSettings);
|
||||
if (session.Settings.So2rBoxPort.Length > 0)
|
||||
{
|
||||
yield return ("SO2R box", session.ApplySo2rSettings);
|
||||
@@ -204,55 +313,11 @@ public sealed partial class EntryWindow : Window
|
||||
ExchangeField field = Logging.Entry.Exchange[at];
|
||||
AddBox(field.Label, field.Width, at + 1);
|
||||
}
|
||||
AddNotes();
|
||||
boxes[0].Focus();
|
||||
SyncBoxes();
|
||||
Refresh();
|
||||
}
|
||||
|
||||
/// N1MM keeps a name and a comment beside the exchange, whatever the
|
||||
/// contest is. Neither is part of the exchange: they fill the log columns
|
||||
/// of the same names, and a contest that exchanges a name already has one.
|
||||
private void AddNotes()
|
||||
{
|
||||
nameBox = Logging!.Entry.Exchange.Any(f => f.Slot == ExchangeSlot.Name)
|
||||
? null
|
||||
: AddNote("Name", 8, EntryGrid.ColumnDefinitions.Count);
|
||||
commentBox = AddNote("Comment", 12, EntryGrid.ColumnDefinitions.Count);
|
||||
}
|
||||
|
||||
private TextBox AddNote(string label, int width, int index)
|
||||
{
|
||||
EntryGrid.ColumnDefinitions.Add(new ColumnDefinition(GridLength.Auto));
|
||||
TextBlock caption = new() { Text = label };
|
||||
caption.Classes.Add("label");
|
||||
Grid.SetColumn(caption, index);
|
||||
Grid.SetRow(caption, 0);
|
||||
EntryGrid.Children.Add(caption);
|
||||
|
||||
TextBox box = new()
|
||||
{
|
||||
Width = (width * 13) + 20,
|
||||
Margin = new Avalonia.Thickness(0, 0, 6, 0),
|
||||
HorizontalAlignment = HorizontalAlignment.Left,
|
||||
};
|
||||
box.Classes.Add("entry");
|
||||
box.TextChanged += (_, _) => OnNoteChanged();
|
||||
Grid.SetColumn(box, index);
|
||||
Grid.SetRow(box, 1);
|
||||
EntryGrid.Children.Add(box);
|
||||
return box;
|
||||
}
|
||||
|
||||
private void OnNoteChanged()
|
||||
{
|
||||
if (updating || Logging is null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
Logging.OtherName = nameBox?.Text ?? "";
|
||||
Logging.Comment = commentBox?.Text ?? "";
|
||||
}
|
||||
|
||||
private void AddBox(string label, int width, int index)
|
||||
{
|
||||
EntryGrid.ColumnDefinitions.Add(new ColumnDefinition(GridLength.Auto));
|
||||
@@ -325,11 +390,50 @@ public sealed partial class EntryWindow : Window
|
||||
}
|
||||
// typing answers whatever the status bar was reporting
|
||||
message = "";
|
||||
Refresh();
|
||||
RefreshAfterTyping();
|
||||
}
|
||||
|
||||
private bool typingRefreshPosted;
|
||||
|
||||
/// Refresh redraws this window and every open tool window, which is too
|
||||
/// slow to run between two key presses. Typing refreshes this window and
|
||||
/// the tool windows that show the call, and it runs once the key presses
|
||||
/// waiting in the queue have been handled, so fast typing costs one
|
||||
/// refresh instead of one per letter.
|
||||
private void RefreshAfterTyping()
|
||||
{
|
||||
if (typingRefreshPosted)
|
||||
{
|
||||
return;
|
||||
}
|
||||
typingRefreshPosted = true;
|
||||
Dispatcher.UIThread.Post(
|
||||
() =>
|
||||
{
|
||||
typingRefreshPosted = false;
|
||||
RefreshForTyping();
|
||||
},
|
||||
DispatcherPriority.Background);
|
||||
}
|
||||
|
||||
/// Set by Alt+W. Releasing Alt moves focus to the menu bar, so the
|
||||
/// callsign box takes focus back when Alt comes up.
|
||||
private bool refocusOnAltUp;
|
||||
|
||||
private void OnWindowKeyUp(object? sender, KeyEventArgs e)
|
||||
{
|
||||
if (!refocusOnAltUp || e.Key is not (Key.LeftAlt or Key.RightAlt))
|
||||
{
|
||||
return;
|
||||
}
|
||||
refocusOnAltUp = false;
|
||||
e.Handled = true;
|
||||
boxes[0].Focus();
|
||||
}
|
||||
|
||||
private void OnWindowKeyDown(object? sender, KeyEventArgs e)
|
||||
{
|
||||
OperatorActivity.KeyPressed();
|
||||
if (Logging is null)
|
||||
{
|
||||
return;
|
||||
@@ -355,6 +459,7 @@ public sealed partial class EntryWindow : Window
|
||||
case Key.Escape:
|
||||
e.Handled = true;
|
||||
sending = false;
|
||||
StopRecording();
|
||||
// N1MM's Escape holds alternating CQ where it is rather than
|
||||
// switching it off; the next CQ carries it on
|
||||
session.Alternating?.Hold();
|
||||
@@ -378,8 +483,12 @@ public sealed partial class EntryWindow : Window
|
||||
e.Handled = true;
|
||||
session.SwapRadio();
|
||||
break;
|
||||
case Key.Tab when FocusedIsEntryBox() || FocusedIsNoteBox():
|
||||
case Key.Tab when FocusedIsEntryBox():
|
||||
e.Handled = true;
|
||||
if (Logging is not null && boxes[0].IsFocused)
|
||||
{
|
||||
session.SendLookup(Logging);
|
||||
}
|
||||
MoveToNextBox(forward: !e.KeyModifiers.HasFlag(KeyModifiers.Shift));
|
||||
break;
|
||||
case Key.Z when e.KeyModifiers.HasFlag(KeyModifiers.Control):
|
||||
@@ -398,6 +507,11 @@ public sealed partial class EntryWindow : Window
|
||||
e.Handled = true;
|
||||
OnQuickEditBack(this, new RoutedEventArgs());
|
||||
break;
|
||||
case Key.A when e.KeyModifiers.HasFlag(KeyModifiers.Alt)
|
||||
&& openWindows.GetValueOrDefault(typeof(AvailableWindow)) is AvailableWindow available:
|
||||
e.Handled = true;
|
||||
available.Step(e.KeyModifiers);
|
||||
break;
|
||||
case Key.A when e.KeyModifiers.HasFlag(KeyModifiers.Control):
|
||||
e.Handled = true;
|
||||
OnQuickEditForward(this, new RoutedEventArgs());
|
||||
@@ -414,10 +528,20 @@ public sealed partial class EntryWindow : Window
|
||||
e.Handled = true;
|
||||
OnWipe(this, new RoutedEventArgs());
|
||||
break;
|
||||
case Key.W when e.KeyModifiers.HasFlag(KeyModifiers.Alt):
|
||||
e.Handled = true;
|
||||
refocusOnAltUp = true;
|
||||
OnWipeOrRestore(this, new RoutedEventArgs());
|
||||
break;
|
||||
case Key.L when e.KeyModifiers.HasFlag(KeyModifiers.Control):
|
||||
e.Handled = true;
|
||||
OnShowLog(this, new RoutedEventArgs());
|
||||
break;
|
||||
case Key.M when e.KeyModifiers.HasFlag(KeyModifiers.Control)
|
||||
&& e.KeyModifiers.HasFlag(KeyModifiers.Alt):
|
||||
e.Handled = true;
|
||||
session.IsRun2 = !session.IsRun2;
|
||||
break;
|
||||
case Key.M when e.KeyModifiers.HasFlag(KeyModifiers.Control):
|
||||
e.Handled = true;
|
||||
OnToggleEsm(this, new RoutedEventArgs());
|
||||
@@ -459,6 +583,19 @@ public sealed partial class EntryWindow : Window
|
||||
e.Handled = true;
|
||||
ToggleRun();
|
||||
break;
|
||||
// N1MM opens the function key editor on Alt+K, for the mode the
|
||||
// radio is on. Right-clicking a key button opens the same one
|
||||
case Key.K when e.KeyModifiers.HasFlag(KeyModifiers.Alt):
|
||||
e.Handled = true;
|
||||
_ = EditMessages();
|
||||
break;
|
||||
// N1MM records into the file this key plays, and stops on the
|
||||
// same pair
|
||||
case >= Key.F1 and <= Key.F12 when e.KeyModifiers.HasFlag(KeyModifiers.Control)
|
||||
&& e.KeyModifiers.HasFlag(KeyModifiers.Shift):
|
||||
e.Handled = true;
|
||||
RecordFunctionKey(e.Key - Key.F1);
|
||||
break;
|
||||
case >= Key.F1 and <= Key.F12:
|
||||
e.Handled = true;
|
||||
RunFunctionKey(e.Key - Key.F1);
|
||||
@@ -504,7 +641,7 @@ public sealed partial class EntryWindow : Window
|
||||
_ = RunEsmAsync();
|
||||
return;
|
||||
}
|
||||
if (!Logging.Entry.IsComplete)
|
||||
if (!Logging.IsEntryComplete)
|
||||
{
|
||||
MoveFocus(forward: true);
|
||||
return;
|
||||
@@ -516,7 +653,7 @@ public sealed partial class EntryWindow : Window
|
||||
/// both do.
|
||||
private void SaveQuickEdit()
|
||||
{
|
||||
if (Logging?.SaveQuickEdit() is not { } saved)
|
||||
if (!IsEntryUsable() || Logging?.SaveQuickEdit() is not { } saved)
|
||||
{
|
||||
return;
|
||||
}
|
||||
@@ -528,14 +665,16 @@ public sealed partial class EntryWindow : Window
|
||||
|
||||
private void LogContact()
|
||||
{
|
||||
if (Logging is null)
|
||||
if (Logging is null || !IsEntryUsable())
|
||||
{
|
||||
return;
|
||||
}
|
||||
string loggedCall;
|
||||
try
|
||||
{
|
||||
Qso logged = Logging.LogContact();
|
||||
Status($"logged {logged.Call} for {logged.Points} points");
|
||||
loggedCall = logged.Call.Text;
|
||||
}
|
||||
catch (Exception e) when (e is InvalidOperationException or IOException)
|
||||
{
|
||||
@@ -545,6 +684,50 @@ public sealed partial class EntryWindow : Window
|
||||
ResetEsm();
|
||||
SyncBoxes();
|
||||
boxes[0].Focus();
|
||||
if (!Logging.IsRunning && openWindows.GetValueOrDefault(typeof(AvailableWindow)) is AvailableWindow list)
|
||||
{
|
||||
list.QsyToTopSpot(loggedCall);
|
||||
}
|
||||
}
|
||||
|
||||
/// N1MM's `{FORCELOG}`: the contact goes in the log with whatever is in the
|
||||
/// boxes, holes and all. The status line says it was forced, because the
|
||||
/// row will need fixing before the log is sent in.
|
||||
private void LogContactAnyway()
|
||||
{
|
||||
if (Logging is null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
try
|
||||
{
|
||||
Qso logged = Logging.LogContactAnyway();
|
||||
Status($"logged {logged.Call} as it stands — check it before sending the log in");
|
||||
}
|
||||
catch (Exception e) when (e is InvalidOperationException or IOException)
|
||||
{
|
||||
Status($"could not log the contact: {e.Message}");
|
||||
return;
|
||||
}
|
||||
ResetEsm();
|
||||
SyncBoxes();
|
||||
boxes[0].Focus();
|
||||
}
|
||||
|
||||
/// True when everything typed can go in the log. A value the contest will
|
||||
/// not take puts the reason in the status line and the cursor in its box,
|
||||
/// which is where the operator has to fix it.
|
||||
private bool IsEntryUsable()
|
||||
{
|
||||
if (Logging?.EntryProblem() is not { } problem)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
Status(problem.Message);
|
||||
Logging.Entry.FocusOn(problem.Field);
|
||||
boxes[problem.Field].Focus();
|
||||
boxes[problem.Field].SelectAll();
|
||||
return false;
|
||||
}
|
||||
|
||||
/// What space does: the callsign box and the exchange boxes, stepping over
|
||||
@@ -628,7 +811,6 @@ public sealed partial class EntryWindow : Window
|
||||
bool filled = TakeFramedCall();
|
||||
filled |= Logging.FillReports();
|
||||
filled |= Logging.FillFromHistory();
|
||||
filled |= FillNameFromHistory();
|
||||
if (filled)
|
||||
{
|
||||
SyncBoxes();
|
||||
@@ -643,26 +825,19 @@ public sealed partial class EntryWindow : Window
|
||||
FocusEntryBox();
|
||||
}
|
||||
|
||||
/// What tab does: every box in turn, reports, name and comment included,
|
||||
/// and round again. N1MM does not touch the tab key, so tab there walks
|
||||
/// the boxes in the order they are laid out, and this walks the same ones.
|
||||
/// What tab does: every box in turn, the reports included, and round
|
||||
/// again. N1MM does not touch the tab key, so tab there walks the boxes in
|
||||
/// the order they are laid out, and this walks the same ones.
|
||||
private void MoveToNextBox(bool forward)
|
||||
{
|
||||
if (Logging is null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
List<TextBox> all = [.. boxes, .. new[] { nameBox, commentBox }.OfType<TextBox>()];
|
||||
int at = all.FindIndex(box => box.IsFocused);
|
||||
int next = ((at < 0 ? 0 : at) + (forward ? 1 : -1) + all.Count) % all.Count;
|
||||
if (next < boxes.Count)
|
||||
{
|
||||
Logging.Entry.FocusOn(next);
|
||||
FocusEntryBox();
|
||||
return;
|
||||
}
|
||||
all[next].Focus();
|
||||
all[next].CaretIndex = all[next].Text?.Length ?? 0;
|
||||
int at = boxes.FindIndex(box => box.IsFocused);
|
||||
int next = ((at < 0 ? 0 : at) + (forward ? 1 : -1) + boxes.Count) % boxes.Count;
|
||||
Logging.Entry.FocusOn(next);
|
||||
FocusEntryBox();
|
||||
}
|
||||
|
||||
private void FocusEntryBox()
|
||||
@@ -675,27 +850,8 @@ public sealed partial class EntryWindow : Window
|
||||
boxes[Logging.Entry.Focus].CaretIndex = boxes[Logging.Entry.Focus].Text?.Length ?? 0;
|
||||
}
|
||||
|
||||
/// The call history knows the names in a lot of contests, and the name box
|
||||
/// is where N1MM shows it when the contest does not exchange one.
|
||||
private bool FillNameFromHistory()
|
||||
{
|
||||
if (Logging is null || nameBox is null || Logging.OtherName.Trim().Length > 0)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
string known = Logging.Session.History.Find(Logging.Entry.Call)?.Name ?? "";
|
||||
if (known.Length == 0)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
Logging.OtherName = known;
|
||||
return true;
|
||||
}
|
||||
|
||||
private bool FocusedIsEntryBox() => boxes.Any(b => b.IsFocused);
|
||||
|
||||
private bool FocusedIsNoteBox() => nameBox?.IsFocused == true || commentBox?.IsFocused == true;
|
||||
|
||||
/// The buttons N1MM puts under its function keys. Each one does what its
|
||||
/// key does, so there is one place deciding what happens.
|
||||
private void OnStopSending(object? sender, RoutedEventArgs e)
|
||||
@@ -719,6 +875,21 @@ public sealed partial class EntryWindow : Window
|
||||
Refresh();
|
||||
}
|
||||
|
||||
/// N1MM's Alt+W: it wipes the boxes, and pressed again on empty boxes it
|
||||
/// puts back what it wiped.
|
||||
private void OnWipeOrRestore(object? sender, RoutedEventArgs e)
|
||||
{
|
||||
if (Logging is null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
Logging.WipeOrRestore();
|
||||
ResetEsm();
|
||||
SyncBoxes();
|
||||
boxes[0].Focus();
|
||||
Refresh();
|
||||
}
|
||||
|
||||
private void OnLogIt(object? sender, RoutedEventArgs e) => LogContact();
|
||||
|
||||
/// Opens the callsign's page in a browser, as N1MM's QRZ button does.
|
||||
@@ -778,21 +949,34 @@ public sealed partial class EntryWindow : Window
|
||||
{
|
||||
boxes[at].Text = Logging.Entry[at];
|
||||
}
|
||||
if (nameBox is not null)
|
||||
{
|
||||
nameBox.Text = Logging.OtherName;
|
||||
}
|
||||
if (commentBox is not null)
|
||||
{
|
||||
commentBox.Text = Logging.Comment;
|
||||
}
|
||||
updating = false;
|
||||
}
|
||||
|
||||
internal void Refresh()
|
||||
{
|
||||
RefreshSelf();
|
||||
foreach (Window window in openWindows.Values)
|
||||
{
|
||||
(window as RefreshableWindow)?.RefreshFromSession();
|
||||
}
|
||||
}
|
||||
|
||||
/// What a typed letter changes: this window, and the tool windows that
|
||||
/// show something about the call being typed.
|
||||
private void RefreshForTyping()
|
||||
{
|
||||
RefreshSelf();
|
||||
foreach (Window window in openWindows.Values)
|
||||
{
|
||||
(window as RefreshableWindow)?.RefreshForEntry();
|
||||
}
|
||||
}
|
||||
|
||||
private void RefreshSelf()
|
||||
{
|
||||
ShowFunctionKeys();
|
||||
ShowBandButtons();
|
||||
QtcExportItem.IsVisible = Logging?.Contest.HasQtcTraffic == true;
|
||||
if (Logging is null)
|
||||
{
|
||||
VerdictText.Text = "";
|
||||
@@ -824,6 +1008,7 @@ public sealed partial class EntryWindow : Window
|
||||
Title = TitleLine();
|
||||
ShowCallFrame();
|
||||
PathText.Text = PathLine();
|
||||
ShowQtcInfo();
|
||||
UserTextText.Text = Logging.Session.History.Find(Logging.Entry.Call)?.UserText ?? "";
|
||||
ShowLights();
|
||||
|
||||
@@ -836,10 +1021,6 @@ public sealed partial class EntryWindow : Window
|
||||
VerdictBorder.Background = Verdicts.Background(verdict);
|
||||
VerdictText.Text = VerdictLine(verdict);
|
||||
VerdictText.Foreground = Themes.Brush(Themes.Current.FormForeground);
|
||||
foreach (Window window in openWindows.Values)
|
||||
{
|
||||
(window as RefreshableWindow)?.Refresh();
|
||||
}
|
||||
}
|
||||
|
||||
/// N1MM colours the callsign itself rather than the box: blue for a station
|
||||
@@ -897,7 +1078,7 @@ public sealed partial class EntryWindow : Window
|
||||
BreakdownText.Text = string.Join(
|
||||
"/",
|
||||
new[] { Logging.Log.Tally.Qsos }.Concat(
|
||||
Logging.Contest.MultiplierNames.Select(
|
||||
Logging.Contest.MultiplierNamesFor(Logging.Me).Select(
|
||||
(_, at) => Logging.Log.Tally.MultiplierCount(at + 1))));
|
||||
ScoreText.Text = $"{Logging.Log.TotalScore:N0}";
|
||||
}
|
||||
@@ -975,6 +1156,24 @@ public sealed partial class EntryWindow : Window
|
||||
+ $"{path.DistanceKm:N0} km · {path.DistanceKm * MilesPerKilometre:N0} mi{sun}";
|
||||
}
|
||||
|
||||
/// WAE's QTC tally for the station being worked, which N1MM keeps in a
|
||||
/// blue label under the entry boxes: how many lines have gone with it, how
|
||||
/// many more may go, and how many contacts are left to report to anybody.
|
||||
/// The line is only there in WAE, because no other contest has traffic.
|
||||
private void ShowQtcInfo()
|
||||
{
|
||||
if (Logging is null || Logging.Contest is not Wae)
|
||||
{
|
||||
QtcInfoText.IsVisible = false;
|
||||
return;
|
||||
}
|
||||
string call = Logging.Entry.Call.Trim();
|
||||
QtcCounts counts = new QtcTraffic(Logging)
|
||||
.CountsFor(Callsign.Parse(call.Length >= 3 ? call : ""));
|
||||
QtcInfoText.Text = counts.IsFull ? $"{counts.Text} — at the limit" : counts.Text;
|
||||
QtcInfoText.IsVisible = true;
|
||||
}
|
||||
|
||||
/// A blank line where a bearing should be is a puzzle. This says which of
|
||||
/// the two ends could not be placed and what to do about it.
|
||||
private string WhyNoPath()
|
||||
@@ -1000,6 +1199,37 @@ public sealed partial class EntryWindow : Window
|
||||
{
|
||||
ClockText.Text = DateTime.UtcNow.ToString("HH:mm:ss") + "Z";
|
||||
ShowBandTimer();
|
||||
// another station keying up is not something this window is told about,
|
||||
// so the box is worked out again every second as well
|
||||
ShowTransmitWarning();
|
||||
}
|
||||
|
||||
/// The red box: this station is transmitting and the entry is over the
|
||||
/// signals it is allowed, or two of its stations are on one band. N1MM
|
||||
/// blocks the transmitter for this; this program says so and leaves the
|
||||
/// operator to stop, because a logger that decides for itself when an
|
||||
/// operator may not send loses a contact every time it is wrong.
|
||||
private void ShowTransmitWarning()
|
||||
{
|
||||
string? why = TransmitViolation();
|
||||
TransmitWarning.IsVisible = why is not null;
|
||||
TransmitWarningText.Text = why is null ? "" : $"STOP — {why}";
|
||||
}
|
||||
|
||||
private string? TransmitViolation()
|
||||
{
|
||||
if (!sending || Logging is null || session.Link is not { } link)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
List<Transmitter> others = link.Stations
|
||||
.Where(s => !s.IsMine && s.IsTransmitting)
|
||||
.Select(s => new Transmitter(s.ComputerName, s.Band, s.Mode?.Category))
|
||||
.ToList();
|
||||
return TransmitRules.Violation(
|
||||
Logging.Log.Entry,
|
||||
new Transmitter(link.ComputerName, Bands.ForFrequency(Logging.Frequency), Logging.Mode.Category),
|
||||
others);
|
||||
}
|
||||
|
||||
/// The countdown N1MM puts in its info window: how long the station still
|
||||
@@ -1093,7 +1323,11 @@ public sealed partial class EntryWindow : Window
|
||||
/// WAE QTC traffic, on Ctrl+Z as in N1MM. The contact is logged first if it
|
||||
/// is still in the boxes: the traffic belongs to a station that has been
|
||||
/// worked.
|
||||
private async Task OpenQtcWindow()
|
||||
///
|
||||
/// `wanted` is the way N1MM's `{DIGQTCS}` and `{DIGQTCR}` ask for, which
|
||||
/// is only allowed where the contest and the station leave it open. Ctrl+Z
|
||||
/// passes null and the rules decide.
|
||||
private async Task OpenQtcWindow(QtcDirection? wanted = null)
|
||||
{
|
||||
if (Logging is null)
|
||||
{
|
||||
@@ -1105,9 +1339,13 @@ public sealed partial class EntryWindow : Window
|
||||
Status("QTC traffic is a WAE thing");
|
||||
return;
|
||||
}
|
||||
if (Logging.Entry.Call.Trim().Length > 0 && Logging.Entry.IsComplete)
|
||||
// logging it here rather than through Enter: with ESM on, Enter sends
|
||||
// the next message of the contact instead of logging it, and Ctrl+Z
|
||||
// means log it and open the window. N1MM calls `LogContact` at the
|
||||
// same point
|
||||
if (Logging.Entry.Call.Trim().Length > 0 && Logging.IsEntryComplete)
|
||||
{
|
||||
OnEnter();
|
||||
LogContact();
|
||||
}
|
||||
string typed = Logging.Entry.Call.Trim();
|
||||
Callsign station = Callsign.Parse(
|
||||
@@ -1118,12 +1356,22 @@ public sealed partial class EntryWindow : Window
|
||||
Status(why);
|
||||
return;
|
||||
}
|
||||
if (wanted is { } asked)
|
||||
{
|
||||
if (direction is not QtcDirection.Either && direction != asked)
|
||||
{
|
||||
Status($"traffic with {station.Text} can only go the other way");
|
||||
return;
|
||||
}
|
||||
direction = asked;
|
||||
}
|
||||
if (direction is QtcDirection.Send && traffic.ToSend(station).Count == 0)
|
||||
{
|
||||
Status("nothing left to report to " + station.Text);
|
||||
return;
|
||||
}
|
||||
QtcWindow window = new(session, Logging, station, direction, text => SendTextAsync(text));
|
||||
QtcWindow window = new(
|
||||
session, Logging, station, direction, text => SendTextAsync(text), Refresh);
|
||||
bool saved = await window.ShowDialog<bool>(this);
|
||||
Logging.Wipe();
|
||||
SyncBoxes();
|
||||
@@ -1185,7 +1433,10 @@ public sealed partial class EntryWindow : Window
|
||||
Logging.Frequency,
|
||||
DateTime.UtcNow,
|
||||
Nonemm.Spotting.SpotSource.Operator,
|
||||
Logging.Me.Callsign));
|
||||
Logging.Me.Callsign)
|
||||
{
|
||||
Computer = session.ComputerName,
|
||||
});
|
||||
Status($"{Logging.Entry.Call.Trim()} put on the bandmap");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,70 @@
|
||||
using Avalonia.Input;
|
||||
using Avalonia.Interactivity;
|
||||
|
||||
namespace Nonemm.App.Windows;
|
||||
|
||||
/// Ctrl+wheel and Ctrl+plus / Ctrl+minus on a window change the size of its
|
||||
/// text, and Ctrl+0 puts it back to `normal`. The handlers run before the controls inside get the event, so a grid
|
||||
/// or a scroll viewer does not take the wheel first.
|
||||
public sealed class FontZoom
|
||||
{
|
||||
public const int Smallest = 8;
|
||||
public const int Largest = 32;
|
||||
|
||||
private readonly int normal;
|
||||
private readonly Func<int> size;
|
||||
private readonly Action<int> apply;
|
||||
|
||||
public FontZoom(InputElement target, int normal, Func<int> size, Action<int> apply)
|
||||
{
|
||||
this.normal = normal;
|
||||
this.size = size;
|
||||
this.apply = apply;
|
||||
target.AddHandler(InputElement.PointerWheelChangedEvent, OnWheel, RoutingStrategies.Tunnel);
|
||||
target.AddHandler(InputElement.KeyDownEvent, OnKeyDown, RoutingStrategies.Tunnel);
|
||||
}
|
||||
|
||||
private void OnWheel(object? sender, PointerWheelEventArgs e)
|
||||
{
|
||||
if (e.KeyModifiers.HasFlag(KeyModifiers.Control) && e.Delta.Y != 0)
|
||||
{
|
||||
Step(e.Delta.Y > 0 ? 1 : -1);
|
||||
e.Handled = true;
|
||||
}
|
||||
}
|
||||
|
||||
private void OnKeyDown(object? sender, KeyEventArgs e)
|
||||
{
|
||||
if (!e.KeyModifiers.HasFlag(KeyModifiers.Control))
|
||||
{
|
||||
return;
|
||||
}
|
||||
if (e.Key is Key.D0 or Key.NumPad0)
|
||||
{
|
||||
Set(normal);
|
||||
e.Handled = true;
|
||||
return;
|
||||
}
|
||||
int by = e.Key switch
|
||||
{
|
||||
Key.OemPlus or Key.Add => 1,
|
||||
Key.OemMinus or Key.Subtract => -1,
|
||||
_ => 0,
|
||||
};
|
||||
if (by != 0)
|
||||
{
|
||||
Step(by);
|
||||
e.Handled = true;
|
||||
}
|
||||
}
|
||||
|
||||
private void Step(int by) => Set(Math.Clamp(size() + by, Smallest, Largest));
|
||||
|
||||
private void Set(int wanted)
|
||||
{
|
||||
if (wanted != size())
|
||||
{
|
||||
apply(wanted);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,3 +1,4 @@
|
||||
using Nonemm.App.Theming;
|
||||
using System.Globalization;
|
||||
using Avalonia;
|
||||
using Avalonia.Controls;
|
||||
@@ -26,7 +27,7 @@ public sealed class GraylineView : Control
|
||||
private static readonly IBrush Graticule = new SolidColorBrush(Colors.White, 0.15);
|
||||
private static readonly IBrush Sun = new SolidColorBrush(Color.FromRgb(0xFF, 0xD7, 0x00));
|
||||
|
||||
private readonly Typeface typeface = new(new FontFamily("monospace"));
|
||||
private readonly Typeface typeface = new(Fonts.Mono);
|
||||
|
||||
/// The moment the map is drawn for, which is now unless the operator has
|
||||
/// stepped it forward to see where the grey line will be.
|
||||
@@ -48,24 +49,55 @@ public sealed class GraylineView : Control
|
||||
}
|
||||
}
|
||||
|
||||
private static readonly Pen CoastPen = new(Land, 1);
|
||||
private Geometry? coastlines;
|
||||
private Size coastlinesFor;
|
||||
|
||||
/// The coastlines are thousands of short segments, so they are built into
|
||||
/// one shape that is kept until the window changes size.
|
||||
private void DrawCoastlines(DrawingContext context)
|
||||
{
|
||||
Pen pen = new(Land, 1);
|
||||
if (coastlines is null || coastlinesFor != Bounds.Size)
|
||||
{
|
||||
coastlines = BuildCoastlines();
|
||||
coastlinesFor = Bounds.Size;
|
||||
}
|
||||
context.DrawGeometry(null, CoastPen, coastlines);
|
||||
}
|
||||
|
||||
private StreamGeometry BuildCoastlines()
|
||||
{
|
||||
StreamGeometry shape = new();
|
||||
using StreamGeometryContext path = shape.Open();
|
||||
foreach (IReadOnlyList<Point> line in WorldMap.Coastlines)
|
||||
{
|
||||
for (int at = 1; at < line.Count; at++)
|
||||
bool open = false;
|
||||
for (int at = 0; at < line.Count; at++)
|
||||
{
|
||||
Point from = line[at - 1];
|
||||
Point to = line[at];
|
||||
// a line that runs off one edge and back on at the other is the
|
||||
// date line being crossed, and is left undrawn
|
||||
if (Math.Abs(to.X - from.X) > 180)
|
||||
if (open && Math.Abs(to.X - line[at - 1].X) > 180)
|
||||
{
|
||||
continue;
|
||||
path.EndFigure(false);
|
||||
open = false;
|
||||
}
|
||||
context.DrawLine(pen, At(from.Y, from.X), At(to.Y, to.X));
|
||||
if (open)
|
||||
{
|
||||
path.LineTo(At(to.Y, to.X));
|
||||
}
|
||||
else
|
||||
{
|
||||
path.BeginFigure(At(to.Y, to.X), isFilled: false);
|
||||
open = true;
|
||||
}
|
||||
}
|
||||
if (open)
|
||||
{
|
||||
path.EndFigure(false);
|
||||
}
|
||||
}
|
||||
return shape;
|
||||
}
|
||||
|
||||
/// The night is one shape, its edge the terminator: the latitude where the
|
||||
|
||||
@@ -25,21 +25,40 @@ public sealed partial class GraylineWindow : RefreshableWindow
|
||||
clock = new DispatcherTimer { Interval = TimeSpan.FromMinutes(1) };
|
||||
clock.Tick += (_, _) => Refresh();
|
||||
clock.Start();
|
||||
session.Changed += WhenSessionChanged;
|
||||
Closed += (_, _) =>
|
||||
{
|
||||
clock.Stop();
|
||||
session.Changed -= WhenSessionChanged;
|
||||
later?.Cancel();
|
||||
};
|
||||
Refresh();
|
||||
}
|
||||
|
||||
private OperatingPosition? Radio => session.Position;
|
||||
|
||||
private Throttled? later;
|
||||
|
||||
/// The map is not watched closely: a station typed or spotted shows up
|
||||
/// within fifteen seconds, and the grey line moves too slowly to see.
|
||||
public override void RefreshForEntry() => RefreshFromSession();
|
||||
|
||||
public override void RefreshFromSession()
|
||||
{
|
||||
later ??= new Throttled(TimeSpan.FromSeconds(15), Refresh, holdWhileTyping: true);
|
||||
later.Request();
|
||||
}
|
||||
|
||||
public override void Refresh()
|
||||
{
|
||||
Map.Moment = DateTime.UtcNow;
|
||||
Map.Markers = Markers();
|
||||
DateTime now = DateTime.UtcNow;
|
||||
IReadOnlyList<MapMarker> markers = Markers();
|
||||
// the terminator moves a quarter of a degree a minute, so a redraw
|
||||
// for nothing but the clock can wait
|
||||
if (now - Map.Moment < TimeSpan.FromSeconds(30) && Map.Markers.SequenceEqual(markers))
|
||||
{
|
||||
return;
|
||||
}
|
||||
Map.Moment = now;
|
||||
Map.Markers = markers;
|
||||
Map.InvalidateVisual();
|
||||
}
|
||||
|
||||
@@ -93,8 +112,5 @@ public sealed partial class GraylineWindow : RefreshableWindow
|
||||
private CountryLookup? Where(string call) =>
|
||||
call.Trim().Length == 0 ? null : session.Countries?.Find(call.Trim());
|
||||
|
||||
private void WhenSessionChanged(object? sender, EventArgs e) =>
|
||||
Dispatcher.UIThread.Post(Refresh);
|
||||
|
||||
private sealed record Station(string Call, double Latitude, double Longitude, IBrush Colour);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,11 @@
|
||||
using Avalonia.Media;
|
||||
|
||||
namespace Nonemm.App.Windows;
|
||||
|
||||
/// The three colours N1MM's info window uses for a figure against its target.
|
||||
public static class InfoColours
|
||||
{
|
||||
public static readonly IBrush Good = new SolidColorBrush(Color.FromRgb(0xB8, 0xE6, 0xB0));
|
||||
public static readonly IBrush Fair = new SolidColorBrush(Color.FromRgb(0xF5, 0xE0, 0x7A));
|
||||
public static readonly IBrush Poor = new SolidColorBrush(Color.FromRgb(0xE8, 0x9A, 0x8F));
|
||||
}
|
||||
@@ -0,0 +1,158 @@
|
||||
using Nonemm.Contests;
|
||||
using Nonemm.Core;
|
||||
|
||||
namespace Nonemm.App.Windows;
|
||||
|
||||
public sealed partial class InfoWindow
|
||||
{
|
||||
/// The graphs only change with the clock every so often, so the timer
|
||||
/// redraws them on one tick in this many.
|
||||
private const int GraphEveryTicks = 15;
|
||||
|
||||
/// N1MM leaves this much room above the tallest bar.
|
||||
private const double RateHeadroom = 1.35;
|
||||
|
||||
private const int EmptyScale = 100;
|
||||
|
||||
private string goalsShown = "";
|
||||
private Goals goals = Goals.Default;
|
||||
|
||||
private bool IsNetworked => session.Link is not null || session.Network is not null;
|
||||
|
||||
/// The contacts the graphs count: the claimed ones, narrowed to this
|
||||
/// computer on a network unless the menu says all, and to the radio's band
|
||||
/// if it says so.
|
||||
private IReadOnlyList<Qso> GraphContacts()
|
||||
{
|
||||
if (Logging is null)
|
||||
{
|
||||
return [];
|
||||
}
|
||||
IEnumerable<Qso> found = Logging.Log.Qsos.Where(q => q.IsClaimed && Logging.Contest.IsContact(q));
|
||||
if (!Info.NetworkedRate && IsNetworked)
|
||||
{
|
||||
found = found.Where(q => q.StationName == session.ComputerName);
|
||||
}
|
||||
if (Info.BandRate && session.Position?.Band is { } band)
|
||||
{
|
||||
found = found.Where(q => q.Band == band);
|
||||
}
|
||||
return [.. found];
|
||||
}
|
||||
|
||||
private Goals CurrentGoals()
|
||||
{
|
||||
if (Info.Goals != goalsShown)
|
||||
{
|
||||
goalsShown = Info.Goals;
|
||||
try
|
||||
{
|
||||
goals = Goals.Parse(goalsShown);
|
||||
}
|
||||
catch (FormatException)
|
||||
{
|
||||
goals = Goals.Default;
|
||||
}
|
||||
}
|
||||
return goals;
|
||||
}
|
||||
|
||||
private void ShowGraphs()
|
||||
{
|
||||
if (Logging is null)
|
||||
{
|
||||
RateGraph.Bars = [];
|
||||
GoalGraph.Bars = [];
|
||||
RateLabel.Text = "";
|
||||
GoalLabel.Text = "";
|
||||
NextGoalText.Text = "";
|
||||
RateGraph.InvalidateVisual();
|
||||
GoalGraph.InvalidateVisual();
|
||||
return;
|
||||
}
|
||||
DateTime now = DateTime.UtcNow;
|
||||
IReadOnlyList<Qso> contacts = GraphContacts();
|
||||
ShowRates(contacts, now);
|
||||
ShowHourly(contacts, now);
|
||||
}
|
||||
|
||||
private void ShowRates(IReadOnlyList<Qso> contacts, DateTime now)
|
||||
{
|
||||
TimeSpan minimum = Logging!.Contest.MinimumOffTime;
|
||||
TimeSpan hour = TimeSpan.FromHours(1);
|
||||
int goal = Info.ShowGoals ? CurrentGoals().At(now, Logging.Instance.StartDate) : 0;
|
||||
int[] values = Info.ShowPoints
|
||||
?
|
||||
[
|
||||
RateBars.PointsOfLast(contacts, 10, now, minimum),
|
||||
RateBars.PointsOfLast(contacts, 100, now, minimum),
|
||||
RateBars.PointsWithin(contacts, now, hour),
|
||||
RateBars.PointsThisClockHour(contacts, now),
|
||||
]
|
||||
:
|
||||
[
|
||||
Rates.PerHour(contacts, 10, now, minimum),
|
||||
Rates.PerHour(contacts, 100, now, minimum),
|
||||
RateBars.Within(contacts, now, hour),
|
||||
RateBars.ThisClockHour(contacts, now),
|
||||
];
|
||||
bool isColoured = Info.ShowGoals && !Info.ShowPoints;
|
||||
string[] names = ["10", "100", "60m", "hr"];
|
||||
RateGraph.Bars = [.. values.Select((v, at) => new RateBar(names[at], v, isColoured ? LevelOf(v, goal) : RateLevel.Plain))];
|
||||
int tallest = Math.Max(values.Max(), isColoured ? goal : 0);
|
||||
RateGraph.Maximum = tallest > 0 ? tallest * RateHeadroom : EmptyScale;
|
||||
RateGraph.Shaded = isColoured ? goal : null;
|
||||
RateLabel.Text = $"{(Info.ShowPoints ? "Points" : "Q's")} - 10, 100, 60m, {now.Minute}m";
|
||||
RateGraph.InvalidateVisual();
|
||||
}
|
||||
|
||||
/// A bar at or over the goal is green, at half the goal or under is red,
|
||||
/// and the rest are yellow.
|
||||
private static RateLevel LevelOf(int rate, int goal) =>
|
||||
rate >= goal ? RateLevel.Good : rate <= 0.5 * goal ? RateLevel.Poor : RateLevel.Fair;
|
||||
|
||||
private void ShowHourly(IReadOnlyList<Qso> contacts, DateTime now)
|
||||
{
|
||||
int step = Info.HourlyMinutes;
|
||||
IReadOnlyList<int> rates = RateBars.Hourly(contacts, now, step);
|
||||
DateTime start = Logging!.Instance.StartDate;
|
||||
Goals wanted = CurrentGoals();
|
||||
IReadOnlyList<int?> aims =
|
||||
[
|
||||
.. rates.Select((_, at) => Info.ShowGoals
|
||||
? (int?)wanted.At(now.AddMinutes(-(rates.Count - 1 - at) * step), start)
|
||||
: null),
|
||||
];
|
||||
DateTime current = now.AddMinutes(-(now.Minute % step));
|
||||
GoalGraph.Bars =
|
||||
[
|
||||
.. rates.Select((rate, at) => new RateBar(
|
||||
current.AddMinutes(-(rates.Count - 1 - at) * step).ToString("HH:mm"),
|
||||
rate,
|
||||
RateLevel.Plain,
|
||||
aims[at])),
|
||||
];
|
||||
int tallest = Math.Max(rates.Max(), aims.Max() ?? 0);
|
||||
// N1MM's scale: about a tenth of the tallest figure, plus one, times ten
|
||||
GoalGraph.Maximum = tallest > 0 ? (((int)Math.Round(tallest * 0.11)) + 1) * 10 : EmptyScale;
|
||||
GoalGraph.ShowGoalLine = Info.ShowGoals;
|
||||
NextGoalText.Text = Info.ShowGoals
|
||||
? $"Next Goal {wanted.At(now.AddMinutes(step), start)}"
|
||||
: "";
|
||||
GoalLabel.Text = GoalTitle();
|
||||
GoalGraph.InvalidateVisual();
|
||||
}
|
||||
|
||||
private string GoalTitle()
|
||||
{
|
||||
if (!IsNetworked)
|
||||
{
|
||||
return Info.BandRate ? "Active Band - Q's/Hr" : "Q's/Hr";
|
||||
}
|
||||
if (Info.NetworkedRate)
|
||||
{
|
||||
return Info.BandRate ? "My Band All Stns - Q's/Hr" : "All Stations - Q's/Hr";
|
||||
}
|
||||
return Info.BandRate ? "Active Band - Q's/Hr" : $"{session.ComputerName.ToUpperInvariant()} - Q's/Hr";
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,164 @@
|
||||
using System.Diagnostics;
|
||||
using Avalonia.Controls;
|
||||
using Avalonia.Input.Platform;
|
||||
using Avalonia.Interactivity;
|
||||
using Avalonia.Platform.Storage;
|
||||
using Nonemm.App.Configuration;
|
||||
using Nonemm.App.Dialogs;
|
||||
using Nonemm.Contests;
|
||||
|
||||
namespace Nonemm.App.Windows;
|
||||
|
||||
public sealed partial class InfoWindow
|
||||
{
|
||||
private const string HelpUrl = "https://n1mmwp.hamdocs.com/manual-windows/info-window/";
|
||||
|
||||
private void OnMenuOpening(object? sender, System.ComponentModel.CancelEventArgs e)
|
||||
{
|
||||
SpotItem.IsChecked = Info.CallFrameSpot;
|
||||
CountryItem.IsChecked = Info.CountryInfo;
|
||||
SunItem.IsChecked = Info.SunTimes;
|
||||
WwvItem.IsChecked = Info.Wwv;
|
||||
MessagesItem.IsChecked = Info.Messages;
|
||||
GoalsItem.IsChecked = Info.ShowGoals;
|
||||
TimersItem.IsChecked = Info.QsoTimers;
|
||||
NetworkedItem.IsChecked = Info.NetworkedRate;
|
||||
NetworkedItem.IsEnabled = IsNetworked;
|
||||
BandItem.IsChecked = Info.BandRate;
|
||||
ContactsItem.IsChecked = !Info.ShowPoints;
|
||||
PointsItem.IsChecked = Info.ShowPoints;
|
||||
Minutes20Item.IsChecked = Info.HourlyMinutes == 20;
|
||||
Minutes30Item.IsChecked = Info.HourlyMinutes == 30;
|
||||
Minutes60Item.IsChecked = Info.HourlyMinutes == 60;
|
||||
}
|
||||
|
||||
private void Change(Func<StoredInfoWindow, StoredInfoWindow> change)
|
||||
{
|
||||
session.Save(session.Settings with { Info = change(Info) });
|
||||
Refresh();
|
||||
}
|
||||
|
||||
private void OnToggleSpot(object? sender, RoutedEventArgs e) =>
|
||||
Change(i => i with { CallFrameSpot = !i.CallFrameSpot });
|
||||
|
||||
private void OnToggleCountry(object? sender, RoutedEventArgs e) =>
|
||||
Change(i => i with { CountryInfo = !i.CountryInfo });
|
||||
|
||||
private void OnToggleSun(object? sender, RoutedEventArgs e) =>
|
||||
Change(i => i with { SunTimes = !i.SunTimes });
|
||||
|
||||
private void OnToggleWwv(object? sender, RoutedEventArgs e) =>
|
||||
Change(i => i with { Wwv = !i.Wwv });
|
||||
|
||||
private void OnToggleMessages(object? sender, RoutedEventArgs e) =>
|
||||
Change(i => i with { Messages = !i.Messages });
|
||||
|
||||
private void OnToggleGoals(object? sender, RoutedEventArgs e) =>
|
||||
Change(i => i with { ShowGoals = !i.ShowGoals });
|
||||
|
||||
private void OnToggleTimers(object? sender, RoutedEventArgs e) =>
|
||||
Change(i => i with { QsoTimers = !i.QsoTimers });
|
||||
|
||||
private void OnToggleNetworked(object? sender, RoutedEventArgs e) =>
|
||||
Change(i => i with { NetworkedRate = !i.NetworkedRate });
|
||||
|
||||
private void OnToggleBand(object? sender, RoutedEventArgs e) =>
|
||||
Change(i => i with { BandRate = !i.BandRate });
|
||||
|
||||
private void OnShowContacts(object? sender, RoutedEventArgs e) => Change(i => i with { ShowPoints = false });
|
||||
|
||||
private void OnShowPoints(object? sender, RoutedEventArgs e) => Change(i => i with { ShowPoints = true });
|
||||
|
||||
private void OnMinutes20(object? sender, RoutedEventArgs e) => Change(i => i with { HourlyMinutes = 20 });
|
||||
|
||||
private void OnMinutes30(object? sender, RoutedEventArgs e) => Change(i => i with { HourlyMinutes = 30 });
|
||||
|
||||
private void OnMinutes60(object? sender, RoutedEventArgs e) => Change(i => i with { HourlyMinutes = 60 });
|
||||
|
||||
private async void OnCopyMessages(object? sender, RoutedEventArgs e)
|
||||
{
|
||||
if (Clipboard is { } clipboard)
|
||||
{
|
||||
await clipboard.SetTextAsync(string.Join(
|
||||
'\n',
|
||||
session.Notices.Select(n => $"{n.AtUtc:HH:mm:ss} {n.Text}")));
|
||||
}
|
||||
}
|
||||
|
||||
private void OnClearMessages(object? sender, RoutedEventArgs e) => session.ClearNotices();
|
||||
|
||||
/// Opens the Reverse Beacon Network's page for this station's call, which
|
||||
/// lists who has heard it lately. It is useful on CW and RTTY and says
|
||||
/// nothing about phone.
|
||||
private void OnShowRbn(object? sender, RoutedEventArgs e)
|
||||
{
|
||||
string call = session.Settings.Station.Callsign.Trim();
|
||||
if (call.Length > 0)
|
||||
{
|
||||
Open($"http://www.reversebeacon.net/dxsd1/dxsd1.php?f=0&c={Uri.EscapeDataString(call)}&t=dx");
|
||||
}
|
||||
}
|
||||
|
||||
private void OnHelp(object? sender, RoutedEventArgs e) => Open(HelpUrl);
|
||||
|
||||
private void Open(string url)
|
||||
{
|
||||
try
|
||||
{
|
||||
Process.Start(new ProcessStartInfo(url) { UseShellExecute = true });
|
||||
}
|
||||
catch (Exception error) when (error is System.ComponentModel.Win32Exception or IOException)
|
||||
{
|
||||
session.PostNotice($"could not open a browser for {url}: {error.Message}");
|
||||
}
|
||||
}
|
||||
|
||||
private async void OnEditGoals(object? sender, RoutedEventArgs e)
|
||||
{
|
||||
string current = Info.Goals.Length > 0 ? Info.Goals : Goals.Default.ToText();
|
||||
if (await new GoalsDialog(current, session.Paths.GoalFiles).ShowDialog<string?>(this) is { } edited)
|
||||
{
|
||||
Change(i => i with { Goals = edited });
|
||||
}
|
||||
}
|
||||
|
||||
/// N1MM asks which band's column to take from a statistics file, then
|
||||
/// which file.
|
||||
private async void OnImportGoals(object? sender, RoutedEventArgs e)
|
||||
{
|
||||
if (await new ImportGoalsDialog().ShowDialog<int?>(this) is not { } fromEnd)
|
||||
{
|
||||
return;
|
||||
}
|
||||
IReadOnlyList<IStorageFile> picked = await StorageProvider.OpenFilePickerAsync(
|
||||
new FilePickerOpenOptions
|
||||
{
|
||||
Title = "Select Filename",
|
||||
AllowMultiple = false,
|
||||
SuggestedStartLocation = await StorageProvider.TryGetFolderFromPathAsync(session.Paths.GoalFiles),
|
||||
FileTypeFilter =
|
||||
[
|
||||
new FilePickerFileType("Goal TXT Files") { Patterns = ["*.txt"] },
|
||||
new FilePickerFileType("Goal CSV files") { Patterns = ["*.csv"] },
|
||||
],
|
||||
});
|
||||
if (picked.Count == 0)
|
||||
{
|
||||
return;
|
||||
}
|
||||
string path = picked[0].Path.LocalPath;
|
||||
try
|
||||
{
|
||||
Goals imported = Goals.Parse(
|
||||
await File.ReadAllTextAsync(path),
|
||||
isCsv: path.EndsWith(".csv", StringComparison.OrdinalIgnoreCase),
|
||||
fromEnd);
|
||||
Change(i => i with { Goals = imported.ToText() });
|
||||
session.PostNotice($"goals imported from {picked[0].Name}");
|
||||
}
|
||||
catch (Exception problem) when (problem is FormatException or IOException)
|
||||
{
|
||||
session.PostNotice($"could not import goals from {picked[0].Name}: {problem.Message}");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,152 @@
|
||||
using Avalonia.Controls;
|
||||
using Avalonia.Interactivity;
|
||||
using Avalonia.Media;
|
||||
using Nonemm.Contests;
|
||||
using Nonemm.Core;
|
||||
|
||||
namespace Nonemm.App.Windows;
|
||||
|
||||
public sealed partial class InfoWindow
|
||||
{
|
||||
/// The contest names whose band timer N1MM calls a band/multiplier timer.
|
||||
private static readonly string[] BandMultTimers = ["ARIDX", "LZBALCHIK"];
|
||||
|
||||
private void ShowTimers()
|
||||
{
|
||||
if (Logging is null)
|
||||
{
|
||||
QsoTimerFrame.IsVisible = false;
|
||||
BandTimerFrame.IsVisible = false;
|
||||
BandChangeFrame.IsVisible = false;
|
||||
RunBox.IsVisible = false;
|
||||
return;
|
||||
}
|
||||
DateTime now = DateTime.UtcNow;
|
||||
IReadOnlyList<Qso> contacts = [.. Logging.Log.Qsos.Where(Logging.Contest.IsContact)];
|
||||
ShowQsoTimer(contacts, now);
|
||||
ShowBandRules(contacts, now);
|
||||
ShowMultRun();
|
||||
}
|
||||
|
||||
private void ShowQsoTimer(IReadOnlyList<Qso> contacts, DateTime now)
|
||||
{
|
||||
QsoTimerFrame.IsVisible = Info.QsoTimers;
|
||||
if (!Info.QsoTimers)
|
||||
{
|
||||
return;
|
||||
}
|
||||
TimeSpan minimum = Logging!.Contest.MinimumOffTime;
|
||||
QsoTimerReading reading = QsoTimer.Read(
|
||||
contacts,
|
||||
Info.TimerOption,
|
||||
minimum,
|
||||
Logging.Instance.StartDate,
|
||||
now,
|
||||
session.ComputerName);
|
||||
QsoTimerCaption.Text = QsoTimer.Caption(Info.TimerOption, (int)minimum.TotalMinutes, session.Positions.Count > 1);
|
||||
QsoTimerText.Text = reading.Text;
|
||||
Paint(QsoTimerBox, QsoTimerText, reading.State switch
|
||||
{
|
||||
TimerState.Met => InfoColours.Good,
|
||||
TimerState.Warning => InfoColours.Fair,
|
||||
TimerState.Over => InfoColours.Poor,
|
||||
_ => null,
|
||||
});
|
||||
}
|
||||
|
||||
/// The band timer of a contest that makes the station stay on a band, and
|
||||
/// the count of band changes of a contest that limits them.
|
||||
private void ShowBandRules(IReadOnlyList<Qso> contacts, DateTime now)
|
||||
{
|
||||
BandChangeRules rules = Logging!.Contest.BandChangesFor(Logging.Log.Entry);
|
||||
BandTimerFrame.IsVisible = rules.HasStayTimer;
|
||||
if (rules.HasStayTimer)
|
||||
{
|
||||
TimeSpan left = rules.StayLeft(contacts, now);
|
||||
BandTimerText.Text = $"{(int)left.TotalMinutes:00}:{left.Seconds:00}";
|
||||
Paint(
|
||||
BandTimerBox,
|
||||
BandTimerText,
|
||||
left == TimeSpan.Zero ? InfoColours.Good : left < TimeSpan.FromMinutes(1) ? InfoColours.Fair : null);
|
||||
BandTimerCaption.Text = $"{(int)rules.MinimumStay.TotalMinutes} Min {BandTimerName()} Timer";
|
||||
}
|
||||
|
||||
BandChangeFrame.IsVisible = rules.IsCounted;
|
||||
if (rules.IsCounted)
|
||||
{
|
||||
int changes = rules.CountedIn(contacts, now);
|
||||
BandChangeText.Text = changes.ToString();
|
||||
Paint(
|
||||
BandChangeBox,
|
||||
BandChangeText,
|
||||
changes < rules.Max - 1 ? InfoColours.Good : changes == rules.Max - 1 ? InfoColours.Fair : InfoColours.Poor);
|
||||
}
|
||||
}
|
||||
|
||||
private string BandTimerName()
|
||||
{
|
||||
string contest = Logging!.Instance.ContestName;
|
||||
bool isBandMult = BandMultTimers.Contains(contest)
|
||||
|| (contest == "IARU" && EntryCategories.IsMultiOne(Logging.Log.Entry));
|
||||
return isBandMult ? "B/M" : "Band";
|
||||
}
|
||||
|
||||
/// `Run1` or `Run2` for a multi-two entry, `RUN` or `MULT` for a
|
||||
/// multi-one entry, and nothing for any other category.
|
||||
private void ShowMultRun()
|
||||
{
|
||||
ContestEntry entry = Logging!.Log.Entry;
|
||||
bool isOne = EntryCategories.IsMultiOne(entry);
|
||||
RunBox.IsVisible = isOne || EntryCategories.IsMultiTwo(entry);
|
||||
if (RunBox.IsVisible)
|
||||
{
|
||||
RunText.Text = isOne
|
||||
? session.IsRun2 ? "MULT" : "RUN"
|
||||
: session.IsRun2 ? "Run2" : "Run1";
|
||||
}
|
||||
}
|
||||
|
||||
private static void Paint(Border box, TextBlock text, IBrush? background)
|
||||
{
|
||||
box.Background = background;
|
||||
if (background is null)
|
||||
{
|
||||
text.ClearValue(TextBlock.ForegroundProperty);
|
||||
}
|
||||
else
|
||||
{
|
||||
text.Foreground = Brushes.Black;
|
||||
}
|
||||
}
|
||||
|
||||
private void OnTimerMenuOpening(object? sender, System.ComponentModel.CancelEventArgs e)
|
||||
{
|
||||
CountDownItem.IsChecked = Info.TimerOption == QsoTimerOption.CountDown;
|
||||
CountUpItem.IsChecked = Info.TimerOption == QsoTimerOption.CountUp;
|
||||
CumulativeItem.IsChecked = Info.TimerOption == QsoTimerOption.Cumulative;
|
||||
AllStationsItem.IsChecked = Info.TimerOption == QsoTimerOption.AllStations;
|
||||
ThisStationItem.IsChecked = Info.TimerOption == QsoTimerOption.ThisStation;
|
||||
LeftRadioItem.IsChecked = Info.TimerOption == QsoTimerOption.LeftRadio;
|
||||
RightRadioItem.IsChecked = Info.TimerOption == QsoTimerOption.RightRadio;
|
||||
}
|
||||
|
||||
private void UseTimer(QsoTimerOption option)
|
||||
{
|
||||
session.Save(session.Settings with { Info = Info with { TimerOption = option } });
|
||||
ShowTimers();
|
||||
}
|
||||
|
||||
private void OnTimerCountDown(object? sender, RoutedEventArgs e) => UseTimer(QsoTimerOption.CountDown);
|
||||
|
||||
private void OnTimerCountUp(object? sender, RoutedEventArgs e) => UseTimer(QsoTimerOption.CountUp);
|
||||
|
||||
private void OnTimerCumulative(object? sender, RoutedEventArgs e) => UseTimer(QsoTimerOption.Cumulative);
|
||||
|
||||
private void OnTimerAllStations(object? sender, RoutedEventArgs e) => UseTimer(QsoTimerOption.AllStations);
|
||||
|
||||
private void OnTimerThisStation(object? sender, RoutedEventArgs e) => UseTimer(QsoTimerOption.ThisStation);
|
||||
|
||||
private void OnTimerLeftRadio(object? sender, RoutedEventArgs e) => UseTimer(QsoTimerOption.LeftRadio);
|
||||
|
||||
private void OnTimerRightRadio(object? sender, RoutedEventArgs e) => UseTimer(QsoTimerOption.RightRadio);
|
||||
}
|
||||
@@ -0,0 +1,114 @@
|
||||
<local:RefreshableWindow xmlns="https://github.com/avaloniaui"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:local="using:Nonemm.App.Windows"
|
||||
x:Class="Nonemm.App.Windows.InfoWindow"
|
||||
Title="Info" Width="560" Height="470">
|
||||
<local:RefreshableWindow.ContextMenu>
|
||||
<ContextMenu Opening="OnMenuOpening">
|
||||
<MenuItem Name="SpotItem" Header="Callframe Spot" ToggleType="CheckBox" Click="OnToggleSpot" />
|
||||
<MenuItem Name="CountryItem" Header="Country Info" ToggleType="CheckBox" Click="OnToggleCountry" />
|
||||
<MenuItem Name="SunItem" Header="Sunrise/Sunset" ToggleType="CheckBox" Click="OnToggleSun" />
|
||||
<MenuItem Name="WwvItem" Header="WWV Messages" ToggleType="CheckBox" Click="OnToggleWwv" />
|
||||
<MenuItem Name="MessagesItem" Header="Message Window" ToggleType="CheckBox" Click="OnToggleMessages" />
|
||||
<MenuItem Name="GoalsItem" Header="Show Goals" ToggleType="CheckBox" Click="OnToggleGoals" />
|
||||
<MenuItem Name="TimersItem" Header="Show QSO Timers" ToggleType="CheckBox" Click="OnToggleTimers" />
|
||||
<Separator />
|
||||
<MenuItem Name="NetworkedItem" Header="Rates & Goals - All Computers" ToggleType="CheckBox"
|
||||
Click="OnToggleNetworked" />
|
||||
<MenuItem Name="BandItem" Header="Rates & Goals - Only Current Band" ToggleType="CheckBox"
|
||||
Click="OnToggleBand" />
|
||||
<MenuItem Name="ContactsItem" Header="Contacts" ToggleType="Radio" Click="OnShowContacts" />
|
||||
<MenuItem Name="PointsItem" Header="Points" ToggleType="Radio" Click="OnShowPoints" />
|
||||
<Separator />
|
||||
<MenuItem Name="Minutes20Item" Header="Goals Chart - 20min Moving Average" ToggleType="Radio"
|
||||
Click="OnMinutes20" />
|
||||
<MenuItem Name="Minutes30Item" Header="Goals Chart - 30min Moving Average" ToggleType="Radio"
|
||||
Click="OnMinutes30" />
|
||||
<MenuItem Name="Minutes60Item" Header="Goals Chart - 60min Moving Average" ToggleType="Radio"
|
||||
Click="OnMinutes60" />
|
||||
<Separator />
|
||||
<MenuItem Header="Edit, Export Goals…" Click="OnEditGoals" />
|
||||
<MenuItem Header="Import Goals…" Click="OnImportGoals" />
|
||||
<Separator />
|
||||
<MenuItem Header="Copy Message Text to Clipboard" Click="OnCopyMessages" />
|
||||
<MenuItem Header="Clear Message Window" Click="OnClearMessages" />
|
||||
<MenuItem Header="Show RBN Spots of this Station" Click="OnShowRbn" />
|
||||
<MenuItem Header="Help" Click="OnHelp" />
|
||||
</ContextMenu>
|
||||
</local:RefreshableWindow.ContextMenu>
|
||||
<DockPanel Margin="4">
|
||||
<ScrollViewer DockPanel.Dock="Bottom" Name="MessagesScroll" Height="90" Margin="0,4,0,0">
|
||||
<SelectableTextBlock Name="MessagesText" FontSize="11" TextWrapping="Wrap" />
|
||||
</ScrollViewer>
|
||||
<TextBlock DockPanel.Dock="Bottom" Name="StatusText" FontSize="11" Opacity="0.8" Margin="0,2,0,0" />
|
||||
<StackPanel DockPanel.Dock="Top" Spacing="1" Margin="0,0,0,4">
|
||||
<TextBlock Name="SpotText" FontFamily="monospace" FontSize="12" TextTrimming="CharacterEllipsis" />
|
||||
<TextBlock Name="CountryText" FontFamily="monospace" FontSize="12" TextTrimming="CharacterEllipsis" />
|
||||
<TextBlock Name="SunText" FontFamily="monospace" FontSize="12" TextTrimming="CharacterEllipsis" />
|
||||
<TextBlock Name="WwvText" FontFamily="monospace" FontSize="12" TextTrimming="CharacterEllipsis" />
|
||||
</StackPanel>
|
||||
<Grid ColumnDefinitions="*,Auto">
|
||||
<Grid Grid.Column="0" ColumnDefinitions="*,*" RowDefinitions="Auto,*,Auto" Margin="0,0,6,0">
|
||||
<TextBlock Grid.Row="0" Grid.Column="0" Name="RateLabel" FontSize="11" HorizontalAlignment="Center" />
|
||||
<TextBlock Grid.Row="0" Grid.Column="1" Name="GoalLabel" FontSize="11" HorizontalAlignment="Center" />
|
||||
<local:RateGraphView Grid.Row="1" Grid.Column="0" Name="RateGraph" Margin="0,2,3,0"
|
||||
ToolTip.Tip="Rates for the last 10 and 100 QSOs, the last 60 minutes and since the top of the hour. The shaded area is the goal." />
|
||||
<local:RateGraphView Grid.Row="1" Grid.Column="1" Name="GoalGraph" Margin="3,2,0,0" />
|
||||
<TextBlock Grid.Row="2" Grid.Column="1" Name="NextGoalText" FontSize="11" HorizontalAlignment="Center" />
|
||||
</Grid>
|
||||
<StackPanel Grid.Column="1" Width="150" Spacing="4">
|
||||
<TextBlock Name="OperatorText" FontSize="18" FontWeight="Bold" HorizontalAlignment="Right" />
|
||||
<Border Name="QsoTimerFrame" BorderBrush="Gray" BorderThickness="1" CornerRadius="3" Padding="4,2">
|
||||
<Border.ContextMenu>
|
||||
<ContextMenu Opening="OnTimerMenuOpening">
|
||||
<MenuItem Header="Display Off Time (full minutes with no QSO's)">
|
||||
<MenuItem Name="CountDownItem" Header="Current Interval Count Down Timer" ToggleType="Radio"
|
||||
Click="OnTimerCountDown" />
|
||||
<MenuItem Name="CountUpItem" Header="Current Interval Count Up Timer" ToggleType="Radio"
|
||||
Click="OnTimerCountUp" />
|
||||
<MenuItem Name="CumulativeItem" Header="Cumulative Contest Off Time" ToggleType="Radio"
|
||||
Click="OnTimerCumulative" />
|
||||
</MenuItem>
|
||||
<MenuItem Header="Time Since Last QSO (not for off time rule compliance)">
|
||||
<MenuItem Name="AllStationsItem" Header="All Computers & Radios" ToggleType="Radio"
|
||||
Click="OnTimerAllStations" />
|
||||
<MenuItem Name="ThisStationItem" Header="Both Radios (SO2R), VFO A/B (SO1V/2V)" ToggleType="Radio"
|
||||
Click="OnTimerThisStation" />
|
||||
<MenuItem Name="LeftRadioItem" Header="Left Radio (SO2R), VFOA (SO2V)" ToggleType="Radio"
|
||||
Click="OnTimerLeftRadio" />
|
||||
<MenuItem Name="RightRadioItem" Header="Right Radio (SO2R), VFO B (SO2V)" ToggleType="Radio"
|
||||
Click="OnTimerRightRadio" />
|
||||
</MenuItem>
|
||||
</ContextMenu>
|
||||
</Border.ContextMenu>
|
||||
<StackPanel>
|
||||
<TextBlock Name="QsoTimerCaption" FontSize="10" />
|
||||
<Border Name="QsoTimerBox" Padding="4,1" CornerRadius="2">
|
||||
<TextBlock Name="QsoTimerText" FontFamily="monospace" FontSize="18" HorizontalAlignment="Center" />
|
||||
</Border>
|
||||
</StackPanel>
|
||||
</Border>
|
||||
<Border Name="BandTimerFrame" BorderBrush="Gray" BorderThickness="1" CornerRadius="3" Padding="4,2">
|
||||
<StackPanel>
|
||||
<TextBlock Name="BandTimerCaption" FontSize="10" />
|
||||
<Border Name="BandTimerBox" Padding="4,1" CornerRadius="2">
|
||||
<TextBlock Name="BandTimerText" FontFamily="monospace" FontSize="18" HorizontalAlignment="Center" />
|
||||
</Border>
|
||||
</StackPanel>
|
||||
</Border>
|
||||
<Border Name="BandChangeFrame" BorderBrush="Gray" BorderThickness="1" CornerRadius="3" Padding="4,2">
|
||||
<StackPanel>
|
||||
<TextBlock Text="Band Chgs" FontSize="10" />
|
||||
<Border Name="BandChangeBox" Padding="4,1" CornerRadius="2">
|
||||
<TextBlock Name="BandChangeText" FontFamily="monospace" FontSize="18" HorizontalAlignment="Center" />
|
||||
</Border>
|
||||
</StackPanel>
|
||||
</Border>
|
||||
<Border Name="RunBox" Padding="4,1" CornerRadius="2" BorderBrush="Gray" BorderThickness="1">
|
||||
<TextBlock Name="RunText" FontFamily="monospace" FontSize="16" HorizontalAlignment="Center"
|
||||
ToolTip.Tip="Ctrl+Alt+M toggles Run and Mult" />
|
||||
</Border>
|
||||
</StackPanel>
|
||||
</Grid>
|
||||
</DockPanel>
|
||||
</local:RefreshableWindow>
|
||||
@@ -0,0 +1,188 @@
|
||||
using Avalonia.Controls;
|
||||
using Avalonia.Controls.Documents;
|
||||
using Avalonia.Media;
|
||||
using Avalonia.Threading;
|
||||
using Nonemm.Contests;
|
||||
using Nonemm.Core;
|
||||
using Nonemm.Core.Country;
|
||||
using Nonemm.Session;
|
||||
using Nonemm.Spotting;
|
||||
|
||||
namespace Nonemm.App.Windows;
|
||||
|
||||
/// N1MM's info window: who is operating, what is known about the station in the
|
||||
/// call box, the rate graphs against the goals, and the timers contests with a
|
||||
/// rest rule or a band-change rule ask the operator to watch.
|
||||
public sealed partial class InfoWindow : RefreshableWindow
|
||||
{
|
||||
/// How far from the radio's frequency a spot may be and still be the one
|
||||
/// the call-frame line shows.
|
||||
private static readonly Frequency SpotReach = Frequency.FromHertz(500);
|
||||
|
||||
private readonly AppSession session;
|
||||
private readonly DispatcherTimer clock;
|
||||
private readonly Throttled later;
|
||||
private readonly EventHandler onNotices;
|
||||
private readonly EventHandler onSolar;
|
||||
private int ticks;
|
||||
|
||||
public InfoWindow(AppSession session)
|
||||
{
|
||||
this.session = session;
|
||||
InitializeComponent();
|
||||
later = new Throttled(TimeSpan.FromSeconds(2), Refresh, holdWhileTyping: true);
|
||||
clock = new DispatcherTimer { Interval = TimeSpan.FromSeconds(1) };
|
||||
clock.Tick += (_, _) =>
|
||||
{
|
||||
ShowTimers();
|
||||
if (++ticks % GraphEveryTicks == 0)
|
||||
{
|
||||
ShowGraphs();
|
||||
}
|
||||
};
|
||||
clock.Start();
|
||||
onNotices = (_, _) => Dispatcher.UIThread.Post(ShowMessages);
|
||||
onSolar = (_, _) => Dispatcher.UIThread.Post(ShowWwv);
|
||||
session.NoticesChanged += onNotices;
|
||||
session.SolarChanged += onSolar;
|
||||
Closed += (_, _) =>
|
||||
{
|
||||
clock.Stop();
|
||||
later.Cancel();
|
||||
session.NoticesChanged -= onNotices;
|
||||
session.SolarChanged -= onSolar;
|
||||
};
|
||||
Refresh();
|
||||
}
|
||||
|
||||
private ContestSession? Logging => session.Logging;
|
||||
|
||||
private Configuration.StoredInfoWindow Info => session.Settings.Info;
|
||||
|
||||
public override void RefreshFromSession() => later.Request();
|
||||
|
||||
public override void RefreshForEntry() => ShowLines();
|
||||
|
||||
public override void Refresh()
|
||||
{
|
||||
ShowHeader();
|
||||
ShowLines();
|
||||
ShowWwv();
|
||||
ShowMessages();
|
||||
ShowGraphs();
|
||||
ShowTimers();
|
||||
}
|
||||
|
||||
/// N1MM's caption: `Info - DL1ABC - Exch: 599 001`, where the number is the
|
||||
/// next one to be sent in a contest that sends one.
|
||||
private void ShowHeader()
|
||||
{
|
||||
string station = session.Settings.Station.Callsign;
|
||||
if (Logging is null || session.Position is not { } position)
|
||||
{
|
||||
Title = $"Info - {station}";
|
||||
OperatorText.Text = station;
|
||||
StatusText.Text = "";
|
||||
return;
|
||||
}
|
||||
string report = position.Entry.Exchange.Any(f => f.Slot == Contests.ExchangeSlot.SentReport)
|
||||
? position.DefaultReport()
|
||||
: "";
|
||||
string sent = Logging.Instance.SentExchange;
|
||||
string exchange = sent.Contains("001") || sent.Contains('#')
|
||||
? position.SentNumber.ToString().PadLeft(3, '0')
|
||||
: sent;
|
||||
Title = $"Info - {station} - Exch: {report} {exchange}";
|
||||
OperatorText.Text = Logging.Operator.Length > 0
|
||||
? Logging.Operator
|
||||
: session.Settings.CurrentOperator.Length > 0 ? session.Settings.CurrentOperator : station;
|
||||
StatusText.Text = Info.ShowGoals ? $"Contest Start Time: {Logging.Instance.StartDate:yyyy-MM-dd HH:mm:ss}Z" : "";
|
||||
}
|
||||
|
||||
/// The spot, the country with its bearing, and the sun there. They follow
|
||||
/// the call in the entry window, and the spot under the radio's frequency
|
||||
/// when no call is being typed.
|
||||
private void ShowLines()
|
||||
{
|
||||
SpotText.IsVisible = Info.CallFrameSpot;
|
||||
CountryText.IsVisible = Info.CountryInfo;
|
||||
SunText.IsVisible = Info.SunTimes;
|
||||
SpotText.Text = "";
|
||||
CountryText.Text = "";
|
||||
SunText.Text = "";
|
||||
if (session.Position is not { } position)
|
||||
{
|
||||
return;
|
||||
}
|
||||
DateTime now = DateTime.UtcNow;
|
||||
string call = position.Entry.Call.Trim();
|
||||
Spot? spot = SpotFor(position, call);
|
||||
if (spot is not null)
|
||||
{
|
||||
SpotText.Text = InfoLines.Spot(spot, now);
|
||||
}
|
||||
CountryLookup? country = call.Length >= 2
|
||||
? position.Country()
|
||||
: spot is null ? null : session.Countries?.Find(spot.Call);
|
||||
if (country is null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
StationPath? path = call.Length >= 2
|
||||
? StationPath.For(position, now)
|
||||
: StationPath.ToCall(position, spot!.Call, now);
|
||||
string where = InfoLines.Country(country, Logging?.Contest.UsesItuZones ?? false);
|
||||
CountryText.Text = path is null ? where : $"{where}, {InfoLines.Bearing(path, position.Me.Continent == "NA")}";
|
||||
SunLine sun = InfoLines.Sun(country, now);
|
||||
SunText.Text = sun.Text;
|
||||
if (sun.IsSoon)
|
||||
{
|
||||
SunText.Foreground = Brushes.OrangeRed;
|
||||
}
|
||||
else
|
||||
{
|
||||
SunText.ClearValue(TextBlock.ForegroundProperty);
|
||||
}
|
||||
}
|
||||
|
||||
private Spot? SpotFor(OperatingPosition position, string call)
|
||||
{
|
||||
if (call.Length < 2)
|
||||
{
|
||||
return session.Bandmap.Near(position.Frequency, SpotReach) is { IsStation: true } near ? near : null;
|
||||
}
|
||||
Band? band = position.Band;
|
||||
return session.Bandmap.All()
|
||||
.Where(s => s.IsStation && string.Equals(s.Call.Text, call, StringComparison.OrdinalIgnoreCase))
|
||||
.OrderByDescending(s => s.Band == band)
|
||||
.ThenByDescending(s => s.AtUtc)
|
||||
.FirstOrDefault();
|
||||
}
|
||||
|
||||
private void ShowWwv()
|
||||
{
|
||||
WwvText.IsVisible = Info.Wwv;
|
||||
WwvText.Text = session.Solar?.Original ?? "";
|
||||
}
|
||||
|
||||
private void ShowMessages()
|
||||
{
|
||||
MessagesScroll.IsVisible = Info.Messages;
|
||||
if (!Info.Messages)
|
||||
{
|
||||
return;
|
||||
}
|
||||
MessagesText.Inlines?.Clear();
|
||||
foreach (Notice notice in session.Notices)
|
||||
{
|
||||
Run line = new($"{notice.AtUtc:HH:mm:ss} {notice.Text}\n");
|
||||
if (notice.IsAlert)
|
||||
{
|
||||
line.FontWeight = FontWeight.Bold;
|
||||
line.Foreground = Brushes.OrangeRed;
|
||||
}
|
||||
MessagesText.Inlines?.Add(line);
|
||||
}
|
||||
MessagesScroll.ScrollToEnd();
|
||||
}
|
||||
}
|
||||
@@ -1,3 +1,4 @@
|
||||
using System.ComponentModel;
|
||||
using Avalonia.Media;
|
||||
using Nonemm.Contests;
|
||||
using Nonemm.Core;
|
||||
@@ -5,41 +6,39 @@ using Nonemm.Session;
|
||||
|
||||
namespace Nonemm.App.Windows;
|
||||
|
||||
/// One line of the log window. The grid reaches the editable fields through the
|
||||
/// indexer, so the columns can follow the contest exchange instead of being
|
||||
/// fixed in the XAML. The colour comes from the same scorer as the entry window
|
||||
/// and the bandmap.
|
||||
public sealed class LogRow
|
||||
/// One line of the log window. The grid reaches the fields through the indexer,
|
||||
/// so the columns can follow the contest exchange and the operator's choice
|
||||
/// instead of being fixed in the XAML. The colour comes from the same scorer as
|
||||
/// the entry window and the bandmap.
|
||||
public sealed class LogRow : INotifyPropertyChanged
|
||||
{
|
||||
private readonly Func<Qso, QsoField, string, bool> edit;
|
||||
|
||||
public LogRow(Qso qso, Verdict? verdict, Func<Qso, QsoField, string, bool> edit)
|
||||
public LogRow(Qso qso, Verdict? verdict)
|
||||
{
|
||||
Qso = qso;
|
||||
Verdict = verdict;
|
||||
this.edit = edit;
|
||||
}
|
||||
|
||||
public Qso Qso { get; }
|
||||
public event PropertyChangedEventHandler? PropertyChanged;
|
||||
|
||||
public Verdict? Verdict { get; }
|
||||
public Qso Qso { get; private set; }
|
||||
|
||||
/// `name` is a `QsoField` name. A refused edit leaves the contact alone, so
|
||||
/// the grid reads the old value back and the cell reverts.
|
||||
public string this[string name]
|
||||
public Verdict? Verdict { get; private set; }
|
||||
|
||||
/// Takes the contact again after it was edited. The grid redraws the line
|
||||
/// it is already showing, so the view stays where it was. "Item" is the
|
||||
/// name the indexer below has in the metadata, and the name the binding
|
||||
/// listens for; any other name is ignored.
|
||||
public void Show(Qso qso, Verdict? verdict)
|
||||
{
|
||||
get => QsoEditor.Read(Qso, Enum.Parse<QsoField>(name));
|
||||
set => edit(Qso, Enum.Parse<QsoField>(name), value);
|
||||
Qso = qso;
|
||||
Verdict = verdict;
|
||||
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs("Item"));
|
||||
}
|
||||
|
||||
public string Country => Qso.CountryPrefix;
|
||||
|
||||
public int Points => Qso.Points;
|
||||
|
||||
public string Multipliers => string.Concat(
|
||||
Qso.IsMultiplier1 ? "1" : "",
|
||||
Qso.IsMultiplier2 ? "2" : "",
|
||||
Qso.IsMultiplier3 ? "3" : "");
|
||||
/// `name` is a `QsoField` name. Read only: an edited cell is written back by
|
||||
/// `LogWindow.TakeCellEdit` when the operator takes the edit, not as the
|
||||
/// text is typed.
|
||||
public string this[string name] => QsoEditor.Read(Qso, Enum.Parse<QsoField>(name));
|
||||
|
||||
public IBrush Colour => Verdicts.Colour(Verdict);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,201 @@
|
||||
using System.Collections;
|
||||
using System.Globalization;
|
||||
using Avalonia;
|
||||
using Avalonia.Collections;
|
||||
using Avalonia.Controls;
|
||||
using Avalonia.Controls.Primitives;
|
||||
using Avalonia.Data;
|
||||
using Avalonia.Input;
|
||||
using Avalonia.Media;
|
||||
using Avalonia.VisualTree;
|
||||
using Nonemm.Session;
|
||||
|
||||
namespace Nonemm.App.Windows;
|
||||
|
||||
/// Which columns the log shows, in which order, and which one it sorts on. The
|
||||
/// contest gives the set the log opens with; a right click on a header adds or
|
||||
/// removes one and a header can be dragged to move its column, both of which
|
||||
/// are kept in the settings file. A click on a header sorts on that column and
|
||||
/// lasts as long as the window is open.
|
||||
public sealed partial class LogWindow
|
||||
{
|
||||
/// What a cell takes besides its text, in device pixels.
|
||||
private const double CellPadding = 15;
|
||||
|
||||
/// What a header takes besides its text: its own padding and the room the
|
||||
/// theme keeps for the sort arrow, which is much more than a cell takes.
|
||||
private const double HeaderPadding = 45;
|
||||
|
||||
private readonly Dictionary<DataGridColumn, QsoColumn> columnOf = [];
|
||||
private IReadOnlyList<QsoColumn> shown = [];
|
||||
private Control? hiddenDragIndicator;
|
||||
private string builtFor = "";
|
||||
|
||||
/// Avalonia arranges the drag indicator once before it has worked out where
|
||||
/// the pointer is, and that first frame draws the header about a column's
|
||||
/// width to the left of where it belongs. The indicator is hidden until the
|
||||
/// next pointer move, which is the first frame that carries the offset.
|
||||
private void HideDragIndicator(object? sender, DataGridColumnReorderingEventArgs e)
|
||||
{
|
||||
hiddenDragIndicator = e.DragIndicator;
|
||||
if (hiddenDragIndicator is not null)
|
||||
{
|
||||
hiddenDragIndicator.Opacity = 0;
|
||||
}
|
||||
}
|
||||
|
||||
private void ShowDragIndicator(object? sender, PointerEventArgs e)
|
||||
{
|
||||
if (hiddenDragIndicator is null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
hiddenDragIndicator.Opacity = 1;
|
||||
hiddenDragIndicator = null;
|
||||
}
|
||||
|
||||
private static bool IsColumnHeader(object? source) =>
|
||||
source is Visual visual && visual.GetSelfAndVisualAncestors().OfType<DataGridColumnHeader>().Any();
|
||||
|
||||
/// One item per column the contest or this program can show, ticked when it
|
||||
/// is on screen. The last item puts the contest's own set back.
|
||||
private ContextMenu ColumnMenu()
|
||||
{
|
||||
List<Control> items = [];
|
||||
foreach (QsoColumn column in LogColumns.Choices(ContestColumns()))
|
||||
{
|
||||
MenuItem item = new()
|
||||
{
|
||||
Header = column.Label,
|
||||
ToggleType = MenuItemToggleType.CheckBox,
|
||||
IsChecked = shown.Any(c => c.Field == column.Field),
|
||||
};
|
||||
item.Click += (_, _) => Toggle(column);
|
||||
items.Add(item);
|
||||
}
|
||||
MenuItem reset = new() { Header = "Default columns" };
|
||||
reset.Click += (_, _) => Store([]);
|
||||
items.Add(new Separator());
|
||||
items.Add(reset);
|
||||
return new ContextMenu { ItemsSource = items };
|
||||
}
|
||||
|
||||
/// Removing the last column would leave a grid nothing can be selected in,
|
||||
/// so the last one stays.
|
||||
private void Toggle(QsoColumn column)
|
||||
{
|
||||
List<QsoColumn> next = [.. shown];
|
||||
if (next.RemoveAll(c => c.Field == column.Field) == 0)
|
||||
{
|
||||
next.Add(column);
|
||||
}
|
||||
else if (next.Count == 0)
|
||||
{
|
||||
return;
|
||||
}
|
||||
Store(LogColumns.Store(next));
|
||||
}
|
||||
|
||||
private void SaveColumnOrder() =>
|
||||
Store(LogColumns.Store(Rows.Columns
|
||||
.OrderBy(c => c.DisplayIndex)
|
||||
.Select(c => columnOf[c])));
|
||||
|
||||
private void Store(IReadOnlyList<string> columns)
|
||||
{
|
||||
session.Save(session.Settings with { LogColumns = columns });
|
||||
builtFor = "";
|
||||
Refresh();
|
||||
}
|
||||
|
||||
private IReadOnlyList<QsoColumn> ContestColumns() =>
|
||||
session.Logging?.Editor.Columns ?? [];
|
||||
|
||||
/// The columns follow the contest exchange and the operator's choice, so
|
||||
/// they are rebuilt when either changes. Both grids get the same columns: a
|
||||
/// value in the pane has to sit under the column it belongs to.
|
||||
private void BuildColumns(QsoEditor editor)
|
||||
{
|
||||
IReadOnlyList<QsoColumn> chosen = LogColumns.Chosen(editor.Columns, session.Settings.LogColumns);
|
||||
string wanted = string.Join('|', chosen.Select(c => $"{c.Field}:{c.Label}"));
|
||||
if (wanted == builtFor)
|
||||
{
|
||||
return;
|
||||
}
|
||||
builtFor = wanted;
|
||||
shown = chosen;
|
||||
FillColumns(Rows, chosen);
|
||||
FillColumns(Earlier, chosen);
|
||||
columnOf.Clear();
|
||||
for (int at = 0; at < chosen.Count; at++)
|
||||
{
|
||||
columnOf[Rows.Columns[at]] = chosen[at];
|
||||
}
|
||||
}
|
||||
|
||||
/// N1MM gives each column the width of the longest value it can hold, and
|
||||
/// the last column what is left over. A fixed width also keeps a column from
|
||||
/// changing size as rows scroll into view.
|
||||
private static void FillColumns(DataGrid grid, IReadOnlyList<QsoColumn> columns)
|
||||
{
|
||||
grid.Columns.Clear();
|
||||
double Width(QsoColumn column) => WidthFor(column, grid);
|
||||
for (int at = 0; at < columns.Count; at++)
|
||||
{
|
||||
QsoColumn column = columns[at];
|
||||
grid.Columns.Add(new DataGridTextColumn
|
||||
{
|
||||
Header = column.Label,
|
||||
IsReadOnly = !column.IsEditable,
|
||||
Width = at == columns.Count - 1
|
||||
? new DataGridLength(1, DataGridLengthUnitType.Star)
|
||||
: new DataGridLength(Width(column)),
|
||||
MinWidth = Width(column),
|
||||
// one way in both directions of the grid: `LogWindow.TakeCellEdit`
|
||||
// writes an edited cell back. A two-way binding would write on
|
||||
// every key press, and the DataGrid turns a binding without a
|
||||
// mode into a two-way one
|
||||
Binding = new Binding($"[{column.Field}]") { Mode = BindingMode.OneWay },
|
||||
CustomSortComparer = By(column.Field),
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
/// The grid sorts on the field itself rather than on the text of the cell,
|
||||
/// which is what `LogColumns.SortKey` gives.
|
||||
private static IComparer By(QsoField field) =>
|
||||
Comparer<LogRow>.Create((left, right) =>
|
||||
LogColumns.SortKey(left.Qso, field).CompareTo(LogColumns.SortKey(right.Qso, field)));
|
||||
|
||||
/// A new view for each refresh, carrying over the sort the operator clicked.
|
||||
/// Without one the log shows the order the contacts were worked in.
|
||||
private DataGridCollectionView Sorted(IEnumerable<LogRow> rows)
|
||||
{
|
||||
DataGridCollectionView view = new(rows);
|
||||
if (Rows.ItemsSource is DataGridCollectionView old)
|
||||
{
|
||||
foreach (DataGridSortDescription sort in old.SortDescriptions)
|
||||
{
|
||||
view.SortDescriptions.Add(sort);
|
||||
}
|
||||
}
|
||||
return view;
|
||||
}
|
||||
|
||||
/// Wide enough for both the longest value and the header. They are in
|
||||
/// different fonts — the values in the grid's monospace, the header in the
|
||||
/// theme's own font — so each is measured in the font it is drawn in.
|
||||
private static double WidthFor(QsoColumn column, DataGrid grid) =>
|
||||
Math.Max(
|
||||
TextWidth(new string('0', column.Width + 1), grid.FontFamily, grid.FontSize) + CellPadding,
|
||||
TextWidth(column.Label + "0", FontFamily.Default, grid.FontSize) + HeaderPadding);
|
||||
|
||||
private static double TextWidth(string text, FontFamily family, double size) =>
|
||||
new FormattedText(
|
||||
text,
|
||||
CultureInfo.InvariantCulture,
|
||||
FlowDirection.LeftToRight,
|
||||
new Typeface(family),
|
||||
size,
|
||||
null).Width;
|
||||
}
|
||||
@@ -1,32 +1,63 @@
|
||||
<local:RefreshableWindow xmlns="https://github.com/avaloniaui"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:local="using:Nonemm.App.Windows"
|
||||
xmlns:theming="using:Nonemm.App.Theming"
|
||||
x:Class="Nonemm.App.Windows.LogWindow"
|
||||
Title="Log" Width="1000" Height="420">
|
||||
<DockPanel>
|
||||
<TextBlock DockPanel.Dock="Bottom" Name="SummaryText" Margin="8,4" FontSize="11" Opacity="0.75" />
|
||||
<Grid RowDefinitions="2*,Auto,*">
|
||||
<Grid.Styles>
|
||||
<!-- the DataGrid's own font settings do not reach the cells, and the
|
||||
columns are sized from the width of the text in this font -->
|
||||
<Style Selector="DataGridCell TextBlock">
|
||||
<Setter Property="FontFamily" Value="monospace" />
|
||||
<Setter Property="FontSize" Value="12" />
|
||||
<Setter Property="FontFamily" Value="{x:Static theming:Fonts.Mono}" />
|
||||
<Setter Property="FontSize" Value="{DynamicResource LogFontSize}" />
|
||||
<!-- half of what the theme leaves either side of the text, so more
|
||||
columns fit across the window -->
|
||||
<Setter Property="Margin" Value="6,0" />
|
||||
</Style>
|
||||
<!-- the theme gives a cell 32 pixels of height, which fits about a
|
||||
dozen rows on screen. The row is cut down to the height of its
|
||||
text and one pixel either side -->
|
||||
<Style Selector="DataGridRow">
|
||||
<Setter Property="MinHeight" Value="0" />
|
||||
</Style>
|
||||
<Style Selector="DataGridCell">
|
||||
<Setter Property="MinHeight" Value="0" />
|
||||
<Setter Property="Padding" Value="0,1" />
|
||||
</Style>
|
||||
<Style Selector="DataGridColumnHeader">
|
||||
<Setter Property="MinHeight" Value="0" />
|
||||
</Style>
|
||||
<!-- the frame around the cell the keyboard is on goes with the picked
|
||||
lines while another window is in front. The theme draws it with a
|
||||
rectangle inside the cell rather than with the cell's own border,
|
||||
so setting the border brush does nothing -->
|
||||
<Style Selector="DataGrid.away DataGridCell:current /template/ Rectangle">
|
||||
<Setter Property="IsVisible" Value="False" />
|
||||
</Style>
|
||||
<!-- the editing box takes the same height as the text it covers,
|
||||
otherwise it grows the row and the whole grid shifts as editing
|
||||
starts. Its border is what would make it two pixels taller, so it
|
||||
is dropped: the white background already marks the cell out. The
|
||||
padding is what the cell gives its text, so the text does not move
|
||||
sideways as the box opens -->
|
||||
<Style Selector="DataGridCell TextBox">
|
||||
<Setter Property="FontFamily" Value="{x:Static theming:Fonts.Mono}" />
|
||||
<Setter Property="FontSize" Value="{DynamicResource LogFontSize}" />
|
||||
<Setter Property="MinHeight" Value="0" />
|
||||
<Setter Property="Margin" Value="0" />
|
||||
<Setter Property="Padding" Value="6,0" />
|
||||
<Setter Property="BorderThickness" Value="0" />
|
||||
<Setter Property="VerticalContentAlignment" Value="Center" />
|
||||
</Style>
|
||||
</Grid.Styles>
|
||||
<DataGrid Name="Rows" Grid.Row="0" GridLinesVisibility="Horizontal" CanUserSortColumns="False"
|
||||
FontSize="12" FontFamily="monospace">
|
||||
<DataGrid.ContextMenu>
|
||||
<ContextMenu>
|
||||
<MenuItem Header="Edit contact…" Click="OnEditContact" InputGesture="Enter" />
|
||||
<MenuItem Header="Delete contact" Click="OnDelete" InputGesture="Delete" />
|
||||
</ContextMenu>
|
||||
</DataGrid.ContextMenu>
|
||||
</DataGrid>
|
||||
<GridSplitter Grid.Row="1" Height="3" ResizeDirection="Rows" />
|
||||
<DataGrid Name="Rows" Grid.Row="0" GridLinesVisibility="Horizontal" CanUserSortColumns="True"
|
||||
CanUserReorderColumns="True" FontFamily="{x:Static theming:Fonts.Mono}" />
|
||||
<GridSplitter Grid.Row="1" Height="5" ResizeDirection="Rows" Background="{DynamicResource DataGridGridLinesBrush}" />
|
||||
<DataGrid Name="Earlier" Grid.Row="2" IsReadOnly="True" GridLinesVisibility="Horizontal"
|
||||
CanUserSortColumns="False" HeadersVisibility="None"
|
||||
FontSize="12" FontFamily="monospace" />
|
||||
FontFamily="{x:Static theming:Fonts.Mono}" />
|
||||
</Grid>
|
||||
</DockPanel>
|
||||
</local:RefreshableWindow>
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user