-
Notifications
You must be signed in to change notification settings - Fork 260
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
#1914 P25 P1 & P2 Talker Alias Support for Motorola and L3Harris. Tal…
…ker alias manager caches aliases and applies to future events. Active (cached) talker aliases now listed in the channel Details tab. Enables multi-select in message viewer for all supported protocols. Note: decoding of Motorola's talker alias format not yet implemented - only recognition and reassembly of the encoded sequence is currently supported. (#2001) Co-authored-by: Dennis Sheirer <[email protected]>
- Loading branch information
Showing
42 changed files
with
2,047 additions
and
445 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
145 changes: 145 additions & 0 deletions
145
src/main/java/io/github/dsheirer/identifier/alias/TalkerAliasManager.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,145 @@ | ||
/* | ||
* ***************************************************************************** | ||
* Copyright (C) 2014-2024 Dennis Sheirer | ||
* | ||
* This program is free software: you can redistribute it and/or modify | ||
* it under the terms of the GNU General Public License as published by | ||
* the Free Software Foundation, either version 3 of the License, or | ||
* (at your option) any later version. | ||
* | ||
* This program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU General Public License | ||
* along with this program. If not, see <http://www.gnu.org/licenses/> | ||
* **************************************************************************** | ||
*/ | ||
|
||
package io.github.dsheirer.identifier.alias; | ||
|
||
import io.github.dsheirer.identifier.Identifier; | ||
import io.github.dsheirer.identifier.IdentifierCollection; | ||
import io.github.dsheirer.identifier.MutableIdentifierCollection; | ||
import io.github.dsheirer.identifier.Role; | ||
import io.github.dsheirer.identifier.radio.RadioIdentifier; | ||
import java.util.ArrayList; | ||
import java.util.Collections; | ||
import java.util.List; | ||
import java.util.Map; | ||
import java.util.concurrent.ConcurrentHashMap; | ||
|
||
/** | ||
* Talker alias cache manager. Collects observed talker aliases and inserts them into an identifier collection when | ||
* the corresponding radio is active in a FROM role. | ||
* | ||
* This implementation is thread safe and is intended to be used across control and traffic channels. | ||
*/ | ||
public class TalkerAliasManager | ||
{ | ||
private Map<Integer,TalkerAliasIdentifier> mAliasMap = new ConcurrentHashMap<>(); | ||
|
||
/** | ||
* Constructs an instance | ||
*/ | ||
public TalkerAliasManager() | ||
{ | ||
} | ||
|
||
/** | ||
* Updates the alias for the | ||
* @param identifier | ||
* @param alias | ||
*/ | ||
public void update(RadioIdentifier identifier, TalkerAliasIdentifier alias) | ||
{ | ||
if(identifier.getRole() == Role.FROM) | ||
{ | ||
mAliasMap.put(identifier.getValue(), alias); | ||
} | ||
} | ||
|
||
/** | ||
* Indicates if an alias exists for the identifier | ||
* @param radioIdentifier to test | ||
* @return true if an alias exists. | ||
*/ | ||
public boolean hasAlias(RadioIdentifier radioIdentifier) | ||
{ | ||
return mAliasMap.containsKey(radioIdentifier.getValue()); | ||
} | ||
|
||
/** | ||
* Enriches the immutable identifier collection by detecting a radio identifier with the FROM role, lookup a | ||
* matching alias, and insert the alias into a new mutable identifier collection. | ||
* @param originalIC to enrich | ||
* @return enriched identifier collection or the original identifier collection if we don't have an alias. | ||
*/ | ||
public synchronized IdentifierCollection enrich(IdentifierCollection originalIC) | ||
{ | ||
Identifier fromRadio = originalIC.getFromIdentifier(); | ||
|
||
if(fromRadio instanceof RadioIdentifier rid) | ||
{ | ||
TalkerAliasIdentifier alias = mAliasMap.get(rid.getValue()); | ||
|
||
if(alias != null) | ||
{ | ||
MutableIdentifierCollection enrichedIC = new MutableIdentifierCollection(originalIC.getIdentifiers()); | ||
enrichedIC.update(alias); | ||
return enrichedIC; | ||
} | ||
} | ||
|
||
return originalIC; | ||
} | ||
|
||
/** | ||
* Enriches the mutable identifier collection by detecting a radio identifier with the FROM role, lookup a | ||
* matching alias, and insert the alias into the mutable identifier collection argument. | ||
* @param mic to enrich | ||
*/ | ||
public synchronized void enrichMutable(MutableIdentifierCollection mic) | ||
{ | ||
Identifier fromRadio = mic.getFromIdentifier(); | ||
|
||
if(fromRadio instanceof RadioIdentifier rid) | ||
{ | ||
TalkerAliasIdentifier alias = mAliasMap.get(rid.getValue()); | ||
|
||
if(alias != null) | ||
{ | ||
mic.update(alias); | ||
} | ||
} | ||
} | ||
|
||
/** | ||
* Creates a summary listing of talker aliases | ||
* @return summary. | ||
*/ | ||
public synchronized String getAliasSummary() | ||
{ | ||
StringBuilder sb = new StringBuilder(); | ||
sb.append("Active System Radio Aliases\n"); | ||
List<Integer> radios = new ArrayList<>(mAliasMap.keySet()); | ||
|
||
if(radios.size() > 0) | ||
{ | ||
Collections.sort(radios); | ||
for(Integer radio : radios) | ||
{ | ||
sb.append(" ").append(radio); | ||
sb.append("\t").append(mAliasMap.get(radio).getValue()); | ||
sb.append("\n"); | ||
} | ||
} | ||
else | ||
{ | ||
sb.append(" None\n"); | ||
} | ||
|
||
return sb.toString(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.