mirror of
https://github.com/DSheirer/sdrtrunk.git
synced 2026-11-12 16:47:31 -05:00
Identifier Framework and Message/Event Processing Overhaul (#455)
* WIP on new P25 message framer. * WIP on new P25 message framer. * Adds new 1/2 and 3/4 rate trellis decoders. Still trying to chase down why there is a sync pattern mismatch in the NID buffer queue. * WIP - new p25 message framer works correctly now. PDU's are dectected and decoded using the 1/2 and 3/4 rate trellis decoders. Packet Sequences are assembled. Need to add a new packet sequence message factory that can detect Motorola Auto Registration Service (ARS) formatted UDP/ID packets and SNDCP command packets. * WIP - removes nullify on channel results queue. * WIP - updates message framer for TSBK 1/2/3 processing. * WIP removing P25 sync pattern and nid bits from all message parsers. * WIP - merges identifier framework branch changes into this branch. * WIP on updating link control words to new format and identifier framework. * WIP - implements rest of link control words for extended formats * WIP - initial work on ISP/OSP TSBK message restructuring. * WIP - adds more TSBK ISP and OSP messages * WIP - finished updating most of the TSBK ISP and OSP messages. Converted all messages to no longer include the NID (nac + dataunitID) so that each message can simply hold the parsed values. Removed AliasList as an argument to each message and updated all messges to use the new IIdentifer and IAPCO25Channel interfaces. Removed legacy TDU and LDU link control messages and replaced with a single LinkControlWord class hierarchy. P25 decoder state is not yet updated for the new message structure. PDU message parsing is not fully implemented. * WIP - adds some Multi-Block trunking control messages with Alternate and Unconfirmed formats. * WIP - Fully implements AMBTC and UMBTC PDU message parsers. Some package restructuring. * WIP - Resolves Link control parsing in LDU1 and 2 messages. * WIP - finishes updating TSBK and Link Control messages. Adds support for moto link control messages for patch groups. * WIP - finishes updating TSBK and Link Control messages. Adds support for moto link control messages for patch groups. Adds support for moto ARS service, IPV4 decoding, and UDP/IP packets. * WIP - finishes SNDCP packet data with header parsing. Compressed IP or UDP headers are not yet supported, but are logged as such. * WIP - converts all talkgroup identifiers to integers and updates alias list to create a per-protocol map of talkgroup id's to alias. Inserts a legacy talkgroup (ltr, p25, passport, mpt1327, mdc, etc.) conversion utility to convert existing legacy (string) talkgroups to new integer talkgroup format. Creates an audio packet manager to insert metadata into audio packets before streaming packets for playback, recording, and/or streaming. Creates identifier collection to manage current identifiers in each of the channel and decoder states. Creates simplified channel metadata to maintain the now playing display. Moves channel attributes (alias list, system, site, name) as configuration identifiers in the channel state. Many other refactoring and updates. * WIP - numerous updates to push use of identifier collection throughout the system. Updates the channel metadata and audio packet processing logic. Implements a large portion of the P25 decode state processing. Updates traffic channel management. Adds user preferences for timestamp and identifier formatting, however doesn't add a user interface yet. * WIP - initial implementation of user preferences editor window. * WIP - updates preferences editor window to close and dispose window but retain javafx event thread running. * WIP - fully updates p25 decoder state and traffic channel processing to use the new identifier framework. Cleans up channel event processing and removes channel model as the sole broadcaster of channel events. Channel processing manager now listens for all start/stop events and requestors dispatch event directly to the channel processing manager. Resolves issue in airspy that was causing user interface to lock-up. The issue appears to occur when the dongle is plugged into a usb port that can't fully support the data rate. sdrtrunk now recognizes these errors and warns the user that they should use another usb port. * WIP - updates alias action manager and adds new talkgroup range alias identifier. Updates playlist to incorporate a version number so that the playlist updater only runs when needed, to update a playlist to the correct version format. Updates user preferences to use the google event bus to broadcast preference update notifications to remove the need for listeners to register directly on the user preferences instance. * WIP - updates alias id editors to flag invalid values and moves legacy alias ids to legacy package. Updates event logging configuration to add traffic channel decode events and decoded message logging. Removes binary message logging since that is now replaced with demodulated bitstream recording. * Removes system properties from user preferences. Preferences are stored in the OS-dependent settings store (windows - registry) * Updates MapService to use new PlottableDecodeEvent instead of monitoring all of the decoded messages. Updates Fleetsync decoder and related messages to identifier framework. * Updates LTR-Net, Fleetsync and LJ1200 decoders to new identifier framework and adds support for user preferences for formatting of LTR-Net and fleetsync talkgroup identifiers. Breaks LTR-Net messages into various message types and uses a new message factory. Removes alias list from message processing for ltr-net, fleetsync and lj1200. * Updates LTR-Standard messages to Identifier framework. * Removes Plottable and IPlottable from codebase. * wip * WIP on MPT-1327 messages. * Updates MPT1327 decoder to identifier framework and new traffic channel manager. This decoder still needs to be updated with a new message parser factory and a sync detector like what is now used for P25. * Updates MDC1200 decoder and message to identifier framework. * Updates Tait1200 and Passport decoders to identifier framework. * Merges changes from master branch. * Removes legacy alias support classes. Updates passport message processor to only pass valid messages. Adds support to playlist updater for converting passport mobile ids to become passport talkgroup values. * Updates P25 decoder state and channel state to better track allocated traffic channels. Resolves issue in timestamp manager for trackig message timestamps. Resolves issue in airspy tuner that was causing the tuner to stop sending samples to the application. * Update P25 Decoder state to process SNDCP management messages and PDU messages. Updates P25 activity summary to display network and site details. Resolves issue with overlay panel that prevented enabled channels from rendering correctly when zoomed in. * Creates a new FilePreferences as part of the user preferences to begin the transition of SystemProperties over to user preferences and consolidate file preferences in one location. Updates playlist manager to use the new file preferences and to use default.xml as the new default playlist name, following conversion of a playlist_v2.xml format to the new format. In the near future, the user will be able to edit file locations and to create/use other playlists. Resolved an issue with all decoder states where not all identifiers were being included in decode events.
This commit is contained in:
@@ -1,111 +0,0 @@
|
||||
/*******************************************************************************
|
||||
* 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 io.github.dsheirer.channel.metadata;
|
||||
|
||||
import io.github.dsheirer.alias.Alias;
|
||||
|
||||
public class AliasedIdentifier
|
||||
{
|
||||
private String mIdentifier;
|
||||
private Alias mAlias;
|
||||
|
||||
/**
|
||||
* Identifier and corresponding optional alias
|
||||
*/
|
||||
public AliasedIdentifier()
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* Resets alias and value to null
|
||||
*
|
||||
* Package Private - should only be changed within MutableMetadata
|
||||
*/
|
||||
void reset()
|
||||
{
|
||||
mIdentifier = null;
|
||||
mAlias = null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Identifier
|
||||
*/
|
||||
public String getIdentifier()
|
||||
{
|
||||
return mIdentifier;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the identifier to the argument value
|
||||
*
|
||||
* Package Private - should only be changed within MutableMetadata
|
||||
*/
|
||||
void setIdentifier(String identifier)
|
||||
{
|
||||
mIdentifier = identifier;
|
||||
}
|
||||
|
||||
/**
|
||||
* Indicates if there is a non-null, non-empty identifier
|
||||
*/
|
||||
public boolean hasIdentifier()
|
||||
{
|
||||
return mIdentifier != null && !mIdentifier.isEmpty();
|
||||
}
|
||||
|
||||
/**
|
||||
* Alias for the identifier.
|
||||
*/
|
||||
public Alias getAlias()
|
||||
{
|
||||
return mAlias;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the alias to the argument
|
||||
*
|
||||
* Package Private - should only be changed within MutableMetadata
|
||||
*/
|
||||
void setAlias(Alias alias)
|
||||
{
|
||||
mAlias = alias;
|
||||
}
|
||||
|
||||
/**
|
||||
* Indicates if there is an alias corresponding to the identifier
|
||||
*/
|
||||
public boolean hasAlias()
|
||||
{
|
||||
return mAlias != null;
|
||||
}
|
||||
|
||||
public AliasedIdentifier copyOf()
|
||||
{
|
||||
AliasedIdentifier copy = new AliasedIdentifier();
|
||||
|
||||
copy.setAlias(mAlias);
|
||||
|
||||
if(mIdentifier != null)
|
||||
{
|
||||
copy.setIdentifier(new String(mIdentifier));
|
||||
}
|
||||
|
||||
return copy;
|
||||
}
|
||||
}
|
||||
@@ -1,101 +0,0 @@
|
||||
/*******************************************************************************
|
||||
* 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 io.github.dsheirer.channel.metadata;
|
||||
|
||||
import io.github.dsheirer.alias.Alias;
|
||||
import io.github.dsheirer.alias.AliasList;
|
||||
import io.github.dsheirer.alias.id.AliasIDType;
|
||||
import io.github.dsheirer.sample.Listener;
|
||||
|
||||
import static io.github.dsheirer.alias.id.AliasIDType.LTR_NET_UID;
|
||||
import static io.github.dsheirer.alias.id.AliasIDType.STATUS;
|
||||
|
||||
|
||||
public class AliasedIntegerAttributeMonitor extends AttributeMonitor<Integer>
|
||||
{
|
||||
private static final AliasIDType[] VALID_ID_TYPES = {STATUS, LTR_NET_UID};
|
||||
|
||||
private AliasList mAliasList;
|
||||
private AliasIDType mAliasIDType;
|
||||
|
||||
/**
|
||||
* Provides monitoring of a String attribute's values with occurrence heuristics enabled and alias lookup with each
|
||||
* change in the attribute's value.
|
||||
*
|
||||
* @param attribute to monitor
|
||||
* @param listener to receive change requests
|
||||
* @param aliasList to lookup alias from
|
||||
* @param aliasIDType to determine correct alias lookup method in alias list
|
||||
*/
|
||||
public AliasedIntegerAttributeMonitor(Attribute attribute, Listener<AttributeChangeRequest> listener, AliasList aliasList,
|
||||
AliasIDType aliasIDType)
|
||||
{
|
||||
super(attribute, listener);
|
||||
|
||||
if(!isValidIDType(aliasIDType))
|
||||
{
|
||||
throw new IllegalArgumentException("Alias ID Type [" + aliasIDType.name() + "] is not supported");
|
||||
}
|
||||
mAliasList = aliasList;
|
||||
mAliasIDType = aliasIDType;
|
||||
}
|
||||
|
||||
/**
|
||||
* Indicates if the alias ID type is a supported/valid type for this monitor.
|
||||
*/
|
||||
public static boolean isValidIDType(AliasIDType type)
|
||||
{
|
||||
for(AliasIDType validType: VALID_ID_TYPES)
|
||||
{
|
||||
if(type == validType)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Lookup of the alias that corresponds to the value's alias ID type
|
||||
*/
|
||||
@Override
|
||||
protected Alias getAlias()
|
||||
{
|
||||
Alias alias = null;
|
||||
|
||||
if(mAliasList != null)
|
||||
{
|
||||
if(hasValue())
|
||||
{
|
||||
switch(mAliasIDType)
|
||||
{
|
||||
case STATUS:
|
||||
alias = mAliasList.getStatus(getValue());
|
||||
break;
|
||||
case LTR_NET_UID:
|
||||
alias = mAliasList.getUniqueID(getValue());
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return alias;
|
||||
}
|
||||
}
|
||||
@@ -1,121 +0,0 @@
|
||||
/*******************************************************************************
|
||||
* 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 io.github.dsheirer.channel.metadata;
|
||||
|
||||
import io.github.dsheirer.alias.Alias;
|
||||
import io.github.dsheirer.alias.AliasList;
|
||||
import io.github.dsheirer.alias.id.AliasIDType;
|
||||
import io.github.dsheirer.sample.Listener;
|
||||
|
||||
import static io.github.dsheirer.alias.id.AliasIDType.ESN;
|
||||
import static io.github.dsheirer.alias.id.AliasIDType.FLEETSYNC;
|
||||
import static io.github.dsheirer.alias.id.AliasIDType.MDC1200;
|
||||
import static io.github.dsheirer.alias.id.AliasIDType.MIN;
|
||||
import static io.github.dsheirer.alias.id.AliasIDType.MPT1327;
|
||||
import static io.github.dsheirer.alias.id.AliasIDType.SITE;
|
||||
import static io.github.dsheirer.alias.id.AliasIDType.TALKGROUP;
|
||||
|
||||
|
||||
public class AliasedStringAttributeMonitor extends AttributeMonitor<String>
|
||||
{
|
||||
private static final AliasIDType[] VALID_ID_TYPES = {ESN, FLEETSYNC, MDC1200, MIN, MPT1327, SITE, TALKGROUP};
|
||||
|
||||
private AliasList mAliasList;
|
||||
private AliasIDType mAliasIDType;
|
||||
|
||||
/**
|
||||
* Provides monitoring of a String attribute's values with occurrence heuristics enabled and alias lookup with each
|
||||
* change in the attribute's value.
|
||||
*
|
||||
* @param attribute to monitor
|
||||
* @param listener to receive change requests
|
||||
* @param aliasList to lookup alias from
|
||||
* @param aliasIDType to determine correct alias lookup method in alias list
|
||||
*/
|
||||
public AliasedStringAttributeMonitor(Attribute attribute, Listener<AttributeChangeRequest> listener, AliasList aliasList,
|
||||
AliasIDType aliasIDType)
|
||||
{
|
||||
super(attribute, listener);
|
||||
|
||||
if(!isValidIDType(aliasIDType))
|
||||
{
|
||||
throw new IllegalArgumentException("Alias ID Type [" + aliasIDType.name() + "] is not supported");
|
||||
}
|
||||
mAliasList = aliasList;
|
||||
mAliasIDType = aliasIDType;
|
||||
}
|
||||
|
||||
/**
|
||||
* Indicates if the alias ID type is a supported/valid type for this monitor.
|
||||
*/
|
||||
public static boolean isValidIDType(AliasIDType type)
|
||||
{
|
||||
for(AliasIDType validType: VALID_ID_TYPES)
|
||||
{
|
||||
if(type == validType)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Lookup of the alias that corresponds to the value's alias ID type
|
||||
*/
|
||||
@Override
|
||||
protected Alias getAlias()
|
||||
{
|
||||
Alias alias = null;
|
||||
|
||||
if(mAliasList != null)
|
||||
{
|
||||
if(hasValue())
|
||||
{
|
||||
switch(mAliasIDType)
|
||||
{
|
||||
case ESN:
|
||||
alias = mAliasList.getESNAlias(getValue());
|
||||
break;
|
||||
case FLEETSYNC:
|
||||
alias = mAliasList.getFleetsyncAlias(getValue());
|
||||
break;
|
||||
case MDC1200:
|
||||
alias = mAliasList.getMDC1200Alias(getValue());
|
||||
break;
|
||||
case MIN:
|
||||
alias = mAliasList.getMobileIDNumberAlias(getValue());
|
||||
break;
|
||||
case MPT1327:
|
||||
alias = mAliasList.getMPT1327Alias(getValue());
|
||||
break;
|
||||
case SITE:
|
||||
alias = mAliasList.getSiteID(getValue());
|
||||
break;
|
||||
case TALKGROUP:
|
||||
alias = mAliasList.getTalkgroupAlias(getValue());
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return alias;
|
||||
}
|
||||
}
|
||||
@@ -1,159 +0,0 @@
|
||||
/*******************************************************************************
|
||||
* 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 io.github.dsheirer.channel.metadata;
|
||||
|
||||
import io.github.dsheirer.alias.Alias;
|
||||
import io.github.dsheirer.sample.Listener;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
public class AttributeMonitor<T>
|
||||
{
|
||||
private Attribute mAttribute;
|
||||
private Listener<AttributeChangeRequest> mListener;
|
||||
private boolean mHeuristicsEnabled = true;
|
||||
private Map<T,Integer> mOccurrenceCounts = new HashMap<>();
|
||||
private T mCurrentValue;
|
||||
private List<T> mIllegalValues = new ArrayList<>();
|
||||
|
||||
public AttributeMonitor(Attribute attribute, Listener<AttributeChangeRequest> listener)
|
||||
{
|
||||
mAttribute = attribute;
|
||||
mListener = listener;
|
||||
}
|
||||
|
||||
/**
|
||||
* Processes the value and emits a change request if the value needs to be changed. If heuristics are enabled,
|
||||
* an internal mapping of values to occurrence counts is updated and a change is emitted once a value that is
|
||||
* different from the current value, has a higher occurrence count than the current value. If heuristics are
|
||||
* disabled, then a change is emitted at each change in the value.
|
||||
*
|
||||
* @param t type
|
||||
* @return true if the value was changed after processing
|
||||
*/
|
||||
public boolean process(T t)
|
||||
{
|
||||
boolean changed = false;
|
||||
|
||||
if(t != null && !mIllegalValues.contains(t))
|
||||
{
|
||||
if(mHeuristicsEnabled)
|
||||
{
|
||||
if(mOccurrenceCounts.containsKey(t))
|
||||
{
|
||||
mOccurrenceCounts.put(t, mOccurrenceCounts.get(t) + 1);
|
||||
}
|
||||
else
|
||||
{
|
||||
mOccurrenceCounts.put(t, 1);
|
||||
}
|
||||
}
|
||||
|
||||
if(mCurrentValue == null)
|
||||
{
|
||||
mCurrentValue = t;
|
||||
changed = true;
|
||||
}
|
||||
else if(!mCurrentValue.equals(t))
|
||||
{
|
||||
if(mHeuristicsEnabled)
|
||||
{
|
||||
int count = mOccurrenceCounts.get(mCurrentValue);
|
||||
|
||||
for(Map.Entry<T,Integer> entry : mOccurrenceCounts.entrySet())
|
||||
{
|
||||
if(entry.getValue() > count)
|
||||
{
|
||||
count = entry.getValue();
|
||||
mCurrentValue = entry.getKey();
|
||||
changed = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
mCurrentValue = t;
|
||||
changed = true;
|
||||
}
|
||||
}
|
||||
|
||||
if(changed && mListener != null)
|
||||
{
|
||||
mListener.receive(new AttributeChangeRequest(mAttribute, getValue(), getAlias()));
|
||||
}
|
||||
}
|
||||
|
||||
return changed;
|
||||
}
|
||||
|
||||
/**
|
||||
* Alias for the current value. This class does not return an alias, but subclasses can return an alias that
|
||||
* is appropriate for the monitored attribute value.
|
||||
*
|
||||
* @return an optional alias for the current value
|
||||
*/
|
||||
protected Alias getAlias()
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Resets the attribute value to null and resets occurrence heuristics.
|
||||
*/
|
||||
public void reset()
|
||||
{
|
||||
mCurrentValue = null;
|
||||
mOccurrenceCounts.clear();
|
||||
|
||||
if(mListener != null)
|
||||
{
|
||||
mListener.receive(new AttributeChangeRequest(mAttribute, null, null));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds a value to the internal list of illegal values. The monitor will not allow the attribute to be changed to
|
||||
* any values contained in this list.
|
||||
*
|
||||
* @param illegalValue to prevent for the monitored alias
|
||||
*/
|
||||
public void addIllegalValue(T illegalValue)
|
||||
{
|
||||
mIllegalValues.add(illegalValue);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the current value or null if the monitor is newly started or reset.
|
||||
*/
|
||||
public T getValue()
|
||||
{
|
||||
return mCurrentValue;
|
||||
}
|
||||
|
||||
/**
|
||||
* Indicates if the current value is non-null
|
||||
*/
|
||||
public boolean hasValue()
|
||||
{
|
||||
return mCurrentValue != null;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,336 @@
|
||||
/*
|
||||
* ******************************************************************************
|
||||
* sdrtrunk
|
||||
* Copyright (C) 2014-2018 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.channel.metadata;
|
||||
|
||||
import io.github.dsheirer.alias.Alias;
|
||||
import io.github.dsheirer.alias.AliasList;
|
||||
import io.github.dsheirer.alias.AliasModel;
|
||||
import io.github.dsheirer.identifier.Identifier;
|
||||
import io.github.dsheirer.identifier.IdentifierUpdateListener;
|
||||
import io.github.dsheirer.identifier.IdentifierUpdateNotification;
|
||||
import io.github.dsheirer.identifier.Role;
|
||||
import io.github.dsheirer.identifier.configuration.AliasListConfigurationIdentifier;
|
||||
import io.github.dsheirer.identifier.configuration.ChannelNameConfigurationIdentifier;
|
||||
import io.github.dsheirer.identifier.configuration.DecoderTypeConfigurationIdentifier;
|
||||
import io.github.dsheirer.identifier.configuration.FrequencyConfigurationIdentifier;
|
||||
import io.github.dsheirer.identifier.configuration.SiteConfigurationIdentifier;
|
||||
import io.github.dsheirer.identifier.configuration.SystemConfigurationIdentifier;
|
||||
import io.github.dsheirer.identifier.decoder.DecoderLogicalChannelNameIdentifier;
|
||||
import io.github.dsheirer.identifier.decoder.DecoderStateIdentifier;
|
||||
import io.github.dsheirer.sample.Listener;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
/**
|
||||
* Channel metadata containing details about the channel configuration, decoder state and current
|
||||
* set of decoded user identifiers (ie TO and FROM).
|
||||
*/
|
||||
public class ChannelMetadata implements Listener<IdentifierUpdateNotification>, IdentifierUpdateListener
|
||||
{
|
||||
private final static Logger mLog = LoggerFactory.getLogger(ChannelMetadata.class);
|
||||
|
||||
private SystemConfigurationIdentifier mSystemConfigurationIdentifier;
|
||||
private SiteConfigurationIdentifier mSiteConfigurationIdentifier;
|
||||
private ChannelNameConfigurationIdentifier mChannelNameConfigurationIdentifier;
|
||||
private FrequencyConfigurationIdentifier mFrequencyConfigurationIdentifier;
|
||||
private DecoderStateIdentifier mDecoderStateIdentifier = DecoderStateIdentifier.IDLE;
|
||||
private DecoderLogicalChannelNameIdentifier mDecoderLogicalChannelNameIdentifier;
|
||||
private DecoderTypeConfigurationIdentifier mDecoderTypeConfigurationIdentifier;
|
||||
private Identifier mFromIdentifier;
|
||||
private Alias mFromIdentifierAlias;
|
||||
private Identifier mToIdentifier;
|
||||
private Alias mToIdentifierAlias;
|
||||
|
||||
private IChannelMetadataUpdateListener mIChannelMetadataUpdateListener;
|
||||
private AliasModel mAliasModel;
|
||||
private AliasList mAliasList;
|
||||
|
||||
public ChannelMetadata(AliasModel aliasModel)
|
||||
{
|
||||
mAliasModel = aliasModel;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Listener<IdentifierUpdateNotification> getIdentifierUpdateListener()
|
||||
{
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* System configuration identifier
|
||||
*/
|
||||
public SystemConfigurationIdentifier getSystemConfigurationIdentifier()
|
||||
{
|
||||
return mSystemConfigurationIdentifier;
|
||||
}
|
||||
|
||||
public boolean hasSystemConfigurationIdentifier()
|
||||
{
|
||||
return mSystemConfigurationIdentifier != null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Site configuration identifier
|
||||
*/
|
||||
public SiteConfigurationIdentifier getSiteConfigurationIdentifier()
|
||||
{
|
||||
return mSiteConfigurationIdentifier;
|
||||
}
|
||||
|
||||
public boolean hasSiteConfigurationIdentifier()
|
||||
{
|
||||
return mSiteConfigurationIdentifier != null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Channel configuration identifier
|
||||
*/
|
||||
public ChannelNameConfigurationIdentifier getChannelNameConfigurationIdentifier()
|
||||
{
|
||||
return mChannelNameConfigurationIdentifier;
|
||||
}
|
||||
|
||||
public boolean hasChannelConfigurationIdentifier()
|
||||
{
|
||||
return mChannelNameConfigurationIdentifier != null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Logical channel name/number expoded by the decoder
|
||||
*/
|
||||
public DecoderLogicalChannelNameIdentifier getDecoderLogicalChannelNameIdentifier()
|
||||
{
|
||||
return mDecoderLogicalChannelNameIdentifier;
|
||||
}
|
||||
|
||||
public boolean hasDecoderLogicalChannelNameIdentifier()
|
||||
{
|
||||
return mDecoderLogicalChannelNameIdentifier != null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Frequency configuration identifier
|
||||
*/
|
||||
public FrequencyConfigurationIdentifier getFrequencyConfigurationIdentifier()
|
||||
{
|
||||
return mFrequencyConfigurationIdentifier;
|
||||
}
|
||||
|
||||
public boolean hasFrequencyConfigurationIdentifier()
|
||||
{
|
||||
return mFrequencyConfigurationIdentifier != null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Decoder state identifier
|
||||
*/
|
||||
public DecoderStateIdentifier getDecoderStateIdentifier()
|
||||
{
|
||||
return mDecoderStateIdentifier;
|
||||
}
|
||||
|
||||
public boolean hasDecoderStateIdentifier()
|
||||
{
|
||||
return mDecoderStateIdentifier != null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Decoder type identifier
|
||||
*/
|
||||
public DecoderTypeConfigurationIdentifier getDecoderTypeConfigurationIdentifier()
|
||||
{
|
||||
return mDecoderTypeConfigurationIdentifier;
|
||||
}
|
||||
|
||||
public boolean hasDecoderTypeIdentifier()
|
||||
{
|
||||
return mDecoderTypeConfigurationIdentifier != null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Current call event FROM identifier
|
||||
*/
|
||||
public Identifier getFromIdentifier()
|
||||
{
|
||||
return mFromIdentifier;
|
||||
}
|
||||
|
||||
public boolean hasFromIdentifier()
|
||||
{
|
||||
return mFromIdentifier != null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Optional alias associated with the FROM identifier
|
||||
*/
|
||||
public Alias getFromIdentifierAlias()
|
||||
{
|
||||
return mFromIdentifierAlias;
|
||||
}
|
||||
|
||||
/**
|
||||
* Current call event TO identifier
|
||||
*/
|
||||
public Identifier getToIdentifier()
|
||||
{
|
||||
return mToIdentifier;
|
||||
}
|
||||
|
||||
public boolean hasToIdentifier()
|
||||
{
|
||||
return mToIdentifier != null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Optional alias associated with the TO identifier
|
||||
*/
|
||||
public Alias getToIdentifierAlias()
|
||||
{
|
||||
return mToIdentifierAlias;
|
||||
}
|
||||
|
||||
/**
|
||||
* Registers the listener for receiving field update events
|
||||
*/
|
||||
public void setUpdateEventListener(IChannelMetadataUpdateListener listener)
|
||||
{
|
||||
mIChannelMetadataUpdateListener = listener;
|
||||
}
|
||||
|
||||
/**
|
||||
* Deregisters the listener from receiving field update events
|
||||
*/
|
||||
public void removeUpdateEventListener()
|
||||
{
|
||||
mIChannelMetadataUpdateListener = null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Broadcasts this metadata and the field that has been updated
|
||||
*
|
||||
* @param field that has been updated
|
||||
*/
|
||||
private void broadcastUpdate(ChannelMetadataField field)
|
||||
{
|
||||
if(mIChannelMetadataUpdateListener != null)
|
||||
{
|
||||
mIChannelMetadataUpdateListener.updated(this, field);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void receive(IdentifierUpdateNotification update)
|
||||
{
|
||||
Identifier identifier = update.getIdentifier();
|
||||
|
||||
switch(identifier.getIdentifierClass())
|
||||
{
|
||||
case CONFIGURATION:
|
||||
switch(identifier.getForm())
|
||||
{
|
||||
case ALIAS_LIST:
|
||||
if(update.isAdded())
|
||||
{
|
||||
mAliasList = mAliasModel.getAliasList((AliasListConfigurationIdentifier)identifier);
|
||||
|
||||
if(mAliasList != null)
|
||||
{
|
||||
if(mToIdentifier != null)
|
||||
{
|
||||
mToIdentifierAlias = mAliasList.getAlias(mToIdentifier);
|
||||
}
|
||||
if(mFromIdentifier != null)
|
||||
{
|
||||
mFromIdentifierAlias = mAliasList.getAlias(mFromIdentifier);
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
case CHANNEL:
|
||||
mChannelNameConfigurationIdentifier = update.isAdded() ? (ChannelNameConfigurationIdentifier)identifier : null;
|
||||
broadcastUpdate(ChannelMetadataField.CONFIGURATION_CHANNEL);
|
||||
break;
|
||||
case CHANNEL_FREQUENCY:
|
||||
mFrequencyConfigurationIdentifier = update.isAdded() ? (FrequencyConfigurationIdentifier)identifier : null;
|
||||
broadcastUpdate(ChannelMetadataField.CONFIGURATION_FREQUENCY);
|
||||
break;
|
||||
case DECODER_TYPE:
|
||||
mDecoderTypeConfigurationIdentifier = update.isAdded() ? (DecoderTypeConfigurationIdentifier)identifier : null;
|
||||
broadcastUpdate(ChannelMetadataField.DECODER_TYPE);
|
||||
break;
|
||||
case SITE:
|
||||
mSiteConfigurationIdentifier = update.isAdded() ? (SiteConfigurationIdentifier)identifier : null;
|
||||
broadcastUpdate(ChannelMetadataField.CONFIGURATION_SITE);
|
||||
break;
|
||||
case SYSTEM:
|
||||
mSystemConfigurationIdentifier = update.isAdded() ? (SystemConfigurationIdentifier)identifier : null;
|
||||
broadcastUpdate(ChannelMetadataField.CONFIGURATION_SYSTEM);
|
||||
break;
|
||||
}
|
||||
break;
|
||||
case DECODER:
|
||||
switch(identifier.getForm())
|
||||
{
|
||||
case CHANNEL_NAME:
|
||||
mDecoderLogicalChannelNameIdentifier = update.isAdded() ? (DecoderLogicalChannelNameIdentifier)identifier : null;
|
||||
broadcastUpdate(ChannelMetadataField.DECODER_CHANNEL_NAME);
|
||||
break;
|
||||
case STATE:
|
||||
mDecoderStateIdentifier = update.isAdded() ? (DecoderStateIdentifier)identifier : null;
|
||||
broadcastUpdate(ChannelMetadataField.DECODER_STATE);
|
||||
break;
|
||||
}
|
||||
break;
|
||||
case USER:
|
||||
if(identifier.getRole() == Role.FROM)
|
||||
{
|
||||
mFromIdentifier = update.isAdded() ? identifier : null;
|
||||
|
||||
if(mAliasList != null && mFromIdentifier != null)
|
||||
{
|
||||
mFromIdentifierAlias = mAliasList.getAlias(mFromIdentifier);
|
||||
}
|
||||
else
|
||||
{
|
||||
mFromIdentifierAlias = null;
|
||||
}
|
||||
|
||||
broadcastUpdate(ChannelMetadataField.USER_FROM);
|
||||
}
|
||||
else if(identifier.getRole() == Role.TO)
|
||||
{
|
||||
mToIdentifier = update.isAdded() ? identifier : null;
|
||||
|
||||
if(mAliasList != null && mToIdentifier != null)
|
||||
{
|
||||
mToIdentifierAlias = mAliasList.getAlias(mToIdentifier);
|
||||
}
|
||||
else
|
||||
{
|
||||
mToIdentifierAlias = null;
|
||||
}
|
||||
|
||||
broadcastUpdate(ChannelMetadataField.USER_TO);
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,34 @@
|
||||
/*
|
||||
* ******************************************************************************
|
||||
* sdrtrunk
|
||||
* Copyright (C) 2014-2018 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.channel.metadata;
|
||||
|
||||
public enum ChannelMetadataField
|
||||
{
|
||||
CONFIGURATION_CHANNEL,
|
||||
CONFIGURATION_FREQUENCY,
|
||||
CONFIGURATION_SITE,
|
||||
CONFIGURATION_SYSTEM,
|
||||
DECODER_CHANNEL_NAME,
|
||||
DECODER_STATE,
|
||||
DECODER_TYPE,
|
||||
USER_FROM,
|
||||
USER_TO;
|
||||
}
|
||||
@@ -15,44 +15,65 @@
|
||||
******************************************************************************/
|
||||
package io.github.dsheirer.channel.metadata;
|
||||
|
||||
import io.github.dsheirer.channel.state.State;
|
||||
import com.google.common.eventbus.Subscribe;
|
||||
import io.github.dsheirer.alias.Alias;
|
||||
import io.github.dsheirer.controller.channel.Channel;
|
||||
import io.github.dsheirer.sample.Listener;
|
||||
import io.github.dsheirer.eventbus.MyEventBus;
|
||||
import io.github.dsheirer.identifier.Identifier;
|
||||
import io.github.dsheirer.preference.PreferenceType;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import javax.swing.table.AbstractTableModel;
|
||||
import java.awt.EventQueue;
|
||||
import java.text.DecimalFormat;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
public class ChannelMetadataModel extends AbstractTableModel implements Listener<MutableMetadataChangeEvent>
|
||||
public class ChannelMetadataModel extends AbstractTableModel implements IChannelMetadataUpdateListener
|
||||
{
|
||||
private final static Logger mLog = LoggerFactory.getLogger(ChannelMetadataModel.class);
|
||||
|
||||
private final DecimalFormat FREQUENCY_FORMATTER = new DecimalFormat( "#.00000" );
|
||||
public static final int COLUMN_DECODER_STATE = 0;
|
||||
public static final int COLUMN_DECODER_TYPE = 1;
|
||||
public static final int COLUMN_USER_FROM = 2;
|
||||
public static final int COLUMN_USER_FROM_ALIAS = 3;
|
||||
public static final int COLUMN_USER_TO = 4;
|
||||
public static final int COLUMN_USER_TO_ALIAS = 5;
|
||||
public static final int COLUMN_DECODER_LOGICAL_CHANNEL_NAME = 6;
|
||||
public static final int COLUMN_CONFIGURATION_FREQUENCY = 7;
|
||||
public static final int COLUMN_CONFIGURATION_CHANNEL = 8;
|
||||
|
||||
public static final int COLUMN_STATE = 0;
|
||||
public static final int COLUMN_DECODER = 1;
|
||||
public static final int COLUMN_CHANNEL = 2;
|
||||
public static final int COLUMN_FREQUENCY = 3;
|
||||
public static final int COLUMN_PRIMARY_FROM = 4;
|
||||
public static final int COLUMN_PRIMARY_TO = 5;
|
||||
public static final int COLUMN_SECONDARY_FROM = 6;
|
||||
public static final int COLUMN_SECONDARY_TO = 7;
|
||||
public static final int COLUMN_CONFIGURATION_NAME = 8;
|
||||
public static final int COLUMN_MESSAGE = 9;
|
||||
private static final String[] COLUMNS = {"Status", "Decoder", "From", "Alias", "To", "Alias", "Channel", "Frequency", "Channel Name"};
|
||||
|
||||
private static final String[] COLUMNS = {"Status", "Decoder", "Channel", "Frequency", "Primary From", "Primary To",
|
||||
"Secondary From", "Secondary To", "Channel Name", "Message"};
|
||||
private List<ChannelMetadata> mChannelMetadata = new ArrayList();
|
||||
private Map<ChannelMetadata,Channel> mMetadataChannelMap = new HashMap();
|
||||
|
||||
private List<MutableMetadata> mChannelMetadata = new ArrayList();
|
||||
private Map<MutableMetadata,Channel> mMetadataChannelMap = new HashMap();
|
||||
public ChannelMetadataModel()
|
||||
{
|
||||
MyEventBus.getEventBus().register(this);
|
||||
}
|
||||
|
||||
public void add(MutableMetadata metadata, Channel channel)
|
||||
/**
|
||||
* Receives preference update notifications via the event bus
|
||||
* @param preferenceType that was updated
|
||||
*/
|
||||
@Subscribe
|
||||
public void preferenceUpdated(PreferenceType preferenceType)
|
||||
{
|
||||
if(preferenceType == PreferenceType.IDENTIFIER)
|
||||
{
|
||||
for(int row = 0; row < mChannelMetadata.size(); row++)
|
||||
{
|
||||
fireTableCellUpdated(row, COLUMN_USER_FROM);
|
||||
fireTableCellUpdated(row, COLUMN_USER_TO);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public void add(ChannelMetadata channelMetadata, Channel channel)
|
||||
{
|
||||
//Execute on the swing thread to avoid threading issues
|
||||
EventQueue.invokeLater(new Runnable()
|
||||
@@ -60,19 +81,16 @@ public class ChannelMetadataModel extends AbstractTableModel implements Listener
|
||||
@Override
|
||||
public void run()
|
||||
{
|
||||
mChannelMetadata.add(metadata);
|
||||
mMetadataChannelMap.put(metadata, channel);
|
||||
|
||||
int index = mChannelMetadata.indexOf(metadata);
|
||||
|
||||
mChannelMetadata.add(channelMetadata);
|
||||
mMetadataChannelMap.put(channelMetadata, channel);
|
||||
int index = mChannelMetadata.indexOf(channelMetadata);
|
||||
fireTableRowsInserted(index, index);
|
||||
|
||||
metadata.addListener(ChannelMetadataModel.this);
|
||||
channelMetadata.setUpdateEventListener(ChannelMetadataModel.this);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public void remove(MutableMetadata metadata)
|
||||
public void remove(ChannelMetadata channelMetadata)
|
||||
{
|
||||
//Execute on the swing thread to avoid threading issues
|
||||
EventQueue.invokeLater(new Runnable()
|
||||
@@ -80,13 +98,10 @@ public class ChannelMetadataModel extends AbstractTableModel implements Listener
|
||||
@Override
|
||||
public void run()
|
||||
{
|
||||
metadata.removeListener(ChannelMetadataModel.this);
|
||||
|
||||
int index = mChannelMetadata.indexOf(metadata);
|
||||
|
||||
mChannelMetadata.remove(metadata);
|
||||
mMetadataChannelMap.remove(metadata);
|
||||
|
||||
channelMetadata.removeUpdateEventListener();
|
||||
int index = mChannelMetadata.indexOf(channelMetadata);
|
||||
mChannelMetadata.remove(channelMetadata);
|
||||
mMetadataChannelMap.remove(channelMetadata);
|
||||
fireTableRowsDeleted(index, index);
|
||||
}
|
||||
});
|
||||
@@ -95,7 +110,7 @@ public class ChannelMetadataModel extends AbstractTableModel implements Listener
|
||||
/**
|
||||
* Get the channel metadata at the specified model row index
|
||||
*/
|
||||
public Metadata getMetadata(int row)
|
||||
public ChannelMetadata getChannelMetadata(int row)
|
||||
{
|
||||
if(row < mChannelMetadata.size())
|
||||
{
|
||||
@@ -108,9 +123,9 @@ public class ChannelMetadataModel extends AbstractTableModel implements Listener
|
||||
/**
|
||||
* Returns the channel that matches the metadata or null
|
||||
*/
|
||||
public Channel getChannelFromMetadata(Metadata metadata)
|
||||
public Channel getChannelFromMetadata(ChannelMetadata channelMetadata)
|
||||
{
|
||||
return mMetadataChannelMap.get(metadata);
|
||||
return mMetadataChannelMap.get(channelMetadata);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -136,24 +151,14 @@ public class ChannelMetadataModel extends AbstractTableModel implements Listener
|
||||
{
|
||||
switch(columnIndex)
|
||||
{
|
||||
case COLUMN_STATE:
|
||||
return State.class;
|
||||
|
||||
case COLUMN_DECODER:
|
||||
case COLUMN_CHANNEL:
|
||||
case COLUMN_FREQUENCY:
|
||||
case COLUMN_MESSAGE:
|
||||
case COLUMN_CONFIGURATION_NAME:
|
||||
return String.class;
|
||||
|
||||
case COLUMN_PRIMARY_TO:
|
||||
case COLUMN_PRIMARY_FROM:
|
||||
case COLUMN_SECONDARY_TO:
|
||||
case COLUMN_SECONDARY_FROM:
|
||||
return MutableMetadata.class;
|
||||
|
||||
case COLUMN_USER_FROM:
|
||||
case COLUMN_USER_TO:
|
||||
return ChannelMetadata.class;
|
||||
case COLUMN_USER_FROM_ALIAS:
|
||||
case COLUMN_USER_TO_ALIAS:
|
||||
return Alias.class;
|
||||
default:
|
||||
return String.class;
|
||||
return Identifier.class;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -162,60 +167,28 @@ public class ChannelMetadataModel extends AbstractTableModel implements Listener
|
||||
{
|
||||
if(rowIndex <= mChannelMetadata.size())
|
||||
{
|
||||
Metadata metadata = mChannelMetadata.get(rowIndex);
|
||||
ChannelMetadata channelMetadata = mChannelMetadata.get(rowIndex);
|
||||
|
||||
switch(columnIndex)
|
||||
{
|
||||
case COLUMN_STATE:
|
||||
return metadata.getState();
|
||||
case COLUMN_DECODER:
|
||||
if(metadata.hasPrimaryDecoderType())
|
||||
{
|
||||
return metadata.getPrimaryDecoderType().getShortDisplayString();
|
||||
}
|
||||
|
||||
return null;
|
||||
case COLUMN_CHANNEL:
|
||||
return metadata.getChannelFrequencyLabel();
|
||||
case COLUMN_FREQUENCY:
|
||||
if(metadata.hasChannelFrequency())
|
||||
{
|
||||
return FREQUENCY_FORMATTER.format((double)metadata.getChannelFrequency() / 1E6d);
|
||||
}
|
||||
|
||||
return null;
|
||||
case COLUMN_MESSAGE:
|
||||
if(metadata.isBufferOverflow())
|
||||
{
|
||||
return "**OVERFLOW**";
|
||||
}
|
||||
else if(metadata.hasMessageType() || metadata.hasMessage())
|
||||
{
|
||||
StringBuilder sb = new StringBuilder();
|
||||
if(metadata.hasMessageType())
|
||||
{
|
||||
sb.append(metadata.getMessageType()).append(" ");
|
||||
}
|
||||
|
||||
if(metadata.hasMessage())
|
||||
{
|
||||
sb.append(metadata.getMessage());
|
||||
}
|
||||
|
||||
return sb.toString();
|
||||
}
|
||||
|
||||
return null;
|
||||
case COLUMN_CONFIGURATION_NAME:
|
||||
return metadata.getChannelConfigurationName();
|
||||
case COLUMN_PRIMARY_TO:
|
||||
case COLUMN_PRIMARY_FROM:
|
||||
case COLUMN_SECONDARY_TO:
|
||||
case COLUMN_SECONDARY_FROM:
|
||||
return metadata;
|
||||
|
||||
default:
|
||||
return String.class;
|
||||
case COLUMN_DECODER_STATE:
|
||||
return channelMetadata.getDecoderStateIdentifier();
|
||||
case COLUMN_DECODER_TYPE:
|
||||
return channelMetadata.getDecoderTypeConfigurationIdentifier();
|
||||
case COLUMN_DECODER_LOGICAL_CHANNEL_NAME:
|
||||
return channelMetadata.getDecoderLogicalChannelNameIdentifier();
|
||||
case COLUMN_CONFIGURATION_FREQUENCY:
|
||||
return channelMetadata.getFrequencyConfigurationIdentifier();
|
||||
case COLUMN_CONFIGURATION_CHANNEL:
|
||||
return channelMetadata.getChannelNameConfigurationIdentifier();
|
||||
case COLUMN_USER_TO:
|
||||
return channelMetadata;
|
||||
case COLUMN_USER_FROM:
|
||||
return channelMetadata;
|
||||
case COLUMN_USER_FROM_ALIAS:
|
||||
return channelMetadata.getFromIdentifierAlias();
|
||||
case COLUMN_USER_TO_ALIAS:
|
||||
return channelMetadata.getToIdentifierAlias();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -223,59 +196,46 @@ public class ChannelMetadataModel extends AbstractTableModel implements Listener
|
||||
}
|
||||
|
||||
@Override
|
||||
public void receive(MutableMetadataChangeEvent mutableMetadataChangeEvent)
|
||||
public void updated(ChannelMetadata channelMetadata, ChannelMetadataField channelMetadataField)
|
||||
{
|
||||
//Execute on the swing thread to avoid threading issues
|
||||
EventQueue.invokeLater(new Runnable()
|
||||
{
|
||||
@Override
|
||||
public void run()
|
||||
{
|
||||
int rowIndex = mChannelMetadata.indexOf(mutableMetadataChangeEvent.getMetadata());
|
||||
final int rowIndex = mChannelMetadata.indexOf(channelMetadata);
|
||||
|
||||
if(rowIndex >= 0)
|
||||
if(rowIndex >= 0)
|
||||
{
|
||||
//Execute on the swing thread to avoid threading issues
|
||||
EventQueue.invokeLater(new Runnable()
|
||||
{
|
||||
@Override
|
||||
public void run()
|
||||
{
|
||||
switch(mutableMetadataChangeEvent.getAttribute())
|
||||
switch(channelMetadataField)
|
||||
{
|
||||
case CHANNEL_CONFIGURATION_SYSTEM:
|
||||
case CONFIGURATION_CHANNEL:
|
||||
fireTableCellUpdated(rowIndex, COLUMN_CONFIGURATION_CHANNEL);
|
||||
break;
|
||||
case CHANNEL_CONFIGURATION_SITE:
|
||||
case CONFIGURATION_FREQUENCY:
|
||||
fireTableCellUpdated(rowIndex, COLUMN_CONFIGURATION_FREQUENCY);
|
||||
break;
|
||||
case CHANNEL_CONFIGURATION_NAME:
|
||||
fireTableCellUpdated(rowIndex, COLUMN_CONFIGURATION_NAME);
|
||||
case DECODER_CHANNEL_NAME:
|
||||
fireTableCellUpdated(rowIndex, COLUMN_DECODER_LOGICAL_CHANNEL_NAME);
|
||||
break;
|
||||
case CHANNEL_FREQUENCY:
|
||||
fireTableCellUpdated(rowIndex, COLUMN_FREQUENCY);
|
||||
case DECODER_TYPE:
|
||||
fireTableCellUpdated(rowIndex, COLUMN_DECODER_TYPE);
|
||||
break;
|
||||
case CHANNEL_FREQUENCY_LABEL:
|
||||
fireTableCellUpdated(rowIndex, COLUMN_CHANNEL);
|
||||
case DECODER_STATE:
|
||||
fireTableCellUpdated(rowIndex, COLUMN_DECODER_STATE);
|
||||
break;
|
||||
case CHANNEL_STATE:
|
||||
fireTableCellUpdated(rowIndex, COLUMN_STATE);
|
||||
case USER_FROM:
|
||||
fireTableCellUpdated(rowIndex, COLUMN_USER_FROM);
|
||||
fireTableCellUpdated(rowIndex, COLUMN_USER_FROM_ALIAS);
|
||||
break;
|
||||
case BUFFER_OVERFLOW:
|
||||
case MESSAGE:
|
||||
case MESSAGE_TYPE:
|
||||
fireTableCellUpdated(rowIndex, COLUMN_MESSAGE);
|
||||
break;
|
||||
case PRIMARY_ADDRESS_FROM:
|
||||
fireTableCellUpdated(rowIndex, COLUMN_PRIMARY_FROM);
|
||||
break;
|
||||
case PRIMARY_ADDRESS_TO:
|
||||
fireTableCellUpdated(rowIndex, COLUMN_PRIMARY_TO);
|
||||
break;
|
||||
case PRIMARY_DECODER_TYPE:
|
||||
fireTableCellUpdated(rowIndex, COLUMN_DECODER);
|
||||
break;
|
||||
case SECONDARY_ADDRESS_FROM:
|
||||
fireTableCellUpdated(rowIndex, COLUMN_SECONDARY_FROM);
|
||||
break;
|
||||
case SECONDARY_ADDRESS_TO:
|
||||
fireTableCellUpdated(rowIndex, COLUMN_SECONDARY_TO);
|
||||
case USER_TO:
|
||||
fireTableCellUpdated(rowIndex, COLUMN_USER_TO);
|
||||
fireTableCellUpdated(rowIndex, COLUMN_USER_TO_ALIAS);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
/*******************************************************************************
|
||||
/*
|
||||
* ******************************************************************************
|
||||
* sdrtrunk
|
||||
* Copyright (C) 2014-2017 Dennis Sheirer
|
||||
* Copyright (C) 2014-2018 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
|
||||
@@ -14,21 +15,26 @@
|
||||
*
|
||||
* 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.channel.metadata;
|
||||
|
||||
import io.github.dsheirer.alias.Alias;
|
||||
import io.github.dsheirer.channel.state.State;
|
||||
import io.github.dsheirer.controller.channel.Channel;
|
||||
import io.github.dsheirer.controller.channel.ChannelModel;
|
||||
import io.github.dsheirer.controller.channel.ChannelProcessingManager;
|
||||
import io.github.dsheirer.controller.channel.ChannelUtils;
|
||||
import io.github.dsheirer.icon.IconManager;
|
||||
import io.github.dsheirer.identifier.Identifier;
|
||||
import io.github.dsheirer.identifier.configuration.FrequencyConfigurationIdentifier;
|
||||
import io.github.dsheirer.identifier.decoder.DecoderStateIdentifier;
|
||||
import io.github.dsheirer.module.ProcessingChain;
|
||||
import io.github.dsheirer.preference.UserPreferences;
|
||||
import io.github.dsheirer.preference.identifier.TalkgroupFormatPreference;
|
||||
import io.github.dsheirer.sample.Broadcaster;
|
||||
import io.github.dsheirer.sample.Listener;
|
||||
import net.miginfocom.swing.MigLayout;
|
||||
import org.apache.commons.lang3.Validate;
|
||||
|
||||
import javax.swing.JLabel;
|
||||
import javax.swing.JMenuItem;
|
||||
@@ -44,13 +50,16 @@ import java.awt.Color;
|
||||
import java.awt.Component;
|
||||
import java.awt.event.MouseAdapter;
|
||||
import java.awt.event.MouseEvent;
|
||||
import java.text.DecimalFormat;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
public class ChannelMetadataPanel extends JPanel implements ListSelectionListener
|
||||
{
|
||||
private ChannelModel mChannelModel;
|
||||
private ChannelProcessingManager mChannelProcessingManager;
|
||||
private IconManager mIconManager;
|
||||
private UserPreferences mUserPreferences;
|
||||
private JTable mTable;
|
||||
private Broadcaster<ProcessingChain> mSelectedProcessingChainBroadcaster = new Broadcaster<>();
|
||||
private Map<State,Color> mBackgroundColors = new HashMap<>();
|
||||
@@ -59,11 +68,13 @@ public class ChannelMetadataPanel extends JPanel implements ListSelectionListene
|
||||
/**
|
||||
* Table view for currently decoding channel metadata
|
||||
*/
|
||||
public ChannelMetadataPanel(ChannelProcessingManager channelProcessingManager, IconManager iconManager)
|
||||
public ChannelMetadataPanel(ChannelModel channelModel, ChannelProcessingManager channelProcessingManager,
|
||||
IconManager iconManager, UserPreferences userPreferences)
|
||||
{
|
||||
mIconManager = iconManager;
|
||||
mChannelModel = channelModel;
|
||||
mChannelProcessingManager = channelProcessingManager;
|
||||
|
||||
mIconManager = iconManager;
|
||||
mUserPreferences = userPreferences;
|
||||
init();
|
||||
}
|
||||
|
||||
@@ -82,16 +93,18 @@ public class ChannelMetadataPanel extends JPanel implements ListSelectionListene
|
||||
mTable.getSelectionModel().addListSelectionListener(this);
|
||||
mTable.addMouseListener(new MouseSupport());
|
||||
|
||||
mTable.getColumnModel().getColumn(ChannelMetadataModel.COLUMN_STATE)
|
||||
mTable.getColumnModel().getColumn(ChannelMetadataModel.COLUMN_DECODER_STATE)
|
||||
.setCellRenderer(new ColoredStateCellRenderer());
|
||||
mTable.getColumnModel().getColumn(ChannelMetadataModel.COLUMN_PRIMARY_TO)
|
||||
.setCellRenderer(new AliasedValueCellRenderer(Attribute.PRIMARY_ADDRESS_TO));
|
||||
mTable.getColumnModel().getColumn(ChannelMetadataModel.COLUMN_PRIMARY_FROM)
|
||||
.setCellRenderer(new AliasedValueCellRenderer(Attribute.PRIMARY_ADDRESS_FROM));
|
||||
mTable.getColumnModel().getColumn(ChannelMetadataModel.COLUMN_SECONDARY_TO)
|
||||
.setCellRenderer(new AliasedValueCellRenderer(Attribute.SECONDARY_ADDRESS_TO));
|
||||
mTable.getColumnModel().getColumn(ChannelMetadataModel.COLUMN_SECONDARY_FROM)
|
||||
.setCellRenderer(new AliasedValueCellRenderer(Attribute.SECONDARY_ADDRESS_FROM));
|
||||
mTable.getColumnModel().getColumn(ChannelMetadataModel.COLUMN_USER_FROM)
|
||||
.setCellRenderer(new FromCellRenderer(mUserPreferences.getTalkgroupFormatPreference()));
|
||||
mTable.getColumnModel().getColumn(ChannelMetadataModel.COLUMN_USER_TO)
|
||||
.setCellRenderer(new ToCellRenderer(mUserPreferences.getTalkgroupFormatPreference()));
|
||||
mTable.getColumnModel().getColumn(ChannelMetadataModel.COLUMN_USER_FROM_ALIAS)
|
||||
.setCellRenderer(new AliasCellRenderer());
|
||||
mTable.getColumnModel().getColumn(ChannelMetadataModel.COLUMN_USER_TO_ALIAS)
|
||||
.setCellRenderer(new AliasCellRenderer());
|
||||
mTable.getColumnModel().getColumn(ChannelMetadataModel.COLUMN_CONFIGURATION_FREQUENCY)
|
||||
.setCellRenderer(new FrequencyCellRenderer());
|
||||
|
||||
JScrollPane scrollPane = new JScrollPane(mTable, JScrollPane.VERTICAL_SCROLLBAR_ALWAYS,
|
||||
JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED);
|
||||
@@ -139,14 +152,16 @@ public class ChannelMetadataPanel extends JPanel implements ListSelectionListene
|
||||
{
|
||||
int selectedModelRow = mTable.convertRowIndexToModel(selectedViewRow);
|
||||
|
||||
Metadata selectedMetadata = mChannelProcessingManager.getChannelMetadataModel()
|
||||
.getMetadata(selectedModelRow);
|
||||
ChannelMetadata selectedMetadata = mChannelProcessingManager.getChannelMetadataModel()
|
||||
.getChannelMetadata(selectedModelRow);
|
||||
|
||||
if(selectedMetadata != null)
|
||||
{
|
||||
Channel selectedChannel = mChannelProcessingManager.getChannelMetadataModel()
|
||||
.getChannelFromMetadata(selectedMetadata);
|
||||
|
||||
|
||||
|
||||
processingChain = mChannelProcessingManager.getProcessingChain(selectedChannel);
|
||||
}
|
||||
}
|
||||
@@ -164,35 +179,148 @@ public class ChannelMetadataPanel extends JPanel implements ListSelectionListene
|
||||
mSelectedProcessingChainBroadcaster.addListener(listener);
|
||||
}
|
||||
|
||||
public class AliasedValueCellRenderer extends DefaultTableCellRenderer
|
||||
/**
|
||||
* Cell renderer for frequency values
|
||||
*/
|
||||
public class FrequencyCellRenderer extends DefaultTableCellRenderer
|
||||
{
|
||||
private Attribute mAttribute;
|
||||
private final DecimalFormat FREQUENCY_FORMATTER = new DecimalFormat( "#.00000" );
|
||||
|
||||
public AliasedValueCellRenderer(Attribute attribute)
|
||||
public FrequencyCellRenderer()
|
||||
{
|
||||
Validate.isTrue(attribute != null);
|
||||
mAttribute = attribute;
|
||||
setHorizontalAlignment(JLabel.CENTER);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus,
|
||||
int row, int column)
|
||||
public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column)
|
||||
{
|
||||
JLabel label = (JLabel)super.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column);
|
||||
|
||||
Metadata metadata = (Metadata)value;
|
||||
String value1 = metadata.getValue(mAttribute);
|
||||
Alias alias = metadata.getAlias(mAttribute);
|
||||
|
||||
label.setText(alias != null ? alias.getName() : value1);
|
||||
label.setIcon(alias != null ? mIconManager.getIcon(alias.getIconName(), IconManager.DEFAULT_ICON_SIZE) : null);
|
||||
label.setForeground(alias != null ? alias.getDisplayColor() : table.getForeground());
|
||||
if(value instanceof FrequencyConfigurationIdentifier)
|
||||
{
|
||||
long frequency = ((FrequencyConfigurationIdentifier)value).getValue();
|
||||
label.setText(FREQUENCY_FORMATTER.format(frequency / 1e6d));
|
||||
}
|
||||
else
|
||||
{
|
||||
label.setText(null);
|
||||
}
|
||||
|
||||
return label;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Alias cell renderer
|
||||
*/
|
||||
public class AliasCellRenderer extends DefaultTableCellRenderer
|
||||
{
|
||||
public AliasCellRenderer()
|
||||
{
|
||||
setHorizontalAlignment(JLabel.LEFT);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column)
|
||||
{
|
||||
JLabel label = (JLabel)super.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column);
|
||||
|
||||
if(value instanceof Alias)
|
||||
{
|
||||
Alias alias = (Alias)value;
|
||||
|
||||
label.setText(alias.getName());
|
||||
label.setIcon(mIconManager.getIcon(alias.getIconName(), IconManager.DEFAULT_ICON_SIZE));
|
||||
label.setForeground(alias.getDisplayColor());
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
label.setText(null);
|
||||
label.setIcon(null);
|
||||
label.setForeground(table.getForeground());
|
||||
}
|
||||
|
||||
return label;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Abstract cell renderer for identifiers
|
||||
*/
|
||||
public abstract class IdentifierCellRenderer extends DefaultTableCellRenderer
|
||||
{
|
||||
private final static String EMPTY_VALUE = "-----";
|
||||
private TalkgroupFormatPreference mTalkgroupFormatPreference;
|
||||
|
||||
public IdentifierCellRenderer(TalkgroupFormatPreference talkgroupFormatPreference)
|
||||
{
|
||||
mTalkgroupFormatPreference = talkgroupFormatPreference;
|
||||
setHorizontalAlignment(JLabel.CENTER);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column)
|
||||
{
|
||||
JLabel label = (JLabel)super.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column);
|
||||
|
||||
if(value instanceof ChannelMetadata)
|
||||
{
|
||||
ChannelMetadata channelMetadata = (ChannelMetadata)value;
|
||||
Identifier identifier = getIdentifier(channelMetadata);
|
||||
String text = mTalkgroupFormatPreference.format(identifier);
|
||||
if(text == null || text.isEmpty())
|
||||
{
|
||||
text = EMPTY_VALUE;
|
||||
}
|
||||
|
||||
label.setText(text);
|
||||
}
|
||||
else
|
||||
{
|
||||
label.setText(EMPTY_VALUE);
|
||||
}
|
||||
|
||||
return label;
|
||||
}
|
||||
|
||||
public abstract Identifier getIdentifier(ChannelMetadata channelMetadata);
|
||||
}
|
||||
|
||||
/**
|
||||
* Cell renderer for the FROM identifier
|
||||
*/
|
||||
public class FromCellRenderer extends IdentifierCellRenderer
|
||||
{
|
||||
public FromCellRenderer(TalkgroupFormatPreference talkgroupFormatPreference)
|
||||
{
|
||||
super(talkgroupFormatPreference);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Identifier getIdentifier(ChannelMetadata channelMetadata)
|
||||
{
|
||||
return channelMetadata.getFromIdentifier();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Cell renderer for the TO identifier
|
||||
*/
|
||||
public class ToCellRenderer extends IdentifierCellRenderer
|
||||
{
|
||||
public ToCellRenderer(TalkgroupFormatPreference talkgroupFormatPreference)
|
||||
{
|
||||
super(talkgroupFormatPreference);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Identifier getIdentifier(ChannelMetadata channelMetadata)
|
||||
{
|
||||
return channelMetadata.getToIdentifier();
|
||||
}
|
||||
}
|
||||
|
||||
public class ColoredStateCellRenderer extends DefaultTableCellRenderer
|
||||
{
|
||||
public ColoredStateCellRenderer()
|
||||
@@ -209,9 +337,9 @@ public class ChannelMetadataPanel extends JPanel implements ListSelectionListene
|
||||
Color background = table.getBackground();
|
||||
Color foreground = table.getForeground();
|
||||
|
||||
if(value instanceof State)
|
||||
if(value instanceof DecoderStateIdentifier)
|
||||
{
|
||||
State state = (State)value;
|
||||
State state = ((DecoderStateIdentifier)value).getValue();
|
||||
label.setText(state.getDisplayValue());
|
||||
|
||||
if(mBackgroundColors.containsKey(state))
|
||||
@@ -226,7 +354,7 @@ public class ChannelMetadataPanel extends JPanel implements ListSelectionListene
|
||||
}
|
||||
else
|
||||
{
|
||||
setText("");
|
||||
setText("----");
|
||||
}
|
||||
|
||||
setBackground(background);
|
||||
@@ -255,7 +383,7 @@ public class ChannelMetadataPanel extends JPanel implements ListSelectionListene
|
||||
|
||||
if(modelRowIndex >= 0)
|
||||
{
|
||||
Metadata metadata = mChannelProcessingManager.getChannelMetadataModel().getMetadata(modelRowIndex);
|
||||
ChannelMetadata metadata = mChannelProcessingManager.getChannelMetadataModel().getChannelMetadata(modelRowIndex);
|
||||
|
||||
if(metadata != null)
|
||||
{
|
||||
@@ -264,9 +392,7 @@ public class ChannelMetadataPanel extends JPanel implements ListSelectionListene
|
||||
|
||||
if(channel != null)
|
||||
{
|
||||
popupMenu.add(ChannelUtils.getContextMenu(mChannelProcessingManager.getChannelModel(),
|
||||
mChannelProcessingManager, channel, mTable));
|
||||
|
||||
popupMenu.add(ChannelUtils.getContextMenu(mChannelModel, mChannelProcessingManager, channel, mTable));
|
||||
populated = true;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -20,12 +20,14 @@ package io.github.dsheirer.channel.metadata;
|
||||
|
||||
import com.jidesoft.swing.JideSplitPane;
|
||||
import com.jidesoft.swing.JideTabbedPane;
|
||||
import io.github.dsheirer.alias.AliasModel;
|
||||
import io.github.dsheirer.channel.details.ChannelDetailPanel;
|
||||
import io.github.dsheirer.controller.channel.ChannelModel;
|
||||
import io.github.dsheirer.controller.channel.ChannelProcessingManager;
|
||||
import io.github.dsheirer.icon.IconManager;
|
||||
import io.github.dsheirer.module.decode.event.CallEventPanel;
|
||||
import io.github.dsheirer.module.decode.event.DecodeEventPanel;
|
||||
import io.github.dsheirer.module.decode.event.MessageActivityPanel;
|
||||
import io.github.dsheirer.settings.SettingsManager;
|
||||
import io.github.dsheirer.preference.UserPreferences;
|
||||
import net.miginfocom.swing.MigLayout;
|
||||
|
||||
import javax.swing.JPanel;
|
||||
@@ -36,20 +38,20 @@ public class ChannelMetadataViewer extends JPanel
|
||||
private ChannelMetadataPanel mChannelMetadataPanel;
|
||||
|
||||
private ChannelDetailPanel mChannelDetailPanel;
|
||||
private CallEventPanel mCallEventPanel;
|
||||
private DecodeEventPanel mDecodeEventPanel;
|
||||
private MessageActivityPanel mMessageActivityPanel;
|
||||
|
||||
/**
|
||||
* GUI panel that combines the currently decoding channels metadata table and viewers for channel details,
|
||||
* messages, events, and spectral view.
|
||||
*/
|
||||
public ChannelMetadataViewer(ChannelProcessingManager channelProcessingManager, IconManager iconManager,
|
||||
SettingsManager settingsManager)
|
||||
public ChannelMetadataViewer(ChannelModel channelModel, ChannelProcessingManager channelProcessingManager,
|
||||
IconManager iconManager, AliasModel aliasModel, UserPreferences userPreferences)
|
||||
{
|
||||
mChannelDetailPanel = new ChannelDetailPanel(channelProcessingManager);
|
||||
mCallEventPanel = new CallEventPanel(iconManager);
|
||||
mDecodeEventPanel = new DecodeEventPanel(iconManager, userPreferences, aliasModel);
|
||||
mMessageActivityPanel = new MessageActivityPanel(channelProcessingManager);
|
||||
mChannelMetadataPanel = new ChannelMetadataPanel(channelProcessingManager, iconManager);
|
||||
mChannelMetadataPanel = new ChannelMetadataPanel(channelModel, channelProcessingManager, iconManager, userPreferences);
|
||||
|
||||
init();
|
||||
}
|
||||
@@ -60,7 +62,7 @@ public class ChannelMetadataViewer extends JPanel
|
||||
|
||||
JideTabbedPane tabbedPane = new JideTabbedPane();
|
||||
tabbedPane.addTab("Details", mChannelDetailPanel);
|
||||
tabbedPane.addTab("Events", mCallEventPanel);
|
||||
tabbedPane.addTab("Events", mDecodeEventPanel);
|
||||
tabbedPane.addTab("Messages", mMessageActivityPanel);
|
||||
// tabbedPane.addTab("Spectrum", mChannelSpectrumPanel);
|
||||
tabbedPane.setFont(this.getFont());
|
||||
@@ -73,7 +75,7 @@ public class ChannelMetadataViewer extends JPanel
|
||||
add(splitPane);
|
||||
|
||||
mChannelMetadataPanel.addProcessingChainSelectionListener(mChannelDetailPanel);
|
||||
mChannelMetadataPanel.addProcessingChainSelectionListener(mCallEventPanel);
|
||||
mChannelMetadataPanel.addProcessingChainSelectionListener(mDecodeEventPanel);
|
||||
mChannelMetadataPanel.addProcessingChainSelectionListener(mMessageActivityPanel);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,29 @@
|
||||
/*
|
||||
* ******************************************************************************
|
||||
* sdrtrunk
|
||||
* Copyright (C) 2014-2018 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.channel.metadata;
|
||||
|
||||
/**
|
||||
* Interface to receive channel metadata update notifications
|
||||
*/
|
||||
public interface IChannelMetadataUpdateListener
|
||||
{
|
||||
void updated(ChannelMetadata channelMetadata, ChannelMetadataField channelMetadataField);
|
||||
}
|
||||
@@ -1,664 +0,0 @@
|
||||
/*******************************************************************************
|
||||
* 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 io.github.dsheirer.channel.metadata;
|
||||
|
||||
import io.github.dsheirer.alias.Alias;
|
||||
import io.github.dsheirer.alias.id.broadcast.BroadcastChannel;
|
||||
import io.github.dsheirer.alias.id.priority.Priority;
|
||||
import io.github.dsheirer.channel.state.State;
|
||||
import io.github.dsheirer.module.decode.DecoderType;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import java.util.Set;
|
||||
import java.util.TreeSet;
|
||||
|
||||
public class Metadata
|
||||
{
|
||||
private final static Logger mLog = LoggerFactory.getLogger(Metadata.class);
|
||||
|
||||
// Static unique metadata identifier tracking
|
||||
private static int UNIQUE_METADATA_ID_GENERATOR = 0;
|
||||
|
||||
private int mMetadataID;
|
||||
|
||||
protected boolean mUpdated;
|
||||
protected DecoderType mPrimaryDecoderType;
|
||||
protected boolean mSelected;
|
||||
protected boolean mBufferOverflow;
|
||||
protected State mState = State.IDLE;
|
||||
protected String mChannelConfigurationSystem;
|
||||
protected String mChannelConfigurationSite;
|
||||
protected String mChannelConfigurationName;
|
||||
protected String mChannelFrequencyLabel;
|
||||
protected long mChannelFrequency;
|
||||
protected AliasedIdentifier mNetworkID1 = new AliasedIdentifier();
|
||||
protected AliasedIdentifier mNetworkID2 = new AliasedIdentifier();
|
||||
|
||||
protected String mMessage;
|
||||
protected String mMessageType;
|
||||
protected AliasedIdentifier mPrimaryAddressFrom = new AliasedIdentifier();
|
||||
protected AliasedIdentifier mPrimaryAddressTo = new AliasedIdentifier();
|
||||
protected AliasedIdentifier mSecondaryAddressFrom = new AliasedIdentifier();
|
||||
protected AliasedIdentifier mSecondaryAddressTo = new AliasedIdentifier();
|
||||
|
||||
//Lazily constructed member variables.
|
||||
private Integer mAudioPriority;
|
||||
protected Boolean mRecordable = false;
|
||||
protected Boolean mDoNotRecord;
|
||||
private Set<BroadcastChannel> mBroadcastChannels;
|
||||
|
||||
private long mTimestamp = System.currentTimeMillis();
|
||||
|
||||
|
||||
/**
|
||||
* Channel metadata. Contains all attributes that reflect the state and current attribute values for a channel
|
||||
* that is currently decoding. This metadata is intended to support any decoding channel gui components to
|
||||
* graphically convey the current state of a decoding channel and to provide audio metadata
|
||||
*/
|
||||
public Metadata()
|
||||
{
|
||||
mMetadataID = UNIQUE_METADATA_ID_GENERATOR++;
|
||||
}
|
||||
|
||||
/**
|
||||
* Protected constructor. Primarily used by the copyOf() method to create a metadata copy with the same ID
|
||||
*/
|
||||
protected Metadata(int metadataID)
|
||||
{
|
||||
mMetadataID = metadataID;
|
||||
}
|
||||
|
||||
/**
|
||||
* Timestamp when this metadata was created
|
||||
* @return milliseconds since epoch
|
||||
*/
|
||||
public long getTimestamp()
|
||||
{
|
||||
return mTimestamp;
|
||||
}
|
||||
/**
|
||||
* Unique string identifier for this metadata that is comprised of the channel ID and the primary TO address.
|
||||
*
|
||||
* This identifier can be used to uniquely identify a channel audio stream and the primary communicant.
|
||||
*/
|
||||
public String getUniqueIdentifier()
|
||||
{
|
||||
return "SRC:" + mMetadataID +
|
||||
" ID:" + (mPrimaryAddressTo.hasIdentifier() ? mPrimaryAddressTo.getIdentifier() : "UNKNOWN");
|
||||
}
|
||||
|
||||
/**
|
||||
* Indicates if any of the fields of this metadata have been updated since the last time a copy was made from this
|
||||
* metadata. This method is primarily used by downstream audio playback and audio recording to signal when changes
|
||||
* are made to the metadata that requires the downstream component to reinspect the metadata.
|
||||
*
|
||||
* This flag is reset to false immediately after a copy is made of this metadata via the copyOf() method.
|
||||
*/
|
||||
public boolean isUpdated()
|
||||
{
|
||||
return mUpdated;
|
||||
}
|
||||
|
||||
/**
|
||||
* Audio Priority as the highest audio priority value from across the primary and secondary identifier aliases.
|
||||
*
|
||||
* A default priority will be used if there are no aliased values. If there is a conflict between audio priority
|
||||
* and 'Do Not Monitor' among the aliases, the highest audio priority will be used (prefer to monitor).
|
||||
*
|
||||
* -1 Do Not Monitor
|
||||
* 0 Channel Selected for immediate monitor
|
||||
* 1 Highest Priority
|
||||
* 100 Lowest Priority (default)
|
||||
*
|
||||
* @return audio priority
|
||||
*/
|
||||
public int getAudioPriority()
|
||||
{
|
||||
if(isSelected())
|
||||
{
|
||||
return Priority.SELECTED_PRIORITY;
|
||||
}
|
||||
|
||||
if(mAudioPriority == null)
|
||||
{
|
||||
determineAudioPriority();
|
||||
}
|
||||
|
||||
return mAudioPriority;
|
||||
}
|
||||
|
||||
/**
|
||||
* Indicates if the audio priority is set to 'Do Not Monitor'
|
||||
*/
|
||||
public boolean isDoNotMonitor()
|
||||
{
|
||||
return getAudioPriority() == Priority.DO_NOT_MONITOR;
|
||||
}
|
||||
|
||||
/**
|
||||
* Indicates if any of the primary or secondary TO/FROM aliases are identified as recordable
|
||||
*/
|
||||
public boolean isRecordable()
|
||||
{
|
||||
if(mDoNotRecord == null)
|
||||
{
|
||||
determineRecordable();
|
||||
}
|
||||
|
||||
return mRecordable && !mDoNotRecord;
|
||||
}
|
||||
|
||||
/**
|
||||
* Indicates that this metadata has been selected by the user and any audio produced by this channel will be set
|
||||
* to the highest playback priority (immediate monitor).
|
||||
*/
|
||||
public boolean isSelected()
|
||||
{
|
||||
return mSelected;
|
||||
}
|
||||
|
||||
/**
|
||||
* Indicates if the channel for this metadata is in a buffer overflow state.
|
||||
*/
|
||||
public boolean isBufferOverflow()
|
||||
{
|
||||
return mBufferOverflow;
|
||||
}
|
||||
|
||||
/**
|
||||
* List of de-duplicated broadcast channels aggregated from the primary and secondary TO/FROM aliases.
|
||||
*/
|
||||
public Set<BroadcastChannel> getBroadcastChannels()
|
||||
{
|
||||
if(mBroadcastChannels == null)
|
||||
{
|
||||
determineBroadcastChannels();
|
||||
}
|
||||
|
||||
return mBroadcastChannels;
|
||||
}
|
||||
|
||||
/**
|
||||
* Indicates if this metadata is streamable, meaning that it contains one ore more broadcast channels
|
||||
*/
|
||||
public boolean isStreamable()
|
||||
{
|
||||
return !getBroadcastChannels().isEmpty();
|
||||
}
|
||||
|
||||
/**
|
||||
* Unique identifier for the source channel that produces this metadata
|
||||
*/
|
||||
public int getMetadataID()
|
||||
{
|
||||
return mMetadataID;
|
||||
}
|
||||
|
||||
/**
|
||||
* Decoder type (ie protocol) for the primary decoder
|
||||
*/
|
||||
public DecoderType getPrimaryDecoderType()
|
||||
{
|
||||
return mPrimaryDecoderType;
|
||||
}
|
||||
|
||||
/**
|
||||
* Indicates if this metadata has a primary decoder type defined
|
||||
*/
|
||||
public boolean hasPrimaryDecoderType()
|
||||
{
|
||||
return mPrimaryDecoderType != null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the alias associated with the attribute or null
|
||||
*/
|
||||
public Alias getAlias(Attribute attribute)
|
||||
{
|
||||
switch(attribute)
|
||||
{
|
||||
case NETWORK_ID_1:
|
||||
return getNetworkID1().getAlias();
|
||||
case NETWORK_ID_2:
|
||||
return getNetworkID2().getAlias();
|
||||
case PRIMARY_ADDRESS_FROM:
|
||||
return getPrimaryAddressFrom().getAlias();
|
||||
case PRIMARY_ADDRESS_TO:
|
||||
return getPrimaryAddressTo().getAlias();
|
||||
case SECONDARY_ADDRESS_FROM:
|
||||
return getSecondaryAddressFrom().getAlias();
|
||||
case SECONDARY_ADDRESS_TO:
|
||||
return getSecondaryAddressTo().getAlias();
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the string value for the specified attribute or null
|
||||
*/
|
||||
public String getValue(Attribute attribute)
|
||||
{
|
||||
switch(attribute)
|
||||
{
|
||||
case CHANNEL_CONFIGURATION_SYSTEM:
|
||||
return mChannelConfigurationSystem;
|
||||
case CHANNEL_CONFIGURATION_SITE:
|
||||
return mChannelConfigurationSite;
|
||||
case CHANNEL_FREQUENCY_LABEL:
|
||||
return mChannelFrequencyLabel;
|
||||
case CHANNEL_STATE:
|
||||
return mState.getDisplayValue();
|
||||
case MESSAGE:
|
||||
return mMessage;
|
||||
case MESSAGE_TYPE:
|
||||
return mMessageType;
|
||||
case NETWORK_ID_1:
|
||||
return mNetworkID1.getIdentifier();
|
||||
case NETWORK_ID_2:
|
||||
return mNetworkID2.getIdentifier();
|
||||
case PRIMARY_ADDRESS_FROM:
|
||||
return mPrimaryAddressFrom.getIdentifier();
|
||||
case PRIMARY_ADDRESS_TO:
|
||||
return mPrimaryAddressTo.getIdentifier();
|
||||
case SECONDARY_ADDRESS_FROM:
|
||||
return mSecondaryAddressFrom.getIdentifier();
|
||||
case SECONDARY_ADDRESS_TO:
|
||||
return mSecondaryAddressTo.getIdentifier();
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Current channel state
|
||||
*/
|
||||
public State getState()
|
||||
{
|
||||
return mState;
|
||||
}
|
||||
|
||||
/**
|
||||
* System name from the channel configuration
|
||||
*/
|
||||
public String getChannelConfigurationSystem()
|
||||
{
|
||||
return mChannelConfigurationSystem;
|
||||
}
|
||||
|
||||
/**
|
||||
* Indicates if there is a non-null, non-empty channel configuration system value
|
||||
*/
|
||||
public boolean hasChannelConfigurationSystem()
|
||||
{
|
||||
return mChannelConfigurationSystem != null && !mChannelConfigurationSystem.isEmpty();
|
||||
}
|
||||
|
||||
/**
|
||||
* Site name from the channel configuration
|
||||
*/
|
||||
public String getChannelConfigurationSite()
|
||||
{
|
||||
return mChannelConfigurationSite;
|
||||
}
|
||||
|
||||
/**
|
||||
* Indicates if there is a non-null, non-empty channel configuration site value
|
||||
*/
|
||||
public boolean hasChannelConfigurationSite()
|
||||
{
|
||||
return mChannelConfigurationSite != null && !mChannelConfigurationSite.isEmpty();
|
||||
}
|
||||
|
||||
/**
|
||||
* Site name from the channel configuration
|
||||
*/
|
||||
public String getChannelConfigurationName()
|
||||
{
|
||||
return mChannelConfigurationName;
|
||||
}
|
||||
|
||||
/**
|
||||
* Indicates if there is a non-null, non-empty channel configuration name value
|
||||
*/
|
||||
public boolean hasChannelConfigurationName()
|
||||
{
|
||||
return mChannelConfigurationSite != null && !mChannelConfigurationSite.isEmpty();
|
||||
}
|
||||
|
||||
/**
|
||||
* Channel ID or Channel Number
|
||||
*/
|
||||
public String getChannelFrequencyLabel()
|
||||
{
|
||||
return mChannelFrequencyLabel;
|
||||
}
|
||||
|
||||
/**
|
||||
* Indicates if there is a non-null, non-empty channel identifier value
|
||||
*/
|
||||
public boolean hasChannelFrequencyLabel()
|
||||
{
|
||||
return mChannelFrequencyLabel != null && !mChannelFrequencyLabel.isEmpty();
|
||||
}
|
||||
|
||||
/**
|
||||
* Channel frequency
|
||||
*/
|
||||
public long getChannelFrequency()
|
||||
{
|
||||
return mChannelFrequency;
|
||||
}
|
||||
|
||||
/**
|
||||
* Indicates if there is a non-zero channel frequency value
|
||||
*/
|
||||
public boolean hasChannelFrequency()
|
||||
{
|
||||
return mChannelFrequency > 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Network Identifier 1
|
||||
*/
|
||||
public AliasedIdentifier getNetworkID1()
|
||||
{
|
||||
return mNetworkID1;
|
||||
}
|
||||
|
||||
/**
|
||||
* Network Identifier 2
|
||||
*/
|
||||
public AliasedIdentifier getNetworkID2()
|
||||
{
|
||||
return mNetworkID2;
|
||||
}
|
||||
|
||||
/**
|
||||
* Message
|
||||
*/
|
||||
public String getMessage()
|
||||
{
|
||||
return mMessage;
|
||||
}
|
||||
|
||||
/**
|
||||
* Indicates if there is a non-null, non-empty message value
|
||||
*/
|
||||
public boolean hasMessage()
|
||||
{
|
||||
return mMessage != null && !mMessage.isEmpty();
|
||||
}
|
||||
|
||||
/**
|
||||
* Message and Decoder type
|
||||
*/
|
||||
public String getMessageType()
|
||||
{
|
||||
return mMessageType;
|
||||
}
|
||||
|
||||
/**
|
||||
* Indicates if there is a non-null, non-empty message and decoder type value
|
||||
*/
|
||||
public boolean hasMessageType()
|
||||
{
|
||||
return mMessageType != null && !mMessageType.isEmpty();
|
||||
}
|
||||
|
||||
/**
|
||||
* Primary FROM Address
|
||||
*/
|
||||
public AliasedIdentifier getPrimaryAddressFrom()
|
||||
{
|
||||
return mPrimaryAddressFrom;
|
||||
}
|
||||
|
||||
/**
|
||||
* Primary TO Address
|
||||
*/
|
||||
public AliasedIdentifier getPrimaryAddressTo()
|
||||
{
|
||||
return mPrimaryAddressTo;
|
||||
}
|
||||
|
||||
/**
|
||||
* Secondary FROM Address
|
||||
*/
|
||||
public AliasedIdentifier getSecondaryAddressFrom()
|
||||
{
|
||||
return mSecondaryAddressFrom;
|
||||
}
|
||||
|
||||
/**
|
||||
* Secondary TO Address
|
||||
*/
|
||||
public AliasedIdentifier getSecondaryAddressTo()
|
||||
{
|
||||
return mSecondaryAddressTo;
|
||||
}
|
||||
|
||||
/**
|
||||
* Determines the audio priority from across the primary and secondary TO/FROM aliases when they exist
|
||||
*/
|
||||
private void determineAudioPriority()
|
||||
{
|
||||
int priority = Priority.DEFAULT_PRIORITY;
|
||||
|
||||
boolean doNotMonitorFound = false;
|
||||
boolean audioPriorityFound = false;
|
||||
|
||||
if(getPrimaryAddressTo().hasAlias())
|
||||
{
|
||||
Alias primaryTo = getPrimaryAddressTo().getAlias();
|
||||
|
||||
if(primaryTo.hasCallPriority())
|
||||
{
|
||||
if(primaryTo.getCallPriority() == Priority.DO_NOT_MONITOR)
|
||||
{
|
||||
doNotMonitorFound = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
audioPriorityFound = true;
|
||||
|
||||
if(primaryTo.getCallPriority() < priority)
|
||||
{
|
||||
priority = primaryTo.getCallPriority();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if(getPrimaryAddressFrom().hasAlias())
|
||||
{
|
||||
Alias primaryFrom = getPrimaryAddressFrom().getAlias();
|
||||
|
||||
if(primaryFrom.hasCallPriority())
|
||||
{
|
||||
if(primaryFrom.getCallPriority() == Priority.DO_NOT_MONITOR)
|
||||
{
|
||||
doNotMonitorFound = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
audioPriorityFound = true;
|
||||
|
||||
if(primaryFrom.getCallPriority() < priority)
|
||||
{
|
||||
priority = primaryFrom.getCallPriority();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if(getSecondaryAddressTo().hasAlias())
|
||||
{
|
||||
Alias secondaryTo = getSecondaryAddressTo().getAlias();
|
||||
|
||||
if(secondaryTo.hasCallPriority())
|
||||
{
|
||||
if(secondaryTo.getCallPriority() == Priority.DO_NOT_MONITOR)
|
||||
{
|
||||
doNotMonitorFound = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
audioPriorityFound = true;
|
||||
|
||||
if(secondaryTo.getCallPriority() < priority)
|
||||
{
|
||||
priority = secondaryTo.getCallPriority();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if(getSecondaryAddressFrom().hasAlias())
|
||||
{
|
||||
Alias secondaryFrom = getSecondaryAddressFrom().getAlias();
|
||||
|
||||
if(secondaryFrom.hasCallPriority())
|
||||
{
|
||||
if(secondaryFrom.getCallPriority() == Priority.DO_NOT_MONITOR)
|
||||
{
|
||||
doNotMonitorFound = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
audioPriorityFound = true;
|
||||
|
||||
if(secondaryFrom.getCallPriority() < priority)
|
||||
{
|
||||
priority = secondaryFrom.getCallPriority();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//If we found a 'Do Not Monitor' and no other audio priority, then set to do not monitor
|
||||
if(doNotMonitorFound && !audioPriorityFound)
|
||||
{
|
||||
mAudioPriority = Priority.DO_NOT_MONITOR;
|
||||
}
|
||||
else
|
||||
{
|
||||
mAudioPriority = priority;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Determines if any of the primary or secondary to/from aliases are recordable.
|
||||
*/
|
||||
private void determineRecordable()
|
||||
{
|
||||
mDoNotRecord = false;
|
||||
|
||||
if(mPrimaryAddressTo.hasAlias() && !mPrimaryAddressTo.getAlias().isRecordable())
|
||||
{
|
||||
mDoNotRecord = true;
|
||||
return;
|
||||
}
|
||||
|
||||
if(mPrimaryAddressFrom.hasAlias() && !mPrimaryAddressFrom.getAlias().isRecordable())
|
||||
{
|
||||
mDoNotRecord = true;
|
||||
return;
|
||||
}
|
||||
|
||||
if(mSecondaryAddressTo.hasAlias() && !mSecondaryAddressTo.getAlias().isRecordable())
|
||||
{
|
||||
mDoNotRecord = true;
|
||||
return;
|
||||
}
|
||||
|
||||
if(mSecondaryAddressFrom.hasAlias() && !mSecondaryAddressFrom.getAlias().isRecordable())
|
||||
{
|
||||
mDoNotRecord = true;
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Aggregates a de-duplicated list of broadcast channels from among the primary/secondary to/from aliases
|
||||
*/
|
||||
private void determineBroadcastChannels()
|
||||
{
|
||||
mBroadcastChannels = new TreeSet<>();
|
||||
|
||||
if(mPrimaryAddressTo.hasAlias() && mPrimaryAddressTo.getAlias().isStreamable())
|
||||
{
|
||||
mBroadcastChannels.addAll(mPrimaryAddressTo.getAlias().getBroadcastChannels());
|
||||
}
|
||||
|
||||
if(mPrimaryAddressFrom.hasAlias() && mPrimaryAddressFrom.getAlias().isStreamable())
|
||||
{
|
||||
mBroadcastChannels.addAll(mPrimaryAddressFrom.getAlias().getBroadcastChannels());
|
||||
}
|
||||
|
||||
if(mSecondaryAddressTo.hasAlias() && mSecondaryAddressTo.getAlias().isStreamable())
|
||||
{
|
||||
mBroadcastChannels.addAll(mSecondaryAddressTo.getAlias().getBroadcastChannels());
|
||||
}
|
||||
|
||||
if(mSecondaryAddressFrom.hasAlias() && mSecondaryAddressFrom.getAlias().isStreamable())
|
||||
{
|
||||
mBroadcastChannels.addAll(mSecondaryAddressFrom.getAlias().getBroadcastChannels());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a deep/full snapshot copy of this metadata set.
|
||||
*
|
||||
* The streamable, recordable, audio priority and broadcast channels are not copied. These are lazily determined
|
||||
* when initially requested.
|
||||
*/
|
||||
public Metadata copyOf()
|
||||
{
|
||||
Metadata copy = new Metadata(mMetadataID);
|
||||
|
||||
copy.mDoNotRecord = mDoNotRecord;
|
||||
copy.mRecordable = mRecordable;
|
||||
copy.mState = mState;
|
||||
copy.mPrimaryDecoderType = mPrimaryDecoderType;
|
||||
copy.mChannelFrequency = mChannelFrequency;
|
||||
|
||||
copy.mChannelConfigurationSystem = hasChannelConfigurationSystem() ? new String(mChannelConfigurationSystem) : null;
|
||||
copy.mChannelConfigurationSite = hasChannelConfigurationSite() ? new String(mChannelConfigurationSite) : null;
|
||||
copy.mChannelConfigurationName = hasChannelConfigurationName() ? new String(mChannelConfigurationName) : null;
|
||||
copy.mChannelFrequencyLabel = hasChannelFrequencyLabel() ? new String(mChannelFrequencyLabel) : null;
|
||||
copy.mMessage = hasMessage() ? new String(mMessage) : null;
|
||||
copy.mMessageType = hasMessageType() ? new String(mMessageType) : null;
|
||||
|
||||
copy.mNetworkID1 = mNetworkID1.copyOf();
|
||||
copy.mNetworkID2 = mNetworkID2.copyOf();
|
||||
copy.mPrimaryAddressFrom = mPrimaryAddressFrom.copyOf();
|
||||
copy.mPrimaryAddressTo = mPrimaryAddressTo.copyOf();
|
||||
copy.mSecondaryAddressFrom = mSecondaryAddressFrom.copyOf();
|
||||
copy.mSecondaryAddressTo = mSecondaryAddressTo.copyOf();
|
||||
|
||||
copy.mUpdated = mUpdated;
|
||||
|
||||
//Reset the updated flag
|
||||
mUpdated = false;
|
||||
|
||||
return copy;
|
||||
}
|
||||
}
|
||||
@@ -1,294 +0,0 @@
|
||||
/*******************************************************************************
|
||||
* 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 io.github.dsheirer.channel.metadata;
|
||||
|
||||
import io.github.dsheirer.channel.state.State;
|
||||
import io.github.dsheirer.module.decode.DecoderType;
|
||||
import io.github.dsheirer.sample.Broadcaster;
|
||||
import io.github.dsheirer.sample.Listener;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
public class MutableMetadata extends Metadata implements Listener<AttributeChangeRequest>
|
||||
{
|
||||
private final static Logger mLog = LoggerFactory.getLogger(MutableMetadata.class);
|
||||
|
||||
private Broadcaster<MutableMetadataChangeEvent> mMetadataChangeEventBroadcaster = new Broadcaster<>();
|
||||
|
||||
/**
|
||||
* Mutable channel metadata. Contains all attributes that reflect the state and current attribute values for a
|
||||
* channel that is currently decoding. This metadata is intended to support any decoding channel gui components to
|
||||
* graphically convey the current state of a decoding channel and to provide audio metadata
|
||||
*/
|
||||
public MutableMetadata()
|
||||
{
|
||||
super();
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the selected state for this metadata. Selected indicates that the user has selected this metadata for
|
||||
* immediate monitor in the audio panel. When true, this overrides the audio priority for any audio produced
|
||||
* by the channel and sets that audio to the highest priority.
|
||||
*
|
||||
* Any component that toggles the selected state for this metadata is also responsible for clearing the flag.
|
||||
*/
|
||||
public void setSelected(boolean selected)
|
||||
{
|
||||
mSelected = selected;
|
||||
mUpdated = true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the recordable flag to the argument value and overrides any recordable settings in the enclosed aliases.
|
||||
*/
|
||||
public void setRecordable(boolean recordable)
|
||||
{
|
||||
mRecordable = recordable;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the primary decoder type
|
||||
*/
|
||||
public void setPrimaryDecoderType(DecoderType decoderType)
|
||||
{
|
||||
mPrimaryDecoderType = decoderType;
|
||||
mUpdated = true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Request to change an attribute value for this metadata. This is the primary method for updating all attributes
|
||||
* in this metadata set.
|
||||
*/
|
||||
@Override
|
||||
public void receive(AttributeChangeRequest request)
|
||||
{
|
||||
switch(request.getAttribute())
|
||||
{
|
||||
case BUFFER_OVERFLOW:
|
||||
mBufferOverflow = request.getBooleanValue();
|
||||
broadcast(Attribute.BUFFER_OVERFLOW);
|
||||
break;
|
||||
case CHANNEL_CONFIGURATION_SYSTEM:
|
||||
mChannelConfigurationSystem = request.getStringValue();
|
||||
broadcast(Attribute.CHANNEL_CONFIGURATION_SYSTEM);
|
||||
break;
|
||||
case CHANNEL_CONFIGURATION_SITE:
|
||||
mChannelConfigurationSite = request.getStringValue();
|
||||
broadcast(Attribute.CHANNEL_CONFIGURATION_SITE);
|
||||
break;
|
||||
case CHANNEL_CONFIGURATION_NAME:
|
||||
mChannelConfigurationName = request.getStringValue();
|
||||
broadcast(Attribute.CHANNEL_CONFIGURATION_NAME);
|
||||
break;
|
||||
case CHANNEL_FREQUENCY:
|
||||
if(request.hasValue())
|
||||
{
|
||||
mChannelFrequency = request.getLongValue();
|
||||
}
|
||||
broadcast(Attribute.CHANNEL_FREQUENCY);
|
||||
break;
|
||||
case CHANNEL_FREQUENCY_LABEL:
|
||||
mChannelFrequencyLabel = request.getStringValue();
|
||||
broadcast(Attribute.CHANNEL_FREQUENCY_LABEL);
|
||||
break;
|
||||
case MESSAGE:
|
||||
mMessage = request.getStringValue();
|
||||
broadcast(Attribute.MESSAGE);
|
||||
break;
|
||||
case MESSAGE_TYPE:
|
||||
mMessageType = request.getStringValue();
|
||||
broadcast(Attribute.MESSAGE_TYPE);
|
||||
break;
|
||||
case NETWORK_ID_1:
|
||||
mNetworkID1.setIdentifier(request.getStringValue());
|
||||
mNetworkID1.setAlias(request.getAlias());
|
||||
broadcast(Attribute.NETWORK_ID_1);
|
||||
break;
|
||||
case NETWORK_ID_2:
|
||||
mNetworkID2.setIdentifier(request.getStringValue());
|
||||
mNetworkID2.setAlias(request.getAlias());
|
||||
broadcast(Attribute.NETWORK_ID_2);
|
||||
break;
|
||||
case PRIMARY_ADDRESS_FROM:
|
||||
mPrimaryAddressFrom.setIdentifier(request.getStringValue());
|
||||
mPrimaryAddressFrom.setAlias(request.getAlias());
|
||||
broadcast(Attribute.PRIMARY_ADDRESS_FROM);
|
||||
break;
|
||||
case PRIMARY_ADDRESS_TO:
|
||||
mPrimaryAddressTo.setIdentifier(request.getStringValue());
|
||||
mPrimaryAddressTo.setAlias(request.getAlias());
|
||||
broadcast(Attribute.PRIMARY_ADDRESS_TO);
|
||||
break;
|
||||
case PRIMARY_DECODER_TYPE:
|
||||
mPrimaryDecoderType = request.getDecoderTypeValue();
|
||||
broadcast(Attribute.PRIMARY_DECODER_TYPE);
|
||||
break;
|
||||
case SECONDARY_ADDRESS_FROM:
|
||||
mSecondaryAddressFrom.setIdentifier(request.getStringValue());
|
||||
mSecondaryAddressFrom.setAlias(request.getAlias());
|
||||
broadcast(Attribute.SECONDARY_ADDRESS_FROM);
|
||||
break;
|
||||
case SECONDARY_ADDRESS_TO:
|
||||
mSecondaryAddressTo.setIdentifier(request.getStringValue());
|
||||
mSecondaryAddressTo.setAlias(request.getAlias());
|
||||
broadcast(Attribute.SECONDARY_ADDRESS_TO);
|
||||
break;
|
||||
case CHANNEL_STATE:
|
||||
mState = (State) request.getValue();
|
||||
broadcast(Attribute.CHANNEL_STATE);
|
||||
break;
|
||||
default:
|
||||
throw new IllegalArgumentException("Unrecognized Metadata Attribute: " +
|
||||
request.getAttribute().name());
|
||||
}
|
||||
|
||||
mUpdated = true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Resets temporal attributes to null value. This only resets attributes that have a non-ull value in order to
|
||||
* limit the number of change events that are produced.
|
||||
*/
|
||||
public void resetTemporalAttributes()
|
||||
{
|
||||
mDoNotRecord = null;
|
||||
mBufferOverflow = false;
|
||||
|
||||
if(hasMessage())
|
||||
{
|
||||
mMessage = null;
|
||||
broadcast(Attribute.MESSAGE);
|
||||
}
|
||||
|
||||
if(hasMessageType())
|
||||
{
|
||||
mMessageType = null;
|
||||
broadcast(Attribute.MESSAGE_TYPE);
|
||||
}
|
||||
|
||||
if(mPrimaryAddressFrom.hasIdentifier())
|
||||
{
|
||||
mPrimaryAddressFrom.reset();
|
||||
broadcast(Attribute.PRIMARY_ADDRESS_FROM);
|
||||
}
|
||||
|
||||
if(mPrimaryAddressTo.hasIdentifier())
|
||||
{
|
||||
mPrimaryAddressTo.reset();
|
||||
broadcast(Attribute.PRIMARY_ADDRESS_TO);
|
||||
}
|
||||
|
||||
if(mSecondaryAddressFrom.hasIdentifier())
|
||||
{
|
||||
mSecondaryAddressFrom.reset();
|
||||
broadcast(Attribute.SECONDARY_ADDRESS_FROM);
|
||||
}
|
||||
|
||||
if(mSecondaryAddressTo.hasIdentifier())
|
||||
{
|
||||
mSecondaryAddressTo.reset();
|
||||
broadcast(Attribute.SECONDARY_ADDRESS_TO);
|
||||
}
|
||||
|
||||
mUpdated = true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Resets all attributes to empty values
|
||||
*/
|
||||
public void resetAllAttributes()
|
||||
{
|
||||
resetTemporalAttributes();
|
||||
|
||||
if(hasChannelConfigurationSystem())
|
||||
{
|
||||
mChannelConfigurationSystem = null;
|
||||
broadcast(Attribute.CHANNEL_CONFIGURATION_SYSTEM);
|
||||
}
|
||||
|
||||
if(hasChannelConfigurationSite())
|
||||
{
|
||||
mChannelConfigurationSite = null;
|
||||
broadcast(Attribute.CHANNEL_CONFIGURATION_SITE);
|
||||
}
|
||||
|
||||
if(hasChannelConfigurationName())
|
||||
{
|
||||
mChannelConfigurationSite = null;
|
||||
broadcast(Attribute.CHANNEL_CONFIGURATION_NAME);
|
||||
}
|
||||
|
||||
if(hasChannelFrequencyLabel())
|
||||
{
|
||||
mChannelFrequencyLabel = null;
|
||||
broadcast(Attribute.CHANNEL_FREQUENCY_LABEL);
|
||||
}
|
||||
|
||||
if(hasChannelFrequency())
|
||||
{
|
||||
mChannelFrequency = 0;
|
||||
broadcast(Attribute.CHANNEL_FREQUENCY);
|
||||
}
|
||||
|
||||
if(hasPrimaryDecoderType())
|
||||
{
|
||||
mPrimaryDecoderType = null;
|
||||
broadcast(Attribute.PRIMARY_DECODER_TYPE);
|
||||
}
|
||||
|
||||
if(mNetworkID1.hasIdentifier())
|
||||
{
|
||||
mNetworkID1.reset();
|
||||
broadcast(Attribute.NETWORK_ID_1);
|
||||
}
|
||||
|
||||
if(mNetworkID2.hasIdentifier())
|
||||
{
|
||||
mNetworkID2.reset();
|
||||
broadcast(Attribute.NETWORK_ID_2);
|
||||
}
|
||||
|
||||
mUpdated = true;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Broadcasts to registered listeners that an attribute has changed for this metadata
|
||||
*/
|
||||
private void broadcast(Attribute attribute)
|
||||
{
|
||||
mMetadataChangeEventBroadcaster.broadcast(new MutableMetadataChangeEvent(this, attribute));
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds the listener to receive metadata change events for this channel metadata
|
||||
*/
|
||||
public void addListener(Listener<MutableMetadataChangeEvent> listener)
|
||||
{
|
||||
mMetadataChangeEventBroadcaster.addListener(listener);
|
||||
}
|
||||
|
||||
/**
|
||||
* Removes the listener from receiving metadata change events for this channel metadata
|
||||
*/
|
||||
public void removeListener(Listener<MutableMetadataChangeEvent> listener)
|
||||
{
|
||||
mMetadataChangeEventBroadcaster.removeListener(listener);
|
||||
}
|
||||
}
|
||||
@@ -1,53 +0,0 @@
|
||||
/*******************************************************************************
|
||||
* 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 io.github.dsheirer.channel.metadata;
|
||||
|
||||
public class MutableMetadataChangeEvent
|
||||
{
|
||||
private MutableMetadata mMetadata;
|
||||
private Attribute mAttribute;
|
||||
|
||||
/**
|
||||
* Channel metadata changed attribute event
|
||||
*
|
||||
* @param metadata where the change occurred
|
||||
* @param attribute that changed
|
||||
*/
|
||||
public MutableMetadataChangeEvent(MutableMetadata metadata, Attribute attribute)
|
||||
{
|
||||
mMetadata = metadata;
|
||||
mAttribute = attribute;
|
||||
}
|
||||
|
||||
/**
|
||||
* Channel metadata where the change occurred
|
||||
*/
|
||||
public MutableMetadata getMetadata()
|
||||
{
|
||||
return mMetadata;
|
||||
}
|
||||
|
||||
/**
|
||||
* Channel metadata attribute that has changed
|
||||
*/
|
||||
public Attribute getAttribute()
|
||||
{
|
||||
return mAttribute;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user