mirror of
https://github.com/DSheirer/sdrtrunk.git
synced 2026-11-21 21:15:45 -05:00
Merge pull request #97 from DSheirer/#78_p25_patch_group_management
#78 p25 patch group management
This commit is contained in:
@@ -9,9 +9,12 @@
|
||||
- Updated alias list management of alias id values and wildcards. Weighting is now
|
||||
applied to each wildcard so that they can be ordered from most specific to least
|
||||
specific for lookup value matching purposes.
|
||||
- Added handling for Motorola-specific P25 patch messages
|
||||
- Added handling for Motorola-specific P25 patch messages and auto-generation of
|
||||
patch group aliases that roll-up aliases from each patched talkgroup to support
|
||||
audio recording and streaming of patch calls according to the identifiers and
|
||||
actions defined for each of the patched talkgroups.
|
||||
- Updated airspy controller for airspy-mini specific sample rate handling.
|
||||
- New remez filter designer tool and internal usage
|
||||
- New developer remez filter designer tool and internal usage
|
||||
|
||||
0.2.0 20160329
|
||||
- Major overhaul of underlying processing chain and extensive updates to all
|
||||
|
||||
214
src/alias/PatchGroupAlias.java
Normal file
214
src/alias/PatchGroupAlias.java
Normal file
@@ -0,0 +1,214 @@
|
||||
/*******************************************************************************
|
||||
* sdrtrunk
|
||||
* Copyright (C) 2014-2017 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 alias;
|
||||
|
||||
import alias.action.AliasAction;
|
||||
import alias.id.AliasID;
|
||||
import alias.id.AliasIDType;
|
||||
import alias.id.broadcast.BroadcastChannel;
|
||||
import alias.id.priority.Priority;
|
||||
import alias.id.talkgroup.TalkgroupID;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class PatchGroupAlias extends Alias
|
||||
{
|
||||
private List<Alias> mPatchedAliases = new ArrayList<>();
|
||||
|
||||
/**
|
||||
* Patch group alias is a single alias for a group of aliases that are temporarily patched together. This will
|
||||
* normally be used for patched talkgroups, but could be used with any type of alias identifiers that can be
|
||||
* temporarily joined to form a patch group.
|
||||
*
|
||||
* Alias properties such as recordable, streamable and call priority are an aggregation from the set of patched
|
||||
* aliases contained in this patch group alias and where applicable, return the highest value/priority from the
|
||||
* group of patched aliases.
|
||||
*/
|
||||
public PatchGroupAlias()
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* List of patched aliases contained in this patch group
|
||||
*/
|
||||
public List<Alias> getPatchedAliases()
|
||||
{
|
||||
return mPatchedAliases;
|
||||
}
|
||||
|
||||
/**
|
||||
* Removes/clears all patched aliases from this patch alias group
|
||||
*/
|
||||
public void clearPatchedAliases()
|
||||
{
|
||||
mPatchedAliases.clear();
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds the patched alias to this patch alias group
|
||||
*/
|
||||
public void addPatchedAlias(Alias alias)
|
||||
{
|
||||
mPatchedAliases.add(alias);
|
||||
}
|
||||
|
||||
/**
|
||||
* Removes the patched alias from this patch alias group
|
||||
*/
|
||||
public void removePatchedAlias(Alias alias)
|
||||
{
|
||||
mPatchedAliases.remove(alias);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName()
|
||||
{
|
||||
if(getId().size() > 0)
|
||||
{
|
||||
for(AliasID id: getId())
|
||||
{
|
||||
if(id.getType() == AliasIDType.TALKGROUP)
|
||||
{
|
||||
return "PATCH:" + ((TalkgroupID)id).getTalkgroup();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return "PATCH";
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<AliasAction> getAction()
|
||||
{
|
||||
List<AliasAction> aliasActions = new ArrayList<>();
|
||||
|
||||
for(Alias alias: mPatchedAliases)
|
||||
{
|
||||
aliasActions.addAll(alias.getAction());
|
||||
}
|
||||
|
||||
return aliasActions;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasActions()
|
||||
{
|
||||
for(Alias alias: mPatchedAliases)
|
||||
{
|
||||
if(alias.hasActions())
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getCallPriority()
|
||||
{
|
||||
int highestPriority = Priority.DEFAULT_PRIORITY;
|
||||
|
||||
for(Alias alias: mPatchedAliases)
|
||||
{
|
||||
if(alias.getCallPriority() < highestPriority)
|
||||
{
|
||||
highestPriority = alias.getCallPriority();
|
||||
}
|
||||
}
|
||||
|
||||
return highestPriority;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasCallPriority()
|
||||
{
|
||||
for(Alias alias: mPatchedAliases)
|
||||
{
|
||||
if(alias.hasCallPriority())
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isRecordable()
|
||||
{
|
||||
for(Alias alias: mPatchedAliases)
|
||||
{
|
||||
if(alias.isRecordable())
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isStreamable()
|
||||
{
|
||||
for(Alias alias: mPatchedAliases)
|
||||
{
|
||||
if(alias.isStreamable())
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<BroadcastChannel> getBroadcastChannels()
|
||||
{
|
||||
List<BroadcastChannel> broadcastChannels = new ArrayList<>();
|
||||
|
||||
for(Alias alias: mPatchedAliases)
|
||||
{
|
||||
for(BroadcastChannel broadcastChannel: alias.getBroadcastChannels())
|
||||
{
|
||||
if(!broadcastChannels.contains(broadcastChannel))
|
||||
{
|
||||
broadcastChannels.add(broadcastChannel);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return broadcastChannels;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasBroadcastChannel(String channel)
|
||||
{
|
||||
for(Alias alias: mPatchedAliases)
|
||||
{
|
||||
if(alias.hasBroadcastChannel(channel))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -17,11 +17,11 @@
|
||||
******************************************************************************/
|
||||
package alias.id.talkgroup;
|
||||
|
||||
import javax.xml.bind.annotation.XmlAttribute;
|
||||
|
||||
import alias.id.AliasID;
|
||||
import alias.id.AliasIDType;
|
||||
|
||||
import javax.xml.bind.annotation.XmlAttribute;
|
||||
|
||||
|
||||
public class TalkgroupID extends AliasID
|
||||
{
|
||||
@@ -29,6 +29,12 @@ public class TalkgroupID extends AliasID
|
||||
|
||||
public TalkgroupID()
|
||||
{
|
||||
//No arg JAXB constructor
|
||||
}
|
||||
|
||||
public TalkgroupID(String talkgroup)
|
||||
{
|
||||
mTalkgroup = talkgroup;
|
||||
}
|
||||
|
||||
@XmlAttribute
|
||||
|
||||
@@ -19,6 +19,8 @@ package module.decode.p25;
|
||||
|
||||
import alias.Alias;
|
||||
import alias.AliasList;
|
||||
import alias.PatchGroupAlias;
|
||||
import alias.id.talkgroup.TalkgroupID;
|
||||
import audio.metadata.Metadata;
|
||||
import audio.metadata.MetadataType;
|
||||
import controller.channel.Channel.ChannelType;
|
||||
@@ -160,6 +162,7 @@ public class P25DecoderState extends DecoderState
|
||||
private Map<Integer, IdentifierUpdate> mBands = new HashMap<>();
|
||||
private Map<String, Long> mRegistrations = new HashMap<>();
|
||||
private Map<String, IAdjacentSite> mNeighborMap = new HashMap<>();
|
||||
private Map<String, List<String>> mPatchGroupMap = new HashMap<>();
|
||||
|
||||
private String mLastCommandEventID;
|
||||
private String mLastPageEventID;
|
||||
@@ -2778,32 +2781,34 @@ public class P25DecoderState extends DecoderState
|
||||
case PATCH_GROUP_ADD:
|
||||
PatchGroupAdd pga = (PatchGroupAdd) tsbk;
|
||||
|
||||
if(addPatchGroup(pga.getPatchGroupAddress(), pga.getPatchedTalkgroups()))
|
||||
{
|
||||
StringBuilder sb = new StringBuilder();
|
||||
|
||||
sb.append("PATCH GROUP:").append(pga.getPatchGroupAddress());
|
||||
sb.append(" 1:").append(pga.getGroupAddress1());
|
||||
sb.append(" 2:").append(pga.getGroupAddress2());
|
||||
sb.append(" 3:").append(pga.getGroupAddress3());
|
||||
sb.append(" ").append(pga.getPatchedTalkgroups());
|
||||
|
||||
broadcast(new P25CallEvent.Builder(CallEventType.PATCH_GROUP_ADD)
|
||||
.aliasList(getAliasList())
|
||||
.details(sb.toString())
|
||||
.build());
|
||||
}
|
||||
break;
|
||||
case PATCH_GROUP_DELETE:
|
||||
PatchGroupDelete pgd = (PatchGroupDelete) tsbk;
|
||||
|
||||
if(removePatchGroup(pgd.getPatchGroupAddress(), pgd.getPatchedTalkgroups()))
|
||||
{
|
||||
StringBuilder sbpgd = new StringBuilder();
|
||||
|
||||
sbpgd.append("PATCH GROUP:").append(pgd.getPatchGroupAddress());
|
||||
sbpgd.append(" 1:").append(pgd.getGroupAddress1());
|
||||
sbpgd.append(" 2:").append(pgd.getGroupAddress2());
|
||||
sbpgd.append(" 3:").append(pgd.getGroupAddress3());
|
||||
sbpgd.append(" ").append(pgd.getPatchedTalkgroups());
|
||||
|
||||
broadcast(new P25CallEvent.Builder(CallEventType.PATCH_GROUP_DELETE)
|
||||
.aliasList(getAliasList())
|
||||
.details(sbpgd.toString())
|
||||
.build());
|
||||
}
|
||||
break;
|
||||
case CCH_PLANNED_SHUTDOWN:
|
||||
if(!mControlChannelShutdownLogged)
|
||||
@@ -2818,6 +2823,145 @@ public class P25DecoderState extends DecoderState
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a new patch group or updates an existing patch group with the patched talkgroup entries.
|
||||
*
|
||||
* @param patchGroupID for the patch group
|
||||
* @param talkgroupsToAdd to include in the patch group
|
||||
* @return true if the patch group or the patch group map was updated
|
||||
*/
|
||||
private boolean addPatchGroup(String patchGroupID, List<String> talkgroupsToAdd)
|
||||
{
|
||||
boolean updated = false;
|
||||
|
||||
if(patchGroupID != null && !talkgroupsToAdd.isEmpty())
|
||||
{
|
||||
List<String> patchedTalkgroups = mPatchGroupMap.get(patchGroupID);
|
||||
|
||||
if(patchedTalkgroups == null)
|
||||
{
|
||||
patchedTalkgroups = new ArrayList<>();
|
||||
}
|
||||
|
||||
for(String talkgroupToAdd: talkgroupsToAdd)
|
||||
{
|
||||
if(!patchedTalkgroups.contains(talkgroupToAdd))
|
||||
{
|
||||
patchedTalkgroups.add(talkgroupToAdd);
|
||||
updated = true;
|
||||
}
|
||||
}
|
||||
|
||||
if(updated)
|
||||
{
|
||||
mPatchGroupMap.put(patchGroupID, patchedTalkgroups);
|
||||
updatePatchAlias(patchGroupID, patchedTalkgroups);
|
||||
}
|
||||
}
|
||||
|
||||
return updated;
|
||||
}
|
||||
|
||||
/**
|
||||
* Removes the patched talkgroups from the patch group and removes the patch group from the patch group map if
|
||||
* there are no more patched talkgroups in the patch group.
|
||||
*
|
||||
* @param patchGroupID for the patch group
|
||||
* @param talkgroupsToRemove to remove from the patch group
|
||||
* @return true if the patch group or the patch group map was updated
|
||||
*/
|
||||
private boolean removePatchGroup(String patchGroupID, List<String> talkgroupsToRemove)
|
||||
{
|
||||
boolean updated = false;
|
||||
|
||||
if(patchGroupID != null && !talkgroupsToRemove.isEmpty())
|
||||
{
|
||||
List<String> patchedTalkgroups = mPatchGroupMap.get(patchGroupID);
|
||||
|
||||
if(patchedTalkgroups != null)
|
||||
{
|
||||
for(String talkgroupToRemove: talkgroupsToRemove)
|
||||
{
|
||||
if(patchedTalkgroups.contains(talkgroupToRemove))
|
||||
{
|
||||
patchedTalkgroups.remove(talkgroupToRemove);
|
||||
updated = true;
|
||||
}
|
||||
}
|
||||
|
||||
if(patchedTalkgroups.isEmpty())
|
||||
{
|
||||
mPatchGroupMap.remove(patchGroupID);
|
||||
removePatchGroupAlias(patchGroupID);
|
||||
updated = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
updatePatchAlias(patchGroupID, patchedTalkgroups);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return updated;
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds/updates a patch group alias to the alias list containing aliases for each of the patched talkgroups
|
||||
*
|
||||
* @param patchGroupID for the patch group
|
||||
* @param patchedTalkgroups containing the talkgroup IDs for each of the patched talkgroups
|
||||
*/
|
||||
private void updatePatchAlias(String patchGroupID, List<String> patchedTalkgroups)
|
||||
{
|
||||
PatchGroupAlias patchGroupAlias = null;
|
||||
|
||||
//Check for an existing alias for the patch talkgroup
|
||||
Alias alias = getAliasList().getTalkgroupAlias(patchGroupID);
|
||||
|
||||
if(alias instanceof PatchGroupAlias)
|
||||
{
|
||||
patchGroupAlias = (PatchGroupAlias)alias;
|
||||
}
|
||||
else if(alias != null)
|
||||
{
|
||||
//If the talkgroup is already aliased to a non-patch group, do nothing
|
||||
}
|
||||
else
|
||||
{
|
||||
patchGroupAlias = new PatchGroupAlias();
|
||||
patchGroupAlias.addAliasID(new TalkgroupID(patchGroupID));
|
||||
getAliasList().addAlias(patchGroupAlias);
|
||||
}
|
||||
|
||||
if(patchGroupAlias != null)
|
||||
{
|
||||
patchGroupAlias.clearPatchedAliases();
|
||||
|
||||
for(String patchedTalkgroup: patchedTalkgroups)
|
||||
{
|
||||
Alias patchedAlias = getAliasList().getTalkgroupAlias(patchedTalkgroup);
|
||||
|
||||
if(patchedAlias != null)
|
||||
{
|
||||
patchGroupAlias.addPatchedAlias(patchedAlias);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Removes the temporary patch group alias from the alias list
|
||||
*/
|
||||
private void removePatchGroupAlias(String patchGroupID)
|
||||
{
|
||||
Alias alias = getAliasList().getTalkgroupAlias(patchGroupID);
|
||||
|
||||
if(alias instanceof PatchGroupAlias)
|
||||
{
|
||||
getAliasList().removeAlias(alias);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Process a traffic channel allocation message
|
||||
*/
|
||||
|
||||
@@ -4,6 +4,10 @@ import module.decode.p25.reference.DataUnitID;
|
||||
import alias.AliasList;
|
||||
import bits.BinaryMessage;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
public abstract class PatchGroup extends MotorolaTSBKMessage
|
||||
{
|
||||
public static final int[] PATCH_GROUP_ADDRESS = { 80,81,82,83,84,85,86,87,
|
||||
@@ -15,6 +19,8 @@ public abstract class PatchGroup extends MotorolaTSBKMessage
|
||||
public static final int[] GROUP_ADDRESS_3 = { 128,129,130,131,132,133,134,
|
||||
135,136,137,138,139,140,141,142,143 };
|
||||
|
||||
private List<String> mPatchedTalkgroups;
|
||||
|
||||
public PatchGroup( BinaryMessage message, DataUnitID duid,
|
||||
AliasList aliasList )
|
||||
{
|
||||
@@ -28,14 +34,10 @@ public abstract class PatchGroup extends MotorolaTSBKMessage
|
||||
|
||||
sb.append( getMessageStub() );
|
||||
|
||||
sb.append( " PATCH GROUP:" );
|
||||
sb.append( " " );
|
||||
sb.append( getPatchGroupAddress() );
|
||||
sb.append( " GRP1:" );
|
||||
sb.append( getGroupAddress1() );
|
||||
sb.append( " GRP2:" );
|
||||
sb.append( getGroupAddress2() );
|
||||
sb.append( " GRP3:" );
|
||||
sb.append( getGroupAddress3() );
|
||||
sb.append(" ");
|
||||
sb.append(getPatchedTalkgroups());
|
||||
|
||||
return sb.toString();
|
||||
}
|
||||
@@ -45,6 +47,35 @@ public abstract class PatchGroup extends MotorolaTSBKMessage
|
||||
return mMessage.getHex( PATCH_GROUP_ADDRESS, 4 );
|
||||
}
|
||||
|
||||
/**
|
||||
* List of de-deplicated patched talkgroups contained in this message
|
||||
*/
|
||||
public List<String> getPatchedTalkgroups()
|
||||
{
|
||||
if(mPatchedTalkgroups == null)
|
||||
{
|
||||
mPatchedTalkgroups = new ArrayList<>();
|
||||
|
||||
mPatchedTalkgroups.add(getGroupAddress1());
|
||||
|
||||
String group2 = getGroupAddress2();
|
||||
|
||||
if(!mPatchedTalkgroups.contains(group2))
|
||||
{
|
||||
mPatchedTalkgroups.add(group2);
|
||||
}
|
||||
|
||||
String group3 = getGroupAddress3();
|
||||
|
||||
if(!mPatchedTalkgroups.contains(group3))
|
||||
{
|
||||
mPatchedTalkgroups.add(group3);
|
||||
}
|
||||
}
|
||||
|
||||
return mPatchedTalkgroups;
|
||||
}
|
||||
|
||||
public String getGroupAddress1()
|
||||
{
|
||||
return mMessage.getHex( GROUP_ADDRESS_1, 4 );
|
||||
|
||||
Reference in New Issue
Block a user