#1914 P25 P1 & P2 Talker Alias Support for Motorola and L3Harris. Talker 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 <dsheirer@github.com>
This commit is contained in:
Denny Sheirer
2024-10-05 03:47:18 -04:00
committed by GitHub
parent 600db3fb8a
commit 3c8cd0386d
42 changed files with 2047 additions and 445 deletions

View File

@@ -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();
}
}

View File

@@ -63,13 +63,13 @@ public class PatchGroupManager
if(trackers.isEmpty())
{
sb.append("None");
sb.append(" None\n");
}
else
{
for(PatchGroupTracker tracker : trackers)
{
sb.append(" ").append(tracker.mPatchGroupIdentifier).append("\n");
sb.append(" ").append(tracker.mPatchGroupIdentifier).append("\n");
}
}