mirror of
https://github.com/praktimarc/kst4contest.git
synced 2026-09-11 03:35:28 +02:00
fix(wintest): add band-aware sked QRG resolution, preserve portable callsigns, strip KST suffixes and correct ADDSKED timestamps
This commit is contained in:
@@ -318,86 +318,6 @@ public class ChatController implements ThreadStatusCallback, PstRotatorEventList
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Chooses a useful initial band for a new sked.
|
||||
*
|
||||
* <p>Recent frequency evidence has priority over station-name information.
|
||||
* Manual NOT-QRV exclusions are respected. The operator can still select
|
||||
* another locally enabled band from the dropdown.</p>
|
||||
*/
|
||||
private Band resolveDefaultSkedBand(ChatMember selectedMember,
|
||||
EnumSet<Band> enabledBands) {
|
||||
|
||||
if (selectedMember == null || enabledBands == null || enabledBands.isEmpty()) {
|
||||
return null;
|
||||
}
|
||||
|
||||
List<ChatMember> variants =
|
||||
chatcontroller.findActiveChatMembersByRawCall(
|
||||
selectedMember.getCallSignRaw()
|
||||
);
|
||||
|
||||
if (variants.isEmpty()) {
|
||||
variants = List.of(selectedMember);
|
||||
}
|
||||
|
||||
BandOpportunityResolver.Resolution resolution =
|
||||
BandOpportunityResolver.resolve(
|
||||
variants,
|
||||
System.currentTimeMillis()
|
||||
);
|
||||
|
||||
EnumSet<Band> availableBands = resolution.getAvailableBands();
|
||||
availableBands.retainAll(enabledBands);
|
||||
|
||||
Band newestFrequencyBand = null;
|
||||
long newestTimestamp = Long.MIN_VALUE;
|
||||
long now = System.currentTimeMillis();
|
||||
|
||||
for (ChatMember member : variants) {
|
||||
if (member == null || member.getKnownActiveBands() == null) {
|
||||
continue;
|
||||
}
|
||||
|
||||
for (Map.Entry<Band, ChatMember.ActiveFrequencyInfo> entry
|
||||
: member.getKnownActiveBands().entrySet()) {
|
||||
|
||||
Band band = entry.getKey();
|
||||
ChatMember.ActiveFrequencyInfo info = entry.getValue();
|
||||
|
||||
if (band == null
|
||||
|| info == null
|
||||
|| !availableBands.contains(band)
|
||||
|| !band.isPlausible(info.frequency)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
long ageMs = now - info.timestampEpoch;
|
||||
if (ageMs < 0L
|
||||
|| ageMs > BandOpportunityResolver.RECENT_DYNAMIC_EVIDENCE_MAX_AGE_MS) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (info.timestampEpoch > newestTimestamp) {
|
||||
newestTimestamp = info.timestampEpoch;
|
||||
newestFrequencyBand = band;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (newestFrequencyBand != null) {
|
||||
return newestFrequencyBand;
|
||||
}
|
||||
|
||||
if (!availableBands.isEmpty()) {
|
||||
return availableBands.iterator().next();
|
||||
}
|
||||
|
||||
return enabledBands.iterator().next();
|
||||
}
|
||||
|
||||
|
||||
|
||||
public void stopRotator() {
|
||||
if (rotatorClient != null) {
|
||||
rotatorClient.stop();
|
||||
|
||||
Reference in New Issue
Block a user