Ask about antenna, log program, rotator and AirScout in the setup wizard

Written-by: Codex (GPT-6.2 Sol)
Written-by: Claude Fable 5.2
This commit is contained in:
Rsclub2_2 committed 2026-11-18 21:32:13 +01:00
1 parent facba2b010
commit bde77f3ec1
7 files changed
+625 -44

No files matched your search

@@ -535,8 +535,6 @@ wizard.summary.personal=Persönliches
wizard.summary.login=Anmeldung
wizard.summary.station=Station
wizard.summary.bands=Bänder
wizard.summary.turnedOff=Wird abgeschaltet: Zweitchat.
wizard.summary.integrationsUnchanged=Logprogramm, Rotor, AirScout und DX-Cluster-Server behalten ihre gespeicherten Werte. Im Einstellungsfenster prüfen.
wizard.summary.none=keine
wizard.summary.passwordSet=gesetzt
@@ -545,3 +543,37 @@ 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.
@@ -544,8 +544,6 @@ wizard.summary.personal=Personal
wizard.summary.login=Login
wizard.summary.station=Station
wizard.summary.bands=Bands
wizard.summary.turnedOff=Will be switched off: second chat.
wizard.summary.integrationsUnchanged=Log program, rotator, AirScout and DX cluster server keep their stored settings. Check them in the settings window.
wizard.summary.none=none
wizard.summary.passwordSet=set
@@ -554,3 +552,37 @@ 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.
@@ -23,6 +23,7 @@ import androidx.compose.ui.unit.dp
import kst4contest.model.ChatCategory
import kst4contest.view.compose.Density
import kst4contest.view.compose.Form
import kst4contest.view.compose.tabs.FilePathRow
import kst4contest.view.i18n.LanguageStore
import kst4contest.view.i18n.LocalStrings
import kst4contest.view.i18n.SYSTEM_LANGUAGE
@@ -72,6 +73,9 @@ fun SetupWizardContent(
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)
}
}
@@ -121,7 +125,7 @@ private fun Refusal(text: String) {
}
@Composable
private fun SourceOption(label: String, selected: Boolean, onSelect: () -> Unit) {
private fun RadioOption(label: String, selected: Boolean, onSelect: () -> Unit) {
Row(
modifier = Modifier
.fillMaxWidth()
@@ -142,7 +146,7 @@ private fun EntryPage(state: SetupWizardState, strings: Strings) {
if (state.loginSources.size > 1) {
Form.section(strings.wizardEntryLogin) {
state.loginSources.forEach { source ->
SourceOption(
RadioOption(
label = when (source) {
WizardSource.NEW -> strings.wizardSourceLoginNew
WizardSource.KEEP -> strings.wizardSourceLoginKeep(state.storedCallsign)
@@ -157,7 +161,7 @@ private fun EntryPage(state: SetupWizardState, strings: Strings) {
if (state.stationSources.size > 1) {
Form.section(strings.wizardEntryStation) {
state.stationSources.forEach { source ->
SourceOption(
RadioOption(
label = when (source) {
WizardSource.NEW -> strings.wizardSourceStationNew
WizardSource.KEEP -> strings.wizardSourceStationKeep(state.storedLocator)
@@ -236,6 +240,116 @@ private fun SitePage(state: SetupWizardState, strings: Strings) {
}
}
/** 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
}
@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() }) {
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) }
@@ -247,8 +361,9 @@ private fun SummaryPage(state: SetupWizardState, strings: Strings, saveFailed: B
if (saveFailed) Refusal(strings.wizardSaveFailed)
if (!state.mandatoryComplete) Refusal(strings.wizardMissing)
if (state.turnsOffSecondChat) Text(strings.wizardSummaryTurnedOff)
if (state.leavesIntegrationsUntouched) Text(strings.wizardSummaryIntegrationsUnchanged)
if (state.switchedOff.isNotEmpty()) {
Text(strings.wizardSummarySwitchedOff(state.switchedOff.joinToString(", ") { switchName(it, strings) }))
}
Form.section(strings.wizardSummaryPersonal) {
SummaryRow(
@@ -286,4 +401,35 @@ private fun SummaryPage(state: SetupWizardState, strings: Strings, saveFailed: B
)
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(integrations.qrgFollow))
SummaryRow(strings.wizardSummaryClusterServer, yesNo(integrations.networked && integrations.clusterServer))
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) }
}
}
@@ -17,7 +17,7 @@ enum class WizardSource {
}
/** The pages, in the order they can appear. */
enum class WizardPage { ENTRY, PERSONAL, LOGIN, SITE, SUMMARY }
enum class WizardPage { ENTRY, PERSONAL, LOGIN, SITE, ANTENNA, LOG, GEAR, SUMMARY }
/**
* A band the station can be active on.
@@ -121,8 +121,24 @@ class SetupWizardState(prefs: ChatPreferences) {
var secondCategory: Int? by mutableStateOf(null)
/** Antenna and power; always proposals from what is stored. */
val antenna = WizardAntenna(prefs)
/** Log program, rotator and AirScout. */
val integrations = WizardIntegrations(prefs)
private var loginShown by mutableStateOf(false)
private var stationShown 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
@@ -161,7 +177,12 @@ class SetupWizardState(prefs: ChatPreferences) {
secondCategory = if (keep) storedSecondCategory else null
// A kept category is the operator's; the suggestion must not replace it.
categoryChosenByOperator = keep
stationShown = !keep || !stationComplete
siteShown = !keep || !stationComplete
antennaShown = !keep
logShown = !keep
gearShown = !keep
// A new station gets only what the operator says yes to.
if (keep) integrations.loadStored() else integrations.loadFresh()
appliedStationSource = stationSource
}
}
@@ -199,7 +220,10 @@ class SetupWizardState(prefs: ChatPreferences) {
if (hasEntryPage) add(WizardPage.ENTRY)
add(WizardPage.PERSONAL)
if (loginShown) add(WizardPage.LOGIN)
if (stationShown) add(WizardPage.SITE)
if (siteShown) add(WizardPage.SITE)
if (antennaShown) add(WizardPage.ANTENNA)
if (logShown) add(WizardPage.LOG)
if (gearShown) add(WizardPage.GEAR)
add(WizardPage.SUMMARY)
}
@@ -213,9 +237,19 @@ class SetupWizardState(prefs: ChatPreferences) {
get() = isLocator(locator) && bands.isNotEmpty() && category in CATEGORY_NUMBERS &&
(!secondChat || secondCategory in secondCategoryOptions)
/** Whether everything the profile needs to log in is there. */
/** 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
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
@@ -239,6 +273,9 @@ class SetupWizardState(prefs: ChatPreferences) {
WizardPage.PERSONAL -> personalComplete
WizardPage.LOGIN -> loginComplete
WizardPage.SITE -> stationComplete
WizardPage.ANTENNA -> antenna.complete
WizardPage.LOG -> integrations.logComplete
WizardPage.GEAR -> integrations.gearComplete
WizardPage.SUMMARY -> false
}
@@ -266,27 +303,38 @@ class SetupWizardState(prefs: ChatPreferences) {
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 -> stationShown = 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
}
/** The profile had a second chat and will have none. */
val turnsOffSecondChat: Boolean
get() = storedSecondChat && !secondChat
/**
* A new station is set up, and this stage does not ask about log program, rotator,
* AirScout and DX cluster server: they keep their stored values, and the summary says so.
* What was on in the profile and will be off after Save, for the summary. Pages that are
* not part of this run change nothing and contribute nothing.
*/
val leavesIntegrationsUntouched: Boolean
get() = stationSource == WizardSource.NEW
val switchedOff: List<WizardSwitch>
get() = buildList {
if (storedSecondChat && !secondChat) add(WizardSwitch.SECOND_CHAT)
if (logShown) addAll(integrations.switchedOffByLog())
if (gearShown) addAll(integrations.switchedOffByGear())
}
/**
* Puts the answers into [prefs] and writes its file.
@@ -298,6 +346,9 @@ class SetupWizardState(prefs: ChatPreferences) {
* 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.
*
* @return false when a mandatory answer is missing -- nothing is touched then -- or when
* the file could not be written
*/
@@ -323,6 +374,10 @@ class SetupWizardState(prefs: ChatPreferences) {
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)
}
@@ -124,4 +124,57 @@ class SetupWizardContentScreenTest {
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 theSummaryNamesWhatANewStationSwitchesOff() = runComposeUiTest {
val state = SetupWizardState(firstInstallation())
state.walkToTheLogPage()
state.finish()
show(state)
onNodeWithText("Will be switched off: network log synchronisation, AirScout.").assertExists()
}
}
@@ -65,7 +65,10 @@ class SetupWizardStateTest {
assertFalse(state.hasEntryPage)
assertEquals(WizardPage.PERSONAL, state.page)
assertEquals(
listOf(WizardPage.PERSONAL, WizardPage.LOGIN, WizardPage.SITE, WizardPage.SUMMARY),
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")
@@ -280,19 +283,6 @@ class SetupWizardStateTest {
assertEquals(WizardPage.SUMMARY, state.page)
}
@Test
fun theSummarySaysWhatIsSwitchedOffAndWhatIsLeftAlone() {
val fresh = SetupWizardState(freshInstallation())
assertTrue(fresh.turnsOffSecondChat, "the template has the second chat on, a new station has it off")
assertTrue(fresh.leavesIntegrationsUntouched)
val kept = SetupWizardState(duplicatedProfile())
kept.chooseStationSource(WizardSource.KEEP)
kept.next()
assertFalse(kept.turnsOffSecondChat)
assertFalse(kept.leavesIntegrationsUntouched)
}
@Test
fun keepingAStationWithMissingLocatorKeepsTheSitePageInTheCourse() {
val state = SetupWizardState(duplicatedProfile().apply { setStn_loginLocatorMainCat("") })
@@ -414,4 +404,165 @@ class SetupWizardStateTest {
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)
}
}
@@ -100,9 +100,6 @@ class SetupWizardWriteTest(@param:TempDir private val directory: Path) {
val prefs = read(file)
val server = prefs.getStn_on4kstServersDns()
val rotatorPort = prefs.getStn_pstRotatorPort()
val udpListener = prefs.isLogsynch_ucxUDPWkdCallListenerEnabled()
val clusterServer = prefs.isNotify_dxClusterServerEnabled()
val airScout = prefs.isAirScout_asUDPListenerEnabled()
val beamWidth = prefs.getStn_antennaBeamWidthDeg()
val state = SetupWizardState(prefs)
@@ -112,9 +109,6 @@ class SetupWizardWriteTest(@param:TempDir private val directory: Path) {
val restored = read(file)
assertEquals(server, restored.getStn_on4kstServersDns())
assertEquals(rotatorPort, restored.getStn_pstRotatorPort())
assertEquals(udpListener, restored.isLogsynch_ucxUDPWkdCallListenerEnabled())
assertEquals(clusterServer, restored.isNotify_dxClusterServerEnabled())
assertEquals(airScout, restored.isAirScout_asUDPListenerEnabled())
assertEquals(beamWidth, restored.getStn_antennaBeamWidthDeg())
}
@@ -224,4 +218,122 @@ class SetupWizardWriteTest(@param:TempDir private val directory: Path) {
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())
}
}