Work in progress.

-Started work on new channel editor channel viewer/controller
-Removed a number of unused buffer package classes
-Moved automatic frequency control to be a module and removed special
handling
-Added IUnfilteredRealBufferListener & Provider interfaces
-Completely removed the ResourceManager class
This commit is contained in:
denny
2016-01-10 18:02:04 -05:00
parent c405ddad96
commit 4be63d4b95
197 changed files with 4181 additions and 4439 deletions

View File

@@ -17,14 +17,24 @@
******************************************************************************/
package controller;
import playlist.PlaylistManager;
public abstract class ConfigurableNode extends BaseNode
{
private static final long serialVersionUID = 1L;
private PlaylistManager mPlaylistManager;
public ConfigurableNode( Object object )
public ConfigurableNode( PlaylistManager playlistManager, Object object )
{
super( object );
mPlaylistManager = playlistManager;
}
protected PlaylistManager getPlaylistManager()
{
return mPlaylistManager;
}
/**
@@ -32,7 +42,7 @@ public abstract class ConfigurableNode extends BaseNode
*/
public void save()
{
getModel().getResourceManager().getPlaylistManager().save();
mPlaylistManager.save();
BaseNode parent = (BaseNode)getParent();

View File

@@ -28,9 +28,14 @@ import javax.swing.tree.DefaultTreeModel;
import javax.swing.tree.MutableTreeNode;
import javax.swing.tree.TreePath;
import map.IconManager;
import module.decode.DecoderType;
import playlist.PlaylistManager;
import playlist.PlaylistNode;
import settings.SettingsManager;
import source.SourceManager;
import source.recording.RecordingGroupNode;
import source.tuner.Tuner;
import source.tuner.TunerGroupNode;
import source.tuner.TunerNode;
@@ -39,14 +44,14 @@ import controller.channel.Channel;
import controller.channel.ChannelModel;
import controller.channel.ChannelNode;
import controller.channel.ChannelProcessingManager;
public class ConfigurationControllerModel extends DefaultTreeModel
{
private static final long serialVersionUID = 1L;
private JTree mTree;
private ResourceManager mResourceManager;
private ArrayList<TunerSelectionListener> mTunerSelectionListeners =
new ArrayList<TunerSelectionListener>();
@@ -54,7 +59,11 @@ public class ConfigurationControllerModel extends DefaultTreeModel
private TunerGroupNode mTunerGroupNode;
// private RecordingGroupNode mRecordingGroupNode;
private IconManager mIconManagerFrame;
private ChannelModel mChannelModel;
private ChannelProcessingManager mChannelProcessingManager;
private PlaylistManager mPlaylistManager;
private SettingsManager mSettingsManager;
private SourceManager mSourceManager;
private ChannelModel mChannelModel;
/**
@@ -63,14 +72,21 @@ public class ConfigurationControllerModel extends DefaultTreeModel
* design perspective, the model and the control are necessarily merged to
* work well with the JTree as the system view.
*/
public ConfigurationControllerModel( ChannelModel channelModel,
ResourceManager resourceManager )
public ConfigurationControllerModel( ChannelModel channelModel,
ChannelProcessingManager channelProcessingManager,
PlaylistManager playlistManager,
SettingsManager settingsManager,
SourceManager sourceManager )
{
super( new BaseNode( null ) );
mChannelModel = channelModel;
mResourceManager = resourceManager;
mChannelModel = channelModel;
mChannelProcessingManager = channelProcessingManager;
mPlaylistManager = playlistManager;
mSettingsManager = settingsManager;
mSourceManager = sourceManager;
/**
* Give the root node a reference to this model, so that all nodes can
@@ -84,23 +100,6 @@ public class ConfigurationControllerModel extends DefaultTreeModel
return mTree;
}
public void showIconManager()
{
if( mIconManagerFrame == null )
{
mIconManagerFrame = new IconManager( mResourceManager, mTree );
mResourceManager.getSettingsManager().addListener( mIconManagerFrame );
}
if( !mIconManagerFrame.isVisible() )
{
mIconManagerFrame.setVisible( true );
}
mIconManagerFrame.toFront();
}
/**
* init() gets invoked manually/externally, after all of the references
* are established in the constructor
@@ -124,7 +123,8 @@ public class ConfigurationControllerModel extends DefaultTreeModel
/**
* Add the playlist node
*/
mPlaylistNode = new PlaylistNode();
mPlaylistNode = new PlaylistNode( mChannelModel, mChannelProcessingManager,
mPlaylistManager, mSettingsManager, mSourceManager );
insertNodeInto( mPlaylistNode, (MutableTreeNode)root, 1 );
mPlaylistNode.loadPlaylist();
}
@@ -137,11 +137,6 @@ public class ConfigurationControllerModel extends DefaultTreeModel
}
}
public ResourceManager getResourceManager()
{
return mResourceManager;
}
public void setTree( JTree tree )
{
mTree = tree;
@@ -149,11 +144,13 @@ public class ConfigurationControllerModel extends DefaultTreeModel
private void addTuners( TunerGroupNode parent )
{
List<Tuner> tuners = mResourceManager.getTunerManager().getTuners();
List<Tuner> tuners = mSourceManager.getTunerManager().getTuners();
for( Tuner tuner: tuners )
{
TunerNode child = new TunerNode( mChannelModel, tuner );
TunerNode child = new TunerNode( mChannelModel,
mChannelProcessingManager, mPlaylistManager, mSettingsManager,
tuner );
insertNodeInto( child, parent, parent.getChildCount() );

View File

@@ -33,8 +33,10 @@ import module.decode.event.CallEventPanel;
import module.decode.event.MessageActivityPanel;
import module.decode.state.ChannelList;
import net.miginfocom.swing.MigLayout;
import playlist.PlaylistEditor;
import playlist.PlaylistManager;
import settings.SettingsManager;
import source.SourceManager;
import spectrum.ChannelSpectrumPanel;
import audio.AudioManager;
import audio.AudioPanel;
@@ -53,15 +55,16 @@ public class ControllerPanel extends JPanel
private CallEventPanel mCallEventPanel;
private MessageActivityPanel mMessageActivityPanel =
new MessageActivityPanel();
private MessageActivityPanel mMessageActivityPanel;
private ChannelSpectrumPanel mChannelSpectrumPanel;
private JideTabbedPane mTabbedPane;
private PlaylistEditor mPlaylistEditor;
private JideTabbedPane mTabbedPane;
protected ConfigurationTreePanel mSystemControlViewPanel;
protected ConfigurationEditor mConfigurationEditor;
protected OldConfigurationEditor mConfigurationEditor;
protected JideSplitPane mSystemControlSplitPane;
protected JTable mChannelActivityTable = new JTable();
@@ -78,20 +81,30 @@ public class ControllerPanel extends JPanel
ChannelProcessingManager channelProcessingManager,
MapService mapService,
PlaylistManager playlistManager,
SettingsManager settingsManager )
SettingsManager settingsManager,
SourceManager sourceManager )
{
mChannelModel = channelModel;
mController = controller;
mSettingsManager = settingsManager;
mAudioPanel = new AudioPanel( mSettingsManager, audioManager );
mAudioPanel = new AudioPanel( mSettingsManager, sourceManager, audioManager );
mMapPanel = new MapPanel( mapService, mSettingsManager, channelProcessingManager );
mMapPanel = new MapPanel( mapService, mSettingsManager );
mCallEventPanel = new CallEventPanel( mSettingsManager );
mChannelStateList = new ChannelList( playlistManager, mSettingsManager );
mMessageActivityPanel = new MessageActivityPanel( channelProcessingManager );
mCallEventPanel = new CallEventPanel( mSettingsManager,
channelProcessingManager );
mChannelSpectrumPanel = new ChannelSpectrumPanel( mSettingsManager,
channelProcessingManager );
mChannelStateList = new ChannelList( channelModel, channelProcessingManager,
playlistManager, mSettingsManager );
mPlaylistEditor = new PlaylistEditor( channelModel, playlistManager, sourceManager );
init();
}
@@ -102,7 +115,7 @@ public class ControllerPanel extends JPanel
"[grow,fill]") );
//System Configuration View and Editor
mConfigurationEditor = new ConfigurationEditor();
mConfigurationEditor = new OldConfigurationEditor();
mSystemControlViewPanel = new ConfigurationTreePanel( mController );
mSystemControlViewPanel.addTreeSelectionListener( mConfigurationEditor );
@@ -112,8 +125,6 @@ public class ControllerPanel extends JPanel
mSystemControlSplitPane.add( mSystemControlViewPanel );
mSystemControlSplitPane.add( mConfigurationEditor );
mChannelSpectrumPanel = new ChannelSpectrumPanel( mSettingsManager );
//Tabbed View - configuration, calls, messages, map
mTabbedPane = new JideTabbedPane();
mTabbedPane.setFont( this.getFont() );
@@ -122,10 +133,8 @@ public class ControllerPanel extends JPanel
mTabbedPane.addTab( "Channel Spectrum", mChannelSpectrumPanel );
mTabbedPane.addTab( "Events", mCallEventPanel );
mTabbedPane.addTab( "Messages", mMessageActivityPanel );
JTable channelsTable = new JTable( mChannelModel );
JScrollPane channelsScroller = new JScrollPane( channelsTable );
mTabbedPane.addTab( "Channels", channelsScroller );
mTabbedPane.addTab( "Playlist", mPlaylistEditor );
/**
* Change listener to enable/disable the channel spectrum display

View File

@@ -26,7 +26,7 @@ import javax.swing.JTree;
import javax.swing.event.TreeSelectionEvent;
import javax.swing.event.TreeSelectionListener;
public class ConfigurationEditor extends JPanel
public class OldConfigurationEditor extends JPanel
implements TreeSelectionListener
{
private static final long serialVersionUID = 1L;
@@ -34,7 +34,7 @@ public class ConfigurationEditor extends JPanel
/**
* Host for configuration editor display panels
*/
public ConfigurationEditor()
public OldConfigurationEditor()
{
init();
}

View File

@@ -1,177 +0,0 @@
/*******************************************************************************
* SDR Trunk
* Copyright (C) 2014 Dennis Sheirer
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>
******************************************************************************/
package controller;
import map.MapService;
import module.log.EventLogManager;
import playlist.PlaylistManager;
import record.RecorderManager;
import settings.SettingsManager;
import source.SourceManager;
import source.recording.RecordingSourceManager;
import source.tuner.TunerManager;
import audio.AudioManager;
import controller.channel.ChannelModel;
/**
* Manager for system wide resources
*/
public class ResourceManager
{
private AudioManager mAudioManager;
private EventLogManager mEventLogManager;
private PlaylistManager mPlaylistManager;
private RecorderManager mRecorderManager;
private RecordingSourceManager mRecordingSourceManager;
private SettingsManager mSettingsManager;
private SourceManager mSourceManager;
private TunerManager mTunerManager;
private ConfigurationControllerModel mController;
private MapService mMapService;
private ThreadPoolManager mThreadPoolManager;
public ResourceManager( PlaylistManager playlistManager,
ThreadPoolManager threadPoolManager,
ChannelModel channelModel )
{
this( threadPoolManager,
new SettingsManager(),
playlistManager,
new EventLogManager(),
channelModel );
}
public ResourceManager( ThreadPoolManager threadPoolManager,
SettingsManager settingsManager,
PlaylistManager playlistManager,
EventLogManager eventLogManager,
ChannelModel channelModel )
{
mThreadPoolManager = threadPoolManager;
mSettingsManager = settingsManager;
mPlaylistManager = playlistManager;
mEventLogManager = eventLogManager;
/**
* ChannelManager requires a reference to the ResourceManager so that
* channel processing chains can access system wide resources
*/
mAudioManager = new AudioManager( mThreadPoolManager );
mRecorderManager = new RecorderManager( mThreadPoolManager );
mSourceManager = new SourceManager( this );
mRecordingSourceManager = new RecordingSourceManager( this );
mTunerManager = new TunerManager( this );
mController = new ConfigurationControllerModel( channelModel, this );
mMapService = new MapService( this );
}
public AudioManager getAudioManager()
{
return mAudioManager;
}
public void setAudioManager( AudioManager audioManager )
{
mAudioManager = audioManager;
}
public ConfigurationControllerModel getController()
{
return mController;
}
public ThreadPoolManager getThreadPoolManager()
{
return mThreadPoolManager;
}
public void setController( ConfigurationControllerModel controller )
{
mController = controller;
}
public TunerManager getTunerManager()
{
return mTunerManager;
}
public MapService getMapService()
{
return mMapService;
}
public SettingsManager getSettingsManager()
{
return mSettingsManager;
}
public void setSettingsManager( SettingsManager manager )
{
mSettingsManager = manager;
}
public PlaylistManager getPlaylistManager()
{
return mPlaylistManager;
}
public void setPlaylistManager( PlaylistManager aliasManager )
{
mPlaylistManager = aliasManager;
}
public EventLogManager getEventLogManager()
{
return mEventLogManager;
}
public void setEventLogManager( EventLogManager eventLogManager )
{
mEventLogManager = eventLogManager;
}
public RecorderManager getRecorderManager()
{
return mRecorderManager;
}
public void setRecorderManager( RecorderManager recorderManager )
{
mRecorderManager = recorderManager;
}
public SourceManager getSourceManager()
{
return mSourceManager;
}
public void setSourceManager( SourceManager sourceManager )
{
mSourceManager = sourceManager;
}
public RecordingSourceManager getRecordingSourceManager()
{
return mRecordingSourceManager;
}
public void setRecordingSourceManager( RecordingSourceManager manager )
{
mRecordingSourceManager = manager;
}
}

View File

@@ -17,23 +17,22 @@
******************************************************************************/
package controller.channel;
import controller.Editor;
public abstract class AbstractChannelEditor extends Editor
public abstract class AbstractChannelEditor extends ChannelConfigurationEditor
{
private static final long serialVersionUID = 1L;
protected ChannelNode mChannelNode;
protected Channel mChannel;
public AbstractChannelEditor( ChannelNode channel )
public AbstractChannelEditor( Channel channel )
{
super();
mChannelNode = channel;
mChannel = channel;
}
public ChannelNode getChannelNode()
public Channel getChannel()
{
return mChannelNode;
return mChannel;
}
public abstract void save();

View File

@@ -1,6 +1,6 @@
/*******************************************************************************
* SDR Trunk
* Copyright (C) 2014 Dennis Sheirer
* 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
@@ -17,35 +17,21 @@
******************************************************************************/
package controller.channel;
import java.util.List;
import javax.xml.bind.annotation.XmlAttribute;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlSeeAlso;
import javax.xml.bind.annotation.XmlTransient;
import message.Message;
import module.Module;
import module.ProcessingChain;
import module.decode.DecoderFactory;
import module.decode.config.AuxDecodeConfiguration;
import module.decode.config.DecodeConfigFactory;
import module.decode.config.DecodeConfiguration;
import module.decode.event.CallEventModel;
import module.decode.event.MessageActivityModel;
import module.decode.state.ChannelState;
import module.log.MessageEventLogger;
import module.log.config.EventLogConfiguration;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import record.RecorderManager;
import record.RecorderType;
import record.config.RecordConfiguration;
import source.Source;
import source.SourceException;
import source.SourceType;
import source.config.SourceConfigFactory;
import source.config.SourceConfigRecording;
@@ -53,27 +39,25 @@ import source.config.SourceConfigTuner;
import source.config.SourceConfiguration;
import source.tuner.TunerChannel;
import source.tuner.TunerChannel.Type;
import alias.AliasList;
import audio.metadata.Metadata;
import audio.metadata.MetadataType;
import controller.ResourceManager;
import source.tuner.frequency.FrequencyChangeEvent;
import source.tuner.frequency.FrequencyChangeEvent.Event;
import source.tuner.frequency.IFrequencyChangeProcessor;
import controller.config.Configuration;
import filter.FilterSet;
@XmlSeeAlso( { Configuration.class } )
@XmlRootElement( name = "channel" )
public class Channel extends Configuration
public class Channel extends Configuration implements IFrequencyChangeProcessor
{
private final static Logger mLog = LoggerFactory.getLogger( Channel.class );
private static final boolean DISABLED = false;
public enum ChannelType
{
STANDARD,
TRAFFIC
};
// Standard channels are persisted and traffic channels are temporary
public enum ChannelType { STANDARD, TRAFFIC };
// Static unique channel identifier tracking
private static int UNIQUE_ID = 0;
private DecodeConfiguration mDecodeConfiguration =
DecodeConfigFactory.getDefaultDecodeConfiguration();
private AuxDecodeConfiguration mAuxDecodeConfiguration =
@@ -84,134 +68,67 @@ public class Channel extends Configuration
new EventLogConfiguration();
private RecordConfiguration mRecordConfiguration = new RecordConfiguration();
private ResourceManager mResourceManager;
private String mAliasListName;
private String mSystem;
private String mSite;
private String mName;
private String mSystem = "System";
private String mSite = "Site";
private String mName = "Channel";
private boolean mEnabled;
private boolean mSelected;
private ChannelType mChannelType;
private ChannelState mChannelState;
private CallEventModel mCallEventModel;
private MessageActivityModel mMessageActivityModel;
private MessageEventLogger mEventLogger;
private ProcessingChain mProcessingChain;
private TunerChannel mTunerChannel = null;
private long mTrafficChannelTimeout =
DecodeConfiguration.DEFAULT_CALL_TIMEOUT_SECONDS;
private ChannelType mChannelType = ChannelType.STANDARD;
private int mChannelID;
private int mChannelFrequencyCorrection = 0;
/**
* Constructs a new standard channel with a default name of "New Channel"
*/
public Channel()
{
this( "New Channel", ChannelType.STANDARD );
}
/**
* Constructs a new standard channel with the specified channel name
*/
public Channel( String channelName )
{
this( channelName, ChannelType.STANDARD );
}
/**
* Constructs a new channel with the specified channel name and type.
* Channel represents a complete set of configurations needed to setup and
* manage a processing chain and/or manage as a set of business objects that
* can be displayed in graphical components.
*
* @param channelName
* @param channelType
*/
public Channel( String channelName, ChannelType channelType )
{
mName = channelName;
this( channelName );
mChannelType = channelType;
}
/**
* Indicates if the channel has Automatic or Direct Frequency Control
* Constructs a new standard channel with the specified channel name
*/
public boolean hasFrequencyControl()
public Channel( String channelName )
{
return mProcessingChain != null &&
mProcessingChain.hasFrequencyCorrectionControl();
}
public long getFrequencyCorrection()
{
if( hasFrequencyControl() )
{
return mProcessingChain.getFrequencyCorrectionControl().getErrorCorrection();
}
return 0;
this();
mName = channelName;
}
/**
* Sets the channel state traffic channel call end timer to the specified
* value.
*/
public void setTrafficChannelTimeout( long milliseconds )
{
mTrafficChannelTimeout = milliseconds;
if( mChannelState != null )
{
mChannelState.setTrafficChannelTimeout( milliseconds );
}
}
/**
* Sets the resource manager responsible for this channel and registers
* the channel manager as a listener to this channel. Fires channel add
* channel event to the newly added channel manager channel listener.
*
* Note: resource manager instance is applied after object construction
* since we construct the channel objects from the xml playlist
* Constructs a new standard channel with a default name of "Channel"
*/
//TODO: remove this
public void setResourceManager( ResourceManager resourceManager )
public Channel()
{
mResourceManager = resourceManager;
/* If we're enabled, fire enable changed event to get processing started */
if( mEnabled )
{
enableChanged();
}
mChannelID = UNIQUE_ID++;
}
//TODO: remove this
@XmlTransient
public ResourceManager getResourceManager()
{
return mResourceManager;
}
/**
* Returns the processing chain for this channel. If the processing chain
* is not currently constructed and running, this method will return null.
* Unique identifier for this channel. Value is transient (not persisted).
*/
@XmlTransient
public ProcessingChain getProcessingChain()
public int getChannelID()
{
return mProcessingChain;
return mChannelID;
}
/**
* Indicates if this channel has a processing chain constructed and it
* is processing.
*/
public boolean isProcessing()
{
return mProcessingChain != null && mProcessingChain.processing();
}
/**
* Indicates if this channel has been selected for audio output
* Indicates if this channel has been selected for prioritized audio output
* and display of processing chain products
*/
@XmlTransient
public boolean isSelected()
@@ -224,100 +141,12 @@ public class Channel extends Configuration
mSelected = selected;
}
@XmlTransient
public CallEventModel getCallEventModel()
{
return mCallEventModel;
}
/**
* Returns the MessageEventLogger for this processing chain
*/
@XmlTransient
public MessageEventLogger getEventLogger()
{
return mEventLogger;
}
/**
* Sets the MessageEventLogger for this processing chain
*/
public void setEventLogger( MessageEventLogger eventLogger )
{
mEventLogger = eventLogger;
}
@XmlTransient
public MessageActivityModel getMessageActivityModel()
{
return mMessageActivityModel;
}
@XmlTransient
public ChannelState getChannelState()
{
return mChannelState;
}
@XmlTransient
public ChannelType getChannelType()
{
return mChannelType;
}
/**
* Orderly shutdown method when this channel is going to be deleted.
*/
public void dispose()
{
setEnabled( DISABLED );
}
/**
* Returns a full channel name containing the system, site and channel name.
*/
public String getChannelDisplayName()
{
StringBuilder sb = new StringBuilder();
sb.append( ( mSystem == null ? "-" : mSystem ) );
sb.append( ( mSite == null ? "-" : mSite ) );
sb.append( mName );
return sb.toString();
}
/**
* Returns the tuner channel requirement for this channel when the source
* configuration specifies a tuner and frequency as the source for this
* channel.
*
* If the source configuration is anything else, this method returns null.
*/
public TunerChannel getTunerChannel()
{
TunerChannel retVal = null;
if( mSourceConfiguration.getSourceType() == SourceType.TUNER )
{
SourceConfigTuner config = (SourceConfigTuner)mSourceConfiguration;
retVal = new TunerChannel( Type.LOCKED, config.getFrequency(),
mDecodeConfiguration.getDecoderType().getChannelBandwidth() );
}
else if( mSourceConfiguration.getSourceType() == SourceType.RECORDING )
{
SourceConfigRecording config =
(SourceConfigRecording)mSourceConfiguration;
retVal = new TunerChannel( Type.LOCKED, config.getFrequency(),
mDecodeConfiguration.getDecoderType().getChannelBandwidth() );
}
return retVal;
}
/**
* Returns the owning system for this channel.
*/
@@ -343,50 +172,78 @@ public class Channel extends Configuration
@XmlAttribute( name = "site" )
public String getSite()
{
return mSite;
return mSite;
}
public void setSite( String site )
{
mSite = site;
}
public boolean hasSite()
{
return mSite != null;
}
/**
* Returns the name of this channel.
*/
@XmlAttribute( name = "name" )
public String getName()
{
return mName;
}
/**
* Sets the name of this channel.
*/
public void setName( String name )
{
mName = name;
}
/**
* Default display string for this channel -- the channel name.
* Default display string for this channel: SYSTEM_SITE_NAME
*/
public String toString()
{
return mName;
StringBuilder sb = new StringBuilder();
sb.append( hasSystem() ? getSystem() : "SYSTEM" );
sb.append( "_" );
sb.append( hasSite() ? getSite() : "SITE" );
sb.append( "_" );
sb.append( getName() );
return sb.toString();
}
/**
* Indicates if this channel is enabled for processing.
*/
@XmlAttribute
@XmlAttribute( name = "enabled" )
public boolean getEnabled()
{
return mEnabled;
}
/**
* Enables/disables this channel for processing. Automatically starts or
* stops channel processing in response to this change.
* Indicates if this channel will automatically start processing on
* application startup or if this channel is currently processing after
* application startup.
*
* Note: this method is package private and is intended to be managed
* by a co-package central processing manager
*
* @see controller.ChannelProcessingManager
*/
public void setEnabled( boolean enabled )
void setEnabled( boolean enabled )
{
mEnabled = enabled;
enableChanged();
}
/**
* Returns the alias list that is used by this channel for looking up alias
* values for the various identifiers produced by the decoder.
* values for the various identifiers produced by the decoder(s).
*/
@XmlElement( name = "alias_list_name" )
public String getAliasListName()
@@ -404,7 +261,7 @@ public class Channel extends Configuration
}
/**
* Gets the decoder configuration used by this channel
* Gets the primary decoder configuration used by this channel
*/
@XmlElement( name = "decode_configuration" )
public DecodeConfiguration getDecodeConfiguration()
@@ -413,7 +270,7 @@ public class Channel extends Configuration
}
/**
* Sets the decoder configuration used by this channel
* Sets the primary decoder configuration used by this channel
*/
public void setDecodeConfiguration( DecodeConfiguration config )
{
@@ -421,7 +278,8 @@ public class Channel extends Configuration
}
/**
* Gets the aux decoder configuration used by this channel
* Gets the aux decoder configuration used by this channel. Aux decoders
* operate on demodulated audio
*/
@XmlElement( name = "aux_decode_configuration" )
public AuxDecodeConfiguration getAuxDecodeConfiguration()
@@ -438,7 +296,8 @@ public class Channel extends Configuration
}
/**
* Returns the source configuration for this channel.
* Returns the source configuration for this channel. A channel source
* identifies where the processing chain will get source sample data from.
*/
@XmlElement( name = "source_configuration" )
public SourceConfiguration getSourceConfiguration()
@@ -452,6 +311,10 @@ public class Channel extends Configuration
public void setSourceConfiguration( SourceConfiguration config )
{
mSourceConfiguration = config;
//Clear the tune channel object so that it can be recreated if the
//source configuration changes
mTunerChannel = null;
}
/**
@@ -489,252 +352,41 @@ public class Channel extends Configuration
}
/**
* Returns the name of this channel.
*/
@XmlAttribute
public String getName()
{
return mName;
}
/**
* Sets the name of this channel.
*/
public void setName( String name )
{
mName = name;
}
/**
* Responds to changes in the enabled setting by starting the processing
* change if the channel is now enabled, or stopping the procesing chain
* if it was already started.
*/
private void enableChanged()
{
if( mEnabled )
{
start();
}
else
{
stop();
}
}
/**
* Starts the channel processing chain.
*/
private void start()
{
if( mEnabled && mResourceManager != null )
{
setupChannelState();
try
{
setup();
mProcessingChain.start();
}
catch( SourceException se )
{
//Do nothing, we couldn't get a source for the channel
}
}
}
private void setupChannelState()
{
if( mChannelState == null )
{
mChannelState = new ChannelState( mResourceManager
.getThreadPoolManager(), mChannelType );
mChannelState.setTrafficChannelTimeout( mTrafficChannelTimeout );
}
}
/**
* Sets up the channel and prepares to start processing. Sets up the
* processing chain and requests a source.
* Convenience method to construct a tuner channel object representing a
* tuner or recording source frequency and bandwidth that can be used by
* application components for graphically representing this channel.
*
* @throws SourceException - if no source is available or if there is an
* error obtaining a source
* If the source configuration is not a tuner or recording, this method
* returns null.
*/
public void setup() throws SourceException
{
setupProcessingChain();
setupSource();
}
@XmlTransient
public TunerChannel getTunerChannel()
{
if( mTunerChannel == null )
{
if( mSourceConfiguration.getSourceType() == SourceType.TUNER )
{
SourceConfigTuner config = (SourceConfigTuner)mSourceConfiguration;
mTunerChannel = new TunerChannel( Type.LOCKED, config.getFrequency(),
mDecodeConfiguration.getDecoderType().getChannelBandwidth() );
}
else if( mSourceConfiguration.getSourceType() == SourceType.RECORDING )
{
SourceConfigRecording config =
(SourceConfigRecording)mSourceConfiguration;
mTunerChannel = new TunerChannel( Type.LOCKED, config.getFrequency(),
mDecodeConfiguration.getDecoderType().getChannelBandwidth() );
}
}
return mTunerChannel;
}
/**
* Setup recording options. Adds RecorderManager as a audio packet listener
* to receive and record decoded audio.
*/
private void setupRecording()
{
List<RecorderType> recorders = mRecordConfiguration.getRecorders();
if( !recorders.isEmpty() )
{
if( recorders.contains( RecorderType.AUDIO ) )
{
mProcessingChain.addAudioPacketListener(
mResourceManager.getRecorderManager() );
}
/* Add baseband recorder */
if( ( recorders.contains( RecorderType.BASEBAND ) &&
mChannelType == ChannelType.STANDARD ) )
{
mProcessingChain.addModule( RecorderManager.getBasebandRecorder(
mResourceManager.getThreadPoolManager(), getChannelName() ) );
}
/* Add traffic channel baseband recorder */
if( recorders.contains( RecorderType.TRAFFIC_BASEBAND ) &&
mChannelType == ChannelType.TRAFFIC )
{
mProcessingChain.addModule( RecorderManager.getBasebandRecorder(
mResourceManager.getThreadPoolManager(), getChannelName() ) );
}
}
}
private String getChannelName()
{
StringBuilder sb = new StringBuilder();
sb.append( mSystem );
sb.append( "_" );
sb.append( mSite );
sb.append( "_" );
sb.append( mName );
return sb.toString();
}
private void setupLogging()
{
if( mProcessingChain != null )
{
String channelName = getChannelName();
List<Module> loggers = mResourceManager.getEventLogManager()
.getLoggers( mEventLogConfiguration, channelName );
if( !loggers.isEmpty() )
{
mProcessingChain.addModules( loggers );
}
}
}
private void setupProcessingChain()
{
if( mProcessingChain == null )
{
mProcessingChain = new ProcessingChain();
/* Get the optional alias list for the decode modules to use */
AliasList aliasList = mResourceManager.getPlaylistManager()
.getPlayist().getAliasDirectory().getAliasList( mAliasListName );
/* Add the channel state as a module */
mProcessingChain.addModule( mChannelState );
/* Processing Modules */
List<Module> modules = DecoderFactory.getModules( mChannelType,
mResourceManager, mDecodeConfiguration, mRecordConfiguration,
mAuxDecodeConfiguration, aliasList, mSystem,
mSite, mName );
mProcessingChain.addModules( modules );
/* Get message filters for the set of processing modules */
FilterSet<Message> messageFilter = DecoderFactory.getMessageFilters( modules );
/* Setup the message activity model and add message listeners */
mMessageActivityModel = new MessageActivityModel( messageFilter );
mProcessingChain.addMessageListener( mMessageActivityModel );
/* Add audio manager as listener for audio packets */
mProcessingChain.addAudioPacketListener(
mResourceManager.getAudioManager() );
/* Create the call event model to receive call events */
mCallEventModel = new CallEventModel();
mProcessingChain.addCallEventListener( mCallEventModel );
setupLogging();
setupRecording();
/* Inject channel metadata that will be inserted into audio packets
* for the recorder manager and streaming */
mProcessingChain.broadcast(
new Metadata( MetadataType.SYSTEM, mSystem ) );
mProcessingChain.broadcast(
new Metadata( MetadataType.SITE_ID, mSite ) );
mProcessingChain.broadcast(
new Metadata( MetadataType.CHANNEL_NAME, mName ) );
}
}
/**
* Attempts to obtain a source and apply it to the processing chain.
*
* @throws SourceException - if the processing chain is not setup or if
* there is an error produced while obtaining the source
*/
private void setupSource() throws SourceException
{
if( mProcessingChain != null )
{
Source source = mResourceManager.getSourceManager()
.getSource( getSourceConfiguration(), getDecodeConfiguration()
.getDecoderType().getChannelBandwidth() );
if( source != null )
{
mProcessingChain.setSource( source );
}
else
{
throw new SourceException( "Couldn't obtain tuner channel source" );
}
}
else
{
throw new SourceException( "Cannot obtain source for a null "
+ "processing chain - setup the processing chain first" );
}
}
/**
* Stops the channel processing chain
*/
private void stop()
{
if( !mEnabled && mProcessingChain != null )
{
fireChannelEvent( Event.CHANNEL_PROCESSING_STOPPED );
mProcessingChain.stop();
if( mChannelType == ChannelType.STANDARD )
{
mProcessingChain.dispose();
mProcessingChain = null;
}
mSelected = false;
}
}
/**
* Indicates if any part of this channel is contained within the
* minimum and maximum frequency values.
* Convenience method to indicate if any part of this channel is contained
* within the minimum and maximum frequency values.
*/
public boolean isWithin( long minimum, long maximum )
{

View File

@@ -1,6 +1,7 @@
/*******************************************************************************
* SDR Trunk
* Copyright (C) 2014 Dennis Sheirer
* 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
@@ -15,37 +16,29 @@
* 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 controller;
package controller.channel;
import javax.swing.JPanel;
import net.miginfocom.swing.MigLayout;
import controller.channel.ChannelValidationException;
public abstract class Editor extends JPanel
public abstract class ChannelConfigurationEditor extends JPanel
{
private static final long serialVersionUID = 1L;
public Editor()
{
setLayout( new MigLayout() );
}
/**
* Sets or resets the configuration editor components
*/
public abstract void setConfiguration( Channel channel );
/**
* Saves the contents of the editor components to the configuration
*/
public abstract void save();
public abstract void reset();
/**
* Override this method to allow the editor to inspect the argument for
* valid configuration
* Validates the contents of the editor components prior to saving the
* content to the configuration.
*
* @param editor - any editor
*
* @throws ChannelValidationException if the configuration is not compatible
* with this editor's configuration. Supplies a validation text value for
* display to the user
* @throws ConfigurationValidationException if the content is invalid
*/
public void validate( Editor editor ) throws ChannelValidationException
{
}
public abstract void validateConfiguration() throws ConfigurationValidationException;
}

View File

@@ -19,21 +19,17 @@ package controller.channel;
import java.awt.Color;
import java.awt.ComponentOrientation;
import java.awt.Component;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.util.Collections;
import java.util.List;
import javax.swing.DefaultComboBoxModel;
import javax.swing.JButton;
import javax.swing.JCheckBox;
import javax.swing.JComboBox;
import javax.swing.JLabel;
import javax.swing.JOptionPane;
import javax.swing.JPanel;
import javax.swing.JTextField;
import javax.swing.tree.DefaultTreeModel;
import javax.swing.tree.TreePath;
import module.decode.AuxDecodeComponentEditor;
import module.decode.DecodeComponentEditor;
@@ -46,20 +42,21 @@ import org.slf4j.LoggerFactory;
import playlist.PlaylistManager;
import record.RecordComponentEditor;
import source.SourceComponentEditor;
import source.SourceManager;
import alias.AliasList;
import com.jidesoft.swing.JideTabbedPane;
import controller.Editor;
import controller.channel.ChannelEvent.Event;
public class ChannelEditor extends Editor implements ActionListener
public class ChannelEditor extends JPanel
implements ActionListener, ChannelEventListener
{
private static final long serialVersionUID = 1L;
private final static Logger mLog = LoggerFactory.getLogger( ChannelEditor.class );
private static final long serialVersionUID = 1L;
private DefaultTreeModel mTreeModel;
private ChannelNode mChannelNode;
private ChannelConfigurationEditor mNameConfigurationEditor;
private DecodeComponentEditor mDecodeEditor;
private AuxDecodeComponentEditor mAuxDecodeEditor;
private EventLogComponentEditor mEventLogEditor;
@@ -70,18 +67,33 @@ public class ChannelEditor extends Editor implements ActionListener
private JCheckBox mChannelEnabled = new JCheckBox();
private JComboBox<AliasList> mComboAliasLists;
private Channel mChannel;
private ChannelModel mChannelModel;
private PlaylistManager mPlaylistManager;
private SourceManager mSourceManager;
public ChannelEditor( ChannelNode channel, PlaylistManager playlistManager )
public ChannelEditor( ChannelModel channelModel,
PlaylistManager playlistManager,
SourceManager sourceManager )
{
super();
mChannelNode = channel;
mChannelModel = channelModel;
mPlaylistManager = playlistManager;
mSourceManager = sourceManager;
mNameConfigurationEditor = new NameConfigurationEditor(
mChannelModel, mPlaylistManager );
initGUI();
}
public void setChannel( Channel channel )
{
mNameConfigurationEditor.setConfiguration( channel );
mChannel = channel;
}
private void initGUI()
{
@@ -89,65 +101,29 @@ public class ChannelEditor extends Editor implements ActionListener
add( new JLabel( "Channel Configuration" ), "span, align center" );
add( new JLabel( "Enabled:" ) );
add( new JLabel( "Enabled:" ), "wrap" );
mChannelEnabled.setSelected(
mChannelNode.getChannel().getEnabled() );
mChannelEnabled.setComponentOrientation( ComponentOrientation.RIGHT_TO_LEFT );
add( mChannelEnabled );
add( new JLabel( "Name:" ) );
mChannelName = new JTextField( mChannelNode.getChannel().getName() );
add( mChannelName, "growx,push" );
/**
* ComboBox: Alias Lists
*/
add( new JLabel( "Alias List:" ) );
mComboAliasLists = new JComboBox<AliasList>();
List<AliasList> lists = mChannelNode.getModel().getResourceManager()
.getPlaylistManager().getPlayist().getAliasDirectory().getAliasList();
Collections.sort( lists );
mComboAliasLists.setModel( new DefaultComboBoxModel<AliasList>(
lists.toArray( new AliasList[ lists.size() ] ) ) );
String aliasListName =
mChannelNode.getChannel().getAliasListName();
if( aliasListName != null )
{
AliasList selected = mChannelNode.getModel().getResourceManager()
.getPlaylistManager().getPlayist().getAliasDirectory()
.getAliasList( aliasListName );
mComboAliasLists.setSelectedItem( selected );
}
add( mComboAliasLists, "growx,push" );
add( mNameConfigurationEditor );
JideTabbedPane tabs = new JideTabbedPane();
tabs.setFont( this.getFont() );
tabs.setForeground( Color.BLACK );
mSourceEditor = new SourceComponentEditor( mChannelNode );
tabs.addTab( "Source", mSourceEditor );
mDecodeEditor = new DecodeComponentEditor( mChannelNode, mPlaylistManager );
tabs.addTab( "Decoder", mDecodeEditor );
mAuxDecodeEditor = new AuxDecodeComponentEditor( mChannelNode );
tabs.addTab( "Aux", mAuxDecodeEditor );
mEventLogEditor = new EventLogComponentEditor( mChannelNode );
tabs.addTab( "Event Log", mEventLogEditor );
mRecordEditor = new RecordComponentEditor( mChannelNode );
tabs.addTab( "Record", mRecordEditor );
tabs.addTab( "Name/Alias", mNameConfigurationEditor );
// mSourceEditor = new SourceComponentEditor( mSourceManager, mChannel );
// tabs.addTab( "Source", mSourceEditor );
//
// mDecodeEditor = new DecodeComponentEditor( mPlaylistManager, mChannel );
// tabs.addTab( "Decoder", mDecodeEditor );
//
// mAuxDecodeEditor = new AuxDecodeComponentEditor( mChannel );
// tabs.addTab( "Aux", mAuxDecodeEditor );
//
// mEventLogEditor = new EventLogComponentEditor( mChannel );
// tabs.addTab( "Event Log", mEventLogEditor );
//
// mRecordEditor = new RecordComponentEditor( mChannel );
// tabs.addTab( "Record", mRecordEditor );
add( tabs, "span,grow,push" );
@@ -159,6 +135,12 @@ public class ChannelEditor extends Editor implements ActionListener
btnReset.addActionListener( ChannelEditor.this );
add( btnReset, "growx,push" );
}
@Override
public void channelChanged( ChannelEvent event )
{
}
@Override
public void actionPerformed( ActionEvent e )
@@ -171,109 +153,105 @@ public class ChannelEditor extends Editor implements ActionListener
}
else if( command.contentEquals( "Reset" ) )
{
reset();
}
if( mTreeModel != null )
{
mTreeModel.nodeChanged( mChannelNode );
setChannel( mChannel );
}
}
@Override
public void save()
{
try
{
/**
* Validate the source configuration against the other component
* configuration editors
*/
validate( mSourceEditor.getSourceEditor() );
boolean expanded = mChannelNode.getModel().getTree()
.isExpanded( new TreePath( mChannelNode ) );
mSourceEditor.save();
mDecodeEditor.save();
mAuxDecodeEditor.save();
mEventLogEditor.save();
mRecordEditor.save();
mChannelNode.getChannel().setName( mChannelName.getText() );
mChannelNode.getChannel().setEnabled( mChannelEnabled.isSelected() );
AliasList selected = mComboAliasLists.getItemAt(
mComboAliasLists.getSelectedIndex() );
if( selected != null )
{
mChannelNode.getChannel().setAliasListName( selected.getName() );
}
mChannelNode.save();
mChannelNode.show();
if( expanded )
{
mChannelNode.getModel().getTree().expandPath( new TreePath( mChannelNode ) );
}
//Validate each of the configuration editors to check for errors
mNameConfigurationEditor.validateConfiguration();
// /**
// * Validate the source configuration against the other component
// * configuration editors
// */
// validate( mSourceEditor.getSourceEditor() );
//
// mSourceEditor.save();
// mDecodeEditor.save();
// mAuxDecodeEditor.save();
// mEventLogEditor.save();
// mRecordEditor.save();
//
// mChannel.setName( mChannelName.getText() );
// mChannel.setEnabled( mChannelEnabled.isSelected() );
//
// AliasList selected = mComboAliasLists.getItemAt(
// mComboAliasLists.getSelectedIndex() );
// if( selected != null )
// {
// mChannel.setAliasListName( selected.getName() );
// }
}
catch ( ChannelValidationException validationException )
catch ( ConfigurationValidationException validationException )
{
/* ChannelValidationException can be thrown by any of the component
* editors. Show the validation error text in a popup menu to the
* user */
* user and set the focus on the error component */
JOptionPane.showMessageDialog( ChannelEditor.this,
validationException.getMessage(),
"Channel Configuration Error",
JOptionPane.ERROR_MESSAGE );
Component component = validationException.getComponent();
if( component != null )
{
component.requestFocus();
}
return;
}
}
@Override
public void reset()
{
mChannelName.setText(
mChannelNode.getChannel().getName() );
mChannelName.requestFocus();
mChannelName.requestFocusInWindow();
//Save the contents of each editor to the channel configuration
mNameConfigurationEditor.save();
mChannelEnabled.setSelected(
mChannelNode.getChannel().getEnabled() );
mChannelEnabled.requestFocus();
mChannelEnabled.requestFocusInWindow();
String aliasListName =
mChannelNode.getChannel().getAliasListName();
if( aliasListName != null )
{
AliasList selected = mChannelNode.getModel().getResourceManager()
.getPlaylistManager().getPlayist().getAliasDirectory()
.getAliasList( aliasListName );
mComboAliasLists.setSelectedItem( selected );
}
mSourceEditor.reset();
mDecodeEditor.reset();
mAuxDecodeEditor.reset();
mEventLogEditor.reset();
mRecordEditor.reset();
//Broadcast a channel configuration change event
mChannelModel.broadcast( new ChannelEvent( mChannel,
Event.NOTIFICATION_CONFIGURATION_CHANGE ) );
}
/**
* Validate the specified editor against each of the component editors
*/
@Override
public void validate( Editor editor ) throws ChannelValidationException
{
mSourceEditor.validate( editor );
mDecodeEditor.validate( editor );
mAuxDecodeEditor.validate( editor );
mEventLogEditor.validate( editor );
mRecordEditor.validate( editor );
}
// @Override
// public void reset()
// {
// mChannelName.setText( mChannel.getName() );
// mChannelName.requestFocus();
// mChannelName.requestFocusInWindow();
//
// mChannelEnabled.setSelected( mChannel.getEnabled() );
// mChannelEnabled.requestFocus();
// mChannelEnabled.requestFocusInWindow();
//
// String aliasListName = mChannel.getAliasListName();
//
// if( aliasListName != null )
// {
// AliasList selected = mPlaylistManager.getPlayist().getAliasDirectory()
// .getAliasList( aliasListName );
//
// mComboAliasLists.setSelectedItem( selected );
// }
//
//
// mSourceEditor.reset();
// mDecodeEditor.reset();
// mAuxDecodeEditor.reset();
// mEventLogEditor.reset();
// mRecordEditor.reset();
// }
// /**
// * Validate the specified editor against each of the component editors
// */
// @Override
// public void validate( ChannelConfigurationEditor editor ) throws ConfigurationValidationException
// {
// mSourceEditor.validate( editor );
// mDecodeEditor.validate( editor );
// mAuxDecodeEditor.validate( editor );
// mEventLogEditor.validate( editor );
// mRecordEditor.validate( editor );
// }
}

View File

@@ -64,6 +64,8 @@ public class ChannelEvent
NOTIFICATION_SELECTION_CHANGE,
//Channel's channel-state has been reset
NOTIFICATION_STATE_RESET,
//Request to delete the channel
REQUEST_DELETE,
//Request to deselect the channel
REQUEST_DESELECT,
//Request to disable a channel - response will be a PROCESSING_STOP_NOTIFICATION

View File

@@ -0,0 +1,346 @@
/*******************************************************************************
* SDR Trunk
* Copyright (C) 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 controller.channel;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.concurrent.CopyOnWriteArrayList;
import javax.swing.event.TableModelEvent;
import javax.swing.event.TableModelListener;
import javax.swing.table.TableModel;
import module.decode.DecoderType;
import controller.channel.Channel.ChannelType;
import controller.channel.ChannelEvent.Event;
/**
* Channel Model
*/
public class ChannelModel implements IChannelEventBroadcaster, TableModel
{
private ChannelSelectionManager mChannelSelectionManager;
private List<Channel> mChannels = new ArrayList<>();
private List<Channel> mTrafficChannels = new ArrayList<>();
private List<ChannelEventListener> mListeners = new CopyOnWriteArrayList<>();
private List<TableModelListener> mTableModelListeners = new CopyOnWriteArrayList<>();
public ChannelModel()
{
mChannelSelectionManager = new ChannelSelectionManager( this );
addListener( mChannelSelectionManager );
}
/**
* Unmodifiable list of non-traffic channels currently in the model
*/
public List<Channel> getChannels()
{
return Collections.unmodifiableList( mChannels );
}
/**
* Returns a list of unique system values from across the channel set
*/
public List<String> getSystems()
{
List<String> systems = new ArrayList<>();
for( Channel channel: mChannels )
{
if( channel.hasSystem() && !systems.contains( channel.getSystem() ) )
{
systems.add( channel.getSystem() );
}
}
Collections.sort( systems );
return systems;
}
/**
* Returns a list of unique site values for all channels that have a matching
* system value
*/
public List<String> getSites( String system )
{
List<String> sites = new ArrayList<>();
if( system != null )
{
for( Channel channel: mChannels )
{
if( channel.hasSystem() &&
system.equals( channel.getSystem() ) &&
channel.hasSite() &&
!sites.contains( channel.getSite() ) )
{
sites.add( channel.getSite() );
}
}
}
Collections.sort( sites );
return sites;
}
/**
* Broadcasts the channel event to all registered listeners
*/
@Override
public void broadcast( ChannelEvent event )
{
for( ChannelEventListener listener: mListeners )
{
listener.channelChanged( event );
}
if( event.getChannel().getChannelType() == ChannelType.STANDARD )
{
switch( event.getEvent() )
{
case NOTIFICATION_CONFIGURATION_CHANGE:
case NOTIFICATION_PROCESSING_START:
case NOTIFICATION_PROCESSING_STOP:
case NOTIFICATION_SELECTION_CHANGE:
int index = mChannels.indexOf( event.getChannel() );
broadcast( new TableModelEvent( this, index ) );
break;
default:
break;
}
}
if( event.getEvent() == Event.REQUEST_DELETE )
{
removeChannel( event.getChannel() );
}
}
/**
* Bulk loading of channel list. Each channel is added and a channel add
* event is broadcast.
*/
public void addChannels( List<Channel> channels )
{
for( Channel channel: channels )
{
addChannel( channel );
}
}
/**
* Adds the channel to the model and broadcasts a channel add event
*/
public void addChannel( Channel channel )
{
switch( channel.getChannelType() )
{
case STANDARD:
mChannels.add( channel );
int index = mChannels.size() - 1;
broadcast( new TableModelEvent( this, index, index,
TableModelEvent.ALL_COLUMNS, TableModelEvent.INSERT ) );
break;
case TRAFFIC:
mTrafficChannels.add( channel );
break;
default:
break;
}
broadcast( new ChannelEvent( channel, Event.NOTIFICATION_ADD ) );
}
/**
* Removes the channel from the model and broadcasts a channel remove event
*/
public void removeChannel( Channel channel )
{
switch( channel.getChannelType() )
{
case STANDARD:
int index = mChannels.indexOf( channel );
mChannels.remove( channel );
if( index >= 0 )
{
broadcast( new TableModelEvent( this, index, index,
TableModelEvent.ALL_COLUMNS, TableModelEvent.DELETE ) );
}
break;
case TRAFFIC:
mTrafficChannels.remove( channel );
break;
default:
break;
}
broadcast( new ChannelEvent( channel, Event.NOTIFICATION_DELETE ) );
}
/**
* Returns a list of channels that fall within the frequency range
*
* @param start frequency of the range
* @param stop frequency of the range
*
* @return list of channels or an empty list if none fall within the range
*/
public List<Channel> getChannelsInFrequencyRange( long start, long stop )
{
List<Channel> channels = new ArrayList<>();
for( Channel channel: mChannels )
{
if( channel.isWithin( start, stop ) )
{
channels.add( channel );
}
}
for( Channel channel: mTrafficChannels )
{
if( channel.isWithin( start, stop ) )
{
channels.add( channel );
}
}
return channels;
}
public void addListener( ChannelEventListener listener )
{
mListeners.add( listener );
}
public void removeListener( ChannelEventListener listener )
{
mListeners.remove( listener );
}
//Table Model Interface Methods - standard channels only
@Override
public int getRowCount()
{
return mChannels.size();
}
@Override
public int getColumnCount()
{
return 6;
}
@Override
public String getColumnName( int columnIndex )
{
switch( columnIndex )
{
case 0:
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;
}
@Override
public Class<?> getColumnClass( int columnIndex )
{
return String.class;
}
@Override
public boolean isCellEditable( int rowIndex, int columnIndex )
{
return false;
}
@Override
public Object getValueAt( int rowIndex, int columnIndex )
{
Channel channel = mChannels.get( rowIndex );
switch( columnIndex )
{
case 0:
return channel.getSystem();
case 1:
return channel.getSite();
case 2:
return channel.getName();
case 3:
return channel.getAliasListName();
case 4:
return channel.getSourceConfiguration().getDescription();
case 5:
return channel.getDecodeConfiguration()
.getDecoderType().getShortDisplayString();
}
return null;
}
@Override
public void setValueAt( Object aValue, int rowIndex, int columnIndex )
{
throw new IllegalArgumentException( "Not yet implemented" );
}
private void broadcast( TableModelEvent event )
{
for( TableModelListener listener: mTableModelListeners )
{
listener.tableChanged( event );
}
}
@Override
public void addTableModelListener( TableModelListener listener )
{
mTableModelListeners.add( listener );
}
@Override
public void removeTableModelListener( TableModelListener listener )
{
mTableModelListeners.remove( listener );
}
public void createChannel( DecoderType decoderType, long frequency )
{
throw new UnsupportedOperationException( "Not yet implemented" );
}
}

View File

@@ -27,6 +27,8 @@ import javax.swing.JPopupMenu;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import playlist.PlaylistManager;
import source.SourceManager;
import source.tuner.TunerChannel;
import controller.ConfigurableNode;
import controller.site.SiteNode;
@@ -43,10 +45,22 @@ public class ChannelNode extends ConfigurableNode implements ChannelEventListene
private final static Logger mLog = LoggerFactory.getLogger( ChannelNode.class );
private static DecimalFormat sFORMAT = new DecimalFormat( "0.0000" );
private ChannelModel mChannelModel;
private ChannelProcessingManager mChannelProcessingManager;
private SourceManager mSourceManager;
public ChannelNode( Channel channel )
public ChannelNode( Channel channel,
ChannelModel channelModel,
ChannelProcessingManager channelProcessingManager,
PlaylistManager playlistManager,
SourceManager sourceManager )
{
super( channel );
super( playlistManager, channel );
mChannelModel = channelModel;
mChannelProcessingManager = channelProcessingManager;
mSourceManager = sourceManager;
}
public void init()
@@ -69,9 +83,6 @@ public class ChannelNode extends ConfigurableNode implements ChannelEventListene
/* Add this node as listener to receive changes from underlying channel */
// getChannel().addListener( this );
/* Add the resource manager to the channel so that the channel
* can provide channel change events to all system resources */
getChannel().setResourceManager( getModel().getResourceManager() );
}
/**
@@ -109,7 +120,7 @@ public class ChannelNode extends ConfigurableNode implements ChannelEventListene
{
if( getChannel().getEnabled() )
{
if( getChannel().isProcessing() )
if( getChannel().getEnabled() )
{
return Color.GREEN;
}
@@ -125,9 +136,7 @@ public class ChannelNode extends ConfigurableNode implements ChannelEventListene
@Override
public JPanel getEditor()
{
return new ChannelEditor( this,
getChannel().getResourceManager() == null ? null :
getChannel().getResourceManager().getPlaylistManager() );
return new OldChannelEditor( getChannel(), mChannelModel, getPlaylistManager(), mSourceManager );
}
public Channel getChannel()
@@ -158,9 +167,9 @@ public class ChannelNode extends ConfigurableNode implements ChannelEventListene
{
JPopupMenu popupMenu = new JPopupMenu();
JMenu channelMenu = ChannelUtils.getContextMenu(
getModel().getResourceManager().getPlaylistManager(),
getChannel(), getModel().getTree() );
JMenu channelMenu = ChannelUtils.getContextMenu( mChannelModel,
mChannelProcessingManager, getPlaylistManager(), getChannel(),
getModel().getTree() );
if( channelMenu != null )
{

View File

@@ -0,0 +1,301 @@
/*******************************************************************************
* 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 controller.channel;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.concurrent.CopyOnWriteArrayList;
import message.Message;
import module.Module;
import module.ProcessingChain;
import module.decode.DecoderFactory;
import module.decode.event.MessageActivityModel;
import module.log.EventLogManager;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import playlist.PlaylistManager;
import record.RecorderManager;
import record.RecorderType;
import sample.Listener;
import source.Source;
import source.SourceException;
import source.SourceManager;
import audio.AudioPacket;
import audio.metadata.Metadata;
import audio.metadata.MetadataType;
import controller.ThreadPoolManager;
import controller.channel.Channel.ChannelType;
import controller.channel.ChannelEvent.Event;
import filter.FilterSet;
public class ChannelProcessingManager implements ChannelEventListener
{
private final static Logger mLog = LoggerFactory.getLogger( ChannelProcessingManager.class );
private Map<Integer,ProcessingChain> mProcessingChains = new HashMap<>();
private List<Listener<AudioPacket>> mAudioPacketListeners = new CopyOnWriteArrayList<>();
private List<Listener<Message>> mMessageListeners = new CopyOnWriteArrayList<>();
private ChannelModel mChannelModel;
private EventLogManager mEventLogManager;
private PlaylistManager mPlaylistManager;
private RecorderManager mRecorderManager;
private SourceManager mSourceManager;
private ThreadPoolManager mThreadPoolManager;
public ChannelProcessingManager( ChannelModel channelModel,
EventLogManager eventLogManager,
PlaylistManager playlistManager,
RecorderManager recorderManager,
SourceManager sourceManager,
ThreadPoolManager threadPoolManager )
{
mChannelModel = channelModel;
mEventLogManager = eventLogManager;
mPlaylistManager = playlistManager;
mRecorderManager = recorderManager;
mSourceManager = sourceManager;
mThreadPoolManager = threadPoolManager;
mChannelModel.addListener( this );
}
/**
* Indicates if a processing chain is constructed for the channel and that
* the processing chain is currently processing.
*/
public boolean isProcessing( Channel channel )
{
if( mProcessingChains.containsKey( channel.getChannelID() ) )
{
return mProcessingChains.get( channel.getChannelID() ).isProcessing();
}
return false;
}
/**
* Returns the current processing chain associated with the channel, or
* null if a processing chain is not currently setup for the channel
*/
public ProcessingChain getProcessingChain( Channel channel )
{
return mProcessingChains.get( channel.getChannelID() );
}
@Override
public void channelChanged( ChannelEvent event )
{
Channel channel = event.getChannel();
switch( event.getEvent() )
{
case REQUEST_ENABLE:
if( !mProcessingChains.containsKey( channel.getChannelID() ) ||
!mProcessingChains.get( channel.getChannelID() ).isProcessing() )
{
startProcessing( channel );
}
break;
case REQUEST_DISABLE:
if( channel.getEnabled() )
{
switch( channel.getChannelType() )
{
case STANDARD:
stopProcessing( channel, true );
break;
case TRAFFIC:
//Don't remove traffic channel processing chains
//until explicitly deleted, so that we can reuse them
stopProcessing( channel, false );
default:
break;
}
}
case NOTIFICATION_DELETE:
if( channel.getEnabled() )
{
stopProcessing( channel, true );
}
break;
default:
break;
}
}
private void startProcessing( Channel channel )
{
ProcessingChain processingChain = mProcessingChains.get( channel.getChannelID() );
//If we're already processing, ignore the request
if( processingChain != null && processingChain.isProcessing() )
{
return;
}
//Ensure that we can get a source before we construct a new processing chain
Source source = null;
try
{
source = mSourceManager.getSource( channel.getSourceConfiguration(),
channel.getDecodeConfiguration().getDecoderType().getChannelBandwidth() );
}
catch( SourceException se )
{
mLog.debug( "Error obtaining source for channel [" + channel.getName() + "]", se );
}
if( source == null )
{
channel.setEnabled( false );
mChannelModel.broadcast(
new ChannelEvent( channel, Event.NOTIFICATION_ENABLE_REJECTED ) );
return;
}
if( processingChain == null )
{
processingChain = new ProcessingChain( mThreadPoolManager,
channel.getChannelType() );
/* Register global listeners */
for( Listener<AudioPacket> listener: mAudioPacketListeners )
{
processingChain.addAudioPacketListener( listener );
}
for( Listener<Message> listener: mMessageListeners )
{
processingChain.addMessageListener( listener );
}
/* Processing Modules */
List<Module> modules = DecoderFactory.getModules( mChannelModel,
this, mPlaylistManager, channel );
processingChain.addModules( modules );
/* Setup message activity model with filtering */
FilterSet<Message> messageFilter = DecoderFactory.getMessageFilters( modules );
MessageActivityModel messageModel = new MessageActivityModel( messageFilter );
processingChain.setMessageActivityModel( messageModel );
/* Setup event logging */
List<Module> loggers = mEventLogManager.getLoggers(
channel.getEventLogConfiguration(), channel.getName() );
if( !loggers.isEmpty() )
{
processingChain.addModules( loggers );
}
/* Setup recorders */
List<RecorderType> recorders = channel.getRecordConfiguration().getRecorders();
if( !recorders.isEmpty() )
{
if( recorders.contains( RecorderType.AUDIO ) )
{
processingChain.addAudioPacketListener( mRecorderManager );
}
/* Add baseband recorder */
if( ( recorders.contains( RecorderType.BASEBAND ) &&
channel.getChannelType() == ChannelType.STANDARD ) )
{
processingChain.addModule( mRecorderManager.getBasebandRecorder(
channel.toString() ) );
}
/* Add traffic channel baseband recorder */
if( recorders.contains( RecorderType.TRAFFIC_BASEBAND ) &&
channel.getChannelType() == ChannelType.TRAFFIC )
{
processingChain.addModule( mRecorderManager
.getBasebandRecorder( channel.toString() ) );
}
}
/* Inject channel metadata that will be inserted into audio packets
* for the recorder manager and streaming */
processingChain.broadcast(
new Metadata( MetadataType.SYSTEM, channel.getSystem() ) );
processingChain.broadcast(
new Metadata( MetadataType.SITE_ID, channel.getSite() ) );
processingChain.broadcast(
new Metadata( MetadataType.CHANNEL_NAME, channel.getName() ) );
}
processingChain.setSource( source );
processingChain.start();
channel.setEnabled( true );
mChannelModel.broadcast(
new ChannelEvent( channel, Event.NOTIFICATION_PROCESSING_START ) );
}
private void stopProcessing( Channel channel, boolean remove )
{
mChannelModel.broadcast(
new ChannelEvent( channel, Event.NOTIFICATION_PROCESSING_STOP ) );
}
/**
* Adds a message listener that will be added to all channels to receive
* any messages.
*/
public void addAudioPacketListener( Listener<AudioPacket> listener )
{
mAudioPacketListeners.add( listener );
}
/**
* Removes a message listener.
*/
public void removeAudioPacketListener( Listener<AudioPacket> listener )
{
mAudioPacketListeners.remove( listener );
}
/**
* Adds a message listener that will be added to all channels to receive
* any messages.
*/
public void addMessageListener( Listener<Message> listener )
{
mMessageListeners.add( listener );
}
/**
* Removes a message listener.
*/
public void removeMessageListener( Listener<Message> listener )
{
mMessageListeners.remove( listener );
}
}

View File

@@ -0,0 +1,71 @@
/*******************************************************************************
* SDR Trunk
* Copyright (C) 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 controller.channel;
import controller.channel.ChannelEvent.Event;
public class ChannelSelectionManager implements ChannelEventListener
{
private IChannelEventBroadcaster mChannelEventBroadcaster;
private Channel mSelectedChannel = null;
/**
* Manages channel selection state to ensure that only one channel is ever
* in a selected state.
*/
public ChannelSelectionManager( IChannelEventBroadcaster broadcaster )
{
mChannelEventBroadcaster = broadcaster;
}
@Override
public void channelChanged( ChannelEvent event )
{
switch( event.getEvent() )
{
case REQUEST_SELECT:
if( mSelectedChannel != null )
{
mSelectedChannel.setSelected( false );
mChannelEventBroadcaster.broadcast( new ChannelEvent( mSelectedChannel,
Event.NOTIFICATION_SELECTION_CHANGE ) );
mSelectedChannel = null;
}
mSelectedChannel = event.getChannel();
mSelectedChannel.setSelected( true );
mChannelEventBroadcaster.broadcast( new ChannelEvent( event.getChannel(),
Event.NOTIFICATION_SELECTION_CHANGE ) );
break;
case NOTIFICATION_PROCESSING_STOP:
case REQUEST_DESELECT:
if( mSelectedChannel != null &&
mSelectedChannel == event.getChannel() )
{
mSelectedChannel.setSelected( false );
mSelectedChannel = null;
mChannelEventBroadcaster.broadcast( new ChannelEvent( event.getChannel(),
Event.NOTIFICATION_SELECTION_CHANGE ) );
}
break;
default:
break;
}
}
}

View File

@@ -9,10 +9,11 @@ import javax.swing.JMenuItem;
import javax.swing.JOptionPane;
import javax.swing.JSeparator;
import controller.channel.ChannelEvent.Event;
import module.ProcessingChain;
import module.decode.event.ActivitySummaryFrame;
import module.decode.state.DecoderState;
import playlist.PlaylistManager;
import controller.channel.ChannelEvent.Event;
public class ChannelUtils
{
@@ -23,7 +24,9 @@ public class ChannelUtils
/**
* Creates a context menu for the channel argument
*/
public static JMenu getContextMenu( final PlaylistManager playlistManager,
public static JMenu getContextMenu( final ChannelModel channelModel,
final ChannelProcessingManager channelProcessingManager,
final PlaylistManager playlistManager,
final Channel channel,
final Component anchor )
{
@@ -39,12 +42,8 @@ public class ChannelUtils
@Override
public void actionPerformed( ActionEvent e )
{
channel.setEnabled( DISABLED );
if( playlistManager != null )
{
playlistManager.save();
}
channelModel.broadcast(
new ChannelEvent( channel, Event.REQUEST_DISABLE ) );
}
} );
@@ -62,10 +61,14 @@ public class ChannelUtils
{
StringBuilder sb = new StringBuilder();
for( DecoderState decoderState: channel
.getProcessingChain().getDecoderStates() )
ProcessingChain chain = channelProcessingManager.getProcessingChain( channel );
if( chain != null )
{
sb.append( decoderState.getActivitySummary() );
for( DecoderState decoderState: chain.getDecoderStates() )
{
sb.append( decoderState.getActivitySummary() );
}
}
new ActivitySummaryFrame( sb.toString(), anchor );
@@ -82,12 +85,8 @@ public class ChannelUtils
@Override
public void actionPerformed( ActionEvent e )
{
channel.setEnabled( ENABLED );
if( playlistManager != null )
{
playlistManager.save();
}
channelModel.broadcast(
new ChannelEvent( channel, Event.REQUEST_ENABLE ) );
}
} );
@@ -108,16 +107,8 @@ public class ChannelUtils
if( response == JOptionPane.YES_OPTION )
{
/* Disable the channel */
channel.setEnabled( DISABLED );
/* Broadcast channel deleted event */
// channel.fireChannelEvent( Event.NOTIFICATION_DELETE );
if( playlistManager != null )
{
playlistManager.save();
}
channelModel.broadcast(
new ChannelEvent( channel, Event.REQUEST_DELETE ) );
}
}
} );

View File

@@ -1,11 +0,0 @@
package controller.channel;
public class ChannelValidationException extends Exception
{
private static final long serialVersionUID = 1L;
public ChannelValidationException( String validationMessage )
{
super( validationMessage );
}
}

View File

@@ -0,0 +1,23 @@
package controller.channel;
import java.awt.Component;
public class ConfigurationValidationException extends Exception
{
private static final long serialVersionUID = 1L;
private Component mComponent;
public ConfigurationValidationException( Component component,
String validationMessage )
{
super( validationMessage );
mComponent = component;
}
public Component getComponent()
{
return mComponent;
}
}

View File

@@ -0,0 +1,29 @@
/*******************************************************************************
* SDR Trunk
* Copyright (C) 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 controller.channel;
/**
* Provides channel event broadcasting capability.
*/
public interface IChannelEventBroadcaster
{
/**
* Broadcasts the channel event
*/
public void broadcast( ChannelEvent event );
}

View File

@@ -0,0 +1,221 @@
package controller.channel;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.util.Collections;
import java.util.List;
import javax.swing.ComboBoxModel;
import javax.swing.DefaultComboBoxModel;
import javax.swing.JButton;
import javax.swing.JComboBox;
import javax.swing.JLabel;
import javax.swing.JOptionPane;
import javax.swing.JTextField;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import net.miginfocom.swing.MigLayout;
import playlist.PlaylistManager;
import alias.AliasList;
public class NameConfigurationEditor extends ChannelConfigurationEditor
{
private static final long serialVersionUID = 1L;
private final static Logger mLog = LoggerFactory.getLogger( NameConfigurationEditor.class );
private static ComboBoxModel<String> EMPTY_MODEL = new DefaultComboBoxModel<>();
private ChannelModel mChannelModel;
private PlaylistManager mPlaylistManager;
private JTextField mChannelName = new JTextField( "Please select a channel to edit" );
private JComboBox<String> mSystemNameCombo = new JComboBox<>( EMPTY_MODEL );
private JComboBox<String> mSiteNameCombo = new JComboBox<>( EMPTY_MODEL );
private JComboBox<AliasList> mAliasListCombo;
private Channel mChannel;
public NameConfigurationEditor( ChannelModel model,
PlaylistManager playlistManager )
{
mChannelModel = model;
mPlaylistManager = playlistManager;
setLayout( new MigLayout( "fill,wrap 2", "[right][]", "[][][][grow]" ) );
add( new JLabel( "Name:" ) );
add( mChannelName, "growx" );
mSystemNameCombo.setEditable( true );
mSystemNameCombo.addActionListener( new ActionListener()
{
@Override
public void actionPerformed( ActionEvent e )
{
Object selected = mSystemNameCombo.getSelectedItem();
if( selected != null )
{
String system = (String)selected;
List<String> sites = mChannelModel.getSites( system );
if( !sites.contains( mChannel.getSite() ) )
{
sites.add( mChannel.getSite() );
}
if( sites.isEmpty() )
{
mSiteNameCombo.setModel( EMPTY_MODEL );
}
else
{
mSiteNameCombo.setModel( new DefaultComboBoxModel<String>(
sites.toArray( new String[ sites.size() ] ) ) );;
}
mSiteNameCombo.setSelectedItem( mChannel.getSite() );
}
}
} );
add( new JLabel( "System:" ) );
add( mSystemNameCombo, "growx" );
mSiteNameCombo.setEditable( true );
add( new JLabel( "Site:" ) );
add( mSiteNameCombo, "growx" );
/**
* ComboBox: Alias Lists
*/
add( new JLabel( "Alias List:" ) );
mAliasListCombo = new JComboBox<AliasList>();
List<AliasList> lists = mPlaylistManager.getPlayist()
.getAliasDirectory().getAliasList();
Collections.sort( lists );
mAliasListCombo.setModel( new DefaultComboBoxModel<AliasList>(
lists.toArray( new AliasList[ lists.size() ] ) ) );
add( mAliasListCombo, "growx" );
add( new JLabel() );
final JButton aliasListButton = new JButton( "New Alias List ..." );
aliasListButton.addActionListener( new ActionListener()
{
@Override
public void actionPerformed( ActionEvent e )
{
String name = JOptionPane.showInputDialog( aliasListButton,
"Please enter an Alias List name:" );
if( name != null && !name.isEmpty() )
{
AliasList aliasList = new AliasList( name );
mPlaylistManager.getPlayist().getAliasDirectory()
.addAliasList( aliasList );
mPlaylistManager.save();
List<AliasList> lists = mPlaylistManager.getPlayist()
.getAliasDirectory().getAliasList();
Collections.sort( lists );
mAliasListCombo.setModel( new DefaultComboBoxModel<AliasList>(
lists.toArray( new AliasList[ lists.size() ] ) ) );
mAliasListCombo.setSelectedItem( aliasList );
}
}
} );
add( aliasListButton, "growx" );
}
@Override
public void save()
{
if( mChannel != null )
{
mChannel.setName( mChannelName.getText() );
Object system = mSystemNameCombo.getSelectedItem();
mChannel.setSystem( ( system == null ? null : (String)system ) );
Object site = mSiteNameCombo.getSelectedItem();
mChannel.setSystem( ( site == null ? null : (String)site ) );
}
}
@Override
public void validateConfiguration() throws ConfigurationValidationException
{
//System and site can be null, but we must (should?) have a channel name
String name = mChannelName.getText();
if( name == null || name.isEmpty() )
{
throw new ConfigurationValidationException(
mChannelName, "Channel name cannot be empty" );
}
}
@Override
public void setConfiguration( Channel channel )
{
mChannel = channel;
mChannelName.setText( channel.getName() );
List<String> systems = mChannelModel.getSystems();
if( systems.isEmpty() )
{
mSystemNameCombo.setModel( EMPTY_MODEL );
}
else
{
mSystemNameCombo.setModel( new DefaultComboBoxModel<String>(
systems.toArray( new String[ systems.size() ] ) ) );;
}
mSystemNameCombo.setSelectedItem( channel.getSystem() );
List<String> sites = mChannelModel.getSites( channel.getSystem() );
if( sites.isEmpty() )
{
mSiteNameCombo.setModel( EMPTY_MODEL );
}
else
{
mSiteNameCombo.setModel( new DefaultComboBoxModel<String>(
sites.toArray( new String[ sites.size() ] ) ) );;
}
mSiteNameCombo.setSelectedItem( channel.getSite() );
String aliasListName = mChannel.getAliasListName();
if( aliasListName != null )
{
AliasList selected = mPlaylistManager.getPlayist().getAliasDirectory()
.getAliasList( aliasListName );
mAliasListCombo.setSelectedItem( selected );
}
}
}

View File

@@ -0,0 +1,260 @@
/*******************************************************************************
* SDR Trunk
* Copyright (C) 2014 Dennis Sheirer
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>
******************************************************************************/
package controller.channel;
import java.awt.Color;
import java.awt.ComponentOrientation;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.util.Collections;
import java.util.List;
import javax.swing.DefaultComboBoxModel;
import javax.swing.JButton;
import javax.swing.JCheckBox;
import javax.swing.JComboBox;
import javax.swing.JLabel;
import javax.swing.JTextField;
import module.decode.AuxDecodeComponentEditor;
import module.decode.DecodeComponentEditor;
import module.log.EventLogComponentEditor;
import net.miginfocom.swing.MigLayout;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import playlist.PlaylistManager;
import record.RecordComponentEditor;
import source.SourceComponentEditor;
import source.SourceManager;
import alias.AliasList;
import com.jidesoft.swing.JideTabbedPane;
public class OldChannelEditor extends ChannelConfigurationEditor implements ActionListener
{
private final static Logger mLog = LoggerFactory.getLogger( OldChannelEditor.class );
private static final long serialVersionUID = 1L;
private DecodeComponentEditor mDecodeEditor;
private AuxDecodeComponentEditor mAuxDecodeEditor;
private EventLogComponentEditor mEventLogEditor;
private RecordComponentEditor mRecordEditor;
private SourceComponentEditor mSourceEditor;
private JTextField mChannelName;
private JCheckBox mChannelEnabled = new JCheckBox();
private JComboBox<AliasList> mComboAliasLists;
private Channel mChannel;
private ChannelModel mChannelModel;
private PlaylistManager mPlaylistManager;
private SourceManager mSourceManager;
public OldChannelEditor( Channel channel,
ChannelModel channelModel,
PlaylistManager playlistManager,
SourceManager sourceManager )
{
super();
mChannel = channel;
mChannelModel = channelModel;
mPlaylistManager = playlistManager;
mSourceManager = sourceManager;
initGUI();
}
private void initGUI()
{
setLayout( new MigLayout( "fill,wrap 2", "[right,grow][grow]", "[][][][][grow][]" ) );
add( new JLabel( "Channel Configuration" ), "span, align center" );
add( new JLabel( "Enabled:" ) );
mChannelEnabled.setSelected( mChannel.getEnabled() );
mChannelEnabled.setComponentOrientation( ComponentOrientation.RIGHT_TO_LEFT );
add( mChannelEnabled );
add( new JLabel( "Name:" ) );
mChannelName = new JTextField( mChannel.getName() );
add( mChannelName, "growx,push" );
/**
* ComboBox: Alias Lists
*/
add( new JLabel( "Alias List:" ) );
mComboAliasLists = new JComboBox<AliasList>();
List<AliasList> lists = mPlaylistManager.getPlayist()
.getAliasDirectory().getAliasList();
Collections.sort( lists );
mComboAliasLists.setModel( new DefaultComboBoxModel<AliasList>(
lists.toArray( new AliasList[ lists.size() ] ) ) );
String aliasListName = mChannel.getAliasListName();
if( aliasListName != null )
{
AliasList selected = mPlaylistManager.getPlayist().getAliasDirectory()
.getAliasList( aliasListName );
mComboAliasLists.setSelectedItem( selected );
}
add( mComboAliasLists, "growx,push" );
JideTabbedPane tabs = new JideTabbedPane();
tabs.setFont( this.getFont() );
tabs.setForeground( Color.BLACK );
mSourceEditor = new SourceComponentEditor( mSourceManager, mChannel );
tabs.addTab( "Source", mSourceEditor );
mDecodeEditor = new DecodeComponentEditor( mPlaylistManager, mChannel );
tabs.addTab( "Decoder", mDecodeEditor );
mAuxDecodeEditor = new AuxDecodeComponentEditor( mChannel );
tabs.addTab( "Aux", mAuxDecodeEditor );
mEventLogEditor = new EventLogComponentEditor( mChannel );
tabs.addTab( "Event Log", mEventLogEditor );
mRecordEditor = new RecordComponentEditor( mChannel );
tabs.addTab( "Record", mRecordEditor );
add( tabs, "span,grow,push" );
JButton btnSave = new JButton( "Save" );
btnSave.addActionListener( OldChannelEditor.this );
add( btnSave, "growx,push" );
JButton btnReset = new JButton( "Reset" );
btnReset.addActionListener( OldChannelEditor.this );
add( btnReset, "growx,push" );
}
@Override
public void actionPerformed( ActionEvent e )
{
String command = e.getActionCommand();
if( command.contentEquals( "Save" ) )
{
save();
}
else if( command.contentEquals( "Reset" ) )
{
// reset();
}
}
@Override
public void save()
{
// try
// {
// /**
// * Validate the source configuration against the other component
// * configuration editors
// */
// validate( mSourceEditor.getSourceEditor() );
//
// mSourceEditor.save();
// mDecodeEditor.save();
// mAuxDecodeEditor.save();
// mEventLogEditor.save();
// mRecordEditor.save();
//
// mChannel.setName( mChannelName.getText() );
// mChannel.setEnabled( mChannelEnabled.isSelected() );
//
// AliasList selected = mComboAliasLists.getItemAt(
// mComboAliasLists.getSelectedIndex() );
// if( selected != null )
// {
// mChannel.setAliasListName( selected.getName() );
// }
// }
// catch ( ConfigurationValidationException validationException )
// {
// /* ChannelValidationException can be thrown by any of the component
// * editors. Show the validation error text in a popup menu to the
// * user */
// JOptionPane.showMessageDialog( OldChannelEditor.this,
// validationException.getMessage(),
// "Channel Configuration Error",
// JOptionPane.ERROR_MESSAGE );
// }
}
// @Override
// public void reset()
// {
// mChannelName.setText( mChannel.getName() );
// mChannelName.requestFocus();
// mChannelName.requestFocusInWindow();
//
// mChannelEnabled.setSelected( mChannel.getEnabled() );
// mChannelEnabled.requestFocus();
// mChannelEnabled.requestFocusInWindow();
//
// String aliasListName = mChannel.getAliasListName();
//
// if( aliasListName != null )
// {
// AliasList selected = mPlaylistManager.getPlayist().getAliasDirectory()
// .getAliasList( aliasListName );
//
// mComboAliasLists.setSelectedItem( selected );
// }
//
//
// mSourceEditor.reset();
// mDecodeEditor.reset();
// mAuxDecodeEditor.reset();
// mEventLogEditor.reset();
// mRecordEditor.reset();
// }
@Override
public void setConfiguration( Channel channel )
{
}
@Override
public void validateConfiguration() throws ConfigurationValidationException
{
mSourceEditor.validate();
mDecodeEditor.validate();
mAuxDecodeEditor.validate();
mEventLogEditor.validate();
mRecordEditor.validate();
}
}

View File

@@ -23,15 +23,16 @@ import java.awt.event.ActionListener;
import javax.swing.JMenuItem;
import javax.swing.JPopupMenu;
import playlist.PlaylistManager;
import controller.ConfigurableNode;
public class ChannelMapListNode extends ConfigurableNode
{
private static final long serialVersionUID = 1L;
public ChannelMapListNode( ChannelMapList list )
public ChannelMapListNode( PlaylistManager playlistManager, ChannelMapList list )
{
super( list );
super( playlistManager, list );
}
public ChannelMapList getChannelMapList()
@@ -43,7 +44,7 @@ public class ChannelMapListNode extends ConfigurableNode
{
for( ChannelMap channelMap: getChannelMapList().getChannelMap() )
{
ChannelMapNode node = new ChannelMapNode( channelMap );
ChannelMapNode node = new ChannelMapNode( getPlaylistManager(), channelMap );
getModel().addNode( node, ChannelMapListNode.this, getChildCount() );
@@ -72,7 +73,7 @@ public class ChannelMapListNode extends ConfigurableNode
getChannelMapList().addChannelMap( channelMap );
getModel().addNode( new ChannelMapNode( channelMap ),
getModel().addNode( new ChannelMapNode( getPlaylistManager(), channelMap ),
ChannelMapListNode.this,
ChannelMapListNode.this.getChildCount() );

View File

@@ -25,15 +25,16 @@ import javax.swing.JMenuItem;
import javax.swing.JPanel;
import javax.swing.JPopupMenu;
import playlist.PlaylistManager;
import controller.ConfigurableNode;
public class ChannelMapNode extends ConfigurableNode
{
private static final long serialVersionUID = 1L;
public ChannelMapNode( ChannelMap ChannelMap )
public ChannelMapNode( PlaylistManager playlistManager, ChannelMap ChannelMap )
{
super( ChannelMap );
super( playlistManager, ChannelMap );
}
public void init()

View File

@@ -29,26 +29,43 @@ import javax.swing.JPopupMenu;
import javax.swing.JSeparator;
import javax.swing.tree.DefaultMutableTreeNode;
import playlist.PlaylistManager;
import source.SourceManager;
import controller.ConfigurableNode;
import controller.channel.Channel;
import controller.channel.ChannelModel;
import controller.channel.ChannelNode;
import controller.channel.ChannelProcessingManager;
import controller.system.System;
import controller.system.SystemNode;
public class SiteNode extends ConfigurableNode
{
private static final long serialVersionUID = 1L;
private ChannelModel mChannelModel;
private ChannelProcessingManager mChannelProcessingManager;
private SourceManager mSourceManager;
public SiteNode( Site site )
public SiteNode( Site site,
ChannelModel channelModel,
ChannelProcessingManager channelProcessingManager,
PlaylistManager playlistManager,
SourceManager sourceManager )
{
super( site );
super( playlistManager, site );
mChannelModel = channelModel;
mChannelProcessingManager = channelProcessingManager;
mSourceManager = sourceManager;
}
public void init()
{
for( Channel channel: getSite().getChannel() )
{
ChannelNode node = new ChannelNode( channel );
ChannelNode node = new ChannelNode( channel, mChannelModel,
mChannelProcessingManager, getPlaylistManager(), mSourceManager );
getModel().insertNodeInto( node, SiteNode.this, getChildCount() );
@@ -130,7 +147,8 @@ public class SiteNode extends ConfigurableNode
getSite().addChannel( channel );
ChannelNode node = new ChannelNode( channel );
ChannelNode node = new ChannelNode( channel, mChannelModel,
mChannelProcessingManager, getPlaylistManager(), mSourceManager );
getModel().addNode( node,
SiteNode.this,
@@ -139,11 +157,6 @@ public class SiteNode extends ConfigurableNode
sort();
save();
node.show();
/* Give channel reference to the resource manager and the
* channel will register the listeners and send a channel
* add event */
channel.setResourceManager( getModel().getResourceManager() );
}
} );

View File

@@ -23,15 +23,31 @@ import java.awt.event.ActionListener;
import javax.swing.JMenuItem;
import javax.swing.JPopupMenu;
import playlist.PlaylistManager;
import source.SourceManager;
import controller.ConfigurableNode;
import controller.channel.ChannelModel;
import controller.channel.ChannelProcessingManager;
public class SystemListNode extends ConfigurableNode
{
private static final long serialVersionUID = 1L;
public SystemListNode( SystemList list )
private ChannelModel mChannelModel;
private ChannelProcessingManager mChannelProcessingManager;
private SourceManager mSourceManager;
public SystemListNode( SystemList list,
ChannelModel channelModel,
ChannelProcessingManager channelProcessingManager,
PlaylistManager playlistManager,
SourceManager sourceManager )
{
super( list );
super( playlistManager, list );
mChannelModel = channelModel;
mChannelProcessingManager = channelProcessingManager;
mSourceManager = sourceManager;
}
public SystemList getSystemList()
@@ -43,7 +59,8 @@ public class SystemListNode extends ConfigurableNode
{
for( System system: getSystemList().getSystem() )
{
SystemNode node = new SystemNode( system );
SystemNode node = new SystemNode( system, mChannelModel,
mChannelProcessingManager, getPlaylistManager(), mSourceManager );
getModel().addNode( node, SystemListNode.this, getChildCount() );
@@ -72,9 +89,9 @@ public class SystemListNode extends ConfigurableNode
getSystemList().addSystem( system );
getModel().addNode( new SystemNode( system ),
SystemListNode.this,
SystemListNode.this.getChildCount() );
getModel().addNode( new SystemNode( system, mChannelModel,
mChannelProcessingManager, getPlaylistManager(), mSourceManager ),
SystemListNode.this, SystemListNode.this.getChildCount() );
}
} );

View File

@@ -29,7 +29,11 @@ import javax.swing.JPopupMenu;
import javax.swing.JSeparator;
import javax.swing.tree.DefaultMutableTreeNode;
import playlist.PlaylistManager;
import source.SourceManager;
import controller.ConfigurableNode;
import controller.channel.ChannelModel;
import controller.channel.ChannelProcessingManager;
import controller.site.Site;
import controller.site.SiteNode;
@@ -37,16 +41,29 @@ public class SystemNode extends ConfigurableNode
{
private static final long serialVersionUID = 1L;
public SystemNode( System system )
private ChannelModel mChannelModel;
private ChannelProcessingManager mChannelProcessingManager;
private SourceManager mSourceManager;
public SystemNode( System system,
ChannelModel channelModel,
ChannelProcessingManager channelProcessingManager,
PlaylistManager playlistManager,
SourceManager sourceManager )
{
super( system );
super( playlistManager, system );
mChannelModel = channelModel;
mChannelProcessingManager = channelProcessingManager;
mSourceManager = sourceManager;
}
public void init()
{
for( Site site: getSystem().getSite() )
{
SiteNode node = new SiteNode( site );
SiteNode node = new SiteNode( site, mChannelModel,
mChannelProcessingManager, getPlaylistManager(), mSourceManager );
getModel().insertNodeInto( node, SystemNode.this, getChildCount() );
@@ -133,7 +150,8 @@ public class SystemNode extends ConfigurableNode
Site site = new Site();
getSystem().addSite( site );
SiteNode node = new SiteNode( site );
SiteNode node = new SiteNode( site, mChannelModel,
mChannelProcessingManager, getPlaylistManager(), mSourceManager );
getModel().addNode( node,
SystemNode.this,