mirror of
https://github.com/praktimarc/kst4contest.git
synced 2026-09-11 19:55:40 +02:00
Issue #68 Adds Band.B_50/B_70 and wires them through the same band-opportunity machinery as the other bands: X/a/B+/o table columns and filter button in the User table and the Workedstn database table, NOT-QRV checkboxes and propagation across callsign variants, "My station uses 6m/4m band" toggles, station-name detection ("50", "6M", "70MHZ", "4M" - without stealing the existing bare "70"/"6" cm-band shorthand), Win-Test sked band IDs (10/50MHz, 11/70MHz), and UCX-logger worked-band recognition. Persists worked50/70 and notQRV50/70 via an additive SQLite migration (same ensureColumnExists pattern as the earlier v1.1->v1.2 migration), verified against a real database file. ReachabilityService.resolveAutoBand() now also falls back to 50 MHz (then 70 MHz) for stations in the "50/70 MHz" chat category, mirroring the existing Microwave-category fallback to 23cm. Assisted by Claude Sonnet 5 <noreply@anthropic.com>
111 lines
3.2 KiB
Java
111 lines
3.2 KiB
Java
package kst4contest.model;
|
|
|
|
/**
|
|
* Represents Amateur Radio Bands and their physical limits.
|
|
* Used for plausibility checks in the Smart Parser.
|
|
*/
|
|
public enum Band {
|
|
B_50(50.000, 54.000, "50"),
|
|
B_70(70.000, 70.500, "70"),
|
|
B_144(144.000, 146.000, "144"),
|
|
B_432(432.000, 434.000, "432"),
|
|
B_1296(1296.000, 1298.000, "1296"),
|
|
B_2320(2320.000, 2322.000, "2320"),
|
|
B_3400(3400.000, 3410.000, "3400"),
|
|
B_5760(5760.000, 5762.000, "5760"),
|
|
B_10G(10368.000, 10370.000, "10368"),
|
|
B_24G(24048.000, 24050.000, "24048");
|
|
// more space for future usage
|
|
|
|
private final double minFreq;
|
|
private final double maxFreq;
|
|
private final String prefix; // Default prefix for "short value" parsing (e.g., .210)
|
|
|
|
Band(double min, double max, String prefix) {
|
|
this.minFreq = min;
|
|
this.maxFreq = max;
|
|
this.prefix = prefix;
|
|
}
|
|
|
|
public String getPrefix() {
|
|
return prefix;
|
|
}
|
|
|
|
|
|
/**
|
|
* Resolves a configured MHz prefix to one of the bands supported by the
|
|
* frequency parser.
|
|
*
|
|
* <p>The former free-text preference accepted arbitrary numeric values even
|
|
* though only prefixes represented by this enum can be used for a plausible
|
|
* frequency. Keeping the lookup here gives the UI and the parser one common
|
|
* definition of a valid fallback band.</p>
|
|
*
|
|
* @param prefix configured MHz prefix, for example {@code 144} or {@code 10368}
|
|
* @return matching band, or {@code null} if the prefix is not supported
|
|
*/
|
|
public static Band fromPrefix(String prefix) {
|
|
if (prefix == null) {
|
|
return null;
|
|
}
|
|
|
|
String normalizedPrefix = prefix.trim();
|
|
|
|
for (Band band : values()) {
|
|
if (band.prefix.equals(normalizedPrefix)) {
|
|
return band;
|
|
}
|
|
}
|
|
|
|
return null;
|
|
}
|
|
|
|
/**
|
|
* Returns the lower edge used as practical analysis frequency when only the band
|
|
* is known. This keeps the batch reachability calculation deterministic.
|
|
*
|
|
* @return frequency in MHz
|
|
*/
|
|
public double getDefaultAnalysisFrequencyMHz() {
|
|
return minFreq;
|
|
}
|
|
|
|
/**
|
|
* Returns a compact label for table display and filter controls.
|
|
*
|
|
* @return human readable band label
|
|
*/
|
|
public String getDisplayLabel() {
|
|
switch (this) {
|
|
case B_50: return "50";
|
|
case B_70: return "70";
|
|
case B_144: return "144";
|
|
case B_432: return "432";
|
|
case B_1296: return "1296";
|
|
case B_2320: return "2320";
|
|
case B_3400: return "3400";
|
|
case B_5760: return "5760";
|
|
case B_10G: return "10G";
|
|
case B_24G: return "24G";
|
|
default: return prefix;
|
|
}
|
|
}
|
|
|
|
/**
|
|
* Checks if a specific frequency falls within this band's limits.
|
|
*/
|
|
public boolean isPlausible(double freq) {
|
|
return freq >= minFreq && freq <= maxFreq;
|
|
}
|
|
|
|
/**
|
|
* Helper to find the matching Band enum for a given frequency.
|
|
* Returns null if no band matches.
|
|
*/
|
|
public static Band fromFrequency(double freq) {
|
|
for (Band b : values()) {
|
|
if (b.isPlausible(freq)) return b;
|
|
}
|
|
return null;
|
|
}
|
|
} |