mirror of
https://github.com/DSheirer/sdrtrunk.git
synced 2026-11-20 04:27:48 -05:00
Merge pull request #122 from DSheirer/#90-channel_processing_list_and_gui_reformat
#90 channel processing list and gui reformat
This commit is contained in:
1
.idea/dictionaries/denny.xml
generated
1
.idea/dictionaries/denny.xml
generated
@@ -8,6 +8,7 @@
|
|||||||
<w>icecast</w>
|
<w>icecast</w>
|
||||||
<w>ident</w>
|
<w>ident</w>
|
||||||
<w>polyphase</w>
|
<w>polyphase</w>
|
||||||
|
<w>remez</w>
|
||||||
<w>samplerate</w>
|
<w>samplerate</w>
|
||||||
<w>sdrtrunk</w>
|
<w>sdrtrunk</w>
|
||||||
<w>sheirer</w>
|
<w>sheirer</w>
|
||||||
|
|||||||
@@ -117,9 +117,9 @@ public class Alias
|
|||||||
mColor = color;
|
mColor = color;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Color getMapColor()
|
public Color getDisplayColor()
|
||||||
{
|
{
|
||||||
return new Color( mColor );
|
return new Color( getColor() );
|
||||||
}
|
}
|
||||||
|
|
||||||
@XmlAttribute
|
@XmlAttribute
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
/*******************************************************************************
|
/*******************************************************************************
|
||||||
* SDR Trunk
|
* sdrtrunk
|
||||||
* Copyright (C) 2014-2016 Dennis Sheirer
|
* Copyright (C) 2014-2017 Dennis Sheirer
|
||||||
*
|
*
|
||||||
* This program is free software: you can redistribute it and/or modify
|
* 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
|
* it under the terms of the GNU General Public License as published by
|
||||||
@@ -14,6 +14,7 @@
|
|||||||
*
|
*
|
||||||
* You should have received a copy of the GNU General Public License
|
* You should have received a copy of the GNU General Public License
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>
|
* along with this program. If not, see <http://www.gnu.org/licenses/>
|
||||||
|
*
|
||||||
******************************************************************************/
|
******************************************************************************/
|
||||||
package alias;
|
package alias;
|
||||||
|
|
||||||
@@ -29,7 +30,6 @@ import alias.id.siteID.SiteID;
|
|||||||
import alias.id.status.StatusID;
|
import alias.id.status.StatusID;
|
||||||
import alias.id.talkgroup.TalkgroupID;
|
import alias.id.talkgroup.TalkgroupID;
|
||||||
import alias.id.uniqueID.UniqueID;
|
import alias.id.uniqueID.UniqueID;
|
||||||
import audio.metadata.MetadataType;
|
|
||||||
import module.decode.lj1200.LJ1200Message.Function;
|
import module.decode.lj1200.LJ1200Message.Function;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
@@ -631,61 +631,6 @@ public class AliasList implements Listener<AliasEvent>
|
|||||||
return mName;
|
return mName;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Lookup an alias by metadata type and string value
|
|
||||||
*/
|
|
||||||
public Alias getAlias(String value, MetadataType type)
|
|
||||||
{
|
|
||||||
switch (type)
|
|
||||||
{
|
|
||||||
case ESN:
|
|
||||||
return getESNAlias(value);
|
|
||||||
case FLEETSYNC:
|
|
||||||
return getFleetsyncAlias(value);
|
|
||||||
case MDC1200:
|
|
||||||
return getMDC1200Alias(value);
|
|
||||||
case MOBILE_ID:
|
|
||||||
return getMobileIDNumberAlias(value);
|
|
||||||
case MPT1327:
|
|
||||||
return getMPT1327Alias(value);
|
|
||||||
case SITE_ID:
|
|
||||||
return getSiteID(value);
|
|
||||||
case STATUS:
|
|
||||||
if (value != null)
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
return getStatus(Integer.valueOf(value));
|
|
||||||
}
|
|
||||||
catch (Exception e)
|
|
||||||
{
|
|
||||||
//do nothing, we couldn't parse the int value
|
|
||||||
}
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case FROM:
|
|
||||||
case TO:
|
|
||||||
return getTalkgroupAlias(value);
|
|
||||||
case UNIQUE_ID:
|
|
||||||
if (value != null)
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
return getUniqueID(Integer.valueOf(value));
|
|
||||||
}
|
|
||||||
catch (Exception e)
|
|
||||||
{
|
|
||||||
//do nothing, we couldn't parse the int value
|
|
||||||
}
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Receive alias change event notifications and modify this list accordingly
|
* Receive alias change event notifications and modify this list accordingly
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -148,7 +148,7 @@ public class AliasNameEditor extends Editor<Alias>
|
|||||||
Color newColor = JColorChooser.showDialog(
|
Color newColor = JColorChooser.showDialog(
|
||||||
AliasNameEditor.this,
|
AliasNameEditor.this,
|
||||||
"Choose color for this alias",
|
"Choose color for this alias",
|
||||||
(hasItem() ? getItem().getMapColor() : null));
|
(hasItem() ? getItem().getDisplayColor() : null));
|
||||||
|
|
||||||
if(newColor != null)
|
if(newColor != null)
|
||||||
{
|
{
|
||||||
@@ -264,7 +264,7 @@ public class AliasNameEditor extends Editor<Alias>
|
|||||||
|
|
||||||
mGroupCombo.setSelectedItem(alias.getGroup());
|
mGroupCombo.setSelectedItem(alias.getGroup());
|
||||||
|
|
||||||
Color color = alias.getMapColor();
|
Color color = alias.getDisplayColor();
|
||||||
|
|
||||||
mButtonColor.setBackground(color);
|
mButtonColor.setBackground(color);
|
||||||
mButtonColor.setForeground(color);
|
mButtonColor.setForeground(color);
|
||||||
|
|||||||
@@ -47,6 +47,17 @@ public class PatchGroupAlias extends Alias
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getColor()
|
||||||
|
{
|
||||||
|
if(mPatchGroupAlias != null)
|
||||||
|
{
|
||||||
|
return mPatchGroupAlias.getColor();
|
||||||
|
}
|
||||||
|
|
||||||
|
return super.getColor();
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets an alias for this patch group ID
|
* Sets an alias for this patch group ID
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -19,12 +19,13 @@
|
|||||||
package audio;
|
package audio;
|
||||||
|
|
||||||
import alias.Alias;
|
import alias.Alias;
|
||||||
import audio.metadata.AudioMetadata;
|
|
||||||
import audio.metadata.Metadata;
|
|
||||||
import audio.metadata.MetadataType;
|
|
||||||
import audio.output.AudioOutput;
|
import audio.output.AudioOutput;
|
||||||
|
import channel.metadata.Metadata;
|
||||||
import icon.IconManager;
|
import icon.IconManager;
|
||||||
import net.miginfocom.swing.MigLayout;
|
import net.miginfocom.swing.MigLayout;
|
||||||
|
import org.slf4j.Logger;
|
||||||
|
import org.slf4j.LoggerFactory;
|
||||||
|
import properties.SystemProperties;
|
||||||
import sample.Listener;
|
import sample.Listener;
|
||||||
import settings.ColorSetting;
|
import settings.ColorSetting;
|
||||||
import settings.ColorSetting.ColorSettingName;
|
import settings.ColorSetting.ColorSettingName;
|
||||||
@@ -39,24 +40,29 @@ public class AudioChannelPanel extends JPanel
|
|||||||
implements Listener<AudioEvent>, SettingChangeListener
|
implements Listener<AudioEvent>, SettingChangeListener
|
||||||
{
|
{
|
||||||
private static final long serialVersionUID = 1L;
|
private static final long serialVersionUID = 1L;
|
||||||
|
private static final Logger mLog = LoggerFactory.getLogger(AudioChannelPanel.class);
|
||||||
|
|
||||||
private Font mFont = new Font(Font.MONOSPACED, Font.PLAIN, 12);
|
public static final String PROPERTY_PREFIX = "audio.channel.panel.color.";
|
||||||
|
public static final String PROPERTY_COLOR_BACKGROUND = PROPERTY_PREFIX + "background";
|
||||||
|
public static final String PROPERTY_COLOR_LABEL = PROPERTY_PREFIX + "label";
|
||||||
|
public static final String PROPERTY_COLOR_MUTED = PROPERTY_PREFIX + "muted";
|
||||||
|
public static final String PROPERTY_COLOR_VALUE = PROPERTY_PREFIX + "value";
|
||||||
|
|
||||||
|
private Font mFont = new Font(Font.MONOSPACED, Font.PLAIN, 16);
|
||||||
|
|
||||||
|
private Color mBackgroundColor;
|
||||||
private Color mLabelColor;
|
private Color mLabelColor;
|
||||||
private Color mDetailsColor;
|
private Color mMutedColor;
|
||||||
|
private Color mValueColor;
|
||||||
|
|
||||||
private IconManager mIconManager;
|
private IconManager mIconManager;
|
||||||
private SettingsManager mSettingsManager;
|
private SettingsManager mSettingsManager;
|
||||||
private AudioOutput mAudioOutput;
|
private AudioOutput mAudioOutput;
|
||||||
|
|
||||||
|
private JLabel mMutedLabel = new JLabel("M");
|
||||||
private JLabel mChannelName = new JLabel(" ");
|
private JLabel mChannelName = new JLabel(" ");
|
||||||
private JLabel mToLabel = new JLabel("TO:");
|
|
||||||
private JLabel mTo = new JLabel("");
|
|
||||||
private JLabel mToAlias = new JLabel(" ");
|
private JLabel mToAlias = new JLabel(" ");
|
||||||
|
private JLabel mTo = new JLabel("-----");
|
||||||
private JLabel mMutedLabel = new JLabel(" ");
|
|
||||||
private JLabel mFromLabel = new JLabel("FROM:");
|
|
||||||
private JLabel mFrom = new JLabel("");
|
|
||||||
private JLabel mFromAlias = new JLabel("");
|
|
||||||
|
|
||||||
private boolean mConfigured = false;
|
private boolean mConfigured = false;
|
||||||
|
|
||||||
@@ -71,69 +77,39 @@ public class AudioChannelPanel extends JPanel
|
|||||||
if(mAudioOutput != null)
|
if(mAudioOutput != null)
|
||||||
{
|
{
|
||||||
mAudioOutput.addAudioEventListener(this);
|
mAudioOutput.addAudioEventListener(this);
|
||||||
mAudioOutput.setAudioMetadataListener(new AudioMetadataProcessor());
|
mAudioOutput.setMetadataListener(new AudioMetadataProcessor());
|
||||||
}
|
}
|
||||||
|
|
||||||
mLabelColor = mSettingsManager.getColorSetting(
|
mBackgroundColor = SystemProperties.getInstance().get(PROPERTY_COLOR_BACKGROUND, Color.BLACK);
|
||||||
ColorSettingName.CHANNEL_STATE_LABEL_DECODER).getColor();
|
mLabelColor = SystemProperties.getInstance().get(PROPERTY_COLOR_LABEL, Color.LIGHT_GRAY);
|
||||||
mDetailsColor = mSettingsManager.getColorSetting(
|
mMutedColor = SystemProperties.getInstance().get(PROPERTY_COLOR_MUTED, Color.RED);
|
||||||
ColorSettingName.CHANNEL_STATE_LABEL_DETAILS).getColor();
|
mValueColor = SystemProperties.getInstance().get(PROPERTY_COLOR_VALUE, Color.GREEN);
|
||||||
|
|
||||||
init();
|
init();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void init()
|
private void init()
|
||||||
{
|
{
|
||||||
setLayout(new MigLayout("insets 0 0 0 0", "[][right][][grow,fill]", "[]0[]0[grow,fill]"));
|
setLayout(new MigLayout("align center center, insets 0 0 0 0", "[][][align right]0[grow,fill]", ""));
|
||||||
setBackground(Color.BLACK);
|
setBackground(mBackgroundColor);
|
||||||
|
|
||||||
|
mMutedLabel.setFont(mFont);
|
||||||
|
mMutedLabel.setForeground(mMutedColor);
|
||||||
|
mMutedLabel.setVisible(false);
|
||||||
|
add(mMutedLabel);
|
||||||
|
|
||||||
mChannelName = new JLabel(mAudioOutput != null ? mAudioOutput.getChannelName() : " ");
|
mChannelName = new JLabel(mAudioOutput != null ? mAudioOutput.getChannelName() : " ");
|
||||||
mChannelName.setFont(mFont);
|
mChannelName.setFont(mFont);
|
||||||
mChannelName.setForeground(mDetailsColor);
|
mChannelName.setForeground(mLabelColor);
|
||||||
add(mChannelName);
|
add(mChannelName);
|
||||||
|
|
||||||
mToLabel.setFont(mFont);
|
mToAlias.setFont(mFont);
|
||||||
if(mAudioOutput != null)
|
mToAlias.setForeground(mValueColor);
|
||||||
{
|
add(mToAlias);
|
||||||
mToLabel.setForeground(mLabelColor);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
mToLabel.setForeground(getBackground());
|
|
||||||
}
|
|
||||||
add(mToLabel);
|
|
||||||
|
|
||||||
mTo.setFont(mFont);
|
mTo.setFont(mFont);
|
||||||
mTo.setForeground(mLabelColor);
|
mTo.setForeground(mValueColor);
|
||||||
add(mTo);
|
add(mTo);
|
||||||
|
|
||||||
mToAlias.setFont(mFont);
|
|
||||||
mToAlias.setForeground(mLabelColor);
|
|
||||||
add(mToAlias, "wrap");
|
|
||||||
|
|
||||||
mMutedLabel.setFont(mFont);
|
|
||||||
mMutedLabel.setForeground(Color.RED);
|
|
||||||
add(mMutedLabel);
|
|
||||||
|
|
||||||
mFromLabel.setFont(mFont);
|
|
||||||
if(mAudioOutput != null)
|
|
||||||
{
|
|
||||||
mFromLabel.setForeground(mLabelColor);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
mFromLabel.setForeground(getBackground());
|
|
||||||
}
|
|
||||||
add(mFromLabel);
|
|
||||||
|
|
||||||
mFrom.setFont(mFont);
|
|
||||||
mFrom.setForeground(mLabelColor);
|
|
||||||
add(mFrom);
|
|
||||||
|
|
||||||
mFromAlias.setFont(mFont);
|
|
||||||
mFromAlias.setForeground(mLabelColor);
|
|
||||||
add(mFromAlias, "wrap");
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -158,7 +134,7 @@ public class AudioChannelPanel extends JPanel
|
|||||||
@Override
|
@Override
|
||||||
public void run()
|
public void run()
|
||||||
{
|
{
|
||||||
mMutedLabel.setText(mAudioOutput.isMuted() ? "M" : " ");
|
mMutedLabel.setVisible(mAudioOutput.isMuted());
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
break;
|
break;
|
||||||
@@ -173,11 +149,7 @@ public class AudioChannelPanel extends JPanel
|
|||||||
*/
|
*/
|
||||||
private void resetLabels()
|
private void resetLabels()
|
||||||
{
|
{
|
||||||
mFrom.setText("");
|
updateLabel(mTo, null, mToAlias, null);
|
||||||
updateAlias(mFromAlias, null);
|
|
||||||
|
|
||||||
mTo.setText("");
|
|
||||||
updateAlias(mToAlias, null);
|
|
||||||
|
|
||||||
mConfigured = false;
|
mConfigured = false;
|
||||||
}
|
}
|
||||||
@@ -187,27 +159,26 @@ public class AudioChannelPanel extends JPanel
|
|||||||
* does not occur on the Swing event thread -- wrap any calls to this
|
* does not occur on the Swing event thread -- wrap any calls to this
|
||||||
* method with an event thread call.
|
* method with an event thread call.
|
||||||
*/
|
*/
|
||||||
private void updateAlias(JLabel label, Alias alias)
|
private void updateLabel(JLabel valueLabel, String value, JLabel aliasLabel, Alias alias)
|
||||||
{
|
{
|
||||||
|
if(value != null)
|
||||||
|
{
|
||||||
|
|
||||||
if(alias != null)
|
if(alias != null)
|
||||||
{
|
{
|
||||||
label.setText(alias.getName());
|
valueLabel.setText(alias.getName());
|
||||||
|
aliasLabel.setIcon(mIconManager.getIcon(alias.getIconName(), 18));
|
||||||
String icon = alias.getIconName();
|
|
||||||
|
|
||||||
if(icon != null)
|
|
||||||
{
|
|
||||||
label.setIcon(mIconManager.getIcon(icon, IconManager.DEFAULT_ICON_SIZE));
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
label.setIcon(null);
|
valueLabel.setText(value);
|
||||||
|
aliasLabel.setIcon(null);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
label.setText("");
|
valueLabel.setText("-----");
|
||||||
label.setIcon(null);
|
aliasLabel.setIcon(null);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -215,45 +186,25 @@ public class AudioChannelPanel extends JPanel
|
|||||||
/**
|
/**
|
||||||
* Processes audio metadata to update this panel's display values
|
* Processes audio metadata to update this panel's display values
|
||||||
*/
|
*/
|
||||||
public class AudioMetadataProcessor implements Listener<AudioMetadata>
|
public class AudioMetadataProcessor implements Listener<Metadata>
|
||||||
{
|
{
|
||||||
@Override
|
@Override
|
||||||
public void receive(AudioMetadata audioMetadata)
|
public void receive(final Metadata metadata)
|
||||||
{
|
{
|
||||||
if(!mConfigured || audioMetadata.isUpdated())
|
if(metadata.isUpdated() || !mConfigured)
|
||||||
{
|
{
|
||||||
final Metadata from = audioMetadata.getMetadata(MetadataType.FROM);
|
|
||||||
|
|
||||||
final Metadata to = audioMetadata.getMetadata(MetadataType.TO);
|
|
||||||
|
|
||||||
EventQueue.invokeLater(new Runnable()
|
EventQueue.invokeLater(new Runnable()
|
||||||
{
|
{
|
||||||
@Override
|
@Override
|
||||||
public void run()
|
public void run()
|
||||||
{
|
{
|
||||||
if(from != null)
|
updateLabel(mTo, metadata.getPrimaryAddressTo().getIdentifier(),
|
||||||
{
|
mToAlias, metadata.getPrimaryAddressTo().getAlias());
|
||||||
mFrom.setText(from.getValue());
|
|
||||||
updateAlias(mFromAlias, from.getAlias());
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
mFrom.setText("-----");
|
|
||||||
}
|
|
||||||
|
|
||||||
if(to != null)
|
mConfigured = true;
|
||||||
{
|
|
||||||
mTo.setText(to.getValue());
|
|
||||||
updateAlias(mToAlias, to.getAlias());
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
mTo.setText("-----");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
mConfigured = true;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -269,14 +220,6 @@ public class AudioChannelPanel extends JPanel
|
|||||||
switch(colorSetting.getColorSettingName())
|
switch(colorSetting.getColorSettingName())
|
||||||
{
|
{
|
||||||
case CHANNEL_STATE_LABEL_DECODER:
|
case CHANNEL_STATE_LABEL_DECODER:
|
||||||
if(mFrom != null)
|
|
||||||
{
|
|
||||||
mFrom.setForeground(mLabelColor);
|
|
||||||
}
|
|
||||||
if(mFromAlias != null)
|
|
||||||
{
|
|
||||||
mFromAlias.setForeground(mLabelColor);
|
|
||||||
}
|
|
||||||
if(mTo != null)
|
if(mTo != null)
|
||||||
{
|
{
|
||||||
mTo.setForeground(mLabelColor);
|
mTo.setForeground(mLabelColor);
|
||||||
@@ -286,16 +229,6 @@ public class AudioChannelPanel extends JPanel
|
|||||||
mToAlias.setForeground(mLabelColor);
|
mToAlias.setForeground(mLabelColor);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case CHANNEL_STATE_LABEL_DETAILS:
|
|
||||||
if(mFromLabel != null)
|
|
||||||
{
|
|
||||||
mFromLabel.setForeground(mDetailsColor);
|
|
||||||
}
|
|
||||||
if(mToLabel != null)
|
|
||||||
{
|
|
||||||
mToLabel.setForeground(mDetailsColor);
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -33,15 +33,18 @@ public class AudioChannelsPanel extends JPanel
|
|||||||
|
|
||||||
public AudioChannelsPanel(IconManager iconManager, SettingsManager settingsManager, IAudioController controller)
|
public AudioChannelsPanel(IconManager iconManager, SettingsManager settingsManager, IAudioController controller)
|
||||||
{
|
{
|
||||||
setLayout(new MigLayout("insets 0 0 0 0", "[grow,fill]", "[]0[]"));
|
// setLayout(new MigLayout("insets 0 0 0 0", "[][grow,fill][][grow,fill]", "[grow,fill]"));
|
||||||
|
setLayout(new MigLayout("insets 0 0 0 0", "[][sg,grow,fill][][sg,grow,fill]", "[grow,fill]"));
|
||||||
|
|
||||||
setBackground(Color.BLACK);
|
setBackground(Color.BLACK);
|
||||||
|
|
||||||
List<AudioOutput> outputs = controller.getAudioOutputs();
|
List<AudioOutput> outputs = controller.getAudioOutputs();
|
||||||
|
|
||||||
|
addSeparator();
|
||||||
|
|
||||||
for(int x = 0; x < outputs.size(); x++)
|
for(int x = 0; x < outputs.size(); x++)
|
||||||
{
|
{
|
||||||
add(new AudioChannelPanel(iconManager, settingsManager, outputs.get(x)), "wrap");
|
add(new AudioChannelPanel(iconManager, settingsManager, outputs.get(x)), "growx");
|
||||||
|
|
||||||
if(x < outputs.size() - 1)
|
if(x < outputs.size() - 1)
|
||||||
{
|
{
|
||||||
@@ -54,14 +57,14 @@ public class AudioChannelsPanel extends JPanel
|
|||||||
if(outputs.size() == 1)
|
if(outputs.size() == 1)
|
||||||
{
|
{
|
||||||
addSeparator();
|
addSeparator();
|
||||||
add(new AudioChannelPanel(iconManager, settingsManager, null), "wrap");
|
add(new AudioChannelPanel(iconManager, settingsManager, null), "growx");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void addSeparator()
|
private void addSeparator()
|
||||||
{
|
{
|
||||||
JSeparator separator = new JSeparator(JSeparator.HORIZONTAL);
|
JSeparator separator = new JSeparator(JSeparator.VERTICAL);
|
||||||
separator.setBackground(Color.DARK_GRAY);
|
separator.setBackground(Color.DARK_GRAY);
|
||||||
add(separator, "span,growx");
|
add(separator);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
/*******************************************************************************
|
/*******************************************************************************
|
||||||
* SDR Trunk
|
* sdrtrunk
|
||||||
* Copyright (C) 2014-2016 Dennis Sheirer
|
* Copyright (C) 2014-2017 Dennis Sheirer
|
||||||
*
|
*
|
||||||
* This program is free software: you can redistribute it and/or modify
|
* 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
|
* it under the terms of the GNU General Public License as published by
|
||||||
@@ -14,9 +14,27 @@
|
|||||||
*
|
*
|
||||||
* You should have received a copy of the GNU General Public License
|
* You should have received a copy of the GNU General Public License
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>
|
* along with this program. If not, see <http://www.gnu.org/licenses/>
|
||||||
|
*
|
||||||
******************************************************************************/
|
******************************************************************************/
|
||||||
package audio;
|
package audio;
|
||||||
|
|
||||||
|
import audio.AudioEvent.Type;
|
||||||
|
import audio.output.AudioOutput;
|
||||||
|
import audio.output.MonoAudioOutput;
|
||||||
|
import audio.output.StereoAudioOutput;
|
||||||
|
import controller.ThreadPoolManager;
|
||||||
|
import controller.ThreadPoolManager.ThreadType;
|
||||||
|
import org.slf4j.Logger;
|
||||||
|
import org.slf4j.LoggerFactory;
|
||||||
|
import properties.SystemProperties;
|
||||||
|
import sample.Broadcaster;
|
||||||
|
import sample.Listener;
|
||||||
|
import source.mixer.MixerChannel;
|
||||||
|
import source.mixer.MixerChannelConfiguration;
|
||||||
|
import source.mixer.MixerManager;
|
||||||
|
|
||||||
|
import javax.sound.sampled.AudioSystem;
|
||||||
|
import javax.sound.sampled.Mixer;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.Comparator;
|
import java.util.Comparator;
|
||||||
@@ -27,25 +45,6 @@ import java.util.concurrent.LinkedTransferQueue;
|
|||||||
import java.util.concurrent.ScheduledFuture;
|
import java.util.concurrent.ScheduledFuture;
|
||||||
import java.util.concurrent.TimeUnit;
|
import java.util.concurrent.TimeUnit;
|
||||||
|
|
||||||
import javax.sound.sampled.AudioSystem;
|
|
||||||
import javax.sound.sampled.Mixer;
|
|
||||||
|
|
||||||
import org.slf4j.Logger;
|
|
||||||
import org.slf4j.LoggerFactory;
|
|
||||||
|
|
||||||
import properties.SystemProperties;
|
|
||||||
import sample.Broadcaster;
|
|
||||||
import sample.Listener;
|
|
||||||
import source.mixer.MixerChannel;
|
|
||||||
import source.mixer.MixerChannelConfiguration;
|
|
||||||
import source.mixer.MixerManager;
|
|
||||||
import audio.AudioEvent.Type;
|
|
||||||
import audio.output.AudioOutput;
|
|
||||||
import audio.output.MonoAudioOutput;
|
|
||||||
import audio.output.StereoAudioOutput;
|
|
||||||
import controller.ThreadPoolManager;
|
|
||||||
import controller.ThreadPoolManager.ThreadType;
|
|
||||||
|
|
||||||
public class AudioManager implements Listener<AudioPacket>, IAudioController
|
public class AudioManager implements Listener<AudioPacket>, IAudioController
|
||||||
{
|
{
|
||||||
private static final Logger mLog = LoggerFactory.getLogger(AudioManager.class);
|
private static final Logger mLog = LoggerFactory.getLogger(AudioManager.class);
|
||||||
@@ -119,12 +118,11 @@ public class AudioManager implements Listener<AudioPacket>, IAudioController
|
|||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
setMixerChannelConfiguration( configuration );
|
setMixerChannelConfiguration(configuration, false);
|
||||||
}
|
}
|
||||||
catch(Exception e)
|
catch(Exception e)
|
||||||
{
|
{
|
||||||
mLog.error( "Couldn't set stored audio mixer/channel configuration"
|
mLog.error("Couldn't set stored audio mixer/channel configuration - using default", e);
|
||||||
+ " - using default", e );
|
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
@@ -132,8 +130,7 @@ public class AudioManager implements Listener<AudioPacket>, IAudioController
|
|||||||
}
|
}
|
||||||
catch(Exception e2)
|
catch(Exception e2)
|
||||||
{
|
{
|
||||||
mLog.error( "Couldn't set default audio mixer/channel "
|
mLog.error("Couldn't set default audio mixer/channel configuration - no audio will be available", e2);
|
||||||
+ "configuration - no audio will be available", e2 );
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -184,9 +181,9 @@ public class AudioManager implements Listener<AudioPacket>, IAudioController
|
|||||||
for(AudioOutputConnection connection : mAudioOutputConnections)
|
for(AudioOutputConnection connection : mAudioOutputConnections)
|
||||||
{
|
{
|
||||||
if(connection.isInactive() &&
|
if(connection.isInactive() &&
|
||||||
mChannelConnectionMap.containsKey( connection.getSource() ) )
|
mChannelConnectionMap.containsKey(connection.getChannelMetadataID()))
|
||||||
{
|
{
|
||||||
mChannelConnectionMap.remove( connection.getSource() );
|
mChannelConnectionMap.remove(connection.getChannelMetadataID());
|
||||||
connection.disconnect();
|
connection.disconnect();
|
||||||
changed = true;
|
changed = true;
|
||||||
}
|
}
|
||||||
@@ -208,8 +205,7 @@ public class AudioManager implements Listener<AudioPacket>, IAudioController
|
|||||||
for(AudioOutputConnection connection : mAudioOutputConnections)
|
for(AudioOutputConnection connection : mAudioOutputConnections)
|
||||||
{
|
{
|
||||||
if(connection.isConnected() &&
|
if(connection.isConnected() &&
|
||||||
( mLowestPriorityConnection == null ||
|
(mLowestPriorityConnection == null || mLowestPriorityConnection.getPriority() > connection.getPriority()))
|
||||||
mLowestPriorityConnection.getPriority() > connection.getPriority() ) )
|
|
||||||
{
|
{
|
||||||
mLowestPriorityConnection = connection;
|
mLowestPriorityConnection = connection;
|
||||||
}
|
}
|
||||||
@@ -219,9 +215,12 @@ public class AudioManager implements Listener<AudioPacket>, IAudioController
|
|||||||
@Override
|
@Override
|
||||||
public void setMixerChannelConfiguration(MixerChannelConfiguration entry) throws AudioException
|
public void setMixerChannelConfiguration(MixerChannelConfiguration entry) throws AudioException
|
||||||
{
|
{
|
||||||
if( entry != null &&
|
setMixerChannelConfiguration(entry, true);
|
||||||
( entry.getMixerChannel() == MixerChannel.MONO ||
|
}
|
||||||
entry.getMixerChannel() == MixerChannel.STEREO ) )
|
|
||||||
|
public void setMixerChannelConfiguration(MixerChannelConfiguration entry, boolean saveSettings) throws AudioException
|
||||||
|
{
|
||||||
|
if(entry != null && (entry.getMixerChannel() == MixerChannel.MONO || entry.getMixerChannel() == MixerChannel.STEREO))
|
||||||
{
|
{
|
||||||
mControllerBroadcaster.broadcast(CONFIGURATION_CHANGE_STARTED);
|
mControllerBroadcaster.broadcast(CONFIGURATION_CHANGE_STARTED);
|
||||||
|
|
||||||
@@ -242,14 +241,12 @@ public class AudioManager implements Listener<AudioPacket>, IAudioController
|
|||||||
mAudioOutputMap.put(mono.getChannelName(), mono);
|
mAudioOutputMap.put(mono.getChannelName(), mono);
|
||||||
break;
|
break;
|
||||||
case STEREO:
|
case STEREO:
|
||||||
AudioOutput left = new StereoAudioOutput( mThreadPoolManager,
|
AudioOutput left = new StereoAudioOutput(mThreadPoolManager, entry.getMixer(), MixerChannel.LEFT);
|
||||||
entry.getMixer(), MixerChannel.LEFT );
|
|
||||||
mAudioOutputConnections.add(new AudioOutputConnection(left));
|
mAudioOutputConnections.add(new AudioOutputConnection(left));
|
||||||
mAvailableConnectionCount++;
|
mAvailableConnectionCount++;
|
||||||
mAudioOutputMap.put(left.getChannelName(), left);
|
mAudioOutputMap.put(left.getChannelName(), left);
|
||||||
|
|
||||||
AudioOutput right = new StereoAudioOutput( mThreadPoolManager,
|
AudioOutput right = new StereoAudioOutput(mThreadPoolManager, entry.getMixer(), MixerChannel.RIGHT);
|
||||||
entry.getMixer(), MixerChannel.RIGHT );
|
|
||||||
mAudioOutputConnections.add(new AudioOutputConnection(right));
|
mAudioOutputConnections.add(new AudioOutputConnection(right));
|
||||||
mAvailableConnectionCount++;
|
mAvailableConnectionCount++;
|
||||||
mAudioOutputMap.put(right.getChannelName(), right);
|
mAudioOutputMap.put(right.getChannelName(), right);
|
||||||
@@ -265,11 +262,12 @@ public class AudioManager implements Listener<AudioPacket>, IAudioController
|
|||||||
|
|
||||||
mControllerBroadcaster.broadcast(CONFIGURATION_CHANGE_COMPLETE);
|
mControllerBroadcaster.broadcast(CONFIGURATION_CHANGE_COMPLETE);
|
||||||
|
|
||||||
|
if(saveSettings)
|
||||||
|
{
|
||||||
SystemProperties properties = SystemProperties.getInstance();
|
SystemProperties properties = SystemProperties.getInstance();
|
||||||
|
|
||||||
properties.set(AUDIO_MIXER_PROPERTY, entry.getMixer().getMixerInfo().getName());
|
properties.set(AUDIO_MIXER_PROPERTY, entry.getMixer().getMixerInfo().getName());
|
||||||
properties.set(AUDIO_CHANNELS_PROPERTY, entry.getMixerChannel().name());
|
properties.set(AUDIO_CHANNELS_PROPERTY, entry.getMixerChannel().name());
|
||||||
properties.save();
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -341,12 +339,12 @@ public class AudioManager implements Listener<AudioPacket>, IAudioController
|
|||||||
*/
|
*/
|
||||||
private AudioOutputConnection getConnection(AudioPacket packet)
|
private AudioOutputConnection getConnection(AudioPacket packet)
|
||||||
{
|
{
|
||||||
int source = packet.getAudioMetadata().getSource();
|
int channelMetadataID = packet.getMetadata().getMetadataID();
|
||||||
|
|
||||||
//Use an existing connection
|
//Use an existing connection
|
||||||
if( mChannelConnectionMap.containsKey( source ) )
|
if(mChannelConnectionMap.containsKey(channelMetadataID))
|
||||||
{
|
{
|
||||||
return mChannelConnectionMap.get( source );
|
return mChannelConnectionMap.get(channelMetadataID);
|
||||||
}
|
}
|
||||||
|
|
||||||
//Connect to and use an available connection
|
//Connect to and use an available connection
|
||||||
@@ -356,8 +354,8 @@ public class AudioManager implements Listener<AudioPacket>, IAudioController
|
|||||||
{
|
{
|
||||||
if(connection.isDisconnected())
|
if(connection.isDisconnected())
|
||||||
{
|
{
|
||||||
connection.connect( source );
|
connection.connect(channelMetadataID);
|
||||||
mChannelConnectionMap.put( source, connection );
|
mChannelConnectionMap.put(channelMetadataID, connection);
|
||||||
return connection;
|
return connection;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -365,18 +363,18 @@ public class AudioManager implements Listener<AudioPacket>, IAudioController
|
|||||||
//Preempt an existing connection and connect it to this higher priority source
|
//Preempt an existing connection and connect it to this higher priority source
|
||||||
else //Check for a channel priority override
|
else //Check for a channel priority override
|
||||||
{
|
{
|
||||||
int priority = packet.getAudioMetadata().getPriority();
|
int priority = packet.getMetadata().getAudioPriority();
|
||||||
|
|
||||||
if(mLowestPriorityConnection != null &&
|
if(mLowestPriorityConnection != null &&
|
||||||
priority < mLowestPriorityConnection.getPriority())
|
priority < mLowestPriorityConnection.getPriority())
|
||||||
{
|
{
|
||||||
AudioOutputConnection connection = mLowestPriorityConnection;
|
AudioOutputConnection connection = mLowestPriorityConnection;
|
||||||
|
|
||||||
mChannelConnectionMap.remove( connection.getSource() );
|
mChannelConnectionMap.remove(connection.getChannelMetadataID());
|
||||||
|
|
||||||
connection.connect( source );
|
connection.connect(channelMetadataID);
|
||||||
|
|
||||||
mChannelConnectionMap.put( source, connection );
|
mChannelConnectionMap.put(channelMetadataID, connection);
|
||||||
|
|
||||||
updateLowestPriorityAssignment();
|
updateLowestPriorityAssignment();
|
||||||
|
|
||||||
@@ -405,8 +403,7 @@ public class AudioManager implements Listener<AudioPacket>, IAudioController
|
|||||||
for(AudioPacket packet : packets)
|
for(AudioPacket packet : packets)
|
||||||
{
|
{
|
||||||
/* Don't process any packet's marked as do not monitor */
|
/* Don't process any packet's marked as do not monitor */
|
||||||
if( !packet.getAudioMetadata().isDoNotMonitor() &&
|
if(!packet.getMetadata().isDoNotMonitor() && packet.getType() == AudioPacket.Type.AUDIO)
|
||||||
packet.getType() == AudioPacket.Type.AUDIO )
|
|
||||||
{
|
{
|
||||||
AudioOutputConnection connection = getConnection(packet);
|
AudioOutputConnection connection = getConnection(packet);
|
||||||
|
|
||||||
@@ -436,7 +433,7 @@ public class AudioManager implements Listener<AudioPacket>, IAudioController
|
|||||||
|
|
||||||
private AudioOutput mAudioOutput;
|
private AudioOutput mAudioOutput;
|
||||||
private int mPriority = 0;
|
private int mPriority = 0;
|
||||||
private int mSource = DISCONNECTED;
|
private int mChannelMetadataID = DISCONNECTED;
|
||||||
|
|
||||||
public AudioOutputConnection(AudioOutput audioOutput)
|
public AudioOutputConnection(AudioOutput audioOutput)
|
||||||
{
|
{
|
||||||
@@ -445,10 +442,9 @@ public class AudioManager implements Listener<AudioPacket>, IAudioController
|
|||||||
|
|
||||||
public void receive(AudioPacket packet)
|
public void receive(AudioPacket packet)
|
||||||
{
|
{
|
||||||
if( packet.hasAudioMetadata() &&
|
if(packet.hasMetadata() && packet.getMetadata().getMetadataID() == mChannelMetadataID)
|
||||||
packet.getAudioMetadata().getSource() == mSource )
|
|
||||||
{
|
{
|
||||||
int priority = packet.getAudioMetadata().getPriority();
|
int priority = packet.getMetadata().getAudioPriority();
|
||||||
|
|
||||||
if(mPriority != priority)
|
if(mPriority != priority)
|
||||||
{
|
{
|
||||||
@@ -463,17 +459,14 @@ public class AudioManager implements Listener<AudioPacket>, IAudioController
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if( packet.hasAudioMetadata() )
|
if(packet.hasMetadata())
|
||||||
{
|
{
|
||||||
mLog.error( "Received audio packet from channel source [" +
|
mLog.error("Received audio packet from channel metadata [" + packet.getMetadata().getMetadataID() +
|
||||||
packet.getAudioMetadata().getSource() +
|
"] however this assignment is currently connected to metadata [" + mChannelMetadataID + "]");
|
||||||
"] however this assignment is currently connected "
|
|
||||||
+ "to channel source [" + mSource + "]" );
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
mLog.error( "Received audio packet with no metadata - "
|
mLog.error("Received audio packet with no metadata - cannot route audio packet");
|
||||||
+ "cannot route audio packet" );
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -492,7 +485,7 @@ public class AudioManager implements Listener<AudioPacket>, IAudioController
|
|||||||
*/
|
*/
|
||||||
public boolean isDisconnected()
|
public boolean isDisconnected()
|
||||||
{
|
{
|
||||||
return mSource == DISCONNECTED;
|
return mChannelMetadataID == DISCONNECTED;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -509,7 +502,7 @@ public class AudioManager implements Listener<AudioPacket>, IAudioController
|
|||||||
*/
|
*/
|
||||||
public void connect(int source)
|
public void connect(int source)
|
||||||
{
|
{
|
||||||
mSource = source;
|
mChannelMetadataID = source;
|
||||||
|
|
||||||
mAudioOutput.updateTimestamp();
|
mAudioOutput.updateTimestamp();
|
||||||
}
|
}
|
||||||
@@ -517,9 +510,9 @@ public class AudioManager implements Listener<AudioPacket>, IAudioController
|
|||||||
/**
|
/**
|
||||||
* Currently connected source or -1 if disconnected
|
* Currently connected source or -1 if disconnected
|
||||||
*/
|
*/
|
||||||
public int getSource()
|
public int getChannelMetadataID()
|
||||||
{
|
{
|
||||||
return mSource;
|
return mChannelMetadataID;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -528,7 +521,7 @@ public class AudioManager implements Listener<AudioPacket>, IAudioController
|
|||||||
*/
|
*/
|
||||||
public void disconnect()
|
public void disconnect()
|
||||||
{
|
{
|
||||||
mSource = DISCONNECTED;
|
mChannelMetadataID = DISCONNECTED;
|
||||||
mPriority = 0;
|
mPriority = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,29 +1,38 @@
|
|||||||
|
/*******************************************************************************
|
||||||
|
* 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 audio;
|
package audio;
|
||||||
|
|
||||||
import java.util.Arrays;
|
import audio.squelch.ISquelchStateListener;
|
||||||
import java.util.concurrent.ScheduledExecutorService;
|
import audio.squelch.SquelchState;
|
||||||
|
import channel.metadata.Metadata;
|
||||||
import dsp.filter.design.FilterDesignException;
|
import dsp.filter.design.FilterDesignException;
|
||||||
import dsp.filter.fir.FIRFilterSpecification;
|
import dsp.filter.fir.FIRFilterSpecification;
|
||||||
import dsp.filter.fir.remez.RemezFIRFilterDesigner;
|
import dsp.filter.fir.remez.RemezFIRFilterDesigner;
|
||||||
import dsp.filter.polyphase.PolyphaseFIRDecimatingFilter_RB;
|
import dsp.filter.polyphase.PolyphaseFIRDecimatingFilter_RB;
|
||||||
import module.Module;
|
import module.Module;
|
||||||
|
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
import sample.Listener;
|
import sample.Listener;
|
||||||
import sample.real.IFilteredRealBufferListener;
|
import sample.real.IFilteredRealBufferListener;
|
||||||
import sample.real.RealBuffer;
|
import sample.real.RealBuffer;
|
||||||
import audio.metadata.AudioMetadata;
|
|
||||||
import audio.metadata.IMetadataListener;
|
import java.util.concurrent.ScheduledExecutorService;
|
||||||
import audio.metadata.Metadata;
|
|
||||||
import audio.squelch.ISquelchStateListener;
|
|
||||||
import audio.squelch.SquelchState;
|
|
||||||
import controller.channel.ChannelEvent;
|
|
||||||
import controller.channel.IChannelEventListener;
|
|
||||||
import dsp.filter.Filters;
|
|
||||||
import dsp.filter.fir.real.RealFIRFilter_R_R;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Provides packaging of demodulated audio sample buffers into audio packets for
|
* Provides packaging of demodulated audio sample buffers into audio packets for
|
||||||
@@ -33,12 +42,8 @@ import dsp.filter.fir.real.RealFIRFilter_R_R;
|
|||||||
* Incorporates audio squelch state listener to control if audio packets are
|
* Incorporates audio squelch state listener to control if audio packets are
|
||||||
* broadcast or ignored.
|
* broadcast or ignored.
|
||||||
*/
|
*/
|
||||||
public class AudioModule extends Module implements IAudioPacketProvider,
|
public class AudioModule extends Module implements IAudioPacketProvider, IFilteredRealBufferListener,
|
||||||
IChannelEventListener,
|
ISquelchStateListener, Listener<RealBuffer>
|
||||||
IMetadataListener,
|
|
||||||
IFilteredRealBufferListener,
|
|
||||||
ISquelchStateListener,
|
|
||||||
Listener<RealBuffer>
|
|
||||||
{
|
{
|
||||||
protected static final Logger mLog = LoggerFactory.getLogger(AudioModule.class);
|
protected static final Logger mLog = LoggerFactory.getLogger(AudioModule.class);
|
||||||
|
|
||||||
@@ -74,22 +79,15 @@ public class AudioModule extends Module implements IAudioPacketProvider,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Provides a unique identifier for this audio module instance to use as a
|
|
||||||
* source identifier for all audio packets */
|
|
||||||
private static int UNIQUE_ID = 0;
|
|
||||||
private int mSourceID;
|
|
||||||
|
|
||||||
private AudioMetadata mAudioMetadata;
|
|
||||||
private ChannelEventListener mChannelEventListener = new ChannelEventListener();
|
|
||||||
private SquelchStateListener mSquelchStateListener = new SquelchStateListener();
|
private SquelchStateListener mSquelchStateListener = new SquelchStateListener();
|
||||||
private SquelchState mSquelchState = SquelchState.SQUELCH;
|
private SquelchState mSquelchState = SquelchState.SQUELCH;
|
||||||
private Listener<AudioPacket> mAudioPacketListener;
|
private Listener<AudioPacket> mAudioPacketListener;
|
||||||
private PolyphaseFIRDecimatingFilter_RB mAudioDecimationFilter;
|
private PolyphaseFIRDecimatingFilter_RB mAudioDecimationFilter;
|
||||||
|
private Metadata mMetadata;
|
||||||
|
|
||||||
public AudioModule(boolean record)
|
public AudioModule(Metadata metadata)
|
||||||
{
|
{
|
||||||
mSourceID = ++UNIQUE_ID;
|
mMetadata = metadata;
|
||||||
mAudioMetadata = new AudioMetadata(mSourceID, record);
|
|
||||||
|
|
||||||
mAudioDecimationFilter = new PolyphaseFIRDecimatingFilter_RB(mDecimationCoefficients, 6, 2.0f);
|
mAudioDecimationFilter = new PolyphaseFIRDecimatingFilter_RB(mDecimationCoefficients, 6, 2.0f);
|
||||||
mAudioDecimationFilter.setListener(new Listener<RealBuffer>()
|
mAudioDecimationFilter.setListener(new Listener<RealBuffer>()
|
||||||
@@ -99,7 +97,7 @@ public class AudioModule extends Module implements IAudioPacketProvider,
|
|||||||
{
|
{
|
||||||
if(mAudioPacketListener != null)
|
if(mAudioPacketListener != null)
|
||||||
{
|
{
|
||||||
AudioPacket packet = new AudioPacket(realBuffer.getSamples(), mAudioMetadata.copyOf());
|
AudioPacket packet = new AudioPacket(realBuffer.getSamples(), mMetadata.copyOf());
|
||||||
mAudioPacketListener.receive(packet);
|
mAudioPacketListener.receive(packet);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -116,7 +114,6 @@ public class AudioModule extends Module implements IAudioPacketProvider,
|
|||||||
@Override
|
@Override
|
||||||
public void reset()
|
public void reset()
|
||||||
{
|
{
|
||||||
mAudioMetadata.reset();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -131,8 +128,7 @@ public class AudioModule extends Module implements IAudioPacketProvider,
|
|||||||
/* Issue an end audio packet in case a recorder is still rolling */
|
/* Issue an end audio packet in case a recorder is still rolling */
|
||||||
if(mAudioPacketListener != null)
|
if(mAudioPacketListener != null)
|
||||||
{
|
{
|
||||||
mAudioPacketListener.receive(new AudioPacket(AudioPacket.Type.END,
|
mAudioPacketListener.receive(new AudioPacket(AudioPacket.Type.END, mMetadata.copyOf()));
|
||||||
mAudioMetadata.copyOf()));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -146,12 +142,6 @@ public class AudioModule extends Module implements IAudioPacketProvider,
|
|||||||
if(mAudioPacketListener != null && mSquelchState == SquelchState.UNSQUELCH)
|
if(mAudioPacketListener != null && mSquelchState == SquelchState.UNSQUELCH)
|
||||||
{
|
{
|
||||||
mAudioDecimationFilter.receive(buffer);
|
mAudioDecimationFilter.receive(buffer);
|
||||||
|
|
||||||
// /* We make a copy of the samples, so that we don't affect any other
|
|
||||||
// * processes that might be concurrently processing the same buffer */
|
|
||||||
// float[] audio = Arrays.copyOf( buffer.getSamples(), buffer.getSamples().length );
|
|
||||||
//
|
|
||||||
// mAudioFilter.filter( audio );
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -161,12 +151,6 @@ public class AudioModule extends Module implements IAudioPacketProvider,
|
|||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public Listener<Metadata> getMetadataListener()
|
|
||||||
{
|
|
||||||
return mAudioMetadata;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setAudioPacketListener(Listener<AudioPacket> listener)
|
public void setAudioPacketListener(Listener<AudioPacket> listener)
|
||||||
{
|
{
|
||||||
@@ -179,41 +163,12 @@ public class AudioModule extends Module implements IAudioPacketProvider,
|
|||||||
mAudioPacketListener = null;
|
mAudioPacketListener = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public Listener<ChannelEvent> getChannelEventListener()
|
|
||||||
{
|
|
||||||
return mChannelEventListener;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Listener<SquelchState> getSquelchStateListener()
|
public Listener<SquelchState> getSquelchStateListener()
|
||||||
{
|
{
|
||||||
return mSquelchStateListener;
|
return mSquelchStateListener;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Wrapper for channel event listener. Responds to channel state reset
|
|
||||||
* events to remove/cleanup current audio metadata
|
|
||||||
*/
|
|
||||||
public class ChannelEventListener implements Listener<ChannelEvent>
|
|
||||||
{
|
|
||||||
@Override
|
|
||||||
public void receive(ChannelEvent event)
|
|
||||||
{
|
|
||||||
switch (event.getEvent())
|
|
||||||
{
|
|
||||||
case NOTIFICATION_STATE_RESET:
|
|
||||||
mAudioMetadata.reset();
|
|
||||||
break;
|
|
||||||
case NOTIFICATION_SELECTION_CHANGE:
|
|
||||||
mAudioMetadata.setSelected(event.getChannel().isSelected());
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Wrapper for squelch state listener
|
* Wrapper for squelch state listener
|
||||||
*/
|
*/
|
||||||
@@ -224,8 +179,7 @@ public class AudioModule extends Module implements IAudioPacketProvider,
|
|||||||
{
|
{
|
||||||
if(state == SquelchState.SQUELCH && mAudioPacketListener != null)
|
if(state == SquelchState.SQUELCH && mAudioPacketListener != null)
|
||||||
{
|
{
|
||||||
mAudioPacketListener.receive(new AudioPacket(AudioPacket.Type.END,
|
mAudioPacketListener.receive(new AudioPacket(AudioPacket.Type.END, mMetadata.copyOf()));
|
||||||
mAudioMetadata.copyOf()));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
mSquelchState = state;
|
mSquelchState = state;
|
||||||
|
|||||||
@@ -1,11 +1,6 @@
|
|||||||
package audio;
|
|
||||||
|
|
||||||
import sample.real.RealBuffer;
|
|
||||||
import audio.metadata.AudioMetadata;
|
|
||||||
|
|
||||||
/*******************************************************************************
|
/*******************************************************************************
|
||||||
* SDR Trunk
|
* sdrtrunk
|
||||||
* Copyright (C) 2014,2016 Dennis Sheirer
|
* Copyright (C) 2014-2017 Dennis Sheirer
|
||||||
*
|
*
|
||||||
* This program is free software: you can redistribute it and/or modify
|
* 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
|
* it under the terms of the GNU General Public License as published by
|
||||||
@@ -19,39 +14,45 @@ import audio.metadata.AudioMetadata;
|
|||||||
*
|
*
|
||||||
* You should have received a copy of the GNU General Public License
|
* You should have received a copy of the GNU General Public License
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>
|
* along with this program. If not, see <http://www.gnu.org/licenses/>
|
||||||
|
*
|
||||||
******************************************************************************/
|
******************************************************************************/
|
||||||
|
package audio;
|
||||||
|
|
||||||
|
import channel.metadata.Metadata;
|
||||||
|
import sample.real.RealBuffer;
|
||||||
|
|
||||||
public class AudioPacket
|
public class AudioPacket
|
||||||
{
|
{
|
||||||
private Type mType;
|
private Type mType;
|
||||||
private RealBuffer mAudioData;
|
private RealBuffer mAudioData;
|
||||||
private AudioMetadata mAudioMetadata;
|
private Metadata mMetadata;
|
||||||
|
|
||||||
public AudioPacket( Type type, AudioMetadata metadata )
|
public AudioPacket(Type type, Metadata metadata)
|
||||||
{
|
{
|
||||||
mType = type;
|
mType = type;
|
||||||
mAudioMetadata = metadata;
|
mMetadata = metadata;
|
||||||
}
|
}
|
||||||
|
|
||||||
public AudioPacket( float[] audio, AudioMetadata metadata )
|
public AudioPacket(float[] audio, Metadata metadata)
|
||||||
{
|
{
|
||||||
this(Type.AUDIO, metadata);
|
this(Type.AUDIO, metadata);
|
||||||
|
|
||||||
mAudioData = new RealBuffer(audio);
|
mAudioData = new RealBuffer(audio);
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean hasAudioMetadata()
|
public boolean hasMetadata()
|
||||||
{
|
{
|
||||||
return mAudioMetadata != null;
|
return mMetadata != null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public AudioMetadata getAudioMetadata()
|
public Metadata getMetadata()
|
||||||
{
|
{
|
||||||
return mAudioMetadata;
|
return mMetadata;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setMetadata( AudioMetadata metadata )
|
public void setMetadata(Metadata metadata)
|
||||||
{
|
{
|
||||||
mAudioMetadata = metadata;
|
mMetadata = metadata;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Type getType()
|
public Type getType()
|
||||||
|
|||||||
@@ -45,9 +45,9 @@ public class AudioPanel extends JPanel implements Listener<AudioEvent>
|
|||||||
private static final Logger mLog = LoggerFactory.getLogger(AudioPanel.class);
|
private static final Logger mLog = LoggerFactory.getLogger(AudioPanel.class);
|
||||||
|
|
||||||
private static ImageIcon MUTED_ICON = IconManager.getScaledIcon(
|
private static ImageIcon MUTED_ICON = IconManager.getScaledIcon(
|
||||||
new ImageIcon("images/audio_muted.png"), 38);
|
new ImageIcon("images/audio_muted.png"), 20);
|
||||||
private static ImageIcon UNMUTED_ICON = IconManager.getScaledIcon(
|
private static ImageIcon UNMUTED_ICON = IconManager.getScaledIcon(
|
||||||
new ImageIcon("images/audio_unmuted.png"), 38);
|
new ImageIcon("images/audio_unmuted.png"), 20);
|
||||||
|
|
||||||
private IconManager mIconManager;
|
private IconManager mIconManager;
|
||||||
private SettingsManager mSettingsManager;
|
private SettingsManager mSettingsManager;
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
/*******************************************************************************
|
/*******************************************************************************
|
||||||
* sdrtrunk
|
* sdrtrunk
|
||||||
* Copyright (C) 2014-2016 Dennis Sheirer
|
* Copyright (C) 2014-2017 Dennis Sheirer
|
||||||
*
|
*
|
||||||
* This program is free software: you can redistribute it and/or modify
|
* 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
|
* it under the terms of the GNU General Public License as published by
|
||||||
@@ -18,14 +18,11 @@
|
|||||||
******************************************************************************/
|
******************************************************************************/
|
||||||
package audio.broadcast;
|
package audio.broadcast;
|
||||||
|
|
||||||
import audio.AudioPacket;
|
|
||||||
import audio.IAudioPacketListener;
|
|
||||||
import audio.convert.ISilenceGenerator;
|
import audio.convert.ISilenceGenerator;
|
||||||
import audio.metadata.AudioMetadata;
|
import channel.metadata.Metadata;
|
||||||
import controller.ThreadPoolManager;
|
import controller.ThreadPoolManager;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
import properties.SystemProperties;
|
|
||||||
import sample.Listener;
|
import sample.Listener;
|
||||||
|
|
||||||
import java.io.ByteArrayInputStream;
|
import java.io.ByteArrayInputStream;
|
||||||
@@ -34,7 +31,6 @@ import java.nio.file.Files;
|
|||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.concurrent.CopyOnWriteArrayList;
|
import java.util.concurrent.CopyOnWriteArrayList;
|
||||||
import java.util.concurrent.LinkedTransferQueue;
|
|
||||||
import java.util.concurrent.ScheduledFuture;
|
import java.util.concurrent.ScheduledFuture;
|
||||||
import java.util.concurrent.TimeUnit;
|
import java.util.concurrent.TimeUnit;
|
||||||
import java.util.concurrent.atomic.AtomicBoolean;
|
import java.util.concurrent.atomic.AtomicBoolean;
|
||||||
@@ -107,9 +103,10 @@ public abstract class AudioBroadcaster implements Listener<AudioRecording>
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Broadcasts the next song's audio metadata prior to streaming the next song.
|
* Broadcasts the next song's audio metadata prior to streaming the next song.
|
||||||
|
*
|
||||||
* @param metadata for the next recording that will be streamed
|
* @param metadata for the next recording that will be streamed
|
||||||
*/
|
*/
|
||||||
protected void broadcastMetadata(AudioMetadata metadata)
|
protected void broadcastMetadata(Metadata metadata)
|
||||||
{
|
{
|
||||||
IBroadcastMetadataUpdater metadataUpdater = getMetadataUpdater();
|
IBroadcastMetadataUpdater metadataUpdater = getMetadataUpdater();
|
||||||
|
|
||||||
@@ -160,6 +157,7 @@ public abstract class AudioBroadcaster implements Listener<AudioRecording>
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Stream name for the broadcast configuration for this broadcaster
|
* Stream name for the broadcast configuration for this broadcaster
|
||||||
|
*
|
||||||
* @return stream name or null
|
* @return stream name or null
|
||||||
*/
|
*/
|
||||||
public String getStreamName()
|
public String getStreamName()
|
||||||
@@ -260,10 +258,17 @@ public abstract class AudioBroadcaster implements Listener<AudioRecording>
|
|||||||
{
|
{
|
||||||
//Remove all pending audio recordings
|
//Remove all pending audio recordings
|
||||||
while(!mAudioRecordingQueue.isEmpty())
|
while(!mAudioRecordingQueue.isEmpty())
|
||||||
|
{
|
||||||
|
try
|
||||||
{
|
{
|
||||||
AudioRecording recording = mAudioRecordingQueue.get(0);
|
AudioRecording recording = mAudioRecordingQueue.get(0);
|
||||||
recording.removePendingReplay();
|
recording.removePendingReplay();
|
||||||
}
|
}
|
||||||
|
catch(Exception e)
|
||||||
|
{
|
||||||
|
//Ignore
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -431,7 +436,7 @@ public abstract class AudioBroadcaster implements Listener<AudioRecording>
|
|||||||
|
|
||||||
if(connected())
|
if(connected())
|
||||||
{
|
{
|
||||||
broadcastMetadata(nextRecording.getAudioMetadata());
|
broadcastMetadata(nextRecording.getMetadata());
|
||||||
}
|
}
|
||||||
|
|
||||||
metadataUpdateRequired = false;
|
metadataUpdateRequired = false;
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
/*******************************************************************************
|
/*******************************************************************************
|
||||||
* sdrtrunk
|
* sdrtrunk
|
||||||
* Copyright (C) 2014-2016 Dennis Sheirer
|
* Copyright (C) 2014-2017 Dennis Sheirer
|
||||||
*
|
*
|
||||||
* This program is free software: you can redistribute it and/or modify
|
* 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
|
* it under the terms of the GNU General Public License as published by
|
||||||
@@ -18,7 +18,7 @@
|
|||||||
******************************************************************************/
|
******************************************************************************/
|
||||||
package audio.broadcast;
|
package audio.broadcast;
|
||||||
|
|
||||||
import audio.metadata.AudioMetadata;
|
import channel.metadata.Metadata;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
@@ -30,22 +30,23 @@ public class AudioRecording implements Comparable<AudioRecording>
|
|||||||
private final static Logger mLog = LoggerFactory.getLogger(StreamManager.class);
|
private final static Logger mLog = LoggerFactory.getLogger(StreamManager.class);
|
||||||
|
|
||||||
private Path mPath;
|
private Path mPath;
|
||||||
private AudioMetadata mAudioMetadata;
|
|
||||||
private long mStartTime;
|
private long mStartTime;
|
||||||
private long mRecordingLength;
|
private long mRecordingLength;
|
||||||
private AtomicInteger mPendingReplayCount = new AtomicInteger();
|
private AtomicInteger mPendingReplayCount = new AtomicInteger();
|
||||||
|
private Metadata mMetadata;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Audio recording that is ready to be streamed
|
* Audio recording that is ready to be streamed
|
||||||
|
*
|
||||||
* @param path to the audio recording file
|
* @param path to the audio recording file
|
||||||
* @param audioMetadata associated with the recording
|
* @param metadata associated with the recording
|
||||||
* @param start time of recording in milliseconds since epoch
|
* @param start time of recording in milliseconds since epoch
|
||||||
* @param recordingLength in milliseconds
|
* @param recordingLength in milliseconds
|
||||||
*/
|
*/
|
||||||
public AudioRecording(Path path, AudioMetadata audioMetadata, long start, long recordingLength)
|
public AudioRecording(Path path, Metadata metadata, long start, long recordingLength)
|
||||||
{
|
{
|
||||||
mPath = path;
|
mPath = path;
|
||||||
mAudioMetadata = audioMetadata;
|
mMetadata = metadata;
|
||||||
mStartTime = start;
|
mStartTime = start;
|
||||||
mRecordingLength = recordingLength;
|
mRecordingLength = recordingLength;
|
||||||
}
|
}
|
||||||
@@ -61,9 +62,9 @@ public class AudioRecording implements Comparable<AudioRecording>
|
|||||||
/**
|
/**
|
||||||
* Optional audio metadata for the recording.
|
* Optional audio metadata for the recording.
|
||||||
*/
|
*/
|
||||||
public AudioMetadata getAudioMetadata()
|
public Metadata getMetadata()
|
||||||
{
|
{
|
||||||
return mAudioMetadata;
|
return mMetadata;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -20,7 +20,7 @@ package audio.broadcast;
|
|||||||
|
|
||||||
import alias.id.broadcast.BroadcastChannel;
|
import alias.id.broadcast.BroadcastChannel;
|
||||||
import audio.AudioPacket;
|
import audio.AudioPacket;
|
||||||
import audio.metadata.AudioMetadata;
|
import channel.metadata.Metadata;
|
||||||
import controller.ThreadPoolManager;
|
import controller.ThreadPoolManager;
|
||||||
import icon.IconManager;
|
import icon.IconManager;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
@@ -164,6 +164,7 @@ public class BroadcastModel extends AbstractTableModel implements Listener<Audio
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Updates the configuration's name so that it is unique among all other broadcast configurations
|
* Updates the configuration's name so that it is unique among all other broadcast configurations
|
||||||
|
*
|
||||||
* @param configuration
|
* @param configuration
|
||||||
*/
|
*/
|
||||||
private void ensureUniqueName(BroadcastConfiguration configuration)
|
private void ensureUniqueName(BroadcastConfiguration configuration)
|
||||||
@@ -275,8 +276,8 @@ public class BroadcastModel extends AbstractTableModel implements Listener<Audio
|
|||||||
@Override
|
@Override
|
||||||
public void receive(AudioPacket audioPacket)
|
public void receive(AudioPacket audioPacket)
|
||||||
{
|
{
|
||||||
if (audioPacket.hasAudioMetadata() &&
|
if(audioPacket.hasMetadata() &&
|
||||||
audioPacket.getAudioMetadata().isStreamable())
|
audioPacket.getMetadata().isStreamable())
|
||||||
{
|
{
|
||||||
mStreamManager.receive(audioPacket);
|
mStreamManager.receive(audioPacket);
|
||||||
}
|
}
|
||||||
@@ -584,7 +585,7 @@ public class BroadcastModel extends AbstractTableModel implements Listener<Audio
|
|||||||
switch(column)
|
switch(column)
|
||||||
{
|
{
|
||||||
case COLUMN_SERVER_ICON:
|
case COLUMN_SERVER_ICON:
|
||||||
return null;
|
return "Streaming";
|
||||||
case COLUMN_STREAM_NAME:
|
case COLUMN_STREAM_NAME:
|
||||||
return "Name";
|
return "Name";
|
||||||
case COLUMN_BROADCASTER_STATUS:
|
case COLUMN_BROADCASTER_STATUS:
|
||||||
@@ -686,7 +687,7 @@ public class BroadcastModel extends AbstractTableModel implements Listener<Audio
|
|||||||
@Override
|
@Override
|
||||||
public void receive(AudioRecording audioRecording)
|
public void receive(AudioRecording audioRecording)
|
||||||
{
|
{
|
||||||
AudioMetadata metadata = audioRecording.getAudioMetadata();
|
Metadata metadata = audioRecording.getMetadata();
|
||||||
|
|
||||||
if(metadata != null && metadata.isStreamable())
|
if(metadata != null && metadata.isStreamable())
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -50,7 +50,7 @@ public class BroadcastPanel extends JPanel implements ActionListener, ListSelect
|
|||||||
private AliasModel mAliasModel;
|
private AliasModel mAliasModel;
|
||||||
private IconManager mIconManager;
|
private IconManager mIconManager;
|
||||||
|
|
||||||
private JTable mBroadcastConfigurationTable;
|
private BroadcastStatusPanel mBroadcastStatusPanel;
|
||||||
private JideSplitPane mSplitPane;
|
private JideSplitPane mSplitPane;
|
||||||
private Editor<BroadcastConfiguration> mEmptyEditor = new EmptyEditor<>("Configuration:");
|
private Editor<BroadcastConfiguration> mEmptyEditor = new EmptyEditor<>("Configuration:");
|
||||||
private Editor<BroadcastConfiguration> mEditor;
|
private Editor<BroadcastConfiguration> mEditor;
|
||||||
@@ -72,17 +72,11 @@ public class BroadcastPanel extends JPanel implements ActionListener, ListSelect
|
|||||||
{
|
{
|
||||||
setLayout(new MigLayout("insets 0 0 0 0 ", "[grow,fill]", "[grow,fill]"));
|
setLayout(new MigLayout("insets 0 0 0 0 ", "[grow,fill]", "[grow,fill]"));
|
||||||
|
|
||||||
mBroadcastConfigurationTable = new JTable(mBroadcastModel);
|
mBroadcastStatusPanel = new BroadcastStatusPanel(mBroadcastModel);
|
||||||
mBroadcastConfigurationTable.setAutoCreateRowSorter(true);
|
|
||||||
mBroadcastConfigurationTable.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
|
|
||||||
mBroadcastConfigurationTable.getSelectionModel().addListSelectionListener(BroadcastPanel.this);
|
|
||||||
|
|
||||||
mBroadcastConfigurationTable.getColumnModel().getColumn(BroadcastModel.COLUMN_SERVER_ICON).setPreferredWidth(1);
|
mBroadcastStatusPanel.getTable().setAutoCreateRowSorter(true);
|
||||||
mBroadcastConfigurationTable.getColumnModel().getColumn(BroadcastModel.COLUMN_STREAM_NAME).setPreferredWidth(25);
|
mBroadcastStatusPanel.getTable().setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
|
||||||
mBroadcastConfigurationTable.getColumnModel().getColumn(BroadcastModel.COLUMN_BROADCASTER_STATUS)
|
mBroadcastStatusPanel.getTable().getSelectionModel().addListSelectionListener(BroadcastPanel.this);
|
||||||
.setCellRenderer(new StatusCellRenderer());
|
|
||||||
|
|
||||||
JScrollPane scroller = new JScrollPane(mBroadcastConfigurationTable);
|
|
||||||
|
|
||||||
JPanel buttonsPanel = new JPanel();
|
JPanel buttonsPanel = new JPanel();
|
||||||
buttonsPanel.setLayout(new MigLayout("insets 0 0 0 0", "[grow,fill][grow,fill][grow,fill]", "[]"));
|
buttonsPanel.setLayout(new MigLayout("insets 0 0 0 0", "[grow,fill][grow,fill][grow,fill]", "[]"));
|
||||||
@@ -122,7 +116,7 @@ public class BroadcastPanel extends JPanel implements ActionListener, ListSelect
|
|||||||
|
|
||||||
listAndButtonsPanel.setLayout(new MigLayout("insets 0 0 0 0", "[grow,fill]", "[grow,fill][]"));
|
listAndButtonsPanel.setLayout(new MigLayout("insets 0 0 0 0", "[grow,fill]", "[grow,fill][]"));
|
||||||
|
|
||||||
listAndButtonsPanel.add(scroller, "wrap");
|
listAndButtonsPanel.add(mBroadcastStatusPanel, "wrap");
|
||||||
listAndButtonsPanel.add(buttonsPanel);
|
listAndButtonsPanel.add(buttonsPanel);
|
||||||
|
|
||||||
mSplitPane = new JideSplitPane(JideSplitPane.HORIZONTAL_SPLIT);
|
mSplitPane = new JideSplitPane(JideSplitPane.HORIZONTAL_SPLIT);
|
||||||
@@ -168,11 +162,11 @@ public class BroadcastPanel extends JPanel implements ActionListener, ListSelect
|
|||||||
*/
|
*/
|
||||||
private BroadcastConfiguration getSelectedBroadcastConfiguration()
|
private BroadcastConfiguration getSelectedBroadcastConfiguration()
|
||||||
{
|
{
|
||||||
int viewRow = mBroadcastConfigurationTable.getSelectedRow();
|
int viewRow = mBroadcastStatusPanel.getTable().getSelectedRow();
|
||||||
|
|
||||||
if(viewRow >= 0)
|
if(viewRow >= 0)
|
||||||
{
|
{
|
||||||
int modelRow = mBroadcastConfigurationTable.convertRowIndexToModel(viewRow);
|
int modelRow = mBroadcastStatusPanel.getTable().convertRowIndexToModel(viewRow);
|
||||||
|
|
||||||
if(modelRow >= 0)
|
if(modelRow >= 0)
|
||||||
{
|
{
|
||||||
@@ -255,75 +249,12 @@ public class BroadcastPanel extends JPanel implements ActionListener, ListSelect
|
|||||||
mBroadcastModel.addBroadcastConfiguration(configuration);
|
mBroadcastModel.addBroadcastConfiguration(configuration);
|
||||||
|
|
||||||
int modelRow = mBroadcastModel.getRowForConfiguration(configuration);
|
int modelRow = mBroadcastModel.getRowForConfiguration(configuration);
|
||||||
int tableRow = mBroadcastConfigurationTable.convertRowIndexToView(modelRow);
|
int tableRow = mBroadcastStatusPanel.getTable().convertRowIndexToView(modelRow);
|
||||||
mBroadcastConfigurationTable.changeSelection(tableRow, 0, false, false);
|
mBroadcastStatusPanel.getTable().changeSelection(tableRow, 0, false, false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Custom cell renderer for the broadcast state column.
|
|
||||||
*/
|
|
||||||
public class StatusCellRenderer extends DefaultTableCellRenderer
|
|
||||||
{
|
|
||||||
public StatusCellRenderer()
|
|
||||||
{
|
|
||||||
setOpaque(true);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected,
|
|
||||||
boolean hasFocus, int row, int column)
|
|
||||||
{
|
|
||||||
JLabel component = (JLabel)super.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column);
|
|
||||||
|
|
||||||
if(isSelected)
|
|
||||||
{
|
|
||||||
setBackground(table.getSelectionBackground());
|
|
||||||
setForeground(table.getSelectionForeground());
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
if(value instanceof BroadcastState)
|
|
||||||
{
|
|
||||||
BroadcastState state = (BroadcastState)value;
|
|
||||||
|
|
||||||
if(state == BroadcastState.CONNECTED)
|
|
||||||
{
|
|
||||||
setBackground(Color.GREEN);
|
|
||||||
setForeground(table.getForeground());
|
|
||||||
}
|
|
||||||
else if(state == BroadcastState.DISABLED)
|
|
||||||
{
|
|
||||||
setBackground(table.getBackground());
|
|
||||||
setForeground(Color.LIGHT_GRAY);
|
|
||||||
}
|
|
||||||
else if(state == BroadcastState.INVALID_SETTINGS)
|
|
||||||
{
|
|
||||||
setBackground(Color.YELLOW);
|
|
||||||
setForeground(table.getForeground());
|
|
||||||
}
|
|
||||||
else if(state.isErrorState())
|
|
||||||
{
|
|
||||||
setBackground(Color.RED);
|
|
||||||
setForeground(table.getForeground());
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
setBackground(table.getBackground());
|
|
||||||
setForeground(table.getForeground());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
setForeground(table.getForeground());
|
|
||||||
setBackground(table.getBackground());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
125
src/audio/broadcast/BroadcastStatusPanel.java
Normal file
125
src/audio/broadcast/BroadcastStatusPanel.java
Normal file
@@ -0,0 +1,125 @@
|
|||||||
|
/*******************************************************************************
|
||||||
|
* 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 audio.broadcast;
|
||||||
|
|
||||||
|
import net.miginfocom.swing.MigLayout;
|
||||||
|
|
||||||
|
import javax.swing.*;
|
||||||
|
import javax.swing.table.DefaultTableCellRenderer;
|
||||||
|
import java.awt.*;
|
||||||
|
|
||||||
|
public class BroadcastStatusPanel extends JPanel
|
||||||
|
{
|
||||||
|
private JTable mTable;
|
||||||
|
private JScrollPane mScrollPane;
|
||||||
|
private BroadcastModel mBroadcastModel;
|
||||||
|
|
||||||
|
public BroadcastStatusPanel(BroadcastModel broadcastModel)
|
||||||
|
{
|
||||||
|
mBroadcastModel = broadcastModel;
|
||||||
|
|
||||||
|
init();
|
||||||
|
}
|
||||||
|
|
||||||
|
public JTable getTable()
|
||||||
|
{
|
||||||
|
return mTable;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void init()
|
||||||
|
{
|
||||||
|
setLayout(new MigLayout("insets 0 0 0 0 ", "[grow,fill]", "[grow,fill]"));
|
||||||
|
|
||||||
|
mTable = new JTable(mBroadcastModel);
|
||||||
|
|
||||||
|
DefaultTableCellRenderer renderer = (DefaultTableCellRenderer)mTable.getDefaultRenderer(String.class);
|
||||||
|
renderer.setHorizontalAlignment(SwingConstants.CENTER);
|
||||||
|
|
||||||
|
mTable.getColumnModel().getColumn(BroadcastModel.COLUMN_BROADCASTER_STATUS).setCellRenderer(new StatusCellRenderer());
|
||||||
|
|
||||||
|
mScrollPane = new JScrollPane(mTable);
|
||||||
|
|
||||||
|
add(mScrollPane);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Custom cell renderer for the broadcast state column.
|
||||||
|
*/
|
||||||
|
public class StatusCellRenderer extends DefaultTableCellRenderer
|
||||||
|
{
|
||||||
|
public StatusCellRenderer()
|
||||||
|
{
|
||||||
|
setOpaque(true);
|
||||||
|
setHorizontalAlignment(SwingConstants.CENTER);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected,
|
||||||
|
boolean hasFocus, int row, int column)
|
||||||
|
{
|
||||||
|
JLabel component = (JLabel)super.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column);
|
||||||
|
|
||||||
|
if(isSelected)
|
||||||
|
{
|
||||||
|
setBackground(table.getSelectionBackground());
|
||||||
|
setForeground(table.getSelectionForeground());
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if(value instanceof BroadcastState)
|
||||||
|
{
|
||||||
|
BroadcastState state = (BroadcastState)value;
|
||||||
|
|
||||||
|
if(state == BroadcastState.CONNECTED)
|
||||||
|
{
|
||||||
|
setBackground(Color.GREEN);
|
||||||
|
setForeground(table.getForeground());
|
||||||
|
}
|
||||||
|
else if(state == BroadcastState.DISABLED)
|
||||||
|
{
|
||||||
|
setBackground(table.getBackground());
|
||||||
|
setForeground(Color.LIGHT_GRAY);
|
||||||
|
}
|
||||||
|
else if(state == BroadcastState.INVALID_SETTINGS)
|
||||||
|
{
|
||||||
|
setBackground(Color.YELLOW);
|
||||||
|
setForeground(table.getForeground());
|
||||||
|
}
|
||||||
|
else if(state.isErrorState())
|
||||||
|
{
|
||||||
|
setBackground(Color.RED);
|
||||||
|
setForeground(table.getForeground());
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
setBackground(table.getBackground());
|
||||||
|
setForeground(table.getForeground());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
setForeground(table.getForeground());
|
||||||
|
setBackground(table.getBackground());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -18,7 +18,7 @@
|
|||||||
******************************************************************************/
|
******************************************************************************/
|
||||||
package audio.broadcast;
|
package audio.broadcast;
|
||||||
|
|
||||||
import audio.metadata.AudioMetadata;
|
import channel.metadata.Metadata;
|
||||||
|
|
||||||
public interface IBroadcastMetadataUpdater
|
public interface IBroadcastMetadataUpdater
|
||||||
{
|
{
|
||||||
@@ -27,5 +27,5 @@ public interface IBroadcastMetadataUpdater
|
|||||||
*
|
*
|
||||||
* @param metadata containing metadata attributes
|
* @param metadata containing metadata attributes
|
||||||
*/
|
*/
|
||||||
void update(AudioMetadata metadata);
|
void update(Metadata metadata);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
/*******************************************************************************
|
/*******************************************************************************
|
||||||
* sdrtrunk
|
* sdrtrunk
|
||||||
* Copyright (C) 2014-2016 Dennis Sheirer
|
* Copyright (C) 2014-2017 Dennis Sheirer
|
||||||
*
|
*
|
||||||
* This program is free software: you can redistribute it and/or modify
|
* 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
|
* it under the terms of the GNU General Public License as published by
|
||||||
@@ -122,19 +122,19 @@ public class StreamManager implements Listener<AudioPacket>
|
|||||||
@Override
|
@Override
|
||||||
public void receive(AudioPacket audioPacket)
|
public void receive(AudioPacket audioPacket)
|
||||||
{
|
{
|
||||||
if(mRunning.get() && audioPacket.hasAudioMetadata())
|
if(mRunning.get() && audioPacket.hasMetadata())
|
||||||
{
|
{
|
||||||
synchronized(mStreamRecorders)
|
synchronized(mStreamRecorders)
|
||||||
{
|
{
|
||||||
int sourceChannelID = audioPacket.getAudioMetadata().getSource();
|
int channelMetadataID = audioPacket.getMetadata().getMetadataID();
|
||||||
|
|
||||||
AudioPacket.Type type = audioPacket.getType();
|
AudioPacket.Type type = audioPacket.getType();
|
||||||
|
|
||||||
if(type == AudioPacket.Type.AUDIO)
|
if(type == AudioPacket.Type.AUDIO)
|
||||||
{
|
{
|
||||||
if(mStreamRecorders.containsKey(sourceChannelID))
|
if(mStreamRecorders.containsKey(channelMetadataID))
|
||||||
{
|
{
|
||||||
AudioRecorder recorder = mStreamRecorders.get(sourceChannelID);
|
AudioRecorder recorder = mStreamRecorders.get(channelMetadataID);
|
||||||
|
|
||||||
if(recorder != null)
|
if(recorder != null)
|
||||||
{
|
{
|
||||||
@@ -147,12 +147,12 @@ public class StreamManager implements Listener<AudioPacket>
|
|||||||
mBroadcastFormat);
|
mBroadcastFormat);
|
||||||
recorder.start(mThreadPoolManager.getScheduledExecutorService());
|
recorder.start(mThreadPoolManager.getScheduledExecutorService());
|
||||||
recorder.receive(audioPacket);
|
recorder.receive(audioPacket);
|
||||||
mStreamRecorders.put(sourceChannelID, recorder);
|
mStreamRecorders.put(channelMetadataID, recorder);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if(type == AudioPacket.Type.END)
|
else if(type == AudioPacket.Type.END)
|
||||||
{
|
{
|
||||||
removeRecorder(sourceChannelID);
|
removeRecorder(channelMetadataID);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
/*******************************************************************************
|
/*******************************************************************************
|
||||||
* sdrtrunk
|
* sdrtrunk
|
||||||
* Copyright (C) 2014-2016 Dennis Sheirer
|
* Copyright (C) 2014-2017 Dennis Sheirer
|
||||||
*
|
*
|
||||||
* This program is free software: you can redistribute it and/or modify
|
* 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
|
* it under the terms of the GNU General Public License as published by
|
||||||
@@ -19,9 +19,7 @@
|
|||||||
package audio.broadcast.icecast;
|
package audio.broadcast.icecast;
|
||||||
|
|
||||||
import audio.broadcast.IBroadcastMetadataUpdater;
|
import audio.broadcast.IBroadcastMetadataUpdater;
|
||||||
import audio.metadata.AudioMetadata;
|
import channel.metadata.Metadata;
|
||||||
import audio.metadata.Metadata;
|
|
||||||
import audio.metadata.MetadataType;
|
|
||||||
import controller.ThreadPoolManager;
|
import controller.ThreadPoolManager;
|
||||||
import org.apache.mina.core.future.ConnectFuture;
|
import org.apache.mina.core.future.ConnectFuture;
|
||||||
import org.apache.mina.core.service.IoHandlerAdapter;
|
import org.apache.mina.core.service.IoHandlerAdapter;
|
||||||
@@ -116,9 +114,9 @@ public class IcecastBroadcastMetadataUpdater implements IBroadcastMetadataUpdate
|
|||||||
* and will remain in the update queue until the next metadata update is requested. However, this is a design
|
* and will remain in the update queue until the next metadata update is requested. However, this is a design
|
||||||
* trade-off to avoid having a scheduled runnable repeatedly processing the update queue.
|
* trade-off to avoid having a scheduled runnable repeatedly processing the update queue.
|
||||||
*/
|
*/
|
||||||
public void update(AudioMetadata audioMetadata)
|
public void update(Metadata metadata)
|
||||||
{
|
{
|
||||||
mMetadataQueue.offer(getSong(audioMetadata));
|
mMetadataQueue.offer(getSong(metadata));
|
||||||
|
|
||||||
if(mUpdating.compareAndSet(false, true))
|
if(mUpdating.compareAndSet(false, true))
|
||||||
{
|
{
|
||||||
@@ -182,52 +180,45 @@ public class IcecastBroadcastMetadataUpdater implements IBroadcastMetadataUpdate
|
|||||||
/**
|
/**
|
||||||
* Creates the song information for a metadata update
|
* Creates the song information for a metadata update
|
||||||
*/
|
*/
|
||||||
private static String getSong(AudioMetadata audioMetadata)
|
private static String getSong(Metadata metadata)
|
||||||
{
|
{
|
||||||
StringBuilder sb = new StringBuilder();
|
StringBuilder sb = new StringBuilder();
|
||||||
|
|
||||||
if(audioMetadata != null)
|
if(metadata != null)
|
||||||
{
|
{
|
||||||
Metadata to = audioMetadata.getMetadata(MetadataType.TO);
|
String to = metadata.getPrimaryAddressTo().getIdentifier();
|
||||||
|
|
||||||
sb.append("TO:");
|
sb.append("TO:");
|
||||||
|
|
||||||
if(to != null)
|
if(metadata.getPrimaryAddressTo().hasAlias())
|
||||||
{
|
{
|
||||||
if(to.hasAlias())
|
sb.append(metadata.getPrimaryAddressTo().getAlias().getName());
|
||||||
{
|
|
||||||
sb.append(to.getAlias().getName());
|
|
||||||
}
|
}
|
||||||
else
|
else if(metadata.getPrimaryAddressTo().hasIdentifier())
|
||||||
{
|
{
|
||||||
sb.append(to.getValue());
|
sb.append(metadata.getPrimaryAddressTo().getIdentifier());
|
||||||
}
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
sb.append("UNKNOWN");
|
sb.append("UNKNOWN");
|
||||||
}
|
}
|
||||||
|
|
||||||
Metadata from = audioMetadata.getMetadata(MetadataType.FROM);
|
|
||||||
|
|
||||||
sb.append(" FROM:");
|
sb.append(" FROM:");
|
||||||
|
|
||||||
if(from != null)
|
if(metadata.getPrimaryAddressFrom().hasAlias())
|
||||||
{
|
{
|
||||||
|
sb.append(metadata.getPrimaryAddressFrom().getAlias().getName());
|
||||||
if(from.hasAlias())
|
|
||||||
{
|
|
||||||
sb.append(from.getAlias().getName());
|
|
||||||
}
|
}
|
||||||
else
|
else if(metadata.getPrimaryAddressFrom().hasIdentifier())
|
||||||
{
|
{
|
||||||
sb.append(from.getValue());
|
sb.append(metadata.getPrimaryAddressFrom().getIdentifier());
|
||||||
}
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
sb.append("UNKNOWN");
|
sb.append("UNKNOWN");
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -19,9 +19,7 @@
|
|||||||
package audio.broadcast.shoutcast.v1;
|
package audio.broadcast.shoutcast.v1;
|
||||||
|
|
||||||
import audio.broadcast.IBroadcastMetadataUpdater;
|
import audio.broadcast.IBroadcastMetadataUpdater;
|
||||||
import audio.metadata.AudioMetadata;
|
import channel.metadata.Metadata;
|
||||||
import audio.metadata.Metadata;
|
|
||||||
import audio.metadata.MetadataType;
|
|
||||||
import controller.ThreadPoolManager;
|
import controller.ThreadPoolManager;
|
||||||
import org.apache.mina.core.future.ConnectFuture;
|
import org.apache.mina.core.future.ConnectFuture;
|
||||||
import org.apache.mina.core.service.IoHandlerAdapter;
|
import org.apache.mina.core.service.IoHandlerAdapter;
|
||||||
@@ -57,7 +55,6 @@ public class ShoutcastV1BroadcastMetadataUpdater implements IBroadcastMetadataUp
|
|||||||
private NioSocketConnector mSocketConnector;
|
private NioSocketConnector mSocketConnector;
|
||||||
private AtomicBoolean mUpdating = new AtomicBoolean();
|
private AtomicBoolean mUpdating = new AtomicBoolean();
|
||||||
private Queue<String> mMetadataQueue = new LinkedTransferQueue<>();
|
private Queue<String> mMetadataQueue = new LinkedTransferQueue<>();
|
||||||
private Map<String, String> mHTTPHeaders;
|
|
||||||
private boolean mStackTraceLoggingSuppressed;
|
private boolean mStackTraceLoggingSuppressed;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -116,9 +113,9 @@ public class ShoutcastV1BroadcastMetadataUpdater implements IBroadcastMetadataUp
|
|||||||
* and will remain in the update queue until the next metadata update is requested. However, this is a design
|
* and will remain in the update queue until the next metadata update is requested. However, this is a design
|
||||||
* trade-off to avoid having a scheduled runnable repeatedly processing the update queue.
|
* trade-off to avoid having a scheduled runnable repeatedly processing the update queue.
|
||||||
*/
|
*/
|
||||||
public void update(AudioMetadata audioMetadata)
|
public void update(Metadata metadata)
|
||||||
{
|
{
|
||||||
mMetadataQueue.offer(getSong(audioMetadata));
|
mMetadataQueue.offer(getSong(metadata));
|
||||||
|
|
||||||
if(mUpdating.compareAndSet(false, true))
|
if(mUpdating.compareAndSet(false, true))
|
||||||
{
|
{
|
||||||
@@ -182,52 +179,45 @@ public class ShoutcastV1BroadcastMetadataUpdater implements IBroadcastMetadataUp
|
|||||||
/**
|
/**
|
||||||
* Creates the song information for a metadata update
|
* Creates the song information for a metadata update
|
||||||
*/
|
*/
|
||||||
private static String getSong(AudioMetadata audioMetadata)
|
private static String getSong(Metadata metadata)
|
||||||
{
|
{
|
||||||
StringBuilder sb = new StringBuilder();
|
StringBuilder sb = new StringBuilder();
|
||||||
|
|
||||||
if(audioMetadata != null)
|
if(metadata != null)
|
||||||
{
|
{
|
||||||
Metadata to = audioMetadata.getMetadata(MetadataType.TO);
|
String to = metadata.getPrimaryAddressTo().getIdentifier();
|
||||||
|
|
||||||
sb.append("TO:");
|
sb.append("TO:");
|
||||||
|
|
||||||
if(to != null)
|
if(metadata.getPrimaryAddressTo().hasAlias())
|
||||||
{
|
{
|
||||||
if(to.hasAlias())
|
sb.append(metadata.getPrimaryAddressTo().getAlias().getName());
|
||||||
{
|
|
||||||
sb.append(to.getAlias().getName());
|
|
||||||
}
|
}
|
||||||
else
|
else if(metadata.getPrimaryAddressTo().hasIdentifier())
|
||||||
{
|
{
|
||||||
sb.append(to.getValue());
|
sb.append(metadata.getPrimaryAddressTo().getIdentifier());
|
||||||
}
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
sb.append("UNKNOWN");
|
sb.append("UNKNOWN");
|
||||||
}
|
}
|
||||||
|
|
||||||
Metadata from = audioMetadata.getMetadata(MetadataType.FROM);
|
|
||||||
|
|
||||||
sb.append(" FROM:");
|
sb.append(" FROM:");
|
||||||
|
|
||||||
if(from != null)
|
if(metadata.getPrimaryAddressFrom().hasAlias())
|
||||||
{
|
{
|
||||||
|
sb.append(metadata.getPrimaryAddressFrom().getAlias().getName());
|
||||||
if(from.hasAlias())
|
|
||||||
{
|
|
||||||
sb.append(from.getAlias().getName());
|
|
||||||
}
|
}
|
||||||
else
|
else if(metadata.getPrimaryAddressFrom().hasIdentifier())
|
||||||
{
|
{
|
||||||
sb.append(from.getValue());
|
sb.append(metadata.getPrimaryAddressFrom().getIdentifier());
|
||||||
}
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
sb.append("UNKNOWN");
|
sb.append("UNKNOWN");
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -37,9 +37,7 @@ import audio.broadcast.shoutcast.v2.ultravox.UltravoxMessageFactory;
|
|||||||
import audio.broadcast.shoutcast.v2.ultravox.UltravoxMessageType;
|
import audio.broadcast.shoutcast.v2.ultravox.UltravoxMessageType;
|
||||||
import audio.broadcast.shoutcast.v2.ultravox.UltravoxMetadata;
|
import audio.broadcast.shoutcast.v2.ultravox.UltravoxMetadata;
|
||||||
import audio.broadcast.shoutcast.v2.ultravox.UltravoxProtocolFactory;
|
import audio.broadcast.shoutcast.v2.ultravox.UltravoxProtocolFactory;
|
||||||
import audio.metadata.AudioMetadata;
|
import channel.metadata.Metadata;
|
||||||
import audio.metadata.Metadata;
|
|
||||||
import audio.metadata.MetadataType;
|
|
||||||
import controller.ThreadPoolManager;
|
import controller.ThreadPoolManager;
|
||||||
import org.apache.mina.core.RuntimeIoException;
|
import org.apache.mina.core.RuntimeIoException;
|
||||||
import org.apache.mina.core.future.ConnectFuture;
|
import org.apache.mina.core.future.ConnectFuture;
|
||||||
@@ -122,7 +120,7 @@ public class ShoutcastV2AudioBroadcaster extends AudioBroadcaster implements IBr
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void update(AudioMetadata metadata)
|
public void update(Metadata metadata)
|
||||||
{
|
{
|
||||||
List<UltravoxMessage> metadataMessages = getMetadataMessages(metadata);
|
List<UltravoxMessage> metadataMessages = getMetadataMessages(metadata);
|
||||||
|
|
||||||
@@ -242,7 +240,7 @@ public class ShoutcastV2AudioBroadcaster extends AudioBroadcaster implements IBr
|
|||||||
* @param metadata containing audio metadata tags and attributes
|
* @param metadata containing audio metadata tags and attributes
|
||||||
* @return a sequence of CacheableXMLMetadata messages sufficient to carry the complete set of metadata
|
* @return a sequence of CacheableXMLMetadata messages sufficient to carry the complete set of metadata
|
||||||
*/
|
*/
|
||||||
private List<UltravoxMessage> getMetadataMessages(AudioMetadata metadata)
|
private List<UltravoxMessage> getMetadataMessages(Metadata metadata)
|
||||||
{
|
{
|
||||||
StringBuilder sb = new StringBuilder();
|
StringBuilder sb = new StringBuilder();
|
||||||
|
|
||||||
@@ -264,30 +262,22 @@ public class ShoutcastV2AudioBroadcaster extends AudioBroadcaster implements IBr
|
|||||||
|
|
||||||
if(metadata != null)
|
if(metadata != null)
|
||||||
{
|
{
|
||||||
Metadata to = metadata.getMetadata(MetadataType.TO);
|
if(metadata.getPrimaryAddressTo().hasAlias())
|
||||||
if(to != null)
|
|
||||||
{
|
{
|
||||||
if(to.hasAlias())
|
sb.append(UltravoxMetadata.TITLE_2.asXML(metadata.getPrimaryAddressTo().getAlias().getName()));
|
||||||
{
|
|
||||||
sb.append(UltravoxMetadata.TITLE_2.asXML(to.getAlias().toString()));
|
|
||||||
}
|
}
|
||||||
else
|
else if(metadata.getPrimaryAddressTo().hasIdentifier())
|
||||||
{
|
{
|
||||||
sb.append(UltravoxMetadata.TITLE_2.asXML(to.getValue()));
|
sb.append(UltravoxMetadata.TITLE_2.asXML(metadata.getPrimaryAddressTo().getIdentifier()));
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Metadata from = metadata.getMetadata(MetadataType.FROM);
|
if(metadata.getPrimaryAddressFrom().hasAlias())
|
||||||
if(from != null)
|
|
||||||
{
|
{
|
||||||
if(from.hasAlias())
|
sb.append(UltravoxMetadata.TITLE_3.asXML("From:" + metadata.getPrimaryAddressFrom().getAlias().getName()));
|
||||||
{
|
|
||||||
sb.append(UltravoxMetadata.TITLE_3.asXML("From: " + from.getAlias().toString()));
|
|
||||||
}
|
}
|
||||||
else
|
else if(metadata.getPrimaryAddressFrom().hasIdentifier())
|
||||||
{
|
{
|
||||||
sb.append(UltravoxMetadata.TITLE_3.asXML("From: " + from.getValue()));
|
sb.append(UltravoxMetadata.TITLE_3.asXML("From:" + metadata.getPrimaryAddressFrom().getIdentifier()));
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
|||||||
@@ -1,357 +0,0 @@
|
|||||||
/*******************************************************************************
|
|
||||||
* SDR Trunk
|
|
||||||
* Copyright (C) 2014-2016 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 audio.metadata;
|
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.Collection;
|
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Map;
|
|
||||||
import java.util.Map.Entry;
|
|
||||||
import java.util.Set;
|
|
||||||
import java.util.TreeSet;
|
|
||||||
|
|
||||||
import alias.id.broadcast.BroadcastChannel;
|
|
||||||
import org.slf4j.Logger;
|
|
||||||
import org.slf4j.LoggerFactory;
|
|
||||||
|
|
||||||
import sample.Listener;
|
|
||||||
import alias.Alias;
|
|
||||||
import alias.id.priority.Priority;
|
|
||||||
|
|
||||||
public class AudioMetadata implements Listener<Metadata>
|
|
||||||
{
|
|
||||||
protected static final Logger mLog = LoggerFactory.getLogger(AudioMetadata.class);
|
|
||||||
|
|
||||||
private int mSource;
|
|
||||||
private Map<MetadataType, Metadata> mMetadata = new HashMap<>();
|
|
||||||
private boolean mUpdated = false;
|
|
||||||
|
|
||||||
/* Channel Selected == highest priority */
|
|
||||||
private boolean mSelected = false;
|
|
||||||
|
|
||||||
/* Call Priority */
|
|
||||||
private int mPriority = Priority.DEFAULT_PRIORITY;
|
|
||||||
|
|
||||||
/* Indicates if the overall source is recordable */
|
|
||||||
private boolean mSourceRecordable = false;
|
|
||||||
|
|
||||||
/* Indicates the current recordable state */
|
|
||||||
private boolean mRecordable = false;
|
|
||||||
|
|
||||||
/* Indicates the current streamable state */
|
|
||||||
private boolean mStreamable = false;
|
|
||||||
|
|
||||||
/* A unique identifier for this metadata */
|
|
||||||
private String mIdentifier;
|
|
||||||
|
|
||||||
public AudioMetadata(int source, boolean recordable)
|
|
||||||
{
|
|
||||||
mSource = source;
|
|
||||||
|
|
||||||
setIdentifier(mSource);
|
|
||||||
|
|
||||||
mSourceRecordable = recordable;
|
|
||||||
|
|
||||||
setRecordable(mSourceRecordable);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns a unique identifier for this audio metadata that contains the
|
|
||||||
* source id and optionally the TO metadata string.
|
|
||||||
*/
|
|
||||||
public String getIdentifier()
|
|
||||||
{
|
|
||||||
return mIdentifier;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setIdentifier(int source)
|
|
||||||
{
|
|
||||||
setIdentifier(source, null);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setIdentifier(int source, String id)
|
|
||||||
{
|
|
||||||
mIdentifier = "SRC:" + source + " ID:" + (id == null ? "UNKNOWN" : id);
|
|
||||||
mUpdated = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns a copy of the current audio metadata.
|
|
||||||
*/
|
|
||||||
public AudioMetadata copyOf()
|
|
||||||
{
|
|
||||||
AudioMetadata copy = new AudioMetadata(mSource, mSourceRecordable);
|
|
||||||
|
|
||||||
copy.mPriority = mPriority;
|
|
||||||
copy.mSelected = mSelected;
|
|
||||||
copy.mRecordable = mRecordable;
|
|
||||||
copy.mStreamable = mStreamable;
|
|
||||||
|
|
||||||
copy.mMetadata.putAll(mMetadata);
|
|
||||||
copy.mUpdated = mUpdated;
|
|
||||||
copy.mIdentifier = new String(mIdentifier);
|
|
||||||
|
|
||||||
mUpdated = false;
|
|
||||||
|
|
||||||
return copy;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Removes any accumulated temporal metadata and returns to a default set.
|
|
||||||
*/
|
|
||||||
public void reset()
|
|
||||||
{
|
|
||||||
//Reset recordable state, identifier and audio call priority levels and reprocess the metadata
|
|
||||||
mRecordable = mSourceRecordable;
|
|
||||||
mStreamable = false;
|
|
||||||
setIdentifier(mSource);
|
|
||||||
mPriority = Priority.DEFAULT_PRIORITY;
|
|
||||||
|
|
||||||
List<MetadataType> toRemove = new ArrayList<>();
|
|
||||||
|
|
||||||
for (MetadataType type : mMetadata.keySet())
|
|
||||||
{
|
|
||||||
Metadata metadata = mMetadata.get(type);
|
|
||||||
|
|
||||||
if (metadata != null)
|
|
||||||
{
|
|
||||||
if (metadata.isTemporal())
|
|
||||||
{
|
|
||||||
toRemove.add(type);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
processMetadata(metadata);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
for (MetadataType type : toRemove)
|
|
||||||
{
|
|
||||||
mMetadata.remove(type);
|
|
||||||
}
|
|
||||||
|
|
||||||
mUpdated = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
private void processMetadata(Metadata metadata)
|
|
||||||
{
|
|
||||||
if (metadata.hasAlias())
|
|
||||||
{
|
|
||||||
Alias alias = metadata.getAlias();
|
|
||||||
|
|
||||||
if (metadata.getMetadataType() == MetadataType.FROM || metadata.getMetadataType() == MetadataType.TO)
|
|
||||||
{
|
|
||||||
if (!alias.isRecordable())
|
|
||||||
{
|
|
||||||
mRecordable = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (alias.isStreamable())
|
|
||||||
{
|
|
||||||
mStreamable = true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (metadata.getMetadataType() == MetadataType.TO)
|
|
||||||
{
|
|
||||||
setIdentifier(mSource, metadata.getValue());
|
|
||||||
}
|
|
||||||
|
|
||||||
if (alias != null && alias.getCallPriority() < mPriority)
|
|
||||||
{
|
|
||||||
mPriority = alias.getCallPriority();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Indicates if this audio metadata contains updated information. The flag
|
|
||||||
* will only be set when new data is added and will be reset by a copyOf()
|
|
||||||
* method invocation.
|
|
||||||
*/
|
|
||||||
public boolean isUpdated()
|
|
||||||
{
|
|
||||||
return mUpdated;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setUpdated(boolean updated)
|
|
||||||
{
|
|
||||||
mUpdated = updated;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Adds the metadata. Any temporal metadata will be removed when the
|
|
||||||
* dispose() method is invoked.
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
public void receive(Metadata metadata)
|
|
||||||
{
|
|
||||||
if (metadata.isReset())
|
|
||||||
{
|
|
||||||
reset();
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
Metadata existing = mMetadata.get(metadata.getMetadataType());
|
|
||||||
|
|
||||||
if (existing == null || !existing.equals(metadata))
|
|
||||||
{
|
|
||||||
mMetadata.put(metadata.getMetadataType(), metadata);
|
|
||||||
processMetadata(metadata);
|
|
||||||
setUpdated(true);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
mUpdated = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns the complete set of metadata
|
|
||||||
*/
|
|
||||||
public Map<MetadataType, Metadata> getMetadata()
|
|
||||||
{
|
|
||||||
return mMetadata;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns the metadata object matching the type or null
|
|
||||||
*/
|
|
||||||
public Metadata getMetadata(MetadataType type)
|
|
||||||
{
|
|
||||||
return mMetadata.get(type);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Source channel ID
|
|
||||||
*/
|
|
||||||
public void setSource(int source)
|
|
||||||
{
|
|
||||||
mSource = source;
|
|
||||||
|
|
||||||
mUpdated = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
public int getSource()
|
|
||||||
{
|
|
||||||
return mSource;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Sets the priority of this audio packet within the defined min/max priority range
|
|
||||||
*/
|
|
||||||
public void setPriority(int priority)
|
|
||||||
{
|
|
||||||
mPriority = priority;
|
|
||||||
|
|
||||||
mUpdated = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns the priority of this audio metadata
|
|
||||||
*
|
|
||||||
* @return - priority of audio packet where lower numbers are higher priority
|
|
||||||
*/
|
|
||||||
public int getPriority()
|
|
||||||
{
|
|
||||||
return mPriority;
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean isDoNotMonitor()
|
|
||||||
{
|
|
||||||
return mPriority == Priority.DO_NOT_MONITOR;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Selected audio channel. A selected channel will override the priority
|
|
||||||
* level so that the audio can be listened to immediately.
|
|
||||||
*/
|
|
||||||
public void setSelected(boolean selected)
|
|
||||||
{
|
|
||||||
mSelected = selected;
|
|
||||||
|
|
||||||
mUpdated = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean isSelected()
|
|
||||||
{
|
|
||||||
return mSelected;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Indicates if audio associated with this metadata is recordable.
|
|
||||||
*/
|
|
||||||
public boolean isRecordable()
|
|
||||||
{
|
|
||||||
return mRecordable;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setRecordable(boolean recordable)
|
|
||||||
{
|
|
||||||
mRecordable = recordable;
|
|
||||||
mUpdated = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Indicates if the audio associated with this metadata is streamable
|
|
||||||
*/
|
|
||||||
public boolean isStreamable()
|
|
||||||
{
|
|
||||||
return mStreamable;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Collection<BroadcastChannel> getBroadcastChannels()
|
|
||||||
{
|
|
||||||
Set<BroadcastChannel> broadcastChannels = new TreeSet<>();
|
|
||||||
|
|
||||||
for(Metadata metadata: mMetadata.values())
|
|
||||||
{
|
|
||||||
if(metadata.hasAlias() && metadata.getAlias().isStreamable())
|
|
||||||
{
|
|
||||||
Alias alias = metadata.getAlias();
|
|
||||||
|
|
||||||
broadcastChannels.addAll(alias.getBroadcastChannels());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return broadcastChannels;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String toString()
|
|
||||||
{
|
|
||||||
StringBuilder sb = new StringBuilder();
|
|
||||||
|
|
||||||
sb.append("Audio Metadata - source:");
|
|
||||||
sb.append(getSource());
|
|
||||||
sb.append(" priority:");
|
|
||||||
sb.append(getPriority());
|
|
||||||
sb.append(" updated:" + isUpdated());
|
|
||||||
sb.append(" ");
|
|
||||||
|
|
||||||
for (Entry<MetadataType, Metadata> entry : getMetadata().entrySet())
|
|
||||||
{
|
|
||||||
sb.append(entry.getValue().getKey());
|
|
||||||
sb.append(":");
|
|
||||||
sb.append(entry.getValue().getValue());
|
|
||||||
sb.append(" ");
|
|
||||||
}
|
|
||||||
|
|
||||||
return sb.toString();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,8 +0,0 @@
|
|||||||
package audio.metadata;
|
|
||||||
|
|
||||||
import sample.Listener;
|
|
||||||
|
|
||||||
public interface IMetadataListener
|
|
||||||
{
|
|
||||||
public Listener<Metadata> getMetadataListener();
|
|
||||||
}
|
|
||||||
@@ -1,9 +0,0 @@
|
|||||||
package audio.metadata;
|
|
||||||
|
|
||||||
import sample.Listener;
|
|
||||||
|
|
||||||
public interface IMetadataProvider
|
|
||||||
{
|
|
||||||
public void setMetadataListener( Listener<Metadata> listener );
|
|
||||||
public void removeMetadataListener();
|
|
||||||
}
|
|
||||||
@@ -1,162 +0,0 @@
|
|||||||
/*******************************************************************************
|
|
||||||
* SDR Trunk
|
|
||||||
* Copyright (C) 2014-2016 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 audio.metadata;
|
|
||||||
|
|
||||||
import alias.Alias;
|
|
||||||
|
|
||||||
public class Metadata
|
|
||||||
{
|
|
||||||
private MetadataType mMetadataType;
|
|
||||||
private String mValue;
|
|
||||||
private Alias mValueAlias;
|
|
||||||
private boolean mTemporal;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Constucts a metadata object with the temporal settings. Temporal
|
|
||||||
* indicates that this metadata will be removed at the end of a reset
|
|
||||||
* event, or call end event.
|
|
||||||
*/
|
|
||||||
public Metadata( MetadataType metadataType, String value, Alias alias, boolean temporal )
|
|
||||||
{
|
|
||||||
mMetadataType = metadataType;
|
|
||||||
mValue = value;
|
|
||||||
mValueAlias = alias;
|
|
||||||
mTemporal = temporal;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Constucts a metadata object with the temporal settings. Temporal
|
|
||||||
* indicates that this metadata will be removed at the end of a reset
|
|
||||||
* event, or call end event.
|
|
||||||
*/
|
|
||||||
public Metadata( MetadataType metadataType, String value, boolean temporal )
|
|
||||||
{
|
|
||||||
this( metadataType, value, null, temporal );
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Constucts a non-temporal metadata object
|
|
||||||
*/
|
|
||||||
public Metadata( MetadataType metadataType, String value, Alias alias )
|
|
||||||
{
|
|
||||||
this( metadataType, value, alias, false );
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Constucts a non-temporal metadata object
|
|
||||||
*/
|
|
||||||
public Metadata( MetadataType metadataType, String value )
|
|
||||||
{
|
|
||||||
this( metadataType, value, null, false );
|
|
||||||
}
|
|
||||||
|
|
||||||
public MetadataType getMetadataType()
|
|
||||||
{
|
|
||||||
return mMetadataType;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getKey()
|
|
||||||
{
|
|
||||||
return mMetadataType.getLabel();
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getValue()
|
|
||||||
{
|
|
||||||
return mValue;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Alias getAlias()
|
|
||||||
{
|
|
||||||
return mValueAlias;
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean hasAlias()
|
|
||||||
{
|
|
||||||
return mValueAlias != null;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Indicates that this piece of metadata is only valid for the duration of
|
|
||||||
* a call event and should be removed during a reset
|
|
||||||
*/
|
|
||||||
public boolean isTemporal()
|
|
||||||
{
|
|
||||||
return mTemporal;
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean isReset()
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String toString()
|
|
||||||
{
|
|
||||||
StringBuilder sb = new StringBuilder();
|
|
||||||
|
|
||||||
sb.append( mMetadataType.getLabel() );
|
|
||||||
sb.append( ":" );
|
|
||||||
sb.append( mValue );
|
|
||||||
sb.append( " Alias:" );
|
|
||||||
sb.append( mValueAlias == null ? "null" : getAlias().getName() );
|
|
||||||
sb.append( " [" );
|
|
||||||
sb.append( mMetadataType.name() );
|
|
||||||
sb.append( "] temporal:" );
|
|
||||||
sb.append( mTemporal );
|
|
||||||
|
|
||||||
return sb.toString();
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean equals( Metadata other )
|
|
||||||
{
|
|
||||||
if( mMetadataType != other.getMetadataType() )
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
if( mTemporal != other.isTemporal() )
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
if( mValue != null && other.getValue() != null &&
|
|
||||||
!mValue.contentEquals( other.getValue() ))
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
if( ( mValue == null && other.getValue() != null ) ||
|
|
||||||
( mValue != null && other.getValue() == null ) )
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
if( mValueAlias != null && other.getAlias() != null &&
|
|
||||||
!mValueAlias.getName().contentEquals( other.getAlias().getName() ))
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
if( ( mValueAlias == null && other.getAlias() != null ) ||
|
|
||||||
( mValueAlias != null && other.getAlias() == null ) )
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,14 +0,0 @@
|
|||||||
package audio.metadata;
|
|
||||||
|
|
||||||
public class MetadataReset extends Metadata
|
|
||||||
{
|
|
||||||
public MetadataReset()
|
|
||||||
{
|
|
||||||
super( MetadataType.TEMPORAL_RESET, "reset", true );
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean isReset()
|
|
||||||
{
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,40 +0,0 @@
|
|||||||
package audio.metadata;
|
|
||||||
|
|
||||||
public enum MetadataType
|
|
||||||
{
|
|
||||||
CHANNEL_NUMBER( "Channel Number" ),
|
|
||||||
CHANNEL_NAME( "Channel Name" ),
|
|
||||||
DETAILS( "Details" ),
|
|
||||||
ESN( "ESN" ),
|
|
||||||
FLEETSYNC( "Fleetsync" ),
|
|
||||||
FREQUENCY( "Frequency" ),
|
|
||||||
FROM( "From" ),
|
|
||||||
MDC1200( "MDC-1200" ),
|
|
||||||
MOBILE_ID( "Mobile ID" ),
|
|
||||||
MPT1327( "MPT-1327" ),
|
|
||||||
PROTOCOL( "Protocol" ),
|
|
||||||
SITE_ID( "Site ID" ),
|
|
||||||
STATUS( "Status" ),
|
|
||||||
SYSTEM( "System" ),
|
|
||||||
TO( "To" ),
|
|
||||||
UNIQUE_ID( "Unique ID" ),
|
|
||||||
|
|
||||||
TEMPORAL_RESET( "Reset" );
|
|
||||||
|
|
||||||
private String mLabel;
|
|
||||||
|
|
||||||
private MetadataType( String label )
|
|
||||||
{
|
|
||||||
mLabel = label;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getLabel()
|
|
||||||
{
|
|
||||||
return mLabel;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String toString()
|
|
||||||
{
|
|
||||||
return mLabel;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,6 +1,6 @@
|
|||||||
/*******************************************************************************
|
/*******************************************************************************
|
||||||
* SDR Trunk
|
* sdrtrunk
|
||||||
* Copyright (C) 2014-2016 Dennis Sheirer
|
* Copyright (C) 2014-2017 Dennis Sheirer
|
||||||
*
|
*
|
||||||
* This program is free software: you can redistribute it and/or modify
|
* 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
|
* it under the terms of the GNU General Public License as published by
|
||||||
@@ -14,16 +14,21 @@
|
|||||||
*
|
*
|
||||||
* You should have received a copy of the GNU General Public License
|
* You should have received a copy of the GNU General Public License
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>
|
* along with this program. If not, see <http://www.gnu.org/licenses/>
|
||||||
|
*
|
||||||
******************************************************************************/
|
******************************************************************************/
|
||||||
package audio.output;
|
package audio.output;
|
||||||
|
|
||||||
import java.nio.ByteBuffer;
|
import audio.AudioEvent;
|
||||||
import java.util.ArrayList;
|
import audio.AudioPacket;
|
||||||
import java.util.List;
|
import audio.AudioPacket.Type;
|
||||||
import java.util.concurrent.LinkedTransferQueue;
|
import channel.metadata.Metadata;
|
||||||
import java.util.concurrent.ScheduledFuture;
|
import controller.ThreadPoolManager;
|
||||||
import java.util.concurrent.TimeUnit;
|
import controller.ThreadPoolManager.ThreadType;
|
||||||
import java.util.concurrent.atomic.AtomicBoolean;
|
import org.slf4j.Logger;
|
||||||
|
import org.slf4j.LoggerFactory;
|
||||||
|
import sample.Broadcaster;
|
||||||
|
import sample.Listener;
|
||||||
|
import source.mixer.MixerChannel;
|
||||||
|
|
||||||
import javax.sound.sampled.AudioFormat;
|
import javax.sound.sampled.AudioFormat;
|
||||||
import javax.sound.sampled.BooleanControl;
|
import javax.sound.sampled.BooleanControl;
|
||||||
@@ -35,19 +40,13 @@ import javax.sound.sampled.LineListener;
|
|||||||
import javax.sound.sampled.LineUnavailableException;
|
import javax.sound.sampled.LineUnavailableException;
|
||||||
import javax.sound.sampled.Mixer;
|
import javax.sound.sampled.Mixer;
|
||||||
import javax.sound.sampled.SourceDataLine;
|
import javax.sound.sampled.SourceDataLine;
|
||||||
|
import java.nio.ByteBuffer;
|
||||||
import org.slf4j.Logger;
|
import java.util.ArrayList;
|
||||||
import org.slf4j.LoggerFactory;
|
import java.util.List;
|
||||||
|
import java.util.concurrent.LinkedTransferQueue;
|
||||||
import sample.Broadcaster;
|
import java.util.concurrent.ScheduledFuture;
|
||||||
import sample.Listener;
|
import java.util.concurrent.TimeUnit;
|
||||||
import source.mixer.MixerChannel;
|
import java.util.concurrent.atomic.AtomicBoolean;
|
||||||
import audio.AudioEvent;
|
|
||||||
import audio.AudioPacket;
|
|
||||||
import audio.AudioPacket.Type;
|
|
||||||
import audio.metadata.AudioMetadata;
|
|
||||||
import controller.ThreadPoolManager;
|
|
||||||
import controller.ThreadPoolManager.ThreadType;
|
|
||||||
|
|
||||||
public abstract class AudioOutput implements Listener<AudioPacket>, LineListener
|
public abstract class AudioOutput implements Listener<AudioPacket>, LineListener
|
||||||
{
|
{
|
||||||
@@ -57,7 +56,7 @@ public abstract class AudioOutput implements Listener<AudioPacket>, LineListener
|
|||||||
private int mBufferStartThreshold;
|
private int mBufferStartThreshold;
|
||||||
private int mBufferStopThreshold;
|
private int mBufferStopThreshold;
|
||||||
|
|
||||||
private Listener<AudioMetadata> mAudioMetadataListener;
|
private Listener<Metadata> mMetadataListener;
|
||||||
private Broadcaster<AudioEvent> mAudioEventBroadcaster = new Broadcaster<>();
|
private Broadcaster<AudioEvent> mAudioEventBroadcaster = new Broadcaster<>();
|
||||||
|
|
||||||
private ThreadPoolManager mThreadPoolManager;
|
private ThreadPoolManager mThreadPoolManager;
|
||||||
@@ -183,7 +182,7 @@ public abstract class AudioOutput implements Listener<AudioPacket>, LineListener
|
|||||||
|
|
||||||
mAudioEventBroadcaster.dispose();
|
mAudioEventBroadcaster.dispose();
|
||||||
mAudioEventBroadcaster = null;
|
mAudioEventBroadcaster = null;
|
||||||
mAudioMetadataListener = null;
|
mMetadataListener = null;
|
||||||
|
|
||||||
if(mOutput != null)
|
if(mOutput != null)
|
||||||
{
|
{
|
||||||
@@ -242,24 +241,24 @@ public abstract class AudioOutput implements Listener<AudioPacket>, LineListener
|
|||||||
* Registers a single listener to receive the audio metadata from each
|
* Registers a single listener to receive the audio metadata from each
|
||||||
* audio packet
|
* audio packet
|
||||||
*/
|
*/
|
||||||
public void setAudioMetadataListener( Listener<AudioMetadata> listener )
|
public void setMetadataListener(Listener<Metadata> listener)
|
||||||
{
|
{
|
||||||
mAudioMetadataListener = listener;
|
mMetadataListener = listener;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void removeAudioMetadataListener()
|
public void removeAudioMetadataListener()
|
||||||
{
|
{
|
||||||
mAudioMetadataListener = null;
|
mMetadataListener = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Broadcasts audio metadata to the registered listener
|
* Broadcasts audio metadata to the registered listener
|
||||||
*/
|
*/
|
||||||
private void broadcast( AudioMetadata metadata )
|
private void broadcast(Metadata metadata)
|
||||||
{
|
{
|
||||||
if( mAudioMetadataListener != null )
|
if(mMetadataListener != null)
|
||||||
{
|
{
|
||||||
mAudioMetadataListener.receive( metadata );
|
mMetadataListener.receive(metadata);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -317,7 +316,7 @@ public abstract class AudioOutput implements Listener<AudioPacket>, LineListener
|
|||||||
{
|
{
|
||||||
if(packet.getType() == Type.AUDIO)
|
if(packet.getType() == Type.AUDIO)
|
||||||
{
|
{
|
||||||
broadcast( packet.getAudioMetadata() );
|
broadcast(packet.getMetadata());
|
||||||
|
|
||||||
ByteBuffer buffer = convert(packet);
|
ByteBuffer buffer = convert(packet);
|
||||||
|
|
||||||
|
|||||||
111
src/channel/metadata/AliasedIdentifier.java
Normal file
111
src/channel/metadata/AliasedIdentifier.java
Normal file
@@ -0,0 +1,111 @@
|
|||||||
|
/*******************************************************************************
|
||||||
|
* 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 channel.metadata;
|
||||||
|
|
||||||
|
import 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;
|
||||||
|
}
|
||||||
|
}
|
||||||
99
src/channel/metadata/AliasedIntegerAttributeMonitor.java
Normal file
99
src/channel/metadata/AliasedIntegerAttributeMonitor.java
Normal file
@@ -0,0 +1,99 @@
|
|||||||
|
/*******************************************************************************
|
||||||
|
* 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 channel.metadata;
|
||||||
|
|
||||||
|
import alias.Alias;
|
||||||
|
import alias.AliasList;
|
||||||
|
import alias.id.AliasIDType;
|
||||||
|
import sample.Listener;
|
||||||
|
|
||||||
|
import static alias.id.AliasIDType.*;
|
||||||
|
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
}
|
||||||
114
src/channel/metadata/AliasedStringAttributeMonitor.java
Normal file
114
src/channel/metadata/AliasedStringAttributeMonitor.java
Normal file
@@ -0,0 +1,114 @@
|
|||||||
|
/*******************************************************************************
|
||||||
|
* 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 channel.metadata;
|
||||||
|
|
||||||
|
import alias.Alias;
|
||||||
|
import alias.AliasList;
|
||||||
|
import alias.id.AliasIDType;
|
||||||
|
import sample.Listener;
|
||||||
|
|
||||||
|
import static alias.id.AliasIDType.*;
|
||||||
|
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
}
|
||||||
38
src/channel/metadata/Attribute.java
Normal file
38
src/channel/metadata/Attribute.java
Normal file
@@ -0,0 +1,38 @@
|
|||||||
|
/*******************************************************************************
|
||||||
|
* 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 channel.metadata;
|
||||||
|
|
||||||
|
public enum Attribute
|
||||||
|
{
|
||||||
|
CHANNEL_CONFIGURATION_NAME,
|
||||||
|
CHANNEL_CONFIGURATION_SITE,
|
||||||
|
CHANNEL_CONFIGURATION_SYSTEM,
|
||||||
|
CHANNEL_FREQUENCY,
|
||||||
|
CHANNEL_FREQUENCY_LABEL,
|
||||||
|
CHANNEL_STATE,
|
||||||
|
MESSAGE,
|
||||||
|
MESSAGE_TYPE,
|
||||||
|
NETWORK_ID_1,
|
||||||
|
NETWORK_ID_2,
|
||||||
|
PRIMARY_ADDRESS_FROM,
|
||||||
|
PRIMARY_ADDRESS_TO,
|
||||||
|
PRIMARY_DECODER_TYPE,
|
||||||
|
SECONDARY_ADDRESS_FROM,
|
||||||
|
SECONDARY_ADDRESS_TO,
|
||||||
|
}
|
||||||
131
src/channel/metadata/AttributeChangeRequest.java
Normal file
131
src/channel/metadata/AttributeChangeRequest.java
Normal file
@@ -0,0 +1,131 @@
|
|||||||
|
/*******************************************************************************
|
||||||
|
* 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 channel.metadata;
|
||||||
|
|
||||||
|
import alias.Alias;
|
||||||
|
import module.decode.DecoderType;
|
||||||
|
|
||||||
|
public class AttributeChangeRequest<T>
|
||||||
|
{
|
||||||
|
private Attribute mAttribute;
|
||||||
|
private T mValue;
|
||||||
|
private Alias mAlias;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Request to change the value of an attribute
|
||||||
|
* @param attribute to change
|
||||||
|
* @param value to change for the attribute
|
||||||
|
* @param alias (optional) for the value
|
||||||
|
*/
|
||||||
|
public AttributeChangeRequest(Attribute attribute, T value, Alias alias)
|
||||||
|
{
|
||||||
|
mAttribute = attribute;
|
||||||
|
mValue = value;
|
||||||
|
mAlias = alias;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Request to change the value of an attribute
|
||||||
|
* @param attribute to change
|
||||||
|
* @param value to change for the attribute
|
||||||
|
*/
|
||||||
|
public AttributeChangeRequest(Attribute attribute, T value)
|
||||||
|
{
|
||||||
|
this(attribute, value, null);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Attribute to change
|
||||||
|
*/
|
||||||
|
public Attribute getAttribute()
|
||||||
|
{
|
||||||
|
return mAttribute;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Value to set for the attribute
|
||||||
|
*/
|
||||||
|
public T getValue()
|
||||||
|
{
|
||||||
|
return mValue;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Indicates if this change request has a non-null value for the attribute
|
||||||
|
*/
|
||||||
|
public boolean hasValue()
|
||||||
|
{
|
||||||
|
return mValue != null;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Alias for the corresponding attribute value
|
||||||
|
*/
|
||||||
|
public Alias getAlias()
|
||||||
|
{
|
||||||
|
return mAlias;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Indicates if this change request contains an alias that corresponds to the attribute value
|
||||||
|
*/
|
||||||
|
public boolean hasAlias()
|
||||||
|
{
|
||||||
|
return mAlias != null;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the value as a String or null if the value is not a String instance.
|
||||||
|
*/
|
||||||
|
public String getStringValue()
|
||||||
|
{
|
||||||
|
if(mValue instanceof String)
|
||||||
|
{
|
||||||
|
return (String)mValue;
|
||||||
|
}
|
||||||
|
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the value as a Long or null if the value is not a Long instance.
|
||||||
|
*/
|
||||||
|
public Long getLongValue()
|
||||||
|
{
|
||||||
|
if(mValue instanceof Long)
|
||||||
|
{
|
||||||
|
return (Long)mValue;
|
||||||
|
}
|
||||||
|
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the value as a DecoderType or null if the value is not a DecoderType instance.
|
||||||
|
*/
|
||||||
|
public DecoderType getDecoderTypeValue()
|
||||||
|
{
|
||||||
|
if(mValue instanceof DecoderType)
|
||||||
|
{
|
||||||
|
return (DecoderType)mValue;
|
||||||
|
}
|
||||||
|
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
189
src/channel/metadata/AttributeMonitor.java
Normal file
189
src/channel/metadata/AttributeMonitor.java
Normal file
@@ -0,0 +1,189 @@
|
|||||||
|
/*******************************************************************************
|
||||||
|
* 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 channel.metadata;
|
||||||
|
|
||||||
|
import alias.Alias;
|
||||||
|
import org.slf4j.Logger;
|
||||||
|
import org.slf4j.LoggerFactory;
|
||||||
|
import sample.Listener;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
public class AttributeMonitor<T>
|
||||||
|
{
|
||||||
|
private final static Logger mLog = LoggerFactory.getLogger(AttributeMonitor.class);
|
||||||
|
|
||||||
|
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
|
||||||
|
*
|
||||||
|
* @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();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 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;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void main(String[] args)
|
||||||
|
{
|
||||||
|
AttributeMonitor<String> monitor = new AttributeMonitor<>(Attribute.PRIMARY_ADDRESS_TO, new Listener<AttributeChangeRequest>()
|
||||||
|
{
|
||||||
|
@Override
|
||||||
|
public void receive(AttributeChangeRequest attributeChangeRequest)
|
||||||
|
{
|
||||||
|
mLog.debug("Attribute Changed - value:" + attributeChangeRequest.getValue());
|
||||||
|
}
|
||||||
|
});
|
||||||
|
monitor.addIllegalValue("0000");
|
||||||
|
monitor.addIllegalValue("000000");
|
||||||
|
|
||||||
|
monitor.process("ABCD");
|
||||||
|
monitor.process("EFGH");
|
||||||
|
monitor.process("0000");
|
||||||
|
monitor.process("0000");
|
||||||
|
monitor.process("ABCD");
|
||||||
|
monitor.reset();
|
||||||
|
|
||||||
|
monitor.process("EFGH");
|
||||||
|
monitor.process("ABCD");
|
||||||
|
monitor.process("ABCD");
|
||||||
|
monitor.process("EFGH");
|
||||||
|
monitor.process("EFGH");
|
||||||
|
monitor.process("000000");
|
||||||
|
monitor.process("000000");
|
||||||
|
monitor.process("000000");
|
||||||
|
monitor.process("000000");
|
||||||
|
}
|
||||||
|
}
|
||||||
275
src/channel/metadata/ChannelMetadataModel.java
Normal file
275
src/channel/metadata/ChannelMetadataModel.java
Normal file
@@ -0,0 +1,275 @@
|
|||||||
|
/*******************************************************************************
|
||||||
|
* 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 channel.metadata;
|
||||||
|
|
||||||
|
import channel.state.State;
|
||||||
|
import controller.channel.Channel;
|
||||||
|
import sample.Listener;
|
||||||
|
|
||||||
|
import javax.swing.table.AbstractTableModel;
|
||||||
|
import java.awt.*;
|
||||||
|
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>
|
||||||
|
{
|
||||||
|
private final DecimalFormat FREQUENCY_FORMATTER = new DecimalFormat( "#.0000" );
|
||||||
|
|
||||||
|
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 = {"State", "Decoder", "Channel", "Frequency", "Primary From", "Primary To",
|
||||||
|
"Secondary From", "Secondary To", "Channel Name", "Message"};
|
||||||
|
|
||||||
|
private List<MutableMetadata> mChannelMetadata = new ArrayList();
|
||||||
|
private Map<MutableMetadata,Channel> mMetadataChannelMap = new HashMap();
|
||||||
|
|
||||||
|
public void add(MutableMetadata metadata, Channel channel)
|
||||||
|
{
|
||||||
|
//Execute on the swing thread to avoid threading issues
|
||||||
|
EventQueue.invokeLater(new Runnable()
|
||||||
|
{
|
||||||
|
@Override
|
||||||
|
public void run()
|
||||||
|
{
|
||||||
|
mChannelMetadata.add(metadata);
|
||||||
|
mMetadataChannelMap.put(metadata, channel);
|
||||||
|
|
||||||
|
int index = mChannelMetadata.indexOf(metadata);
|
||||||
|
|
||||||
|
fireTableRowsInserted(index, index);
|
||||||
|
|
||||||
|
metadata.addListener(ChannelMetadataModel.this);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
public void remove(MutableMetadata metadata)
|
||||||
|
{
|
||||||
|
//Execute on the swing thread to avoid threading issues
|
||||||
|
EventQueue.invokeLater(new Runnable()
|
||||||
|
{
|
||||||
|
@Override
|
||||||
|
public void run()
|
||||||
|
{
|
||||||
|
metadata.removeListener(ChannelMetadataModel.this);
|
||||||
|
|
||||||
|
int index = mChannelMetadata.indexOf(metadata);
|
||||||
|
|
||||||
|
mChannelMetadata.remove(metadata);
|
||||||
|
mMetadataChannelMap.remove(metadata);
|
||||||
|
|
||||||
|
fireTableRowsDeleted(index, index);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the channel metadata at the specified model row index
|
||||||
|
*/
|
||||||
|
public Metadata getMetadata(int row)
|
||||||
|
{
|
||||||
|
if(row < mChannelMetadata.size())
|
||||||
|
{
|
||||||
|
return mChannelMetadata.get(row);
|
||||||
|
}
|
||||||
|
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the channel that matches the metadata or null
|
||||||
|
*/
|
||||||
|
public Channel getChannelFromMetadata(Metadata metadata)
|
||||||
|
{
|
||||||
|
return mMetadataChannelMap.get(metadata);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getRowCount()
|
||||||
|
{
|
||||||
|
return mChannelMetadata.size();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getColumnCount()
|
||||||
|
{
|
||||||
|
return COLUMNS.length;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getColumnName(int column)
|
||||||
|
{
|
||||||
|
return COLUMNS[column];
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Class<?> getColumnClass(int columnIndex)
|
||||||
|
{
|
||||||
|
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;
|
||||||
|
|
||||||
|
default:
|
||||||
|
return String.class;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Object getValueAt(int rowIndex, int columnIndex)
|
||||||
|
{
|
||||||
|
if(rowIndex <= mChannelMetadata.size())
|
||||||
|
{
|
||||||
|
Metadata metadata = 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.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;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void receive(MutableMetadataChangeEvent mutableMetadataChangeEvent)
|
||||||
|
{
|
||||||
|
//Execute on the swing thread to avoid threading issues
|
||||||
|
EventQueue.invokeLater(new Runnable()
|
||||||
|
{
|
||||||
|
@Override
|
||||||
|
public void run()
|
||||||
|
{
|
||||||
|
int rowIndex = mChannelMetadata.indexOf(mutableMetadataChangeEvent.getMetadata());
|
||||||
|
|
||||||
|
if(rowIndex >= 0)
|
||||||
|
{
|
||||||
|
switch(mutableMetadataChangeEvent.getAttribute())
|
||||||
|
{
|
||||||
|
case CHANNEL_CONFIGURATION_SYSTEM:
|
||||||
|
break;
|
||||||
|
case CHANNEL_CONFIGURATION_SITE:
|
||||||
|
break;
|
||||||
|
case CHANNEL_CONFIGURATION_NAME:
|
||||||
|
fireTableCellUpdated(rowIndex, COLUMN_CONFIGURATION_NAME);
|
||||||
|
break;
|
||||||
|
case CHANNEL_FREQUENCY:
|
||||||
|
fireTableCellUpdated(rowIndex, COLUMN_FREQUENCY);
|
||||||
|
break;
|
||||||
|
case CHANNEL_FREQUENCY_LABEL:
|
||||||
|
fireTableCellUpdated(rowIndex, COLUMN_CHANNEL);
|
||||||
|
break;
|
||||||
|
case CHANNEL_STATE:
|
||||||
|
fireTableCellUpdated(rowIndex, COLUMN_STATE);
|
||||||
|
break;
|
||||||
|
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);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
227
src/channel/metadata/ChannelMetadataPanel.java
Normal file
227
src/channel/metadata/ChannelMetadataPanel.java
Normal file
@@ -0,0 +1,227 @@
|
|||||||
|
/*******************************************************************************
|
||||||
|
* 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 channel.metadata;
|
||||||
|
|
||||||
|
import alias.Alias;
|
||||||
|
import channel.state.State;
|
||||||
|
import com.sun.xml.internal.ws.api.streaming.XMLStreamReaderFactory;
|
||||||
|
import controller.channel.Channel;
|
||||||
|
import controller.channel.ChannelProcessingManager;
|
||||||
|
import icon.IconManager;
|
||||||
|
import module.ProcessingChain;
|
||||||
|
import net.miginfocom.swing.MigLayout;
|
||||||
|
import properties.SystemProperties;
|
||||||
|
import sample.Broadcaster;
|
||||||
|
import sample.Listener;
|
||||||
|
|
||||||
|
import javax.swing.*;
|
||||||
|
import javax.swing.event.ListSelectionEvent;
|
||||||
|
import javax.swing.event.ListSelectionListener;
|
||||||
|
import javax.swing.table.DefaultTableCellRenderer;
|
||||||
|
import java.awt.*;
|
||||||
|
|
||||||
|
public class ChannelMetadataPanel extends JPanel implements ListSelectionListener
|
||||||
|
{
|
||||||
|
private static final String PROPERTY_PREFIX_BACKGROUND = "channel.metadata.panel.state.color.";
|
||||||
|
private static final String PROPERTY_PREFIX_FOREGROUND = "channel.metadata.panel.text.color.";
|
||||||
|
private ChannelProcessingManager mChannelProcessingManager;
|
||||||
|
private IconManager mIconManager;
|
||||||
|
private JTable mTable;
|
||||||
|
private Broadcaster<ProcessingChain> mSelectedProcessingChainBroadcaster = new Broadcaster<>();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Table view for currently decoding channel metadata
|
||||||
|
*/
|
||||||
|
public ChannelMetadataPanel(ChannelProcessingManager channelProcessingManager, IconManager iconManager)
|
||||||
|
{
|
||||||
|
mIconManager = iconManager;
|
||||||
|
mChannelProcessingManager = channelProcessingManager;
|
||||||
|
|
||||||
|
init();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Initializes the panel
|
||||||
|
*/
|
||||||
|
private void init()
|
||||||
|
{
|
||||||
|
setLayout( new MigLayout( "insets 0 0 0 0", "[grow,fill]", "[grow,fill]") );
|
||||||
|
|
||||||
|
mTable = new JTable(mChannelProcessingManager.getChannelMetadataModel());
|
||||||
|
|
||||||
|
DefaultTableCellRenderer renderer = (DefaultTableCellRenderer)mTable.getDefaultRenderer(String.class);
|
||||||
|
renderer.setHorizontalAlignment(SwingConstants.CENTER);
|
||||||
|
|
||||||
|
mTable.getSelectionModel().addListSelectionListener(this);
|
||||||
|
|
||||||
|
mTable.getColumnModel().getColumn(ChannelMetadataModel.COLUMN_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));
|
||||||
|
|
||||||
|
JScrollPane scrollPane = new JScrollPane(mTable, JScrollPane.VERTICAL_SCROLLBAR_ALWAYS,
|
||||||
|
JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED);
|
||||||
|
|
||||||
|
add(scrollPane);
|
||||||
|
|
||||||
|
// new TableColumnWidthMonitor(mTable, PROPERTY_PREFIX, new int[] {15,15,15,15,25,25,25,25,15,40});
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void valueChanged(ListSelectionEvent e)
|
||||||
|
{
|
||||||
|
if(!mTable.getSelectionModel().getValueIsAdjusting())
|
||||||
|
{
|
||||||
|
ProcessingChain processingChain = null;
|
||||||
|
|
||||||
|
int selectedViewRow = mTable.getSelectedRow();
|
||||||
|
|
||||||
|
if(selectedViewRow >= 0)
|
||||||
|
{
|
||||||
|
int selectedModelRow = mTable.convertRowIndexToModel(selectedViewRow);
|
||||||
|
|
||||||
|
Metadata selectedMetadata = mChannelProcessingManager.getChannelMetadataModel()
|
||||||
|
.getMetadata(selectedModelRow);
|
||||||
|
|
||||||
|
if(selectedMetadata != null)
|
||||||
|
{
|
||||||
|
Channel selectedChannel = mChannelProcessingManager.getChannelMetadataModel()
|
||||||
|
.getChannelFromMetadata(selectedMetadata);
|
||||||
|
|
||||||
|
processingChain = mChannelProcessingManager.getProcessingChain(selectedChannel);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
mSelectedProcessingChainBroadcaster.broadcast(processingChain);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Adds the listener to receive the processing chain associated with the metadata selected in the
|
||||||
|
* metadata table.
|
||||||
|
*/
|
||||||
|
public void addProcessingChainSelectionListener(Listener<ProcessingChain> listener)
|
||||||
|
{
|
||||||
|
mSelectedProcessingChainBroadcaster.addListener(listener);
|
||||||
|
}
|
||||||
|
|
||||||
|
public class AliasedValueCellRenderer extends DefaultTableCellRenderer
|
||||||
|
{
|
||||||
|
private Attribute mAttribute;
|
||||||
|
|
||||||
|
public AliasedValueCellRenderer(Attribute attribute)
|
||||||
|
{
|
||||||
|
assert(attribute != null);
|
||||||
|
mAttribute = attribute;
|
||||||
|
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);
|
||||||
|
|
||||||
|
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());
|
||||||
|
|
||||||
|
return label;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public class ColoredStateCellRenderer extends DefaultTableCellRenderer
|
||||||
|
{
|
||||||
|
public ColoredStateCellRenderer()
|
||||||
|
{
|
||||||
|
setHorizontalAlignment(SwingConstants.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);
|
||||||
|
|
||||||
|
Color background = table.getBackground();
|
||||||
|
Color foreground = table.getForeground();
|
||||||
|
|
||||||
|
if(value instanceof State)
|
||||||
|
{
|
||||||
|
State state = (State)value;
|
||||||
|
label.setText(state.getDisplayValue());
|
||||||
|
|
||||||
|
switch(state)
|
||||||
|
{
|
||||||
|
case CALL:
|
||||||
|
background = SystemProperties.getInstance().get(PROPERTY_PREFIX_BACKGROUND + "call", Color.BLUE);
|
||||||
|
foreground = SystemProperties.getInstance().get(PROPERTY_PREFIX_FOREGROUND + "call", Color.YELLOW);
|
||||||
|
break;
|
||||||
|
case CONTROL:
|
||||||
|
background = SystemProperties.getInstance().get(PROPERTY_PREFIX_BACKGROUND + "control", Color.ORANGE);
|
||||||
|
foreground = SystemProperties.getInstance().get(PROPERTY_PREFIX_FOREGROUND + "control", Color.BLUE);
|
||||||
|
break;
|
||||||
|
case DATA:
|
||||||
|
background = SystemProperties.getInstance().get(PROPERTY_PREFIX_BACKGROUND + "data", Color.GREEN);
|
||||||
|
foreground = SystemProperties.getInstance().get(PROPERTY_PREFIX_FOREGROUND + "data", Color.BLUE);
|
||||||
|
break;
|
||||||
|
case ENCRYPTED:
|
||||||
|
background = SystemProperties.getInstance().get(PROPERTY_PREFIX_BACKGROUND + "encrypted", Color.MAGENTA);
|
||||||
|
foreground = SystemProperties.getInstance().get(PROPERTY_PREFIX_FOREGROUND + "encrypted", Color.WHITE);
|
||||||
|
break;
|
||||||
|
case FADE:
|
||||||
|
background = SystemProperties.getInstance().get(PROPERTY_PREFIX_BACKGROUND + "fade", Color.LIGHT_GRAY.BLUE);
|
||||||
|
foreground = SystemProperties.getInstance().get(PROPERTY_PREFIX_FOREGROUND + "fade", Color.YELLOW);
|
||||||
|
break;
|
||||||
|
case IDLE:
|
||||||
|
background = SystemProperties.getInstance().get(PROPERTY_PREFIX_BACKGROUND + "idle", Color.WHITE);
|
||||||
|
foreground = SystemProperties.getInstance().get(PROPERTY_PREFIX_FOREGROUND + "idle", Color.BLUE);
|
||||||
|
break;
|
||||||
|
case RESET:
|
||||||
|
background = SystemProperties.getInstance().get(PROPERTY_PREFIX_BACKGROUND + "reset", Color.PINK);
|
||||||
|
foreground = SystemProperties.getInstance().get(PROPERTY_PREFIX_FOREGROUND + "reset", Color.YELLOW);
|
||||||
|
break;
|
||||||
|
case TEARDOWN:
|
||||||
|
background = SystemProperties.getInstance().get(PROPERTY_PREFIX_BACKGROUND + "teardown", Color.DARK_GRAY);
|
||||||
|
foreground = SystemProperties.getInstance().get(PROPERTY_PREFIX_FOREGROUND + "teardown", Color.WHITE);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
setText("");
|
||||||
|
}
|
||||||
|
|
||||||
|
setBackground(background);
|
||||||
|
setForeground(foreground);
|
||||||
|
|
||||||
|
return label;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
77
src/channel/metadata/ChannelMetadataViewer.java
Normal file
77
src/channel/metadata/ChannelMetadataViewer.java
Normal file
@@ -0,0 +1,77 @@
|
|||||||
|
/*******************************************************************************
|
||||||
|
* 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 channel.metadata;
|
||||||
|
|
||||||
|
import com.jidesoft.swing.JideSplitPane;
|
||||||
|
import com.jidesoft.swing.JideTabbedPane;
|
||||||
|
import controller.channel.ChannelProcessingManager;
|
||||||
|
import icon.IconManager;
|
||||||
|
import module.decode.event.CallEventPanel;
|
||||||
|
import module.decode.event.MessageActivityPanel;
|
||||||
|
import net.miginfocom.swing.MigLayout;
|
||||||
|
import settings.SettingsManager;
|
||||||
|
import spectrum.ChannelSpectrumPanel;
|
||||||
|
|
||||||
|
import javax.swing.*;
|
||||||
|
import java.awt.*;
|
||||||
|
|
||||||
|
public class ChannelMetadataViewer extends JPanel
|
||||||
|
{
|
||||||
|
private CallEventPanel mCallEventPanel;
|
||||||
|
private MessageActivityPanel mMessageActivityPanel;
|
||||||
|
private ChannelSpectrumPanel mChannelSpectrumPanel;
|
||||||
|
private ChannelMetadataPanel mChannelMetadataPanel;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 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)
|
||||||
|
{
|
||||||
|
mCallEventPanel = new CallEventPanel(iconManager);
|
||||||
|
mMessageActivityPanel = new MessageActivityPanel(channelProcessingManager);
|
||||||
|
mChannelSpectrumPanel = new ChannelSpectrumPanel(settingsManager, channelProcessingManager);
|
||||||
|
mChannelMetadataPanel = new ChannelMetadataPanel(channelProcessingManager, iconManager);
|
||||||
|
|
||||||
|
init();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void init()
|
||||||
|
{
|
||||||
|
setLayout( new MigLayout( "insets 0 0 0 0", "[grow,fill]", "[grow,fill]") );
|
||||||
|
|
||||||
|
JideTabbedPane tabbedPane = new JideTabbedPane();
|
||||||
|
// tabbedPane.addTab("Details", new JPanel());
|
||||||
|
tabbedPane.addTab("Events", mCallEventPanel);
|
||||||
|
tabbedPane.addTab("Messages", mMessageActivityPanel);
|
||||||
|
// tabbedPane.addTab("Spectrum", mChannelSpectrumPanel);
|
||||||
|
tabbedPane.setFont(this.getFont());
|
||||||
|
tabbedPane.setForeground(Color.BLACK);
|
||||||
|
|
||||||
|
JideSplitPane splitPane = new JideSplitPane(JideSplitPane.VERTICAL_SPLIT);
|
||||||
|
splitPane.setShowGripper(true);
|
||||||
|
splitPane.add(mChannelMetadataPanel);
|
||||||
|
splitPane.add(tabbedPane);
|
||||||
|
add(splitPane);
|
||||||
|
|
||||||
|
mChannelMetadataPanel.addProcessingChainSelectionListener(mCallEventPanel);
|
||||||
|
mChannelMetadataPanel.addProcessingChainSelectionListener(mMessageActivityPanel);
|
||||||
|
}
|
||||||
|
}
|
||||||
26
src/channel/metadata/IAttributeChangeRequestListener.java
Normal file
26
src/channel/metadata/IAttributeChangeRequestListener.java
Normal file
@@ -0,0 +1,26 @@
|
|||||||
|
/*******************************************************************************
|
||||||
|
* 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 channel.metadata;
|
||||||
|
|
||||||
|
import sample.Listener;
|
||||||
|
|
||||||
|
public interface IAttributeChangeRequestListener
|
||||||
|
{
|
||||||
|
public Listener<AttributeChangeRequest> getAttributeChangeRequestListener();
|
||||||
|
}
|
||||||
28
src/channel/metadata/IAttributeChangeRequestProvider.java
Normal file
28
src/channel/metadata/IAttributeChangeRequestProvider.java
Normal file
@@ -0,0 +1,28 @@
|
|||||||
|
/*******************************************************************************
|
||||||
|
* 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 channel.metadata;
|
||||||
|
|
||||||
|
import sample.Listener;
|
||||||
|
|
||||||
|
public interface IAttributeChangeRequestProvider
|
||||||
|
{
|
||||||
|
public void setAttributeChangeRequestListener(Listener<AttributeChangeRequest> listener);
|
||||||
|
|
||||||
|
public void removeAttributeChangeRequestListener(Listener<AttributeChangeRequest> listener);
|
||||||
|
}
|
||||||
662
src/channel/metadata/Metadata.java
Normal file
662
src/channel/metadata/Metadata.java
Normal file
@@ -0,0 +1,662 @@
|
|||||||
|
/*******************************************************************************
|
||||||
|
* 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 channel.metadata;
|
||||||
|
|
||||||
|
import alias.Alias;
|
||||||
|
import alias.id.broadcast.BroadcastChannel;
|
||||||
|
import alias.id.priority.Priority;
|
||||||
|
import channel.state.State;
|
||||||
|
import module.decode.DecoderType;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
public class Metadata
|
||||||
|
{
|
||||||
|
// 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 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;
|
||||||
|
private List<BroadcastChannel> mBroadcastChannels;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 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;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 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(mRecordable == null)
|
||||||
|
{
|
||||||
|
determineRecordable();
|
||||||
|
}
|
||||||
|
|
||||||
|
return mRecordable;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 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;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* List of de-duplicated broadcast channels aggregated from the primary and secondary TO/FROM aliases.
|
||||||
|
*/
|
||||||
|
public List<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()
|
||||||
|
{
|
||||||
|
mRecordable = false;
|
||||||
|
|
||||||
|
if(mPrimaryAddressTo.hasAlias() && mPrimaryAddressTo.getAlias().isRecordable())
|
||||||
|
{
|
||||||
|
mRecordable = true;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(mPrimaryAddressFrom.hasAlias() && mPrimaryAddressFrom.getAlias().isRecordable())
|
||||||
|
{
|
||||||
|
mRecordable = true;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(mSecondaryAddressTo.hasAlias() && mSecondaryAddressTo.getAlias().isRecordable())
|
||||||
|
{
|
||||||
|
mRecordable = true;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(mSecondaryAddressFrom.hasAlias() && mSecondaryAddressFrom.getAlias().isRecordable())
|
||||||
|
{
|
||||||
|
mRecordable = true;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Aggregates a de-duplicated list of broadcast channels from among the primary/secondary to/from aliases
|
||||||
|
*/
|
||||||
|
private void determineBroadcastChannels()
|
||||||
|
{
|
||||||
|
mBroadcastChannels = new ArrayList<>();
|
||||||
|
|
||||||
|
if(mPrimaryAddressTo.hasAlias() && mPrimaryAddressTo.getAlias().isStreamable())
|
||||||
|
{
|
||||||
|
for(BroadcastChannel broadcastChannel: mPrimaryAddressTo.getAlias().getBroadcastChannels())
|
||||||
|
{
|
||||||
|
if(!mBroadcastChannels.contains(broadcastChannel))
|
||||||
|
{
|
||||||
|
mBroadcastChannels.add(broadcastChannel);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if(mPrimaryAddressFrom.hasAlias() && mPrimaryAddressFrom.getAlias().isStreamable())
|
||||||
|
{
|
||||||
|
for(BroadcastChannel broadcastChannel: mPrimaryAddressFrom.getAlias().getBroadcastChannels())
|
||||||
|
{
|
||||||
|
if(!mBroadcastChannels.contains(broadcastChannel))
|
||||||
|
{
|
||||||
|
mBroadcastChannels.add(broadcastChannel);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if(mSecondaryAddressTo.hasAlias() && mSecondaryAddressTo.getAlias().isStreamable())
|
||||||
|
{
|
||||||
|
for(BroadcastChannel broadcastChannel: mSecondaryAddressTo.getAlias().getBroadcastChannels())
|
||||||
|
{
|
||||||
|
if(!mBroadcastChannels.contains(broadcastChannel))
|
||||||
|
{
|
||||||
|
mBroadcastChannels.add(broadcastChannel);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if(mSecondaryAddressFrom.hasAlias() && mSecondaryAddressFrom.getAlias().isStreamable())
|
||||||
|
{
|
||||||
|
for(BroadcastChannel broadcastChannel: mSecondaryAddressFrom.getAlias().getBroadcastChannels())
|
||||||
|
{
|
||||||
|
if(!mBroadcastChannels.contains(broadcastChannel))
|
||||||
|
{
|
||||||
|
mBroadcastChannels.add(broadcastChannel);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 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.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;
|
||||||
|
}
|
||||||
|
}
|
||||||
287
src/channel/metadata/MutableMetadata.java
Normal file
287
src/channel/metadata/MutableMetadata.java
Normal file
@@ -0,0 +1,287 @@
|
|||||||
|
/*******************************************************************************
|
||||||
|
* 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 channel.metadata;
|
||||||
|
|
||||||
|
import channel.state.State;
|
||||||
|
import module.decode.DecoderType;
|
||||||
|
import org.slf4j.Logger;
|
||||||
|
import org.slf4j.LoggerFactory;
|
||||||
|
import sample.Broadcaster;
|
||||||
|
import sample.Listener;
|
||||||
|
|
||||||
|
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 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()
|
||||||
|
{
|
||||||
|
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);
|
||||||
|
}
|
||||||
|
}
|
||||||
53
src/channel/metadata/MutableMetadataChangeEvent.java
Normal file
53
src/channel/metadata/MutableMetadataChangeEvent.java
Normal file
@@ -0,0 +1,53 @@
|
|||||||
|
/*******************************************************************************
|
||||||
|
* 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 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;
|
||||||
|
}
|
||||||
|
}
|
||||||
107
src/channel/state/AlwaysUnsquelchedDecoderState.java
Normal file
107
src/channel/state/AlwaysUnsquelchedDecoderState.java
Normal file
@@ -0,0 +1,107 @@
|
|||||||
|
/*******************************************************************************
|
||||||
|
* SDR Trunk
|
||||||
|
* Copyright (C) 2014,2015 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 channel.state;
|
||||||
|
|
||||||
|
import channel.metadata.Attribute;
|
||||||
|
import channel.metadata.AttributeChangeRequest;
|
||||||
|
import channel.state.DecoderStateEvent.Event;
|
||||||
|
import gui.SDRTrunk;
|
||||||
|
import message.Message;
|
||||||
|
import module.decode.DecoderType;
|
||||||
|
import org.slf4j.Logger;
|
||||||
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
|
import java.util.concurrent.ScheduledExecutorService;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Basic decoder channel state - provides the minimum channel state functionality
|
||||||
|
* to support an always un-squelched audio decoder.
|
||||||
|
*/
|
||||||
|
public class AlwaysUnsquelchedDecoderState extends DecoderState
|
||||||
|
{
|
||||||
|
private final static Logger mLog = LoggerFactory.getLogger(AlwaysUnsquelchedDecoderState.class);
|
||||||
|
|
||||||
|
private DecoderType mDecoderType;
|
||||||
|
private String mChannelName;
|
||||||
|
|
||||||
|
public AlwaysUnsquelchedDecoderState(DecoderType decoderType, String channelName)
|
||||||
|
{
|
||||||
|
super(null);
|
||||||
|
|
||||||
|
mDecoderType = decoderType;
|
||||||
|
mChannelName = channelName;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void init()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void reset()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getActivitySummary()
|
||||||
|
{
|
||||||
|
StringBuilder sb = new StringBuilder();
|
||||||
|
|
||||||
|
sb.append("Activity Summary\n");
|
||||||
|
sb.append("\tDecoder:\t");
|
||||||
|
sb.append(mDecoderType);
|
||||||
|
sb.append("\n\n");
|
||||||
|
|
||||||
|
return sb.toString();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void receive(Message t)
|
||||||
|
{
|
||||||
|
/* Not implemented */
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void receiveDecoderStateEvent(DecoderStateEvent event)
|
||||||
|
{
|
||||||
|
if(event.getEvent() == Event.RESET)
|
||||||
|
{
|
||||||
|
//Each time we're reset, set the PRIMARY TO attribute back to the channel name, otherwise we won't have
|
||||||
|
//a primary ID for any audio produced by this state.
|
||||||
|
broadcast(new AttributeChangeRequest<String>(Attribute.PRIMARY_ADDRESS_TO, mChannelName));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public DecoderType getDecoderType()
|
||||||
|
{
|
||||||
|
return mDecoderType;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void start(ScheduledExecutorService executor)
|
||||||
|
{
|
||||||
|
broadcast(new AttributeChangeRequest<String>(Attribute.PRIMARY_ADDRESS_TO, mChannelName));
|
||||||
|
broadcast(new DecoderStateEvent(this, Event.ALWAYS_UNSQUELCH, State.IDLE));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void stop()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
package module.decode.state;
|
package channel.state;
|
||||||
|
|
||||||
import controller.channel.Channel.ChannelType;
|
import controller.channel.Channel.ChannelType;
|
||||||
|
|
||||||
627
src/channel/state/ChannelState.java
Normal file
627
src/channel/state/ChannelState.java
Normal file
@@ -0,0 +1,627 @@
|
|||||||
|
/*******************************************************************************
|
||||||
|
* 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 channel.state;
|
||||||
|
|
||||||
|
import audio.squelch.ISquelchStateProvider;
|
||||||
|
import audio.squelch.SquelchState;
|
||||||
|
import channel.metadata.Attribute;
|
||||||
|
import channel.metadata.AttributeChangeRequest;
|
||||||
|
import channel.metadata.IAttributeChangeRequestListener;
|
||||||
|
import channel.metadata.MutableMetadata;
|
||||||
|
import channel.state.DecoderStateEvent.Event;
|
||||||
|
import channel.traffic.TrafficChannelManager;
|
||||||
|
import controller.channel.Channel.ChannelType;
|
||||||
|
import module.Module;
|
||||||
|
import module.decode.DecoderType;
|
||||||
|
import module.decode.config.DecodeConfiguration;
|
||||||
|
import module.decode.event.CallEvent;
|
||||||
|
import module.decode.event.ICallEventProvider;
|
||||||
|
import org.slf4j.Logger;
|
||||||
|
import org.slf4j.LoggerFactory;
|
||||||
|
import sample.Listener;
|
||||||
|
|
||||||
|
import java.util.concurrent.RejectedExecutionException;
|
||||||
|
import java.util.concurrent.ScheduledExecutorService;
|
||||||
|
import java.util.concurrent.ScheduledFuture;
|
||||||
|
import java.util.concurrent.TimeUnit;
|
||||||
|
|
||||||
|
public class ChannelState extends Module implements ICallEventProvider, IDecoderStateEventListener,
|
||||||
|
IDecoderStateEventProvider, ISquelchStateProvider, IAttributeChangeRequestListener
|
||||||
|
{
|
||||||
|
private final static Logger mLog = LoggerFactory.getLogger(ChannelState.class);
|
||||||
|
|
||||||
|
public static final long FADE_TIMEOUT_DELAY = 1200;
|
||||||
|
public static final long RESET_TIMEOUT_DELAY = 2000;
|
||||||
|
|
||||||
|
private MutableMetadata mMutableMetadata = new MutableMetadata();
|
||||||
|
private State mState = State.IDLE;
|
||||||
|
private Listener<CallEvent> mCallEventListener;
|
||||||
|
private Listener<DecoderStateEvent> mDecoderStateListener;
|
||||||
|
private Listener<SquelchState> mSquelchStateListener;
|
||||||
|
private DecoderStateEventReceiver mDecoderStateEventReceiver = new DecoderStateEventReceiver();
|
||||||
|
private StateMonitor mStateMonitor = new StateMonitor();
|
||||||
|
private ScheduledFuture<?> mStateMonitorFuture;
|
||||||
|
private ChannelType mChannelType;
|
||||||
|
private TrafficChannelManager mTrafficChannelEndListener;
|
||||||
|
private CallEvent mTrafficChannelCallEvent;
|
||||||
|
|
||||||
|
private boolean mSquelchLocked = false;
|
||||||
|
private boolean mSelected = false;
|
||||||
|
|
||||||
|
private long mStandardChannelFadeTimeout = FADE_TIMEOUT_DELAY;
|
||||||
|
private long mTrafficChannelFadeTimeout = DecodeConfiguration.DEFAULT_CALL_TIMEOUT_SECONDS * 1000;
|
||||||
|
private long mFadeTimeout;
|
||||||
|
private long mEndTimeout;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Channel state tracks the overall state of all processing modules and decoders
|
||||||
|
* configured for the channel and provides squelch control and decoder state
|
||||||
|
* reset events.
|
||||||
|
*
|
||||||
|
* Uses a state enumeration that defines allowable channel state transitions in
|
||||||
|
* order to track a call or data decode event from start to finish. Uses a
|
||||||
|
* timer to monitor for inactivity and to provide a FADE period that indicates
|
||||||
|
* to the user that the activity has stopped while continuing to provide details
|
||||||
|
* about the call, before the state is reset to IDLE.
|
||||||
|
*
|
||||||
|
* Since this class is multi-threaded between decoder events and the internal
|
||||||
|
* timer that monitors for inactivity, this class uses the mState object for
|
||||||
|
* thread synchronization.
|
||||||
|
*
|
||||||
|
* State Descriptions:
|
||||||
|
* IDLE Normal state. No voice or data call activity
|
||||||
|
* CALL/DATA/ENCRYPTED/CONTROL
|
||||||
|
* Decoding states.
|
||||||
|
* FADE The phase after a voice or data call when either an explicit
|
||||||
|
* call end has been received, or when no new signalling updates
|
||||||
|
* have been received, and the fade timer has expired. This phase
|
||||||
|
* allows for gui updates to signal to the user that the call is
|
||||||
|
* ended, while continuing to display the call details for the user
|
||||||
|
* TEARDOWN Indicates a traffic channel that will be torn down for reuse.
|
||||||
|
*/
|
||||||
|
public ChannelState(ChannelType channelType)
|
||||||
|
{
|
||||||
|
mChannelType = channelType;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Metadata for this channel containing channel details, primary and secondary entities for call events and any
|
||||||
|
* decoded messages. This metadata is primarily intended to be used by graphical components to convey the
|
||||||
|
* details of the current channel state and to provide metadata backing any decoded audio packets produced by
|
||||||
|
* any audio streams for this channel.
|
||||||
|
*/
|
||||||
|
public MutableMetadata getMutableMetadata()
|
||||||
|
{
|
||||||
|
return mMutableMetadata;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Resets this channel state and prepares it for reuse.
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public void reset()
|
||||||
|
{
|
||||||
|
broadcast(new DecoderStateEvent(this, Event.RESET, State.IDLE));
|
||||||
|
|
||||||
|
mState = State.IDLE;
|
||||||
|
mMutableMetadata.receive(new AttributeChangeRequest<State>(Attribute.CHANNEL_STATE, mState));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void start(ScheduledExecutorService executor)
|
||||||
|
{
|
||||||
|
if(mStateMonitorFuture == null && mStateMonitor != null)
|
||||||
|
{
|
||||||
|
mMutableMetadata.receive(new AttributeChangeRequest<State>(Attribute.CHANNEL_STATE, mState));
|
||||||
|
|
||||||
|
if(mTrafficChannelEndListener != null)
|
||||||
|
{
|
||||||
|
setState(State.CALL);
|
||||||
|
}
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
mStateMonitorFuture = executor.scheduleAtFixedRate(mStateMonitor, 0, 20, TimeUnit.MILLISECONDS);
|
||||||
|
}
|
||||||
|
catch(RejectedExecutionException ree)
|
||||||
|
{
|
||||||
|
mLog.error("state monitor scheduled task rejected", ree);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void stop()
|
||||||
|
{
|
||||||
|
mMutableMetadata.resetAllAttributes();
|
||||||
|
|
||||||
|
if(mStateMonitorFuture != null)
|
||||||
|
{
|
||||||
|
boolean success = mStateMonitorFuture.cancel(true);
|
||||||
|
|
||||||
|
if(!success)
|
||||||
|
{
|
||||||
|
mLog.error("Couldn't stop monitoring scheduled future");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
mTrafficChannelEndListener = null;
|
||||||
|
|
||||||
|
if(mTrafficChannelCallEvent != null)
|
||||||
|
{
|
||||||
|
mTrafficChannelCallEvent.end();
|
||||||
|
broadcast(mTrafficChannelCallEvent);
|
||||||
|
}
|
||||||
|
|
||||||
|
mTrafficChannelCallEvent = null;
|
||||||
|
|
||||||
|
mStateMonitorFuture = null;
|
||||||
|
|
||||||
|
mSquelchLocked = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void dispose()
|
||||||
|
{
|
||||||
|
mCallEventListener = null;
|
||||||
|
mDecoderStateListener = null;
|
||||||
|
mSquelchStateListener = null;
|
||||||
|
mStateMonitor = null;
|
||||||
|
}
|
||||||
|
|
||||||
|
private boolean isStandardChannel()
|
||||||
|
{
|
||||||
|
return mChannelType == ChannelType.STANDARD;
|
||||||
|
}
|
||||||
|
|
||||||
|
private boolean isTrafficChannel()
|
||||||
|
{
|
||||||
|
return mChannelType == ChannelType.TRAFFIC;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setStandardChannelTimeout(long milliseconds)
|
||||||
|
{
|
||||||
|
mStandardChannelFadeTimeout = milliseconds;
|
||||||
|
|
||||||
|
if(mChannelType == ChannelType.STANDARD)
|
||||||
|
{
|
||||||
|
mFadeTimeout = mStandardChannelFadeTimeout;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setTrafficChannelTimeout(long milliseconds)
|
||||||
|
{
|
||||||
|
mTrafficChannelFadeTimeout = milliseconds;
|
||||||
|
|
||||||
|
if(mChannelType == ChannelType.TRAFFIC)
|
||||||
|
{
|
||||||
|
mFadeTimeout = System.currentTimeMillis() + mTrafficChannelFadeTimeout;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setSelected(boolean selected)
|
||||||
|
{
|
||||||
|
mSelected = selected;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isSelected()
|
||||||
|
{
|
||||||
|
return mSelected;
|
||||||
|
}
|
||||||
|
|
||||||
|
public State getState()
|
||||||
|
{
|
||||||
|
return mState;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Updates the fade timeout threshold to the current time plus delay
|
||||||
|
*/
|
||||||
|
private void updateFadeTimeout()
|
||||||
|
{
|
||||||
|
if(isTrafficChannel())
|
||||||
|
{
|
||||||
|
mFadeTimeout = System.currentTimeMillis() + mTrafficChannelFadeTimeout;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
mFadeTimeout = System.currentTimeMillis() + mStandardChannelFadeTimeout;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Updates the reset timeout threshold to the current time plus delay
|
||||||
|
*/
|
||||||
|
private void updateResetTimeout()
|
||||||
|
{
|
||||||
|
if(isTrafficChannel())
|
||||||
|
{
|
||||||
|
mEndTimeout = System.currentTimeMillis();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
mEndTimeout = System.currentTimeMillis() + RESET_TIMEOUT_DELAY;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Broadcasts the squelch state to the registered listener
|
||||||
|
*/
|
||||||
|
protected void broadcast(SquelchState state)
|
||||||
|
{
|
||||||
|
if(mSquelchStateListener != null && !mSquelchLocked)
|
||||||
|
{
|
||||||
|
mSquelchStateListener.receive(state);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets the squelch state listener
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public void setSquelchStateListener(Listener<SquelchState> listener)
|
||||||
|
{
|
||||||
|
mSquelchStateListener = listener;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Removes the squelch state listener
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public void removeSquelchStateListener()
|
||||||
|
{
|
||||||
|
mSquelchStateListener = null;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets the channel state to the specified state, or updates the timeout
|
||||||
|
* values so that the state monitor will not change state. Broadcasts a
|
||||||
|
* squelch event when the state changes and the audio squelch state should
|
||||||
|
* change. Also broadcasts changed attribute and decoder state events so
|
||||||
|
* that external processes can maintain sync with this channel state.
|
||||||
|
*/
|
||||||
|
protected void setState(State state)
|
||||||
|
{
|
||||||
|
synchronized(mState)
|
||||||
|
{
|
||||||
|
if(state == mState)
|
||||||
|
{
|
||||||
|
if(State.CALL_STATES.contains(state))
|
||||||
|
{
|
||||||
|
updateFadeTimeout();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if(state != mState && mState.canChangeTo(state))
|
||||||
|
{
|
||||||
|
switch(state)
|
||||||
|
{
|
||||||
|
case CONTROL:
|
||||||
|
//Don't allow traffic channels to be control channels,
|
||||||
|
//otherwise they can't transition to call tear down
|
||||||
|
if(isStandardChannel())
|
||||||
|
{
|
||||||
|
broadcast(SquelchState.SQUELCH);
|
||||||
|
updateFadeTimeout();
|
||||||
|
mState = state;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case DATA:
|
||||||
|
case ENCRYPTED:
|
||||||
|
broadcast(SquelchState.SQUELCH);
|
||||||
|
updateFadeTimeout();
|
||||||
|
mState = state;
|
||||||
|
break;
|
||||||
|
case CALL:
|
||||||
|
broadcast(SquelchState.UNSQUELCH);
|
||||||
|
updateFadeTimeout();
|
||||||
|
mState = state;
|
||||||
|
break;
|
||||||
|
case FADE:
|
||||||
|
processFadeState();
|
||||||
|
break;
|
||||||
|
case IDLE:
|
||||||
|
processIdleState();
|
||||||
|
break;
|
||||||
|
case TEARDOWN:
|
||||||
|
processTeardownState();
|
||||||
|
break;
|
||||||
|
case RESET:
|
||||||
|
mState = State.IDLE;
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
mMutableMetadata.receive(new AttributeChangeRequest<State>(Attribute.CHANNEL_STATE, mState));
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// mLog.debug( "Can't change from [" + mState + "] to [" + state + "]" );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets the state and processes related actions
|
||||||
|
*/
|
||||||
|
private void processFadeState()
|
||||||
|
{
|
||||||
|
updateResetTimeout();
|
||||||
|
mState = State.FADE;
|
||||||
|
|
||||||
|
broadcast(SquelchState.SQUELCH);
|
||||||
|
mMutableMetadata.receive(new AttributeChangeRequest<State>(Attribute.CHANNEL_STATE, mState));
|
||||||
|
}
|
||||||
|
|
||||||
|
private void processIdleState()
|
||||||
|
{
|
||||||
|
broadcast(SquelchState.SQUELCH);
|
||||||
|
|
||||||
|
if(mState == State.FADE)
|
||||||
|
{
|
||||||
|
getMutableMetadata().resetTemporalAttributes();
|
||||||
|
broadcast(new DecoderStateEvent(this, Event.RESET, State.IDLE));
|
||||||
|
}
|
||||||
|
|
||||||
|
mState = State.IDLE;
|
||||||
|
getMutableMetadata().receive(new AttributeChangeRequest<State>(Attribute.CHANNEL_STATE, mState));
|
||||||
|
}
|
||||||
|
|
||||||
|
private void processTeardownState()
|
||||||
|
{
|
||||||
|
broadcast(SquelchState.SQUELCH);
|
||||||
|
|
||||||
|
getMutableMetadata().resetTemporalAttributes();
|
||||||
|
|
||||||
|
mState = State.TEARDOWN;
|
||||||
|
|
||||||
|
mMutableMetadata.receive(new AttributeChangeRequest<State>(Attribute.CHANNEL_STATE, mState));
|
||||||
|
|
||||||
|
if(mTrafficChannelEndListener != null)
|
||||||
|
{
|
||||||
|
mTrafficChannelEndListener.callEnd(mTrafficChannelCallEvent.getChannel());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Broadcasts the call event to the registered listener
|
||||||
|
*/
|
||||||
|
protected void broadcast(CallEvent event)
|
||||||
|
{
|
||||||
|
if(mCallEventListener != null)
|
||||||
|
{
|
||||||
|
mCallEventListener.receive(event);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void addCallEventListener(Listener<CallEvent> listener)
|
||||||
|
{
|
||||||
|
mCallEventListener = listener;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void removeCallEventListener(Listener<CallEvent> listener)
|
||||||
|
{
|
||||||
|
mCallEventListener = null;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//NEW:
|
||||||
|
@Override
|
||||||
|
public Listener<AttributeChangeRequest> getAttributeChangeRequestListener()
|
||||||
|
{
|
||||||
|
return mMutableMetadata;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Broadcasts a channel state event to any registered listeners
|
||||||
|
*/
|
||||||
|
protected void broadcast(DecoderStateEvent event)
|
||||||
|
{
|
||||||
|
if(mDecoderStateListener != null)
|
||||||
|
{
|
||||||
|
mDecoderStateListener.receive(event);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Adds a decoder state event listener
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public void setDecoderStateListener(Listener<DecoderStateEvent> listener)
|
||||||
|
{
|
||||||
|
mDecoderStateListener = listener;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Removes the decoder state event listener
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public void removeDecoderStateListener()
|
||||||
|
{
|
||||||
|
mDecoderStateListener = null;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Listener<DecoderStateEvent> getDecoderStateListener()
|
||||||
|
{
|
||||||
|
return mDecoderStateEventReceiver;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Registers a listener to be notified when a traffic channel call event is
|
||||||
|
* completed, so that the listener can perform call tear-down
|
||||||
|
*/
|
||||||
|
public void configureAsTrafficChannel(TrafficChannelManager manager, CallEvent callEvent)
|
||||||
|
{
|
||||||
|
mTrafficChannelEndListener = manager;
|
||||||
|
|
||||||
|
mTrafficChannelCallEvent = callEvent;
|
||||||
|
|
||||||
|
/* Broadcast the call event details as metadata for the audio manager */
|
||||||
|
String channel = mTrafficChannelCallEvent.getChannel();
|
||||||
|
|
||||||
|
if(channel != null)
|
||||||
|
{
|
||||||
|
mMutableMetadata.receive(new AttributeChangeRequest<String>(Attribute.CHANNEL_FREQUENCY_LABEL, channel));
|
||||||
|
}
|
||||||
|
|
||||||
|
long frequency = mTrafficChannelCallEvent.getFrequency();
|
||||||
|
|
||||||
|
if(frequency > 0)
|
||||||
|
{
|
||||||
|
mMutableMetadata.receive(new AttributeChangeRequest<Long>(Attribute.CHANNEL_FREQUENCY, frequency));
|
||||||
|
}
|
||||||
|
|
||||||
|
mMutableMetadata.receive(new AttributeChangeRequest<DecoderType>(Attribute.PRIMARY_DECODER_TYPE,
|
||||||
|
mTrafficChannelCallEvent.getDecoderType()));
|
||||||
|
|
||||||
|
mMutableMetadata.receive(new AttributeChangeRequest<String>(Attribute.CHANNEL_CONFIGURATION_NAME, "TRAFFIC"));
|
||||||
|
|
||||||
|
String from = mTrafficChannelCallEvent.getFromID();
|
||||||
|
|
||||||
|
if(from != null)
|
||||||
|
{
|
||||||
|
mMutableMetadata.receive(new AttributeChangeRequest<String>(Attribute.PRIMARY_ADDRESS_FROM, from,
|
||||||
|
mTrafficChannelCallEvent.getFromIDAlias()));
|
||||||
|
}
|
||||||
|
|
||||||
|
String to = mTrafficChannelCallEvent.getToID();
|
||||||
|
|
||||||
|
if(to != null)
|
||||||
|
{
|
||||||
|
mMutableMetadata.receive(new AttributeChangeRequest<String>(Attribute.PRIMARY_ADDRESS_TO, to,
|
||||||
|
mTrafficChannelCallEvent.getToIDAlias()));
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Rebroadcast the allocation event so that the internal decoder states
|
||||||
|
* can self-configure with the call event details */
|
||||||
|
broadcast(mTrafficChannelCallEvent);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* DecoderStateEvent receiver wrapper
|
||||||
|
*/
|
||||||
|
public class DecoderStateEventReceiver implements Listener<DecoderStateEvent>
|
||||||
|
{
|
||||||
|
@Override
|
||||||
|
public void receive(DecoderStateEvent event)
|
||||||
|
{
|
||||||
|
if(event.getSource() != this)
|
||||||
|
{
|
||||||
|
switch(event.getEvent())
|
||||||
|
{
|
||||||
|
case ALWAYS_UNSQUELCH:
|
||||||
|
broadcast(SquelchState.UNSQUELCH);
|
||||||
|
mSquelchLocked = true;
|
||||||
|
break;
|
||||||
|
case CHANGE_CALL_TIMEOUT:
|
||||||
|
if(event instanceof ChangeChannelTimeoutEvent)
|
||||||
|
{
|
||||||
|
ChangeChannelTimeoutEvent timeout = (ChangeChannelTimeoutEvent) event;
|
||||||
|
|
||||||
|
if(timeout.getChannelType() == ChannelType.STANDARD)
|
||||||
|
{
|
||||||
|
setStandardChannelTimeout(timeout.getCallTimeout());
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
setTrafficChannelTimeout(timeout.getCallTimeout());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
case CONTINUATION:
|
||||||
|
case DECODE:
|
||||||
|
case START:
|
||||||
|
if(State.CALL_STATES.contains(event.getState()))
|
||||||
|
{
|
||||||
|
setState(event.getState());
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case END:
|
||||||
|
if(isTrafficChannel())
|
||||||
|
{
|
||||||
|
setState(State.TEARDOWN);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
setState(State.FADE);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case RESET:
|
||||||
|
/* Channel State does not respond to reset events */
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Monitors decoder state events to automatically transition the channel
|
||||||
|
* state to IDLE (standard channel) or to TEARDOWN (traffic channel) when
|
||||||
|
* decoding stops or the monitored channel returns to a no signal state.
|
||||||
|
*
|
||||||
|
* Provides a FADE transition state to allow for momentary decoding dropouts
|
||||||
|
* and to allow the user access to call details for a fade period upon
|
||||||
|
* call end.
|
||||||
|
*/
|
||||||
|
public class StateMonitor implements Runnable
|
||||||
|
{
|
||||||
|
@Override
|
||||||
|
public void run()
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
synchronized(mState)
|
||||||
|
{
|
||||||
|
if(State.CALL_STATES.contains(mState) &&
|
||||||
|
mFadeTimeout <= System.currentTimeMillis())
|
||||||
|
{
|
||||||
|
processFadeState();
|
||||||
|
}
|
||||||
|
else if(mState == State.FADE &&
|
||||||
|
mEndTimeout <= System.currentTimeMillis())
|
||||||
|
{
|
||||||
|
if(isTrafficChannel())
|
||||||
|
{
|
||||||
|
processTeardownState();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
processIdleState();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch(Exception e)
|
||||||
|
{
|
||||||
|
mLog.error("Exception thrown while state monitor is running " +
|
||||||
|
"- state [" + getState() +
|
||||||
|
"] current [" + System.currentTimeMillis() +
|
||||||
|
"] mResetTimeout [" + mEndTimeout +
|
||||||
|
"] mFadeTimeout [" + mFadeTimeout +
|
||||||
|
"]", e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -15,7 +15,7 @@
|
|||||||
* You should have received a copy of the GNU General Public License
|
* You should have received a copy of the GNU General Public License
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>
|
* along with this program. If not, see <http://www.gnu.org/licenses/>
|
||||||
******************************************************************************/
|
******************************************************************************/
|
||||||
package module.decode.state;
|
package channel.state;
|
||||||
|
|
||||||
|
|
||||||
public interface ChannelStateSelectionListener
|
public interface ChannelStateSelectionListener
|
||||||
198
src/channel/state/DecoderState.java
Normal file
198
src/channel/state/DecoderState.java
Normal file
@@ -0,0 +1,198 @@
|
|||||||
|
package channel.state;
|
||||||
|
|
||||||
|
import alias.AliasList;
|
||||||
|
import channel.metadata.AttributeChangeRequest;
|
||||||
|
import channel.metadata.IAttributeChangeRequestProvider;
|
||||||
|
import message.IMessageListener;
|
||||||
|
import message.Message;
|
||||||
|
import module.Module;
|
||||||
|
import module.decode.DecoderType;
|
||||||
|
import module.decode.event.ActivitySummaryProvider;
|
||||||
|
import module.decode.event.CallEvent;
|
||||||
|
import module.decode.event.ICallEventProvider;
|
||||||
|
import sample.Broadcaster;
|
||||||
|
import sample.Listener;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Channel state monitors the stream of decoded messages produced by the
|
||||||
|
* decoder and broadcasts call events as they occur within the decoded message activity.
|
||||||
|
*
|
||||||
|
* Provides access to a textual activity summary of events observed.
|
||||||
|
*/
|
||||||
|
public abstract class DecoderState extends Module implements ActivitySummaryProvider, Listener<Message>,
|
||||||
|
IAttributeChangeRequestProvider, ICallEventProvider, IDecoderStateEventListener,
|
||||||
|
IDecoderStateEventProvider, IMessageListener
|
||||||
|
{
|
||||||
|
/* This has to be a broadcaster in order for references to persist */
|
||||||
|
private Broadcaster<CallEvent> mCallEventBroadcaster = new Broadcaster<>();
|
||||||
|
private Broadcaster<AttributeChangeRequest> mAttributeChangeRequestBroadcaster = new Broadcaster<>();
|
||||||
|
private Listener<DecoderStateEvent> mDecoderStateListener;
|
||||||
|
|
||||||
|
private DecoderStateEventListener mDecoderStateEventListener = new DecoderStateEventListener();
|
||||||
|
|
||||||
|
protected CallEvent mCurrentCallEvent;
|
||||||
|
|
||||||
|
private AliasList mAliasList;
|
||||||
|
|
||||||
|
public DecoderState(AliasList aliasList)
|
||||||
|
{
|
||||||
|
mAliasList = aliasList;
|
||||||
|
}
|
||||||
|
|
||||||
|
public abstract DecoderType getDecoderType();
|
||||||
|
|
||||||
|
public AliasList getAliasList()
|
||||||
|
{
|
||||||
|
return mAliasList;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean hasAliasList()
|
||||||
|
{
|
||||||
|
return mAliasList != null;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Reset the decoder state to prepare for processing a different sample
|
||||||
|
* source
|
||||||
|
*/
|
||||||
|
public abstract void reset();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Allow the decoder to perform any setup actions
|
||||||
|
*/
|
||||||
|
public abstract void init();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Implements the IDecoderStateEventListener interface to receive state
|
||||||
|
* reset events.
|
||||||
|
*/
|
||||||
|
public abstract void receiveDecoderStateEvent(DecoderStateEvent event);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Disposes any resources or pointers held by this instance to prepare for
|
||||||
|
* garbage collection
|
||||||
|
*/
|
||||||
|
public void dispose()
|
||||||
|
{
|
||||||
|
mCallEventBroadcaster.dispose();
|
||||||
|
mCallEventBroadcaster = null;
|
||||||
|
mDecoderStateListener = null;
|
||||||
|
|
||||||
|
mAliasList = null;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Activity Summary - textual summary of activity observed by the channel state.
|
||||||
|
*/
|
||||||
|
public abstract String getActivitySummary();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Broadcasts a call event to any registered listeners
|
||||||
|
*/
|
||||||
|
protected void broadcast(CallEvent event)
|
||||||
|
{
|
||||||
|
mCallEventBroadcaster.broadcast(event);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Adds a call event listener
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public void addCallEventListener(Listener<CallEvent> listener)
|
||||||
|
{
|
||||||
|
mCallEventBroadcaster.addListener(listener);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Removes the call event listener
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public void removeCallEventListener(Listener<CallEvent> listener)
|
||||||
|
{
|
||||||
|
mCallEventBroadcaster.removeListener(listener);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Listener<DecoderStateEvent> getDecoderStateListener()
|
||||||
|
{
|
||||||
|
return mDecoderStateEventListener;
|
||||||
|
}
|
||||||
|
|
||||||
|
private class DecoderStateEventListener implements Listener<DecoderStateEvent>
|
||||||
|
{
|
||||||
|
@Override
|
||||||
|
public void receive(DecoderStateEvent event)
|
||||||
|
{
|
||||||
|
receiveDecoderStateEvent(event);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Broadcasts a channel state event to any registered listeners
|
||||||
|
*/
|
||||||
|
protected void broadcast(DecoderStateEvent event)
|
||||||
|
{
|
||||||
|
if(mDecoderStateListener != null)
|
||||||
|
{
|
||||||
|
mDecoderStateListener.receive(event);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Adds a decoder state event listener
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public void setDecoderStateListener(Listener<DecoderStateEvent> listener)
|
||||||
|
{
|
||||||
|
mDecoderStateListener = listener;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Removes the decoder state event listener
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public void removeDecoderStateListener()
|
||||||
|
{
|
||||||
|
mDecoderStateListener = null;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Listener<Message> getMessageListener()
|
||||||
|
{
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Broadcasts the attribute change request to the registered listener
|
||||||
|
*/
|
||||||
|
protected void broadcast(AttributeChangeRequest<?> request)
|
||||||
|
{
|
||||||
|
mAttributeChangeRequestBroadcaster.broadcast(request);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets the listener to receive attribute change requests from this decoder state
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public void setAttributeChangeRequestListener(Listener<AttributeChangeRequest> listener)
|
||||||
|
{
|
||||||
|
mAttributeChangeRequestBroadcaster.addListener(listener);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Removes any listener from receiving attribute change requests
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public void removeAttributeChangeRequestListener(Listener<AttributeChangeRequest> listener)
|
||||||
|
{
|
||||||
|
mAttributeChangeRequestBroadcaster.removeListener(listener);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Broadaster so that Attribute monitors can broadcast attribute change requests
|
||||||
|
*/
|
||||||
|
protected Listener<AttributeChangeRequest> getAttributeChangeRequestListener()
|
||||||
|
{
|
||||||
|
return mAttributeChangeRequestBroadcaster;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
package module.decode.state;
|
package channel.state;
|
||||||
|
|
||||||
public class DecoderStateEvent
|
public class DecoderStateEvent
|
||||||
{
|
{
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
package module.decode.state;
|
package channel.state;
|
||||||
|
|
||||||
import sample.Listener;
|
import sample.Listener;
|
||||||
|
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
package module.decode.state;
|
package channel.state;
|
||||||
|
|
||||||
import sample.Listener;
|
import sample.Listener;
|
||||||
|
|
||||||
@@ -15,7 +15,7 @@
|
|||||||
* You should have received a copy of the GNU General Public License
|
* You should have received a copy of the GNU General Public License
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>
|
* along with this program. If not, see <http://www.gnu.org/licenses/>
|
||||||
******************************************************************************/
|
******************************************************************************/
|
||||||
package module.decode.state;
|
package channel.state;
|
||||||
|
|
||||||
import java.util.EnumSet;
|
import java.util.EnumSet;
|
||||||
|
|
||||||
45
src/channel/traffic/TrafficChannelAllocationEvent.java
Normal file
45
src/channel/traffic/TrafficChannelAllocationEvent.java
Normal file
@@ -0,0 +1,45 @@
|
|||||||
|
/*******************************************************************************
|
||||||
|
* 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 channel.traffic;
|
||||||
|
|
||||||
|
import channel.state.DecoderStateEvent;
|
||||||
|
import channel.state.State;
|
||||||
|
import module.decode.event.CallEvent;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Traffic channel allocation event wraps a call event indicating the channel
|
||||||
|
* and frequency for a traffic channel allocation event, so that the traffic
|
||||||
|
* channel manager can respond and allocate a decoder channel and source if
|
||||||
|
* available, or change the wrapped call event to a call detect event and log it.
|
||||||
|
*/
|
||||||
|
public class TrafficChannelAllocationEvent extends DecoderStateEvent
|
||||||
|
{
|
||||||
|
private CallEvent mCallEvent;
|
||||||
|
|
||||||
|
public TrafficChannelAllocationEvent( Object source, CallEvent callEvent )
|
||||||
|
{
|
||||||
|
super( source, Event.TRAFFIC_CHANNEL_ALLOCATION, State.CALL );
|
||||||
|
mCallEvent = callEvent;
|
||||||
|
}
|
||||||
|
|
||||||
|
public CallEvent getCallEvent()
|
||||||
|
{
|
||||||
|
return mCallEvent;
|
||||||
|
}
|
||||||
|
}
|
||||||
447
src/channel/traffic/TrafficChannelManager.java
Normal file
447
src/channel/traffic/TrafficChannelManager.java
Normal file
@@ -0,0 +1,447 @@
|
|||||||
|
/*******************************************************************************
|
||||||
|
* 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 channel.traffic;
|
||||||
|
|
||||||
|
import alias.Alias;
|
||||||
|
import alias.id.priority.Priority;
|
||||||
|
import channel.state.DecoderStateEvent;
|
||||||
|
import channel.state.IDecoderStateEventListener;
|
||||||
|
import controller.channel.Channel;
|
||||||
|
import controller.channel.Channel.ChannelType;
|
||||||
|
import controller.channel.ChannelEvent;
|
||||||
|
import controller.channel.ChannelEvent.Event;
|
||||||
|
import controller.channel.ChannelModel;
|
||||||
|
import controller.channel.ChannelProcessingManager;
|
||||||
|
import controller.channel.TrafficChannelEvent;
|
||||||
|
import module.Module;
|
||||||
|
import module.decode.config.DecodeConfiguration;
|
||||||
|
import module.decode.event.CallEvent;
|
||||||
|
import module.decode.event.CallEvent.CallEventType;
|
||||||
|
import module.decode.event.ICallEventProvider;
|
||||||
|
import org.slf4j.Logger;
|
||||||
|
import org.slf4j.LoggerFactory;
|
||||||
|
import record.config.RecordConfiguration;
|
||||||
|
import sample.Listener;
|
||||||
|
import source.config.SourceConfigTuner;
|
||||||
|
import source.tuner.TunerChannel;
|
||||||
|
import source.tuner.TunerChannel.Type;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.concurrent.ConcurrentHashMap;
|
||||||
|
import java.util.concurrent.ScheduledExecutorService;
|
||||||
|
|
||||||
|
public class TrafficChannelManager extends Module implements ICallEventProvider, IDecoderStateEventListener
|
||||||
|
{
|
||||||
|
private final static Logger mLog = LoggerFactory.getLogger(TrafficChannelManager.class);
|
||||||
|
public static final String CHANNEL_START_REJECTED = "CHANNEL START REJECTED";
|
||||||
|
public static final String NO_TUNER_AVAILABLE = "NO TUNER AVAILABLE";
|
||||||
|
public static final String UNKNOWN_FREQUENCY = "UNKNOWN FREQUENCY";
|
||||||
|
|
||||||
|
private int mTrafficChannelPoolMaximumSize = DecodeConfiguration.TRAFFIC_CHANNEL_LIMIT_DEFAULT;
|
||||||
|
private List<Channel> mTrafficChannelPool = new ArrayList<Channel>();
|
||||||
|
private Map<String,Channel> mTrafficChannelsInUse = new ConcurrentHashMap<String,Channel>();
|
||||||
|
|
||||||
|
private DecoderStateEventListener mEventListener = new DecoderStateEventListener();
|
||||||
|
private Listener<CallEvent> mCallEventListener;
|
||||||
|
|
||||||
|
private ChannelModel mChannelModel;
|
||||||
|
private ChannelProcessingManager mChannelProcessingManager;
|
||||||
|
private DecodeConfiguration mDecodeConfiguration;
|
||||||
|
private RecordConfiguration mRecordConfiguration;
|
||||||
|
private String mSystem;
|
||||||
|
private String mSite;
|
||||||
|
private String mAliasListName;
|
||||||
|
private CallEvent mPreviousDoNotMonitorCallEvent;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Monitors call events and allocates traffic decoder channels in response
|
||||||
|
* to traffic channel allocation call events. Manages a pool of reusable
|
||||||
|
* traffic channel allocations.
|
||||||
|
*
|
||||||
|
* @param channelModel containing channels currently in use
|
||||||
|
* @param channelProcessingManager
|
||||||
|
* @param decodeConfiguration - decoder configuration to use for each
|
||||||
|
* traffic channel allocation.
|
||||||
|
* @param recordConfiguration - recording options for each traffic channel
|
||||||
|
* @param system label to use to describe the system
|
||||||
|
* @param site label to use to describe the site
|
||||||
|
* @param aliasListName designated for the channel
|
||||||
|
* @param trafficChannelTimeout - millisecond call timer limit used when an
|
||||||
|
* end of call signalling event is not decoded.
|
||||||
|
* @param trafficChannelPoolSize - maximum number of allocated traffic channels
|
||||||
|
* in the pool
|
||||||
|
*/
|
||||||
|
public TrafficChannelManager(ChannelModel channelModel,
|
||||||
|
ChannelProcessingManager channelProcessingManager,
|
||||||
|
DecodeConfiguration decodeConfiguration,
|
||||||
|
RecordConfiguration recordConfiguration,
|
||||||
|
String system,
|
||||||
|
String site,
|
||||||
|
String aliasListName,
|
||||||
|
long trafficChannelTimeout,
|
||||||
|
int trafficChannelPoolSize)
|
||||||
|
{
|
||||||
|
mChannelModel = channelModel;
|
||||||
|
mChannelProcessingManager = channelProcessingManager;
|
||||||
|
mDecodeConfiguration = decodeConfiguration;
|
||||||
|
mRecordConfiguration = recordConfiguration;
|
||||||
|
mSystem = system;
|
||||||
|
mSite = site;
|
||||||
|
mAliasListName = aliasListName;
|
||||||
|
mTrafficChannelPoolMaximumSize = trafficChannelPoolSize;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void dispose()
|
||||||
|
{
|
||||||
|
for(Channel trafficChannel : mTrafficChannelPool)
|
||||||
|
{
|
||||||
|
mChannelModel.broadcast(new ChannelEvent(trafficChannel, Event.REQUEST_DISABLE));
|
||||||
|
}
|
||||||
|
|
||||||
|
mTrafficChannelPool.clear();
|
||||||
|
|
||||||
|
mTrafficChannelsInUse.clear();
|
||||||
|
|
||||||
|
mCallEventListener = null;
|
||||||
|
mDecodeConfiguration = null;
|
||||||
|
mPreviousDoNotMonitorCallEvent = null;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Provides a channel by either reusing an existing channel or constructing
|
||||||
|
* a new one, limited by the total number of constructed channels allowed.
|
||||||
|
*
|
||||||
|
* Note: you must enforce thread safety on the mTrafficChannelsInUse
|
||||||
|
* external to this method.
|
||||||
|
*
|
||||||
|
* @param channelNumber
|
||||||
|
* @param tunerChannel
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
private Channel getChannel(String channelNumber, TunerChannel tunerChannel)
|
||||||
|
{
|
||||||
|
Channel channel = null;
|
||||||
|
|
||||||
|
if(!mTrafficChannelsInUse.containsKey(channelNumber))
|
||||||
|
{
|
||||||
|
for(Channel configuredChannel : mTrafficChannelPool)
|
||||||
|
{
|
||||||
|
if(!configuredChannel.getEnabled())
|
||||||
|
{
|
||||||
|
channel = configuredChannel;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if(channel == null && mTrafficChannelPool.size() < mTrafficChannelPoolMaximumSize)
|
||||||
|
{
|
||||||
|
channel = new Channel("Traffic", ChannelType.TRAFFIC);
|
||||||
|
|
||||||
|
channel.setDecodeConfiguration(mDecodeConfiguration);
|
||||||
|
|
||||||
|
channel.setRecordConfiguration(mRecordConfiguration);
|
||||||
|
|
||||||
|
channel.setAliasListName(mAliasListName);
|
||||||
|
|
||||||
|
mChannelModel.addChannel(channel);
|
||||||
|
|
||||||
|
mTrafficChannelPool.add(channel);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* If we have a configured channel, update metadata */
|
||||||
|
if(channel != null)
|
||||||
|
{
|
||||||
|
channel.setSourceConfiguration(new SourceConfigTuner(tunerChannel));
|
||||||
|
channel.setSystem(mSystem);
|
||||||
|
channel.setSite(mSite);
|
||||||
|
channel.setName(channelNumber);
|
||||||
|
|
||||||
|
mChannelModel.broadcast(new ChannelEvent(channel, Event.NOTIFICATION_CONFIGURATION_CHANGE));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return channel;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Processes the event and creates a traffic channel is resources are
|
||||||
|
* available
|
||||||
|
*/
|
||||||
|
private void process(TrafficChannelAllocationEvent event)
|
||||||
|
{
|
||||||
|
CallEvent callEvent = event.getCallEvent();
|
||||||
|
|
||||||
|
/* Check for duplicate events and suppress */
|
||||||
|
synchronized(mTrafficChannelsInUse)
|
||||||
|
{
|
||||||
|
if(mTrafficChannelsInUse.containsKey(callEvent.getChannel()))
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
long frequency = callEvent.getFrequency();
|
||||||
|
|
||||||
|
/* Check the from/to aliases for do not monitor priority */
|
||||||
|
if(isDoNotMonitor(callEvent))
|
||||||
|
{
|
||||||
|
callEvent.setCallEventType(CallEventType.CALL_DO_NOT_MONITOR);
|
||||||
|
|
||||||
|
if(isSameCallEvent(mPreviousDoNotMonitorCallEvent, callEvent))
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
mPreviousDoNotMonitorCallEvent = callEvent;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if(frequency > 0)
|
||||||
|
{
|
||||||
|
Channel channel = getChannel(callEvent.getChannel(), new TunerChannel(Type.TRAFFIC,
|
||||||
|
frequency, mDecodeConfiguration.getDecoderType().getChannelBandwidth()));
|
||||||
|
|
||||||
|
if(channel != null)
|
||||||
|
{
|
||||||
|
TrafficChannelEvent trafficChannelEvent =
|
||||||
|
new TrafficChannelEvent(this, channel, Event.REQUEST_ENABLE, callEvent);
|
||||||
|
|
||||||
|
//Request to enable the channel
|
||||||
|
mChannelModel.broadcast(trafficChannelEvent);
|
||||||
|
|
||||||
|
if(channel.getEnabled())
|
||||||
|
{
|
||||||
|
mTrafficChannelsInUse.put(callEvent.getChannel(), channel);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
callEvent.setCallEventType(CallEventType.CALL_DETECT);
|
||||||
|
|
||||||
|
String details = callEvent.getDetails();
|
||||||
|
|
||||||
|
if(details == null || details.isEmpty())
|
||||||
|
{
|
||||||
|
callEvent.setDetails(CHANNEL_START_REJECTED);
|
||||||
|
}
|
||||||
|
else if(!details.contains(CHANNEL_START_REJECTED))
|
||||||
|
{
|
||||||
|
callEvent.setDetails(new StringBuilder(CHANNEL_START_REJECTED).append(" : ")
|
||||||
|
.append(callEvent.getDetails()).toString());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
callEvent.setCallEventType(CallEventType.CALL_DETECT);
|
||||||
|
|
||||||
|
String details = callEvent.getDetails();
|
||||||
|
|
||||||
|
if(details == null || details.isEmpty())
|
||||||
|
{
|
||||||
|
callEvent.setDetails(NO_TUNER_AVAILABLE);
|
||||||
|
}
|
||||||
|
else if(!details.contains(NO_TUNER_AVAILABLE))
|
||||||
|
{
|
||||||
|
callEvent.setDetails(new StringBuilder(NO_TUNER_AVAILABLE).append(" : ")
|
||||||
|
.append(callEvent.getDetails()).toString());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
callEvent.setCallEventType(CallEventType.CALL_DETECT);
|
||||||
|
|
||||||
|
String details = callEvent.getDetails();
|
||||||
|
|
||||||
|
if(details == null || details.isEmpty())
|
||||||
|
{
|
||||||
|
callEvent.setDetails(UNKNOWN_FREQUENCY);
|
||||||
|
}
|
||||||
|
else if(!details.contains(UNKNOWN_FREQUENCY))
|
||||||
|
{
|
||||||
|
callEvent.setDetails(new StringBuilder(UNKNOWN_FREQUENCY).append(" : ")
|
||||||
|
.append(callEvent.getDetails()).toString());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
final Listener<CallEvent> listener = mCallEventListener;
|
||||||
|
|
||||||
|
if(listener != null)
|
||||||
|
{
|
||||||
|
listener.receive(callEvent);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Compares the call type, channel and to fields for equivalence and the
|
||||||
|
* from field for either both null, or equivalence.
|
||||||
|
*
|
||||||
|
* @param e1
|
||||||
|
* @param e2
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public static boolean isSameCallEvent(CallEvent e1, CallEvent e2)
|
||||||
|
{
|
||||||
|
if(e1 == null || e2 == null)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(e1.getCallEventType() != e2.getCallEventType())
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(e1.getChannel() == null || e2.getChannel() == null || !e1.getChannel().contentEquals(e2.getChannel()))
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(e1.getToID() == null || e2.getToID() == null || !e1.getToID().contentEquals(e2.getToID()))
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(e1.getFromID() == null || e2.getFromID() == null)
|
||||||
|
{
|
||||||
|
return (e1.getFromID() == null && e2.getFromID() == null);
|
||||||
|
}
|
||||||
|
else if(e1.getFromID().contentEquals(e2.getFromID()))
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Checks for aliases that contain a do not follow/process priority.
|
||||||
|
*
|
||||||
|
* @param event
|
||||||
|
* @return - true if there is an alias that has a do not process alias id
|
||||||
|
*/
|
||||||
|
private boolean isDoNotMonitor(CallEvent event)
|
||||||
|
{
|
||||||
|
Alias to = event.getToIDAlias();
|
||||||
|
|
||||||
|
if(to != null && to.hasCallPriority() && to.getCallPriority() == Priority.DO_NOT_MONITOR)
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
Alias from = event.getFromIDAlias();
|
||||||
|
|
||||||
|
if(from != null && from.hasCallPriority() && from.getCallPriority() == Priority.DO_NOT_MONITOR)
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Listener<DecoderStateEvent> getDecoderStateListener()
|
||||||
|
{
|
||||||
|
return mEventListener;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void addCallEventListener(Listener<CallEvent> listener)
|
||||||
|
{
|
||||||
|
mCallEventListener = listener;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void removeCallEventListener(Listener<CallEvent> listener)
|
||||||
|
{
|
||||||
|
mCallEventListener = null;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void reset()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void start(ScheduledExecutorService executor)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void stop()
|
||||||
|
{
|
||||||
|
if(!mTrafficChannelsInUse.isEmpty())
|
||||||
|
{
|
||||||
|
List<String> channels = new ArrayList<>();
|
||||||
|
|
||||||
|
/* Copy the keyset so we don't get concurrent modification of the map */
|
||||||
|
channels.addAll(mTrafficChannelsInUse.keySet());
|
||||||
|
|
||||||
|
for(String channel : channels)
|
||||||
|
{
|
||||||
|
callEnd(channel);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Callback used by the TrafficChannelStatusListener class to signal the
|
||||||
|
* end of a an allocated traffic channel call event
|
||||||
|
*
|
||||||
|
* @param channelNumber - channel number from the call event that signaled
|
||||||
|
* the start of a traffic channel allocation
|
||||||
|
*/
|
||||||
|
public void callEnd(String channelNumber)
|
||||||
|
{
|
||||||
|
synchronized(mTrafficChannelsInUse)
|
||||||
|
{
|
||||||
|
if(channelNumber != null && mTrafficChannelsInUse.containsKey(channelNumber))
|
||||||
|
{
|
||||||
|
Channel channel = mTrafficChannelsInUse.get(channelNumber);
|
||||||
|
|
||||||
|
mChannelModel.broadcast(new ChannelEvent(channel, Event.REQUEST_DISABLE));
|
||||||
|
|
||||||
|
mTrafficChannelsInUse.remove(channelNumber);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Wrapper class for the decoder state event listener interface to catch
|
||||||
|
* traffic channel allocation requests
|
||||||
|
*/
|
||||||
|
public class DecoderStateEventListener implements Listener<DecoderStateEvent>
|
||||||
|
{
|
||||||
|
@Override
|
||||||
|
public void receive(DecoderStateEvent event)
|
||||||
|
{
|
||||||
|
switch(event.getEvent())
|
||||||
|
{
|
||||||
|
case TRAFFIC_CHANNEL_ALLOCATION:
|
||||||
|
process((TrafficChannelAllocationEvent) event);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,6 +1,6 @@
|
|||||||
/*******************************************************************************
|
/*******************************************************************************
|
||||||
* SDR Trunk
|
* sdrtrunk
|
||||||
* Copyright (C) 2014-2016 Dennis Sheirer
|
* Copyright (C) 2014-2017 Dennis Sheirer
|
||||||
*
|
*
|
||||||
* This program is free software: you can redistribute it and/or modify
|
* 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
|
* it under the terms of the GNU General Public License as published by
|
||||||
@@ -14,45 +14,35 @@
|
|||||||
*
|
*
|
||||||
* You should have received a copy of the GNU General Public License
|
* You should have received a copy of the GNU General Public License
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>
|
* along with this program. If not, see <http://www.gnu.org/licenses/>
|
||||||
|
*
|
||||||
******************************************************************************/
|
******************************************************************************/
|
||||||
package controller;
|
package controller;
|
||||||
|
|
||||||
import java.awt.Color;
|
|
||||||
import java.awt.Component;
|
|
||||||
import java.awt.Dimension;
|
|
||||||
|
|
||||||
import javax.swing.JPanel;
|
|
||||||
import javax.swing.JScrollPane;
|
|
||||||
import javax.swing.JTable;
|
|
||||||
import javax.swing.event.ChangeEvent;
|
|
||||||
import javax.swing.event.ChangeListener;
|
|
||||||
|
|
||||||
import audio.broadcast.BroadcastModel;
|
|
||||||
import audio.broadcast.BroadcastPanel;
|
|
||||||
import icon.IconManager;
|
|
||||||
import map.MapPanel;
|
|
||||||
import map.MapService;
|
|
||||||
import module.decode.event.CallEventPanel;
|
|
||||||
import module.decode.event.MessageActivityPanel;
|
|
||||||
import module.decode.state.ChannelList;
|
|
||||||
import net.miginfocom.swing.MigLayout;
|
|
||||||
import settings.SettingsManager;
|
|
||||||
import source.SourceManager;
|
|
||||||
import source.tuner.TunerModel;
|
|
||||||
import source.tuner.TunerViewPanel;
|
|
||||||
import spectrum.ChannelSpectrumPanel;
|
|
||||||
import alias.AliasController;
|
import alias.AliasController;
|
||||||
import alias.AliasModel;
|
import alias.AliasModel;
|
||||||
import audio.AudioManager;
|
import audio.AudioManager;
|
||||||
import audio.AudioPanel;
|
import audio.AudioPanel;
|
||||||
|
import audio.broadcast.BroadcastModel;
|
||||||
import com.jidesoft.swing.JideSplitPane;
|
import audio.broadcast.BroadcastPanel;
|
||||||
|
import audio.broadcast.BroadcastStatusPanel;
|
||||||
|
import channel.metadata.ChannelMetadataViewer;
|
||||||
import com.jidesoft.swing.JideTabbedPane;
|
import com.jidesoft.swing.JideTabbedPane;
|
||||||
|
|
||||||
import controller.channel.ChannelController;
|
import controller.channel.ChannelController;
|
||||||
import controller.channel.ChannelModel;
|
import controller.channel.ChannelModel;
|
||||||
import controller.channel.ChannelProcessingManager;
|
import controller.channel.ChannelProcessingManager;
|
||||||
import controller.channel.map.ChannelMapModel;
|
import controller.channel.map.ChannelMapModel;
|
||||||
|
import icon.IconManager;
|
||||||
|
import map.MapPanel;
|
||||||
|
import map.MapService;
|
||||||
|
import net.miginfocom.swing.MigLayout;
|
||||||
|
import properties.SystemProperties;
|
||||||
|
import settings.SettingsManager;
|
||||||
|
import source.SourceManager;
|
||||||
|
import source.tuner.TunerModel;
|
||||||
|
import source.tuner.TunerViewPanel;
|
||||||
|
|
||||||
|
import javax.swing.*;
|
||||||
|
import java.awt.*;
|
||||||
|
|
||||||
public class ControllerPanel extends JPanel
|
public class ControllerPanel extends JPanel
|
||||||
{
|
{
|
||||||
@@ -61,14 +51,12 @@ public class ControllerPanel extends JPanel
|
|||||||
private AliasController mAliasController;
|
private AliasController mAliasController;
|
||||||
private AudioPanel mAudioPanel;
|
private AudioPanel mAudioPanel;
|
||||||
private BroadcastPanel mBroadcastPanel;
|
private BroadcastPanel mBroadcastPanel;
|
||||||
private CallEventPanel mCallEventPanel;
|
|
||||||
private ChannelController mChannelController;
|
private ChannelController mChannelController;
|
||||||
private ChannelList mChannelStateList;
|
private ChannelMetadataViewer mChannelMetadataViewer;
|
||||||
private ChannelModel mChannelModel;
|
private ChannelModel mChannelModel;
|
||||||
private ChannelSpectrumPanel mChannelSpectrumPanel;
|
|
||||||
private MapPanel mMapPanel;
|
private MapPanel mMapPanel;
|
||||||
private MessageActivityPanel mMessageActivityPanel;
|
|
||||||
private TunerViewPanel mTunerManagerPanel;
|
private TunerViewPanel mTunerManagerPanel;
|
||||||
|
private BroadcastModel mBroadcastModel;
|
||||||
|
|
||||||
private JideTabbedPane mTabbedPane;
|
private JideTabbedPane mTabbedPane;
|
||||||
protected JTable mChannelActivityTable = new JTable();
|
protected JTable mChannelActivityTable = new JTable();
|
||||||
@@ -85,28 +73,21 @@ public class ControllerPanel extends JPanel
|
|||||||
SourceManager sourceManager,
|
SourceManager sourceManager,
|
||||||
TunerModel tunerModel)
|
TunerModel tunerModel)
|
||||||
{
|
{
|
||||||
|
mBroadcastModel = broadcastModel;
|
||||||
mChannelModel = channelModel;
|
mChannelModel = channelModel;
|
||||||
|
|
||||||
mAudioPanel = new AudioPanel(iconManager, settingsManager, sourceManager, audioManager);
|
mAudioPanel = new AudioPanel(iconManager, settingsManager, sourceManager, audioManager);
|
||||||
|
|
||||||
mMapPanel = new MapPanel(mapService, iconManager, settingsManager);
|
mChannelMetadataViewer = new ChannelMetadataViewer(channelProcessingManager, iconManager, settingsManager);
|
||||||
|
|
||||||
mMessageActivityPanel = new MessageActivityPanel(channelProcessingManager);
|
mMapPanel = new MapPanel(mapService, iconManager, settingsManager);
|
||||||
|
|
||||||
mBroadcastPanel = new BroadcastPanel(broadcastModel, aliasModel, iconManager);
|
mBroadcastPanel = new BroadcastPanel(broadcastModel, aliasModel, iconManager);
|
||||||
|
|
||||||
mCallEventPanel = new CallEventPanel(iconManager, channelProcessingManager);
|
mChannelController = new ChannelController(channelModel, channelMapModel, sourceManager, aliasModel);
|
||||||
|
|
||||||
mChannelSpectrumPanel = new ChannelSpectrumPanel(settingsManager,
|
|
||||||
channelProcessingManager);
|
|
||||||
|
|
||||||
mChannelStateList = new ChannelList(channelModel, channelProcessingManager, iconManager,
|
|
||||||
settingsManager, mAudioPanel);
|
|
||||||
|
|
||||||
mChannelController = new ChannelController(channelModel, channelMapModel,
|
|
||||||
sourceManager, aliasModel);
|
|
||||||
|
|
||||||
mAliasController = new AliasController(aliasModel, broadcastModel, iconManager);
|
mAliasController = new AliasController(aliasModel, broadcastModel, iconManager);
|
||||||
|
|
||||||
mTunerManagerPanel = new TunerViewPanel(tunerModel);
|
mTunerManagerPanel = new TunerViewPanel(tunerModel);
|
||||||
|
|
||||||
init();
|
init();
|
||||||
@@ -114,66 +95,24 @@ public class ControllerPanel extends JPanel
|
|||||||
|
|
||||||
private void init()
|
private void init()
|
||||||
{
|
{
|
||||||
setLayout(new MigLayout("insets 0 0 0 0 ",
|
setLayout(new MigLayout("insets 0 0 0 0 ", "[grow,fill]", "[]0[grow,fill]0[]"));
|
||||||
"[grow,fill]",
|
|
||||||
"[grow,fill]"));
|
add(mAudioPanel, "wrap");
|
||||||
|
|
||||||
//Tabbed View - configuration, calls, messages, map
|
//Tabbed View - configuration, calls, messages, map
|
||||||
mTabbedPane = new JideTabbedPane();
|
mTabbedPane = new JideTabbedPane();
|
||||||
mTabbedPane.setFont(this.getFont());
|
mTabbedPane.setFont(this.getFont());
|
||||||
mTabbedPane.setForeground(Color.BLACK);
|
mTabbedPane.setForeground(Color.BLACK);
|
||||||
mTabbedPane.addTab("Tuners", mTunerManagerPanel);
|
mTabbedPane.addTab("Now Playing", mChannelMetadataViewer);
|
||||||
mTabbedPane.addTab("Channels", mChannelController);
|
|
||||||
mTabbedPane.addTab("Aliases", mAliasController);
|
mTabbedPane.addTab("Aliases", mAliasController);
|
||||||
mTabbedPane.addTab("Channel Spectrum", mChannelSpectrumPanel);
|
mTabbedPane.addTab("Channels", mChannelController);
|
||||||
mTabbedPane.addTab("Events", mCallEventPanel);
|
|
||||||
mTabbedPane.addTab("Map", mMapPanel);
|
mTabbedPane.addTab("Map", mMapPanel);
|
||||||
mTabbedPane.addTab("Messages", mMessageActivityPanel);
|
|
||||||
mTabbedPane.addTab("Streaming", mBroadcastPanel);
|
mTabbedPane.addTab("Streaming", mBroadcastPanel);
|
||||||
|
mTabbedPane.addTab("Tuners", mTunerManagerPanel);
|
||||||
/**
|
|
||||||
* Change listener to enable/disable the channel spectrum display
|
|
||||||
* only when the tab is visible, and a channel has been selected
|
|
||||||
*/
|
|
||||||
mTabbedPane.addChangeListener(new ChangeListener()
|
|
||||||
{
|
|
||||||
@Override
|
|
||||||
public void stateChanged(ChangeEvent event)
|
|
||||||
{
|
|
||||||
int index = mTabbedPane.getSelectedIndex();
|
|
||||||
|
|
||||||
Component component = mTabbedPane.getComponentAt(index);
|
|
||||||
|
|
||||||
if (component instanceof ChannelSpectrumPanel)
|
|
||||||
{
|
|
||||||
mChannelSpectrumPanel.setEnabled(true);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
mChannelSpectrumPanel.setEnabled(false);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
/* Register each of the components to receive channel events when the
|
|
||||||
* channels are selected or change */
|
|
||||||
mChannelModel.addListener(mCallEventPanel);
|
|
||||||
mChannelModel.addListener(mChannelStateList);
|
|
||||||
mChannelModel.addListener(mChannelSpectrumPanel);
|
|
||||||
mChannelModel.addListener(mMessageActivityPanel);
|
|
||||||
|
|
||||||
JScrollPane channelStateListScroll = new JScrollPane();
|
|
||||||
channelStateListScroll.getViewport().setView(mChannelStateList);
|
|
||||||
channelStateListScroll.setPreferredSize(new Dimension(400, 500));
|
|
||||||
|
|
||||||
//Set preferred size to influence the split between these panels
|
//Set preferred size to influence the split between these panels
|
||||||
mTabbedPane.setPreferredSize(new Dimension(880, 500));
|
mTabbedPane.setPreferredSize(new Dimension(880, 500));
|
||||||
|
|
||||||
JideSplitPane channelSplit = new JideSplitPane(JideSplitPane.HORIZONTAL_SPLIT);
|
add(mTabbedPane,"wrap");
|
||||||
channelSplit.setDividerSize(5);
|
|
||||||
channelSplit.add(channelStateListScroll);
|
|
||||||
channelSplit.add(mTabbedPane);
|
|
||||||
|
|
||||||
add(channelSplit);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
/*******************************************************************************
|
/*******************************************************************************
|
||||||
* SDR Trunk
|
* sdrtrunk
|
||||||
* Copyright (C) 2014-2016 Dennis Sheirer
|
* Copyright (C) 2014-2017 Dennis Sheirer
|
||||||
*
|
*
|
||||||
* This program is free software: you can redistribute it and/or modify
|
* 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
|
* it under the terms of the GNU General Public License as published by
|
||||||
@@ -14,20 +14,20 @@
|
|||||||
*
|
*
|
||||||
* You should have received a copy of the GNU General Public License
|
* You should have received a copy of the GNU General Public License
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>
|
* along with this program. If not, see <http://www.gnu.org/licenses/>
|
||||||
|
*
|
||||||
******************************************************************************/
|
******************************************************************************/
|
||||||
package controller.channel;
|
package controller.channel;
|
||||||
|
|
||||||
|
import controller.channel.Channel.ChannelType;
|
||||||
|
import controller.channel.ChannelEvent.Event;
|
||||||
|
import module.decode.DecoderType;
|
||||||
|
|
||||||
|
import javax.swing.table.AbstractTableModel;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.concurrent.CopyOnWriteArrayList;
|
import java.util.concurrent.CopyOnWriteArrayList;
|
||||||
|
|
||||||
import javax.swing.table.AbstractTableModel;
|
|
||||||
|
|
||||||
import module.decode.DecoderType;
|
|
||||||
import controller.channel.Channel.ChannelType;
|
|
||||||
import controller.channel.ChannelEvent.Event;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Channel Model
|
* Channel Model
|
||||||
*/
|
*/
|
||||||
@@ -35,6 +35,17 @@ public class ChannelModel extends AbstractTableModel implements IChannelEventBro
|
|||||||
{
|
{
|
||||||
private static final long serialVersionUID = 1L;
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
|
public static final int COLUMN_ENABLED = 0;
|
||||||
|
public static final int COLUMN_SYSTEM = 1;
|
||||||
|
public static final int COLUMN_SITE = 2;
|
||||||
|
public static final int COLUMN_NAME = 3;
|
||||||
|
public static final int COLUMN_ALIAS_LIST = 4;
|
||||||
|
public static final int COLUMN_SOURCE = 5;
|
||||||
|
public static final int COLUMN_DECODER = 6;
|
||||||
|
|
||||||
|
private static final String[] COLUMN_NAMES = new String[] {"Enabled", "System", "Site", "Name", "Alias List",
|
||||||
|
"Source", "Decoder"};
|
||||||
|
|
||||||
private List<Channel> mChannels = new CopyOnWriteArrayList<>();
|
private List<Channel> mChannels = new CopyOnWriteArrayList<>();
|
||||||
private List<Channel> mTrafficChannels = new CopyOnWriteArrayList<>();
|
private List<Channel> mTrafficChannels = new CopyOnWriteArrayList<>();
|
||||||
private List<ChannelEventListener> mListeners = new CopyOnWriteArrayList<>();
|
private List<ChannelEventListener> mListeners = new CopyOnWriteArrayList<>();
|
||||||
@@ -53,7 +64,7 @@ public class ChannelModel extends AbstractTableModel implements IChannelEventBro
|
|||||||
|
|
||||||
public Channel getChannelAtIndex(int row)
|
public Channel getChannelAtIndex(int row)
|
||||||
{
|
{
|
||||||
if( mChannels.size() >= row )
|
if(row < mChannels.size())
|
||||||
{
|
{
|
||||||
return mChannels.get(row);
|
return mChannels.get(row);
|
||||||
}
|
}
|
||||||
@@ -222,7 +233,6 @@ public class ChannelModel extends AbstractTableModel implements IChannelEventBro
|
|||||||
*
|
*
|
||||||
* @param start frequency of the range
|
* @param start frequency of the range
|
||||||
* @param stop frequency of the range
|
* @param stop frequency of the range
|
||||||
*
|
|
||||||
* @return list of channels or an empty list if none fall within the range
|
* @return list of channels or an empty list if none fall within the range
|
||||||
*/
|
*/
|
||||||
public List<Channel> getChannelsInFrequencyRange(long start, long stop)
|
public List<Channel> getChannelsInFrequencyRange(long start, long stop)
|
||||||
@@ -268,26 +278,15 @@ public class ChannelModel extends AbstractTableModel implements IChannelEventBro
|
|||||||
@Override
|
@Override
|
||||||
public int getColumnCount()
|
public int getColumnCount()
|
||||||
{
|
{
|
||||||
return 6;
|
return COLUMN_NAMES.length;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getColumnName(int columnIndex)
|
public String getColumnName(int columnIndex)
|
||||||
{
|
{
|
||||||
switch( columnIndex )
|
if(columnIndex < COLUMN_NAMES.length)
|
||||||
{
|
{
|
||||||
case 0:
|
return COLUMN_NAMES[columnIndex];
|
||||||
return "System";
|
|
||||||
case 1:
|
|
||||||
return "Site";
|
|
||||||
case 2:
|
|
||||||
return "Name";
|
|
||||||
case 3:
|
|
||||||
return "Alias List";
|
|
||||||
case 4:
|
|
||||||
return "Source";
|
|
||||||
case 5:
|
|
||||||
return "Decoder";
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
@@ -312,19 +311,20 @@ public class ChannelModel extends AbstractTableModel implements IChannelEventBro
|
|||||||
|
|
||||||
switch(columnIndex)
|
switch(columnIndex)
|
||||||
{
|
{
|
||||||
case 0:
|
case COLUMN_ENABLED:
|
||||||
|
return channel.getEnabled() ? "Enabled" : null;
|
||||||
|
case COLUMN_SYSTEM:
|
||||||
return channel.getSystem();
|
return channel.getSystem();
|
||||||
case 1:
|
case COLUMN_SITE:
|
||||||
return channel.getSite();
|
return channel.getSite();
|
||||||
case 2:
|
case COLUMN_NAME:
|
||||||
return channel.getName();
|
return channel.getName();
|
||||||
case 3:
|
case COLUMN_ALIAS_LIST:
|
||||||
return channel.getAliasListName();
|
return channel.getAliasListName();
|
||||||
case 4:
|
case COLUMN_SOURCE:
|
||||||
return channel.getSourceConfiguration().getDescription();
|
return channel.getSourceConfiguration().getDescription();
|
||||||
case 5:
|
case COLUMN_DECODER:
|
||||||
return channel.getDecodeConfiguration()
|
return channel.getDecodeConfiguration().getDecoderType().getShortDisplayString();
|
||||||
.getDecoderType().getShortDisplayString();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
/*******************************************************************************
|
/*******************************************************************************
|
||||||
* SDR Trunk
|
* sdrtrunk
|
||||||
* Copyright (C) 2014-2016 Dennis Sheirer
|
* Copyright (C) 2014-2017 Dennis Sheirer
|
||||||
*
|
*
|
||||||
* This program is free software: you can redistribute it and/or modify
|
* 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
|
* it under the terms of the GNU General Public License as published by
|
||||||
@@ -14,38 +14,41 @@
|
|||||||
*
|
*
|
||||||
* You should have received a copy of the GNU General Public License
|
* You should have received a copy of the GNU General Public License
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>
|
* along with this program. If not, see <http://www.gnu.org/licenses/>
|
||||||
|
*
|
||||||
******************************************************************************/
|
******************************************************************************/
|
||||||
package controller.channel;
|
package controller.channel;
|
||||||
|
|
||||||
import java.util.HashMap;
|
import alias.AliasModel;
|
||||||
import java.util.List;
|
import audio.AudioPacket;
|
||||||
import java.util.Map;
|
import channel.metadata.Attribute;
|
||||||
import java.util.concurrent.CopyOnWriteArrayList;
|
import channel.metadata.AttributeChangeRequest;
|
||||||
|
import channel.metadata.ChannelMetadataModel;
|
||||||
|
import controller.channel.Channel.ChannelType;
|
||||||
|
import controller.channel.ChannelEvent.Event;
|
||||||
|
import controller.channel.map.ChannelMapModel;
|
||||||
|
import filter.FilterSet;
|
||||||
import message.Message;
|
import message.Message;
|
||||||
import module.Module;
|
import module.Module;
|
||||||
import module.ProcessingChain;
|
import module.ProcessingChain;
|
||||||
import module.decode.DecoderFactory;
|
import module.decode.DecoderFactory;
|
||||||
|
import module.decode.DecoderType;
|
||||||
import module.decode.event.MessageActivityModel;
|
import module.decode.event.MessageActivityModel;
|
||||||
import module.log.EventLogManager;
|
import module.log.EventLogManager;
|
||||||
|
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
import record.RecorderManager;
|
import record.RecorderManager;
|
||||||
import record.RecorderType;
|
import record.RecorderType;
|
||||||
import sample.Listener;
|
import sample.Listener;
|
||||||
import source.Source;
|
import source.Source;
|
||||||
import source.SourceException;
|
import source.SourceException;
|
||||||
import source.SourceManager;
|
import source.SourceManager;
|
||||||
import alias.AliasModel;
|
import source.SourceType;
|
||||||
import audio.AudioPacket;
|
import source.config.SourceConfigTuner;
|
||||||
import audio.metadata.Metadata;
|
|
||||||
import audio.metadata.MetadataType;
|
import java.util.HashMap;
|
||||||
import controller.channel.Channel.ChannelType;
|
import java.util.List;
|
||||||
import controller.channel.ChannelEvent.Event;
|
import java.util.Map;
|
||||||
import controller.channel.map.ChannelMapModel;
|
import java.util.concurrent.CopyOnWriteArrayList;
|
||||||
import filter.FilterSet;
|
|
||||||
|
|
||||||
public class ChannelProcessingManager implements ChannelEventListener
|
public class ChannelProcessingManager implements ChannelEventListener
|
||||||
{
|
{
|
||||||
@@ -58,6 +61,7 @@ public class ChannelProcessingManager implements ChannelEventListener
|
|||||||
|
|
||||||
private ChannelModel mChannelModel;
|
private ChannelModel mChannelModel;
|
||||||
private ChannelMapModel mChannelMapModel;
|
private ChannelMapModel mChannelMapModel;
|
||||||
|
private ChannelMetadataModel mChannelMetadataModel = new ChannelMetadataModel();
|
||||||
private AliasModel mAliasModel;
|
private AliasModel mAliasModel;
|
||||||
private EventLogManager mEventLogManager;
|
private EventLogManager mEventLogManager;
|
||||||
private RecorderManager mRecorderManager;
|
private RecorderManager mRecorderManager;
|
||||||
@@ -78,6 +82,14 @@ public class ChannelProcessingManager implements ChannelEventListener
|
|||||||
mSourceManager = sourceManager;
|
mSourceManager = sourceManager;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Channel metadata model containing metadata for each channel or channel time-slice that is currently processing.
|
||||||
|
*/
|
||||||
|
public ChannelMetadataModel getChannelMetadataModel()
|
||||||
|
{
|
||||||
|
return mChannelMetadataModel;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Indicates if a processing chain is constructed for the channel and that
|
* Indicates if a processing chain is constructed for the channel and that
|
||||||
* the processing chain is currently processing.
|
* the processing chain is currently processing.
|
||||||
@@ -175,16 +187,14 @@ public class ChannelProcessingManager implements ChannelEventListener
|
|||||||
{
|
{
|
||||||
channel.setEnabled(false);
|
channel.setEnabled(false);
|
||||||
|
|
||||||
mChannelModel.broadcast(
|
mChannelModel.broadcast(new ChannelEvent(channel, Event.NOTIFICATION_ENABLE_REJECTED));
|
||||||
new ChannelEvent(channel, Event.NOTIFICATION_ENABLE_REJECTED));
|
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(processingChain == null)
|
if(processingChain == null)
|
||||||
{
|
{
|
||||||
processingChain = new ProcessingChain(channel.getName(),
|
processingChain = new ProcessingChain(channel.getName(), channel.getChannelType());
|
||||||
channel.getChannelType());
|
|
||||||
|
|
||||||
/* Register global listeners */
|
/* Register global listeners */
|
||||||
for(Listener<AudioPacket> listener : mAudioPacketListeners)
|
for(Listener<AudioPacket> listener : mAudioPacketListeners)
|
||||||
@@ -198,8 +208,8 @@ public class ChannelProcessingManager implements ChannelEventListener
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Processing Modules */
|
/* Processing Modules */
|
||||||
List<Module> modules = DecoderFactory.getModules(mChannelModel,
|
List<Module> modules = DecoderFactory.getModules(mChannelModel, mChannelMapModel, this,
|
||||||
mChannelMapModel, this, mAliasModel, channel);
|
mAliasModel, channel, processingChain.getChannelState().getMutableMetadata());
|
||||||
processingChain.addModules(modules);
|
processingChain.addModules(modules);
|
||||||
|
|
||||||
/* Setup message activity model with filtering */
|
/* Setup message activity model with filtering */
|
||||||
@@ -207,14 +217,32 @@ public class ChannelProcessingManager implements ChannelEventListener
|
|||||||
MessageActivityModel messageModel = new MessageActivityModel(messageFilter);
|
MessageActivityModel messageModel = new MessageActivityModel(messageFilter);
|
||||||
processingChain.setMessageActivityModel(messageModel);
|
processingChain.setMessageActivityModel(messageModel);
|
||||||
|
|
||||||
/* Inject channel metadata that will be inserted into audio packets
|
//Override recordable flag in metadata if user has specified audio recording
|
||||||
* for the recorder manager and streaming */
|
if(channel.getRecordConfiguration() != null &&
|
||||||
processingChain.broadcast(
|
channel.getRecordConfiguration().getRecorders().contains(RecorderType.AUDIO))
|
||||||
new Metadata(MetadataType.SYSTEM, channel.getSystem()));
|
{
|
||||||
processingChain.broadcast(
|
processingChain.getChannelState().getMutableMetadata().setRecordable(true);
|
||||||
new Metadata(MetadataType.SITE_ID, channel.getSite()));
|
}
|
||||||
processingChain.broadcast(
|
|
||||||
new Metadata(MetadataType.CHANNEL_NAME, channel.getName()));
|
//Inject channel metadata that will be inserted into audio packets for recorder manager and streaming
|
||||||
|
processingChain.getChannelState().getMutableMetadata().receive(
|
||||||
|
new AttributeChangeRequest<String>(Attribute.CHANNEL_CONFIGURATION_SYSTEM, channel.getSystem()));
|
||||||
|
processingChain.getChannelState().getMutableMetadata().receive(
|
||||||
|
new AttributeChangeRequest<String>(Attribute.CHANNEL_CONFIGURATION_SITE, channel.getSite()));
|
||||||
|
processingChain.getChannelState().getMutableMetadata().receive(
|
||||||
|
new AttributeChangeRequest<String>(Attribute.CHANNEL_CONFIGURATION_NAME, channel.getName()));
|
||||||
|
|
||||||
|
if(channel.getSourceConfiguration().getSourceType() == SourceType.TUNER)
|
||||||
|
{
|
||||||
|
long frequency = ((SourceConfigTuner)channel.getSourceConfiguration()).getFrequency();
|
||||||
|
|
||||||
|
processingChain.getChannelState().getMutableMetadata().receive(
|
||||||
|
new AttributeChangeRequest<Long>(Attribute.CHANNEL_FREQUENCY, frequency));
|
||||||
|
}
|
||||||
|
|
||||||
|
processingChain.getChannelState().getMutableMetadata().receive(
|
||||||
|
new AttributeChangeRequest<DecoderType>(Attribute.PRIMARY_DECODER_TYPE,
|
||||||
|
channel.getDecodeConfiguration().getDecoderType()));
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Setup event logging */
|
/* Setup event logging */
|
||||||
@@ -256,12 +284,13 @@ public class ChannelProcessingManager implements ChannelEventListener
|
|||||||
|
|
||||||
processingChain.start();
|
processingChain.start();
|
||||||
|
|
||||||
|
getChannelMetadataModel().add(processingChain.getChannelState().getMutableMetadata(), channel);
|
||||||
|
|
||||||
channel.setEnabled(true);
|
channel.setEnabled(true);
|
||||||
|
|
||||||
mProcessingChains.put(channel.getChannelID(), processingChain);
|
mProcessingChains.put(channel.getChannelID(), processingChain);
|
||||||
|
|
||||||
mChannelModel.broadcast(
|
mChannelModel.broadcast(new ChannelEvent(channel, Event.NOTIFICATION_PROCESSING_START));
|
||||||
new ChannelEvent(channel, Event.NOTIFICATION_PROCESSING_START));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void stopProcessing(Channel channel, boolean remove)
|
private void stopProcessing(Channel channel, boolean remove)
|
||||||
@@ -272,6 +301,8 @@ public class ChannelProcessingManager implements ChannelEventListener
|
|||||||
{
|
{
|
||||||
ProcessingChain processingChain = mProcessingChains.get(channel.getChannelID());
|
ProcessingChain processingChain = mProcessingChains.get(channel.getChannelID());
|
||||||
|
|
||||||
|
getChannelMetadataModel().remove(processingChain.getChannelState().getMutableMetadata());
|
||||||
|
|
||||||
processingChain.stop();
|
processingChain.stop();
|
||||||
|
|
||||||
processingChain.removeEventLoggingModules();
|
processingChain.removeEventLoggingModules();
|
||||||
|
|||||||
@@ -11,7 +11,7 @@ import javax.swing.JSeparator;
|
|||||||
|
|
||||||
import module.ProcessingChain;
|
import module.ProcessingChain;
|
||||||
import module.decode.event.ActivitySummaryFrame;
|
import module.decode.event.ActivitySummaryFrame;
|
||||||
import module.decode.state.DecoderState;
|
import channel.state.DecoderState;
|
||||||
import controller.channel.ChannelEvent.Event;
|
import controller.channel.ChannelEvent.Event;
|
||||||
|
|
||||||
public class ChannelUtils
|
public class ChannelUtils
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
package controller.channel;
|
package controller.channel;
|
||||||
|
|
||||||
import module.decode.event.CallEvent;
|
import module.decode.event.CallEvent;
|
||||||
import module.decode.state.TrafficChannelManager;
|
import channel.traffic.TrafficChannelManager;
|
||||||
|
|
||||||
public class TrafficChannelEvent extends ChannelEvent
|
public class TrafficChannelEvent extends ChannelEvent
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -1,18 +1,20 @@
|
|||||||
package controller.channel.map;
|
package controller.channel.map;
|
||||||
|
|
||||||
|
import controller.channel.map.ChannelMapEvent.Event;
|
||||||
|
import org.slf4j.Logger;
|
||||||
|
import org.slf4j.LoggerFactory;
|
||||||
|
import sample.Broadcaster;
|
||||||
|
import sample.Listener;
|
||||||
|
|
||||||
|
import javax.swing.*;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import javax.swing.AbstractListModel;
|
|
||||||
|
|
||||||
import controller.channel.map.ChannelMapEvent.Event;
|
|
||||||
import sample.Broadcaster;
|
|
||||||
import sample.Listener;
|
|
||||||
|
|
||||||
public class ChannelMapModel extends AbstractListModel<ChannelMap>
|
public class ChannelMapModel extends AbstractListModel<ChannelMap>
|
||||||
{
|
{
|
||||||
private static final long serialVersionUID = 1L;
|
private static final long serialVersionUID = 1L;
|
||||||
|
private final static Logger mLog = LoggerFactory.getLogger(ChannelMapModel.class);
|
||||||
|
|
||||||
private List<ChannelMap> mChannelMaps = new ArrayList<>();
|
private List<ChannelMap> mChannelMaps = new ArrayList<>();
|
||||||
private Broadcaster<ChannelMapEvent> mEventBroadcaster = new Broadcaster<>();
|
private Broadcaster<ChannelMapEvent> mEventBroadcaster = new Broadcaster<>();
|
||||||
|
|||||||
@@ -22,16 +22,18 @@
|
|||||||
******************************************************************************/
|
******************************************************************************/
|
||||||
package dsp.filter;
|
package dsp.filter;
|
||||||
|
|
||||||
import java.util.Arrays;
|
import dsp.filter.Window.WindowType;
|
||||||
import java.util.Set;
|
import dsp.filter.cic.ComplexPrimeCICDecimate;
|
||||||
import java.util.TreeSet;
|
import dsp.filter.design.FilterDesignException;
|
||||||
|
import dsp.filter.fir.FIRFilterSpecification;
|
||||||
|
import dsp.filter.fir.remez.RemezFIRFilterDesigner;
|
||||||
import org.jtransforms.fft.FloatFFT_1D;
|
import org.jtransforms.fft.FloatFFT_1D;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
import dsp.filter.Window.WindowType;
|
import java.util.Arrays;
|
||||||
import dsp.filter.cic.ComplexPrimeCICDecimate;
|
import java.util.Set;
|
||||||
|
import java.util.TreeSet;
|
||||||
|
|
||||||
public class FilterFactory
|
public class FilterFactory
|
||||||
{
|
{
|
||||||
@@ -40,6 +42,7 @@ public class FilterFactory
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Generates coefficients for a unity-gain, windowed low-pass filter
|
* Generates coefficients for a unity-gain, windowed low-pass filter
|
||||||
|
*
|
||||||
* @param sampleRate - hertz
|
* @param sampleRate - hertz
|
||||||
* @param frequency - cutoff in hertz
|
* @param frequency - cutoff in hertz
|
||||||
* @param length - filter length
|
* @param length - filter length
|
||||||
@@ -89,6 +92,7 @@ public class FilterFactory
|
|||||||
/**
|
/**
|
||||||
* Normalizes all filter coefficients to achieve unity (1) gain, by ensuring
|
* Normalizes all filter coefficients to achieve unity (1) gain, by ensuring
|
||||||
* that the sum of the absolute value of all coefficients adds up to 1.
|
* that the sum of the absolute value of all coefficients adds up to 1.
|
||||||
|
*
|
||||||
* @param coefficients
|
* @param coefficients
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
@@ -568,8 +572,8 @@ public class FilterFactory
|
|||||||
* Assumes that the pass band is 1/4 of the output sample rate.
|
* Assumes that the pass band is 1/4 of the output sample rate.
|
||||||
*
|
*
|
||||||
* Assumes the stop band is: pass + (pass * .25).
|
* Assumes the stop band is: pass + (pass * .25).
|
||||||
|
*
|
||||||
* @param outputSampleRate
|
* @param outputSampleRate
|
||||||
* @param stageCount
|
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
public static float[] getCICCleanupFilter(int outputSampleRate,
|
public static float[] getCICCleanupFilter(int outputSampleRate,
|
||||||
@@ -661,7 +665,6 @@ public class FilterFactory
|
|||||||
* @param samplesPerSymbol - number of samples per symbol
|
* @param samplesPerSymbol - number of samples per symbol
|
||||||
* @param symbols - number of symbols - must be even
|
* @param symbols - number of symbols - must be even
|
||||||
* @param alpha - roll-off factor
|
* @param alpha - roll-off factor
|
||||||
*
|
|
||||||
* @return - filter coefficients
|
* @return - filter coefficients
|
||||||
*/
|
*/
|
||||||
public static float[] getRootRaisedCosine(int samplesPerSymbol,
|
public static float[] getRootRaisedCosine(int samplesPerSymbol,
|
||||||
@@ -736,4 +739,23 @@ public class FilterFactory
|
|||||||
|
|
||||||
return coefficients;
|
return coefficients;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates a filter from the filter specification
|
||||||
|
*
|
||||||
|
* @param specification
|
||||||
|
* @return
|
||||||
|
* @throws FilterDesignException if the filter cannot be designed
|
||||||
|
*/
|
||||||
|
public static float[] getTaps(FIRFilterSpecification specification) throws FilterDesignException
|
||||||
|
{
|
||||||
|
RemezFIRFilterDesigner designer = new RemezFIRFilterDesigner(specification);
|
||||||
|
|
||||||
|
if(designer.isValid())
|
||||||
|
{
|
||||||
|
return designer.getImpulseResponse();
|
||||||
|
}
|
||||||
|
|
||||||
|
return null;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -51,26 +51,26 @@ public class FilterViewer extends Application
|
|||||||
// .stopBandRipple( 0.027 )
|
// .stopBandRipple( 0.027 )
|
||||||
// .build();
|
// .build();
|
||||||
|
|
||||||
FIRFilterSpecification specification = FIRFilterSpecification.highPassBuilder()
|
// FIRFilterSpecification specification = FIRFilterSpecification.highPassBuilder()
|
||||||
.sampleRate( 8000 )
|
// .sampleRate( 8000 )
|
||||||
.stopBandCutoff( 250 )
|
// .stopBandCutoff( 250 )
|
||||||
.stopBandAmplitude( 0.0 )
|
// .stopBandAmplitude( 0.0 )
|
||||||
.stopBandRipple( 0.01 )
|
// .stopBandRipple( 0.01 )
|
||||||
.passBandStart( 300 )
|
// .passBandStart( 300 )
|
||||||
.passBandAmplitude( 1.0 )
|
// .passBandAmplitude( 1.0 )
|
||||||
.passBandRipple( 0.01 )
|
// .passBandRipple( 0.01 )
|
||||||
.build();
|
|
||||||
|
|
||||||
// FIRFilterSpecification specification = FIRFilterSpecification.bandPassBuilder()
|
|
||||||
// .sampleRate( 48000 )
|
|
||||||
// .stopFrequency1( 150 )
|
|
||||||
// .passFrequencyBegin( 200 )
|
|
||||||
// .passFrequencyEnd( 3950 )
|
|
||||||
// .stopFrequency2( 4000 )
|
|
||||||
// .stopRipple( 0.0005 )
|
|
||||||
// .passRipple( 0.003)
|
|
||||||
// .build();
|
// .build();
|
||||||
|
|
||||||
|
FIRFilterSpecification specification = FIRFilterSpecification.bandPassBuilder()
|
||||||
|
.sampleRate( 48000 )
|
||||||
|
.stopFrequency1( 200 )
|
||||||
|
.passFrequencyBegin( 400 )
|
||||||
|
.passFrequencyEnd( 3200 )
|
||||||
|
.stopFrequency2( 3400 )
|
||||||
|
.stopRipple( 0.0003 )
|
||||||
|
.passRipple( 0.008)
|
||||||
|
.build();
|
||||||
|
|
||||||
float[] taps = null;
|
float[] taps = null;
|
||||||
|
|
||||||
// taps = FilterFactory.getLowPass( 16000, 2400, 73, WindowType.HANNING );
|
// taps = FilterFactory.getLowPass( 16000, 2400, 73, WindowType.HANNING );
|
||||||
|
|||||||
@@ -17,21 +17,22 @@
|
|||||||
******************************************************************************/
|
******************************************************************************/
|
||||||
package dsp.fsk;
|
package dsp.fsk;
|
||||||
|
|
||||||
|
import buffer.BooleanAveragingBuffer;
|
||||||
|
import dsp.symbol.SymbolEvent;
|
||||||
|
import dsp.symbol.SymbolEvent.Shift;
|
||||||
import instrument.Instrumentable;
|
import instrument.Instrumentable;
|
||||||
import instrument.tap.Tap;
|
import instrument.tap.Tap;
|
||||||
import instrument.tap.TapGroup;
|
import instrument.tap.TapGroup;
|
||||||
import instrument.tap.stream.SymbolEventTap;
|
import instrument.tap.stream.SymbolEventTap;
|
||||||
|
import org.slf4j.Logger;
|
||||||
|
import org.slf4j.LoggerFactory;
|
||||||
|
import sample.Listener;
|
||||||
|
import sample.real.RealBuffer;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.BitSet;
|
import java.util.BitSet;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import sample.Listener;
|
|
||||||
import sample.real.RealBuffer;
|
|
||||||
import buffer.BooleanAveragingBuffer;
|
|
||||||
import dsp.symbol.SymbolEvent;
|
|
||||||
import dsp.symbol.SymbolEvent.Shift;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Binary Frequency Shift Keying (FSK) decoder. Implements a BFSK correlation
|
* Binary Frequency Shift Keying (FSK) decoder. Implements a BFSK correlation
|
||||||
* decoder. Provides normal or inverted decoded output. Requires the symbol
|
* decoder. Provides normal or inverted decoded output. Requires the symbol
|
||||||
@@ -54,7 +55,12 @@ import dsp.symbol.SymbolEvent.Shift;
|
|||||||
*/
|
*/
|
||||||
public class FSK2Decoder implements Instrumentable, Listener<RealBuffer>
|
public class FSK2Decoder implements Instrumentable, Listener<RealBuffer>
|
||||||
{
|
{
|
||||||
public enum Output{ NORMAL, INVERTED };
|
private final static Logger mLog = LoggerFactory.getLogger(FSK2Decoder.class);
|
||||||
|
|
||||||
|
public enum Output
|
||||||
|
{
|
||||||
|
NORMAL, INVERTED
|
||||||
|
}
|
||||||
|
|
||||||
/* Instrumentation taps */
|
/* Instrumentation taps */
|
||||||
private static final String INSTRUMENT_DECISION =
|
private static final String INSTRUMENT_DECISION =
|
||||||
|
|||||||
@@ -21,6 +21,7 @@ import alias.AliasModel;
|
|||||||
import alias.action.AliasActionManager;
|
import alias.action.AliasActionManager;
|
||||||
import audio.AudioManager;
|
import audio.AudioManager;
|
||||||
import audio.broadcast.BroadcastModel;
|
import audio.broadcast.BroadcastModel;
|
||||||
|
import audio.broadcast.BroadcastStatusPanel;
|
||||||
import com.jidesoft.swing.JideSplitPane;
|
import com.jidesoft.swing.JideSplitPane;
|
||||||
import controller.ControllerPanel;
|
import controller.ControllerPanel;
|
||||||
import controller.ThreadPoolManager;
|
import controller.ThreadPoolManager;
|
||||||
@@ -65,12 +66,17 @@ import java.util.concurrent.TimeUnit;
|
|||||||
public class SDRTrunk implements Listener<TunerEvent>
|
public class SDRTrunk implements Listener<TunerEvent>
|
||||||
{
|
{
|
||||||
private final static Logger mLog = LoggerFactory.getLogger(SDRTrunk.class);
|
private final static Logger mLog = LoggerFactory.getLogger(SDRTrunk.class);
|
||||||
|
private static final String PROPERTY_BROADCAST_STATUS_VISIBLE = "main.broadcast.status.visible";
|
||||||
|
private boolean mBroadcastStatusVisible;
|
||||||
|
|
||||||
private IconManager mIconManager;
|
private IconManager mIconManager;
|
||||||
|
private BroadcastStatusPanel mBroadcastStatusPanel;
|
||||||
|
private BroadcastModel mBroadcastModel;
|
||||||
private ControllerPanel mControllerPanel;
|
private ControllerPanel mControllerPanel;
|
||||||
private SettingsManager mSettingsManager;
|
private SettingsManager mSettingsManager;
|
||||||
private SpectralDisplayPanel mSpectralPanel;
|
private SpectralDisplayPanel mSpectralPanel;
|
||||||
private JFrame mMainGui = new JFrame();
|
private JFrame mMainGui = new JFrame();
|
||||||
|
private JideSplitPane mSplitPane;
|
||||||
|
|
||||||
private String mTitle;
|
private String mTitle;
|
||||||
|
|
||||||
@@ -139,14 +145,14 @@ public class SDRTrunk implements Listener<TunerEvent>
|
|||||||
AudioManager audioManager = new AudioManager(threadPoolManager, sourceManager.getMixerManager());
|
AudioManager audioManager = new AudioManager(threadPoolManager, sourceManager.getMixerManager());
|
||||||
channelProcessingManager.addAudioPacketListener(audioManager);
|
channelProcessingManager.addAudioPacketListener(audioManager);
|
||||||
|
|
||||||
BroadcastModel broadcastModel = new BroadcastModel(threadPoolManager, mIconManager);
|
mBroadcastModel = new BroadcastModel(threadPoolManager, mIconManager);
|
||||||
|
|
||||||
channelProcessingManager.addAudioPacketListener(broadcastModel);
|
channelProcessingManager.addAudioPacketListener(mBroadcastModel);
|
||||||
|
|
||||||
MapService mapService = new MapService(mIconManager);
|
MapService mapService = new MapService(mIconManager);
|
||||||
channelProcessingManager.addMessageListener(mapService);
|
channelProcessingManager.addMessageListener(mapService);
|
||||||
|
|
||||||
mControllerPanel = new ControllerPanel(audioManager, aliasModel, broadcastModel,
|
mControllerPanel = new ControllerPanel(audioManager, aliasModel, mBroadcastModel,
|
||||||
channelModel, channelMapModel, channelProcessingManager, mIconManager,
|
channelModel, channelMapModel, channelProcessingManager, mIconManager,
|
||||||
mapService, mSettingsManager, sourceManager, tunerModel);
|
mapService, mSettingsManager, sourceManager, tunerModel);
|
||||||
|
|
||||||
@@ -160,7 +166,7 @@ public class SDRTrunk implements Listener<TunerEvent>
|
|||||||
tunerModel.addListener(this);
|
tunerModel.addListener(this);
|
||||||
|
|
||||||
PlaylistManager playlistManager = new PlaylistManager(threadPoolManager,
|
PlaylistManager playlistManager = new PlaylistManager(threadPoolManager,
|
||||||
aliasModel, broadcastModel, channelModel, channelMapModel);
|
aliasModel, mBroadcastModel, channelModel, channelMapModel);
|
||||||
|
|
||||||
playlistManager.init();
|
playlistManager.init();
|
||||||
|
|
||||||
@@ -209,9 +215,7 @@ public class SDRTrunk implements Listener<TunerEvent>
|
|||||||
*/
|
*/
|
||||||
private void initGUI()
|
private void initGUI()
|
||||||
{
|
{
|
||||||
mMainGui.setLayout(new MigLayout("insets 0 0 0 0 ",
|
mMainGui.setLayout(new MigLayout("insets 0 0 0 0 ", "[grow,fill]", "[grow,fill]"));
|
||||||
"[grow,fill]",
|
|
||||||
"[grow,fill]"));
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Setup main JFrame window
|
* Setup main JFrame window
|
||||||
@@ -225,12 +229,20 @@ public class SDRTrunk implements Listener<TunerEvent>
|
|||||||
mSpectralPanel.setPreferredSize(new Dimension(1280, 300));
|
mSpectralPanel.setPreferredSize(new Dimension(1280, 300));
|
||||||
mControllerPanel.setPreferredSize(new Dimension(1280, 500));
|
mControllerPanel.setPreferredSize(new Dimension(1280, 500));
|
||||||
|
|
||||||
JideSplitPane splitPane = new JideSplitPane(JideSplitPane.VERTICAL_SPLIT);
|
mSplitPane = new JideSplitPane(JideSplitPane.VERTICAL_SPLIT);
|
||||||
splitPane.setDividerSize(5);
|
mSplitPane.setDividerSize(5);
|
||||||
splitPane.add(mSpectralPanel);
|
mSplitPane.add(mSpectralPanel);
|
||||||
splitPane.add(mControllerPanel);
|
mSplitPane.add(mControllerPanel);
|
||||||
|
|
||||||
mMainGui.add(splitPane, "cell 0 0,span,grow");
|
mBroadcastStatusVisible = SystemProperties.getInstance().get(PROPERTY_BROADCAST_STATUS_VISIBLE, false);
|
||||||
|
|
||||||
|
//Show broadcast status panel when user requests - disabled by default
|
||||||
|
if(mBroadcastStatusVisible)
|
||||||
|
{
|
||||||
|
mSplitPane.add(getBroadcastStatusPanel());
|
||||||
|
}
|
||||||
|
|
||||||
|
mMainGui.add(mSplitPane, "cell 0 0,span,grow");
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Menu items
|
* Menu items
|
||||||
@@ -291,6 +303,12 @@ public class SDRTrunk implements Listener<TunerEvent>
|
|||||||
|
|
||||||
fileMenu.add(exitMenu);
|
fileMenu.add(exitMenu);
|
||||||
|
|
||||||
|
JMenu viewMenu = new JMenu("View");
|
||||||
|
|
||||||
|
viewMenu.add(new BroadcastStatusVisibleMenuItem(mControllerPanel));
|
||||||
|
|
||||||
|
menuBar.add(viewMenu);
|
||||||
|
|
||||||
JMenuItem screenCaptureItem = new JMenuItem("Screen Capture");
|
JMenuItem screenCaptureItem = new JMenuItem("Screen Capture");
|
||||||
|
|
||||||
screenCaptureItem.setMnemonic(KeyEvent.VK_C);
|
screenCaptureItem.setMnemonic(KeyEvent.VK_C);
|
||||||
@@ -360,6 +378,50 @@ public class SDRTrunk implements Listener<TunerEvent>
|
|||||||
menuBar.add(screenCaptureItem);
|
menuBar.add(screenCaptureItem);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Lazy constructor for broadcast status panel
|
||||||
|
*/
|
||||||
|
private BroadcastStatusPanel getBroadcastStatusPanel()
|
||||||
|
{
|
||||||
|
if(mBroadcastStatusPanel == null)
|
||||||
|
{
|
||||||
|
mBroadcastStatusPanel = new BroadcastStatusPanel(mBroadcastModel);
|
||||||
|
mBroadcastStatusPanel.setPreferredSize(new Dimension(880, 70));
|
||||||
|
mBroadcastStatusPanel.getTable().setEnabled(false);
|
||||||
|
}
|
||||||
|
|
||||||
|
return mBroadcastStatusPanel;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Toggles visibility of the broadcast channels status panel at the bottom of the controller panel
|
||||||
|
*/
|
||||||
|
private void toggleBroadcastStatusPanelVisibility()
|
||||||
|
{
|
||||||
|
mBroadcastStatusVisible = !mBroadcastStatusVisible;
|
||||||
|
|
||||||
|
EventQueue.invokeLater(new Runnable()
|
||||||
|
{
|
||||||
|
@Override
|
||||||
|
public void run()
|
||||||
|
{
|
||||||
|
if(mBroadcastStatusVisible)
|
||||||
|
{
|
||||||
|
mSplitPane.add(getBroadcastStatusPanel());
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
mSplitPane.remove(getBroadcastStatusPanel());
|
||||||
|
}
|
||||||
|
|
||||||
|
mMainGui.revalidate();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
SystemProperties.getInstance().set(PROPERTY_BROADCAST_STATUS_VISIBLE, mBroadcastStatusVisible);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Loads the application properties file from the user's home directory,
|
* Loads the application properties file from the user's home directory,
|
||||||
* creating the properties file for the first-time, if necessary
|
* creating the properties file for the first-time, if necessary
|
||||||
@@ -435,4 +497,28 @@ public class SDRTrunk implements Listener<TunerEvent>
|
|||||||
mMainGui.setTitle(mTitle + " - " + event.getTuner().getName());
|
mMainGui.setTitle(mTitle + " - " + event.getTuner().getName());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public class BroadcastStatusVisibleMenuItem extends JCheckBoxMenuItem
|
||||||
|
{
|
||||||
|
private ControllerPanel mControllerPanel;
|
||||||
|
|
||||||
|
public BroadcastStatusVisibleMenuItem(ControllerPanel controllerPanel)
|
||||||
|
{
|
||||||
|
super("Show Streaming Status");
|
||||||
|
|
||||||
|
mControllerPanel = controllerPanel;
|
||||||
|
|
||||||
|
setSelected(mBroadcastStatusPanel != null);
|
||||||
|
|
||||||
|
addActionListener(new ActionListener()
|
||||||
|
{
|
||||||
|
@Override
|
||||||
|
public void actionPerformed(ActionEvent e)
|
||||||
|
{
|
||||||
|
toggleBroadcastStatusPanelVisibility();
|
||||||
|
setSelected(mBroadcastStatusVisible);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
/*******************************************************************************
|
/*******************************************************************************
|
||||||
* SDR Trunk
|
* sdrtrunk
|
||||||
* Copyright (C) 2014 Dennis Sheirer
|
* Copyright (C) 2014-2017 Dennis Sheirer
|
||||||
*
|
*
|
||||||
* This program is free software: you can redistribute it and/or modify
|
* 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
|
* it under the terms of the GNU General Public License as published by
|
||||||
@@ -14,9 +14,15 @@
|
|||||||
*
|
*
|
||||||
* You should have received a copy of the GNU General Public License
|
* You should have received a copy of the GNU General Public License
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>
|
* along with this program. If not, see <http://www.gnu.org/licenses/>
|
||||||
|
*
|
||||||
******************************************************************************/
|
******************************************************************************/
|
||||||
package instrument.gui;
|
package instrument.gui;
|
||||||
|
|
||||||
|
import alias.AliasModel;
|
||||||
|
import controller.channel.Channel;
|
||||||
|
import controller.channel.ChannelModel;
|
||||||
|
import controller.channel.ChannelProcessingManager;
|
||||||
|
import controller.channel.map.ChannelMapModel;
|
||||||
import instrument.Instrumentable;
|
import instrument.Instrumentable;
|
||||||
import instrument.InstrumentableProcessingChain;
|
import instrument.InstrumentableProcessingChain;
|
||||||
import instrument.tap.Tap;
|
import instrument.tap.Tap;
|
||||||
@@ -38,8 +44,21 @@ import instrument.tap.stream.QPSKTap;
|
|||||||
import instrument.tap.stream.QPSKTapPanel;
|
import instrument.tap.stream.QPSKTapPanel;
|
||||||
import instrument.tap.stream.SymbolEventTap;
|
import instrument.tap.stream.SymbolEventTap;
|
||||||
import instrument.tap.stream.SymbolEventTapViewPanel;
|
import instrument.tap.stream.SymbolEventTapViewPanel;
|
||||||
|
import message.Message;
|
||||||
|
import module.Module;
|
||||||
|
import module.decode.DecoderFactory;
|
||||||
|
import module.decode.config.DecodeConfiguration;
|
||||||
|
import module.log.EventLogManager;
|
||||||
|
import net.miginfocom.swing.MigLayout;
|
||||||
|
import org.slf4j.Logger;
|
||||||
|
import org.slf4j.LoggerFactory;
|
||||||
|
import playlist.PlaylistManager;
|
||||||
|
import sample.Listener;
|
||||||
|
import source.IControllableFileSource;
|
||||||
|
import source.Source;
|
||||||
|
|
||||||
import java.awt.Dimension;
|
import javax.swing.*;
|
||||||
|
import java.awt.*;
|
||||||
import java.awt.event.ActionEvent;
|
import java.awt.event.ActionEvent;
|
||||||
import java.awt.event.ActionListener;
|
import java.awt.event.ActionListener;
|
||||||
import java.awt.event.MouseEvent;
|
import java.awt.event.MouseEvent;
|
||||||
@@ -47,50 +66,18 @@ import java.awt.event.MouseListener;
|
|||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import javax.swing.JCheckBoxMenuItem;
|
public class DecoderViewFrame extends JInternalFrame implements Listener<Message>
|
||||||
import javax.swing.JInternalFrame;
|
|
||||||
import javax.swing.JMenu;
|
|
||||||
import javax.swing.JMenuItem;
|
|
||||||
import javax.swing.JPopupMenu;
|
|
||||||
import javax.swing.JSeparator;
|
|
||||||
|
|
||||||
import message.Message;
|
|
||||||
import module.Module;
|
|
||||||
import module.decode.DecoderFactory;
|
|
||||||
import module.decode.config.DecodeConfiguration;
|
|
||||||
import module.log.EventLogManager;
|
|
||||||
import net.miginfocom.swing.MigLayout;
|
|
||||||
|
|
||||||
import org.slf4j.Logger;
|
|
||||||
import org.slf4j.LoggerFactory;
|
|
||||||
|
|
||||||
import playlist.PlaylistManager;
|
|
||||||
import sample.Listener;
|
|
||||||
import source.IControllableFileSource;
|
|
||||||
import source.Source;
|
|
||||||
import alias.AliasModel;
|
|
||||||
import controller.channel.Channel;
|
|
||||||
import controller.channel.ChannelModel;
|
|
||||||
import controller.channel.ChannelProcessingManager;
|
|
||||||
import controller.channel.map.ChannelMapModel;
|
|
||||||
|
|
||||||
public class DecoderViewFrame extends JInternalFrame
|
|
||||||
implements Listener<Message>
|
|
||||||
{
|
{
|
||||||
private static final long serialVersionUID = 1L;
|
private static final long serialVersionUID = 1L;
|
||||||
private final static Logger mLog =
|
private final static Logger mLog = LoggerFactory.getLogger(DecoderViewFrame.class);
|
||||||
LoggerFactory.getLogger( DecoderViewFrame.class );
|
|
||||||
|
|
||||||
private DecodeConfiguration mDecodeConfig;
|
private DecodeConfiguration mDecodeConfig;
|
||||||
private InstrumentableProcessingChain mProcessingChain;
|
private InstrumentableProcessingChain mProcessingChain;
|
||||||
private IControllableFileSource mSource;
|
private IControllableFileSource mSource;
|
||||||
|
|
||||||
private HashMap<Tap,TapViewPanel> mPanelMap =
|
private HashMap<Tap,TapViewPanel> mPanelMap = new HashMap<Tap,TapViewPanel>();
|
||||||
new HashMap<Tap,TapViewPanel>();
|
|
||||||
|
|
||||||
public DecoderViewFrame( PlaylistManager playlistManager,
|
public DecoderViewFrame(PlaylistManager playlistManager, Channel channel, IControllableFileSource source)
|
||||||
Channel channel,
|
|
||||||
IControllableFileSource source )
|
|
||||||
{
|
{
|
||||||
mSource = source;
|
mSource = source;
|
||||||
|
|
||||||
@@ -101,12 +88,11 @@ public class DecoderViewFrame extends JInternalFrame
|
|||||||
ChannelModel channelModel = new ChannelModel();
|
ChannelModel channelModel = new ChannelModel();
|
||||||
ChannelMapModel channelMapModel = new ChannelMapModel();
|
ChannelMapModel channelMapModel = new ChannelMapModel();
|
||||||
|
|
||||||
ChannelProcessingManager channelProcessingManager =
|
ChannelProcessingManager channelProcessingManager = new ChannelProcessingManager(channelModel, channelMapModel,
|
||||||
new ChannelProcessingManager( channelModel, channelMapModel,
|
|
||||||
new AliasModel(), new EventLogManager(), null, null);
|
new AliasModel(), new EventLogManager(), null, null);
|
||||||
|
|
||||||
List<Module> modules = DecoderFactory.getModules( channelModel,
|
List<Module> modules = DecoderFactory.getModules(channelModel, channelMapModel, channelProcessingManager,
|
||||||
channelMapModel, channelProcessingManager, new AliasModel(), channel );
|
new AliasModel(), channel, mProcessingChain.getChannelState().getMutableMetadata());
|
||||||
|
|
||||||
mProcessingChain.addModules(modules);
|
mProcessingChain.addModules(modules);
|
||||||
|
|
||||||
@@ -158,13 +144,24 @@ public class DecoderViewFrame extends JInternalFrame
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void mouseEntered( MouseEvent arg0 ) {}
|
public void mouseEntered(MouseEvent arg0)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void mouseExited( MouseEvent arg0 ) {}
|
public void mouseExited(MouseEvent arg0)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void mousePressed( MouseEvent arg0 ) {}
|
public void mousePressed(MouseEvent arg0)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void mouseReleased( MouseEvent arg0 ) {}
|
public void mouseReleased(MouseEvent arg0)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -23,7 +23,6 @@ import controller.NamingThreadFactory;
|
|||||||
import icon.IconManager;
|
import icon.IconManager;
|
||||||
import message.Message;
|
import message.Message;
|
||||||
import sample.Listener;
|
import sample.Listener;
|
||||||
import settings.SettingsManager;
|
|
||||||
|
|
||||||
import java.awt.*;
|
import java.awt.*;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
@@ -102,7 +101,7 @@ public class MapService implements Listener<Message>
|
|||||||
|
|
||||||
if(alias != null)
|
if(alias != null)
|
||||||
{
|
{
|
||||||
color = alias.getMapColor();
|
color = alias.getDisplayColor();
|
||||||
}
|
}
|
||||||
|
|
||||||
if(color == null)
|
if(color == null)
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
/*******************************************************************************
|
/*******************************************************************************
|
||||||
* SDR Trunk
|
* sdrtrunk
|
||||||
* Copyright (C) 2015-2016 Dennis Sheirer
|
* Copyright (C) 2014-2017 Dennis Sheirer
|
||||||
*
|
*
|
||||||
* This program is free software: you can redistribute it and/or modify
|
* 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
|
* it under the terms of the GNU General Public License as published by
|
||||||
@@ -14,18 +14,26 @@
|
|||||||
*
|
*
|
||||||
* You should have received a copy of the GNU General Public License
|
* You should have received a copy of the GNU General Public License
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>
|
* along with this program. If not, see <http://www.gnu.org/licenses/>
|
||||||
|
*
|
||||||
******************************************************************************/
|
******************************************************************************/
|
||||||
package module;
|
package module;
|
||||||
|
|
||||||
import audio.AudioPacket;
|
import audio.AudioPacket;
|
||||||
import audio.IAudioPacketListener;
|
import audio.IAudioPacketListener;
|
||||||
import audio.IAudioPacketProvider;
|
import audio.IAudioPacketProvider;
|
||||||
import audio.metadata.IMetadataListener;
|
|
||||||
import audio.metadata.IMetadataProvider;
|
|
||||||
import audio.metadata.Metadata;
|
|
||||||
import audio.squelch.ISquelchStateListener;
|
import audio.squelch.ISquelchStateListener;
|
||||||
import audio.squelch.ISquelchStateProvider;
|
import audio.squelch.ISquelchStateProvider;
|
||||||
import audio.squelch.SquelchState;
|
import audio.squelch.SquelchState;
|
||||||
|
import channel.metadata.AttributeChangeRequest;
|
||||||
|
import channel.metadata.IAttributeChangeRequestListener;
|
||||||
|
import channel.metadata.IAttributeChangeRequestProvider;
|
||||||
|
import channel.state.ChannelState;
|
||||||
|
import channel.state.DecoderState;
|
||||||
|
import channel.state.DecoderStateEvent;
|
||||||
|
import channel.state.DecoderStateEvent.Event;
|
||||||
|
import channel.state.IDecoderStateEventListener;
|
||||||
|
import channel.state.IDecoderStateEventProvider;
|
||||||
|
import channel.state.State;
|
||||||
import controller.NamingThreadFactory;
|
import controller.NamingThreadFactory;
|
||||||
import controller.channel.Channel.ChannelType;
|
import controller.channel.Channel.ChannelType;
|
||||||
import controller.channel.ChannelEvent;
|
import controller.channel.ChannelEvent;
|
||||||
@@ -39,13 +47,6 @@ import module.decode.event.CallEventModel;
|
|||||||
import module.decode.event.ICallEventListener;
|
import module.decode.event.ICallEventListener;
|
||||||
import module.decode.event.ICallEventProvider;
|
import module.decode.event.ICallEventProvider;
|
||||||
import module.decode.event.MessageActivityModel;
|
import module.decode.event.MessageActivityModel;
|
||||||
import module.decode.state.ChannelState;
|
|
||||||
import module.decode.state.DecoderState;
|
|
||||||
import module.decode.state.DecoderStateEvent;
|
|
||||||
import module.decode.state.DecoderStateEvent.Event;
|
|
||||||
import module.decode.state.IDecoderStateEventListener;
|
|
||||||
import module.decode.state.IDecoderStateEventProvider;
|
|
||||||
import module.decode.state.State;
|
|
||||||
import module.log.EventLogger;
|
import module.log.EventLogger;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
@@ -97,8 +98,8 @@ public class ProcessingChain implements IChannelEventListener
|
|||||||
{
|
{
|
||||||
private final static Logger mLog = LoggerFactory.getLogger(ProcessingChain.class);
|
private final static Logger mLog = LoggerFactory.getLogger(ProcessingChain.class);
|
||||||
|
|
||||||
|
private Broadcaster<AttributeChangeRequest> mAttributeChangeRequestBroadcaster = new Broadcaster<>();
|
||||||
private Broadcaster<AudioPacket> mAudioPacketBroadcaster = new Broadcaster<>();
|
private Broadcaster<AudioPacket> mAudioPacketBroadcaster = new Broadcaster<>();
|
||||||
private Broadcaster<Metadata> mMetadataBroadcaster = new Broadcaster<>();
|
|
||||||
private Broadcaster<CallEvent> mCallEventBroadcaster = new Broadcaster<>();
|
private Broadcaster<CallEvent> mCallEventBroadcaster = new Broadcaster<>();
|
||||||
private Broadcaster<ChannelEvent> mChannelEventBroadcaster = new Broadcaster<>();
|
private Broadcaster<ChannelEvent> mChannelEventBroadcaster = new Broadcaster<>();
|
||||||
private Broadcaster<ComplexBuffer> mComplexBufferBroadcaster = new Broadcaster<>();
|
private Broadcaster<ComplexBuffer> mComplexBufferBroadcaster = new Broadcaster<>();
|
||||||
@@ -186,17 +187,6 @@ public class ProcessingChain implements IChannelEventListener
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Broadcasts the metadata to any registered listeners
|
|
||||||
*/
|
|
||||||
public void broadcast(Metadata metadata)
|
|
||||||
{
|
|
||||||
if(mMetadataBroadcaster != null)
|
|
||||||
{
|
|
||||||
mMetadataBroadcaster.broadcast(metadata);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Indicates if this processing chain is currently receiving samples from
|
* Indicates if this processing chain is currently receiving samples from
|
||||||
* a source and sending those samples to the decoders.
|
* a source and sending those samples to the decoders.
|
||||||
@@ -227,9 +217,8 @@ public class ProcessingChain implements IChannelEventListener
|
|||||||
{
|
{
|
||||||
if(isProcessing())
|
if(isProcessing())
|
||||||
{
|
{
|
||||||
throw new IllegalStateException("Processing chain is currently "
|
throw new IllegalStateException("Processing chain is currently processing. Invoke stop() on the " +
|
||||||
+ "processing. Invoke stop() on the processing chain before "
|
"processing chain before applying a new sample source");
|
||||||
+ "applying a new sample source");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
mSource = source;
|
mSource = source;
|
||||||
@@ -312,70 +301,59 @@ public class ProcessingChain implements IChannelEventListener
|
|||||||
*/
|
*/
|
||||||
private void registerListeners(Module module)
|
private void registerListeners(Module module)
|
||||||
{
|
{
|
||||||
|
if(module instanceof IAttributeChangeRequestListener)
|
||||||
|
{
|
||||||
|
mAttributeChangeRequestBroadcaster.addListener(((IAttributeChangeRequestListener)module).getAttributeChangeRequestListener());
|
||||||
|
}
|
||||||
|
|
||||||
if(module instanceof IAudioPacketListener)
|
if(module instanceof IAudioPacketListener)
|
||||||
{
|
{
|
||||||
mAudioPacketBroadcaster.addListener(
|
mAudioPacketBroadcaster.addListener(((IAudioPacketListener) module).getAudioPacketListener());
|
||||||
((IAudioPacketListener) module).getAudioPacketListener());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if(module instanceof ICallEventListener)
|
if(module instanceof ICallEventListener)
|
||||||
{
|
{
|
||||||
mCallEventBroadcaster.addListener(
|
mCallEventBroadcaster.addListener(((ICallEventListener) module).getCallEventListener());
|
||||||
((ICallEventListener) module).getCallEventListener());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if(module instanceof IChannelEventListener)
|
if(module instanceof IChannelEventListener)
|
||||||
{
|
{
|
||||||
mChannelEventBroadcaster.addListener(
|
mChannelEventBroadcaster.addListener(((IChannelEventListener) module).getChannelEventListener());
|
||||||
((IChannelEventListener) module).getChannelEventListener());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if(module instanceof IComplexBufferListener)
|
if(module instanceof IComplexBufferListener)
|
||||||
{
|
{
|
||||||
mComplexBufferBroadcaster.addListener(
|
mComplexBufferBroadcaster.addListener(((IComplexBufferListener) module).getComplexBufferListener());
|
||||||
((IComplexBufferListener) module).getComplexBufferListener());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if(module instanceof IDecoderStateEventListener)
|
if(module instanceof IDecoderStateEventListener)
|
||||||
{
|
{
|
||||||
mDecoderStateEventBroadcaster.addListener(
|
mDecoderStateEventBroadcaster.addListener(((IDecoderStateEventListener) module).getDecoderStateListener());
|
||||||
((IDecoderStateEventListener) module).getDecoderStateListener());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if(module instanceof IFrequencyChangeListener)
|
if(module instanceof IFrequencyChangeListener)
|
||||||
{
|
{
|
||||||
mFrequencyChangeEventBroadcaster.addListener(
|
mFrequencyChangeEventBroadcaster.addListener(((IFrequencyChangeListener) module).getFrequencyChangeListener());
|
||||||
((IFrequencyChangeListener) module).getFrequencyChangeListener());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if(module instanceof IMessageListener)
|
if(module instanceof IMessageListener)
|
||||||
{
|
{
|
||||||
mMessageBroadcaster.addListener(
|
mMessageBroadcaster.addListener(((IMessageListener) module).getMessageListener());
|
||||||
((IMessageListener) module).getMessageListener());
|
|
||||||
}
|
|
||||||
|
|
||||||
if(module instanceof IMetadataListener)
|
|
||||||
{
|
|
||||||
mMetadataBroadcaster.addListener(
|
|
||||||
((IMetadataListener) module).getMetadataListener());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if(module instanceof IFilteredRealBufferListener)
|
if(module instanceof IFilteredRealBufferListener)
|
||||||
{
|
{
|
||||||
mFilteredRealBufferBroadcaster.addListener(
|
mFilteredRealBufferBroadcaster.addListener(((IFilteredRealBufferListener) module).getFilteredRealBufferListener());
|
||||||
((IFilteredRealBufferListener) module).getFilteredRealBufferListener());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if(module instanceof ISquelchStateListener)
|
if(module instanceof ISquelchStateListener)
|
||||||
{
|
{
|
||||||
mSquelchStateBroadcaster.addListener(
|
mSquelchStateBroadcaster.addListener(((ISquelchStateListener) module).getSquelchStateListener());
|
||||||
((ISquelchStateListener) module).getSquelchStateListener());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if(module instanceof IUnFilteredRealBufferListener)
|
if(module instanceof IUnFilteredRealBufferListener)
|
||||||
{
|
{
|
||||||
mUnFilteredRealBufferBroadcaster.addListener(
|
mUnFilteredRealBufferBroadcaster.addListener(((IUnFilteredRealBufferListener) module).getUnFilteredRealBufferListener());
|
||||||
((IUnFilteredRealBufferListener) module).getUnFilteredRealBufferListener());
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -385,40 +363,39 @@ public class ProcessingChain implements IChannelEventListener
|
|||||||
*/
|
*/
|
||||||
private void unregisterListeners(Module module)
|
private void unregisterListeners(Module module)
|
||||||
{
|
{
|
||||||
|
if(module instanceof IAttributeChangeRequestListener)
|
||||||
|
{
|
||||||
|
mAttributeChangeRequestBroadcaster.removeListener(((IAttributeChangeRequestListener) module).getAttributeChangeRequestListener());
|
||||||
|
}
|
||||||
|
|
||||||
if(module instanceof IAudioPacketListener)
|
if(module instanceof IAudioPacketListener)
|
||||||
{
|
{
|
||||||
mAudioPacketBroadcaster.removeListener(
|
mAudioPacketBroadcaster.removeListener(((IAudioPacketListener) module).getAudioPacketListener());
|
||||||
((IAudioPacketListener) module).getAudioPacketListener());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if(module instanceof ICallEventListener)
|
if(module instanceof ICallEventListener)
|
||||||
{
|
{
|
||||||
mCallEventBroadcaster.removeListener(
|
mCallEventBroadcaster.removeListener(((ICallEventListener) module).getCallEventListener());
|
||||||
((ICallEventListener) module).getCallEventListener());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if(module instanceof IChannelEventListener)
|
if(module instanceof IChannelEventListener)
|
||||||
{
|
{
|
||||||
mChannelEventBroadcaster.removeListener(
|
mChannelEventBroadcaster.removeListener(((IChannelEventListener) module).getChannelEventListener());
|
||||||
((IChannelEventListener) module).getChannelEventListener());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if(module instanceof IComplexBufferListener)
|
if(module instanceof IComplexBufferListener)
|
||||||
{
|
{
|
||||||
mComplexBufferBroadcaster.removeListener(
|
mComplexBufferBroadcaster.removeListener(((IComplexBufferListener) module).getComplexBufferListener());
|
||||||
((IComplexBufferListener) module).getComplexBufferListener());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if(module instanceof IDecoderStateEventListener)
|
if(module instanceof IDecoderStateEventListener)
|
||||||
{
|
{
|
||||||
mDecoderStateEventBroadcaster.removeListener(
|
mDecoderStateEventBroadcaster.removeListener(((IDecoderStateEventListener) module).getDecoderStateListener());
|
||||||
((IDecoderStateEventListener) module).getDecoderStateListener());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if(module instanceof IFrequencyChangeListener)
|
if(module instanceof IFrequencyChangeListener)
|
||||||
{
|
{
|
||||||
mFrequencyChangeEventBroadcaster.removeListener(
|
mFrequencyChangeEventBroadcaster.removeListener(((IFrequencyChangeListener) module).getFrequencyChangeListener());
|
||||||
((IFrequencyChangeListener) module).getFrequencyChangeListener());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if(module instanceof IMessageListener)
|
if(module instanceof IMessageListener)
|
||||||
@@ -426,27 +403,19 @@ public class ProcessingChain implements IChannelEventListener
|
|||||||
mMessageBroadcaster.removeListener(((IMessageListener) module).getMessageListener());
|
mMessageBroadcaster.removeListener(((IMessageListener) module).getMessageListener());
|
||||||
}
|
}
|
||||||
|
|
||||||
if(module instanceof IMetadataListener)
|
|
||||||
{
|
|
||||||
mMetadataBroadcaster.removeListener(((IMetadataListener) module).getMetadataListener());
|
|
||||||
}
|
|
||||||
|
|
||||||
if(module instanceof IFilteredRealBufferListener)
|
if(module instanceof IFilteredRealBufferListener)
|
||||||
{
|
{
|
||||||
mFilteredRealBufferBroadcaster.removeListener(
|
mFilteredRealBufferBroadcaster.removeListener(((IFilteredRealBufferListener) module).getFilteredRealBufferListener());
|
||||||
((IFilteredRealBufferListener) module).getFilteredRealBufferListener());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if(module instanceof ISquelchStateListener)
|
if(module instanceof ISquelchStateListener)
|
||||||
{
|
{
|
||||||
mSquelchStateBroadcaster.removeListener(
|
mSquelchStateBroadcaster.removeListener(((ISquelchStateListener) module).getSquelchStateListener());
|
||||||
((ISquelchStateListener) module).getSquelchStateListener());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if(module instanceof IUnFilteredRealBufferListener)
|
if(module instanceof IUnFilteredRealBufferListener)
|
||||||
{
|
{
|
||||||
mUnFilteredRealBufferBroadcaster.removeListener(
|
mUnFilteredRealBufferBroadcaster.removeListener(((IUnFilteredRealBufferListener) module).getUnFilteredRealBufferListener());
|
||||||
((IUnFilteredRealBufferListener) module).getUnFilteredRealBufferListener());
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -456,10 +425,14 @@ public class ProcessingChain implements IChannelEventListener
|
|||||||
*/
|
*/
|
||||||
private void registerProviders(Module module)
|
private void registerProviders(Module module)
|
||||||
{
|
{
|
||||||
|
if(module instanceof IAttributeChangeRequestProvider)
|
||||||
|
{
|
||||||
|
((IAttributeChangeRequestProvider)module).setAttributeChangeRequestListener(mAttributeChangeRequestBroadcaster);
|
||||||
|
}
|
||||||
|
|
||||||
if(module instanceof IAudioPacketProvider)
|
if(module instanceof IAudioPacketProvider)
|
||||||
{
|
{
|
||||||
((IAudioPacketProvider) module).setAudioPacketListener(
|
((IAudioPacketProvider) module).setAudioPacketListener(mAudioPacketBroadcaster);
|
||||||
mAudioPacketBroadcaster);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if(module instanceof ICallEventProvider)
|
if(module instanceof ICallEventProvider)
|
||||||
@@ -469,20 +442,17 @@ public class ProcessingChain implements IChannelEventListener
|
|||||||
|
|
||||||
if(module instanceof IChannelEventProvider)
|
if(module instanceof IChannelEventProvider)
|
||||||
{
|
{
|
||||||
((IChannelEventProvider) module).setChannelEventListener(
|
((IChannelEventProvider) module).setChannelEventListener(mChannelEventBroadcaster);
|
||||||
mChannelEventBroadcaster);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if(module instanceof IDecoderStateEventProvider)
|
if(module instanceof IDecoderStateEventProvider)
|
||||||
{
|
{
|
||||||
((IDecoderStateEventProvider) module).setDecoderStateListener(
|
((IDecoderStateEventProvider) module).setDecoderStateListener(mDecoderStateEventBroadcaster);
|
||||||
mDecoderStateEventBroadcaster);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if(module instanceof IFrequencyChangeProvider)
|
if(module instanceof IFrequencyChangeProvider)
|
||||||
{
|
{
|
||||||
((IFrequencyChangeProvider) module).setFrequencyChangeListener(
|
((IFrequencyChangeProvider) module).setFrequencyChangeListener(mFrequencyChangeEventBroadcaster);
|
||||||
mFrequencyChangeEventBroadcaster);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if(module instanceof IMessageProvider)
|
if(module instanceof IMessageProvider)
|
||||||
@@ -490,28 +460,19 @@ public class ProcessingChain implements IChannelEventListener
|
|||||||
((IMessageProvider) module).setMessageListener(mMessageBroadcaster);
|
((IMessageProvider) module).setMessageListener(mMessageBroadcaster);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(module instanceof IMetadataProvider)
|
|
||||||
{
|
|
||||||
((IMetadataProvider) module).setMetadataListener(
|
|
||||||
mMetadataBroadcaster);
|
|
||||||
}
|
|
||||||
|
|
||||||
if(module instanceof IFilteredRealBufferProvider)
|
if(module instanceof IFilteredRealBufferProvider)
|
||||||
{
|
{
|
||||||
((IFilteredRealBufferProvider) module)
|
((IFilteredRealBufferProvider) module).setFilteredRealBufferListener(mFilteredRealBufferBroadcaster);
|
||||||
.setFilteredRealBufferListener(mFilteredRealBufferBroadcaster);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if(module instanceof ISquelchStateProvider)
|
if(module instanceof ISquelchStateProvider)
|
||||||
{
|
{
|
||||||
((ISquelchStateProvider) module).setSquelchStateListener(
|
((ISquelchStateProvider) module).setSquelchStateListener(mSquelchStateBroadcaster);
|
||||||
mSquelchStateBroadcaster);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if(module instanceof IUnFilteredRealBufferProvider)
|
if(module instanceof IUnFilteredRealBufferProvider)
|
||||||
{
|
{
|
||||||
((IUnFilteredRealBufferProvider) module)
|
((IUnFilteredRealBufferProvider) module).setUnFilteredRealBufferListener(mUnFilteredRealBufferBroadcaster);
|
||||||
.setUnFilteredRealBufferListener(mUnFilteredRealBufferBroadcaster);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -521,6 +482,11 @@ public class ProcessingChain implements IChannelEventListener
|
|||||||
*/
|
*/
|
||||||
private void unregisterProviders(Module module)
|
private void unregisterProviders(Module module)
|
||||||
{
|
{
|
||||||
|
if(module instanceof IAttributeChangeRequestProvider)
|
||||||
|
{
|
||||||
|
((IAttributeChangeRequestProvider)module).removeAttributeChangeRequestListener(mAttributeChangeRequestBroadcaster);
|
||||||
|
}
|
||||||
|
|
||||||
if(module instanceof IAudioPacketProvider)
|
if(module instanceof IAudioPacketProvider)
|
||||||
{
|
{
|
||||||
((IAudioPacketProvider) module).setAudioPacketListener(null);
|
((IAudioPacketProvider) module).setAudioPacketListener(null);
|
||||||
@@ -551,11 +517,6 @@ public class ProcessingChain implements IChannelEventListener
|
|||||||
((IMessageProvider) module).setMessageListener(null);
|
((IMessageProvider) module).setMessageListener(null);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(module instanceof IMetadataProvider)
|
|
||||||
{
|
|
||||||
((IMetadataProvider) module).setMetadataListener(null);
|
|
||||||
}
|
|
||||||
|
|
||||||
if(module instanceof IFilteredRealBufferProvider)
|
if(module instanceof IFilteredRealBufferProvider)
|
||||||
{
|
{
|
||||||
((IFilteredRealBufferProvider) module).setFilteredRealBufferListener(null);
|
((IFilteredRealBufferProvider) module).setFilteredRealBufferListener(null);
|
||||||
@@ -615,8 +576,7 @@ public class ProcessingChain implements IChannelEventListener
|
|||||||
long frequency = tcs.getFrequency();
|
long frequency = tcs.getFrequency();
|
||||||
|
|
||||||
mDecoderStateEventBroadcaster.broadcast(
|
mDecoderStateEventBroadcaster.broadcast(
|
||||||
new DecoderStateEvent(this, Event.SOURCE_FREQUENCY,
|
new DecoderStateEvent(this, Event.SOURCE_FREQUENCY, State.IDLE, frequency));
|
||||||
State.IDLE, frequency));
|
|
||||||
}
|
}
|
||||||
catch(SourceException e)
|
catch(SourceException e)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -21,66 +21,61 @@ package module.decode;
|
|||||||
import alias.AliasList;
|
import alias.AliasList;
|
||||||
import alias.AliasModel;
|
import alias.AliasModel;
|
||||||
import audio.AudioModule;
|
import audio.AudioModule;
|
||||||
|
import channel.metadata.Metadata;
|
||||||
|
import channel.state.AlwaysUnsquelchedDecoderState;
|
||||||
|
import channel.traffic.TrafficChannelManager;
|
||||||
import controller.channel.Channel;
|
import controller.channel.Channel;
|
||||||
import controller.channel.Channel.ChannelType;
|
import controller.channel.Channel.ChannelType;
|
||||||
import controller.channel.ChannelModel;
|
import controller.channel.ChannelModel;
|
||||||
import controller.channel.ChannelProcessingManager;
|
import controller.channel.ChannelProcessingManager;
|
||||||
import controller.channel.map.ChannelMap;
|
import controller.channel.map.ChannelMap;
|
||||||
import controller.channel.map.ChannelMapModel;
|
import controller.channel.map.ChannelMapModel;
|
||||||
|
import dsp.filter.FilterFactory;
|
||||||
|
import dsp.filter.fir.FIRFilterSpecification;
|
||||||
import filter.AllPassFilter;
|
import filter.AllPassFilter;
|
||||||
import filter.FilterSet;
|
import filter.FilterSet;
|
||||||
import filter.IFilter;
|
import filter.IFilter;
|
||||||
import gui.editor.EmptyValidatingEditor;
|
import gui.editor.EmptyValidatingEditor;
|
||||||
import gui.editor.ValidatingEditor;
|
import gui.editor.ValidatingEditor;
|
||||||
import icon.IconManager;
|
|
||||||
import message.Message;
|
import message.Message;
|
||||||
import message.MessageDirection;
|
import message.MessageDirection;
|
||||||
import module.Module;
|
import module.Module;
|
||||||
import module.decode.am.AMDecoder;
|
import module.decode.am.AMDecoder;
|
||||||
import module.decode.am.AMDecoderEditor;
|
import module.decode.am.AMDecoderEditor;
|
||||||
import module.decode.am.AMDecoderPanel;
|
|
||||||
import module.decode.am.DecodeConfigAM;
|
import module.decode.am.DecodeConfigAM;
|
||||||
import module.decode.config.AuxDecodeConfiguration;
|
import module.decode.config.AuxDecodeConfiguration;
|
||||||
import module.decode.config.DecodeConfiguration;
|
import module.decode.config.DecodeConfiguration;
|
||||||
import module.decode.fleetsync2.Fleetsync2Decoder;
|
import module.decode.fleetsync2.Fleetsync2Decoder;
|
||||||
import module.decode.fleetsync2.Fleetsync2DecoderPanel;
|
|
||||||
import module.decode.fleetsync2.Fleetsync2DecoderState;
|
import module.decode.fleetsync2.Fleetsync2DecoderState;
|
||||||
import module.decode.fleetsync2.FleetsyncMessageFilter;
|
import module.decode.fleetsync2.FleetsyncMessageFilter;
|
||||||
import module.decode.lj1200.LJ1200Decoder;
|
import module.decode.lj1200.LJ1200Decoder;
|
||||||
import module.decode.lj1200.LJ1200DecoderPanel;
|
|
||||||
import module.decode.lj1200.LJ1200DecoderState;
|
import module.decode.lj1200.LJ1200DecoderState;
|
||||||
import module.decode.lj1200.LJ1200MessageFilter;
|
import module.decode.lj1200.LJ1200MessageFilter;
|
||||||
import module.decode.ltrnet.DecodeConfigLTRNet;
|
import module.decode.ltrnet.DecodeConfigLTRNet;
|
||||||
import module.decode.ltrnet.LTRNetDecoder;
|
import module.decode.ltrnet.LTRNetDecoder;
|
||||||
import module.decode.ltrnet.LTRNetDecoderEditor;
|
import module.decode.ltrnet.LTRNetDecoderEditor;
|
||||||
import module.decode.ltrnet.LTRNetDecoderPanel;
|
|
||||||
import module.decode.ltrnet.LTRNetDecoderState;
|
import module.decode.ltrnet.LTRNetDecoderState;
|
||||||
import module.decode.ltrnet.LTRNetMessageFilter;
|
import module.decode.ltrnet.LTRNetMessageFilter;
|
||||||
import module.decode.ltrstandard.DecodeConfigLTRStandard;
|
import module.decode.ltrstandard.DecodeConfigLTRStandard;
|
||||||
import module.decode.ltrstandard.LTRStandardDecoder;
|
import module.decode.ltrstandard.LTRStandardDecoder;
|
||||||
import module.decode.ltrstandard.LTRStandardDecoderEditor;
|
import module.decode.ltrstandard.LTRStandardDecoderEditor;
|
||||||
import module.decode.ltrstandard.LTRStandardDecoderPanel;
|
|
||||||
import module.decode.ltrstandard.LTRStandardDecoderState;
|
import module.decode.ltrstandard.LTRStandardDecoderState;
|
||||||
import module.decode.ltrstandard.LTRStandardMessageFilter;
|
import module.decode.ltrstandard.LTRStandardMessageFilter;
|
||||||
import module.decode.mdc1200.MDCDecoder;
|
import module.decode.mdc1200.MDCDecoder;
|
||||||
import module.decode.mdc1200.MDCDecoderPanel;
|
|
||||||
import module.decode.mdc1200.MDCDecoderState;
|
import module.decode.mdc1200.MDCDecoderState;
|
||||||
import module.decode.mdc1200.MDCMessageFilter;
|
import module.decode.mdc1200.MDCMessageFilter;
|
||||||
import module.decode.mpt1327.DecodeConfigMPT1327;
|
import module.decode.mpt1327.DecodeConfigMPT1327;
|
||||||
import module.decode.mpt1327.MPT1327Decoder;
|
import module.decode.mpt1327.MPT1327Decoder;
|
||||||
import module.decode.mpt1327.MPT1327Decoder.Sync;
|
import module.decode.mpt1327.MPT1327Decoder.Sync;
|
||||||
import module.decode.mpt1327.MPT1327DecoderEditor;
|
import module.decode.mpt1327.MPT1327DecoderEditor;
|
||||||
import module.decode.mpt1327.MPT1327DecoderPanel;
|
|
||||||
import module.decode.mpt1327.MPT1327DecoderState;
|
import module.decode.mpt1327.MPT1327DecoderState;
|
||||||
import module.decode.mpt1327.MPT1327MessageFilter;
|
import module.decode.mpt1327.MPT1327MessageFilter;
|
||||||
import module.decode.nbfm.DecodeConfigNBFM;
|
import module.decode.nbfm.DecodeConfigNBFM;
|
||||||
import module.decode.nbfm.NBFMDecoder;
|
import module.decode.nbfm.NBFMDecoder;
|
||||||
import module.decode.nbfm.NBFMDecoderEditor;
|
import module.decode.nbfm.NBFMDecoderEditor;
|
||||||
import module.decode.nbfm.NBFMDecoderPanel;
|
|
||||||
import module.decode.p25.DecodeConfigP25Phase1;
|
import module.decode.p25.DecodeConfigP25Phase1;
|
||||||
import module.decode.p25.P25Decoder.Modulation;
|
import module.decode.p25.P25Decoder.Modulation;
|
||||||
import module.decode.p25.P25DecoderEditor;
|
import module.decode.p25.P25DecoderEditor;
|
||||||
import module.decode.p25.P25DecoderPanel;
|
|
||||||
import module.decode.p25.P25DecoderState;
|
import module.decode.p25.P25DecoderState;
|
||||||
import module.decode.p25.P25_C4FMDecoder;
|
import module.decode.p25.P25_C4FMDecoder;
|
||||||
import module.decode.p25.P25_LSMDecoder;
|
import module.decode.p25.P25_LSMDecoder;
|
||||||
@@ -89,31 +84,41 @@ import module.decode.p25.message.filter.P25MessageFilterSet;
|
|||||||
import module.decode.passport.DecodeConfigPassport;
|
import module.decode.passport.DecodeConfigPassport;
|
||||||
import module.decode.passport.PassportDecoder;
|
import module.decode.passport.PassportDecoder;
|
||||||
import module.decode.passport.PassportDecoderEditor;
|
import module.decode.passport.PassportDecoderEditor;
|
||||||
import module.decode.passport.PassportDecoderPanel;
|
|
||||||
import module.decode.passport.PassportDecoderState;
|
import module.decode.passport.PassportDecoderState;
|
||||||
import module.decode.passport.PassportMessageFilter;
|
import module.decode.passport.PassportMessageFilter;
|
||||||
import module.decode.state.AlwaysUnsquelchedDecoderState;
|
|
||||||
import module.decode.state.DecoderPanel;
|
|
||||||
import module.decode.state.DecoderState;
|
|
||||||
import module.decode.state.TrafficChannelManager;
|
|
||||||
import module.decode.tait.Tait1200Decoder;
|
import module.decode.tait.Tait1200Decoder;
|
||||||
import module.decode.tait.Tait1200DecoderPanel;
|
|
||||||
import module.decode.tait.Tait1200DecoderState;
|
import module.decode.tait.Tait1200DecoderState;
|
||||||
import module.demodulate.am.AMDemodulatorModule;
|
import module.demodulate.am.AMDemodulatorModule;
|
||||||
import module.demodulate.audio.DemodulatedAudioFilterModule;
|
import module.demodulate.audio.DemodulatedAudioFilterModule;
|
||||||
import module.demodulate.fm.FMDemodulatorModule;
|
import module.demodulate.fm.FMDemodulatorModule;
|
||||||
import properties.SystemProperties;
|
import org.slf4j.Logger;
|
||||||
import record.RecorderType;
|
import org.slf4j.LoggerFactory;
|
||||||
import record.config.RecordConfiguration;
|
|
||||||
import settings.SettingsManager;
|
|
||||||
import util.TimeStamp;
|
|
||||||
|
|
||||||
import java.io.File;
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
public class DecoderFactory
|
public class DecoderFactory
|
||||||
{
|
{
|
||||||
|
private final static Logger mLog = LoggerFactory.getLogger(DecoderFactory.class);
|
||||||
|
|
||||||
|
private static final FIRFilterSpecification MPT1327_FILTER_SPECIFICATION = FIRFilterSpecification.bandPassBuilder()
|
||||||
|
.sampleRate(48000).stopFrequency1(200).passFrequencyBegin(400).passFrequencyEnd(3200)
|
||||||
|
.stopFrequency2(3400).stopRipple(0.0003).passRipple(0.008).build();
|
||||||
|
|
||||||
|
private static float[] MPT1327_BANDPASS_FILTER;
|
||||||
|
|
||||||
|
static
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
MPT1327_BANDPASS_FILTER = FilterFactory.getTaps(MPT1327_FILTER_SPECIFICATION);
|
||||||
|
}
|
||||||
|
catch(Exception e)
|
||||||
|
{
|
||||||
|
mLog.error("Couldn't design MPT1327 bandpass filter");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public static final boolean NO_REMOVE_DC = false;
|
public static final boolean NO_REMOVE_DC = false;
|
||||||
public static final boolean REMOVE_DC = true;
|
public static final boolean REMOVE_DC = true;
|
||||||
|
|
||||||
@@ -129,14 +134,15 @@ public class DecoderFactory
|
|||||||
ChannelMapModel channelMapModel,
|
ChannelMapModel channelMapModel,
|
||||||
ChannelProcessingManager channelProcessingManager,
|
ChannelProcessingManager channelProcessingManager,
|
||||||
AliasModel aliasModel,
|
AliasModel aliasModel,
|
||||||
Channel channel)
|
Channel channel,
|
||||||
|
Metadata metadata)
|
||||||
{
|
{
|
||||||
|
|
||||||
/* Get the optional alias list for the decode modules to use */
|
/* Get the optional alias list for the decode modules to use */
|
||||||
AliasList aliasList = aliasModel.getAliasList(channel.getAliasListName());
|
AliasList aliasList = aliasModel.getAliasList(channel.getAliasListName());
|
||||||
|
|
||||||
List<Module> modules = getPrimaryModules(channelModel, channelMapModel,
|
List<Module> modules = getPrimaryModules(channelModel, channelMapModel, channelProcessingManager, aliasList,
|
||||||
channelProcessingManager, aliasList, channel);
|
channel, metadata);
|
||||||
|
|
||||||
modules.addAll(getAuxiliaryDecoders(channel.getAuxDecodeConfiguration(), aliasList));
|
modules.addAll(getAuxiliaryDecoders(channel.getAuxDecodeConfiguration(), aliasList));
|
||||||
|
|
||||||
@@ -150,7 +156,7 @@ public class DecoderFactory
|
|||||||
ChannelMapModel channelMapModel,
|
ChannelMapModel channelMapModel,
|
||||||
ChannelProcessingManager channelProcessingManager,
|
ChannelProcessingManager channelProcessingManager,
|
||||||
AliasList aliasList,
|
AliasList aliasList,
|
||||||
Channel channel)
|
Channel channel, Metadata metadata)
|
||||||
{
|
{
|
||||||
List<Module> modules = new ArrayList<Module>();
|
List<Module> modules = new ArrayList<Module>();
|
||||||
|
|
||||||
@@ -162,11 +168,6 @@ public class DecoderFactory
|
|||||||
int iqPass = decodeConfig.getDecoderType().getChannelBandwidth() / 2;
|
int iqPass = decodeConfig.getDecoderType().getChannelBandwidth() / 2;
|
||||||
int iqStop = iqPass + 1250;
|
int iqStop = iqPass + 1250;
|
||||||
|
|
||||||
RecordConfiguration recordConfig = channel.getRecordConfiguration();
|
|
||||||
|
|
||||||
boolean recordAudio = recordConfig == null ? false :
|
|
||||||
recordConfig.getRecorders().contains(RecorderType.AUDIO);
|
|
||||||
|
|
||||||
switch(decodeConfig.getDecoderType())
|
switch(decodeConfig.getDecoderType())
|
||||||
{
|
{
|
||||||
case AM:
|
case AM:
|
||||||
@@ -174,14 +175,14 @@ public class DecoderFactory
|
|||||||
modules.add(new AlwaysUnsquelchedDecoderState(DecoderType.AM, channel.getName()));
|
modules.add(new AlwaysUnsquelchedDecoderState(DecoderType.AM, channel.getName()));
|
||||||
modules.add(new AMDemodulatorModule());
|
modules.add(new AMDemodulatorModule());
|
||||||
modules.add(new DemodulatedAudioFilterModule(4000, 6000));
|
modules.add(new DemodulatedAudioFilterModule(4000, 6000));
|
||||||
modules.add(new AudioModule(recordAudio));
|
modules.add(new AudioModule(metadata));
|
||||||
break;
|
break;
|
||||||
case NBFM:
|
case NBFM:
|
||||||
modules.add(new NBFMDecoder(decodeConfig));
|
modules.add(new NBFMDecoder(decodeConfig));
|
||||||
modules.add(new AlwaysUnsquelchedDecoderState(DecoderType.NBFM, channel.getName()));
|
modules.add(new AlwaysUnsquelchedDecoderState(DecoderType.NBFM, channel.getName()));
|
||||||
modules.add(new FMDemodulatorModule(iqPass, iqStop));
|
modules.add(new FMDemodulatorModule(iqPass, iqStop));
|
||||||
modules.add(new DemodulatedAudioFilterModule(4000, 6000));
|
modules.add(new DemodulatedAudioFilterModule(4000, 6000));
|
||||||
modules.add(new AudioModule(recordAudio));
|
modules.add(new AudioModule(metadata));
|
||||||
break;
|
break;
|
||||||
case LTR_STANDARD:
|
case LTR_STANDARD:
|
||||||
MessageDirection direction = ((DecodeConfigLTRStandard) decodeConfig).getMessageDirection();
|
MessageDirection direction = ((DecodeConfigLTRStandard) decodeConfig).getMessageDirection();
|
||||||
@@ -189,49 +190,46 @@ public class DecoderFactory
|
|||||||
modules.add(new LTRStandardDecoderState(aliasList));
|
modules.add(new LTRStandardDecoderState(aliasList));
|
||||||
modules.add(new FMDemodulatorModule(iqPass, iqStop));
|
modules.add(new FMDemodulatorModule(iqPass, iqStop));
|
||||||
modules.add(new DemodulatedAudioFilterModule(4000, 6000));
|
modules.add(new DemodulatedAudioFilterModule(4000, 6000));
|
||||||
modules.add(new AudioModule(recordAudio));
|
modules.add(new AudioModule(metadata));
|
||||||
break;
|
break;
|
||||||
case LTR_NET:
|
case LTR_NET:
|
||||||
modules.add(new LTRNetDecoder((DecodeConfigLTRNet) decodeConfig, aliasList));
|
modules.add(new LTRNetDecoder((DecodeConfigLTRNet) decodeConfig, aliasList));
|
||||||
modules.add(new LTRNetDecoderState(aliasList));
|
modules.add(new LTRNetDecoderState(aliasList));
|
||||||
modules.add(new FMDemodulatorModule(iqPass, iqStop));
|
modules.add(new FMDemodulatorModule(iqPass, iqStop));
|
||||||
modules.add(new DemodulatedAudioFilterModule(4000, 6000));
|
modules.add(new DemodulatedAudioFilterModule(4000, 6000));
|
||||||
modules.add(new AudioModule(recordAudio));
|
modules.add(new AudioModule(metadata));
|
||||||
break;
|
break;
|
||||||
case MPT1327:
|
case MPT1327:
|
||||||
DecodeConfigMPT1327 mptConfig = (DecodeConfigMPT1327) decodeConfig;
|
DecodeConfigMPT1327 mptConfig = (DecodeConfigMPT1327) decodeConfig;
|
||||||
|
|
||||||
ChannelMap channelMap = channelMapModel
|
ChannelMap channelMap = channelMapModel.getChannelMap(mptConfig.getChannelMapName());
|
||||||
.getChannelMap(mptConfig.getChannelMapName());
|
|
||||||
|
|
||||||
Sync sync = mptConfig.getSync();
|
Sync sync = mptConfig.getSync();
|
||||||
|
|
||||||
modules.add(new MPT1327Decoder(aliasList, sync));
|
modules.add(new MPT1327Decoder(aliasList, sync));
|
||||||
|
|
||||||
|
|
||||||
modules.add(new MPT1327DecoderState(aliasList, channelMap,
|
modules.add(new MPT1327DecoderState(aliasList, channelMap, channelType, mptConfig.getCallTimeout() * 1000));
|
||||||
channelType, mptConfig.getCallTimeout() * 1000));
|
|
||||||
|
|
||||||
if(channelType == ChannelType.STANDARD)
|
if(channelType == ChannelType.STANDARD)
|
||||||
{
|
{
|
||||||
long timeout = mptConfig.getCallTimeout() * 1000; //convert to milliseconds
|
long timeout = mptConfig.getCallTimeout() * 1000; //convert to milliseconds
|
||||||
|
|
||||||
modules.add(new TrafficChannelManager(channelModel, channelProcessingManager,
|
modules.add(new TrafficChannelManager(channelModel, channelProcessingManager, decodeConfig,
|
||||||
decodeConfig, recordConfig, channel.getSystem(),
|
channel.getRecordConfiguration(), channel.getSystem(), channel.getSite(),
|
||||||
channel.getSite(), (aliasList != null ? aliasList.getName() : null), timeout,
|
(aliasList != null ? aliasList.getName() : null), timeout, mptConfig.getTrafficChannelPoolSize()));
|
||||||
mptConfig.getTrafficChannelPoolSize()));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
modules.add(new FMDemodulatorModule(iqPass, iqStop));
|
modules.add(new FMDemodulatorModule(iqPass, iqStop));
|
||||||
modules.add(new DemodulatedAudioFilterModule(4000, 6000));
|
modules.add(new DemodulatedAudioFilterModule(MPT1327_BANDPASS_FILTER, 2.0f));
|
||||||
modules.add(new AudioModule(recordAudio));
|
modules.add(new AudioModule(metadata));
|
||||||
break;
|
break;
|
||||||
case PASSPORT:
|
case PASSPORT:
|
||||||
modules.add(new PassportDecoder(decodeConfig, aliasList));
|
modules.add(new PassportDecoder(decodeConfig, aliasList));
|
||||||
modules.add(new PassportDecoderState(aliasList));
|
modules.add(new PassportDecoderState(aliasList));
|
||||||
modules.add(new FMDemodulatorModule(iqPass, iqStop));
|
modules.add(new FMDemodulatorModule(iqPass, iqStop));
|
||||||
modules.add(new DemodulatedAudioFilterModule(4000, 6000));
|
modules.add(new DemodulatedAudioFilterModule(4000, 6000));
|
||||||
modules.add(new AudioModule(recordAudio));
|
modules.add(new AudioModule(metadata));
|
||||||
break;
|
break;
|
||||||
case P25_PHASE1:
|
case P25_PHASE1:
|
||||||
DecodeConfigP25Phase1 p25Config = (DecodeConfigP25Phase1) decodeConfig;
|
DecodeConfigP25Phase1 p25Config = (DecodeConfigP25Phase1) decodeConfig;
|
||||||
@@ -244,17 +242,15 @@ public class DecoderFactory
|
|||||||
case C4FM:
|
case C4FM:
|
||||||
modules.add(new FMDemodulatorModule(6750, 7500));
|
modules.add(new FMDemodulatorModule(6750, 7500));
|
||||||
modules.add(new P25_C4FMDecoder(aliasList, decodeConfig.getAFCMaximumCorrection()));
|
modules.add(new P25_C4FMDecoder(aliasList, decodeConfig.getAFCMaximumCorrection()));
|
||||||
modules.add(new P25DecoderState(aliasList, channelType,
|
modules.add(new P25DecoderState(aliasList, channelType, Modulation.C4FM,
|
||||||
Modulation.C4FM, p25Config.getIgnoreDataCalls()));
|
p25Config.getIgnoreDataCalls()));
|
||||||
break;
|
break;
|
||||||
case CQPSK:
|
case CQPSK:
|
||||||
modules.add(new P25_LSMDecoder(aliasList));
|
modules.add(new P25_LSMDecoder(aliasList));
|
||||||
modules.add(new P25DecoderState(aliasList, channelType,
|
modules.add(new P25DecoderState(aliasList, channelType, Modulation.CQPSK, p25Config.getIgnoreDataCalls()));
|
||||||
Modulation.CQPSK, p25Config.getIgnoreDataCalls()));
|
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
throw new IllegalArgumentException("Unrecognized P25 "
|
throw new IllegalArgumentException("Unrecognized P25 Phase 1 Modulation [" + modulation + "]");
|
||||||
+ "Phase 1 Modulation [" + modulation + "]");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if(channelType == ChannelType.STANDARD)
|
if(channelType == ChannelType.STANDARD)
|
||||||
@@ -262,19 +258,15 @@ public class DecoderFactory
|
|||||||
//Set call timeout to 3 seconds for P25 traffic channels
|
//Set call timeout to 3 seconds for P25 traffic channels
|
||||||
long timeout = 3000;
|
long timeout = 3000;
|
||||||
|
|
||||||
modules.add(new TrafficChannelManager(channelModel,
|
modules.add(new TrafficChannelManager(channelModel, channelProcessingManager, decodeConfig,
|
||||||
channelProcessingManager, decodeConfig,
|
channel.getRecordConfiguration(), channel.getSystem(), channel.getSite(),
|
||||||
recordConfig, channel.getSystem(), channel.getSite(),
|
(aliasList != null ? aliasList.getName() : null), timeout, p25Config.getTrafficChannelPoolSize()));
|
||||||
(aliasList != null ? aliasList.getName() : null), timeout,
|
|
||||||
p25Config.getTrafficChannelPoolSize()));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
modules.add(new P25AudioModule(recordAudio));
|
modules.add(new P25AudioModule(metadata));
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
throw new IllegalArgumentException(
|
throw new IllegalArgumentException("Unknown decoder type [" + decodeConfig.getDecoderType().toString() + "]");
|
||||||
"Unknown decoder type [" +
|
|
||||||
decodeConfig.getDecoderType().toString() + "]");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return modules;
|
return modules;
|
||||||
@@ -324,39 +316,6 @@ public class DecoderFactory
|
|||||||
return modules;
|
return modules;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static DecoderPanel getDecoderPanel(IconManager iconManager, SettingsManager settingsManager,
|
|
||||||
DecoderState decoderState)
|
|
||||||
{
|
|
||||||
switch(decoderState.getDecoderType())
|
|
||||||
{
|
|
||||||
case AM:
|
|
||||||
return new AMDecoderPanel(iconManager, settingsManager, decoderState);
|
|
||||||
case FLEETSYNC2:
|
|
||||||
return new Fleetsync2DecoderPanel(iconManager, settingsManager, (Fleetsync2DecoderState) decoderState);
|
|
||||||
case LJ_1200:
|
|
||||||
return new LJ1200DecoderPanel(iconManager, settingsManager, (LJ1200DecoderState) decoderState);
|
|
||||||
case LTR_NET:
|
|
||||||
return new LTRNetDecoderPanel(iconManager, settingsManager, (LTRNetDecoderState) decoderState);
|
|
||||||
case LTR_STANDARD:
|
|
||||||
return new LTRStandardDecoderPanel(iconManager, settingsManager, (LTRStandardDecoderState) decoderState);
|
|
||||||
case MDC1200:
|
|
||||||
return new MDCDecoderPanel(iconManager, settingsManager, (MDCDecoderState) decoderState);
|
|
||||||
case MPT1327:
|
|
||||||
return new MPT1327DecoderPanel(iconManager, settingsManager, (MPT1327DecoderState) decoderState);
|
|
||||||
case NBFM:
|
|
||||||
return new NBFMDecoderPanel(iconManager, settingsManager, decoderState);
|
|
||||||
case P25_PHASE1:
|
|
||||||
return new P25DecoderPanel(iconManager, settingsManager, (P25DecoderState) decoderState);
|
|
||||||
case PASSPORT:
|
|
||||||
return new PassportDecoderPanel(iconManager, settingsManager, (PassportDecoderState) decoderState);
|
|
||||||
case TAIT_1200:
|
|
||||||
return new Tait1200DecoderPanel(iconManager, settingsManager, (Tait1200DecoderState) decoderState);
|
|
||||||
default:
|
|
||||||
throw new IllegalArgumentException("Unrecognized decoder: " +
|
|
||||||
decoderState.getDecoderType().getDisplayString());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Assembles a filter set containing filters for the primary channel
|
* Assembles a filter set containing filters for the primary channel
|
||||||
* decoder and each of the auxiliary decoders
|
* decoder and each of the auxiliary decoders
|
||||||
@@ -451,8 +410,7 @@ public class DecoderFactory
|
|||||||
case P25_PHASE1:
|
case P25_PHASE1:
|
||||||
return new DecodeConfigP25Phase1();
|
return new DecodeConfigP25Phase1();
|
||||||
default:
|
default:
|
||||||
throw new IllegalArgumentException("DecodeConfigFactory - unknown decoder type ["
|
throw new IllegalArgumentException("DecodeConfigFactory - unknown decoder type [" + decoder.toString() + "]");
|
||||||
+ decoder.toString() + "]");
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -542,25 +500,10 @@ public class DecoderFactory
|
|||||||
copyPass.setAFCMaximumCorrection(originalPass.getAFCMaximumCorrection());
|
copyPass.setAFCMaximumCorrection(originalPass.getAFCMaximumCorrection());
|
||||||
return copyPass;
|
return copyPass;
|
||||||
default:
|
default:
|
||||||
throw new IllegalArgumentException("Unrecognized decoder "
|
throw new IllegalArgumentException("Unrecognized decoder configuration type:" + config.getDecoderType());
|
||||||
+ "configuration type:" + config.getDecoderType());
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static String getRecordingFilename(String token)
|
|
||||||
{
|
|
||||||
//Get the base recording filename
|
|
||||||
StringBuilder sb = new StringBuilder();
|
|
||||||
sb.append(SystemProperties.getInstance()
|
|
||||||
.getApplicationFolder("recordings"));
|
|
||||||
sb.append(File.separator);
|
|
||||||
sb.append(TimeStamp.getTimeStamp("_"));
|
|
||||||
sb.append("_");
|
|
||||||
sb.append(token);
|
|
||||||
|
|
||||||
return sb.toString();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,84 +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 module.decode.am;
|
|
||||||
|
|
||||||
import icon.IconManager;
|
|
||||||
import module.decode.state.ChangedAttribute;
|
|
||||||
import module.decode.state.DecoderPanel;
|
|
||||||
import module.decode.state.DecoderState;
|
|
||||||
import net.miginfocom.swing.MigLayout;
|
|
||||||
import settings.ColorSetting;
|
|
||||||
import settings.Setting;
|
|
||||||
import settings.SettingsManager;
|
|
||||||
|
|
||||||
import javax.swing.*;
|
|
||||||
|
|
||||||
public class AMDecoderPanel extends DecoderPanel
|
|
||||||
{
|
|
||||||
private static final long serialVersionUID = 1L;
|
|
||||||
|
|
||||||
private JLabel mProtocol = new JLabel("AM");
|
|
||||||
|
|
||||||
public AMDecoderPanel(IconManager iconManager, SettingsManager settingsManager, DecoderState decoderState)
|
|
||||||
{
|
|
||||||
super(iconManager, settingsManager, decoderState);
|
|
||||||
|
|
||||||
init();
|
|
||||||
}
|
|
||||||
|
|
||||||
public void init()
|
|
||||||
{
|
|
||||||
super.init();
|
|
||||||
|
|
||||||
setLayout(new MigLayout("insets 0 0 0 0", "[grow,fill]", "[]0[]0[]"));
|
|
||||||
|
|
||||||
mProtocol.setFont(mFontDecoder);
|
|
||||||
mProtocol.setForeground(mColorLabelDecoder);
|
|
||||||
|
|
||||||
add(mProtocol, "wrap");
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void receive(final ChangedAttribute changedAttribute)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void settingChanged(Setting setting)
|
|
||||||
{
|
|
||||||
super.settingChanged(setting);
|
|
||||||
|
|
||||||
if(setting instanceof ColorSetting)
|
|
||||||
{
|
|
||||||
ColorSetting colorSetting = (ColorSetting) setting;
|
|
||||||
|
|
||||||
switch(colorSetting.getColorSettingName())
|
|
||||||
{
|
|
||||||
case CHANNEL_STATE_LABEL_DECODER:
|
|
||||||
if(mProtocol != null)
|
|
||||||
{
|
|
||||||
mProtocol.setForeground(mColorLabelDecoder);
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,6 +1,6 @@
|
|||||||
/*******************************************************************************
|
/*******************************************************************************
|
||||||
* SDR Trunk
|
* sdrtrunk
|
||||||
* Copyright (C) 2014 Dennis Sheirer
|
* Copyright (C) 2014-2017 Dennis Sheirer
|
||||||
*
|
*
|
||||||
* This program is free software: you can redistribute it and/or modify
|
* 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
|
* it under the terms of the GNU General Public License as published by
|
||||||
@@ -14,16 +14,16 @@
|
|||||||
*
|
*
|
||||||
* You should have received a copy of the GNU General Public License
|
* You should have received a copy of the GNU General Public License
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>
|
* along with this program. If not, see <http://www.gnu.org/licenses/>
|
||||||
|
*
|
||||||
******************************************************************************/
|
******************************************************************************/
|
||||||
package module.decode.event;
|
package module.decode.event;
|
||||||
|
|
||||||
import java.text.SimpleDateFormat;
|
|
||||||
import java.util.Date;
|
|
||||||
|
|
||||||
import module.decode.DecoderType;
|
|
||||||
import alias.Alias;
|
import alias.Alias;
|
||||||
import alias.AliasList;
|
import alias.AliasList;
|
||||||
import audio.metadata.MetadataType;
|
import module.decode.DecoderType;
|
||||||
|
|
||||||
|
import java.text.SimpleDateFormat;
|
||||||
|
import java.util.Date;
|
||||||
|
|
||||||
public abstract class CallEvent implements Comparable<CallEvent>
|
public abstract class CallEvent implements Comparable<CallEvent>
|
||||||
{
|
{
|
||||||
@@ -41,12 +41,8 @@ public abstract class CallEvent implements Comparable<CallEvent>
|
|||||||
|
|
||||||
private boolean mValid = true;
|
private boolean mValid = true;
|
||||||
|
|
||||||
public CallEvent( DecoderType decoder,
|
public CallEvent(DecoderType decoder, CallEventType callEventType, AliasList aliasList, String fromID,
|
||||||
CallEventType callEventType,
|
String toID, String details)
|
||||||
AliasList aliasList,
|
|
||||||
String fromID,
|
|
||||||
String toID,
|
|
||||||
String details )
|
|
||||||
{
|
{
|
||||||
mDecoderType = decoder;
|
mDecoderType = decoder;
|
||||||
mCallEventType = callEventType;
|
mCallEventType = callEventType;
|
||||||
@@ -131,11 +127,6 @@ public abstract class CallEvent implements Comparable<CallEvent>
|
|||||||
return mFromID != null;
|
return mFromID != null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public MetadataType getFromIDType()
|
|
||||||
{
|
|
||||||
return MetadataType.FROM;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setFromID(String id)
|
public void setFromID(String id)
|
||||||
{
|
{
|
||||||
mFromID = id;
|
mFromID = id;
|
||||||
@@ -156,11 +147,6 @@ public abstract class CallEvent implements Comparable<CallEvent>
|
|||||||
mToID = id;
|
mToID = id;
|
||||||
}
|
}
|
||||||
|
|
||||||
public MetadataType getToIDType()
|
|
||||||
{
|
|
||||||
return MetadataType.TO;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getDetails()
|
public String getDetails()
|
||||||
{
|
{
|
||||||
return mDetails;
|
return mDetails;
|
||||||
@@ -181,9 +167,8 @@ public abstract class CallEvent implements Comparable<CallEvent>
|
|||||||
|
|
||||||
public static String getCSVHeader()
|
public static String getCSVHeader()
|
||||||
{
|
{
|
||||||
return "START_DATE,START_TIME,END_DATE,END_TIME,"
|
return "START_DATE,START_TIME,END_DATE,END_TIME,DECODER,EVENT,FROM,FROM_ALIAS,TO,TO_ALIAS,CHANNEL," +
|
||||||
+ "DECODER,EVENT,FROM,FROM_ALIAS,TO,TO_ALIAS,"
|
"FREQUENCY,DETAILS";
|
||||||
+ "CHANNEL,FREQUENCY,DETAILS";
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public String toCSV()
|
public String toCSV()
|
||||||
|
|||||||
@@ -19,10 +19,14 @@
|
|||||||
package module.decode.event;
|
package module.decode.event;
|
||||||
|
|
||||||
import alias.Alias;
|
import alias.Alias;
|
||||||
|
import gui.SDRTrunk;
|
||||||
import icon.IconManager;
|
import icon.IconManager;
|
||||||
|
import org.slf4j.Logger;
|
||||||
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
import javax.swing.*;
|
import javax.swing.*;
|
||||||
import javax.swing.table.DefaultTableCellRenderer;
|
import javax.swing.table.DefaultTableCellRenderer;
|
||||||
|
import java.awt.*;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Custom renderer for JTable cells that contain Alias objects. Renders the
|
* Custom renderer for JTable cells that contain Alias objects. Renders the
|
||||||
@@ -32,6 +36,7 @@ import javax.swing.table.DefaultTableCellRenderer;
|
|||||||
public class CallEventAliasCellRenderer extends DefaultTableCellRenderer
|
public class CallEventAliasCellRenderer extends DefaultTableCellRenderer
|
||||||
{
|
{
|
||||||
private static final long serialVersionUID = 1L;
|
private static final long serialVersionUID = 1L;
|
||||||
|
private final static Logger mLog = LoggerFactory.getLogger(CallEventAliasCellRenderer.class);
|
||||||
|
|
||||||
private IconManager mIconManager;
|
private IconManager mIconManager;
|
||||||
|
|
||||||
@@ -41,35 +46,26 @@ public class CallEventAliasCellRenderer extends DefaultTableCellRenderer
|
|||||||
mIconManager = iconManager;
|
mIconManager = iconManager;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setValue(Object obj)
|
@Override
|
||||||
|
public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column)
|
||||||
{
|
{
|
||||||
if(obj != null && obj instanceof Alias)
|
JLabel label = (JLabel)super.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column);
|
||||||
|
|
||||||
|
if(value instanceof Alias)
|
||||||
{
|
{
|
||||||
Alias alias = (Alias) obj;
|
Alias alias = (Alias)value;
|
||||||
|
|
||||||
setText(alias.getName());
|
label.setText(alias.getName());
|
||||||
|
label.setForeground(alias.getDisplayColor());
|
||||||
ImageIcon icon = getIcon(alias, IconManager.DEFAULT_ICON_SIZE);
|
label.setIcon(mIconManager.getIcon(alias.getIconName(), IconManager.DEFAULT_ICON_SIZE));
|
||||||
|
|
||||||
if(icon != null)
|
|
||||||
{
|
|
||||||
setIcon(icon);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
setText(" ");
|
label.setText("");
|
||||||
setIcon(null);
|
label.setForeground(table.getForeground());
|
||||||
}
|
label.setIcon(null);
|
||||||
}
|
}
|
||||||
|
|
||||||
private ImageIcon getIcon(Alias alias, int height)
|
return label;
|
||||||
{
|
|
||||||
if(mIconManager != null && alias != null)
|
|
||||||
{
|
|
||||||
return mIconManager.getIcon(alias.getIconName(), height);
|
|
||||||
}
|
|
||||||
|
|
||||||
return null;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -17,16 +17,16 @@
|
|||||||
******************************************************************************/
|
******************************************************************************/
|
||||||
package module.decode.event;
|
package module.decode.event;
|
||||||
|
|
||||||
|
import alias.Alias;
|
||||||
|
import module.decode.event.CallEvent.CallEventType;
|
||||||
|
import sample.Listener;
|
||||||
|
|
||||||
|
import javax.swing.table.AbstractTableModel;
|
||||||
import java.text.DecimalFormat;
|
import java.text.DecimalFormat;
|
||||||
import java.text.SimpleDateFormat;
|
import java.text.SimpleDateFormat;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import javax.swing.table.AbstractTableModel;
|
|
||||||
|
|
||||||
import module.decode.event.CallEvent.CallEventType;
|
|
||||||
import sample.Listener;
|
|
||||||
|
|
||||||
public class CallEventModel extends AbstractTableModel implements Listener<CallEvent>
|
public class CallEventModel extends AbstractTableModel implements Listener<CallEvent>
|
||||||
{
|
{
|
||||||
private static final long serialVersionUID = 1L;
|
private static final long serialVersionUID = 1L;
|
||||||
@@ -207,4 +207,15 @@ public class CallEventModel extends AbstractTableModel implements Listener<CallE
|
|||||||
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Class<?> getColumnClass(int columnIndex)
|
||||||
|
{
|
||||||
|
if(columnIndex == FROM_ALIAS || columnIndex == TO_ALIAS)
|
||||||
|
{
|
||||||
|
return Alias.class;
|
||||||
|
}
|
||||||
|
|
||||||
|
return super.getColumnClass(columnIndex);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -18,112 +18,58 @@
|
|||||||
******************************************************************************/
|
******************************************************************************/
|
||||||
package module.decode.event;
|
package module.decode.event;
|
||||||
|
|
||||||
import controller.channel.Channel;
|
|
||||||
import controller.channel.ChannelEvent;
|
|
||||||
import controller.channel.ChannelEvent.Event;
|
|
||||||
import controller.channel.ChannelEventListener;
|
|
||||||
import controller.channel.ChannelProcessingManager;
|
|
||||||
import icon.IconManager;
|
import icon.IconManager;
|
||||||
import module.ProcessingChain;
|
import module.ProcessingChain;
|
||||||
import net.miginfocom.swing.MigLayout;
|
import net.miginfocom.swing.MigLayout;
|
||||||
|
import sample.Listener;
|
||||||
|
|
||||||
import javax.swing.*;
|
import javax.swing.*;
|
||||||
import java.awt.*;
|
import java.awt.*;
|
||||||
|
|
||||||
public class CallEventPanel extends JPanel implements ChannelEventListener
|
public class CallEventPanel extends JPanel implements Listener<ProcessingChain>
|
||||||
{
|
{
|
||||||
private static final long serialVersionUID = 1L;
|
private static final long serialVersionUID = 1L;
|
||||||
|
private JTable mTable;
|
||||||
|
private CallEventModel mEmptyCallEventModel = new CallEventModel();
|
||||||
private JScrollPane mEmptyScroller;
|
private JScrollPane mEmptyScroller;
|
||||||
private Channel mDisplayedChannel;
|
|
||||||
private CallEventAliasCellRenderer mRenderer;
|
private CallEventAliasCellRenderer mRenderer;
|
||||||
private ChannelProcessingManager mChannelProcessingManager;
|
|
||||||
|
|
||||||
public CallEventPanel(IconManager iconManager, ChannelProcessingManager channelProcessingManager)
|
/**
|
||||||
|
* View for call event table
|
||||||
|
* @param iconManager to display alias icons in table rows
|
||||||
|
*/
|
||||||
|
public CallEventPanel(IconManager iconManager)
|
||||||
{
|
{
|
||||||
mChannelProcessingManager = channelProcessingManager;
|
|
||||||
|
|
||||||
setLayout(new MigLayout("insets 0 0 0 0", "[grow,fill]", "[grow,fill]"));
|
setLayout(new MigLayout("insets 0 0 0 0", "[grow,fill]", "[grow,fill]"));
|
||||||
|
|
||||||
JTable table = new JTable(new CallEventModel());
|
mTable = new JTable(mEmptyCallEventModel);
|
||||||
table.setAutoCreateRowSorter(true);
|
mTable.setAutoCreateRowSorter(true);
|
||||||
table.setAutoResizeMode(JTable.AUTO_RESIZE_LAST_COLUMN);
|
mTable.setAutoResizeMode(JTable.AUTO_RESIZE_LAST_COLUMN);
|
||||||
|
|
||||||
mRenderer = new CallEventAliasCellRenderer(iconManager);
|
mRenderer = new CallEventAliasCellRenderer(iconManager);
|
||||||
|
|
||||||
table.getColumnModel().getColumn(CallEventModel.FROM_ALIAS).setCellRenderer(mRenderer);
|
|
||||||
|
|
||||||
table.getColumnModel().getColumn(CallEventModel.TO_ALIAS).setCellRenderer(mRenderer);
|
mEmptyScroller = new JScrollPane(mTable);
|
||||||
|
|
||||||
mEmptyScroller = new JScrollPane(table);
|
|
||||||
|
|
||||||
add(mEmptyScroller);
|
add(mEmptyScroller);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void channelChanged(final ChannelEvent event)
|
public void receive(ProcessingChain processingChain)
|
||||||
{
|
|
||||||
if(event.getEvent() == Event.NOTIFICATION_SELECTION_CHANGE && event.getChannel().isSelected())
|
|
||||||
{
|
|
||||||
if(mDisplayedChannel == null || (mDisplayedChannel != null && mDisplayedChannel != event.getChannel()))
|
|
||||||
{
|
|
||||||
ProcessingChain chain = mChannelProcessingManager.getProcessingChain(event.getChannel());
|
|
||||||
|
|
||||||
if(chain != null)
|
|
||||||
{
|
|
||||||
final CallEventModel model = chain.getCallEventModel();
|
|
||||||
|
|
||||||
if(model != null)
|
|
||||||
{
|
{
|
||||||
EventQueue.invokeLater(new Runnable()
|
EventQueue.invokeLater(new Runnable()
|
||||||
{
|
{
|
||||||
@Override
|
@Override
|
||||||
public void run()
|
public void run()
|
||||||
{
|
{
|
||||||
removeAll();
|
mTable.setModel(processingChain != null ? processingChain.getCallEventModel() : mEmptyCallEventModel);
|
||||||
|
|
||||||
JTable table = new JTable(model);
|
if(processingChain != null)
|
||||||
|
{
|
||||||
table.setAutoCreateRowSorter(true);
|
mTable.getColumnModel().getColumn(CallEventModel.FROM_ALIAS).setCellRenderer(mRenderer);
|
||||||
table.setAutoResizeMode(JTable.AUTO_RESIZE_LAST_COLUMN);
|
mTable.getColumnModel().getColumn(CallEventModel.TO_ALIAS).setCellRenderer(mRenderer);
|
||||||
|
}
|
||||||
table.getColumnModel().getColumn(CallEventModel.FROM_ALIAS)
|
|
||||||
.setCellRenderer(mRenderer);
|
|
||||||
|
|
||||||
table.getColumnModel().getColumn(CallEventModel.TO_ALIAS)
|
|
||||||
.setCellRenderer(mRenderer);
|
|
||||||
|
|
||||||
add(new JScrollPane(table));
|
|
||||||
|
|
||||||
mDisplayedChannel = event.getChannel();
|
|
||||||
|
|
||||||
revalidate();
|
|
||||||
repaint();
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
|
||||||
else if(event.getEvent() == Event.NOTIFICATION_PROCESSING_STOP || event.getEvent() == Event.REQUEST_DISABLE)
|
|
||||||
{
|
|
||||||
if(mDisplayedChannel != null && mDisplayedChannel == event.getChannel())
|
|
||||||
{
|
|
||||||
mDisplayedChannel = null;
|
|
||||||
|
|
||||||
EventQueue.invokeLater(new Runnable()
|
|
||||||
{
|
|
||||||
@Override
|
|
||||||
public void run()
|
|
||||||
{
|
|
||||||
removeAll();
|
|
||||||
add(mEmptyScroller);
|
|
||||||
|
|
||||||
revalidate();
|
|
||||||
repaint();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
/*******************************************************************************
|
/*******************************************************************************
|
||||||
* SDR Trunk
|
* sdrtrunk
|
||||||
* Copyright (C) 2014-2016 Dennis Sheirer
|
* Copyright (C) 2014-2017 Dennis Sheirer
|
||||||
*
|
*
|
||||||
* This program is free software: you can redistribute it and/or modify
|
* 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
|
* it under the terms of the GNU General Public License as published by
|
||||||
@@ -14,37 +14,12 @@
|
|||||||
*
|
*
|
||||||
* You should have received a copy of the GNU General Public License
|
* You should have received a copy of the GNU General Public License
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>
|
* along with this program. If not, see <http://www.gnu.org/licenses/>
|
||||||
|
*
|
||||||
******************************************************************************/
|
******************************************************************************/
|
||||||
package module.decode.event;
|
package module.decode.event;
|
||||||
|
|
||||||
import java.awt.EventQueue;
|
|
||||||
import java.awt.event.ActionEvent;
|
|
||||||
import java.awt.event.ActionListener;
|
|
||||||
import java.awt.event.MouseEvent;
|
|
||||||
import java.awt.event.MouseListener;
|
|
||||||
|
|
||||||
import javax.swing.JButton;
|
|
||||||
import javax.swing.JFrame;
|
|
||||||
import javax.swing.JLabel;
|
|
||||||
import javax.swing.JOptionPane;
|
|
||||||
import javax.swing.JPanel;
|
|
||||||
import javax.swing.JScrollPane;
|
|
||||||
import javax.swing.JSlider;
|
|
||||||
import javax.swing.JTable;
|
|
||||||
import javax.swing.SwingUtilities;
|
|
||||||
import javax.swing.event.ChangeEvent;
|
|
||||||
import javax.swing.event.ChangeListener;
|
|
||||||
|
|
||||||
import message.Message;
|
|
||||||
import module.ProcessingChain;
|
|
||||||
import net.miginfocom.swing.MigLayout;
|
|
||||||
|
|
||||||
import org.slf4j.Logger;
|
|
||||||
import org.slf4j.LoggerFactory;
|
|
||||||
|
|
||||||
import com.jidesoft.swing.JideButton;
|
import com.jidesoft.swing.JideButton;
|
||||||
import com.jidesoft.swing.JideSplitButton;
|
import com.jidesoft.swing.JideSplitButton;
|
||||||
|
|
||||||
import controller.channel.Channel;
|
import controller.channel.Channel;
|
||||||
import controller.channel.ChannelEvent;
|
import controller.channel.ChannelEvent;
|
||||||
import controller.channel.ChannelEvent.Event;
|
import controller.channel.ChannelEvent.Event;
|
||||||
@@ -52,20 +27,31 @@ import controller.channel.ChannelEventListener;
|
|||||||
import controller.channel.ChannelProcessingManager;
|
import controller.channel.ChannelProcessingManager;
|
||||||
import filter.FilterEditorPanel;
|
import filter.FilterEditorPanel;
|
||||||
import filter.FilterSet;
|
import filter.FilterSet;
|
||||||
|
import message.Message;
|
||||||
|
import module.ProcessingChain;
|
||||||
|
import net.miginfocom.swing.MigLayout;
|
||||||
|
import org.slf4j.Logger;
|
||||||
|
import org.slf4j.LoggerFactory;
|
||||||
|
import sample.Listener;
|
||||||
|
|
||||||
public class MessageActivityPanel extends JPanel implements ChannelEventListener
|
import javax.swing.*;
|
||||||
|
import javax.swing.event.ChangeEvent;
|
||||||
|
import javax.swing.event.ChangeListener;
|
||||||
|
import java.awt.*;
|
||||||
|
import java.awt.event.ActionEvent;
|
||||||
|
import java.awt.event.ActionListener;
|
||||||
|
import java.awt.event.MouseEvent;
|
||||||
|
import java.awt.event.MouseListener;
|
||||||
|
|
||||||
|
public class MessageActivityPanel extends JPanel implements Listener<ProcessingChain>
|
||||||
{
|
{
|
||||||
private static final long serialVersionUID = 1L;
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
private final static Logger mLog =
|
private final static Logger mLog = LoggerFactory.getLogger(MessageActivityPanel.class);
|
||||||
LoggerFactory.getLogger( MessageActivityPanel.class );
|
|
||||||
|
|
||||||
private static MessageActivityModel EMPTY_MODEL = new MessageActivityModel();
|
private static MessageActivityModel EMPTY_MODEL = new MessageActivityModel();
|
||||||
|
|
||||||
private JTable mMessageTable;
|
private JTable mTable = new JTable(EMPTY_MODEL);
|
||||||
|
|
||||||
private Channel mDisplayedChannel;
|
|
||||||
private MessageActivityModel mDisplayedModel = EMPTY_MODEL;
|
|
||||||
|
|
||||||
private MessageManagementPanel mManagementPanel = new MessageManagementPanel();
|
private MessageManagementPanel mManagementPanel = new MessageManagementPanel();
|
||||||
|
|
||||||
@@ -79,73 +65,88 @@ public class MessageActivityPanel extends JPanel implements ChannelEventListener
|
|||||||
|
|
||||||
add(mManagementPanel, "span,growx");
|
add(mManagementPanel, "span,growx");
|
||||||
|
|
||||||
mMessageTable = new JTable( mDisplayedModel );
|
add(new JScrollPane(mTable), "span,grow");
|
||||||
|
|
||||||
add( new JScrollPane( mMessageTable ), "span,grow" );
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void channelChanged( ChannelEvent event )
|
public void receive(ProcessingChain processingChain)
|
||||||
{
|
{
|
||||||
boolean changed = false;
|
EventQueue.invokeLater(new Runnable()
|
||||||
|
{
|
||||||
|
@Override
|
||||||
|
public void run()
|
||||||
|
{
|
||||||
|
mTable.setModel(processingChain != null ? processingChain.getMessageActivityModel() : EMPTY_MODEL);
|
||||||
|
|
||||||
if( event.getEvent() == Event.NOTIFICATION_SELECTION_CHANGE &&
|
if(processingChain != null)
|
||||||
event.getChannel().isSelected() )
|
|
||||||
{
|
{
|
||||||
if( mDisplayedChannel == null ||
|
mManagementPanel.enableButtons();
|
||||||
( mDisplayedChannel != null &&
|
|
||||||
mDisplayedChannel != event.getChannel() ) )
|
|
||||||
{
|
|
||||||
mDisplayedChannel = event.getChannel();
|
|
||||||
|
|
||||||
ProcessingChain chain = mChannelProcessingManager
|
|
||||||
.getProcessingChain( mDisplayedChannel );
|
|
||||||
|
|
||||||
if( chain != null )
|
|
||||||
{
|
|
||||||
mDisplayedModel = chain.getMessageActivityModel();
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
mDisplayedModel = EMPTY_MODEL;
|
mManagementPanel.disableButtons();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
mMessageTable.setModel( mDisplayedModel );
|
// @Override
|
||||||
|
// public void channelChanged(ChannelEvent event)
|
||||||
if( mDisplayedChannel != null )
|
// {
|
||||||
{
|
// boolean changed = false;
|
||||||
mManagementPanel.enable();
|
//
|
||||||
}
|
// if(event.getEvent() == Event.NOTIFICATION_SELECTION_CHANGE &&
|
||||||
else
|
// event.getChannel().isSelected())
|
||||||
{
|
// {
|
||||||
mManagementPanel.disable();
|
// if(mDisplayedChannel == null || (mDisplayedChannel != null && mDisplayedChannel != event.getChannel()))
|
||||||
}
|
// {
|
||||||
|
// mDisplayedChannel = event.getChannel();
|
||||||
changed = true;
|
//
|
||||||
}
|
// ProcessingChain chain = mChannelProcessingManager.getProcessingChain(mDisplayedChannel);
|
||||||
}
|
//
|
||||||
else if( event.getEvent() == Event.NOTIFICATION_PROCESSING_STOP ||
|
// if(chain != null)
|
||||||
event.getEvent() == Event.REQUEST_DISABLE )
|
// {
|
||||||
{
|
// mDisplayedModel = chain.getMessageActivityModel();
|
||||||
if( mDisplayedChannel != null &&
|
// }
|
||||||
mDisplayedChannel == event.getChannel() )
|
// else
|
||||||
{
|
// {
|
||||||
mDisplayedChannel = null;
|
// mDisplayedModel = EMPTY_MODEL;
|
||||||
|
// }
|
||||||
mMessageTable.setModel( EMPTY_MODEL );
|
//
|
||||||
|
// mMessageTable.setModel(mDisplayedModel);
|
||||||
mManagementPanel.disable();
|
//
|
||||||
|
// if(mDisplayedChannel != null)
|
||||||
changed = true;
|
// {
|
||||||
}
|
// mManagementPanel.enableButtons();
|
||||||
}
|
// }
|
||||||
|
// else
|
||||||
if( changed )
|
// {
|
||||||
{
|
// mManagementPanel.disableButtons();
|
||||||
revalidate();
|
// }
|
||||||
repaint();
|
//
|
||||||
}
|
// changed = true;
|
||||||
}
|
// }
|
||||||
|
// }
|
||||||
|
// else if(event.getEvent() == Event.NOTIFICATION_PROCESSING_STOP || event.getEvent() == Event.REQUEST_DISABLE)
|
||||||
|
// {
|
||||||
|
// if(mDisplayedChannel != null && mDisplayedChannel == event.getChannel())
|
||||||
|
// {
|
||||||
|
// mDisplayedChannel = null;
|
||||||
|
//
|
||||||
|
// mMessageTable.setModel(EMPTY_MODEL);
|
||||||
|
//
|
||||||
|
// mManagementPanel.disableButtons();
|
||||||
|
//
|
||||||
|
// changed = true;
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// if(changed)
|
||||||
|
// {
|
||||||
|
// revalidate();
|
||||||
|
// repaint();
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
|
||||||
public class MessageManagementPanel extends JPanel
|
public class MessageManagementPanel extends JPanel
|
||||||
{
|
{
|
||||||
@@ -158,19 +159,19 @@ public class MessageActivityPanel extends JPanel implements ChannelEventListener
|
|||||||
{
|
{
|
||||||
setLayout(new MigLayout("insets 2 2 5 5", "[]5[left,grow]", ""));
|
setLayout(new MigLayout("insets 2 2 5 5", "[]5[left,grow]", ""));
|
||||||
|
|
||||||
disable();
|
disableButtons();
|
||||||
|
|
||||||
add(mFilterButton);
|
add(mFilterButton);
|
||||||
add(mHistoryButton);
|
add(mHistoryButton);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void enable()
|
public void enableButtons()
|
||||||
{
|
{
|
||||||
mHistoryButton.setEnabled(true);
|
mHistoryButton.setEnabled(true);
|
||||||
mFilterButton.setEnabled(true);
|
mFilterButton.setEnabled(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void disable()
|
public void disableButtons()
|
||||||
{
|
{
|
||||||
mHistoryButton.setEnabled(false);
|
mHistoryButton.setEnabled(false);
|
||||||
mFilterButton.setEnabled(false);
|
mFilterButton.setEnabled(false);
|
||||||
@@ -201,37 +202,36 @@ public class MessageActivityPanel extends JPanel implements ChannelEventListener
|
|||||||
@Override
|
@Override
|
||||||
public void mouseClicked(MouseEvent arg0)
|
public void mouseClicked(MouseEvent arg0)
|
||||||
{
|
{
|
||||||
if( SwingUtilities.isLeftMouseButton( arg0 ) &&
|
if(SwingUtilities.isLeftMouseButton(arg0) && arg0.getClickCount() == 2)
|
||||||
arg0.getClickCount() == 2 )
|
|
||||||
{
|
{
|
||||||
slider.setValue(500); //default
|
slider.setValue(500); //default
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void mouseEntered( MouseEvent arg0 ) {}
|
public void mouseEntered(MouseEvent arg0)
|
||||||
public void mouseExited( MouseEvent arg0 ) {}
|
{
|
||||||
public void mousePressed( MouseEvent arg0 ) {}
|
}
|
||||||
public void mouseReleased( MouseEvent arg0 ) {}
|
|
||||||
|
public void mouseExited(MouseEvent arg0)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
public void mousePressed(MouseEvent arg0)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
public void mouseReleased(MouseEvent arg0)
|
||||||
|
{
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
if( mDisplayedModel != null )
|
slider.setValue(((MessageActivityModel)mTable.getModel()).getMaxMessageCount());
|
||||||
{
|
|
||||||
slider.setValue( mDisplayedModel.getMaxMessageCount() );
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
slider.setValue( 500 );
|
|
||||||
}
|
|
||||||
|
|
||||||
slider.addChangeListener(new ChangeListener()
|
slider.addChangeListener(new ChangeListener()
|
||||||
{
|
{
|
||||||
@Override
|
@Override
|
||||||
public void stateChanged(ChangeEvent arg0)
|
public void stateChanged(ChangeEvent arg0)
|
||||||
{
|
{
|
||||||
if( mDisplayedModel != null )
|
((MessageActivityModel)mTable.getModel()).setMaxMessageCount(slider.getValue());
|
||||||
{
|
|
||||||
mDisplayedModel.setMaxMessageCount( slider.getValue() );
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -245,10 +245,7 @@ public class MessageActivityPanel extends JPanel implements ChannelEventListener
|
|||||||
@Override
|
@Override
|
||||||
public void actionPerformed(ActionEvent e)
|
public void actionPerformed(ActionEvent e)
|
||||||
{
|
{
|
||||||
if( mDisplayedModel != null )
|
((MessageActivityModel)mTable.getModel()).clear();
|
||||||
{
|
|
||||||
mDisplayedModel.clear();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@@ -266,16 +263,6 @@ public class MessageActivityPanel extends JPanel implements ChannelEventListener
|
|||||||
{
|
{
|
||||||
@Override
|
@Override
|
||||||
public void actionPerformed(ActionEvent arg0)
|
public void actionPerformed(ActionEvent arg0)
|
||||||
{
|
|
||||||
if( mDisplayedChannel == null )
|
|
||||||
{
|
|
||||||
JOptionPane.showMessageDialog( MessageFilterButton.this,
|
|
||||||
"Please enable and select a decoding channel to "
|
|
||||||
+ "adjust the channel's message display filter" );
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
if( mDisplayedModel != null )
|
|
||||||
{
|
{
|
||||||
final JFrame editor = new JFrame();
|
final JFrame editor = new JFrame();
|
||||||
|
|
||||||
@@ -287,19 +274,16 @@ public class MessageActivityPanel extends JPanel implements ChannelEventListener
|
|||||||
"[grow,fill][][]"));
|
"[grow,fill][][]"));
|
||||||
|
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
FilterSet<Message> filter = (FilterSet<Message>)
|
FilterSet<Message> filter = (FilterSet<Message>) ((MessageActivityModel)mTable.getModel()).getMessageFilter();
|
||||||
mDisplayedModel.getMessageFilter();
|
|
||||||
|
|
||||||
FilterEditorPanel<Message> panel =
|
FilterEditorPanel<Message> panel = new FilterEditorPanel<Message>(filter);
|
||||||
new FilterEditorPanel<Message>( filter );
|
|
||||||
|
|
||||||
JScrollPane scroller = new JScrollPane(panel);
|
JScrollPane scroller = new JScrollPane(panel);
|
||||||
scroller.setViewportView(panel);
|
scroller.setViewportView(panel);
|
||||||
|
|
||||||
editor.add(scroller, "wrap");
|
editor.add(scroller, "wrap");
|
||||||
|
|
||||||
editor.add( new JLabel( "Right-click to select/deselect "
|
editor.add(new JLabel("Right-click to select/deselect all nodes"), "wrap");
|
||||||
+ "all nodes" ), "wrap" );
|
|
||||||
|
|
||||||
JButton close = new JButton("Close");
|
JButton close = new JButton("Close");
|
||||||
close.addActionListener(new ActionListener()
|
close.addActionListener(new ActionListener()
|
||||||
@@ -321,8 +305,6 @@ public class MessageActivityPanel extends JPanel implements ChannelEventListener
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,201 +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 module.decode.fleetsync2;
|
|
||||||
|
|
||||||
import icon.IconManager;
|
|
||||||
import module.decode.state.ChangedAttribute;
|
|
||||||
import module.decode.state.DecoderPanel;
|
|
||||||
import net.miginfocom.swing.MigLayout;
|
|
||||||
import org.slf4j.Logger;
|
|
||||||
import org.slf4j.LoggerFactory;
|
|
||||||
import settings.ColorSetting;
|
|
||||||
import settings.ColorSetting.ColorSettingName;
|
|
||||||
import settings.Setting;
|
|
||||||
import settings.SettingsManager;
|
|
||||||
|
|
||||||
import javax.swing.*;
|
|
||||||
import java.awt.*;
|
|
||||||
|
|
||||||
public class Fleetsync2DecoderPanel extends DecoderPanel
|
|
||||||
{
|
|
||||||
private final static Logger mLog = LoggerFactory.getLogger(Fleetsync2DecoderPanel.class);
|
|
||||||
|
|
||||||
private static final long serialVersionUID = 1L;
|
|
||||||
private static final String PROTOCOL = "FSync II";
|
|
||||||
|
|
||||||
private JLabel mToLabel = new JLabel(" ");
|
|
||||||
private JLabel mTo = new JLabel(" ");
|
|
||||||
private JLabel mToAlias = new JLabel(" ");
|
|
||||||
|
|
||||||
private JLabel mFromLabel = new JLabel(" ");
|
|
||||||
private JLabel mFrom = new JLabel(" ");
|
|
||||||
private JLabel mFromAlias = new JLabel(" ");
|
|
||||||
|
|
||||||
private JLabel mProtocol = new JLabel(PROTOCOL);
|
|
||||||
private JLabel mMessage = new JLabel(" ");
|
|
||||||
private JLabel mMessageType = new JLabel(" ");
|
|
||||||
|
|
||||||
public Fleetsync2DecoderPanel(IconManager iconManager, SettingsManager settingsManager,
|
|
||||||
Fleetsync2DecoderState decoderState)
|
|
||||||
{
|
|
||||||
super(iconManager, settingsManager, decoderState);
|
|
||||||
|
|
||||||
init();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Fleetsync2DecoderState getDecoderState()
|
|
||||||
{
|
|
||||||
return (Fleetsync2DecoderState) super.getDecoderState();
|
|
||||||
}
|
|
||||||
|
|
||||||
public void dispose()
|
|
||||||
{
|
|
||||||
super.dispose();
|
|
||||||
}
|
|
||||||
|
|
||||||
protected void init()
|
|
||||||
{
|
|
||||||
/* Calling super init will get and broadcast color settings to properly
|
|
||||||
* setup the jlabel colors */
|
|
||||||
super.init();
|
|
||||||
|
|
||||||
setLayout(new MigLayout("insets 1 0 0 0", "[grow,fill]", "[]0[]0[]"));
|
|
||||||
|
|
||||||
mToLabel.setFont(mFontAuxDecoder);
|
|
||||||
mToLabel.setForeground(mColorLabelAuxDecoder);
|
|
||||||
add(mToLabel);
|
|
||||||
|
|
||||||
mTo.setFont(mFontAuxDecoder);
|
|
||||||
mTo.setForeground(mColorLabelAuxDecoder);
|
|
||||||
add(mTo);
|
|
||||||
|
|
||||||
mToAlias.setFont(mFontAuxDecoder);
|
|
||||||
mToAlias.setForeground(mColorLabelAuxDecoder);
|
|
||||||
add(mToAlias, "wrap");
|
|
||||||
|
|
||||||
mFromLabel.setFont(mFontAuxDecoder);
|
|
||||||
mFromLabel.setForeground(mColorLabelAuxDecoder);
|
|
||||||
add(mFromLabel);
|
|
||||||
|
|
||||||
mFrom.setFont(mFontAuxDecoder);
|
|
||||||
mFrom.setForeground(mColorLabelAuxDecoder);
|
|
||||||
add(mFrom);
|
|
||||||
|
|
||||||
mFromAlias.setFont(mFontAuxDecoder);
|
|
||||||
mFromAlias.setForeground(mColorLabelAuxDecoder);
|
|
||||||
add(mFromAlias, "wrap");
|
|
||||||
|
|
||||||
mProtocol.setFont(mFontAuxDecoder);
|
|
||||||
mProtocol.setForeground(mColorLabelAuxDecoder);
|
|
||||||
add(mProtocol);
|
|
||||||
|
|
||||||
mMessageType.setFont(mFontAuxDecoder);
|
|
||||||
mMessageType.setForeground(mColorLabelAuxDecoder);
|
|
||||||
add(mMessageType);
|
|
||||||
|
|
||||||
mMessage.setFont(mFontAuxDecoder);
|
|
||||||
mMessage.setForeground(mColorLabelAuxDecoder);
|
|
||||||
add(mMessage, "wrap");
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void receive(final ChangedAttribute changedAttribute)
|
|
||||||
{
|
|
||||||
EventQueue.invokeLater(new Runnable()
|
|
||||||
{
|
|
||||||
@Override
|
|
||||||
public void run()
|
|
||||||
{
|
|
||||||
switch(changedAttribute)
|
|
||||||
{
|
|
||||||
case FROM_TALKGROUP:
|
|
||||||
String from = getDecoderState().getFromID();
|
|
||||||
|
|
||||||
if(from != null)
|
|
||||||
{
|
|
||||||
mFromLabel.setText("FROM:");
|
|
||||||
mFrom.setText(from);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
mFromLabel.setText(" ");
|
|
||||||
mFrom.setText(" ");
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case FROM_TALKGROUP_ALIAS:
|
|
||||||
setAliasLabel(mFromAlias, getDecoderState().getFromIDAlias());
|
|
||||||
break;
|
|
||||||
case MESSAGE:
|
|
||||||
mMessage.setText(getDecoderState().getMessage());
|
|
||||||
break;
|
|
||||||
case MESSAGE_TYPE:
|
|
||||||
mMessageType.setText(getDecoderState().getMessageType());
|
|
||||||
break;
|
|
||||||
case TO_TALKGROUP:
|
|
||||||
String to = getDecoderState().getToID();
|
|
||||||
|
|
||||||
if(to != null)
|
|
||||||
{
|
|
||||||
mToLabel.setText("TO:");
|
|
||||||
mTo.setText(to);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
mToLabel.setText(" ");
|
|
||||||
mTo.setText(" ");
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case TO_TALKGROUP_ALIAS:
|
|
||||||
setAliasLabel(mToAlias, getDecoderState().getToIDAlias());
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
repaint();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void settingChanged(Setting setting)
|
|
||||||
{
|
|
||||||
super.settingChanged(setting);
|
|
||||||
|
|
||||||
if(setting instanceof ColorSetting)
|
|
||||||
{
|
|
||||||
ColorSetting color = (ColorSetting) setting;
|
|
||||||
|
|
||||||
if(color.getColorSettingName() ==
|
|
||||||
ColorSettingName.CHANNEL_STATE_LABEL_AUX_DECODER)
|
|
||||||
{
|
|
||||||
mFromLabel.setForeground(color.getColor());
|
|
||||||
mFrom.setForeground(color.getColor());
|
|
||||||
mFromAlias.setForeground(color.getColor());
|
|
||||||
mToLabel.setForeground(color.getColor());
|
|
||||||
mTo.setForeground(color.getColor());
|
|
||||||
mToAlias.setForeground(color.getColor());
|
|
||||||
mProtocol.setForeground(color.getColor());
|
|
||||||
mMessageType.setForeground(color.getColor());
|
|
||||||
mMessage.setForeground(color.getColor());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,6 +1,6 @@
|
|||||||
/*******************************************************************************
|
/*******************************************************************************
|
||||||
* SDR Trunk
|
* sdrtrunk
|
||||||
* Copyright (C) 2014,2015 Dennis Sheirer
|
* Copyright (C) 2014-2017 Dennis Sheirer
|
||||||
*
|
*
|
||||||
* This program is free software: you can redistribute it and/or modify
|
* 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
|
* it under the terms of the GNU General Public License as published by
|
||||||
@@ -14,42 +14,47 @@
|
|||||||
*
|
*
|
||||||
* You should have received a copy of the GNU General Public License
|
* You should have received a copy of the GNU General Public License
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>
|
* along with this program. If not, see <http://www.gnu.org/licenses/>
|
||||||
|
*
|
||||||
******************************************************************************/
|
******************************************************************************/
|
||||||
package module.decode.fleetsync2;
|
package module.decode.fleetsync2;
|
||||||
|
|
||||||
|
import alias.Alias;
|
||||||
|
import alias.AliasList;
|
||||||
|
import alias.id.AliasIDType;
|
||||||
|
import channel.metadata.AliasedStringAttributeMonitor;
|
||||||
|
import channel.metadata.Attribute;
|
||||||
|
import channel.metadata.AttributeChangeRequest;
|
||||||
|
import channel.state.DecoderState;
|
||||||
|
import channel.state.DecoderStateEvent;
|
||||||
|
import channel.state.DecoderStateEvent.Event;
|
||||||
|
import channel.state.State;
|
||||||
|
import message.Message;
|
||||||
|
import module.decode.DecoderType;
|
||||||
|
import util.StringUtils;
|
||||||
|
|
||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
import java.util.TreeSet;
|
import java.util.TreeSet;
|
||||||
import java.util.concurrent.ScheduledExecutorService;
|
import java.util.concurrent.ScheduledExecutorService;
|
||||||
|
|
||||||
import message.Message;
|
|
||||||
import module.decode.DecoderType;
|
|
||||||
import module.decode.state.ChangedAttribute;
|
|
||||||
import module.decode.state.DecoderState;
|
|
||||||
import module.decode.state.DecoderStateEvent;
|
|
||||||
import module.decode.state.DecoderStateEvent.Event;
|
|
||||||
import module.decode.state.State;
|
|
||||||
import alias.Alias;
|
|
||||||
import alias.AliasList;
|
|
||||||
|
|
||||||
public class Fleetsync2DecoderState extends DecoderState
|
public class Fleetsync2DecoderState extends DecoderState
|
||||||
{
|
{
|
||||||
private TreeSet<String> mIdents = new TreeSet<String>();
|
private TreeSet<String> mIdents = new TreeSet<String>();
|
||||||
private TreeSet<String> mEmergencyIdents = new TreeSet<String>();
|
private TreeSet<String> mEmergencyIdents = new TreeSet<String>();
|
||||||
|
|
||||||
private String mFrom;
|
private AliasedStringAttributeMonitor mFromAttribute;
|
||||||
private Alias mFromAlias;
|
private AliasedStringAttributeMonitor mToAttribute;
|
||||||
|
|
||||||
private String mTo;
|
|
||||||
private Alias mToAlias;
|
|
||||||
|
|
||||||
private String mMessage;
|
private String mMessage;
|
||||||
private String mMessageType;
|
private String mMessageType;
|
||||||
|
|
||||||
private long mFrequency;
|
private long mFrequency;
|
||||||
|
|
||||||
public Fleetsync2DecoderState(AliasList aliasList)
|
public Fleetsync2DecoderState(AliasList aliasList)
|
||||||
{
|
{
|
||||||
super(aliasList);
|
super(aliasList);
|
||||||
|
|
||||||
|
mFromAttribute = new AliasedStringAttributeMonitor(Attribute.SECONDARY_ADDRESS_FROM,
|
||||||
|
getAttributeChangeRequestListener(), getAliasList(), AliasIDType.FLEETSYNC);
|
||||||
|
mToAttribute = new AliasedStringAttributeMonitor(Attribute.SECONDARY_ADDRESS_TO,
|
||||||
|
getAttributeChangeRequestListener(), getAliasList(), AliasIDType.FLEETSYNC);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -96,12 +101,10 @@ public class Fleetsync2DecoderState extends DecoderState
|
|||||||
*/
|
*/
|
||||||
public void resetState()
|
public void resetState()
|
||||||
{
|
{
|
||||||
setFromID( null );
|
mFromAttribute.reset();
|
||||||
setFromIDAlias( null );
|
mToAttribute.reset();
|
||||||
setToID( null );
|
mMessage = null;
|
||||||
setToIDAlias( null );
|
mMessageType = null;
|
||||||
setMessage( null );
|
|
||||||
setMessageType( null );
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -115,16 +118,14 @@ public class Fleetsync2DecoderState extends DecoderState
|
|||||||
{
|
{
|
||||||
State state = State.CALL;
|
State state = State.CALL;
|
||||||
|
|
||||||
setFromID( fleetsync.getFromID() );
|
mFromAttribute.process(fleetsync.getFromID());
|
||||||
setFromIDAlias( fleetsync.getFromIDAlias() );
|
|
||||||
mIdents.add(fleetsync.getFromID());
|
mIdents.add(fleetsync.getFromID());
|
||||||
|
|
||||||
FleetsyncMessageType type = fleetsync.getMessageType();
|
FleetsyncMessageType type = fleetsync.getMessageType();
|
||||||
|
|
||||||
if(type != FleetsyncMessageType.ANI)
|
if(type != FleetsyncMessageType.ANI)
|
||||||
{
|
{
|
||||||
setToID( fleetsync.getToID() );
|
mToAttribute.process(fleetsync.getToID());
|
||||||
setToIDAlias( fleetsync.getToIDAlias() );
|
|
||||||
mIdents.add(fleetsync.getToID());
|
mIdents.add(fleetsync.getToID());
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -174,70 +175,32 @@ public class Fleetsync2DecoderState extends DecoderState
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getFromID()
|
|
||||||
{
|
|
||||||
return mFrom;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setFromID( String from )
|
|
||||||
{
|
|
||||||
mFrom = from;
|
|
||||||
broadcast( ChangedAttribute.FROM_TALKGROUP );
|
|
||||||
}
|
|
||||||
|
|
||||||
public Alias getFromIDAlias()
|
|
||||||
{
|
|
||||||
return mFromAlias;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setFromIDAlias( Alias alias )
|
|
||||||
{
|
|
||||||
mFromAlias = alias;
|
|
||||||
broadcast( ChangedAttribute.FROM_TALKGROUP_ALIAS );
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getToID()
|
|
||||||
{
|
|
||||||
return mTo;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setToID( String to )
|
|
||||||
{
|
|
||||||
mTo = to;
|
|
||||||
broadcast( ChangedAttribute.TO_TALKGROUP );
|
|
||||||
}
|
|
||||||
|
|
||||||
public Alias getToIDAlias()
|
|
||||||
{
|
|
||||||
return mToAlias;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setToIDAlias( Alias alias )
|
|
||||||
{
|
|
||||||
mToAlias = alias;
|
|
||||||
broadcast( ChangedAttribute.TO_TALKGROUP_ALIAS );
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getMessage()
|
public String getMessage()
|
||||||
{
|
{
|
||||||
return mMessage;
|
return mMessage;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setMessage(String message)
|
public void setMessage(String message)
|
||||||
|
{
|
||||||
|
if(!StringUtils.isEqual(mMessage, message))
|
||||||
{
|
{
|
||||||
mMessage = message;
|
mMessage = message;
|
||||||
broadcast( ChangedAttribute.MESSAGE );
|
broadcast(new AttributeChangeRequest<String>(Attribute.MESSAGE, mMessage));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getMessageType()
|
public String getMessageType()
|
||||||
{
|
{
|
||||||
return mMessageType;
|
return "Fleetsync " + mMessageType;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setMessageType(String type)
|
public void setMessageType(String type)
|
||||||
|
{
|
||||||
|
if(!StringUtils.isEqual(mMessageType, type))
|
||||||
{
|
{
|
||||||
mMessageType = type;
|
mMessageType = type;
|
||||||
broadcast( ChangedAttribute.MESSAGE_TYPE );
|
broadcast(new AttributeChangeRequest<String>(Attribute.MESSAGE_TYPE, getMessageType()));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -1,127 +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 module.decode.lj1200;
|
|
||||||
|
|
||||||
import alias.Alias;
|
|
||||||
import icon.IconManager;
|
|
||||||
import module.decode.state.ChangedAttribute;
|
|
||||||
import module.decode.state.DecoderPanel;
|
|
||||||
import net.miginfocom.swing.MigLayout;
|
|
||||||
import settings.ColorSetting;
|
|
||||||
import settings.ColorSetting.ColorSettingName;
|
|
||||||
import settings.Setting;
|
|
||||||
import settings.SettingsManager;
|
|
||||||
|
|
||||||
import javax.swing.*;
|
|
||||||
|
|
||||||
public class LJ1200DecoderPanel extends DecoderPanel
|
|
||||||
{
|
|
||||||
private static final long serialVersionUID = 1L;
|
|
||||||
private static final String PROTOCOL = "LJ-1200";
|
|
||||||
|
|
||||||
private JLabel mProtocol = new JLabel(PROTOCOL);
|
|
||||||
private JLabel mTo = new JLabel();
|
|
||||||
private JLabel mToAlias = new JLabel();
|
|
||||||
|
|
||||||
public LJ1200DecoderPanel(IconManager iconManager, SettingsManager settingsManager, LJ1200DecoderState decoderState)
|
|
||||||
{
|
|
||||||
super(iconManager, settingsManager, decoderState);
|
|
||||||
|
|
||||||
init();
|
|
||||||
}
|
|
||||||
|
|
||||||
public void dispose()
|
|
||||||
{
|
|
||||||
super.dispose();
|
|
||||||
}
|
|
||||||
|
|
||||||
protected void init()
|
|
||||||
{
|
|
||||||
/* Calling super init will get and broadcast color settings to properly
|
|
||||||
* setup the jlabel colors */
|
|
||||||
super.init();
|
|
||||||
|
|
||||||
setLayout(new MigLayout("insets 1 0 0 0", "[grow,fill]", ""));
|
|
||||||
|
|
||||||
mProtocol.setFont(mFontDecoder);
|
|
||||||
mProtocol.setForeground(mColorLabelDecoder);
|
|
||||||
|
|
||||||
mTo.setFont(mFontDecoder);
|
|
||||||
mTo.setForeground(mColorLabelDecoder);
|
|
||||||
|
|
||||||
mToAlias.setFont(mFontDecoder);
|
|
||||||
mToAlias.setForeground(mColorLabelDecoder);
|
|
||||||
|
|
||||||
add(mProtocol);
|
|
||||||
add(mTo);
|
|
||||||
add(mToAlias, "wrap");
|
|
||||||
}
|
|
||||||
|
|
||||||
public LJ1200DecoderState getDecoderState()
|
|
||||||
{
|
|
||||||
return (LJ1200DecoderState) super.getDecoderState();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void receive(final ChangedAttribute changedAttribute)
|
|
||||||
{
|
|
||||||
switch(changedAttribute)
|
|
||||||
{
|
|
||||||
case TO_TALKGROUP:
|
|
||||||
mTo.setText(getDecoderState().getAddress());
|
|
||||||
repaint();
|
|
||||||
break;
|
|
||||||
case TO_TALKGROUP_ALIAS:
|
|
||||||
Alias alias = getDecoderState().getAddressAlias();
|
|
||||||
|
|
||||||
if(alias != null)
|
|
||||||
{
|
|
||||||
mToAlias.setText(alias.getName());
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
mToAlias.setText("");
|
|
||||||
}
|
|
||||||
|
|
||||||
repaint();
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void settingChanged(Setting setting)
|
|
||||||
{
|
|
||||||
super.settingChanged(setting);
|
|
||||||
|
|
||||||
if(setting instanceof ColorSetting)
|
|
||||||
{
|
|
||||||
ColorSetting color = (ColorSetting) setting;
|
|
||||||
|
|
||||||
if(color.getColorSettingName() ==
|
|
||||||
ColorSettingName.CHANNEL_STATE_LABEL_AUX_DECODER)
|
|
||||||
{
|
|
||||||
mProtocol.setForeground(color.getColor());
|
|
||||||
mTo.setForeground(color.getColor());
|
|
||||||
mToAlias.setForeground(color.getColor());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,6 +1,6 @@
|
|||||||
/*******************************************************************************
|
/*******************************************************************************
|
||||||
* SDR Trunk
|
* sdrtrunk
|
||||||
* Copyright (C) 2014,2015 Dennis Sheirer
|
* Copyright (C) 2014-2017 Dennis Sheirer
|
||||||
*
|
*
|
||||||
* This program is free software: you can redistribute it and/or modify
|
* 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
|
* it under the terms of the GNU General Public License as published by
|
||||||
@@ -14,9 +14,26 @@
|
|||||||
*
|
*
|
||||||
* You should have received a copy of the GNU General Public License
|
* You should have received a copy of the GNU General Public License
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>
|
* along with this program. If not, see <http://www.gnu.org/licenses/>
|
||||||
|
*
|
||||||
******************************************************************************/
|
******************************************************************************/
|
||||||
package module.decode.lj1200;
|
package module.decode.lj1200;
|
||||||
|
|
||||||
|
import alias.Alias;
|
||||||
|
import alias.AliasList;
|
||||||
|
import alias.id.AliasIDType;
|
||||||
|
import channel.metadata.AliasedStringAttributeMonitor;
|
||||||
|
import channel.metadata.Attribute;
|
||||||
|
import channel.metadata.AttributeChangeRequest;
|
||||||
|
import channel.state.DecoderState;
|
||||||
|
import channel.state.DecoderStateEvent;
|
||||||
|
import channel.state.DecoderStateEvent.Event;
|
||||||
|
import channel.state.State;
|
||||||
|
import message.Message;
|
||||||
|
import module.decode.DecoderType;
|
||||||
|
import org.slf4j.Logger;
|
||||||
|
import org.slf4j.LoggerFactory;
|
||||||
|
import util.StringUtils;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
@@ -24,32 +41,20 @@ import java.util.Set;
|
|||||||
import java.util.TreeSet;
|
import java.util.TreeSet;
|
||||||
import java.util.concurrent.ScheduledExecutorService;
|
import java.util.concurrent.ScheduledExecutorService;
|
||||||
|
|
||||||
import message.Message;
|
|
||||||
import module.decode.DecoderType;
|
|
||||||
import module.decode.state.ChangedAttribute;
|
|
||||||
import module.decode.state.DecoderState;
|
|
||||||
import module.decode.state.DecoderStateEvent;
|
|
||||||
import module.decode.state.DecoderStateEvent.Event;
|
|
||||||
import module.decode.state.State;
|
|
||||||
|
|
||||||
import org.slf4j.Logger;
|
|
||||||
import org.slf4j.LoggerFactory;
|
|
||||||
|
|
||||||
import alias.Alias;
|
|
||||||
import alias.AliasList;
|
|
||||||
|
|
||||||
public class LJ1200DecoderState extends DecoderState
|
public class LJ1200DecoderState extends DecoderState
|
||||||
{
|
{
|
||||||
private final static Logger mLog = LoggerFactory.getLogger(LJ1200DecoderState.class);
|
private final static Logger mLog = LoggerFactory.getLogger(LJ1200DecoderState.class);
|
||||||
|
|
||||||
private Set<String> mAddresses = new TreeSet<String>();
|
private Set<String> mAddresses = new TreeSet<String>();
|
||||||
|
|
||||||
private String mAddress;
|
private AliasedStringAttributeMonitor mAddressAttribute;
|
||||||
private Alias mAddressAlias;
|
|
||||||
|
|
||||||
public LJ1200DecoderState(AliasList aliasList)
|
public LJ1200DecoderState(AliasList aliasList)
|
||||||
{
|
{
|
||||||
super(aliasList);
|
super(aliasList);
|
||||||
|
|
||||||
|
mAddressAttribute = new AliasedStringAttributeMonitor(Attribute.SECONDARY_ADDRESS_TO,
|
||||||
|
getAttributeChangeRequestListener(), getAliasList(), AliasIDType.LOJACK);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -68,16 +73,6 @@ public class LJ1200DecoderState extends DecoderState
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getAddress()
|
|
||||||
{
|
|
||||||
return mAddress;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Alias getAddressAlias()
|
|
||||||
{
|
|
||||||
return mAddressAlias;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void receive(Message message)
|
public void receive(Message message)
|
||||||
{
|
{
|
||||||
@@ -87,10 +82,10 @@ public class LJ1200DecoderState extends DecoderState
|
|||||||
|
|
||||||
if(lj.isValid())
|
if(lj.isValid())
|
||||||
{
|
{
|
||||||
setAddress( lj.getAddress() );
|
String address = lj.getAddress();
|
||||||
setAddressAlias( lj.getTransponderAlias() );
|
|
||||||
|
|
||||||
mAddresses.add( mAddress );
|
mAddressAttribute.process(address);
|
||||||
|
mAddresses.add(address);
|
||||||
|
|
||||||
broadcast(LJ1200CallEvent.getLJ1200Event(lj));
|
broadcast(LJ1200CallEvent.getLJ1200Event(lj));
|
||||||
|
|
||||||
@@ -103,18 +98,6 @@ public class LJ1200DecoderState extends DecoderState
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void setAddress( String address )
|
|
||||||
{
|
|
||||||
mAddress = address;
|
|
||||||
broadcast( ChangedAttribute.TO_TALKGROUP );
|
|
||||||
}
|
|
||||||
|
|
||||||
private void setAddressAlias( Alias alias )
|
|
||||||
{
|
|
||||||
mAddressAlias = alias;
|
|
||||||
broadcast( ChangedAttribute.TO_TALKGROUP_ALIAS );
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getActivitySummary()
|
public String getActivitySummary()
|
||||||
{
|
{
|
||||||
@@ -159,10 +142,7 @@ public class LJ1200DecoderState extends DecoderState
|
|||||||
|
|
||||||
private void resetState()
|
private void resetState()
|
||||||
{
|
{
|
||||||
setAddress( null );
|
mAddressAttribute.reset();
|
||||||
broadcast( ChangedAttribute.TO_TALKGROUP );
|
|
||||||
setAddressAlias( null );
|
|
||||||
broadcast( ChangedAttribute.TO_TALKGROUP_ALIAS );
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -1,157 +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 module.decode.ltrnet;
|
|
||||||
|
|
||||||
import alias.Alias;
|
|
||||||
import icon.IconManager;
|
|
||||||
import module.decode.state.ChangedAttribute;
|
|
||||||
import module.decode.state.DecoderPanel;
|
|
||||||
import net.miginfocom.swing.MigLayout;
|
|
||||||
import settings.ColorSetting;
|
|
||||||
import settings.Setting;
|
|
||||||
import settings.SettingsManager;
|
|
||||||
|
|
||||||
import javax.swing.*;
|
|
||||||
import java.awt.*;
|
|
||||||
|
|
||||||
public class LTRNetDecoderPanel extends DecoderPanel
|
|
||||||
{
|
|
||||||
private static final long serialVersionUID = 1L;
|
|
||||||
|
|
||||||
private JLabel mProtocol = new JLabel("LTR-Net");
|
|
||||||
private JLabel mTalkgroup = new JLabel();
|
|
||||||
private JLabel mTalkgroupAlias = new JLabel();
|
|
||||||
|
|
||||||
private JLabel mLCN = new JLabel("LCN:");
|
|
||||||
private JLabel mDescription = new JLabel();
|
|
||||||
|
|
||||||
public LTRNetDecoderPanel(IconManager iconManager, SettingsManager settingsManager, LTRNetDecoderState decoderState)
|
|
||||||
{
|
|
||||||
super(iconManager, settingsManager, decoderState);
|
|
||||||
|
|
||||||
init();
|
|
||||||
}
|
|
||||||
|
|
||||||
public void init()
|
|
||||||
{
|
|
||||||
super.init();
|
|
||||||
|
|
||||||
setLayout(new MigLayout("insets 0 0 0 0", "[grow,fill]", "[]0[]0[]"));
|
|
||||||
|
|
||||||
mProtocol.setFont(mFontDecoder);
|
|
||||||
mProtocol.setForeground(mColorLabelDecoder);
|
|
||||||
|
|
||||||
mTalkgroup.setFont(mFontDecoder);
|
|
||||||
mTalkgroup.setForeground(mColorLabelDecoder);
|
|
||||||
|
|
||||||
mTalkgroupAlias.setFont(mFontDecoder);
|
|
||||||
mTalkgroupAlias.setForeground(mColorLabelDecoder);
|
|
||||||
|
|
||||||
mLCN.setFont(mFontDecoder);
|
|
||||||
mLCN.setForeground(mColorLabelDecoder);
|
|
||||||
|
|
||||||
mDescription.setFont(mFontDecoder);
|
|
||||||
mDescription.setForeground(mColorLabelDecoder);
|
|
||||||
|
|
||||||
add(mProtocol);
|
|
||||||
add(mTalkgroup);
|
|
||||||
add(mTalkgroupAlias, "wrap");
|
|
||||||
|
|
||||||
add(mLCN);
|
|
||||||
add(mDescription, "span");
|
|
||||||
}
|
|
||||||
|
|
||||||
public LTRNetDecoderState getDecoderState()
|
|
||||||
{
|
|
||||||
return (LTRNetDecoderState) super.getDecoderState();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void receive(final ChangedAttribute changedAttribute)
|
|
||||||
{
|
|
||||||
EventQueue.invokeLater(new Runnable()
|
|
||||||
{
|
|
||||||
@Override
|
|
||||||
public void run()
|
|
||||||
{
|
|
||||||
LTRNetDecoderState state = getDecoderState();
|
|
||||||
|
|
||||||
switch(changedAttribute)
|
|
||||||
{
|
|
||||||
case TO_TALKGROUP:
|
|
||||||
mTalkgroup.setText(state.getToTalkgroup());
|
|
||||||
break;
|
|
||||||
case TO_TALKGROUP_ALIAS:
|
|
||||||
Alias tgAlias = state.getToTalkgroupAlias();
|
|
||||||
setAliasLabel(mTalkgroupAlias, tgAlias);
|
|
||||||
break;
|
|
||||||
case DESCRIPTION:
|
|
||||||
mDescription.setText(state.getDescription());
|
|
||||||
break;
|
|
||||||
case CHANNEL_NUMBER:
|
|
||||||
mLCN.setText("LCN: " + state.getChannelNumber());
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
repaint();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void settingChanged(Setting setting)
|
|
||||||
{
|
|
||||||
super.settingChanged(setting);
|
|
||||||
|
|
||||||
if(setting instanceof ColorSetting)
|
|
||||||
{
|
|
||||||
ColorSetting colorSetting = (ColorSetting) setting;
|
|
||||||
|
|
||||||
switch(colorSetting.getColorSettingName())
|
|
||||||
{
|
|
||||||
case CHANNEL_STATE_LABEL_DECODER:
|
|
||||||
if(mProtocol != null)
|
|
||||||
{
|
|
||||||
mProtocol.setForeground(mColorLabelDecoder);
|
|
||||||
}
|
|
||||||
if(mTalkgroup != null)
|
|
||||||
{
|
|
||||||
mTalkgroup.setForeground(mColorLabelDecoder);
|
|
||||||
}
|
|
||||||
if(mTalkgroupAlias != null)
|
|
||||||
{
|
|
||||||
mTalkgroupAlias.setForeground(mColorLabelDecoder);
|
|
||||||
}
|
|
||||||
if(mLCN != null)
|
|
||||||
{
|
|
||||||
mLCN.setForeground(mColorLabelDecoder);
|
|
||||||
}
|
|
||||||
if(mDescription != null)
|
|
||||||
{
|
|
||||||
mDescription.setForeground(mColorLabelDecoder);
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -17,30 +17,31 @@
|
|||||||
******************************************************************************/
|
******************************************************************************/
|
||||||
package module.decode.ltrnet;
|
package module.decode.ltrnet;
|
||||||
|
|
||||||
|
import alias.Alias;
|
||||||
|
import alias.AliasList;
|
||||||
|
import alias.id.AliasIDType;
|
||||||
|
import channel.metadata.AliasedIntegerAttributeMonitor;
|
||||||
|
import channel.metadata.AliasedStringAttributeMonitor;
|
||||||
|
import channel.metadata.Attribute;
|
||||||
|
import channel.metadata.AttributeChangeRequest;
|
||||||
|
import channel.state.DecoderState;
|
||||||
|
import channel.state.DecoderStateEvent;
|
||||||
|
import channel.state.DecoderStateEvent.Event;
|
||||||
|
import channel.state.State;
|
||||||
|
import message.Message;
|
||||||
|
import module.decode.DecoderType;
|
||||||
|
import module.decode.event.CallEvent;
|
||||||
|
import module.decode.event.CallEvent.CallEventType;
|
||||||
|
import org.slf4j.Logger;
|
||||||
|
import org.slf4j.LoggerFactory;
|
||||||
|
import util.StringUtils;
|
||||||
|
|
||||||
import java.text.DecimalFormat;
|
import java.text.DecimalFormat;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
import java.util.TreeSet;
|
import java.util.TreeSet;
|
||||||
import java.util.concurrent.ScheduledExecutorService;
|
import java.util.concurrent.ScheduledExecutorService;
|
||||||
|
|
||||||
import message.Message;
|
|
||||||
import module.decode.DecoderType;
|
|
||||||
import module.decode.event.CallEvent;
|
|
||||||
import module.decode.event.CallEvent.CallEventType;
|
|
||||||
import module.decode.state.ChangedAttribute;
|
|
||||||
import module.decode.state.DecoderState;
|
|
||||||
import module.decode.state.DecoderStateEvent;
|
|
||||||
import module.decode.state.DecoderStateEvent.Event;
|
|
||||||
import module.decode.state.State;
|
|
||||||
|
|
||||||
import org.slf4j.Logger;
|
|
||||||
import org.slf4j.LoggerFactory;
|
|
||||||
|
|
||||||
import alias.Alias;
|
|
||||||
import alias.AliasList;
|
|
||||||
import audio.metadata.Metadata;
|
|
||||||
import audio.metadata.MetadataType;
|
|
||||||
|
|
||||||
public class LTRNetDecoderState extends DecoderState
|
public class LTRNetDecoderState extends DecoderState
|
||||||
{
|
{
|
||||||
private final static Logger mLog = LoggerFactory.getLogger(LTRNetDecoderState.class);
|
private final static Logger mLog = LoggerFactory.getLogger(LTRNetDecoderState.class);
|
||||||
@@ -59,15 +60,27 @@ public class LTRNetDecoderState extends DecoderState
|
|||||||
new HashMap<Integer,Long>();
|
new HashMap<Integer,Long>();
|
||||||
private HashMap<Integer,String> mActiveCalls = new HashMap<Integer,String>();
|
private HashMap<Integer,String> mActiveCalls = new HashMap<Integer,String>();
|
||||||
|
|
||||||
private String mTalkgroup;
|
private AliasedStringAttributeMonitor mToAttribute;
|
||||||
private Alias mTalkgroupAlias;
|
private AliasedIntegerAttributeMonitor mFromUIDAttribute;
|
||||||
private String mDescription;
|
private AliasedStringAttributeMonitor mESNAttribute;
|
||||||
|
private String mMessage;
|
||||||
|
private String mMessageType;
|
||||||
private int mChannelNumber;
|
private int mChannelNumber;
|
||||||
private long mFrequency = 0;
|
private long mFrequency = 0;
|
||||||
|
|
||||||
public LTRNetDecoderState(AliasList aliasList)
|
public LTRNetDecoderState(AliasList aliasList)
|
||||||
{
|
{
|
||||||
super(aliasList);
|
super(aliasList);
|
||||||
|
|
||||||
|
mToAttribute = new AliasedStringAttributeMonitor(Attribute.PRIMARY_ADDRESS_TO,
|
||||||
|
getAttributeChangeRequestListener(), getAliasList(), AliasIDType.TALKGROUP);
|
||||||
|
mToAttribute.addIllegalValue("0-00-000");
|
||||||
|
|
||||||
|
mFromUIDAttribute = new AliasedIntegerAttributeMonitor(Attribute.PRIMARY_ADDRESS_TO,
|
||||||
|
getAttributeChangeRequestListener(), getAliasList(), AliasIDType.LTR_NET_UID);
|
||||||
|
|
||||||
|
mESNAttribute = new AliasedStringAttributeMonitor(Attribute.SECONDARY_ADDRESS_FROM,
|
||||||
|
getAttributeChangeRequestListener(), getAliasList(), AliasIDType.ESN);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -92,8 +105,7 @@ public class LTRNetDecoderState extends DecoderState
|
|||||||
case CA_ENDD:
|
case CA_ENDD:
|
||||||
if(mChannelNumber == 0)
|
if(mChannelNumber == 0)
|
||||||
{
|
{
|
||||||
mChannelNumber = ltr.getChannel();
|
setChannelNumber(ltr.getChannel());
|
||||||
broadcast(ChangedAttribute.CHANNEL_NUMBER);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Process FCC Station ID Events */
|
/* Process FCC Station ID Events */
|
||||||
@@ -113,13 +125,11 @@ public class LTRNetDecoderState extends DecoderState
|
|||||||
|
|
||||||
broadcast(mCurrentCallEvent);
|
broadcast(mCurrentCallEvent);
|
||||||
|
|
||||||
broadcast(new DecoderStateEvent(this,
|
broadcast(new DecoderStateEvent(this, Event.START, State.DATA));
|
||||||
Event.START, State.DATA));
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
broadcast(new DecoderStateEvent(this,
|
broadcast(new DecoderStateEvent(this, Event.CONTINUATION, State.DATA));
|
||||||
Event.CONTINUATION, State.DATA));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@@ -130,8 +140,7 @@ public class LTRNetDecoderState extends DecoderState
|
|||||||
case CA_STRT:
|
case CA_STRT:
|
||||||
if(mChannelNumber == 0)
|
if(mChannelNumber == 0)
|
||||||
{
|
{
|
||||||
mChannelNumber = ltr.getChannel();
|
setChannelNumber(ltr.getChannel());
|
||||||
broadcast(ChangedAttribute.CHANNEL_NUMBER);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* If the call event channel matches our current channel
|
/* If the call event channel matches our current channel
|
||||||
@@ -149,8 +158,7 @@ public class LTRNetDecoderState extends DecoderState
|
|||||||
case SY_IDLE:
|
case SY_IDLE:
|
||||||
if(mChannelNumber != ltr.getChannel())
|
if(mChannelNumber != ltr.getChannel())
|
||||||
{
|
{
|
||||||
mChannelNumber = ltr.getChannel();
|
setChannelNumber(ltr.getChannel());
|
||||||
broadcast(ChangedAttribute.CHANNEL_NUMBER);
|
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case MA_CHNH:
|
case MA_CHNH:
|
||||||
@@ -161,16 +169,14 @@ public class LTRNetDecoderState extends DecoderState
|
|||||||
case FQ_RXLO:
|
case FQ_RXLO:
|
||||||
if(ltr.getFrequency() > 0)
|
if(ltr.getFrequency() > 0)
|
||||||
{
|
{
|
||||||
mReceiveFrequencies.put(ltr.getHomeRepeater(),
|
mReceiveFrequencies.put(ltr.getHomeRepeater(), ltr.getFrequency());
|
||||||
ltr.getFrequency());
|
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case FQ_TXHI:
|
case FQ_TXHI:
|
||||||
case FQ_TXLO:
|
case FQ_TXLO:
|
||||||
if(ltr.getFrequency() > 0)
|
if(ltr.getFrequency() > 0)
|
||||||
{
|
{
|
||||||
mTransmitFrequencies.put(ltr.getHomeRepeater(),
|
mTransmitFrequencies.put(ltr.getHomeRepeater(), ltr.getFrequency());
|
||||||
ltr.getFrequency());
|
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case ID_NBOR:
|
case ID_NBOR:
|
||||||
@@ -210,11 +216,7 @@ public class LTRNetDecoderState extends DecoderState
|
|||||||
broadcast(mCurrentCallEvent);
|
broadcast(mCurrentCallEvent);
|
||||||
}
|
}
|
||||||
|
|
||||||
mTalkgroup = String.valueOf(uniqueID);
|
mFromUIDAttribute.process(uniqueID);
|
||||||
broadcast(ChangedAttribute.TO_TALKGROUP);
|
|
||||||
|
|
||||||
mTalkgroupAlias = ltr.getRadioUniqueIDAlias();
|
|
||||||
broadcast(ChangedAttribute.TO_TALKGROUP_ALIAS);
|
|
||||||
break;
|
break;
|
||||||
case ID_SITE:
|
case ID_SITE:
|
||||||
String siteID = ltr.getSiteID();
|
String siteID = ltr.getSiteID();
|
||||||
@@ -251,14 +253,8 @@ public class LTRNetDecoderState extends DecoderState
|
|||||||
mESNs.add(ltr.getESN());
|
mESNs.add(ltr.getESN());
|
||||||
}
|
}
|
||||||
|
|
||||||
mDescription = "ESN";
|
setMessageType("ESN");
|
||||||
broadcast(ChangedAttribute.DESCRIPTION);
|
mESNAttribute.process(ltr.getESN());
|
||||||
|
|
||||||
mTalkgroup = ltr.getESN();
|
|
||||||
broadcast(ChangedAttribute.TO_TALKGROUP);
|
|
||||||
|
|
||||||
mTalkgroupAlias = ltr.getESNAlias();
|
|
||||||
broadcast(ChangedAttribute.TO_TALKGROUP_ALIAS);
|
|
||||||
|
|
||||||
broadcast(new DecoderStateEvent(this, Event.DECODE, State.DATA));
|
broadcast(new DecoderStateEvent(this, Event.DECODE, State.DATA));
|
||||||
|
|
||||||
@@ -285,14 +281,8 @@ public class LTRNetDecoderState extends DecoderState
|
|||||||
{
|
{
|
||||||
mUniqueIDs.add(uniqueid);
|
mUniqueIDs.add(uniqueid);
|
||||||
|
|
||||||
mDescription = "REGISTER UID";
|
setMessageType("REGISTER UID");
|
||||||
broadcast(ChangedAttribute.DESCRIPTION);
|
mFromUIDAttribute.process(uniqueid);
|
||||||
|
|
||||||
mTalkgroup = String.valueOf(uniqueid);
|
|
||||||
broadcast(ChangedAttribute.TO_TALKGROUP);
|
|
||||||
|
|
||||||
mTalkgroupAlias = ltr.getRadioUniqueIDAlias();
|
|
||||||
broadcast(ChangedAttribute.TO_TALKGROUP_ALIAS);
|
|
||||||
|
|
||||||
if(getCurrentLTRCallEvent() == null)
|
if(getCurrentLTRCallEvent() == null)
|
||||||
{
|
{
|
||||||
@@ -618,9 +608,8 @@ public class LTRNetDecoderState extends DecoderState
|
|||||||
/* Process call registration */
|
/* Process call registration */
|
||||||
if(group == 253)
|
if(group == 253)
|
||||||
{
|
{
|
||||||
|
setMessageType("REGISTER");
|
||||||
broadcast(new DecoderStateEvent(this, Event.START, State.DATA));
|
broadcast(new DecoderStateEvent(this, Event.START, State.DATA));
|
||||||
mDescription = "REGISTER";
|
|
||||||
broadcast(ChangedAttribute.DESCRIPTION);
|
|
||||||
}
|
}
|
||||||
/* Process call */
|
/* Process call */
|
||||||
else
|
else
|
||||||
@@ -629,10 +618,11 @@ public class LTRNetDecoderState extends DecoderState
|
|||||||
|
|
||||||
if(isValidTalkgroup(talkgroup))
|
if(isValidTalkgroup(talkgroup))
|
||||||
{
|
{
|
||||||
|
mToAttribute.process(talkgroup);
|
||||||
|
|
||||||
final LTRCallEvent current = getCurrentLTRCallEvent();
|
final LTRCallEvent current = getCurrentLTRCallEvent();
|
||||||
|
|
||||||
/* If this is a new call or the talkgroup is different from the current
|
//If this is a new call or the talkgroup is different from the current call, create a new call event
|
||||||
* call, create a new call event */
|
|
||||||
if(current == null || isDifferentTalkgroup(talkgroup))
|
if(current == null || isDifferentTalkgroup(talkgroup))
|
||||||
{
|
{
|
||||||
/* Invalidate the current call */
|
/* Invalidate the current call */
|
||||||
@@ -642,24 +632,18 @@ public class LTRNetDecoderState extends DecoderState
|
|||||||
broadcast(current);
|
broadcast(current);
|
||||||
}
|
}
|
||||||
|
|
||||||
mTalkgroup = message.getTalkgroupID();
|
|
||||||
broadcast(ChangedAttribute.TO_TALKGROUP);
|
|
||||||
|
|
||||||
/* A talkgroup must be seen at least once before it will be added
|
/* A talkgroup must be seen at least once before it will be added
|
||||||
* to the mTalkgroups list that is used in the activity summary,
|
* to the mTalkgroups list that is used in the activity summary,
|
||||||
* so that we don't pollute the summary with one-off error talkgroups */
|
* so that we don't pollute the summary with one-off error talkgroups */
|
||||||
if (mTalkgroupsFirstHeard.contains(mTalkgroup))
|
if(mTalkgroupsFirstHeard.contains(talkgroup))
|
||||||
{
|
{
|
||||||
mTalkgroups.add(mTalkgroup);
|
mTalkgroups.add(talkgroup);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
mTalkgroupsFirstHeard.add(mTalkgroup);
|
mTalkgroupsFirstHeard.add(talkgroup);
|
||||||
}
|
}
|
||||||
|
|
||||||
mTalkgroupAlias = message.getTalkgroupIDAlias();
|
|
||||||
broadcast(ChangedAttribute.TO_TALKGROUP_ALIAS);
|
|
||||||
|
|
||||||
CallEvent callEvent = new LTRCallEvent.Builder(DecoderType.LTR_NET, CallEventType.CALL)
|
CallEvent callEvent = new LTRCallEvent.Builder(DecoderType.LTR_NET, CallEventType.CALL)
|
||||||
.aliasList(getAliasList())
|
.aliasList(getAliasList())
|
||||||
.channel(String.valueOf(message.getChannel()))
|
.channel(String.valueOf(message.getChannel()))
|
||||||
@@ -671,8 +655,6 @@ public class LTRNetDecoderState extends DecoderState
|
|||||||
|
|
||||||
mCurrentCallEvent = callEvent;
|
mCurrentCallEvent = callEvent;
|
||||||
|
|
||||||
broadcast(new Metadata(MetadataType.TO, mTalkgroup, mTalkgroupAlias, true));
|
|
||||||
|
|
||||||
broadcast(new DecoderStateEvent(this, Event.START, State.CALL));
|
broadcast(new DecoderStateEvent(this, Event.START, State.CALL));
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -728,29 +710,39 @@ public class LTRNetDecoderState extends DecoderState
|
|||||||
|
|
||||||
mCurrentCallEvent = null;
|
mCurrentCallEvent = null;
|
||||||
|
|
||||||
mTalkgroup = null;
|
mToAttribute.reset();
|
||||||
broadcast(ChangedAttribute.TO_TALKGROUP);
|
mESNAttribute.reset();
|
||||||
|
mFromUIDAttribute.reset();
|
||||||
mTalkgroupAlias = null;
|
mMessage = null;
|
||||||
broadcast(ChangedAttribute.TO_TALKGROUP_ALIAS);
|
mMessageType = null;
|
||||||
|
|
||||||
mDescription = null;
|
|
||||||
broadcast(ChangedAttribute.DESCRIPTION);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getToTalkgroup()
|
public String getMessage()
|
||||||
{
|
{
|
||||||
return mTalkgroup;
|
return mMessage;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Alias getToTalkgroupAlias()
|
public void setMessage(String message)
|
||||||
{
|
{
|
||||||
return mTalkgroupAlias;
|
if(!StringUtils.isEqual(mMessage, message))
|
||||||
|
{
|
||||||
|
mMessage = message;
|
||||||
|
broadcast(new AttributeChangeRequest<String>(Attribute.MESSAGE, mMessageType));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getDescription()
|
public String getMessageType()
|
||||||
{
|
{
|
||||||
return mDescription;
|
return mMessageType;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void setMessageType(String messageType)
|
||||||
|
{
|
||||||
|
if(!StringUtils.isEqual(mMessageType, messageType))
|
||||||
|
{
|
||||||
|
mMessageType = messageType;
|
||||||
|
broadcast(new AttributeChangeRequest<String>(Attribute.MESSAGE_TYPE, mMessageType));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean hasChannelNumber()
|
public boolean hasChannelNumber()
|
||||||
@@ -763,6 +755,16 @@ public class LTRNetDecoderState extends DecoderState
|
|||||||
return mChannelNumber;
|
return mChannelNumber;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void setChannelNumber(int channelNumber)
|
||||||
|
{
|
||||||
|
if(mChannelNumber != channelNumber)
|
||||||
|
{
|
||||||
|
mChannelNumber = channelNumber;
|
||||||
|
broadcast(new AttributeChangeRequest<String>(Attribute.CHANNEL_FREQUENCY_LABEL,
|
||||||
|
"LCN:" + getChannelNumber()));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void init()
|
public void init()
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -1,164 +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 module.decode.ltrstandard;
|
|
||||||
|
|
||||||
import alias.Alias;
|
|
||||||
import icon.IconManager;
|
|
||||||
import module.decode.state.ChangedAttribute;
|
|
||||||
import module.decode.state.DecoderPanel;
|
|
||||||
import net.miginfocom.swing.MigLayout;
|
|
||||||
import settings.ColorSetting;
|
|
||||||
import settings.Setting;
|
|
||||||
import settings.SettingsManager;
|
|
||||||
|
|
||||||
import javax.swing.*;
|
|
||||||
import java.awt.*;
|
|
||||||
|
|
||||||
public class LTRStandardDecoderPanel extends DecoderPanel
|
|
||||||
{
|
|
||||||
private static final long serialVersionUID = 1L;
|
|
||||||
|
|
||||||
private JLabel mProtocol = new JLabel("LTR Standard");
|
|
||||||
private JLabel mTalkgroup = new JLabel();
|
|
||||||
private JLabel mTalkgroupAlias = new JLabel();
|
|
||||||
|
|
||||||
private JLabel mLCN = new JLabel("LCN:");
|
|
||||||
|
|
||||||
public LTRStandardDecoderPanel(IconManager iconManager, SettingsManager settingsManager,
|
|
||||||
LTRStandardDecoderState decoderState)
|
|
||||||
{
|
|
||||||
super(iconManager, settingsManager, decoderState);
|
|
||||||
|
|
||||||
init();
|
|
||||||
}
|
|
||||||
|
|
||||||
public void dispose()
|
|
||||||
{
|
|
||||||
super.dispose();
|
|
||||||
}
|
|
||||||
|
|
||||||
public void init()
|
|
||||||
{
|
|
||||||
super.init();
|
|
||||||
|
|
||||||
setLayout(new MigLayout("insets 0 0 0 0", "[grow,fill]", "[]0[]0[]"));
|
|
||||||
|
|
||||||
mProtocol.setFont(mFontDecoder);
|
|
||||||
mProtocol.setForeground(mColorLabelDecoder);
|
|
||||||
|
|
||||||
mTalkgroup.setFont(mFontDecoder);
|
|
||||||
mTalkgroup.setForeground(mColorLabelDecoder);
|
|
||||||
|
|
||||||
mTalkgroupAlias.setFont(mFontDecoder);
|
|
||||||
mTalkgroupAlias.setForeground(mColorLabelDecoder);
|
|
||||||
|
|
||||||
mLCN.setFont(mFontDecoder);
|
|
||||||
mLCN.setForeground(mColorLabelDecoder);
|
|
||||||
|
|
||||||
add(mProtocol);
|
|
||||||
add(mTalkgroup);
|
|
||||||
add(mTalkgroupAlias, "wrap");
|
|
||||||
|
|
||||||
add(mLCN, "wrap");
|
|
||||||
}
|
|
||||||
|
|
||||||
public LTRStandardDecoderState getDecoderState()
|
|
||||||
{
|
|
||||||
return (LTRStandardDecoderState) super.getDecoderState();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void receive(final ChangedAttribute attribute)
|
|
||||||
{
|
|
||||||
EventQueue.invokeLater(new Runnable()
|
|
||||||
{
|
|
||||||
@Override
|
|
||||||
public void run()
|
|
||||||
{
|
|
||||||
LTRStandardDecoderState state = getDecoderState();
|
|
||||||
|
|
||||||
switch(attribute)
|
|
||||||
{
|
|
||||||
case CHANNEL_NUMBER:
|
|
||||||
if(state.getChannelNumber() != 0)
|
|
||||||
{
|
|
||||||
mLCN.setText("LCN: " + state.getChannelNumber());
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case TO_TALKGROUP:
|
|
||||||
mTalkgroup.setText(state.getTalkgroup());
|
|
||||||
/* fall-through */
|
|
||||||
case TO_TALKGROUP_ALIAS:
|
|
||||||
Alias alias = state.getTalkgroupAlias();
|
|
||||||
|
|
||||||
if(alias != null)
|
|
||||||
{
|
|
||||||
mTalkgroupAlias.setText(alias.getName());
|
|
||||||
mTalkgroupAlias.setIcon(mIconManager.getIcon(alias.getIconName(),
|
|
||||||
IconManager.DEFAULT_ICON_SIZE));
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
mTalkgroupAlias.setText(null);
|
|
||||||
mTalkgroupAlias.setIcon(null);
|
|
||||||
}
|
|
||||||
default:
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
repaint();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void settingChanged(Setting setting)
|
|
||||||
{
|
|
||||||
super.settingChanged(setting);
|
|
||||||
|
|
||||||
if(setting instanceof ColorSetting)
|
|
||||||
{
|
|
||||||
ColorSetting colorSetting = (ColorSetting) setting;
|
|
||||||
|
|
||||||
switch(colorSetting.getColorSettingName())
|
|
||||||
{
|
|
||||||
case CHANNEL_STATE_LABEL_DECODER:
|
|
||||||
if(mProtocol != null)
|
|
||||||
{
|
|
||||||
mProtocol.setForeground(mColorLabelDecoder);
|
|
||||||
}
|
|
||||||
if(mTalkgroup != null)
|
|
||||||
{
|
|
||||||
mTalkgroup.setForeground(mColorLabelDecoder);
|
|
||||||
}
|
|
||||||
if(mTalkgroupAlias != null)
|
|
||||||
{
|
|
||||||
mTalkgroupAlias.setForeground(mColorLabelDecoder);
|
|
||||||
}
|
|
||||||
if(mLCN != null)
|
|
||||||
{
|
|
||||||
mLCN.setForeground(mColorLabelDecoder);
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,6 +1,6 @@
|
|||||||
/*******************************************************************************
|
/*******************************************************************************
|
||||||
* SDR Trunk
|
* sdrtrunk
|
||||||
* Copyright (C) 2014-2016 Dennis Sheirer
|
* Copyright (C) 2014-2017 Dennis Sheirer
|
||||||
*
|
*
|
||||||
* This program is free software: you can redistribute it and/or modify
|
* 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
|
* it under the terms of the GNU General Public License as published by
|
||||||
@@ -14,9 +14,32 @@
|
|||||||
*
|
*
|
||||||
* You should have received a copy of the GNU General Public License
|
* You should have received a copy of the GNU General Public License
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>
|
* along with this program. If not, see <http://www.gnu.org/licenses/>
|
||||||
|
*
|
||||||
******************************************************************************/
|
******************************************************************************/
|
||||||
package module.decode.ltrstandard;
|
package module.decode.ltrstandard;
|
||||||
|
|
||||||
|
import alias.Alias;
|
||||||
|
import alias.AliasList;
|
||||||
|
import alias.id.AliasIDType;
|
||||||
|
import channel.metadata.AliasedStringAttributeMonitor;
|
||||||
|
import channel.metadata.Attribute;
|
||||||
|
import channel.metadata.AttributeChangeRequest;
|
||||||
|
import channel.state.DecoderState;
|
||||||
|
import channel.state.DecoderStateEvent;
|
||||||
|
import channel.state.DecoderStateEvent.Event;
|
||||||
|
import channel.state.State;
|
||||||
|
import message.Message;
|
||||||
|
import module.decode.DecoderType;
|
||||||
|
import module.decode.event.CallEvent.CallEventType;
|
||||||
|
import module.decode.ltrnet.LTRCallEvent;
|
||||||
|
import module.decode.ltrstandard.message.CallEndMessage;
|
||||||
|
import module.decode.ltrstandard.message.CallMessage;
|
||||||
|
import module.decode.ltrstandard.message.IdleMessage;
|
||||||
|
import module.decode.ltrstandard.message.LTRStandardMessage;
|
||||||
|
import org.slf4j.Logger;
|
||||||
|
import org.slf4j.LoggerFactory;
|
||||||
|
import util.StringUtils;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
@@ -26,28 +49,6 @@ import java.util.Set;
|
|||||||
import java.util.TreeSet;
|
import java.util.TreeSet;
|
||||||
import java.util.concurrent.ScheduledExecutorService;
|
import java.util.concurrent.ScheduledExecutorService;
|
||||||
|
|
||||||
import message.Message;
|
|
||||||
import module.decode.DecoderType;
|
|
||||||
import module.decode.event.CallEvent.CallEventType;
|
|
||||||
import module.decode.ltrnet.LTRCallEvent;
|
|
||||||
import module.decode.ltrstandard.message.CallEndMessage;
|
|
||||||
import module.decode.ltrstandard.message.CallMessage;
|
|
||||||
import module.decode.ltrstandard.message.IdleMessage;
|
|
||||||
import module.decode.ltrstandard.message.LTRStandardMessage;
|
|
||||||
import module.decode.state.ChangedAttribute;
|
|
||||||
import module.decode.state.DecoderState;
|
|
||||||
import module.decode.state.DecoderStateEvent;
|
|
||||||
import module.decode.state.DecoderStateEvent.Event;
|
|
||||||
import module.decode.state.State;
|
|
||||||
|
|
||||||
import org.slf4j.Logger;
|
|
||||||
import org.slf4j.LoggerFactory;
|
|
||||||
|
|
||||||
import alias.Alias;
|
|
||||||
import alias.AliasList;
|
|
||||||
import audio.metadata.Metadata;
|
|
||||||
import audio.metadata.MetadataType;
|
|
||||||
|
|
||||||
public class LTRStandardDecoderState extends DecoderState
|
public class LTRStandardDecoderState extends DecoderState
|
||||||
{
|
{
|
||||||
private final static Logger mLog =
|
private final static Logger mLog =
|
||||||
@@ -57,14 +58,16 @@ public class LTRStandardDecoderState extends DecoderState
|
|||||||
private Set<String> mTalkgroupsFirstHeard = new HashSet<>();
|
private Set<String> mTalkgroupsFirstHeard = new HashSet<>();
|
||||||
private Set<String> mTalkgroups = new TreeSet<>();
|
private Set<String> mTalkgroups = new TreeSet<>();
|
||||||
|
|
||||||
private String mTalkgroup;
|
private AliasedStringAttributeMonitor mTalkgroupAttribute;
|
||||||
private Alias mTalkgroupAlias;
|
|
||||||
private long mFrequency;
|
private long mFrequency;
|
||||||
private LCNTracker mLCNTracker = new LCNTracker();
|
private LCNTracker mLCNTracker = new LCNTracker();
|
||||||
|
|
||||||
public LTRStandardDecoderState(AliasList aliasList)
|
public LTRStandardDecoderState(AliasList aliasList)
|
||||||
{
|
{
|
||||||
super(aliasList);
|
super(aliasList);
|
||||||
|
|
||||||
|
mTalkgroupAttribute = new AliasedStringAttributeMonitor(Attribute.PRIMARY_ADDRESS_TO,
|
||||||
|
getAttributeChangeRequestListener(), getAliasList(), AliasIDType.TALKGROUP);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -97,7 +100,7 @@ public class LTRStandardDecoderState extends DecoderState
|
|||||||
|
|
||||||
int channel = start.getChannel();
|
int channel = start.getChannel();
|
||||||
|
|
||||||
mLCNTracker.processCallChannel( channel );
|
setChannelNumber(channel);
|
||||||
|
|
||||||
mLCNTracker.processFreeChannel(start.getFree());
|
mLCNTracker.processFreeChannel(start.getFree());
|
||||||
|
|
||||||
@@ -109,8 +112,7 @@ public class LTRStandardDecoderState extends DecoderState
|
|||||||
{
|
{
|
||||||
LTRCallEvent event = mActiveCalls.get(channel);
|
LTRCallEvent event = mActiveCalls.get(channel);
|
||||||
|
|
||||||
if( event == null ||
|
if(event == null || !event.isMatchingTalkgroup(start.getToID()))
|
||||||
!event.isMatchingTalkgroup( start.getToID() ) )
|
|
||||||
{
|
{
|
||||||
//Check for different talkgroup
|
//Check for different talkgroup
|
||||||
if(event != null)
|
if(event != null)
|
||||||
@@ -136,21 +138,13 @@ public class LTRStandardDecoderState extends DecoderState
|
|||||||
|
|
||||||
if(mLCNTracker.isCurrentChannel(channel))
|
if(mLCNTracker.isCurrentChannel(channel))
|
||||||
{
|
{
|
||||||
mTalkgroup = start.getToID();
|
String talkgroup = start.getToID();
|
||||||
broadcast( ChangedAttribute.TO_TALKGROUP );
|
mTalkgroupAttribute.process(talkgroup);
|
||||||
|
processTalkgroup(talkgroup);
|
||||||
processTalkgroup( mTalkgroup );
|
|
||||||
|
|
||||||
mTalkgroupAlias = start.getToIDAlias();
|
|
||||||
broadcast( ChangedAttribute.TO_TALKGROUP_ALIAS );
|
|
||||||
|
|
||||||
broadcast( new Metadata( MetadataType.TO,
|
|
||||||
mTalkgroup, mTalkgroupAlias, true ) );
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
broadcast( new DecoderStateEvent( this,
|
broadcast(new DecoderStateEvent(this, Event.CONTINUATION, State.CALL));
|
||||||
Event.CONTINUATION, State.CALL ) );
|
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case CA_ENDD:
|
case CA_ENDD:
|
||||||
@@ -160,17 +154,13 @@ public class LTRStandardDecoderState extends DecoderState
|
|||||||
//as the call end channel
|
//as the call end channel
|
||||||
int repeater = end.getFree();
|
int repeater = end.getFree();
|
||||||
|
|
||||||
mLCNTracker.processCallChannel( repeater );
|
setChannelNumber(repeater);
|
||||||
|
|
||||||
if(mLCNTracker.isCurrentChannel(repeater))
|
if(mLCNTracker.isCurrentChannel(repeater))
|
||||||
{
|
{
|
||||||
mTalkgroup = end.getToID();
|
String talkgroup = end.getToID();
|
||||||
broadcast( ChangedAttribute.TO_TALKGROUP );
|
mTalkgroupAttribute.process(talkgroup);
|
||||||
|
processTalkgroup(talkgroup);
|
||||||
processTalkgroup( mTalkgroup );
|
|
||||||
|
|
||||||
mTalkgroupAlias = end.getToIDAlias();
|
|
||||||
broadcast( ChangedAttribute.TO_TALKGROUP_ALIAS );
|
|
||||||
|
|
||||||
LTRCallEvent event = mActiveCalls.remove(repeater);
|
LTRCallEvent event = mActiveCalls.remove(repeater);
|
||||||
|
|
||||||
@@ -241,21 +231,7 @@ public class LTRStandardDecoderState extends DecoderState
|
|||||||
|
|
||||||
mActiveCalls.clear();
|
mActiveCalls.clear();
|
||||||
|
|
||||||
mTalkgroup = null;
|
mTalkgroupAttribute.reset();
|
||||||
broadcast( ChangedAttribute.TO_TALKGROUP );
|
|
||||||
|
|
||||||
mTalkgroupAlias = null;
|
|
||||||
broadcast( ChangedAttribute.TO_TALKGROUP_ALIAS );
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getTalkgroup()
|
|
||||||
{
|
|
||||||
return mTalkgroup;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Alias getTalkgroupAlias()
|
|
||||||
{
|
|
||||||
return mTalkgroupAlias;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean hasChannelNumber()
|
public boolean hasChannelNumber()
|
||||||
@@ -268,6 +244,19 @@ public class LTRStandardDecoderState extends DecoderState
|
|||||||
return mLCNTracker.getCurrentChannel();
|
return mLCNTracker.getCurrentChannel();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void setChannelNumber(int channel)
|
||||||
|
{
|
||||||
|
int original = mLCNTracker.getCurrentChannel();
|
||||||
|
|
||||||
|
mLCNTracker.processCallChannel(channel);
|
||||||
|
|
||||||
|
if(mLCNTracker.getCurrentChannel() != original)
|
||||||
|
{
|
||||||
|
broadcast(new AttributeChangeRequest<String>(Attribute.CHANNEL_FREQUENCY_LABEL,
|
||||||
|
"LCN:" + mLCNTracker.getCurrentChannel()));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void init()
|
public void init()
|
||||||
{
|
{
|
||||||
@@ -452,8 +441,6 @@ public class LTRStandardDecoderState extends DecoderState
|
|||||||
{
|
{
|
||||||
mCallHighestCount = mCallLCNCounts[channel];
|
mCallHighestCount = mCallLCNCounts[channel];
|
||||||
mCurrentLCN = channel;
|
mCurrentLCN = channel;
|
||||||
|
|
||||||
broadcast( ChangedAttribute.CHANNEL_NUMBER );
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,183 +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 module.decode.mdc1200;
|
|
||||||
|
|
||||||
import alias.Alias;
|
|
||||||
import icon.IconManager;
|
|
||||||
import module.decode.state.ChangedAttribute;
|
|
||||||
import module.decode.state.DecoderPanel;
|
|
||||||
import net.miginfocom.swing.MigLayout;
|
|
||||||
import settings.ColorSetting;
|
|
||||||
import settings.ColorSetting.ColorSettingName;
|
|
||||||
import settings.Setting;
|
|
||||||
import settings.SettingsManager;
|
|
||||||
|
|
||||||
import javax.swing.*;
|
|
||||||
import java.awt.*;
|
|
||||||
|
|
||||||
public class MDCDecoderPanel extends DecoderPanel
|
|
||||||
{
|
|
||||||
private static final long serialVersionUID = 1L;
|
|
||||||
private static final String sPROTOCOL = "MDC-1200";
|
|
||||||
|
|
||||||
private JLabel mFromLabel = new JLabel(" ");
|
|
||||||
private JLabel mFrom = new JLabel();
|
|
||||||
private JLabel mFromAlias = new JLabel();
|
|
||||||
|
|
||||||
private JLabel mToLabel = new JLabel(" ");
|
|
||||||
private JLabel mTo = new JLabel();
|
|
||||||
private JLabel mToAlias = new JLabel();
|
|
||||||
|
|
||||||
private JLabel mProtocol = new JLabel(sPROTOCOL);
|
|
||||||
private JLabel mMessage = new JLabel();
|
|
||||||
private JLabel mMessageType = new JLabel();
|
|
||||||
|
|
||||||
public MDCDecoderPanel(IconManager iconManager, SettingsManager settingsManager, MDCDecoderState decoderState)
|
|
||||||
{
|
|
||||||
super(iconManager, settingsManager, decoderState);
|
|
||||||
|
|
||||||
init();
|
|
||||||
}
|
|
||||||
|
|
||||||
public MDCDecoderState getDecoderState()
|
|
||||||
{
|
|
||||||
return (MDCDecoderState) super.getDecoderState();
|
|
||||||
}
|
|
||||||
|
|
||||||
protected void init()
|
|
||||||
{
|
|
||||||
/* Calling super init will get and broadcast color settings to properly
|
|
||||||
* setup the jlabel colors */
|
|
||||||
super.init();
|
|
||||||
|
|
||||||
setLayout(new MigLayout("insets 1 0 0 0", "[grow,fill]", "[]0[]0[]"));
|
|
||||||
|
|
||||||
add(mFromLabel);
|
|
||||||
add(mFrom);
|
|
||||||
add(mFromAlias, "wrap");
|
|
||||||
|
|
||||||
add(mToLabel);
|
|
||||||
add(mTo);
|
|
||||||
add(mToAlias, "wrap");
|
|
||||||
|
|
||||||
add(mProtocol);
|
|
||||||
add(mMessageType);
|
|
||||||
add(mMessage, "wrap");
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void receive(final ChangedAttribute changedAttribute)
|
|
||||||
{
|
|
||||||
EventQueue.invokeLater(new Runnable()
|
|
||||||
{
|
|
||||||
@Override
|
|
||||||
public void run()
|
|
||||||
{
|
|
||||||
switch(changedAttribute)
|
|
||||||
{
|
|
||||||
case FROM_TALKGROUP:
|
|
||||||
String from = getDecoderState().getFrom();
|
|
||||||
|
|
||||||
if(from != null)
|
|
||||||
{
|
|
||||||
mFromLabel.setText("FM:");
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
mFromLabel.setText(" ");
|
|
||||||
}
|
|
||||||
mFrom.setText(from);
|
|
||||||
break;
|
|
||||||
case FROM_TALKGROUP_ALIAS:
|
|
||||||
Alias fromAlias = getDecoderState().getFromAlias();
|
|
||||||
|
|
||||||
if(fromAlias != null)
|
|
||||||
{
|
|
||||||
mFromAlias.setText(fromAlias.getName());
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
mFromAlias.setText(null);
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case TO_TALKGROUP:
|
|
||||||
String to = getDecoderState().getTo();
|
|
||||||
|
|
||||||
if(to != null)
|
|
||||||
{
|
|
||||||
mToLabel.setText("TO:");
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
mToLabel.setText(" ");
|
|
||||||
}
|
|
||||||
mTo.setText(to);
|
|
||||||
break;
|
|
||||||
case TO_TALKGROUP_ALIAS:
|
|
||||||
Alias toAlias = getDecoderState().getToAlias();
|
|
||||||
|
|
||||||
if(toAlias != null)
|
|
||||||
{
|
|
||||||
mToAlias.setText(toAlias.getName());
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
mToAlias.setText(null);
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case MESSAGE:
|
|
||||||
mMessage.setText(getDecoderState().getMessage());
|
|
||||||
break;
|
|
||||||
case MESSAGE_TYPE:
|
|
||||||
mMessageType.setText(getDecoderState().getMessageType());
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
repaint();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void settingChanged(Setting setting)
|
|
||||||
{
|
|
||||||
super.settingChanged(setting);
|
|
||||||
|
|
||||||
if(setting instanceof ColorSetting)
|
|
||||||
{
|
|
||||||
ColorSetting color = (ColorSetting) setting;
|
|
||||||
|
|
||||||
if(color.getColorSettingName() ==
|
|
||||||
ColorSettingName.CHANNEL_STATE_LABEL_AUX_DECODER)
|
|
||||||
{
|
|
||||||
mFromLabel.setForeground(color.getColor());
|
|
||||||
mFrom.setForeground(color.getColor());
|
|
||||||
mFromAlias.setForeground(color.getColor());
|
|
||||||
mToLabel.setForeground(color.getColor());
|
|
||||||
mTo.setForeground(color.getColor());
|
|
||||||
mToAlias.setForeground(color.getColor());
|
|
||||||
mProtocol.setForeground(color.getColor());
|
|
||||||
mMessageType.setForeground(color.getColor());
|
|
||||||
mMessage.setForeground(color.getColor());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,6 +1,6 @@
|
|||||||
/*******************************************************************************
|
/*******************************************************************************
|
||||||
* SDR Trunk
|
* sdrtrunk
|
||||||
* Copyright (C) 2014,2015 Dennis Sheirer
|
* Copyright (C) 2014-2017 Dennis Sheirer
|
||||||
*
|
*
|
||||||
* This program is free software: you can redistribute it and/or modify
|
* 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
|
* it under the terms of the GNU General Public License as published by
|
||||||
@@ -14,38 +14,43 @@
|
|||||||
*
|
*
|
||||||
* You should have received a copy of the GNU General Public License
|
* You should have received a copy of the GNU General Public License
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>
|
* along with this program. If not, see <http://www.gnu.org/licenses/>
|
||||||
|
*
|
||||||
******************************************************************************/
|
******************************************************************************/
|
||||||
package module.decode.mdc1200;
|
package module.decode.mdc1200;
|
||||||
|
|
||||||
|
import alias.Alias;
|
||||||
|
import alias.AliasList;
|
||||||
|
import alias.id.AliasIDType;
|
||||||
|
import channel.metadata.AliasedStringAttributeMonitor;
|
||||||
|
import channel.metadata.Attribute;
|
||||||
|
import channel.metadata.AttributeChangeRequest;
|
||||||
|
import channel.state.DecoderState;
|
||||||
|
import channel.state.DecoderStateEvent;
|
||||||
|
import channel.state.DecoderStateEvent.Event;
|
||||||
|
import channel.state.State;
|
||||||
|
import message.Message;
|
||||||
|
import module.decode.DecoderType;
|
||||||
|
import util.StringUtils;
|
||||||
|
|
||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
import java.util.TreeSet;
|
import java.util.TreeSet;
|
||||||
import java.util.concurrent.ScheduledExecutorService;
|
import java.util.concurrent.ScheduledExecutorService;
|
||||||
|
|
||||||
import message.Message;
|
|
||||||
import module.decode.DecoderType;
|
|
||||||
import module.decode.state.ChangedAttribute;
|
|
||||||
import module.decode.state.DecoderState;
|
|
||||||
import module.decode.state.DecoderStateEvent;
|
|
||||||
import module.decode.state.State;
|
|
||||||
import module.decode.state.DecoderStateEvent.Event;
|
|
||||||
import alias.Alias;
|
|
||||||
import alias.AliasList;
|
|
||||||
|
|
||||||
public class MDCDecoderState extends DecoderState
|
public class MDCDecoderState extends DecoderState
|
||||||
{
|
{
|
||||||
private TreeSet<String> mIdents = new TreeSet<String>();
|
private TreeSet<String> mIdents = new TreeSet<String>();
|
||||||
private TreeSet<String> mEmergencyIdents = new TreeSet<String>();
|
private TreeSet<String> mEmergencyIdents = new TreeSet<String>();
|
||||||
|
|
||||||
private String mFrom;
|
private AliasedStringAttributeMonitor mFromAttribute;
|
||||||
private Alias mFromAlias;
|
|
||||||
private String mTo;
|
|
||||||
private Alias mToAlias;
|
|
||||||
private String mMessage;
|
private String mMessage;
|
||||||
private String mMessageType;
|
private String mMessageType;
|
||||||
|
|
||||||
public MDCDecoderState(AliasList aliasList)
|
public MDCDecoderState(AliasList aliasList)
|
||||||
{
|
{
|
||||||
super(aliasList);
|
super(aliasList);
|
||||||
|
|
||||||
|
mFromAttribute = new AliasedStringAttributeMonitor(Attribute.SECONDARY_ADDRESS_FROM,
|
||||||
|
getAttributeChangeRequestListener(), getAliasList(), AliasIDType.MDC1200);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -75,12 +80,9 @@ public class MDCDecoderState extends DecoderState
|
|||||||
|
|
||||||
private void resetState()
|
private void resetState()
|
||||||
{
|
{
|
||||||
setFrom( null );
|
mFromAttribute.reset();
|
||||||
setFromAlias( null );
|
mMessage = null;
|
||||||
setTo( null);
|
mMessageType = null;
|
||||||
setToAlias( null );
|
|
||||||
setMessage( null );
|
|
||||||
setMessageType( null );
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -97,8 +99,7 @@ public class MDCDecoderState extends DecoderState
|
|||||||
mEmergencyIdents.add(mdc.getUnitID());
|
mEmergencyIdents.add(mdc.getUnitID());
|
||||||
}
|
}
|
||||||
|
|
||||||
setFrom( mdc.getFromID() );
|
mFromAttribute.process(mdc.getFromID());
|
||||||
setFromAlias( mdc.getFromIDAlias() );
|
|
||||||
|
|
||||||
MDCMessageType type = mdc.getMessageType();
|
MDCMessageType type = mdc.getMessageType();
|
||||||
|
|
||||||
@@ -142,59 +143,18 @@ public class MDCDecoderState extends DecoderState
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getFrom()
|
|
||||||
{
|
|
||||||
return mFrom;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setFrom( String from )
|
|
||||||
{
|
|
||||||
mFrom = from;
|
|
||||||
broadcast( ChangedAttribute.FROM_TALKGROUP );
|
|
||||||
}
|
|
||||||
|
|
||||||
public Alias getFromAlias()
|
|
||||||
{
|
|
||||||
return mFromAlias;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setFromAlias( Alias alias )
|
|
||||||
{
|
|
||||||
mFromAlias = alias;
|
|
||||||
broadcast( ChangedAttribute.FROM_TALKGROUP_ALIAS );
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getTo()
|
|
||||||
{
|
|
||||||
return mTo;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setTo( String to )
|
|
||||||
{
|
|
||||||
mTo = to;
|
|
||||||
broadcast( ChangedAttribute.TO_TALKGROUP );
|
|
||||||
}
|
|
||||||
|
|
||||||
public Alias getToAlias()
|
|
||||||
{
|
|
||||||
return mToAlias;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setToAlias( Alias alias )
|
|
||||||
{
|
|
||||||
mToAlias = alias;
|
|
||||||
broadcast( ChangedAttribute.TO_TALKGROUP_ALIAS );
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getMessage()
|
public String getMessage()
|
||||||
{
|
{
|
||||||
return mMessage;
|
return mMessage;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setMessage(String message)
|
public void setMessage(String message)
|
||||||
|
{
|
||||||
|
if(!StringUtils.isEqual(mMessage, message))
|
||||||
{
|
{
|
||||||
mMessage = message;
|
mMessage = message;
|
||||||
broadcast( ChangedAttribute.MESSAGE );
|
broadcast(new AttributeChangeRequest<String>(Attribute.MESSAGE, mMessage));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getMessageType()
|
public String getMessageType()
|
||||||
@@ -203,9 +163,12 @@ public class MDCDecoderState extends DecoderState
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void setMessageType(String type)
|
public void setMessageType(String type)
|
||||||
|
{
|
||||||
|
if(!StringUtils.isEqual(mMessageType, type))
|
||||||
{
|
{
|
||||||
mMessageType = type;
|
mMessageType = type;
|
||||||
broadcast( ChangedAttribute.MESSAGE_TYPE );
|
broadcast(new AttributeChangeRequest<String>(Attribute.MESSAGE_TYPE, "MDC:" + mMessageType));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
/*******************************************************************************
|
/*******************************************************************************
|
||||||
* SDR Trunk
|
* sdrtrunk
|
||||||
* Copyright (C) 2014 Dennis Sheirer
|
* Copyright (C) 2014-2017 Dennis Sheirer
|
||||||
*
|
*
|
||||||
* This program is free software: you can redistribute it and/or modify
|
* 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
|
* it under the terms of the GNU General Public License as published by
|
||||||
@@ -14,49 +14,44 @@
|
|||||||
*
|
*
|
||||||
* You should have received a copy of the GNU General Public License
|
* You should have received a copy of the GNU General Public License
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>
|
* along with this program. If not, see <http://www.gnu.org/licenses/>
|
||||||
|
*
|
||||||
******************************************************************************/
|
******************************************************************************/
|
||||||
package module.decode.mpt1327;
|
package module.decode.mpt1327;
|
||||||
|
|
||||||
|
import alias.AliasList;
|
||||||
|
import bits.MessageFramer;
|
||||||
|
import bits.SyncPattern;
|
||||||
|
import dsp.filter.Filters;
|
||||||
|
import dsp.filter.dc.DCRemovalFilterLyons;
|
||||||
|
import dsp.filter.fir.real.RealFIRFilter_RB_RB;
|
||||||
|
import dsp.filter.halfband.real.HalfBandFilter_RB_RB;
|
||||||
|
import dsp.fsk.FSK2Decoder;
|
||||||
|
import dsp.fsk.FSK2Decoder.Output;
|
||||||
import instrument.Instrumentable;
|
import instrument.Instrumentable;
|
||||||
import instrument.tap.Tap;
|
import instrument.tap.Tap;
|
||||||
import instrument.tap.TapGroup;
|
import instrument.tap.TapGroup;
|
||||||
import instrument.tap.stream.BinaryTap;
|
import instrument.tap.stream.BinaryTap;
|
||||||
import instrument.tap.stream.FloatBufferTap;
|
import instrument.tap.stream.FloatBufferTap;
|
||||||
import instrument.tap.stream.FloatTap;
|
import instrument.tap.stream.FloatTap;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.concurrent.ScheduledExecutorService;
|
|
||||||
|
|
||||||
import module.decode.Decoder;
|
import module.decode.Decoder;
|
||||||
import module.decode.DecoderType;
|
import module.decode.DecoderType;
|
||||||
|
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
import sample.Broadcaster;
|
import sample.Broadcaster;
|
||||||
import sample.Listener;
|
import sample.Listener;
|
||||||
import sample.real.IFilteredRealBufferListener;
|
import sample.real.IFilteredRealBufferListener;
|
||||||
import sample.real.RealBuffer;
|
import sample.real.RealBuffer;
|
||||||
import alias.AliasList;
|
|
||||||
import bits.MessageFramer;
|
import java.util.ArrayList;
|
||||||
import bits.SyncPattern;
|
import java.util.List;
|
||||||
import dsp.filter.FilterFactory;
|
import java.util.concurrent.ScheduledExecutorService;
|
||||||
import dsp.filter.Filters;
|
|
||||||
import dsp.filter.Window.WindowType;
|
|
||||||
import dsp.filter.dc.DCRemovalFilterLyons;
|
|
||||||
import dsp.filter.fir.real.RealFIRFilter_RB_RB;
|
|
||||||
import dsp.filter.halfband.real.HalfBandFilter_RB_RB;
|
|
||||||
import dsp.fsk.FSK2Decoder;
|
|
||||||
import dsp.fsk.FSK2Decoder.Output;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* MPT1327 Decoder - 1200 baud 2FSK decoder that can process 48k sample rate
|
* MPT1327 Decoder - 1200 baud 2FSK decoder that can process 48k sample rate
|
||||||
* complex or floating point samples and output fully framed MPT1327 control and
|
* complex or floating point samples and output fully framed MPT1327 control and
|
||||||
* traffic messages.
|
* traffic messages.
|
||||||
*/
|
*/
|
||||||
public class MPT1327Decoder extends Decoder
|
public class MPT1327Decoder extends Decoder implements IFilteredRealBufferListener, Instrumentable
|
||||||
implements IFilteredRealBufferListener, Instrumentable
|
|
||||||
{
|
{
|
||||||
private final static Logger mLog = LoggerFactory.getLogger(MPT1327Decoder.class);
|
private final static Logger mLog = LoggerFactory.getLogger(MPT1327Decoder.class);
|
||||||
|
|
||||||
@@ -90,21 +85,8 @@ public class MPT1327Decoder extends Decoder
|
|||||||
|
|
||||||
public MPT1327Decoder(AliasList aliasList, Sync sync)
|
public MPT1327Decoder(AliasList aliasList, Sync sync)
|
||||||
{
|
{
|
||||||
|
|
||||||
/* Decimation filter - 48000 / 2 = 24000 output */
|
/* Decimation filter - 48000 / 2 = 24000 output */
|
||||||
mDecimationFilter = new HalfBandFilter_RB_RB(
|
mDecimationFilter = new HalfBandFilter_RB_RB(Filters.FIR_HALF_BAND_31T_ONE_EIGHTH_FCO.getCoefficients(), 1.0002f, true);
|
||||||
Filters.FIR_HALF_BAND_31T_ONE_EIGHTH_FCO.getCoefficients(), 1.0002f, true );
|
|
||||||
|
|
||||||
/* Low pass filter: 2kHz to pass the 1200 & 1800 Hz FSK */
|
|
||||||
mLowPassFilter = new RealFIRFilter_RB_RB(
|
|
||||||
FilterFactory.getLowPass( 24000, //sampleRate,
|
|
||||||
2000, //passFrequency,
|
|
||||||
4000, //stopFrequency,
|
|
||||||
60, //attenuation,
|
|
||||||
WindowType.HANNING, //windowType,
|
|
||||||
true ) //forceOddLength
|
|
||||||
, 2.0f ); //Gain
|
|
||||||
mDecimationFilter.setListener( mLowPassFilter );
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Normal: 2FSK Decoder with inverted output
|
* Normal: 2FSK Decoder with inverted output
|
||||||
@@ -122,21 +104,18 @@ public class MPT1327Decoder extends Decoder
|
|||||||
{
|
{
|
||||||
throw new IllegalArgumentException("MPT1327 Decoder - unrecognized Sync type");
|
throw new IllegalArgumentException("MPT1327 Decoder - unrecognized Sync type");
|
||||||
}
|
}
|
||||||
mLowPassFilter.setListener( mFSKDecoder );
|
|
||||||
|
mDecimationFilter.setListener(mFSKDecoder);
|
||||||
|
|
||||||
mSymbolBroadcaster = new Broadcaster<Boolean>();
|
mSymbolBroadcaster = new Broadcaster<Boolean>();
|
||||||
mFSKDecoder.setListener(mSymbolBroadcaster);
|
mFSKDecoder.setListener(mSymbolBroadcaster);
|
||||||
|
|
||||||
/* Message framer for control channel messages */
|
/* Message framer for control channel messages */
|
||||||
mControlMessageFramer =
|
mControlMessageFramer = new MessageFramer(sync.getControlSyncPattern().getPattern(), sMESSAGE_LENGTH);
|
||||||
new MessageFramer( sync.getControlSyncPattern().getPattern(),
|
|
||||||
sMESSAGE_LENGTH );
|
|
||||||
mSymbolBroadcaster.addListener(mControlMessageFramer);
|
mSymbolBroadcaster.addListener(mControlMessageFramer);
|
||||||
|
|
||||||
/* Message framer for traffic channel massages */
|
/* Message framer for traffic channel massages */
|
||||||
mTrafficMessageFramer =
|
mTrafficMessageFramer = new MessageFramer(sync.getTrafficSyncPattern().getPattern(), sMESSAGE_LENGTH);
|
||||||
new MessageFramer( sync.getTrafficSyncPattern().getPattern(),
|
|
||||||
sMESSAGE_LENGTH );
|
|
||||||
mSymbolBroadcaster.addListener(mTrafficMessageFramer);
|
mSymbolBroadcaster.addListener(mTrafficMessageFramer);
|
||||||
|
|
||||||
/* Fully decoded and framed messages processor */
|
/* Fully decoded and framed messages processor */
|
||||||
@@ -195,12 +174,9 @@ public class MPT1327Decoder extends Decoder
|
|||||||
|
|
||||||
TapGroup group = new TapGroup("MPT-1327 Decoder");
|
TapGroup group = new TapGroup("MPT-1327 Decoder");
|
||||||
|
|
||||||
group.add(
|
group.add(new FloatTap(INSTRUMENT_HB1_FILTER_TO_LOW_PASS, 0, 0.5f));
|
||||||
new FloatTap( INSTRUMENT_HB1_FILTER_TO_LOW_PASS, 0, 0.5f ) );
|
group.add(new FloatTap(INSTRUMENT_LOW_PASS_TO_DECODER, 0, 0.5f));
|
||||||
group.add(
|
group.add(new BinaryTap(INSTRUMENT_DECODER_TO_FRAMER, 0, 0.025f));
|
||||||
new FloatTap( INSTRUMENT_LOW_PASS_TO_DECODER, 0, 0.5f ) );
|
|
||||||
group.add(
|
|
||||||
new BinaryTap( INSTRUMENT_DECODER_TO_FRAMER, 0, 0.025f ) );
|
|
||||||
|
|
||||||
mAvailableTaps.add(group);
|
mAvailableTaps.add(group);
|
||||||
|
|
||||||
@@ -258,20 +234,14 @@ public class MPT1327Decoder extends Decoder
|
|||||||
|
|
||||||
public enum Sync
|
public enum Sync
|
||||||
{
|
{
|
||||||
NORMAL( "Normal",
|
NORMAL("Normal", SyncPattern.MPT1327_CONTROL, SyncPattern.MPT1327_TRAFFIC),
|
||||||
SyncPattern.MPT1327_CONTROL,
|
FRENCH("French", SyncPattern.MPT1327_CONTROL_FRENCH, SyncPattern.MPT1327_TRAFFIC_FRENCH);
|
||||||
SyncPattern.MPT1327_TRAFFIC ),
|
|
||||||
FRENCH( "French",
|
|
||||||
SyncPattern.MPT1327_CONTROL_FRENCH,
|
|
||||||
SyncPattern.MPT1327_TRAFFIC_FRENCH );
|
|
||||||
|
|
||||||
private String mLabel;
|
private String mLabel;
|
||||||
private SyncPattern mControlSyncPattern;
|
private SyncPattern mControlSyncPattern;
|
||||||
private SyncPattern mTrafficSyncPattern;
|
private SyncPattern mTrafficSyncPattern;
|
||||||
|
|
||||||
private Sync( String label,
|
private Sync(String label, SyncPattern controlPattern, SyncPattern trafficPattern)
|
||||||
SyncPattern controlPattern,
|
|
||||||
SyncPattern trafficPattern )
|
|
||||||
{
|
{
|
||||||
mLabel = label;
|
mLabel = label;
|
||||||
mControlSyncPattern = controlPattern;
|
mControlSyncPattern = controlPattern;
|
||||||
@@ -310,13 +280,11 @@ public class MPT1327Decoder extends Decoder
|
|||||||
public void start(ScheduledExecutorService executor)
|
public void start(ScheduledExecutorService executor)
|
||||||
{
|
{
|
||||||
// TODO Auto-generated method stub
|
// TODO Auto-generated method stub
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void stop()
|
public void stop()
|
||||||
{
|
{
|
||||||
// TODO Auto-generated method stub
|
// TODO Auto-generated method stub
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,200 +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 module.decode.mpt1327;
|
|
||||||
|
|
||||||
import controller.channel.Channel.ChannelType;
|
|
||||||
import icon.IconManager;
|
|
||||||
import module.decode.state.ChangedAttribute;
|
|
||||||
import module.decode.state.DecoderPanel;
|
|
||||||
import net.miginfocom.swing.MigLayout;
|
|
||||||
import settings.ColorSetting;
|
|
||||||
import settings.Setting;
|
|
||||||
import settings.SettingsManager;
|
|
||||||
|
|
||||||
import javax.swing.*;
|
|
||||||
import java.awt.*;
|
|
||||||
|
|
||||||
public class MPT1327DecoderPanel extends DecoderPanel
|
|
||||||
{
|
|
||||||
private static final long serialVersionUID = 1L;
|
|
||||||
|
|
||||||
private JLabel mProtocol = new JLabel("");
|
|
||||||
private JLabel mSiteOrToTalkgroup = new JLabel("");
|
|
||||||
private JLabel mSiteOrToTalkgroupAlias = new JLabel("");
|
|
||||||
|
|
||||||
private JLabel mFromTalkgroupLabel = new JLabel("");
|
|
||||||
private JLabel mFromTalkgroup = new JLabel("");
|
|
||||||
private JLabel mFromTalkgroupAliasLabel = new JLabel("");
|
|
||||||
|
|
||||||
public MPT1327DecoderPanel(IconManager iconManager, SettingsManager settingsManager, MPT1327DecoderState decoderState)
|
|
||||||
{
|
|
||||||
super(iconManager, settingsManager, decoderState);
|
|
||||||
|
|
||||||
init();
|
|
||||||
}
|
|
||||||
|
|
||||||
public MPT1327DecoderState getDecoderState()
|
|
||||||
{
|
|
||||||
return (MPT1327DecoderState) super.getDecoderState();
|
|
||||||
}
|
|
||||||
|
|
||||||
public void dispose()
|
|
||||||
{
|
|
||||||
super.dispose();
|
|
||||||
}
|
|
||||||
|
|
||||||
public void init()
|
|
||||||
{
|
|
||||||
super.init();
|
|
||||||
|
|
||||||
setLayout(new MigLayout("insets 0 0 0 0", "[grow,fill]", "[]0[]0[]"));
|
|
||||||
|
|
||||||
mProtocol.setText("MPT1327");
|
|
||||||
mProtocol.setFont(mFontDecoder);
|
|
||||||
mProtocol.setForeground(mColorLabelDecoder);
|
|
||||||
|
|
||||||
MPT1327DecoderState mptState = getDecoderState();
|
|
||||||
|
|
||||||
mSiteOrToTalkgroup.setFont(mFontDecoder);
|
|
||||||
mSiteOrToTalkgroup.setForeground(mColorLabelDecoder);
|
|
||||||
|
|
||||||
mSiteOrToTalkgroupAlias.setFont(mFontDecoder);
|
|
||||||
mSiteOrToTalkgroupAlias.setForeground(mColorLabelDecoder);
|
|
||||||
|
|
||||||
mFromTalkgroupLabel.setFont(mFontDetails);
|
|
||||||
mFromTalkgroupLabel.setForeground(mColorLabelDetails);
|
|
||||||
|
|
||||||
mFromTalkgroup.setFont(mFontDecoder);
|
|
||||||
mFromTalkgroup.setForeground(mColorLabelDecoder);
|
|
||||||
|
|
||||||
mFromTalkgroupAliasLabel.setFont(mFontDecoder);
|
|
||||||
mFromTalkgroupAliasLabel.setForeground(mColorLabelDecoder);
|
|
||||||
|
|
||||||
|
|
||||||
switch(mptState.getChannelType())
|
|
||||||
{
|
|
||||||
case STANDARD:
|
|
||||||
mSiteOrToTalkgroup.setText(mptState.getSite());
|
|
||||||
setAliasLabel(mSiteOrToTalkgroupAlias, mptState.getSiteAlias());
|
|
||||||
break;
|
|
||||||
case TRAFFIC:
|
|
||||||
mSiteOrToTalkgroup.setText(mptState.getToTalkgroup());
|
|
||||||
setAliasLabel(mSiteOrToTalkgroupAlias, mptState.getToTalkgroupAlias());
|
|
||||||
|
|
||||||
mFromTalkgroupLabel.setText("From:");
|
|
||||||
mFromTalkgroup.setText(getDecoderState().getFromTalkgroup());
|
|
||||||
setAliasLabel(mFromTalkgroupAliasLabel, mptState.getFromTalkgroupAlias());
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
throw new IllegalArgumentException("Unrecognized channel "
|
|
||||||
+ "type in MPT1327 Decoder [" + getDecoderState()
|
|
||||||
.getChannelType().name() + "]");
|
|
||||||
}
|
|
||||||
|
|
||||||
add(mProtocol);
|
|
||||||
add(mSiteOrToTalkgroup);
|
|
||||||
add(mSiteOrToTalkgroupAlias, "wrap");
|
|
||||||
|
|
||||||
if(mptState.getChannelType() == ChannelType.TRAFFIC)
|
|
||||||
{
|
|
||||||
add(mFromTalkgroupLabel);
|
|
||||||
add(mFromTalkgroup);
|
|
||||||
add(mFromTalkgroupAliasLabel, "wrap");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void receive(final ChangedAttribute changedAttribute)
|
|
||||||
{
|
|
||||||
final MPT1327DecoderState state = getDecoderState();
|
|
||||||
|
|
||||||
EventQueue.invokeLater(new Runnable()
|
|
||||||
{
|
|
||||||
@Override
|
|
||||||
public void run()
|
|
||||||
{
|
|
||||||
switch(changedAttribute)
|
|
||||||
{
|
|
||||||
case CHANNEL_SITE_NUMBER:
|
|
||||||
mSiteOrToTalkgroup.setText(String.valueOf(state.getSite()));
|
|
||||||
setAliasLabel(mSiteOrToTalkgroupAlias, state.getSiteAlias(), false);
|
|
||||||
repaint();
|
|
||||||
break;
|
|
||||||
case TO_TALKGROUP:
|
|
||||||
mSiteOrToTalkgroup.setText(state.getToTalkgroup());
|
|
||||||
setAliasLabel(mSiteOrToTalkgroupAlias, state.getToTalkgroupAlias());
|
|
||||||
repaint();
|
|
||||||
break;
|
|
||||||
case FROM_TALKGROUP:
|
|
||||||
mFromTalkgroup.setText(state.getFromTalkgroup());
|
|
||||||
setAliasLabel(mFromTalkgroupAliasLabel, state.getFromTalkgroupAlias());
|
|
||||||
repaint();
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void settingChanged(Setting setting)
|
|
||||||
{
|
|
||||||
super.settingChanged(setting);
|
|
||||||
|
|
||||||
if(setting instanceof ColorSetting)
|
|
||||||
{
|
|
||||||
ColorSetting colorSetting = (ColorSetting) setting;
|
|
||||||
|
|
||||||
switch(colorSetting.getColorSettingName())
|
|
||||||
{
|
|
||||||
case CHANNEL_STATE_LABEL_DECODER:
|
|
||||||
if(mProtocol != null)
|
|
||||||
{
|
|
||||||
mProtocol.setForeground(mColorLabelDecoder);
|
|
||||||
}
|
|
||||||
if(mSiteOrToTalkgroup != null)
|
|
||||||
{
|
|
||||||
mSiteOrToTalkgroup.setForeground(mColorLabelDecoder);
|
|
||||||
}
|
|
||||||
if(mSiteOrToTalkgroupAlias != null)
|
|
||||||
{
|
|
||||||
mSiteOrToTalkgroupAlias.setForeground(mColorLabelDecoder);
|
|
||||||
}
|
|
||||||
if(mFromTalkgroup != null)
|
|
||||||
{
|
|
||||||
mFromTalkgroup.setForeground(mColorLabelDecoder);
|
|
||||||
}
|
|
||||||
if(mFromTalkgroupAliasLabel != null)
|
|
||||||
{
|
|
||||||
mFromTalkgroupAliasLabel.setForeground(mColorLabelDecoder);
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case CHANNEL_STATE_LABEL_DETAILS:
|
|
||||||
if(mFromTalkgroupLabel != null)
|
|
||||||
{
|
|
||||||
mFromTalkgroupLabel.setForeground(mColorLabelDetails);
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,6 +1,6 @@
|
|||||||
/*******************************************************************************
|
/*******************************************************************************
|
||||||
* SDR Trunk
|
* sdrtrunk
|
||||||
* Copyright (C) 2014-2016 Dennis Sheirer
|
* Copyright (C) 2014-2017 Dennis Sheirer
|
||||||
*
|
*
|
||||||
* This program is free software: you can redistribute it and/or modify
|
* 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
|
* it under the terms of the GNU General Public License as published by
|
||||||
@@ -14,9 +14,34 @@
|
|||||||
*
|
*
|
||||||
* You should have received a copy of the GNU General Public License
|
* You should have received a copy of the GNU General Public License
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>
|
* along with this program. If not, see <http://www.gnu.org/licenses/>
|
||||||
|
*
|
||||||
******************************************************************************/
|
******************************************************************************/
|
||||||
package module.decode.mpt1327;
|
package module.decode.mpt1327;
|
||||||
|
|
||||||
|
import alias.Alias;
|
||||||
|
import alias.AliasList;
|
||||||
|
import alias.id.AliasIDType;
|
||||||
|
import channel.metadata.AliasedStringAttributeMonitor;
|
||||||
|
import channel.metadata.Attribute;
|
||||||
|
import channel.metadata.AttributeChangeRequest;
|
||||||
|
import channel.state.ChangeChannelTimeoutEvent;
|
||||||
|
import channel.state.DecoderState;
|
||||||
|
import channel.state.DecoderStateEvent;
|
||||||
|
import channel.state.DecoderStateEvent.Event;
|
||||||
|
import channel.state.State;
|
||||||
|
import channel.traffic.TrafficChannelAllocationEvent;
|
||||||
|
import controller.channel.Channel.ChannelType;
|
||||||
|
import controller.channel.map.ChannelMap;
|
||||||
|
import message.Message;
|
||||||
|
import module.decode.DecoderType;
|
||||||
|
import module.decode.config.DecodeConfiguration;
|
||||||
|
import module.decode.event.CallEvent;
|
||||||
|
import module.decode.event.CallEvent.CallEventType;
|
||||||
|
import module.decode.mpt1327.MPT1327Message.IdentType;
|
||||||
|
import org.slf4j.Logger;
|
||||||
|
import org.slf4j.LoggerFactory;
|
||||||
|
import util.StringUtils;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
@@ -25,30 +50,6 @@ import java.util.List;
|
|||||||
import java.util.TreeSet;
|
import java.util.TreeSet;
|
||||||
import java.util.concurrent.ScheduledExecutorService;
|
import java.util.concurrent.ScheduledExecutorService;
|
||||||
|
|
||||||
import message.Message;
|
|
||||||
import module.decode.DecoderType;
|
|
||||||
import module.decode.config.DecodeConfiguration;
|
|
||||||
import module.decode.event.CallEvent;
|
|
||||||
import module.decode.event.CallEvent.CallEventType;
|
|
||||||
import module.decode.mpt1327.MPT1327Message.IdentType;
|
|
||||||
import module.decode.state.ChangeChannelTimeoutEvent;
|
|
||||||
import module.decode.state.ChangedAttribute;
|
|
||||||
import module.decode.state.DecoderState;
|
|
||||||
import module.decode.state.DecoderStateEvent;
|
|
||||||
import module.decode.state.DecoderStateEvent.Event;
|
|
||||||
import module.decode.state.State;
|
|
||||||
import module.decode.state.TrafficChannelAllocationEvent;
|
|
||||||
|
|
||||||
import org.slf4j.Logger;
|
|
||||||
import org.slf4j.LoggerFactory;
|
|
||||||
|
|
||||||
import alias.Alias;
|
|
||||||
import alias.AliasList;
|
|
||||||
import audio.metadata.Metadata;
|
|
||||||
import audio.metadata.MetadataType;
|
|
||||||
import controller.channel.Channel.ChannelType;
|
|
||||||
import controller.channel.map.ChannelMap;
|
|
||||||
|
|
||||||
public class MPT1327DecoderState extends DecoderState
|
public class MPT1327DecoderState extends DecoderState
|
||||||
{
|
{
|
||||||
private final static Logger mLog = LoggerFactory.getLogger(MPT1327DecoderState.class);
|
private final static Logger mLog = LoggerFactory.getLogger(MPT1327DecoderState.class);
|
||||||
@@ -57,8 +58,8 @@ public class MPT1327DecoderState extends DecoderState
|
|||||||
private HashMap<String,ArrayList<String>> mGroups = new HashMap<String,ArrayList<String>>();
|
private HashMap<String,ArrayList<String>> mGroups = new HashMap<String,ArrayList<String>>();
|
||||||
|
|
||||||
private String mSite;
|
private String mSite;
|
||||||
private String mFromTalkgroup;
|
private AliasedStringAttributeMonitor mFromAttribute;
|
||||||
private String mToTalkgroup;
|
private AliasedStringAttributeMonitor mToAttribute;
|
||||||
|
|
||||||
private int mChannelNumber;
|
private int mChannelNumber;
|
||||||
private ChannelType mChannelType;
|
private ChannelType mChannelType;
|
||||||
@@ -67,16 +68,17 @@ public class MPT1327DecoderState extends DecoderState
|
|||||||
private long mFrequency = 0;
|
private long mFrequency = 0;
|
||||||
private long mCallTimeout;
|
private long mCallTimeout;
|
||||||
|
|
||||||
public MPT1327DecoderState( AliasList aliasList,
|
public MPT1327DecoderState(AliasList aliasList, ChannelMap channelMap, ChannelType channelType, long callTimeout)
|
||||||
ChannelMap channelMap,
|
|
||||||
ChannelType channelType,
|
|
||||||
long callTimeout )
|
|
||||||
{
|
{
|
||||||
super(aliasList);
|
super(aliasList);
|
||||||
|
|
||||||
mChannelMap = channelMap;
|
mChannelMap = channelMap;
|
||||||
mChannelType = channelType;
|
mChannelType = channelType;
|
||||||
mCallTimeout = callTimeout;
|
mCallTimeout = callTimeout;
|
||||||
|
mFromAttribute = new AliasedStringAttributeMonitor(Attribute.PRIMARY_ADDRESS_FROM,
|
||||||
|
getAttributeChangeRequestListener(), getAliasList(), AliasIDType.MPT1327);
|
||||||
|
mToAttribute = new AliasedStringAttributeMonitor(Attribute.PRIMARY_ADDRESS_TO,
|
||||||
|
getAttributeChangeRequestListener(), getAliasList(), AliasIDType.MPT1327);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -179,15 +181,7 @@ public class MPT1327DecoderState extends DecoderState
|
|||||||
broadcast(new DecoderStateEvent(this, Event.CONTINUATION, State.CONTROL));
|
broadcast(new DecoderStateEvent(this, Event.CONTINUATION, State.CONTROL));
|
||||||
break;
|
break;
|
||||||
case ALH:
|
case ALH:
|
||||||
String site = mpt.getSiteID();
|
setSite(mpt.getSiteID());
|
||||||
|
|
||||||
if( site != null && ( mSite == null || !site.contentEquals( mSite ) ) )
|
|
||||||
{
|
|
||||||
mSite = site;
|
|
||||||
broadcast( ChangedAttribute.CHANNEL_SITE_NUMBER );
|
|
||||||
}
|
|
||||||
mSite = mpt.getSiteID();
|
|
||||||
|
|
||||||
broadcast(new DecoderStateEvent(this, Event.START, State.CONTROL));
|
broadcast(new DecoderStateEvent(this, Event.START, State.CONTROL));
|
||||||
break;
|
break;
|
||||||
case GTC:
|
case GTC:
|
||||||
@@ -289,12 +283,9 @@ public class MPT1327DecoderState extends DecoderState
|
|||||||
broadcast(mCurrentCallEvent);
|
broadcast(mCurrentCallEvent);
|
||||||
}
|
}
|
||||||
|
|
||||||
broadcast(new Metadata(MetadataType.TO,
|
mToAttribute.process(mpt.getToID());
|
||||||
mpt.getToID(), mpt.getToIDAlias(), true));
|
|
||||||
|
|
||||||
broadcast(new DecoderStateEvent(this, Event.START, State.CALL));
|
broadcast(new DecoderStateEvent(this, Event.START, State.CALL));
|
||||||
|
|
||||||
setToTalkgroup( mpt.getToID() );
|
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
@@ -313,11 +304,8 @@ public class MPT1327DecoderState extends DecoderState
|
|||||||
|
|
||||||
private void resetState()
|
private void resetState()
|
||||||
{
|
{
|
||||||
mFromTalkgroup = null;
|
mFromAttribute.reset();
|
||||||
broadcast( ChangedAttribute.FROM_TALKGROUP );
|
mToAttribute.reset();
|
||||||
|
|
||||||
mToTalkgroup = null;
|
|
||||||
broadcast( ChangedAttribute.TO_TALKGROUP );
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* If this is a standard channel, reset the fade timeout to the default
|
* If this is a standard channel, reset the fade timeout to the default
|
||||||
@@ -344,6 +332,19 @@ public class MPT1327DecoderState extends DecoderState
|
|||||||
return mSite;
|
return mSite;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set the site number.
|
||||||
|
*/
|
||||||
|
public void setSite(String site)
|
||||||
|
{
|
||||||
|
if(!StringUtils.isEqual(mSite, site))
|
||||||
|
{
|
||||||
|
mSite = site;
|
||||||
|
broadcast(new AttributeChangeRequest<String>(Attribute.NETWORK_ID_1, "SITE:" + getSite(),
|
||||||
|
getSiteAlias()));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public Alias getSiteAlias()
|
public Alias getSiteAlias()
|
||||||
{
|
{
|
||||||
if(hasAliasList())
|
if(hasAliasList())
|
||||||
@@ -364,75 +365,23 @@ public class MPT1327DecoderState extends DecoderState
|
|||||||
mChannelMap = channelMap;
|
mChannelMap = channelMap;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getFromTalkgroup()
|
|
||||||
{
|
|
||||||
return mFromTalkgroup;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Set the talkgroup. This is used primarily for traffic channels since
|
|
||||||
* the talkgroup will already have been identified prior to the traffic
|
|
||||||
* channel being created.
|
|
||||||
*/
|
|
||||||
public void setFromTalkgroup( String fromTalkgroup )
|
|
||||||
{
|
|
||||||
mFromTalkgroup = fromTalkgroup;
|
|
||||||
|
|
||||||
broadcast( ChangedAttribute.FROM_TALKGROUP );
|
|
||||||
}
|
|
||||||
|
|
||||||
public Alias getFromTalkgroupAlias()
|
|
||||||
{
|
|
||||||
if( hasAliasList() )
|
|
||||||
{
|
|
||||||
return getAliasList().getMPT1327Alias( mFromTalkgroup );
|
|
||||||
}
|
|
||||||
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getToTalkgroup()
|
|
||||||
{
|
|
||||||
return mToTalkgroup;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Set the talkgroup. This is used primarily for traffic channels since
|
|
||||||
* the talkgroup will already have been identified prior to the traffic
|
|
||||||
* channel being created.
|
|
||||||
*/
|
|
||||||
public void setToTalkgroup( String toTalkgroup )
|
|
||||||
{
|
|
||||||
mToTalkgroup = toTalkgroup;
|
|
||||||
|
|
||||||
broadcast( ChangedAttribute.TO_TALKGROUP );
|
|
||||||
}
|
|
||||||
|
|
||||||
public Alias getToTalkgroupAlias()
|
|
||||||
{
|
|
||||||
if( hasAliasList() )
|
|
||||||
{
|
|
||||||
return getAliasList().getMPT1327Alias( mToTalkgroup );
|
|
||||||
}
|
|
||||||
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
public int getChannelNumber()
|
public int getChannelNumber()
|
||||||
{
|
{
|
||||||
return mChannelNumber;
|
return mChannelNumber;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set the channel number. This is used primarily for traffic channels since
|
* Set the channel number. This is used primarily for traffic channels since
|
||||||
* the channel will already have been identified prior to the traffic
|
* the channel will already have been identified prior to the traffic
|
||||||
* channel being created.
|
* channel being created.
|
||||||
*/
|
*/
|
||||||
public void setChannelNumber(int channel)
|
public void setChannelNumber(int channel)
|
||||||
|
{
|
||||||
|
if(mChannelNumber != channel)
|
||||||
{
|
{
|
||||||
mChannelNumber = channel;
|
mChannelNumber = channel;
|
||||||
|
broadcast(new AttributeChangeRequest<String>(Attribute.CHANNEL_FREQUENCY_LABEL, String.valueOf(mChannelNumber)));
|
||||||
broadcast( ChangedAttribute.CHANNEL_NUMBER );
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -574,6 +523,7 @@ public class MPT1327DecoderState extends DecoderState
|
|||||||
break;
|
break;
|
||||||
case SOURCE_FREQUENCY:
|
case SOURCE_FREQUENCY:
|
||||||
mFrequency = event.getFrequency();
|
mFrequency = event.getFrequency();
|
||||||
|
broadcast(new AttributeChangeRequest<Long>(Attribute.CHANNEL_FREQUENCY, event.getFrequency()));
|
||||||
break;
|
break;
|
||||||
case TRAFFIC_CHANNEL_ALLOCATION:
|
case TRAFFIC_CHANNEL_ALLOCATION:
|
||||||
if(event.getSource() != MPT1327DecoderState.this)
|
if(event.getSource() != MPT1327DecoderState.this)
|
||||||
@@ -589,8 +539,7 @@ public class MPT1327DecoderState extends DecoderState
|
|||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
mChannelNumber = Integer.valueOf( channel );
|
setChannelNumber(Integer.valueOf(channel));
|
||||||
broadcast( ChangedAttribute.CHANNEL_NUMBER );
|
|
||||||
}
|
}
|
||||||
catch(Exception e)
|
catch(Exception e)
|
||||||
{
|
{
|
||||||
@@ -599,13 +548,11 @@ public class MPT1327DecoderState extends DecoderState
|
|||||||
}
|
}
|
||||||
|
|
||||||
mFrequency = allocationEvent.getCallEvent().getFrequency();
|
mFrequency = allocationEvent.getCallEvent().getFrequency();
|
||||||
broadcast( ChangedAttribute.SOURCE );
|
broadcast(new AttributeChangeRequest<Long>(Attribute.CHANNEL_FREQUENCY,
|
||||||
|
allocationEvent.getCallEvent().getFrequency()));
|
||||||
|
|
||||||
mFromTalkgroup = allocationEvent.getCallEvent().getFromID();
|
mFromAttribute.process(allocationEvent.getCallEvent().getFromID());
|
||||||
broadcast( ChangedAttribute.FROM_TALKGROUP );
|
mToAttribute.process(allocationEvent.getCallEvent().getToID());
|
||||||
|
|
||||||
mToTalkgroup = allocationEvent.getCallEvent().getToID();
|
|
||||||
broadcast( ChangedAttribute.TO_TALKGROUP );
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|||||||
@@ -1,179 +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 module.decode.mpt1327;
|
|
||||||
|
|
||||||
import alias.Alias;
|
|
||||||
import icon.IconManager;
|
|
||||||
import module.decode.state.ChangedAttribute;
|
|
||||||
import module.decode.state.DecoderPanel;
|
|
||||||
import settings.ColorSetting;
|
|
||||||
import settings.Setting;
|
|
||||||
import settings.SettingsManager;
|
|
||||||
|
|
||||||
import javax.swing.*;
|
|
||||||
import java.awt.*;
|
|
||||||
|
|
||||||
public class MPT1327TrafficPanel extends DecoderPanel
|
|
||||||
{
|
|
||||||
private static final long serialVersionUID = 1L;
|
|
||||||
|
|
||||||
private JLabel mProtocolLabel;
|
|
||||||
private JLabel mFromTalkgroupLabel;
|
|
||||||
private JLabel mFromTalkgroupAliasLabel;
|
|
||||||
|
|
||||||
private JLabel mToLabel;
|
|
||||||
private JLabel mToTalkgroupLabel;
|
|
||||||
private JLabel mToTalkgroupAliasLabel;
|
|
||||||
|
|
||||||
public MPT1327TrafficPanel(IconManager iconManager, SettingsManager settingsManager,
|
|
||||||
MPT1327DecoderState decoderState)
|
|
||||||
{
|
|
||||||
super(iconManager, settingsManager, decoderState);
|
|
||||||
|
|
||||||
init();
|
|
||||||
}
|
|
||||||
|
|
||||||
public MPT1327DecoderState getDecoderState()
|
|
||||||
{
|
|
||||||
return (MPT1327DecoderState) super.getDecoderState();
|
|
||||||
}
|
|
||||||
|
|
||||||
public void dispose()
|
|
||||||
{
|
|
||||||
super.dispose();
|
|
||||||
}
|
|
||||||
|
|
||||||
public void init()
|
|
||||||
{
|
|
||||||
mProtocolLabel = new JLabel("MPT1327");
|
|
||||||
mProtocolLabel.setFont(mFontDecoder);
|
|
||||||
mProtocolLabel.setForeground(mColorLabelDecoder);
|
|
||||||
|
|
||||||
mFromTalkgroupLabel = new JLabel();
|
|
||||||
mFromTalkgroupLabel.setFont(mFontDecoder);
|
|
||||||
mFromTalkgroupLabel.setForeground(mColorLabelDecoder);
|
|
||||||
|
|
||||||
mFromTalkgroupAliasLabel = new JLabel();
|
|
||||||
mFromTalkgroupAliasLabel.setFont(mFontDecoder);
|
|
||||||
mFromTalkgroupAliasLabel.setForeground(mColorLabelDecoder);
|
|
||||||
|
|
||||||
mToLabel = new JLabel("TO:");
|
|
||||||
mToLabel.setFont(mFontDetails);
|
|
||||||
mToLabel.setForeground(mColorLabelDetails);
|
|
||||||
|
|
||||||
mToTalkgroupLabel = new JLabel(getDecoderState().getFromTalkgroup());
|
|
||||||
mToTalkgroupLabel.setFont(mFontDecoder);
|
|
||||||
mToTalkgroupLabel.setForeground(mColorLabelDecoder);
|
|
||||||
|
|
||||||
mToTalkgroupAliasLabel = new JLabel();
|
|
||||||
mToTalkgroupAliasLabel.setFont(mFontDecoder);
|
|
||||||
mToTalkgroupAliasLabel.setForeground(mColorLabelDecoder);
|
|
||||||
|
|
||||||
add(mProtocolLabel);
|
|
||||||
add(mFromTalkgroupLabel);
|
|
||||||
add(mFromTalkgroupAliasLabel, "wrap");
|
|
||||||
|
|
||||||
add(mToLabel);
|
|
||||||
add(mToTalkgroupLabel);
|
|
||||||
add(mToTalkgroupAliasLabel, "wrap");
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void receive(final ChangedAttribute changedAttribute)
|
|
||||||
{
|
|
||||||
final MPT1327DecoderState state = getDecoderState();
|
|
||||||
|
|
||||||
EventQueue.invokeLater(new Runnable()
|
|
||||||
{
|
|
||||||
@Override
|
|
||||||
public void run()
|
|
||||||
{
|
|
||||||
switch(changedAttribute)
|
|
||||||
{
|
|
||||||
case FROM_TALKGROUP:
|
|
||||||
String talkgroup = state.getFromTalkgroup();
|
|
||||||
|
|
||||||
mFromTalkgroupLabel.setText(talkgroup);
|
|
||||||
|
|
||||||
Alias alias = state.getFromTalkgroupAlias();
|
|
||||||
|
|
||||||
if(alias != null)
|
|
||||||
{
|
|
||||||
mFromTalkgroupAliasLabel.setText(alias.getName());
|
|
||||||
|
|
||||||
String icon = alias.getIconName();
|
|
||||||
|
|
||||||
mFromTalkgroupAliasLabel.setIcon(mIconManager.getIcon(icon, IconManager.DEFAULT_ICON_SIZE));
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case TO_TALKGROUP:
|
|
||||||
String toTalkgroup = state.getToTalkgroup();
|
|
||||||
|
|
||||||
mToTalkgroupLabel.setText(toTalkgroup);
|
|
||||||
|
|
||||||
Alias toAlias = state.getToTalkgroupAlias();
|
|
||||||
|
|
||||||
if(toAlias != null)
|
|
||||||
{
|
|
||||||
mToTalkgroupAliasLabel.setText(toAlias.getName());
|
|
||||||
|
|
||||||
String icon = toAlias.getIconName();
|
|
||||||
|
|
||||||
if(icon != null)
|
|
||||||
{
|
|
||||||
mToTalkgroupAliasLabel.setIcon(mIconManager.getIcon(icon, IconManager.DEFAULT_ICON_SIZE));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
repaint();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void settingChanged(Setting setting)
|
|
||||||
{
|
|
||||||
super.settingChanged(setting);
|
|
||||||
|
|
||||||
if(setting instanceof ColorSetting)
|
|
||||||
{
|
|
||||||
ColorSetting colorSetting = (ColorSetting) setting;
|
|
||||||
|
|
||||||
switch(colorSetting.getColorSettingName())
|
|
||||||
{
|
|
||||||
case CHANNEL_STATE_LABEL_DECODER:
|
|
||||||
mProtocolLabel.setForeground(mColorLabelDecoder);
|
|
||||||
mFromTalkgroupLabel.setForeground(mColorLabelDecoder);
|
|
||||||
mFromTalkgroupAliasLabel.setForeground(mColorLabelDecoder);
|
|
||||||
mToTalkgroupLabel.setForeground(mColorLabelDecoder);
|
|
||||||
mToTalkgroupAliasLabel.setForeground(mColorLabelDecoder);
|
|
||||||
break;
|
|
||||||
case CHANNEL_STATE_LABEL_DETAILS:
|
|
||||||
mToLabel.setForeground(mColorLabelDetails);
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,80 +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 module.decode.nbfm;
|
|
||||||
|
|
||||||
import icon.IconManager;
|
|
||||||
import module.decode.state.ChangedAttribute;
|
|
||||||
import module.decode.state.DecoderPanel;
|
|
||||||
import module.decode.state.DecoderState;
|
|
||||||
import net.miginfocom.swing.MigLayout;
|
|
||||||
import settings.ColorSetting;
|
|
||||||
import settings.ColorSetting.ColorSettingName;
|
|
||||||
import settings.Setting;
|
|
||||||
import settings.SettingsManager;
|
|
||||||
|
|
||||||
import javax.swing.*;
|
|
||||||
|
|
||||||
public class NBFMDecoderPanel extends DecoderPanel
|
|
||||||
{
|
|
||||||
private static final long serialVersionUID = 1L;
|
|
||||||
|
|
||||||
private JLabel mProtocol = new JLabel("NBFM");
|
|
||||||
|
|
||||||
public NBFMDecoderPanel(IconManager iconManager, SettingsManager settingsManager, DecoderState decoderState)
|
|
||||||
{
|
|
||||||
super(iconManager, settingsManager, decoderState);
|
|
||||||
|
|
||||||
init();
|
|
||||||
}
|
|
||||||
|
|
||||||
protected void init()
|
|
||||||
{
|
|
||||||
super.init();
|
|
||||||
|
|
||||||
setLayout(new MigLayout("insets 0 0 0 0", "[grow,fill]", "[]0[]0[]"));
|
|
||||||
|
|
||||||
mProtocol.setFont(mFontDecoder);
|
|
||||||
mProtocol.setForeground(mColorLabelDecoder);
|
|
||||||
|
|
||||||
add(mProtocol, "wrap");
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void receive(ChangedAttribute t)
|
|
||||||
{
|
|
||||||
/* Not implemented */
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void settingChanged(Setting setting)
|
|
||||||
{
|
|
||||||
super.settingChanged(setting);
|
|
||||||
|
|
||||||
if(setting instanceof ColorSetting)
|
|
||||||
{
|
|
||||||
ColorSetting color = (ColorSetting) setting;
|
|
||||||
|
|
||||||
if(color.getColorSettingName() ==
|
|
||||||
ColorSettingName.CHANNEL_STATE_LABEL_DECODER)
|
|
||||||
{
|
|
||||||
mProtocol.setForeground(color.getColor());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,226 +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 module.decode.p25;
|
|
||||||
|
|
||||||
import alias.Alias;
|
|
||||||
import icon.IconManager;
|
|
||||||
import module.decode.state.ChangedAttribute;
|
|
||||||
import module.decode.state.DecoderPanel;
|
|
||||||
import net.miginfocom.swing.MigLayout;
|
|
||||||
import settings.ColorSetting;
|
|
||||||
import settings.Setting;
|
|
||||||
import settings.SettingsManager;
|
|
||||||
|
|
||||||
import javax.swing.*;
|
|
||||||
import java.awt.*;
|
|
||||||
|
|
||||||
public class P25DecoderPanel extends DecoderPanel
|
|
||||||
{
|
|
||||||
private static final long serialVersionUID = 1L;
|
|
||||||
|
|
||||||
private JLabel mProtocol;
|
|
||||||
private JLabel mTo = new JLabel(" ");
|
|
||||||
private JLabel mToAlias = new JLabel(" ");
|
|
||||||
|
|
||||||
private JLabel mNAC = new JLabel("NAC:");
|
|
||||||
private JLabel mFrom = new JLabel(" ");
|
|
||||||
private JLabel mFromAlias = new JLabel(" ");
|
|
||||||
|
|
||||||
private JLabel mSystem = new JLabel("SYS:");
|
|
||||||
private JLabel mSite = new JLabel("Site:");
|
|
||||||
private JLabel mSiteAlias = new JLabel("");
|
|
||||||
|
|
||||||
|
|
||||||
public P25DecoderPanel(IconManager iconManager, SettingsManager settingsManager, P25DecoderState decoderState)
|
|
||||||
{
|
|
||||||
super(iconManager, settingsManager, decoderState);
|
|
||||||
|
|
||||||
mProtocol = new JLabel("P25-1 " + decoderState.getModulation().getShortLabel());
|
|
||||||
|
|
||||||
init();
|
|
||||||
}
|
|
||||||
|
|
||||||
public void init()
|
|
||||||
{
|
|
||||||
super.init();
|
|
||||||
|
|
||||||
setLayout(new MigLayout("insets 0 0 0 0", "[grow,fill]", "[]0[]0[]"));
|
|
||||||
|
|
||||||
mProtocol.setFont(mFontDecoder);
|
|
||||||
mProtocol.setForeground(mColorLabelDecoder);
|
|
||||||
|
|
||||||
mTo.setFont(mFontDecoder);
|
|
||||||
mTo.setForeground(mColorLabelDecoder);
|
|
||||||
|
|
||||||
mToAlias.setFont(mFontDecoder);
|
|
||||||
mToAlias.setForeground(mColorLabelDecoder);
|
|
||||||
|
|
||||||
mNAC.setFont(mFontDetails);
|
|
||||||
mNAC.setForeground(mColorLabelDecoder);
|
|
||||||
|
|
||||||
mFrom.setFont(mFontDecoder);
|
|
||||||
mFrom.setForeground(mColorLabelDecoder);
|
|
||||||
|
|
||||||
mFromAlias.setFont(mFontDecoder);
|
|
||||||
mFromAlias.setForeground(mColorLabelDecoder);
|
|
||||||
|
|
||||||
mSystem.setFont(mFontDetails);
|
|
||||||
mSystem.setForeground(mColorLabelDecoder);
|
|
||||||
|
|
||||||
mSiteAlias.setFont(mFontDecoder);
|
|
||||||
mSiteAlias.setForeground(mColorLabelDecoder);
|
|
||||||
|
|
||||||
mSite.setFont(mFontDetails);
|
|
||||||
mSite.setForeground(mColorLabelDecoder);
|
|
||||||
|
|
||||||
add(mProtocol);
|
|
||||||
add(mTo);
|
|
||||||
add(mToAlias, "wrap");
|
|
||||||
|
|
||||||
add(mNAC);
|
|
||||||
add(mFrom);
|
|
||||||
add(mFromAlias, "wrap");
|
|
||||||
|
|
||||||
add(mSystem);
|
|
||||||
add(mSite);
|
|
||||||
add(mSiteAlias, "wrap");
|
|
||||||
}
|
|
||||||
|
|
||||||
public P25DecoderState getDecoderState()
|
|
||||||
{
|
|
||||||
return (P25DecoderState) super.getDecoderState();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void receive(final ChangedAttribute changedAttribute)
|
|
||||||
{
|
|
||||||
final P25DecoderState state = getDecoderState();
|
|
||||||
|
|
||||||
EventQueue.invokeLater(new Runnable()
|
|
||||||
{
|
|
||||||
@Override
|
|
||||||
public void run()
|
|
||||||
{
|
|
||||||
|
|
||||||
switch(changedAttribute)
|
|
||||||
{
|
|
||||||
case NAC:
|
|
||||||
mNAC.setText("NAC:" + state.getNAC());
|
|
||||||
break;
|
|
||||||
case SYSTEM:
|
|
||||||
mSystem.setText("SYS:" + state.getSystem());
|
|
||||||
break;
|
|
||||||
case SITE:
|
|
||||||
mSite.setText("SITE:" + state.getSite());
|
|
||||||
break;
|
|
||||||
case SITE_ALIAS:
|
|
||||||
mSiteAlias.setText(state.getSiteAlias());
|
|
||||||
break;
|
|
||||||
case FROM_TALKGROUP:
|
|
||||||
if(state.getFromTalkgroup() == null)
|
|
||||||
{
|
|
||||||
mFrom.setText(" ");
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
mFrom.setText(state.getFromTalkgroup());
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case FROM_TALKGROUP_ALIAS:
|
|
||||||
Alias from = state.getFromAlias();
|
|
||||||
|
|
||||||
if(from != null)
|
|
||||||
{
|
|
||||||
mFromAlias.setText(from.getName());
|
|
||||||
|
|
||||||
final String icon = from.getIconName();
|
|
||||||
|
|
||||||
if(icon != null && mIconManager != null)
|
|
||||||
{
|
|
||||||
mFromAlias.setIcon(mIconManager.getIcon(icon, IconManager.DEFAULT_ICON_SIZE));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
mFromAlias.setText(" ");
|
|
||||||
mFromAlias.setIcon(null);
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case TO_TALKGROUP:
|
|
||||||
if(state.getToTalkgroup() == null)
|
|
||||||
{
|
|
||||||
mTo.setText(" ");
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
mTo.setText(state.getToTalkgroup());
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case TO_TALKGROUP_ALIAS:
|
|
||||||
final Alias to = state.getToAlias();
|
|
||||||
|
|
||||||
if(to != null)
|
|
||||||
{
|
|
||||||
mToAlias.setText(to.getName());
|
|
||||||
|
|
||||||
final String icon = to.getIconName();
|
|
||||||
|
|
||||||
if(icon != null && mIconManager != null)
|
|
||||||
{
|
|
||||||
mToAlias.setIcon(mIconManager.getIcon(icon, IconManager.DEFAULT_ICON_SIZE));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
mToAlias.setText(" ");
|
|
||||||
mToAlias.setIcon(null);
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
repaint();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void settingChanged(Setting setting)
|
|
||||||
{
|
|
||||||
super.settingChanged(setting);
|
|
||||||
|
|
||||||
if(setting instanceof ColorSetting)
|
|
||||||
{
|
|
||||||
ColorSetting colorSetting = (ColorSetting) setting;
|
|
||||||
|
|
||||||
switch(colorSetting.getColorSettingName())
|
|
||||||
{
|
|
||||||
case CHANNEL_STATE_LABEL_DECODER:
|
|
||||||
if(mProtocol != null)
|
|
||||||
{
|
|
||||||
mProtocol.setForeground(mColorLabelDecoder);
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -20,9 +20,17 @@ package module.decode.p25;
|
|||||||
import alias.Alias;
|
import alias.Alias;
|
||||||
import alias.AliasList;
|
import alias.AliasList;
|
||||||
import alias.PatchGroupAlias;
|
import alias.PatchGroupAlias;
|
||||||
|
import alias.id.AliasIDType;
|
||||||
import alias.id.talkgroup.TalkgroupID;
|
import alias.id.talkgroup.TalkgroupID;
|
||||||
import audio.metadata.Metadata;
|
import channel.metadata.AliasedStringAttributeMonitor;
|
||||||
import audio.metadata.MetadataType;
|
import channel.metadata.Attribute;
|
||||||
|
import channel.metadata.AttributeChangeRequest;
|
||||||
|
import channel.state.ChangeChannelTimeoutEvent;
|
||||||
|
import channel.state.DecoderState;
|
||||||
|
import channel.state.DecoderStateEvent;
|
||||||
|
import channel.state.DecoderStateEvent.Event;
|
||||||
|
import channel.state.State;
|
||||||
|
import channel.traffic.TrafficChannelAllocationEvent;
|
||||||
import controller.channel.Channel.ChannelType;
|
import controller.channel.Channel.ChannelType;
|
||||||
import message.Message;
|
import message.Message;
|
||||||
import module.decode.DecoderType;
|
import module.decode.DecoderType;
|
||||||
@@ -123,13 +131,6 @@ import module.decode.p25.reference.IPProtocol;
|
|||||||
import module.decode.p25.reference.LinkControlOpcode;
|
import module.decode.p25.reference.LinkControlOpcode;
|
||||||
import module.decode.p25.reference.Response;
|
import module.decode.p25.reference.Response;
|
||||||
import module.decode.p25.reference.Vendor;
|
import module.decode.p25.reference.Vendor;
|
||||||
import module.decode.state.ChangeChannelTimeoutEvent;
|
|
||||||
import module.decode.state.ChangedAttribute;
|
|
||||||
import module.decode.state.DecoderState;
|
|
||||||
import module.decode.state.DecoderStateEvent;
|
|
||||||
import module.decode.state.DecoderStateEvent.Event;
|
|
||||||
import module.decode.state.State;
|
|
||||||
import module.decode.state.TrafficChannelAllocationEvent;
|
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
@@ -170,14 +171,12 @@ public class P25DecoderState extends DecoderState
|
|||||||
private String mLastRegistrationEventID;
|
private String mLastRegistrationEventID;
|
||||||
private String mLastResponseEventID;
|
private String mLastResponseEventID;
|
||||||
|
|
||||||
|
//TODO: create multi-attribute monitor for NAC and System
|
||||||
private String mNAC;
|
private String mNAC;
|
||||||
private String mSystem;
|
private String mSystem;
|
||||||
private String mSite;
|
private AliasedStringAttributeMonitor mSiteAttributeMonitor;
|
||||||
private String mSiteAlias;
|
private AliasedStringAttributeMonitor mFromTalkgroupMonitor;
|
||||||
private String mFromTalkgroup;
|
private AliasedStringAttributeMonitor mToTalkgroupMonitor;
|
||||||
private Alias mFromAlias;
|
|
||||||
private String mToTalkgroup;
|
|
||||||
private Alias mToAlias;
|
|
||||||
private String mCurrentChannel = "CURRENT";
|
private String mCurrentChannel = "CURRENT";
|
||||||
private long mCurrentChannelFrequency = 0;
|
private long mCurrentChannelFrequency = 0;
|
||||||
|
|
||||||
@@ -199,6 +198,16 @@ public class P25DecoderState extends DecoderState
|
|||||||
mChannelType = channelType;
|
mChannelType = channelType;
|
||||||
mModulation = modulation;
|
mModulation = modulation;
|
||||||
mIgnoreDataCalls = ignoreDataCalls;
|
mIgnoreDataCalls = ignoreDataCalls;
|
||||||
|
|
||||||
|
mSiteAttributeMonitor = new AliasedStringAttributeMonitor(Attribute.NETWORK_ID_2,
|
||||||
|
getAttributeChangeRequestListener(), getAliasList(), AliasIDType.SITE);
|
||||||
|
mFromTalkgroupMonitor = new AliasedStringAttributeMonitor(Attribute.PRIMARY_ADDRESS_FROM,
|
||||||
|
getAttributeChangeRequestListener(), getAliasList(), AliasIDType.TALKGROUP);
|
||||||
|
mFromTalkgroupMonitor.addIllegalValue("000000");
|
||||||
|
mToTalkgroupMonitor = new AliasedStringAttributeMonitor(Attribute.PRIMARY_ADDRESS_TO,
|
||||||
|
getAttributeChangeRequestListener(), getAliasList(), AliasIDType.TALKGROUP);
|
||||||
|
mToTalkgroupMonitor.addIllegalValue("0000");
|
||||||
|
mToTalkgroupMonitor.addIllegalValue("000000");
|
||||||
}
|
}
|
||||||
|
|
||||||
public Modulation getModulation()
|
public Modulation getModulation()
|
||||||
@@ -225,9 +234,9 @@ public class P25DecoderState extends DecoderState
|
|||||||
{
|
{
|
||||||
resetState();
|
resetState();
|
||||||
|
|
||||||
updateNAC(null);
|
mNAC = null;
|
||||||
updateSite(null);
|
mSiteAttributeMonitor.reset();
|
||||||
updateSystem(null);
|
mSystem = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -235,17 +244,8 @@ public class P25DecoderState extends DecoderState
|
|||||||
*/
|
*/
|
||||||
private void resetState()
|
private void resetState()
|
||||||
{
|
{
|
||||||
mFromTalkgroup = null;
|
mFromTalkgroupMonitor.reset();
|
||||||
broadcast(ChangedAttribute.FROM_TALKGROUP);
|
mToTalkgroupMonitor.reset();
|
||||||
|
|
||||||
mFromAlias = null;
|
|
||||||
broadcast(ChangedAttribute.FROM_TALKGROUP_ALIAS);
|
|
||||||
|
|
||||||
mToTalkgroup = null;
|
|
||||||
broadcast(ChangedAttribute.TO_TALKGROUP);
|
|
||||||
|
|
||||||
mToAlias = null;
|
|
||||||
broadcast(ChangedAttribute.TO_TALKGROUP_ALIAS);
|
|
||||||
|
|
||||||
mCallDetectTalkgroups.clear();
|
mCallDetectTalkgroups.clear();
|
||||||
|
|
||||||
@@ -412,7 +412,7 @@ public class P25DecoderState extends DecoderState
|
|||||||
|
|
||||||
String to = hdu.getToID();
|
String to = hdu.getToID();
|
||||||
|
|
||||||
updateTo(to);
|
mToTalkgroupMonitor.process(to);
|
||||||
|
|
||||||
if(mCurrentCallEvent == null)
|
if(mCurrentCallEvent == null)
|
||||||
{
|
{
|
||||||
@@ -621,8 +621,8 @@ public class P25DecoderState extends DecoderState
|
|||||||
String from = gvcuser.getSourceAddress();
|
String from = gvcuser.getSourceAddress();
|
||||||
String to = gvcuser.getGroupAddress();
|
String to = gvcuser.getGroupAddress();
|
||||||
|
|
||||||
updateFrom(from);
|
mFromTalkgroupMonitor.process(from);
|
||||||
updateTo(to);
|
mToTalkgroupMonitor.process(to);
|
||||||
|
|
||||||
if(mCurrentCallEvent == null)
|
if(mCurrentCallEvent == null)
|
||||||
{
|
{
|
||||||
@@ -709,7 +709,7 @@ public class P25DecoderState extends DecoderState
|
|||||||
String site = rfsssb.getRFSubsystemID() + "-" +
|
String site = rfsssb.getRFSubsystemID() + "-" +
|
||||||
rfsssb.getSiteID();
|
rfsssb.getSiteID();
|
||||||
|
|
||||||
updateSite(site);
|
mSiteAttributeMonitor.process(site);
|
||||||
|
|
||||||
if(mCurrentChannel == null ||
|
if(mCurrentChannel == null ||
|
||||||
!mCurrentChannel.contentEquals(rfsssb.getChannel()))
|
!mCurrentChannel.contentEquals(rfsssb.getChannel()))
|
||||||
@@ -732,7 +732,7 @@ public class P25DecoderState extends DecoderState
|
|||||||
String site = rfsssbe.getRFSubsystemID() + "-" +
|
String site = rfsssbe.getRFSubsystemID() + "-" +
|
||||||
rfsssbe.getSiteID();
|
rfsssbe.getSiteID();
|
||||||
|
|
||||||
updateSite(site);
|
mSiteAttributeMonitor.process(site);
|
||||||
|
|
||||||
if(mCurrentChannel == null ||
|
if(mCurrentChannel == null ||
|
||||||
!mCurrentChannel.contentEquals(rfsssbe.getTransmitChannel()))
|
!mCurrentChannel.contentEquals(rfsssbe.getTransmitChannel()))
|
||||||
@@ -755,7 +755,7 @@ public class P25DecoderState extends DecoderState
|
|||||||
String site = sccb.getRFSubsystemID() + "-" +
|
String site = sccb.getRFSubsystemID() + "-" +
|
||||||
sccb.getSiteID();
|
sccb.getSiteID();
|
||||||
|
|
||||||
updateSite(site);
|
mSiteAttributeMonitor.process(site);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@@ -771,7 +771,7 @@ public class P25DecoderState extends DecoderState
|
|||||||
String site = sccb.getRFSubsystemID() + "-" +
|
String site = sccb.getRFSubsystemID() + "-" +
|
||||||
sccb.getSiteID();
|
sccb.getSiteID();
|
||||||
|
|
||||||
updateSite(site);
|
mSiteAttributeMonitor.process(site);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@@ -845,7 +845,7 @@ public class P25DecoderState extends DecoderState
|
|||||||
|
|
||||||
String to = tivcu.getAddress();
|
String to = tivcu.getAddress();
|
||||||
|
|
||||||
updateTo(to);
|
mToTalkgroupMonitor.process(to);
|
||||||
|
|
||||||
if(mCurrentCallEvent == null)
|
if(mCurrentCallEvent == null)
|
||||||
{
|
{
|
||||||
@@ -922,10 +922,10 @@ public class P25DecoderState extends DecoderState
|
|||||||
(module.decode.p25.message.tdu.lc.UnitToUnitVoiceChannelUser) tdulc;
|
(module.decode.p25.message.tdu.lc.UnitToUnitVoiceChannelUser) tdulc;
|
||||||
|
|
||||||
String from = uuvcu.getSourceAddress();
|
String from = uuvcu.getSourceAddress();
|
||||||
updateFrom(from);
|
mFromTalkgroupMonitor.process(from);
|
||||||
|
|
||||||
String to = uuvcu.getTargetAddress();
|
String to = uuvcu.getTargetAddress();
|
||||||
updateTo(to);
|
mToTalkgroupMonitor.process(to);
|
||||||
|
|
||||||
if(mCurrentCallEvent != null)
|
if(mCurrentCallEvent != null)
|
||||||
{
|
{
|
||||||
@@ -1170,9 +1170,9 @@ public class P25DecoderState extends DecoderState
|
|||||||
module.decode.p25.message.ldu.lc.GroupVoiceChannelUser gvcuser =
|
module.decode.p25.message.ldu.lc.GroupVoiceChannelUser gvcuser =
|
||||||
(module.decode.p25.message.ldu.lc.GroupVoiceChannelUser) ldu;
|
(module.decode.p25.message.ldu.lc.GroupVoiceChannelUser) ldu;
|
||||||
|
|
||||||
updateFrom(gvcuser.getSourceAddress());
|
mFromTalkgroupMonitor.process(gvcuser.getSourceAddress());
|
||||||
|
|
||||||
updateTo(gvcuser.getGroupAddress());
|
mToTalkgroupMonitor.process(gvcuser.getGroupAddress());
|
||||||
|
|
||||||
if(mChannelType == ChannelType.STANDARD)
|
if(mChannelType == ChannelType.STANDARD)
|
||||||
{
|
{
|
||||||
@@ -1265,7 +1265,7 @@ public class P25DecoderState extends DecoderState
|
|||||||
String site = rfsssb.getRFSubsystemID() + "-" +
|
String site = rfsssb.getRFSubsystemID() + "-" +
|
||||||
rfsssb.getSiteID();
|
rfsssb.getSiteID();
|
||||||
|
|
||||||
updateSite(site);
|
mSiteAttributeMonitor.process(site);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@@ -1281,7 +1281,7 @@ public class P25DecoderState extends DecoderState
|
|||||||
String site = rfsssbe.getRFSubsystemID() + "-" +
|
String site = rfsssbe.getRFSubsystemID() + "-" +
|
||||||
rfsssbe.getSiteID();
|
rfsssbe.getSiteID();
|
||||||
|
|
||||||
updateSite(site);
|
mSiteAttributeMonitor.process(site);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@@ -1297,7 +1297,7 @@ public class P25DecoderState extends DecoderState
|
|||||||
String site = sccb.getRFSubsystemID() + "-" +
|
String site = sccb.getRFSubsystemID() + "-" +
|
||||||
sccb.getSiteID();
|
sccb.getSiteID();
|
||||||
|
|
||||||
updateSite(site);
|
mSiteAttributeMonitor.process(site);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@@ -1313,7 +1313,7 @@ public class P25DecoderState extends DecoderState
|
|||||||
String site = sccb.getRFSubsystemID() + "-" +
|
String site = sccb.getRFSubsystemID() + "-" +
|
||||||
sccb.getSiteID();
|
sccb.getSiteID();
|
||||||
|
|
||||||
updateSite(site);
|
mSiteAttributeMonitor.process(site);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@@ -1386,7 +1386,7 @@ public class P25DecoderState extends DecoderState
|
|||||||
TelephoneInterconnectVoiceChannelUser tivcu =
|
TelephoneInterconnectVoiceChannelUser tivcu =
|
||||||
(TelephoneInterconnectVoiceChannelUser) ldu;
|
(TelephoneInterconnectVoiceChannelUser) ldu;
|
||||||
|
|
||||||
updateTo(tivcu.getAddress());
|
mToTalkgroupMonitor.process(tivcu.getAddress());
|
||||||
|
|
||||||
if(mCurrentCallEvent.getCallEventType() != CallEventType.TELEPHONE_INTERCONNECT)
|
if(mCurrentCallEvent.getCallEventType() != CallEventType.TELEPHONE_INTERCONNECT)
|
||||||
{
|
{
|
||||||
@@ -1467,9 +1467,9 @@ public class P25DecoderState extends DecoderState
|
|||||||
UnitToUnitVoiceChannelUser uuvcu =
|
UnitToUnitVoiceChannelUser uuvcu =
|
||||||
(UnitToUnitVoiceChannelUser) ldu;
|
(UnitToUnitVoiceChannelUser) ldu;
|
||||||
|
|
||||||
updateFrom(uuvcu.getSourceAddress());
|
mFromTalkgroupMonitor.process(uuvcu.getSourceAddress());
|
||||||
|
|
||||||
updateTo(uuvcu.getTargetAddress());
|
mToTalkgroupMonitor.process(uuvcu.getTargetAddress());
|
||||||
|
|
||||||
if(mCurrentCallEvent.getCallEventType() != CallEventType.UNIT_TO_UNIT_CALL)
|
if(mCurrentCallEvent.getCallEventType() != CallEventType.UNIT_TO_UNIT_CALL)
|
||||||
{
|
{
|
||||||
@@ -1884,7 +1884,7 @@ public class P25DecoderState extends DecoderState
|
|||||||
|
|
||||||
updateNAC(mRFSSStatusMessageExtended.getNAC());
|
updateNAC(mRFSSStatusMessageExtended.getNAC());
|
||||||
updateSystem(mRFSSStatusMessageExtended.getSystemID());
|
updateSystem(mRFSSStatusMessageExtended.getSystemID());
|
||||||
updateSite(mRFSSStatusMessageExtended.getRFSubsystemID() +
|
mSiteAttributeMonitor.process(mRFSSStatusMessageExtended.getRFSubsystemID() +
|
||||||
"-" + mRFSSStatusMessageExtended.getSiteID());
|
"-" + mRFSSStatusMessageExtended.getSiteID());
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@@ -2658,7 +2658,7 @@ public class P25DecoderState extends DecoderState
|
|||||||
|
|
||||||
updateSystem(message.getSystemID());
|
updateSystem(message.getSystemID());
|
||||||
|
|
||||||
updateSite(message.getRFSubsystemID() + "-" + message.getSiteID());
|
mSiteAttributeMonitor.process(message.getRFSubsystemID() + "-" + message.getSiteID());
|
||||||
}
|
}
|
||||||
|
|
||||||
private void processTSBKDataChannelAnnouncement(TSBKMessage message)
|
private void processTSBKDataChannelAnnouncement(TSBKMessage message)
|
||||||
@@ -3361,79 +3361,12 @@ public class P25DecoderState extends DecoderState
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
private void updateSystem(String system)
|
||||||
* Broadcasts an update for the TO group or unit address
|
|
||||||
*/
|
|
||||||
private void updateTo(final String to)
|
|
||||||
{
|
{
|
||||||
if(to != null && !to.contentEquals("0000") && !to.contentEquals("000000"))
|
if(mSystem == null || (system != null && !mSystem.contentEquals(system)))
|
||||||
{
|
{
|
||||||
if(mToTalkgroup == null || !mToTalkgroup.contentEquals(to))
|
mSystem = system;
|
||||||
{
|
broadcastSystemAndNACUpdate();
|
||||||
mToTalkgroup = to;
|
|
||||||
|
|
||||||
broadcast(ChangedAttribute.TO_TALKGROUP);
|
|
||||||
|
|
||||||
if(hasAliasList())
|
|
||||||
{
|
|
||||||
mToAlias = getAliasList().getTalkgroupAlias(mToTalkgroup);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
mToAlias = null;
|
|
||||||
}
|
|
||||||
|
|
||||||
broadcast(ChangedAttribute.TO_TALKGROUP_ALIAS);
|
|
||||||
|
|
||||||
/* Send audio metadata update */
|
|
||||||
broadcast(new Metadata(MetadataType.TO, mToTalkgroup, mToAlias, true));
|
|
||||||
|
|
||||||
if(mCurrentCallEvent != null &&
|
|
||||||
(mCurrentCallEvent.getToID() == null ||
|
|
||||||
!mCurrentCallEvent.getToID().contentEquals(to)))
|
|
||||||
{
|
|
||||||
mCurrentCallEvent.setToID(to);
|
|
||||||
broadcast(mCurrentCallEvent);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Broadcasts an update for the FROM group or unit address
|
|
||||||
*/
|
|
||||||
private void updateFrom(final String from)
|
|
||||||
{
|
|
||||||
if(from != null && !from.contentEquals("0000") && !from.contentEquals("000000"))
|
|
||||||
{
|
|
||||||
if(mFromTalkgroup == null || !mFromTalkgroup.contentEquals(from))
|
|
||||||
{
|
|
||||||
mFromTalkgroup = from;
|
|
||||||
broadcast(ChangedAttribute.FROM_TALKGROUP);
|
|
||||||
|
|
||||||
if(hasAliasList())
|
|
||||||
{
|
|
||||||
mFromAlias = getAliasList().getTalkgroupAlias(mFromTalkgroup);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
mFromAlias = null;
|
|
||||||
}
|
|
||||||
|
|
||||||
broadcast(ChangedAttribute.FROM_TALKGROUP_ALIAS);
|
|
||||||
|
|
||||||
/* Send audio metadata update */
|
|
||||||
broadcast(new Metadata(MetadataType.FROM, mFromTalkgroup, mFromAlias, true));
|
|
||||||
|
|
||||||
if(mCurrentCallEvent != null &&
|
|
||||||
(mCurrentCallEvent.getFromID() == null ||
|
|
||||||
!mCurrentCallEvent.getFromID().contentEquals(from)))
|
|
||||||
{
|
|
||||||
mCurrentCallEvent.setFromID(from);
|
|
||||||
broadcast(mCurrentCallEvent);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -3445,48 +3378,14 @@ public class P25DecoderState extends DecoderState
|
|||||||
if(mNAC == null || (nac != null && !mNAC.contentEquals(nac)))
|
if(mNAC == null || (nac != null && !mNAC.contentEquals(nac)))
|
||||||
{
|
{
|
||||||
mNAC = nac;
|
mNAC = nac;
|
||||||
|
broadcastSystemAndNACUpdate();
|
||||||
broadcast(ChangedAttribute.NAC);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
private void broadcastSystemAndNACUpdate()
|
||||||
* Updates the site information
|
|
||||||
*/
|
|
||||||
private void updateSite(String site)
|
|
||||||
{
|
{
|
||||||
if(mSite == null || (site != null && !mSite.contentEquals(site)))
|
String label = String.format("SYS:%s NAC:%s", mSystem, mNAC);
|
||||||
{
|
broadcast(new AttributeChangeRequest<String>(Attribute.NETWORK_ID_1, label));
|
||||||
mSite = site;
|
|
||||||
|
|
||||||
broadcast(ChangedAttribute.SITE);
|
|
||||||
|
|
||||||
if(hasAliasList())
|
|
||||||
{
|
|
||||||
Alias alias = getAliasList().getSiteID(mSite);
|
|
||||||
|
|
||||||
if(alias != null)
|
|
||||||
{
|
|
||||||
mSiteAlias = alias.getName();
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
mSiteAlias = null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
broadcast(ChangedAttribute.SITE_ALIAS);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void updateSystem(String system)
|
|
||||||
{
|
|
||||||
if(mSystem == null || (system != null && !mSystem.contentEquals(system)))
|
|
||||||
{
|
|
||||||
mSystem = system;
|
|
||||||
|
|
||||||
broadcast(ChangedAttribute.SYSTEM);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -3754,46 +3653,6 @@ public class P25DecoderState extends DecoderState
|
|||||||
return sb.toString();
|
return sb.toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getNAC()
|
|
||||||
{
|
|
||||||
return mNAC;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getSystem()
|
|
||||||
{
|
|
||||||
return mSystem;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getSiteAlias()
|
|
||||||
{
|
|
||||||
return mSiteAlias;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getSite()
|
|
||||||
{
|
|
||||||
return mSite;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getFromTalkgroup()
|
|
||||||
{
|
|
||||||
return mFromTalkgroup;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Alias getFromAlias()
|
|
||||||
{
|
|
||||||
return mFromAlias;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getToTalkgroup()
|
|
||||||
{
|
|
||||||
return mToTalkgroup;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Alias getToAlias()
|
|
||||||
{
|
|
||||||
return mToAlias;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void receiveDecoderStateEvent(DecoderStateEvent event)
|
public void receiveDecoderStateEvent(DecoderStateEvent event)
|
||||||
{
|
{
|
||||||
@@ -3810,33 +3669,21 @@ public class P25DecoderState extends DecoderState
|
|||||||
{
|
{
|
||||||
if(event instanceof TrafficChannelAllocationEvent)
|
if(event instanceof TrafficChannelAllocationEvent)
|
||||||
{
|
{
|
||||||
TrafficChannelAllocationEvent allocationEvent =
|
TrafficChannelAllocationEvent allocationEvent = (TrafficChannelAllocationEvent) event;
|
||||||
(TrafficChannelAllocationEvent) event;
|
|
||||||
|
|
||||||
mCurrentCallEvent = (P25CallEvent) allocationEvent.getCallEvent();
|
mCurrentCallEvent = (P25CallEvent) allocationEvent.getCallEvent();
|
||||||
|
|
||||||
mCurrentChannel = allocationEvent.getCallEvent().getChannel();
|
mCurrentChannel = allocationEvent.getCallEvent().getChannel();
|
||||||
broadcast(ChangedAttribute.CHANNEL_NUMBER);
|
broadcast(new AttributeChangeRequest<String>(Attribute.CHANNEL_FREQUENCY_LABEL, mCurrentChannel));
|
||||||
|
|
||||||
mCurrentChannelFrequency = allocationEvent.getCallEvent().getFrequency();
|
mCurrentChannelFrequency = allocationEvent.getCallEvent().getFrequency();
|
||||||
broadcast(ChangedAttribute.SOURCE);
|
broadcast(new AttributeChangeRequest<Long>(Attribute.CHANNEL_FREQUENCY, mCurrentChannelFrequency));
|
||||||
|
|
||||||
mFromTalkgroup = allocationEvent.getCallEvent().getFromID();
|
mFromTalkgroupMonitor.reset();
|
||||||
broadcast(ChangedAttribute.FROM_TALKGROUP);
|
mFromTalkgroupMonitor.process(allocationEvent.getCallEvent().getFromID());
|
||||||
|
|
||||||
mToTalkgroup = allocationEvent.getCallEvent().getToID();
|
mToTalkgroupMonitor.reset();
|
||||||
broadcast(ChangedAttribute.TO_TALKGROUP);
|
mToTalkgroupMonitor.process(allocationEvent.getCallEvent().getToID());
|
||||||
|
|
||||||
if(allocationEvent.getCallEvent().hasAliasList())
|
|
||||||
{
|
|
||||||
AliasList aliasList = allocationEvent.getCallEvent().getAliasList();
|
|
||||||
|
|
||||||
mFromAlias = aliasList.getTalkgroupAlias(mFromTalkgroup);
|
|
||||||
broadcast(ChangedAttribute.FROM_TALKGROUP_ALIAS);
|
|
||||||
|
|
||||||
mToAlias = aliasList.getTalkgroupAlias(mToTalkgroup);
|
|
||||||
broadcast(ChangedAttribute.TO_TALKGROUP_ALIAS);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|||||||
@@ -1,56 +1,42 @@
|
|||||||
package module.decode.p25.audio;
|
package module.decode.p25.audio;
|
||||||
|
|
||||||
import java.util.concurrent.ScheduledExecutorService;
|
import audio.AudioFormats;
|
||||||
|
import audio.AudioPacket;
|
||||||
|
import audio.IAudioPacketProvider;
|
||||||
|
import audio.squelch.ISquelchStateListener;
|
||||||
|
import audio.squelch.SquelchState;
|
||||||
|
import channel.metadata.Metadata;
|
||||||
|
import dsp.gain.NonClippingGain;
|
||||||
import jmbe.iface.AudioConversionLibrary;
|
import jmbe.iface.AudioConversionLibrary;
|
||||||
import jmbe.iface.AudioConverter;
|
import jmbe.iface.AudioConverter;
|
||||||
import message.IMessageListener;
|
import message.IMessageListener;
|
||||||
import message.Message;
|
import message.Message;
|
||||||
import module.Module;
|
import module.Module;
|
||||||
import module.decode.p25.message.ldu.LDUMessage;
|
import module.decode.p25.message.ldu.LDUMessage;
|
||||||
|
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
import sample.Listener;
|
import sample.Listener;
|
||||||
import audio.AudioFormats;
|
|
||||||
import audio.AudioPacket;
|
|
||||||
import audio.IAudioPacketProvider;
|
|
||||||
import audio.metadata.AudioMetadata;
|
|
||||||
import audio.metadata.IMetadataListener;
|
|
||||||
import audio.metadata.Metadata;
|
|
||||||
import audio.squelch.ISquelchStateListener;
|
|
||||||
import audio.squelch.SquelchState;
|
|
||||||
import controller.channel.ChannelEvent;
|
|
||||||
import controller.channel.IChannelEventListener;
|
|
||||||
import dsp.gain.NonClippingGain;
|
|
||||||
|
|
||||||
public class P25AudioModule extends Module implements Listener<Message>,
|
import java.util.concurrent.ScheduledExecutorService;
|
||||||
IAudioPacketProvider, IMessageListener, IChannelEventListener,
|
|
||||||
IMetadataListener, ISquelchStateListener
|
public class P25AudioModule extends Module implements Listener<Message>, IAudioPacketProvider, IMessageListener,
|
||||||
|
ISquelchStateListener
|
||||||
{
|
{
|
||||||
private final static Logger mLog = LoggerFactory.getLogger(P25AudioModule.class);
|
private final static Logger mLog = LoggerFactory.getLogger(P25AudioModule.class);
|
||||||
|
|
||||||
private static final String IMBE_CODEC = "IMBE";
|
private static final String IMBE_CODEC = "IMBE";
|
||||||
|
|
||||||
/* Provides a unique identifier for this audio module instance to use as a
|
|
||||||
* source identifier for all audio packets */
|
|
||||||
private static int UNIQUE_ID = 0;
|
|
||||||
private int mSourceID;
|
|
||||||
private static boolean mLibraryLoadStatusLogged = false;
|
private static boolean mLibraryLoadStatusLogged = false;
|
||||||
private boolean mCanConvertAudio = false;
|
private boolean mCanConvertAudio = false;
|
||||||
private AudioConverter mAudioConverter;
|
private AudioConverter mAudioConverter;
|
||||||
private Listener<AudioPacket> mAudioPacketListener;
|
private Listener<AudioPacket> mAudioPacketListener;
|
||||||
private AudioMetadata mAudioMetadata;
|
|
||||||
private ChannelEventListener mChannelEventListener = new ChannelEventListener();
|
|
||||||
private SquelchStateListener mSquelchStateListener = new SquelchStateListener();
|
private SquelchStateListener mSquelchStateListener = new SquelchStateListener();
|
||||||
private NonClippingGain mGain = new NonClippingGain(5.0f, 0.95f);
|
private NonClippingGain mGain = new NonClippingGain(5.0f, 0.95f);
|
||||||
|
private Metadata mMetadata;
|
||||||
|
|
||||||
public P25AudioModule(boolean record)
|
public P25AudioModule(Metadata metadata)
|
||||||
{
|
{
|
||||||
mSourceID = ++UNIQUE_ID;
|
mMetadata = metadata;
|
||||||
mAudioMetadata = new AudioMetadata(mSourceID, record);
|
|
||||||
|
|
||||||
loadConverter();
|
loadConverter();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -75,7 +61,6 @@ public class P25AudioModule extends Module implements Listener<Message>,
|
|||||||
@Override
|
@Override
|
||||||
public void reset()
|
public void reset()
|
||||||
{
|
{
|
||||||
mAudioMetadata.reset();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -113,8 +98,7 @@ public class P25AudioModule extends Module implements Listener<Message>,
|
|||||||
|
|
||||||
audio = mGain.apply(audio);
|
audio = mGain.apply(audio);
|
||||||
|
|
||||||
mAudioPacketListener.receive(
|
mAudioPacketListener.receive(new AudioPacket(audio, mMetadata.copyOf()));
|
||||||
new AudioPacket(audio, mAudioMetadata.copyOf()));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -211,41 +195,6 @@ public class P25AudioModule extends Module implements Listener<Message>,
|
|||||||
mAudioPacketListener = null;
|
mAudioPacketListener = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public Listener<Metadata> getMetadataListener()
|
|
||||||
{
|
|
||||||
return mAudioMetadata;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Listener<ChannelEvent> getChannelEventListener()
|
|
||||||
{
|
|
||||||
return mChannelEventListener;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Wrapper for channel event listener. Responds to channel state reset
|
|
||||||
* events to remove/cleanup current audio metadata
|
|
||||||
*/
|
|
||||||
public class ChannelEventListener implements Listener<ChannelEvent>
|
|
||||||
{
|
|
||||||
@Override
|
|
||||||
public void receive(ChannelEvent event)
|
|
||||||
{
|
|
||||||
switch (event.getEvent())
|
|
||||||
{
|
|
||||||
case NOTIFICATION_STATE_RESET:
|
|
||||||
mAudioMetadata.reset();
|
|
||||||
break;
|
|
||||||
case NOTIFICATION_SELECTION_CHANGE:
|
|
||||||
mAudioMetadata.setSelected(event.getChannel().isSelected());
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Wrapper for squelch state listener. Internally, the P25 audio module
|
* Wrapper for squelch state listener. Internally, the P25 audio module
|
||||||
* doesn't have a squelch state. If there are IMBE audio frames, we have
|
* doesn't have a squelch state. If there are IMBE audio frames, we have
|
||||||
@@ -259,10 +208,7 @@ public class P25AudioModule extends Module implements Listener<Message>,
|
|||||||
{
|
{
|
||||||
if (state == SquelchState.SQUELCH && mAudioPacketListener != null)
|
if (state == SquelchState.SQUELCH && mAudioPacketListener != null)
|
||||||
{
|
{
|
||||||
mAudioPacketListener.receive(new AudioPacket(AudioPacket.Type.END,
|
mAudioPacketListener.receive(new AudioPacket(AudioPacket.Type.END, mMetadata.copyOf()));
|
||||||
mAudioMetadata.copyOf()));
|
|
||||||
|
|
||||||
mAudioMetadata.reset();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,225 +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 module.decode.passport;
|
|
||||||
|
|
||||||
import alias.Alias;
|
|
||||||
import icon.IconManager;
|
|
||||||
import module.decode.state.ChangedAttribute;
|
|
||||||
import module.decode.state.DecoderPanel;
|
|
||||||
import net.miginfocom.swing.MigLayout;
|
|
||||||
import settings.ColorSetting;
|
|
||||||
import settings.Setting;
|
|
||||||
import settings.SettingsManager;
|
|
||||||
|
|
||||||
import javax.swing.*;
|
|
||||||
import java.awt.*;
|
|
||||||
|
|
||||||
public class PassportDecoderPanel extends DecoderPanel
|
|
||||||
{
|
|
||||||
private static final long serialVersionUID = 1L;
|
|
||||||
|
|
||||||
private JLabel mProtocol = new JLabel("Passport");
|
|
||||||
private JLabel mToTalkgroup = new JLabel();
|
|
||||||
private JLabel mToTalkgroupAlias = new JLabel();
|
|
||||||
|
|
||||||
private JLabel mSiteAndChannel = new JLabel("Site:");
|
|
||||||
private JLabel mFromTalkgroup = new JLabel();
|
|
||||||
private JLabel mFromTalkgroupAlias = new JLabel();
|
|
||||||
|
|
||||||
public PassportDecoderPanel(IconManager iconManager, SettingsManager settingsManager, PassportDecoderState decoderState)
|
|
||||||
{
|
|
||||||
super(iconManager, settingsManager, decoderState);
|
|
||||||
|
|
||||||
init();
|
|
||||||
}
|
|
||||||
|
|
||||||
public void dispose()
|
|
||||||
{
|
|
||||||
super.dispose();
|
|
||||||
}
|
|
||||||
|
|
||||||
public void init()
|
|
||||||
{
|
|
||||||
super.init();
|
|
||||||
|
|
||||||
setLayout(new MigLayout("insets 0 0 0 0", "[grow,fill]", "[]0[]0[]"));
|
|
||||||
|
|
||||||
mProtocol.setFont(mFontDecoder);
|
|
||||||
mProtocol.setForeground(mColorLabelDecoder);
|
|
||||||
|
|
||||||
mToTalkgroup.setFont(mFontDecoder);
|
|
||||||
mToTalkgroup.setForeground(mColorLabelDecoder);
|
|
||||||
|
|
||||||
mToTalkgroupAlias.setFont(mFontDecoder);
|
|
||||||
mToTalkgroupAlias.setForeground(mColorLabelDecoder);
|
|
||||||
|
|
||||||
mSiteAndChannel.setFont(mFontDecoder);
|
|
||||||
mSiteAndChannel.setForeground(mColorLabelDecoder);
|
|
||||||
|
|
||||||
mFromTalkgroup.setFont(mFontDecoder);
|
|
||||||
mFromTalkgroup.setForeground(mColorLabelDecoder);
|
|
||||||
|
|
||||||
mFromTalkgroupAlias.setFont(mFontDecoder);
|
|
||||||
mFromTalkgroupAlias.setForeground(mColorLabelDecoder);
|
|
||||||
|
|
||||||
add(mProtocol);
|
|
||||||
add(mToTalkgroup);
|
|
||||||
add(mToTalkgroupAlias, "wrap");
|
|
||||||
|
|
||||||
add(mSiteAndChannel);
|
|
||||||
add(mFromTalkgroup);
|
|
||||||
add(mFromTalkgroupAlias, "wrap");
|
|
||||||
}
|
|
||||||
|
|
||||||
public PassportDecoderState getDecoderState()
|
|
||||||
{
|
|
||||||
return (PassportDecoderState) super.getDecoderState();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void receive(final ChangedAttribute changedAttribute)
|
|
||||||
{
|
|
||||||
EventQueue.invokeLater(new Runnable()
|
|
||||||
{
|
|
||||||
@Override
|
|
||||||
public void run()
|
|
||||||
{
|
|
||||||
PassportDecoderState state = getDecoderState();
|
|
||||||
|
|
||||||
switch(changedAttribute)
|
|
||||||
{
|
|
||||||
case TO_TALKGROUP:
|
|
||||||
String tg = state.getTalkgroup();
|
|
||||||
|
|
||||||
if(tg != null)
|
|
||||||
{
|
|
||||||
mToTalkgroup.setText("TG:" + tg);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
mToTalkgroup.setText(null);
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case TO_TALKGROUP_ALIAS:
|
|
||||||
Alias toAlias = state.getTalkgroupAlias();
|
|
||||||
|
|
||||||
if(toAlias != null)
|
|
||||||
{
|
|
||||||
mToTalkgroupAlias.setText(toAlias.getName());
|
|
||||||
|
|
||||||
mToTalkgroupAlias.setIcon(mIconManager.getIcon(toAlias.getIconName(), IconManager.DEFAULT_ICON_SIZE));
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
mToTalkgroupAlias.setText(null);
|
|
||||||
mToTalkgroupAlias.setIcon(null);
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case FROM_TALKGROUP:
|
|
||||||
String mid = state.getMobileID();
|
|
||||||
|
|
||||||
if(mid != null)
|
|
||||||
{
|
|
||||||
mFromTalkgroup.setText("MIN:" + mid);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
mFromTalkgroup.setText(null);
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case FROM_TALKGROUP_ALIAS:
|
|
||||||
Alias fromAlias = state.getMobileIDAlias();
|
|
||||||
|
|
||||||
if(fromAlias != null)
|
|
||||||
{
|
|
||||||
mFromTalkgroupAlias.setText(fromAlias.getName());
|
|
||||||
|
|
||||||
mFromTalkgroupAlias.setIcon(mIconManager
|
|
||||||
.getIcon(fromAlias.getIconName(), IconManager.DEFAULT_ICON_SIZE));
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
mFromTalkgroupAlias.setText(null);
|
|
||||||
mFromTalkgroupAlias.setIcon(null);
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case CHANNEL_NUMBER:
|
|
||||||
StringBuilder sb = new StringBuilder();
|
|
||||||
sb.append("Site: ");
|
|
||||||
sb.append(state.getSiteNumber());
|
|
||||||
sb.append("/");
|
|
||||||
sb.append(state.getChannelNumber());
|
|
||||||
|
|
||||||
mSiteAndChannel.setText(sb.toString());
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
repaint();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void settingChanged(Setting setting)
|
|
||||||
{
|
|
||||||
super.settingChanged(setting);
|
|
||||||
|
|
||||||
if(setting instanceof ColorSetting)
|
|
||||||
{
|
|
||||||
ColorSetting colorSetting = (ColorSetting) setting;
|
|
||||||
|
|
||||||
switch(colorSetting.getColorSettingName())
|
|
||||||
{
|
|
||||||
case CHANNEL_STATE_LABEL_DECODER:
|
|
||||||
if(mColorLabelDecoder != null)
|
|
||||||
{
|
|
||||||
if(mProtocol != null)
|
|
||||||
{
|
|
||||||
mProtocol.setForeground(mColorLabelDecoder);
|
|
||||||
}
|
|
||||||
if(mToTalkgroup != null)
|
|
||||||
{
|
|
||||||
mToTalkgroup.setForeground(mColorLabelDecoder);
|
|
||||||
}
|
|
||||||
if(mToTalkgroupAlias != null)
|
|
||||||
{
|
|
||||||
mToTalkgroupAlias.setForeground(mColorLabelDecoder);
|
|
||||||
}
|
|
||||||
if(mSiteAndChannel != null)
|
|
||||||
{
|
|
||||||
mSiteAndChannel.setForeground(mColorLabelDecoder);
|
|
||||||
}
|
|
||||||
if(mFromTalkgroup != null)
|
|
||||||
{
|
|
||||||
mFromTalkgroup.setForeground(mColorLabelDecoder);
|
|
||||||
}
|
|
||||||
if(mFromTalkgroupAlias != null)
|
|
||||||
{
|
|
||||||
mFromTalkgroupAlias.setForeground(mColorLabelDecoder);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,6 +1,6 @@
|
|||||||
/*******************************************************************************
|
/*******************************************************************************
|
||||||
* SDR Trunk
|
* sdrtrunk
|
||||||
* Copyright (C) 2014,2015 Dennis Sheirer
|
* Copyright (C) 2014-2017 Dennis Sheirer
|
||||||
*
|
*
|
||||||
* This program is free software: you can redistribute it and/or modify
|
* 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
|
* it under the terms of the GNU General Public License as published by
|
||||||
@@ -14,9 +14,27 @@
|
|||||||
*
|
*
|
||||||
* You should have received a copy of the GNU General Public License
|
* You should have received a copy of the GNU General Public License
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>
|
* along with this program. If not, see <http://www.gnu.org/licenses/>
|
||||||
|
*
|
||||||
******************************************************************************/
|
******************************************************************************/
|
||||||
package module.decode.passport;
|
package module.decode.passport;
|
||||||
|
|
||||||
|
import alias.Alias;
|
||||||
|
import alias.AliasList;
|
||||||
|
import alias.id.AliasIDType;
|
||||||
|
import channel.metadata.AliasedStringAttributeMonitor;
|
||||||
|
import channel.metadata.Attribute;
|
||||||
|
import channel.metadata.AttributeChangeRequest;
|
||||||
|
import channel.state.DecoderState;
|
||||||
|
import channel.state.DecoderStateEvent;
|
||||||
|
import channel.state.DecoderStateEvent.Event;
|
||||||
|
import channel.state.State;
|
||||||
|
import message.Message;
|
||||||
|
import module.decode.DecoderType;
|
||||||
|
import module.decode.event.CallEvent;
|
||||||
|
import module.decode.event.CallEvent.CallEventType;
|
||||||
|
import org.slf4j.Logger;
|
||||||
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
@@ -25,24 +43,6 @@ import java.util.Iterator;
|
|||||||
import java.util.TreeSet;
|
import java.util.TreeSet;
|
||||||
import java.util.concurrent.ScheduledExecutorService;
|
import java.util.concurrent.ScheduledExecutorService;
|
||||||
|
|
||||||
import message.Message;
|
|
||||||
import module.decode.DecoderType;
|
|
||||||
import module.decode.event.CallEvent;
|
|
||||||
import module.decode.event.CallEvent.CallEventType;
|
|
||||||
import module.decode.state.ChangedAttribute;
|
|
||||||
import module.decode.state.DecoderState;
|
|
||||||
import module.decode.state.DecoderStateEvent;
|
|
||||||
import module.decode.state.DecoderStateEvent.Event;
|
|
||||||
import module.decode.state.State;
|
|
||||||
|
|
||||||
import org.slf4j.Logger;
|
|
||||||
import org.slf4j.LoggerFactory;
|
|
||||||
|
|
||||||
import alias.Alias;
|
|
||||||
import alias.AliasList;
|
|
||||||
import audio.metadata.Metadata;
|
|
||||||
import audio.metadata.MetadataType;
|
|
||||||
|
|
||||||
public class PassportDecoderState extends DecoderState
|
public class PassportDecoderState extends DecoderState
|
||||||
{
|
{
|
||||||
private final static Logger mLog =
|
private final static Logger mLog =
|
||||||
@@ -54,10 +54,8 @@ public class PassportDecoderState extends DecoderState
|
|||||||
private HashMap<Integer,String> mSiteLCNs = new HashMap<Integer,String>();
|
private HashMap<Integer,String> mSiteLCNs = new HashMap<Integer,String>();
|
||||||
private HashMap<Integer,String> mNeighborLCNs = new HashMap<Integer,String>();
|
private HashMap<Integer,String> mNeighborLCNs = new HashMap<Integer,String>();
|
||||||
|
|
||||||
private String mTalkgroup;
|
private AliasedStringAttributeMonitor mFromMobileIDAttribute;
|
||||||
private Alias mTalkgroupAlias;
|
private AliasedStringAttributeMonitor mToTalkgroupAttribute;
|
||||||
private String mMobileID;
|
|
||||||
private Alias mMobileIDAlias;
|
|
||||||
private int mChannelNumber;
|
private int mChannelNumber;
|
||||||
private int mSiteNumber;
|
private int mSiteNumber;
|
||||||
private PassportBand mSiteBand;
|
private PassportBand mSiteBand;
|
||||||
@@ -67,6 +65,11 @@ public class PassportDecoderState extends DecoderState
|
|||||||
public PassportDecoderState(AliasList aliasList)
|
public PassportDecoderState(AliasList aliasList)
|
||||||
{
|
{
|
||||||
super(aliasList);
|
super(aliasList);
|
||||||
|
|
||||||
|
mFromMobileIDAttribute = new AliasedStringAttributeMonitor(Attribute.PRIMARY_ADDRESS_FROM,
|
||||||
|
getAttributeChangeRequestListener(), getAliasList(), AliasIDType.MIN);
|
||||||
|
mToTalkgroupAttribute = new AliasedStringAttributeMonitor(Attribute.PRIMARY_ADDRESS_TO,
|
||||||
|
getAttributeChangeRequestListener(), getAliasList(), AliasIDType.TALKGROUP);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -141,15 +144,13 @@ public class PassportDecoderState extends DecoderState
|
|||||||
|
|
||||||
if(mChannelNumber == 0)
|
if(mChannelNumber == 0)
|
||||||
{
|
{
|
||||||
mChannelNumber = passport.getLCN();
|
setChannelNumber(passport.getLCN());
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Call on this channel */
|
/* Call on this channel */
|
||||||
if(passport.getLCN() == mChannelNumber)
|
if(passport.getLCN() == mChannelNumber)
|
||||||
{
|
{
|
||||||
setTalkgroup( talkgroup );
|
mToTalkgroupAttribute.process(talkgroup);
|
||||||
|
|
||||||
setTalkgroupAlias( passport.getTalkgroupIDAlias() );
|
|
||||||
|
|
||||||
PassportCallEvent current = getCurrentCallEvent();
|
PassportCallEvent current = getCurrentCallEvent();
|
||||||
|
|
||||||
@@ -174,9 +175,6 @@ public class PassportDecoderState extends DecoderState
|
|||||||
|
|
||||||
broadcast(mCurrentCallEvent);
|
broadcast(mCurrentCallEvent);
|
||||||
|
|
||||||
broadcast( new Metadata( MetadataType.TO,
|
|
||||||
mTalkgroup, mTalkgroupAlias, true ) );
|
|
||||||
|
|
||||||
broadcast(new DecoderStateEvent(this,
|
broadcast(new DecoderStateEvent(this,
|
||||||
Event.START, State.CALL));
|
Event.START, State.CALL));
|
||||||
}
|
}
|
||||||
@@ -213,9 +211,7 @@ public class PassportDecoderState extends DecoderState
|
|||||||
String.valueOf(passport.getTalkgroupID());
|
String.valueOf(passport.getTalkgroupID());
|
||||||
|
|
||||||
logTalkgroup(endTalkgroup);
|
logTalkgroup(endTalkgroup);
|
||||||
setTalkgroup( endTalkgroup );
|
mToTalkgroupAttribute.process(endTalkgroup);
|
||||||
|
|
||||||
setTalkgroupAlias( passport.getTalkgroupIDAlias() );
|
|
||||||
|
|
||||||
broadcast(new DecoderStateEvent(this,
|
broadcast(new DecoderStateEvent(this,
|
||||||
Event.END, State.CALL));
|
Event.END, State.CALL));
|
||||||
@@ -240,15 +236,13 @@ public class PassportDecoderState extends DecoderState
|
|||||||
|
|
||||||
if(mChannelNumber == 0)
|
if(mChannelNumber == 0)
|
||||||
{
|
{
|
||||||
mChannelNumber = passport.getLCN();
|
setChannelNumber(passport.getLCN());
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Data call on this channel */
|
/* Data call on this channel */
|
||||||
if(passport.getLCN() == mChannelNumber)
|
if(passport.getLCN() == mChannelNumber)
|
||||||
{
|
{
|
||||||
setTalkgroup( dataTalkgroup );
|
mToTalkgroupAttribute.process(dataTalkgroup);
|
||||||
|
|
||||||
setTalkgroupAlias( passport.getTalkgroupIDAlias() );
|
|
||||||
|
|
||||||
PassportCallEvent current = getCurrentCallEvent();
|
PassportCallEvent current = getCurrentCallEvent();
|
||||||
|
|
||||||
@@ -273,9 +267,6 @@ public class PassportDecoderState extends DecoderState
|
|||||||
|
|
||||||
broadcast(mCurrentCallEvent);
|
broadcast(mCurrentCallEvent);
|
||||||
|
|
||||||
broadcast( new Metadata( MetadataType.TO,
|
|
||||||
mTalkgroup, mTalkgroupAlias, true ) );
|
|
||||||
|
|
||||||
broadcast(new DecoderStateEvent(this,
|
broadcast(new DecoderStateEvent(this,
|
||||||
Event.START, State.DATA));
|
Event.START, State.DATA));
|
||||||
}
|
}
|
||||||
@@ -312,9 +303,7 @@ public class PassportDecoderState extends DecoderState
|
|||||||
String.valueOf(passport.getTalkgroupID());
|
String.valueOf(passport.getTalkgroupID());
|
||||||
|
|
||||||
logTalkgroup(dataEndTalkgroup);
|
logTalkgroup(dataEndTalkgroup);
|
||||||
setTalkgroup( dataEndTalkgroup );
|
mToTalkgroupAttribute.process(dataEndTalkgroup);
|
||||||
|
|
||||||
setTalkgroupAlias( passport.getTalkgroupIDAlias() );
|
|
||||||
|
|
||||||
broadcast(new DecoderStateEvent(this,
|
broadcast(new DecoderStateEvent(this,
|
||||||
Event.END, State.DATA));
|
Event.END, State.DATA));
|
||||||
@@ -336,11 +325,7 @@ public class PassportDecoderState extends DecoderState
|
|||||||
mMobileIDs.add(min);
|
mMobileIDs.add(min);
|
||||||
}
|
}
|
||||||
|
|
||||||
setMobileID( min );
|
mFromMobileIDAttribute.process(min);
|
||||||
setMobileIDAlias( passport.getMobileIDAlias() );
|
|
||||||
|
|
||||||
broadcast( new Metadata( MetadataType.FROM,
|
|
||||||
mMobileID, mMobileIDAlias, true ) );
|
|
||||||
|
|
||||||
final CallEvent current = getCurrentCallEvent();
|
final CallEvent current = getCurrentCallEvent();
|
||||||
|
|
||||||
@@ -380,18 +365,11 @@ public class PassportDecoderState extends DecoderState
|
|||||||
mNeighborLCNs.put(passport.getFree(),
|
mNeighborLCNs.put(passport.getFree(),
|
||||||
passport.getFreeFrequencyFormatted());
|
passport.getFreeFrequencyFormatted());
|
||||||
}
|
}
|
||||||
|
setSiteNumber(passport.getSite());
|
||||||
|
|
||||||
PassportBand band = passport.getSiteBand();
|
PassportBand band = passport.getSiteBand();
|
||||||
|
setSiteBand(band);
|
||||||
if( mSiteBand == null || mSiteBand != band )
|
setChannelNumber(getSiteBand().getChannel(mFrequency));
|
||||||
{
|
|
||||||
mSiteBand = band;
|
|
||||||
|
|
||||||
mSiteNumber = passport.getSite();
|
|
||||||
|
|
||||||
mChannelNumber = mSiteBand.getChannel( mFrequency );
|
|
||||||
|
|
||||||
broadcast( ChangedAttribute.CHANNEL_NUMBER );
|
|
||||||
}
|
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
@@ -545,11 +523,8 @@ public class PassportDecoderState extends DecoderState
|
|||||||
|
|
||||||
private void resetState()
|
private void resetState()
|
||||||
{
|
{
|
||||||
setTalkgroup( null );
|
mToTalkgroupAttribute.reset();
|
||||||
setTalkgroupAlias( null );
|
mFromMobileIDAttribute.reset();
|
||||||
|
|
||||||
setMobileID( null );
|
|
||||||
setMobileIDAlias( null );
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getChannelNumber()
|
public int getChannelNumber()
|
||||||
@@ -557,53 +532,42 @@ public class PassportDecoderState extends DecoderState
|
|||||||
return mChannelNumber;
|
return mChannelNumber;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void setChannelNumber(int channel)
|
||||||
|
{
|
||||||
|
if(mChannelNumber != channel)
|
||||||
|
{
|
||||||
|
mChannelNumber = channel;
|
||||||
|
broadcast(new AttributeChangeRequest<String>(Attribute.CHANNEL_FREQUENCY_LABEL, "CHAN:" + mChannelNumber));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public int getSiteNumber()
|
public int getSiteNumber()
|
||||||
{
|
{
|
||||||
return mSiteNumber;
|
return mSiteNumber;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getTalkgroup()
|
private void setSiteNumber(int site)
|
||||||
{
|
{
|
||||||
return mTalkgroup;
|
if(mSiteNumber != site)
|
||||||
|
{
|
||||||
|
mSiteNumber = site;
|
||||||
|
Alias alias = hasAliasList() ? getAliasList().getSiteID(String.valueOf(getSiteNumber())) : null;
|
||||||
|
broadcast(new AttributeChangeRequest<String>(Attribute.NETWORK_ID_1, "SITE:" + mSiteNumber, alias));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setTalkgroup( String talkgroup )
|
private PassportBand getSiteBand()
|
||||||
{
|
{
|
||||||
mTalkgroup = talkgroup;
|
return mSiteBand;
|
||||||
broadcast( ChangedAttribute.TO_TALKGROUP );
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public Alias getTalkgroupAlias()
|
private void setSiteBand(PassportBand band)
|
||||||
{
|
{
|
||||||
return mTalkgroupAlias;
|
if(mSiteBand == null)
|
||||||
|
{
|
||||||
|
mSiteBand = band;
|
||||||
|
broadcast(new AttributeChangeRequest<String>(Attribute.NETWORK_ID_2, "BAND:" + band.getDescription()));
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setTalkgroupAlias( Alias alias )
|
|
||||||
{
|
|
||||||
mTalkgroupAlias = alias;
|
|
||||||
broadcast( ChangedAttribute.TO_TALKGROUP_ALIAS );
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getMobileID()
|
|
||||||
{
|
|
||||||
return mMobileID;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setMobileID( String id )
|
|
||||||
{
|
|
||||||
mMobileID = id;
|
|
||||||
broadcast( ChangedAttribute.FROM_TALKGROUP );
|
|
||||||
}
|
|
||||||
|
|
||||||
public Alias getMobileIDAlias()
|
|
||||||
{
|
|
||||||
return mMobileIDAlias;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setMobileIDAlias( Alias alias )
|
|
||||||
{
|
|
||||||
mMobileIDAlias = alias;
|
|
||||||
broadcast( ChangedAttribute.FROM_TALKGROUP_ALIAS );
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -616,6 +580,7 @@ public class PassportDecoderState extends DecoderState
|
|||||||
break;
|
break;
|
||||||
case SOURCE_FREQUENCY:
|
case SOURCE_FREQUENCY:
|
||||||
mFrequency = event.getFrequency();
|
mFrequency = event.getFrequency();
|
||||||
|
broadcast(new AttributeChangeRequest<Long>(Attribute.CHANNEL_FREQUENCY, mFrequency));
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
|
|||||||
@@ -1,98 +0,0 @@
|
|||||||
/*******************************************************************************
|
|
||||||
* SDR Trunk
|
|
||||||
* Copyright (C) 2014,2015 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 module.decode.state;
|
|
||||||
|
|
||||||
import java.util.concurrent.ScheduledExecutorService;
|
|
||||||
|
|
||||||
import message.Message;
|
|
||||||
import module.decode.DecoderType;
|
|
||||||
import module.decode.state.DecoderStateEvent.Event;
|
|
||||||
import audio.metadata.Metadata;
|
|
||||||
import audio.metadata.MetadataType;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Basic decoder channel state - provides the minimum channel state functionality
|
|
||||||
* to support an always un-squelched audio decoder.
|
|
||||||
*/
|
|
||||||
public class AlwaysUnsquelchedDecoderState extends DecoderState
|
|
||||||
{
|
|
||||||
private DecoderType mDecoderType;
|
|
||||||
private String mChannelName;
|
|
||||||
|
|
||||||
public AlwaysUnsquelchedDecoderState( DecoderType decoderType, String channelName )
|
|
||||||
{
|
|
||||||
super( null );
|
|
||||||
|
|
||||||
mDecoderType = decoderType;
|
|
||||||
mChannelName = channelName;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void init()
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void reset()
|
|
||||||
{
|
|
||||||
/* No reset actions needed */
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String getActivitySummary()
|
|
||||||
{
|
|
||||||
StringBuilder sb = new StringBuilder();
|
|
||||||
|
|
||||||
sb.append( "Activity Summary\n" );
|
|
||||||
sb.append( "\tDecoder:\t" );
|
|
||||||
sb.append( mDecoderType );
|
|
||||||
sb.append( "\n\n" );
|
|
||||||
|
|
||||||
return sb.toString();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void receive( Message t )
|
|
||||||
{
|
|
||||||
/* Not implemented */
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void receiveDecoderStateEvent( DecoderStateEvent event )
|
|
||||||
{
|
|
||||||
/* Not implemented */
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public DecoderType getDecoderType()
|
|
||||||
{
|
|
||||||
return mDecoderType;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void start( ScheduledExecutorService executor )
|
|
||||||
{
|
|
||||||
broadcast( new Metadata( MetadataType.TO, mChannelName, false ) );
|
|
||||||
broadcast( new DecoderStateEvent( this, Event.ALWAYS_UNSQUELCH, State.IDLE ) );
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void stop()
|
|
||||||
{
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,29 +0,0 @@
|
|||||||
package module.decode.state;
|
|
||||||
|
|
||||||
public enum ChangedAttribute
|
|
||||||
{
|
|
||||||
AUDIO_TYPE,
|
|
||||||
CHANNEL_NUMBER,
|
|
||||||
CHANNEL_NAME,
|
|
||||||
CHANNEL_SITE_NUMBER,
|
|
||||||
CHANNEL_SITE_NUMBER_ALIAS,
|
|
||||||
CHANNEL_STATE,
|
|
||||||
DESCRIPTION,
|
|
||||||
FROM_TALKGROUP,
|
|
||||||
FROM_TALKGROUP_ALIAS,
|
|
||||||
FROM_TALKGROUP_TYPE,
|
|
||||||
MESSAGE,
|
|
||||||
MESSAGE_TYPE,
|
|
||||||
NAC,
|
|
||||||
SITE,
|
|
||||||
SITE_ALIAS,
|
|
||||||
SITE_NAME,
|
|
||||||
SOURCE,
|
|
||||||
SYSTEM,
|
|
||||||
SYSTEM_NAME,
|
|
||||||
SQUELCH,
|
|
||||||
TO_TALKGROUP,
|
|
||||||
TO_TALKGROUP_ALIAS,
|
|
||||||
TO_TALKGROUP_TYPE,
|
|
||||||
WACN;
|
|
||||||
}
|
|
||||||
@@ -1,317 +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 module.decode.state;
|
|
||||||
|
|
||||||
import audio.AudioPanel;
|
|
||||||
import controller.channel.Channel;
|
|
||||||
import controller.channel.ChannelEvent;
|
|
||||||
import controller.channel.ChannelEvent.Event;
|
|
||||||
import controller.channel.ChannelEventListener;
|
|
||||||
import controller.channel.ChannelModel;
|
|
||||||
import controller.channel.ChannelProcessingManager;
|
|
||||||
import icon.IconManager;
|
|
||||||
import net.miginfocom.swing.MigLayout;
|
|
||||||
import settings.ColorSetting.ColorSettingName;
|
|
||||||
import settings.ColorSettingMenuItem;
|
|
||||||
import settings.ColorSettingResetMenuItem;
|
|
||||||
import settings.SettingsManager;
|
|
||||||
|
|
||||||
import javax.swing.*;
|
|
||||||
import java.awt.*;
|
|
||||||
import java.awt.event.MouseEvent;
|
|
||||||
import java.awt.event.MouseListener;
|
|
||||||
import java.util.Map;
|
|
||||||
import java.util.concurrent.ConcurrentHashMap;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Gui wrapper for the list of currently processing primary channels
|
|
||||||
*/
|
|
||||||
public class ChannelList extends JPanel implements ChannelEventListener
|
|
||||||
{
|
|
||||||
private static final long serialVersionUID = 1L;
|
|
||||||
|
|
||||||
private Map<Channel, ChannelPanel> mDisplayedPanels = new ConcurrentHashMap<>();
|
|
||||||
|
|
||||||
private ChannelModel mChannelModel;
|
|
||||||
private ChannelProcessingManager mChannelProcessingManager;
|
|
||||||
private IconManager mIconManager;
|
|
||||||
private SettingsManager mSettingsManager;
|
|
||||||
private AudioPanel mAudioPanel;
|
|
||||||
|
|
||||||
public ChannelList(ChannelModel channelModel,
|
|
||||||
ChannelProcessingManager channelProcessingManager,
|
|
||||||
IconManager iconManager,
|
|
||||||
SettingsManager settingsManager,
|
|
||||||
AudioPanel audioPanel)
|
|
||||||
{
|
|
||||||
mChannelModel = channelModel;
|
|
||||||
mChannelProcessingManager = channelProcessingManager;
|
|
||||||
mIconManager = iconManager;
|
|
||||||
mSettingsManager = settingsManager;
|
|
||||||
mAudioPanel = audioPanel;
|
|
||||||
|
|
||||||
init();
|
|
||||||
}
|
|
||||||
|
|
||||||
private void init()
|
|
||||||
{
|
|
||||||
setLayout(new MigLayout("insets 0 0 0 0,wrap 1", "[grow,fill]", "[]0[]"));
|
|
||||||
setBackground(Color.BLACK);
|
|
||||||
|
|
||||||
addMouseListener(new ListSelectionListener());
|
|
||||||
|
|
||||||
add(mAudioPanel);
|
|
||||||
|
|
||||||
JSeparator separator = new JSeparator(JSeparator.HORIZONTAL);
|
|
||||||
add(separator);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void channelChanged(ChannelEvent event)
|
|
||||||
{
|
|
||||||
switch(event.getEvent())
|
|
||||||
{
|
|
||||||
case NOTIFICATION_PROCESSING_START:
|
|
||||||
addChannelPanel(event.getChannel());
|
|
||||||
break;
|
|
||||||
case NOTIFICATION_PROCESSING_STOP:
|
|
||||||
removeChannelPanel(event.getChannel());
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void addChannelPanel(Channel channel)
|
|
||||||
{
|
|
||||||
if(!mDisplayedPanels.containsKey(channel))
|
|
||||||
{
|
|
||||||
ChannelPanel channelPanel = new ChannelPanel(mChannelModel,
|
|
||||||
mChannelProcessingManager, mIconManager, mSettingsManager, channel);
|
|
||||||
|
|
||||||
add(channelPanel);
|
|
||||||
|
|
||||||
mDisplayedPanels.put(channel, channelPanel);
|
|
||||||
|
|
||||||
revalidate();
|
|
||||||
repaint();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public void removeChannelPanel(Channel channel)
|
|
||||||
{
|
|
||||||
if(mDisplayedPanels.containsKey(channel))
|
|
||||||
{
|
|
||||||
ChannelPanel panel = mDisplayedPanels.remove(channel);
|
|
||||||
|
|
||||||
if(panel != null)
|
|
||||||
{
|
|
||||||
remove(panel);
|
|
||||||
|
|
||||||
panel.dispose();
|
|
||||||
}
|
|
||||||
|
|
||||||
revalidate();
|
|
||||||
repaint();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public class ListSelectionListener implements MouseListener
|
|
||||||
{
|
|
||||||
@Override
|
|
||||||
public void mouseClicked(MouseEvent e)
|
|
||||||
{
|
|
||||||
Component component = getComponentAt(e.getPoint());
|
|
||||||
|
|
||||||
if(component instanceof ChannelPanel)
|
|
||||||
{
|
|
||||||
ChannelPanel panel = (ChannelPanel) component;
|
|
||||||
|
|
||||||
Channel channel = panel.getChannel();
|
|
||||||
|
|
||||||
if(e.getButton() == MouseEvent.BUTTON1)
|
|
||||||
{
|
|
||||||
if(channel.isSelected())
|
|
||||||
{
|
|
||||||
mChannelModel.broadcast(new ChannelEvent(channel, Event.REQUEST_DESELECT));
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
mChannelModel.broadcast(new ChannelEvent(channel, Event.REQUEST_SELECT));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else if(e.getButton() == MouseEvent.BUTTON3)
|
|
||||||
{
|
|
||||||
JPopupMenu popupMenu = new JPopupMenu();
|
|
||||||
|
|
||||||
JMenu menu = panel.getContextMenu();
|
|
||||||
|
|
||||||
if(menu != null)
|
|
||||||
{
|
|
||||||
popupMenu.add(menu);
|
|
||||||
}
|
|
||||||
|
|
||||||
JMenu colorMenu = new JMenu("Color");
|
|
||||||
popupMenu.add(colorMenu);
|
|
||||||
|
|
||||||
JMenu backgroundMenu = new JMenu("Background");
|
|
||||||
colorMenu.add(backgroundMenu);
|
|
||||||
|
|
||||||
backgroundMenu.add(new ColorSettingMenuItem(mSettingsManager,
|
|
||||||
ColorSettingName.CHANNEL_STATE_BACKGROUND));
|
|
||||||
backgroundMenu.add(new ColorSettingResetMenuItem(mSettingsManager,
|
|
||||||
ColorSettingName.CHANNEL_STATE_BACKGROUND));
|
|
||||||
|
|
||||||
JMenu channelsMenu = new JMenu("Channel State");
|
|
||||||
colorMenu.add(channelsMenu);
|
|
||||||
|
|
||||||
JMenu callMenu = new JMenu("Call");
|
|
||||||
channelsMenu.add(callMenu);
|
|
||||||
|
|
||||||
callMenu.add(new ColorSettingMenuItem(mSettingsManager,
|
|
||||||
ColorSettingName.CHANNEL_STATE_GRADIENT_MIDDLE_CALL));
|
|
||||||
callMenu.add(new ColorSettingResetMenuItem(mSettingsManager,
|
|
||||||
ColorSettingName.CHANNEL_STATE_GRADIENT_MIDDLE_CALL));
|
|
||||||
callMenu.add(new JSeparator());
|
|
||||||
|
|
||||||
callMenu.add(new ColorSettingMenuItem(mSettingsManager,
|
|
||||||
ColorSettingName.CHANNEL_STATE_GRADIENT_TOP_CALL));
|
|
||||||
callMenu.add(new ColorSettingResetMenuItem(mSettingsManager,
|
|
||||||
ColorSettingName.CHANNEL_STATE_GRADIENT_TOP_CALL));
|
|
||||||
|
|
||||||
JMenu controlMenu = new JMenu("Control");
|
|
||||||
channelsMenu.add(controlMenu);
|
|
||||||
|
|
||||||
controlMenu.add(new ColorSettingMenuItem(mSettingsManager,
|
|
||||||
ColorSettingName.CHANNEL_STATE_GRADIENT_MIDDLE_CONTROL));
|
|
||||||
controlMenu.add(new ColorSettingResetMenuItem(mSettingsManager,
|
|
||||||
ColorSettingName.CHANNEL_STATE_GRADIENT_MIDDLE_CONTROL));
|
|
||||||
controlMenu.add(new JSeparator());
|
|
||||||
|
|
||||||
controlMenu.add(new ColorSettingMenuItem(mSettingsManager,
|
|
||||||
ColorSettingName.CHANNEL_STATE_GRADIENT_TOP_CONTROL));
|
|
||||||
controlMenu.add(new ColorSettingResetMenuItem(mSettingsManager,
|
|
||||||
ColorSettingName.CHANNEL_STATE_GRADIENT_TOP_CONTROL));
|
|
||||||
|
|
||||||
JMenu dataMenu = new JMenu("Data");
|
|
||||||
channelsMenu.add(dataMenu);
|
|
||||||
|
|
||||||
dataMenu.add(new ColorSettingMenuItem(mSettingsManager,
|
|
||||||
ColorSettingName.CHANNEL_STATE_GRADIENT_MIDDLE_DATA));
|
|
||||||
dataMenu.add(new ColorSettingResetMenuItem(mSettingsManager,
|
|
||||||
ColorSettingName.CHANNEL_STATE_GRADIENT_MIDDLE_DATA));
|
|
||||||
dataMenu.add(new JSeparator());
|
|
||||||
|
|
||||||
dataMenu.add(new ColorSettingMenuItem(mSettingsManager,
|
|
||||||
ColorSettingName.CHANNEL_STATE_GRADIENT_TOP_DATA));
|
|
||||||
dataMenu.add(new ColorSettingResetMenuItem(mSettingsManager,
|
|
||||||
ColorSettingName.CHANNEL_STATE_GRADIENT_TOP_DATA));
|
|
||||||
|
|
||||||
JMenu fadeMenu = new JMenu("Fade");
|
|
||||||
channelsMenu.add(fadeMenu);
|
|
||||||
|
|
||||||
fadeMenu.add(new ColorSettingMenuItem(mSettingsManager,
|
|
||||||
ColorSettingName.CHANNEL_STATE_GRADIENT_MIDDLE_FADE));
|
|
||||||
fadeMenu.add(new ColorSettingResetMenuItem(mSettingsManager,
|
|
||||||
ColorSettingName.CHANNEL_STATE_GRADIENT_MIDDLE_FADE));
|
|
||||||
fadeMenu.add(new JSeparator());
|
|
||||||
|
|
||||||
fadeMenu.add(new ColorSettingMenuItem(mSettingsManager,
|
|
||||||
ColorSettingName.CHANNEL_STATE_GRADIENT_TOP_FADE));
|
|
||||||
fadeMenu.add(new ColorSettingResetMenuItem(mSettingsManager,
|
|
||||||
ColorSettingName.CHANNEL_STATE_GRADIENT_TOP_FADE));
|
|
||||||
|
|
||||||
JMenu idleMenu = new JMenu("Idle");
|
|
||||||
channelsMenu.add(idleMenu);
|
|
||||||
|
|
||||||
idleMenu.add(new ColorSettingMenuItem(mSettingsManager,
|
|
||||||
ColorSettingName.CHANNEL_STATE_GRADIENT_MIDDLE_IDLE));
|
|
||||||
idleMenu.add(new ColorSettingResetMenuItem(mSettingsManager,
|
|
||||||
ColorSettingName.CHANNEL_STATE_GRADIENT_MIDDLE_IDLE));
|
|
||||||
idleMenu.add(new JSeparator());
|
|
||||||
|
|
||||||
idleMenu.add(new ColorSettingMenuItem(mSettingsManager,
|
|
||||||
ColorSettingName.CHANNEL_STATE_GRADIENT_TOP_IDLE));
|
|
||||||
idleMenu.add(new ColorSettingResetMenuItem(mSettingsManager,
|
|
||||||
ColorSettingName.CHANNEL_STATE_GRADIENT_TOP_IDLE));
|
|
||||||
|
|
||||||
JMenu noTunerMenu = new JMenu("No Tuner");
|
|
||||||
channelsMenu.add(noTunerMenu);
|
|
||||||
|
|
||||||
noTunerMenu.add(new ColorSettingMenuItem(mSettingsManager,
|
|
||||||
ColorSettingName.CHANNEL_STATE_GRADIENT_MIDDLE_NO_TUNER));
|
|
||||||
noTunerMenu.add(new ColorSettingResetMenuItem(mSettingsManager,
|
|
||||||
ColorSettingName.CHANNEL_STATE_GRADIENT_MIDDLE_NO_TUNER));
|
|
||||||
noTunerMenu.add(new JSeparator());
|
|
||||||
|
|
||||||
noTunerMenu.add(new ColorSettingMenuItem(mSettingsManager,
|
|
||||||
ColorSettingName.CHANNEL_STATE_GRADIENT_TOP_NO_TUNER));
|
|
||||||
noTunerMenu.add(new ColorSettingResetMenuItem(mSettingsManager,
|
|
||||||
ColorSettingName.CHANNEL_STATE_GRADIENT_TOP_NO_TUNER));
|
|
||||||
|
|
||||||
JMenu labelMenu = new JMenu("Labels");
|
|
||||||
colorMenu.add(labelMenu);
|
|
||||||
|
|
||||||
labelMenu.add(new ColorSettingMenuItem(mSettingsManager,
|
|
||||||
ColorSettingName.CHANNEL_STATE_LABEL_AUX_DECODER));
|
|
||||||
labelMenu.add(new ColorSettingResetMenuItem(mSettingsManager,
|
|
||||||
ColorSettingName.CHANNEL_STATE_LABEL_AUX_DECODER));
|
|
||||||
labelMenu.add(new JSeparator());
|
|
||||||
|
|
||||||
labelMenu.add(new ColorSettingMenuItem(mSettingsManager,
|
|
||||||
ColorSettingName.CHANNEL_STATE_LABEL_DECODER));
|
|
||||||
labelMenu.add(new ColorSettingResetMenuItem(mSettingsManager,
|
|
||||||
ColorSettingName.CHANNEL_STATE_LABEL_DECODER));
|
|
||||||
labelMenu.add(new JSeparator());
|
|
||||||
|
|
||||||
labelMenu.add(new ColorSettingMenuItem(mSettingsManager,
|
|
||||||
ColorSettingName.CHANNEL_STATE_LABEL_DETAILS));
|
|
||||||
labelMenu.add(new ColorSettingResetMenuItem(mSettingsManager,
|
|
||||||
ColorSettingName.CHANNEL_STATE_LABEL_DETAILS));
|
|
||||||
|
|
||||||
JMenu selectedMenu = new JMenu("Selected");
|
|
||||||
colorMenu.add(selectedMenu);
|
|
||||||
|
|
||||||
selectedMenu.add(new ColorSettingMenuItem(mSettingsManager,
|
|
||||||
ColorSettingName.CHANNEL_STATE_SELECTED_CHANNEL));
|
|
||||||
selectedMenu.add(new ColorSettingResetMenuItem(mSettingsManager,
|
|
||||||
ColorSettingName.CHANNEL_STATE_SELECTED_CHANNEL));
|
|
||||||
|
|
||||||
popupMenu.show(ChannelList.this, e.getX(), e.getY());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public void mousePressed(MouseEvent e)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
public void mouseReleased(MouseEvent e)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
public void mouseEntered(MouseEvent e)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
public void mouseExited(MouseEvent e)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,465 +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 module.decode.state;
|
|
||||||
|
|
||||||
import controller.channel.Channel;
|
|
||||||
import controller.channel.ChannelEvent;
|
|
||||||
import controller.channel.ChannelEvent.Event;
|
|
||||||
import controller.channel.ChannelEventListener;
|
|
||||||
import controller.channel.ChannelModel;
|
|
||||||
import controller.channel.ChannelProcessingManager;
|
|
||||||
import controller.channel.ChannelUtils;
|
|
||||||
import icon.IconManager;
|
|
||||||
import module.ProcessingChain;
|
|
||||||
import module.decode.DecoderFactory;
|
|
||||||
import net.miginfocom.swing.MigLayout;
|
|
||||||
import org.slf4j.Logger;
|
|
||||||
import org.slf4j.LoggerFactory;
|
|
||||||
import record.RecorderType;
|
|
||||||
import record.config.RecordConfiguration;
|
|
||||||
import sample.Listener;
|
|
||||||
import settings.ColorSetting;
|
|
||||||
import settings.ColorSetting.ColorSettingName;
|
|
||||||
import settings.Setting;
|
|
||||||
import settings.SettingChangeListener;
|
|
||||||
import settings.SettingsManager;
|
|
||||||
|
|
||||||
import javax.swing.*;
|
|
||||||
import java.awt.*;
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
public class ChannelPanel extends JPanel
|
|
||||||
implements Listener<ChangedAttribute>,
|
|
||||||
SettingChangeListener,
|
|
||||||
ChannelEventListener
|
|
||||||
{
|
|
||||||
private static final long serialVersionUID = 1L;
|
|
||||||
|
|
||||||
private final static Logger mLog = LoggerFactory.getLogger(ChannelPanel.class);
|
|
||||||
|
|
||||||
private Font mFontDetails = new Font(Font.MONOSPACED, Font.PLAIN, 12);
|
|
||||||
private Font mFontDecoder = new Font(Font.MONOSPACED, Font.PLAIN, 12);
|
|
||||||
|
|
||||||
protected Color mColorChannelBackground;
|
|
||||||
protected Color mColorChannelSelected;
|
|
||||||
protected Color mColorTopCall;
|
|
||||||
protected Color mColorMiddleCall;
|
|
||||||
protected Color mColorTopControl;
|
|
||||||
protected Color mColorMiddleControl;
|
|
||||||
protected Color mColorTopData;
|
|
||||||
protected Color mColorMiddleData;
|
|
||||||
protected Color mColorTopFade;
|
|
||||||
protected Color mColorMiddleFade;
|
|
||||||
protected Color mColorTopIdle;
|
|
||||||
protected Color mColorMiddleIdle;
|
|
||||||
protected Color mColorTopNoTuner;
|
|
||||||
protected Color mColorMiddleNoTuner;
|
|
||||||
protected Color mColorLabelDetails;
|
|
||||||
protected Color mColorLabelDecoder;
|
|
||||||
protected Color mColorLabelAuxDecoder;
|
|
||||||
|
|
||||||
private JLabel mStateLabel;
|
|
||||||
private JLabel mSourceLabel;
|
|
||||||
private JLabel mOptionsLabel;
|
|
||||||
|
|
||||||
private JLabel mSystemLabel;
|
|
||||||
private JLabel mSiteLabel;
|
|
||||||
private JLabel mChannelLabel;
|
|
||||||
|
|
||||||
protected SettingsManager mSettingsManager;
|
|
||||||
protected IconManager mIconManager;
|
|
||||||
|
|
||||||
private Channel mChannel;
|
|
||||||
private ChannelState mChannelState;
|
|
||||||
private List<DecoderPanel> mDecoderPanels = new ArrayList<>();
|
|
||||||
private ChannelModel mChannelModel;
|
|
||||||
private ChannelProcessingManager mChannelProcessingManager;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Gui component to a channel state. Provides System, Site and channel
|
|
||||||
* name, source and channel state visualization.
|
|
||||||
*
|
|
||||||
* Updates color background according to current channel state.
|
|
||||||
*/
|
|
||||||
public ChannelPanel(ChannelModel channelModel,
|
|
||||||
ChannelProcessingManager channelProcessingManager,
|
|
||||||
IconManager iconManager,
|
|
||||||
SettingsManager settingsManager,
|
|
||||||
Channel channel)
|
|
||||||
{
|
|
||||||
mChannelModel = channelModel;
|
|
||||||
mChannelProcessingManager = channelProcessingManager;
|
|
||||||
mIconManager = iconManager;
|
|
||||||
mSettingsManager = settingsManager;
|
|
||||||
mChannel = channel;
|
|
||||||
|
|
||||||
ProcessingChain processingChain =
|
|
||||||
channelProcessingManager.getProcessingChain(mChannel);
|
|
||||||
|
|
||||||
if(processingChain != null)
|
|
||||||
{
|
|
||||||
mChannelState = processingChain.getChannelState();
|
|
||||||
|
|
||||||
init();
|
|
||||||
|
|
||||||
for(DecoderState decoderState : processingChain.getDecoderStates())
|
|
||||||
{
|
|
||||||
DecoderPanel panel = DecoderFactory.getDecoderPanel(mIconManager, mSettingsManager, decoderState);
|
|
||||||
mDecoderPanels.add(panel);
|
|
||||||
add(panel, "grow,span");
|
|
||||||
}
|
|
||||||
|
|
||||||
mChannelState.setChangedAttributeListener(this);
|
|
||||||
mChannelModel.addListener(this);
|
|
||||||
mSettingsManager.addListener(this);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
mLog.error("Processing Chain was null!");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void init()
|
|
||||||
{
|
|
||||||
getColors();
|
|
||||||
|
|
||||||
setLayout(new MigLayout("insets 1 1 1 1", "[grow,fill]", "[]0[]0[]"));
|
|
||||||
|
|
||||||
mSystemLabel = new JLabel(mChannel.getSystem());
|
|
||||||
mSystemLabel.setFont(mFontDetails);
|
|
||||||
mSystemLabel.setForeground(mColorLabelDetails);
|
|
||||||
add(mSystemLabel);
|
|
||||||
|
|
||||||
mSiteLabel = new JLabel(mChannel.getSite());
|
|
||||||
mSiteLabel.setFont(mFontDetails);
|
|
||||||
mSiteLabel.setForeground(mColorLabelDetails);
|
|
||||||
add(mSiteLabel);
|
|
||||||
|
|
||||||
mChannelLabel = new JLabel(mChannel.getName());
|
|
||||||
mChannelLabel.setFont(mFontDetails);
|
|
||||||
mChannelLabel.setForeground(mColorLabelDetails);
|
|
||||||
add(mChannelLabel, "wrap");
|
|
||||||
|
|
||||||
mStateLabel = new JLabel(mChannelState.getState().getDisplayValue());
|
|
||||||
mStateLabel.setFont(mFontDecoder);
|
|
||||||
mStateLabel.setForeground(mColorLabelDecoder);
|
|
||||||
add(mStateLabel);
|
|
||||||
|
|
||||||
mSourceLabel = new JLabel(mChannel.getSourceConfiguration().getDescription());
|
|
||||||
mSourceLabel.setFont(mFontDetails);
|
|
||||||
mSourceLabel.setForeground(mColorLabelDetails);
|
|
||||||
add(mSourceLabel);
|
|
||||||
|
|
||||||
StringBuilder sb = new StringBuilder();
|
|
||||||
|
|
||||||
if(!mChannel.getEventLogConfiguration().getLoggers().isEmpty())
|
|
||||||
{
|
|
||||||
sb.append("LOG ");
|
|
||||||
}
|
|
||||||
|
|
||||||
RecordConfiguration recordConfig = mChannel.getRecordConfiguration();
|
|
||||||
|
|
||||||
if(recordConfig.getRecorders().contains(RecorderType.AUDIO))
|
|
||||||
{
|
|
||||||
sb.append("AUDIO ");
|
|
||||||
}
|
|
||||||
|
|
||||||
if(recordConfig.getRecorders().contains(RecorderType.BASEBAND) ||
|
|
||||||
recordConfig.getRecorders().contains(RecorderType.TRAFFIC_BASEBAND))
|
|
||||||
{
|
|
||||||
sb.append("BASEBAND");
|
|
||||||
}
|
|
||||||
|
|
||||||
mOptionsLabel = new JLabel(sb.toString());
|
|
||||||
mOptionsLabel.setFont(mFontDetails);
|
|
||||||
mOptionsLabel.setForeground(mColorLabelAuxDecoder);
|
|
||||||
add(mOptionsLabel, "wrap");
|
|
||||||
}
|
|
||||||
|
|
||||||
public Channel getChannel()
|
|
||||||
{
|
|
||||||
return mChannel;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void dispose()
|
|
||||||
{
|
|
||||||
mChannelModel.removeListener(this);
|
|
||||||
mChannelModel = null;
|
|
||||||
|
|
||||||
mChannelProcessingManager = null;
|
|
||||||
|
|
||||||
mSettingsManager.removeListener(this);
|
|
||||||
mSettingsManager = null;
|
|
||||||
|
|
||||||
mChannelState.removeChangedAttributeListener();
|
|
||||||
mChannelState = null;
|
|
||||||
mChannel = null;
|
|
||||||
|
|
||||||
for(DecoderPanel panel : mDecoderPanels)
|
|
||||||
{
|
|
||||||
panel.dispose();
|
|
||||||
remove(panel);
|
|
||||||
}
|
|
||||||
|
|
||||||
mDecoderPanels.clear();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void receive(final ChangedAttribute changedAttribute)
|
|
||||||
{
|
|
||||||
EventQueue.invokeLater(new Runnable()
|
|
||||||
{
|
|
||||||
@Override
|
|
||||||
public void run()
|
|
||||||
{
|
|
||||||
switch(changedAttribute)
|
|
||||||
{
|
|
||||||
case CHANNEL_STATE:
|
|
||||||
if(mChannelState != null && mChannelState.getState() != null)
|
|
||||||
{
|
|
||||||
mStateLabel.setText(mChannelState.getState().getDisplayValue());
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case SOURCE:
|
|
||||||
mSourceLabel.setText(mChannel.getSourceConfiguration()
|
|
||||||
.getDescription());
|
|
||||||
break;
|
|
||||||
case CHANNEL_NAME:
|
|
||||||
case SITE_NAME:
|
|
||||||
case SYSTEM_NAME:
|
|
||||||
mChannelLabel.setText(mChannel.toString());
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
repaint();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void paintComponent(Graphics g)
|
|
||||||
{
|
|
||||||
super.paintComponent(g);
|
|
||||||
|
|
||||||
setBackground(mColorChannelBackground);
|
|
||||||
|
|
||||||
Graphics2D g2 = (Graphics2D) g.create();
|
|
||||||
|
|
||||||
Paint p = null;
|
|
||||||
|
|
||||||
final Channel channel = mChannel;
|
|
||||||
|
|
||||||
if(mChannelState != null)
|
|
||||||
{
|
|
||||||
switch(mChannelState.getState())
|
|
||||||
{
|
|
||||||
case CALL:
|
|
||||||
p = getGradient(mColorTopCall, mColorMiddleCall);
|
|
||||||
break;
|
|
||||||
case CONTROL:
|
|
||||||
p = getGradient(mColorTopControl, mColorMiddleControl);
|
|
||||||
break;
|
|
||||||
case DATA:
|
|
||||||
p = getGradient(mColorTopData, mColorMiddleData);
|
|
||||||
break;
|
|
||||||
case FADE:
|
|
||||||
p = getGradient(mColorTopFade, mColorMiddleFade);
|
|
||||||
break;
|
|
||||||
case IDLE:
|
|
||||||
default:
|
|
||||||
p = getGradient(mColorTopIdle, mColorMiddleIdle);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if(p == null)
|
|
||||||
{
|
|
||||||
p = getGradient(mColorTopIdle, mColorMiddleIdle);
|
|
||||||
}
|
|
||||||
|
|
||||||
g2.setPaint(p);
|
|
||||||
g2.fillRect(0, 0, getWidth(), getHeight());
|
|
||||||
|
|
||||||
/* Draw bottom separator line */
|
|
||||||
g2.setColor(Color.LIGHT_GRAY);
|
|
||||||
g2.drawLine(0, getHeight() - 1, getWidth(), getHeight() - 1);
|
|
||||||
|
|
||||||
/* Draw channel selected box */
|
|
||||||
if(getChannel() != null && getChannel().isSelected())
|
|
||||||
{
|
|
||||||
g2.setColor(mColorChannelSelected);
|
|
||||||
g2.drawRect(1, 1, getWidth() - 2, getHeight() - 2);
|
|
||||||
}
|
|
||||||
|
|
||||||
g2.dispose();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
private void getColors()
|
|
||||||
{
|
|
||||||
mColorChannelBackground = mSettingsManager.getColorSetting(
|
|
||||||
ColorSettingName.CHANNEL_STATE_BACKGROUND).getColor();
|
|
||||||
mColorChannelSelected = mSettingsManager.getColorSetting(
|
|
||||||
ColorSettingName.CHANNEL_STATE_SELECTED_CHANNEL).getColor();
|
|
||||||
mColorTopCall = mSettingsManager.getColorSetting(
|
|
||||||
ColorSettingName.CHANNEL_STATE_GRADIENT_TOP_CALL).getColor();
|
|
||||||
mColorMiddleCall = mSettingsManager.getColorSetting(
|
|
||||||
ColorSettingName.CHANNEL_STATE_GRADIENT_MIDDLE_CALL).getColor();
|
|
||||||
mColorTopControl = mSettingsManager.getColorSetting(
|
|
||||||
ColorSettingName.CHANNEL_STATE_GRADIENT_TOP_CONTROL).getColor();
|
|
||||||
mColorMiddleControl = mSettingsManager.getColorSetting(
|
|
||||||
ColorSettingName.CHANNEL_STATE_GRADIENT_MIDDLE_CONTROL).getColor();
|
|
||||||
mColorTopData = mSettingsManager.getColorSetting(
|
|
||||||
ColorSettingName.CHANNEL_STATE_GRADIENT_TOP_DATA).getColor();
|
|
||||||
mColorMiddleData = mSettingsManager.getColorSetting(
|
|
||||||
ColorSettingName.CHANNEL_STATE_GRADIENT_MIDDLE_DATA).getColor();
|
|
||||||
mColorTopFade = mSettingsManager.getColorSetting(
|
|
||||||
ColorSettingName.CHANNEL_STATE_GRADIENT_TOP_FADE).getColor();
|
|
||||||
mColorMiddleFade = mSettingsManager.getColorSetting(
|
|
||||||
ColorSettingName.CHANNEL_STATE_GRADIENT_MIDDLE_FADE).getColor();
|
|
||||||
mColorTopIdle = mSettingsManager.getColorSetting(
|
|
||||||
ColorSettingName.CHANNEL_STATE_GRADIENT_TOP_IDLE).getColor();
|
|
||||||
mColorMiddleIdle = mSettingsManager.getColorSetting(
|
|
||||||
ColorSettingName.CHANNEL_STATE_GRADIENT_MIDDLE_IDLE).getColor();
|
|
||||||
mColorTopNoTuner = mSettingsManager.getColorSetting(
|
|
||||||
ColorSettingName.CHANNEL_STATE_GRADIENT_TOP_NO_TUNER).getColor();
|
|
||||||
mColorMiddleNoTuner = mSettingsManager.getColorSetting(
|
|
||||||
ColorSettingName.CHANNEL_STATE_GRADIENT_MIDDLE_NO_TUNER).getColor();
|
|
||||||
|
|
||||||
mColorLabelDetails = mSettingsManager.getColorSetting(
|
|
||||||
ColorSettingName.CHANNEL_STATE_LABEL_DETAILS).getColor();
|
|
||||||
mColorLabelDecoder = mSettingsManager.getColorSetting(
|
|
||||||
ColorSettingName.CHANNEL_STATE_LABEL_DECODER).getColor();
|
|
||||||
mColorLabelAuxDecoder = mSettingsManager.getColorSetting(
|
|
||||||
ColorSettingName.CHANNEL_STATE_LABEL_AUX_DECODER).getColor();
|
|
||||||
}
|
|
||||||
|
|
||||||
private GradientPaint getGradient(Color top, Color middle)
|
|
||||||
{
|
|
||||||
return new GradientPaint(0f, -50.0f, top,
|
|
||||||
0f, (float) getHeight() / 2.2f, middle, true);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void settingChanged(Setting setting)
|
|
||||||
{
|
|
||||||
if(setting instanceof ColorSetting)
|
|
||||||
{
|
|
||||||
ColorSetting colorSetting = (ColorSetting) setting;
|
|
||||||
|
|
||||||
switch(colorSetting.getColorSettingName())
|
|
||||||
{
|
|
||||||
case CHANNEL_STATE_BACKGROUND:
|
|
||||||
mColorChannelBackground = colorSetting.getColor();
|
|
||||||
repaint();
|
|
||||||
break;
|
|
||||||
case CHANNEL_STATE_GRADIENT_MIDDLE_CALL:
|
|
||||||
mColorMiddleCall = colorSetting.getColor();
|
|
||||||
repaint();
|
|
||||||
break;
|
|
||||||
case CHANNEL_STATE_GRADIENT_TOP_CALL:
|
|
||||||
mColorTopCall = colorSetting.getColor();
|
|
||||||
repaint();
|
|
||||||
break;
|
|
||||||
case CHANNEL_STATE_GRADIENT_MIDDLE_CONTROL:
|
|
||||||
mColorMiddleControl = colorSetting.getColor();
|
|
||||||
repaint();
|
|
||||||
break;
|
|
||||||
case CHANNEL_STATE_GRADIENT_TOP_CONTROL:
|
|
||||||
mColorTopControl = colorSetting.getColor();
|
|
||||||
repaint();
|
|
||||||
break;
|
|
||||||
case CHANNEL_STATE_GRADIENT_MIDDLE_DATA:
|
|
||||||
mColorMiddleData = colorSetting.getColor();
|
|
||||||
repaint();
|
|
||||||
break;
|
|
||||||
case CHANNEL_STATE_GRADIENT_TOP_DATA:
|
|
||||||
mColorTopData = colorSetting.getColor();
|
|
||||||
repaint();
|
|
||||||
break;
|
|
||||||
case CHANNEL_STATE_GRADIENT_MIDDLE_FADE:
|
|
||||||
mColorMiddleFade = colorSetting.getColor();
|
|
||||||
repaint();
|
|
||||||
break;
|
|
||||||
case CHANNEL_STATE_GRADIENT_TOP_FADE:
|
|
||||||
mColorTopFade = colorSetting.getColor();
|
|
||||||
repaint();
|
|
||||||
break;
|
|
||||||
case CHANNEL_STATE_GRADIENT_MIDDLE_IDLE:
|
|
||||||
mColorMiddleIdle = colorSetting.getColor();
|
|
||||||
repaint();
|
|
||||||
break;
|
|
||||||
case CHANNEL_STATE_GRADIENT_TOP_IDLE:
|
|
||||||
mColorTopIdle = colorSetting.getColor();
|
|
||||||
repaint();
|
|
||||||
break;
|
|
||||||
case CHANNEL_STATE_GRADIENT_MIDDLE_NO_TUNER:
|
|
||||||
mColorMiddleNoTuner = colorSetting.getColor();
|
|
||||||
repaint();
|
|
||||||
break;
|
|
||||||
case CHANNEL_STATE_GRADIENT_TOP_NO_TUNER:
|
|
||||||
mColorTopNoTuner = colorSetting.getColor();
|
|
||||||
repaint();
|
|
||||||
break;
|
|
||||||
case CHANNEL_STATE_LABEL_AUX_DECODER:
|
|
||||||
mColorLabelAuxDecoder = colorSetting.getColor();
|
|
||||||
repaint();
|
|
||||||
break;
|
|
||||||
case CHANNEL_STATE_LABEL_DECODER:
|
|
||||||
mColorLabelDecoder = colorSetting.getColor();
|
|
||||||
repaint();
|
|
||||||
break;
|
|
||||||
case CHANNEL_STATE_LABEL_DETAILS:
|
|
||||||
mColorLabelDetails = colorSetting.getColor();
|
|
||||||
repaint();
|
|
||||||
break;
|
|
||||||
case CHANNEL_STATE_SELECTED_CHANNEL:
|
|
||||||
mColorChannelSelected = colorSetting.getColor();
|
|
||||||
repaint();
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void settingDeleted(Setting setting)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
public JMenu getContextMenu()
|
|
||||||
{
|
|
||||||
return ChannelUtils.getContextMenu(mChannelModel, mChannelProcessingManager,
|
|
||||||
mChannel, ChannelPanel.this);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void channelChanged(ChannelEvent event)
|
|
||||||
{
|
|
||||||
if(event.getEvent() == Event.NOTIFICATION_SELECTION_CHANGE &&
|
|
||||||
event.getChannel() == mChannel)
|
|
||||||
{
|
|
||||||
repaint();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,676 +0,0 @@
|
|||||||
/*******************************************************************************
|
|
||||||
* SDR Trunk
|
|
||||||
* Copyright (C) 2014-2016 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 module.decode.state;
|
|
||||||
|
|
||||||
import java.util.concurrent.RejectedExecutionException;
|
|
||||||
import java.util.concurrent.ScheduledExecutorService;
|
|
||||||
import java.util.concurrent.ScheduledFuture;
|
|
||||||
import java.util.concurrent.TimeUnit;
|
|
||||||
|
|
||||||
import module.Module;
|
|
||||||
import module.decode.config.DecodeConfiguration;
|
|
||||||
import module.decode.event.CallEvent;
|
|
||||||
import module.decode.event.ICallEventProvider;
|
|
||||||
import module.decode.state.DecoderStateEvent.Event;
|
|
||||||
|
|
||||||
import org.slf4j.Logger;
|
|
||||||
import org.slf4j.LoggerFactory;
|
|
||||||
|
|
||||||
import sample.Listener;
|
|
||||||
import audio.metadata.IMetadataProvider;
|
|
||||||
import audio.metadata.Metadata;
|
|
||||||
import audio.metadata.MetadataReset;
|
|
||||||
import audio.metadata.MetadataType;
|
|
||||||
import audio.squelch.ISquelchStateProvider;
|
|
||||||
import audio.squelch.SquelchState;
|
|
||||||
import controller.channel.Channel.ChannelType;
|
|
||||||
|
|
||||||
public class ChannelState extends Module implements ICallEventProvider, IChangedAttributeProvider,
|
|
||||||
IDecoderStateEventListener, IDecoderStateEventProvider, IMetadataProvider, ISquelchStateProvider
|
|
||||||
{
|
|
||||||
private final static Logger mLog =
|
|
||||||
LoggerFactory.getLogger( ChannelState.class );
|
|
||||||
|
|
||||||
public static final long FADE_TIMEOUT_DELAY = 1200;
|
|
||||||
public static final long RESET_TIMEOUT_DELAY = 2000;
|
|
||||||
|
|
||||||
private State mState = State.IDLE;
|
|
||||||
|
|
||||||
private Listener<CallEvent> mCallEventListener;
|
|
||||||
private Listener<ChangedAttribute> mChangedAttributeListener;
|
|
||||||
private Listener<DecoderStateEvent> mDecoderStateListener;
|
|
||||||
private Listener<Metadata> mMetadataListener;
|
|
||||||
private Listener<SquelchState> mSquelchStateListener;
|
|
||||||
private DecoderStateEventReceiver mDecoderStateEventReceiver =
|
|
||||||
new DecoderStateEventReceiver();
|
|
||||||
|
|
||||||
private boolean mSquelchLocked = false;
|
|
||||||
private boolean mSelected = false;
|
|
||||||
|
|
||||||
private long mStandardChannelFadeTimeout = FADE_TIMEOUT_DELAY;
|
|
||||||
private long mTrafficChannelFadeTimeout = DecodeConfiguration.DEFAULT_CALL_TIMEOUT_SECONDS * 1000;
|
|
||||||
private long mFadeTimeout;
|
|
||||||
private long mEndTimeout;
|
|
||||||
|
|
||||||
private StateMonitor mStateMonitor = new StateMonitor();
|
|
||||||
private ScheduledFuture<?> mStateMonitorFuture;
|
|
||||||
|
|
||||||
private ChannelType mChannelType;
|
|
||||||
|
|
||||||
private TrafficChannelManager mTrafficChannelEndListener;
|
|
||||||
private CallEvent mTrafficChannelCallEvent;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Channel state tracks the overall state of all processing modules and decoders
|
|
||||||
* configured for the channel and provides squelch control and decoder state
|
|
||||||
* reset events.
|
|
||||||
*
|
|
||||||
* Uses a state enumeration that defines allowable channel state transitions in
|
|
||||||
* order to track a call or data decode event from start to finish. Uses a
|
|
||||||
* timer to monitor for inactivity and to provide a FADE period that indicates
|
|
||||||
* to the user that the activity has stopped while continuing to provide details
|
|
||||||
* about the call, before the state is reset to IDLE.
|
|
||||||
*
|
|
||||||
* Since this class is multi-threaded between decoder events and the internal
|
|
||||||
* timer that monitors for inactivity, this class uses the mState object for
|
|
||||||
* thread synchronization.
|
|
||||||
*
|
|
||||||
* State Descriptions:
|
|
||||||
* IDLE Normal state. No voice or data call activity
|
|
||||||
* CALL/DATA/ENCRYPTED/CONTROL
|
|
||||||
* Decoding states.
|
|
||||||
* FADE The phase after a voice or data call when either an explicit
|
|
||||||
* call end has been received, or when no new signalling updates
|
|
||||||
* have been received, and the fade timer has expired. This phase
|
|
||||||
* allows for gui updates to signal to the user that the call is
|
|
||||||
* ended, while continuing to display the call details for the user
|
|
||||||
* TEARDOWN Indicates a traffic channel that will be torn down for reuse.
|
|
||||||
*/
|
|
||||||
public ChannelState( ChannelType channelType )
|
|
||||||
{
|
|
||||||
mChannelType = channelType;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Resets this channel state and prepares it for reuse.
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
public void reset()
|
|
||||||
{
|
|
||||||
broadcast( new DecoderStateEvent( this, Event.RESET, State.IDLE ) );
|
|
||||||
broadcast( new MetadataReset() );
|
|
||||||
|
|
||||||
mState = State.IDLE;
|
|
||||||
broadcast( ChangedAttribute.CHANNEL_STATE );
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void start( ScheduledExecutorService executor )
|
|
||||||
{
|
|
||||||
if( mStateMonitorFuture == null && mStateMonitor != null )
|
|
||||||
{
|
|
||||||
if( mTrafficChannelEndListener != null )
|
|
||||||
{
|
|
||||||
setState( State.CALL );
|
|
||||||
}
|
|
||||||
|
|
||||||
try
|
|
||||||
{
|
|
||||||
mStateMonitorFuture = executor.scheduleAtFixedRate( mStateMonitor, 0, 20, TimeUnit.MILLISECONDS );
|
|
||||||
}
|
|
||||||
catch( RejectedExecutionException ree )
|
|
||||||
{
|
|
||||||
mLog.error( "state monitor scheduled task rejected", ree );
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void stop()
|
|
||||||
{
|
|
||||||
if( mStateMonitorFuture != null )
|
|
||||||
{
|
|
||||||
boolean success = mStateMonitorFuture.cancel( true );
|
|
||||||
|
|
||||||
if( !success )
|
|
||||||
{
|
|
||||||
mLog.error("Couldn't stop monitoring scheduled future" );
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
mTrafficChannelEndListener = null;
|
|
||||||
|
|
||||||
if( mTrafficChannelCallEvent != null )
|
|
||||||
{
|
|
||||||
mTrafficChannelCallEvent.end();
|
|
||||||
broadcast( mTrafficChannelCallEvent );
|
|
||||||
}
|
|
||||||
|
|
||||||
mTrafficChannelCallEvent = null;
|
|
||||||
|
|
||||||
mStateMonitorFuture = null;
|
|
||||||
|
|
||||||
mSquelchLocked = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void dispose()
|
|
||||||
{
|
|
||||||
mCallEventListener = null;
|
|
||||||
mChangedAttributeListener = null;
|
|
||||||
mDecoderStateListener = null;
|
|
||||||
mSquelchStateListener = null;
|
|
||||||
mStateMonitor = null;
|
|
||||||
}
|
|
||||||
|
|
||||||
private boolean isStandardChannel()
|
|
||||||
{
|
|
||||||
return mChannelType == ChannelType.STANDARD;
|
|
||||||
}
|
|
||||||
|
|
||||||
private boolean isTrafficChannel()
|
|
||||||
{
|
|
||||||
return mChannelType == ChannelType.TRAFFIC;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setStandardChannelTimeout( long milliseconds )
|
|
||||||
{
|
|
||||||
mStandardChannelFadeTimeout = milliseconds;
|
|
||||||
|
|
||||||
if( mChannelType == ChannelType.STANDARD )
|
|
||||||
{
|
|
||||||
mFadeTimeout = mStandardChannelFadeTimeout;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setTrafficChannelTimeout( long milliseconds )
|
|
||||||
{
|
|
||||||
mTrafficChannelFadeTimeout = milliseconds;
|
|
||||||
|
|
||||||
if( mChannelType == ChannelType.TRAFFIC )
|
|
||||||
{
|
|
||||||
mFadeTimeout = System.currentTimeMillis() + mTrafficChannelFadeTimeout;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setSelected( boolean selected )
|
|
||||||
{
|
|
||||||
mSelected = selected;
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean isSelected()
|
|
||||||
{
|
|
||||||
return mSelected;
|
|
||||||
}
|
|
||||||
|
|
||||||
public State getState()
|
|
||||||
{
|
|
||||||
return mState;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Updates the fade timeout threshold to the current time plus delay
|
|
||||||
*/
|
|
||||||
private void updateFadeTimeout()
|
|
||||||
{
|
|
||||||
if( isTrafficChannel() )
|
|
||||||
{
|
|
||||||
mFadeTimeout = System.currentTimeMillis() + mTrafficChannelFadeTimeout;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
mFadeTimeout = System.currentTimeMillis() + mStandardChannelFadeTimeout;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Updates the reset timeout threshold to the current time plus delay
|
|
||||||
*/
|
|
||||||
private void updateResetTimeout()
|
|
||||||
{
|
|
||||||
if( isTrafficChannel() )
|
|
||||||
{
|
|
||||||
mEndTimeout = System.currentTimeMillis();
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
mEndTimeout = System.currentTimeMillis() + RESET_TIMEOUT_DELAY;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Broadcasts the squelch state to the registered listener
|
|
||||||
*/
|
|
||||||
protected void broadcast( SquelchState state )
|
|
||||||
{
|
|
||||||
if( mSquelchStateListener != null && !mSquelchLocked )
|
|
||||||
{
|
|
||||||
mSquelchStateListener.receive( state );
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Sets the squelch state listener
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
public void setSquelchStateListener( Listener<SquelchState> listener )
|
|
||||||
{
|
|
||||||
mSquelchStateListener = listener;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Removes the squelch state listener
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
public void removeSquelchStateListener()
|
|
||||||
{
|
|
||||||
mSquelchStateListener = null;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Sets the channel state to the specified state, or updates the timeout
|
|
||||||
* values so that the state monitor will not change state. Broadcasts a
|
|
||||||
* squelch event when the state changes and the audio squelch state should
|
|
||||||
* change. Also broadcasts changed attribute and decoder state events so
|
|
||||||
* that external processes can maintain sync with this channel state.
|
|
||||||
*/
|
|
||||||
protected void setState( State state )
|
|
||||||
{
|
|
||||||
synchronized( mState )
|
|
||||||
{
|
|
||||||
if( state == mState )
|
|
||||||
{
|
|
||||||
if( State.CALL_STATES.contains( state ) )
|
|
||||||
{
|
|
||||||
updateFadeTimeout();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else if( state != mState && mState.canChangeTo( state ) )
|
|
||||||
{
|
|
||||||
switch( state )
|
|
||||||
{
|
|
||||||
case CONTROL:
|
|
||||||
//Don't allow traffic channels to be control channels,
|
|
||||||
//otherwise they can't transition to call tear down
|
|
||||||
if( isStandardChannel() )
|
|
||||||
{
|
|
||||||
broadcast( SquelchState.SQUELCH );
|
|
||||||
updateFadeTimeout();
|
|
||||||
mState = state;
|
|
||||||
broadcast( ChangedAttribute.CHANNEL_STATE );
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case DATA:
|
|
||||||
case ENCRYPTED:
|
|
||||||
broadcast( SquelchState.SQUELCH );
|
|
||||||
updateFadeTimeout();
|
|
||||||
mState = state;
|
|
||||||
broadcast( ChangedAttribute.CHANNEL_STATE );
|
|
||||||
break;
|
|
||||||
case CALL:
|
|
||||||
broadcast( SquelchState.UNSQUELCH );
|
|
||||||
updateFadeTimeout();
|
|
||||||
mState = state;
|
|
||||||
broadcast( ChangedAttribute.CHANNEL_STATE );
|
|
||||||
break;
|
|
||||||
case FADE:
|
|
||||||
processFadeState();
|
|
||||||
break;
|
|
||||||
case IDLE:
|
|
||||||
processIdleState();
|
|
||||||
break;
|
|
||||||
case TEARDOWN:
|
|
||||||
processTeardownState();
|
|
||||||
break;
|
|
||||||
case RESET:
|
|
||||||
mState = State.IDLE;
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
// mLog.debug( "Can't change from [" + mState + "] to [" + state + "]" );
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Sets the state and processes related actions
|
|
||||||
*/
|
|
||||||
private void processFadeState()
|
|
||||||
{
|
|
||||||
updateResetTimeout();
|
|
||||||
mState = State.FADE;
|
|
||||||
|
|
||||||
broadcast( SquelchState.SQUELCH );
|
|
||||||
broadcast( ChangedAttribute.CHANNEL_STATE );
|
|
||||||
}
|
|
||||||
|
|
||||||
private void processIdleState()
|
|
||||||
{
|
|
||||||
broadcast( SquelchState.SQUELCH );
|
|
||||||
|
|
||||||
if( mState == State.FADE )
|
|
||||||
{
|
|
||||||
broadcast( new DecoderStateEvent( this, Event.RESET, State.IDLE ) );
|
|
||||||
broadcast( new MetadataReset() );
|
|
||||||
}
|
|
||||||
|
|
||||||
mState = State.IDLE;
|
|
||||||
|
|
||||||
broadcast( ChangedAttribute.CHANNEL_STATE );
|
|
||||||
}
|
|
||||||
|
|
||||||
private void processTeardownState()
|
|
||||||
{
|
|
||||||
broadcast( SquelchState.SQUELCH );
|
|
||||||
|
|
||||||
broadcast( new MetadataReset() );
|
|
||||||
|
|
||||||
mState = State.TEARDOWN;
|
|
||||||
|
|
||||||
broadcast( ChangedAttribute.CHANNEL_STATE );
|
|
||||||
|
|
||||||
if( mTrafficChannelEndListener != null )
|
|
||||||
{
|
|
||||||
mTrafficChannelEndListener.callEnd( mTrafficChannelCallEvent.getChannel() );
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Broadcasts the call event to the registered listener
|
|
||||||
*/
|
|
||||||
protected void broadcast( CallEvent event )
|
|
||||||
{
|
|
||||||
if( mCallEventListener != null )
|
|
||||||
{
|
|
||||||
mCallEventListener.receive( event );
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void addCallEventListener( Listener<CallEvent> listener )
|
|
||||||
{
|
|
||||||
mCallEventListener = listener;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void removeCallEventListener( Listener<CallEvent> listener )
|
|
||||||
{
|
|
||||||
mCallEventListener = null;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Broadcasts the channel state attribute change event to all registered
|
|
||||||
* listeners
|
|
||||||
*/
|
|
||||||
protected void broadcast( ChangedAttribute attribute )
|
|
||||||
{
|
|
||||||
if( mChangedAttributeListener != null )
|
|
||||||
{
|
|
||||||
mChangedAttributeListener.receive( attribute );
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Adds the listener to receive channel state attribute change events
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
public void setChangedAttributeListener( Listener<ChangedAttribute> listener )
|
|
||||||
{
|
|
||||||
mChangedAttributeListener = listener;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Removes the listener to receive channel state attribute change events
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
public void removeChangedAttributeListener()
|
|
||||||
{
|
|
||||||
mChangedAttributeListener = null;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Broadcasts a channel state event to any registered listeners
|
|
||||||
*/
|
|
||||||
protected void broadcast( DecoderStateEvent event )
|
|
||||||
{
|
|
||||||
if( mDecoderStateListener != null )
|
|
||||||
{
|
|
||||||
mDecoderStateListener.receive( event );
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Adds a decoder state event listener
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
public void setDecoderStateListener( Listener<DecoderStateEvent> listener )
|
|
||||||
{
|
|
||||||
mDecoderStateListener = listener;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Removes the decoder state event listener
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
public void removeDecoderStateListener()
|
|
||||||
{
|
|
||||||
mDecoderStateListener = null;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Listener<DecoderStateEvent> getDecoderStateListener()
|
|
||||||
{
|
|
||||||
return mDecoderStateEventReceiver;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Broadcasts metadata to the registered listener
|
|
||||||
*/
|
|
||||||
protected void broadcast( Metadata metadata )
|
|
||||||
{
|
|
||||||
if( mMetadataListener != null )
|
|
||||||
{
|
|
||||||
mMetadataListener.receive( metadata );
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Adds a metadata listener
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
public void setMetadataListener( Listener<Metadata> listener )
|
|
||||||
{
|
|
||||||
mMetadataListener = listener;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Removes the decoder state event listener
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
public void removeMetadataListener()
|
|
||||||
{
|
|
||||||
mMetadataListener = null;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Registers a listener to be notified when a traffic channel call event is
|
|
||||||
* completed, so that the listener can perform call tear-down
|
|
||||||
*/
|
|
||||||
public void configureAsTrafficChannel( TrafficChannelManager manager, CallEvent callEvent )
|
|
||||||
{
|
|
||||||
mTrafficChannelEndListener = manager;
|
|
||||||
|
|
||||||
mTrafficChannelCallEvent = callEvent;
|
|
||||||
|
|
||||||
/* Broadcast the call event details as metadata for the audio manager */
|
|
||||||
String channel = mTrafficChannelCallEvent.getChannel();
|
|
||||||
|
|
||||||
if( channel != null )
|
|
||||||
{
|
|
||||||
broadcast( new Metadata( MetadataType.CHANNEL_NUMBER, channel, true ) );
|
|
||||||
}
|
|
||||||
|
|
||||||
broadcast( new Metadata( MetadataType.PROTOCOL,
|
|
||||||
mTrafficChannelCallEvent.getDecoderType().getDisplayString(), true ) );
|
|
||||||
|
|
||||||
String details = mTrafficChannelCallEvent.getDetails();
|
|
||||||
|
|
||||||
if( details != null )
|
|
||||||
{
|
|
||||||
broadcast( new Metadata( MetadataType.DETAILS, details, true ) );
|
|
||||||
}
|
|
||||||
|
|
||||||
String from = mTrafficChannelCallEvent.getFromID();
|
|
||||||
|
|
||||||
if( from != null )
|
|
||||||
{
|
|
||||||
broadcast( new Metadata( mTrafficChannelCallEvent.getFromIDType(),
|
|
||||||
from, mTrafficChannelCallEvent.getFromIDAlias(), true ) );
|
|
||||||
}
|
|
||||||
|
|
||||||
String to = mTrafficChannelCallEvent.getToID();
|
|
||||||
|
|
||||||
if( to != null )
|
|
||||||
{
|
|
||||||
broadcast( new Metadata( mTrafficChannelCallEvent.getToIDType(), to,
|
|
||||||
mTrafficChannelCallEvent.getToIDAlias(), true ) );
|
|
||||||
}
|
|
||||||
|
|
||||||
long frequency = mTrafficChannelCallEvent.getFrequency();
|
|
||||||
|
|
||||||
if( frequency > 0 )
|
|
||||||
{
|
|
||||||
broadcast( new Metadata( MetadataType.FREQUENCY, String.valueOf( frequency ), true ) );
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Rebroadcast the allocation event so that the internal decoder states
|
|
||||||
* can self-configure with the call event details */
|
|
||||||
broadcast( mTrafficChannelCallEvent );
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* DecoderStateEvent receiver wrapper
|
|
||||||
*/
|
|
||||||
public class DecoderStateEventReceiver implements Listener<DecoderStateEvent>
|
|
||||||
{
|
|
||||||
@Override
|
|
||||||
public void receive( DecoderStateEvent event )
|
|
||||||
{
|
|
||||||
if( event.getSource() != this )
|
|
||||||
{
|
|
||||||
switch( event.getEvent() )
|
|
||||||
{
|
|
||||||
case ALWAYS_UNSQUELCH:
|
|
||||||
broadcast( SquelchState.UNSQUELCH );
|
|
||||||
mSquelchLocked = true;
|
|
||||||
break;
|
|
||||||
case CHANGE_CALL_TIMEOUT:
|
|
||||||
if( event instanceof ChangeChannelTimeoutEvent )
|
|
||||||
{
|
|
||||||
ChangeChannelTimeoutEvent timeout = (ChangeChannelTimeoutEvent)event;
|
|
||||||
|
|
||||||
if( timeout.getChannelType() == ChannelType.STANDARD )
|
|
||||||
{
|
|
||||||
setStandardChannelTimeout( timeout.getCallTimeout() );
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
setTrafficChannelTimeout( timeout.getCallTimeout() );
|
|
||||||
}
|
|
||||||
}
|
|
||||||
case CONTINUATION:
|
|
||||||
case DECODE:
|
|
||||||
case START:
|
|
||||||
if( State.CALL_STATES.contains( event.getState() ) )
|
|
||||||
{
|
|
||||||
setState( event.getState() );
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case END:
|
|
||||||
if( isTrafficChannel() )
|
|
||||||
{
|
|
||||||
setState( State.TEARDOWN );
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
setState( State.FADE );
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case RESET:
|
|
||||||
/* Channel State does not respond to reset events */
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Monitors decoder state events to automatically transition the channel
|
|
||||||
* state to IDLE (standard channel) or to TEARDOWN (traffic channel) when
|
|
||||||
* decoding stops or the monitored channel returns to a no signal state.
|
|
||||||
*
|
|
||||||
* Provides a FADE transition state to allow for momentary decoding dropouts
|
|
||||||
* and to allow the user access to call details for a fade period upon
|
|
||||||
* call end.
|
|
||||||
*/
|
|
||||||
public class StateMonitor implements Runnable
|
|
||||||
{
|
|
||||||
@Override
|
|
||||||
public void run()
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
synchronized( mState )
|
|
||||||
{
|
|
||||||
if( State.CALL_STATES.contains( mState ) &&
|
|
||||||
mFadeTimeout <= System.currentTimeMillis() )
|
|
||||||
{
|
|
||||||
processFadeState();
|
|
||||||
}
|
|
||||||
else if( mState == State.FADE &&
|
|
||||||
mEndTimeout <= System.currentTimeMillis() )
|
|
||||||
{
|
|
||||||
if( isTrafficChannel() )
|
|
||||||
{
|
|
||||||
processTeardownState();
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
processIdleState();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
catch( Exception e )
|
|
||||||
{
|
|
||||||
mLog.error( "Exception thrown while state monitor is running " +
|
|
||||||
"- state [" + getState() +
|
|
||||||
"] current [" + System.currentTimeMillis() +
|
|
||||||
"] mResetTimeout [" + mEndTimeout +
|
|
||||||
"] mFadeTimeout [" + mFadeTimeout +
|
|
||||||
"]", e );
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,162 +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 module.decode.state;
|
|
||||||
|
|
||||||
import alias.Alias;
|
|
||||||
import icon.IconManager;
|
|
||||||
import sample.Listener;
|
|
||||||
import settings.ColorSetting;
|
|
||||||
import settings.ColorSetting.ColorSettingName;
|
|
||||||
import settings.Setting;
|
|
||||||
import settings.SettingChangeListener;
|
|
||||||
import settings.SettingsManager;
|
|
||||||
|
|
||||||
import javax.swing.*;
|
|
||||||
import java.awt.*;
|
|
||||||
|
|
||||||
public abstract class DecoderPanel extends JPanel
|
|
||||||
implements Listener<ChangedAttribute>, SettingChangeListener
|
|
||||||
{
|
|
||||||
private static final long serialVersionUID = 1L;
|
|
||||||
|
|
||||||
protected Font mFontDetails = new Font(Font.MONOSPACED, Font.PLAIN, 12);
|
|
||||||
protected Font mFontDecoder = new Font(Font.MONOSPACED, Font.PLAIN, 12);
|
|
||||||
protected Font mFontAuxDecoder = new Font(Font.MONOSPACED, Font.PLAIN, 10);
|
|
||||||
public static final int ICON_SIZE = 12;
|
|
||||||
|
|
||||||
protected Color mColorLabelDetails;
|
|
||||||
protected Color mColorLabelDecoder;
|
|
||||||
protected Color mColorLabelAuxDecoder;
|
|
||||||
|
|
||||||
protected IconManager mIconManager;
|
|
||||||
protected SettingsManager mSettingsManager;
|
|
||||||
protected DecoderState mDecoderState;
|
|
||||||
|
|
||||||
public DecoderPanel(IconManager iconManager, SettingsManager settingsManager, DecoderState decoderState)
|
|
||||||
{
|
|
||||||
mIconManager = iconManager;
|
|
||||||
mSettingsManager = settingsManager;
|
|
||||||
mSettingsManager.addListener(this);
|
|
||||||
|
|
||||||
mDecoderState = decoderState;
|
|
||||||
|
|
||||||
mDecoderState.setChangedAttributeListener(this);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void dispose()
|
|
||||||
{
|
|
||||||
mSettingsManager.removeListener(this);
|
|
||||||
mSettingsManager = null;
|
|
||||||
|
|
||||||
mDecoderState.removeChangedAttributeListener();
|
|
||||||
mDecoderState = null;
|
|
||||||
}
|
|
||||||
|
|
||||||
public DecoderState getDecoderState()
|
|
||||||
{
|
|
||||||
return mDecoderState;
|
|
||||||
}
|
|
||||||
|
|
||||||
protected void init()
|
|
||||||
{
|
|
||||||
getColors();
|
|
||||||
|
|
||||||
setOpaque(false); //Use the parent panel's background color
|
|
||||||
}
|
|
||||||
|
|
||||||
private void getColors()
|
|
||||||
{
|
|
||||||
mColorLabelDetails = mSettingsManager.getColorSetting(
|
|
||||||
ColorSettingName.CHANNEL_STATE_LABEL_DETAILS).getColor();
|
|
||||||
mColorLabelDecoder = mSettingsManager.getColorSetting(
|
|
||||||
ColorSettingName.CHANNEL_STATE_LABEL_DECODER).getColor();
|
|
||||||
mColorLabelAuxDecoder = mSettingsManager.getColorSetting(
|
|
||||||
ColorSettingName.CHANNEL_STATE_LABEL_AUX_DECODER).getColor();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void settingChanged(Setting setting)
|
|
||||||
{
|
|
||||||
if(setting instanceof ColorSetting)
|
|
||||||
{
|
|
||||||
ColorSetting colorSetting = (ColorSetting) setting;
|
|
||||||
|
|
||||||
switch(colorSetting.getColorSettingName())
|
|
||||||
{
|
|
||||||
case CHANNEL_STATE_LABEL_AUX_DECODER:
|
|
||||||
mColorLabelAuxDecoder = colorSetting.getColor();
|
|
||||||
repaint();
|
|
||||||
break;
|
|
||||||
case CHANNEL_STATE_LABEL_DECODER:
|
|
||||||
mColorLabelDecoder = colorSetting.getColor();
|
|
||||||
repaint();
|
|
||||||
break;
|
|
||||||
case CHANNEL_STATE_LABEL_DETAILS:
|
|
||||||
mColorLabelDetails = colorSetting.getColor();
|
|
||||||
repaint();
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void settingDeleted(Setting setting)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
protected void setAliasLabel(final JLabel label, final Alias alias)
|
|
||||||
{
|
|
||||||
setAliasLabel(label, alias, true);
|
|
||||||
}
|
|
||||||
|
|
||||||
protected void setAliasLabel(final JLabel label, final Alias alias, boolean includeIcon)
|
|
||||||
{
|
|
||||||
if(alias != null)
|
|
||||||
{
|
|
||||||
label.setText(alias.getName());
|
|
||||||
|
|
||||||
if(includeIcon)
|
|
||||||
{
|
|
||||||
String iconName = alias.getIconName();
|
|
||||||
|
|
||||||
if(iconName != null)
|
|
||||||
{
|
|
||||||
label.setIcon(mIconManager.getIcon(iconName, IconManager.DEFAULT_ICON_SIZE));
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
label.setIcon(null);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
label.setIcon(null);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
label.setText("");
|
|
||||||
label.setIcon(null);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -1,227 +0,0 @@
|
|||||||
package module.decode.state;
|
|
||||||
|
|
||||||
import message.IMessageListener;
|
|
||||||
import message.Message;
|
|
||||||
import module.Module;
|
|
||||||
import module.decode.DecoderType;
|
|
||||||
import module.decode.event.ActivitySummaryProvider;
|
|
||||||
import module.decode.event.CallEvent;
|
|
||||||
import module.decode.event.ICallEventProvider;
|
|
||||||
import sample.Broadcaster;
|
|
||||||
import sample.Listener;
|
|
||||||
import alias.AliasList;
|
|
||||||
import audio.metadata.IMetadataProvider;
|
|
||||||
import audio.metadata.Metadata;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Channel state monitors the stream of decoded messages produced by the
|
|
||||||
* decoder and broadcasts call events as they occur within the decoded message activity.
|
|
||||||
*
|
|
||||||
* Provides access to a textual activity summary of events observed.
|
|
||||||
*/
|
|
||||||
public abstract class DecoderState extends Module
|
|
||||||
implements ActivitySummaryProvider,
|
|
||||||
Listener<Message>,
|
|
||||||
ICallEventProvider,
|
|
||||||
IChangedAttributeProvider,
|
|
||||||
IDecoderStateEventListener,
|
|
||||||
IDecoderStateEventProvider,
|
|
||||||
IMessageListener,
|
|
||||||
IMetadataProvider
|
|
||||||
{
|
|
||||||
/* This has to be a broadcaster in order for references to persist */
|
|
||||||
private Broadcaster<CallEvent> mCallEventBroadcaster = new Broadcaster<>();
|
|
||||||
private Listener<ChangedAttribute> mChangedAttributeListener;
|
|
||||||
private Listener<DecoderStateEvent> mDecoderStateListener;
|
|
||||||
private Listener<Metadata> mMetadataListener;
|
|
||||||
|
|
||||||
private DecoderStateEventListener mDecoderStateEventListener =
|
|
||||||
new DecoderStateEventListener();
|
|
||||||
|
|
||||||
protected CallEvent mCurrentCallEvent;
|
|
||||||
|
|
||||||
private AliasList mAliasList;
|
|
||||||
|
|
||||||
public DecoderState( AliasList aliasList )
|
|
||||||
{
|
|
||||||
mAliasList = aliasList;
|
|
||||||
}
|
|
||||||
|
|
||||||
public abstract DecoderType getDecoderType();
|
|
||||||
|
|
||||||
public AliasList getAliasList()
|
|
||||||
{
|
|
||||||
return mAliasList;
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean hasAliasList()
|
|
||||||
{
|
|
||||||
return mAliasList != null;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Reset the decoder state to prepare for processing a different sample
|
|
||||||
* source
|
|
||||||
*/
|
|
||||||
public abstract void reset();
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Allow the decoder to perform any setup actions
|
|
||||||
*/
|
|
||||||
public abstract void init();
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Implements the IDecoderStateEventListener interface to receive state
|
|
||||||
* reset events.
|
|
||||||
*/
|
|
||||||
public abstract void receiveDecoderStateEvent( DecoderStateEvent event );
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Disposes any resources or pointers held by this instance to prepare for
|
|
||||||
* garbage collection
|
|
||||||
*/
|
|
||||||
public void dispose()
|
|
||||||
{
|
|
||||||
mCallEventBroadcaster.dispose();
|
|
||||||
mCallEventBroadcaster = null;
|
|
||||||
mChangedAttributeListener = null;
|
|
||||||
mDecoderStateListener = null;
|
|
||||||
mMetadataListener = null;
|
|
||||||
|
|
||||||
mAliasList = null;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Activity Summary - textual summary of activity observed by the channel state.
|
|
||||||
*/
|
|
||||||
public abstract String getActivitySummary();
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Broadcasts a call event to any registered listeners
|
|
||||||
*/
|
|
||||||
protected void broadcast( CallEvent event )
|
|
||||||
{
|
|
||||||
mCallEventBroadcaster.broadcast( event );
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Adds a call event listener
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
public void addCallEventListener( Listener<CallEvent> listener )
|
|
||||||
{
|
|
||||||
mCallEventBroadcaster.addListener( listener );
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Removes the call event listener
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
public void removeCallEventListener( Listener<CallEvent> listener )
|
|
||||||
{
|
|
||||||
mCallEventBroadcaster.removeListener( listener );
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Listener<DecoderStateEvent> getDecoderStateListener()
|
|
||||||
{
|
|
||||||
return mDecoderStateEventListener;
|
|
||||||
}
|
|
||||||
|
|
||||||
private class DecoderStateEventListener implements Listener<DecoderStateEvent>
|
|
||||||
{
|
|
||||||
@Override
|
|
||||||
public void receive( DecoderStateEvent event )
|
|
||||||
{
|
|
||||||
receiveDecoderStateEvent( event );
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Broadcasts the channel state attribute change event to all registered
|
|
||||||
* listeners
|
|
||||||
*/
|
|
||||||
protected void broadcast( ChangedAttribute attribute )
|
|
||||||
{
|
|
||||||
if( mChangedAttributeListener != null )
|
|
||||||
{
|
|
||||||
mChangedAttributeListener.receive( attribute );
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Adds the listener to receive channel state attribute change events
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
public void setChangedAttributeListener( Listener<ChangedAttribute> listener )
|
|
||||||
{
|
|
||||||
mChangedAttributeListener = listener;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Removes the listener to receive channel state attribute change events
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
public void removeChangedAttributeListener()
|
|
||||||
{
|
|
||||||
mChangedAttributeListener = null;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Broadcasts a channel state event to any registered listeners
|
|
||||||
*/
|
|
||||||
protected void broadcast( DecoderStateEvent event )
|
|
||||||
{
|
|
||||||
if( mDecoderStateListener != null )
|
|
||||||
{
|
|
||||||
mDecoderStateListener.receive( event );
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Adds a decoder state event listener
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
public void setDecoderStateListener( Listener<DecoderStateEvent> listener )
|
|
||||||
{
|
|
||||||
mDecoderStateListener = listener;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Removes the decoder state event listener
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
public void removeDecoderStateListener()
|
|
||||||
{
|
|
||||||
mDecoderStateListener = null;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Broadcasts metadata to a registered listener
|
|
||||||
*/
|
|
||||||
protected void broadcast( Metadata metadata )
|
|
||||||
{
|
|
||||||
if( mMetadataListener != null )
|
|
||||||
{
|
|
||||||
mMetadataListener.receive( metadata );
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void setMetadataListener( Listener<Metadata> listener )
|
|
||||||
{
|
|
||||||
mMetadataListener = listener;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void removeMetadataListener()
|
|
||||||
{
|
|
||||||
mMetadataListener = null;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Listener<Message> getMessageListener()
|
|
||||||
{
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user