mirror of
https://github.com/DSheirer/sdrtrunk.git
synced 2026-11-19 03:57:26 -05:00
Compare commits
1 Commits
2697-talke
...
master
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
cd098955aa |
@@ -52,9 +52,7 @@ import org.slf4j.LoggerFactory;
|
|||||||
* </ul>
|
* </ul>
|
||||||
*
|
*
|
||||||
* Only aliases whose only identifier is the radio are created or renamed. An alias that combines the radio with other
|
* 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
|
* identifiers (e.g. several radios or talkgroups) is left alone.
|
||||||
* 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.
|
|
||||||
*
|
*
|
||||||
* This class is thread safe. Talker aliases are received on decoder threads and the alias model is updated on the
|
* This class is thread safe. Talker aliases are received on decoder threads and the alias model is updated on the
|
||||||
* JavaFX application thread.
|
* JavaFX application thread.
|
||||||
@@ -202,21 +200,6 @@ public class TalkerAliasAutoAdder implements BiConsumer<RadioIdentifier,TalkerAl
|
|||||||
AliasList aliasList = mAliasModel.getAliasList(mAliasListName);
|
AliasList aliasList = mAliasModel.getAliasList(mAliasListName);
|
||||||
Alias existing = findExactMatch(aliasList.getAliases(radio), aliasId);
|
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)
|
if(existing == null)
|
||||||
{
|
{
|
||||||
Alias alias = new Alias(value);
|
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
|
* Number of identifiers (e.g. radios, talkgroups) in the alias, excluding audio settings like priority, record and
|
||||||
* identifiers share one alias instead of creating an alias for each. This includes user aliases outside the
|
* streaming.
|
||||||
* 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.
|
|
||||||
*/
|
*/
|
||||||
@VisibleForTesting
|
private static int getIdentityCount(Alias alias)
|
||||||
static Alias findCompanion(List<Alias> aliases, RadioIdentifier radio, Radio aliasId)
|
|
||||||
{
|
{
|
||||||
if(aliases == null || aliasId.getProtocol() != Protocol.APCO25)
|
int count = 0;
|
||||||
{
|
|
||||||
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;
|
|
||||||
|
|
||||||
for(AliasID id: alias.getAliasIdentifiers())
|
for(AliasID id: alias.getAliasIdentifiers())
|
||||||
{
|
{
|
||||||
if(!id.isAudioIdentifier())
|
if(!id.isAudioIdentifier())
|
||||||
{
|
{
|
||||||
if(sole != null)
|
count++;
|
||||||
{
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
sole = id;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return sole;
|
return count;
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 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();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private static String getKey(Radio aliasId)
|
private static String getKey(Radio aliasId)
|
||||||
|
|||||||
@@ -660,7 +660,7 @@ public class AliasConfigurationEditor extends SplitPane implements IAliasListRef
|
|||||||
nameColumn.setPrefWidth(140);
|
nameColumn.setPrefWidth(140);
|
||||||
|
|
||||||
TableColumn groupColumn = new TableColumn();
|
TableColumn groupColumn = new TableColumn();
|
||||||
groupColumn.setText("Group");
|
groupColumn.setText("Category");
|
||||||
groupColumn.setCellValueFactory(new PropertyValueFactory<>("group"));
|
groupColumn.setCellValueFactory(new PropertyValueFactory<>("group"));
|
||||||
groupColumn.setPrefWidth(140);
|
groupColumn.setPrefWidth(140);
|
||||||
|
|
||||||
|
|||||||
@@ -1094,7 +1094,7 @@ public class AliasItemEditor extends Editor<Alias>
|
|||||||
GridPane.setConstraints(getColorPicker(), 7, row);
|
GridPane.setConstraints(getColorPicker(), 7, row);
|
||||||
mTextFieldPane.getChildren().add(getColorPicker());
|
mTextFieldPane.getChildren().add(getColorPicker());
|
||||||
|
|
||||||
Label groupLabel = new Label("Group");
|
Label groupLabel = new Label("Category");
|
||||||
groupLabel.setLabelFor(getGroupField());
|
groupLabel.setLabelFor(getGroupField());
|
||||||
GridPane.setHalignment(groupLabel, HPos.RIGHT);
|
GridPane.setHalignment(groupLabel, HPos.RIGHT);
|
||||||
GridPane.setConstraints(groupLabel, 0, ++row);
|
GridPane.setConstraints(groupLabel, 0, ++row);
|
||||||
|
|||||||
@@ -243,7 +243,7 @@ public class AliasViewByIdentifierEditor extends VBox
|
|||||||
aliasColumn.setPrefWidth(200);
|
aliasColumn.setPrefWidth(200);
|
||||||
|
|
||||||
TableColumn<AliasAndIdentifier, String> groupColumn = new TableColumn<>();
|
TableColumn<AliasAndIdentifier, String> groupColumn = new TableColumn<>();
|
||||||
groupColumn.setText("Group");
|
groupColumn.setText("Category");
|
||||||
groupColumn.setCellValueFactory(new PropertyValueFactory<>("group"));
|
groupColumn.setCellValueFactory(new PropertyValueFactory<>("group"));
|
||||||
groupColumn.setPrefWidth(200);
|
groupColumn.setPrefWidth(200);
|
||||||
|
|
||||||
|
|||||||
@@ -241,7 +241,7 @@ public class AliasViewByRecordingEditor extends VBox
|
|||||||
nameColumn.setCellValueFactory(new PropertyValueFactory<Alias,String>("name"));
|
nameColumn.setCellValueFactory(new PropertyValueFactory<Alias,String>("name"));
|
||||||
|
|
||||||
TableColumn groupColumn = new TableColumn();
|
TableColumn groupColumn = new TableColumn();
|
||||||
groupColumn.setText("Group");
|
groupColumn.setText("Category");
|
||||||
groupColumn.setPrefWidth(200);
|
groupColumn.setPrefWidth(200);
|
||||||
groupColumn.setCellValueFactory(new PropertyValueFactory<>("group"));
|
groupColumn.setCellValueFactory(new PropertyValueFactory<>("group"));
|
||||||
|
|
||||||
@@ -280,7 +280,7 @@ public class AliasViewByRecordingEditor extends VBox
|
|||||||
nameColumn.setCellValueFactory(new PropertyValueFactory<Alias,String>("name"));
|
nameColumn.setCellValueFactory(new PropertyValueFactory<Alias,String>("name"));
|
||||||
|
|
||||||
TableColumn groupColumn = new TableColumn();
|
TableColumn groupColumn = new TableColumn();
|
||||||
groupColumn.setText("Group");
|
groupColumn.setText("Category");
|
||||||
groupColumn.setPrefWidth(200);
|
groupColumn.setPrefWidth(200);
|
||||||
groupColumn.setCellValueFactory(new PropertyValueFactory<>("group"));
|
groupColumn.setCellValueFactory(new PropertyValueFactory<>("group"));
|
||||||
|
|
||||||
|
|||||||
@@ -694,8 +694,8 @@ public abstract class ChannelConfigurationEditor extends Editor<Channel>
|
|||||||
mAutoAddTalkerAliasesCheckBox = new CheckBox("Auto-Add Talker Aliases");
|
mAutoAddTalkerAliasesCheckBox = new CheckBox("Auto-Add Talker Aliases");
|
||||||
mAutoAddTalkerAliasesCheckBox.setDisable(true);
|
mAutoAddTalkerAliasesCheckBox.setDisable(true);
|
||||||
mAutoAddTalkerAliasesCheckBox.setTooltip(new Tooltip("Adds decoded talker aliases as radio aliases in " +
|
mAutoAddTalkerAliasesCheckBox.setTooltip(new Tooltip("Adds decoded talker aliases as radio aliases in " +
|
||||||
"the Talker Alias group. Only radio aliases in that group are automatically renamed; existing " +
|
"the Talker Alias category. Only radio aliases in that category are automatically renamed; existing " +
|
||||||
"radio aliases outside the group are left unchanged. Move an alias out of the Talker Alias group " +
|
"radio aliases outside the category are left unchanged. Move an alias out of the Talker Alias category " +
|
||||||
"to preserve a custom name. Applies when the channel is (re)started."));
|
"to preserve a custom name. Applies when the channel is (re)started."));
|
||||||
mAutoAddTalkerAliasesCheckBox.setOnAction(event -> modifiedProperty().set(true));
|
mAutoAddTalkerAliasesCheckBox.setOnAction(event -> modifiedProperty().set(true));
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -225,7 +225,7 @@ public class StreamAliasSelectionEditor extends VBox
|
|||||||
aliasListNameColumn.setCellValueFactory(new PropertyValueFactory<>("aliasListName"));
|
aliasListNameColumn.setCellValueFactory(new PropertyValueFactory<>("aliasListName"));
|
||||||
|
|
||||||
TableColumn groupColumn = new TableColumn();
|
TableColumn groupColumn = new TableColumn();
|
||||||
groupColumn.setText("Group");
|
groupColumn.setText("Category");
|
||||||
groupColumn.setPrefWidth(150);
|
groupColumn.setPrefWidth(150);
|
||||||
groupColumn.setCellValueFactory(new PropertyValueFactory<>("group"));
|
groupColumn.setCellValueFactory(new PropertyValueFactory<>("group"));
|
||||||
|
|
||||||
@@ -270,7 +270,7 @@ public class StreamAliasSelectionEditor extends VBox
|
|||||||
aliasListNameColumn.setCellValueFactory(new PropertyValueFactory<>("aliasListName"));
|
aliasListNameColumn.setCellValueFactory(new PropertyValueFactory<>("aliasListName"));
|
||||||
|
|
||||||
TableColumn groupColumn = new TableColumn();
|
TableColumn groupColumn = new TableColumn();
|
||||||
groupColumn.setText("Group");
|
groupColumn.setText("Category");
|
||||||
groupColumn.setPrefWidth(150);
|
groupColumn.setPrefWidth(150);
|
||||||
groupColumn.setCellValueFactory(new PropertyValueFactory<>("group"));
|
groupColumn.setCellValueFactory(new PropertyValueFactory<>("group"));
|
||||||
|
|
||||||
|
|||||||
@@ -255,118 +255,6 @@ public class TalkerAliasAutoAdderTest
|
|||||||
assertNull(alias(RADIO), "local radio with the same value isn't aliased");
|
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
|
@Test
|
||||||
public void decide()
|
public void decide()
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user