mirror of
https://github.com/praktimarc/kst4contest.git
synced 2026-11-19 18:02:27 +01:00
Compare commits
42
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
c9ddc1959d
|
||
|
|
dbd6caa4ea
|
||
|
|
e527ad4198
|
||
|
|
b7950f8a06
|
||
|
|
dc164403be
|
||
|
|
76e086f4c0
|
||
|
|
52508eec71
|
||
|
|
918f84dc8a
|
||
|
|
9e5759adfe
|
||
|
|
68d86ce320
|
||
|
|
383e0f97c9
|
||
|
|
85a2984234
|
||
|
|
0d0b752bed
|
||
|
|
175b6350c2
|
||
|
|
a24534bbb1
|
||
|
|
bde77f3ec1
|
||
|
|
facba2b010
|
||
|
|
0ab9ffc241
|
||
|
|
adcd9da306
|
||
|
|
da1f261684
|
||
|
|
f607b831ca
|
||
|
|
a8cfe94853
|
||
|
|
f871f551f7
|
||
|
|
0821820dd4
|
||
|
|
bd36beccb5
|
||
|
|
8352af911e
|
||
|
|
f1e80c6ed3
|
||
|
|
f5783ade25
|
||
|
|
0a43af66df
|
||
|
|
3575473fa9
|
||
|
|
64a6eab35f
|
||
|
|
78fc5b98fa
|
||
|
|
3ca6ef411f
|
||
|
|
01e56c6639
|
||
|
|
78a1502a1f
|
||
|
|
1615c4dffc
|
||
|
|
6508978da9
|
||
|
|
aff9b6e2ff
|
||
|
|
b0960a3f04 | ||
|
|
f13fe54fde | ||
|
|
19bcdb428d | ||
|
|
9304df3705 |
No files matched your search
@@ -41,7 +41,7 @@ jobs:
|
||||
uses: actions/checkout@v7
|
||||
|
||||
- name: Set up Java 21
|
||||
uses: actions/setup-java@v6.1.0
|
||||
uses: actions/setup-java@v6.2.0
|
||||
with:
|
||||
distribution: temurin
|
||||
java-version: "21"
|
||||
@@ -143,7 +143,7 @@ jobs:
|
||||
Add-Content -Path $env:GITHUB_ENV -Value "ASSET_BASENAME=praktiKST-$version-$shortSha"
|
||||
|
||||
- name: Set up Java 21
|
||||
uses: actions/setup-java@v6.1.0
|
||||
uses: actions/setup-java@v6.2.0
|
||||
with:
|
||||
distribution: temurin
|
||||
java-version: "21"
|
||||
@@ -193,7 +193,7 @@ jobs:
|
||||
echo "ASSET_BASENAME=KST4Contest-${VERSION}-${SHORT_SHA}" >> "$GITHUB_ENV"
|
||||
|
||||
- name: Set up Java 21
|
||||
uses: actions/setup-java@v6.1.0
|
||||
uses: actions/setup-java@v6.2.0
|
||||
with:
|
||||
distribution: temurin
|
||||
java-version: "21"
|
||||
@@ -267,7 +267,7 @@ jobs:
|
||||
echo "ASSET_BASENAME=KST4Contest-${VERSION}-${SHORT_SHA}" >> "$GITHUB_ENV"
|
||||
|
||||
- name: Set up Java 21
|
||||
uses: actions/setup-java@v6.1.0
|
||||
uses: actions/setup-java@v6.2.0
|
||||
with:
|
||||
distribution: temurin
|
||||
java-version: "21"
|
||||
@@ -313,7 +313,7 @@ jobs:
|
||||
echo "ASSET_BASENAME=KST4Contest-${VERSION}-${SHORT_SHA}" >> "$GITHUB_ENV"
|
||||
|
||||
- name: Set up Java 21
|
||||
uses: actions/setup-java@v6.1.0
|
||||
uses: actions/setup-java@v6.2.0
|
||||
with:
|
||||
distribution: temurin
|
||||
java-version: "21"
|
||||
@@ -361,7 +361,7 @@ jobs:
|
||||
echo "ASSET_BASENAME=KST4Contest-${VERSION}-${SHORT_SHA}" >> "$GITHUB_ENV"
|
||||
|
||||
- name: Set up Java 21
|
||||
uses: actions/setup-java@v6.1.0
|
||||
uses: actions/setup-java@v6.2.0
|
||||
with:
|
||||
distribution: temurin
|
||||
java-version: "21"
|
||||
@@ -473,7 +473,7 @@ jobs:
|
||||
echo "ASSET_BASENAME=KST4Contest-${VERSION}-${SHORT_SHA}" >> "$GITHUB_ENV"
|
||||
|
||||
- name: Set up Java 21
|
||||
uses: actions/setup-java@v6.1.0
|
||||
uses: actions/setup-java@v6.2.0
|
||||
with:
|
||||
distribution: temurin
|
||||
java-version: "21"
|
||||
@@ -664,7 +664,7 @@ jobs:
|
||||
echo "ARCH=$ARCH" >> "$GITHUB_ENV"
|
||||
|
||||
- name: Set up Java 21
|
||||
uses: actions/setup-java@v6.1.0
|
||||
uses: actions/setup-java@v6.2.0
|
||||
with:
|
||||
distribution: temurin
|
||||
java-version: "21"
|
||||
|
||||
@@ -22,7 +22,7 @@ jobs:
|
||||
uses: actions/checkout@v7
|
||||
|
||||
- name: Set up Java 21
|
||||
uses: actions/setup-java@v6.1.0
|
||||
uses: actions/setup-java@v6.2.0
|
||||
with:
|
||||
distribution: temurin
|
||||
java-version: "21"
|
||||
@@ -167,7 +167,7 @@ jobs:
|
||||
uses: actions/checkout@v7
|
||||
|
||||
- name: Set up Java 21
|
||||
uses: actions/setup-java@v6.1.0
|
||||
uses: actions/setup-java@v6.2.0
|
||||
with:
|
||||
distribution: temurin
|
||||
java-version: "21"
|
||||
|
||||
@@ -60,7 +60,7 @@ jobs:
|
||||
echo "Tag $REF_NAME matches composePackageVersion=$PROPERTY_VERSION"
|
||||
|
||||
- name: Set up Java 21
|
||||
uses: actions/setup-java@v6.1.0
|
||||
uses: actions/setup-java@v6.2.0
|
||||
with:
|
||||
distribution: temurin
|
||||
java-version: "21"
|
||||
@@ -153,7 +153,7 @@ jobs:
|
||||
uses: actions/checkout@v7
|
||||
|
||||
- name: Set up Java 21
|
||||
uses: actions/setup-java@v6.1.0
|
||||
uses: actions/setup-java@v6.2.0
|
||||
with:
|
||||
distribution: temurin
|
||||
java-version: "21"
|
||||
@@ -222,7 +222,7 @@ jobs:
|
||||
uses: actions/checkout@v7
|
||||
|
||||
- name: Set up Java 21
|
||||
uses: actions/setup-java@v6.1.0
|
||||
uses: actions/setup-java@v6.2.0
|
||||
with:
|
||||
distribution: temurin
|
||||
java-version: "21"
|
||||
@@ -289,7 +289,7 @@ jobs:
|
||||
uses: actions/checkout@v7
|
||||
|
||||
- name: Set up Java 21
|
||||
uses: actions/setup-java@v6.1.0
|
||||
uses: actions/setup-java@v6.2.0
|
||||
with:
|
||||
distribution: temurin
|
||||
java-version: "21"
|
||||
@@ -360,7 +360,7 @@ jobs:
|
||||
uses: actions/checkout@v7
|
||||
|
||||
- name: Set up Java 21
|
||||
uses: actions/setup-java@v6.1.0
|
||||
uses: actions/setup-java@v6.2.0
|
||||
with:
|
||||
distribution: temurin
|
||||
java-version: "21"
|
||||
@@ -431,7 +431,7 @@ jobs:
|
||||
uses: actions/checkout@v7
|
||||
|
||||
- name: Set up Java 21
|
||||
uses: actions/setup-java@v6.1.0
|
||||
uses: actions/setup-java@v6.2.0
|
||||
with:
|
||||
distribution: temurin
|
||||
java-version: "21"
|
||||
@@ -534,7 +534,7 @@ jobs:
|
||||
uses: actions/checkout@v7
|
||||
|
||||
- name: Set up Java 21
|
||||
uses: actions/setup-java@v6.1.0
|
||||
uses: actions/setup-java@v6.2.0
|
||||
with:
|
||||
distribution: temurin
|
||||
java-version: "21"
|
||||
@@ -664,7 +664,7 @@ jobs:
|
||||
uses: actions/checkout@v7
|
||||
|
||||
- name: Set up Java 21
|
||||
uses: actions/setup-java@v6.1.0
|
||||
uses: actions/setup-java@v6.2.0
|
||||
with:
|
||||
distribution: temurin
|
||||
java-version: "21"
|
||||
|
||||
@@ -460,7 +460,7 @@ column.score=Wertung
|
||||
monitor.title=Cluster & Fremd-QSOs
|
||||
monitor.dxCluster=DX-Cluster
|
||||
profiles.createFailed=Das Profil konnte nicht angelegt werden. Die Profilliste konnte nicht geschrieben werden.
|
||||
profiles.createdWithoutCredentials=Das Profil „{0}" wurde ohne Rufzeichen und Passwort angelegt. Nach dem Wechsel zu diesem Profil beides im Reiter „Station" eintragen.
|
||||
profiles.createdWithoutCredentials=Das Profil „{0}" wurde ohne Rufzeichen und Passwort angelegt. Nach dem Wechsel zu diesem Profil fragt der Einrichtungsassistent beides ab.
|
||||
profiles.duplicateFailed=Das Profil konnte nicht dupliziert werden.
|
||||
profiles.rootNotDeletable=Das Standardprofil verwendet die Dateien der Installation selbst und kann nicht gelöscht werden.
|
||||
profiles.activeNotDeletable=Das gerade benutzte Profil kann nicht gelöscht werden. Zuerst zu einem anderen Profil wechseln.
|
||||
@@ -473,7 +473,17 @@ profiles.changeAfterSwitch=Die Änderung wirkt erst nach einem erneuten Wechsel
|
||||
profiles.alreadyActive=Dieses Profil ist bereits aktiv.
|
||||
profiles.selectFirst=Zuerst ein Profil in der Tabelle wählen.
|
||||
beacon.invalidMessage=Der Bakentext ist ungültig: {0}
|
||||
beacon.intervalTooShort=Einen ganzzahligen Bakenabstand von mindestens {0} Minute eingeben.
|
||||
beacon.intervalTooShort=Einen ganzzahligen Bakenabstand von mindestens {0} Minuten eingeben.
|
||||
beacon.status.main=Hauptkategorie: {0}
|
||||
beacon.status.second=Zweite Kategorie: {0}
|
||||
beacon.status.enabled=aktiv
|
||||
beacon.status.failed=Versand fehlgeschlagen
|
||||
beacon.status.unavailable=nicht verfügbar
|
||||
beacon.reason.session=in dieser Sitzung noch nicht aktiviert
|
||||
beacon.reason.user=durch den Benutzer ausgeschaltet
|
||||
beacon.reason.primaryQrg=Haupt-QRG fehlt oder ist ungültig
|
||||
beacon.reason.secondaryQrg=zweite QRG fehlt oder ist ungültig
|
||||
beacon.reason.automaticQrg=automatische QRG-Änderung um mehr als 5 kHz
|
||||
notification.invalidPort=„{0}" ist kein gültiger TCP-Port. Einen Wert von 1 bis 65535 eingeben.
|
||||
notification.invalidSpotter=„{0}" ist kein gültiges Spotter-Rufzeichen.
|
||||
notification.invalidCallsign=Bitte ein gültiges Rufzeichen eingeben.
|
||||
@@ -485,3 +495,95 @@ profiles.unknown=unbekannt
|
||||
profiles.copyOf=Kopie von {0}
|
||||
profiles.sharedDatabase=gemeinsame Stationsdatenbank
|
||||
profiles.ownDatabase=eigene Datenbank
|
||||
|
||||
wizard.title=Einrichtungsassistent
|
||||
wizard.later=Später
|
||||
wizard.back=Zurück
|
||||
wizard.next=Weiter
|
||||
wizard.finish=Fertig
|
||||
wizard.save=Speichern
|
||||
wizard.saveAndConnect=Speichern und verbinden
|
||||
wizard.change=Ändern
|
||||
wizard.saveFailed=Die Einstellungen konnten nicht geschrieben werden. Es wurde nichts geändert.
|
||||
wizard.missing=Es fehlen noch Pflichtangaben. Über „Ändern" ergänzen.
|
||||
wizard.entry.title=Woher kommen die Angaben?
|
||||
wizard.entry.lead=Für Anmeldung und Station getrennt wählen.
|
||||
wizard.entry.login=Anmeldung (Rufzeichen, Passwort)
|
||||
wizard.entry.station=Station (Locator, Bänder, Chatkategorie)
|
||||
wizard.source.loginNew=Anmeldung neu eingeben
|
||||
wizard.source.loginKeep=Anmeldung unverändert lassen ({0})
|
||||
wizard.source.stationNew=Station neu einrichten
|
||||
wizard.source.stationKeep=Station unverändert lassen (Locator {0})
|
||||
wizard.personal.title=Persönliches
|
||||
wizard.personal.lead=Gehört zum Operator.
|
||||
wizard.personal.name=Anzeigename im Chat
|
||||
wizard.personal.nameInvalid=Der Name darf kein Zeichen | enthalten.
|
||||
wizard.login.title=Anmeldung bei ON4KST
|
||||
wizard.login.lead=Die Zugangsdaten deines ON4KST-Kontos.
|
||||
wizard.login.callsignInvalid=Das sieht nicht nach einem Rufzeichen aus.
|
||||
wizard.login.passwordInvalid=Das Passwort darf nicht mit einem Leerzeichen beginnen oder enden und kein Zeichen | enthalten.
|
||||
wizard.site.title=Standort und Bänder
|
||||
wizard.site.lead=Gehört zur Station, nicht zum Operator.
|
||||
wizard.site.locatorInvalid=Sechsstelliger Maidenhead-Locator, zum Beispiel JO50AA.
|
||||
wizard.site.bands=Aktive Bänder
|
||||
wizard.site.bandsHint=Aus den Bändern wird keine Frequenz abgeleitet.
|
||||
wizard.site.categorySuggestion=Vorschlag aus den Bändern: {0}
|
||||
wizard.site.secondChat=Zweiten Chat öffnen
|
||||
wizard.summary.title=Zusammenfassung
|
||||
wizard.summary.lead=Erst „Speichern" schreibt in die Einstellungsdatei.
|
||||
wizard.summary.personal=Persönliches
|
||||
wizard.summary.login=Anmeldung
|
||||
wizard.summary.station=Station
|
||||
wizard.summary.bands=Bänder
|
||||
wizard.summary.none=keine
|
||||
wizard.summary.passwordSet=gesetzt
|
||||
|
||||
menu.setupWizard=Einrichtungsassistent...
|
||||
alert.setupWizardTitle=Einrichtungsassistent
|
||||
alert.setupWizardQuestion=Sitzung beenden und den Einrichtungsassistenten starten?
|
||||
alert.setupWizardBody=Die ON4KST-Verbindung wird geschlossen, und alle Fenster werden nach dem Assistenten neu aufgebaut. Für einzelne Änderungen im laufenden Betrieb ist das Einstellungsfenster da.
|
||||
dialog.startSetupWizard=Assistent starten
|
||||
wizard.antenna.title=Antenne und Leistung
|
||||
wizard.antenna.lead=Freiwillig. Die Werte speisen die Pfadanalyse und den Antennensektor auf der Karte; für den Chat braucht sie niemand.
|
||||
wizard.antenna.aslHint=Standorthöhe leer lassen, dann entscheidet das Höhenmodell.
|
||||
wizard.log.title=Logprogramm
|
||||
wizard.log.lead=Woher kommen deine gearbeiteten Stationen?
|
||||
wizard.log.none=Keines, kein Abgleich
|
||||
wizard.log.wintest=Win-Test
|
||||
wizard.log.udp=UCXLog, DXLog.net, N1MM+ oder QARTEST
|
||||
wizard.log.file=Eine Logdatei
|
||||
wizard.log.qrgFollow=Eigene Frequenz aus dem Logprogramm übernehmen
|
||||
wizard.log.clusterServer=Spots über den lokalen DX-Cluster-Server an das Logprogramm geben
|
||||
wizard.log.incomplete=Die Angaben zu diesem Logprogramm sind unvollständig oder außerhalb des Bereichs.
|
||||
wizard.gear.title=Rotor und AirScout
|
||||
wizard.gear.lead=Nur was wirklich vorhanden ist.
|
||||
wizard.gear.rotator=PSTRotator wird benutzt
|
||||
wizard.gear.airScout=AirScout wird benutzt
|
||||
wizard.gear.incomplete=Die Angaben auf dieser Seite sind unvollständig oder außerhalb des Bereichs.
|
||||
wizard.switch.secondChat=Zweitchat
|
||||
wizard.switch.logWintest=Win-Test-Abgleich
|
||||
wizard.switch.logUdp=Netzwerk-Logabgleich
|
||||
wizard.switch.logFile=Logdatei-Abgleich
|
||||
wizard.switch.qrgFollow=Frequenz aus dem Logprogramm
|
||||
wizard.switch.clusterServer=DX-Cluster-Server
|
||||
wizard.switch.rotator=PSTRotator
|
||||
wizard.switch.airScout=AirScout
|
||||
wizard.summary.antenna=Antenne und Leistung
|
||||
wizard.summary.log=Logprogramm
|
||||
wizard.summary.gear=Rotor und AirScout
|
||||
wizard.summary.qrgFollow=Eigene Frequenz aus dem Logprogramm
|
||||
wizard.summary.clusterServer=DX-Cluster-Server
|
||||
wizard.summary.yes=ja
|
||||
wizard.summary.no=nein
|
||||
wizard.summary.switchedOff=Wird abgeschaltet: {0}.
|
||||
wizard.summary.logSeveral=In diesem Profil sind mehrere Logquellen eingeschaltet. Im Einstellungsfenster ändern.
|
||||
|
||||
wizard.source.loginTake=Anmeldung von Profil „{0}" übernehmen ({1})
|
||||
wizard.source.loginTakeFrom=Anmeldung von einem anderen Profil übernehmen
|
||||
wizard.source.stationTake=Station von Profil „{0}" übernehmen (Locator {1})
|
||||
wizard.source.stationTakeFrom=Station von einem anderen Profil übernehmen
|
||||
wizard.entry.donor=Profil
|
||||
wizard.summary.takenFrom=Übernommen von Profil „{0}"
|
||||
wizard.switch.so2r=SO2R
|
||||
wizard.switch.rotator2=PSTRotator 2
|
||||
wizard.summary.fallbackBand=Ausweichband für Spots
|
||||
@@ -469,7 +469,7 @@ column.score=Score
|
||||
monitor.title=Cluster & QSO of the other
|
||||
monitor.dxCluster=DX cluster
|
||||
profiles.createFailed=The profile could not be created. The profile registry could not be written.
|
||||
profiles.createdWithoutCredentials=The profile "{0}" was created without callsign and password. Enter them on the Station tab after switching to it.
|
||||
profiles.createdWithoutCredentials=The profile "{0}" was created without callsign and password. After switching to it, the setup assistant asks for both.
|
||||
profiles.duplicateFailed=The profile could not be duplicated.
|
||||
profiles.rootNotDeletable=The default profile uses the files of the installation itself and cannot be deleted.
|
||||
profiles.activeNotDeletable=The profile currently in use cannot be deleted. Switch to another profile first.
|
||||
@@ -482,7 +482,17 @@ profiles.changeAfterSwitch=The change takes effect after switching to this profi
|
||||
profiles.alreadyActive=This profile is already active.
|
||||
profiles.selectFirst=Select a profile in the table first.
|
||||
beacon.invalidMessage=The beacon message is invalid: {0}
|
||||
beacon.intervalTooShort=Enter a whole beacon interval of at least {0} minute.
|
||||
beacon.intervalTooShort=Enter a whole beacon interval of at least {0} minutes.
|
||||
beacon.status.main=Main category: {0}
|
||||
beacon.status.second=Second category: {0}
|
||||
beacon.status.enabled=active
|
||||
beacon.status.failed=send failed
|
||||
beacon.status.unavailable=unavailable
|
||||
beacon.reason.session=not activated in this session
|
||||
beacon.reason.user=switched off by the operator
|
||||
beacon.reason.primaryQrg=primary QRG missing or invalid
|
||||
beacon.reason.secondaryQrg=second QRG missing or invalid
|
||||
beacon.reason.automaticQrg=automatic QRG change greater than 5 kHz
|
||||
notification.invalidPort="{0}" is not a valid TCP port. Enter a value from 1 to 65535.
|
||||
notification.invalidSpotter="{0}" is not a valid spotter callsign.
|
||||
notification.invalidCallsign=Please enter a valid callsign.
|
||||
@@ -494,3 +504,95 @@ profiles.unknown=unknown
|
||||
profiles.copyOf=Copy of {0}
|
||||
profiles.sharedDatabase=common station database
|
||||
profiles.ownDatabase=own database
|
||||
|
||||
wizard.title=Setup assistant
|
||||
wizard.later=Later
|
||||
wizard.back=Back
|
||||
wizard.next=Next
|
||||
wizard.finish=Finish
|
||||
wizard.save=Save
|
||||
wizard.saveAndConnect=Save and connect
|
||||
wizard.change=Change
|
||||
wizard.saveFailed=The settings could not be written. Nothing was changed.
|
||||
wizard.missing=Some required entries are still missing. Use Change to complete them.
|
||||
wizard.entry.title=Where do the entries come from?
|
||||
wizard.entry.lead=Choose separately for login and station.
|
||||
wizard.entry.login=Login (callsign, password)
|
||||
wizard.entry.station=Station (locator, bands, chat category)
|
||||
wizard.source.loginNew=Enter a new login
|
||||
wizard.source.loginKeep=Leave the login unchanged ({0})
|
||||
wizard.source.stationNew=Set up a new station
|
||||
wizard.source.stationKeep=Leave the station unchanged (locator {0})
|
||||
wizard.personal.title=Personal
|
||||
wizard.personal.lead=Belongs to the operator.
|
||||
wizard.personal.name=Name shown in the chat
|
||||
wizard.personal.nameInvalid=The name must not contain a | character.
|
||||
wizard.login.title=ON4KST login
|
||||
wizard.login.lead=The credentials of your ON4KST account.
|
||||
wizard.login.callsignInvalid=This does not look like a callsign.
|
||||
wizard.login.passwordInvalid=The password must not begin or end with a blank and must not contain a | character.
|
||||
wizard.site.title=Location and bands
|
||||
wizard.site.lead=Belongs to the station, not to the operator.
|
||||
wizard.site.locatorInvalid=Six-character Maidenhead locator, for example JO50AA.
|
||||
wizard.site.bands=Active bands
|
||||
wizard.site.bandsHint=No frequency is derived from the bands.
|
||||
wizard.site.categorySuggestion=Suggested from the bands: {0}
|
||||
wizard.site.secondChat=Open a second chat
|
||||
wizard.summary.title=Summary
|
||||
wizard.summary.lead=Nothing is written until you save.
|
||||
wizard.summary.personal=Personal
|
||||
wizard.summary.login=Login
|
||||
wizard.summary.station=Station
|
||||
wizard.summary.bands=Bands
|
||||
wizard.summary.none=none
|
||||
wizard.summary.passwordSet=set
|
||||
|
||||
menu.setupWizard=Setup assistant...
|
||||
alert.setupWizardTitle=Setup assistant
|
||||
alert.setupWizardQuestion=End the session and start the setup assistant?
|
||||
alert.setupWizardBody=The ON4KST connection is closed and all windows are rebuilt after the assistant. For single changes during operation use the settings window.
|
||||
dialog.startSetupWizard=Start assistant
|
||||
wizard.antenna.title=Antenna and power
|
||||
wizard.antenna.lead=Optional. These values feed the path analysis and the antenna sector on the map; the chat does not need them.
|
||||
wizard.antenna.aslHint=Leave the site elevation empty to let the elevation model decide.
|
||||
wizard.log.title=Log program
|
||||
wizard.log.lead=Where do your worked stations come from?
|
||||
wizard.log.none=None, no synchronisation
|
||||
wizard.log.wintest=Win-Test
|
||||
wizard.log.udp=UCXLog, DXLog.net, N1MM+ or QARTEST
|
||||
wizard.log.file=A log file
|
||||
wizard.log.qrgFollow=Take my own frequency from the log program
|
||||
wizard.log.clusterServer=Pass spots to the log program through the local DX cluster server
|
||||
wizard.log.incomplete=The entries for this log program are incomplete or out of range.
|
||||
wizard.gear.title=Rotator and AirScout
|
||||
wizard.gear.lead=Only what is really there.
|
||||
wizard.gear.rotator=PSTRotator is in use
|
||||
wizard.gear.airScout=AirScout is in use
|
||||
wizard.gear.incomplete=The entries on this page are incomplete or out of range.
|
||||
wizard.switch.secondChat=second chat
|
||||
wizard.switch.logWintest=Win-Test synchronisation
|
||||
wizard.switch.logUdp=network log synchronisation
|
||||
wizard.switch.logFile=log file polling
|
||||
wizard.switch.qrgFollow=frequency from the log program
|
||||
wizard.switch.clusterServer=DX cluster server
|
||||
wizard.switch.rotator=PSTRotator
|
||||
wizard.switch.airScout=AirScout
|
||||
wizard.summary.antenna=Antenna and power
|
||||
wizard.summary.log=Log program
|
||||
wizard.summary.gear=Rotator and AirScout
|
||||
wizard.summary.qrgFollow=Own frequency from the log program
|
||||
wizard.summary.clusterServer=DX cluster server
|
||||
wizard.summary.yes=yes
|
||||
wizard.summary.no=no
|
||||
wizard.summary.switchedOff=Will be switched off: {0}.
|
||||
wizard.summary.logSeveral=Several log sources are enabled in this profile. Change them in the settings window.
|
||||
|
||||
wizard.source.loginTake=Take the login from profile "{0}" ({1})
|
||||
wizard.source.loginTakeFrom=Take the login from another profile
|
||||
wizard.source.stationTake=Take the station from profile "{0}" (locator {1})
|
||||
wizard.source.stationTakeFrom=Take the station from another profile
|
||||
wizard.entry.donor=Profile
|
||||
wizard.summary.takenFrom=Taken from profile "{0}"
|
||||
wizard.switch.so2r=SO2R
|
||||
wizard.switch.rotator2=PSTRotator 2
|
||||
wizard.summary.fallbackBand=Fallback band for spots
|
||||
@@ -4,6 +4,7 @@ import kst4contest.controller.ActiveOperatorProfile;
|
||||
import kst4contest.controller.OperatorProfilePaths;
|
||||
import kst4contest.controller.OperatorProfileStore;
|
||||
import kst4contest.model.OperatorProfile;
|
||||
import kst4contest.model.OperatorProfileSelection;
|
||||
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
@@ -24,6 +25,20 @@ public final class ApplicationRuntimeLauncher {
|
||||
|
||||
private static Kst4ContestApplication currentRuntime;
|
||||
|
||||
/**
|
||||
* Whether the next runtime start shows the setup wizard although the profile is set up.
|
||||
* Set by the menu entry and cleared by the start that honours it.
|
||||
*/
|
||||
private static final java.util.concurrent.atomic.AtomicBoolean SETUP_WIZARD_REQUESTED =
|
||||
new java.util.concurrent.atomic.AtomicBoolean(false);
|
||||
|
||||
/**
|
||||
* Guards {@link #switchProfile(OperatorProfile)} against re-entry while window teardown
|
||||
* inside {@link Kst4ContestApplication#shutdownRuntime()} is still pumping events.
|
||||
*/
|
||||
private static final java.util.concurrent.atomic.AtomicBoolean SWITCH_IN_PROGRESS =
|
||||
new java.util.concurrent.atomic.AtomicBoolean(false);
|
||||
|
||||
private ApplicationRuntimeLauncher() {
|
||||
// Utility class.
|
||||
}
|
||||
@@ -61,14 +76,100 @@ public final class ApplicationRuntimeLauncher {
|
||||
System.exit(0);
|
||||
}
|
||||
|
||||
/** Asks the next runtime start to show the setup wizard. */
|
||||
static void requestSetupWizard() {
|
||||
SETUP_WIZARD_REQUESTED.set(true);
|
||||
}
|
||||
|
||||
/**
|
||||
* Tells a starting runtime whether the wizard was asked for, and forgets the request.
|
||||
*
|
||||
* @return true exactly once per request
|
||||
*/
|
||||
static boolean consumeSetupWizardRequest() {
|
||||
return SETUP_WIZARD_REQUESTED.getAndSet(false);
|
||||
}
|
||||
|
||||
/**
|
||||
* Marks a profile switch as in progress if none is currently running.
|
||||
*
|
||||
* @return true if this call obtained the mark
|
||||
*/
|
||||
static boolean beginSwitch() {
|
||||
return SWITCH_IN_PROGRESS.compareAndSet(false, true);
|
||||
}
|
||||
|
||||
/** Clears the in-progress mark of a profile switch. */
|
||||
static void endSwitch() {
|
||||
SWITCH_IN_PROGRESS.set(false);
|
||||
}
|
||||
|
||||
/**
|
||||
* Rebuilds the runtime of the active profile with the setup wizard in front of it.
|
||||
*
|
||||
* <p>The running runtime is torn down first and the wizard shown afterwards, not the
|
||||
* other way round: a runtime shutting down flushes its pending layout write, and that
|
||||
* must not land on the file the wizard has just written.</p>
|
||||
*
|
||||
* <p>The wizard is requested only once this call owns the switch. A call refused
|
||||
* because a switch is already under way therefore leaves that switch's request alone:
|
||||
* clearing it would let the running switch end the session and then start without the
|
||||
* wizard it was made for.</p>
|
||||
*
|
||||
* @return true if the new runtime was built
|
||||
*/
|
||||
public static boolean rerunSetupWizard() {
|
||||
OperatorProfileSelection active = ActiveOperatorProfile.get();
|
||||
|
||||
if (active == null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!beginSwitch()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
try {
|
||||
requestSetupWizard();
|
||||
|
||||
boolean switched = false;
|
||||
try {
|
||||
switched = performSwitch(active.getProfile());
|
||||
} finally {
|
||||
if (!switched) {
|
||||
// The request is this call's own, and no start consumed it.
|
||||
consumeSetupWizardRequest();
|
||||
}
|
||||
}
|
||||
return switched;
|
||||
} finally {
|
||||
endSwitch();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Replaces the running runtime with one bound to another operator profile.
|
||||
*
|
||||
* @param targetProfile profile to activate
|
||||
* @return true if the new runtime was built
|
||||
* @return true if the new runtime was built; false also when another switch is
|
||||
* already under way
|
||||
*/
|
||||
public static boolean switchProfile(final OperatorProfile targetProfile) {
|
||||
|
||||
if (!beginSwitch()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
try {
|
||||
return performSwitch(targetProfile);
|
||||
} finally {
|
||||
endSwitch();
|
||||
}
|
||||
}
|
||||
|
||||
/** The switch itself. The caller holds the switch-in-progress mark. */
|
||||
private static boolean performSwitch(final OperatorProfile targetProfile) {
|
||||
|
||||
if (targetProfile == null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package kst4contest.view;
|
||||
|
||||
import kst4contest.controller.RadioSlot;
|
||||
import kst4contest.model.ChatCategory;
|
||||
import kst4contest.model.ChatMember;
|
||||
import kst4contest.model.ChatMessage;
|
||||
@@ -97,4 +98,9 @@ public final class ComposeChatInputActions implements ChatInputActions {
|
||||
String value = application.chatcontroller.getChatPreferences().getMYQRGSecondCat().get();
|
||||
return value == null ? "" : value;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void applyManualQrg(final RadioSlot slot, final String value) {
|
||||
application.chatcontroller.applyManualQrg(slot, value);
|
||||
}
|
||||
}
|
||||
@@ -54,6 +54,11 @@ public final class ComposeMenuActions implements MainMenuActions {
|
||||
application.runOnUi(application::menuActionToggleSettingsWindow);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void openSetupWizard() {
|
||||
application.runOnUi(application::menuActionOpenSetupWizard);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void toggleMonitorWindow() {
|
||||
application.runOnUi(application::menuActionToggleMonitorWindow);
|
||||
|
||||
@@ -42,6 +42,8 @@ import kst4contest.view.compose.SettingsWindow;
|
||||
import kst4contest.controller.ScoreService;
|
||||
import kst4contest.view.compose.SettingsWindow;
|
||||
import kst4contest.controller.On4KstConnectionState;
|
||||
import kst4contest.view.compose.wizard.SetupWizardLauncher;
|
||||
import kst4contest.view.compose.wizard.SetupWizardOutcome;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
@@ -2177,6 +2179,17 @@ public class Kst4ContestApplication implements StatusUpdateListener, SettingsHos
|
||||
return;
|
||||
}
|
||||
|
||||
/*
|
||||
* The setup wizard, before anything of this profile's runtime exists. It writes
|
||||
* preferences.xml and the ChatController built below reads it like any stored
|
||||
* setting, so there is no running session to bring up to date and no reload.
|
||||
* Blocks until the wizard is closed; see SetupWizardWindow for why that is safe on
|
||||
* either thread this method is called from.
|
||||
*/
|
||||
SetupWizardOutcome setupWizardOutcome = SetupWizardLauncher.runIfNeeded(
|
||||
ActiveOperatorProfile.get().getPreferencesRelativeFileName(),
|
||||
ApplicationRuntimeLauncher.consumeSetupWizardRequest());
|
||||
|
||||
ApplicationRuntimeLauncher.setCurrent(this);
|
||||
|
||||
ApplicationFileUtils.copyResourceIfRequired(ApplicationConstants.APPLICATION_NAME, STYLE_DEFAULTCSSDAY_RESOURCE, STYLE_DEFAULTCSSDAY_FILE);
|
||||
@@ -2297,6 +2310,15 @@ public class Kst4ContestApplication implements StatusUpdateListener, SettingsHos
|
||||
//initialize the timeline
|
||||
uiDispatcher.runOnUi(this::updateTimelineVisuals);
|
||||
|
||||
/*
|
||||
* "Save and connect" in the setup wizard. Here and not earlier: connecting needs the
|
||||
* runtime this method has just finished building. The same path as File -> Connect,
|
||||
* so a refused or failed connection is reported the way it is there.
|
||||
*/
|
||||
if (setupWizardOutcome == SetupWizardOutcome.SAVED_AND_CONNECT) {
|
||||
uiDispatcher.runOnUi(this::menuActionConnect);
|
||||
}
|
||||
|
||||
/*
|
||||
* Replaces Application.stop(), which only JavaFX ever called. This covers a SIGTERM
|
||||
* and a closing terminal; the ordinary exit still goes through
|
||||
@@ -4024,6 +4046,27 @@ public class Kst4ContestApplication implements StatusUpdateListener, SettingsHos
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Options -> setup assistant. Rebuilds the runtime of the active profile with the wizard
|
||||
* in front of it, which costs the running session; hence the question, and hence the
|
||||
* settings edits are settled first, as before a profile switch.
|
||||
*/
|
||||
void menuActionOpenSetupWizard() {
|
||||
SettingsWindow.settleThen(() -> {
|
||||
boolean confirmed = ComposeAlert.confirm(
|
||||
kst4contest.view.i18n.CurrentStrings.get().getAlertSetupWizardTitle(),
|
||||
kst4contest.view.i18n.CurrentStrings.get().getAlertSetupWizardQuestion(),
|
||||
kst4contest.view.i18n.CurrentStrings.get().getAlertSetupWizardBody(),
|
||||
kst4contest.view.i18n.CurrentStrings.get().getDialogStartSetupWizard(),
|
||||
kst4contest.view.i18n.CurrentStrings.get().getDialogCancel(),
|
||||
chatcontroller.getChatPreferences().isGUI_darkModeActive());
|
||||
|
||||
if (confirmed) {
|
||||
ApplicationRuntimeLauncher.rerunSetupWizard();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/** Windows -> open or close the cluster / stranger-QSO monitor window. */
|
||||
void menuActionToggleMonitorWindow() {
|
||||
if (MonitorWindow.isOpen()) {
|
||||
|
||||
@@ -0,0 +1,58 @@
|
||||
package kst4contest.view.compose
|
||||
|
||||
import kst4contest.model.BeaconStatusSnapshot
|
||||
import kst4contest.model.BeaconStatusSnapshot.AggregateState
|
||||
import kst4contest.model.BeaconStatusSnapshot.CategoryStatus
|
||||
import kst4contest.model.BeaconStatusSnapshot.InactiveReason
|
||||
import kst4contest.view.i18n.CurrentStrings
|
||||
import kst4contest.view.i18n.Strings
|
||||
|
||||
enum class ThreadStatusVisualStyle {
|
||||
DEFAULT,
|
||||
BEACON_OFF,
|
||||
BEACON_ACTIVE,
|
||||
BEACON_FAILED,
|
||||
}
|
||||
|
||||
data class BeaconStatusPresentation(
|
||||
val label: String,
|
||||
val tooltip: String,
|
||||
val style: ThreadStatusVisualStyle,
|
||||
) {
|
||||
companion object {
|
||||
fun from(
|
||||
snapshot: BeaconStatusSnapshot,
|
||||
strings: Strings = CurrentStrings.get(),
|
||||
): BeaconStatusPresentation {
|
||||
val label = when (snapshot.aggregateState) {
|
||||
AggregateState.OFF -> "off"
|
||||
AggregateState.PARTIAL -> "1/2"
|
||||
AggregateState.ON -> "on"
|
||||
AggregateState.FAILED -> "FAILED"
|
||||
}
|
||||
val style = when (snapshot.aggregateState) {
|
||||
AggregateState.OFF -> ThreadStatusVisualStyle.BEACON_OFF
|
||||
AggregateState.PARTIAL, AggregateState.ON -> ThreadStatusVisualStyle.BEACON_ACTIVE
|
||||
AggregateState.FAILED -> ThreadStatusVisualStyle.BEACON_FAILED
|
||||
}
|
||||
val tooltip = listOf(
|
||||
strings.beaconStatusMain(describe(snapshot.main, strings)),
|
||||
strings.beaconStatusSecond(describe(snapshot.second, strings)),
|
||||
).joinToString("\n")
|
||||
return BeaconStatusPresentation(label, tooltip, style)
|
||||
}
|
||||
|
||||
private fun describe(category: CategoryStatus, strings: Strings): String {
|
||||
if (!category.isAvailable()) return strings.beaconStatusUnavailable
|
||||
if (category.isFailed()) return strings.beaconStatusFailed
|
||||
if (category.isEnabled()) return strings.beaconStatusEnabled
|
||||
return when (category.inactiveReason) {
|
||||
InactiveReason.NOT_ACTIVATED_THIS_SESSION -> strings.beaconReasonSession
|
||||
InactiveReason.USER_DISABLED -> strings.beaconReasonUser
|
||||
InactiveReason.PRIMARY_QRG_UNAVAILABLE -> strings.beaconReasonPrimaryQrg
|
||||
InactiveReason.SECONDARY_QRG_UNAVAILABLE -> strings.beaconReasonSecondaryQrg
|
||||
InactiveReason.AUTOMATIC_QRG_CHANGE -> strings.beaconReasonAutomaticQrg
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -163,12 +163,12 @@ fun ChatInputRow(
|
||||
// profile on every keystroke.
|
||||
InlineCommittedField(
|
||||
stored = ownQrgMain.value.orEmpty(),
|
||||
onCommit = { prefs.getMYQRGFirstCat().set(it) },
|
||||
onCommit = { state.commitOwnQrg(mainCategory = true, it) },
|
||||
tooltip = kst4contest.view.i18n.CurrentStrings.get().chatOwnQrgTooltip,
|
||||
)
|
||||
InlineCommittedField(
|
||||
stored = ownQrgSecond.value.orEmpty(),
|
||||
onCommit = { prefs.getMYQRGSecondCat().set(it) },
|
||||
onCommit = { state.commitOwnQrg(mainCategory = false, it) },
|
||||
tooltip = if (so2rEnabled) {
|
||||
kst4contest.view.i18n.CurrentStrings.get().chatSecondQrgTooltipSo2r
|
||||
} else {
|
||||
|
||||
@@ -5,6 +5,7 @@ import androidx.compose.runtime.mutableStateOf
|
||||
import androidx.compose.runtime.setValue
|
||||
import androidx.compose.ui.text.TextRange
|
||||
import androidx.compose.ui.text.input.TextFieldValue
|
||||
import kst4contest.controller.RadioSlot
|
||||
import kst4contest.model.ChatCategory
|
||||
import kst4contest.model.ChatMember
|
||||
import kst4contest.model.ChatMessage
|
||||
@@ -46,6 +47,8 @@ interface ChatInputActions {
|
||||
fun ownQrgMain(): String
|
||||
|
||||
fun ownQrgSecond(): String
|
||||
|
||||
fun applyManualQrg(slot: RadioSlot, value: String) {}
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -150,6 +153,10 @@ class ChatInputState(private val actions: ChatInputActions) {
|
||||
appendAndFocus("$qrg ")
|
||||
}
|
||||
|
||||
fun commitOwnQrg(mainCategory: Boolean, value: String) {
|
||||
actions.applyManualQrg(if (mainCategory) RadioSlot.FIRST else RadioSlot.SECOND, value)
|
||||
}
|
||||
|
||||
/**
|
||||
* Replaces the field with "/cq CALL <snippet>", resolved.
|
||||
*
|
||||
|
||||
@@ -55,6 +55,9 @@ interface MainMenuActions {
|
||||
fun setQrgAsNameInChat()
|
||||
fun toggleAwayState()
|
||||
fun toggleSettingsWindow()
|
||||
|
||||
/** Ends the session after asking and runs the setup wizard for the active profile. */
|
||||
fun openSetupWizard()
|
||||
fun toggleMonitorWindow()
|
||||
fun toggleStationMap()
|
||||
fun useDarkDesign()
|
||||
|
||||
@@ -87,6 +87,11 @@ fun mainMenuModel(
|
||||
enabled = true,
|
||||
actions::toggleSettingsWindow,
|
||||
),
|
||||
/*
|
||||
* Always usable, like the profile switch: it rebuilds the runtime and asks before
|
||||
* it gives the session up.
|
||||
*/
|
||||
MenuEntry.Item(strings.menuSetupWizard, state.canSwitchProfile, actions::openSetupWizard),
|
||||
),
|
||||
),
|
||||
MenuSpec(
|
||||
|
||||
@@ -194,6 +194,10 @@ fun buildSettingsTabs(
|
||||
setSecondBeaconEnabled = controller::setSecondBeaconEnabled,
|
||||
mainCategoryName = categoryName(controller.chatCategoryMain, kst4contest.view.i18n.CurrentStrings.get().settingsCategoryMainFallback),
|
||||
secondCategoryName = categoryName(controller.chatCategorySecondChat, kst4contest.view.i18n.CurrentStrings.get().settingsCategorySecondFallback),
|
||||
onBeaconTemplatesApplied = {
|
||||
controller.onMainBeaconTemplateApplied()
|
||||
controller.onSecondBeaconTemplateApplied()
|
||||
},
|
||||
)
|
||||
|
||||
val logSynchState = LogSynchTabState(
|
||||
|
||||
@@ -26,6 +26,7 @@ import androidx.compose.ui.Alignment
|
||||
import androidx.compose.ui.Modifier
|
||||
import androidx.compose.ui.draw.alpha
|
||||
import androidx.compose.ui.graphics.Color
|
||||
import androidx.compose.ui.graphics.luminance
|
||||
import androidx.compose.ui.semantics.Role
|
||||
import androidx.compose.ui.text.font.FontWeight
|
||||
import androidx.compose.ui.unit.dp
|
||||
@@ -202,8 +203,20 @@ private fun ThreadStatusButtonView(button: ThreadStatusButton) {
|
||||
}
|
||||
|
||||
val scheme = MaterialTheme.colorScheme
|
||||
val background = if (button.highlighted) scheme.primary else scheme.surfaceVariant
|
||||
val foreground = if (button.highlighted) scheme.onPrimary else scheme.onSurfaceVariant
|
||||
val colors = if (button.visualStyle == ThreadStatusVisualStyle.DEFAULT) {
|
||||
ThreadButtonColors(
|
||||
background = if (button.highlighted) scheme.primary else scheme.surfaceVariant,
|
||||
border = null,
|
||||
text = if (button.highlighted) scheme.onPrimary else scheme.onSurfaceVariant,
|
||||
)
|
||||
} else {
|
||||
beaconThreadButtonColors(
|
||||
style = button.visualStyle,
|
||||
highlighted = button.highlighted,
|
||||
darkTheme = scheme.surface.luminance() < 0.5f,
|
||||
neutralBackground = scheme.surfaceVariant,
|
||||
)
|
||||
}
|
||||
|
||||
TooltipArea(tooltip = { TooltipCard(button.tooltip) }) {
|
||||
val actionModifier = if (button.hasAction) {
|
||||
@@ -211,17 +224,20 @@ private fun ThreadStatusButtonView(button: ThreadStatusButton) {
|
||||
} else {
|
||||
Modifier
|
||||
}
|
||||
Box(
|
||||
modifier = Modifier
|
||||
var boxModifier = Modifier
|
||||
.defaultMinSize(minHeight = 22.dp)
|
||||
.background(background, NOTICE_SHAPE)
|
||||
.background(colors.background, NOTICE_SHAPE)
|
||||
.then(actionModifier)
|
||||
.padding(NOTICE_PADDING),
|
||||
colors.border?.let { border ->
|
||||
boxModifier = boxModifier.border(1.dp, border, NOTICE_SHAPE)
|
||||
}
|
||||
Box(
|
||||
modifier = boxModifier.padding(NOTICE_PADDING),
|
||||
contentAlignment = Alignment.Center,
|
||||
) {
|
||||
Text(
|
||||
text = button.label,
|
||||
color = foreground,
|
||||
color = colors.text,
|
||||
style = MaterialTheme.typography.labelMedium,
|
||||
maxLines = 1,
|
||||
)
|
||||
@@ -229,6 +245,33 @@ private fun ThreadStatusButtonView(button: ThreadStatusButton) {
|
||||
}
|
||||
}
|
||||
|
||||
internal data class ThreadButtonColors(
|
||||
val background: Color,
|
||||
val border: Color?,
|
||||
val text: Color,
|
||||
)
|
||||
|
||||
internal fun beaconThreadButtonColors(
|
||||
style: ThreadStatusVisualStyle,
|
||||
highlighted: Boolean,
|
||||
darkTheme: Boolean,
|
||||
neutralBackground: Color,
|
||||
): ThreadButtonColors = when (style) {
|
||||
ThreadStatusVisualStyle.BEACON_ACTIVE -> if (highlighted) {
|
||||
ThreadButtonColors(Color(0xFFFFB300), Color(0xFFFFE082), Color(0xFF1B1B1B))
|
||||
} else {
|
||||
ThreadButtonColors(Color(0xFF238636), Color(0xFF56D364), Color.White)
|
||||
}
|
||||
ThreadStatusVisualStyle.BEACON_FAILED ->
|
||||
ThreadButtonColors(Color(0xFFD50000), Color(0xFFFF6B6B), Color.White)
|
||||
ThreadStatusVisualStyle.BEACON_OFF -> ThreadButtonColors(
|
||||
neutralBackground,
|
||||
null,
|
||||
if (darkTheme) Color(0xFFFF6B6B) else Color(0xFFD50000),
|
||||
)
|
||||
ThreadStatusVisualStyle.DEFAULT -> error("Default worker colours come from the theme")
|
||||
}
|
||||
|
||||
/** The tooltips in this bar carry the long text the badges had to cut. */
|
||||
@Composable
|
||||
internal fun TooltipCard(text: String) {
|
||||
|
||||
@@ -187,9 +187,11 @@ class ThreadStatusButtons {
|
||||
val button = bySource.getOrPut(sourceName) {
|
||||
ThreadStatusButton(sourceName, actions[sourceName]).also { ordered.add(it) }
|
||||
}
|
||||
val beacon = effectiveMessage.beaconStatusSnapshot?.let(BeaconStatusPresentation::from)
|
||||
button.report(
|
||||
label = "$sourceName: ${effectiveMessage.runningInformationTextDescription}",
|
||||
tooltip = effectiveMessage.runningInformation.orEmpty(),
|
||||
label = "$sourceName: ${beacon?.label ?: effectiveMessage.runningInformationTextDescription}",
|
||||
tooltip = beacon?.tooltip ?: effectiveMessage.runningInformation.orEmpty(),
|
||||
style = beacon?.style ?: ThreadStatusVisualStyle.DEFAULT,
|
||||
)
|
||||
}
|
||||
|
||||
@@ -226,6 +228,9 @@ class ThreadStatusButton(
|
||||
var highlighted: Boolean by mutableStateOf(false)
|
||||
private set
|
||||
|
||||
var visualStyle: ThreadStatusVisualStyle by mutableStateOf(ThreadStatusVisualStyle.DEFAULT)
|
||||
private set
|
||||
|
||||
var revision: Int by mutableStateOf(0)
|
||||
private set
|
||||
|
||||
@@ -235,10 +240,16 @@ class ThreadStatusButton(
|
||||
val hasAction: Boolean
|
||||
get() = action != null
|
||||
|
||||
internal fun report(label: String, tooltip: String) {
|
||||
internal fun report(
|
||||
label: String,
|
||||
tooltip: String,
|
||||
style: ThreadStatusVisualStyle = ThreadStatusVisualStyle.DEFAULT,
|
||||
) {
|
||||
this.label = label
|
||||
this.tooltip = tooltip
|
||||
highlighted = true
|
||||
visualStyle = style
|
||||
highlighted = style == ThreadStatusVisualStyle.DEFAULT ||
|
||||
style == ThreadStatusVisualStyle.BEACON_ACTIVE
|
||||
revision++
|
||||
}
|
||||
|
||||
|
||||
@@ -30,6 +30,7 @@ class BeaconTabState(
|
||||
val secondCategoryName: String,
|
||||
private val setMainBeaconEnabled: (Boolean) -> Unit = prefs::setBcn_beaconsEnabledMainCat,
|
||||
private val setSecondBeaconEnabled: (Boolean) -> Unit = prefs::setBcn_beaconsEnabledSecondCat,
|
||||
private val onBeaconTemplatesApplied: () -> Unit = {},
|
||||
) {
|
||||
|
||||
val mainBeaconEnabled = prefs.bcnBeaconsEnabledMainCatProperty()
|
||||
@@ -45,10 +46,14 @@ class BeaconTabState(
|
||||
|
||||
private var textMainCat: String by draft.setting(
|
||||
{ prefs.getBcn_beaconTextMainCat() },
|
||||
effectKey = BEACON_TEMPLATE_EFFECT,
|
||||
effect = onBeaconTemplatesApplied,
|
||||
) { prefs.setBcn_beaconTextMainCat(it) }
|
||||
|
||||
private var textSecondCat: String by draft.setting(
|
||||
{ prefs.getBcn_beaconTextSecondCat() },
|
||||
effectKey = BEACON_TEMPLATE_EFFECT,
|
||||
effect = onBeaconTemplatesApplied,
|
||||
) { prefs.setBcn_beaconTextSecondCat(it) }
|
||||
|
||||
/*
|
||||
@@ -123,4 +128,8 @@ class BeaconTabState(
|
||||
interval = minutes
|
||||
return null
|
||||
}
|
||||
|
||||
private companion object {
|
||||
const val BEACON_TEMPLATE_EFFECT = "beaconTemplates"
|
||||
}
|
||||
}
|
||||
+38
-19
@@ -18,10 +18,12 @@ import androidx.compose.runtime.getValue
|
||||
import androidx.compose.runtime.mutableStateOf
|
||||
import androidx.compose.runtime.remember
|
||||
import androidx.compose.runtime.setValue
|
||||
import androidx.compose.runtime.staticCompositionLocalOf
|
||||
import androidx.compose.ui.Alignment
|
||||
import androidx.compose.ui.Modifier
|
||||
import androidx.compose.ui.unit.dp
|
||||
import androidx.compose.ui.window.AwtWindow
|
||||
import java.awt.Dialog
|
||||
import java.awt.FileDialog
|
||||
import java.awt.Frame
|
||||
import java.io.File
|
||||
@@ -125,34 +127,51 @@ internal fun FilePathRow(
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* The AWT file dialog, opened from Compose. The JavaFX chooser started in the user's
|
||||
* home directory and a cancelled choice kept the stored path — both are preserved.
|
||||
*/
|
||||
/** The modal owner that keeps the native file chooser accessible when opened from the wizard. */
|
||||
val LocalFileDialogOwner = staticCompositionLocalOf<Dialog?> { null }
|
||||
|
||||
/** The AWT file dialog, opened from Compose. */
|
||||
@Composable
|
||||
private fun FileChooserDialog(title: String, onResult: (String?) -> Unit) {
|
||||
val owner = LocalFileDialogOwner.current
|
||||
AwtWindow(
|
||||
create = {
|
||||
object : FileDialog(null as Frame?, title, LOAD) {
|
||||
override fun setVisible(visible: Boolean) {
|
||||
if (visible) {
|
||||
directory = System.getProperty("user.home")
|
||||
}
|
||||
super.setVisible(visible)
|
||||
if (visible) {
|
||||
val chosenName = file
|
||||
onResult(
|
||||
if (chosenName == null) null
|
||||
else File(directory ?: "", chosenName).absolutePath
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
if (owner == null) LogFileDialog(title, onResult) else LogFileDialog(owner, title, onResult)
|
||||
},
|
||||
dispose = FileDialog::dispose,
|
||||
)
|
||||
}
|
||||
|
||||
/**
|
||||
* The JavaFX chooser started in the user's home directory and a cancelled choice kept the
|
||||
* stored path. Both constructors share that behaviour.
|
||||
*/
|
||||
private class LogFileDialog : FileDialog {
|
||||
private val onResult: (String?) -> Unit
|
||||
|
||||
constructor(title: String, onResult: (String?) -> Unit) : super(null as Frame?, title, LOAD) {
|
||||
this.onResult = onResult
|
||||
}
|
||||
|
||||
constructor(owner: Dialog, title: String, onResult: (String?) -> Unit) : super(owner, title, LOAD) {
|
||||
this.onResult = onResult
|
||||
}
|
||||
|
||||
override fun setVisible(visible: Boolean) {
|
||||
if (visible) {
|
||||
directory = System.getProperty("user.home")
|
||||
}
|
||||
super.setVisible(visible)
|
||||
if (visible) {
|
||||
val chosenName = file
|
||||
onResult(
|
||||
if (chosenName == null) null
|
||||
else File(directory ?: "", chosenName).absolutePath
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/** The label column width the shared form controls use, so the tabs line up. */
|
||||
@Composable
|
||||
private fun LabelledRow(label: String, field: @Composable () -> Unit) {
|
||||
|
||||
@@ -0,0 +1,492 @@
|
||||
package kst4contest.view.compose.wizard
|
||||
|
||||
import androidx.compose.foundation.layout.Arrangement
|
||||
import androidx.compose.foundation.layout.Column
|
||||
import androidx.compose.foundation.layout.Row
|
||||
import androidx.compose.foundation.layout.Spacer
|
||||
import androidx.compose.foundation.layout.fillMaxSize
|
||||
import androidx.compose.foundation.layout.fillMaxWidth
|
||||
import androidx.compose.foundation.layout.padding
|
||||
import androidx.compose.foundation.rememberScrollState
|
||||
import androidx.compose.foundation.selection.selectable
|
||||
import androidx.compose.foundation.verticalScroll
|
||||
import androidx.compose.material3.MaterialTheme
|
||||
import androidx.compose.material3.RadioButton
|
||||
import androidx.compose.material3.Surface
|
||||
import androidx.compose.material3.Text
|
||||
import androidx.compose.runtime.Composable
|
||||
import androidx.compose.runtime.CompositionLocalProvider
|
||||
import androidx.compose.runtime.getValue
|
||||
import androidx.compose.runtime.mutableStateOf
|
||||
import androidx.compose.runtime.remember
|
||||
import androidx.compose.runtime.setValue
|
||||
import androidx.compose.ui.Alignment
|
||||
import androidx.compose.ui.Modifier
|
||||
import androidx.compose.ui.semantics.Role
|
||||
import androidx.compose.ui.unit.dp
|
||||
import kst4contest.model.ChatCategory
|
||||
import kst4contest.view.compose.Density
|
||||
import kst4contest.view.compose.Form
|
||||
import kst4contest.view.compose.LocalSettingsDraft
|
||||
import kst4contest.view.compose.SettingsDraft
|
||||
import kst4contest.view.compose.tabs.FilePathRow
|
||||
import kst4contest.view.i18n.LanguageStore
|
||||
import kst4contest.view.i18n.LocalStrings
|
||||
import kst4contest.view.i18n.SYSTEM_LANGUAGE
|
||||
import kst4contest.view.i18n.Strings
|
||||
import kst4contest.view.i18n.Translations
|
||||
|
||||
/**
|
||||
* A language store for the wizard: a choice takes effect on screen at once and is kept in
|
||||
* the wizard's answers, not in the preferences. "Later" therefore stores no language, and
|
||||
* the runtime built afterwards puts the stored one back in force.
|
||||
*/
|
||||
fun wizardLanguageStore(state: SetupWizardState): LanguageStore =
|
||||
LanguageStore(storedLanguage = { state.language }, storeLanguage = { state.language = it })
|
||||
|
||||
/** The name a chat category carries in the pickers, the one the Station tab shows. */
|
||||
private fun categoryName(number: Int): String = ChatCategory(number).getChatCategoryName(number)
|
||||
|
||||
/**
|
||||
* The wizard's pages and its button row.
|
||||
*
|
||||
* All decisions are in [state]; this draws them. The texts are read from [languageStore] in
|
||||
* the composition, so the language picker on the personal page switches the wizard itself.
|
||||
*
|
||||
* @param saveFailed whether the last Save could not write the file
|
||||
* @param onLater the operator does not want to set up now; nothing is written
|
||||
* @param onSave the operator saves; true when the session should be started afterwards
|
||||
*/
|
||||
@Composable
|
||||
fun SetupWizardContent(
|
||||
state: SetupWizardState,
|
||||
languageStore: LanguageStore,
|
||||
saveFailed: Boolean,
|
||||
onLater: () -> Unit,
|
||||
onSave: (connect: Boolean) -> Unit,
|
||||
) {
|
||||
val strings = languageStore.strings
|
||||
// The draft only registers typed entries. Wizard answers are never staged or applied through it.
|
||||
val typedEntries = remember { SettingsDraft() }
|
||||
var typedEntryRefusals by remember { mutableStateOf(emptyList<String>()) }
|
||||
|
||||
fun withAcceptedTypedEntries(action: () -> Unit) {
|
||||
val refusals = typedEntries.commitTypedEntries()
|
||||
typedEntryRefusals = refusals
|
||||
if (refusals.isEmpty()) action()
|
||||
}
|
||||
|
||||
CompositionLocalProvider(LocalStrings provides strings, LocalSettingsDraft provides typedEntries) {
|
||||
Surface(modifier = Modifier.fillMaxSize()) {
|
||||
Column(modifier = Modifier.padding(15.dp)) {
|
||||
Column(
|
||||
modifier = Modifier.weight(1f).fillMaxWidth().verticalScroll(rememberScrollState()),
|
||||
verticalArrangement = Arrangement.spacedBy(6.dp),
|
||||
) {
|
||||
when (state.page) {
|
||||
WizardPage.ENTRY -> EntryPage(state, strings)
|
||||
WizardPage.PERSONAL -> PersonalPage(state, strings, languageStore)
|
||||
WizardPage.LOGIN -> LoginPage(state, strings)
|
||||
WizardPage.SITE -> SitePage(state, strings)
|
||||
WizardPage.ANTENNA -> AntennaPage(state.antenna, strings)
|
||||
WizardPage.LOG -> LogPage(state.integrations, strings)
|
||||
WizardPage.GEAR -> GearPage(state.integrations, strings)
|
||||
WizardPage.SUMMARY -> SummaryPage(state, strings, saveFailed)
|
||||
}
|
||||
}
|
||||
|
||||
if (typedEntryRefusals.isNotEmpty()) {
|
||||
Refusal(typedEntryRefusals.joinToString("\n"))
|
||||
}
|
||||
Row(
|
||||
modifier = Modifier.fillMaxWidth().padding(top = 10.dp),
|
||||
horizontalArrangement = Arrangement.spacedBy(Density.BUTTON_GAP),
|
||||
) {
|
||||
Form.button(strings.wizardLater, onClick = onLater)
|
||||
Spacer(Modifier.weight(1f))
|
||||
if (state.canGoBack) {
|
||||
Form.button(strings.wizardBack, onClick = state::back)
|
||||
}
|
||||
if (state.page == WizardPage.SUMMARY) {
|
||||
Form.button(strings.wizardSave, enabled = state.mandatoryComplete) {
|
||||
withAcceptedTypedEntries { onSave(false) }
|
||||
}
|
||||
Form.button(
|
||||
strings.wizardSaveAndConnect,
|
||||
enabled = state.mandatoryComplete,
|
||||
accented = true,
|
||||
) { withAcceptedTypedEntries { onSave(true) } }
|
||||
} else {
|
||||
if (state.canFinish) {
|
||||
Form.button(strings.wizardFinish) { withAcceptedTypedEntries(state::finish) }
|
||||
}
|
||||
Form.button(
|
||||
strings.wizardNext,
|
||||
enabled = state.canGoNext,
|
||||
accented = true,
|
||||
) { withAcceptedTypedEntries(state::next) }
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Composable
|
||||
private fun Heading(title: String, lead: String) {
|
||||
Text(title, style = MaterialTheme.typography.titleMedium)
|
||||
Text(lead, style = MaterialTheme.typography.bodySmall)
|
||||
}
|
||||
|
||||
@Composable
|
||||
private fun Refusal(text: String) {
|
||||
Text(text, color = MaterialTheme.colorScheme.error, style = MaterialTheme.typography.bodySmall)
|
||||
}
|
||||
|
||||
@Composable
|
||||
private fun RadioOption(label: String, selected: Boolean, onSelect: () -> Unit) {
|
||||
Row(
|
||||
modifier = Modifier
|
||||
.fillMaxWidth()
|
||||
.selectable(selected = selected, role = Role.RadioButton, onClick = onSelect)
|
||||
.padding(vertical = 2.dp),
|
||||
verticalAlignment = Alignment.CenterVertically,
|
||||
) {
|
||||
RadioButton(selected = selected, onClick = null)
|
||||
Text(label, modifier = Modifier.padding(start = 6.dp))
|
||||
}
|
||||
}
|
||||
|
||||
@Composable
|
||||
private fun EntryPage(state: SetupWizardState, strings: Strings) {
|
||||
Heading(strings.wizardEntryTitle, strings.wizardEntryLead)
|
||||
val oneDonor = state.donors.singleOrNull()
|
||||
|
||||
/* An axis with a single option is decided already and is not asked about. */
|
||||
if (state.loginSources.size > 1) {
|
||||
Form.section(strings.wizardEntryLogin) {
|
||||
state.loginSources.forEach { source ->
|
||||
RadioOption(
|
||||
label = when (source) {
|
||||
WizardSource.NEW -> strings.wizardSourceLoginNew
|
||||
// One other profile is named in the option; several get a picker below.
|
||||
WizardSource.TAKE ->
|
||||
if (oneDonor != null) strings.wizardSourceLoginTake(oneDonor.displayName, oneDonor.callsign)
|
||||
else strings.wizardSourceLoginTakeFrom
|
||||
WizardSource.KEEP -> strings.wizardSourceLoginKeep(state.storedCallsign)
|
||||
},
|
||||
selected = state.loginSource == source,
|
||||
onSelect = { state.chooseLoginSource(source) },
|
||||
)
|
||||
}
|
||||
if (state.loginSource == WizardSource.TAKE && oneDonor == null) {
|
||||
Form.choice(
|
||||
label = strings.wizardEntryDonor,
|
||||
items = state.donors,
|
||||
selected = state.loginDonor,
|
||||
describe = { "${it.displayName} (${it.callsign})" },
|
||||
onSelect = state::chooseLoginDonor,
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (state.stationSources.size > 1) {
|
||||
Form.section(strings.wizardEntryStation) {
|
||||
state.stationSources.forEach { source ->
|
||||
RadioOption(
|
||||
label = when (source) {
|
||||
WizardSource.NEW -> strings.wizardSourceStationNew
|
||||
WizardSource.TAKE ->
|
||||
if (oneDonor != null) strings.wizardSourceStationTake(oneDonor.displayName, oneDonor.locator)
|
||||
else strings.wizardSourceStationTakeFrom
|
||||
WizardSource.KEEP -> strings.wizardSourceStationKeep(state.storedLocator)
|
||||
},
|
||||
selected = state.stationSource == source,
|
||||
onSelect = { state.chooseStationSource(source) },
|
||||
)
|
||||
}
|
||||
if (state.stationSource == WizardSource.TAKE && oneDonor == null) {
|
||||
Form.choice(
|
||||
label = strings.wizardEntryDonor,
|
||||
items = state.donors,
|
||||
selected = state.stationDonor,
|
||||
describe = { "${it.displayName} (${it.locator})" },
|
||||
onSelect = state::chooseStationDonor,
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Composable
|
||||
private fun PersonalPage(state: SetupWizardState, strings: Strings, languageStore: LanguageStore) {
|
||||
Heading(strings.wizardPersonalTitle, strings.wizardPersonalLead)
|
||||
|
||||
Form.choice(
|
||||
label = strings.guiLanguage,
|
||||
items = listOf(SYSTEM_LANGUAGE) + Translations.BY_LANGUAGE.keys.sorted(),
|
||||
selected = languageStore.stored,
|
||||
// The code in capitals, as the GUI tab shows it.
|
||||
describe = { code -> if (code == SYSTEM_LANGUAGE) strings.guiLanguageSystem else code.uppercase() },
|
||||
onSelect = { languageStore.use(it) },
|
||||
)
|
||||
Form.text(strings.wizardPersonalName, state.name) { state.name = it }
|
||||
if (state.nameRefused) Refusal(strings.wizardPersonalNameInvalid)
|
||||
}
|
||||
|
||||
@Composable
|
||||
private fun LoginPage(state: SetupWizardState, strings: Strings) {
|
||||
Heading(strings.wizardLoginTitle, strings.wizardLoginLead)
|
||||
|
||||
Form.text(strings.stationCallsign, state.callsign) { state.callsign = it }
|
||||
if (state.callsignRefused) Refusal(strings.wizardLoginCallsignInvalid)
|
||||
Form.password(strings.stationPassword, state.password) { state.password = it }
|
||||
if (state.passwordRefused) Refusal(strings.wizardLoginPasswordInvalid)
|
||||
}
|
||||
|
||||
@Composable
|
||||
private fun SitePage(state: SetupWizardState, strings: Strings) {
|
||||
Heading(strings.wizardSiteTitle, strings.wizardSiteLead)
|
||||
|
||||
Form.text(strings.stationLocator, state.locator) { state.locator = it }
|
||||
if (state.locatorRefused) Refusal(strings.wizardSiteLocatorInvalid)
|
||||
|
||||
Form.flowingSection(strings.wizardSiteBands) {
|
||||
WizardBand.entries.forEach { band ->
|
||||
Form.check(band.label, band in state.bands) { state.setBand(band, it) }
|
||||
}
|
||||
}
|
||||
Text(strings.wizardSiteBandsHint, style = MaterialTheme.typography.bodySmall)
|
||||
|
||||
Form.choice(
|
||||
label = strings.stationMainCategory,
|
||||
items = SetupWizardState.CATEGORY_NUMBERS,
|
||||
selected = state.category,
|
||||
describe = ::categoryName,
|
||||
onSelect = state::chooseCategory,
|
||||
)
|
||||
state.suggestedCategory?.let { suggested ->
|
||||
Text(
|
||||
strings.wizardSiteCategorySuggestion(categoryName(suggested)),
|
||||
style = MaterialTheme.typography.bodySmall,
|
||||
)
|
||||
}
|
||||
|
||||
Form.check(strings.wizardSiteSecondChat, state.secondChat) { state.chooseSecondChat(it) }
|
||||
if (state.secondChat) {
|
||||
Form.choice(
|
||||
label = strings.stationSecondCategory,
|
||||
items = state.secondCategoryOptions,
|
||||
selected = state.secondCategory,
|
||||
describe = ::categoryName,
|
||||
onSelect = { state.secondCategory = it },
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
/** The name a log program carries on its page and in the summary. */
|
||||
private fun logProgramName(program: WizardLogProgram, strings: Strings): String = when (program) {
|
||||
WizardLogProgram.NONE -> strings.wizardLogNone
|
||||
WizardLogProgram.WINTEST -> strings.wizardLogWintest
|
||||
WizardLogProgram.UDP -> strings.wizardLogUdp
|
||||
WizardLogProgram.FILE -> strings.wizardLogFile
|
||||
}
|
||||
|
||||
/** The name of something that will be switched off, for the summary's notice. */
|
||||
private fun switchName(switch: WizardSwitch, strings: Strings): String = when (switch) {
|
||||
WizardSwitch.SECOND_CHAT -> strings.wizardSwitchSecondChat
|
||||
WizardSwitch.LOG_WINTEST -> strings.wizardSwitchLogWintest
|
||||
WizardSwitch.LOG_UDP -> strings.wizardSwitchLogUdp
|
||||
WizardSwitch.LOG_FILE -> strings.wizardSwitchLogFile
|
||||
WizardSwitch.QRG_FOLLOW -> strings.wizardSwitchQrgFollow
|
||||
WizardSwitch.CLUSTER_SERVER -> strings.wizardSwitchClusterServer
|
||||
WizardSwitch.ROTATOR -> strings.wizardSwitchRotator
|
||||
WizardSwitch.AIRSCOUT -> strings.wizardSwitchAirScout
|
||||
WizardSwitch.SO2R -> strings.wizardSwitchSo2r
|
||||
WizardSwitch.ROTATOR_2 -> strings.wizardSwitchRotator2
|
||||
}
|
||||
|
||||
@Composable
|
||||
private fun AntennaPage(antenna: WizardAntenna, strings: Strings) {
|
||||
Heading(strings.wizardAntennaTitle, strings.wizardAntennaLead)
|
||||
|
||||
Form.decimal(strings.stationBeamWidth, antenna.beamWidthDeg, isValid = { it.isFinite() }) {
|
||||
antenna.beamWidthDeg = it
|
||||
}
|
||||
Form.decimal(strings.stationOwnAntennaGain, antenna.gainDbi, isValid = { it.isFinite() }) {
|
||||
antenna.gainDbi = it
|
||||
}
|
||||
Form.decimal(strings.stationOwnAntennaHeight, antenna.heightMeters, isValid = { it.isFinite() && it >= 0.0 }) {
|
||||
antenna.heightMeters = it
|
||||
}
|
||||
Form.decimal(strings.stationOwnTxPower, antenna.txPowerWatts, isValid = { it.isFinite() }) {
|
||||
antenna.txPowerWatts = it
|
||||
}
|
||||
|
||||
Form.text(strings.stationOwnHeightAsl, antenna.heightAslText) { antenna.heightAslText = it }
|
||||
if (antenna.heightAslRefused) {
|
||||
Refusal(strings.stationInvalidOwnHeightAsl(antenna.heightAslText.trim()))
|
||||
}
|
||||
Text(strings.wizardAntennaAslHint, style = MaterialTheme.typography.bodySmall)
|
||||
}
|
||||
|
||||
@Composable
|
||||
private fun LogPage(integrations: WizardIntegrations, strings: Strings) {
|
||||
Heading(strings.wizardLogTitle, strings.wizardLogLead)
|
||||
|
||||
WizardLogProgram.entries.forEach { program ->
|
||||
RadioOption(
|
||||
label = logProgramName(program, strings),
|
||||
selected = integrations.logProgram == program,
|
||||
onSelect = { integrations.chooseLogProgram(program) },
|
||||
)
|
||||
}
|
||||
|
||||
/* The details of a program appear only once it is chosen. */
|
||||
when (integrations.logProgram) {
|
||||
WizardLogProgram.WINTEST -> {
|
||||
Form.int(strings.logSynchWinTestPort, integrations.wintestPort) { integrations.wintestPort = it }
|
||||
Form.text(strings.logSynchWinTestStationName, integrations.wintestStationName) {
|
||||
integrations.wintestStationName = it
|
||||
}
|
||||
}
|
||||
WizardLogProgram.UDP ->
|
||||
Form.int(strings.logSynchSharedPort, integrations.udpPort) { integrations.udpPort = it }
|
||||
WizardLogProgram.FILE ->
|
||||
FilePathRow(
|
||||
label = strings.logSynchFileLabel,
|
||||
value = integrations.filePath,
|
||||
chooserTitle = strings.logSynchFileChooserTitle,
|
||||
) { integrations.filePath = it }
|
||||
WizardLogProgram.NONE -> Unit
|
||||
}
|
||||
if (!integrations.logComplete) Refusal(strings.wizardLogIncomplete)
|
||||
|
||||
if (integrations.networked) {
|
||||
Form.check(strings.wizardLogQrgFollow, integrations.qrgFollow) { integrations.qrgFollow = it }
|
||||
Form.check(strings.wizardLogClusterServer, integrations.clusterServer) { integrations.clusterServer = it }
|
||||
// The settings tab's own words: an enabled source does not produce a frequency by itself.
|
||||
Text(strings.trxSynchHint, style = MaterialTheme.typography.bodySmall)
|
||||
}
|
||||
}
|
||||
|
||||
@Composable
|
||||
private fun GearPage(integrations: WizardIntegrations, strings: Strings) {
|
||||
Heading(strings.wizardGearTitle, strings.wizardGearLead)
|
||||
|
||||
Form.check(strings.wizardGearRotator, integrations.rotator) { integrations.rotator = it }
|
||||
if (integrations.rotator) {
|
||||
Form.text(strings.stationRotatorHost, integrations.rotatorHost) { integrations.rotatorHost = it }
|
||||
Form.int(strings.stationRotatorPort, integrations.rotatorPort) { integrations.rotatorPort = it }
|
||||
if (integrations.rotatorPortClashes) {
|
||||
Refusal(strings.stationRotator2PortClash(integrations.rotatorPort.toString()))
|
||||
}
|
||||
}
|
||||
|
||||
Form.check(strings.wizardGearAirScout, integrations.airScout) { integrations.airScout = it }
|
||||
if (integrations.airScout) {
|
||||
Form.int(strings.airscoutUdpPort, integrations.airScoutPort) { integrations.airScoutPort = it }
|
||||
Form.text(strings.airscoutServerIdentifier, integrations.airScoutServerName) {
|
||||
integrations.airScoutServerName = it
|
||||
}
|
||||
Form.text(strings.airscoutClientIdentifier, integrations.airScoutClientName) {
|
||||
integrations.airScoutClientName = it
|
||||
}
|
||||
}
|
||||
if (!integrations.gearComplete) Refusal(strings.wizardGearIncomplete)
|
||||
}
|
||||
|
||||
@Composable
|
||||
private fun SummaryRow(label: String, value: String) {
|
||||
Form.labelledRow(label) { Text(value) }
|
||||
}
|
||||
|
||||
@Composable
|
||||
private fun SummaryPage(state: SetupWizardState, strings: Strings, saveFailed: Boolean) {
|
||||
Heading(strings.wizardSummaryTitle, strings.wizardSummaryLead)
|
||||
|
||||
if (saveFailed) Refusal(strings.wizardSaveFailed)
|
||||
if (!state.mandatoryComplete) Refusal(strings.wizardMissing)
|
||||
if (state.switchedOff.isNotEmpty()) {
|
||||
Text(strings.wizardSummarySwitchedOff(state.switchedOff.joinToString(", ") { switchName(it, strings) }))
|
||||
}
|
||||
|
||||
Form.section(strings.wizardSummaryPersonal) {
|
||||
SummaryRow(
|
||||
strings.guiLanguage,
|
||||
if (state.language == SYSTEM_LANGUAGE) strings.guiLanguageSystem else state.language.uppercase(),
|
||||
)
|
||||
SummaryRow(strings.wizardPersonalName, state.name.ifBlank { strings.wizardSummaryNone })
|
||||
Form.button(strings.wizardChange) { state.edit(WizardPage.PERSONAL) }
|
||||
}
|
||||
|
||||
Form.section(strings.wizardSummaryLogin) {
|
||||
if (state.loginSource == WizardSource.TAKE) {
|
||||
state.loginDonor?.let { Text(strings.wizardSummaryTakenFrom(it.displayName)) }
|
||||
}
|
||||
SummaryRow(strings.stationCallsign, state.callsign.ifBlank { strings.wizardSummaryNone })
|
||||
// Never the password itself: the summary may be read over a shoulder.
|
||||
SummaryRow(
|
||||
strings.stationPassword,
|
||||
if (state.password.isEmpty()) strings.wizardSummaryNone else strings.wizardSummaryPasswordSet,
|
||||
)
|
||||
Form.button(strings.wizardChange) { state.edit(WizardPage.LOGIN) }
|
||||
}
|
||||
|
||||
Form.section(strings.wizardSummaryStation) {
|
||||
if (state.stationSource == WizardSource.TAKE) {
|
||||
state.stationDonor?.let { Text(strings.wizardSummaryTakenFrom(it.displayName)) }
|
||||
}
|
||||
SummaryRow(strings.stationLocator, state.locator.ifBlank { strings.wizardSummaryNone })
|
||||
SummaryRow(
|
||||
strings.wizardSummaryBands,
|
||||
WizardBand.entries.filter { it in state.bands }.joinToString(", ") { it.label }
|
||||
.ifEmpty { strings.wizardSummaryNone },
|
||||
)
|
||||
SummaryRow(
|
||||
strings.wizardSummaryFallbackBand,
|
||||
if (state.summaryFallbackBand.isBlank()) strings.wizardSummaryNone else "${state.summaryFallbackBand} MHz",
|
||||
)
|
||||
SummaryRow(
|
||||
strings.stationMainCategory,
|
||||
state.category?.let(::categoryName) ?: strings.wizardSummaryNone,
|
||||
)
|
||||
SummaryRow(
|
||||
strings.stationSecondCategory,
|
||||
state.secondCategory?.takeIf { state.secondChat }?.let(::categoryName) ?: strings.wizardSummaryNone,
|
||||
)
|
||||
Form.button(strings.wizardChange) { state.edit(WizardPage.SITE) }
|
||||
}
|
||||
|
||||
val antenna = state.antenna
|
||||
Form.section(strings.wizardSummaryAntenna) {
|
||||
SummaryRow(strings.stationBeamWidth, antenna.beamWidthDeg.toString())
|
||||
SummaryRow(strings.stationOwnAntennaGain, antenna.gainDbi.toString())
|
||||
SummaryRow(strings.stationOwnAntennaHeight, antenna.heightMeters.toString())
|
||||
SummaryRow(strings.stationOwnTxPower, antenna.txPowerWatts.toString())
|
||||
SummaryRow(strings.stationOwnHeightAsl, antenna.heightAslText.trim().ifEmpty { strings.wizardSummaryNone })
|
||||
Form.button(strings.wizardChange) { state.edit(WizardPage.ANTENNA) }
|
||||
}
|
||||
|
||||
val integrations = state.integrations
|
||||
val yesNo = { on: Boolean -> if (on) strings.wizardSummaryYes else strings.wizardSummaryNo }
|
||||
|
||||
Form.section(strings.wizardSummaryLog) {
|
||||
if (state.logPageEditable) {
|
||||
SummaryRow(strings.wizardSummaryLog, logProgramName(integrations.logProgram, strings))
|
||||
SummaryRow(strings.wizardSummaryQrgFollow, yesNo(state.summaryQrgFollow))
|
||||
SummaryRow(strings.wizardSummaryClusterServer, yesNo(state.summaryClusterServer))
|
||||
Form.button(strings.wizardChange) { state.edit(WizardPage.LOG) }
|
||||
} else {
|
||||
/* Several sources are on; the page cannot show that and must not be opened. */
|
||||
Text(strings.wizardSummaryLogSeveral)
|
||||
}
|
||||
}
|
||||
|
||||
Form.section(strings.wizardSummaryGear) {
|
||||
SummaryRow(strings.wizardSwitchRotator, yesNo(integrations.rotator))
|
||||
SummaryRow(strings.wizardSwitchAirScout, yesNo(integrations.airScout))
|
||||
Form.button(strings.wizardChange) { state.edit(WizardPage.GEAR) }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,576 @@
|
||||
package kst4contest.view.compose.wizard
|
||||
|
||||
import androidx.compose.runtime.getValue
|
||||
import androidx.compose.runtime.mutableStateOf
|
||||
import androidx.compose.runtime.setValue
|
||||
import kst4contest.controller.LoginConfiguration
|
||||
import kst4contest.model.ChatCategory
|
||||
import kst4contest.model.ChatPreferences
|
||||
|
||||
/** Where the answers of one group come from. */
|
||||
enum class WizardSource {
|
||||
/** Entered in the wizard, starting from the wizard's own empty values. */
|
||||
NEW,
|
||||
|
||||
/** Taken from another, configured profile. */
|
||||
TAKE,
|
||||
|
||||
/** What the profile already holds. */
|
||||
KEEP,
|
||||
}
|
||||
|
||||
/**
|
||||
* Another profile the login or the station can be taken from.
|
||||
*
|
||||
* Its preferences are read from its file and never written: taking over fills the wizard's
|
||||
* answers, and Save writes only into the active profile.
|
||||
*
|
||||
* @param prefs the other profile's preferences, already read from its file
|
||||
*/
|
||||
class WizardDonor(val profileId: String, val displayName: String, val prefs: ChatPreferences) {
|
||||
|
||||
/** For the entry page's label. */
|
||||
val callsign: String = prefs.getStn_loginCallSign().orEmpty()
|
||||
|
||||
/** For the entry page's label. */
|
||||
val locator: String = prefs.getStn_loginLocatorMainCat().orEmpty()
|
||||
}
|
||||
|
||||
/** The pages, in the order they can appear. */
|
||||
enum class WizardPage { ENTRY, PERSONAL, LOGIN, SITE, ANTENNA, LOG, GEAR, SUMMARY }
|
||||
|
||||
/**
|
||||
* A band the station can be active on.
|
||||
*
|
||||
* The labels are amateur shorthand and deliberately not in the translation files.
|
||||
*/
|
||||
enum class WizardBand(
|
||||
val label: String,
|
||||
val megahertz: Int,
|
||||
internal val isActive: (ChatPreferences) -> Boolean,
|
||||
internal val setActive: (ChatPreferences, Boolean) -> Unit,
|
||||
) {
|
||||
B50("50 MHz", 50, { it.isStn_bandActive50() }, { p, on -> p.setStn_bandActive50(on) }),
|
||||
B70("70 MHz", 70, { it.isStn_bandActive70() }, { p, on -> p.setStn_bandActive70(on) }),
|
||||
B144("144 MHz", 144, { it.isStn_bandActive144() }, { p, on -> p.setStn_bandActive144(on) }),
|
||||
B432("432 MHz", 432, { it.isStn_bandActive432() }, { p, on -> p.setStn_bandActive432(on) }),
|
||||
B1240("1240 MHz", 1240, { it.isStn_bandActive1240() }, { p, on -> p.setStn_bandActive1240(on) }),
|
||||
B2300("2300 MHz", 2300, { it.isStn_bandActive2300() }, { p, on -> p.setStn_bandActive2300(on) }),
|
||||
B3400("3400 MHz", 3400, { it.isStn_bandActive3400() }, { p, on -> p.setStn_bandActive3400(on) }),
|
||||
B5600("5600 MHz", 5600, { it.isStn_bandActive5600() }, { p, on -> p.setStn_bandActive5600(on) }),
|
||||
B10G("10 GHz", 10000, { it.isStn_bandActive10G() }, { p, on -> p.setStn_bandActive10G(on) }),
|
||||
}
|
||||
|
||||
/**
|
||||
* The setup wizard's answers and the rules of its course, free of any window.
|
||||
*
|
||||
* It reads the preferences once, when it is built, and does not touch them again until
|
||||
* [writeTo]: closing the wizard without saving therefore leaves the profile exactly as it
|
||||
* was. The design is in `docs/superpowers/specs/2026-11-18-einrichtungsassistent-design.md`.
|
||||
*
|
||||
* The answers are Compose state, so a composition reading them follows; nothing else here
|
||||
* depends on Compose.
|
||||
*
|
||||
* @param prefs the profile's preferences, already read from its file
|
||||
* @param donors other configured profiles the login or the station can be taken from
|
||||
*/
|
||||
class SetupWizardState(prefs: ChatPreferences, val donors: List<WizardDonor> = emptyList()) {
|
||||
|
||||
/** What the pages of the station group show of one profile's preferences. */
|
||||
private class StationSnapshot(prefs: ChatPreferences) {
|
||||
val locator: String = prefs.getStn_loginLocatorMainCat().orEmpty()
|
||||
val bands: Set<WizardBand> = WizardBand.entries.filter { it.isActive(prefs) }.toSet()
|
||||
val category: Int? = prefs.getLoginChatCategoryMain()?.categoryNumber
|
||||
val secondChat: Boolean = prefs.isLoginToSecondChatEnabled()
|
||||
val secondCategory: Int? = prefs.getLoginChatCategorySecond()?.categoryNumber
|
||||
}
|
||||
|
||||
/** Kept to rebuild the answers of the station group when its source changes. */
|
||||
private val ownPrefs: ChatPreferences = prefs
|
||||
private val ownStation = StationSnapshot(prefs)
|
||||
|
||||
/** What the own profile has on, whatever the answers are built from. */
|
||||
private val ownSwitches: Set<WizardSwitch> = WizardIntegrations(prefs).let {
|
||||
it.storedLogSwitches() + it.storedGearSwitches()
|
||||
}
|
||||
|
||||
private val loginConfigured = !LoginConfiguration.isUnconfigured(prefs)
|
||||
private val templateCredentials = LoginConfiguration.carriesTemplateCredentials(prefs)
|
||||
|
||||
/** The callsign the profile holds, for the label of "leave unchanged". */
|
||||
val storedCallsign: String = prefs.getStn_loginCallSign().orEmpty()
|
||||
private val storedPassword: String = prefs.getStn_loginPassword().orEmpty()
|
||||
private val storedName: String = prefs.getStn_loginNameMainCat().orEmpty()
|
||||
private val storedSecondName: String = prefs.getStn_loginNameSecondCat().orEmpty()
|
||||
|
||||
/** The locator the profile holds, for the label of "leave unchanged". */
|
||||
val storedLocator: String = ownStation.locator
|
||||
|
||||
/** A login can be taken where another profile has one, and kept where an operator entered one. */
|
||||
val loginSources: List<WizardSource> = buildList {
|
||||
add(WizardSource.NEW)
|
||||
if (donors.isNotEmpty()) add(WizardSource.TAKE)
|
||||
if (loginConfigured) add(WizardSource.KEEP)
|
||||
}
|
||||
|
||||
/**
|
||||
* A station can be kept unless the profile is the untouched template: its locator and
|
||||
* bands are then nobody's.
|
||||
*/
|
||||
val stationSources: List<WizardSource> = buildList {
|
||||
add(WizardSource.NEW)
|
||||
if (donors.isNotEmpty()) add(WizardSource.TAKE)
|
||||
if (!templateCredentials) add(WizardSource.KEEP)
|
||||
}
|
||||
|
||||
/** Whether there is anything to choose on the entry page. */
|
||||
val hasEntryPage: Boolean = loginSources.size > 1 || stationSources.size > 1
|
||||
|
||||
var loginSource: WizardSource? by mutableStateOf(loginSources.singleOrNull())
|
||||
private set
|
||||
|
||||
var stationSource: WizardSource? by mutableStateOf(stationSources.singleOrNull())
|
||||
private set
|
||||
|
||||
/** The profile the login is taken from; decided with the source when there is only one. */
|
||||
var loginDonor: WizardDonor? by mutableStateOf(null)
|
||||
private set
|
||||
|
||||
/** The profile the station is taken from; decided with the source when there is only one. */
|
||||
var stationDonor: WizardDonor? by mutableStateOf(null)
|
||||
private set
|
||||
|
||||
/* A group is reloaded when its source or its donor changes, and only then. */
|
||||
private var appliedLogin: Pair<WizardSource?, WizardDonor?> = null to null
|
||||
private var appliedStation: Pair<WizardSource?, WizardDonor?> = null to null
|
||||
|
||||
/** The stored form of the language: a code, or empty for the system language. */
|
||||
var language: String by mutableStateOf(prefs.getGuiOptions_language().orEmpty())
|
||||
|
||||
/** Empty on an unconfigured profile: its stored name is the template's or another operator's. */
|
||||
var name: String by mutableStateOf(if (loginConfigured) storedName else "")
|
||||
|
||||
var callsign: String by mutableStateOf("")
|
||||
var password: String by mutableStateOf("")
|
||||
var locator: String by mutableStateOf("")
|
||||
|
||||
var bands: Set<WizardBand> by mutableStateOf(emptySet())
|
||||
private set
|
||||
|
||||
var category: Int? by mutableStateOf(null)
|
||||
private set
|
||||
|
||||
private var categoryChosenByOperator = false
|
||||
|
||||
var secondChat: Boolean by mutableStateOf(false)
|
||||
private set
|
||||
|
||||
var secondCategory: Int? by mutableStateOf(null)
|
||||
|
||||
/**
|
||||
* Antenna and power; always proposals from the profile the station comes from. Replaced
|
||||
* when the station's source changes, so nothing typed under one choice shows under another.
|
||||
*/
|
||||
var antenna: WizardAntenna by mutableStateOf(WizardAntenna(prefs))
|
||||
private set
|
||||
|
||||
/** Log program, rotator and AirScout; replaced like [antenna]. */
|
||||
var integrations: WizardIntegrations by mutableStateOf(WizardIntegrations(prefs))
|
||||
private set
|
||||
|
||||
private var loginShown by mutableStateOf(false)
|
||||
|
||||
/*
|
||||
* One flag per page of the station group. A page that was shown in this run is written;
|
||||
* a page that never was leaves its settings exactly as the profile has them. That is
|
||||
* what keeps "leave the station unchanged" from touching integrations the wizard's
|
||||
* simpler questions could not express.
|
||||
*/
|
||||
private var siteShown by mutableStateOf(false)
|
||||
private var antennaShown by mutableStateOf(false)
|
||||
private var logShown by mutableStateOf(false)
|
||||
private var gearShown by mutableStateOf(false)
|
||||
|
||||
var page: WizardPage by mutableStateOf(if (hasEntryPage) WizardPage.ENTRY else WizardPage.PERSONAL)
|
||||
private set
|
||||
|
||||
init {
|
||||
if (!hasEntryPage) applySources()
|
||||
}
|
||||
|
||||
fun chooseLoginSource(source: WizardSource) {
|
||||
if (source !in loginSources) return
|
||||
loginSource = source
|
||||
if (source == WizardSource.TAKE && loginDonor == null) loginDonor = donors.singleOrNull()
|
||||
}
|
||||
|
||||
fun chooseStationSource(source: WizardSource) {
|
||||
if (source !in stationSources) return
|
||||
stationSource = source
|
||||
if (source == WizardSource.TAKE && stationDonor == null) stationDonor = donors.singleOrNull()
|
||||
}
|
||||
|
||||
fun chooseLoginDonor(donor: WizardDonor) {
|
||||
if (donor in donors) loginDonor = donor
|
||||
}
|
||||
|
||||
fun chooseStationDonor(donor: WizardDonor) {
|
||||
if (donor in donors) stationDonor = donor
|
||||
}
|
||||
|
||||
/** A source is decided once it is chosen and, when it takes over, says from whom. */
|
||||
private fun decided(source: WizardSource?, donor: WizardDonor?): Boolean =
|
||||
source != null && (source != WizardSource.TAKE || donor != null)
|
||||
|
||||
/**
|
||||
* Loads the answers of a group whose source or donor changed. A group whose choice is the
|
||||
* one already applied is left alone, so going back to the entry page costs nothing typed.
|
||||
*/
|
||||
private fun applySources() {
|
||||
val login = loginSource to loginDonor.takeIf { loginSource == WizardSource.TAKE }
|
||||
if (login != appliedLogin) {
|
||||
when (loginSource) {
|
||||
WizardSource.KEEP -> {
|
||||
callsign = storedCallsign
|
||||
password = storedPassword
|
||||
}
|
||||
WizardSource.TAKE -> {
|
||||
callsign = loginDonor?.prefs?.getStn_loginCallSign().orEmpty()
|
||||
password = loginDonor?.prefs?.getStn_loginPassword().orEmpty()
|
||||
}
|
||||
else -> {
|
||||
callsign = ""
|
||||
password = ""
|
||||
}
|
||||
}
|
||||
// Shown when entered anew, and when what was kept or taken cannot be saved as it is.
|
||||
loginShown = loginSource == WizardSource.NEW || !loginComplete
|
||||
appliedLogin = login
|
||||
}
|
||||
|
||||
val station = stationSource to stationDonor.takeIf { stationSource == WizardSource.TAKE }
|
||||
if (station != appliedStation) {
|
||||
val fresh = stationSource == WizardSource.NEW
|
||||
val base = if (stationSource == WizardSource.TAKE) stationDonor?.prefs ?: ownPrefs else ownPrefs
|
||||
val snapshot = if (base === ownPrefs) ownStation else StationSnapshot(base)
|
||||
|
||||
locator = if (fresh) "" else snapshot.locator
|
||||
bands = if (fresh) emptySet() else snapshot.bands
|
||||
category = if (fresh) null else snapshot.category
|
||||
secondChat = !fresh && snapshot.secondChat
|
||||
secondCategory = if (fresh) null else snapshot.secondCategory
|
||||
// A kept or taken category is an operator's; the suggestion must not replace it.
|
||||
categoryChosenByOperator = !fresh
|
||||
|
||||
siteShown = fresh || !stationComplete
|
||||
antennaShown = fresh
|
||||
logShown = fresh
|
||||
gearShown = fresh
|
||||
|
||||
// Built anew from the profile the station comes from; a new station gets only
|
||||
// what the operator says yes to.
|
||||
antenna = WizardAntenna(base)
|
||||
integrations = WizardIntegrations(base).also { if (fresh) it.loadFresh() }
|
||||
appliedStation = station
|
||||
}
|
||||
}
|
||||
|
||||
fun setBand(band: WizardBand, active: Boolean) {
|
||||
bands = if (active) bands + band else bands - band
|
||||
if (!categoryChosenByOperator) updateCategory(suggestCategory(bands))
|
||||
}
|
||||
|
||||
/** What the bands suggest, shown beside the picker whatever is chosen. */
|
||||
val suggestedCategory: Int?
|
||||
get() = suggestCategory(bands)
|
||||
|
||||
fun chooseCategory(number: Int) {
|
||||
categoryChosenByOperator = true
|
||||
updateCategory(number)
|
||||
}
|
||||
|
||||
private fun updateCategory(number: Int?) {
|
||||
category = number
|
||||
if (secondCategory == number) secondCategory = null
|
||||
}
|
||||
|
||||
fun chooseSecondChat(enabled: Boolean) {
|
||||
secondChat = enabled
|
||||
}
|
||||
|
||||
/** The main category is left out, as the Station tab does. */
|
||||
val secondCategoryOptions: List<Int>
|
||||
get() = CATEGORY_NUMBERS.filter { it != category }
|
||||
|
||||
/** The pages of this run, in order. */
|
||||
val pages: List<WizardPage>
|
||||
get() = buildList {
|
||||
if (hasEntryPage) add(WizardPage.ENTRY)
|
||||
add(WizardPage.PERSONAL)
|
||||
if (loginShown) add(WizardPage.LOGIN)
|
||||
if (siteShown) add(WizardPage.SITE)
|
||||
if (antennaShown) add(WizardPage.ANTENNA)
|
||||
if (logShown) add(WizardPage.LOG)
|
||||
if (gearShown) add(WizardPage.GEAR)
|
||||
add(WizardPage.SUMMARY)
|
||||
}
|
||||
|
||||
private val personalComplete: Boolean
|
||||
get() = isStorableName(name)
|
||||
|
||||
private val loginComplete: Boolean
|
||||
get() = isPlausibleCallsign(callsign) && isStorablePassword(password)
|
||||
|
||||
private val stationComplete: Boolean
|
||||
get() = isLocator(locator) && bands.isNotEmpty() && category in CATEGORY_NUMBERS &&
|
||||
(!secondChat || secondCategory in secondCategoryOptions)
|
||||
|
||||
/** The optional pages that are part of this run hold nothing that cannot be stored. */
|
||||
private val shownOptionalPagesComplete: Boolean
|
||||
get() = (!antennaShown || antenna.complete) &&
|
||||
(!logShown || integrations.logComplete) &&
|
||||
(!gearShown || integrations.gearComplete)
|
||||
|
||||
/**
|
||||
* Whether the answers can be saved: everything the profile needs to log in is there, and
|
||||
* no page of this run holds a value that cannot be stored. The optional pages need no
|
||||
* answer, but an out-of-range port on one of them still blocks.
|
||||
*/
|
||||
val mandatoryComplete: Boolean
|
||||
get() = personalComplete && loginComplete && stationComplete && shownOptionalPagesComplete
|
||||
|
||||
/** A chat name that was typed and cannot be sent. An empty or blank field is not an error yet. */
|
||||
val nameRefused: Boolean
|
||||
get() = name.isNotBlank() && !isStorableName(name)
|
||||
|
||||
/** A callsign that was typed and does not look like one. An empty field is not an error yet. */
|
||||
val callsignRefused: Boolean
|
||||
get() = callsign.isNotBlank() && !isPlausibleCallsign(callsign)
|
||||
|
||||
/** A password that was typed and cannot be stored or sent. An empty field is not an error yet. */
|
||||
val passwordRefused: Boolean
|
||||
get() = password.isNotEmpty() && !isStorablePassword(password)
|
||||
|
||||
/** A locator that was typed and is not one. An empty field is not an error yet. */
|
||||
val locatorRefused: Boolean
|
||||
get() = locator.isNotBlank() && !isLocator(locator)
|
||||
|
||||
val canGoNext: Boolean
|
||||
get() = when (page) {
|
||||
WizardPage.ENTRY -> decided(loginSource, loginDonor) && decided(stationSource, stationDonor)
|
||||
WizardPage.PERSONAL -> personalComplete
|
||||
WizardPage.LOGIN -> loginComplete
|
||||
WizardPage.SITE -> stationComplete
|
||||
WizardPage.ANTENNA -> antenna.complete
|
||||
WizardPage.LOG -> integrations.logComplete
|
||||
WizardPage.GEAR -> integrations.gearComplete
|
||||
WizardPage.SUMMARY -> false
|
||||
}
|
||||
|
||||
val canGoBack: Boolean
|
||||
get() = pages.indexOf(page) > 0
|
||||
|
||||
/**
|
||||
* Whether the remaining steps may be skipped. Only with every mandatory answer, because
|
||||
* a summary that cannot be saved helps nobody.
|
||||
*/
|
||||
val canFinish: Boolean
|
||||
get() = page != WizardPage.ENTRY && page != WizardPage.SUMMARY && mandatoryComplete
|
||||
|
||||
fun next() {
|
||||
if (!canGoNext) return
|
||||
if (page == WizardPage.ENTRY) applySources()
|
||||
page = pages[pages.indexOf(page) + 1]
|
||||
}
|
||||
|
||||
fun back() {
|
||||
if (canGoBack) page = pages[pages.indexOf(page) - 1]
|
||||
}
|
||||
|
||||
fun finish() {
|
||||
if (canFinish) page = WizardPage.SUMMARY
|
||||
}
|
||||
|
||||
/**
|
||||
* Whether the log page may be opened: always once it is part of the run, and otherwise
|
||||
* only if the profile has at most one log source on. The page knows one source; opened
|
||||
* over several it would switch the others off.
|
||||
*/
|
||||
val logPageEditable: Boolean
|
||||
get() = logShown || !integrations.severalStoredLogSources
|
||||
|
||||
/** Opens a step from the summary, also one this run skipped. */
|
||||
fun edit(target: WizardPage) {
|
||||
when (target) {
|
||||
WizardPage.LOGIN -> loginShown = true
|
||||
WizardPage.SITE -> siteShown = true
|
||||
WizardPage.ANTENNA -> antennaShown = true
|
||||
WizardPage.LOG -> if (logPageEditable) logShown = true else return
|
||||
WizardPage.GEAR -> gearShown = true
|
||||
WizardPage.PERSONAL -> Unit
|
||||
WizardPage.ENTRY, WizardPage.SUMMARY -> return
|
||||
}
|
||||
page = target
|
||||
}
|
||||
|
||||
/**
|
||||
* Whether the frequency is taken from a log program after Save, for the summary: the
|
||||
* page's answer once the log page is part of the run, and what the profile holds before.
|
||||
* The two differ where a frequency source is on without its log source, which the
|
||||
* settings window allows and the page cannot show.
|
||||
*/
|
||||
val summaryQrgFollow: Boolean
|
||||
get() = if (logShown) integrations.qrgFollow else integrations.storedQrgFollow
|
||||
|
||||
/** Whether the DX cluster server runs after Save; see [summaryQrgFollow]. */
|
||||
val summaryClusterServer: Boolean
|
||||
get() = if (logShown) integrations.networked && integrations.clusterServer else integrations.storedClusterServer
|
||||
|
||||
/**
|
||||
* The fallback band prefix the profile has after Save, for the summary: taken with the
|
||||
* donor's station when chosen, otherwise left as the own profile holds it.
|
||||
*/
|
||||
val summaryFallbackBand: String
|
||||
get() {
|
||||
val sourcePrefs = stationDonor?.takeIf { stationSource == WizardSource.TAKE }?.prefs ?: ownPrefs
|
||||
return sourcePrefs.getNotify_optionalFrequencyPrefix()?.get().orEmpty()
|
||||
}
|
||||
|
||||
/** Rotator 2 only counts while SO2R uses it, as on the Station tab. */
|
||||
private fun so2rSwitches(prefs: ChatPreferences): Set<WizardSwitch> = buildSet {
|
||||
if (prefs.isTrxSynch_so2rEnabled()) {
|
||||
add(WizardSwitch.SO2R)
|
||||
if (prefs.isStn_pstRotator2Enabled()) add(WizardSwitch.ROTATOR_2)
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* What is on in the own profile and will be off after Save, for the summary. Always
|
||||
* against the own profile: with a station taken from another one, that is what the
|
||||
* operator loses, whatever the other profile had.
|
||||
*
|
||||
* A page that is not part of the run contributes what its profile holds -- the own one
|
||||
* for a station left unchanged, the donor's for a station taken over. The wizard never
|
||||
* writes SO2R or rotator 2 itself, so after Save they come from the donor when taking
|
||||
* over a station, otherwise from the own profile.
|
||||
*/
|
||||
val switchedOff: List<WizardSwitch>
|
||||
get() {
|
||||
val neverAskedPrefs = stationDonor?.takeIf { stationSource == WizardSource.TAKE }?.prefs ?: ownPrefs
|
||||
val after = buildSet {
|
||||
if (secondChat) add(WizardSwitch.SECOND_CHAT)
|
||||
addAll(if (logShown) integrations.answeredLogSwitches() else integrations.storedLogSwitches())
|
||||
addAll(if (gearShown) integrations.answeredGearSwitches() else integrations.storedGearSwitches())
|
||||
addAll(so2rSwitches(neverAskedPrefs))
|
||||
}
|
||||
val before = ownSwitches + so2rSwitches(ownPrefs) +
|
||||
if (ownStation.secondChat) setOf(WizardSwitch.SECOND_CHAT) else emptySet()
|
||||
return WizardSwitch.entries.filter { it in before && it !in after }
|
||||
}
|
||||
|
||||
/**
|
||||
* Puts the answers into [prefs] and writes its file.
|
||||
*
|
||||
* Everything the wizard did not ask about stays as [prefs] read it, because the whole
|
||||
* file is read and written back. The callsign and the locator are stored as typed, the
|
||||
* way the Station tab stores them; only surrounding blanks go.
|
||||
*
|
||||
* The second chat's name follows the first unless the operator had set it apart, and the
|
||||
* second category is left alone while the second chat is off.
|
||||
*
|
||||
* Antenna, log program and equipment are written only for the pages that were part of
|
||||
* this run.
|
||||
*
|
||||
* A station taken from another profile is copied whole before the answers are written.
|
||||
*
|
||||
* @return false when a mandatory answer is missing -- nothing is touched then -- or when
|
||||
* the file could not be written
|
||||
*/
|
||||
fun writeTo(prefs: ChatPreferences): Boolean {
|
||||
if (!mandatoryComplete) return false
|
||||
|
||||
val newName = name.trim()
|
||||
|
||||
prefs.setGuiOptions_language(language)
|
||||
prefs.setStn_loginNameMainCat(newName)
|
||||
if (storedSecondName.isBlank() || storedSecondName == storedName) {
|
||||
prefs.setStn_loginNameSecondCat(newName)
|
||||
}
|
||||
|
||||
prefs.setStn_loginCallSign(callsign.trim())
|
||||
prefs.setStn_loginPassword(password)
|
||||
|
||||
// The whole station of the other profile first, also what no page asks about; the
|
||||
// answers below then lie on top, so a taken value the operator changed wins.
|
||||
if (stationSource == WizardSource.TAKE) {
|
||||
stationDonor?.let { copyStation(it.prefs, prefs) }
|
||||
}
|
||||
|
||||
prefs.setStn_loginLocatorMainCat(locator.trim())
|
||||
WizardBand.entries.forEach { it.setActive(prefs, it in bands) }
|
||||
prefs.setLoginChatCategoryMain(ChatCategory(requireNotNull(category)))
|
||||
prefs.setLoginToSecondChatEnabled(secondChat)
|
||||
if (secondChat) {
|
||||
prefs.setLoginChatCategorySecond(ChatCategory(requireNotNull(secondCategory)))
|
||||
}
|
||||
|
||||
if (antennaShown) antenna.writeTo(prefs)
|
||||
if (logShown) integrations.writeLogTo(prefs)
|
||||
if (gearShown) integrations.writeGearTo(prefs)
|
||||
|
||||
// A write that throws is a write that failed; the wizard must stay open either way.
|
||||
return runCatching { prefs.writePreferencesToXmlFile() }.getOrDefault(false)
|
||||
}
|
||||
|
||||
companion object {
|
||||
|
||||
/** The categories the pickers offer, the way the Station tab builds them. */
|
||||
val CATEGORY_NUMBERS: List<Int> = ChatCategory(0).possibleCategoryNumbers.toList()
|
||||
|
||||
private val CALLSIGN = Regex("[A-Za-z0-9]+([-/][A-Za-z0-9]+)?")
|
||||
private val LOCATOR = Regex("[A-Ra-r]{2}[0-9]{2}[A-Xa-x]{2}")
|
||||
|
||||
/**
|
||||
* Whether a text can be a login callsign: letters and digits, at most one "-" or "/"
|
||||
* suffix, and a base of three characters with a letter and a digit. Deliberately
|
||||
* loose -- ON4KST decides what it accepts, this only catches a slip.
|
||||
*/
|
||||
fun isPlausibleCallsign(text: String): Boolean {
|
||||
val trimmed = text.trim()
|
||||
if (!CALLSIGN.matches(trimmed)) return false
|
||||
val base = trimmed.substringBefore('-').substringBefore('/')
|
||||
return base.length >= 3 && base.any(Char::isDigit) && base.any(Char::isLetter)
|
||||
}
|
||||
|
||||
/** Whether a text is a six-character Maidenhead locator, in either case. */
|
||||
fun isLocator(text: String): Boolean = LOCATOR.matches(text.trim())
|
||||
|
||||
/**
|
||||
* Whether a password can be stored in preferences.xml and sent in an ON4KST login frame:
|
||||
* not blank, free of surrounding whitespace (which the XML reader trims), and free of
|
||||
* frame delimiters.
|
||||
*/
|
||||
fun isStorablePassword(text: String): Boolean =
|
||||
text.isNotBlank() && text == text.trim() && '|' !in text && '\r' !in text && '\n' !in text
|
||||
|
||||
/**
|
||||
* Whether a chat display name can be sent in an ON4KST frame: not blank and free of
|
||||
* frame delimiters.
|
||||
*/
|
||||
fun isStorableName(text: String): Boolean =
|
||||
text.isNotBlank() && '|' !in text && '\r' !in text && '\n' !in text
|
||||
|
||||
/**
|
||||
* The chat category the lowest band belongs to: 1 for 50/70 MHz, 2 for 144/432 MHz,
|
||||
* 3 above. Null without a band. A suggestion only -- the operator confirms it.
|
||||
*/
|
||||
fun suggestCategory(bands: Set<WizardBand>): Int? {
|
||||
val lowest = bands.minOfOrNull { it.megahertz } ?: return null
|
||||
return when {
|
||||
lowest <= 70 -> ChatCategory.FIFTYSEVENTYMHz
|
||||
lowest <= 432 -> ChatCategory.VUHF
|
||||
else -> ChatCategory.MICROWAVE
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,243 @@
|
||||
package kst4contest.view.compose.wizard
|
||||
|
||||
import androidx.compose.runtime.CompositionLocalProvider
|
||||
import androidx.compose.runtime.getValue
|
||||
import androidx.compose.runtime.mutableStateOf
|
||||
import androidx.compose.runtime.setValue
|
||||
import androidx.compose.ui.awt.ComposeDialog
|
||||
import kst4contest.ApplicationConstants
|
||||
import kst4contest.controller.LoginConfiguration
|
||||
import kst4contest.controller.OperatorProfilePaths
|
||||
import kst4contest.controller.OperatorProfileStore
|
||||
import kst4contest.model.ChatPreferences
|
||||
import kst4contest.utils.ApplicationFileUtils
|
||||
import kst4contest.view.compose.Kst4ContestTheme
|
||||
import kst4contest.view.compose.WindowPlacementOnScreen
|
||||
import kst4contest.view.compose.openOnEventThread
|
||||
import kst4contest.view.compose.tabs.LocalFileDialogOwner
|
||||
import java.awt.Dialog
|
||||
import java.awt.Dimension
|
||||
import java.nio.file.Files
|
||||
import java.nio.file.Path
|
||||
import java.util.concurrent.atomic.AtomicReference
|
||||
import javax.swing.WindowConstants
|
||||
|
||||
/** How a run of the setup wizard ended. */
|
||||
enum class SetupWizardOutcome {
|
||||
/** The profile is set up, or its file could not be read: the wizard did not open. */
|
||||
NOT_SHOWN,
|
||||
|
||||
/** Closed without saving; the file is as it was. */
|
||||
LATER,
|
||||
|
||||
/** The answers are in the file. */
|
||||
SAVED,
|
||||
|
||||
/** The answers are in the file and the operator wants the session started. */
|
||||
SAVED_AND_CONNECT,
|
||||
}
|
||||
|
||||
/**
|
||||
* Writes the answers and says how the wizard ends.
|
||||
*
|
||||
* @return the outcome to close with, or null when the file could not be written -- the
|
||||
* wizard then stays open, because "saved" would be a lie
|
||||
*/
|
||||
internal fun saveFromWizard(
|
||||
state: SetupWizardState,
|
||||
prefs: ChatPreferences,
|
||||
connect: Boolean,
|
||||
): SetupWizardOutcome? =
|
||||
when {
|
||||
!state.writeTo(prefs) -> null
|
||||
connect -> SetupWizardOutcome.SAVED_AND_CONNECT
|
||||
else -> SetupWizardOutcome.SAVED
|
||||
}
|
||||
|
||||
/**
|
||||
* The setup wizard's window.
|
||||
*
|
||||
* A modal [ComposeDialog] opened through [openOnEventThread], the construction
|
||||
* OperatorProfilePickerWindow uses and for the reason given there: a wait that does not
|
||||
* pump events deadlocks once the caller is the event thread, and this one is called from
|
||||
* `main` at startup and from the event thread when the menu rebuilds the runtime.
|
||||
*/
|
||||
object SetupWizardWindow {
|
||||
|
||||
/** Runs before a profile's runtime exists, so there is no configured size to read. */
|
||||
private const val DIALOG_FONT_SIZE_SP = 12f
|
||||
|
||||
private val DIALOG_SIZE = Dimension(640, 620)
|
||||
|
||||
/**
|
||||
* Opens the wizard and blocks until it is closed.
|
||||
*
|
||||
* @param prefs the profile's preferences; written only by Save
|
||||
* @return never [SetupWizardOutcome.NOT_SHOWN]
|
||||
*/
|
||||
fun show(state: SetupWizardState, prefs: ChatPreferences): SetupWizardOutcome {
|
||||
/* The window's X leaves this untouched: closing is "later". */
|
||||
val outcome = AtomicReference(SetupWizardOutcome.LATER)
|
||||
|
||||
openOnEventThread { open(state, prefs, outcome) }
|
||||
|
||||
return outcome.get()
|
||||
}
|
||||
|
||||
private fun open(
|
||||
state: SetupWizardState,
|
||||
prefs: ChatPreferences,
|
||||
outcome: AtomicReference<SetupWizardOutcome>,
|
||||
) {
|
||||
val languageStore = wizardLanguageStore(state)
|
||||
var saveFailed by mutableStateOf(false)
|
||||
|
||||
val dialog = ComposeDialog(owner = null, modalityType = Dialog.ModalityType.APPLICATION_MODAL)
|
||||
dialog.title = languageStore.strings.wizardTitle
|
||||
dialog.size = DIALOG_SIZE
|
||||
WindowPlacementOnScreen.centreOnMainWindowScreen(dialog)
|
||||
/* Disposed and not hidden: a hidden dialog keeps its window and Skia layer alive. */
|
||||
dialog.defaultCloseOperation = WindowConstants.DISPOSE_ON_CLOSE
|
||||
|
||||
dialog.setContent {
|
||||
Kst4ContestTheme(
|
||||
darkMode = prefs.isGUI_darkModeActiveByDefault(),
|
||||
baseFontSizeSp = DIALOG_FONT_SIZE_SP,
|
||||
) {
|
||||
CompositionLocalProvider(LocalFileDialogOwner provides dialog) {
|
||||
SetupWizardContent(
|
||||
state = state,
|
||||
languageStore = languageStore,
|
||||
saveFailed = saveFailed,
|
||||
onLater = { dialog.dispose() },
|
||||
onSave = { connect ->
|
||||
val saved = saveFromWizard(state, prefs, connect)
|
||||
if (saved == null) {
|
||||
saveFailed = true
|
||||
} else {
|
||||
outcome.set(saved)
|
||||
dialog.dispose()
|
||||
}
|
||||
},
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
dialog.isVisible = true
|
||||
}
|
||||
}
|
||||
|
||||
/** Another profile that might serve as a donor: who it is and where its preferences lie. */
|
||||
internal class DonorCandidate(val profileId: String, val displayName: String, val file: Path)
|
||||
|
||||
/**
|
||||
* Reads the candidates that can serve as donors: the file exists, can be read, and holds a
|
||||
* login an operator entered. A candidate whose file is the same file as [activeFile] (for
|
||||
* example through a symbolic link) is skipped so a profile never becomes its own donor.
|
||||
*
|
||||
* A candidate's file is opened through `ChatPreferences(Path)` and never through the
|
||||
* constructor that takes a name below the application directory: that one seeds a missing
|
||||
* file from the bundled template, and looking for a donor must not create a profile's file.
|
||||
* Nothing here writes.
|
||||
*/
|
||||
internal fun loadDonors(
|
||||
candidates: List<DonorCandidate>,
|
||||
activeFile: Path? = null,
|
||||
): List<WizardDonor> =
|
||||
candidates.mapNotNull { candidate ->
|
||||
if (!Files.isRegularFile(candidate.file)) return@mapNotNull null
|
||||
if (activeFile != null && Files.exists(activeFile) &&
|
||||
runCatching { Files.isSameFile(candidate.file, activeFile) }.getOrDefault(false)
|
||||
) {
|
||||
return@mapNotNull null
|
||||
}
|
||||
|
||||
val prefs = ChatPreferences(candidate.file)
|
||||
// A throwing read counts as failed, as for the profile being set up.
|
||||
if (!runCatching { prefs.readPreferencesFromXmlFile() }.getOrDefault(false)) return@mapNotNull null
|
||||
if (LoginConfiguration.isUnconfigured(prefs)) return@mapNotNull null
|
||||
|
||||
WizardDonor(candidate.profileId, candidate.displayName, prefs)
|
||||
}
|
||||
|
||||
/** Decides whether the wizard opens for a profile, and opens it. */
|
||||
object SetupWizardLauncher {
|
||||
|
||||
/**
|
||||
* Opens the wizard when the profile needs it, before the profile's runtime is built.
|
||||
*
|
||||
* @param preferencesRelativeFileName the profile's preferences file below the
|
||||
* application directory; a missing one is seeded from the bundled template, as
|
||||
* the runtime itself would do
|
||||
* @param forced the operator asked for the wizard from the menu
|
||||
*/
|
||||
@JvmStatic
|
||||
fun runIfNeeded(preferencesRelativeFileName: String, forced: Boolean): SetupWizardOutcome =
|
||||
run(
|
||||
ChatPreferences(preferencesRelativeFileName),
|
||||
forced,
|
||||
{
|
||||
loadDonors(
|
||||
otherProfiles(preferencesRelativeFileName),
|
||||
activeFile = Path.of(
|
||||
ApplicationFileUtils.getFilePath(
|
||||
ApplicationConstants.APPLICATION_NAME,
|
||||
preferencesRelativeFileName,
|
||||
)
|
||||
),
|
||||
)
|
||||
},
|
||||
SetupWizardWindow::show,
|
||||
)
|
||||
|
||||
/**
|
||||
* Every registered profile but the one being set up, with the file its preferences lie
|
||||
* in. Empty on an installation without a profile registry: there is only the root
|
||||
* profile then, and it is the active one.
|
||||
*/
|
||||
private fun otherProfiles(activeRelativeFileName: String): List<DonorCandidate> =
|
||||
OperatorProfileStore().loadProfiles().mapNotNull { profile ->
|
||||
val relativeFileName = OperatorProfilePaths.preferencesRelativeFileName(profile)
|
||||
if (relativeFileName == activeRelativeFileName) return@mapNotNull null
|
||||
|
||||
DonorCandidate(
|
||||
profile.profileId,
|
||||
profile.displayName,
|
||||
Path.of(ApplicationFileUtils.getFilePath(ApplicationConstants.APPLICATION_NAME, relativeFileName)),
|
||||
)
|
||||
}
|
||||
|
||||
/** Without other profiles; for callers and tests that have none. */
|
||||
internal fun run(
|
||||
prefs: ChatPreferences,
|
||||
forced: Boolean,
|
||||
show: (SetupWizardState, ChatPreferences) -> SetupWizardOutcome,
|
||||
): SetupWizardOutcome = run(prefs, forced, { emptyList() }, show)
|
||||
|
||||
/**
|
||||
* @param prefs bound to the profile's file and not read yet
|
||||
* @param donors reads the other profiles; called only once the wizard is certain to
|
||||
* open, so an ordinary start reads no file but its own
|
||||
* @param show opens the window; replaced in the tests
|
||||
*/
|
||||
internal fun run(
|
||||
prefs: ChatPreferences,
|
||||
forced: Boolean,
|
||||
donors: () -> List<WizardDonor>,
|
||||
show: (SetupWizardState, ChatPreferences) -> SetupWizardOutcome,
|
||||
): SetupWizardOutcome {
|
||||
/*
|
||||
* A file that cannot be read is not a profile to set up: the wizard would start from
|
||||
* compiled-in defaults and Save would write them over whatever the file holds. The
|
||||
* runtime deals with such a file as it always did. A throwing read counts as failed too.
|
||||
*/
|
||||
if (!runCatching { prefs.readPreferencesFromXmlFile() }.getOrDefault(false)) {
|
||||
return SetupWizardOutcome.NOT_SHOWN
|
||||
}
|
||||
|
||||
if (!forced && !LoginConfiguration.isUnconfigured(prefs)) return SetupWizardOutcome.NOT_SHOWN
|
||||
|
||||
return show(SetupWizardState(prefs, donors()), prefs)
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,80 @@
|
||||
package kst4contest.view.compose.wizard
|
||||
|
||||
import androidx.compose.runtime.getValue
|
||||
import androidx.compose.runtime.mutableStateOf
|
||||
import androidx.compose.runtime.setValue
|
||||
import kst4contest.model.ChatPreferences
|
||||
import kst4contest.view.compose.tabs.StationTabState
|
||||
|
||||
/**
|
||||
* The setup wizard's answers about antenna and power.
|
||||
*
|
||||
* These numbers have no empty state: every answer starts as the stored value and is a
|
||||
* proposal the operator may pass unchanged, also when a station is set up anew. They feed the
|
||||
* path analysis and the antenna sector on the map; the chat does not need them.
|
||||
*
|
||||
* The site elevation is the exception in form, not in rule: it is text, because empty is a
|
||||
* value of its own -- "let the elevation model decide" -- and it is read exactly as the
|
||||
* Station tab reads it.
|
||||
*
|
||||
* @param prefs the profile's preferences, already read from its file
|
||||
*/
|
||||
class WizardAntenna(prefs: ChatPreferences) {
|
||||
|
||||
private val storedBeamWidthDeg = prefs.getStn_antennaBeamWidthDeg()
|
||||
private val storedGainDbi = prefs.getStn_pathAnalysisOwnAntennaGainDbi()
|
||||
// The XML reader assigns the field directly without clamping, whereas the setter and path analysis treat < 0 as 0.
|
||||
private val storedHeightMeters = prefs.getStn_pathAnalysisOwnAntennaHeightMeters().coerceAtLeast(0.0)
|
||||
private val storedTxPowerWatts = prefs.getStn_pathAnalysisOwnTxPowerWatts()
|
||||
private val storedHeightAslText = elevationText(prefs.getStn_pathAnalysisOwnHeightAslMeters())
|
||||
|
||||
var beamWidthDeg: Double by mutableStateOf(storedBeamWidthDeg)
|
||||
var gainDbi: Double by mutableStateOf(storedGainDbi)
|
||||
var heightMeters: Double by mutableStateOf(storedHeightMeters)
|
||||
var txPowerWatts: Double by mutableStateOf(storedTxPowerWatts)
|
||||
|
||||
/** The site elevation above sea level as the operator types it; empty for the model. */
|
||||
var heightAslText: String by mutableStateOf(storedHeightAslText)
|
||||
|
||||
/**
|
||||
* Puts every answer back to what the profile holds. For the moment the operator changes
|
||||
* his mind about where the station comes from: what he typed for one choice must not
|
||||
* show in the summary of the other, where it would not be written.
|
||||
*/
|
||||
fun loadStored() {
|
||||
beamWidthDeg = storedBeamWidthDeg
|
||||
gainDbi = storedGainDbi
|
||||
heightMeters = storedHeightMeters
|
||||
txPowerWatts = storedTxPowerWatts
|
||||
heightAslText = storedHeightAslText
|
||||
}
|
||||
|
||||
/** A site elevation that is neither empty nor a number in the accepted range. */
|
||||
val heightAslRefused: Boolean
|
||||
get() = StationTabState.parseOwnHeightAsl(heightAslText) == null
|
||||
|
||||
/** Whether every answer can be stored as it stands. */
|
||||
val complete: Boolean
|
||||
get() = beamWidthDeg.isFinite() && gainDbi.isFinite() && heightMeters.isFinite() &&
|
||||
heightMeters >= 0.0 && txPowerWatts.isFinite() && !heightAslRefused
|
||||
|
||||
/** Puts the answers into [prefs]. Call only while [complete]. */
|
||||
fun writeTo(prefs: ChatPreferences) {
|
||||
prefs.setStn_antennaBeamWidthDeg(beamWidthDeg)
|
||||
prefs.setStn_pathAnalysisOwnAntennaGainDbi(gainDbi)
|
||||
prefs.setStn_pathAnalysisOwnAntennaHeightMeters(heightMeters)
|
||||
prefs.setStn_pathAnalysisOwnTxPowerWatts(txPowerWatts)
|
||||
prefs.setStn_pathAnalysisOwnHeightAslMeters(
|
||||
StationTabState.parseOwnHeightAsl(heightAslText) ?: Double.NaN
|
||||
)
|
||||
}
|
||||
|
||||
private companion object {
|
||||
/** Empty for "unset"; a whole number without ".0", so the field shows what one types. */
|
||||
fun elevationText(meters: Double): String = when {
|
||||
meters.isNaN() -> ""
|
||||
meters == Math.floor(meters) && !meters.isInfinite() -> meters.toLong().toString()
|
||||
else -> meters.toString()
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,289 @@
|
||||
package kst4contest.view.compose.wizard
|
||||
|
||||
import androidx.compose.runtime.getValue
|
||||
import androidx.compose.runtime.mutableStateOf
|
||||
import androidx.compose.runtime.setValue
|
||||
import kst4contest.model.ChatPreferences
|
||||
import kst4contest.view.compose.tabs.AirscoutTabState
|
||||
import kst4contest.view.compose.tabs.StationTabState
|
||||
|
||||
/** Where the worked stations come from. The wizard knows one source at a time. */
|
||||
enum class WizardLogProgram {
|
||||
NONE,
|
||||
|
||||
/** The Win-Test network listener. */
|
||||
WINTEST,
|
||||
|
||||
/** UCXLog, DXLog.net, N1MM+ and QARTEST: QSO messages on the shared UDP port. */
|
||||
UDP,
|
||||
|
||||
/** A log file polled for callsigns. */
|
||||
FILE,
|
||||
}
|
||||
|
||||
/** Something that was on in the profile and will be off after Save, for the summary. */
|
||||
enum class WizardSwitch {
|
||||
SECOND_CHAT,
|
||||
LOG_WINTEST,
|
||||
LOG_UDP,
|
||||
LOG_FILE,
|
||||
QRG_FOLLOW,
|
||||
CLUSTER_SERVER,
|
||||
ROTATOR,
|
||||
AIRSCOUT,
|
||||
SO2R,
|
||||
ROTATOR_2,
|
||||
}
|
||||
|
||||
/**
|
||||
* The setup wizard's answers about log program, rotator and AirScout.
|
||||
*
|
||||
* Two pages share this class because they share a rule: a station set up anew gets only what
|
||||
* the operator said yes to. [loadFresh] therefore switches everything off -- the bundled
|
||||
* template has several of these on, which a newcomer without a log program does not know --
|
||||
* while ports, names, host and identifiers stay as stored and are proposals.
|
||||
*
|
||||
* The wizard switches things on and off and takes numbers over. It invents none: no port,
|
||||
* no identifier and no default here differs from what the settings tabs accept.
|
||||
*
|
||||
* The settings window allows several log sources at once and the wizard's question does
|
||||
* not. [severalStoredLogSources] says when the stored profile is such a case, so the caller
|
||||
* can keep the log page shut rather than collapse the sources into one.
|
||||
*
|
||||
* @param prefs the profile's preferences, already read from its file
|
||||
*/
|
||||
class WizardIntegrations(prefs: ChatPreferences) {
|
||||
|
||||
private val storedWintest = prefs.isLogsynch_wintestNetworkListenerEnabled()
|
||||
private val storedUdp = prefs.isLogsynch_ucxUDPWkdCallListenerEnabled()
|
||||
private val storedFile = prefs.isLogsynch_fileBasedWkdCallInterpreterEnabled()
|
||||
private val storedUdpQrg = prefs.isTrxSynch_ucxLogUDPListenerEnabled()
|
||||
private val storedWintestQrg = prefs.isLogsynch_wintestQrgSyncEnabled()
|
||||
private val storedCluster = prefs.isNotify_dxClusterServerEnabled()
|
||||
private val storedRotator = prefs.isStn_pstRotatorEnabled()
|
||||
private val storedAirScout = prefs.isAirScout_asUDPListenerEnabled()
|
||||
|
||||
/** Rotator 2 only counts while SO2R uses it, as on the Station tab. */
|
||||
private val rotatorTwoInUse = prefs.isTrxSynch_so2rEnabled() && prefs.isStn_pstRotator2Enabled()
|
||||
private val rotatorTwoPort = prefs.getStn_pstRotator2Port()
|
||||
|
||||
/** More than one log source is on in the profile; the log page cannot show that. */
|
||||
val severalStoredLogSources: Boolean = listOf(storedWintest, storedUdp, storedFile).count { it } > 1
|
||||
|
||||
var logProgram: WizardLogProgram by mutableStateOf(WizardLogProgram.NONE)
|
||||
private set
|
||||
|
||||
private val storedUdpPort = prefs.getLogsynch_ucxUDPWkdCallListenerPort()
|
||||
private val storedWintestPort = prefs.getLogsynch_wintestNetworkPort()
|
||||
private val storedWintestStationName = prefs.getLogsynch_wintestNetworkStationNameOfKST().orEmpty()
|
||||
private val storedFilePath = prefs.getLogsynch_fileBasedWkdCallInterpreterFileNameReadOnly().orEmpty()
|
||||
private val storedRotatorHost = prefs.getStn_pstRotatorHost().orEmpty()
|
||||
private val storedRotatorPort = prefs.getStn_pstRotatorPort()
|
||||
private val storedAirScoutPort = prefs.getAirScout_asCommunicationPort()
|
||||
private val storedAirScoutServerName = prefs.getAirScout_asServerNameString().orEmpty()
|
||||
private val storedAirScoutClientName = prefs.getAirScout_asClientNameString().orEmpty()
|
||||
|
||||
/**
|
||||
* Whether the profile takes its own frequency from a log program, whichever one. Known
|
||||
* apart from [qrgFollow] because the settings window allows a frequency source without
|
||||
* the matching log source, which the page's single choice cannot show.
|
||||
*/
|
||||
val storedQrgFollow: Boolean = storedUdpQrg || storedWintestQrg
|
||||
|
||||
/** Whether the profile runs the local DX cluster server, with or without a log source. */
|
||||
val storedClusterServer: Boolean = storedCluster
|
||||
|
||||
var udpPort: Int by mutableStateOf(storedUdpPort)
|
||||
var wintestPort: Int by mutableStateOf(storedWintestPort)
|
||||
var wintestStationName: String by mutableStateOf(storedWintestStationName)
|
||||
var filePath: String by mutableStateOf(storedFilePath)
|
||||
|
||||
/** Take the own frequency from the chosen network program. */
|
||||
var qrgFollow: Boolean by mutableStateOf(false)
|
||||
|
||||
/** Pass spots to the log program through the local DX cluster server. */
|
||||
var clusterServer: Boolean by mutableStateOf(false)
|
||||
|
||||
var rotator: Boolean by mutableStateOf(false)
|
||||
var rotatorHost: String by mutableStateOf(storedRotatorHost)
|
||||
var rotatorPort: Int by mutableStateOf(storedRotatorPort)
|
||||
|
||||
var airScout: Boolean by mutableStateOf(false)
|
||||
var airScoutPort: Int by mutableStateOf(storedAirScoutPort)
|
||||
var airScoutServerName: String by mutableStateOf(storedAirScoutServerName)
|
||||
var airScoutClientName: String by mutableStateOf(storedAirScoutClientName)
|
||||
|
||||
init {
|
||||
loadStored()
|
||||
}
|
||||
|
||||
/** The switches as the profile has them. Several sources show as one, the network ones first. */
|
||||
fun loadStored() {
|
||||
logProgram = when {
|
||||
storedWintest -> WizardLogProgram.WINTEST
|
||||
storedUdp -> WizardLogProgram.UDP
|
||||
storedFile -> WizardLogProgram.FILE
|
||||
else -> WizardLogProgram.NONE
|
||||
}
|
||||
qrgFollow = when (logProgram) {
|
||||
WizardLogProgram.WINTEST -> storedWintestQrg
|
||||
WizardLogProgram.UDP -> storedUdpQrg
|
||||
else -> false
|
||||
}
|
||||
clusterServer = networked && storedCluster
|
||||
rotator = storedRotator
|
||||
airScout = storedAirScout
|
||||
loadStoredDetails()
|
||||
}
|
||||
|
||||
/** A station set up anew: every switch off, every number left as a proposal. */
|
||||
fun loadFresh() {
|
||||
logProgram = WizardLogProgram.NONE
|
||||
qrgFollow = false
|
||||
clusterServer = false
|
||||
rotator = false
|
||||
airScout = false
|
||||
loadStoredDetails()
|
||||
}
|
||||
|
||||
/**
|
||||
* Ports, names, host and identifiers back to what the profile holds. Both loads do this:
|
||||
* they run when the operator changes his mind about where the station comes from, and a
|
||||
* number typed under one choice must not turn up under the other.
|
||||
*/
|
||||
private fun loadStoredDetails() {
|
||||
udpPort = storedUdpPort
|
||||
wintestPort = storedWintestPort
|
||||
wintestStationName = storedWintestStationName
|
||||
filePath = storedFilePath
|
||||
rotatorHost = storedRotatorHost
|
||||
rotatorPort = storedRotatorPort
|
||||
airScoutPort = storedAirScoutPort
|
||||
airScoutServerName = storedAirScoutServerName
|
||||
airScoutClientName = storedAirScoutClientName
|
||||
}
|
||||
|
||||
/** Only a network program can deliver a frequency or take spots. */
|
||||
val networked: Boolean
|
||||
get() = logProgram == WizardLogProgram.WINTEST || logProgram == WizardLogProgram.UDP
|
||||
|
||||
fun chooseLogProgram(program: WizardLogProgram) {
|
||||
logProgram = program
|
||||
if (!networked) {
|
||||
qrgFollow = false
|
||||
clusterServer = false
|
||||
}
|
||||
}
|
||||
|
||||
/** Whether what the chosen program needs is there. A program not chosen needs nothing. */
|
||||
val logComplete: Boolean
|
||||
get() = when (logProgram) {
|
||||
WizardLogProgram.NONE -> true
|
||||
WizardLogProgram.WINTEST -> AirscoutTabState.isValidPort(wintestPort) && wintestStationName.isNotBlank()
|
||||
WizardLogProgram.UDP -> AirscoutTabState.isValidPort(udpPort)
|
||||
WizardLogProgram.FILE -> filePath.isNotBlank()
|
||||
}
|
||||
|
||||
/** The same or the next port as rotator 2, which answers on its port + 1. */
|
||||
val rotatorPortClashes: Boolean
|
||||
get() = rotator && rotatorTwoInUse && StationTabState.portsClash(rotatorPort, rotatorTwoPort)
|
||||
|
||||
/** Whether what the switched-on equipment needs is there. */
|
||||
val gearComplete: Boolean
|
||||
get() {
|
||||
val rotatorComplete = !rotator ||
|
||||
(rotatorHost.isNotBlank() && rotatorPort in ROTATOR_PORTS && !rotatorPortClashes)
|
||||
val airScoutComplete = !airScout ||
|
||||
(AirscoutTabState.isValidPort(airScoutPort) &&
|
||||
AirscoutTabState.isValidIdentifier(airScoutServerName) &&
|
||||
AirscoutTabState.isValidIdentifier(airScoutClientName))
|
||||
return rotatorComplete && airScoutComplete
|
||||
}
|
||||
|
||||
/**
|
||||
* Puts the log page's answers into [prefs]: exactly the chosen source on, its details
|
||||
* stored, and the frequency source and the DX cluster server only with a network program.
|
||||
* Details of a program that is not chosen are left as they are. Call only while
|
||||
* [logComplete].
|
||||
*/
|
||||
fun writeLogTo(prefs: ChatPreferences) {
|
||||
prefs.setLogsynch_wintestNetworkListenerEnabled(logProgram == WizardLogProgram.WINTEST)
|
||||
prefs.setLogsynch_ucxUDPWkdCallListenerEnabled(logProgram == WizardLogProgram.UDP)
|
||||
prefs.setLogsynch_fileBasedWkdCallInterpreterEnabled(logProgram == WizardLogProgram.FILE)
|
||||
|
||||
when (logProgram) {
|
||||
WizardLogProgram.WINTEST -> {
|
||||
prefs.setLogsynch_wintestNetworkPort(wintestPort)
|
||||
prefs.setLogsynch_wintestNetworkStationNameOfKST(wintestStationName.trim())
|
||||
}
|
||||
WizardLogProgram.UDP -> prefs.setLogsynch_ucxUDPWkdCallListenerPort(udpPort)
|
||||
WizardLogProgram.FILE -> prefs.setLogsynch_fileBasedWkdCallInterpreterFileNameReadOnly(filePath)
|
||||
WizardLogProgram.NONE -> Unit
|
||||
}
|
||||
|
||||
prefs.setLogsynch_wintestQrgSyncEnabled(logProgram == WizardLogProgram.WINTEST && qrgFollow)
|
||||
prefs.setTrxSynch_ucxLogUDPListenerEnabled(logProgram == WizardLogProgram.UDP && qrgFollow)
|
||||
prefs.setNotify_dxClusterServerEnabled(networked && clusterServer)
|
||||
}
|
||||
|
||||
/**
|
||||
* Puts the equipment page's answers into [prefs]. Host, port and identifiers are stored
|
||||
* only for what is switched on. Call only while [gearComplete].
|
||||
*/
|
||||
fun writeGearTo(prefs: ChatPreferences) {
|
||||
prefs.setStn_pstRotatorEnabled(rotator)
|
||||
if (rotator) {
|
||||
prefs.setStn_pstRotatorHost(rotatorHost.trim())
|
||||
prefs.setStn_pstRotatorPort(rotatorPort)
|
||||
}
|
||||
|
||||
prefs.setAirScout_asUDPListenerEnabled(airScout)
|
||||
if (airScout) {
|
||||
prefs.setAirScout_asCommunicationPort(airScoutPort)
|
||||
prefs.setAirScout_asServerNameString(airScoutServerName.trim())
|
||||
prefs.setAirScout_asClientNameString(airScoutClientName.trim())
|
||||
}
|
||||
}
|
||||
|
||||
/** The log-page switches the profile these answers were built from has on. */
|
||||
fun storedLogSwitches(): Set<WizardSwitch> = buildSet {
|
||||
if (storedWintest) add(WizardSwitch.LOG_WINTEST)
|
||||
if (storedUdp) add(WizardSwitch.LOG_UDP)
|
||||
if (storedFile) add(WizardSwitch.LOG_FILE)
|
||||
if (storedQrgFollow) add(WizardSwitch.QRG_FOLLOW)
|
||||
if (storedCluster) add(WizardSwitch.CLUSTER_SERVER)
|
||||
}
|
||||
|
||||
/** The equipment switches the profile these answers were built from has on. */
|
||||
fun storedGearSwitches(): Set<WizardSwitch> = buildSet {
|
||||
if (storedRotator) add(WizardSwitch.ROTATOR)
|
||||
if (storedAirScout) add(WizardSwitch.AIRSCOUT)
|
||||
}
|
||||
|
||||
/** The log-page switches that are on once [writeLogTo] has run. */
|
||||
fun answeredLogSwitches(): Set<WizardSwitch> = buildSet {
|
||||
when (logProgram) {
|
||||
WizardLogProgram.WINTEST -> add(WizardSwitch.LOG_WINTEST)
|
||||
WizardLogProgram.UDP -> add(WizardSwitch.LOG_UDP)
|
||||
WizardLogProgram.FILE -> add(WizardSwitch.LOG_FILE)
|
||||
WizardLogProgram.NONE -> Unit
|
||||
}
|
||||
if (networked && qrgFollow) add(WizardSwitch.QRG_FOLLOW)
|
||||
if (networked && clusterServer) add(WizardSwitch.CLUSTER_SERVER)
|
||||
}
|
||||
|
||||
/** The equipment switches that are on once [writeGearTo] has run. */
|
||||
fun answeredGearSwitches(): Set<WizardSwitch> = buildSet {
|
||||
if (rotator) add(WizardSwitch.ROTATOR)
|
||||
if (airScout) add(WizardSwitch.AIRSCOUT)
|
||||
}
|
||||
|
||||
private companion object {
|
||||
/**
|
||||
* The ports setStn_pstRotatorPort stores. One short of the full range, because
|
||||
* PSTRotator answers on port + 1; the setter replaces anything else by its factory
|
||||
* default, which would be the wizard inventing a number.
|
||||
*/
|
||||
val ROTATOR_PORTS = 1..65534
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,108 @@
|
||||
package kst4contest.view.compose.wizard
|
||||
|
||||
import kst4contest.model.ChatCategory
|
||||
import kst4contest.model.ChatPreferences
|
||||
|
||||
/**
|
||||
* Copies the station from one profile's preferences to another's.
|
||||
*
|
||||
* "The station" is what hangs on the site and the equipment: locator, bands, chat
|
||||
* categories, antenna and path-analysis values, log program, frequency source, DX cluster
|
||||
* server, rotators, AirScout. It is deliberately more than the setup wizard asks about -- a
|
||||
* further operator at the same station should inherit the second rotator and the Win-Test
|
||||
* station filter too, without ever seeing a question for them.
|
||||
*
|
||||
* It is deliberately not the operator: login, names, language, appearance, layout,
|
||||
* shortcuts, snippets, beacons, automatic answers, sounds, filters. Nor the server address
|
||||
* or the spotter callsign.
|
||||
*
|
||||
* Which setter belongs where is decided line by line in
|
||||
* `src/test/resources/wizard-station-setters.txt` and `wizard-other-setters.txt`; a test
|
||||
* holds this function and those lists together, and fails when ChatPreferences gains a
|
||||
* setter nobody classified.
|
||||
*
|
||||
* Nothing is written to a file here, and [from] is only read.
|
||||
*/
|
||||
internal fun copyStation(from: ChatPreferences, to: ChatPreferences) {
|
||||
// Location, bands and chats. The categories are copied by number: the two profiles
|
||||
// must not share one mutable ChatCategory.
|
||||
to.setStn_loginLocatorMainCat(from.getStn_loginLocatorMainCat())
|
||||
to.setLoginChatCategoryMain(from.getLoginChatCategoryMain()?.let { ChatCategory(it.categoryNumber) })
|
||||
to.setLoginChatCategorySecond(from.getLoginChatCategorySecond()?.let { ChatCategory(it.categoryNumber) })
|
||||
to.setLoginToSecondChatEnabled(from.isLoginToSecondChatEnabled())
|
||||
|
||||
// Bands.
|
||||
to.setStn_bandActive50(from.isStn_bandActive50())
|
||||
to.setStn_bandActive70(from.isStn_bandActive70())
|
||||
to.setStn_bandActive144(from.isStn_bandActive144())
|
||||
to.setStn_bandActive432(from.isStn_bandActive432())
|
||||
to.setStn_bandActive1240(from.isStn_bandActive1240())
|
||||
to.setStn_bandActive2300(from.isStn_bandActive2300())
|
||||
to.setStn_bandActive3400(from.isStn_bandActive3400())
|
||||
to.setStn_bandActive5600(from.isStn_bandActive5600())
|
||||
to.setStn_bandActive10G(from.isStn_bandActive10G())
|
||||
|
||||
// Antenna, defaults and everything the path analysis needs to know about the site.
|
||||
to.setStn_antennaBeamWidthDeg(from.getStn_antennaBeamWidthDeg())
|
||||
to.setStn_qtfDefault(from.getStn_qtfDefault())
|
||||
to.setStn_maxQRBDefault(from.getStn_maxQRBDefault())
|
||||
to.setStn_useQtfFilterDirectionAsAntennaHeading(from.isStn_useQtfFilterDirectionAsAntennaHeading())
|
||||
to.setStn_pathAnalysisOwnAntennaGainDbi(from.getStn_pathAnalysisOwnAntennaGainDbi())
|
||||
to.setStn_pathAnalysisOwnAntennaHeightMeters(from.getStn_pathAnalysisOwnAntennaHeightMeters())
|
||||
to.setStn_pathAnalysisOwnTxPowerWatts(from.getStn_pathAnalysisOwnTxPowerWatts())
|
||||
to.setStn_pathAnalysisOwnHeightAslMeters(from.getStn_pathAnalysisOwnHeightAslMeters())
|
||||
to.setStn_pathAnalysisDefaultTargetAntennaGainDbi(from.getStn_pathAnalysisDefaultTargetAntennaGainDbi())
|
||||
to.setStn_pathAnalysisDefaultTargetAntennaHeightMeters(from.getStn_pathAnalysisDefaultTargetAntennaHeightMeters())
|
||||
to.setStn_pathAnalysisDefaultTargetTxPowerWatts(from.getStn_pathAnalysisDefaultTargetTxPowerWatts())
|
||||
to.setStn_pathAnalysisDxHighestPointInSquare(from.isStn_pathAnalysisDxHighestPointInSquare())
|
||||
to.setStn_pathAnalysisDemRootDirectory(from.getStn_pathAnalysisDemRootDirectory())
|
||||
to.setStn_pathAnalysisDemDatasetId(from.getStn_pathAnalysisDemDatasetId())
|
||||
to.setStn_pathAnalysisVhfFeederLossPerStationDb(from.getStn_pathAnalysisVhfFeederLossPerStationDb())
|
||||
to.setStn_pathAnalysisFeederLossIncreaseDbPer200MHz(from.getStn_pathAnalysisFeederLossIncreaseDbPer200MHz())
|
||||
to.setStn_pathAnalysisMaxEstimatedFeederLossPerStationDb(from.getStn_pathAnalysisMaxEstimatedFeederLossPerStationDb())
|
||||
to.setStn_pathAnalysisRequiredSsbSignalDbm(from.getStn_pathAnalysisRequiredSsbSignalDbm())
|
||||
to.setStn_pathAnalysisRequiredCwSignalDbm(from.getStn_pathAnalysisRequiredCwSignalDbm())
|
||||
to.setStn_pathAnalysisContestMarginDb(from.getStn_pathAnalysisContestMarginDb())
|
||||
|
||||
// Log sources. All of them as they are: a station may run several at once.
|
||||
to.setLogsynch_fileBasedWkdCallInterpreterEnabled(from.isLogsynch_fileBasedWkdCallInterpreterEnabled())
|
||||
to.setLogsynch_fileBasedWkdCallInterpreterFileNameReadOnly(from.getLogsynch_fileBasedWkdCallInterpreterFileNameReadOnly())
|
||||
to.setLogsynch_ucxUDPWkdCallListenerEnabled(from.isLogsynch_ucxUDPWkdCallListenerEnabled())
|
||||
to.setLogsynch_ucxUDPWkdCallListenerPort(from.getLogsynch_ucxUDPWkdCallListenerPort())
|
||||
to.setLogsynch_wintestNetworkListenerEnabled(from.isLogsynch_wintestNetworkListenerEnabled())
|
||||
to.setLogsynch_wintestNetworkPort(from.getLogsynch_wintestNetworkPort())
|
||||
to.setLogsynch_wintestNetworkBroadcastAddress(from.getLogsynch_wintestNetworkBroadcastAddress())
|
||||
to.setLogsynch_wintestNetworkStationNameOfKST(from.getLogsynch_wintestNetworkStationNameOfKST())
|
||||
to.setLogsynch_wintestNetworkStationIDOfKST(from.getLogsynch_wintestNetworkStationIDOfKST())
|
||||
to.setLogsynch_wintestNetworkStationNameOfWintestClient1(from.getLogsynch_wintestNetworkStationNameOfWintestClient1())
|
||||
to.setLogsynch_wintestNetworkStationNameOfWintestClient2(from.getLogsynch_wintestNetworkStationNameOfWintestClient2())
|
||||
to.setLogsynch_wintestNetworkSkedPushEnabled(from.isLogsynch_wintestNetworkSkedPushEnabled())
|
||||
to.setLogsynch_wintestNetworkSimulationEnabled(from.isLogsynch_wintestNetworkSimulationEnabled())
|
||||
to.setLogsynch_wintestSkedMode(from.getLogsynch_wintestSkedMode())
|
||||
|
||||
// Frequency sources, SO2R and the DX cluster server for the log program.
|
||||
to.setLogsynch_wintestQrgSyncEnabled(from.isLogsynch_wintestQrgSyncEnabled())
|
||||
to.setLogsynch_wintestUsePassQrg(from.isLogsynch_wintestUsePassQrg())
|
||||
to.setTrxSynch_ucxLogUDPListenerEnabled(from.isTrxSynch_ucxLogUDPListenerEnabled())
|
||||
to.setTrxSynch_so2rEnabled(from.isTrxSynch_so2rEnabled())
|
||||
to.setNotify_dxClusterServerEnabled(from.isNotify_dxClusterServerEnabled())
|
||||
to.setNotify_dxclusterServerPort(from.getNotify_dxclusterServerPort())
|
||||
// The band a frequency given without one is completed with; it has to fit the bands above.
|
||||
to.setNotify_optionalFrequencyPrefix(from.getNotify_optionalFrequencyPrefix().get())
|
||||
|
||||
// Rotators.
|
||||
to.setStn_pstRotatorEnabled(from.isStn_pstRotatorEnabled())
|
||||
to.setStn_pstRotatorHost(from.getStn_pstRotatorHost())
|
||||
to.setStn_pstRotatorPort(from.getStn_pstRotatorPort())
|
||||
to.setStn_pstRotator2Enabled(from.isStn_pstRotator2Enabled())
|
||||
to.setStn_pstRotator2Host(from.getStn_pstRotator2Host())
|
||||
to.setStn_pstRotator2Port(from.getStn_pstRotator2Port())
|
||||
|
||||
// AirScout.
|
||||
to.setAirScout_asUDPListenerEnabled(from.isAirScout_asUDPListenerEnabled())
|
||||
to.setAirScout_asCommunicationPort(from.getAirScout_asCommunicationPort())
|
||||
to.setAirScout_asServerNameString(from.getAirScout_asServerNameString())
|
||||
to.setAirScout_asClientNameString(from.getAirScout_asClientNameString())
|
||||
to.setAirScout_autoBandSelectionEnabled(from.isAirScout_autoBandSelectionEnabled())
|
||||
to.setAirScout_asBandString(from.getAirScout_asBandString())
|
||||
}
|
||||
+87
@@ -0,0 +1,87 @@
|
||||
package kst4contest.view;
|
||||
|
||||
import kst4contest.controller.ActiveOperatorProfile;
|
||||
import kst4contest.model.OperatorProfile;
|
||||
import kst4contest.model.OperatorProfileSelection;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.assertFalse;
|
||||
import static org.junit.jupiter.api.Assertions.assertTrue;
|
||||
|
||||
/**
|
||||
* The request to show the setup wizard on the next runtime start is honoured exactly once.
|
||||
* A request that stuck would open the wizard on every later profile switch.
|
||||
*/
|
||||
class ApplicationRuntimeLauncherSetupWizardTest {
|
||||
|
||||
@Test
|
||||
void aRequestIsHonouredOnce() {
|
||||
assertFalse(ApplicationRuntimeLauncher.consumeSetupWizardRequest(), "nothing was requested");
|
||||
|
||||
ApplicationRuntimeLauncher.requestSetupWizard();
|
||||
|
||||
assertTrue(ApplicationRuntimeLauncher.consumeSetupWizardRequest());
|
||||
assertFalse(ApplicationRuntimeLauncher.consumeSetupWizardRequest(), "the request must not stick");
|
||||
}
|
||||
|
||||
@Test
|
||||
void switchGuardAllowsOnlyOneSwitchAtATime() {
|
||||
try {
|
||||
assertTrue(ApplicationRuntimeLauncher.beginSwitch());
|
||||
assertFalse(ApplicationRuntimeLauncher.beginSwitch(),
|
||||
"a second switch must be refused while one is in progress");
|
||||
} finally {
|
||||
ApplicationRuntimeLauncher.endSwitch();
|
||||
}
|
||||
|
||||
try {
|
||||
assertTrue(ApplicationRuntimeLauncher.beginSwitch(),
|
||||
"ending the first switch must release the guard");
|
||||
} finally {
|
||||
ApplicationRuntimeLauncher.endSwitch();
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
void aRefusedRerunLeavesTheRequestOfTheRunningSwitchAlone() {
|
||||
OperatorProfileSelection previous = ActiveOperatorProfile.get();
|
||||
OperatorProfile profile = new OperatorProfile("wizard-guard-test", "Wizard Guard Test", false, false);
|
||||
ActiveOperatorProfile.set(new OperatorProfileSelection(profile, "preferences.xml", "worked.db", false));
|
||||
|
||||
// A first rerun is under way: it holds the guard and its request waits for startRuntime.
|
||||
assertTrue(ApplicationRuntimeLauncher.beginSwitch());
|
||||
ApplicationRuntimeLauncher.requestSetupWizard();
|
||||
try {
|
||||
// A second one arrives while the first tears its windows down, and is refused.
|
||||
assertFalse(ApplicationRuntimeLauncher.rerunSetupWizard());
|
||||
|
||||
assertTrue(ApplicationRuntimeLauncher.consumeSetupWizardRequest(),
|
||||
"the refused rerun took the running switch's request with it: that switch "
|
||||
+ "would end the session and then start without the wizard");
|
||||
} finally {
|
||||
ApplicationRuntimeLauncher.endSwitch();
|
||||
ApplicationRuntimeLauncher.consumeSetupWizardRequest();
|
||||
ActiveOperatorProfile.set(previous);
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
void aRefusedRerunLeavesNoRequestOfItsOwn() {
|
||||
OperatorProfileSelection previous = ActiveOperatorProfile.get();
|
||||
OperatorProfile profile = new OperatorProfile("wizard-guard-test", "Wizard Guard Test", false, false);
|
||||
ActiveOperatorProfile.set(new OperatorProfileSelection(profile, "preferences.xml", "worked.db", false));
|
||||
|
||||
// A plain profile switch is under way; nobody asked for the wizard.
|
||||
assertTrue(ApplicationRuntimeLauncher.beginSwitch());
|
||||
try {
|
||||
assertFalse(ApplicationRuntimeLauncher.rerunSetupWizard());
|
||||
|
||||
assertFalse(ApplicationRuntimeLauncher.consumeSetupWizardRequest(),
|
||||
"a refused rerun must not hand its wizard to the switch that refused it");
|
||||
} finally {
|
||||
ApplicationRuntimeLauncher.endSwitch();
|
||||
ApplicationRuntimeLauncher.consumeSetupWizardRequest();
|
||||
ActiveOperatorProfile.set(previous);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,58 @@
|
||||
package kst4contest.view.compose
|
||||
|
||||
import androidx.compose.ui.graphics.Color
|
||||
import org.junit.jupiter.api.Assertions.assertEquals
|
||||
import org.junit.jupiter.api.Assertions.assertFalse
|
||||
import org.junit.jupiter.api.Assertions.assertTrue
|
||||
import org.junit.jupiter.api.Test
|
||||
|
||||
class BeaconStatusColorsTest {
|
||||
private val neutral = Color(0xFF123456)
|
||||
|
||||
@Test
|
||||
fun `active and activity colours are the approved traffic colours`() {
|
||||
assertEquals(
|
||||
ThreadButtonColors(Color(0xFF238636), Color(0xFF56D364), Color.White),
|
||||
beaconThreadButtonColors(ThreadStatusVisualStyle.BEACON_ACTIVE, false, false, neutral),
|
||||
)
|
||||
assertEquals(
|
||||
ThreadButtonColors(Color(0xFFFFB300), Color(0xFFFFE082), Color(0xFF1B1B1B)),
|
||||
beaconThreadButtonColors(ThreadStatusVisualStyle.BEACON_ACTIVE, true, false, neutral),
|
||||
)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `off uses neutral background and theme specific red text`() {
|
||||
assertEquals(Color(0xFFD50000),
|
||||
beaconThreadButtonColors(ThreadStatusVisualStyle.BEACON_OFF, false, false, neutral).text)
|
||||
assertEquals(Color(0xFFFF6B6B),
|
||||
beaconThreadButtonColors(ThreadStatusVisualStyle.BEACON_OFF, false, true, neutral).text)
|
||||
assertEquals(neutral,
|
||||
beaconThreadButtonColors(ThreadStatusVisualStyle.BEACON_OFF, false, true, neutral).background)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `failed stays red even when a highlight is requested`() {
|
||||
val colors = beaconThreadButtonColors(
|
||||
ThreadStatusVisualStyle.BEACON_FAILED,
|
||||
true,
|
||||
false,
|
||||
neutral,
|
||||
)
|
||||
assertEquals(ThreadButtonColors(Color(0xFFD50000), Color(0xFFFF6B6B), Color.White), colors)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `failed suppresses the flash while active status allows it`() {
|
||||
val button = ThreadStatusButton("MyBeacon")
|
||||
button.report("MyBeacon: on", "active", ThreadStatusVisualStyle.BEACON_ACTIVE)
|
||||
assertTrue(button.highlighted)
|
||||
|
||||
button.report("MyBeacon: FAILED", "failed", ThreadStatusVisualStyle.BEACON_FAILED)
|
||||
assertFalse(button.highlighted)
|
||||
assertEquals(
|
||||
ThreadButtonColors(Color(0xFFD50000), Color(0xFFFF6B6B), Color.White),
|
||||
beaconThreadButtonColors(ThreadStatusVisualStyle.BEACON_FAILED, true, false, neutral),
|
||||
)
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,59 @@
|
||||
package kst4contest.view.compose
|
||||
|
||||
import kst4contest.model.BeaconStatusSnapshot
|
||||
import kst4contest.model.BeaconStatusSnapshot.AggregateState
|
||||
import kst4contest.model.BeaconStatusSnapshot.CategoryStatus
|
||||
import kst4contest.model.BeaconStatusSnapshot.InactiveReason
|
||||
import kst4contest.view.i18n.LanguageStore
|
||||
import org.junit.jupiter.api.Assertions.assertEquals
|
||||
import org.junit.jupiter.api.Assertions.assertFalse
|
||||
import org.junit.jupiter.api.Assertions.assertTrue
|
||||
import org.junit.jupiter.api.Test
|
||||
import java.util.Locale
|
||||
|
||||
class BeaconStatusPresentationTest {
|
||||
@Test
|
||||
fun `partial status keeps the inactive category reason in English`() {
|
||||
val presentation = BeaconStatusPresentation.from(snapshot(AggregateState.PARTIAL))
|
||||
|
||||
assertEquals("1/2", presentation.label)
|
||||
assertTrue(presentation.tooltip.contains("Main category: active"))
|
||||
assertTrue(presentation.tooltip.contains("primary QRG missing or invalid"))
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `the same category reasons are available in German`() {
|
||||
val language = LanguageStore({ "de" }, {}, Locale.UK)
|
||||
try {
|
||||
val presentation = BeaconStatusPresentation.from(
|
||||
snapshot(AggregateState.PARTIAL),
|
||||
language.strings,
|
||||
)
|
||||
|
||||
assertTrue(presentation.tooltip.contains("Hauptkategorie: aktiv"))
|
||||
assertTrue(presentation.tooltip.contains("Haupt-QRG fehlt oder ist ungültig"))
|
||||
assertFalse(presentation.tooltip.contains("144."))
|
||||
} finally {
|
||||
language.use("en")
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `failed style overrides an active category`() {
|
||||
val main = CategoryStatus(true, true, true, InactiveReason.USER_DISABLED)
|
||||
val second = CategoryStatus(false, false, false, InactiveReason.NOT_ACTIVATED_THIS_SESSION)
|
||||
val presentation = BeaconStatusPresentation.from(
|
||||
BeaconStatusSnapshot(AggregateState.FAILED, main, second),
|
||||
)
|
||||
|
||||
assertEquals("FAILED", presentation.label)
|
||||
assertEquals(ThreadStatusVisualStyle.BEACON_FAILED, presentation.style)
|
||||
assertTrue(presentation.tooltip.contains("send failed"))
|
||||
}
|
||||
|
||||
private fun snapshot(state: AggregateState): BeaconStatusSnapshot = BeaconStatusSnapshot(
|
||||
state,
|
||||
CategoryStatus(true, true, false, InactiveReason.USER_DISABLED),
|
||||
CategoryStatus(true, false, false, InactiveReason.PRIMARY_QRG_UNAVAILABLE),
|
||||
)
|
||||
}
|
||||
@@ -5,6 +5,7 @@ import androidx.compose.ui.text.input.TextFieldValue
|
||||
import kst4contest.model.ChatCategory
|
||||
import kst4contest.model.ChatMember
|
||||
import kst4contest.model.ChatMessage
|
||||
import kst4contest.controller.RadioSlot
|
||||
import org.junit.jupiter.api.Assertions.assertEquals
|
||||
import org.junit.jupiter.api.Assertions.assertNull
|
||||
import org.junit.jupiter.api.Assertions.assertSame
|
||||
@@ -233,6 +234,20 @@ class ChatInputStateTest {
|
||||
assertEquals("432.200 ", state.value.text)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `manual QRG commits keep their radio source explicit`() {
|
||||
val actions = FakeActions()
|
||||
val state = ChatInputState(actions)
|
||||
|
||||
state.commitOwnQrg(mainCategory = true, "144.300")
|
||||
state.commitOwnQrg(mainCategory = false, "1296.100")
|
||||
|
||||
assertEquals(
|
||||
listOf(RadioSlot.FIRST to "144.300", RadioSlot.SECOND to "1296.100"),
|
||||
actions.manualQrgs,
|
||||
)
|
||||
}
|
||||
|
||||
// ---- the snippets ------------------------------------------------------
|
||||
|
||||
/**
|
||||
@@ -407,6 +422,7 @@ class ChatInputStateTest {
|
||||
val resolvedTemplates = mutableListOf<String>()
|
||||
val recordedCqs = mutableListOf<String>()
|
||||
val recomputeReasons = mutableListOf<String>()
|
||||
val manualQrgs = mutableListOf<Pair<RadioSlot, String>>()
|
||||
|
||||
override fun panelSelection(): ChatMember? = panelSelection
|
||||
override fun tableSelection(): ChatMember? = tableSelection
|
||||
@@ -431,5 +447,6 @@ class ChatInputStateTest {
|
||||
override fun queue(message: ChatMessage) { queued += message }
|
||||
override fun ownQrgMain(): String = ownQrgMain
|
||||
override fun ownQrgSecond(): String = ownQrgSecond
|
||||
override fun applyManualQrg(slot: RadioSlot, value: String) { manualQrgs += slot to value }
|
||||
}
|
||||
}
|
||||
@@ -28,6 +28,7 @@ class MainMenuModelTest {
|
||||
override fun setQrgAsNameInChat() { calls += "setQrgAsNameInChat" }
|
||||
override fun toggleAwayState() { calls += "toggleAwayState" }
|
||||
override fun toggleSettingsWindow() { calls += "toggleSettingsWindow" }
|
||||
override fun openSetupWizard() { calls += "openSetupWizard" }
|
||||
override fun toggleMonitorWindow() { calls += "toggleMonitorWindow" }
|
||||
override fun toggleStationMap() { calls += "toggleStationMap" }
|
||||
override fun useDarkDesign() { calls += "useDarkDesign" }
|
||||
@@ -181,4 +182,19 @@ class MainMenuModelTest {
|
||||
"every item must reach an action; one of them did nothing",
|
||||
)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun theSetupAssistantIsReachableFromOptionsWhateverTheConnection() {
|
||||
for (connectionState in On4KstConnectionState.values()) {
|
||||
val actions = RecordingActions()
|
||||
val model = model(connectionState = connectionState, actions = actions)
|
||||
val entry = items(model.single { it.title == "Options" }).single { it.label == "Setup assistant..." }
|
||||
|
||||
// Like the profile switch: it gives the session up itself, after asking.
|
||||
assertTrue(entry.enabled, "the assistant must be reachable while $connectionState")
|
||||
|
||||
entry.onClick()
|
||||
assertEquals("openSetupWizard", actions.calls.last())
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -55,6 +55,7 @@ class MainMenuRowScreenTest {
|
||||
override fun setQrgAsNameInChat() { calls += "setQrgAsNameInChat" }
|
||||
override fun toggleAwayState() { calls += "toggleAwayState" }
|
||||
override fun toggleSettingsWindow() { calls += "toggleSettingsWindow" }
|
||||
override fun openSetupWizard() { calls += "openSetupWizard" }
|
||||
override fun toggleMonitorWindow() { calls += "toggleMonitorWindow" }
|
||||
override fun toggleStationMap() { calls += "toggleStationMap" }
|
||||
override fun useDarkDesign() { calls += "useDarkDesign" }
|
||||
@@ -116,6 +117,7 @@ class MainMenuRowScreenTest {
|
||||
Triple("Options", "Set QRG as name in Chat (main category)", "setQrgAsNameInChat"),
|
||||
Triple("Options", "Show me as AWAY FROM chat!", "toggleAwayState"),
|
||||
Triple("Options", "Show options", "toggleSettingsWindow"),
|
||||
Triple("Options", "Setup assistant...", "openSetupWizard"),
|
||||
Triple("Windows", "Show cluster / stranger QSOs", "toggleMonitorWindow"),
|
||||
Triple("Windows", "Show / hide station map", "toggleStationMap"),
|
||||
Triple("Windows", "Use dark mode design", "useDarkDesign"),
|
||||
|
||||
@@ -173,13 +173,24 @@ class BeaconTabStateTest(@TempDir private val tempDir: Path) {
|
||||
s.prefs.setBcn_beaconIntervalInMinutesMainCat(5)
|
||||
val state = s.state()
|
||||
|
||||
assertNotNull(state.commitBeaconInterval("0"))
|
||||
assertNotNull(state.commitBeaconInterval("4"))
|
||||
|
||||
assertEquals(5, s.prefs.getBcn_beaconIntervalInMinutesMainCat())
|
||||
assertEquals(0, s.timerRestarts,
|
||||
"restarting the timer per rejected keystroke would disturb the cooldown")
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `exactly five minutes is accepted`() {
|
||||
val s = Session()
|
||||
val state = s.state()
|
||||
|
||||
assertNull(state.commitBeaconInterval("5"))
|
||||
|
||||
assertEquals(5, s.prefs.getBcn_beaconIntervalInMinutesMainCat())
|
||||
assertEquals(5, s.prefs.getBcn_beaconIntervalInMinutesSecondCat())
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `an interval that is not a whole number is refused`() {
|
||||
val s = Session()
|
||||
|
||||
+292
@@ -0,0 +1,292 @@
|
||||
package kst4contest.view.compose.wizard
|
||||
|
||||
import androidx.compose.ui.test.ComposeUiTest
|
||||
import androidx.compose.ui.test.ExperimentalTestApi
|
||||
import androidx.compose.ui.test.hasSetTextAction
|
||||
import androidx.compose.ui.test.onNodeWithText
|
||||
import androidx.compose.ui.test.performClick
|
||||
import androidx.compose.ui.test.performTextReplacement
|
||||
import androidx.compose.ui.test.runComposeUiTest
|
||||
import kst4contest.model.ChatCategory
|
||||
import kst4contest.model.ChatPreferences
|
||||
import kst4contest.view.compose.Kst4ContestTheme
|
||||
import kst4contest.view.i18n.LanguageStore
|
||||
import org.junit.jupiter.api.Assertions.assertEquals
|
||||
import org.junit.jupiter.api.Assertions.assertTrue
|
||||
import org.junit.jupiter.api.Test
|
||||
import java.nio.file.Path
|
||||
import java.util.Locale
|
||||
|
||||
/**
|
||||
* The drawn wizard, clicked the way an operator clicks it. The rules live in
|
||||
* SetupWizardState and are tested there; this holds the wiring -- that a button reaches the
|
||||
* state, and that a button which must not work does not.
|
||||
*/
|
||||
@OptIn(ExperimentalTestApi::class)
|
||||
class SetupWizardContentScreenTest {
|
||||
|
||||
private fun configuredProfile() =
|
||||
ChatPreferences(Path.of("setup-wizard-screen-test-unused.xml")).apply {
|
||||
setStn_loginCallSign("DL0TEST")
|
||||
setStn_loginPassword("secret")
|
||||
setStn_loginNameMainCat("Philipp")
|
||||
setStn_loginLocatorMainCat("JO50AA")
|
||||
setStn_bandActive144(true)
|
||||
setLoginChatCategoryMain(ChatCategory(2))
|
||||
// Stated, not left to the compiled-in default: with a second chat and no second
|
||||
// category the summary could not be saved.
|
||||
setLoginToSecondChatEnabled(false)
|
||||
}
|
||||
|
||||
private class Recorded {
|
||||
var later = 0
|
||||
val saves = mutableListOf<Boolean>()
|
||||
}
|
||||
|
||||
private fun ComposeUiTest.show(state: SetupWizardState, saveFailed: Boolean = false): Recorded {
|
||||
val recorded = Recorded()
|
||||
// English, whatever language an earlier test in this JVM left behind.
|
||||
val english = LanguageStore({ "en" }, {}, Locale.ENGLISH)
|
||||
setContent {
|
||||
Kst4ContestTheme(darkMode = false, baseFontSizeSp = 12f) {
|
||||
SetupWizardContent(
|
||||
state = state,
|
||||
languageStore = english,
|
||||
saveFailed = saveFailed,
|
||||
onLater = { recorded.later++ },
|
||||
onSave = { recorded.saves += it },
|
||||
)
|
||||
}
|
||||
}
|
||||
return recorded
|
||||
}
|
||||
|
||||
@Test
|
||||
fun nextDoesNothingUntilBothSourcesAreChosen() = runComposeUiTest {
|
||||
val state = SetupWizardState(configuredProfile())
|
||||
show(state)
|
||||
|
||||
onNodeWithText("Next").performClick()
|
||||
assertEquals(WizardPage.ENTRY, state.page, "Next worked without a choice")
|
||||
|
||||
onNodeWithText("Leave the login unchanged (DL0TEST)").performClick()
|
||||
onNodeWithText("Leave the station unchanged (locator JO50AA)").performClick()
|
||||
assertEquals(WizardSource.KEEP, state.loginSource)
|
||||
assertEquals(WizardSource.KEEP, state.stationSource)
|
||||
|
||||
onNodeWithText("Next").performClick()
|
||||
assertEquals(WizardPage.PERSONAL, state.page)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun laterIsReportedAndNothingElse() = runComposeUiTest {
|
||||
val recorded = show(SetupWizardState(configuredProfile()))
|
||||
|
||||
onNodeWithText("Later").performClick()
|
||||
|
||||
assertEquals(1, recorded.later)
|
||||
assertTrue(recorded.saves.isEmpty())
|
||||
}
|
||||
|
||||
@Test
|
||||
fun theSummaryOffersBothWaysOfSaving() = runComposeUiTest {
|
||||
val state = SetupWizardState(configuredProfile())
|
||||
state.chooseLoginSource(WizardSource.KEEP)
|
||||
state.chooseStationSource(WizardSource.KEEP)
|
||||
state.next()
|
||||
state.next()
|
||||
val recorded = show(state)
|
||||
|
||||
onNodeWithText("Save").performClick()
|
||||
onNodeWithText("Save and connect").performClick()
|
||||
|
||||
assertEquals(listOf(false, true), recorded.saves)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun aFailedSaveIsToldToTheOperator() = runComposeUiTest {
|
||||
val state = SetupWizardState(configuredProfile())
|
||||
state.chooseLoginSource(WizardSource.KEEP)
|
||||
state.chooseStationSource(WizardSource.KEEP)
|
||||
state.next()
|
||||
state.next()
|
||||
show(state, saveFailed = true)
|
||||
|
||||
onNodeWithText("The settings could not be written. Nothing was changed.").assertExists()
|
||||
}
|
||||
|
||||
@Test
|
||||
fun theSummaryShowsTheChosenLanguage() = runComposeUiTest {
|
||||
val state = SetupWizardState(configuredProfile().apply { setGuiOptions_language("de") })
|
||||
state.chooseLoginSource(WizardSource.KEEP)
|
||||
state.chooseStationSource(WizardSource.KEEP)
|
||||
state.next()
|
||||
state.next()
|
||||
show(state)
|
||||
|
||||
onNodeWithText("DE").assertExists()
|
||||
}
|
||||
|
||||
/** A first installation: the template's credentials, so the wizard starts from scratch. */
|
||||
private fun firstInstallation() =
|
||||
ChatPreferences(Path.of("setup-wizard-screen-test-unused.xml")).apply {
|
||||
setStn_loginCallSign("DO5AMF")
|
||||
setStn_loginPassword("changeMe")
|
||||
setLogsynch_wintestNetworkListenerEnabled(false)
|
||||
setLogsynch_ucxUDPWkdCallListenerEnabled(true)
|
||||
setLogsynch_fileBasedWkdCallInterpreterEnabled(false)
|
||||
// Every other switch stated too, so the summary's wording does not hang on a
|
||||
// compiled-in default.
|
||||
setTrxSynch_ucxLogUDPListenerEnabled(false)
|
||||
setLogsynch_wintestQrgSyncEnabled(false)
|
||||
setNotify_dxClusterServerEnabled(false)
|
||||
setStn_pstRotatorEnabled(false)
|
||||
setAirScout_asUDPListenerEnabled(true)
|
||||
setLoginToSecondChatEnabled(false)
|
||||
}
|
||||
|
||||
private fun SetupWizardState.walkToTheLogPage() {
|
||||
name = "Philipp"
|
||||
next()
|
||||
callsign = "DL0TEST"
|
||||
password = "secret"
|
||||
next()
|
||||
locator = "JO50AA"
|
||||
setBand(WizardBand.B144, true)
|
||||
next()
|
||||
next()
|
||||
}
|
||||
|
||||
@Test
|
||||
fun choosingALogProgramOnTheDrawnPageReachesTheState() = runComposeUiTest {
|
||||
val state = SetupWizardState(firstInstallation())
|
||||
state.walkToTheLogPage()
|
||||
assertEquals(WizardPage.LOG, state.page)
|
||||
show(state)
|
||||
|
||||
onNodeWithText("Win-Test").performClick()
|
||||
|
||||
assertEquals(WizardLogProgram.WINTEST, state.integrations.logProgram)
|
||||
onNodeWithText("Take my own frequency from the log program").assertExists()
|
||||
}
|
||||
|
||||
@Test
|
||||
fun nextRefusesAnUnreadableUdpPortAndAcceptsItsCorrection() = runComposeUiTest {
|
||||
val state = SetupWizardState(firstInstallation())
|
||||
state.walkToTheLogPage()
|
||||
state.integrations.chooseLogProgram(WizardLogProgram.UDP)
|
||||
val originalPort = state.integrations.udpPort
|
||||
show(state)
|
||||
|
||||
val portField = onNode(hasSetTextAction())
|
||||
val refusal = onNodeWithText(
|
||||
"Shared UDP port for QSO and TRX messages [default 12060]:: \"abc\" is not a valid entry.",
|
||||
)
|
||||
portField.performTextReplacement("abc")
|
||||
onNodeWithText("Next").performClick()
|
||||
|
||||
assertEquals(originalPort, state.integrations.udpPort)
|
||||
assertEquals(WizardPage.LOG, state.page)
|
||||
refusal.assertExists()
|
||||
|
||||
portField.performTextReplacement("12061")
|
||||
refusal.assertExists()
|
||||
onNodeWithText("Next").performClick()
|
||||
|
||||
assertEquals(WizardPage.GEAR, state.page)
|
||||
assertEquals(12061, state.integrations.udpPort)
|
||||
refusal.assertDoesNotExist()
|
||||
}
|
||||
|
||||
@Test
|
||||
fun finishRefusesAnUnreadableUdpPort() = runComposeUiTest {
|
||||
val state = SetupWizardState(firstInstallation())
|
||||
state.walkToTheLogPage()
|
||||
state.integrations.chooseLogProgram(WizardLogProgram.UDP)
|
||||
show(state)
|
||||
|
||||
onNode(hasSetTextAction()).performTextReplacement("abc")
|
||||
onNodeWithText("Finish").performClick()
|
||||
|
||||
assertEquals(WizardPage.LOG, state.page)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun theSummaryNamesWhatANewStationSwitchesOff() = runComposeUiTest {
|
||||
val state = SetupWizardState(firstInstallation())
|
||||
state.walkToTheLogPage()
|
||||
state.finish()
|
||||
show(state)
|
||||
|
||||
onNodeWithText("Will be switched off: network log synchronisation, AirScout.").assertExists()
|
||||
}
|
||||
|
||||
private fun donor(id: String, name: String, callsign: String, locator: String) =
|
||||
WizardDonor(id, name, ChatPreferences(Path.of("setup-wizard-screen-donor-unused.xml")).apply {
|
||||
setStn_loginCallSign(callsign)
|
||||
setStn_loginPassword("secret")
|
||||
setStn_loginLocatorMainCat(locator)
|
||||
setStn_bandActive144(true)
|
||||
setLoginChatCategoryMain(ChatCategory(2))
|
||||
setLoginToSecondChatEnabled(false)
|
||||
})
|
||||
|
||||
private fun emptyProfile() =
|
||||
ChatPreferences(Path.of("setup-wizard-screen-test-unused.xml")).apply {
|
||||
setStn_loginCallSign("")
|
||||
setStn_loginPassword("")
|
||||
setStn_loginLocatorMainCat("JO54ME")
|
||||
setStn_bandActive144(true)
|
||||
setLoginChatCategoryMain(ChatCategory(2))
|
||||
setLoginToSecondChatEnabled(false)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun aSingleDonorIsNamedInTheOptionAndTakenWithOneClick() = runComposeUiTest {
|
||||
val state = SetupWizardState(emptyProfile(), listOf(donor("a", "Conteststation", "DL0TEST", "JO50AA")))
|
||||
show(state)
|
||||
|
||||
onNodeWithText("Take the login from profile \"Conteststation\" (DL0TEST)").performClick()
|
||||
onNodeWithText("Take the station from profile \"Conteststation\" (locator JO50AA)").performClick()
|
||||
|
||||
assertEquals(WizardSource.TAKE, state.loginSource)
|
||||
assertEquals("a", state.loginDonor?.profileId)
|
||||
assertEquals(WizardSource.TAKE, state.stationSource)
|
||||
|
||||
onNodeWithText("Next").performClick()
|
||||
assertEquals(WizardPage.PERSONAL, state.page)
|
||||
assertEquals("DL0TEST", state.callsign)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun withSeveralDonorsNextWaitsForAProfile() = runComposeUiTest {
|
||||
val state = SetupWizardState(
|
||||
emptyProfile(),
|
||||
listOf(donor("a", "Conteststation", "DL0TEST", "JO50AA"), donor("b", "Portabel", "DL0TEST/P", "JN58QA")),
|
||||
)
|
||||
show(state)
|
||||
|
||||
onNodeWithText("Take the login from another profile").performClick()
|
||||
onNodeWithText("Set up a new station").performClick()
|
||||
onNodeWithText("Next").performClick()
|
||||
|
||||
assertEquals(WizardPage.ENTRY, state.page, "which profile is not said yet")
|
||||
}
|
||||
|
||||
@Test
|
||||
fun theSummaryShowsTheFallbackBandForSpots() = runComposeUiTest {
|
||||
val prefs = configuredProfile().apply {
|
||||
setStn_bandActive144(false)
|
||||
setStn_bandActive432(true)
|
||||
setNotify_optionalFrequencyPrefix("144")
|
||||
}
|
||||
val state = SetupWizardState(prefs)
|
||||
state.chooseLoginSource(WizardSource.KEEP)
|
||||
state.chooseStationSource(WizardSource.KEEP)
|
||||
state.next()
|
||||
state.next()
|
||||
show(state)
|
||||
|
||||
onNodeWithText("144 MHz").assertExists()
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,446 @@
|
||||
package kst4contest.view.compose.wizard
|
||||
|
||||
import kst4contest.model.ChatCategory
|
||||
import kst4contest.model.ChatPreferences
|
||||
import org.junit.jupiter.api.Assertions.assertArrayEquals
|
||||
import org.junit.jupiter.api.Assertions.assertEquals
|
||||
import org.junit.jupiter.api.Assertions.assertFalse
|
||||
import org.junit.jupiter.api.Assertions.assertNull
|
||||
import org.junit.jupiter.api.Assertions.assertTrue
|
||||
import org.junit.jupiter.api.Test
|
||||
import org.junit.jupiter.api.io.TempDir
|
||||
import java.nio.file.Files
|
||||
import java.nio.file.Path
|
||||
import java.nio.file.StandardCopyOption
|
||||
|
||||
/**
|
||||
* Taking the login or the station from another profile: what is offered, what the answers
|
||||
* become, what the summary says against the own profile, and what reaches the file.
|
||||
*/
|
||||
class SetupWizardDonorTest(@param:TempDir private val directory: Path) {
|
||||
|
||||
private fun prefs(configure: ChatPreferences.() -> Unit = {}): ChatPreferences =
|
||||
ChatPreferences(Path.of("setup-wizard-donor-test-unused.xml")).apply(configure)
|
||||
|
||||
/** Every integration switch stated, so no test hangs on a compiled-in default. */
|
||||
private fun ChatPreferences.integrationsOff() {
|
||||
setLogsynch_wintestNetworkListenerEnabled(false)
|
||||
setLogsynch_ucxUDPWkdCallListenerEnabled(false)
|
||||
setLogsynch_fileBasedWkdCallInterpreterEnabled(false)
|
||||
setTrxSynch_ucxLogUDPListenerEnabled(false)
|
||||
setLogsynch_wintestQrgSyncEnabled(false)
|
||||
setNotify_dxClusterServerEnabled(false)
|
||||
setStn_pstRotatorEnabled(false)
|
||||
setAirScout_asUDPListenerEnabled(false)
|
||||
setTrxSynch_so2rEnabled(false)
|
||||
setStn_pstRotator2Enabled(false)
|
||||
}
|
||||
|
||||
/** An empty profile, as "new profile" creates it: no login, the template's integrations on. */
|
||||
private fun emptyProfile() = prefs {
|
||||
integrationsOff()
|
||||
setStn_loginCallSign("")
|
||||
setStn_loginPassword("")
|
||||
setStn_loginLocatorMainCat("JO54ME")
|
||||
setStn_bandActive144(true)
|
||||
setLoginChatCategoryMain(ChatCategory(2))
|
||||
setLoginToSecondChatEnabled(true)
|
||||
setLoginChatCategorySecond(ChatCategory(3))
|
||||
setLogsynch_ucxUDPWkdCallListenerEnabled(true)
|
||||
setAirScout_asUDPListenerEnabled(true)
|
||||
}
|
||||
|
||||
private fun contestStation() = WizardDonor("contest", "Conteststation", prefs {
|
||||
integrationsOff()
|
||||
setStn_loginCallSign("DL0TEST")
|
||||
setStn_loginPassword("secret")
|
||||
setStn_loginLocatorMainCat("JO50AA")
|
||||
setStn_bandActive144(true)
|
||||
setStn_bandActive432(true)
|
||||
setLoginChatCategoryMain(ChatCategory(2))
|
||||
setLoginToSecondChatEnabled(false)
|
||||
setStn_antennaBeamWidthDeg(28.0)
|
||||
setStn_qtfDefault(270.0)
|
||||
setLogsynch_wintestNetworkListenerEnabled(true)
|
||||
setLogsynch_wintestNetworkPort(9871)
|
||||
setLogsynch_wintestNetworkStationNameOfKST("KST")
|
||||
setLogsynch_wintestQrgSyncEnabled(true)
|
||||
setStn_pstRotatorEnabled(true)
|
||||
setStn_pstRotatorHost("127.0.0.1")
|
||||
setStn_pstRotatorPort(12000)
|
||||
})
|
||||
|
||||
private fun portable() = WizardDonor("portable", "Portabel", prefs {
|
||||
integrationsOff()
|
||||
setStn_loginCallSign("DL0TEST/P")
|
||||
setStn_loginPassword("secret")
|
||||
setStn_loginLocatorMainCat("JN58QA")
|
||||
setStn_bandActive1240(true)
|
||||
setLoginChatCategoryMain(ChatCategory(3))
|
||||
setLoginToSecondChatEnabled(false)
|
||||
})
|
||||
|
||||
@Test
|
||||
fun withoutDonorsNothingChanges() {
|
||||
val state = SetupWizardState(emptyProfile())
|
||||
|
||||
assertEquals(listOf(WizardSource.NEW), state.loginSources)
|
||||
assertEquals(listOf(WizardSource.NEW, WizardSource.KEEP), state.stationSources)
|
||||
assertTrue(state.donors.isEmpty())
|
||||
}
|
||||
|
||||
@Test
|
||||
fun aDonorAddsTakeBetweenNewAndKeep() {
|
||||
val state = SetupWizardState(emptyProfile(), listOf(contestStation()))
|
||||
|
||||
assertEquals(listOf(WizardSource.NEW, WizardSource.TAKE), state.loginSources)
|
||||
assertEquals(listOf(WizardSource.NEW, WizardSource.TAKE, WizardSource.KEEP), state.stationSources)
|
||||
assertTrue(state.hasEntryPage)
|
||||
assertNull(state.loginSource, "with a choice nothing is preselected")
|
||||
}
|
||||
|
||||
@Test
|
||||
fun aSingleDonorIsChosenWithTheSource() {
|
||||
val donor = contestStation()
|
||||
val state = SetupWizardState(emptyProfile(), listOf(donor))
|
||||
|
||||
state.chooseLoginSource(WizardSource.TAKE)
|
||||
state.chooseStationSource(WizardSource.NEW)
|
||||
|
||||
assertEquals(donor, state.loginDonor, "one donor needs no second question")
|
||||
assertTrue(state.canGoNext)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun severalDonorsNeedAChoice() {
|
||||
val contest = contestStation()
|
||||
val state = SetupWizardState(emptyProfile(), listOf(contest, portable()))
|
||||
|
||||
state.chooseLoginSource(WizardSource.TAKE)
|
||||
state.chooseStationSource(WizardSource.NEW)
|
||||
assertNull(state.loginDonor)
|
||||
assertFalse(state.canGoNext, "which profile is not said yet")
|
||||
|
||||
state.chooseLoginDonor(contest)
|
||||
assertTrue(state.canGoNext)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun aDonorThatIsNotOfferedIsNotAccepted() {
|
||||
val state = SetupWizardState(emptyProfile(), listOf(contestStation()))
|
||||
state.chooseLoginSource(WizardSource.TAKE)
|
||||
val first = state.loginDonor
|
||||
|
||||
state.chooseLoginDonor(portable())
|
||||
|
||||
assertEquals(first, state.loginDonor)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun takingTheLoginSkipsItsPageAndLeavesItChangeable() {
|
||||
val state = SetupWizardState(emptyProfile(), listOf(contestStation()))
|
||||
state.chooseLoginSource(WizardSource.TAKE)
|
||||
state.chooseStationSource(WizardSource.KEEP)
|
||||
state.next()
|
||||
|
||||
assertEquals("DL0TEST", state.callsign)
|
||||
assertEquals("secret", state.password)
|
||||
assertFalse(state.pages.contains(WizardPage.LOGIN))
|
||||
|
||||
state.name = "Philipp"
|
||||
state.next()
|
||||
assertEquals(WizardPage.SUMMARY, state.page)
|
||||
state.edit(WizardPage.LOGIN)
|
||||
state.callsign = "DL0TEST/P"
|
||||
state.next()
|
||||
assertEquals("DL0TEST/P", state.callsign, "a taken callsign gets its /P")
|
||||
}
|
||||
|
||||
@Test
|
||||
fun takingTheStationLoadsEverythingThePagesShow() {
|
||||
val state = SetupWizardState(emptyProfile(), listOf(contestStation()))
|
||||
state.chooseLoginSource(WizardSource.NEW)
|
||||
state.chooseStationSource(WizardSource.TAKE)
|
||||
state.next()
|
||||
|
||||
assertEquals("JO50AA", state.locator)
|
||||
assertEquals(setOf(WizardBand.B144, WizardBand.B432), state.bands)
|
||||
assertEquals(2, state.category)
|
||||
assertFalse(state.secondChat)
|
||||
assertEquals(28.0, state.antenna.beamWidthDeg)
|
||||
assertEquals(WizardLogProgram.WINTEST, state.integrations.logProgram)
|
||||
assertTrue(state.integrations.rotator)
|
||||
assertTrue(state.summaryQrgFollow)
|
||||
assertEquals(
|
||||
listOf(WizardPage.ENTRY, WizardPage.PERSONAL, WizardPage.LOGIN, WizardPage.SUMMARY),
|
||||
state.pages,
|
||||
"a taken station shows no page of its own",
|
||||
)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun takingAStationNamesWhatTheOwnProfileLoses() {
|
||||
val state = SetupWizardState(emptyProfile(), listOf(contestStation()))
|
||||
state.chooseLoginSource(WizardSource.NEW)
|
||||
state.chooseStationSource(WizardSource.TAKE)
|
||||
state.next()
|
||||
|
||||
// The own profile had the second chat, the network listener and AirScout on; the
|
||||
// donor has none of them. Win-Test and the rotator come new and are not "switched off".
|
||||
assertEquals(
|
||||
listOf(WizardSwitch.SECOND_CHAT, WizardSwitch.LOG_UDP, WizardSwitch.AIRSCOUT),
|
||||
state.switchedOff,
|
||||
)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun aTakenStationKeepsSeveralLogSources() {
|
||||
val several = WizardDonor("several", "Zwei Quellen", contestStation().prefs.apply {
|
||||
setLogsynch_fileBasedWkdCallInterpreterEnabled(true)
|
||||
})
|
||||
val state = SetupWizardState(emptyProfile(), listOf(several))
|
||||
state.chooseLoginSource(WizardSource.NEW)
|
||||
state.chooseStationSource(WizardSource.TAKE)
|
||||
state.next()
|
||||
|
||||
assertFalse(state.logPageEditable, "the page knows one source and would switch the other off")
|
||||
state.edit(WizardPage.LOG)
|
||||
assertFalse(state.pages.contains(WizardPage.LOG))
|
||||
}
|
||||
|
||||
@Test
|
||||
fun changingTheDonorLoadsItsValues() {
|
||||
val contest = contestStation()
|
||||
val other = portable()
|
||||
val state = SetupWizardState(emptyProfile(), listOf(contest, other))
|
||||
state.chooseLoginSource(WizardSource.NEW)
|
||||
state.chooseStationSource(WizardSource.TAKE)
|
||||
state.chooseStationDonor(contest)
|
||||
state.next()
|
||||
assertEquals("JO50AA", state.locator)
|
||||
|
||||
state.back()
|
||||
state.chooseStationDonor(other)
|
||||
state.next()
|
||||
|
||||
assertEquals("JN58QA", state.locator)
|
||||
assertEquals(setOf(WizardBand.B1240), state.bands)
|
||||
assertEquals(3, state.category)
|
||||
assertEquals(WizardLogProgram.NONE, state.integrations.logProgram, "nothing of the first donor is left")
|
||||
assertFalse(state.integrations.rotator)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun goingBackToNewDropsWhatWasTaken() {
|
||||
val state = SetupWizardState(emptyProfile(), listOf(contestStation()))
|
||||
state.chooseLoginSource(WizardSource.NEW)
|
||||
state.chooseStationSource(WizardSource.TAKE)
|
||||
state.next()
|
||||
state.back()
|
||||
state.chooseStationSource(WizardSource.NEW)
|
||||
state.next()
|
||||
|
||||
assertEquals("", state.locator)
|
||||
assertTrue(state.bands.isEmpty())
|
||||
assertEquals(WizardLogProgram.NONE, state.integrations.logProgram)
|
||||
assertFalse(state.integrations.rotator)
|
||||
assertTrue(state.pages.contains(WizardPage.LOG))
|
||||
}
|
||||
|
||||
// --- against real files -------------------------------------------------------------
|
||||
|
||||
private fun file(name: String, configure: ChatPreferences.() -> Unit): Path {
|
||||
val path = directory.resolve(name)
|
||||
ChatPreferences::class.java.getResourceAsStream(ChatPreferences.PREFERENCE_RESOURCE).use { template ->
|
||||
Files.copy(requireNotNull(template), path, StandardCopyOption.REPLACE_EXISTING)
|
||||
}
|
||||
ChatPreferences(path).apply {
|
||||
assertTrue(readPreferencesFromXmlFile())
|
||||
configure()
|
||||
assertTrue(writePreferencesToXmlFile())
|
||||
}
|
||||
return path
|
||||
}
|
||||
|
||||
private fun read(path: Path) = ChatPreferences(path).also { assertTrue(it.readPreferencesFromXmlFile()) }
|
||||
|
||||
@Test
|
||||
fun saveWritesTheWholeTakenStationAndTheTakenLoginIntoTheOwnFile() {
|
||||
val donorFile = file("donor.xml") {
|
||||
setStn_loginCallSign("DL0TEST")
|
||||
setStn_loginPassword("secret")
|
||||
setStn_loginLocatorMainCat("JO50AA")
|
||||
setStn_bandActive144(true)
|
||||
setLoginChatCategoryMain(ChatCategory(2))
|
||||
setLoginToSecondChatEnabled(false)
|
||||
setStn_qtfDefault(270.0)
|
||||
setTrxSynch_so2rEnabled(true)
|
||||
setStn_pstRotator2Enabled(true)
|
||||
setStn_pstRotator2Port(12020)
|
||||
setLogsynch_wintestNetworkListenerEnabled(true)
|
||||
setLogsynch_wintestNetworkStationNameOfWintestClient1("RUN")
|
||||
}
|
||||
val ownFile = file("own.xml") {
|
||||
setStn_loginCallSign("")
|
||||
setStn_loginPassword("")
|
||||
setStn_on4kstServersDns("own.example")
|
||||
}
|
||||
val donorBytes = Files.readAllBytes(donorFile)
|
||||
val own = read(ownFile)
|
||||
val state = SetupWizardState(own, listOf(WizardDonor("contest", "Conteststation", read(donorFile))))
|
||||
state.chooseLoginSource(WizardSource.TAKE)
|
||||
state.chooseStationSource(WizardSource.TAKE)
|
||||
state.next()
|
||||
state.name = "Philipp"
|
||||
state.next()
|
||||
assertEquals(WizardPage.SUMMARY, state.page)
|
||||
|
||||
assertTrue(state.writeTo(own))
|
||||
|
||||
val restored = read(ownFile)
|
||||
assertEquals("DL0TEST", restored.getStn_loginCallSign())
|
||||
assertEquals("secret", restored.getStn_loginPassword())
|
||||
assertEquals("Philipp", restored.getStn_loginNameMainCat())
|
||||
assertEquals("JO50AA", restored.getStn_loginLocatorMainCat())
|
||||
assertEquals(270.0, restored.getStn_qtfDefault(), "a station value the wizard never asks about")
|
||||
assertTrue(restored.isTrxSynch_so2rEnabled())
|
||||
assertTrue(restored.isStn_pstRotator2Enabled())
|
||||
assertEquals(12020, restored.getStn_pstRotator2Port())
|
||||
assertTrue(restored.isLogsynch_wintestNetworkListenerEnabled())
|
||||
assertEquals("RUN", restored.getLogsynch_wintestNetworkStationNameOfWintestClient1())
|
||||
assertEquals("own.example", restored.getStn_on4kstServersDns(), "not part of the station")
|
||||
assertArrayEquals(donorBytes, Files.readAllBytes(donorFile), "the donor's file was touched")
|
||||
}
|
||||
|
||||
@Test
|
||||
fun aPageOpenedAfterTakingOverridesTheCopy() {
|
||||
val donorFile = file("donor.xml") {
|
||||
setStn_loginCallSign("DL0TEST")
|
||||
setStn_loginPassword("secret")
|
||||
setStn_loginLocatorMainCat("JO50AA")
|
||||
setStn_bandActive144(true)
|
||||
setLoginChatCategoryMain(ChatCategory(2))
|
||||
setLoginToSecondChatEnabled(false)
|
||||
setStn_pstRotatorEnabled(true)
|
||||
setStn_pstRotatorHost("127.0.0.1")
|
||||
setStn_pstRotatorPort(12000)
|
||||
}
|
||||
val ownFile = file("own.xml") {
|
||||
setStn_loginCallSign("")
|
||||
setStn_loginPassword("")
|
||||
}
|
||||
val own = read(ownFile)
|
||||
val state = SetupWizardState(own, listOf(WizardDonor("contest", "Conteststation", read(donorFile))))
|
||||
state.chooseLoginSource(WizardSource.TAKE)
|
||||
state.chooseStationSource(WizardSource.TAKE)
|
||||
state.next()
|
||||
state.name = "Philipp"
|
||||
state.next()
|
||||
state.edit(WizardPage.GEAR)
|
||||
state.integrations.rotator = false
|
||||
state.next()
|
||||
state.edit(WizardPage.SITE)
|
||||
state.locator = "JN58QA"
|
||||
state.next()
|
||||
|
||||
assertTrue(state.writeTo(own))
|
||||
|
||||
val restored = read(ownFile)
|
||||
assertFalse(restored.isStn_pstRotatorEnabled(), "the operator switched the taken rotator off")
|
||||
assertEquals("JN58QA", restored.getStn_loginLocatorMainCat(), "the operator changed the taken locator")
|
||||
}
|
||||
|
||||
@Test
|
||||
fun takingAStationNamesSo2rAndRotatorTwoWhenTheDonorDropsThem() {
|
||||
val own = emptyProfile().apply {
|
||||
setTrxSynch_so2rEnabled(true)
|
||||
setStn_pstRotator2Enabled(true)
|
||||
}
|
||||
val donorOff = contestStation()
|
||||
val donorOn = WizardDonor("both-on", "Beide an", prefs {
|
||||
integrationsOff()
|
||||
setStn_loginCallSign("DL0BOTH")
|
||||
setStn_loginPassword("secret")
|
||||
setStn_loginLocatorMainCat("JO50AA")
|
||||
setStn_bandActive144(true)
|
||||
setLoginChatCategoryMain(ChatCategory(2))
|
||||
setLoginToSecondChatEnabled(false)
|
||||
setTrxSynch_so2rEnabled(true)
|
||||
setStn_pstRotator2Enabled(true)
|
||||
})
|
||||
|
||||
val takeDrops = SetupWizardState(own, listOf(donorOff)).apply {
|
||||
chooseLoginSource(WizardSource.NEW)
|
||||
chooseStationSource(WizardSource.TAKE)
|
||||
next()
|
||||
}
|
||||
assertEquals(
|
||||
listOf(WizardSwitch.SO2R, WizardSwitch.ROTATOR_2),
|
||||
takeDrops.switchedOff.takeLast(2),
|
||||
)
|
||||
|
||||
val keep = SetupWizardState(own, listOf(donorOff)).apply {
|
||||
chooseLoginSource(WizardSource.NEW)
|
||||
chooseStationSource(WizardSource.KEEP)
|
||||
next()
|
||||
}
|
||||
assertFalse(WizardSwitch.SO2R in keep.switchedOff)
|
||||
assertFalse(WizardSwitch.ROTATOR_2 in keep.switchedOff)
|
||||
|
||||
val takeKeeps = SetupWizardState(own, listOf(donorOn)).apply {
|
||||
chooseLoginSource(WizardSource.NEW)
|
||||
chooseStationSource(WizardSource.TAKE)
|
||||
next()
|
||||
}
|
||||
assertFalse(WizardSwitch.SO2R in takeKeeps.switchedOff)
|
||||
assertFalse(WizardSwitch.ROTATOR_2 in takeKeeps.switchedOff)
|
||||
|
||||
val ownRotator2WithoutSo2r = emptyProfile().apply {
|
||||
setTrxSynch_so2rEnabled(false)
|
||||
setStn_pstRotator2Enabled(true)
|
||||
}
|
||||
val noSo2r = SetupWizardState(ownRotator2WithoutSo2r, listOf(donorOff)).apply {
|
||||
chooseLoginSource(WizardSource.NEW)
|
||||
chooseStationSource(WizardSource.TAKE)
|
||||
next()
|
||||
}
|
||||
assertFalse(WizardSwitch.ROTATOR_2 in noSo2r.switchedOff)
|
||||
assertFalse(WizardSwitch.SO2R in noSo2r.switchedOff)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun theSummaryFallbackBandFollowsTheStationSource() {
|
||||
val own = emptyProfile().apply { setNotify_optionalFrequencyPrefix("144") }
|
||||
val donor = WizardDonor("uhf", "UHF", prefs {
|
||||
integrationsOff()
|
||||
setStn_loginCallSign("DL0UHF")
|
||||
setStn_loginPassword("secret")
|
||||
setStn_loginLocatorMainCat("JO50AA")
|
||||
setStn_bandActive432(true)
|
||||
setLoginChatCategoryMain(ChatCategory(2))
|
||||
setLoginToSecondChatEnabled(false)
|
||||
setNotify_optionalFrequencyPrefix("432")
|
||||
})
|
||||
|
||||
val take = SetupWizardState(own, listOf(donor)).apply {
|
||||
chooseLoginSource(WizardSource.NEW)
|
||||
chooseStationSource(WizardSource.TAKE)
|
||||
next()
|
||||
}
|
||||
assertEquals("432", take.summaryFallbackBand)
|
||||
|
||||
val keep = SetupWizardState(own, listOf(donor)).apply {
|
||||
chooseLoginSource(WizardSource.NEW)
|
||||
chooseStationSource(WizardSource.KEEP)
|
||||
next()
|
||||
}
|
||||
assertEquals("144", keep.summaryFallbackBand)
|
||||
|
||||
val fresh = SetupWizardState(own, listOf(donor)).apply {
|
||||
chooseLoginSource(WizardSource.NEW)
|
||||
chooseStationSource(WizardSource.NEW)
|
||||
next()
|
||||
}
|
||||
assertEquals("144", fresh.summaryFallbackBand)
|
||||
}
|
||||
}
|
||||
+224
@@ -0,0 +1,224 @@
|
||||
package kst4contest.view.compose.wizard
|
||||
|
||||
import kst4contest.model.ChatPreferences
|
||||
import org.junit.jupiter.api.Assertions.assertArrayEquals
|
||||
import org.junit.jupiter.api.Assertions.assertEquals
|
||||
import org.junit.jupiter.api.Assertions.assertFalse
|
||||
import org.junit.jupiter.api.Assertions.assertNull
|
||||
import org.junit.jupiter.api.Assertions.assertTrue
|
||||
import org.junit.jupiter.api.Assumptions
|
||||
import org.junit.jupiter.api.Test
|
||||
import org.junit.jupiter.api.io.TempDir
|
||||
import java.nio.file.Files
|
||||
import java.nio.file.Path
|
||||
import java.nio.file.StandardCopyOption
|
||||
|
||||
/** When the wizard opens at all, decided without a window. */
|
||||
class SetupWizardLauncherTest(@param:TempDir private val directory: Path) {
|
||||
|
||||
private fun templateFile(): Path {
|
||||
val file = directory.resolve("preferences.xml")
|
||||
ChatPreferences::class.java.getResourceAsStream(ChatPreferences.PREFERENCE_RESOURCE).use { template ->
|
||||
Files.copy(requireNotNull(template), file, StandardCopyOption.REPLACE_EXISTING)
|
||||
}
|
||||
return file
|
||||
}
|
||||
|
||||
private fun configuredFile(): Path {
|
||||
val file = templateFile()
|
||||
ChatPreferences(file).apply {
|
||||
assertTrue(readPreferencesFromXmlFile())
|
||||
setStn_loginCallSign("DL0TEST")
|
||||
setStn_loginPassword("secret")
|
||||
assertTrue(writePreferencesToXmlFile())
|
||||
}
|
||||
return file
|
||||
}
|
||||
|
||||
private val neverShown: (SetupWizardState, ChatPreferences) -> SetupWizardOutcome =
|
||||
{ _, _ -> throw AssertionError("the wizard must not open here") }
|
||||
|
||||
@Test
|
||||
fun anUnconfiguredProfileOpensTheWizard() {
|
||||
var shown = 0
|
||||
|
||||
val outcome = SetupWizardLauncher.run(ChatPreferences(templateFile()), forced = false) { _, _ ->
|
||||
shown++
|
||||
SetupWizardOutcome.LATER
|
||||
}
|
||||
|
||||
assertEquals(1, shown)
|
||||
assertEquals(SetupWizardOutcome.LATER, outcome)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun aConfiguredProfileStartsWithoutTheWizard() {
|
||||
assertEquals(
|
||||
SetupWizardOutcome.NOT_SHOWN,
|
||||
SetupWizardLauncher.run(ChatPreferences(configuredFile()), forced = false, neverShown),
|
||||
)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun theMenuOpensItOnAConfiguredProfileToo() {
|
||||
val outcome = SetupWizardLauncher.run(ChatPreferences(configuredFile()), forced = true) { state, _ ->
|
||||
assertEquals(listOf(WizardSource.NEW, WizardSource.KEEP), state.loginSources)
|
||||
SetupWizardOutcome.SAVED
|
||||
}
|
||||
|
||||
assertEquals(SetupWizardOutcome.SAVED, outcome)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun anUnreadableFileNeverOpensTheWizard() {
|
||||
val garbage = directory.resolve("broken.xml")
|
||||
Files.writeString(garbage, "this is not xml <<<")
|
||||
val before = Files.readAllBytes(garbage)
|
||||
|
||||
// Forced as well: a wizard over a file it could not read would save over it.
|
||||
assertEquals(
|
||||
SetupWizardOutcome.NOT_SHOWN,
|
||||
SetupWizardLauncher.run(ChatPreferences(garbage), forced = true, neverShown),
|
||||
)
|
||||
assertArrayEquals(before, Files.readAllBytes(garbage), "the unreadable file was touched")
|
||||
}
|
||||
|
||||
@Test
|
||||
fun aFileTheReaderThrowsOnNeverOpensTheWizard() {
|
||||
val file = templateFile()
|
||||
val original = Files.readString(file)
|
||||
assertTrue(original.contains("<ChatCategory>2</ChatCategory>"))
|
||||
Files.writeString(file, original.replace("<ChatCategory>2</ChatCategory>", "<ChatCategory>2.0</ChatCategory>"))
|
||||
val before = Files.readAllBytes(file)
|
||||
|
||||
assertEquals(
|
||||
SetupWizardOutcome.NOT_SHOWN,
|
||||
SetupWizardLauncher.run(ChatPreferences(file), forced = true, neverShown),
|
||||
)
|
||||
assertArrayEquals(before, Files.readAllBytes(file), "the unreadable file was touched")
|
||||
}
|
||||
|
||||
@Test
|
||||
fun aFailedSaveKeepsTheWizardOpen() {
|
||||
val source = ChatPreferences(templateFile()).apply { assertTrue(readPreferencesFromXmlFile()) }
|
||||
val state = SetupWizardState(source).apply {
|
||||
name = "Philipp"
|
||||
next()
|
||||
callsign = "DL0TEST"
|
||||
password = "secret"
|
||||
next()
|
||||
locator = "JO50AA"
|
||||
setBand(WizardBand.B144, true)
|
||||
}
|
||||
val unwritable = ChatPreferences(Files.createDirectory(directory.resolve("not-a-file")))
|
||||
|
||||
assertNull(saveFromWizard(state, unwritable, connect = true), "a failed write must not close the wizard")
|
||||
}
|
||||
|
||||
@Test
|
||||
fun aSaveReportsWhetherToConnect() {
|
||||
val file = templateFile()
|
||||
val prefs = ChatPreferences(file).apply { assertTrue(readPreferencesFromXmlFile()) }
|
||||
val state = SetupWizardState(prefs).apply {
|
||||
name = "Philipp"
|
||||
next()
|
||||
callsign = "DL0TEST"
|
||||
password = "secret"
|
||||
next()
|
||||
locator = "JO50AA"
|
||||
setBand(WizardBand.B144, true)
|
||||
}
|
||||
|
||||
assertEquals(SetupWizardOutcome.SAVED, saveFromWizard(state, prefs, connect = false))
|
||||
assertEquals(SetupWizardOutcome.SAVED_AND_CONNECT, saveFromWizard(state, prefs, connect = true))
|
||||
}
|
||||
|
||||
private fun profileFile(name: String, callsign: String, password: String): Path {
|
||||
val file = directory.resolve(name)
|
||||
ChatPreferences::class.java.getResourceAsStream(ChatPreferences.PREFERENCE_RESOURCE).use { template ->
|
||||
Files.copy(requireNotNull(template), file, StandardCopyOption.REPLACE_EXISTING)
|
||||
}
|
||||
ChatPreferences(file).apply {
|
||||
assertTrue(readPreferencesFromXmlFile())
|
||||
setStn_loginCallSign(callsign)
|
||||
setStn_loginPassword(password)
|
||||
assertTrue(writePreferencesToXmlFile())
|
||||
}
|
||||
return file
|
||||
}
|
||||
|
||||
@Test
|
||||
fun onlyConfiguredReadableProfilesBecomeDonors() {
|
||||
val configured = profileFile("configured.xml", "DL0TEST", "secret")
|
||||
val emptyLogin = profileFile("empty.xml", "", "")
|
||||
val template = profileFile("template.xml", "DO5AMF", "changeMe")
|
||||
val garbage = directory.resolve("garbage.xml").also { Files.writeString(it, "this is not xml <<<") }
|
||||
|
||||
val donors = loadDonors(
|
||||
listOf(
|
||||
DonorCandidate("a", "Conteststation", configured),
|
||||
DonorCandidate("b", "Leer", emptyLogin),
|
||||
DonorCandidate("c", "Vorlage", template),
|
||||
DonorCandidate("d", "Kaputt", garbage),
|
||||
DonorCandidate("e", "Fehlt", directory.resolve("missing.xml")),
|
||||
)
|
||||
)
|
||||
|
||||
assertEquals(listOf("a"), donors.map { it.profileId })
|
||||
assertEquals("Conteststation", donors.single().displayName)
|
||||
assertEquals("DL0TEST", donors.single().callsign)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun aMissingDonorFileIsNotCreated() {
|
||||
val missing = directory.resolve("missing.xml")
|
||||
|
||||
loadDonors(listOf(DonorCandidate("e", "Fehlt", missing)))
|
||||
|
||||
assertFalse(Files.exists(missing), "looking for a donor must not create its file")
|
||||
}
|
||||
|
||||
@Test
|
||||
fun readingADonorLeavesItsFileAlone() {
|
||||
val configured = profileFile("configured.xml", "DL0TEST", "secret")
|
||||
val before = Files.readAllBytes(configured)
|
||||
|
||||
loadDonors(listOf(DonorCandidate("a", "Conteststation", configured)))
|
||||
|
||||
assertArrayEquals(before, Files.readAllBytes(configured))
|
||||
}
|
||||
|
||||
@Test
|
||||
fun donorsAreOnlyLoadedWhenTheWizardOpens() {
|
||||
var loaded = 0
|
||||
val donors = { loaded++; emptyList<WizardDonor>() }
|
||||
|
||||
SetupWizardLauncher.run(ChatPreferences(configuredFile()), forced = false, donors, neverShown)
|
||||
assertEquals(0, loaded, "a configured profile starts without reading other profiles")
|
||||
|
||||
var seen: List<WizardDonor>? = null
|
||||
SetupWizardLauncher.run(ChatPreferences(templateFile()), forced = false, donors) { state, _ ->
|
||||
seen = state.donors
|
||||
SetupWizardOutcome.LATER
|
||||
}
|
||||
assertEquals(1, loaded)
|
||||
assertEquals(emptyList<WizardDonor>(), seen)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun aLinkedDirectoryToTheActiveProfileIsNotOfferedAsItsOwnDonor() {
|
||||
val dirB = Files.createDirectory(directory.resolve("b"))
|
||||
val fileInB = dirB.resolve("preferences.xml")
|
||||
Files.copy(configuredFile(), fileInB, StandardCopyOption.REPLACE_EXISTING)
|
||||
val linkA = directory.resolve("a")
|
||||
val linked = runCatching { Files.createSymbolicLink(linkA, dirB) }
|
||||
Assumptions.assumeTrue(
|
||||
linked.isSuccess,
|
||||
"file system refused symbolic link: ${linked.exceptionOrNull()?.message}",
|
||||
)
|
||||
|
||||
val candidates = listOf(DonorCandidate("b", "B", fileInB))
|
||||
assertTrue(loadDonors(candidates, activeFile = linkA.resolve("preferences.xml")).isEmpty())
|
||||
assertEquals(listOf("b"), loadDonors(candidates).map { it.profileId })
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,628 @@
|
||||
package kst4contest.view.compose.wizard
|
||||
|
||||
import kst4contest.model.ChatCategory
|
||||
import kst4contest.model.ChatPreferences
|
||||
import org.junit.jupiter.api.Assertions.assertEquals
|
||||
import org.junit.jupiter.api.Assertions.assertFalse
|
||||
import org.junit.jupiter.api.Assertions.assertNull
|
||||
import org.junit.jupiter.api.Assertions.assertTrue
|
||||
import org.junit.jupiter.api.Test
|
||||
import java.nio.file.Path
|
||||
|
||||
/**
|
||||
* The wizard's rules without a window: which pages appear, what they start with, and when
|
||||
* the operator may go on. Nothing here reads or writes a file.
|
||||
*/
|
||||
class SetupWizardStateTest {
|
||||
|
||||
/** Preferences that never touch a file: the path is only read by read/write calls. */
|
||||
private fun prefs(configure: ChatPreferences.() -> Unit = {}): ChatPreferences =
|
||||
ChatPreferences(Path.of("setup-wizard-state-test-unused.xml")).apply(configure)
|
||||
|
||||
private fun freshInstallation() = prefs {
|
||||
setStn_loginCallSign("DO5AMF")
|
||||
setStn_loginPassword("changeMe")
|
||||
setStn_loginNameMainCat("KST4Contest1263")
|
||||
setStn_loginLocatorMainCat("JO54ME")
|
||||
setStn_bandActive144(true)
|
||||
setLoginChatCategoryMain(ChatCategory(2))
|
||||
setLoginToSecondChatEnabled(true)
|
||||
setLoginChatCategorySecond(ChatCategory(3))
|
||||
}
|
||||
|
||||
private fun duplicatedProfile() = prefs {
|
||||
setStn_loginCallSign("")
|
||||
setStn_loginPassword("")
|
||||
setStn_loginNameMainCat("Other Operator")
|
||||
setStn_loginLocatorMainCat("JO50AA")
|
||||
setStn_bandActive144(true)
|
||||
setStn_bandActive432(true)
|
||||
setLoginChatCategoryMain(ChatCategory(2))
|
||||
setLoginToSecondChatEnabled(false)
|
||||
}
|
||||
|
||||
private fun configuredProfile() = duplicatedProfile().apply {
|
||||
setStn_loginCallSign("DL0TEST")
|
||||
setStn_loginPassword("secret")
|
||||
setStn_loginNameMainCat("Philipp")
|
||||
}
|
||||
|
||||
/** Fills every mandatory answer of a first installation, leaving the wizard on SITE. */
|
||||
private fun SetupWizardState.fillFirstInstallation() {
|
||||
name = "Philipp"
|
||||
next()
|
||||
callsign = "DL0TEST"
|
||||
password = "secret"
|
||||
next()
|
||||
locator = "JO50AA"
|
||||
setBand(WizardBand.B144, true)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun aFreshInstallationHasNoEntryPageAndStartsEmpty() {
|
||||
val state = SetupWizardState(freshInstallation())
|
||||
|
||||
assertFalse(state.hasEntryPage)
|
||||
assertEquals(WizardPage.PERSONAL, state.page)
|
||||
assertEquals(
|
||||
listOf(
|
||||
WizardPage.PERSONAL, WizardPage.LOGIN, WizardPage.SITE,
|
||||
WizardPage.ANTENNA, WizardPage.LOG, WizardPage.GEAR, WizardPage.SUMMARY,
|
||||
),
|
||||
state.pages,
|
||||
)
|
||||
assertEquals("", state.name, "the template's name is nobody's name")
|
||||
assertEquals("", state.callsign)
|
||||
assertEquals("", state.locator)
|
||||
assertTrue(state.bands.isEmpty())
|
||||
assertNull(state.category)
|
||||
assertFalse(state.secondChat)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun aDuplicatedProfileIsAskedOnlyAboutTheStation() {
|
||||
val state = SetupWizardState(duplicatedProfile())
|
||||
|
||||
assertEquals(listOf(WizardSource.NEW), state.loginSources)
|
||||
assertEquals(listOf(WizardSource.NEW, WizardSource.KEEP), state.stationSources)
|
||||
assertTrue(state.hasEntryPage)
|
||||
assertEquals(WizardPage.ENTRY, state.page)
|
||||
assertEquals(WizardSource.NEW, state.loginSource, "a single option is chosen already")
|
||||
assertNull(state.stationSource, "nothing is preselected where there is a choice")
|
||||
assertFalse(state.canGoNext)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun aConfiguredProfileMayKeepBoth() {
|
||||
val state = SetupWizardState(configuredProfile())
|
||||
|
||||
assertEquals(listOf(WizardSource.NEW, WizardSource.KEEP), state.loginSources)
|
||||
assertEquals(listOf(WizardSource.NEW, WizardSource.KEEP), state.stationSources)
|
||||
assertEquals("Philipp", state.name, "a configured profile keeps its operator's name")
|
||||
}
|
||||
|
||||
@Test
|
||||
fun keepingTheStationSkipsItsStepAndCarriesTheStoredValues() {
|
||||
val state = SetupWizardState(duplicatedProfile())
|
||||
state.chooseStationSource(WizardSource.KEEP)
|
||||
state.next()
|
||||
|
||||
assertEquals(
|
||||
listOf(WizardPage.ENTRY, WizardPage.PERSONAL, WizardPage.LOGIN, WizardPage.SUMMARY),
|
||||
state.pages,
|
||||
)
|
||||
assertEquals("JO50AA", state.locator)
|
||||
assertEquals(setOf(WizardBand.B144, WizardBand.B432), state.bands)
|
||||
assertEquals(2, state.category)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun aNewStationStartsEmptyEvenOnAProfileThatHasOne() {
|
||||
val state = SetupWizardState(duplicatedProfile())
|
||||
state.chooseStationSource(WizardSource.NEW)
|
||||
state.next()
|
||||
|
||||
assertEquals("", state.locator)
|
||||
assertTrue(state.bands.isEmpty())
|
||||
assertNull(state.category)
|
||||
assertTrue(state.pages.contains(WizardPage.SITE))
|
||||
}
|
||||
|
||||
@Test
|
||||
fun goingBackToTheEntryPageAndOnAgainKeepsWhatWasTyped() {
|
||||
val state = SetupWizardState(duplicatedProfile())
|
||||
state.chooseStationSource(WizardSource.NEW)
|
||||
state.next()
|
||||
state.name = "Philipp"
|
||||
state.back()
|
||||
state.next()
|
||||
|
||||
assertEquals("Philipp", state.name)
|
||||
|
||||
state.next()
|
||||
state.callsign = "DL0TEST"
|
||||
state.back()
|
||||
state.back()
|
||||
state.chooseStationSource(WizardSource.KEEP)
|
||||
state.next()
|
||||
|
||||
assertEquals("JO50AA", state.locator, "a changed source loads its own values")
|
||||
state.next()
|
||||
assertEquals("DL0TEST", state.callsign, "the login source did not change")
|
||||
}
|
||||
|
||||
@Test
|
||||
fun callsignsWithSuffixAndLowerCaseAreAccepted() {
|
||||
listOf("DL0TEST", "DL0TEST/P", "DO5AMF-2", "do5amf", " DL0TEST ").forEach {
|
||||
assertTrue(SetupWizardState.isPlausibleCallsign(it), "'$it' must be accepted")
|
||||
}
|
||||
listOf("", "DL", "ABC", "123", "DL0 TEST", "DL0TEST|X", "DL0-TEST-2", "DL0TEST/").forEach {
|
||||
assertFalse(SetupWizardState.isPlausibleCallsign(it), "'$it' must be refused")
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
fun onlyASixCharacterLocatorIsAccepted() {
|
||||
listOf("JO50AA", "jo50aa", " JN49FL ").forEach {
|
||||
assertTrue(SetupWizardState.isLocator(it), "'$it' must be accepted")
|
||||
}
|
||||
listOf("", "JO50", "JO50AAA", "SS50AA", "JO50YY", "JO5OAA").forEach {
|
||||
assertFalse(SetupWizardState.isLocator(it), "'$it' must be refused")
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
fun theCategoryIsSuggestedFromTheLowestBand() {
|
||||
assertNull(SetupWizardState.suggestCategory(emptySet()))
|
||||
assertEquals(1, SetupWizardState.suggestCategory(setOf(WizardBand.B50, WizardBand.B144)))
|
||||
assertEquals(1, SetupWizardState.suggestCategory(setOf(WizardBand.B70)))
|
||||
assertEquals(2, SetupWizardState.suggestCategory(setOf(WizardBand.B144, WizardBand.B1240)))
|
||||
assertEquals(2, SetupWizardState.suggestCategory(setOf(WizardBand.B432)))
|
||||
assertEquals(3, SetupWizardState.suggestCategory(setOf(WizardBand.B1240, WizardBand.B10G)))
|
||||
}
|
||||
|
||||
@Test
|
||||
fun theSuggestionFollowsTheBandsUntilTheOperatorChooses() {
|
||||
val state = SetupWizardState(freshInstallation())
|
||||
|
||||
state.setBand(WizardBand.B1240, true)
|
||||
assertEquals(3, state.category)
|
||||
|
||||
state.setBand(WizardBand.B144, true)
|
||||
assertEquals(2, state.category)
|
||||
|
||||
state.chooseCategory(3)
|
||||
state.setBand(WizardBand.B50, true)
|
||||
assertEquals(3, state.category, "an operator's choice is not overwritten")
|
||||
assertEquals(1, state.suggestedCategory, "the suggestion is still shown")
|
||||
}
|
||||
|
||||
@Test
|
||||
fun aSecondChatNeedsADifferentCategory() {
|
||||
val state = SetupWizardState(freshInstallation())
|
||||
state.fillFirstInstallation()
|
||||
assertTrue(state.canGoNext)
|
||||
|
||||
state.chooseSecondChat(true)
|
||||
assertFalse(state.canGoNext, "the second chat has no category yet")
|
||||
assertFalse(state.secondCategoryOptions.contains(2), "the main category is not offered twice")
|
||||
|
||||
state.secondCategory = 3
|
||||
assertTrue(state.canGoNext)
|
||||
|
||||
state.chooseCategory(3)
|
||||
assertNull(state.secondCategory, "the same chat cannot be opened twice")
|
||||
assertFalse(state.canGoNext)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun finishNeedsEveryMandatoryAnswer() {
|
||||
val state = SetupWizardState(freshInstallation())
|
||||
|
||||
state.name = "Philipp"
|
||||
assertFalse(state.canFinish)
|
||||
state.next()
|
||||
state.callsign = "DL0TEST"
|
||||
state.password = "secret"
|
||||
assertFalse(state.canFinish, "a new station still lacks its locator")
|
||||
state.next()
|
||||
state.locator = "JO50AA"
|
||||
assertFalse(state.canFinish, "no band yet")
|
||||
state.setBand(WizardBand.B144, true)
|
||||
assertTrue(state.canFinish)
|
||||
|
||||
state.finish()
|
||||
assertEquals(WizardPage.SUMMARY, state.page)
|
||||
assertTrue(state.mandatoryComplete)
|
||||
assertFalse(state.canFinish, "the summary has Save instead")
|
||||
}
|
||||
|
||||
@Test
|
||||
fun aKeptStationLetsTheOperatorFinishAfterTheLogin() {
|
||||
val state = SetupWizardState(duplicatedProfile())
|
||||
state.chooseStationSource(WizardSource.KEEP)
|
||||
state.next()
|
||||
state.name = "Philipp"
|
||||
state.next()
|
||||
state.callsign = "DL0TEST/P"
|
||||
state.password = "secret"
|
||||
|
||||
assertTrue(state.canFinish)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun aRefusedEntryIsOnlyShownOnceSomethingWasTyped() {
|
||||
val state = SetupWizardState(freshInstallation())
|
||||
|
||||
assertFalse(state.callsignRefused, "an empty field is not an error yet")
|
||||
state.callsign = "DL"
|
||||
assertTrue(state.callsignRefused)
|
||||
state.callsign = "DL0TEST"
|
||||
assertFalse(state.callsignRefused)
|
||||
|
||||
assertFalse(state.locatorRefused)
|
||||
state.locator = "JO50"
|
||||
assertTrue(state.locatorRefused)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun changeFromTheSummaryOpensAStepThatWasSkipped() {
|
||||
val state = SetupWizardState(configuredProfile())
|
||||
state.chooseLoginSource(WizardSource.KEEP)
|
||||
state.chooseStationSource(WizardSource.KEEP)
|
||||
state.next()
|
||||
state.next()
|
||||
assertEquals(WizardPage.SUMMARY, state.page)
|
||||
|
||||
state.edit(WizardPage.LOGIN)
|
||||
|
||||
assertEquals(WizardPage.LOGIN, state.page)
|
||||
assertEquals("DL0TEST", state.callsign, "the kept value is there to be changed")
|
||||
state.callsign = "DL0TEST/P"
|
||||
state.next()
|
||||
assertEquals(WizardPage.SUMMARY, state.page)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun keepingAStationWithMissingLocatorKeepsTheSitePageInTheCourse() {
|
||||
val state = SetupWizardState(duplicatedProfile().apply { setStn_loginLocatorMainCat("") })
|
||||
state.chooseStationSource(WizardSource.KEEP)
|
||||
state.next()
|
||||
|
||||
assertTrue(state.pages.contains(WizardPage.SITE))
|
||||
state.name = "Philipp"
|
||||
state.next()
|
||||
state.callsign = "DL0TEST"
|
||||
state.password = "secret"
|
||||
state.next()
|
||||
|
||||
assertEquals(WizardPage.SITE, state.page)
|
||||
assertEquals(setOf(WizardBand.B144, WizardBand.B432), state.bands)
|
||||
assertEquals(2, state.category)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun keepingALoginWithMissingPasswordKeepsTheLoginPageInTheCourse() {
|
||||
val state = SetupWizardState(configuredProfile().apply { setStn_loginPassword("") })
|
||||
state.chooseLoginSource(WizardSource.KEEP)
|
||||
state.chooseStationSource(WizardSource.KEEP)
|
||||
state.next()
|
||||
|
||||
assertTrue(state.pages.contains(WizardPage.LOGIN))
|
||||
assertEquals("DL0TEST", state.callsign)
|
||||
assertEquals("", state.password)
|
||||
assertFalse(state.mandatoryComplete)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun keepingAnUnknownCategoryIsIncompleteAndKeepsTheSitePage() {
|
||||
val state = SetupWizardState(configuredProfile().apply { setLoginChatCategoryMain(ChatCategory(13)) })
|
||||
state.chooseLoginSource(WizardSource.KEEP)
|
||||
state.chooseStationSource(WizardSource.KEEP)
|
||||
state.next()
|
||||
|
||||
assertFalse(state.mandatoryComplete)
|
||||
assertTrue(state.pages.contains(WizardPage.SITE))
|
||||
}
|
||||
|
||||
@Test
|
||||
fun keepingValidCategoriesOutsideTheBandSuggestionsCompletesAndSkipsSite() {
|
||||
val state = SetupWizardState(
|
||||
configuredProfile().apply {
|
||||
setLoginChatCategoryMain(ChatCategory(7))
|
||||
setLoginToSecondChatEnabled(true)
|
||||
setLoginChatCategorySecond(ChatCategory(9))
|
||||
},
|
||||
)
|
||||
state.chooseLoginSource(WizardSource.KEEP)
|
||||
state.chooseStationSource(WizardSource.KEEP)
|
||||
state.next()
|
||||
|
||||
assertTrue(state.mandatoryComplete)
|
||||
assertFalse(state.pages.contains(WizardPage.SITE))
|
||||
}
|
||||
|
||||
@Test
|
||||
fun storablePasswordsAndNamesRejectDelimitersAndOuterWhitespace() {
|
||||
listOf("secret", "se cret").forEach {
|
||||
assertTrue(SetupWizardState.isStorablePassword(it), "'$it' must be accepted")
|
||||
}
|
||||
listOf("", " ", " secret", "secret ", "se|cret", "se\ncret", "se\rcret").forEach {
|
||||
assertFalse(SetupWizardState.isStorablePassword(it), "'$it' must be refused")
|
||||
}
|
||||
|
||||
listOf("Philipp", "Philipp W").forEach {
|
||||
assertTrue(SetupWizardState.isStorableName(it), "'$it' must be accepted")
|
||||
}
|
||||
listOf("", " ", "Phil|ipp", "Phil\nipp", "Phil\ripp").forEach {
|
||||
assertFalse(SetupWizardState.isStorableName(it), "'$it' must be refused")
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
fun aRefusedPasswordOrNameIsReportedAndBlocksCompletion() {
|
||||
val state = SetupWizardState(freshInstallation())
|
||||
assertFalse(state.nameRefused)
|
||||
state.name = " "
|
||||
assertFalse(state.nameRefused)
|
||||
assertFalse(state.canGoNext)
|
||||
state.name = "Phil|ipp"
|
||||
assertTrue(state.nameRefused)
|
||||
assertFalse(state.canGoNext)
|
||||
|
||||
state.fillFirstInstallation()
|
||||
state.back()
|
||||
assertEquals(WizardPage.LOGIN, state.page)
|
||||
assertFalse(state.passwordRefused)
|
||||
|
||||
listOf(" secret", "secret ", " ", "se|cret", "se\ncret").forEach { refused ->
|
||||
state.password = refused
|
||||
assertTrue(state.passwordRefused, "'$refused' must set passwordRefused")
|
||||
assertFalse(state.canGoNext, "'$refused' must block Next on login")
|
||||
assertFalse(state.mandatoryComplete, "'$refused' must block mandatoryComplete")
|
||||
}
|
||||
|
||||
state.password = ""
|
||||
assertFalse(state.passwordRefused)
|
||||
assertFalse(state.canGoNext)
|
||||
|
||||
state.password = "se cret"
|
||||
assertFalse(state.passwordRefused)
|
||||
assertTrue(state.canGoNext)
|
||||
assertTrue(state.mandatoryComplete)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun keepingALoginWithAStorablePasswordSkipsTheLoginPage() {
|
||||
val state = SetupWizardState(configuredProfile())
|
||||
state.chooseLoginSource(WizardSource.KEEP)
|
||||
state.chooseStationSource(WizardSource.KEEP)
|
||||
state.next()
|
||||
|
||||
assertFalse(state.pages.contains(WizardPage.LOGIN))
|
||||
assertEquals(WizardPage.PERSONAL, state.page)
|
||||
state.next()
|
||||
assertEquals(WizardPage.SUMMARY, state.page)
|
||||
}
|
||||
|
||||
/** A first installation whose stored integrations are those of the bundled template. */
|
||||
private fun freshInstallationLikeTheTemplate() = freshInstallation().apply {
|
||||
setLogsynch_wintestNetworkListenerEnabled(false)
|
||||
setLogsynch_ucxUDPWkdCallListenerEnabled(true)
|
||||
setLogsynch_fileBasedWkdCallInterpreterEnabled(true)
|
||||
setTrxSynch_ucxLogUDPListenerEnabled(true)
|
||||
setLogsynch_wintestQrgSyncEnabled(false)
|
||||
setNotify_dxClusterServerEnabled(true)
|
||||
setStn_pstRotatorEnabled(false)
|
||||
setAirScout_asUDPListenerEnabled(true)
|
||||
setLogsynch_ucxUDPWkdCallListenerPort(12060)
|
||||
}
|
||||
|
||||
/** A duplicated profile at a Win-Test station with a rotator. */
|
||||
private fun duplicatedWinTestStation() = duplicatedProfile().apply {
|
||||
setLogsynch_wintestNetworkListenerEnabled(true)
|
||||
setLogsynch_wintestNetworkPort(9871)
|
||||
setLogsynch_wintestNetworkStationNameOfKST("KST")
|
||||
setLogsynch_ucxUDPWkdCallListenerEnabled(false)
|
||||
setLogsynch_fileBasedWkdCallInterpreterEnabled(false)
|
||||
setLogsynch_wintestQrgSyncEnabled(true)
|
||||
setTrxSynch_ucxLogUDPListenerEnabled(false)
|
||||
setNotify_dxClusterServerEnabled(false)
|
||||
setStn_pstRotatorEnabled(true)
|
||||
setStn_pstRotatorHost("127.0.0.1")
|
||||
setStn_pstRotatorPort(12000)
|
||||
setAirScout_asUDPListenerEnabled(false)
|
||||
setTrxSynch_so2rEnabled(false)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun aNewStationStartsWithEveryIntegrationOff() {
|
||||
val state = SetupWizardState(freshInstallationLikeTheTemplate())
|
||||
|
||||
assertEquals(WizardLogProgram.NONE, state.integrations.logProgram)
|
||||
assertFalse(state.integrations.qrgFollow)
|
||||
assertFalse(state.integrations.clusterServer)
|
||||
assertFalse(state.integrations.rotator)
|
||||
assertFalse(state.integrations.airScout)
|
||||
assertEquals(
|
||||
listOf(
|
||||
WizardSwitch.SECOND_CHAT, WizardSwitch.LOG_UDP, WizardSwitch.LOG_FILE,
|
||||
WizardSwitch.QRG_FOLLOW, WizardSwitch.CLUSTER_SERVER, WizardSwitch.AIRSCOUT,
|
||||
),
|
||||
state.switchedOff,
|
||||
"the summary names everything the template had on",
|
||||
)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun theNewPagesComeAfterTheLocationAndCanBeWalkedThrough() {
|
||||
val state = SetupWizardState(freshInstallationLikeTheTemplate())
|
||||
state.fillFirstInstallation()
|
||||
|
||||
state.next()
|
||||
assertEquals(WizardPage.ANTENNA, state.page)
|
||||
assertTrue(state.canGoNext, "the antenna values are proposals and valid as they stand")
|
||||
state.next()
|
||||
assertEquals(WizardPage.LOG, state.page)
|
||||
state.next()
|
||||
assertEquals(WizardPage.GEAR, state.page)
|
||||
state.next()
|
||||
assertEquals(WizardPage.SUMMARY, state.page)
|
||||
|
||||
state.back()
|
||||
assertEquals(WizardPage.GEAR, state.page)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun finishingEarlyStillSwitchesANewStationsIntegrationsOff() {
|
||||
val state = SetupWizardState(freshInstallationLikeTheTemplate())
|
||||
state.fillFirstInstallation()
|
||||
assertTrue(state.canFinish)
|
||||
|
||||
state.finish()
|
||||
|
||||
assertEquals(WizardPage.SUMMARY, state.page)
|
||||
assertTrue(state.switchedOff.contains(WizardSwitch.LOG_UDP), "a skipped page of a new station still applies")
|
||||
assertTrue(state.switchedOff.contains(WizardSwitch.AIRSCOUT))
|
||||
}
|
||||
|
||||
@Test
|
||||
fun aKeptStationSkipsTheNewPagesAndSwitchesNothingOff() {
|
||||
val state = SetupWizardState(duplicatedWinTestStation())
|
||||
state.chooseStationSource(WizardSource.KEEP)
|
||||
state.next()
|
||||
|
||||
assertEquals(
|
||||
listOf(WizardPage.ENTRY, WizardPage.PERSONAL, WizardPage.LOGIN, WizardPage.SUMMARY),
|
||||
state.pages,
|
||||
)
|
||||
assertEquals(WizardLogProgram.WINTEST, state.integrations.logProgram, "the summary shows what is stored")
|
||||
assertTrue(state.integrations.rotator)
|
||||
assertEquals(emptyList<WizardSwitch>(), state.switchedOff)
|
||||
assertTrue(state.logPageEditable)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun changeFromTheSummaryOpensANewPageOfAKeptStation() {
|
||||
val state = SetupWizardState(duplicatedWinTestStation())
|
||||
state.chooseStationSource(WizardSource.KEEP)
|
||||
state.next()
|
||||
state.name = "Philipp"
|
||||
state.next()
|
||||
state.callsign = "DL0TEST"
|
||||
state.password = "secret"
|
||||
state.next()
|
||||
assertEquals(WizardPage.SUMMARY, state.page)
|
||||
|
||||
state.edit(WizardPage.GEAR)
|
||||
assertEquals(WizardPage.GEAR, state.page)
|
||||
state.integrations.rotator = false
|
||||
state.next()
|
||||
|
||||
assertEquals(WizardPage.SUMMARY, state.page)
|
||||
assertEquals(listOf(WizardSwitch.ROTATOR), state.switchedOff)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun aKeptStationWithSeveralLogSourcesCannotOpenTheLogPage() {
|
||||
val state = SetupWizardState(duplicatedProfile().apply {
|
||||
setLogsynch_wintestNetworkListenerEnabled(false)
|
||||
setLogsynch_ucxUDPWkdCallListenerEnabled(true)
|
||||
setLogsynch_fileBasedWkdCallInterpreterEnabled(true)
|
||||
})
|
||||
state.chooseStationSource(WizardSource.KEEP)
|
||||
state.next()
|
||||
state.name = "Philipp"
|
||||
state.next()
|
||||
state.callsign = "DL0TEST"
|
||||
state.password = "secret"
|
||||
state.next()
|
||||
|
||||
assertFalse(state.logPageEditable, "the page knows one source and would switch the other off")
|
||||
state.edit(WizardPage.LOG)
|
||||
assertEquals(WizardPage.SUMMARY, state.page, "the log page must stay shut")
|
||||
|
||||
state.edit(WizardPage.GEAR)
|
||||
assertEquals(WizardPage.GEAR, state.page, "the other pages are not affected")
|
||||
}
|
||||
|
||||
@Test
|
||||
fun anInvalidOptionalPageBlocksSaving() {
|
||||
val state = SetupWizardState(freshInstallationLikeTheTemplate())
|
||||
state.fillFirstInstallation()
|
||||
state.next()
|
||||
state.next()
|
||||
assertEquals(WizardPage.LOG, state.page)
|
||||
|
||||
state.integrations.chooseLogProgram(WizardLogProgram.UDP)
|
||||
state.integrations.udpPort = 0
|
||||
|
||||
assertFalse(state.canGoNext)
|
||||
assertFalse(state.canFinish, "a summary that cannot be saved helps nobody")
|
||||
assertFalse(state.mandatoryComplete)
|
||||
|
||||
state.integrations.udpPort = 12060
|
||||
assertTrue(state.canGoNext)
|
||||
assertTrue(state.mandatoryComplete)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun antennaValuesTypedForANewStationAreGoneWhenTheStationIsKeptAfterAll() {
|
||||
val profile = duplicatedWinTestStation().apply { setStn_antennaBeamWidthDeg(28.0) }
|
||||
val state = SetupWizardState(profile)
|
||||
state.chooseStationSource(WizardSource.NEW)
|
||||
state.next()
|
||||
state.name = "Philipp"
|
||||
state.next()
|
||||
state.callsign = "DL0TEST"
|
||||
state.password = "secret"
|
||||
state.next()
|
||||
state.locator = "JO50AA"
|
||||
state.setBand(WizardBand.B144, true)
|
||||
state.next()
|
||||
assertEquals(WizardPage.ANTENNA, state.page)
|
||||
state.antenna.beamWidthDeg = 99.0
|
||||
|
||||
repeat(4) { state.back() }
|
||||
assertEquals(WizardPage.ENTRY, state.page)
|
||||
state.chooseStationSource(WizardSource.KEEP)
|
||||
state.next()
|
||||
|
||||
assertFalse(state.pages.contains(WizardPage.ANTENNA), "a kept station does not write the antenna page")
|
||||
assertEquals(
|
||||
28.0,
|
||||
state.antenna.beamWidthDeg,
|
||||
"the summary must not show a value that Save will not write",
|
||||
)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun theSummaryOfAKeptStationShowsWhatSaveLeavesOn() {
|
||||
// No log source, but the DX cluster server and a frequency source are on.
|
||||
val state = SetupWizardState(duplicatedWinTestStation().apply {
|
||||
setLogsynch_wintestNetworkListenerEnabled(false)
|
||||
setLogsynch_wintestQrgSyncEnabled(true)
|
||||
setNotify_dxClusterServerEnabled(true)
|
||||
})
|
||||
state.chooseStationSource(WizardSource.KEEP)
|
||||
state.next()
|
||||
state.name = "Philipp"
|
||||
state.next()
|
||||
state.callsign = "DL0TEST"
|
||||
state.password = "secret"
|
||||
state.next()
|
||||
assertEquals(WizardPage.SUMMARY, state.page)
|
||||
|
||||
assertTrue(state.summaryClusterServer, "Save leaves it on, so the summary must not say no")
|
||||
assertTrue(state.summaryQrgFollow)
|
||||
assertFalse(state.switchedOff.contains(WizardSwitch.CLUSTER_SERVER))
|
||||
|
||||
// Once the log page is part of the run its answers count, and what they drop is named.
|
||||
state.edit(WizardPage.LOG)
|
||||
state.next()
|
||||
|
||||
assertFalse(state.summaryClusterServer)
|
||||
assertFalse(state.summaryQrgFollow)
|
||||
assertTrue(state.switchedOff.containsAll(listOf(WizardSwitch.QRG_FOLLOW, WizardSwitch.CLUSTER_SERVER)))
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,115 @@
|
||||
package kst4contest.view.compose.wizard
|
||||
|
||||
import kst4contest.model.ChatPreferences
|
||||
import kst4contest.testing.Await.awaitUntil
|
||||
import org.junit.jupiter.api.Assertions.assertEquals
|
||||
import org.junit.jupiter.api.Assumptions.assumeFalse
|
||||
import org.junit.jupiter.api.Test
|
||||
import java.awt.Dialog
|
||||
import java.awt.EventQueue
|
||||
import java.awt.GraphicsEnvironment
|
||||
import java.awt.Window
|
||||
import java.nio.file.Path
|
||||
import java.time.Duration
|
||||
import java.util.concurrent.Executors
|
||||
import java.util.concurrent.Future
|
||||
import java.util.concurrent.TimeUnit
|
||||
|
||||
/**
|
||||
* The wizard's dialog must open from both threads that open it: `main` at startup, and the
|
||||
* event thread when the menu rebuilds the runtime. A latch-based wait deadlocked the profile
|
||||
* picker in exactly the second case; see OperatorProfilePickerWindow.
|
||||
*/
|
||||
class SetupWizardWindowTest {
|
||||
|
||||
private companion object {
|
||||
fun prefs() = ChatPreferences(Path.of("setup-wizard-window-test-unused.xml"))
|
||||
|
||||
val wizardTitle = wizardLanguageStore(SetupWizardState(prefs())).strings.wizardTitle
|
||||
}
|
||||
|
||||
private fun showingDialog(): Window? =
|
||||
Window.getWindows().firstOrNull {
|
||||
it is Dialog && it.isShowing && it.javaClass.name.contains("ComposeDialog") && it.title == wizardTitle
|
||||
}
|
||||
|
||||
/** Removes whatever dialog this test still has showing, without waiting and without failing again. */
|
||||
private fun disposeLeftoverDialog() {
|
||||
EventQueue.invokeLater {
|
||||
showingDialog()?.dispose()
|
||||
}
|
||||
}
|
||||
|
||||
private fun <T> showWithInterruptedCleanup(show: () -> T): T {
|
||||
try {
|
||||
return show()
|
||||
} catch (interrupted: InterruptedException) {
|
||||
// invokeAndWait can post the open event after the test's first cleanup was queued.
|
||||
disposeLeftoverDialog()
|
||||
throw interrupted
|
||||
}
|
||||
}
|
||||
|
||||
private val closer = Executors.newSingleThreadExecutor()
|
||||
|
||||
/** Closes the dialog the way its X does, as soon as it is on screen. */
|
||||
private fun closeOnceShowing(): Future<*> =
|
||||
closer.submit {
|
||||
awaitUntil(Duration.ofSeconds(10), "the wizard's dialog never appeared") {
|
||||
showingDialog() != null
|
||||
}
|
||||
EventQueue.invokeLater {
|
||||
val window = showingDialog()
|
||||
window?.dispatchEvent(java.awt.event.WindowEvent(window, java.awt.event.WindowEvent.WINDOW_CLOSING))
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
fun closingTheWindowCountsAsLater() {
|
||||
assumeFalse(GraphicsEnvironment.isHeadless(), "needs a display")
|
||||
|
||||
val worker = Executors.newSingleThreadExecutor()
|
||||
try {
|
||||
val closing = closeOnceShowing()
|
||||
val prefs = prefs()
|
||||
val call = worker.submit<SetupWizardOutcome> {
|
||||
showWithInterruptedCleanup { SetupWizardWindow.show(SetupWizardState(prefs), prefs) }
|
||||
}
|
||||
|
||||
// A dialog that never appears must fail the test, not hang it.
|
||||
val outcome = call.get(20, TimeUnit.SECONDS)
|
||||
|
||||
assertEquals(SetupWizardOutcome.LATER, outcome)
|
||||
assertEquals("", prefs.getStn_loginCallSign(), "closing the window wrote something")
|
||||
closing.get(1, TimeUnit.SECONDS)
|
||||
} finally {
|
||||
disposeLeftoverDialog()
|
||||
worker.shutdownNow()
|
||||
closer.shutdownNow()
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
fun opensAndReturnsWhenCalledOnTheEventThread() {
|
||||
assumeFalse(GraphicsEnvironment.isHeadless(), "needs a display")
|
||||
|
||||
val worker = Executors.newSingleThreadExecutor()
|
||||
try {
|
||||
val closing = closeOnceShowing()
|
||||
val prefs = prefs()
|
||||
val call = worker.submit {
|
||||
showWithInterruptedCleanup {
|
||||
EventQueue.invokeAndWait { SetupWizardWindow.show(SetupWizardState(prefs), prefs) }
|
||||
}
|
||||
}
|
||||
|
||||
// A deadlock here has no timeout of its own: without one this never completes.
|
||||
call.get(20, TimeUnit.SECONDS)
|
||||
closing.get(1, TimeUnit.SECONDS)
|
||||
} finally {
|
||||
disposeLeftoverDialog()
|
||||
worker.shutdownNow()
|
||||
closer.shutdownNow()
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,339 @@
|
||||
package kst4contest.view.compose.wizard
|
||||
|
||||
import kst4contest.model.ChatCategory
|
||||
import kst4contest.model.ChatPreferences
|
||||
import org.junit.jupiter.api.Assertions.assertArrayEquals
|
||||
import org.junit.jupiter.api.Assertions.assertEquals
|
||||
import org.junit.jupiter.api.Assertions.assertFalse
|
||||
import org.junit.jupiter.api.Assertions.assertTrue
|
||||
import org.junit.jupiter.api.Test
|
||||
import org.junit.jupiter.api.io.TempDir
|
||||
import java.nio.file.Files
|
||||
import java.nio.file.Path
|
||||
import java.nio.file.StandardCopyOption
|
||||
|
||||
/**
|
||||
* What the wizard does to a real preferences file: nothing until Save, exactly the answers
|
||||
* afterwards, and every setting it never asked about left as it was.
|
||||
*/
|
||||
class SetupWizardWriteTest(@param:TempDir private val directory: Path) {
|
||||
|
||||
/** A copy of the bundled template, read the way the runtime reads a profile. */
|
||||
private fun templateFile(): Path {
|
||||
val file = directory.resolve("preferences.xml")
|
||||
ChatPreferences::class.java.getResourceAsStream(ChatPreferences.PREFERENCE_RESOURCE).use { template ->
|
||||
Files.copy(requireNotNull(template), file, StandardCopyOption.REPLACE_EXISTING)
|
||||
}
|
||||
return file
|
||||
}
|
||||
|
||||
private fun read(file: Path): ChatPreferences =
|
||||
ChatPreferences(file).also { assertTrue(it.readPreferencesFromXmlFile(), "reading $file failed") }
|
||||
|
||||
/** A profile an operator set up: read the template, change it, write it back. */
|
||||
private fun configuredFile(change: ChatPreferences.() -> Unit = {}): Path {
|
||||
val file = templateFile()
|
||||
read(file).apply {
|
||||
setStn_loginCallSign("DL0TEST")
|
||||
setStn_loginPassword("secret")
|
||||
setStn_loginNameMainCat("Philipp")
|
||||
setStn_loginNameSecondCat("Philipp")
|
||||
setStn_loginLocatorMainCat("JO50AA")
|
||||
setStn_bandActive144(true)
|
||||
setLoginChatCategoryMain(ChatCategory(2))
|
||||
setLoginToSecondChatEnabled(false)
|
||||
change()
|
||||
assertTrue(writePreferencesToXmlFile())
|
||||
}
|
||||
return file
|
||||
}
|
||||
|
||||
private fun SetupWizardState.answerFirstInstallation() {
|
||||
name = "Philipp"
|
||||
next()
|
||||
callsign = "DL0TEST"
|
||||
password = "secret"
|
||||
next()
|
||||
locator = "JO50AA"
|
||||
setBand(WizardBand.B144, true)
|
||||
setBand(WizardBand.B1240, true)
|
||||
finish()
|
||||
}
|
||||
|
||||
@Test
|
||||
fun nothingIsWrittenBeforeSave() {
|
||||
val file = templateFile()
|
||||
val prefs = read(file)
|
||||
// Taken after the read, so only the wizard is measured here.
|
||||
val before = Files.readAllBytes(file)
|
||||
|
||||
SetupWizardState(prefs).answerFirstInstallation()
|
||||
|
||||
assertArrayEquals(before, Files.readAllBytes(file), "the file changed without Save")
|
||||
assertEquals("DO5AMF", prefs.getStn_loginCallSign(), "the preferences changed without Save")
|
||||
}
|
||||
|
||||
@Test
|
||||
fun saveWritesExactlyTheAnswers() {
|
||||
val file = templateFile()
|
||||
val prefs = read(file)
|
||||
val state = SetupWizardState(prefs)
|
||||
state.answerFirstInstallation()
|
||||
|
||||
assertTrue(state.writeTo(prefs))
|
||||
|
||||
val restored = read(file)
|
||||
assertEquals("DL0TEST", restored.getStn_loginCallSign())
|
||||
assertEquals("secret", restored.getStn_loginPassword())
|
||||
assertEquals("Philipp", restored.getStn_loginNameMainCat())
|
||||
assertEquals("JO50AA", restored.getStn_loginLocatorMainCat())
|
||||
assertTrue(restored.isStn_bandActive144())
|
||||
assertTrue(restored.isStn_bandActive1240())
|
||||
assertFalse(restored.isStn_bandActive432(), "a band the operator did not tick is off")
|
||||
assertEquals(2, restored.getLoginChatCategoryMain().categoryNumber)
|
||||
assertFalse(restored.isLoginToSecondChatEnabled(), "a new station starts without a second chat")
|
||||
}
|
||||
|
||||
@Test
|
||||
fun whatTheWizardNeverAskedAboutIsLeftAsItWas() {
|
||||
val file = templateFile()
|
||||
val prefs = read(file)
|
||||
val server = prefs.getStn_on4kstServersDns()
|
||||
val rotatorPort = prefs.getStn_pstRotatorPort()
|
||||
val beamWidth = prefs.getStn_antennaBeamWidthDeg()
|
||||
|
||||
val state = SetupWizardState(prefs)
|
||||
state.answerFirstInstallation()
|
||||
assertTrue(state.writeTo(prefs))
|
||||
|
||||
val restored = read(file)
|
||||
assertEquals(server, restored.getStn_on4kstServersDns())
|
||||
assertEquals(rotatorPort, restored.getStn_pstRotatorPort())
|
||||
assertEquals(beamWidth, restored.getStn_antennaBeamWidthDeg())
|
||||
}
|
||||
|
||||
@Test
|
||||
fun aCallsignIsStoredAsTyped() {
|
||||
val file = templateFile()
|
||||
val prefs = read(file)
|
||||
val state = SetupWizardState(prefs)
|
||||
state.name = "Philipp"
|
||||
state.next()
|
||||
state.callsign = " do5amf-2 "
|
||||
state.password = "secret"
|
||||
state.next()
|
||||
state.locator = " jo50aa "
|
||||
state.setBand(WizardBand.B144, true)
|
||||
|
||||
assertTrue(state.writeTo(prefs))
|
||||
|
||||
val restored = read(file)
|
||||
assertEquals("do5amf-2", restored.getStn_loginCallSign(), "only the surrounding blanks go")
|
||||
assertEquals("jo50aa", restored.getStn_loginLocatorMainCat(), "the Station tab stores it as typed too")
|
||||
}
|
||||
|
||||
@Test
|
||||
fun aKeptCategoryOutsideTheSuggestionsSurvives() {
|
||||
val file = configuredFile {
|
||||
setLoginChatCategoryMain(ChatCategory(7))
|
||||
setLoginToSecondChatEnabled(true)
|
||||
setLoginChatCategorySecond(ChatCategory(9))
|
||||
}
|
||||
val prefs = read(file)
|
||||
val state = SetupWizardState(prefs)
|
||||
state.chooseLoginSource(WizardSource.KEEP)
|
||||
state.chooseStationSource(WizardSource.KEEP)
|
||||
state.next()
|
||||
state.next()
|
||||
|
||||
assertTrue(state.writeTo(prefs))
|
||||
|
||||
val restored = read(file)
|
||||
assertEquals(7, restored.getLoginChatCategoryMain().categoryNumber)
|
||||
assertTrue(restored.isLoginToSecondChatEnabled())
|
||||
assertEquals(9, restored.getLoginChatCategorySecond().categoryNumber)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun theSecondNameFollowsTheFirstUnlessItWasSetApart() {
|
||||
val following = configuredFile()
|
||||
val prefs = read(following)
|
||||
val state = SetupWizardState(prefs)
|
||||
state.chooseLoginSource(WizardSource.KEEP)
|
||||
state.chooseStationSource(WizardSource.KEEP)
|
||||
state.next()
|
||||
state.name = "Marc"
|
||||
state.next()
|
||||
assertTrue(state.writeTo(prefs))
|
||||
assertEquals("Marc", read(following).getStn_loginNameSecondCat())
|
||||
|
||||
val apart = configuredFile { setStn_loginNameSecondCat("Philipp SHF") }
|
||||
val apartPrefs = read(apart)
|
||||
val apartState = SetupWizardState(apartPrefs)
|
||||
apartState.chooseLoginSource(WizardSource.KEEP)
|
||||
apartState.chooseStationSource(WizardSource.KEEP)
|
||||
apartState.next()
|
||||
apartState.name = "Marc"
|
||||
apartState.next()
|
||||
assertTrue(apartState.writeTo(apartPrefs))
|
||||
assertEquals("Philipp SHF", read(apart).getStn_loginNameSecondCat(), "a name set apart is the operator's")
|
||||
}
|
||||
|
||||
@Test
|
||||
fun anUntouchedLanguageStaysEvenIfThisBuildDoesNotKnowIt() {
|
||||
val file = configuredFile { setGuiOptions_language("fr") }
|
||||
val prefs = read(file)
|
||||
val state = SetupWizardState(prefs)
|
||||
state.chooseLoginSource(WizardSource.KEEP)
|
||||
state.chooseStationSource(WizardSource.KEEP)
|
||||
state.next()
|
||||
state.next()
|
||||
|
||||
assertTrue(state.writeTo(prefs))
|
||||
|
||||
assertEquals("fr", read(file).getGuiOptions_language())
|
||||
}
|
||||
|
||||
@Test
|
||||
fun incompleteAnswersAreNotWritten() {
|
||||
val file = templateFile()
|
||||
val prefs = read(file)
|
||||
val before = Files.readAllBytes(file)
|
||||
val state = SetupWizardState(prefs)
|
||||
state.name = "Philipp"
|
||||
|
||||
assertFalse(state.writeTo(prefs))
|
||||
|
||||
assertArrayEquals(before, Files.readAllBytes(file))
|
||||
assertEquals("DO5AMF", prefs.getStn_loginCallSign())
|
||||
}
|
||||
|
||||
@Test
|
||||
fun aFailedWriteIsReported() {
|
||||
val source = read(templateFile())
|
||||
// A directory where the file should be: the write cannot succeed.
|
||||
val unwritable = ChatPreferences(Files.createDirectory(directory.resolve("not-a-file")))
|
||||
val state = SetupWizardState(source)
|
||||
state.answerFirstInstallation()
|
||||
|
||||
assertFalse(state.writeTo(unwritable), "a write that failed must not read as saved")
|
||||
}
|
||||
|
||||
@Test
|
||||
fun aNewStationWithoutALogProgramHasEverySynchronisationOff() {
|
||||
val file = templateFile()
|
||||
val prefs = read(file)
|
||||
val state = SetupWizardState(prefs)
|
||||
state.answerFirstInstallation()
|
||||
|
||||
assertTrue(state.writeTo(prefs))
|
||||
|
||||
val restored = read(file)
|
||||
assertFalse(restored.isLogsynch_wintestNetworkListenerEnabled())
|
||||
assertFalse(restored.isLogsynch_ucxUDPWkdCallListenerEnabled())
|
||||
assertFalse(restored.isLogsynch_fileBasedWkdCallInterpreterEnabled())
|
||||
assertFalse(restored.isTrxSynch_ucxLogUDPListenerEnabled())
|
||||
assertFalse(restored.isLogsynch_wintestQrgSyncEnabled())
|
||||
assertFalse(restored.isNotify_dxClusterServerEnabled())
|
||||
assertFalse(restored.isStn_pstRotatorEnabled())
|
||||
assertFalse(restored.isAirScout_asUDPListenerEnabled())
|
||||
}
|
||||
|
||||
@Test
|
||||
fun theAnswersOfTheNewPagesAreWritten() {
|
||||
val file = templateFile()
|
||||
val prefs = read(file)
|
||||
val state = SetupWizardState(prefs)
|
||||
state.name = "Philipp"
|
||||
state.next()
|
||||
state.callsign = "DL0TEST"
|
||||
state.password = "secret"
|
||||
state.next()
|
||||
state.locator = "JO50AA"
|
||||
state.setBand(WizardBand.B144, true)
|
||||
state.next()
|
||||
state.antenna.beamWidthDeg = 28.0
|
||||
state.antenna.heightAslText = "612"
|
||||
state.next()
|
||||
state.integrations.chooseLogProgram(WizardLogProgram.WINTEST)
|
||||
state.integrations.wintestPort = 9871
|
||||
// Stated, not taken from the template: without a name the page could not be left.
|
||||
state.integrations.wintestStationName = "KST"
|
||||
state.integrations.qrgFollow = true
|
||||
state.next()
|
||||
assertEquals(WizardPage.GEAR, state.page)
|
||||
state.integrations.rotator = true
|
||||
state.integrations.rotatorHost = "127.0.0.1"
|
||||
state.integrations.rotatorPort = 12000
|
||||
|
||||
assertTrue(state.writeTo(prefs))
|
||||
|
||||
val restored = read(file)
|
||||
assertEquals(28.0, restored.getStn_antennaBeamWidthDeg())
|
||||
assertEquals(612.0, restored.getStn_pathAnalysisOwnHeightAslMeters())
|
||||
assertTrue(restored.isLogsynch_wintestNetworkListenerEnabled())
|
||||
assertEquals(9871, restored.getLogsynch_wintestNetworkPort())
|
||||
assertTrue(restored.isLogsynch_wintestQrgSyncEnabled())
|
||||
assertFalse(restored.isLogsynch_ucxUDPWkdCallListenerEnabled())
|
||||
assertTrue(restored.isStn_pstRotatorEnabled())
|
||||
assertFalse(restored.isAirScout_asUDPListenerEnabled())
|
||||
}
|
||||
|
||||
@Test
|
||||
fun aKeptStationKeepsEveryIntegrationAsItWas() {
|
||||
// The template's integrations, several log sources among them, under a real login.
|
||||
val file = configuredFile()
|
||||
val before = read(file)
|
||||
val prefs = read(file)
|
||||
val state = SetupWizardState(prefs)
|
||||
state.chooseLoginSource(WizardSource.KEEP)
|
||||
state.chooseStationSource(WizardSource.KEEP)
|
||||
state.next()
|
||||
state.next()
|
||||
|
||||
assertTrue(state.writeTo(prefs))
|
||||
|
||||
val restored = read(file)
|
||||
assertEquals(before.isLogsynch_ucxUDPWkdCallListenerEnabled(), restored.isLogsynch_ucxUDPWkdCallListenerEnabled())
|
||||
assertEquals(
|
||||
before.isLogsynch_fileBasedWkdCallInterpreterEnabled(),
|
||||
restored.isLogsynch_fileBasedWkdCallInterpreterEnabled(),
|
||||
)
|
||||
assertEquals(before.isTrxSynch_ucxLogUDPListenerEnabled(), restored.isTrxSynch_ucxLogUDPListenerEnabled())
|
||||
assertEquals(before.isNotify_dxClusterServerEnabled(), restored.isNotify_dxClusterServerEnabled())
|
||||
assertEquals(before.isAirScout_asUDPListenerEnabled(), restored.isAirScout_asUDPListenerEnabled())
|
||||
assertEquals(before.getStn_antennaBeamWidthDeg(), restored.getStn_antennaBeamWidthDeg())
|
||||
assertTrue(
|
||||
restored.isLogsynch_ucxUDPWkdCallListenerEnabled() && restored.isLogsynch_fileBasedWkdCallInterpreterEnabled(),
|
||||
"the template has two log sources on; if this fails the template changed and the test needs another example",
|
||||
)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun openingOneNewPageOfAKeptStationWritesOnlyThatPage() {
|
||||
val file = configuredFile()
|
||||
val before = read(file)
|
||||
val prefs = read(file)
|
||||
val state = SetupWizardState(prefs)
|
||||
state.chooseLoginSource(WizardSource.KEEP)
|
||||
state.chooseStationSource(WizardSource.KEEP)
|
||||
state.next()
|
||||
state.next()
|
||||
state.edit(WizardPage.GEAR)
|
||||
state.integrations.rotator = true
|
||||
state.integrations.rotatorHost = "127.0.0.1"
|
||||
state.integrations.rotatorPort = 12000
|
||||
state.next()
|
||||
|
||||
assertTrue(state.writeTo(prefs))
|
||||
|
||||
val restored = read(file)
|
||||
assertTrue(restored.isStn_pstRotatorEnabled())
|
||||
assertEquals(
|
||||
before.isLogsynch_fileBasedWkdCallInterpreterEnabled(),
|
||||
restored.isLogsynch_fileBasedWkdCallInterpreterEnabled(),
|
||||
"the log page was not opened, so the log sources stay",
|
||||
)
|
||||
assertEquals(before.isNotify_dxClusterServerEnabled(), restored.isNotify_dxClusterServerEnabled())
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,151 @@
|
||||
package kst4contest.view.compose.wizard
|
||||
|
||||
import kst4contest.model.ChatPreferences
|
||||
import org.junit.jupiter.api.Assertions.assertEquals
|
||||
import org.junit.jupiter.api.Assertions.assertFalse
|
||||
import org.junit.jupiter.api.Assertions.assertTrue
|
||||
import org.junit.jupiter.api.Test
|
||||
import java.nio.file.Path
|
||||
|
||||
/**
|
||||
* The antenna and power answers: always proposals taken from what is stored, never empty,
|
||||
* and the site elevation read the way the Station tab reads it.
|
||||
*/
|
||||
class WizardAntennaTest {
|
||||
|
||||
private fun prefs(configure: ChatPreferences.() -> Unit = {}): ChatPreferences =
|
||||
ChatPreferences(Path.of("wizard-antenna-test-unused.xml")).apply(configure)
|
||||
|
||||
private fun stored() = prefs {
|
||||
setStn_antennaBeamWidthDeg(28.0)
|
||||
setStn_pathAnalysisOwnAntennaGainDbi(16.5)
|
||||
setStn_pathAnalysisOwnAntennaHeightMeters(18.0)
|
||||
setStn_pathAnalysisOwnTxPowerWatts(400.0)
|
||||
setStn_pathAnalysisOwnHeightAslMeters(612.0)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun theAnswersStartAsTheStoredValues() {
|
||||
val antenna = WizardAntenna(stored())
|
||||
|
||||
assertEquals(28.0, antenna.beamWidthDeg)
|
||||
assertEquals(16.5, antenna.gainDbi)
|
||||
assertEquals(18.0, antenna.heightMeters)
|
||||
assertEquals(400.0, antenna.txPowerWatts)
|
||||
assertEquals("612", antenna.heightAslText, "a whole number is shown without a decimal point")
|
||||
assertTrue(antenna.complete)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun anUnsetSiteElevationIsAnEmptyField() {
|
||||
val antenna = WizardAntenna(prefs { setStn_pathAnalysisOwnHeightAslMeters(Double.NaN) })
|
||||
|
||||
assertEquals("", antenna.heightAslText)
|
||||
assertFalse(antenna.heightAslRefused, "empty means the elevation model, not an error")
|
||||
assertTrue(antenna.complete)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun aFractionalSiteElevationKeepsItsFraction() {
|
||||
val antenna = WizardAntenna(prefs { setStn_pathAnalysisOwnHeightAslMeters(250.5) })
|
||||
|
||||
assertEquals("250.5", antenna.heightAslText)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun theSiteElevationIsReadTheWayTheStationTabReadsIt() {
|
||||
val antenna = WizardAntenna(stored())
|
||||
|
||||
listOf("", " ", "250", "250,5", "250.5", "-100").forEach {
|
||||
antenna.heightAslText = it
|
||||
assertFalse(antenna.heightAslRefused, "'$it' must be accepted")
|
||||
}
|
||||
listOf("abc", "99999", "-501", "12 m").forEach {
|
||||
antenna.heightAslText = it
|
||||
assertTrue(antenna.heightAslRefused, "'$it' must be refused")
|
||||
assertFalse(antenna.complete)
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
fun aNumberThatIsNotOneMakesThePageIncomplete() {
|
||||
val antenna = WizardAntenna(stored())
|
||||
|
||||
antenna.gainDbi = Double.NaN
|
||||
assertFalse(antenna.complete)
|
||||
|
||||
antenna.gainDbi = 12.0
|
||||
antenna.txPowerWatts = Double.POSITIVE_INFINITY
|
||||
assertFalse(antenna.complete)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun antennaHeightMustBeNonNegative() {
|
||||
val antenna = WizardAntenna(stored())
|
||||
|
||||
antenna.heightMeters = -5.0
|
||||
assertFalse(antenna.complete)
|
||||
|
||||
antenna.heightMeters = 0.0
|
||||
assertTrue(antenna.complete)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun writingPutsTheAnswersIntoThePreferences() {
|
||||
val target = prefs()
|
||||
val antenna = WizardAntenna(stored())
|
||||
antenna.beamWidthDeg = 35.0
|
||||
antenna.heightAslText = "250,5"
|
||||
|
||||
antenna.writeTo(target)
|
||||
|
||||
assertEquals(35.0, target.getStn_antennaBeamWidthDeg())
|
||||
assertEquals(16.5, target.getStn_pathAnalysisOwnAntennaGainDbi())
|
||||
assertEquals(18.0, target.getStn_pathAnalysisOwnAntennaHeightMeters())
|
||||
assertEquals(400.0, target.getStn_pathAnalysisOwnTxPowerWatts())
|
||||
assertEquals(250.5, target.getStn_pathAnalysisOwnHeightAslMeters())
|
||||
}
|
||||
|
||||
@Test
|
||||
fun anEmptySiteElevationIsWrittenAsUnset() {
|
||||
val target = prefs { setStn_pathAnalysisOwnHeightAslMeters(612.0) }
|
||||
val antenna = WizardAntenna(stored())
|
||||
antenna.heightAslText = ""
|
||||
|
||||
antenna.writeTo(target)
|
||||
|
||||
assertTrue(target.getStn_pathAnalysisOwnHeightAslMeters().isNaN(), "empty hands the elevation back to the model")
|
||||
}
|
||||
|
||||
@Test
|
||||
fun loadingTheStoredValuesAgainDropsWhatWasTyped() {
|
||||
val antenna = WizardAntenna(stored())
|
||||
antenna.beamWidthDeg = 99.0
|
||||
antenna.gainDbi = 1.0
|
||||
antenna.heightMeters = 2.0
|
||||
antenna.txPowerWatts = 3.0
|
||||
antenna.heightAslText = "abc"
|
||||
|
||||
antenna.loadStored()
|
||||
|
||||
assertEquals(28.0, antenna.beamWidthDeg)
|
||||
assertEquals(16.5, antenna.gainDbi)
|
||||
assertEquals(18.0, antenna.heightMeters)
|
||||
assertEquals(400.0, antenna.txPowerWatts)
|
||||
assertEquals("612", antenna.heightAslText)
|
||||
assertTrue(antenna.complete)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun aNegativeStoredAntennaHeightIsClampedToZero() {
|
||||
val prefs = stored()
|
||||
val field = ChatPreferences::class.java.getDeclaredField("stn_pathAnalysisOwnAntennaHeightMeters")
|
||||
field.isAccessible = true
|
||||
field.setDouble(prefs, -2.0)
|
||||
|
||||
val antenna = WizardAntenna(prefs)
|
||||
|
||||
assertEquals(0.0, antenna.heightMeters)
|
||||
assertTrue(antenna.complete)
|
||||
}
|
||||
}
|
||||
+363
@@ -0,0 +1,363 @@
|
||||
package kst4contest.view.compose.wizard
|
||||
|
||||
import kst4contest.model.ChatPreferences
|
||||
import org.junit.jupiter.api.Assertions.assertEquals
|
||||
import org.junit.jupiter.api.Assertions.assertFalse
|
||||
import org.junit.jupiter.api.Assertions.assertTrue
|
||||
import org.junit.jupiter.api.Test
|
||||
import java.nio.file.Path
|
||||
|
||||
/**
|
||||
* The answers about log program, rotator and AirScout: what a new station starts with, what
|
||||
* a kept one shows, when a page may be left, and what is written.
|
||||
*/
|
||||
class WizardIntegrationsTest {
|
||||
|
||||
private fun prefs(configure: ChatPreferences.() -> Unit = {}): ChatPreferences =
|
||||
ChatPreferences(Path.of("wizard-integrations-test-unused.xml")).apply(configure)
|
||||
|
||||
/** Everything off, so each test states what it switches on. */
|
||||
private fun allOff(configure: ChatPreferences.() -> Unit = {}) = prefs {
|
||||
setLogsynch_wintestNetworkListenerEnabled(false)
|
||||
setLogsynch_ucxUDPWkdCallListenerEnabled(false)
|
||||
setLogsynch_fileBasedWkdCallInterpreterEnabled(false)
|
||||
setTrxSynch_ucxLogUDPListenerEnabled(false)
|
||||
setLogsynch_wintestQrgSyncEnabled(false)
|
||||
setNotify_dxClusterServerEnabled(false)
|
||||
setStn_pstRotatorEnabled(false)
|
||||
setAirScout_asUDPListenerEnabled(false)
|
||||
setTrxSynch_so2rEnabled(false)
|
||||
setStn_pstRotator2Enabled(false)
|
||||
setLogsynch_ucxUDPWkdCallListenerPort(12060)
|
||||
setLogsynch_wintestNetworkPort(9871)
|
||||
setLogsynch_wintestNetworkStationNameOfKST("KST")
|
||||
setStn_pstRotatorHost("127.0.0.1")
|
||||
setStn_pstRotatorPort(12000)
|
||||
setStn_pstRotator2Port(12010)
|
||||
setAirScout_asCommunicationPort(9872)
|
||||
setAirScout_asServerNameString("AS")
|
||||
setAirScout_asClientNameString("KST")
|
||||
configure()
|
||||
}
|
||||
|
||||
/** What the bundled template switches on. */
|
||||
private fun likeTheTemplate() = allOff {
|
||||
setLogsynch_ucxUDPWkdCallListenerEnabled(true)
|
||||
setLogsynch_fileBasedWkdCallInterpreterEnabled(true)
|
||||
setTrxSynch_ucxLogUDPListenerEnabled(true)
|
||||
setNotify_dxClusterServerEnabled(true)
|
||||
setAirScout_asUDPListenerEnabled(true)
|
||||
}
|
||||
|
||||
private fun winTestStation() = allOff {
|
||||
setLogsynch_wintestNetworkListenerEnabled(true)
|
||||
setLogsynch_wintestNetworkPort(9999)
|
||||
setLogsynch_wintestQrgSyncEnabled(true)
|
||||
setNotify_dxClusterServerEnabled(true)
|
||||
setStn_pstRotatorEnabled(true)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun aKeptStationShowsWhatIsStored() {
|
||||
val answers = WizardIntegrations(winTestStation())
|
||||
|
||||
assertEquals(WizardLogProgram.WINTEST, answers.logProgram)
|
||||
assertEquals(9999, answers.wintestPort)
|
||||
assertTrue(answers.qrgFollow)
|
||||
assertTrue(answers.clusterServer)
|
||||
assertTrue(answers.rotator)
|
||||
assertFalse(answers.airScout)
|
||||
assertFalse(answers.severalStoredLogSources)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun aNewStationStartsWithEverythingOffButKeepsTheNumbers() {
|
||||
val answers = WizardIntegrations(winTestStation())
|
||||
|
||||
answers.loadFresh()
|
||||
|
||||
assertEquals(WizardLogProgram.NONE, answers.logProgram)
|
||||
assertFalse(answers.qrgFollow)
|
||||
assertFalse(answers.clusterServer)
|
||||
assertFalse(answers.rotator)
|
||||
assertFalse(answers.airScout)
|
||||
assertEquals(9999, answers.wintestPort, "a port the operator once set is a proposal, not lost")
|
||||
assertTrue(answers.logComplete)
|
||||
assertTrue(answers.gearComplete)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun loadingTheStoredValuesAgainUndoesAFreshStart() {
|
||||
val answers = WizardIntegrations(winTestStation())
|
||||
answers.loadFresh()
|
||||
|
||||
answers.loadStored()
|
||||
|
||||
assertEquals(WizardLogProgram.WINTEST, answers.logProgram)
|
||||
assertTrue(answers.rotator)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun severalStoredSourcesMakeTheLogPageUneditable() {
|
||||
val answers = WizardIntegrations(likeTheTemplate())
|
||||
|
||||
assertTrue(answers.severalStoredLogSources, "the template has the network listener and the file on")
|
||||
// Shown as one of them, the network one first; the state decides not to offer the page.
|
||||
assertEquals(WizardLogProgram.UDP, answers.logProgram)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun leavingANetworkProgramDropsWhatOnlyANetworkProgramCanDo() {
|
||||
val answers = WizardIntegrations(allOff())
|
||||
answers.chooseLogProgram(WizardLogProgram.UDP)
|
||||
answers.qrgFollow = true
|
||||
answers.clusterServer = true
|
||||
assertTrue(answers.networked)
|
||||
|
||||
answers.chooseLogProgram(WizardLogProgram.FILE)
|
||||
|
||||
assertFalse(answers.networked)
|
||||
assertFalse(answers.qrgFollow)
|
||||
assertFalse(answers.clusterServer)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun aLogFileNeedsAFile() {
|
||||
val answers = WizardIntegrations(allOff())
|
||||
// The compiled-in default names a file, which is a proposal like every stored value.
|
||||
answers.filePath = ""
|
||||
|
||||
answers.chooseLogProgram(WizardLogProgram.FILE)
|
||||
assertFalse(answers.logComplete)
|
||||
|
||||
answers.filePath = "/home/op/log.txt"
|
||||
assertTrue(answers.logComplete)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun anInvalidPortMakesItsPageIncomplete() {
|
||||
val answers = WizardIntegrations(allOff())
|
||||
|
||||
answers.chooseLogProgram(WizardLogProgram.UDP)
|
||||
answers.udpPort = 0
|
||||
assertFalse(answers.logComplete)
|
||||
answers.udpPort = 70000
|
||||
assertFalse(answers.logComplete)
|
||||
answers.udpPort = 12060
|
||||
assertTrue(answers.logComplete)
|
||||
|
||||
answers.chooseLogProgram(WizardLogProgram.WINTEST)
|
||||
answers.wintestStationName = " "
|
||||
assertFalse(answers.logComplete, "Win-Test needs a station name to send from")
|
||||
answers.wintestStationName = "KST"
|
||||
answers.wintestPort = -1
|
||||
assertFalse(answers.logComplete)
|
||||
|
||||
// A port of a program that is not chosen is nobody's problem.
|
||||
answers.chooseLogProgram(WizardLogProgram.NONE)
|
||||
assertTrue(answers.logComplete)
|
||||
|
||||
answers.airScout = true
|
||||
answers.airScoutPort = 0
|
||||
assertFalse(answers.gearComplete)
|
||||
answers.airScoutPort = 9872
|
||||
answers.airScoutServerName = "A\"S"
|
||||
assertFalse(answers.gearComplete, "a quotation mark breaks the AirScout message")
|
||||
answers.airScoutServerName = "AS"
|
||||
assertTrue(answers.gearComplete)
|
||||
|
||||
answers.rotator = true
|
||||
answers.rotatorHost = " "
|
||||
assertFalse(answers.gearComplete)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun aRotatorPortNextToRotatorTwoIsRefusedOnlyWithSo2r() {
|
||||
val withSo2r = WizardIntegrations(allOff {
|
||||
setTrxSynch_so2rEnabled(true)
|
||||
setStn_pstRotator2Enabled(true)
|
||||
})
|
||||
withSo2r.rotator = true
|
||||
withSo2r.rotatorPort = 12011
|
||||
assertTrue(withSo2r.rotatorPortClashes, "PSTRotator answers on port + 1")
|
||||
assertFalse(withSo2r.gearComplete)
|
||||
withSo2r.rotatorPort = 12000
|
||||
assertFalse(withSo2r.rotatorPortClashes)
|
||||
assertTrue(withSo2r.gearComplete)
|
||||
|
||||
val withoutSo2r = WizardIntegrations(allOff())
|
||||
withoutSo2r.rotator = true
|
||||
withoutSo2r.rotatorPort = 12011
|
||||
assertFalse(withoutSo2r.rotatorPortClashes, "rotator 2 is not in use without SO2R")
|
||||
assertTrue(withoutSo2r.gearComplete)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun writingTheLogPageSwitchesExactlyTheChosenSourceOn() {
|
||||
val target = likeTheTemplate()
|
||||
val answers = WizardIntegrations(target)
|
||||
answers.loadFresh()
|
||||
answers.chooseLogProgram(WizardLogProgram.WINTEST)
|
||||
answers.wintestPort = 9871
|
||||
answers.wintestStationName = " KST "
|
||||
answers.qrgFollow = true
|
||||
|
||||
answers.writeLogTo(target)
|
||||
|
||||
assertTrue(target.isLogsynch_wintestNetworkListenerEnabled())
|
||||
assertFalse(target.isLogsynch_ucxUDPWkdCallListenerEnabled())
|
||||
assertFalse(target.isLogsynch_fileBasedWkdCallInterpreterEnabled())
|
||||
assertEquals(9871, target.getLogsynch_wintestNetworkPort())
|
||||
assertEquals("KST", target.getLogsynch_wintestNetworkStationNameOfKST(), "trimmed, as the tab stores it")
|
||||
assertTrue(target.isLogsynch_wintestQrgSyncEnabled())
|
||||
assertFalse(target.isTrxSynch_ucxLogUDPListenerEnabled(), "the other program's frequency source goes off")
|
||||
assertFalse(target.isNotify_dxClusterServerEnabled())
|
||||
assertTrue(target.isAirScout_asUDPListenerEnabled(), "the log page does not touch AirScout")
|
||||
}
|
||||
|
||||
@Test
|
||||
fun writingNoLogProgramSwitchesEverySynchronisationOff() {
|
||||
val target = likeTheTemplate()
|
||||
val answers = WizardIntegrations(target)
|
||||
answers.loadFresh()
|
||||
|
||||
answers.writeLogTo(target)
|
||||
|
||||
assertFalse(target.isLogsynch_wintestNetworkListenerEnabled())
|
||||
assertFalse(target.isLogsynch_ucxUDPWkdCallListenerEnabled())
|
||||
assertFalse(target.isLogsynch_fileBasedWkdCallInterpreterEnabled())
|
||||
assertFalse(target.isTrxSynch_ucxLogUDPListenerEnabled())
|
||||
assertFalse(target.isLogsynch_wintestQrgSyncEnabled())
|
||||
assertFalse(target.isNotify_dxClusterServerEnabled())
|
||||
assertEquals(12060, target.getLogsynch_ucxUDPWkdCallListenerPort(), "an unused port is left alone")
|
||||
}
|
||||
|
||||
@Test
|
||||
fun writingTheGearPageSetsRotatorAndAirScoutOnly() {
|
||||
val target = likeTheTemplate()
|
||||
val answers = WizardIntegrations(target)
|
||||
answers.loadFresh()
|
||||
answers.rotator = true
|
||||
answers.rotatorHost = " 192.168.1.20 "
|
||||
answers.rotatorPort = 12040
|
||||
|
||||
answers.writeGearTo(target)
|
||||
|
||||
assertTrue(target.isStn_pstRotatorEnabled())
|
||||
assertEquals("192.168.1.20", target.getStn_pstRotatorHost())
|
||||
assertEquals(12040, target.getStn_pstRotatorPort())
|
||||
assertFalse(target.isAirScout_asUDPListenerEnabled())
|
||||
assertEquals(9872, target.getAirScout_asCommunicationPort(), "an unused port is left alone")
|
||||
assertTrue(target.isLogsynch_ucxUDPWkdCallListenerEnabled(), "the gear page does not touch the log sources")
|
||||
}
|
||||
|
||||
@Test
|
||||
fun theStoredSwitchesAreWhatTheProfileHasOn() {
|
||||
val template = WizardIntegrations(likeTheTemplate())
|
||||
|
||||
assertEquals(
|
||||
setOf(WizardSwitch.LOG_UDP, WizardSwitch.LOG_FILE, WizardSwitch.QRG_FOLLOW, WizardSwitch.CLUSTER_SERVER),
|
||||
template.storedLogSwitches(),
|
||||
)
|
||||
assertEquals(setOf(WizardSwitch.AIRSCOUT), template.storedGearSwitches())
|
||||
|
||||
val nothing = WizardIntegrations(allOff())
|
||||
assertEquals(emptySet<WizardSwitch>(), nothing.storedLogSwitches())
|
||||
assertEquals(emptySet<WizardSwitch>(), nothing.storedGearSwitches())
|
||||
}
|
||||
|
||||
@Test
|
||||
fun theAnsweredSwitchesFollowThePages() {
|
||||
val answers = WizardIntegrations(likeTheTemplate())
|
||||
answers.loadFresh()
|
||||
|
||||
assertEquals(emptySet<WizardSwitch>(), answers.answeredLogSwitches())
|
||||
assertEquals(emptySet<WizardSwitch>(), answers.answeredGearSwitches())
|
||||
|
||||
answers.chooseLogProgram(WizardLogProgram.WINTEST)
|
||||
answers.qrgFollow = true
|
||||
answers.clusterServer = true
|
||||
answers.rotator = true
|
||||
|
||||
assertEquals(
|
||||
setOf(WizardSwitch.LOG_WINTEST, WizardSwitch.QRG_FOLLOW, WizardSwitch.CLUSTER_SERVER),
|
||||
answers.answeredLogSwitches(),
|
||||
)
|
||||
assertEquals(setOf(WizardSwitch.ROTATOR), answers.answeredGearSwitches())
|
||||
// The stored side does not move with the answers.
|
||||
assertEquals(setOf(WizardSwitch.AIRSCOUT), answers.storedGearSwitches())
|
||||
}
|
||||
|
||||
@Test
|
||||
fun theHighestPortIsNoRotatorPort() {
|
||||
// PSTRotator answers on port + 1, so the setter stores 1..65534 only and would
|
||||
// replace 65535 by its factory default without a word.
|
||||
val target = allOff()
|
||||
val answers = WizardIntegrations(target)
|
||||
answers.rotator = true
|
||||
|
||||
answers.rotatorPort = 65535
|
||||
assertFalse(answers.gearComplete, "65535 would be stored as 12000")
|
||||
|
||||
answers.rotatorPort = 65534
|
||||
assertTrue(answers.gearComplete)
|
||||
answers.writeGearTo(target)
|
||||
assertEquals(65534, target.getStn_pstRotatorPort(), "an accepted port is stored as entered")
|
||||
|
||||
answers.rotatorPort = 0
|
||||
assertFalse(answers.gearComplete)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun loadingAgainPutsTheDetailsBackToTheStoredOnes() {
|
||||
val answers = WizardIntegrations(winTestStation())
|
||||
val storedFilePath = answers.filePath
|
||||
answers.udpPort = 1
|
||||
answers.wintestPort = 2
|
||||
answers.wintestStationName = "typed"
|
||||
answers.filePath = "/typed"
|
||||
answers.rotatorHost = "typed"
|
||||
answers.rotatorPort = 3
|
||||
answers.airScoutPort = 4
|
||||
answers.airScoutServerName = "typed"
|
||||
answers.airScoutClientName = "typed"
|
||||
|
||||
answers.loadFresh()
|
||||
|
||||
assertEquals(12060, answers.udpPort)
|
||||
assertEquals(9999, answers.wintestPort)
|
||||
assertEquals("KST", answers.wintestStationName)
|
||||
assertEquals(storedFilePath, answers.filePath)
|
||||
assertEquals("127.0.0.1", answers.rotatorHost)
|
||||
assertEquals(12000, answers.rotatorPort)
|
||||
assertEquals(9872, answers.airScoutPort)
|
||||
assertEquals("AS", answers.airScoutServerName)
|
||||
assertEquals("KST", answers.airScoutClientName)
|
||||
|
||||
answers.filePath = "/typed"
|
||||
answers.rotatorPort = 3
|
||||
answers.loadStored()
|
||||
|
||||
assertEquals(storedFilePath, answers.filePath)
|
||||
assertEquals(12000, answers.rotatorPort)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun theStoredSwitchesAreKnownWhateverTheLogProgram() {
|
||||
// The settings window lets the DX cluster server and a frequency source run without
|
||||
// a log source; the page's own answers cannot express that.
|
||||
val answers = WizardIntegrations(allOff {
|
||||
setNotify_dxClusterServerEnabled(true)
|
||||
setTrxSynch_ucxLogUDPListenerEnabled(true)
|
||||
})
|
||||
|
||||
assertEquals(WizardLogProgram.NONE, answers.logProgram)
|
||||
assertFalse(answers.clusterServer, "the page shows none of it")
|
||||
assertTrue(answers.storedClusterServer)
|
||||
assertTrue(answers.storedQrgFollow)
|
||||
|
||||
val off = WizardIntegrations(allOff())
|
||||
assertFalse(off.storedClusterServer)
|
||||
assertFalse(off.storedQrgFollow)
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,182 @@
|
||||
package kst4contest.view.compose.wizard
|
||||
|
||||
import kst4contest.model.ChatCategory
|
||||
import kst4contest.model.ChatPreferences
|
||||
import org.junit.jupiter.api.Assertions.assertEquals
|
||||
import org.junit.jupiter.api.Assertions.assertFalse
|
||||
import org.junit.jupiter.api.Assertions.assertTrue
|
||||
import org.junit.jupiter.api.Test
|
||||
import org.mockito.Mockito
|
||||
import java.io.File
|
||||
import java.lang.reflect.Modifier
|
||||
import java.nio.file.Path
|
||||
|
||||
/**
|
||||
* What "the station" is when one profile takes it from another.
|
||||
*
|
||||
* The two lists under src/test/resources are the decision, one line per ChatPreferences
|
||||
* setter. A setter in neither list fails the first test, so a new setting cannot be forgotten
|
||||
* here: somebody has to say whether another operator at the same station should inherit it.
|
||||
*/
|
||||
class WizardStationCopyTest {
|
||||
|
||||
private fun lines(name: String): Set<String> =
|
||||
File("src/test/resources/$name").readLines().map { it.trim() }.filter { it.isNotEmpty() }.toSet()
|
||||
|
||||
private val stationSetters = lines("wizard-station-setters.txt")
|
||||
private val otherSetters = lines("wizard-other-setters.txt")
|
||||
|
||||
/** Every public setter with one parameter, the shape every preference has. */
|
||||
private fun allSetters(): Set<String> =
|
||||
ChatPreferences::class.java.methods
|
||||
.filter { it.name.startsWith("set") && it.parameterCount == 1 && Modifier.isPublic(it.modifiers) }
|
||||
.map { it.name }
|
||||
.toSet()
|
||||
|
||||
private fun prefs(configure: ChatPreferences.() -> Unit = {}): ChatPreferences =
|
||||
ChatPreferences(Path.of("wizard-station-copy-test-unused.xml")).apply(configure)
|
||||
|
||||
@Test
|
||||
fun everySetterIsClassified() {
|
||||
val all = allSetters()
|
||||
|
||||
assertEquals(
|
||||
emptySet<String>(),
|
||||
all - stationSetters - otherSetters,
|
||||
"new ChatPreferences setters: add each to wizard-station-setters.txt (and to copyStation) " +
|
||||
"or to wizard-other-setters.txt",
|
||||
)
|
||||
assertEquals(emptySet<String>(), (stationSetters + otherSetters) - all, "listed setters that no longer exist")
|
||||
assertEquals(emptySet<String>(), stationSetters.intersect(otherSetters), "a setter cannot be in both lists")
|
||||
}
|
||||
|
||||
@Test
|
||||
fun copyStationCallsExactlyTheStationSetters() {
|
||||
val target = Mockito.mock(ChatPreferences::class.java)
|
||||
|
||||
copyStation(prefs(), target)
|
||||
|
||||
val called = Mockito.mockingDetails(target).invocations
|
||||
.map { it.method.name }
|
||||
.filter { it.startsWith("set") }
|
||||
|
||||
assertEquals(stationSetters, called.toSet(), "copyStation and wizard-station-setters.txt disagree")
|
||||
assertEquals(called.size, called.toSet().size, "a setter was called twice")
|
||||
assertTrue(
|
||||
Mockito.mockingDetails(target).invocations.none { it.method.name == "writePreferencesToXmlFile" },
|
||||
"copying must not write a file",
|
||||
)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun theStationArrivesIncludingWhatTheWizardNeverAsks() {
|
||||
val donor = prefs {
|
||||
setStn_loginLocatorMainCat("JO50AA")
|
||||
setStn_bandActive144(true)
|
||||
setStn_bandActive1240(true)
|
||||
setStn_bandActive432(false)
|
||||
setLoginChatCategoryMain(ChatCategory(2))
|
||||
setLoginToSecondChatEnabled(true)
|
||||
setLoginChatCategorySecond(ChatCategory(3))
|
||||
setStn_qtfDefault(270.0)
|
||||
setStn_maxQRBDefault(800.0)
|
||||
setStn_pathAnalysisDemRootDirectory("/srv/dem")
|
||||
setStn_pathAnalysisContestMarginDb(9.0)
|
||||
setTrxSynch_so2rEnabled(true)
|
||||
setStn_pstRotator2Enabled(true)
|
||||
setStn_pstRotator2Port(12020)
|
||||
// Several log sources at once: the wizard's own question could not express this.
|
||||
setLogsynch_wintestNetworkListenerEnabled(true)
|
||||
setLogsynch_fileBasedWkdCallInterpreterEnabled(true)
|
||||
setLogsynch_wintestNetworkStationNameOfWintestClient1("RUN")
|
||||
setLogsynch_wintestUsePassQrg(true)
|
||||
setAirScout_asBandString("4320000")
|
||||
}
|
||||
val target = prefs {
|
||||
setStn_bandActive432(true)
|
||||
setLoginChatCategoryMain(ChatCategory(3))
|
||||
}
|
||||
|
||||
copyStation(donor, target)
|
||||
|
||||
assertEquals("JO50AA", target.getStn_loginLocatorMainCat())
|
||||
assertTrue(target.isStn_bandActive144())
|
||||
assertTrue(target.isStn_bandActive1240())
|
||||
assertFalse(target.isStn_bandActive432(), "a band the donor does not have goes off")
|
||||
assertEquals(2, target.getLoginChatCategoryMain().categoryNumber)
|
||||
assertTrue(target.isLoginToSecondChatEnabled())
|
||||
assertEquals(3, target.getLoginChatCategorySecond().categoryNumber)
|
||||
assertEquals(270.0, target.getStn_qtfDefault())
|
||||
assertEquals(800.0, target.getStn_maxQRBDefault())
|
||||
assertEquals("/srv/dem", target.getStn_pathAnalysisDemRootDirectory())
|
||||
assertEquals(9.0, target.getStn_pathAnalysisContestMarginDb())
|
||||
assertTrue(target.isTrxSynch_so2rEnabled())
|
||||
assertTrue(target.isStn_pstRotator2Enabled())
|
||||
assertEquals(12020, target.getStn_pstRotator2Port())
|
||||
assertTrue(target.isLogsynch_wintestNetworkListenerEnabled())
|
||||
assertTrue(target.isLogsynch_fileBasedWkdCallInterpreterEnabled())
|
||||
assertEquals("RUN", target.getLogsynch_wintestNetworkStationNameOfWintestClient1())
|
||||
assertTrue(target.isLogsynch_wintestUsePassQrg())
|
||||
assertEquals("4320000", target.getAirScout_asBandString())
|
||||
}
|
||||
|
||||
@Test
|
||||
fun whatBelongsToTheOperatorStays() {
|
||||
val donor = prefs {
|
||||
setStn_loginCallSign("DL0TEST")
|
||||
setStn_loginPassword("donor-secret")
|
||||
setStn_loginNameMainCat("Donor")
|
||||
setStn_loginNameSecondCat("Donor SHF")
|
||||
setGuiOptions_language("en")
|
||||
setGUI_darkModeActiveByDefault(true)
|
||||
setStn_on4kstServersDns("donor.example")
|
||||
setNotify_DXCSrv_SpottersCallSign("DL0TEST")
|
||||
setBcn_beaconTextMainCat("donor beacon")
|
||||
}
|
||||
val target = prefs {
|
||||
setStn_loginCallSign("DM5XX")
|
||||
setStn_loginPassword("own-secret")
|
||||
setStn_loginNameMainCat("Own")
|
||||
setStn_loginNameSecondCat("Own SHF")
|
||||
setGuiOptions_language("de")
|
||||
setGUI_darkModeActiveByDefault(false)
|
||||
setStn_on4kstServersDns("own.example")
|
||||
setNotify_DXCSrv_SpottersCallSign("DM5XX")
|
||||
setBcn_beaconTextMainCat("own beacon")
|
||||
}
|
||||
|
||||
copyStation(donor, target)
|
||||
|
||||
assertEquals("DM5XX", target.getStn_loginCallSign())
|
||||
assertEquals("own-secret", target.getStn_loginPassword())
|
||||
assertEquals("Own", target.getStn_loginNameMainCat())
|
||||
assertEquals("Own SHF", target.getStn_loginNameSecondCat())
|
||||
assertEquals("de", target.getGuiOptions_language())
|
||||
assertFalse(target.isGUI_darkModeActiveByDefault())
|
||||
assertEquals("own.example", target.getStn_on4kstServersDns())
|
||||
assertEquals("DM5XX", target.getNotify_DXCSrv_SpottersCallSign().get())
|
||||
assertEquals("own beacon", target.getBcn_beaconTextMainCat())
|
||||
}
|
||||
|
||||
@Test
|
||||
fun theDonorIsNotChangedAndSharesNoObjectWithTheTarget() {
|
||||
val donor = prefs { setLoginChatCategoryMain(ChatCategory(2)) }
|
||||
val target = prefs()
|
||||
|
||||
copyStation(donor, target)
|
||||
target.getLoginChatCategoryMain().categoryNumber = 7
|
||||
|
||||
assertEquals(2, donor.getLoginChatCategoryMain().categoryNumber, "the two profiles must not share a category object")
|
||||
}
|
||||
|
||||
@Test
|
||||
fun theFallbackBandComesWithTheStation() {
|
||||
// It completes frequencies given without a band, so it has to fit the station's bands.
|
||||
val donor = prefs { setNotify_optionalFrequencyPrefix("432") }
|
||||
val target = prefs { setNotify_optionalFrequencyPrefix("144") }
|
||||
|
||||
copyStation(donor, target)
|
||||
|
||||
assertEquals("432", target.getNotify_optionalFrequencyPrefix().get())
|
||||
}
|
||||
}
|
||||
+1
-1
@@ -73,7 +73,7 @@ class RemainingTextsFollowTheLanguageTest {
|
||||
|
||||
assertEquals("Wertung", score.title(), "the column title stayed in the old language")
|
||||
assertEquals(
|
||||
"Einen ganzzahligen Bakenabstand von mindestens 1 Minute eingeben.",
|
||||
"Einen ganzzahligen Bakenabstand von mindestens 5 Minuten eingeben.",
|
||||
beacon.commitBeaconInterval("0"),
|
||||
"the refusal from the tab state stayed in the old language",
|
||||
)
|
||||
|
||||
@@ -0,0 +1,72 @@
|
||||
setActualQTF
|
||||
setBcn_beaconIntervalInMinutesMainCat
|
||||
setBcn_beaconIntervalInMinutesSecondCat
|
||||
setBcn_beaconTextMainCat
|
||||
setBcn_beaconTextSecondCat
|
||||
setBcn_beaconsEnabledMainCat
|
||||
setBcn_beaconsEnabledSecondCat
|
||||
setBcn_contestScoreSum
|
||||
setChatState
|
||||
setGUI_darkModeActive
|
||||
setGUI_darkModeActiveByDefault
|
||||
setGUIclusterAndQSOMonStage_SceneSizeHW
|
||||
setGUImainWindowLeftSplitPane_dividerposition
|
||||
setGUImainWindowRightSplitPane_dividerposition
|
||||
setGUImessageSectionSplitpane_dividerposition
|
||||
setGUIpnl_directedMSGWin_dividerpositionDefault
|
||||
setGUIscn_ChatwindowMainSceneSizeHW
|
||||
setGUIselectedCallSignSplitPane_dividerposition
|
||||
setGUIsettingsStageSceneSizeHW
|
||||
setGUIstage_updateStage_SceneSizeHW
|
||||
setGUIstationMapAlwaysOnTop
|
||||
setGUIstationMapClusteringEnabled
|
||||
setGUIstationMapPathAnalysisVisible
|
||||
setGUIstationMapStagePositionXY
|
||||
setGUIstationMapStageSceneSizeHW
|
||||
setGuiOptions_defaultFilterNothing
|
||||
setGuiOptions_defaultFilterPmToMe
|
||||
setGuiOptions_defaultFilterPmToOther
|
||||
setGuiOptions_defaultFilterPublicMsgs
|
||||
setGuiOptions_language
|
||||
setGuiOptions_paletteOverridesDay
|
||||
setGuiOptions_paletteOverridesEvening
|
||||
setGuiOptions_rememberWindowPositions
|
||||
setGuiOptions_showFreshCallHintInBandColumns
|
||||
setGuiOptions_showGrossFieldWorkedHintInBandColumns
|
||||
setLogSynch_storeWorkedCallSignsFileNameUDPMessageBackup
|
||||
setLogsynch_storeWorkedCallSignsFileNameUDPMessageBackup
|
||||
setLstNotify_QSOSniffer_sniffedPrefixLocList
|
||||
setLst_txtShortCutBtnList
|
||||
setLst_txtSnipList
|
||||
setMYQRGFirstCat
|
||||
setMYQRGSecondCat
|
||||
setMessageHandling_autoAnswerEnabled
|
||||
setMessageHandling_autoAnswerEnabledSecondCat
|
||||
setMessageHandling_autoAnswerTextMainCat
|
||||
setMessageHandling_autoAnswerTextSecondCat
|
||||
setMessageHandling_autoAnswerToQRGRequestEnabled
|
||||
setMessageHandling_beaconUnworkedstationsPrefix
|
||||
setMessageHandling_debugModeToFileEnabled
|
||||
setMessageHandling_unworkedStnRequesterBeaconsEnabled
|
||||
setMessageHandling_unworkedStnRequesterBeaconsInterval
|
||||
setMessageHandling_unworkedStnRequesterBeaconsText
|
||||
setNotify_DXCSrv_SpottersCallSign
|
||||
setNotify_DXClusterServerTriggerBearing
|
||||
setNotify_DXClusterServerTriggerOnQRGDetect
|
||||
setNotify_bandUpgradeHintOnLogEnabled
|
||||
setNotify_bandUpgradePriorityBoostEnabled
|
||||
setNotify_momentumWindowSeconds
|
||||
setNotify_noReplyPenaltyMinutes
|
||||
setNotify_playCWCallsignsOnRxedPMs
|
||||
setNotify_playSimpleSounds
|
||||
setNotify_playVoiceCallsignsOnRxedPMs
|
||||
setNotify_positiveSignalsPatterns
|
||||
setProgramVersion
|
||||
setStn_loginAFKState
|
||||
setStn_loginCallSign
|
||||
setStn_loginNameMainCat
|
||||
setStn_loginNameSecondCat
|
||||
setStn_loginPassword
|
||||
setStn_on4kstServersDns
|
||||
setStn_on4kstServersPort
|
||||
setStoreAndRestorePreferencesFileName
|
||||
@@ -0,0 +1,66 @@
|
||||
setAirScout_asBandString
|
||||
setAirScout_asClientNameString
|
||||
setAirScout_asCommunicationPort
|
||||
setAirScout_asServerNameString
|
||||
setAirScout_asUDPListenerEnabled
|
||||
setAirScout_autoBandSelectionEnabled
|
||||
setLoginChatCategoryMain
|
||||
setLoginChatCategorySecond
|
||||
setLoginToSecondChatEnabled
|
||||
setLogsynch_fileBasedWkdCallInterpreterEnabled
|
||||
setLogsynch_fileBasedWkdCallInterpreterFileNameReadOnly
|
||||
setLogsynch_ucxUDPWkdCallListenerEnabled
|
||||
setLogsynch_ucxUDPWkdCallListenerPort
|
||||
setLogsynch_wintestNetworkBroadcastAddress
|
||||
setLogsynch_wintestNetworkListenerEnabled
|
||||
setLogsynch_wintestNetworkPort
|
||||
setLogsynch_wintestNetworkSimulationEnabled
|
||||
setLogsynch_wintestNetworkSkedPushEnabled
|
||||
setLogsynch_wintestNetworkStationIDOfKST
|
||||
setLogsynch_wintestNetworkStationNameOfKST
|
||||
setLogsynch_wintestNetworkStationNameOfWintestClient1
|
||||
setLogsynch_wintestNetworkStationNameOfWintestClient2
|
||||
setLogsynch_wintestQrgSyncEnabled
|
||||
setLogsynch_wintestSkedMode
|
||||
setLogsynch_wintestUsePassQrg
|
||||
setNotify_dxClusterServerEnabled
|
||||
setNotify_dxclusterServerPort
|
||||
setNotify_optionalFrequencyPrefix
|
||||
setStn_antennaBeamWidthDeg
|
||||
setStn_bandActive10G
|
||||
setStn_bandActive1240
|
||||
setStn_bandActive144
|
||||
setStn_bandActive2300
|
||||
setStn_bandActive3400
|
||||
setStn_bandActive432
|
||||
setStn_bandActive50
|
||||
setStn_bandActive5600
|
||||
setStn_bandActive70
|
||||
setStn_loginLocatorMainCat
|
||||
setStn_maxQRBDefault
|
||||
setStn_pathAnalysisContestMarginDb
|
||||
setStn_pathAnalysisDefaultTargetAntennaGainDbi
|
||||
setStn_pathAnalysisDefaultTargetAntennaHeightMeters
|
||||
setStn_pathAnalysisDefaultTargetTxPowerWatts
|
||||
setStn_pathAnalysisDemDatasetId
|
||||
setStn_pathAnalysisDemRootDirectory
|
||||
setStn_pathAnalysisDxHighestPointInSquare
|
||||
setStn_pathAnalysisFeederLossIncreaseDbPer200MHz
|
||||
setStn_pathAnalysisMaxEstimatedFeederLossPerStationDb
|
||||
setStn_pathAnalysisOwnAntennaGainDbi
|
||||
setStn_pathAnalysisOwnAntennaHeightMeters
|
||||
setStn_pathAnalysisOwnHeightAslMeters
|
||||
setStn_pathAnalysisOwnTxPowerWatts
|
||||
setStn_pathAnalysisRequiredCwSignalDbm
|
||||
setStn_pathAnalysisRequiredSsbSignalDbm
|
||||
setStn_pathAnalysisVhfFeederLossPerStationDb
|
||||
setStn_pstRotator2Enabled
|
||||
setStn_pstRotator2Host
|
||||
setStn_pstRotator2Port
|
||||
setStn_pstRotatorEnabled
|
||||
setStn_pstRotatorHost
|
||||
setStn_pstRotatorPort
|
||||
setStn_qtfDefault
|
||||
setStn_useQtfFilterDirectionAsAntennaHeading
|
||||
setTrxSynch_so2rEnabled
|
||||
setTrxSynch_ucxLogUDPListenerEnabled
|
||||
@@ -0,0 +1,15 @@
|
||||
package kst4contest.controller;
|
||||
|
||||
/** Adds the fixed marker used by every user-visible automatic chat message. */
|
||||
final class AutomaticChatMessageFormatter {
|
||||
|
||||
/** Exact marker appended to every user-visible automatic chat message. */
|
||||
/* default */ static final String SUFFIX = " *a*";
|
||||
|
||||
private AutomaticChatMessageFormatter() {
|
||||
}
|
||||
|
||||
/* default */ static String appendSuffix(final String messageText) {
|
||||
return messageText + SUFFIX;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,66 @@
|
||||
package kst4contest.controller;
|
||||
|
||||
import java.util.OptionalLong;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
import kst4contest.model.Band;
|
||||
|
||||
/** Parses complete beacon-reference frequencies without floating-point comparisons. */
|
||||
final class BeaconFrequencyParser {
|
||||
private static final Pattern GROUPED = Pattern.compile(
|
||||
"^(\\d{2,5})[.,](\\d{1,3})(?:[.,](\\d{1,3}))?$"
|
||||
);
|
||||
private static final Pattern COMPACT = Pattern.compile("^\\d{5,8}$");
|
||||
|
||||
private BeaconFrequencyParser() {
|
||||
}
|
||||
|
||||
static OptionalLong parseHz(String value) {
|
||||
if (value == null) {
|
||||
return OptionalLong.empty();
|
||||
}
|
||||
|
||||
String normalized = value.trim();
|
||||
if (normalized.isEmpty()) {
|
||||
return OptionalLong.empty();
|
||||
}
|
||||
|
||||
try {
|
||||
long frequencyHz;
|
||||
Matcher grouped = GROUPED.matcher(normalized);
|
||||
if (grouped.matches()) {
|
||||
long megahertz = Long.parseLong(grouped.group(1));
|
||||
long kilohertz = rightPadToThree(grouped.group(2));
|
||||
long hertz = grouped.group(3) == null
|
||||
? 0L
|
||||
: rightPadToThree(grouped.group(3));
|
||||
frequencyHz = Math.addExact(
|
||||
Math.multiplyExact(megahertz, 1_000_000L),
|
||||
Math.addExact(Math.multiplyExact(kilohertz, 1_000L), hertz)
|
||||
);
|
||||
} else if (COMPACT.matcher(normalized).matches()) {
|
||||
long compact = Long.parseLong(normalized);
|
||||
frequencyHz = Math.multiplyExact(compact, 1_000L);
|
||||
} else {
|
||||
return OptionalLong.empty();
|
||||
}
|
||||
|
||||
if (frequencyHz <= 0L
|
||||
|| Band.fromFrequency(frequencyHz / 1_000_000.0) == null) {
|
||||
return OptionalLong.empty();
|
||||
}
|
||||
return OptionalLong.of(frequencyHz);
|
||||
} catch (ArithmeticException | NumberFormatException ignored) {
|
||||
return OptionalLong.empty();
|
||||
}
|
||||
}
|
||||
|
||||
private static long rightPadToThree(String digits) {
|
||||
long value = Long.parseLong(digits);
|
||||
for (int index = digits.length(); index < 3; index++) {
|
||||
value *= 10L;
|
||||
}
|
||||
return value;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,225 @@
|
||||
package kst4contest.controller;
|
||||
|
||||
import java.util.OptionalLong;
|
||||
|
||||
import kst4contest.model.BeaconStatusSnapshot;
|
||||
import kst4contest.model.BeaconStatusSnapshot.AggregateState;
|
||||
import kst4contest.model.BeaconStatusSnapshot.CategoryStatus;
|
||||
import kst4contest.model.BeaconStatusSnapshot.InactiveReason;
|
||||
import kst4contest.model.ChatPreferences;
|
||||
|
||||
/** Owns session-only beacon activation, QRG references, reasons, and send failures. */
|
||||
final class BeaconSessionState {
|
||||
static final long MAX_AUTOMATIC_QRG_DELTA_HZ = 5_000L;
|
||||
|
||||
enum Channel {
|
||||
MAIN,
|
||||
SECOND
|
||||
}
|
||||
|
||||
private final ChannelState main = new ChannelState();
|
||||
private final ChannelState second = new ChannelState();
|
||||
|
||||
void resetSession(ChatPreferences preferences) {
|
||||
synchronized (this) {
|
||||
main.reset();
|
||||
second.reset();
|
||||
}
|
||||
project(preferences);
|
||||
}
|
||||
|
||||
boolean setEnabled(Channel channel, boolean enabled, ChatPreferences preferences) {
|
||||
boolean accepted;
|
||||
synchronized (this) {
|
||||
ChannelState target = state(channel);
|
||||
if (!enabled) {
|
||||
target.disable(InactiveReason.USER_DISABLED);
|
||||
accepted = true;
|
||||
} else {
|
||||
InactiveReason invalidReason = missingRequiredQrg(channel, preferences);
|
||||
if (invalidReason != null) {
|
||||
target.disable(invalidReason);
|
||||
accepted = false;
|
||||
} else {
|
||||
target.enabled = true;
|
||||
target.failed = false;
|
||||
OptionalLong reference = ownQrg(channel, preferences);
|
||||
target.referenceHz = reference.isPresent() ? reference.getAsLong() : null;
|
||||
accepted = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
project(preferences);
|
||||
return accepted;
|
||||
}
|
||||
|
||||
void onManualQrgChanged(Channel channel, String value, ChatPreferences preferences) {
|
||||
if (channel == Channel.MAIN) {
|
||||
preferences.getMYQRGFirstCat().set(value);
|
||||
} else {
|
||||
preferences.getMYQRGSecondCat().set(value);
|
||||
}
|
||||
OptionalLong parsed = BeaconFrequencyParser.parseHz(value);
|
||||
synchronized (this) {
|
||||
ChannelState target = state(channel);
|
||||
if (target.enabled) {
|
||||
target.referenceHz = parsed.isPresent() ? parsed.getAsLong() : null;
|
||||
}
|
||||
revalidateEnabled(preferences);
|
||||
}
|
||||
project(preferences);
|
||||
}
|
||||
|
||||
void onExternalQrgChanged(Channel channel, long frequencyHz, ChatPreferences preferences) {
|
||||
boolean valid = frequencyHz > 0L && ownQrg(channel, preferences).isPresent();
|
||||
synchronized (this) {
|
||||
ChannelState target = state(channel);
|
||||
if (target.enabled) {
|
||||
if (!valid) {
|
||||
target.referenceHz = null;
|
||||
} else if (target.referenceHz == null) {
|
||||
target.referenceHz = frequencyHz;
|
||||
} else if (absoluteDifference(target.referenceHz, frequencyHz)
|
||||
> MAX_AUTOMATIC_QRG_DELTA_HZ) {
|
||||
target.disable(InactiveReason.AUTOMATIC_QRG_CHANGE);
|
||||
}
|
||||
}
|
||||
revalidateEnabled(preferences);
|
||||
}
|
||||
project(preferences);
|
||||
}
|
||||
|
||||
void onTemplateChanged(Channel channel, ChatPreferences preferences) {
|
||||
synchronized (this) {
|
||||
ChannelState target = state(channel);
|
||||
if (target.enabled) {
|
||||
InactiveReason reason = missingRequiredQrg(channel, preferences);
|
||||
if (reason != null) {
|
||||
target.disable(reason);
|
||||
}
|
||||
}
|
||||
}
|
||||
project(preferences);
|
||||
}
|
||||
|
||||
synchronized boolean isEnabled(Channel channel) {
|
||||
return state(channel).enabled;
|
||||
}
|
||||
|
||||
synchronized void recordSendFailure(Channel channel, boolean failed) {
|
||||
ChannelState target = state(channel);
|
||||
target.failed = target.enabled && failed;
|
||||
}
|
||||
|
||||
synchronized BeaconStatusSnapshot snapshot(ChatPreferences preferences) {
|
||||
boolean secondAvailable = preferences.isLoginToSecondChatEnabled();
|
||||
boolean mainEnabled = main.enabled;
|
||||
boolean secondEnabled = secondAvailable && second.enabled;
|
||||
boolean failed = (mainEnabled && main.failed) || (secondEnabled && second.failed);
|
||||
int available = secondAvailable ? 2 : 1;
|
||||
int enabled = (mainEnabled ? 1 : 0) + (secondEnabled ? 1 : 0);
|
||||
|
||||
AggregateState aggregate;
|
||||
if (failed) {
|
||||
aggregate = AggregateState.FAILED;
|
||||
} else if (enabled == 0) {
|
||||
aggregate = AggregateState.OFF;
|
||||
} else if (enabled == available) {
|
||||
aggregate = AggregateState.ON;
|
||||
} else {
|
||||
aggregate = AggregateState.PARTIAL;
|
||||
}
|
||||
|
||||
return new BeaconStatusSnapshot(
|
||||
aggregate,
|
||||
new CategoryStatus(true, mainEnabled, main.failed, main.reason),
|
||||
new CategoryStatus(secondAvailable, secondEnabled, second.failed, second.reason)
|
||||
);
|
||||
}
|
||||
|
||||
private void revalidateEnabled(ChatPreferences preferences) {
|
||||
revalidate(Channel.MAIN, preferences);
|
||||
revalidate(Channel.SECOND, preferences);
|
||||
}
|
||||
|
||||
private void revalidate(Channel channel, ChatPreferences preferences) {
|
||||
ChannelState target = state(channel);
|
||||
if (!target.enabled) {
|
||||
return;
|
||||
}
|
||||
InactiveReason reason = missingRequiredQrg(channel, preferences);
|
||||
if (reason != null) {
|
||||
target.disable(reason);
|
||||
}
|
||||
}
|
||||
|
||||
private static InactiveReason missingRequiredQrg(
|
||||
Channel channel,
|
||||
ChatPreferences preferences
|
||||
) {
|
||||
String template = channel == Channel.MAIN
|
||||
? preferences.getBcn_beaconTextMainCat()
|
||||
: preferences.getBcn_beaconTextSecondCat();
|
||||
String safeTemplate = template == null ? "" : template;
|
||||
if ((safeTemplate.contains("MYQRG") || safeTemplate.contains("MYQRGSHORT"))
|
||||
&& BeaconFrequencyParser.parseHz(preferences.getMYQRGFirstCat().get()).isEmpty()) {
|
||||
return InactiveReason.PRIMARY_QRG_UNAVAILABLE;
|
||||
}
|
||||
if (safeTemplate.contains("SECONDQRG")
|
||||
&& BeaconFrequencyParser.parseHz(preferences.getMYQRGSecondCat().get()).isEmpty()) {
|
||||
return InactiveReason.SECONDARY_QRG_UNAVAILABLE;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
private static OptionalLong ownQrg(Channel channel, ChatPreferences preferences) {
|
||||
String value = channel == Channel.MAIN
|
||||
? preferences.getMYQRGFirstCat().get()
|
||||
: preferences.getMYQRGSecondCat().get();
|
||||
return BeaconFrequencyParser.parseHz(value);
|
||||
}
|
||||
|
||||
private static long absoluteDifference(long first, long second) {
|
||||
return first >= second ? first - second : second - first;
|
||||
}
|
||||
|
||||
private void project(ChatPreferences preferences) {
|
||||
boolean mainEnabled;
|
||||
boolean secondEnabled;
|
||||
synchronized (this) {
|
||||
mainEnabled = main.enabled;
|
||||
secondEnabled = second.enabled;
|
||||
}
|
||||
if (preferences.isBcn_beaconsEnabledMainCat() != mainEnabled) {
|
||||
preferences.setBcn_beaconsEnabledMainCat(mainEnabled);
|
||||
}
|
||||
if (preferences.isBcn_beaconsEnabledSecondCat() != secondEnabled) {
|
||||
preferences.setBcn_beaconsEnabledSecondCat(secondEnabled);
|
||||
}
|
||||
}
|
||||
|
||||
private ChannelState state(Channel channel) {
|
||||
return channel == Channel.MAIN ? main : second;
|
||||
}
|
||||
|
||||
private static final class ChannelState {
|
||||
private boolean enabled;
|
||||
private boolean failed;
|
||||
private Long referenceHz;
|
||||
private InactiveReason reason = InactiveReason.NOT_ACTIVATED_THIS_SESSION;
|
||||
|
||||
private void reset() {
|
||||
enabled = false;
|
||||
failed = false;
|
||||
referenceHz = null;
|
||||
reason = InactiveReason.NOT_ACTIVATED_THIS_SESSION;
|
||||
}
|
||||
|
||||
private void disable(InactiveReason inactiveReason) {
|
||||
enabled = false;
|
||||
failed = false;
|
||||
referenceHz = null;
|
||||
reason = inactiveReason;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,25 +1,18 @@
|
||||
package kst4contest.controller;
|
||||
|
||||
import kst4contest.model.BeaconStatusSnapshot;
|
||||
import kst4contest.model.ChatPreferences;
|
||||
import kst4contest.model.ThreadStateMessage;
|
||||
|
||||
/** Keeps category failures and builds the single status shown for both beacons. */
|
||||
/** Builds the single status shown for both beacons from their session state. */
|
||||
final class BeaconStatus {
|
||||
|
||||
static final String SOURCE_NAME = ChatController.BEACON_STATUS_SOURCE;
|
||||
|
||||
private boolean mainInvalid;
|
||||
private boolean secondInvalid;
|
||||
private String activity = "Beacon configuration loaded.";
|
||||
|
||||
/** Records the result of one complete timer run. */
|
||||
synchronized void recordRun(
|
||||
boolean mainInvalid,
|
||||
boolean secondInvalid,
|
||||
String activity
|
||||
) {
|
||||
this.mainInvalid = mainInvalid;
|
||||
this.secondInvalid = secondInvalid;
|
||||
synchronized void recordRun(String activity) {
|
||||
this.activity = activity;
|
||||
}
|
||||
|
||||
@@ -29,47 +22,33 @@ final class BeaconStatus {
|
||||
}
|
||||
|
||||
/** Builds a fresh aggregate from the current preferences and remembered failures. */
|
||||
synchronized ThreadStateMessage message(ChatPreferences preferences) {
|
||||
boolean secondAvailable = preferences.isLoginToSecondChatEnabled();
|
||||
boolean mainEnabled = preferences.isBcn_beaconsEnabledMainCat();
|
||||
boolean secondEnabled = secondAvailable
|
||||
&& preferences.isBcn_beaconsEnabledSecondCat();
|
||||
int available = secondAvailable ? 2 : 1;
|
||||
int enabled = (mainEnabled ? 1 : 0) + (secondEnabled ? 1 : 0);
|
||||
boolean critical = (mainInvalid && mainEnabled)
|
||||
|| (secondInvalid && secondEnabled);
|
||||
synchronized ThreadStateMessage message(
|
||||
ChatPreferences preferences,
|
||||
BeaconSessionState sessionState
|
||||
) {
|
||||
BeaconStatusSnapshot snapshot = sessionState.snapshot(preferences);
|
||||
boolean critical = snapshot.getAggregateState()
|
||||
== BeaconStatusSnapshot.AggregateState.FAILED;
|
||||
boolean running = snapshot.getAggregateState()
|
||||
!= BeaconStatusSnapshot.AggregateState.OFF;
|
||||
|
||||
String description;
|
||||
if (critical) {
|
||||
description = "FAILED";
|
||||
} else if (enabled == 0) {
|
||||
description = "off";
|
||||
} else if (enabled == available) {
|
||||
description = "on";
|
||||
} else {
|
||||
description = enabled + "/" + available;
|
||||
switch (snapshot.getAggregateState()) {
|
||||
case FAILED -> description = "FAILED";
|
||||
case OFF -> description = "off";
|
||||
case ON -> description = "on";
|
||||
case PARTIAL -> description = "1/2";
|
||||
default -> throw new IllegalStateException("Unknown beacon status");
|
||||
}
|
||||
|
||||
String details = "Main category beacon: " + onOff(mainEnabled)
|
||||
+ "; second category beacon: "
|
||||
+ (secondAvailable
|
||||
? onOff(secondEnabled)
|
||||
: "unavailable");
|
||||
String information = activity == null || activity.isBlank()
|
||||
? details
|
||||
: activity + "\n" + details;
|
||||
|
||||
ThreadStateMessage message = new ThreadStateMessage(
|
||||
SOURCE_NAME,
|
||||
enabled > 0,
|
||||
information,
|
||||
running,
|
||||
activity,
|
||||
critical
|
||||
);
|
||||
message.setRunningInformationTextDescription(description);
|
||||
message.setBeaconStatusSnapshot(snapshot);
|
||||
return message;
|
||||
}
|
||||
|
||||
private static String onOff(boolean enabled) {
|
||||
return enabled ? "on" : "off";
|
||||
}
|
||||
}
|
||||
@@ -22,6 +22,7 @@ public class BeaconTask extends TimerTask {
|
||||
private final ChatController chatController;
|
||||
private final ThreadStatusCallback callbackToController;
|
||||
private final BeaconStatus beaconStatus;
|
||||
private final BeaconSessionState beaconSessionState;
|
||||
|
||||
/**
|
||||
* Creates one execution of the shared beacon timer.
|
||||
@@ -36,6 +37,7 @@ public class BeaconTask extends TimerTask {
|
||||
this.chatController = chatController;
|
||||
this.callbackToController = callbackToController;
|
||||
this.beaconStatus = chatController.beaconStatusState();
|
||||
this.beaconSessionState = chatController.beaconSessionState();
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -45,23 +47,34 @@ public class BeaconTask extends TimerTask {
|
||||
Attempt second = sendSecondCategoryBeacon();
|
||||
String activity = "Main category: " + main.description
|
||||
+ "; second category: " + second.description;
|
||||
beaconStatus.recordRun(
|
||||
main == Attempt.INVALID,
|
||||
second == Attempt.INVALID,
|
||||
activity
|
||||
);
|
||||
recordSendResult(BeaconSessionState.Channel.MAIN, main);
|
||||
recordSendResult(BeaconSessionState.Channel.SECOND, second);
|
||||
beaconStatus.recordRun(activity);
|
||||
callbackToController.onThreadStatus(
|
||||
BeaconStatus.SOURCE_NAME,
|
||||
beaconStatus.message(chatController.getChatPreferences())
|
||||
beaconStatus.message(
|
||||
chatController.getChatPreferences(),
|
||||
beaconSessionState
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
private void recordSendResult(
|
||||
BeaconSessionState.Channel channel,
|
||||
Attempt attempt
|
||||
) {
|
||||
if (attempt == Attempt.INVALID) {
|
||||
beaconSessionState.recordSendFailure(channel, true);
|
||||
} else if (attempt == Attempt.SENT) {
|
||||
beaconSessionState.recordSendFailure(channel, false);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Sends the main-category beacon if it is currently enabled.
|
||||
*/
|
||||
private Attempt sendMainCategoryBeacon() {
|
||||
if (!chatController.getChatPreferences()
|
||||
.isBcn_beaconsEnabledMainCat()) {
|
||||
if (!beaconSessionState.isEnabled(BeaconSessionState.Channel.MAIN)) {
|
||||
return Attempt.OFF;
|
||||
}
|
||||
|
||||
@@ -95,7 +108,7 @@ public class BeaconTask extends TimerTask {
|
||||
if (!chatController.getChatPreferences().isLoginToSecondChatEnabled()) {
|
||||
return Attempt.UNAVAILABLE;
|
||||
}
|
||||
if (!chatController.getChatPreferences().isBcn_beaconsEnabledSecondCat()) {
|
||||
if (!beaconSessionState.isEnabled(BeaconSessionState.Channel.SECOND)) {
|
||||
return Attempt.OFF;
|
||||
}
|
||||
|
||||
|
||||
@@ -65,9 +65,13 @@ public class ChatController implements ThreadStatusCallback {
|
||||
|
||||
|
||||
public static final String BEACON_STATUS_SOURCE = "MyBeacon";
|
||||
public static final int MIN_BEACON_INTERVAL_MINUTES = 1;
|
||||
public static final int MAX_BEACON_TEXT_LENGTH = 120;
|
||||
public static final int MIN_BEACON_INTERVAL_MINUTES = 5;
|
||||
public static final int MAX_BEACON_PAYLOAD_LENGTH = 120;
|
||||
public static final int MAX_BEACON_TEXT_LENGTH =
|
||||
MAX_BEACON_PAYLOAD_LENGTH
|
||||
+ AutomaticChatMessageFormatter.SUFFIX.length();
|
||||
private static final long INITIAL_BEACON_DELAY_MILLIS = 10_000L;
|
||||
private final BeaconSessionState beaconSessionState = new BeaconSessionState();
|
||||
private final BeaconStatus beaconStatus = new BeaconStatus();
|
||||
|
||||
private Consumer<Double> viewRotorCallback;
|
||||
@@ -3036,6 +3040,7 @@ private SimpleRoster<String>
|
||||
|
||||
chatPreferences = new ChatPreferences(preferencesRelativeFileName);
|
||||
chatPreferences.readPreferencesFromXmlFile();
|
||||
beaconSessionState.resetSession(chatPreferences);
|
||||
Path historyFile = Path.of(ApplicationFileUtils.getDebugFilePath(
|
||||
ApplicationConstants.APPLICATION_NAME,
|
||||
MessageHistoryRecorder.CURRENT_FILE_NAME));
|
||||
@@ -3288,6 +3293,7 @@ private SimpleRoster<String>
|
||||
|
||||
public void setChatPreferences(ChatPreferences chatPreferences) {
|
||||
this.chatPreferences = chatPreferences;
|
||||
beaconSessionState.resetSession(chatPreferences);
|
||||
}
|
||||
|
||||
public ChatMember getownChatMemberObject() {
|
||||
@@ -3385,13 +3391,21 @@ private SimpleRoster<String>
|
||||
|
||||
/** Applies the main-category beacon switch to the running session immediately. */
|
||||
public void setMainBeaconEnabled(boolean enabled) {
|
||||
getChatPreferences().setBcn_beaconsEnabledMainCat(enabled);
|
||||
beaconSessionState.setEnabled(
|
||||
BeaconSessionState.Channel.MAIN,
|
||||
enabled,
|
||||
getChatPreferences()
|
||||
);
|
||||
publishBeaconStatus("Beacon configuration changed.");
|
||||
}
|
||||
|
||||
/** Applies the second-category beacon switch to the running session immediately. */
|
||||
public void setSecondBeaconEnabled(boolean enabled) {
|
||||
getChatPreferences().setBcn_beaconsEnabledSecondCat(enabled);
|
||||
beaconSessionState.setEnabled(
|
||||
BeaconSessionState.Channel.SECOND,
|
||||
enabled,
|
||||
getChatPreferences()
|
||||
);
|
||||
publishBeaconStatus("Beacon configuration changed.");
|
||||
}
|
||||
|
||||
@@ -3405,18 +3419,66 @@ private SimpleRoster<String>
|
||||
public void toggleUsableBeacons() {
|
||||
ChatPreferences preferences = getChatPreferences();
|
||||
boolean secondAvailable = preferences.isLoginToSecondChatEnabled();
|
||||
boolean anyEnabled = preferences.isBcn_beaconsEnabledMainCat()
|
||||
boolean anyEnabled = beaconSessionState.isEnabled(BeaconSessionState.Channel.MAIN)
|
||||
|| (secondAvailable
|
||||
&& preferences.isBcn_beaconsEnabledSecondCat());
|
||||
&& beaconSessionState.isEnabled(BeaconSessionState.Channel.SECOND));
|
||||
boolean enable = !anyEnabled;
|
||||
|
||||
preferences.setBcn_beaconsEnabledMainCat(enable);
|
||||
beaconSessionState.setEnabled(
|
||||
BeaconSessionState.Channel.MAIN,
|
||||
enable,
|
||||
preferences
|
||||
);
|
||||
if (secondAvailable) {
|
||||
preferences.setBcn_beaconsEnabledSecondCat(enable);
|
||||
beaconSessionState.setEnabled(
|
||||
BeaconSessionState.Channel.SECOND,
|
||||
enable,
|
||||
preferences
|
||||
);
|
||||
}
|
||||
publishBeaconStatus("Beacon status toggled from the main window.");
|
||||
}
|
||||
|
||||
/** Applies a deliberate operator QRG entry and rebases the affected beacon. */
|
||||
public void applyManualQrg(RadioSlot slot, String value) {
|
||||
BeaconSessionState.Channel channel = slot == RadioSlot.FIRST
|
||||
? BeaconSessionState.Channel.MAIN
|
||||
: BeaconSessionState.Channel.SECOND;
|
||||
beaconSessionState.onManualQrgChanged(channel, value, getChatPreferences());
|
||||
publishBeaconStatus("QRG changed by the operator.");
|
||||
}
|
||||
|
||||
/** Applies a logger QRG report and enforces the automatic-QSY safety boundary. */
|
||||
public void applyExternalQrg(RadioSlot slot, String displayValue, long frequencyHz) {
|
||||
if (frequencyHz <= 0L) {
|
||||
return;
|
||||
}
|
||||
slot.qrgIn(getChatPreferences()).set(displayValue);
|
||||
BeaconSessionState.Channel channel = slot == RadioSlot.FIRST
|
||||
? BeaconSessionState.Channel.MAIN
|
||||
: BeaconSessionState.Channel.SECOND;
|
||||
beaconSessionState.onExternalQrgChanged(channel, frequencyHz, getChatPreferences());
|
||||
publishBeaconStatus("QRG updated by logging software.");
|
||||
}
|
||||
|
||||
/** Revalidates the applied main-category template. */
|
||||
public void onMainBeaconTemplateApplied() {
|
||||
beaconSessionState.onTemplateChanged(
|
||||
BeaconSessionState.Channel.MAIN,
|
||||
getChatPreferences()
|
||||
);
|
||||
publishBeaconStatus("Beacon template changed.");
|
||||
}
|
||||
|
||||
/** Revalidates the applied second-category template. */
|
||||
public void onSecondBeaconTemplateApplied() {
|
||||
beaconSessionState.onTemplateChanged(
|
||||
BeaconSessionState.Channel.SECOND,
|
||||
getChatPreferences()
|
||||
);
|
||||
publishBeaconStatus("Beacon template changed.");
|
||||
}
|
||||
|
||||
/** Publishes the loaded state without changing either category switch. */
|
||||
public void refreshBeaconStatus() {
|
||||
publishBeaconStatus("Beacon configuration loaded.");
|
||||
@@ -3427,9 +3489,13 @@ private SimpleRoster<String>
|
||||
return beaconStatus;
|
||||
}
|
||||
|
||||
BeaconSessionState beaconSessionState() {
|
||||
return beaconSessionState;
|
||||
}
|
||||
|
||||
/** Builds the current aggregate when the UI is ready to display it. */
|
||||
public ThreadStateMessage currentBeaconStatus() {
|
||||
return beaconStatus.message(getChatPreferences());
|
||||
return beaconStatus.message(getChatPreferences(), beaconSessionState);
|
||||
}
|
||||
|
||||
/** Publishes the aggregate state used by the single beacon status chip. */
|
||||
@@ -3454,7 +3520,7 @@ private SimpleRoster<String>
|
||||
* @param configuredText configured beacon template
|
||||
* @throws IllegalArgumentException if the template contains invalid protocol
|
||||
* content or currently resolves to more than
|
||||
* {@value MAX_BEACON_TEXT_LENGTH} characters
|
||||
* {@value MAX_BEACON_PAYLOAD_LENGTH} characters
|
||||
*/
|
||||
public void validateBeaconTemplate(String configuredText) {
|
||||
String normalizedTemplate =
|
||||
@@ -3473,7 +3539,10 @@ private SimpleRoster<String>
|
||||
return;
|
||||
}
|
||||
|
||||
validateResolvedBeaconText(resolvedText);
|
||||
validateBeaconText(
|
||||
resolvedText,
|
||||
MAX_BEACON_PAYLOAD_LENGTH
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -3494,22 +3563,29 @@ private SimpleRoster<String>
|
||||
new MessageVariableResolver(chatPreferences)
|
||||
.resolveGlobalVariables(configuredText);
|
||||
|
||||
return validateResolvedBeaconText(resolvedText);
|
||||
String normalizedPayload = validateBeaconText(
|
||||
resolvedText,
|
||||
MAX_BEACON_PAYLOAD_LENGTH
|
||||
);
|
||||
return validateBeaconText(
|
||||
AutomaticChatMessageFormatter.appendSuffix(normalizedPayload),
|
||||
MAX_BEACON_TEXT_LENGTH
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Applies the message-text and length rules to a fully resolved beacon.
|
||||
* Applies the message-text and length rules to a beacon processing stage.
|
||||
*/
|
||||
private String validateResolvedBeaconText(String resolvedText) {
|
||||
private String validateBeaconText(String resolvedText, int maximumLength) {
|
||||
String normalizedText =
|
||||
On4KstProtocol.messageText(resolvedText);
|
||||
|
||||
if (normalizedText.length() > MAX_BEACON_TEXT_LENGTH) {
|
||||
if (normalizedText.length() > maximumLength) {
|
||||
throw new IllegalArgumentException(
|
||||
"The resolved beacon message contains "
|
||||
+ normalizedText.length()
|
||||
+ " characters; maximum is "
|
||||
+ MAX_BEACON_TEXT_LENGTH
|
||||
+ maximumLength
|
||||
+ "."
|
||||
);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,53 @@
|
||||
package kst4contest.controller;
|
||||
|
||||
import kst4contest.model.ChatPreferences;
|
||||
|
||||
/**
|
||||
* Tells whether a profile has login credentials an operator entered.
|
||||
*
|
||||
* <p>Two states count as unconfigured. An empty callsign is what every created or duplicated
|
||||
* profile starts with, because {@link OperatorProfileManagementService} clears the
|
||||
* credentials on purpose. The bundled template's credentials are what the root profile of a
|
||||
* fresh installation carries. Neither can log in as the operator, so neither needs a flag of
|
||||
* its own in {@code preferences.xml}.</p>
|
||||
*/
|
||||
public final class LoginConfiguration {
|
||||
|
||||
/** Callsign shipped in {@code praktiKSTpreferences.xml}; held equal by a test. */
|
||||
public static final String TEMPLATE_CALLSIGN = "DO5AMF";
|
||||
|
||||
/** Password shipped in {@code praktiKSTpreferences.xml}; held equal by a test. */
|
||||
public static final String TEMPLATE_PASSWORD = "changeMe";
|
||||
|
||||
private LoginConfiguration() {
|
||||
// Utility class.
|
||||
}
|
||||
|
||||
/**
|
||||
* Whether the preferences still hold the bundled template's credentials.
|
||||
*
|
||||
* <p>Only the pair counts. The callsign alone belongs to a real operator.</p>
|
||||
*
|
||||
* @param preferences preferences of the profile to judge
|
||||
* @return true for an untouched template
|
||||
*/
|
||||
public static boolean carriesTemplateCredentials(final ChatPreferences preferences) {
|
||||
return TEMPLATE_CALLSIGN.equalsIgnoreCase(trimmed(preferences.getStn_loginCallSign()))
|
||||
&& TEMPLATE_PASSWORD.equals(preferences.getStn_loginPassword());
|
||||
}
|
||||
|
||||
/**
|
||||
* Whether the profile has no login an operator entered.
|
||||
*
|
||||
* @param preferences preferences of the profile to judge
|
||||
* @return true when the callsign is empty or the template's credentials are still there
|
||||
*/
|
||||
public static boolean isUnconfigured(final ChatPreferences preferences) {
|
||||
return trimmed(preferences.getStn_loginCallSign()).isEmpty()
|
||||
|| carriesTemplateCredentials(preferences);
|
||||
}
|
||||
|
||||
private static String trimmed(final String value) {
|
||||
return value == null ? "" : value.trim();
|
||||
}
|
||||
}
|
||||
@@ -872,10 +872,14 @@ public class MessageBusManagementThread extends Thread {
|
||||
versionInfo.setSender(itsMe);
|
||||
versionInfo.setReceiver(newMessageArrived.getSender());
|
||||
versionInfo.setChatCategory(newMessageArrived.getChatCategory());
|
||||
versionInfo.setMessageText("/CQ " + newMessageArrived.getSender().getCallSign()
|
||||
+ " " + AUTOANSWER_PREFIX
|
||||
+ " KST4Contest v" + ApplicationConstants.APPLICATION_CURRENT_VERSION
|
||||
+ " by DO5AMF");
|
||||
versionInfo.setMessageText(
|
||||
AutomaticChatMessageFormatter.appendSuffix(
|
||||
"/CQ " + newMessageArrived.getSender().getCallSign()
|
||||
+ " " + AUTOANSWER_PREFIX
|
||||
+ " KST4Contest v" + ApplicationConstants.APPLICATION_CURRENT_VERSION
|
||||
+ " by DO5AMF"
|
||||
)
|
||||
);
|
||||
|
||||
this.client.getMessageTXBus().add(versionInfo);
|
||||
}
|
||||
@@ -2070,7 +2074,9 @@ public class MessageBusManagementThread extends Thread {
|
||||
+ payload;
|
||||
|
||||
try {
|
||||
return On4KstProtocol.messageText(messageText);
|
||||
return On4KstProtocol.messageText(
|
||||
AutomaticChatMessageFormatter.appendSuffix(messageText)
|
||||
);
|
||||
|
||||
} catch (IllegalArgumentException invalidMessage) {
|
||||
LOGGER.warning(
|
||||
|
||||
@@ -535,6 +535,7 @@ public class ReadUDPByWintestThread extends Thread {
|
||||
* interpreted as frequencies.
|
||||
*/
|
||||
String formattedPassQrg = null;
|
||||
Long passFrequencyRawValue = null;
|
||||
|
||||
if (parts.size() > 11) {
|
||||
try {
|
||||
@@ -544,6 +545,7 @@ public class ReadUDPByWintestThread extends Thread {
|
||||
passFrequencyRaw / 10.0;
|
||||
|
||||
if (passFrequencyKHz > 100.0) {
|
||||
passFrequencyRawValue = passFrequencyRaw;
|
||||
formattedPassQrg =
|
||||
helper_formatWinTestFrequency(
|
||||
passFrequencyRaw
|
||||
@@ -566,10 +568,16 @@ public class ReadUDPByWintestThread extends Thread {
|
||||
usePassQrg && formattedPassQrg != null
|
||||
? formattedPassQrg
|
||||
: formattedMainQrg;
|
||||
final long selectedFrequencyRaw =
|
||||
usePassQrg && passFrequencyRawValue != null
|
||||
? passFrequencyRawValue
|
||||
: mainFrequencyRaw;
|
||||
final long selectedFrequencyHz = Math.multiplyExact(selectedFrequencyRaw, 100L);
|
||||
|
||||
if (prefs.isLogsynch_wintestQrgSyncEnabled()) {
|
||||
RadioSlot target = slot.get();
|
||||
client.uiDispatcher().runOnUi(() -> target.qrgIn(prefs).set(qrgToSet));
|
||||
client.uiDispatcher().runOnUi(() ->
|
||||
client.applyExternalQrg(target, qrgToSet, selectedFrequencyHz));
|
||||
}
|
||||
|
||||
System.out.println(
|
||||
|
||||
@@ -417,7 +417,19 @@ public class ReadUDPbyUCXMessageThread extends Thread {
|
||||
}
|
||||
|
||||
String qrg = freqNode.getTextContent();
|
||||
qrg = qrg == null ? "" : qrg.trim();
|
||||
String mode = modeNode.getTextContent();
|
||||
final long frequencyHz;
|
||||
try {
|
||||
frequencyHz = Math.multiplyExact(Long.parseLong(qrg), 10L);
|
||||
} catch (NumberFormatException | ArithmeticException invalidFrequency) {
|
||||
System.out.println("[ReadUDPFromUCX, warning]: RadioInfo with invalid Freq ignored");
|
||||
continue;
|
||||
}
|
||||
if (frequencyHz <= 0L) {
|
||||
System.out.println("[ReadUDPFromUCX, warning]: RadioInfo with non-positive Freq ignored");
|
||||
continue;
|
||||
}
|
||||
|
||||
// System.out.println("QRG Length: " + qrg.length() + " // " + qrg);
|
||||
|
||||
@@ -464,7 +476,7 @@ public class ReadUDPbyUCXMessageThread extends Thread {
|
||||
final String finalFormattedQRG = formattedQRG;
|
||||
final RadioSlot target = slot.get();
|
||||
helper_runOnFxThread(() ->
|
||||
target.qrgIn(this.client.getChatPreferences()).set(finalFormattedQRG)
|
||||
this.client.applyExternalQrg(target, finalFormattedQRG, frequencyHz)
|
||||
);
|
||||
|
||||
// System.out.println("[ReadUDPbyUCXTh: ] Radioinfo processed: " + formattedQRG);
|
||||
|
||||
@@ -0,0 +1,83 @@
|
||||
package kst4contest.model;
|
||||
|
||||
import java.util.Objects;
|
||||
|
||||
/** Immutable, display-neutral status of both beacon categories. */
|
||||
public final class BeaconStatusSnapshot {
|
||||
public enum AggregateState {
|
||||
OFF,
|
||||
PARTIAL,
|
||||
ON,
|
||||
FAILED
|
||||
}
|
||||
|
||||
public enum InactiveReason {
|
||||
NOT_ACTIVATED_THIS_SESSION,
|
||||
USER_DISABLED,
|
||||
PRIMARY_QRG_UNAVAILABLE,
|
||||
SECONDARY_QRG_UNAVAILABLE,
|
||||
AUTOMATIC_QRG_CHANGE
|
||||
}
|
||||
|
||||
/** Immutable status of one beacon category. */
|
||||
public static final class CategoryStatus {
|
||||
private final boolean available;
|
||||
private final boolean enabled;
|
||||
private final boolean failed;
|
||||
private final InactiveReason inactiveReason;
|
||||
|
||||
public CategoryStatus(
|
||||
boolean available,
|
||||
boolean enabled,
|
||||
boolean failed,
|
||||
InactiveReason inactiveReason
|
||||
) {
|
||||
this.available = available;
|
||||
this.enabled = enabled;
|
||||
this.failed = failed;
|
||||
this.inactiveReason = Objects.requireNonNull(inactiveReason);
|
||||
}
|
||||
|
||||
public boolean isAvailable() {
|
||||
return available;
|
||||
}
|
||||
|
||||
public boolean isEnabled() {
|
||||
return enabled;
|
||||
}
|
||||
|
||||
public boolean isFailed() {
|
||||
return failed;
|
||||
}
|
||||
|
||||
public InactiveReason getInactiveReason() {
|
||||
return inactiveReason;
|
||||
}
|
||||
}
|
||||
|
||||
private final AggregateState aggregateState;
|
||||
private final CategoryStatus main;
|
||||
private final CategoryStatus second;
|
||||
|
||||
public BeaconStatusSnapshot(
|
||||
AggregateState aggregateState,
|
||||
CategoryStatus main,
|
||||
CategoryStatus second
|
||||
) {
|
||||
this.aggregateState = Objects.requireNonNull(aggregateState);
|
||||
this.main = Objects.requireNonNull(main);
|
||||
this.second = Objects.requireNonNull(second);
|
||||
}
|
||||
|
||||
public AggregateState getAggregateState() {
|
||||
return aggregateState;
|
||||
}
|
||||
|
||||
public CategoryStatus getMain() {
|
||||
return main;
|
||||
}
|
||||
|
||||
public CategoryStatus getSecond() {
|
||||
return second;
|
||||
}
|
||||
}
|
||||
@@ -366,7 +366,8 @@ public class ChatPreferences {
|
||||
* Beacon prefs
|
||||
*/
|
||||
|
||||
MutableValue<Boolean> bcn_beaconsEnabledMainCat = new SimpleValue<>(true);
|
||||
private static final int MIN_BEACON_INTERVAL_MINUTES = 5;
|
||||
MutableValue<Boolean> bcn_beaconsEnabledMainCat = new SimpleValue<>(false);
|
||||
MutableValue<Boolean> bcn_beaconsEnabledSecondCat = new SimpleValue<>(false);
|
||||
int bcn_beaconIntervalInMinutesMainCat = 20;
|
||||
int bcn_beaconIntervalInMinutesSecondCat = 20;
|
||||
@@ -2198,11 +2199,11 @@ public class ChatPreferences {
|
||||
beaconCQ.appendChild(bcn_beaconIntervalInMinutesMainCat);
|
||||
|
||||
Element beaconCQEnabled = doc.createElement("beaconCQEnabled");
|
||||
beaconCQEnabled.setTextContent(this.isBcn_beaconsEnabledMainCat()+"");
|
||||
beaconCQEnabled.setTextContent("false");
|
||||
beaconCQ.appendChild(beaconCQEnabled);
|
||||
|
||||
Element bcn_beaconsEnabledMainCat = doc.createElement("bcn_beaconsEnabledMainCat");
|
||||
bcn_beaconsEnabledMainCat.setTextContent(this.isBcn_beaconsEnabledMainCat()+"");
|
||||
bcn_beaconsEnabledMainCat.setTextContent("false");
|
||||
beaconCQ.appendChild(bcn_beaconsEnabledMainCat);
|
||||
|
||||
|
||||
@@ -2223,11 +2224,11 @@ public class ChatPreferences {
|
||||
beaconCQ.appendChild(bcn_beaconIntervalInMinutesSecondCat);
|
||||
|
||||
Element beaconCQEnabledSecondCat = doc.createElement("beaconCQEnabledSecondCat");
|
||||
beaconCQEnabledSecondCat.setTextContent(this.isBcn_beaconsEnabledSecondCat()+"");
|
||||
beaconCQEnabledSecondCat.setTextContent("false");
|
||||
beaconCQ.appendChild(beaconCQEnabledSecondCat);
|
||||
|
||||
Element bcn_beaconsEnabledSecondCat = doc.createElement("bcn_beaconsEnabledSecondCat");
|
||||
bcn_beaconsEnabledSecondCat.setTextContent(this.isBcn_beaconsEnabledSecondCat()+"");
|
||||
bcn_beaconsEnabledSecondCat.setTextContent("false");
|
||||
beaconCQ.appendChild(bcn_beaconsEnabledSecondCat);
|
||||
|
||||
/**
|
||||
@@ -2600,6 +2601,8 @@ public class ChatPreferences {
|
||||
*/
|
||||
public boolean readPreferencesFromXmlFile() {
|
||||
|
||||
boolean readable = true;
|
||||
|
||||
System.out.println("[ChatPreferences, Info]: restoring prefs from file " + storeAndRestorePreferencesFileName);
|
||||
|
||||
DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
|
||||
@@ -2616,6 +2619,10 @@ public class ChatPreferences {
|
||||
|
||||
DocumentBuilder db = dbf.newDocumentBuilder();
|
||||
Document doc = db.parse(xmlConfigFile);
|
||||
Element rootElement = doc.getDocumentElement();
|
||||
if (rootElement == null || !"praktiKST".equals(rootElement.getTagName())) {
|
||||
readable = false;
|
||||
}
|
||||
NodeList list;
|
||||
|
||||
// --- Schema version (optional) ---
|
||||
@@ -3178,12 +3185,18 @@ public class ChatPreferences {
|
||||
|
||||
Element beaconCQEl = getFirstElement(doc, "beaconCQ");
|
||||
if (beaconCQEl != null) {
|
||||
setBcn_beaconsEnabledMainCat(getBoolean(beaconCQEl, isBcn_beaconsEnabledMainCat(), "bcn_beaconsEnabledMainCat", "beaconCQEnabled"));
|
||||
bcn_beaconIntervalInMinutesMainCat = getInt(beaconCQEl, bcn_beaconIntervalInMinutesMainCat, "bcn_beaconIntervalInMinutesMainCat", "beaconCQIntervalMinutes");
|
||||
setBcn_beaconsEnabledMainCat(false);
|
||||
bcn_beaconIntervalInMinutesMainCat = Math.max(
|
||||
MIN_BEACON_INTERVAL_MINUTES,
|
||||
getInt(beaconCQEl, bcn_beaconIntervalInMinutesMainCat, "bcn_beaconIntervalInMinutesMainCat", "beaconCQIntervalMinutes")
|
||||
);
|
||||
bcn_beaconTextMainCat = getText(beaconCQEl, bcn_beaconTextMainCat, "bcn_beaconTextMainCat", "beaconCQText");
|
||||
|
||||
setBcn_beaconsEnabledSecondCat(getBoolean(beaconCQEl, isBcn_beaconsEnabledSecondCat(), "bcn_beaconsEnabledSecondCat", "beaconCQEnabledSecondCat"));
|
||||
bcn_beaconIntervalInMinutesSecondCat = getInt(beaconCQEl, bcn_beaconIntervalInMinutesSecondCat, "bcn_beaconIntervalInMinutesSecondCat", "beaconCQIntervalMinutesSecondCat");
|
||||
setBcn_beaconsEnabledSecondCat(false);
|
||||
bcn_beaconIntervalInMinutesSecondCat = Math.max(
|
||||
MIN_BEACON_INTERVAL_MINUTES,
|
||||
getInt(beaconCQEl, bcn_beaconIntervalInMinutesSecondCat, "bcn_beaconIntervalInMinutesSecondCat", "beaconCQIntervalMinutesSecondCat")
|
||||
);
|
||||
bcn_beaconTextSecondCat = getText(beaconCQEl, bcn_beaconTextSecondCat, "bcn_beaconTextSecondCat", "beaconCQTextSecondText");
|
||||
|
||||
System.out.println("[ChatPreferences, info]: beaconCQ main='" + bcn_beaconTextMainCat + "', second='" + bcn_beaconTextSecondCat + "'");
|
||||
@@ -3450,13 +3463,14 @@ public class ChatPreferences {
|
||||
|
||||
|
||||
} catch (ParserConfigurationException | SAXException | IOException e) {
|
||||
readable = false;
|
||||
e.printStackTrace();
|
||||
System.out.println(e.getCause());
|
||||
System.out.println(e.getMessage());
|
||||
}
|
||||
|
||||
initializeActualQtfFromDefaultIfRequired();
|
||||
return true;
|
||||
return readable;
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -14,6 +14,7 @@ public class ThreadStateMessage {
|
||||
|
||||
boolean criticalState;
|
||||
String criticalStateFurtherInfo;
|
||||
BeaconStatusSnapshot beaconStatusSnapshot;
|
||||
|
||||
|
||||
|
||||
@@ -99,5 +100,13 @@ public class ThreadStateMessage {
|
||||
public void setCriticalStateFurtherInfo(String criticalStateFurtherInfo) {
|
||||
this.criticalStateFurtherInfo = criticalStateFurtherInfo;
|
||||
}
|
||||
|
||||
public BeaconStatusSnapshot getBeaconStatusSnapshot() {
|
||||
return beaconStatusSnapshot;
|
||||
}
|
||||
|
||||
public void setBeaconStatusSnapshot(BeaconStatusSnapshot beaconStatusSnapshot) {
|
||||
this.beaconStatusSnapshot = beaconStatusSnapshot;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -112,10 +112,10 @@
|
||||
</textSnippets>
|
||||
<beaconCQ>
|
||||
<beaconCQText>_.~'"´"'~.__.~'´ CQ CQ CQ NAC de MYCALL, pse try 144.317 for JO54 `'~.__.~'"`"'~._</beaconCQText>
|
||||
<beaconCQIntervalMinutes>1</beaconCQIntervalMinutes>
|
||||
<beaconCQIntervalMinutes>5</beaconCQIntervalMinutes>
|
||||
<beaconCQEnabled>false</beaconCQEnabled>
|
||||
<beaconCQTextSecondText>_.~'"´"'~.__.~'´ CQ CQ CQ de MYCALL, pse sked or SECONDQRG `'~.__.~'"`"'~._</beaconCQTextSecondText>
|
||||
<beaconCQIntervalMinutesSecondCat>3</beaconCQIntervalMinutesSecondCat>
|
||||
<beaconCQIntervalMinutesSecondCat>5</beaconCQIntervalMinutesSecondCat>
|
||||
<beaconCQEnabledSecondCat>false</beaconCQEnabledSecondCat>
|
||||
</beaconCQ>
|
||||
<beaconUnworkedstations>
|
||||
|
||||
@@ -0,0 +1,27 @@
|
||||
package kst4contest.controller;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
/** Verifies the fixed suffix contract for automatic chat messages. */
|
||||
class AutomaticChatMessageFormatterTest {
|
||||
|
||||
@Test
|
||||
void appendsTheExactAutomaticChatSuffix() {
|
||||
assertEquals(
|
||||
"CQ test *a*",
|
||||
AutomaticChatMessageFormatter.appendSuffix("CQ test"),
|
||||
"the suffix must include its leading space"
|
||||
);
|
||||
}
|
||||
|
||||
@Test
|
||||
void appendsTheSuffixEvenWhenTheTextAlreadyEndsWithIt() {
|
||||
assertEquals(
|
||||
"CQ test *a* *a*",
|
||||
AutomaticChatMessageFormatter.appendSuffix("CQ test *a*"),
|
||||
"an existing suffix must not be deduplicated"
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -36,8 +36,7 @@ class BeaconControlTest {
|
||||
@Test
|
||||
void toggleWithSecondChatDisabledChangesOnlyTheMainBeacon() {
|
||||
preferences.setLoginToSecondChatEnabled(false);
|
||||
preferences.setBcn_beaconsEnabledMainCat(false);
|
||||
preferences.setBcn_beaconsEnabledSecondCat(true);
|
||||
controller.setSecondBeaconEnabled(true);
|
||||
|
||||
controller.toggleUsableBeacons();
|
||||
|
||||
@@ -56,8 +55,6 @@ class BeaconControlTest {
|
||||
@Test
|
||||
void toggleWithSecondChatEnabledSwitchesBothUsableBeacons() {
|
||||
preferences.setLoginToSecondChatEnabled(true);
|
||||
preferences.setBcn_beaconsEnabledMainCat(false);
|
||||
preferences.setBcn_beaconsEnabledSecondCat(false);
|
||||
|
||||
controller.toggleUsableBeacons();
|
||||
|
||||
@@ -65,7 +62,7 @@ class BeaconControlTest {
|
||||
assertTrue(preferences.isBcn_beaconsEnabledSecondCat());
|
||||
assertLastDescription("on");
|
||||
|
||||
preferences.setBcn_beaconsEnabledSecondCat(false);
|
||||
controller.setSecondBeaconEnabled(false);
|
||||
controller.toggleUsableBeacons();
|
||||
|
||||
assertFalse(preferences.isBcn_beaconsEnabledMainCat());
|
||||
@@ -76,8 +73,6 @@ class BeaconControlTest {
|
||||
@Test
|
||||
void anIndividualCheckboxPublishesThePartialStateImmediately() {
|
||||
preferences.setLoginToSecondChatEnabled(true);
|
||||
preferences.setBcn_beaconsEnabledMainCat(false);
|
||||
preferences.setBcn_beaconsEnabledSecondCat(false);
|
||||
|
||||
controller.setMainBeaconEnabled(true);
|
||||
|
||||
@@ -86,6 +81,47 @@ class BeaconControlTest {
|
||||
assertLastDescription("1/2");
|
||||
}
|
||||
|
||||
@Test
|
||||
void activationRejectsOnlyTheTemplateWhoseRequiredQrgIsMissing() {
|
||||
preferences.setLoginToSecondChatEnabled(true);
|
||||
preferences.setMYQRGSecondCat("1296.200");
|
||||
preferences.setBcn_beaconTextMainCat("CQ SECONDQRG");
|
||||
preferences.setBcn_beaconTextSecondCat("CQ MYQRG");
|
||||
|
||||
controller.toggleUsableBeacons();
|
||||
|
||||
assertTrue(preferences.isBcn_beaconsEnabledMainCat());
|
||||
assertFalse(preferences.isBcn_beaconsEnabledSecondCat());
|
||||
}
|
||||
|
||||
@Test
|
||||
void manualQrgRebasesBeforeAnAutomaticMoveIsCompared() {
|
||||
preferences.setBcn_beaconTextMainCat("CQ");
|
||||
controller.setMainBeaconEnabled(true);
|
||||
controller.applyManualQrg(RadioSlot.FIRST, "144.300");
|
||||
controller.applyExternalQrg(RadioSlot.FIRST, "144.305", 144_305_000L);
|
||||
assertTrue(preferences.isBcn_beaconsEnabledMainCat());
|
||||
|
||||
controller.applyManualQrg(RadioSlot.FIRST, "144.310");
|
||||
controller.applyExternalQrg(RadioSlot.FIRST, "144.315.01", 144_315_010L);
|
||||
|
||||
assertFalse(preferences.isBcn_beaconsEnabledMainCat());
|
||||
}
|
||||
|
||||
@Test
|
||||
void nonPositiveExternalQrgCannotOverwriteTheDisplayOrClearTheReference() {
|
||||
preferences.setBcn_beaconTextMainCat("CQ");
|
||||
controller.applyManualQrg(RadioSlot.FIRST, "144.300");
|
||||
controller.setMainBeaconEnabled(true);
|
||||
|
||||
controller.applyExternalQrg(RadioSlot.FIRST, "0", 0L);
|
||||
|
||||
assertEquals("144.300", preferences.getMYQRGFirstCat().get());
|
||||
controller.applyExternalQrg(RadioSlot.FIRST, "144.306", 144_306_000L);
|
||||
assertFalse(preferences.isBcn_beaconsEnabledMainCat(),
|
||||
"the rejected packet must not clear the 144.300 reference");
|
||||
}
|
||||
|
||||
private void assertLastDescription(String expected) {
|
||||
ArgumentCaptor<String> key = ArgumentCaptor.forClass(String.class);
|
||||
ArgumentCaptor<ThreadStateMessage> message = ArgumentCaptor.forClass(ThreadStateMessage.class);
|
||||
|
||||
@@ -0,0 +1,31 @@
|
||||
package kst4contest.controller;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
import static org.junit.jupiter.api.Assertions.assertTrue;
|
||||
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
class BeaconFrequencyParserTest {
|
||||
|
||||
@Test
|
||||
void parsesEveryCompleteQrgFormWithoutLosingHertz() {
|
||||
assertHz("144.300", 144_300_000L);
|
||||
assertHz("144,300", 144_300_000L);
|
||||
assertHz("144.300.03", 144_300_030L);
|
||||
assertHz("1296.123.000", 1_296_123_000L);
|
||||
assertHz("144300", 144_300_000L);
|
||||
assertHz("10368100", 10_368_100_000L);
|
||||
}
|
||||
|
||||
@Test
|
||||
void rejectsIncompleteMalformedAndUnsupportedValues() {
|
||||
for (String value : new String[] {null, "", " ", "210", "144 MHz", "0", "-144.300",
|
||||
"999999999999999999999999999999"}) {
|
||||
assertTrue(BeaconFrequencyParser.parseHz(value).isEmpty(), value);
|
||||
}
|
||||
}
|
||||
|
||||
private static void assertHz(String value, long expected) {
|
||||
assertEquals(expected, BeaconFrequencyParser.parseHz(value).orElseThrow());
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,136 @@
|
||||
package kst4contest.controller;
|
||||
|
||||
import static kst4contest.controller.BeaconSessionState.Channel.MAIN;
|
||||
import static kst4contest.controller.BeaconSessionState.Channel.SECOND;
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
import static org.junit.jupiter.api.Assertions.assertFalse;
|
||||
import static org.junit.jupiter.api.Assertions.assertTrue;
|
||||
|
||||
import java.nio.file.Path;
|
||||
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.junit.jupiter.api.io.TempDir;
|
||||
|
||||
import kst4contest.model.BeaconStatusSnapshot;
|
||||
import kst4contest.model.BeaconStatusSnapshot.AggregateState;
|
||||
import kst4contest.model.BeaconStatusSnapshot.InactiveReason;
|
||||
import kst4contest.model.ChatPreferences;
|
||||
|
||||
class BeaconSessionStateTest {
|
||||
@TempDir Path tempDir;
|
||||
private ChatPreferences preferences;
|
||||
private BeaconSessionState state;
|
||||
|
||||
@BeforeEach
|
||||
void setUp() {
|
||||
preferences = new ChatPreferences(tempDir.resolve("preferences.xml"));
|
||||
preferences.setLoginToSecondChatEnabled(true);
|
||||
preferences.setBcn_beaconTextMainCat("CQ MAIN");
|
||||
preferences.setBcn_beaconTextSecondCat("CQ SECOND");
|
||||
preferences.setMYQRGFirstCat("");
|
||||
preferences.setMYQRGSecondCat("");
|
||||
state = new BeaconSessionState();
|
||||
state.resetSession(preferences);
|
||||
}
|
||||
|
||||
@Test
|
||||
void resetStartsBothCategoriesOffWithSessionReason() {
|
||||
BeaconStatusSnapshot snapshot = state.snapshot(preferences);
|
||||
assertEquals(AggregateState.OFF, snapshot.getAggregateState());
|
||||
assertEquals(InactiveReason.NOT_ACTIVATED_THIS_SESSION, snapshot.getMain().getInactiveReason());
|
||||
assertEquals(InactiveReason.NOT_ACTIVATED_THIS_SESSION, snapshot.getSecond().getInactiveReason());
|
||||
assertFalse(preferences.isBcn_beaconsEnabledMainCat());
|
||||
assertFalse(preferences.isBcn_beaconsEnabledSecondCat());
|
||||
}
|
||||
|
||||
@Test
|
||||
void enablesValidCategoryAndRejectsOtherCategoryWithMissingCrossTemplateQrg() {
|
||||
preferences.setMYQRGSecondCat("1296.123");
|
||||
preferences.setBcn_beaconTextMainCat("CQ SECONDQRG");
|
||||
preferences.setBcn_beaconTextSecondCat("CQ MYQRG");
|
||||
|
||||
assertTrue(state.setEnabled(MAIN, true, preferences));
|
||||
assertFalse(state.setEnabled(SECOND, true, preferences));
|
||||
|
||||
BeaconStatusSnapshot snapshot = state.snapshot(preferences);
|
||||
assertEquals(AggregateState.PARTIAL, snapshot.getAggregateState());
|
||||
assertTrue(snapshot.getMain().isEnabled());
|
||||
assertEquals(InactiveReason.PRIMARY_QRG_UNAVAILABLE, snapshot.getSecond().getInactiveReason());
|
||||
}
|
||||
|
||||
@Test
|
||||
void manualQrgRebasesAndInvalidValueClearsReferenceWithoutPlaceholder() {
|
||||
assertTrue(state.setEnabled(MAIN, true, preferences));
|
||||
state.onManualQrgChanged(MAIN, "144.300", preferences);
|
||||
state.onExternalQrgChanged(MAIN, 144_306_000L, preferences);
|
||||
assertFalse(state.isEnabled(MAIN));
|
||||
|
||||
assertTrue(state.setEnabled(MAIN, true, preferences));
|
||||
state.onManualQrgChanged(MAIN, "invalid", preferences);
|
||||
assertTrue(state.isEnabled(MAIN));
|
||||
state.onExternalQrgChanged(MAIN, 144_310_000L, preferences);
|
||||
assertTrue(state.isEnabled(MAIN), "first valid report establishes the cleared reference");
|
||||
}
|
||||
|
||||
@Test
|
||||
void invalidManualQrgDisablesEveryActiveTemplateThatNeedsIt() {
|
||||
preferences.setMYQRGFirstCat("144.300");
|
||||
preferences.setBcn_beaconTextMainCat("CQ MYQRG");
|
||||
preferences.setBcn_beaconTextSecondCat("CQ MYQRGSHORT");
|
||||
assertTrue(state.setEnabled(MAIN, true, preferences));
|
||||
assertTrue(state.setEnabled(SECOND, true, preferences));
|
||||
|
||||
state.onManualQrgChanged(MAIN, "", preferences);
|
||||
|
||||
assertFalse(state.isEnabled(MAIN));
|
||||
assertFalse(state.isEnabled(SECOND));
|
||||
assertEquals(InactiveReason.PRIMARY_QRG_UNAVAILABLE,
|
||||
state.snapshot(preferences).getSecond().getInactiveReason());
|
||||
}
|
||||
|
||||
@Test
|
||||
void externalMoveUsesStrictFiveKhzBoundaryAndOnlyItsCategory() {
|
||||
preferences.setMYQRGFirstCat("144.300");
|
||||
preferences.setMYQRGSecondCat("1296.100");
|
||||
assertTrue(state.setEnabled(MAIN, true, preferences));
|
||||
assertTrue(state.setEnabled(SECOND, true, preferences));
|
||||
|
||||
state.onExternalQrgChanged(MAIN, 144_305_000L, preferences);
|
||||
assertTrue(state.isEnabled(MAIN));
|
||||
state.onExternalQrgChanged(MAIN, 144_305_001L, preferences);
|
||||
|
||||
assertFalse(state.isEnabled(MAIN));
|
||||
assertTrue(state.isEnabled(SECOND));
|
||||
assertEquals(InactiveReason.AUTOMATIC_QRG_CHANGE,
|
||||
state.snapshot(preferences).getMain().getInactiveReason());
|
||||
}
|
||||
|
||||
@Test
|
||||
void invalidExternalQrgClearsTheReferenceWithoutAPlaceholder() {
|
||||
assertTrue(state.setEnabled(MAIN, true, preferences));
|
||||
preferences.setMYQRGFirstCat("7.100.00");
|
||||
state.onExternalQrgChanged(MAIN, 7_100_000L, preferences);
|
||||
assertTrue(state.isEnabled(MAIN));
|
||||
|
||||
preferences.setMYQRGFirstCat("144.300");
|
||||
state.onExternalQrgChanged(MAIN, 144_300_000L, preferences);
|
||||
|
||||
assertTrue(state.isEnabled(MAIN), "the first valid report must establish the reference");
|
||||
}
|
||||
|
||||
@Test
|
||||
void failureOverridesAggregateAndA_successClearsOnlyThatCategory() {
|
||||
assertTrue(state.setEnabled(MAIN, true, preferences));
|
||||
assertTrue(state.setEnabled(SECOND, true, preferences));
|
||||
state.recordSendFailure(MAIN, true);
|
||||
state.recordSendFailure(SECOND, true);
|
||||
assertEquals(AggregateState.FAILED, state.snapshot(preferences).getAggregateState());
|
||||
|
||||
state.recordSendFailure(MAIN, false);
|
||||
BeaconStatusSnapshot snapshot = state.snapshot(preferences);
|
||||
assertEquals(AggregateState.FAILED, snapshot.getAggregateState());
|
||||
assertFalse(snapshot.getMain().isFailed());
|
||||
assertTrue(snapshot.getSecond().isFailed());
|
||||
}
|
||||
}
|
||||
@@ -65,8 +65,9 @@ class BeaconTaskTest {
|
||||
|
||||
@Test
|
||||
void invalidEnabledBeaconIsNotQueuedAndReportsOneCriticalAggregateState() {
|
||||
preferences.setBcn_beaconsEnabledMainCat(true);
|
||||
controller.setMainBeaconEnabled(true);
|
||||
preferences.setBcn_beaconTextMainCat("invalid|template");
|
||||
statuses.clear();
|
||||
|
||||
task.run();
|
||||
|
||||
@@ -80,8 +81,9 @@ class BeaconTaskTest {
|
||||
|
||||
@Test
|
||||
void changingTheOtherCheckboxDoesNotHideAnActiveCategoryFailure() {
|
||||
preferences.setBcn_beaconsEnabledMainCat(true);
|
||||
controller.setMainBeaconEnabled(true);
|
||||
preferences.setBcn_beaconTextMainCat("invalid|template");
|
||||
statuses.clear();
|
||||
task.run();
|
||||
statuses.clear();
|
||||
|
||||
@@ -93,6 +95,29 @@ class BeaconTaskTest {
|
||||
assertTrue(status.isCriticalState());
|
||||
}
|
||||
|
||||
@Test
|
||||
void unavailableCategoryRetainsFailureUntilItsNextSuccessfulRun() {
|
||||
controller.setSecondBeaconEnabled(true);
|
||||
preferences.setBcn_beaconTextSecondCat("invalid|template");
|
||||
task.run();
|
||||
assertTrue(controller.currentBeaconStatus()
|
||||
.getBeaconStatusSnapshot().getSecond().isFailed());
|
||||
|
||||
preferences.setLoginToSecondChatEnabled(false);
|
||||
task.run();
|
||||
assertTrue(controller.currentBeaconStatus()
|
||||
.getBeaconStatusSnapshot().getSecond().isFailed(),
|
||||
"an unavailable run did not succeed and must not clear the failure");
|
||||
|
||||
preferences.setLoginToSecondChatEnabled(true);
|
||||
assertEquals("FAILED", controller.currentBeaconStatus()
|
||||
.getRunningInformationTextDescription());
|
||||
preferences.setBcn_beaconTextSecondCat("CQ SECOND");
|
||||
task.run();
|
||||
assertFalse(controller.currentBeaconStatus()
|
||||
.getBeaconStatusSnapshot().getSecond().isFailed());
|
||||
}
|
||||
|
||||
@Test
|
||||
void everyRunUsesTheCurrentEnableFlagsAndReportsOneAggregateState() {
|
||||
task.run();
|
||||
@@ -100,16 +125,22 @@ class BeaconTaskTest {
|
||||
assertAggregateStatus("off", false);
|
||||
|
||||
statuses.clear();
|
||||
preferences.setBcn_beaconsEnabledMainCat(true);
|
||||
controller.setMainBeaconEnabled(true);
|
||||
statuses.clear();
|
||||
task.run();
|
||||
assertEquals(1, txBus.size());
|
||||
assertEquals(ChatCategory.VUHF, txBus.peek().getChatCategory().getCategoryNumber());
|
||||
assertEquals("CQ MAIN *a*", txBus.peek().getMessageText());
|
||||
assertAggregateStatus("1/2", true);
|
||||
|
||||
statuses.clear();
|
||||
preferences.setBcn_beaconsEnabledSecondCat(true);
|
||||
controller.setSecondBeaconEnabled(true);
|
||||
statuses.clear();
|
||||
task.run();
|
||||
assertEquals(3, txBus.size());
|
||||
List<ChatMessage> sentMessages = new ArrayList<>(txBus);
|
||||
assertEquals("CQ MAIN *a*", sentMessages.get(1).getMessageText());
|
||||
assertEquals("CQ SECOND *a*", sentMessages.get(2).getMessageText());
|
||||
assertAggregateStatus("on", true);
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,79 @@
|
||||
package kst4contest.controller;
|
||||
|
||||
import kst4contest.model.ChatPreferences;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.junit.jupiter.api.io.TempDir;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Path;
|
||||
import java.nio.file.StandardCopyOption;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.assertFalse;
|
||||
import static org.junit.jupiter.api.Assertions.assertNotNull;
|
||||
import static org.junit.jupiter.api.Assertions.assertTrue;
|
||||
|
||||
/**
|
||||
* When a profile counts as not set up yet. The setup wizard appears on exactly this
|
||||
* condition, so a wrong answer either nags a working station or leaves a newcomer alone
|
||||
* with the template's callsign.
|
||||
*/
|
||||
class LoginConfigurationTest {
|
||||
|
||||
@TempDir
|
||||
Path temporaryDirectory;
|
||||
|
||||
private ChatPreferences preferences(String callsign, String password) {
|
||||
ChatPreferences preferences = new ChatPreferences(temporaryDirectory.resolve("unused.xml"));
|
||||
preferences.setStn_loginCallSign(callsign);
|
||||
preferences.setStn_loginPassword(password);
|
||||
return preferences;
|
||||
}
|
||||
|
||||
@Test
|
||||
void anEmptyCallsignIsUnconfigured() {
|
||||
assertTrue(LoginConfiguration.isUnconfigured(preferences("", "secret")));
|
||||
assertTrue(LoginConfiguration.isUnconfigured(preferences(" ", "secret")));
|
||||
}
|
||||
|
||||
@Test
|
||||
void theTemplateCredentialsAreUnconfigured() {
|
||||
ChatPreferences template = preferences("DO5AMF", "changeMe");
|
||||
|
||||
assertTrue(LoginConfiguration.carriesTemplateCredentials(template));
|
||||
assertTrue(LoginConfiguration.isUnconfigured(template));
|
||||
}
|
||||
|
||||
@Test
|
||||
void theTemplateCallsignWithItsOwnPasswordIsConfigured() {
|
||||
// The callsign belongs to a real operator; only the pair marks an untouched template.
|
||||
ChatPreferences owner = preferences("DO5AMF", "a-real-password");
|
||||
|
||||
assertFalse(LoginConfiguration.carriesTemplateCredentials(owner));
|
||||
assertFalse(LoginConfiguration.isUnconfigured(owner));
|
||||
}
|
||||
|
||||
@Test
|
||||
void aRealLoginIsConfigured() {
|
||||
assertFalse(LoginConfiguration.isUnconfigured(preferences("DL0TEST", "secret")));
|
||||
assertFalse(LoginConfiguration.isUnconfigured(preferences("DL0TEST/P", "")));
|
||||
}
|
||||
|
||||
@Test
|
||||
void theConstantsMatchTheBundledTemplate() throws IOException {
|
||||
Path templateCopy = temporaryDirectory.resolve("template.xml");
|
||||
try (InputStream template = ChatPreferences.class
|
||||
.getResourceAsStream(ChatPreferences.PREFERENCE_RESOURCE)) {
|
||||
assertNotNull(template, "bundled resource " + ChatPreferences.PREFERENCE_RESOURCE);
|
||||
Files.copy(template, templateCopy, StandardCopyOption.REPLACE_EXISTING);
|
||||
}
|
||||
|
||||
ChatPreferences fromTemplate = new ChatPreferences(templateCopy);
|
||||
assertTrue(fromTemplate.readPreferencesFromXmlFile());
|
||||
|
||||
assertTrue(LoginConfiguration.carriesTemplateCredentials(fromTemplate),
|
||||
"the template's credentials changed; a fresh installation would no longer "
|
||||
+ "be recognised as unconfigured");
|
||||
}
|
||||
}
|
||||
+4
-4
@@ -116,7 +116,7 @@ class MessageBusManagementThreadAutoAnswerDecisionTest {
|
||||
@Test
|
||||
void buildsTheQrgReply() {
|
||||
assertEquals(
|
||||
"/CQ DL1ABC " + MARKER + " QRG is: 144.300",
|
||||
"/CQ DL1ABC " + MARKER + " QRG is: 144.300 *a*",
|
||||
MessageBusManagementThread.buildAutoAnswerMessageText(
|
||||
"DL1ABC", VUHF, true, " 144.300 ", false, null));
|
||||
}
|
||||
@@ -124,7 +124,7 @@ class MessageBusManagementThreadAutoAnswerDecisionTest {
|
||||
@Test
|
||||
void qrgRequestWinsOverTheGenericReply() {
|
||||
assertEquals(
|
||||
"/CQ DL1ABC " + MARKER + " QRG is: 144.300",
|
||||
"/CQ DL1ABC " + MARKER + " QRG is: 144.300 *a*",
|
||||
MessageBusManagementThread.buildAutoAnswerMessageText(
|
||||
"DL1ABC", VUHF, true, "144.300", true, "not qrv"));
|
||||
}
|
||||
@@ -143,7 +143,7 @@ class MessageBusManagementThreadAutoAnswerDecisionTest {
|
||||
@Test
|
||||
void buildsTheGenericReplyTrimmed() {
|
||||
assertEquals(
|
||||
"/CQ DL1ABC " + MARKER + " not qrv, back at 18z",
|
||||
"/CQ DL1ABC " + MARKER + " not qrv, back at 18z *a*",
|
||||
MessageBusManagementThread.buildAutoAnswerMessageText(
|
||||
"DL1ABC", VUHF, false, "144.300", true, " not qrv, back at 18z "));
|
||||
}
|
||||
@@ -169,7 +169,7 @@ class MessageBusManagementThreadAutoAnswerDecisionTest {
|
||||
@Test
|
||||
void senderCallSignIsTrimmedButNotUpperCased() {
|
||||
assertEquals(
|
||||
"/CQ dl1abc " + MARKER + " QRG is: 144.300",
|
||||
"/CQ dl1abc " + MARKER + " QRG is: 144.300 *a*",
|
||||
MessageBusManagementThread.buildAutoAnswerMessageText(
|
||||
" dl1abc ", VUHF, true, "144.300", false, null));
|
||||
}
|
||||
|
||||
+7
-7
@@ -104,7 +104,7 @@ class MessageBusManagementThreadAutoAnswerTest {
|
||||
ChatMessage reply = replies.get(0);
|
||||
assertEquals(
|
||||
"/CQ " + REMOTE_CALL + " " + ApplicationConstants.AUTOANSWER_PREFIX
|
||||
+ " QRG is: " + FIRST_QRG,
|
||||
+ " QRG is: " + FIRST_QRG + " *a*",
|
||||
reply.getMessageText());
|
||||
assertEquals(MY_CALL, reply.getSender().getCallSign());
|
||||
assertEquals(REMOTE_CALL, reply.getReceiver().getCallSign());
|
||||
@@ -152,7 +152,7 @@ class MessageBusManagementThreadAutoAnswerTest {
|
||||
"another station and another category each get their own reply");
|
||||
assertEquals(
|
||||
"/CQ " + REMOTE_CALL + " " + ApplicationConstants.AUTOANSWER_PREFIX
|
||||
+ " QRG is: " + SECOND_QRG,
|
||||
+ " QRG is: " + SECOND_QRG + " *a*",
|
||||
replies.get(2).getMessageText(),
|
||||
"the second-category question is answered with the second QRG");
|
||||
assertSame(secondCategory, replies.get(2).getChatCategory());
|
||||
@@ -232,7 +232,7 @@ class MessageBusManagementThreadAutoAnswerTest {
|
||||
"the rejected reply must not have started the cooldown");
|
||||
assertEquals(
|
||||
"/CQ " + REMOTE_CALL + " " + ApplicationConstants.AUTOANSWER_PREFIX
|
||||
+ " QRG is: " + FIRST_QRG,
|
||||
+ " QRG is: " + FIRST_QRG + " *a*",
|
||||
txBus.peek().getMessageText());
|
||||
}
|
||||
|
||||
@@ -248,7 +248,7 @@ class MessageBusManagementThreadAutoAnswerTest {
|
||||
assertEquals(1, txBus.size());
|
||||
assertEquals(
|
||||
"/CQ " + REMOTE_CALL + " " + ApplicationConstants.AUTOANSWER_PREFIX
|
||||
+ " not qrv, back at 18z",
|
||||
+ " not qrv, back at 18z *a*",
|
||||
txBus.peek().getMessageText(),
|
||||
"the configured text is trimmed");
|
||||
}
|
||||
@@ -265,7 +265,7 @@ class MessageBusManagementThreadAutoAnswerTest {
|
||||
assertEquals(1, txBus.size());
|
||||
assertEquals(
|
||||
"/CQ " + REMOTE_CALL + " " + ApplicationConstants.AUTOANSWER_PREFIX
|
||||
+ " QRG is: " + FIRST_QRG,
|
||||
+ " QRG is: " + FIRST_QRG + " *a*",
|
||||
txBus.peek().getMessageText());
|
||||
}
|
||||
|
||||
@@ -282,7 +282,7 @@ class MessageBusManagementThreadAutoAnswerTest {
|
||||
|
||||
assertEquals(1, txBus.size(),
|
||||
"the blank generic reply is dropped; the QRG reply still goes out");
|
||||
assertTrue(txBus.peek().getMessageText().endsWith("QRG is: " + FIRST_QRG));
|
||||
assertTrue(txBus.peek().getMessageText().endsWith("QRG is: " + FIRST_QRG + " *a*"));
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -295,7 +295,7 @@ class MessageBusManagementThreadAutoAnswerTest {
|
||||
assertEquals(
|
||||
"/CQ " + REMOTE_CALL + " " + ApplicationConstants.AUTOANSWER_PREFIX
|
||||
+ " KST4Contest v" + ApplicationConstants.APPLICATION_CURRENT_VERSION
|
||||
+ " by DO5AMF",
|
||||
+ " by DO5AMF *a*",
|
||||
txBus.peek().getMessageText());
|
||||
}
|
||||
|
||||
|
||||
+1
-1
@@ -134,7 +134,7 @@ class MessageBusManagementThreadChatFrameTest {
|
||||
assertEquals(
|
||||
"/CQ " + REMOTE_CALL + " " + ApplicationConstants.AUTOANSWER_PREFIX
|
||||
+ " KST4Contest v" + ApplicationConstants.APPLICATION_CURRENT_VERSION
|
||||
+ " by DO5AMF",
|
||||
+ " by DO5AMF *a*",
|
||||
txBus.peek().getMessageText());
|
||||
verify(controller, times(1)).publishChatMessage(any(ChatMessage.class));
|
||||
}
|
||||
|
||||
@@ -89,13 +89,32 @@ class On4KstProtocolTest {
|
||||
);
|
||||
|
||||
assertEquals(
|
||||
"calling cq at 144.300",
|
||||
"calling cq at 144.300 *a*",
|
||||
controller.resolveAndValidateBeaconText(
|
||||
"calling cq at MYQRG"
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
@Test
|
||||
void keepsThe120CharacterPayloadAllowanceWithA124CharacterFinalBeacon() {
|
||||
ChatPreferences preferences = new ChatPreferences(tempDir.resolve("preferences.xml"));
|
||||
ChatController controller = new ChatController();
|
||||
controller.setChatPreferences(preferences);
|
||||
String payload = "x".repeat(120);
|
||||
|
||||
assertDoesNotThrow(() -> controller.validateBeaconTemplate(payload));
|
||||
|
||||
String finalMessage = controller.resolveAndValidateBeaconText(payload);
|
||||
assertEquals(124, finalMessage.length());
|
||||
assertEquals(payload + " *a*", finalMessage);
|
||||
|
||||
assertThrows(
|
||||
IllegalArgumentException.class,
|
||||
() -> controller.validateBeaconTemplate("x".repeat(121))
|
||||
);
|
||||
}
|
||||
|
||||
@Test
|
||||
void acceptsTemporarilyUnresolvedVariableOnlyBeaconTemplate() {
|
||||
ChatPreferences preferences = new ChatPreferences(tempDir.resolve("preferences.xml"));
|
||||
@@ -136,11 +155,8 @@ class On4KstProtocolTest {
|
||||
assertThrows(
|
||||
IllegalArgumentException.class,
|
||||
() -> controller.validateBeaconTemplate(
|
||||
"x".repeat(
|
||||
ChatController.MAX_BEACON_TEXT_LENGTH
|
||||
+ 1
|
||||
)
|
||||
"x".repeat(121)
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -4,7 +4,10 @@ import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
import static org.junit.jupiter.api.Assertions.assertFalse;
|
||||
import static org.junit.jupiter.api.Assertions.assertTrue;
|
||||
import static org.mockito.ArgumentMatchers.any;
|
||||
import static org.mockito.ArgumentMatchers.anyLong;
|
||||
import static org.mockito.ArgumentMatchers.anyString;
|
||||
import static org.mockito.ArgumentMatchers.eq;
|
||||
import static org.mockito.Mockito.doAnswer;
|
||||
import static org.mockito.Mockito.doThrow;
|
||||
import static org.mockito.Mockito.mock;
|
||||
import static org.mockito.Mockito.never;
|
||||
@@ -105,6 +108,7 @@ class ReadUDPbyUCXMessageThreadLoopbackTest {
|
||||
when(preferences.isTrxSynch_ucxLogUDPListenerEnabled()).thenReturn(true);
|
||||
SimpleValue<String> qrg = new SimpleValue<>("");
|
||||
when(preferences.getMYQRGFirstCat()).thenReturn(qrg);
|
||||
stubExternalQrgWrites(qrg);
|
||||
CountDownLatch firstQrg = new CountDownLatch(1);
|
||||
CountDownLatch secondQrg = new CountDownLatch(1);
|
||||
qrg.addListener(value -> {
|
||||
@@ -230,6 +234,29 @@ class ReadUDPbyUCXMessageThreadLoopbackTest {
|
||||
assertEquals("1296.200.00", markerQrg.get());
|
||||
}
|
||||
|
||||
/** A malformed Freq is expected external input and must be ignored without the safety net. */
|
||||
@Test
|
||||
void malformedRadioInfoFrequencyIsSkippedWithoutAnUnexpectedError(@TempDir Path tempDir) throws Exception {
|
||||
givenQsoProcessingEnabled(tempDir.resolve("udp-backup.txt"));
|
||||
|
||||
sendThenAwaitMarker("<RadioInfo><Freq>not-a-number</Freq><Mode>CW</Mode></RadioInfo>");
|
||||
|
||||
assertEquals("1296.200.00", markerQrg.get());
|
||||
assertFalse(statusMessages.stream()
|
||||
.anyMatch(message -> message.getRunningInformation().startsWith("packet dropped after error")));
|
||||
}
|
||||
|
||||
@Test
|
||||
void nonPositiveRadioInfoFrequencyIsIgnoredBeforeItReachesTheController(@TempDir Path tempDir)
|
||||
throws Exception {
|
||||
givenQsoProcessingEnabled(tempDir.resolve("udp-backup.txt"));
|
||||
|
||||
sendThenAwaitMarker("<RadioInfo><Freq>0</Freq><Mode>CW</Mode></RadioInfo>");
|
||||
|
||||
verify(controller, never()).applyExternalQrg(any(RadioSlot.class), eq("0"), eq(0L));
|
||||
assertEquals("1296.200.00", markerQrg.get());
|
||||
}
|
||||
|
||||
/**
|
||||
* Any runtime exception while processing one packet drops that packet,
|
||||
* reports a non-critical status and leaves the receive loop running.
|
||||
@@ -275,6 +302,16 @@ class ReadUDPbyUCXMessageThreadLoopbackTest {
|
||||
when(controller.uiDispatcher()).thenReturn(new DirectUiDispatcher());
|
||||
when(preferences.isTrxSynch_ucxLogUDPListenerEnabled()).thenReturn(true);
|
||||
when(preferences.getMYQRGFirstCat()).thenReturn(markerQrg);
|
||||
stubExternalQrgWrites(markerQrg);
|
||||
}
|
||||
|
||||
private void stubExternalQrgWrites(SimpleValue<String> firstQrg) {
|
||||
doAnswer(invocation -> {
|
||||
RadioSlot slot = invocation.getArgument(0);
|
||||
String value = invocation.getArgument(1);
|
||||
(slot == RadioSlot.FIRST ? firstQrg : secondQrg).set(value);
|
||||
return null;
|
||||
}).when(controller).applyExternalQrg(any(RadioSlot.class), anyString(), anyLong());
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -5,12 +5,10 @@ import kst4contest.observe.DirectUiDispatcher;
|
||||
import kst4contest.observe.SimpleValue;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
import static org.junit.jupiter.api.Assertions.assertTrue;
|
||||
import static org.mockito.Mockito.mock;
|
||||
import static org.mockito.Mockito.verify;
|
||||
import static org.mockito.Mockito.when;
|
||||
|
||||
/** A Win-Test STATUS of the second station writes SECONDQRG when SO2R is on. */
|
||||
@@ -18,18 +16,10 @@ class WinTestStatusSlotTest {
|
||||
|
||||
/* STATUS layout as parseStatus reads it: token 1 station, 5 mode, 7 frequency in 100 Hz. */
|
||||
private static final String STATUS_STN2 = "STATUS: \"STN2\" \"\" 0 12 0 0 4322000 0";
|
||||
private static final String STATUS_STN1 = "STATUS: \"STN1\" \"\" 0 12 0 0 1443000 0";
|
||||
|
||||
private final ChatController controller = mock(ChatController.class);
|
||||
private final ChatPreferences prefs = mock(ChatPreferences.class);
|
||||
private final List<String> first = new ArrayList<>();
|
||||
private final List<String> second = new ArrayList<>();
|
||||
|
||||
private static SimpleValue<String> recording(List<String> writes) {
|
||||
SimpleValue<String> value = new SimpleValue<>("");
|
||||
value.addListener(writes::add);
|
||||
return value;
|
||||
}
|
||||
|
||||
private ReadUDPByWintestThread thread(boolean so2r) {
|
||||
when(controller.getChatPreferences()).thenReturn(prefs);
|
||||
when(controller.uiDispatcher()).thenReturn(new DirectUiDispatcher());
|
||||
@@ -37,8 +27,6 @@ class WinTestStatusSlotTest {
|
||||
when(prefs.isTrxSynch_so2rEnabled()).thenReturn(so2r);
|
||||
when(prefs.getLogsynch_wintestNetworkStationNameOfWintestClient1()).thenReturn("STN1");
|
||||
when(prefs.getLogsynch_wintestNetworkStationNameOfWintestClient2()).thenReturn("STN2");
|
||||
when(prefs.getMYQRGFirstCat()).thenReturn(recording(first));
|
||||
when(prefs.getMYQRGSecondCat()).thenReturn(recording(second));
|
||||
return new ReadUDPByWintestThread(controller, mock(ThreadStatusCallback.class));
|
||||
}
|
||||
|
||||
@@ -46,15 +34,21 @@ class WinTestStatusSlotTest {
|
||||
void withSo2rTheSecondStationWritesTheSecondQrg() {
|
||||
thread(true).parseStatus(STATUS_STN2);
|
||||
|
||||
assertEquals(1, second.size());
|
||||
assertTrue(first.isEmpty());
|
||||
verify(controller).applyExternalQrg(RadioSlot.SECOND, "432.200.00", 432_200_000L);
|
||||
}
|
||||
|
||||
@Test
|
||||
void withoutSo2rTheSecondStationIsFilteredOutAsBefore() {
|
||||
thread(false).parseStatus(STATUS_STN2);
|
||||
|
||||
assertTrue(first.isEmpty());
|
||||
assertTrue(second.isEmpty());
|
||||
org.mockito.Mockito.verify(controller, org.mockito.Mockito.never())
|
||||
.applyExternalQrg(org.mockito.ArgumentMatchers.any(), org.mockito.ArgumentMatchers.anyString(), org.mockito.ArgumentMatchers.anyLong());
|
||||
}
|
||||
|
||||
@Test
|
||||
void withoutSo2rTheFirstStationUpdatesOnlyTheMainSlotWithExactHz() {
|
||||
thread(false).parseStatus(STATUS_STN1);
|
||||
|
||||
verify(controller).applyExternalQrg(RadioSlot.FIRST, "144.300.00", 144_300_000L);
|
||||
}
|
||||
}
|
||||
@@ -5,6 +5,7 @@ import static org.junit.jupiter.api.Assertions.assertFalse;
|
||||
import static org.junit.jupiter.api.Assertions.assertTrue;
|
||||
|
||||
import java.nio.file.Path;
|
||||
import java.nio.file.Files;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
@@ -24,31 +25,60 @@ class ChatPreferencesBeaconStateTest {
|
||||
preferences.bcnBeaconsEnabledMainCatProperty().addListener(mainChanges::add);
|
||||
preferences.bcnBeaconsEnabledSecondCatProperty().addListener(secondChanges::add);
|
||||
|
||||
preferences.setBcn_beaconsEnabledMainCat(true);
|
||||
preferences.setBcn_beaconsEnabledMainCat(false);
|
||||
preferences.setBcn_beaconsEnabledSecondCat(true);
|
||||
|
||||
assertFalse(preferences.isBcn_beaconsEnabledMainCat());
|
||||
assertTrue(preferences.isBcn_beaconsEnabledSecondCat());
|
||||
assertEquals(List.of(false), mainChanges);
|
||||
assertEquals(List.of(true, false), mainChanges);
|
||||
assertEquals(List.of(true), secondChanges);
|
||||
}
|
||||
|
||||
@Test
|
||||
void explicitWritePersistsBeaconActivationButAnUnsavedChangeDoesNot() {
|
||||
void activationIsSessionOnlyAndEveryFullWriteStoresFalse() throws Exception {
|
||||
ChatPreferences preferences = preferences("persistence.xml");
|
||||
preferences.setBcn_beaconsEnabledMainCat(false);
|
||||
preferences.setBcn_beaconsEnabledMainCat(true);
|
||||
preferences.setBcn_beaconsEnabledSecondCat(true);
|
||||
assertTrue(preferences.writePreferencesToXmlFile());
|
||||
|
||||
String xml = Files.readString(tempDir.resolve("persistence.xml"));
|
||||
assertTrue(xml.contains("<beaconCQEnabled>false</beaconCQEnabled>"));
|
||||
assertTrue(xml.contains("<bcn_beaconsEnabledMainCat>false</bcn_beaconsEnabledMainCat>"));
|
||||
assertTrue(xml.contains("<beaconCQEnabledSecondCat>false</beaconCQEnabledSecondCat>"));
|
||||
assertTrue(xml.contains("<bcn_beaconsEnabledSecondCat>false</bcn_beaconsEnabledSecondCat>"));
|
||||
|
||||
preferences.setBcn_beaconsEnabledMainCat(true);
|
||||
preferences.setBcn_beaconsEnabledSecondCat(false);
|
||||
preferences.setBcn_beaconsEnabledSecondCat(true);
|
||||
assertTrue(preferences.writeLayoutPreferencesToXmlFile());
|
||||
|
||||
ChatPreferences restored = preferences("persistence.xml");
|
||||
restored.readPreferencesFromXmlFile();
|
||||
|
||||
assertFalse(restored.isBcn_beaconsEnabledMainCat());
|
||||
assertTrue(restored.isBcn_beaconsEnabledSecondCat());
|
||||
assertFalse(restored.isBcn_beaconsEnabledSecondCat());
|
||||
}
|
||||
|
||||
@Test
|
||||
void storedActivationIsIgnoredAndIntervalsBelowFiveAreNormalized() throws Exception {
|
||||
Path file = tempDir.resolve("legacy.xml");
|
||||
Files.writeString(file, """
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<praktiKST><beaconCQ>
|
||||
<beaconCQEnabled>true</beaconCQEnabled>
|
||||
<beaconCQEnabledSecondCat>true</beaconCQEnabledSecondCat>
|
||||
<beaconCQIntervalMinutes>1</beaconCQIntervalMinutes>
|
||||
<beaconCQIntervalMinutesSecondCat>9</beaconCQIntervalMinutesSecondCat>
|
||||
</beaconCQ></praktiKST>
|
||||
""");
|
||||
|
||||
ChatPreferences restored = new ChatPreferences(file);
|
||||
assertTrue(restored.readPreferencesFromXmlFile());
|
||||
|
||||
assertFalse(restored.isBcn_beaconsEnabledMainCat());
|
||||
assertFalse(restored.isBcn_beaconsEnabledSecondCat());
|
||||
assertEquals(5, restored.getBcn_beaconIntervalInMinutesMainCat());
|
||||
assertEquals(9, restored.getBcn_beaconIntervalInMinutesSecondCat());
|
||||
}
|
||||
|
||||
private ChatPreferences preferences(String fileName) {
|
||||
|
||||
@@ -0,0 +1,72 @@
|
||||
package kst4contest.model;
|
||||
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.junit.jupiter.api.io.TempDir;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Path;
|
||||
import java.nio.file.StandardCopyOption;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.assertArrayEquals;
|
||||
import static org.junit.jupiter.api.Assertions.assertFalse;
|
||||
import static org.junit.jupiter.api.Assertions.assertNotNull;
|
||||
import static org.junit.jupiter.api.Assertions.assertTrue;
|
||||
|
||||
/**
|
||||
* Pins the return value of {@link ChatPreferences#readPreferencesFromXmlFile()}: it must
|
||||
* report a failed read as {@code false} so callers such as the setup wizard launcher can
|
||||
* tell an unreadable profile file from a readable one.
|
||||
*/
|
||||
class ChatPreferencesReadResultTest {
|
||||
|
||||
@TempDir
|
||||
Path temporaryDirectory;
|
||||
|
||||
@Test
|
||||
void aFileThatIsNotXmlIsReportedAsUnreadable() throws IOException {
|
||||
Path file = temporaryDirectory.resolve("notxml.xml");
|
||||
byte[] original = "this is not xml <<<".getBytes(StandardCharsets.UTF_8);
|
||||
Files.write(file, original);
|
||||
|
||||
ChatPreferences preferences = new ChatPreferences(file);
|
||||
assertFalse(preferences.readPreferencesFromXmlFile(), "a non-XML file must be reported as unreadable");
|
||||
assertArrayEquals(original, Files.readAllBytes(file), "the unreadable file must be left untouched");
|
||||
}
|
||||
|
||||
@Test
|
||||
void aMissingFileIsReportedAsUnreadable() {
|
||||
Path file = temporaryDirectory.resolve("missing.xml");
|
||||
|
||||
ChatPreferences preferences = new ChatPreferences(file);
|
||||
assertFalse(preferences.readPreferencesFromXmlFile(), "a missing file must be reported as unreadable");
|
||||
assertFalse(Files.exists(file), "reading a missing file must not create it");
|
||||
}
|
||||
|
||||
@Test
|
||||
void aWellFormedXmlWithForeignRootIsReportedAsUnreadable() throws IOException {
|
||||
Path file = temporaryDirectory.resolve("foreign.xml");
|
||||
byte[] original = "<somethingElse><station><LoginCallSign>DL0TEST</LoginCallSign></station></somethingElse>"
|
||||
.getBytes(StandardCharsets.UTF_8);
|
||||
Files.write(file, original);
|
||||
|
||||
ChatPreferences preferences = new ChatPreferences(file);
|
||||
assertFalse(preferences.readPreferencesFromXmlFile(), "a foreign XML root must be reported as unreadable");
|
||||
assertArrayEquals(original, Files.readAllBytes(file), "the foreign XML file must be left untouched");
|
||||
}
|
||||
|
||||
@Test
|
||||
void theBundledTemplateIsReadable() throws IOException {
|
||||
Path templateCopy = temporaryDirectory.resolve("template.xml");
|
||||
try (InputStream template = ChatPreferences.class
|
||||
.getResourceAsStream(ChatPreferences.PREFERENCE_RESOURCE)) {
|
||||
assertNotNull(template, "bundled resource " + ChatPreferences.PREFERENCE_RESOURCE);
|
||||
Files.copy(template, templateCopy, StandardCopyOption.REPLACE_EXISTING);
|
||||
}
|
||||
|
||||
ChatPreferences fromTemplate = new ChatPreferences(templateCopy);
|
||||
assertTrue(fromTemplate.readPreferencesFromXmlFile(), "the bundled template must be readable");
|
||||
}
|
||||
}
|
||||
@@ -64,6 +64,10 @@ class ChatPreferencesRoundTripTest {
|
||||
Map.entry("setMessageHandling_autoAnswerEnabledSecondCat",
|
||||
"Same deliberate mirroring as the second-category auto-answer text; the "
|
||||
+ "main-category flag wins after every read"),
|
||||
Map.entry("setBcn_beaconsEnabledMainCat",
|
||||
"Session-only safety switch; every XML write stores false and every read starts false"),
|
||||
Map.entry("setBcn_beaconsEnabledSecondCat",
|
||||
"Session-only safety switch; every XML write stores false and every read starts false"),
|
||||
Map.entry("setBcn_contestScoreSum",
|
||||
"DEAD FIELD: declared with accessors only, no caller in core or app-desktop, "
|
||||
+ "never written nor read")
|
||||
|
||||
+39
-3
@@ -215,10 +215,12 @@ CR/LF framing, XML framing, ports/transports, callsign normalization and frequen
|
||||
## Autoanswer / Beacon
|
||||
|
||||
- Automated-message loops must be prevented.
|
||||
- Cooldown/minimum-interval rules must be preserved.
|
||||
- Every user-visible automatic chat message generated by KST4Contest ends with the exact suffix ` *a*`: generic and QRG-specific automatic replies, `//VER` replies and both category beacons. Automatic replies retain their `[KST4C Automsg]` prefix as the loop guard. The suffix is appended unconditionally after message construction or beacon variable resolution; manual messages and internal login, keepalive and control frames are unchanged. Beacon content remains limited to 120 characters before the suffix, making 124 characters the final transmitted maximum.
|
||||
- Cooldown/minimum-interval rules must be preserved. The shared beacon interval has a hard minimum of five minutes; older stored values below five are normalized while loading.
|
||||
- A reply rejected before a complete valid TX item is queued must not consume cooldown.
|
||||
- Both category beacons share one timer, while their enable flags and templates remain profile-scoped and independent. The enable flags are observable runtime preferences: Settings changes and the `MyBeacon` status-chip action update them immediately, and every timer run reads their current values without restarting the timer or causing an immediate transmission. Only the explicit full settings write persists those flags; layout autosave deliberately leaves the on-disk functional state untouched.
|
||||
- `MyBeacon` owns one aggregate thread-status entry for both categories (`off`, a partial `enabled/available` count, `on`, or `FAILED`). Its action disables all currently usable beacons if any is enabled, otherwise it enables all currently usable beacons. A disabled second chat is not usable and its dormant enable flag must not be changed by the aggregate action. Category-specific timer failures remain authoritative while the affected beacon stays active; independent switch changes cannot hide them. The status bar resolves the aggregate from current controller state when a queued UI update is applied, so a delayed timer snapshot cannot overwrite a newer manual switch. Open Settings views observe the same preference values, so changes from the status chip remain synchronized without a parallel UI state.
|
||||
- Both category beacons share one timer, while their message templates remain profile-scoped and independent. `BeaconSessionState` is the authoritative owner of activation, per-category QRG references, deactivation reasons and send failures. Activations are never restored from XML: both start off after program startup and every profile switch, remain unchanged during an ON4KST reconnect in the same application session, and are projected into the legacy observable preference booleans for Settings/UI compatibility. Full preference writes emit both legacy/current enable tags as `false`.
|
||||
- Enabling validates QRG placeholders across either template: `MYQRG` and `MYQRGSHORT` require a valid primary QRG; `SECONDQRG` requires a valid secondary QRG. A template without a QRG placeholder may be enabled without a current QRG, and the first later valid own-category QRG establishes its reference. A valid manual QRG change always rebases the corresponding active beacon. A UCXLog or Win-Test update more than 5,000 Hz away from the reference disables only that category; exactly 5,000 Hz remains allowed. Without SO2R, logger updates reach the primary category only; with SO2R each radio/category is handled independently. A missing/invalid required QRG disables an active beacon, while an invalid own QRG without a QRG placeholder only clears its reference.
|
||||
- `MyBeacon` owns one structured aggregate thread-status snapshot for both categories (`off`, `1/2`, `on`, or `FAILED`). Its action disables all currently usable beacons if any is enabled, otherwise it attempts to enable each usable beacon independently, so one invalid category can remain off. The tooltip derives the state or last general deactivation reason for each category from the same snapshot. Active states use the dedicated green treatment with a 200 ms orange activity flash; `off` keeps a neutral surface with red text; `FAILED` uses a persistent red surface with white text and suppresses the activity flash. Other thread-status chips keep their existing styling.
|
||||
- Current implementation/tests define the exact message markers and timer details.
|
||||
|
||||
## Build / Verification
|
||||
@@ -398,6 +400,29 @@ section records only the durable architecture and operational boundaries.
|
||||
- The station map is a Compose canvas that fetches its own tiles. The JavaFX WebView, the bundled Leaflet resources, the CSS-3D-transform workaround and the `TileProxyServer` were removed with JavaFX; offline DEM, terrain packages and the profile cache are unaffected and must stay that way.
|
||||
- Deliberate test data, comments and Easter eggs are preserved unless explicitly changed.
|
||||
- Chat frames (issue #105, second slice): CH (live) and CR (history) go through one `MessageBusManagementThread.processChatFrame(fields, live)`. `classifyRoute` and `decideChatFrameEffects` are pure; history frames never play sounds, answer or spot, and keep their frequency extraction after publishing. Known oddities kept on purpose: TO_ME is case-sensitive, FROM_ME case-insensitive; the CR SERVER sender has no AirScout info.
|
||||
- **The setup wizard writes `preferences.xml` and does not touch a running session.** It runs
|
||||
in `startRuntime` after the profile is resolved and before the `ChatController` exists, on
|
||||
a `ChatPreferences` of its own, so what it stores is read like any stored setting. That is
|
||||
why it needs neither `SettingsDraft` nor the tab states: there is no session to bring up to
|
||||
date. From the menu the runtime is torn down first and the same profile restarted
|
||||
(`ApplicationRuntimeLauncher.rerunSetupWizard`), which costs the session and asks first. A
|
||||
profile counts as unconfigured when its callsign is empty or it still carries the bundled
|
||||
template's credentials (`LoginConfiguration`); there is no flag for it in the file. It
|
||||
asks for name, login, locator, bands and chat category, and optionally for antenna and
|
||||
power, log program, rotator and AirScout. A station set up anew gets only what the
|
||||
operator said yes to: the bundled template has several integrations on, and the wizard
|
||||
switches them off and says so in its summary. That holds for a new
|
||||
station also when the operator skips those pages with Finish: they are part of the run and
|
||||
are written with their start values. A station left unchanged is the opposite case: a page
|
||||
of it is written only if the operator opened it from the summary, which is what lets such a
|
||||
profile keep several log sources as they are. Login and station can
|
||||
each be taken from another configured profile; "station" then means every setting listed
|
||||
in `app-desktop/src/test/resources/wizard-station-setters.txt`, also those no page asks
|
||||
about, and a test fails when a new `ChatPreferences` setter is in neither that list nor
|
||||
`wizard-other-setters.txt`. A new setting therefore needs that one decision: does another
|
||||
operator at the same station inherit it. The other profile's file is only read, through
|
||||
`ChatPreferences(Path)`, so a missing one is not seeded from the template. The reasons are
|
||||
in `docs/superpowers/specs/2026-11-18-einrichtungsassistent-design.md`.
|
||||
|
||||
## Planned Technical Direction
|
||||
|
||||
@@ -417,10 +442,21 @@ Before implementing planned items, re-check current decisions and obtain a fresh
|
||||
- Historical project context is useful but may be stale; current code/tests win.
|
||||
- External service/API behaviour must be verified against current upstream documentation when uncertain.
|
||||
- Screenshots in manuals/website may need targeted replacement after visible UI changes; never fabricate them.
|
||||
- `client_settings_window_beacon.png` was recaptured from the current Compose UI in a live application session on 2026-11-13. It shows both beacons disabled after a profile switch and the five-minute minimum interval.
|
||||
- `station_map_path_analysis.png` and `station_map_reset.png` predate the current header controls, callsign-only markers, shared station context menu and Worked-square overlay. The former remains useful only where the visible analysis panel itself is the subject. `station_map_spatial_filters.png` is the current general map screenshot shared by the DE/EN interface manuals and the website through `/manual/assets/`.
|
||||
|
||||
## Recent Significant Changes
|
||||
|
||||
### 2026-11-13 – Automatic chat messages marked with a suffix
|
||||
|
||||
- Generic and QRG-specific automatic replies, `//VER` replies and both beacons now carry the exact ` *a*` suffix. Existing auto-reply loop protection remains based on `[KST4C Automsg]`; manual chat and ON4KST control traffic are unchanged.
|
||||
- Beacon templates and resolved payloads retain the 120-character limit. The fixed suffix is added afterwards, so a transmitted beacon may contain up to 124 characters.
|
||||
|
||||
### 2026-11-12 – Beacon activation and QRG safety made session-scoped
|
||||
|
||||
- Beacon activation is now explicit per application session, while ordinary ON4KST reconnects preserve it. Per-category references distinguish deliberate manual QRG changes from UCXLog/Win-Test moves and disable only the affected beacon after a change greater than 5 kHz.
|
||||
- The structured aggregate beacon status keeps per-category deactivation reasons and drives the dedicated green/orange/red `MyBeacon` chip without changing other thread-status chips.
|
||||
|
||||
### 2026-10-17 – Repository moved to the HamRadioOnline organisation
|
||||
|
||||
- The GitHub repository moved from `praktimarc/kst4contest` to `HamRadioOnline/kst4contest`. GitHub redirects the old repository, Pages, API and git URLs, so published links and release assets from before the move keep working.
|
||||
|
||||
@@ -0,0 +1,207 @@
|
||||
# Beacon Session Safety Implementation Plan
|
||||
|
||||
> **For agentic workers:** REQUIRED SUB-SKILL: Use superpowers:subagent-driven-development (recommended) or superpowers:executing-plans to implement this plan task-by-task. Steps use checkbox (`- [ ]`) syntax for tracking.
|
||||
|
||||
**Goal:** Make beacon activation session-only, enforce a five-minute minimum, disable the correct category after an external QRG move beyond 5 kHz, and render a reason-aware traffic-colour `MyBeacon` chip.
|
||||
|
||||
**Architecture:** A controller-owned `BeaconSessionState` coordinates the existing observable runtime flags, category references, inactive reasons and send failures. Manual QRG commits and UCXLog/Win-Test reports enter through distinct controller methods; a structured model snapshot crosses the existing thread-status boundary and `app-desktop` localises and styles it.
|
||||
|
||||
**Tech Stack:** Java 21, Kotlin 2.2, Compose Multiplatform 1.8.x, JUnit 5, Mockito, Gradle wrapper
|
||||
|
||||
**Spec:** `docs/superpowers/specs/2026-11-11-beacon-session-safety-design.md`
|
||||
|
||||
## Global Constraints
|
||||
|
||||
- Work directly on `main`, as explicitly authorised.
|
||||
- Do not stage, commit, push, merge, tag, release or deploy; commit steps are deliberately omitted because Marc authorised none of them.
|
||||
- Keep source comments and Javadoc in English; user-facing DE/EN text follows the project writing style.
|
||||
- Use exactly 5 minutes and 5,000 Hz; exactly 5,000 Hz must not disable a beacon.
|
||||
- Do not add a production dependency or change ON4KST/UCXLog/Win-Test framing.
|
||||
- Keep the shared timer, initial ten-second check, outbound queue and second-chat eligibility unchanged.
|
||||
- Do not execute UI callbacks while holding an internal beacon-state lock.
|
||||
- Preserve unrelated local changes and inspect the diff before and after every task.
|
||||
|
||||
## Review Focus
|
||||
|
||||
- A secondary beacon using `MYQRG` must be refused or disabled when the primary QRG is invalid, even though its own reference remains the secondary QRG; Task 1 pins this cross-template case.
|
||||
- An external report with no reference must establish the reference without disabling; Task 1 pins this first-report case.
|
||||
- Without SO2R a Win-Test/UCXLog report must affect only the main beacon; Task 3 pins both integrations.
|
||||
- An old XML file with enabled flags and a one-minute interval must load as disabled with a five-minute interval and later write `false`; Task 2 pins the migration.
|
||||
- `FAILED` must stay red without an orange flash while ordinary worker chips retain current theme colours; Task 4 pins both sides.
|
||||
|
||||
---
|
||||
|
||||
### Task 1: Pure beacon session policy and structured status
|
||||
|
||||
**Files:**
|
||||
- Create: `core/src/main/java/kst4contest/controller/BeaconFrequencyParser.java`
|
||||
- Create: `core/src/main/java/kst4contest/controller/BeaconSessionState.java`
|
||||
- Create: `core/src/main/java/kst4contest/model/BeaconStatusSnapshot.java`
|
||||
- Create: `core/src/test/java/kst4contest/controller/BeaconFrequencyParserTest.java`
|
||||
- Create: `core/src/test/java/kst4contest/controller/BeaconSessionStateTest.java`
|
||||
|
||||
**Interfaces:**
|
||||
- Produces: `BeaconFrequencyParser.parseHz(String): OptionalLong`.
|
||||
- Produces: `BeaconSessionState.Channel { MAIN, SECOND }` and synchronized policy methods `resetSession(ChatPreferences)`, `setEnabled(Channel, boolean, ChatPreferences)`, `onManualQrgChanged(Channel, String, ChatPreferences)`, `onExternalQrgChanged(Channel, long, ChatPreferences)`, `onTemplateChanged(Channel, ChatPreferences)`, `recordSendFailure(Channel, boolean)` and `snapshot(ChatPreferences): BeaconStatusSnapshot`.
|
||||
- Produces: explicit `BeaconStatusSnapshot` DTO with aggregate state `OFF`, `PARTIAL`, `ON`, `FAILED`, plus main/second category DTOs carrying availability, enablement, failure and `InactiveReason`.
|
||||
|
||||
- [ ] **Step 1: Write parser tests** for `144.300`, `144,300`, `144.300.03`, `1296.123.000`, compact `144300`, compact `10368100`, blanks, malformed text, non-positive values and overflow.
|
||||
- [ ] **Step 2: Run the parser test and verify RED.**
|
||||
|
||||
Run: `.\gradlew.bat :core:test --tests kst4contest.controller.BeaconFrequencyParserTest --console=plain`
|
||||
|
||||
Expected: compilation failure because `BeaconFrequencyParser` does not exist.
|
||||
|
||||
- [ ] **Step 3: Implement `BeaconFrequencyParser`** with integer arithmetic and the QRG forms already used by the client; accept only a complete positive frequency that maps to a supported `Band`.
|
||||
- [ ] **Step 4: Re-run the parser test and verify GREEN.**
|
||||
- [ ] **Step 5: Write session-policy tests** for initial reasons, independent enablement, placeholder requirements in either template, partial aggregate activation, manual reference creation/rebase, invalid manual clearing, cross-template invalidation, first external reference, 5,000/5,001-Hz boundaries, per-category external changes, reason retention and send-failure clearing.
|
||||
- [ ] **Step 6: Run `BeaconSessionStateTest` and verify RED** because the policy and DTO are absent.
|
||||
- [ ] **Step 7: Implement the DTO and policy** so the existing observable preference booleans are projection only and no listener/callback leaves a synchronized method.
|
||||
- [ ] **Step 8: Re-run both focused tests and verify GREEN.**
|
||||
- [ ] **Step 9: Inspect the task diff** for duplicated state, floating-point frequency comparisons or display strings in `core`.
|
||||
|
||||
### Task 2: Session-only persistence and five-minute migration
|
||||
|
||||
**Files:**
|
||||
- Modify: `core/src/main/java/kst4contest/model/ChatPreferences.java`
|
||||
- Modify: `core/src/main/java/kst4contest/controller/ChatController.java`
|
||||
- Modify: `core/src/main/resources/praktiKSTpreferences.xml`
|
||||
- Modify: `core/src/test/java/kst4contest/model/ChatPreferencesBeaconStateTest.java`
|
||||
- Modify: `core/src/test/java/kst4contest/model/ChatPreferencesRoundTripTest.java`
|
||||
- Modify: `app-desktop/src/test/kotlin/kst4contest/view/compose/tabs/BeaconTabStateTest.kt`
|
||||
- Modify: `app-desktop/src/test/kotlin/kst4contest/view/i18n/RemainingTextsFollowTheLanguageTest.kt`
|
||||
|
||||
**Interfaces:**
|
||||
- Consumes: Task 1 `BeaconSessionState`.
|
||||
- Produces: `ChatController.MIN_BEACON_INTERVAL_MINUTES == 5` and session reset during controller/profile construction without reset on reconnect.
|
||||
|
||||
- [ ] **Step 1: Replace persistence expectations with failing tests** proving defaults are off, stored `true` is ignored, every full write stores both legacy/current enable tags as `false`, layout-only writes do not revive them, and intervals below five normalise in memory.
|
||||
- [ ] **Step 2: Add interval tests** proving four is refused, five accepted, and an old stored one becomes five without changing a larger value.
|
||||
- [ ] **Step 3: Run the focused core and desktop tests and verify RED.**
|
||||
|
||||
Run: `.\gradlew.bat :core:test --tests kst4contest.model.ChatPreferencesBeaconStateTest --tests kst4contest.model.ChatPreferencesRoundTripTest :app-desktop:test --tests kst4contest.view.compose.tabs.BeaconTabStateTest --tests kst4contest.view.i18n.RemainingTextsFollowTheLanguageTest --console=plain`
|
||||
|
||||
- [ ] **Step 4: Make enable flags session-only**: initialise both false, ignore XML enable values, always serialise `false`, retain existing element names, and reset the policy only when a new controller/profile preferences object is installed.
|
||||
- [ ] **Step 5: Set and enforce the five-minute minimum** in controller, XML defaults and preference-load normalisation; retain timer start/restart semantics.
|
||||
- [ ] **Step 6: Re-run the focused tests and inspect their XML summaries.**
|
||||
- [ ] **Step 7: Inspect the task diff** to confirm no reconnect path resets the session and no default was silently raised to ten minutes.
|
||||
|
||||
### Task 3: Explicit manual and external QRG paths
|
||||
|
||||
**Files:**
|
||||
- Modify: `core/src/main/java/kst4contest/controller/ChatController.java`
|
||||
- Modify: `core/src/main/java/kst4contest/controller/ReadUDPbyUCXMessageThread.java`
|
||||
- Modify: `core/src/main/java/kst4contest/controller/ReadUDPByWintestThread.java`
|
||||
- Modify: `app-desktop/src/main/kotlin/kst4contest/view/compose/ChatInputState.kt`
|
||||
- Modify: `app-desktop/src/main/kotlin/kst4contest/view/compose/ChatInputRow.kt`
|
||||
- Modify: `app-desktop/src/main/java/kst4contest/view/ComposeChatInputActions.java`
|
||||
- Modify: `app-desktop/src/main/kotlin/kst4contest/view/compose/tabs/BeaconTabState.kt`
|
||||
- Modify: `app-desktop/src/main/kotlin/kst4contest/view/compose/SettingsTabs.kt`
|
||||
- Modify: focused fake `ChatInputActions` implementations in affected tests
|
||||
- Modify: `core/src/test/java/kst4contest/controller/BeaconControlTest.java`
|
||||
- Modify: `core/src/test/java/kst4contest/controller/ReadUDPbyUCXMessageThreadLoopbackTest.java`
|
||||
- Modify: `core/src/test/java/kst4contest/controller/WinTestStatusSlotTest.java`
|
||||
- Modify: `app-desktop/src/test/kotlin/kst4contest/view/compose/ChatInputStateTest.kt`
|
||||
- Modify: `app-desktop/src/test/kotlin/kst4contest/view/compose/tabs/BeaconTabStateTest.kt`
|
||||
|
||||
**Interfaces:**
|
||||
- Produces: controller methods `applyManualQrg(RadioSlot, String)`, `applyExternalQrg(RadioSlot, String, long)`, `onMainBeaconTemplateApplied()` and `onSecondBeaconTemplateApplied()`.
|
||||
- Produces: a `ChatInputActions`/`ChatInputState` manual-QRG commit method used by `ChatInputRow` instead of writing preferences directly.
|
||||
- Consumes: Task 1 policy and Task 2 session lifecycle.
|
||||
|
||||
- [ ] **Step 1: Add failing controller tests** for individual activation refusal, valid partial chip activation, user disable reason, manual rebase, invalid manual cross-template disabling and template-apply revalidation.
|
||||
- [ ] **Step 2: Add failing chat-input tests** proving both manual fields call the explicit action with the correct `RadioSlot`/category and never write preferences directly.
|
||||
- [ ] **Step 3: Add failing UCXLog tests** for exact Hz conversion, first-reference behaviour, >5-kHz main-only shutdown without SO2R and second-only shutdown for RadioNr 2 with SO2R.
|
||||
- [ ] **Step 4: Add failing Win-Test tests** for main/pass frequency selection, 100-Hz units, non-SO2R main-only and SO2R slot routing.
|
||||
- [ ] **Step 5: Run the four focused test groups and verify RED.**
|
||||
- [ ] **Step 6: Implement the controller entry points** so the preference value and policy update occur together on the existing UI-dispatch boundary and publish a fresh beacon status only after state is consistent.
|
||||
- [ ] **Step 7: Route manual Compose commits through `ComposeChatInputActions`** while preserving focus/commit behaviour and existing displayed `ObservedValue` mirrors.
|
||||
- [ ] **Step 8: Give both template draft properties a shared post-apply effect key** that revalidates active beacons after all writes, without changing their validation-before-stage behaviour.
|
||||
- [ ] **Step 9: Route UCXLog and Win-Test through `applyExternalQrg`** only when their current QRG-sync setting already permits the update; preserve packet parsing and diagnostics.
|
||||
- [ ] **Step 10: Re-run focused tests and inspect XML summaries.**
|
||||
- [ ] **Step 11: Run related integration tests** for SO2R routing, settings apply and chat-input rendering.
|
||||
- [ ] **Step 12: Inspect the task diff** for protocol/framing changes, toolkit calls in `core`, or source inference through listeners.
|
||||
|
||||
### Task 4: Beacon task status, translated tooltips and traffic colours
|
||||
|
||||
**Files:**
|
||||
- Modify: `core/src/main/java/kst4contest/controller/BeaconTask.java`
|
||||
- Modify: `core/src/main/java/kst4contest/controller/BeaconStatus.java`
|
||||
- Modify: `core/src/main/java/kst4contest/model/ThreadStateMessage.java`
|
||||
- Create: `app-desktop/src/main/kotlin/kst4contest/view/compose/BeaconStatusPresentation.kt`
|
||||
- Modify: `app-desktop/src/main/kotlin/kst4contest/view/compose/StatusIndicatorState.kt`
|
||||
- Modify: `app-desktop/src/main/kotlin/kst4contest/view/compose/StatusBar.kt`
|
||||
- Modify: `app-desktop/src/main/i18n/strings_de.properties`
|
||||
- Modify: `app-desktop/src/main/i18n/strings_en.properties`
|
||||
- Modify: `core/src/test/java/kst4contest/controller/BeaconTaskTest.java`
|
||||
- Modify: `core/src/test/java/kst4contest/controller/BeaconControlTest.java`
|
||||
- Create: `app-desktop/src/test/kotlin/kst4contest/view/compose/BeaconStatusPresentationTest.kt`
|
||||
- Modify: `app-desktop/src/test/kotlin/kst4contest/view/compose/StatusIndicatorStateTest.kt`
|
||||
- Modify: `app-desktop/src/test/kotlin/kst4contest/view/compose/StatusBarScreenTest.kt`
|
||||
- Modify: relevant i18n boundary tests
|
||||
|
||||
**Interfaces:**
|
||||
- Consumes: Task 1 `BeaconStatusSnapshot` and policy send-failure methods.
|
||||
- Produces: optional structured beacon snapshot on `ThreadStateMessage`; other thread messages remain unchanged.
|
||||
- Produces: `BeaconStatusPresentation` mapping snapshot plus current strings to label, tooltip and visual style.
|
||||
|
||||
- [ ] **Step 1: Add failing core tests** proving a failed active category yields `FAILED`, a later successful run clears only its failure, disabled categories are not failed, and ordinary timer runs preserve inactive reasons.
|
||||
- [ ] **Step 2: Add failing presentation tests** for bilingual per-category tooltips, initial/user/QRG/QRG-invalid reasons, `1/2`, and no concrete frequency in the QRG reason.
|
||||
- [ ] **Step 3: Add failing colour-model tests** for the exact light/dark OFF colours, ON/PARTIAL green, 200-ms orange highlight, FAILED red/white with highlight suppression and unchanged default-worker colours.
|
||||
- [ ] **Step 4: Run focused core and desktop tests and verify RED.**
|
||||
- [ ] **Step 5: Attach the structured snapshot to the existing status message** without adding translated display prose to `core`.
|
||||
- [ ] **Step 6: Make `BeaconTask` record per-category outcomes** while retaining text resolution, category validation and regular TX queue insertion.
|
||||
- [ ] **Step 7: Implement translated presentation and visual style** only for messages carrying a beacon snapshot; keep action/provider ordering and stale-update protection intact.
|
||||
- [ ] **Step 8: Implement the selected colours in `ThreadStatusButtonView`** and suppress the highlight when style is FAILED.
|
||||
- [ ] **Step 9: Add aligned DE/EN i18n keys** and re-run translation-boundary tests.
|
||||
- [ ] **Step 10: Re-run focused tests and inspect XML summaries.**
|
||||
- [ ] **Step 11: Run the affected Compose screen tests** and inspect a rendered light/dark result if the test harness emits one.
|
||||
- [ ] **Step 12: Inspect the task diff** to ensure no non-beacon chip acquired special colours or click behaviour.
|
||||
|
||||
### Task 5: Targeted documentation, context and full verification
|
||||
|
||||
**Files:**
|
||||
- Modify: `github_docs/de-Konfiguration.md`
|
||||
- Modify: `github_docs/en-Configuration.md`
|
||||
- Modify: `github_docs/de-Contest-Workflow.md`
|
||||
- Modify: `github_docs/en-Contest-Workflow.md`
|
||||
- Modify: `github_docs/de-Makros-und-Variablen.md`
|
||||
- Modify: `github_docs/en-Macros-and-Variables.md`
|
||||
- Review/modify: `github_docs/de-Funktionen.md`, `github_docs/en-Features.md`
|
||||
- Review/modify: `github_docs/de-Benutzeroberflaeche.md`, `github_docs/en-User-Interface.md`
|
||||
- Modify: `github_docs/de-Changelog.md`
|
||||
- Modify: `github_docs/en-Changelog.md`
|
||||
- Modify: `website/src/features/macros.md`
|
||||
- Review/modify: `website/src/features/trx-qrg-synchronisation.md`
|
||||
- Modify: `docs/PROJECT_CONTEXT.md`
|
||||
- Modify: `docs/superpowers/specs/2026-11-04-live-beacon-control-design.md`
|
||||
- Review: `github_docs/client_settings_window_beacon.png`
|
||||
|
||||
**Interfaces:**
|
||||
- Consumes: completed behaviour from Tasks 1-4.
|
||||
- Produces: semantically aligned DE/EN user documentation and current durable project context.
|
||||
|
||||
- [ ] **Step 1: Update the targeted manual sections** with session-only activation, five-minute minimum, activation prerequisites, source-specific reference/QSY rules, per-category tooltip and traffic colours.
|
||||
- [ ] **Step 2: Update both changelogs compactly** without inventing a version or release state.
|
||||
- [ ] **Step 3: Update only website sections that already describe interval or TRX-QRG behaviour**; do not duplicate the manual.
|
||||
- [ ] **Step 4: Reconcile the older live-beacon design and `PROJECT_CONTEXT`** so they no longer claim activation persists or the one-minute minimum remains unchanged.
|
||||
- [ ] **Step 5: Inspect the existing Beacon settings screenshot** and record replacement only if a visible value is now false; do not fabricate an image.
|
||||
- [ ] **Step 6: Run all focused test classes from Tasks 1-4.**
|
||||
- [ ] **Step 7: Run the full build.**
|
||||
|
||||
Run: `.\gradlew.bat build --console=plain`
|
||||
|
||||
Expected: `BUILD SUCCESSFUL` with no failed tests.
|
||||
|
||||
- [ ] **Step 8: Read every generated `*/build/test-results/**/TEST-*.xml` summary** and report test/failure/error/skipped totals rather than relying only on exit code.
|
||||
- [ ] **Step 9: Count PMD and SpotBugs XML findings per module** from `<violation` and `<BugInstance>` and identify findings touching changed production files.
|
||||
- [ ] **Step 10: Run `git diff --check` and inspect `git status --short`.**
|
||||
- [ ] **Step 11: Review the complete diff against the approved spec** for unrelated cleanup, stale documentation, accidental protocol changes and user-authored changes.
|
||||
- [ ] **Step 12: Perform a manual runtime check if safely possible**: initial off state, valid/invalid category activation, manual rebase, external >5-kHz shutdown, `1/2`, OFF tooltip, orange flash and persistent FAILED red.
|
||||
|
||||
## Self-Review Result
|
||||
|
||||
- Every approved behaviour maps to Tasks 1-4; documentation and durable context map to Task 5.
|
||||
- Exact types and controller entry points are defined once in the Interfaces blocks.
|
||||
- Cross-template QRG dependencies, first external reference, non-SO2R routing, XML migration and FAILED colour priority are explicit tests.
|
||||
- Plan size reflects five independently reviewable deliverables; no implementation bodies or unauthorised Git actions are included.
|
||||
@@ -0,0 +1,96 @@
|
||||
# Automatic Chat Suffix Implementation Plan
|
||||
|
||||
> **For agentic workers:** REQUIRED SUB-SKILL: Use superpowers:subagent-driven-development (recommended) or superpowers:executing-plans to implement this plan task-by-task. Steps use checkbox (`- [ ]`) syntax for tracking.
|
||||
|
||||
**Goal:** Append the fixed suffix ` *a*` to every active KST4Contest autoanswer and beacon while leaving manual and protocol traffic unchanged.
|
||||
|
||||
**Architecture:** A package-private `AutomaticChatMessageFormatter` owns the suffix and performs unconditional appending. The active autoanswer and beacon producers call it explicitly; beacon validation keeps a 120-character payload allowance and validates the resulting 124-character maximum.
|
||||
|
||||
**Tech Stack:** Java 21, Kotlin 2.2, Gradle wrapper, JUnit 5, Mockito
|
||||
|
||||
**Spec:** `docs/superpowers/specs/2026-11-13-automatic-chat-suffix-design.md`
|
||||
|
||||
## Global Constraints
|
||||
|
||||
- The exact suffix is ` *a*`, including its leading space.
|
||||
- `[KST4C Automsg]` remains on autoanswers and remains the loop-prevention marker.
|
||||
- Suffix insertion is unconditional; duplicate `*a*` markers are allowed.
|
||||
- Beacon payloads remain limited to 120 characters; complete suffixed beacons are limited to 124 characters.
|
||||
- Manual messages and internal ON4KST frames must remain byte-for-byte unaffected by this feature.
|
||||
- No new dependency, setting, persistence field, version bump, staging, commit or publication action.
|
||||
|
||||
## Review Focus
|
||||
|
||||
- A 120-character beacon payload must be sent as exactly 124 characters after suffix insertion.
|
||||
- A 121-character beacon payload must still be rejected rather than producing a 125-character frame.
|
||||
- Text already ending in `*a*` must receive a second suffix without deduplication.
|
||||
- Autoanswer validation and cooldown accounting must still reject invalid text before consuming cooldown.
|
||||
- The existing prefix-based ping-pong guard and all manual send paths must remain unchanged.
|
||||
|
||||
---
|
||||
|
||||
### Task 1: Shared automatic-message formatter and autoanswers
|
||||
|
||||
**Files:**
|
||||
- Create: `core/src/main/java/kst4contest/controller/AutomaticChatMessageFormatter.java`
|
||||
- Create: `core/src/test/java/kst4contest/controller/AutomaticChatMessageFormatterTest.java`
|
||||
- Modify: `core/src/main/java/kst4contest/controller/MessageBusManagementThread.java`
|
||||
- Modify: `core/src/test/java/kst4contest/controller/MessageBusManagementThreadAutoAnswerDecisionTest.java`
|
||||
- Modify: `core/src/test/java/kst4contest/controller/MessageBusManagementThreadAutoAnswerTest.java`
|
||||
- Modify: `core/src/test/java/kst4contest/controller/MessageBusManagementThreadChatFrameTest.java`
|
||||
|
||||
**Interfaces:**
|
||||
- Produces: `AutomaticChatMessageFormatter.appendSuffix(String messageText): String`
|
||||
- Consumes: existing `ApplicationConstants.AUTOANSWER_PREFIX` and `On4KstProtocol.messageText(String)`
|
||||
|
||||
- [x] Add failing formatter tests for exact suffix insertion and intentional duplicate suffixes.
|
||||
- [x] Run `\.\gradlew.bat :core:test --tests "kst4contest.controller.AutomaticChatMessageFormatterTest"` and confirm the tests fail because the formatter is absent.
|
||||
- [x] Implement the package-private formatter with `SUFFIX = " *a*"` and unconditional appending.
|
||||
- [x] Update failing autoanswer and version-reply expectations so generic, QRG and `//VER` replies end in ` *a*` while retaining `[KST4C Automsg]`.
|
||||
- [x] Append before final autoanswer protocol validation and in the `//VER` construction path.
|
||||
- [x] Run the formatter and three focused autoanswer test classes and confirm zero failures.
|
||||
|
||||
### Task 2: Beacon suffix and length boundaries
|
||||
|
||||
**Files:**
|
||||
- Modify: `core/src/main/java/kst4contest/controller/ChatController.java`
|
||||
- Modify: `core/src/main/java/kst4contest/controller/BeaconTask.java`
|
||||
- Modify: `core/src/test/java/kst4contest/controller/On4KstProtocolTest.java`
|
||||
- Modify: `core/src/test/java/kst4contest/controller/BeaconTaskTest.java`
|
||||
|
||||
**Interfaces:**
|
||||
- Consumes: `AutomaticChatMessageFormatter.appendSuffix(String)` from Task 1
|
||||
- Produces: beacon payload validation at 120 characters and final-message validation at 124 characters
|
||||
|
||||
- [x] Add failing tests asserting that each queued beacon ends in ` *a*`, a 120-character payload produces a 124-character message, and a 121-character payload is rejected.
|
||||
- [x] Run `\.\gradlew.bat :core:test --tests "kst4contest.controller.On4KstProtocolTest" --tests "kst4contest.controller.BeaconTaskTest"` and confirm the new assertions fail.
|
||||
- [x] Separate the 120-character payload limit from the 124-character final beacon limit in `ChatController`.
|
||||
- [x] Append the suffix only after macro resolution and payload validation, then validate the final message before queueing.
|
||||
- [x] Run the focused beacon tests and confirm zero failures.
|
||||
|
||||
### Task 3: Targeted documentation and verification
|
||||
|
||||
**Files:**
|
||||
- Modify: `github_docs/de-Konfiguration.md`
|
||||
- Modify: `github_docs/en-Configuration.md`
|
||||
- Modify: `github_docs/de-Makros-und-Variablen.md`
|
||||
- Modify: `github_docs/en-Macros-and-Variables.md`
|
||||
- Modify: `github_docs/de-Funktionen.md`
|
||||
- Modify: `github_docs/en-Features.md`
|
||||
- Modify: `github_docs/de-Changelog.md`
|
||||
- Modify: `github_docs/en-Changelog.md`
|
||||
- Modify: `website/src/features/automatic-replies.md`
|
||||
- Modify: `website/src/features/macros.md`
|
||||
- Modify: `docs/PROJECT_CONTEXT.md`
|
||||
|
||||
**Interfaces:**
|
||||
- Consumes: implemented suffix and length behaviour from Tasks 1 and 2
|
||||
- Produces: aligned German/English user documentation and durable current-state context
|
||||
|
||||
- [x] Update examples and behavioural text so autoanswers retain `[KST4C Automsg]` and all automated chat messages end in ` *a*`.
|
||||
- [x] Document the 120-character beacon payload and 124-character transmitted-message limits in German and English.
|
||||
- [x] Record the fixed suffix rule in the changelogs and `docs/PROJECT_CONTEXT.md` without changing unrelated documentation.
|
||||
- [x] Run the focused core tests from Tasks 1 and 2, then `\.\gradlew.bat build`.
|
||||
- [x] Read every Gradle test-result XML summary and report failures, errors and skipped tests; inspect PMD and SpotBugs XML counts produced by the build.
|
||||
- [x] Run the website test/build commands defined by the current `website/package.json` if the changed website pages participate in that build.
|
||||
- [x] Run `git diff --check` and review the complete scoped diff for accidental changes; perform no Git publication action.
|
||||
@@ -2,6 +2,10 @@
|
||||
|
||||
Freigegeben von Marc am 2026-11-04.
|
||||
|
||||
> Durch das freigegebene [Beacon Session Safety Design](2026-11-11-beacon-session-safety-design.md)
|
||||
> abgelöst, soweit Aktivierungspersistenz, Mindestintervall, QRG-Sicherung und Chip-Darstellung
|
||||
> betroffen sind.
|
||||
|
||||
## Ziel
|
||||
|
||||
Die beiden Beacon-Aktivierungsschalter wirken in der laufenden Sitzung sofort. Der gemeinsame
|
||||
@@ -11,19 +15,19 @@ gemeinsam ein- oder ausschalten.
|
||||
|
||||
## Verbindliches Verhalten
|
||||
|
||||
- Die gespeicherten Beacon-Zustände werden beim Profilstart geladen.
|
||||
- Nach einem Programmstart und Profilwechsel sind beide Beacon-Zustände ausgeschaltet.
|
||||
- Ein normaler ON4KST-Reconnect innerhalb derselben Programmsitzung verändert sie nicht.
|
||||
- Ein Klick auf eine Beacon-Checkbox wirkt sofort im Speicher und damit beim nächsten
|
||||
regulären Timerlauf.
|
||||
- Aktivieren sendet nicht sofort und startet den Timer nicht neu.
|
||||
- Erst **Einstellungen speichern** schreibt die Zustände in die Profil-XML. Ohne explizites
|
||||
Speichern gilt die Änderung nur für die laufende Sitzung.
|
||||
- Aktivierungszustände werden nicht in die Profil-XML übernommen; ein vollständiger
|
||||
Einstellungsspeichervorgang schreibt die kompatiblen Aktivierungs-Tags als `false`.
|
||||
- Beacon-Text und Intervall bleiben normale Settings-Entwurfswerte. Das Intervall startet den
|
||||
Timer erst beim Anwenden neu.
|
||||
- Der Status-Chip zeigt `off`, `1/2` oder `on` für die aktuell nutzbaren Kategorien.
|
||||
- Der Status-Chip zeigt `off`, `1/2`, `on` oder `FAILED` für die aktuell nutzbaren Kategorien.
|
||||
- Sind alle nutzbaren Beacons aus, aktiviert ein Chip-Klick alle nutzbaren Beacons. Ist
|
||||
mindestens eine nutzbare Beacon an, deaktiviert der Klick alle nutzbaren Beacons.
|
||||
- Bei deaktiviertem zweiten Chat schaltet der Chip nur die Hauptkategorie und verändert das
|
||||
gespeicherte Flag der zweiten Kategorie nicht.
|
||||
- Bei deaktiviertem zweiten Chat schaltet der Chip nur die Hauptkategorie.
|
||||
- Chip und geöffnetes Settings-Fenster zeigen denselben beobachtbaren Zustand.
|
||||
- Nur der Beacon-Chip wird anklickbar. Andere Thread-Status-Chips bleiben reine Anzeigen.
|
||||
|
||||
@@ -32,15 +36,15 @@ gemeinsam ein- oder ausschalten.
|
||||
- Beide Kategorien behalten eigene Aktivierungsflags und Texte.
|
||||
- Der zweite Beacon-Versand setzt weiterhin einen aktivierten zweiten Chat voraus.
|
||||
- Nachrichtenvalidierung, TX-Warteschlange und ON4KST-Protokoll bleiben unverändert.
|
||||
- Mindestintervall, gemeinsamer Timer und Intervall-Persistenz bleiben unverändert.
|
||||
- Gemeinsamer Timer und Intervall-Persistenz bleiben unverändert; das Mindestintervall beträgt
|
||||
fünf Minuten.
|
||||
- Profilzustände werden nicht miteinander vermischt.
|
||||
|
||||
## Technischer Ansatz
|
||||
|
||||
Die vorhandenen `ChatPreferences`-Getter und -Setter bleiben die kompatible Schnittstelle,
|
||||
werden für die beiden Aktivierungsflags aber auf thread-sichere beobachtbare Werte gestellt.
|
||||
Der Settings-Tab liest diese Werte als Compose-State und schreibt Aktivierungen direkt durch
|
||||
den Controller. Der Controller veröffentlicht nach jeder manuellen Umschaltung einen
|
||||
zusammengefassten `MyBeacon`-Status. `BeaconTask` meldet nach einem Timerlauf ebenfalls genau
|
||||
diesen zusammengefassten Status. `ThreadStatusButtons` erhält eine optionale Aktion pro
|
||||
Quelle; die Anwendung registriert sie nur für `MyBeacon`.
|
||||
`BeaconSessionState` ist die maßgebliche sitzungsbezogene Quelle für Aktivierung,
|
||||
QRG-Referenzen, Abschaltgründe und Fehler. Die vorhandenen beobachtbaren
|
||||
`ChatPreferences`-Werte bleiben die kompatible Projektion für Settings und UI. Controller und
|
||||
`BeaconTask` veröffentlichen einen strukturierten `BeaconStatusSnapshot`, aus dem Chip-Text,
|
||||
Tooltip und die Beacon-spezifische Farbgebung entstehen. Details der QRG-Prüfung und
|
||||
Darstellung stehen im ablösenden Design vom 2026-11-11.
|
||||
@@ -0,0 +1,128 @@
|
||||
# Beacon Session Safety Design
|
||||
|
||||
Freigegeben von Marc am 2026-11-11.
|
||||
|
||||
## Ziel
|
||||
|
||||
Die Beacon-Funktion darf nach einem Programmstart oder Profilwechsel nicht aus einer
|
||||
gespeicherten Aktivierung weiterlaufen. Jeder Beacon wird in der laufenden Sitzung bewusst
|
||||
eingeschaltet, hält seine eigene Kategorie-QRG als Referenz fest und schaltet nur bei einer
|
||||
automatisch von UCXLog oder Win-Test gemeldeten Abweichung von mehr als 5 kHz ab.
|
||||
|
||||
Der zusammengefasste `MyBeacon`-Chip macht Aktivierung, Teilaktivierung, automatische
|
||||
Abschaltung und Versandfehler ohne Umweg über das Einstellungsfenster erkennbar.
|
||||
|
||||
## Verbindliches Verhalten
|
||||
|
||||
### Intervall und Sitzung
|
||||
|
||||
- Das kleinste zulässige gemeinsame Beacon-Intervall beträgt fünf Minuten.
|
||||
- Genau fünf Minuten sind zulässig. Kleinere geladene Werte werden im Speicher auf fünf
|
||||
Minuten normalisiert; die mitgelieferte Konfiguration verwendet für beide Kategorien fünf.
|
||||
- Nach jedem Programmstart und Profilwechsel sind beide Beacons ausgeschaltet.
|
||||
- Ein Disconnect oder Reconnect innerhalb derselben Programmsitzung verändert ihre
|
||||
Aktivierung nicht.
|
||||
- Die Aktivierungsflags werden nicht aus XML gelesen. Die vorhandenen XML-Elemente bleiben
|
||||
für die Dateikompatibilität erhalten, werden aber immer mit `false` geschrieben.
|
||||
|
||||
### Aktivierung und benötigte QRG-Werte
|
||||
|
||||
- `MYQRG` und `MYQRGSHORT` benötigen eine gültige Haupt-QRG.
|
||||
- `SECONDQRG` benötigt eine gültige zweite QRG.
|
||||
- Diese Voraussetzung gilt unabhängig davon, in welchem der beiden Bakentexte die Variable
|
||||
vorkommt.
|
||||
- Fehlt ein benötigter Wert oder ist er ungültig, bleibt der betroffene Beacon aus. Sein
|
||||
kategorieweiser Status nennt die fehlende oder ungültige QRG als Grund.
|
||||
- Der gemeinsame Chip aktiviert beide nutzbaren Kategorien unabhängig. Ein gültiger Beacon
|
||||
wird eingeschaltet, auch wenn der andere abgelehnt wird; der Chip zeigt dann `1/2`.
|
||||
- Ein Text ohne QRG-Platzhalter darf ohne bekannte QRG aktiviert werden.
|
||||
- Geprüft wird der bereits angewendete Text, nicht ein noch offener Settings-Entwurf.
|
||||
|
||||
### Kategoriebezogene Referenz-QRG
|
||||
|
||||
- Beim Einschalten übernimmt jeder Beacon die aktuell gültige QRG seiner eigenen Kategorie
|
||||
als Referenz.
|
||||
- Ist keine gültige Kategorie-QRG vorhanden und benötigt der Text sie nicht, wird die erste
|
||||
später gültige manuelle oder externe QRG zur Referenz.
|
||||
- Eine gültige manuelle QRG-Eingabe ist eine bewusste Operatorentscheidung. Sie deaktiviert
|
||||
keinen Beacon und verschiebt die Referenz der zugehörigen Kategorie.
|
||||
- Eine ungültige manuelle Eingabe deaktiviert jeden aktiven Beacon, dessen angewendeter Text
|
||||
den betroffenen QRG-Wert benötigt. Benötigt sein Text ihn nicht, bleibt der Beacon aktiv;
|
||||
nur die Referenz seiner Kategorie wird gelöscht.
|
||||
- Ausschließlich QRG-Übernahmen von UCXLog `RadioInfo` und Win-Test `STATUS`, für die der
|
||||
bestehende QRG-Abgleich aktiv ist, dürfen automatisch abschalten.
|
||||
- Der Vergleich erfolgt in ganzzahligen Hz gegen die aktuelle Referenz. Genau 5.000 Hz sind
|
||||
zulässig; erst eine größere Abweichung schaltet ab.
|
||||
- Ohne Referenz setzt die erste externe QRG nur die Referenz und schaltet nicht ab.
|
||||
- Ohne SO2R betrifft eine externe Änderung von `MYQRG` ausschließlich die Hauptbake. Mit
|
||||
SO2R folgt Radio 1 `MYQRG` und Radio 2 `SECONDQRG`.
|
||||
|
||||
### Status und Tooltip
|
||||
|
||||
- Der Status wird als strukturierter Snapshot aus `core` geliefert. Übersetzte Anzeigetexte
|
||||
entstehen ausschließlich in `app-desktop`.
|
||||
- Der Snapshot kennt `OFF`, `PARTIAL`, `ON` und `FAILED` sowie den Zustand beider Kategorien.
|
||||
- Der Tooltip zeigt je Kategorie den aktuellen Zustand oder letzten Abschalt-/Ablehnungsgrund:
|
||||
noch nicht in dieser Sitzung aktiviert, durch den Benutzer ausgeschaltet, fehlende oder
|
||||
ungültige Haupt-QRG, fehlende oder ungültige zweite QRG oder automatische QRG-Abweichung
|
||||
von mehr als 5 kHz.
|
||||
- Der QRG-Grund nennt keine konkreten Frequenzen.
|
||||
- Timeraktivität überschreibt den kategorieweisen Grund nicht.
|
||||
- Ein erfolgreicher späterer Lauf löscht einen früheren Versandfehler der Kategorie.
|
||||
|
||||
### Verkehrsfarben des `MyBeacon`-Chips
|
||||
|
||||
- `on` und `1/2`: Hintergrund `#238636`, Rand `#56D364`, weiße Schrift.
|
||||
- Der bestehende 200-ms-Aktivitätsblitz verwendet Hintergrund `#FFB300`, Rand `#FFE082`
|
||||
und Schrift `#1B1B1B`.
|
||||
- `off`: neutraler Theme-Hintergrund mit `#D50000` im hellen beziehungsweise `#FF6B6B` im
|
||||
dunklen Design.
|
||||
- `FAILED`: dauerhaft `#D50000` mit Rand `#FF6B6B` und weißer Schrift.
|
||||
- `FAILED` unterdrückt den orangefarbenen Aktivitätsblitz.
|
||||
- Andere Status-Chips behalten ihr heutiges Theme-Verhalten.
|
||||
|
||||
## Technischer Ansatz
|
||||
|
||||
Eine controllerseitige `BeaconSessionState`-Komponente koordiniert den Zustand beider
|
||||
Kategorien. Die beobachtbaren Flags in `ChatPreferences` bleiben kompatible UI-Projektion,
|
||||
aber kein persistenter Produktzustand. Die Komponente verwaltet Referenzen, kategorieweise
|
||||
Gründe und Versandfehler und ist der einzige Produktionsschreibpfad der Aktivierungsflags.
|
||||
|
||||
Manuelle QRG-Eingaben und externe Logger-Meldungen verwenden getrennte Controller-Einstiege.
|
||||
UCXLog und Win-Test übergeben die bereits ermittelte Kategorie, den formatierten Anzeigewert
|
||||
und die genaue Frequenz in Hz innerhalb der bestehenden `UiDispatcher`-Grenze. Damit ist die
|
||||
Herkunft explizit; Listener, Thread-lokale Markierungen oder erratene Ursprünge sind unnötig.
|
||||
|
||||
Der vorhandene `BeaconTask` bleibt für Auflösung, Validierung und Einreihung in die reguläre
|
||||
TX-Warteschlange verantwortlich. Er meldet je Kategorie Erfolg oder Fehler an den
|
||||
Sitzungszustand zurück. Ein DTO im gemeinsamen Model transportiert den strukturierten Status
|
||||
über den bestehenden Threadstatus-Kanal; Compose übersetzt Gründe und wählt die Chipfarben.
|
||||
|
||||
## Unveränderte Grenzen
|
||||
|
||||
- Beide Kategorien teilen einen Timer und besitzen getrennte Aktivierung und Texte.
|
||||
- Der zweite Versand setzt weiterhin eine verfügbare zweite Chatkategorie voraus.
|
||||
- Aktivieren sendet nicht sofort und startet den Timer nicht neu.
|
||||
- Der erste Timerlauf nach dem Verbindungsaufbau bleibt bei ungefähr zehn Sekunden.
|
||||
- Nachrichtenauflösung, Längenlimit, TX-Warteschlange und ON4KST-Framing bleiben unverändert.
|
||||
- Die Chip-Texte `off`, `1/2`, `on` und `FAILED` und seine gemeinsame Klickfunktion bleiben.
|
||||
- Es gibt keine neue Produktionsabhängigkeit, kein neues persistentes Schema und keine
|
||||
Änderung eines externen Protokolls.
|
||||
|
||||
## Berücksichtigte Ansätze
|
||||
|
||||
1. **Gewählt:** controllerseitiger Sitzungszustand mit expliziten manuellen und externen
|
||||
Ereignissen. Das hält Policy, Referenzen und Gründe zusammen und bleibt testbar.
|
||||
2. **Verworfen:** Flags in Preferences, Referenzen in einem Guard und Gründe in `BeaconStatus`.
|
||||
Der zusammengehörige Zustand wäre auf mehrere Besitzer verteilt.
|
||||
3. **Verworfen:** Beobachtung der QRG-Werte mit temporärer Herkunftsmarkierung. `MutableValue`
|
||||
trägt keine Quelle; die asynchrone UI-Weitergabe machte diesen Ansatz fragil.
|
||||
|
||||
## Dokumentationswirkung
|
||||
|
||||
Die Änderung ist benutzerseitig sichtbar, betrifft Laufzeit/Persistenz sowie die bestehende
|
||||
UCXLog-/Win-Test-Integration. Geprüft und bei Bedarf angepasst werden die relevanten
|
||||
deutschen und englischen Konfigurations-, Workflow-, Variablen-, Funktions- und
|
||||
Benutzeroberflächenabschnitte, Changelog, Website-Texte, `docs/PROJECT_CONTEXT.md` und der
|
||||
ältere Live-Beacon-Entwurf. README und verbundene Projekte sind voraussichtlich nicht
|
||||
betroffen.
|
||||
@@ -0,0 +1,27 @@
|
||||
# Automatic Chat Suffix Design
|
||||
|
||||
## Intent
|
||||
|
||||
Every user-visible chat message generated and sent automatically by KST4Contest must end with the fixed suffix ` *a*`. The marker makes automatic traffic recognisable without changing manual messages or ON4KST control traffic.
|
||||
|
||||
## Behaviour
|
||||
|
||||
- Append ` *a*` to generic private autoanswers, QRG autoanswers, `//VER` replies and both beacon categories.
|
||||
- Keep the existing `[KST4C Automsg]` prefix on every autoanswer and continue using it for the reply-loop guard.
|
||||
- Append the suffix unconditionally after text preparation. A configured text which already ends in `*a*` therefore receives another ` *a*`.
|
||||
- Preserve the existing 120-character beacon payload allowance. The complete transmitted beacon, including the four-character suffix, may contain up to 124 characters.
|
||||
|
||||
## Non-goals
|
||||
|
||||
- Do not mark manually sent messages, snippets or manually triggered CQ messages.
|
||||
- Do not alter login, keepalive, ON4KST command or other internal protocol frames.
|
||||
- Do not change cooldowns, category routing, beacon activation, QRG safeguards, timer behaviour, persistence or settings UI.
|
||||
- Do not revive or refactor the unused legacy `ScoreboardUpdateTask`.
|
||||
|
||||
## Selected Approach
|
||||
|
||||
Use one package-private formatter in the controller package to append the fixed suffix. Call it explicitly from the active autoanswer and beacon construction paths. This keeps the scope visible and prevents a broad writer-layer rule from modifying manual messages or raw protocol frames.
|
||||
|
||||
## Validation and Documentation
|
||||
|
||||
Validate autoanswers after suffix insertion. Validate beacon payloads against 120 characters, append the suffix, then validate the final text against 124 characters. Update focused tests, the German and English manuals, relevant website feature pages, changelogs and durable project context.
|
||||
@@ -0,0 +1,286 @@
|
||||
# Entwurf — Einrichtungsassistent für unkonfigurierte Profile
|
||||
|
||||
Stand 2026-11-18. Konzept mit Philipp abgestimmt, **noch nicht vom Maintainer freigegeben**.
|
||||
Berührt den Entwurfsmechanismus aus `2026-10-16-settings-apply-drafts-design.md` bewusst nicht.
|
||||
|
||||
## Warum
|
||||
|
||||
Das Einstellungsfenster hat zwölf Reiter und 74 Felder (`settings-fields.txt`). Wer das
|
||||
Programm zum ersten Mal startet, landet genau dort (`Kst4ContestApplication.startRuntime`
|
||||
ruft am Ende `openSettingsWindow()`), und nichts sagt ihm, welche fünf Angaben er braucht
|
||||
und welche siebzig er lassen kann.
|
||||
|
||||
Dazu kommt, dass die mitgelieferte Vorlage `praktiKSTpreferences.xml` keine neutrale
|
||||
Ausgangslage ist. Sie trägt das Rufzeichen `DO5AMF` mit dem Passwort `changeMe` und schaltet
|
||||
ein, was nur mit passender Gegenstelle sinnvoll ist: den UDP-Empfang für UCXLog, den
|
||||
Abgleich über eine Logdatei, die Frequenzübernahme, AirScout, den lokalen DX-Cluster-Server
|
||||
und den Zweitchat. Ein Neuling ohne Logprogramm hat das alles aktiv, ohne es zu wissen.
|
||||
|
||||
Der Assistent fragt das Nötige ab, schaltet ab, was nicht vorhanden ist, und lässt den Rest
|
||||
auf seinen Werten.
|
||||
|
||||
## Wann er erscheint
|
||||
|
||||
Ein Profil gilt als **unkonfiguriert**, wenn sein Rufzeichen leer ist oder wenn es noch die
|
||||
Anmeldedaten der Vorlage trägt (`DO5AMF` mit `changeMe`). Das erste trifft auf jedes neu
|
||||
angelegte und jedes duplizierte Profil zu, weil `OperatorProfileManagementService` dort
|
||||
Rufzeichen und Passwort löscht; das zweite auf das Stammprofil einer frischen Installation.
|
||||
|
||||
Die Regel gilt **pro Profil**, nicht pro Installation, und sie braucht kein eigenes Merkmal
|
||||
in `preferences.xml`: ohne Rufzeichen lässt sich ohnehin nicht verbinden.
|
||||
|
||||
- Beim Start eines unkonfigurierten Profils öffnet sich der Assistent als eigenes Fenster,
|
||||
**bevor** die Laufzeit des Profils gebaut wird: nach der Profilwahl, vor dem
|
||||
`ChatController`.
|
||||
- Schließt er sich, gleich auf welchem Weg, geht der Start weiter wie heute, und das
|
||||
Einstellungsfenster öffnet sich. Es bleibt der Weg in den Chat.
|
||||
- Später ist er über „Optionen → Einrichtungsassistent" erreichbar, für jedes Profil. Dort
|
||||
kostet er die laufende Sitzung, siehe „Mechanismus", und fragt vorher.
|
||||
- Assistent und Einstellungsfenster sind nie zugleich offen. Der Aufruf aus dem Menü läuft
|
||||
durch `SettingsWindow.settleThen`, damit offene Änderungen dort erst entschieden sind.
|
||||
|
||||
## Drei Gruppen
|
||||
|
||||
Der Assistent ordnet, was er fragt, in drei Gruppen. Die Ordnung folgt der Frage, **woran**
|
||||
eine Angabe hängt, nicht dem Reiter, auf dem sie heute steht.
|
||||
|
||||
**Persönliches** hängt am Operator: Sprache, Anzeigename (`stn_loginNameMainCat`, und
|
||||
`stn_loginNameSecondCat` folgt ihm, solange es nicht eigens gesetzt wurde).
|
||||
|
||||
**Anmeldung**: `stn_loginCallSign`, `stn_loginPassword`.
|
||||
|
||||
**Station** hängt am Standort und an der Technik:
|
||||
|
||||
- gefragt: Locator (`stn_loginLocatorMainCat`), aktive Bänder (`stn_bandActive…`),
|
||||
Hauptkategorie, Zweitchat und dessen Kategorie, Logprogramm mit seinen Angaben
|
||||
(`logsynch_…`, `trxSynch_ucxLogUDPListenerEnabled`, `notify_dxClusterServerEnabled`),
|
||||
PSTRotator (`stn_pstRotator…`), AirScout (`AirScout_…`);
|
||||
- gefragt, aber freiwillig: Öffnungswinkel der Antenne (`stn_antennaBeamWidthDeg`) und die
|
||||
eigenen Werte der Pfadanalyse — Antennengewinn, Antennenhöhe, Sendeleistung,
|
||||
Standorthöhe über NN (`stn_pathAnalysisOwnAntennaGainDbi`, `…OwnAntennaHeightMeters`,
|
||||
`…OwnTxPowerWatts`, `…OwnHeightAslMeters`);
|
||||
- nie gefragt, aber Teil der Station: QTF-Vorgabe, größte Entfernung, das
|
||||
DEM-Verzeichnis, die Annahmen über die Gegenstation und die Dämpfungs- und
|
||||
Empfindlichkeitswerte der Pfadanalyse (`stn_qtfDefault`, `stn_maxQRBDefault`, übrige
|
||||
`stn_pathAnalysis…`).
|
||||
|
||||
Der Locator steht im Einstellungsfenster bei den Anmeldefeldern und bleibt dort. Im
|
||||
Assistenten gehört er zur Station: wer mit demselben Rufzeichen an zwei Standorten arbeitet,
|
||||
hat zwei Locator und eine Anmeldung.
|
||||
|
||||
## Die Einstiegsseite
|
||||
|
||||
Anmeldung und Station sind zwei unabhängige Entscheidungen. Für jede fragt die erste Seite,
|
||||
woher sie kommt:
|
||||
|
||||
| Wahl | Bedeutung | angeboten, wenn |
|
||||
|---|---|---|
|
||||
| neu eingeben | die Schritte der Gruppe erscheinen, mit den Startwerten des Assistenten | immer |
|
||||
| von Profil X übernehmen | die Werte der Gruppe aus einem anderen Profil | ein anderes, konfiguriertes Profil existiert |
|
||||
| unverändert lassen | die Werte, die das Profil schon hat | Anmeldung: das Profil ist konfiguriert. Station: das Profil trägt nicht die Anmeldedaten der Vorlage |
|
||||
|
||||
Nichts ist vorausgewählt; der Assistent rät nicht, welcher Fall vorliegt. Bleibt für beide
|
||||
Gruppen nur „neu eingeben" übrig — die frische Installation —, entfällt die Seite.
|
||||
|
||||
Damit sind die Betriebsarten abgedeckt, ohne dass der Assistent sie beim Namen kennen muss:
|
||||
|
||||
| Fall | Anmeldung | Station |
|
||||
|---|---|---|
|
||||
| Erste Installation | neu | neu |
|
||||
| Mehrmannbetrieb, gemeinsames Rufzeichen | übernehmen | übernehmen oder unverändert |
|
||||
| Mehrmannbetrieb, eigenes Rufzeichen | neu | übernehmen oder unverändert |
|
||||
| Ein Operator, mehrere Standorte | übernehmen | neu |
|
||||
| Neuer Operator, neue Station | neu | neu |
|
||||
|
||||
„Unverändert" ist der Fall des duplizierten Profils: `duplicateProfile` hat die Station
|
||||
schon kopiert und nur die Anmeldung geleert. „Übernehmen" ist derselbe Fall für ein leer
|
||||
angelegtes Profil.
|
||||
|
||||
Die Wahl bestimmt, **womit die Schritte vorbelegt sind**, und ob sie im Ablauf erscheinen:
|
||||
|
||||
- neu → Startwerte des Assistenten, Schritte erscheinen;
|
||||
- übernehmen → Werte des gewählten Profils, Schritte erscheinen nicht;
|
||||
- unverändert → Werte des eigenen Profils, Schritte erscheinen nicht.
|
||||
|
||||
In allen drei Fällen zeigt die Zusammenfassung die Werte, und von dort lässt sich jeder
|
||||
Schritt öffnen und ändern. Ein übernommenes Rufzeichen bekommt so sein `/P`.
|
||||
|
||||
Eine Ausnahme hat das Logprogramm. Das Einstellungsfenster erlaubt mehrere Logquellen
|
||||
zugleich, die Frage des Assistenten nur eine. Hat ein unverändert gelassenes Profil mehr als
|
||||
eine Quelle eingeschaltet, zeigt die Zusammenfassung das an und hält die Seite geschlossen:
|
||||
sie würde beim Öffnen alle Quellen bis auf eine abschalten.
|
||||
|
||||
**Bei einer unverändert gelassenen Station wird nur geschrieben, was geöffnet wurde.**
|
||||
Öffnet der Nutzer weder Antenne noch Logprogramm noch Rotor und AirScout, fasst der
|
||||
Assistent diese Einstellungen nicht an. Die Zusammenfassung zeigt dann, was im Profil steht,
|
||||
auch wo das Einstellungsfenster mehr erlaubt als die Fragen des Assistenten: einen
|
||||
DX-Cluster-Server oder eine Frequenzquelle ohne Logquelle.
|
||||
|
||||
Bei einer **neu eingerichteten** Station gehören alle Seiten zum Lauf. Wer sie mit „Fertig"
|
||||
überspringt, bekommt ihre Startwerte geschrieben: Integrationen aus, Antennenwerte wie
|
||||
gespeichert.
|
||||
|
||||
Die **Startwerte des Assistenten** für eine neue Station sind bewusst nicht die der Vorlage:
|
||||
kein Band gewählt, Locator leer, kein Zweitchat, kein Logprogramm, kein lokaler
|
||||
DX-Cluster-Server, kein Rotor, kein AirScout. Wer „neu einrichten" wählt, bekommt nur
|
||||
eingeschaltet, was er bejaht hat.
|
||||
|
||||
Die Zahlen des Schritts „Antenne und Leistung" haben keinen leeren Zustand. Sie bleiben auch
|
||||
bei einer neuen Station mit den gespeicherten Werten vorbelegt und sind Vorschläge.
|
||||
|
||||
## Die Schritte
|
||||
|
||||
1. **Persönliches** — Sprache, Anzeigename. Immer.
|
||||
2. **Anmeldung** — Rufzeichen, Passwort.
|
||||
3. **Standort und Bänder** — Locator, Bänder, Hauptkategorie. Der Assistent schlägt die
|
||||
Kategorie aus den Bändern vor (1 für 50/70 MHz, 2 für 144/432 MHz, 3 ab 1240 MHz), der
|
||||
Nutzer bestätigt sie. Der Zweitchat ist eine Ja/Nein-Frage; bei Ja folgt seine Kategorie.
|
||||
Aus der Bandwahl wird **keine Frequenz** abgeleitet.
|
||||
4. **Antenne und Leistung** — Öffnungswinkel, Antennengewinn, Antennenhöhe über Grund,
|
||||
Sendeleistung, Standorthöhe über NN. Freiwillig: der Schritt lässt sich unverändert
|
||||
durchgehen. Ein leeres Feld für die Standorthöhe heißt, wie im Reiter Station, dass das
|
||||
Höhenmodell entscheidet. Die Werte speisen die Pfadanalyse und die Antennenkeule auf
|
||||
der Karte; für den Chatbetrieb braucht sie niemand.
|
||||
5. **Logprogramm** — keines, Win-Test, UCXLog/DXLog.net/N1MM+/QARTEST, oder eine Logdatei.
|
||||
Erst nach der Wahl erscheinen die zugehörigen Angaben (Port, Stationsnamen, Datei),
|
||||
vorbelegt mit den gespeicherten Werten. Mit einem Netzwerk-Logprogramm folgen zwei
|
||||
Ja/Nein-Fragen: eigene Frequenz übernehmen, Spots über den lokalen DX-Cluster-Server
|
||||
an das Logprogramm geben.
|
||||
6. **Rotor und AirScout** — je eine Ja/Nein-Frage; Host, Port und Kennungen erst bei Ja.
|
||||
7. **Zusammenfassung** — alle drei Gruppen, das Passwort verdeckt, je Gruppe „Ändern". Was
|
||||
der Assistent **abschaltet**, steht dort ausdrücklich. Darunter „Speichern" und
|
||||
„Speichern und verbinden".
|
||||
|
||||
„Fertig" führt von jedem Schritt zur Zusammenfassung, sobald die **Pflichtangaben**
|
||||
stehen: Anzeigename, Rufzeichen, Passwort, Locator, mindestens ein Band und die
|
||||
Chatkategorie. Vorher wäre die Zusammenfassung nicht speicherbar. Wer eine neue Station
|
||||
einrichtet, kann also nach Schritt 3 fertig sein; wer die Station übernimmt, nach der
|
||||
Anmeldung. Niemand muss durch Antenne, Logprogramm und Rotor, um in den Chat zu kommen.
|
||||
|
||||
„Später" und das Schließen des Fensters schreiben nichts, auch die Sprache nicht: der
|
||||
Assistent zeigt sich sofort in der gewählten Sprache, gespeichert wird sie erst mit allem
|
||||
anderen.
|
||||
|
||||
## Was unsichtbar bleibt
|
||||
|
||||
Serveradresse und -port, Baken, automatische Antworten, Kurzbefehle und Textbausteine,
|
||||
Töne, Farben, Filter, SO2R, die Worked-Datenbank, der Fehlermitschnitt, die Fensteranordnung
|
||||
und alle Profilaktionen. Der Assistent fasst keinen dieser Werte an. Eine Ausnahme macht das Übernehmen einer Station: dann kommen auch SO2R und Rotor 2 aus dem anderen Profil, und die Zusammenfassung nennt es, wenn sie dabei abgeschaltet werden.
|
||||
|
||||
Die automatische Antwort auf Frequenzanfragen (`autoAnswerToQrgRequestEnabled`) steht in der
|
||||
Vorlage auf an. Ob der Assistent sie bei einer Station ohne Frequenzquelle abschalten soll,
|
||||
ist **nicht entschieden** und nicht Teil dieses Entwurfs.
|
||||
|
||||
## Mechanismus
|
||||
|
||||
**Der Assistent schreibt `preferences.xml`, und die Laufzeit liest sie beim Start.** Er
|
||||
ändert keine laufende Sitzung.
|
||||
|
||||
Das Einstellungsfenster muss beides können: einen Wert speichern und die laufende Sitzung
|
||||
nachführen — einen Listener neu binden, den Rotor neu einrichten, die Kategorie am
|
||||
`ChatController` setzen. Dafür gibt es `SettingsDraft` mit seinen Wirkungen. Der Assistent
|
||||
braucht das zweite nicht, denn er läuft, bevor es eine Sitzung gibt. Was er schreibt, liest
|
||||
`startRuntime` danach so ein, wie es jede gespeicherte Einstellung einliest. Dieser Weg ist
|
||||
der am besten erprobte im Programm: jeder Start und jeder Profilwechsel geht ihn.
|
||||
|
||||
Im Einzelnen:
|
||||
|
||||
- Der Assistent arbeitet auf einem eigenen `ChatPreferences`-Objekt, das die Datei des
|
||||
Profils gelesen hat, so wie `OperatorProfileManagementService.createPreferencesFile` es
|
||||
beim Anlegen eines Profils tut. Bis zum Speichern hält er seine Antworten in einem
|
||||
`SetupWizardState` und fasst dieses Objekt nicht an.
|
||||
- „Speichern" setzt die Antworten über die Setter von `ChatPreferences` und ruft
|
||||
`writePreferencesToXmlFile`. Alles, was der Assistent nicht gefragt hat, steht danach
|
||||
unverändert in der Datei, weil es gelesen und wieder geschrieben wurde.
|
||||
- **Beim Start** gibt es danach nichts neu zu laden: die Laufzeit wird erst jetzt gebaut.
|
||||
- **Aus dem Menü** läuft eine Laufzeit. Der Assistent fragt deshalb zuerst, ob die Sitzung
|
||||
aufgegeben werden darf, wie der Profilwechsel fragt. Dann wird die Laufzeit abgebaut,
|
||||
der Assistent gezeigt, und danach das **selbe** Profil neu gestartet — der Weg von
|
||||
`ApplicationRuntimeLauncher.switchProfile`, der ein Ziel gleich dem aktiven Profil
|
||||
zulässt. Abgebaut wird **vor** dem Assistenten, nicht danach: sonst schriebe die
|
||||
Laufzeit beim Abbau (`layoutAutosave.flushPending`) über die Datei, die der Assistent
|
||||
gerade geschrieben hat.
|
||||
- **Übernehmen von Profil X** liest dessen Datei in ein zweites `ChatPreferences`-Objekt
|
||||
und belegt die Antworten der Gruppe damit vor. Geschrieben wird nur in das aktive Profil.
|
||||
`duplicateProfile` bleibt unverändert und löscht die Anmeldedaten weiterhin: das
|
||||
Duplizieren kopiert sie nie von selbst, im Assistenten wählt der Nutzer es ausdrücklich.
|
||||
- **Was „Station" beim Übernehmen heißt**, steht Zeile für Zeile in
|
||||
`app-desktop/src/test/resources/wizard-station-setters.txt`: jeder Setter von
|
||||
`ChatPreferences` ist dort oder in `wizard-other-setters.txt` eingeordnet, und ein Test
|
||||
schlägt fehl, wenn ein neuer Setter in keiner der beiden Listen steht. Übernommen wird die
|
||||
ganze Station, auch was der Assistent nie fragt und was seine Fragen nicht ausdrücken
|
||||
können (Rotor 2, SO2R, mehrere Logquellen). „Wird abgeschaltet" vergleicht dabei immer mit
|
||||
dem eigenen Profil. Als Spender gilt nur ein Profil, dessen Datei vorhanden und lesbar ist
|
||||
und das eine eigene Anmeldung hat; gelesen wird es über `ChatPreferences(Path)`, damit
|
||||
eine fehlende Datei nicht aus der Vorlage angelegt wird.
|
||||
- **„Speichern und verbinden"** merkt sich den Wunsch; nach dem Start der Laufzeit geht er
|
||||
den Weg des Verbinden-Knopfs (`connectFromSettings`).
|
||||
|
||||
`SetupWizardState` kennt weder Fenster noch Laufzeit und ist ohne Oberfläche prüfbar. Weil
|
||||
er nur ein `ChatPreferences`-Objekt braucht, hängt er an keinem Reiterzustand, und die
|
||||
Frage, welche Eigenschaft eines Reiterzustands von außen setzbar ist, stellt sich nicht.
|
||||
|
||||
**Die Erkennung** ist eine Abfrage in `core` auf `ChatPreferences`. Die Anmeldedaten der
|
||||
Vorlage stehen als Konstanten daneben; ein Test liest die mitgelieferte
|
||||
`praktiKSTpreferences.xml` und hält beide gleich.
|
||||
|
||||
Der Preis dieses Wegs: der Assistent aus dem Menü beendet die Sitzung. Das ist hingenommen.
|
||||
Er ist für die Einrichtung da; wer im Contest einen Port ändert, nimmt das
|
||||
Einstellungsfenster, das dafür gebaut ist.
|
||||
|
||||
## Fäden
|
||||
|
||||
Beim Start läuft der Assistent auf dem Weg, den die Profilwahl geht
|
||||
(`OperatorProfilePickerWindow.showAndSelect`): ein modaler Dialog, auf dem
|
||||
AWT-Ereignisfaden gebaut, der seinen Aufrufer anhält und dabei weiter Ereignisse
|
||||
verarbeitet. **Kein** eigener Faden mit Riegel — genau diese Bauart hat sich bei der
|
||||
Profilwahl verklemmt, die Begründung steht dort im Quelltext. Aus dem Menü kommt der Aufruf
|
||||
vom Ereignisfaden und geht denselben Weg.
|
||||
|
||||
Der Assistent liest die Profilliste und, wenn er sich öffnet, die Dateien der anderen Profile, kleine lokale Dateien.
|
||||
|
||||
Netzprüfungen gibt es in diesem Entwurf nicht. Ein Probe-Login wäre eine zweite echte
|
||||
Sitzung am Server, und ein Lauschen auf UDP sagt bei Stille nichts: die Logprogramme senden
|
||||
nur bei einem QSO oder Statuswechsel. Geprüft wird lokal — Form von Rufzeichen und Locator,
|
||||
Portkollisionen wie in `StationTabState` — und danach zeigt „Speichern und verbinden" den
|
||||
tatsächlichen Anmeldestatus.
|
||||
|
||||
## Ausbaustufen
|
||||
|
||||
1. Erkennung, Fenster, Menüeintrag, Einstiegsseite mit „neu" und „unverändert", Schritte
|
||||
1 bis 3, Zusammenfassung, Speichern, Speichern und verbinden.
|
||||
2. Schritte 4 bis 6: Antenne und Leistung, dann Logprogramm, Rotor und AirScout mit den
|
||||
Startwerten, die Integrationen abschalten.
|
||||
3. „Von Profil X übernehmen".
|
||||
|
||||
Alle drei Stufen sind umgesetzt.
|
||||
|
||||
## Unverändert
|
||||
|
||||
Das Format von `preferences.xml`. Das Einstellungsfenster mit seinen zwölf Reitern, ihrer
|
||||
Reihenfolge und ihren Titeln. Der Vertrag von `SettingsDraft.apply`. Die Sperre der
|
||||
Anmeldefelder während einer Sitzung. Das Anlegen und Duplizieren von Profilen. Die
|
||||
Vorlage `praktiKSTpreferences.xml`. Der Start- und der Profilwechselweg. Kein
|
||||
automatisches Verbinden, außer der Nutzer wählt „Speichern und verbinden".
|
||||
|
||||
## Prüfung
|
||||
|
||||
- Erkennung: leeres Rufzeichen, Anmeldedaten der Vorlage, konfiguriertes Profil; die
|
||||
Konstanten gegen die mitgelieferte Vorlage.
|
||||
- Einstiegsseite: welche Wahl in welcher Lage angeboten wird, und dass sie auf der frischen
|
||||
Installation entfällt.
|
||||
- Ablauf: die fünf Fälle der Tabelle, „Fertig" erst mit allen Pflichtangaben, Zurück erhält die
|
||||
Eingaben, die Zusammenfassung nennt das Abgeschaltete.
|
||||
- Schreiben, gegen eine echte Datei wie in `ChatPreferencesRoundTripTest`: nach „Später"
|
||||
ist die Datei Byte für Byte unverändert; nach „Speichern" liest ein frisches
|
||||
`ChatPreferences` genau die gewählten Werte; jedes nicht gefragte Feld hat seinen alten
|
||||
Wert; eine neue Station ohne Logprogramm hat alle Abgleiche aus.
|
||||
- Aus dem Menü: die Rückfrage kommt vor dem Abbau, „Zurück" lässt die Sitzung stehen, und
|
||||
nach dem Speichern steht nichts von der abgebauten Laufzeit in der Datei.
|
||||
- Übernehmen: nur die Felder der gewählten Gruppe wandern, das Quellprofil bleibt
|
||||
unberührt.
|
||||
- `SettingsFieldCoverageTest` und `SettingsForeignWriteCoverageTest` bleiben unberührt:
|
||||
sie prüfen, dass das Einstellungsfenster jeden Setter noch ruft, und der Assistent nimmt
|
||||
dort nichts weg.
|
||||
- Oberflächentexte in `strings_de.properties` und `strings_en.properties`; der Erzeuger
|
||||
prüft beim Bau.
|
||||
Binary file not shown.
|
Before Width: | Height: | Size: 63 KiB After Width: | Height: | Size: 53 KiB |
@@ -565,7 +565,7 @@ Bei einer ungünstigen Aufteilung sollten zuerst die Divider und Spaltenbreiten
|
||||
|
||||
## Tipps zur Bedienung
|
||||
|
||||
- **Beacon schnell schalten**: Die Aktivierung ist im geöffneten Einstellungsfenster je Kategorie möglich. Ein Klick auf den Status-Chip **MyBeacon** schaltet alle derzeit nutzbaren Beacons gemeinsam ein oder aus.
|
||||
- **Beacon schnell schalten**: Die Aktivierung ist im geöffneten Einstellungsfenster je Kategorie möglich. Ein Klick auf den Status-Chip **MyBeacon** schaltet alle derzeit nutzbaren Beacons gemeinsam ein oder aus. **off** hat rote Schrift, **1/2** und **on** sind grün, bei gemeldeter Aktivität blitzt der Chip orange. **FAILED** bleibt rot mit weißer Schrift. Der Tooltip nennt den Zustand oder letzten Abschaltgrund je Kategorie.
|
||||
- **Rechtsklick in der Benutzerliste**: Öffnet das Snippet-Menü und weitere Aktionen (QRZ.com-Profil, NOT-QRV-Tags setzen).
|
||||
- **Enter aus dem Chat heraus**: Wenn im Sendfeld Text steht, sendet Enter direkt – auch wenn der Fokus woanders liegt.
|
||||
- **Beacon stoppen**: Beim Scannen von Frequenzen den Beacon ausschalten, damit der Chat nicht mit Meldungen überflutet wird.
|
||||
- **Beacon nach dem Start prüfen**: Nach einem Programmstart oder Profilwechsel sind beide Beacons ausgeschaltet. Ein normaler ON4KST-Reconnect innerhalb derselben Programmsitzung verändert ihren Zustand nicht.
|
||||
@@ -40,6 +40,10 @@ Mehrere Operateure an einem Rechner können jetzt eigene Rufzeichen, Locators un
|
||||
|
||||
### Geändert
|
||||
|
||||
- **Automatische Chatmeldungen eindeutig markiert:** Allgemeine und QRG-bezogene Autoantworten, `//VER`-Antworten sowie beide Beacons enden jetzt mit ` *a*`. Das bestehende Präfix `[KST4C Automsg]` der Autoantworten bleibt erhalten. Der aufgelöste Beacon-Inhalt bleibt auf 120 Zeichen begrenzt; mit dem festen Suffix kann die gesendete Nachricht 124 Zeichen lang sein.
|
||||
|
||||
- **Beacon mit Sitzungs- und QRG-Sicherung:** Beacons starten nach jedem Programmstart und Profilwechsel ausgeschaltet, bleiben bei einem normalen ON4KST-Reconnect aber aktiv. Das Mindestintervall beträgt fünf Minuten. Jeder aktive Beacon überwacht die QRG seiner eigenen Kategorie: Manuelle Änderungen verschieben die Referenz, ein automatischer Sprung durch UCXLog oder Win-Test von mehr als 5 kHz schaltet nur den betroffenen Beacon aus. Der **MyBeacon**-Chip zeigt `off`, `1/2`, `on` und `FAILED` mit eindeutigen Verkehrsfarben; sein Tooltip nennt den Zustand oder letzten Abschaltgrund je Kategorie.
|
||||
|
||||
- **Neues Zuhause auf GitHub:** Das Projekt ist vom Konto `praktimarc` in die GitHub-Organisation [HamRadioOnline](https://github.com/HamRadioOnline) umgezogen und liegt jetzt unter [HamRadioOnline/kst4contest](https://github.com/HamRadioOnline/kst4contest). Alte Links auf das Repository, die Releases, die Issues und das Wiki leiten auf die neue Adresse weiter. Auch das Flatpak-Repository ist umgezogen und liegt jetzt unter `https://hamradioonline.github.io/kst4contest/`; bestehende Flatpak-Installationen aktualisieren über die Weiterleitung der alten Adresse weiter, neue Einrichtungen verwenden die neue Adresse aus der Installationsanleitung. Die AUR-Pakete zeigen ebenfalls auf die neue Adresse.
|
||||
|
||||
- **Zwischenspeicher der Geländeprofile getrennt:** Berechnete Geländeprofile liegen jetzt in der eigenen, gemeinsam genutzten Datei `terrainprofilecache.db` und werden nach Besitzer getrennt gespeichert. Bisher wurde der gesamte Zwischenspeicher gelöscht, sobald sich Rufzeichen oder Locator änderten; bei einem Profilwechsel wäre damit jedes berechnete Profil verloren gegangen.
|
||||
|
||||
@@ -93,9 +93,9 @@ KST4Contest hält die benötigten Informationen zwischen diesen Schritten zusamm
|
||||
|
||||
Bei einer weitgehend festen CQ-QRG sollten `MYQRG` beziehungsweise `SECONDQRG` den tatsächlich verwendeten Frequenzen entsprechen. Eine aktivierte und tatsächlich liefernde TRX-Synchronisation kann `MYQRG` automatisch aktualisieren. Die Aktivierung allein reicht nicht: Vor dem Contest sollte mit einer realen Frequenzänderung geprüft werden, ob gültige Pakete ankommen. Ohne funktionierende automatische Quelle muss der Wert von Hand gepflegt werden.
|
||||
|
||||
Der Beacon kann die aktuelle QRG, den Locator und die Antennenrichtung regelmäßig im Chat veröffentlichen. Seine Variablen werden bei jedem Sendedurchlauf erneut ausgewertet.
|
||||
Der Beacon kann die aktuelle QRG, den Locator und die Antennenrichtung regelmäßig im Chat veröffentlichen. Er muss nach jedem Programmstart oder Profilwechsel bewusst aktiviert werden. Eine manuell geänderte QRG wird zur neuen Referenz; meldet UCXLog oder Win-Test danach einen Sprung von mehr als 5 kHz, wird der betroffene Beacon automatisch ausgeschaltet.
|
||||
|
||||
Wird während des CQ-Betriebs über mehrere Frequenzen gescannt, sollte der Beacon deaktiviert werden. Eine automatisch veröffentlichte QRG ist nur hilfreich, solange sie noch stimmt.
|
||||
Beim Scannen über mehrere Frequenzen verhindert diese Sicherung eine unbeabsichtigte Aussendung mit einer neuen Logger-QRG. Der Status-Tooltip zeigt, welche Kategorie abgeschaltet wurde und warum.
|
||||
|
||||
Shortcuts und Snippets sollten die regelmäßig benötigten Nachrichten abdecken, beispielsweise:
|
||||
|
||||
|
||||
@@ -301,7 +301,7 @@ Bei zwei gleichzeitig geöffneten Chat-Kategorien bleibt der Zusammenhang erhalt
|
||||
|
||||
Fehlt die QRG der betreffenden Kategorie, sendet KST4Contest keine inhaltslose Auskunft. Auch ein leerer oder protokollwidriger allgemeiner Antworttext wird nicht in die Sendequeue übernommen.
|
||||
|
||||
Automatische Antworten benötigen Grenzen. KST4Contest versieht sie daher mit `[KST4C Automsg]`, ignoriert entsprechend gekennzeichnete Nachrichten und begrenzt weitere Antworten an dasselbe vollständige Rufzeichen in derselben Kategorie auf eine Nachricht innerhalb von zwei Minuten. Der Schutz gilt gemeinsam für die allgemeine und die QRG-bezogene Antwort.
|
||||
Automatische Antworten benötigen Grenzen. KST4Contest versieht sie daher mit `[KST4C Automsg]`, ignoriert entsprechend gekennzeichnete Nachrichten und begrenzt weitere Antworten an dasselbe vollständige Rufzeichen in derselben Kategorie auf eine Nachricht innerhalb von zwei Minuten. Der Schutz gilt gemeinsam für die allgemeine und die QRG-bezogene Antwort. Zusätzlich endet jede automatisch erzeugte Chatmeldung einschließlich `//VER`-Antworten und Beacons mit ` *a*`.
|
||||
|
||||
Die Sperrzeit wird nur nach einer vollständigen und lokal gültigen Antwort gestartet. Eine fehlende QRG oder ein verworfener Antworttext verhindert daher keine spätere gültige Antwort.
|
||||
|
||||
@@ -798,13 +798,13 @@ Die Timeline ist eine Vorschau. AirScout-Daten können sich ändern, und ein ein
|
||||
|
||||
KST4Contest kann wiederkehrende CQ-Nachrichten in den öffentlichen Chat senden. Der Beacon ist für längeres CQ-Rufen auf einer festen Frequenz gedacht: Die eigene QRG wird regelmäßig veröffentlicht, ohne dass derselbe Text von Hand wiederholt werden muss.
|
||||
|
||||
Beide Chat-Kategorien verwenden ein gemeinsames Intervall, besitzen aber jeweils einen eigenen Aktivierungsschalter und Nachrichtentext. Der zweite Beacon wird nur gesendet, wenn die zweite Kategorie in derselben ON4KST-Sitzung aktiviert und vollständig synchronisiert ist.
|
||||
Beide Chat-Kategorien verwenden ein gemeinsames Intervall von mindestens fünf Minuten, besitzen aber jeweils einen eigenen Aktivierungsschalter und Nachrichtentext. Die Aktivierung gilt nur für die laufende Programmsitzung und muss nach einem Programmstart oder Profilwechsel erneut erfolgen. Ein ON4KST-Reconnect ändert sie nicht. Der zweite Beacon wird nur gesendet, wenn die zweite Kategorie in derselben ON4KST-Sitzung aktiviert und vollständig synchronisiert ist.
|
||||
|
||||
Globale Variablen wie `MYQRG`, `SECONDQRG`, `MYLOCATOR` oder `MYQTF` werden unmittelbar vor jeder Aussendung neu aufgelöst. Eine zwischenzeitlich vom Logprogramm aktualisierte QRG kann dadurch bereits im nächsten Beacon erscheinen.
|
||||
Globale Variablen wie `MYQRG`, `SECONDQRG`, `MYLOCATOR` oder `MYQTF` werden unmittelbar vor jeder Aussendung neu aufgelöst. Jeder aktive Beacon überwacht dabei die QRG seiner eigenen Kategorie. Eine manuelle Änderung verschiebt die Referenz; ein automatischer Sprung durch UCXLog oder Win-Test von mehr als 5 kHz schaltet den betroffenen Beacon aus.
|
||||
|
||||
Vor dem Versand prüft KST4Contest den vollständig aufgelösten Nachrichtentext. Leere Nachrichten, Zeilenumbrüche, das Protokoll-Trennzeichen `|` und Texte mit mehr als 120 Zeichen werden nicht gesendet.
|
||||
Vor dem Versand prüft KST4Contest den vollständig aufgelösten Beacon-Inhalt. Leere Inhalte, Zeilenumbrüche, das Protokoll-Trennzeichen `|` und Inhalte mit mehr als 120 Zeichen werden nicht gesendet. Danach wird ` *a*` angehängt; die gesendete Nachricht kann damit bis zu 124 Zeichen lang sein.
|
||||
|
||||
Beim Absuchen oder häufigen Wechseln der QRG sollte der Beacon ausgeschaltet werden. Eine automatisch verbreitete Frequenz ist nur dann hilfreich, wenn dort tatsächlich jemand hört und ruft.
|
||||
Der farbige **MyBeacon**-Chip zeigt aktive, teilweise aktive, ausgeschaltete und fehlgeschlagene Zustände. Sein Tooltip nennt den Zustand oder letzten Abschaltgrund je Kategorie.
|
||||
|
||||
Konfiguration, Timer-Verhalten und verfügbare Variablen: [Konfiguration – Beacon Settings](de-Konfiguration#beacon-settings-automatischer-beacon).
|
||||
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
> 🇬🇧 [English version](en-Configuration) | 🇩🇪 Du liest gerade die deutsche Version
|
||||
|
||||
Nach dem ersten Start öffnet sich das **Einstellungsfenster** – dieses ist der zentrale Ausgangspunkt für alle Konfigurationen. Es empfiehlt sich, das Einstellungsfenster während des Betriebs geöffnet zu lassen (z. B. um den Beacon schnell ein- und auszuschalten).
|
||||
Beim ersten Start fragt der **Einrichtungsassistent** das Nötigste ab (siehe unten). Danach öffnet sich das **Einstellungsfenster** – dieses ist der zentrale Ausgangspunkt für alle Konfigurationen. Es empfiehlt sich, das Einstellungsfenster während des Betriebs geöffnet zu lassen (z. B. um den Beacon schnell ein- und auszuschalten).
|
||||
|
||||
> **Wichtig**: Änderungen im Einstellungsfenster wirken, sobald **Apply/Close prefs** oder **Save Settings** gedrückt wird; **Connect** übernimmt sie ebenfalls vorher. Wer mit offenen Änderungen das Fenster schließt, das Profil wechselt oder das Programm beendet, wird zuerst gefragt, ob sie übernommen oder verworfen werden sollen, oder kann zurück. Farben, Sprache, die Anmeldedaten im Reiter **Station** und die beiden Beacon-Aktivierungsschalter wirken sofort.
|
||||
>
|
||||
@@ -10,6 +10,52 @@ Nach dem ersten Start öffnet sich das **Einstellungsfenster** – dieses ist de
|
||||
|
||||
---
|
||||
|
||||
## Einrichtungsassistent (ab v1.50)
|
||||
|
||||
Solange ein Profil kein eigenes Rufzeichen hat, startet es mit dem Einrichtungsassistenten. Das gilt für die erste Installation und für jedes neu angelegte oder duplizierte Operator-Profil.
|
||||
|
||||
Der Assistent fragt:
|
||||
|
||||
1. **Persönliches** – Sprache und Anzeigename im Chat.
|
||||
2. **Anmeldung** – Rufzeichen und Passwort des ON4KST-Kontos.
|
||||
3. **Standort und Bänder** – Locator, aktive Bänder und Chatkategorie. Die Kategorie wird aus den Bändern vorgeschlagen und lässt sich ändern. Ein zweiter Chat ist freiwillig.
|
||||
4. **Antenne und Leistung** – freiwillig: Öffnungswinkel, Antennengewinn, Antennenhöhe, Sendeleistung und Standorthöhe. Die Werte speisen die Pfadanalyse; für den Chat braucht sie niemand.
|
||||
5. **Logprogramm** – keines, Win-Test, UCXLog/DXLog.net/N1MM+/QARTEST oder eine Logdatei. Port, Stationsname oder Datei erscheinen erst nach der Wahl und sind mit den gespeicherten Werten vorbelegt; eine schon eingetragene Logdatei muss also nicht neu gewählt werden. Mit einem Netzwerk-Logprogramm lässt sich außerdem die eigene Frequenz übernehmen und der lokale DX-Cluster-Server einschalten.
|
||||
6. **Rotor und AirScout** – je ein Schalter; Host, Port und Kennungen erscheinen erst, wenn er gesetzt ist.
|
||||
7. **Zusammenfassung** – erst **Speichern** schreibt die Einstellungen. **Speichern und verbinden** meldet danach gleich am Chat an.
|
||||
|
||||
Sobald die Pflichtangaben gültig sind – Anzeigename, Anmeldung, Locator, mindestens ein Band, die Chatkategorie und bei eingeschaltetem Zweitchat dessen Kategorie –, führt **Fertig** direkt zur Zusammenfassung. Die Schritte 4 bis 6 lassen sich also überspringen. Steht auf einer dieser Seiten schon ein ungültiger Wert, etwa ein Port außerhalb des Bereichs, muss er erst berichtigt werden.
|
||||
|
||||
Eine **neu eingerichtete** Station bekommt nur eingeschaltet, was im Assistenten bejaht wurde. Die mitgelieferte Vorlage hat Logabgleich, Frequenzübernahme, DX-Cluster-Server und AirScout an; der Assistent schaltet ab, was nicht gewählt wurde, und nennt es in der Zusammenfassung unter „Wird abgeschaltet".
|
||||
|
||||
Gibt es schon ein eingerichtetes Profil oder hat das Profil selbst schon eine Station, fragt die erste Seite getrennt für **Anmeldung** und **Station**, woher die Angaben kommen:
|
||||
|
||||
- **neu eingeben** – immer möglich; die Schritte erscheinen, eine neue Station beginnt leer;
|
||||
- **von einem anderen Profil übernehmen** – nur, wenn es ein anderes Profil mit eigener Anmeldung gibt; die Werte kommen aus dem gewählten Profil;
|
||||
- **unverändert lassen** – das Profil behält, was es hat. Für die Anmeldung gibt es das nur, wenn das Profil schon eine eigene hat; für die Station immer, solange das Profil nicht mehr die mitgelieferten Anmeldedaten der Vorlage trägt, also nicht bei einer frischen Installation.
|
||||
|
||||
Anmeldung und Station werden unabhängig gewählt und können aus verschiedenen Profilen kommen.
|
||||
|
||||
Damit sind die üblichen Fälle mit wenigen Klicks erledigt:
|
||||
|
||||
| Fall | Anmeldung | Station |
|
||||
|---|---|---|
|
||||
| Mehrmannbetrieb, gemeinsames Rufzeichen | übernehmen | übernehmen |
|
||||
| Mehrmannbetrieb, eigenes Rufzeichen | neu | übernehmen |
|
||||
| Ein Operator, mehrere Standorte | übernehmen | neu |
|
||||
|
||||
Übernommen wird beim Punkt **Station** die ganze Station: Locator, Bänder, das Ausweichband für Spots, Chatkategorien, Antennen- und Pfadanalysewerte, QTF-Vorgabe und größte Entfernung, alle Logquellen, die Frequenzübernahme samt SO2R, der lokale DX-Cluster-Server, Rotoren und AirScout – auch Einzelheiten, die der Assistent nie fragt. Sprache, Anzeigename, Fensteranordnung, Farben, Kurzbefehle und Baken gehören zum Operator und werden nie übernommen, ebenso wenig das Spotter-Rufzeichen des DX-Cluster-Servers. Schaltet das Übernehmen etwas ab, das im eigenen Profil eingeschaltet war, steht es in der Zusammenfassung unter „Wird abgeschaltet".
|
||||
|
||||
Übernommene Werte lassen sich in der Zusammenfassung über **Ändern** anpassen, etwa ein `/P` am Rufzeichen. Ändern lässt sich dort, was der Assistent auch fragt; übernommene Einzelheiten wie Rotor 2, SO2R oder die Win-Test-Feineinstellungen ändert man im Einstellungsfenster. Schaltet das Übernehmen SO2R oder Rotor 2 ab, steht auch das unter „Wird abgeschaltet". Die Zusammenfassung zeigt außerdem das Ausweichband für Spots, das mit der Station kommt. Eine Ausnahme: Hat die übernommene Station mehrere Logquellen zugleich eingeschaltet, kommen alle an, die Seite „Logprogramm" lässt sich dann aber nicht öffnen, weil sie nur eine Quelle kennt; solche Änderungen macht man im Einstellungsfenster. Das andere Profil wird nur gelesen und nie verändert. Angeboten werden nur Profile, die selbst eine Anmeldung haben.
|
||||
|
||||
**Später** schließt den Assistenten, ohne etwas zu schreiben. Er erscheint beim nächsten Start des Profils wieder, solange das Rufzeichen fehlt.
|
||||
|
||||
Über **Options → Einrichtungsassistent...** lässt er sich jederzeit erneut aufrufen. Dabei wird die laufende Sitzung nach einer Rückfrage beendet und das Profil neu gestartet. Für einzelne Änderungen im Betrieb ist das Einstellungsfenster gedacht.
|
||||
|
||||
Bleibt die Station **unverändert**, fasst der Assistent Antenne, Logprogramm, Rotor und AirScout nicht an, solange die zugehörige Seite nicht über **Ändern** geöffnet wird. Sind im Profil mehrere Logquellen zugleich eingeschaltet, lässt sich die Seite „Logprogramm" nicht öffnen: sie kennt nur eine Quelle. Solche Stationen stellt man weiter im Einstellungsfenster ein.
|
||||
|
||||
---
|
||||
|
||||
## Station Settings (Stationseinstellungen)
|
||||
|
||||

|
||||
@@ -135,7 +181,7 @@ Dedizierter Netzwerk-Erkenner für Win-Test. KST4Contest empfängt und verarbeit
|
||||
|
||||
## TRX-Sync-Einstellungen
|
||||
|
||||
Die TRX-Synchronisation übernimmt die aktuelle Frequenz aus dem Logprogramm und stellt sie in KST4Contest als eigene QRG der ersten Chat-Kategorie bereit. QSO- und Frequenzsynchronisation verwenden teilweise denselben UDP-Empfänger, sind funktional aber voneinander getrennt: Ein empfangenes `RadioInfo`-Paket markiert keine Station als gearbeitet, und ein QSO-Paket ändert nicht automatisch die eigene QRG.
|
||||
Die TRX-Synchronisation übernimmt die aktuelle Frequenz aus dem Logprogramm und stellt sie in KST4Contest als eigene QRG bereit. Ohne SO2R ist das `MYQRG` der ersten Chat-Kategorie; mit SO2R kann Gerät 2 getrennt `SECONDQRG` aktualisieren. QSO- und Frequenzsynchronisation verwenden teilweise denselben UDP-Empfänger, sind funktional aber voneinander getrennt: Ein empfangenes `RadioInfo`-Paket markiert keine Station als gearbeitet, und ein QSO-Paket ändert nicht automatisch die eigene QRG.
|
||||
|
||||

|
||||
|
||||
@@ -153,11 +199,11 @@ Wird der gemeinsame UDP-Port geändert, muss KST4Contest neu gestartet werden. E
|
||||
|
||||
### Welche QRG wird aktualisiert?
|
||||
|
||||
Beide automatischen Quellen aktualisieren ausschließlich `MYQRG`. Das ist die eigene QRG der ersten beziehungsweise primären Chat-Kategorie.
|
||||
Ohne SO2R aktualisieren beide automatischen Quellen ausschließlich `MYQRG`. Das ist die eigene QRG der ersten beziehungsweise primären Chat-Kategorie; `SECONDQRG` bleibt unabhängig und kann von Hand eingetragen werden.
|
||||
|
||||
Bei aktiviertem zweiten Chat bleibt dessen QRG davon unabhängig. Sie wird nicht aus den empfangenen TRX-Paketen abgeleitet und steht als `SECONDQRG` zur Verfügung. Dadurch kann beispielsweise die erste Kategorie automatisch der Frequenz des Logprogramms folgen, während für die zweite Kategorie eine eigene QRG von Hand eingetragen wird.
|
||||
Mit SO2R ordnet KST4Contest die Pakete einem Gerät zu: Gerät 1 aktualisiert `MYQRG`, Gerät 2 `SECONDQRG`. Die genaue Zuordnung steht unter [SO2R: zwei Funkgeräte getrennt führen](#so2r-zwei-funkgeräte-getrennt-führen).
|
||||
|
||||
Sobald mindestens eine automatische QRG-Quelle aktiviert ist und einen gültigen Wert liefert, folgt das QRG-Feld der ersten Kategorie im Hauptfenster der empfangenen Frequenz. Bleiben die erwarteten Pakete aus, sollte die Schnittstelle vor dem Contest geprüft werden. Eine manuelle Eingabe in dieses Feld ist möglich, wenn sowohl der allgemeine RadioInfo-Listener als auch die Win-Test-STATUS-Synchronisation deaktiviert sind.
|
||||
Sobald mindestens eine automatische QRG-Quelle aktiviert ist und einen gültigen Wert liefert, folgt das zugeordnete QRG-Feld im Hauptfenster der empfangenen Frequenz. Bleiben die erwarteten Pakete aus, sollte die Schnittstelle vor dem Contest geprüft werden. Eine manuelle Eingabe bleibt möglich und gilt für die Beacon-Sicherung als bewusste neue Referenz; ein späteres Logger-Paket wird gegen diesen Wert geprüft.
|
||||
|
||||
### Haupt- oder Pass-Frequenz aus Win-Test
|
||||
|
||||
@@ -176,7 +222,7 @@ Die Frequenzen werden einheitlich im KST4Contest-Format dargestellt, beispielswe
|
||||
10368.100.00
|
||||
```
|
||||
|
||||
Die Werte werden erst beim Auflösen des Nachrichtentextes eingesetzt. Ändert das Logprogramm zwischen zwei Beacon-Läufen die Frequenz, verwendet die nächste Nachricht bereits den aktualisierten Wert.
|
||||
Die Werte werden erst beim Auflösen des Nachrichtentextes eingesetzt. Bei normalen Nachrichten steht eine Logger-Änderung sofort zur Verfügung. Ein aktiver Beacon verwendet dagegen seine QRG-Referenz: Ein automatischer Sprung um mehr als 5 kHz schaltet den betroffenen Beacon aus. Einzelheiten stehen unter [Beacon Settings](#beacon-settings-automatischer-beacon).
|
||||
|
||||
Die eigene QRG kann außerdem als Fallback für die Übergabe eines Skeds an Win-Test verwendet werden. Das geschieht nur, wenn die QRG auswertbar ist und zum ausdrücklich ausgewählten Sked-Band gehört. Einzelheiten stehen unter [Log-Synchronisation](de-Log-Synchronisation#skeds-an-win-test-übergeben).
|
||||
|
||||
@@ -603,13 +649,13 @@ KST4Contest verwendet einen gemeinsamen Timer für beide Chat-Kategorien. Aktivi
|
||||
|
||||
Sind beide Beacons aktiviert, werden sie beim selben Timer-Lauf nacheinander in ihren jeweiligen Kategorien gesendet. Der zweite Beacon wird nur berücksichtigt, wenn die zweite Kategorie in derselben ON4KST-Sitzung aktiviert und vollständig synchronisiert ist.
|
||||
|
||||
Die beiden Aktivierungsschalter wirken sofort auf den laufenden Timer. Sie starten weder den Countdown neu noch senden sie unmittelbar eine Nachricht; der nächste reguläre Timer-Lauf prüft den aktuellen Zustand. Erst **Save Settings** speichert die Aktivierung für den nächsten Programmstart. Nachrichtentexte und Intervall folgen weiterhin der normalen Apply-/Save-Logik.
|
||||
Die beiden Aktivierungsschalter wirken sofort auf den laufenden Timer. Sie starten weder den Countdown neu noch senden sie unmittelbar eine Nachricht; der nächste reguläre Timer-Lauf prüft den aktuellen Zustand. Die Aktivierung gilt bewusst nur für die laufende Programmsitzung: Nach jedem Programmstart und Profilwechsel sind beide Beacons ausgeschaltet. Ein normaler ON4KST-Reconnect innerhalb derselben Programmsitzung lässt den Zustand dagegen unverändert. Nachrichtentexte und Intervall folgen weiterhin der normalen Apply-/Save-Logik.
|
||||
|
||||
Der Status-Chip **MyBeacon** im Hauptfenster fasst beide nutzbaren Kategorien zusammen: **off** bedeutet kein aktiver Beacon, **1/2** genau eine von zwei aktiven Kategorien und **on** alle derzeit nutzbaren Kategorien. Ein Klick auf den Chip schaltet alle nutzbaren Beacons gemeinsam ein oder aus. Ist der zweite Chat deaktiviert, ändert der Chip nur den Beacon der Hauptkategorie und lässt die gespeicherte Einstellung des zweiten Beacons unverändert.
|
||||
Der Status-Chip **MyBeacon** im Hauptfenster fasst beide nutzbaren Kategorien zusammen: **off** bedeutet kein aktiver Beacon, **1/2** genau eine von zwei aktiven Kategorien und **on** alle derzeit nutzbaren Kategorien. Ein Klick auf den Chip schaltet alle nutzbaren Beacons gemeinsam ein oder aus. Ist der zweite Chat deaktiviert, ändert der Chip nur den Beacon der Hauptkategorie. **off** erscheint mit roter Schrift, **1/2** und **on** dauerhaft grün. Bei gemeldeter Aktivität blitzt der aktive Chip kurz orange auf. **FAILED** überschreibt diese Anzeige dauerhaft mit rotem Hintergrund und weißer Schrift; der orange Aktivitätsblitz wird dann unterdrückt. Der Tooltip nennt für jede Kategorie den aktuellen Zustand oder den letzten allgemeinen Abschaltgrund.
|
||||
|
||||
### Intervall und Timer-Verhalten
|
||||
|
||||
Das Intervall wird in ganzen Minuten angegeben. Der kleinste zulässige Wert ist eine Minute.
|
||||
Das Intervall wird in ganzen Minuten angegeben. Der kleinste zulässige Wert beträgt fünf Minuten. Kleinere Werte aus einer älteren Konfiguration werden beim Laden auf fünf Minuten angehoben.
|
||||
|
||||
Nach dem Aufbau der Chat-Verbindung prüft KST4Contest die Beacons erstmals nach ungefähr zehn Sekunden. Anschließend gilt das eingestellte Intervall.
|
||||
|
||||
@@ -635,15 +681,19 @@ Eine mögliche Nachricht für die erste Chat-Kategorie ist:
|
||||
calling cq at MYQRGSHORT, ant MYQTF deg, loc MYLOCATOR
|
||||
```
|
||||
|
||||
KST4Contest hängt an jede gesendete Beacon-Nachricht automatisch das feste Suffix ` *a*` an. Es gehört deshalb nicht in das konfigurierte Template.
|
||||
|
||||
Für den zweiten Chat muss `SECONDQRG` verwendet werden, wenn dessen Frequenz von der ersten Kategorie abweicht:
|
||||
|
||||
```text
|
||||
calling cq at SECONDQRG, ant MYQTF deg, loc MYLOCATOR
|
||||
```
|
||||
|
||||
Die Variablen werden bei jedem Timer-Lauf neu aufgelöst. Ändert die Logsoftware zwischenzeitlich die in `MYQRG` gespeicherte Frequenz, verwendet bereits der nächste Beacon den aktualisierten Wert. Das Template selbst muss dafür nicht geändert werden.
|
||||
Die Variablen werden bei jedem Timer-Lauf neu aufgelöst. `MYQRG` und `MYQRGSHORT` benötigen immer eine gültige QRG der ersten Chat-Kategorie, `SECONDQRG` immer eine gültige QRG der zweiten Kategorie. Diese Zuordnung gilt unabhängig davon, in welchem der beiden Beacon-Texte die Variable steht.
|
||||
|
||||
`MYQRG` und `MYQRGSHORT` beziehen sich immer auf die erste Chat-Kategorie. Die Auswahl oder Aktivierung des zweiten Chats ändert diese Zuordnung nicht.
|
||||
Enthält ein Beacon-Text eine solche QRG-Variable, kann der betreffende Beacon nur mit gültigem zugeordnetem QRG-Wert aktiviert bleiben. Fehlt der Wert oder ist er ungültig, bleibt nur dieser Beacon ausgeschaltet beziehungsweise wird ausgeschaltet; der Tooltip nennt den Grund. Ein Beacon-Text ohne QRG-Variable darf dagegen auch ohne vorhandene QRG aktiviert werden.
|
||||
|
||||
Beim Einschalten merkt sich jeder Beacon die gültige QRG seiner eigenen Kategorie als Referenz. Ist noch keine gültige eigene QRG vorhanden und enthält der Text keine QRG-Variable, wird die erste später manuell oder vom Logger gemeldete gültige Frequenz zur Referenz. Eine manuelle QRG-Änderung gilt als bewusste Bedienung und verschiebt die Referenz auf den neuen Wert. Ändert UCXLog oder Win-Test die zugeordnete QRG später um mehr als 5 kHz gegenüber dieser Referenz, schaltet KST4Contest den betreffenden Beacon automatisch aus. Genau 5 kHz sind noch zulässig. Ohne SO2R betrifft eine automatische Logger-QRG nur den Beacon der Hauptkategorie; mit SO2R wird die zweite QRG und damit der zweite Beacon getrennt behandelt.
|
||||
|
||||
Stationsbezogene Variablen wie `QRZNAME`, `FIRSTAP` oder `SECONDAP` benötigen eine ausgewählte Gegenstation. Da ein öffentlicher Beacon keine bestimmte Station adressiert, werden diese Variablen im Beacon nicht aufgelöst.
|
||||
|
||||
@@ -651,16 +701,16 @@ Stationsbezogene Variablen wie `QRZNAME`, `FIRSTAP` oder `SECONDAP` benötigen e
|
||||
|
||||
KST4Contest prüft sowohl das eingetragene Template als auch den nach der Variablenauflösung tatsächlich zu sendenden Text.
|
||||
|
||||
Für Beacon-Nachrichten gelten folgende Bedingungen:
|
||||
Für den aufgelösten Beacon-Inhalt vor dem festen Suffix gelten folgende Bedingungen:
|
||||
|
||||
- Der endgültige Nachrichtentext darf nicht leer sein.
|
||||
- Er darf nicht leer sein.
|
||||
- Er darf höchstens 120 Zeichen enthalten.
|
||||
- Das Protokoll-Trennzeichen `|` ist nicht zulässig.
|
||||
- Zeilenumbrüche sind nicht zulässig.
|
||||
|
||||
Eine ungültige Eingabe wird nicht als neue Beacon-Konfiguration übernommen. Wird ein Template erst durch eine spätere Variablenauflösung ungültig, beispielsweise weil der aufgelöste Text länger als 120 Zeichen ist, wird dieser Beacon-Lauf ausgelassen.
|
||||
KST4Contest hängt anschließend ` *a*` an. Die tatsächlich gesendete Beacon-Nachricht darf damit höchstens 124 Zeichen lang sein. Eine ungültige Eingabe wird nicht als neue Beacon-Konfiguration übernommen. Wird ein Template erst durch eine spätere Variablenauflösung ungültig, beispielsweise weil der aufgelöste Inhalt länger als 120 Zeichen ist, wird dieser Beacon-Lauf ausgelassen.
|
||||
|
||||
Ein Template, das ausschließlich aus einer momentan noch leeren globalen Variable besteht, kann gespeichert werden. Das ist beispielsweise beim Start möglich, bevor die erste QRG vom Logprogramm empfangen wurde. Solange die Variable keinen verwendbaren Inhalt liefert, sendet KST4Contest jedoch keine leere Nachricht.
|
||||
Ein Template mit einer QRG-Variable kann gespeichert werden, bevor eine passende QRG vorhanden ist; der betroffene Beacon lässt sich dann aber nicht aktivieren. Wird eine benötigte QRG später ungültig, wird ein bereits aktiver Beacon ausgeschaltet. Enthält das Template keine QRG-Variable, löscht eine ungültige eigene QRG lediglich die Referenz und der Beacon bleibt aktiv.
|
||||
|
||||
### Wann sollte der Beacon ausgeschaltet werden?
|
||||
|
||||
@@ -668,7 +718,7 @@ Der Beacon ist nur dann hilfreich, wenn seine QRG-Angabe zum tatsächlichen Betr
|
||||
|
||||
Im Klartext: Solange auf einer festen QRG CQ gerufen wird, spart der Beacon Arbeit. Beim „Schleichen“ über das Band sollte er ausgeschaltet werden.
|
||||
|
||||
Änderungen wirken während der laufenden Verbindung. Damit Aktivierung, Texte und Intervall auch nach dem nächsten Programmstart erhalten bleiben, anschließend **Save Settings** verwenden.
|
||||
Änderungen wirken während der laufenden Verbindung. **Save Settings** speichert Texte und Intervall für den nächsten Programmstart. Die Aktivierung wird absichtlich nicht gespeichert und muss in jeder Programmsitzung erneut erfolgen.
|
||||
|
||||
---
|
||||
|
||||
@@ -690,12 +740,12 @@ Eine zweckmäßige Nachricht ist beispielsweise:
|
||||
Sri, I am not taking part in this contest. No skeds.
|
||||
```
|
||||
|
||||
Das Präfix `[KST4C Automsg]` muss nicht in das Eingabefeld geschrieben werden. KST4Contest ergänzt es automatisch.
|
||||
Das Präfix `[KST4C Automsg]` und das feste Suffix ` *a*` müssen nicht in das Eingabefeld geschrieben werden. KST4Contest ergänzt beides automatisch.
|
||||
|
||||
Die beim Empfänger sichtbare Nachricht lautet daher beispielsweise:
|
||||
|
||||
```text
|
||||
[KST4C Automsg] Sri, I am not taking part in this contest. No skeds.
|
||||
[KST4C Automsg] Sri, I am not taking part in this contest. No skeds. *a*
|
||||
```
|
||||
|
||||
Die eingegangene Privatnachricht bleibt sichtbar. Die Funktion blockiert oder verwirft keine Anfrage, sondern erspart lediglich die wiederholte manuelle Antwort.
|
||||
@@ -726,7 +776,7 @@ Die Antwort enthält ausschließlich die QRG der Kategorie, in der die Anfrage e
|
||||
Eine mögliche Antwort lautet:
|
||||
|
||||
```text
|
||||
[KST4C Automsg] QRG is: 144.300.00
|
||||
[KST4C Automsg] QRG is: 144.300.00 *a*
|
||||
```
|
||||
|
||||
Die Werte stammen aus denselben QRG-Feldern, die auch von `MYQRG` und `SECONDQRG` verwendet werden. Die Haupt-QRG kann manuell eingetragen oder durch die [TRX-Synchronisation](#trx-sync-einstellungen) aktualisiert werden. Für die zweite Kategorie wird der dort konfigurierte beziehungsweise manuell eingetragene Wert verwendet; mit SO2R schreibt Funkgerät 2 dieses Feld (`SECONDQRG`).
|
||||
@@ -762,7 +812,7 @@ Das vorhandene Bild `client_settings_window_messagehandling.png` zeigt die neue
|
||||
|
||||
### Schutz vor wiederholten Antworten
|
||||
|
||||
Jede automatisch erzeugte Nachricht trägt das feste Präfix:
|
||||
Jede automatische Antwort trägt das feste Präfix:
|
||||
|
||||
```text
|
||||
[KST4C Automsg]
|
||||
@@ -770,6 +820,8 @@ Jede automatisch erzeugte Nachricht trägt das feste Präfix:
|
||||
|
||||
Die allgemeine und die QRG-bezogene Antwort reagieren nicht auf Nachrichten, die dieses Präfix bereits enthalten. Dadurch beantworten sich zwei entsprechend arbeitende Clients nicht gegenseitig in einer Schleife.
|
||||
|
||||
Zusätzlich endet jede von KST4Contest automatisch erzeugte Chatmeldung mit ` *a*`. Das gilt für allgemeine und QRG-bezogene Antworten, `//VER`-Antworten sowie beide Beacons. Das Suffix wird immer angehängt, auch wenn der konfigurierte Text bereits damit endet. Manuell gesendete Nachrichten und interne ON4KST-Steuerframes bleiben unverändert.
|
||||
|
||||
Zusätzlich gilt eine gemeinsame Sperrzeit von zwei Minuten für beide Antwortarten. Die Sperre wird getrennt nach vollständigem Rufzeichen und Chat-Kategorie geführt.
|
||||
|
||||
Daraus folgt:
|
||||
|
||||
@@ -305,16 +305,20 @@ Verwendet die zweite Chat-Kategorie eine andere QRG, muss deren Vorlage `SECONDQ
|
||||
calling cq at SECONDQRG, ant MYQTF deg, loc MYLOCATOR
|
||||
```
|
||||
|
||||
Die globalen Variablen werden bei jedem Timer-Lauf erneut ausgewertet. Eine inzwischen vom Logprogramm aktualisierte QRG kann dadurch bereits in der nächsten Beacon-Nachricht erscheinen.
|
||||
Die globalen Variablen werden bei jedem Timer-Lauf erneut ausgewertet. `MYQRG` und `MYQRGSHORT` benötigen immer eine gültige QRG der Hauptkategorie, `SECONDQRG` immer eine gültige QRG der zweiten Kategorie – unabhängig davon, in welcher Beacon-Vorlage sie stehen. Fehlt eine benötigte QRG, lässt sich nur der betroffene Beacon nicht aktivieren beziehungsweise wird ausgeschaltet. Eine Vorlage ohne QRG-Variable darf auch ohne vorhandene QRG aktiviert werden.
|
||||
|
||||
Der vollständig aufgelöste Beacon-Text:
|
||||
Beim Einschalten merkt sich jeder Beacon die QRG seiner eigenen Kategorie. Eine manuelle QRG-Änderung verschiebt diese Referenz. Ändert UCXLog oder Win-Test die zugeordnete QRG später um mehr als 5 kHz, schaltet KST4Contest den betreffenden Beacon automatisch aus, statt die neue Frequenz unbemerkt in die nächste Aussendung zu übernehmen. Ist beim Einschalten noch keine eigene QRG vorhanden, wird die erste später gültig eingegebene oder empfangene Frequenz zur Referenz.
|
||||
|
||||
Der vollständig aufgelöste Beacon-Inhalt vor dem festen Suffix ` *a*`:
|
||||
|
||||
- muss mindestens ein gültiges Zeichen enthalten,
|
||||
- darf höchstens 120 Zeichen lang sein,
|
||||
- darf das Protokoll-Trennzeichen `|` nicht enthalten und
|
||||
- darf keine Zeilenumbrüche enthalten.
|
||||
|
||||
Ist der Text beim vorgesehenen Versand leer oder ungültig, wird der betreffende Beacon-Lauf ausgelassen.
|
||||
KST4Contest hängt das Suffix anschließend automatisch an. Die tatsächlich gesendete Beacon-Nachricht kann deshalb bis zu 124 Zeichen lang sein.
|
||||
|
||||
Ist der aufgelöste Text beim vorgesehenen Versand aus einem anderen Grund leer oder ungültig, wird der betreffende Beacon-Lauf ausgelassen und der Status-Chip zeigt **FAILED**.
|
||||
|
||||
Intervall, Aktivierung und Verhalten beider Kategorien sind unter [Konfiguration – Beacon Settings](de-Konfiguration#beacon-settings-automatischer-beacon) beschrieben.
|
||||
|
||||
|
||||
@@ -40,6 +40,10 @@ Several operators sharing one computer can now use their own callsigns, locators
|
||||
|
||||
### Changed
|
||||
|
||||
- **Automatic chat messages marked consistently:** general and QRG-specific automatic replies, `//VER` replies and both beacons now end with ` *a*`. Automatic replies keep their existing `[KST4C Automsg]` prefix. Resolved beacon content remains limited to 120 characters; including the fixed suffix, the transmitted message may contain 124 characters.
|
||||
|
||||
- **Beacon session and QRG safeguards:** beacons start off after every program start and profile switch, but remain active across a normal ON4KST reconnect. The minimum interval is five minutes. Each active beacon monitors the QRG of its own category: manual changes move the reference, while an automatic UCXLog or Win-Test jump of more than 5 kHz disables only the affected beacon. The **MyBeacon** chip shows `off`, `1/2`, `on` and `FAILED` with clear traffic-light colours; its tooltip lists the state or last deactivation reason for each category.
|
||||
|
||||
- **New home on GitHub:** the project moved from the `praktimarc` account to the [HamRadioOnline](https://github.com/HamRadioOnline) GitHub organisation and now lives at [HamRadioOnline/kst4contest](https://github.com/HamRadioOnline/kst4contest). Old links to the repository, the releases, the issues and the wiki redirect to the new address. The Flatpak repository moved as well and now lives at `https://hamradioonline.github.io/kst4contest/`; existing Flatpak installations keep updating through the redirect of the old address, new setups use the new address from the installation manual. The AUR packages point to the new address too.
|
||||
|
||||
- **The terrain profile cache is separate:** computed terrain profiles now live in their own shared file `terrainprofilecache.db` and are stored per owner. Previously the whole cache was dropped whenever the callsign or locator changed, which would have discarded every computed profile on each profile switch.
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
> 🇬🇧 You are reading the English version | 🇩🇪 [Deutsche Version](de-Konfiguration)
|
||||
|
||||
After the first start, the **settings window** opens – this is the central starting point for all configuration. It is recommended to keep the settings window open during operation (e.g. to quickly toggle the beacon on and off).
|
||||
On the first start, the **setup assistant** asks for the essentials (see below). After that the **settings window** opens – this is the central starting point for all configuration. It is recommended to keep the settings window open during operation (e.g. to quickly toggle the beacon on and off).
|
||||
|
||||
> **Important**: Changes in the settings window take effect when you click **Apply/Close prefs** or **Save Settings**; **Connect** applies them first as well. Closing the window, switching the operator profile or exiting with changes pending first asks whether to apply or discard them, or to go back. Colours, the language, the login data on the **Station** tab and both beacon enable settings take effect immediately.
|
||||
>
|
||||
@@ -10,6 +10,52 @@ After the first start, the **settings window** opens – this is the central sta
|
||||
|
||||
---
|
||||
|
||||
## Setup Assistant (since v1.50)
|
||||
|
||||
As long as a profile has no callsign of its own, it starts with the setup assistant. This applies to the first installation and to every newly created or duplicated operator profile.
|
||||
|
||||
The assistant asks for:
|
||||
|
||||
1. **Personal** – language and the name shown in the chat.
|
||||
2. **Login** – callsign and password of the ON4KST account.
|
||||
3. **Location and bands** – locator, active bands and chat category. The category is suggested from the bands and can be changed. A second chat is optional.
|
||||
4. **Antenna and power** – optional: beam width, antenna gain, antenna height, transmit power and site elevation. These values feed the path analysis; the chat does not need them.
|
||||
5. **Log program** – none, Win-Test, UCXLog/DXLog.net/N1MM+/QARTEST, or a log file. Port, station name or file appear only after the choice and start from the stored values, so a log file that is already entered need not be chosen again. With a network log program you can also take your own frequency from it and enable the local DX cluster server.
|
||||
6. **Rotator and AirScout** – one switch each; host, port and identifiers appear only once it is set.
|
||||
7. **Summary** – nothing is written until you click **Save**. **Save and connect** logs into the chat right afterwards.
|
||||
|
||||
As soon as the required entries are valid – name, login, locator, at least one band, the chat category and, with a second chat enabled, its category – **Finish** leads straight to the summary. Steps 4 to 6 can be skipped. If one of those pages already holds an invalid value, such as a port out of range, it has to be corrected first.
|
||||
|
||||
A station that is **set up anew** gets only what was confirmed in the assistant. The bundled template has log synchronisation, frequency takeover, DX cluster server and AirScout enabled; the assistant switches off what was not chosen and names it in the summary under "Will be switched off".
|
||||
|
||||
If a configured profile already exists, or the profile itself already has a station, the first page asks separately for **login** and **station** where the entries come from:
|
||||
|
||||
- **enter new** – always possible; the steps appear, a new station starts empty;
|
||||
- **take from another profile** – only if another profile with a login of its own exists; the values come from the chosen profile;
|
||||
- **leave unchanged** – the profile keeps what it has. For the login this is offered only if the profile already has one of its own; for the station always, as long as the profile no longer carries the bundled template login, that is, not on a fresh installation.
|
||||
|
||||
Login and station are chosen independently and may come from different profiles.
|
||||
|
||||
This settles the usual cases with a few clicks:
|
||||
|
||||
| Case | Login | Station |
|
||||
|---|---|---|
|
||||
| Multi-operator, shared callsign | take | take |
|
||||
| Multi-operator, own callsign | new | take |
|
||||
| One operator, several sites | take | new |
|
||||
|
||||
For **station**, the whole station is taken: locator, bands, the fallback band for spots, chat categories, antenna and path-analysis values, default QTF and maximum distance, all log sources, frequency takeover including SO2R, the local DX cluster server, rotators and AirScout – including details the assistant never asks about. Language, display name, window layout, colours, shortcuts and beacons belong to the operator and are never taken, nor is the spotter callsign of the DX cluster server. If taking over switches off something that was enabled in the own profile, the summary lists it under "Will be switched off".
|
||||
|
||||
Taken values can be adjusted in the summary through **Change**, for example a `/P` on the callsign. What can be changed there is what the assistant asks about; taken details such as rotator 2, SO2R or the Win-Test fine settings are changed in the settings window. If taking over switches off SO2R or rotator 2, that is listed under "Will be switched off" too. The summary also shows the fallback band for spots that comes with the station. One exception: if the taken station has several log sources enabled at once, all of them arrive, but the "Log program" page then cannot be opened, because it knows one source only; such changes are made in the settings window. The other profile is only read and never changed. Only profiles that have a login of their own are offered.
|
||||
|
||||
**Later** closes the assistant without writing anything. It appears again on the next start of the profile as long as the callsign is missing.
|
||||
|
||||
**Options → Setup assistant...** opens it again at any time. This ends the running session after a confirmation and restarts the profile. Use the settings window for single changes during operation.
|
||||
|
||||
If the station is left **unchanged**, the assistant does not touch antenna, log program, rotator and AirScout unless the corresponding page is opened through **Change**. If several log sources are enabled in the profile at once, the "Log program" page cannot be opened: it knows one source only. Such stations are still configured in the settings window.
|
||||
|
||||
---
|
||||
|
||||
## Station Settings
|
||||
|
||||

|
||||
@@ -154,7 +200,7 @@ Configuration of the individual logging applications, band and locator handling,
|
||||
|
||||
## TRX Sync Settings
|
||||
|
||||
TRX synchronisation imports the current frequency from the logging application and makes it available in KST4Contest as the local QRG of the first chat category. QSO and frequency synchronisation may use the same UDP receiver, but they remain separate functions: receiving a `RadioInfo` packet does not mark a station as worked, and receiving a QSO packet does not automatically change the local QRG.
|
||||
TRX synchronisation imports the current frequency from the logging application and makes it available as a local QRG in KST4Contest. Without SO2R this is `MYQRG` for the first chat category; with SO2R, radio 2 can update `SECONDQRG` separately. QSO and frequency synchronisation may use the same UDP receiver, but they remain separate functions: receiving a `RadioInfo` packet does not mark a station as worked, and receiving a QSO packet does not automatically change the local QRG.
|
||||
|
||||

|
||||
|
||||
@@ -172,11 +218,11 @@ Restart KST4Contest after changing the shared UDP port. Changes to the two QRG-s
|
||||
|
||||
### Which QRG Is Updated?
|
||||
|
||||
Both automatic sources update `MYQRG` only. This is the local QRG of the first or primary chat category.
|
||||
Without SO2R, both automatic sources update `MYQRG` only. This is the local QRG of the first or primary chat category; `SECONDQRG` remains independent and can be entered manually.
|
||||
|
||||
If a second chat is enabled, its QRG remains independent. It is not derived from incoming TRX packets and is available through `SECONDQRG`. The first category can therefore follow the logging application's frequency automatically while a separate QRG is entered manually for the second category.
|
||||
With SO2R, KST4Contest assigns packets to a radio: radio 1 updates `MYQRG`, while radio 2 updates `SECONDQRG`. The exact assignment is described under [SO2R: Keeping Two Radios Apart](#so2r-keeping-two-radios-apart).
|
||||
|
||||
When at least one automatic QRG source is enabled and supplies a valid value, the first category's QRG field in the main window follows the received frequency. If the expected packets do not arrive, verify the interface before the contest. Manual entry is available when both the general RadioInfo listener and Win-Test STATUS synchronisation are disabled.
|
||||
When at least one automatic QRG source is enabled and supplies a valid value, the assigned QRG field in the main window follows the received frequency. If the expected packets do not arrive, verify the interface before the contest. Manual entry remains possible and is treated as the deliberate new reference for beacon safety; a later logger packet is compared with that value.
|
||||
|
||||
### Main or Pass Frequency from Win-Test
|
||||
|
||||
@@ -220,7 +266,7 @@ The synchronised QRG can be used in every text processed by the common KST4Conte
|
||||
- snippets, and
|
||||
- automatic beacons.
|
||||
|
||||
`MYQRG` contains the complete QRG of the first chat category. `MYQRGSHORT` uses only its first seven characters. `SECONDQRG` contains the separately entered QRG of the second chat category.
|
||||
`MYQRG` contains the complete QRG of the first chat category. `MYQRGSHORT` uses only its first seven characters. `SECONDQRG` contains the QRG of the second chat category, whether it was entered manually or supplied by radio 2 with SO2R enabled.
|
||||
|
||||
Examples:
|
||||
|
||||
@@ -603,13 +649,13 @@ KST4Contest uses one shared timer for both chat categories. Each category nevert
|
||||
|
||||
When both beacons are enabled, they are sent one after the other in their respective categories during the same timer run. The second beacon is only considered while the second category is enabled and fully synchronised in the same ON4KST session.
|
||||
|
||||
Both enable settings affect the running timer immediately. They neither restart the countdown nor send a message straight away; the next regular timer run checks the current state. Only **Save Settings** stores the enable state for the next program start. Message templates and the interval continue to follow the normal Apply/Save workflow.
|
||||
Both enable settings affect the running timer immediately. They neither restart the countdown nor send a message straight away; the next regular timer run checks the current state. Activation deliberately lasts only for the current program session: both beacons are off after every program start and profile switch. A normal ON4KST reconnect within the same program session preserves their state. Message templates and the interval continue to follow the normal Apply/Save workflow.
|
||||
|
||||
The **MyBeacon** status chip in the main window combines the currently usable categories: **off** means that no beacon is enabled, **1/2** that one of two categories is enabled, and **on** that every usable category is enabled. Clicking the chip enables or disables all usable beacons together. If the second chat is disabled, the chip changes only the primary-category beacon and leaves the stored secondary-beacon setting untouched.
|
||||
The **MyBeacon** status chip in the main window combines the currently usable categories: **off** means that no beacon is enabled, **1/2** that one of two categories is enabled, and **on** that every usable category is enabled. Clicking the chip enables or disables all usable beacons together. If the second chat is disabled, the chip changes only the primary-category beacon. **off** uses red text, while **1/2** and **on** remain green. The active chip briefly flashes orange when activity is reported. **FAILED** overrides this with a persistent red background and white text; no orange activity flash is shown then. The tooltip lists the current state or last general deactivation reason for each category.
|
||||
|
||||
### Interval and timer behaviour
|
||||
|
||||
The interval is entered in whole minutes. The minimum permitted value is one minute.
|
||||
The interval is entered in whole minutes. The minimum permitted value is five minutes. Smaller values from an older configuration are raised to five minutes when loaded.
|
||||
|
||||
After the chat connection has been established, KST4Contest performs the first beacon check after approximately ten seconds. The configured interval applies after that initial check.
|
||||
|
||||
@@ -635,15 +681,19 @@ A suitable message for the primary chat category is:
|
||||
calling cq at MYQRGSHORT, ant MYQTF deg, loc MYLOCATOR
|
||||
```
|
||||
|
||||
KST4Contest automatically appends the fixed suffix ` *a*` to every transmitted beacon message. It therefore does not belong in the configured template.
|
||||
|
||||
Use `SECONDQRG` for the second chat if it operates on a different frequency:
|
||||
|
||||
```text
|
||||
calling cq at SECONDQRG, ant MYQTF deg, loc MYLOCATOR
|
||||
```
|
||||
|
||||
Variables are resolved again on every timer run. If the logging software changes the QRG stored in `MYQRG`, the next beacon can already contain the updated value. The message template does not have to be edited.
|
||||
Variables are resolved again on every timer run. `MYQRG` and `MYQRGSHORT` always require a valid primary-category QRG, while `SECONDQRG` always requires a valid secondary-category QRG. This assignment is independent of which beacon template contains the variable.
|
||||
|
||||
`MYQRG` and `MYQRGSHORT` always refer to the primary chat category. Enabling or selecting the second chat does not change this assignment.
|
||||
If a beacon template contains one of these QRG variables, that beacon can remain enabled only while the assigned QRG is valid. If the value is missing or invalid, only that beacon remains off or is disabled, and its tooltip states the reason. A template without a QRG variable may still be enabled when no QRG is available.
|
||||
|
||||
When enabled, each beacon remembers the valid QRG of its own category as its reference. If no valid own QRG exists yet and the template has no QRG variable, the first valid frequency reported later by the user or logger becomes the reference. A manual QRG change is treated as intentional and moves the reference to the new value. If UCXLog or Win-Test later changes the assigned QRG by more than 5 kHz from that reference, KST4Contest disables the affected beacon automatically. Exactly 5 kHz is still permitted. Without SO2R, an automatic logger QRG affects only the primary beacon; with SO2R, the secondary QRG and beacon are handled separately.
|
||||
|
||||
Station-specific variables such as `QRZNAME`, `FIRSTAP` and `SECONDAP` require a selected remote station. A public beacon has no such destination, so these variables are not resolved in beacon messages.
|
||||
|
||||
@@ -651,16 +701,16 @@ Station-specific variables such as `QRZNAME`, `FIRSTAP` and `SECONDAP` require a
|
||||
|
||||
KST4Contest validates both the configured template and the message which remains after all variables have been resolved.
|
||||
|
||||
The following restrictions apply:
|
||||
The following restrictions apply to the resolved beacon content before the fixed suffix:
|
||||
|
||||
- The final message must not be empty.
|
||||
- It must not be empty.
|
||||
- It must not exceed 120 characters.
|
||||
- The protocol separator `|` is not permitted.
|
||||
- Line breaks are not permitted.
|
||||
|
||||
An invalid entry is not accepted as the new beacon configuration. If a template becomes invalid only after resolving its variables, for example because the resulting text exceeds 120 characters, that beacon run is skipped.
|
||||
KST4Contest then appends ` *a*`, so the transmitted beacon message may contain up to 124 characters. An invalid entry is not accepted as the new beacon configuration. If a template becomes invalid only after resolving its variables, for example because the resolved content exceeds 120 characters, that beacon run is skipped.
|
||||
|
||||
A template which consists only of a temporarily empty global variable may still be stored. This can happen during startup before the first QRG has been received from the logger. KST4Contest does not send an empty message while the variable has no usable value.
|
||||
A template containing a QRG variable may be stored before a matching QRG is available, but the affected beacon cannot then be enabled. If a required QRG becomes invalid later, an active beacon is disabled. If the template contains no QRG variable, an invalid own QRG only clears the reference and the beacon remains enabled.
|
||||
|
||||
### When should the beacon be disabled?
|
||||
|
||||
@@ -668,7 +718,7 @@ The beacon is useful only while its QRG matches the actual operation. Leaving it
|
||||
|
||||
In plain terms: the beacon saves work while calling CQ on a fixed QRG. It should be disabled while moving around the band.
|
||||
|
||||
Changes take effect during the current connection. Use **Save Settings** afterwards to retain the enable settings, message templates and interval for the next program start.
|
||||
Changes take effect during the current connection. **Save Settings** stores the message templates and interval for the next program start. Activation is deliberately not stored and must be performed again in every program session.
|
||||
|
||||
---
|
||||
|
||||
@@ -690,12 +740,12 @@ A suitable message is:
|
||||
Sri, I am not taking part in this contest. No skeds.
|
||||
```
|
||||
|
||||
Do not add the `[KST4C Automsg]` prefix to the configured text. KST4Contest inserts it automatically.
|
||||
Do not add the `[KST4C Automsg]` prefix or the fixed ` *a*` suffix to the configured text. KST4Contest inserts both automatically.
|
||||
|
||||
The message received by the remote station may therefore be:
|
||||
|
||||
```text
|
||||
[KST4C Automsg] Sri, I am not taking part in this contest. No skeds.
|
||||
[KST4C Automsg] Sri, I am not taking part in this contest. No skeds. *a*
|
||||
```
|
||||
|
||||
The incoming private message remains visible. The function neither blocks nor discards the request; it merely avoids entering the same answer repeatedly.
|
||||
@@ -726,7 +776,7 @@ The answer contains only the QRG belonging to the category in which the request
|
||||
A possible reply is:
|
||||
|
||||
```text
|
||||
[KST4C Automsg] QRG is: 144.300.00
|
||||
[KST4C Automsg] QRG is: 144.300.00 *a*
|
||||
```
|
||||
|
||||
The values come from the same QRG fields used by `MYQRG` and `SECONDQRG`. The primary QRG may be entered manually or updated through [TRX synchronisation](#trx-sync-settings). The second category uses the value configured or entered for that category; with SO2R, radio 2 writes this field (`SECONDQRG`).
|
||||
@@ -762,7 +812,7 @@ The existing `client_settings_window_messagehandling.png` screenshot does not ye
|
||||
|
||||
### Protection against repeated replies
|
||||
|
||||
Every automatically generated reply contains the fixed prefix:
|
||||
Every automatic reply contains the fixed prefix:
|
||||
|
||||
```text
|
||||
[KST4C Automsg]
|
||||
@@ -770,6 +820,8 @@ Every automatically generated reply contains the fixed prefix:
|
||||
|
||||
The general and QRG-specific functions ignore messages which already contain this prefix. This prevents two clients with automatic replies enabled from answering each other indefinitely.
|
||||
|
||||
In addition, every chat message generated automatically by KST4Contest ends with ` *a*`. This applies to general and QRG-specific replies, `//VER` replies and both beacons. The suffix is always appended, even if the configured text already ends with it. Manually sent messages and internal ON4KST control frames remain unchanged.
|
||||
|
||||
A common two-minute cooldown additionally applies to both reply types. The cooldown is tracked separately for each complete callsign and chat category.
|
||||
|
||||
This means:
|
||||
|
||||
@@ -93,9 +93,9 @@ KST4Contest keeps the required information together between these steps. Changin
|
||||
|
||||
During operation on a mainly fixed CQ frequency, `MYQRG` and `SECONDQRG` should match the frequencies actually in use. TRX synchronisation can update `MYQRG` automatically only when it is enabled and actually supplies valid packets. Before the contest, verify this with a real frequency change. Without a working automatic source, the value must be maintained manually.
|
||||
|
||||
The beacon can publish the current QRG, locator and antenna direction in the chat at regular intervals. Its variables are evaluated again for every transmission.
|
||||
The beacon can publish the current QRG, locator and antenna direction in the chat at regular intervals. It must be enabled deliberately after every program start or profile switch. A manually changed QRG becomes the new reference; if UCXLog or Win-Test later reports a jump of more than 5 kHz, the affected beacon is disabled automatically.
|
||||
|
||||
Disable the beacon while scanning across several frequencies. An automatically published QRG is useful only while it is still correct.
|
||||
While scanning across several frequencies, this safeguard prevents an unintended transmission with a new logger QRG. The status tooltip shows which category was disabled and why.
|
||||
|
||||
Shortcuts and snippets should cover the messages required regularly, for example:
|
||||
|
||||
|
||||
@@ -300,7 +300,7 @@ When two chat categories are connected, the original context is retained. The re
|
||||
|
||||
If the required QRG is missing, KST4Contest sends no incomplete answer. Empty or locally invalid general reply texts are rejected as well.
|
||||
|
||||
Automatic replies need limits. KST4Contest adds the fixed prefix `[KST4C Automsg]`, ignores incoming messages which already contain that prefix and permits only one automatic reply to the same complete callsign in the same category within two minutes. The cooldown is shared by the general and QRG-specific reply functions.
|
||||
Automatic replies need limits. KST4Contest adds the fixed prefix `[KST4C Automsg]`, ignores incoming messages which already contain that prefix and permits only one automatic reply to the same complete callsign in the same category within two minutes. The cooldown is shared by the general and QRG-specific reply functions. In addition, every automatically generated chat message, including `//VER` replies and beacons, ends with ` *a*`.
|
||||
|
||||
A rejected reply does not start the cooldown. After entering the missing QRG or correcting the configured text, KST4Contest can therefore answer the next request immediately.
|
||||
|
||||
@@ -796,13 +796,13 @@ The timeline is a preview. AirScout data can change, and a stored sked guarantee
|
||||
|
||||
KST4Contest can send recurring CQ messages to the public chat. The beacon is intended for longer periods of calling CQ on a fixed frequency: it publishes the local QRG regularly without requiring the operator to enter the same text again.
|
||||
|
||||
Both chat categories use one shared interval, but each category has its own enable setting and message template. The second beacon is only sent while the second category is enabled and fully synchronised in the shared ON4KST session.
|
||||
Both chat categories use one shared interval of at least five minutes, but each category has its own enable setting and message template. Activation lasts only for the current program session and must be repeated after a program start or profile switch. An ON4KST reconnect does not change it. The second beacon is only sent while the second category is enabled and fully synchronised in the shared ON4KST session.
|
||||
|
||||
Global variables such as `MYQRG`, `SECONDQRG`, `MYLOCATOR` and `MYQTF` are resolved immediately before every transmission. A QRG updated by the logging software can therefore appear in the next beacon.
|
||||
Global variables such as `MYQRG`, `SECONDQRG`, `MYLOCATOR` and `MYQTF` are resolved immediately before every transmission. Each active beacon also monitors the QRG of its own category. A manual change moves the reference; an automatic jump of more than 5 kHz from UCXLog or Win-Test disables the affected beacon.
|
||||
|
||||
Before transmission, KST4Contest validates the completely resolved message. Empty messages, line breaks, the protocol separator `|` and messages exceeding 120 characters are not sent.
|
||||
Before transmission, KST4Contest validates the completely resolved beacon content. Empty content, line breaks, the protocol separator `|` and content exceeding 120 characters are not sent. It then appends ` *a*`, so the transmitted message may contain up to 124 characters.
|
||||
|
||||
Disable the beacon while searching the band or changing QRG frequently. An automatically published frequency is useful only while somebody is actually listening and calling there.
|
||||
The coloured **MyBeacon** chip shows active, partially active, off and failed states. Its tooltip lists the state or last deactivation reason for each category.
|
||||
|
||||
Configuration, timer behaviour and available variables: [Configuration – Beacon Settings](en-Configuration#beacon-settings).
|
||||
|
||||
|
||||
@@ -307,16 +307,20 @@ If the second chat category uses a different QRG, its template must contain `SEC
|
||||
calling cq at SECONDQRG, ant MYQTF deg, loc MYLOCATOR
|
||||
```
|
||||
|
||||
Global variables are evaluated again on every timer run. A QRG updated by the logging software can therefore already appear in the next beacon message.
|
||||
Global variables are evaluated again on every timer run. `MYQRG` and `MYQRGSHORT` always require a valid primary-category QRG, while `SECONDQRG` always requires a valid secondary-category QRG, regardless of which beacon template contains them. If a required QRG is unavailable, only the affected beacon cannot be enabled or is disabled. A template without a QRG variable may still be enabled without an available QRG.
|
||||
|
||||
The fully resolved beacon text:
|
||||
When enabled, each beacon remembers the QRG of its own category. A manual QRG change moves this reference. If UCXLog or Win-Test later changes the assigned QRG by more than 5 kHz, KST4Contest disables the affected beacon instead of silently including the new frequency in its next transmission. If no own QRG exists when the beacon is enabled, the first valid frequency entered or received later becomes the reference.
|
||||
|
||||
The fully resolved beacon content before the fixed ` *a*` suffix:
|
||||
|
||||
- must contain at least one valid character,
|
||||
- must not exceed 120 characters,
|
||||
- must not contain the protocol separator `|`, and
|
||||
- must not contain line breaks.
|
||||
|
||||
If the text is empty or invalid when transmission is due, that beacon run is skipped.
|
||||
KST4Contest appends the suffix automatically afterwards. The transmitted beacon message may therefore contain up to 124 characters.
|
||||
|
||||
If the resolved text is empty or invalid for another reason when transmission is due, that beacon run is skipped and the status chip shows **FAILED**.
|
||||
|
||||
The interval, activation and behaviour of both categories are described under [Configuration – Beacon Settings](en-Configuration#beacon-settings).
|
||||
|
||||
|
||||
@@ -570,7 +570,7 @@ If the layout has become inconvenient, first move the dividers and column widths
|
||||
|
||||
## Operating Tips
|
||||
|
||||
- **Toggle beacons quickly**: Keep the settings window open to control each category separately. Click the **MyBeacon** status chip to enable or disable all currently usable beacons together.
|
||||
- **Toggle beacons quickly**: Keep the settings window open to control each category separately. Click the **MyBeacon** status chip to enable or disable all currently usable beacons together. **off** uses red text, **1/2** and **on** are green, and the chip flashes orange when activity is reported. **FAILED** stays red with white text. The tooltip lists the state or last deactivation reason for each category.
|
||||
- **Right-click in the user list**: Opens the snippet menu and additional actions, including QRZ.com profiles and NOT-QRV marks.
|
||||
- **Press Enter while working in the chat**: If the send field contains text, Enter sends it directly even when another control has focus.
|
||||
- **Stop the beacon while scanning**: Disable the beacon while moving through frequencies to avoid flooding the chat with unnecessary messages.
|
||||
- **Check the beacon after startup**: Both beacons are off after a program start or profile switch. A normal ON4KST reconnect within the same program session does not change their state.
|
||||
@@ -1,5 +1,5 @@
|
||||
[versions]
|
||||
sqliteJdbc = "3.53.4.0"
|
||||
sqliteJdbc = "3.54.1.0"
|
||||
jlayer = "1.0.1"
|
||||
junit = "6.1.3"
|
||||
mockito = "5.24.0"
|
||||
|
||||
Vendored
BIN
Binary file not shown.
+1
-1
@@ -1,6 +1,6 @@
|
||||
distributionBase=GRADLE_USER_HOME
|
||||
distributionPath=wrapper/dists
|
||||
distributionUrl=https\://services.gradle.org/distributions/gradle-9.8.1-bin.zip
|
||||
distributionUrl=https\://services.gradle.org/distributions/gradle-9.9.1-bin.zip
|
||||
networkTimeout=10000
|
||||
retries=0
|
||||
retryBackOffMs=500
|
||||
|
||||
@@ -47,7 +47,7 @@ pse qrg
|
||||
and answers with the QRG belonging to the chat category in which the request was received:
|
||||
|
||||
```text
|
||||
[KST4C Automsg] QRG is: 144.300.00
|
||||
[KST4C Automsg] QRG is: 144.300.00 *a*
|
||||
```
|
||||
|
||||
When both functions are enabled, a recognised QRG request receives the QRG reply only. It does not additionally trigger the general answer.
|
||||
@@ -82,6 +82,8 @@ Every automatic reply contains:
|
||||
|
||||
Messages which already contain this prefix are not answered automatically. Two KST4Contest clients therefore do not continue replying to each other.
|
||||
|
||||
Every chat message generated automatically by KST4Contest also ends with ` *a*`. This includes general and QRG-specific replies, `//VER` replies and both beacons. The suffix is added even when the configured text already ends with it; manual messages are unchanged.
|
||||
|
||||
A shared two-minute cooldown additionally applies to the general and QRG-specific functions. It is tracked separately for each complete callsign and chat category.
|
||||
|
||||
A rejected reply does not start the cooldown. If a QRG was missing and is entered afterwards, the next request can be answered immediately.
|
||||
|
||||
@@ -170,11 +170,13 @@ A public beacon has no selected remote station. It can therefore use only global
|
||||
|
||||

|
||||
|
||||
Each chat category has its own enable setting and message template. Both categories use the same timer interval. The second beacon is sent only when the second category and its beacon are enabled in the shared ON4KST session.
|
||||
Each chat category has its own enable setting and message template. Both categories use the same timer interval. Beacon activation is session-only: both are off after a program start or profile switch, but an ON4KST reconnect within the same program session preserves their state. The second beacon is sent only when the second category and its beacon are enabled in the shared ON4KST session.
|
||||
|
||||
Global variables are evaluated again on every timer run. A QRG changed by the logger can therefore be included in the next beacon without editing its template.
|
||||
Global variables are evaluated again on every timer run. `MYQRG` and `MYQRGSHORT` require a valid primary QRG, while `SECONDQRG` requires a valid secondary QRG, regardless of which beacon template contains them. A template without a QRG variable may be enabled before any QRG is known.
|
||||
|
||||
The completely resolved beacon text must not exceed 120 characters. The configured minimum interval is one minute.
|
||||
When enabled, each beacon remembers the QRG of its own category. A manual QRG change moves that reference. A later UCXLog or Win-Test change of more than 5 kHz disables the affected beacon automatically; exactly 5 kHz remains allowed. If no reference exists yet, the first valid manual or logger QRG establishes it.
|
||||
|
||||
The completely resolved beacon content before the fixed suffix must not exceed 120 characters. KST4Contest then appends ` *a*`, so the transmitted message may contain up to 124 characters. The configured minimum interval is five minutes.
|
||||
|
||||
A suitable template is:
|
||||
|
||||
|
||||
@@ -3,8 +3,8 @@ title: TRX/QRG Synchronisation
|
||||
icon: 🎛️
|
||||
category: Station Control
|
||||
since: "1.0"
|
||||
summary: Keep the primary operating frequency in MYQRG current from RadioInfo or Win-Test STATUS packets while leaving logging and SECONDQRG independent.
|
||||
description: KST4Contest can take the local primary QRG from compatible logger packets and make it available immediately to messages, beacons, QRG replies and Win-Test sked handover.
|
||||
summary: Keep MYQRG and, with SO2R, SECONDQRG current from RadioInfo or Win-Test STATUS packets while leaving QSO logging independent.
|
||||
description: KST4Contest can take local QRGs from compatible logger packets and make them available immediately to messages, beacons, QRG replies and Win-Test sked handover.
|
||||
tagsList:
|
||||
- TRX synchronisation
|
||||
- QRG
|
||||
@@ -25,34 +25,34 @@ related:
|
||||
|
||||
Changing frequency in the logger and then copying the same value into the chat client is easy to forget. The result may be a perfectly valid beacon or QRG reply which points to yesterday's frequency.
|
||||
|
||||
KST4Contest can therefore update the primary local QRG, `MYQRG`, from the logger. The current value is then available immediately wherever the application's own QRG is required.
|
||||
KST4Contest can therefore update the primary local QRG, `MYQRG`, from the logger. With SO2R enabled, radio 2 can update `SECONDQRG` independently. The current values are then available immediately wherever the application's own QRG is required.
|
||||
|
||||
TRX/QRG Synchronisation has existed since version 1.0. Support for native Win-Test `STATUS` packets is included from version 1.31 onwards.
|
||||
|
||||

|
||||
|
||||
## Which sources can update MYQRG?
|
||||
## Which sources can update the local QRGs?
|
||||
|
||||
Two automatic sources are available:
|
||||
|
||||
- compatible `RadioInfo` packets received through the shared log-sync UDP listener; and
|
||||
- native Win-Test `STATUS` packets received through the Win-Test network listener.
|
||||
|
||||
If neither source is enabled, `MYQRG` can be entered manually in the main window. Enabling an automatic source makes the received value the primary QRG instead.
|
||||
If neither source is enabled, `MYQRG` and `SECONDQRG` can be entered manually in the main window. Without SO2R, automatic packets update `MYQRG` only. With SO2R, the configured radio or station mapping assigns radio 1 to `MYQRG` and radio 2 to `SECONDQRG`.
|
||||
|
||||
## Frequency and QSO synchronisation are separate
|
||||
|
||||
The general UDP listener may receive QSO data and `RadioInfo` packets on the same port, but KST4Contest treats them as different functions.
|
||||
|
||||
A `RadioInfo` packet can update `MYQRG`; it does not mark a station as worked. Conversely, QSO or Worked synchronisation updates the log-derived station state without automatically changing the local QRG.
|
||||
A `RadioInfo` packet can update a local QRG; it does not mark a station as worked. Conversely, QSO or Worked synchronisation updates the log-derived station state without automatically changing a local QRG.
|
||||
|
||||
This separation is deliberate. A radio frequency says where the local station is operating. It says nothing about which remote station has just been worked.
|
||||
|
||||
## MYQRG does not mean SECONDQRG
|
||||
## MYQRG and SECONDQRG remain distinct
|
||||
|
||||
Both automatic sources update `MYQRG` only. This is the local QRG of the first or primary chat category.
|
||||
Without SO2R, both automatic sources update `MYQRG` only. This is the local QRG of the first or primary chat category; the secondary value remains independent.
|
||||
|
||||
`SECONDQRG` remains independent and is not derived from incoming TRX packets. A dual-chat setup can therefore follow the logger automatically for the primary category while retaining a separately entered QRG for the second category.
|
||||
With SO2R enabled, `RadioInfo` packets use `RadioNr` to update radio 1 or radio 2. Win-Test uses the configured station name for each radio. Radio 2 updates `SECONDQRG`, without changing the meaning of either variable.
|
||||
|
||||
## Main or pass frequency from Win-Test
|
||||
|
||||
@@ -64,27 +64,29 @@ Several Win-Test operating positions may transmit `STATUS` packets on the same n
|
||||
|
||||
## What happens with several frequency sources?
|
||||
|
||||
All enabled sources write to the same `MYQRG` value. KST4Contest does not assign a fixed priority to `RadioInfo` and Win-Test `STATUS` packets.
|
||||
All enabled sources assigned to the same radio write to the same QRG value. KST4Contest does not assign a fixed priority to `RadioInfo` and Win-Test `STATUS` packets.
|
||||
|
||||
If several sources are active, the most recently processed packet determines the current primary QRG. That is useful when the sources describe the same radio. Independent radios should not compete for the same value unless that last-packet behaviour is actually intended.
|
||||
If several sources are active, the most recently processed packet for that radio determines its current QRG. That is useful when the sources describe the same radio. Independent radios should use the SO2R assignments instead of competing for the same value.
|
||||
|
||||
## Where is the synchronised QRG used?
|
||||
|
||||
The current primary QRG is immediately available for:
|
||||
The current assigned QRG is immediately available for:
|
||||
|
||||
- [macros and variables](/features/macros/), including `MYQRG` and `MYQRGSHORT`;
|
||||
- [macros and variables](/features/macros/), including `MYQRG`, `MYQRGSHORT` and `SECONDQRG`;
|
||||
- automatic beacons;
|
||||
- [automatic QRG replies](/features/automatic-replies/) in the primary chat category; and
|
||||
- a matching primary local-frequency fallback when a [sked is handed to Win-Test](/features/sked-reminder/).
|
||||
|
||||
The sked handover still checks whether the local QRG belongs to the selected band. Synchronisation supplies the value; it does not bypass that validation.
|
||||
|
||||
An active beacon treats a manual QRG edit as intentional and moves its category reference to the new value. If UCXLog or Win-Test later changes that category QRG by more than 5 kHz, KST4Contest disables the affected beacon. Without SO2R only the primary beacon can be affected by an automatic QRG update; with SO2R both category references are monitored independently.
|
||||
|
||||
## What the function does not do
|
||||
|
||||
TRX/QRG Synchronisation tracks the local station's primary frequency. It does not detect the QRG of a remote station from chat text; that is the separate [Automatic QRG Detection](/features/qrg-detection/) function.
|
||||
TRX/QRG Synchronisation tracks the local station's assigned frequency or frequencies. It does not detect the QRG of a remote station from chat text; that is the separate [Automatic QRG Detection](/features/qrg-detection/) function.
|
||||
|
||||
It also does not turn a `RadioInfo` packet into a logged QSO. Worked information remains the responsibility of [Log Synchronisation](/features/log-sync/).
|
||||
|
||||
In practical terms: one current local QRG can feed several operating workflows, but it remains one value. `SECONDQRG`, remote-station frequencies and Worked state keep their own meanings.
|
||||
In practical terms, each current local QRG can feed several operating workflows, while primary QRG, secondary QRG, remote-station frequencies and Worked state keep their own meanings.
|
||||
|
||||
[Read the complete TRX Sync configuration in the manual.](/manual/en/configuration/#trx-sync-settings)
|
||||
Reference in new issue
Block a user