Compare commits

..

1 Commits

Author SHA1 Message Date
denny
291853c32e #2687 HistoryTableViewTest uses the platform copy shortcut so it passes on macOS
HistoryTableView matches SHORTCUT_DOWN+C, which JavaFX maps to Cmd-C on macOS. The test always fired Ctrl-C, so the copy never triggered on the macOS CI runner and the clipboard assertion failed. The test now fires Meta-C on macOS and Ctrl-C elsewhere.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-19 03:04:15 -05:00
14 changed files with 11 additions and 243 deletions

View File

@@ -52,9 +52,7 @@ import org.slf4j.LoggerFactory;
* </ul>
*
* Only aliases whose only identifier is the radio are created or renamed. An alias that combines the radio with other
* identifiers (e.g. several radios or talkgroups) is left alone. The exception is a P25 radio's simple and fully
* qualified radio identifiers with the same radio ID: the second form decoded is added to the alias for the first
* form, including a user alias outside the managed group, instead of creating a second alias for the same radio.
* identifiers (e.g. several radios or talkgroups) is left alone.
*
* This class is thread safe. Talker aliases are received on decoder threads and the alias model is updated on the
* JavaFX application thread.
@@ -202,21 +200,6 @@ public class TalkerAliasAutoAdder implements BiConsumer<RadioIdentifier,TalkerAl
AliasList aliasList = mAliasModel.getAliasList(mAliasListName);
Alias existing = findExactMatch(aliasList.getAliases(radio), aliasId);
if(existing == null)
{
existing = findCompanion(aliasList.aliases(), radio, aliasId);
if(existing != null)
{
//Add the radio to the alias for the same radio's other identifier form, then continue below to
//compare the talker alias with the alias name (only managed aliases are renamed).
existing.addAliasID(aliasId);
aliasList.updateAlias(existing);
mLog.info("Talker alias radio [" + aliasId + "] added to existing alias [" + existing.getName() +
"] in alias list [" + mAliasListName + "]");
}
}
if(existing == null)
{
Alias alias = new Alias(value);
@@ -425,114 +408,22 @@ public class TalkerAliasAutoAdder implements BiConsumer<RadioIdentifier,TalkerAl
}
/**
* Finds the alias for the other identifier form of a P25 radio, so that a radio's simple and fully qualified
* identifiers share one alias instead of creating an alias for each. This includes user aliases outside the
* managed group, so that either identifier maps to the user's alias. The user alias is never renamed.
* <ul>
* <li>Fully qualified radio: the alias whose only identifier is the simple radio with the same radio
* ID. Only when the fully qualified radio isn't using a different local address (e.g. a roaming radio), since
* the radio ID then belongs to the home system and doesn't identify the radio on this system.</li>
* <li>Simple radio: the alias whose only identifier is a fully qualified radio with the same radio ID. None
* when more than one fully qualified radio alias matches.</li>
* </ul>
* @param aliases to search
* @param radio decoded radio identifier
* @param aliasId created from the decoded radio
* @return companion alias or null.
* Number of identifiers (e.g. radios, talkgroups) in the alias, excluding audio settings like priority, record and
* streaming.
*/
@VisibleForTesting
static Alias findCompanion(List<Alias> aliases, RadioIdentifier radio, Radio aliasId)
private static int getIdentityCount(Alias alias)
{
if(aliases == null || aliasId.getProtocol() != Protocol.APCO25)
{
return null;
}
boolean fullyQualified = aliasId instanceof P25FullyQualifiedRadio;
if(fullyQualified && !(radio instanceof FullyQualifiedRadioIdentifier fqri &&
fqri.getValue() != null && fqri.getValue() == fqri.getRadio()))
{
return null;
}
Alias match = null;
for(Alias alias: aliases)
{
if(getSoleIdentity(alias) instanceof Radio candidate &&
(candidate instanceof P25FullyQualifiedRadio) != fullyQualified &&
candidate.getProtocol() == Protocol.APCO25 && candidate.getValue() == aliasId.getValue())
{
if(match != null)
{
//Ambiguous - more than one candidate.
return null;
}
match = alias;
}
}
return match;
}
/**
* Identifier of an alias that has exactly one identifier, excluding audio settings.
* @return identifier or null if the alias has none or more than one.
*/
private static AliasID getSoleIdentity(Alias alias)
{
AliasID sole = null;
int count = 0;
for(AliasID id: alias.getAliasIdentifiers())
{
if(!id.isAudioIdentifier())
{
if(sole != null)
{
return null;
}
sole = id;
count++;
}
}
return sole;
}
/**
* Number of identities (e.g. radios, talkgroups) in the alias, excluding audio settings like priority, record and
* streaming. A P25 radio's simple and fully qualified radio identifiers with the same radio ID count as one
* identity.
*/
private static int getIdentityCount(Alias alias)
{
List<AliasID> ids = alias.getAliasIdentifiers().stream().filter(id -> !id.isAudioIdentifier()).toList();
if(ids.size() == 2 && isRadioPair(ids.get(0), ids.get(1)))
{
return 1;
}
return ids.size();
}
/**
* Indicates if the identifiers are the simple and fully qualified forms of the same P25 radio ID.
*/
private static boolean isRadioPair(AliasID a, AliasID b)
{
if(a instanceof P25FullyQualifiedRadio)
{
AliasID swap = a;
a = b;
b = swap;
}
return a instanceof Radio simple && !(a instanceof P25FullyQualifiedRadio) &&
b instanceof P25FullyQualifiedRadio fqr && simple.getProtocol() == Protocol.APCO25 &&
simple.getValue() == fqr.getValue();
return count;
}
private static String getKey(Radio aliasId)

View File

@@ -42,7 +42,6 @@ public class ChannelDFTFactory
case VECTOR_SIMD_PREFERRED:
return new VectorChannelDFT(channelCount);
case SCALAR:
case UNCALIBRATED:
default:
return new ScalarChannelDFT(channelCount);
}

View File

@@ -42,7 +42,6 @@ public class DcRemovalFilterFactory
case VECTOR_SIMD_PREFERRED:
return new VectorDcRemovalFilter(gain);
case SCALAR:
case UNCALIBRATED:
default:
return new ScalarDcRemovalFilter(gain);
}

View File

@@ -52,7 +52,6 @@ public class FmDemodulatorFactory
case VECTOR_SIMD_512:
return new VectorFMDemodulator512();
case SCALAR:
case UNCALIBRATED:
default:
return new ScalarFMDemodulator();
}

View File

@@ -44,7 +44,6 @@ public class ComplexGainFactory
return new VectorComplexGainControl();
}
case SCALAR:
case UNCALIBRATED:
default:
return new ComplexGainControl();
}
@@ -65,7 +64,6 @@ public class ComplexGainFactory
return new VectorComplexGain(gain);
}
case SCALAR:
case UNCALIBRATED:
default:
return new ScalarComplexGain(gain);
}

View File

@@ -52,7 +52,6 @@ public class MagnitudeFactory
case VECTOR_SIMD_512:
return new VectorMagnitudeCalculator512();
case SCALAR:
case UNCALIBRATED:
default:
return new ScalarMagnitudeCalculator();
}

View File

@@ -49,7 +49,6 @@ public class ComplexMixerFactory
return new VectorComplexMixer(frequency, sampleRate);
}
case SCALAR:
case UNCALIBRATED:
{
return new ScalarComplexMixer(frequency, sampleRate);
}

View File

@@ -49,7 +49,6 @@ public class OscillatorFactory
case VECTOR_SIMD_PREFERRED:
return new VectorRealOscillator(frequency, sampleRate);
case SCALAR:
case UNCALIBRATED:
default:
return new ScalarRealOscillator(frequency, sampleRate);
}
@@ -70,7 +69,6 @@ public class OscillatorFactory
case VECTOR_SIMD_PREFERRED:
return new VectorComplexOscillator(frequency, sampleRate);
case SCALAR:
case UNCALIBRATED:
default:
return new ScalarComplexOscillator(frequency, sampleRate);
}

View File

@@ -45,8 +45,7 @@ public class DifferentialDemodulatorFactory
case VECTOR_SIMD_128 -> new DifferentialDemodulatorFloatVector128(sampleRate, symbolRate);
case VECTOR_SIMD_256 -> new DifferentialDemodulatorFloatVector256(sampleRate, symbolRate);
case VECTOR_SIMD_512 -> new DifferentialDemodulatorFloatVector512(sampleRate, symbolRate);
case SCALAR, UNCALIBRATED -> new DifferentialDemodulatorFloatScalar(sampleRate, symbolRate);
default -> new DifferentialDemodulatorFloatScalar(sampleRate, symbolRate);
default -> new DifferentialDemodulatorFloatScalar(sampleRate, symbolRate); //Includes SCALAR case
};
}
}

View File

@@ -52,7 +52,6 @@ public class DMRSoftSyncDetectorFactory
case VECTOR_SIMD_512:
return new DMRSoftSyncDetectorVector512();
case SCALAR:
case UNCALIBRATED:
default:
return new DMRSoftSyncDetectorScalar();
}

View File

@@ -51,7 +51,6 @@ public class NXDNSyncDetectorFactory
case VECTOR_SIMD_512:
return new NXDNSoftSyncDetectorVector512();
case SCALAR:
case UNCALIBRATED:
default:
return new NXDNSoftSyncDetectorScalar();
}

View File

@@ -52,7 +52,6 @@ public class P25P1SoftSyncDetectorFactory
case VECTOR_SIMD_512:
return new P25P1SoftSyncDetectorVector512();
case SCALAR:
case UNCALIBRATED:
default:
return new P25P1SoftSyncDetectorScalar();
}

View File

@@ -255,118 +255,6 @@ public class TalkerAliasAutoAdderTest
assertNull(alias(RADIO), "local radio with the same value isn't aliased");
}
/**
* Fully qualified form of RADIO, with a local address that matches the radio ID.
*/
private static final RadioIdentifier QUALIFIED = APCO25FullyQualifiedRadioIdentifier.createFrom(1234, 0xBEE00,
0x123, 1234);
private void assertSingleAliasForBothForms(String name)
{
assertEquals(1, aliases().size(), "one alias for both radio identifier forms");
Alias alias = aliases().get(0);
assertEquals(name, alias.getName());
assertEquals(2, alias.getAliasIdentifiers().size());
AliasList aliasList = mAliasModel.getAliasList(LIST);
assertEquals(List.of(alias), aliasList.getAliases(RADIO), "alias list finds the simple radio");
assertEquals(List.of(alias), aliasList.getAliases(QUALIFIED), "alias list finds the fully qualified radio");
}
@Test
public void fullyQualifiedRadioAddedToSimpleRadioAlias()
{
decode(RADIO, "ENGINE 12");
decode(QUALIFIED, "ENGINE 12");
assertSingleAliasForBothForms("ENGINE 12");
decode(QUALIFIED, "ENGINE 12");
decode(RADIO, "ENGINE 12");
assertSingleAliasForBothForms("ENGINE 12");
}
@Test
public void simpleRadioAddedToFullyQualifiedRadioAlias()
{
decode(QUALIFIED, "ENGINE 12");
decode(RADIO, "ENGINE 12");
assertSingleAliasForBothForms("ENGINE 12");
}
@Test
public void mergedAliasIsStillRenamed()
{
decode(RADIO, "ENGINE 1");
decode(QUALIFIED, "ENGINE 12 OFFICER");
assertSingleAliasForBothForms("ENGINE 12 OFFICER");
decode(RADIO, "LADDER 3");
decode(RADIO, "LADDER 3");
assertSingleAliasForBothForms("LADDER 3");
decode(QUALIFIED, "RESCUE 5");
decode(QUALIFIED, "RESCUE 5");
assertSingleAliasForBothForms("RESCUE 5");
}
@Test
public void roamingRadioIsNotAddedToHomeRadioIdAlias()
{
RadioIdentifier home = APCO25RadioIdentifier.createFrom(777);
decode(home, "LOCAL 777");
decode(APCO25FullyQualifiedRadioIdentifier.createFrom(1234, 0xBEE00, 0x123, 777), "ROAMER");
assertEquals(2, aliases().size());
assertEquals("LOCAL 777", alias(home).getName());
assertEquals(1, alias(home).getAliasIdentifiers().size());
}
@Test
public void simpleRadioIsNotAddedToAmbiguousFullyQualifiedAliases()
{
decode(QUALIFIED, "ENGINE 12");
decode(APCO25FullyQualifiedRadioIdentifier.createFrom(1234, 0xBEE01, 0x456, 1234), "OTHER 12");
decode(RADIO, "ENGINE 12");
assertEquals(3, aliases().size());
assertEquals(1, alias(RADIO).getAliasIdentifiers().size());
}
private Alias userAlias(Radio radio)
{
Alias alias = new Alias("Custom Name");
alias.setAliasListName(LIST);
alias.setGroup("Apparatus");
alias.addAliasID(radio);
mAliasModel.addAlias(alias);
return alias;
}
@Test
public void userAliasIsGivenFullyQualifiedRadio()
{
Alias alias = userAlias(new Radio(Protocol.APCO25, 1234));
decode(QUALIFIED, "ENGINE 12");
decode(QUALIFIED, "ENGINE 12");
assertSingleAliasForBothForms("Custom Name");
assertEquals("Apparatus", alias.getGroup());
}
@Test
public void userAliasIsGivenSimpleRadio()
{
Alias alias = userAlias(new P25FullyQualifiedRadio(0xBEE00, 0x123, 1234));
decode(RADIO, "ENGINE 12");
decode(RADIO, "ENGINE 12");
assertSingleAliasForBothForms("Custom Name");
assertEquals("Apparatus", alias.getGroup());
}
@Test
public void multiIdentifierUserAliasIsNotGivenFullyQualifiedRadio()
{
Alias alias = userAlias(new Radio(Protocol.APCO25, 1234));
alias.addAliasID(new Talkgroup(Protocol.APCO25, 100));
mAliasModel.getAliasList(LIST).updateAlias(alias);
decode(QUALIFIED, "ENGINE 12");
assertEquals(2, aliases().size());
assertEquals(2, alias.getAliasIdentifiers().size());
}
@Test
public void decide()
{

View File

@@ -76,9 +76,11 @@ public class HistoryTableViewTest
table.getSelectionModel().select(0);
table.getSelectionModel().select(2);
//The copy shortcut is Cmd-C (meta) on macOS and Ctrl-C elsewhere
boolean mac = System.getProperty("os.name", "").toLowerCase().startsWith("mac");
Clipboard.getSystemClipboard().clear();
Event.fireEvent(table, new KeyEvent(KeyEvent.KEY_PRESSED, "", "", KeyCode.C, false,
true, false, false));
!mac, false, mac));
copied.complete(Clipboard.getSystemClipboard().getString());
}
catch(Throwable t)