mirror of
https://github.com/DSheirer/sdrtrunk.git
synced 2026-11-12 08:37:25 -05:00
#78 patch group alias and call event management. Adds new PatchGroupAlias which is a temporary alias group that is added to the alias list by the decoder state. The P25 decoder state maintains a mapping of patch group identifier to patched talkgroups and creates the patch group alias. This allows audio recording and audio streaming of patched talkgroups, according to the aliases corresponding to the group of patched aliases contained in the patch group alias.
Event logging is now pared down to only logging events when the internal patch group mapping is updated.
This commit is contained in:
@@ -52,7 +52,7 @@ public class Alias
|
||||
public Alias()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
public Alias( String name )
|
||||
{
|
||||
mName = name;
|
||||
|
||||
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;
|
||||
}
|
||||
}
|
||||
@@ -1,83 +1,89 @@
|
||||
/*******************************************************************************
|
||||
* SDR Trunk
|
||||
* Copyright (C) 2014 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.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
|
||||
{
|
||||
private String mTalkgroup;
|
||||
|
||||
public TalkgroupID()
|
||||
{
|
||||
}
|
||||
private String mTalkgroup;
|
||||
|
||||
@XmlAttribute
|
||||
public String getTalkgroup()
|
||||
{
|
||||
return mTalkgroup;
|
||||
}
|
||||
|
||||
public void setTalkgroup( String talkgroup )
|
||||
{
|
||||
mTalkgroup = talkgroup;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isValid()
|
||||
{
|
||||
return mTalkgroup != null;
|
||||
}
|
||||
|
||||
public String toString()
|
||||
{
|
||||
StringBuilder sb = new StringBuilder();
|
||||
|
||||
sb.append( "Talkgroup: " + mTalkgroup );
|
||||
|
||||
return sb.toString();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean matches( AliasID id )
|
||||
public TalkgroupID()
|
||||
{
|
||||
boolean retVal = false;
|
||||
|
||||
if( id instanceof TalkgroupID )
|
||||
{
|
||||
TalkgroupID tgid = (TalkgroupID)id;
|
||||
|
||||
//Create a pattern - replace * wildcards with regex single-char wildcard
|
||||
String pattern = mTalkgroup.replace( "*", ".?" );
|
||||
|
||||
retVal = tgid.getTalkgroup().matches( pattern );
|
||||
}
|
||||
|
||||
return retVal;
|
||||
//No arg JAXB constructor
|
||||
}
|
||||
|
||||
@Override
|
||||
public TalkgroupID(String talkgroup)
|
||||
{
|
||||
mTalkgroup = talkgroup;
|
||||
}
|
||||
|
||||
@XmlAttribute
|
||||
public String getTalkgroup()
|
||||
{
|
||||
return mTalkgroup;
|
||||
}
|
||||
|
||||
public void setTalkgroup(String talkgroup)
|
||||
{
|
||||
mTalkgroup = talkgroup;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isValid()
|
||||
{
|
||||
return mTalkgroup != null;
|
||||
}
|
||||
|
||||
public String toString()
|
||||
{
|
||||
StringBuilder sb = new StringBuilder();
|
||||
|
||||
sb.append("Talkgroup: " + mTalkgroup);
|
||||
|
||||
return sb.toString();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean matches(AliasID id)
|
||||
{
|
||||
boolean retVal = false;
|
||||
|
||||
if(id instanceof TalkgroupID)
|
||||
{
|
||||
TalkgroupID tgid = (TalkgroupID) id;
|
||||
|
||||
//Create a pattern - replace * wildcards with regex single-char wildcard
|
||||
String pattern = mTalkgroup.replace("*", ".?");
|
||||
|
||||
retVal = tgid.getTalkgroup().matches(pattern);
|
||||
}
|
||||
|
||||
return retVal;
|
||||
}
|
||||
|
||||
@Override
|
||||
public AliasIDType getType()
|
||||
{
|
||||
return AliasIDType.TALKGROUP;
|
||||
return AliasIDType.TALKGROUP;
|
||||
}
|
||||
}
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -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,15 +34,11 @@ 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();
|
||||
}
|
||||
|
||||
@@ -44,6 +46,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()
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user