Work in progress - program compiles and runs

This commit is contained in:
denny
2016-01-02 12:29:40 -05:00
parent d8a20b5adb
commit c405ddad96
36 changed files with 374 additions and 694 deletions

View File

@@ -1,6 +1,6 @@
/*******************************************************************************
* SDR Trunk
* Copyright (C) 2015 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

View File

@@ -9,7 +9,7 @@ import org.slf4j.LoggerFactory;
import sample.Listener;
import alias.Alias;
import controller.ResourceManager;
import controller.ThreadPoolManager;
/**
* Manages all alias action events. Each received message is interrogated for
@@ -23,11 +23,11 @@ public class AliasActionManager implements Listener<Message>
private final static Logger mLog =
LoggerFactory.getLogger( AliasActionManager.class );
private ResourceManager mResourceManager;
private ThreadPoolManager mThreadPoolManager;
public AliasActionManager( ResourceManager resourceManager )
public AliasActionManager( ThreadPoolManager threadPoolManager )
{
mResourceManager = resourceManager;
mThreadPoolManager = threadPoolManager;
}
@Override
@@ -51,8 +51,7 @@ public class AliasActionManager implements Listener<Message>
* action needs to setup a timer, and provide the original
* message to be used as part of the action (e.g. sending
* the message as a text message to a cell phone */
action.execute( mResourceManager.getThreadPoolManager(),
alias, message );
action.execute( mThreadPoolManager, alias, message );
}
}
}

View File

@@ -183,10 +183,10 @@ public class AudioModule extends Module implements IAudioPacketProvider,
{
switch( event.getEvent() )
{
case CHANNEL_STATE_RESET:
case NOTIFICATION_STATE_RESET:
mAudioMetadata.reset();
break;
case CHANGE_SELECTED:
case NOTIFICATION_SELECTION_CHANGE:
mAudioMetadata.setSelected( event.getChannel().isSelected() );
break;
default:

View File

@@ -30,21 +30,14 @@ import javax.swing.tree.TreePath;
import map.IconManager;
import module.decode.DecoderType;
import module.decode.config.DecodeConfigFactory;
import playlist.PlaylistNode;
import source.config.SourceConfigTuner;
import source.tuner.Tuner;
import source.tuner.TunerGroupNode;
import source.tuner.TunerNode;
import source.tuner.TunerSelectionListener;
import controller.channel.Channel;
import controller.channel.ChannelEvent;
import controller.channel.ChannelEvent.Event;
import controller.channel.ChannelModel;
import controller.channel.ChannelNode;
import controller.site.Site;
import controller.system.System;
import controller.system.SystemListNode;
import controller.system.SystemNode;
public class ConfigurationControllerModel extends DefaultTreeModel
{
@@ -62,6 +55,7 @@ public class ConfigurationControllerModel extends DefaultTreeModel
// private RecordingGroupNode mRecordingGroupNode;
private IconManager mIconManagerFrame;
private ChannelModel mChannelModel;
/**
* Implements a merged system controller and (tree) model. The user will
@@ -69,9 +63,12 @@ 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( ResourceManager resourceManager )
public ConfigurationControllerModel( ChannelModel channelModel,
ResourceManager resourceManager )
{
super( new BaseNode( null ) );
mChannelModel = channelModel;
mResourceManager = resourceManager;
@@ -156,7 +153,7 @@ public class ConfigurationControllerModel extends DefaultTreeModel
for( Tuner tuner: tuners )
{
TunerNode child = new TunerNode( tuner );
TunerNode child = new TunerNode( mChannelModel, tuner );
insertNodeInto( child, parent, parent.getChildCount() );
@@ -173,29 +170,30 @@ public class ConfigurationControllerModel extends DefaultTreeModel
*/
public void createChannel( long frequency, DecoderType decoder )
{
System system = new System();
Site site = new Site();
system.addSite( site );
Channel channel = new Channel();
channel.setDecodeConfiguration(
DecodeConfigFactory.getDecodeConfiguration( decoder ) );
SourceConfigTuner sourceConfig = new SourceConfigTuner();
sourceConfig.setFrequency( frequency );
channel.setSourceConfiguration( sourceConfig );
mResourceManager.getChannelManager().channelChanged( new ChannelEvent( channel, Event.CHANNEL_ADDED ) );
channel.setEnabled( true, true );
site.addChannel( channel );
mPlaylistNode.getPlaylist().getSystemList().addSystem( system );
SystemNode systemNode = new SystemNode( system );
SystemListNode systemListNode = mPlaylistNode.getSystemListNode();
addNode( systemNode, systemListNode, systemListNode.getChildCount() );
systemNode.init();
systemNode.save();
throw new UnsupportedOperationException( "This has to be updated to new channel model format" );
// System system = new System();
//
// Site site = new Site();
// system.addSite( site );
//
// Channel channel = new Channel();
// channel.setDecodeConfiguration(
// DecodeConfigFactory.getDecodeConfiguration( decoder ) );
// SourceConfigTuner sourceConfig = new SourceConfigTuner();
// sourceConfig.setFrequency( frequency );
// channel.setSourceConfiguration( sourceConfig );
// mResourceManager.getChannelManager().channelChanged( new ChannelEvent( channel, Event.NOTIFICATION_ADD ) );
// channel.setEnabled( true, true );
// site.addChannel( channel );
//
// mPlaylistNode.getPlaylist().getSystemList().addSystem( system );
//
// SystemNode systemNode = new SystemNode( system );
// SystemListNode systemListNode = mPlaylistNode.getSystemListNode();
// addNode( systemNode, systemListNode, systemListNode.getChildCount() );
// systemNode.init();
//
// systemNode.save();
}
public void addNode( BaseNode child, BaseNode parent, int index )

View File

@@ -42,7 +42,8 @@ import audio.AudioPanel;
import com.jidesoft.swing.JideSplitPane;
import com.jidesoft.swing.JideTabbedPane;
import controller.channel.ChannelManager;
import controller.channel.ChannelModel;
import controller.channel.ChannelProcessingManager;
public class ControllerPanel extends JPanel
{
@@ -67,24 +68,25 @@ public class ControllerPanel extends JPanel
private AudioPanel mAudioPanel;
private MapPanel mMapPanel;
private ChannelManager mChannelManager;
private ChannelModel mChannelModel;
private ConfigurationControllerModel mController;
protected SettingsManager mSettingsManager;
public ControllerPanel( AudioManager audioManager,
ConfigurationControllerModel controller,
ChannelManager channelManager,
ChannelModel channelModel,
ChannelProcessingManager channelProcessingManager,
MapService mapService,
PlaylistManager playlistManager,
SettingsManager settingsManager )
{
mChannelManager = channelManager;
mChannelModel = channelModel;
mController = controller;
mSettingsManager = settingsManager;
mAudioPanel = new AudioPanel( mSettingsManager, audioManager );
mMapPanel = new MapPanel( mapService, mSettingsManager, mChannelManager );
mMapPanel = new MapPanel( mapService, mSettingsManager, channelProcessingManager );
mCallEventPanel = new CallEventPanel( mSettingsManager );
@@ -120,6 +122,10 @@ 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 );
/**
* Change listener to enable/disable the channel spectrum display
@@ -152,10 +158,10 @@ public class ControllerPanel extends JPanel
/* Register each of the components to receive channel events when the
* channels are selected or change */
mChannelManager.addListener( mCallEventPanel );
mChannelManager.addListener( mChannelStateList );
mChannelManager.addListener( mChannelSpectrumPanel );
mChannelManager.addListener( mMessageActivityPanel );
mChannelModel.addListener( mCallEventPanel );
mChannelModel.addListener( mChannelStateList );
mChannelModel.addListener( mChannelSpectrumPanel );
mChannelModel.addListener( mMessageActivityPanel );
JScrollPane channelStateListScroll = new JScrollPane();
channelStateListScroll.getViewport().setView( mChannelStateList );

View File

@@ -26,7 +26,7 @@ import source.SourceManager;
import source.recording.RecordingSourceManager;
import source.tuner.TunerManager;
import audio.AudioManager;
import controller.channel.ChannelManager;
import controller.channel.ChannelModel;
/**
* Manager for system wide resources
@@ -34,7 +34,6 @@ import controller.channel.ChannelManager;
public class ResourceManager
{
private AudioManager mAudioManager;
private ChannelManager mChannelManager;
private EventLogManager mEventLogManager;
private PlaylistManager mPlaylistManager;
private RecorderManager mRecorderManager;
@@ -46,17 +45,24 @@ public class ResourceManager
private MapService mMapService;
private ThreadPoolManager mThreadPoolManager;
public ResourceManager()
public ResourceManager( PlaylistManager playlistManager,
ThreadPoolManager threadPoolManager,
ChannelModel channelModel )
{
this( new SettingsManager(),
new PlaylistManager(),
new EventLogManager() );
this( threadPoolManager,
new SettingsManager(),
playlistManager,
new EventLogManager(),
channelModel );
}
public ResourceManager( SettingsManager settingsManager,
public ResourceManager( ThreadPoolManager threadPoolManager,
SettingsManager settingsManager,
PlaylistManager playlistManager,
EventLogManager eventLogManager )
EventLogManager eventLogManager,
ChannelModel channelModel )
{
mThreadPoolManager = threadPoolManager;
mSettingsManager = settingsManager;
mPlaylistManager = playlistManager;
mEventLogManager = eventLogManager;
@@ -65,14 +71,12 @@ public class ResourceManager
* ChannelManager requires a reference to the ResourceManager so that
* channel processing chains can access system wide resources
*/
mThreadPoolManager = new ThreadPoolManager();
mAudioManager = new AudioManager( mThreadPoolManager );
mRecorderManager = new RecorderManager( mThreadPoolManager );
mChannelManager = new ChannelManager( this );
mSourceManager = new SourceManager( this );
mRecordingSourceManager = new RecordingSourceManager( this );
mTunerManager = new TunerManager( this );
mController = new ConfigurationControllerModel( this );
mController = new ConfigurationControllerModel( channelModel, this );
mMapService = new MapService( this );
}
@@ -170,14 +174,4 @@ public class ResourceManager
{
mRecordingSourceManager = manager;
}
public ChannelManager getChannelManager()
{
return mChannelManager;
}
public void setChannelManager( ChannelManager channelManager )
{
mChannelManager = channelManager;
}
}

View File

@@ -17,12 +17,7 @@
******************************************************************************/
package controller.channel;
import java.util.Collection;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.concurrent.CopyOnWriteArrayList;
import javax.xml.bind.annotation.XmlAttribute;
import javax.xml.bind.annotation.XmlElement;
@@ -49,7 +44,6 @@ import org.slf4j.LoggerFactory;
import record.RecorderManager;
import record.RecorderType;
import record.config.RecordConfiguration;
import sample.Listener;
import source.Source;
import source.SourceException;
import source.SourceType;
@@ -63,10 +57,7 @@ import alias.AliasList;
import audio.metadata.Metadata;
import audio.metadata.MetadataType;
import controller.ResourceManager;
import controller.channel.ChannelEvent.Event;
import controller.config.Configuration;
import controller.site.Site;
import controller.system.System;
import filter.FilterSet;
@XmlSeeAlso( { Configuration.class } )
@@ -75,9 +66,7 @@ public class Channel extends Configuration
{
private final static Logger mLog = LoggerFactory.getLogger( Channel.class );
private static final boolean ENABLED = true;
private static final boolean DISABLED = false;
private static final boolean BROADCAST_CHANGE = true;
public enum ChannelType
{
@@ -85,15 +74,6 @@ public class Channel extends Configuration
TRAFFIC
};
private CopyOnWriteArrayList<ChannelEventListener> mChannelListeners =
new CopyOnWriteArrayList<ChannelEventListener>();
private CopyOnWriteArrayList<Listener<Message>> mMessageListeners =
new CopyOnWriteArrayList<Listener<Message>>();
private Map<String,Channel> mTrafficChannels = new HashMap<>();
private DecodeConfiguration mDecodeConfiguration =
DecodeConfigFactory.getDefaultDecodeConfiguration();
private AuxDecodeConfiguration mAuxDecodeConfiguration =
@@ -106,19 +86,19 @@ public class Channel extends Configuration
private ResourceManager mResourceManager;
private String mAliasListName;
private System mSystem;
private Site mSite;
private String mSystem;
private String mSite;
private String mName;
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 ChannelState mChannelState;
private long mTrafficChannelTimeout =
DecodeConfiguration.DEFAULT_CALL_TIMEOUT_SECONDS;
@@ -191,13 +171,12 @@ public class Channel extends Configuration
* Note: resource manager instance is applied after object construction
* since we construct the channel objects from the xml playlist
*/
//TODO: remove this
public void setResourceManager( ResourceManager resourceManager )
{
mResourceManager = resourceManager;
/* Add system-wide channel listeners onto this channel */
addListeners( mResourceManager.getChannelManager().getChannelListeners() );
/* If we're enabled, fire enable changed event to get processing started */
if( mEnabled )
{
@@ -205,6 +184,7 @@ public class Channel extends Configuration
}
}
//TODO: remove this
@XmlTransient
public ResourceManager getResourceManager()
{
@@ -242,8 +222,6 @@ public class Channel extends Configuration
public void setSelected( boolean selected )
{
mSelected = selected;
fireChannelEvent( Event.CHANGE_SELECTED );
}
@XmlTransient
@@ -293,10 +271,7 @@ public class Channel extends Configuration
*/
public void dispose()
{
setEnabled( DISABLED, BROADCAST_CHANGE );
/* Broadcast channel deleted event */
fireChannelEvent( Event.CHANNEL_DELETED );
setEnabled( DISABLED );
}
/**
@@ -306,28 +281,8 @@ public class Channel extends Configuration
{
StringBuilder sb = new StringBuilder();
if( mSystem != null )
{
sb.append( mSystem.getName() );
}
else
{
sb.append( "-" );
}
sb.append( "/" );
if( mSite != null )
{
sb.append( mSite.getName() );
}
else
{
sb.append( "-" );
}
sb.append( "/" );
sb.append( ( mSystem == null ? "-" : mSystem ) );
sb.append( ( mSite == null ? "-" : mSite ) );
sb.append( mName );
return sb.toString();
@@ -366,57 +321,41 @@ public class Channel extends Configuration
/**
* Returns the owning system for this channel.
*/
public System getSystem()
@XmlAttribute( name = "system" )
public String getSystem()
{
return mSystem;
}
public void setSystem( String system )
{
mSystem = system;
}
public boolean hasSystem()
{
return mSystem != null;
}
/**
* Sets the owning system for this channel and optionally broadcasts a
* system change channel event.
*/
public void setSystem( System system, boolean fireChangeEvent )
{
mSystem = system;
if( fireChangeEvent )
{
fireChannelEvent( Event.CHANGE_SYSTEM );
}
}
/**
* Returns the owning site for this channel.
*/
public Site getSite()
@XmlAttribute( name = "site" )
public String getSite()
{
return mSite;
}
public void setSite( String site )
{
mSite = site;
}
public boolean hasSite()
{
return mSite != null;
}
/**
* Sets the owning site for this channel and optionally broadcasts a site
* change channel event.
*/
public void setSite( Site site, boolean fireChangeEvent )
{
mSite = site;
if( fireChangeEvent )
{
fireChannelEvent( Event.CHANGE_SITE );
}
}
/**
* Default display string for this channel -- the channel name.
*/
@@ -444,28 +383,6 @@ public class Channel extends Configuration
enableChanged();
}
/**
* Enables/disables this channel for processing. Automatically starts or
* stops channel processing in response to this change. Optionally
* broadcasts a enabled change channel event.
*/
public void setEnabled( boolean enabled, boolean fireChannelEvent )
{
setEnabled( enabled );
if( fireChannelEvent )
{
if( enabled )
{
fireChannelEvent( Event.CHANNEL_ENABLED );
}
else
{
fireChannelEvent( Event.CHANNEL_DISABLED );
}
}
}
/**
* Returns the alias list that is used by this channel for looking up alias
@@ -485,22 +402,6 @@ public class Channel extends Configuration
{
mAliasListName = name;
}
/**
* Sets the alias list to be used for looking up the alias values for the
* various identifiers produced by the decoder. This method is the same
* as setAliasName(name) and optionally broadcasts an alias list change
* channel event.
*/
public void setAliasListName( String name, boolean fireChangeEvent )
{
mAliasListName = name;
if( fireChangeEvent )
{
fireChannelEvent( Event.CHANGE_ALIAS_LIST );
}
}
/**
* Gets the decoder configuration used by this channel
@@ -536,21 +437,6 @@ public class Channel extends Configuration
mAuxDecodeConfiguration = config;
}
/**
* Sets the decoder configuration used by this channel and optionally
* broadcasts a decoder change channel event.
*/
public void setDecodeConfiguration( DecodeConfiguration config,
boolean fireChangeEvent )
{
setDecodeConfiguration( config );
if( fireChangeEvent )
{
fireChannelEvent( Event.CHANGE_DECODER );
}
}
/**
* Returns the source configuration for this channel.
*/
@@ -568,21 +454,6 @@ public class Channel extends Configuration
mSourceConfiguration = config;
}
/**
* Sets the source configuration for this channel and optionally broadcasts
* a source change channel event.
*/
public void setSourceConfiguration( SourceConfiguration config,
boolean fireChangeEvent )
{
setSourceConfiguration( config );
if( fireChangeEvent )
{
fireChannelEvent( Event.CHANGE_SOURCE );
}
}
/**
* Returns the event logger configuration for this channel.
*/
@@ -600,21 +471,6 @@ public class Channel extends Configuration
mEventLogConfiguration = config;
}
/**
* Sets the event logger configuration for this channel and optionally
* broadcasts an event logger change channel event.
*/
public void setEventLogConfiguration( EventLogConfiguration config,
boolean fireChangeEvent )
{
setEventLogConfiguration( config );
if( fireChangeEvent )
{
fireChannelEvent( Event.CHANGE_EVENT_LOGGER );
}
}
/**
* Returns the recorder configuration for this channel.
*/
@@ -632,21 +488,6 @@ public class Channel extends Configuration
mRecordConfiguration = config;
}
/**
* Sets the recorder configuration for this channel and optionally broadcasts
* a recorder configuration change channel event.
*/
public void setRecordConfiguration( RecordConfiguration config,
boolean fireChangeEvent )
{
setRecordConfiguration( config );
if( fireChangeEvent )
{
fireChannelEvent( Event.CHANGE_RECORDER );
}
}
/**
* Returns the name of this channel.
*/
@@ -664,20 +505,6 @@ public class Channel extends Configuration
mName = name;
}
/**
* Sets the name of this channel and optionally broadcasts a name change
* channel event.
*/
public void setName( String name, boolean fireChangeEvent )
{
mName = name;
if( fireChangeEvent )
{
fireChannelEvent( Event.CHANGE_NAME );
}
}
/**
* Responds to changes in the enabled setting by starting the processing
* change if the channel is now enabled, or stopping the procesing chain
@@ -709,8 +536,6 @@ public class Channel extends Configuration
setup();
mProcessingChain.start();
fireChannelEvent( Event.CHANNEL_PROCESSING_STARTED );
}
catch( SourceException se )
{
@@ -837,13 +662,6 @@ public class Channel extends Configuration
mProcessingChain.addAudioPacketListener(
mResourceManager.getAudioManager() );
/* Add system-wide message listeners */
mProcessingChain.addMessageListeners(
mResourceManager.getChannelManager().getMessageListeners() );
/* Add individual message listeners */
mProcessingChain.addMessageListeners( mMessageListeners );
/* Create the call event model to receive call events */
mCallEventModel = new CallEventModel();
mProcessingChain.addCallEventListener( mCallEventModel );
@@ -855,9 +673,9 @@ public class Channel extends Configuration
/* Inject channel metadata that will be inserted into audio packets
* for the recorder manager and streaming */
mProcessingChain.broadcast(
new Metadata( MetadataType.SYSTEM, mSystem.getName() ) );
new Metadata( MetadataType.SYSTEM, mSystem ) );
mProcessingChain.broadcast(
new Metadata( MetadataType.SITE_ID, mSite.getName() ) );
new Metadata( MetadataType.SITE_ID, mSite ) );
mProcessingChain.broadcast(
new Metadata( MetadataType.CHANNEL_NAME, mName ) );
}
@@ -914,86 +732,6 @@ public class Channel extends Configuration
}
}
/**
* Broadcasts a channel change event to all registered listeners
*/
public void fireChannelEvent( Event event )
{
ChannelEvent channelEvent = new ChannelEvent( this, event );
for( ChannelEventListener listener: mChannelListeners )
{
listener.channelChanged( channelEvent );
}
/* Send event to processing chain so modules can respond to channel
* selection events */
if( mProcessingChain != null )
{
mProcessingChain.getChannelEventListener().receive( channelEvent );
}
}
/**
* Adds a channel listener to receive all channel events from this channel
* and automatically sends the listener a channel add event.
*/
public void addListener( ChannelEventListener listener )
{
if( !mChannelListeners.contains( listener ) )
{
mChannelListeners.add( listener );
listener.channelChanged(
new ChannelEvent( this, Event.CHANNEL_ADDED ) );
}
else
{
mLog.error( "Channel - attempt to add already existing channel "
+ "listener [" + listener.getClass() + "]" );
}
}
/**
* Adds a list of channel listeners to receive all channel events from this
* channel and automatically sends each one a channel add event.
*/
public void addListeners( List<ChannelEventListener> listeners )
{
for( ChannelEventListener listener: listeners )
{
addListener( listener );
}
}
/**
* Removes a channel listener from receiving channel events from this channel
*/
public void removeListener( ChannelEventListener listener )
{
mChannelListeners.remove( listener );
}
public void addListener( Listener<Message> listener )
{
mMessageListeners.add( listener );
if( isProcessing() )
{
mProcessingChain.addMessageListener( listener );
}
}
public void removeListener( Listener<Message> listener )
{
mMessageListeners.remove( listener );
if( mProcessingChain != null )
{
mProcessingChain.removeMessageListener( listener );
}
}
/**
* Indicates if any part of this channel is contained within the
* minimum and maximum frequency values.
@@ -1005,35 +743,4 @@ public class Channel extends Configuration
return tunerChannel != null &&
tunerChannel.overlaps( minimum, maximum );
}
public void addTrafficChannel( String channelID, Channel channel )
{
mTrafficChannels.put( channelID, channel );
}
public boolean hasTrafficChannel( Channel channel )
{
return mTrafficChannels.containsValue( channel );
}
public void removeTrafficChannel( Channel channel )
{
String name = channel.getChannelDisplayName();
if( mTrafficChannels.containsKey( name ) )
{
mTrafficChannels.remove( name );
}
}
public Collection<Channel> getTrafficChannels()
{
return Collections.unmodifiableCollection( mTrafficChannels.values() );
}
public boolean hasTrafficChannel( String name )
{
return mTrafficChannels.containsKey( name );
}
}

View File

@@ -200,14 +200,14 @@ public class ChannelEditor extends Editor implements ActionListener
mEventLogEditor.save();
mRecordEditor.save();
mChannelNode.getChannel().setName( mChannelName.getText(), false );
mChannelNode.getChannel().setEnabled( mChannelEnabled.isSelected(), false );
mChannelNode.getChannel().setName( mChannelName.getText() );
mChannelNode.getChannel().setEnabled( mChannelEnabled.isSelected() );
AliasList selected = mComboAliasLists.getItemAt(
mComboAliasLists.getSelectedIndex() );
if( selected != null )
{
mChannelNode.getChannel().setAliasListName( selected.getName(), false );
mChannelNode.getChannel().setAliasListName( selected.getName() );
}

View File

@@ -1,3 +1,20 @@
/*******************************************************************************
* 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 controller.channel;
public class ChannelEvent
@@ -27,33 +44,33 @@ public class ChannelEvent
}
/**
* Channel Events - used to specify channel events and changes to channel
* configurations and settings.
* Channel events to describe the specific event
*/
public enum Event
{
CHANGE_ALIAS_LIST,
CHANGE_DECODER,
CHANGE_EVENT_LOGGER,
CHANGE_NAME,
CHANGE_SELECTED,
CHANGE_SITE,
CHANGE_RECORDER,
CHANGE_SOURCE,
CHANGE_SYSTEM,
CHANNEL_ADDED,
CHANNEL_DELETED,
CHANNEL_ENABLED,
CHANNEL_DISABLED,
CHANNEL_PROCESSING_STARTED,
CHANNEL_PROCESSING_STOPPED,
CHANNEL_STATE_RESET,
TRAFFIC_CHANNEL_ADDED,
TRAFFIC_CHANNEL_DELETED;
//Channel is added
NOTIFICATION_ADD,
//Channel configuration has changed
NOTIFICATION_CONFIGURATION_CHANGE,
//Channel is deleted/removed
NOTIFICATION_DELETE,
//Channel enable request was rejected
NOTIFICATION_ENABLE_REJECTED,
//Channel has started processing/decoding
NOTIFICATION_PROCESSING_START,
//Channel has stopped processing/decoding
NOTIFICATION_PROCESSING_STOP,
//Channel's selection state has changed
NOTIFICATION_SELECTION_CHANGE,
//Channel's channel-state has been reset
NOTIFICATION_STATE_RESET,
//Request to deselect the channel
REQUEST_DESELECT,
//Request to disable a channel - response will be a PROCESSING_STOP_NOTIFICATION
REQUEST_DISABLE,
//Request to enable a channel - response will be a PROCESSING_START_NOTIFICATION
REQUEST_ENABLE,
//Request to select the channel
REQUEST_SELECT;
}
}

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

View File

@@ -1,143 +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 controller.channel;
import java.util.ArrayList;
import java.util.List;
import message.Message;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import sample.Listener;
import alias.action.AliasActionManager;
import controller.ResourceManager;
public class ChannelManager implements ChannelEventListener
{
private final static Logger mLog = LoggerFactory.getLogger( ChannelManager.class );
private List<Channel> mChannels = new ArrayList<>();
private List<ChannelEventListener> mChannelListeners = new ArrayList<>();
private List<Listener<Message>> mMessageListeners = new ArrayList<>();
private AliasActionManager mAliasActionManager;
public ChannelManager( ResourceManager resourceManager )
{
mAliasActionManager = new AliasActionManager( resourceManager );
mChannelListeners.add( this );
/* Add alias action manager as listener to all channels/messages */
mMessageListeners.add( mAliasActionManager );
}
/**
* Notification that a channel has been added or deleted, so that we can
* keep track of all channels and manage system-wide listeners for each
* of those channels
*/
@SuppressWarnings( "incomplete-switch" )
@Override
public void channelChanged( ChannelEvent event )
{
switch( event.getEvent() )
{
case CHANNEL_ADDED:
if( !mChannels.contains( event.getChannel() ) )
{
mChannels.add( event.getChannel() );
}
break;
case CHANNEL_DELETED:
mChannels.remove( event.getChannel() );
break;
}
}
/**
* Adds a channel listener that will be added to all channels to receive
* any channel change events. This listener will automatically receive
* a channel add event as it is added to each of the existing channels.
*/
public void addListener( ChannelEventListener listener )
{
mChannelListeners.add( listener );
for( Channel channel: mChannels )
{
channel.addListener( listener );
}
}
public List<Channel> getChannels()
{
return mChannels;
}
/**
* Removes a channel listener from being automatically added to all channels
* to receive channel change events.
*/
public void removeListener( ChannelEventListener listener )
{
mChannelListeners.remove( listener );
for( Channel channel: mChannels )
{
channel.removeListener( listener );
}
}
/**
* Returns the list of channel change listeners that will be automatically
* added to all channels to receive channel change events
*/
public List<ChannelEventListener> getChannelListeners()
{
return mChannelListeners;
}
/**
* Returns the list of channel change listeners that will be automatically
* added to all channels to receive channel change events
*/
public List<Listener<Message>> getMessageListeners()
{
return mMessageListeners;
}
/**
* Adds a message listener that will be added to all channels to receive
* any messages.
*/
public void addListener( Listener<Message> listener )
{
mMessageListeners.add( listener );
}
/**
* Removes a message listener.
*/
public void removeListener( Listener<Message> listener )
{
mMessageListeners.remove( listener );
}
}

View File

@@ -56,18 +56,18 @@ public class ChannelNode extends ConfigurableNode implements ChannelEventListene
if( siteNode != null )
{
getChannel().setSite( siteNode.getSite(), false );
getChannel().setSite( siteNode.getSite().getName() );
SystemNode systemNode = (SystemNode)siteNode.getParent();
if( systemNode != null )
{
getChannel().setSystem( systemNode.getSystem(), false );
getChannel().setSystem( systemNode.getSystem().getName() );
}
}
/* Add this node as listener to receive changes from underlying channel */
getChannel().addListener( this );
// getChannel().addListener( this );
/* Add the resource manager to the channel so that the channel
* can provide channel change events to all system resources */
@@ -83,19 +83,13 @@ public class ChannelNode extends ConfigurableNode implements ChannelEventListene
switch( event.getEvent() )
{
/* Refresh the node for each of these events */
case CHANGE_DECODER:
case CHANGE_NAME:
case CHANGE_SELECTED:
case CHANGE_SITE:
case CHANGE_SYSTEM:
case CHANNEL_ENABLED:
case CHANNEL_DISABLED:
case CHANNEL_PROCESSING_STARTED:
case CHANNEL_PROCESSING_STOPPED:
case NOTIFICATION_SELECTION_CHANGE:
case NOTIFICATION_PROCESSING_START:
case NOTIFICATION_PROCESSING_STOP:
this.refresh();
break;
/* We're being deleted, so cleanup */
case CHANNEL_DELETED:
case NOTIFICATION_DELETE:
delete();
break;
default:

View File

@@ -39,7 +39,7 @@ public class ChannelUtils
@Override
public void actionPerformed( ActionEvent e )
{
channel.setEnabled( DISABLED, BROADCAST_CHANGE );
channel.setEnabled( DISABLED );
if( playlistManager != null )
{
@@ -82,7 +82,7 @@ public class ChannelUtils
@Override
public void actionPerformed( ActionEvent e )
{
channel.setEnabled( ENABLED, BROADCAST_CHANGE );
channel.setEnabled( ENABLED );
if( playlistManager != null )
{
@@ -109,10 +109,10 @@ public class ChannelUtils
if( response == JOptionPane.YES_OPTION )
{
/* Disable the channel */
channel.setEnabled( DISABLED, BROADCAST_CHANGE );
channel.setEnabled( DISABLED );
/* Broadcast channel deleted event */
channel.fireChannelEvent( Event.CHANNEL_DELETED );
// channel.fireChannelEvent( Event.NOTIFICATION_DELETE );
if( playlistManager != null )
{

View File

@@ -125,8 +125,8 @@ public class SiteNode extends ConfigurableNode
System system = ((SystemNode)getParent()).getSystem();
Channel channel = new Channel();
channel.setSystem( system, false );
channel.setSite( getSite(), false );
channel.setSystem( system.getName() );
channel.setSite( getSite().getName() );
getSite().addChannel( channel );

View File

@@ -5,6 +5,7 @@ import java.text.NumberFormat;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import controller.channel.Channel.ChannelType;
import controller.channel.ChannelEvent;
import controller.channel.ChannelEventListener;
@@ -46,33 +47,40 @@ public class ChannelMemoryLogger implements Runnable, ChannelEventListener
{
switch( event.getEvent() )
{
case CHANNEL_ADDED:
mChannelCount++;
case NOTIFICATION_ADD:
if( event.getChannel().getChannelType() == ChannelType.TRAFFIC )
{
mTrafficChannelCount++;
}
else
{
mChannelCount++;
}
break;
case CHANNEL_DELETED:
mChannelCount--;
case NOTIFICATION_DELETE:
if( event.getChannel().getChannelType() == ChannelType.TRAFFIC )
{
mTrafficChannelCount--;
}
else
{
mChannelCount--;
}
break;
case CHANNEL_DISABLED:
case REQUEST_DISABLE:
break;
case CHANNEL_ENABLED:
case REQUEST_ENABLE:
break;
case CHANNEL_PROCESSING_STARTED:
case NOTIFICATION_PROCESSING_START:
mChannelProcessingCount++;
break;
case CHANNEL_PROCESSING_STOPPED:
case NOTIFICATION_PROCESSING_STOP:
mChannelProcessingCount--;
break;
case CHANNEL_STATE_RESET:
break;
case TRAFFIC_CHANNEL_ADDED:
mTrafficChannelCount++;
break;
case TRAFFIC_CHANNEL_DELETED:
mTrafficChannelCount--;
case NOTIFICATION_STATE_RESET:
break;
default:
break;
}
}
}

View File

@@ -56,6 +56,7 @@ import source.tuner.Tuner;
import source.tuner.TunerSelectionListener;
import spectrum.SpectralDisplayPanel;
import util.TimeStamp;
import alias.action.AliasActionManager;
import audio.AudioManager;
import com.jidesoft.swing.JideSplitPane;
@@ -63,9 +64,12 @@ import com.jidesoft.swing.JideSplitPane;
import controller.ConfigurationControllerModel;
import controller.ControllerPanel;
import controller.ResourceManager;
import controller.ThreadPoolManager;
import controller.ThreadPoolManager.ThreadType;
import controller.channel.ChannelEventListener;
import controller.channel.ChannelManager;
import controller.channel.ChannelModel;
import controller.channel.ChannelProcessingManager;
import controller.channel.ChannelSelectionManager;
public class SDRTrunk
{
@@ -104,27 +108,48 @@ public class SDRTrunk
//Log current properties setting
SystemProperties.getInstance().logCurrentSettings();
ChannelModel channelModel = new ChannelModel();
ChannelProcessingManager channelProcessingManager =
new ChannelProcessingManager( channelModel );
channelModel.addListener( channelProcessingManager );
ThreadPoolManager threadPoolManager = new ThreadPoolManager();
AliasActionManager aliasActionManager = new AliasActionManager( threadPoolManager );
channelProcessingManager.addListener( aliasActionManager );
ChannelSelectionManager channelSelectionManager =
new ChannelSelectionManager( channelModel );
channelModel.addListener( channelSelectionManager );
/**
* Construct the resource manager now, so that it can use the system
* properties that were just loaded
*/
ResourceManager resource = new ResourceManager();
//TODO: get rid of resource manager ... below is start of breaking out
//the encapsulated pieces from the resource manager
PlaylistManager playlistManager = new PlaylistManager( channelModel );
ResourceManager resource =
new ResourceManager( playlistManager, threadPoolManager, channelModel );
AudioManager audio = resource.getAudioManager();
ChannelManager channel = resource.getChannelManager();
ConfigurationControllerModel controller = resource.getController();
ConfigurationControllerModel configurationControllerModel = resource.getController();
MapService map = resource.getMapService();
PlaylistManager playlist = resource.getPlaylistManager();
SettingsManager settings = resource.getSettingsManager();
mControllerPanel = new ControllerPanel( audio, controller, channel,
map, playlist, settings );
mControllerPanel =
new ControllerPanel( audio,
configurationControllerModel,
channelModel,
channelProcessingManager,
map,
playlistManager,
settings );
mSpectralPanel = new SpectralDisplayPanel( channel, controller,
playlist, settings );
mSpectralPanel = new SpectralDisplayPanel( channelModel,
configurationControllerModel, playlistManager, settings );
mTitle = getTitle();
@@ -136,7 +161,7 @@ public class SDRTrunk
if( mLogChannelAndMemoryUsage )
{
Runnable cml = new ChannelMemoryLogger();
resource.getChannelManager().addListener( (ChannelEventListener)cml );
channelModel.addListener( (ChannelEventListener)cml );
resource.getThreadPoolManager().scheduleFixedRate(
ThreadType.DECODER, cml, 5, TimeUnit.SECONDS );
}

View File

@@ -11,15 +11,18 @@ import javax.swing.JInternalFrame;
import module.decode.DecodeComponentEditor;
import module.decode.config.DecodeConfiguration;
import net.miginfocom.swing.MigLayout;
import playlist.PlaylistManager;
import source.IControllableFileSource;
import controller.ResourceManager;
import controller.ThreadPoolManager;
import controller.channel.ChannelModel;
public class DecoderSelectionFrame extends JInternalFrame
{
private static final long serialVersionUID = 1L;
private DecodeComponentEditor mDecodeEditor = new DecodeComponentEditor( null );
private ResourceManager mResourceManager = new ResourceManager();
private ResourceManager mResourceManager;
private IControllableFileSource mSource;
private JDesktopPane mDesktop;
@@ -27,6 +30,11 @@ public class DecoderSelectionFrame extends JInternalFrame
public DecoderSelectionFrame( JDesktopPane desktop,
IControllableFileSource source )
{
ChannelModel channelModel = new ChannelModel();
mResourceManager = new ResourceManager( new PlaylistManager( channelModel ),
new ThreadPoolManager(), channelModel );
mDesktop = desktop;
mSource = source;

View File

@@ -108,8 +108,8 @@ public class DecoderViewFrame extends JInternalFrame
recordConfig,
auxConfig,
aliasList,
new System( "Instrumented" ),
new Site( "Instrumented" ),
"Instrumented",
"Instrumented",
"Channel Name" );
mProcessingChain.addModules( modules );

View File

@@ -35,7 +35,7 @@ import org.jdesktop.swingx.mapviewer.TileFactoryInfo;
import sample.Listener;
import settings.MapViewSetting;
import settings.SettingsManager;
import controller.channel.ChannelManager;
import controller.channel.ChannelProcessingManager;
public class MapPanel extends JPanel implements PlottableUpdateListener
{
@@ -48,14 +48,14 @@ public class MapPanel extends JPanel implements PlottableUpdateListener
public MapPanel( MapService mapService,
SettingsManager settingsManager,
ChannelManager channelManager )
ChannelProcessingManager channelProcessingManager )
{
mSettingsManager = settingsManager;
mMapService = mapService;
mMapPainter = new PlottableEntityPainter( mSettingsManager );
/* Add Map Service as message listener to receive all messages */
channelManager.addListener( (Listener<Message>)mMapService );
channelProcessingManager.addListener( (Listener<Message>)mMapService );
init();
}

View File

@@ -156,7 +156,7 @@ public class DecodeComponentEditor extends AbstractChannelEditor
//The component that calls save will invoke the change broadcast
mChannelNode.getChannel()
.setDecodeConfiguration( mEditor.getConfig(), false );
.setDecodeConfiguration( mEditor.getConfig() );
}
/**

View File

@@ -135,8 +135,8 @@ public class DecoderFactory
RecordConfiguration recordConfig,
AuxDecodeConfiguration auxConfig,
AliasList aliasList,
System system,
Site site,
String system,
String site,
String channelName )
{
List<Module> modules = getPrimaryModules( channelType, decodeConfig,
@@ -176,8 +176,8 @@ public class DecoderFactory
DecodeConfiguration decodeConfig,
RecordConfiguration recordConfig,
AliasList aliasList,
System system,
Site site,
String system,
String site,
String channelName,
ResourceManager resourceManager )
{

View File

@@ -62,7 +62,7 @@ public class CallEventPanel extends JPanel implements ChannelEventListener
@Override
public void channelChanged( final ChannelEvent event )
{
if( event.getEvent() == Event.CHANGE_SELECTED &&
if( event.getEvent() == Event.NOTIFICATION_SELECTION_CHANGE &&
event.getChannel().isSelected() )
{
if( mDisplayedChannel == null ||
@@ -99,8 +99,8 @@ public class CallEventPanel extends JPanel implements ChannelEventListener
}
}
else if( event.getEvent() == Event.CHANNEL_PROCESSING_STOPPED ||
event.getEvent() == Event.CHANNEL_DISABLED )
else if( event.getEvent() == Event.NOTIFICATION_PROCESSING_STOP ||
event.getEvent() == Event.REQUEST_DISABLE )
{
if( mDisplayedChannel != null &&
mDisplayedChannel == event.getChannel() )

View File

@@ -82,7 +82,7 @@ public class MessageActivityPanel extends JPanel implements ChannelEventListener
{
boolean changed = false;
if( event.getEvent() == Event.CHANGE_SELECTED &&
if( event.getEvent() == Event.NOTIFICATION_SELECTION_CHANGE &&
event.getChannel().isSelected() )
{
if( mDisplayedChannel == null ||
@@ -105,8 +105,8 @@ public class MessageActivityPanel extends JPanel implements ChannelEventListener
changed = true;
}
}
else if( event.getEvent() == Event.CHANNEL_PROCESSING_STOPPED ||
event.getEvent() == Event.CHANNEL_DISABLED )
else if( event.getEvent() == Event.NOTIFICATION_PROCESSING_STOP ||
event.getEvent() == Event.REQUEST_DISABLE )
{
if( mDisplayedChannel != null &&
mDisplayedChannel == event.getChannel() )

View File

@@ -232,10 +232,10 @@ public class P25AudioModule extends Module implements Listener<Message>,
{
switch( event.getEvent() )
{
case CHANNEL_STATE_RESET:
case NOTIFICATION_STATE_RESET:
mAudioMetadata.reset();
break;
case CHANGE_SELECTED:
case NOTIFICATION_SELECTION_CHANGE:
mAudioMetadata.setSelected( event.getChannel().isSelected() );
break;
default:

View File

@@ -81,10 +81,10 @@ public class ChannelList extends JPanel implements ChannelEventListener
{
switch( event.getEvent() )
{
case CHANNEL_PROCESSING_STARTED:
case NOTIFICATION_PROCESSING_START:
addChannelPanel( event.getChannel() );
break;
case CHANNEL_PROCESSING_STOPPED:
case NOTIFICATION_PROCESSING_STOP:
removeChannelPanel( event.getChannel() );
break;
default:

View File

@@ -111,12 +111,12 @@ public class ChannelStatePanel extends JPanel
setLayout( new MigLayout( "insets 1 1 1 1", "[grow,fill]", "[]0[]0[]") );
mSystemLabel = new JLabel( mChannel.getSystem().getName() );
mSystemLabel = new JLabel( mChannel.getSystem() );
mSystemLabel.setFont( mFontDetails );
mSystemLabel.setForeground( mColorLabelDetails );
add( mSystemLabel );
mSiteLabel = new JLabel( mChannel.getSite().getName() );
mSiteLabel = new JLabel( mChannel.getSite() );
mSiteLabel.setFont( mFontDetails );
mSiteLabel.setForeground( mColorLabelDetails );
add( mSiteLabel );

View File

@@ -15,7 +15,6 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import record.config.RecordConfiguration;
import sample.Broadcaster;
import sample.Listener;
import source.config.SourceConfigTuner;
import source.tuner.TunerChannel;
@@ -44,8 +43,8 @@ public class TrafficChannelManager extends Module
private DecodeConfiguration mDecodeConfiguration;
private RecordConfiguration mRecordConfiguration;
private ResourceManager mResourceManager;
private System mSystem;
private Site mSite;
private String mSystem;
private String mSite;
private String mAliasListName;
private long mTrafficChannelTimeout;
private CallEvent mPreviousDoNotMonitorCallEvent;
@@ -72,8 +71,8 @@ public class TrafficChannelManager extends Module
public TrafficChannelManager( ResourceManager resourceManager,
DecodeConfiguration decodeConfiguration,
RecordConfiguration recordConfiguration,
System system,
Site site,
String system,
String site,
String aliasListName,
long trafficChannelTimeout,
int trafficChannelPoolSize )
@@ -145,8 +144,8 @@ public class TrafficChannelManager extends Module
{
channel.setSourceConfiguration( new SourceConfigTuner( tunerChannel ) );
channel.setSystem( mSystem, false );
channel.setSite( mSite, false );
channel.setSystem( mSystem );
channel.setSite( mSite );
channel.setName( channelNumber );
channel.setEnabled( true );
@@ -160,8 +159,8 @@ public class TrafficChannelManager extends Module
{
channel.setEnabled( false );
channel.setSystem( mSystem, false );
channel.setSite( mSite, false );
channel.setSystem( mSystem );
channel.setSite( mSite );
channel.setName( "Traffic" );
}
}
@@ -399,7 +398,7 @@ public class TrafficChannelManager extends Module
mTrafficChannelsInUse.remove( channelNumber );
/* Disable the channel and broadcast a notification */
channel.setEnabled( false, true );
channel.setEnabled( false );
}
}
}

View File

@@ -17,15 +17,20 @@
******************************************************************************/
package playlist;
import java.util.ArrayList;
import java.util.List;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlSeeAlso;
import alias.AliasDirectory;
import controller.channel.Channel;
import controller.channel.map.ChannelMapList;
import controller.system.SystemList;
@XmlSeeAlso( { AliasDirectory.class,
Channel.class,
ChannelMapList.class,
SystemList.class } )
@@ -35,11 +40,23 @@ public class Playlist
private AliasDirectory mAliasDirectory = new AliasDirectory();
private ChannelMapList mChannelMapList = new ChannelMapList();
private SystemList mSystemList = new SystemList();
private List<Channel> mChannels = new ArrayList<>();
public Playlist()
{
}
@XmlElement( name = "channel" )
public List<Channel> getChannels()
{
return mChannels;
}
public void setChannels( List<Channel> channels )
{
mChannels = channels;
}
@XmlElement( name = "alias_directory" )
public AliasDirectory getAliasDirectory()
{
@@ -64,6 +81,13 @@ public class Playlist
mSystemList = list;
}
public boolean hasSystemList()
{
return mSystemList != null &&
mSystemList.getSystem() != null &&
!mSystemList.getSystem().isEmpty();
}
@XmlElement( name = "channel_maps" )
public ChannelMapList getChannelMapList()
{

View File

@@ -35,6 +35,10 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import properties.SystemProperties;
import controller.channel.Channel;
import controller.channel.ChannelModel;
import controller.site.Site;
import controller.system.SystemList;
public class PlaylistManager
{
@@ -43,8 +47,11 @@ public class PlaylistManager
private Playlist mPlaylist = new Playlist();
public PlaylistManager()
private ChannelModel mChannelModel;
public PlaylistManager( ChannelModel channelModel )
{
mChannelModel = channelModel;
init();
}
@@ -52,6 +59,15 @@ public class PlaylistManager
{
return mPlaylist;
}
/**
* Transfers data from persisted playlist into system models
*/
private void transferPlaylistToModels()
{
//Load channels
mChannelModel.addChannels( mPlaylist.getChannels() );
}
/**
* Loads playlist from the current playlist file, or the default playlist file,
@@ -70,6 +86,8 @@ public class PlaylistManager
props.get( "playlist.currentfilename", defaultPlaylistFile );
load( playlistFolder.resolve( playlistFile ) );
transferPlaylistToModels();
}
@@ -205,5 +223,44 @@ public class PlaylistManager
{
mPlaylist = new Playlist();
}
//Check for and convert from legacy play list format
if( mPlaylist.hasSystemList() )
{
convertPlaylistFormat();
}
}
/**
* Converts playlist data over to new format
*/
private void convertPlaylistFormat()
{
mLog.info( "Legacy playlist format detected - converting ..." );
//Playlist version 1 to version 2 format conversion. In order to keep
//backwards compatibility, transfer all of the System-Site-Channel
//objects over to the new channel list format
SystemList systemList = mPlaylist.getSystemList();
for( controller.system.System system: systemList.getSystem() )
{
for( Site site: system.getSite() )
{
for( Channel channel: site.getChannel() )
{
channel.setSystem( system.getName() );
channel.setSite( site.getName() );
mPlaylist.getChannels().add( channel );
}
}
}
mPlaylist.getSystemList().clearSystems();
mLog.info( "Converted [" + mPlaylist.getChannels().size() + "] channels to new playlist format" );
save();
}
}

View File

@@ -124,6 +124,6 @@ public class SourceComponentEditor extends AbstractChannelEditor
//Let the calling save method send the config change event
mChannelNode.getChannel()
.setSourceConfiguration( mEditor.getConfig(), false );
.setSourceConfiguration( mEditor.getConfig() );
}
}

View File

@@ -42,6 +42,7 @@ public class SourceConfigMixer extends SourceConfiguration
{
StringBuilder sb = new StringBuilder();
sb.append( "Mixer: " );
sb.append( mMixer );
sb.append( "-" );
sb.append( mChannel.toString() );

View File

@@ -34,6 +34,7 @@ import source.tuner.frequency.FrequencyChangeListener;
import spectrum.SpectrumFrame;
import controller.BaseNode;
import controller.ResourceManager;
import controller.channel.ChannelModel;
public class TunerNode extends BaseNode implements FrequencyChangeListener
{
@@ -46,11 +47,14 @@ public class TunerNode extends BaseNode implements FrequencyChangeListener
private long mFrequency;
private int mSampleRate;
private ChannelModel mChannelModel;
public TunerNode( Tuner tuner )
public TunerNode( ChannelModel channelModel, Tuner tuner )
{
super( tuner ); //does this make it a super tuner?
mChannelModel = channelModel;
tuner.addListener( this );
try
@@ -115,7 +119,7 @@ public class TunerNode extends BaseNode implements FrequencyChangeListener
{
ResourceManager rm = getModel().getResourceManager();
SpectrumFrame frame = new SpectrumFrame( rm.getChannelManager(),
SpectrumFrame frame = new SpectrumFrame( mChannelModel,
rm.getController(), rm.getPlaylistManager(),
rm.getSettingsManager(), getTuner() );
}

View File

@@ -166,7 +166,7 @@ public class ChannelSpectrumPanel extends JPanel
{
switch( event.getEvent() )
{
case CHANGE_SELECTED:
case NOTIFICATION_SELECTION_CHANGE:
if( !event.getChannel().isSelected() )
{
stop();
@@ -192,7 +192,7 @@ public class ChannelSpectrumPanel extends JPanel
start();
}
break;
case CHANNEL_DISABLED:
case REQUEST_DISABLE:
if( event.getChannel() == mCurrentChannel )
{
if( mEnabled.get() )
@@ -203,7 +203,7 @@ public class ChannelSpectrumPanel extends JPanel
mCurrentChannel = null;
}
break;
case CHANNEL_ENABLED:
case REQUEST_ENABLE:
if( event.getChannel() == mCurrentChannel &&
!event.getChannel().isProcessing() )
{

View File

@@ -32,7 +32,6 @@ import java.awt.geom.Line2D;
import java.awt.geom.Rectangle2D;
import java.text.DecimalFormat;
import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.CopyOnWriteArrayList;
import javax.swing.JPanel;
@@ -52,7 +51,7 @@ import controller.channel.Channel;
import controller.channel.Channel.ChannelType;
import controller.channel.ChannelEvent;
import controller.channel.ChannelEventListener;
import controller.channel.ChannelManager;
import controller.channel.ChannelModel;
public class OverlayPanel extends JPanel
implements ChannelEventListener,
@@ -111,14 +110,14 @@ public class OverlayPanel extends JPanel
private LabelSizeManager mLabelSizeMonitor = new LabelSizeManager();
private SettingsManager mSettingsManager;
private ChannelManager mChannelManager;
private ChannelModel mChannelModel;
/**
* Translucent overlay panel for displaying channel configurations,
* processing channels, selected channels, frequency labels and lines, and
* a cursor with a frequency readout.
*/
public OverlayPanel( SettingsManager settingsManager,
ChannelManager channelManager )
ChannelModel channelModel )
{
mSettingsManager = settingsManager;
@@ -127,11 +126,11 @@ public class OverlayPanel extends JPanel
mSettingsManager.addListener( this );
}
mChannelManager = channelManager;
mChannelModel = channelModel;
if( mChannelManager != null )
if( mChannelModel != null )
{
mChannelManager.addListener( this );
mChannelModel.addListener( this );
}
addComponentListener( mLabelSizeMonitor );
@@ -145,14 +144,13 @@ public class OverlayPanel extends JPanel
public void dispose()
{
if( mChannelManager != null )
if( mChannelModel != null )
{
mChannelManager.removeListener( this );
mChannelModel.removeListener( this );
}
mChannelManager = null;
mChannelModel = null;
// mChannels.clear();
mVisibleChannels.clear();
if( mSettingsManager != null )
@@ -571,7 +569,7 @@ public class OverlayPanel extends JPanel
double yAxis = 0;
//Draw the system label and adjust the y-axis position
String system = channel.hasSystem() ? channel.getSystem().getName() : " ";
String system = channel.hasSystem() ? channel.getSystem() : " ";
yAxis += drawLabel( graphics,
system,
@@ -581,7 +579,7 @@ public class OverlayPanel extends JPanel
width );
//Draw the site label and adjust the y-axis position
String site = channel.hasSite() ? channel.getSite().getName() : " ";
String site = channel.hasSite() ? channel.getSite() : " ";
yAxis += drawLabel( graphics,
site,
@@ -689,20 +687,12 @@ public class OverlayPanel extends JPanel
}
/**
* Reset the visible channel configs list
* Reset the visible channels list
*/
mVisibleChannels.clear();
long minimum = getMinFrequency();
long maximum = getMaxFrequency();
for( Channel channel: mChannelManager.getChannels() )
{
if( channel.isWithin( minimum, maximum ) )
{
mVisibleChannels.add( channel );
}
}
mVisibleChannels.addAll(
mChannelModel.getChannelsInFrequencyRange( getMinFrequency(),
getMaxFrequency() ) );
}
/**
@@ -716,27 +706,20 @@ public class OverlayPanel extends JPanel
switch( event.getEvent() )
{
// case CHANNEL_ADDED:
case CHANNEL_ENABLED:
// if( !mChannels.contains( channel ) )
// {
// mChannels.add( channel );
// }
if( channel.isWithin( getMinFrequency(), getMaxFrequency() ) &&
!mVisibleChannels.contains( channel ) )
case NOTIFICATION_ADD:
case NOTIFICATION_PROCESSING_START:
if( !mVisibleChannels.contains( channel ) &&
channel.isWithin( getMinFrequency(), getMaxFrequency() ) )
{
mVisibleChannels.add( channel );
}
break;
case CHANNEL_DELETED:
// mChannels.remove( channel );
case NOTIFICATION_DELETE:
mVisibleChannels.remove( channel );
break;
case CHANNEL_PROCESSING_STOPPED:
case NOTIFICATION_PROCESSING_STOP:
if( channel.getChannelType() == ChannelType.TRAFFIC )
{
// mChannels.remove( channel );
mVisibleChannels.remove( channel );
}
break;

View File

@@ -28,7 +28,6 @@ import java.awt.event.MouseEvent;
import java.awt.event.MouseWheelEvent;
import java.text.DecimalFormat;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Hashtable;
import javax.swing.JCheckBoxMenuItem;
@@ -82,7 +81,7 @@ import com.jidesoft.swing.JideSplitPane;
import controller.ConfigurationControllerModel;
import controller.channel.Channel;
import controller.channel.ChannelManager;
import controller.channel.ChannelModel;
import controller.channel.ChannelUtils;
import dsp.filter.Window.WindowType;
import dsp.filter.smoothing.SmoothingFilter.SmoothingType;
@@ -133,7 +132,7 @@ public class SpectralDisplayPanel extends JPanel
* the DFT is translated to decibels for display in the spectrum and
* waterfall components.
*/
public SpectralDisplayPanel( ChannelManager channelManager,
public SpectralDisplayPanel( ChannelModel channelModel,
ConfigurationControllerModel controller,
PlaylistManager playlistManager,
SettingsManager settingsManager )
@@ -143,7 +142,7 @@ public class SpectralDisplayPanel extends JPanel
mSettingsManager = settingsManager;
mSpectrumPanel = new SpectrumPanel( mSettingsManager );
mOverlayPanel = new OverlayPanel( mSettingsManager, channelManager );
mOverlayPanel = new OverlayPanel( mSettingsManager, channelModel );
mWaterfallPanel = new WaterfallPanel( mSettingsManager );
//Register to receive tuner selection events

View File

@@ -23,13 +23,13 @@ import java.awt.event.WindowListener;
import javax.swing.JFrame;
import playlist.PlaylistManager;
import net.miginfocom.swing.MigLayout;
import playlist.PlaylistManager;
import settings.SettingsManager;
import source.tuner.Tuner;
import controller.ConfigurationControllerModel;
import controller.ResourceManager;
import controller.channel.ChannelManager;
import controller.channel.ChannelModel;
public class SpectrumFrame extends JFrame implements WindowListener
{
@@ -38,7 +38,7 @@ public class SpectrumFrame extends JFrame implements WindowListener
private ResourceManager mResourceManager;
private SpectralDisplayPanel mSpectralDisplayPanel;
public SpectrumFrame( ChannelManager channelManager,
public SpectrumFrame( ChannelModel channelModel,
ConfigurationControllerModel controller,
PlaylistManager playlistManager,
SettingsManager settingsManager,
@@ -50,7 +50,7 @@ public class SpectrumFrame extends JFrame implements WindowListener
setLayout( new MigLayout( "insets 0 0 0 0", "[grow]", "[grow]") );
mSpectralDisplayPanel = new SpectralDisplayPanel( channelManager,
mSpectralDisplayPanel = new SpectralDisplayPanel( channelModel,
controller, playlistManager, settingsManager );
mSpectralDisplayPanel.tunerSelected( tuner );