WIP #34 - more work on tuner model and view. Includes new tuner

configuration and tuner configuration assignment editors.  Beginning of
tuner editor panel rework.   Removes most of the remaining JTree
configuration pieces.  Updates the settings manager to load and save
tuners and refactors all of the tuner configuration management out into
the tuner configuration model.
This commit is contained in:
denny
2016-03-12 12:54:48 -05:00
parent 9d4afb8c1f
commit 218eeb1848
66 changed files with 1983 additions and 2594 deletions

View File

@@ -1,196 +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 java.awt.Color;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import javax.swing.JPanel;
import javax.swing.JPopupMenu;
import javax.swing.tree.DefaultMutableTreeNode;
import javax.swing.tree.TreeNode;
public class BaseNode extends DefaultMutableTreeNode
implements Comparable<BaseNode>
{
private static final long serialVersionUID = 1L;
/**
* Model backing the JTree and nodes. Since we're primarily interacting
* with the model via JTree tree nodes via context menus, injecting a
* reference to the model facilitates nodal access to the model's methods
*/
protected ConfigurationControllerModel mModel = null;
/**
* Implements a base node that has a reference to the underlying
* tree data model to facilitate tree node operations from nodal context
* menus.
*/
public BaseNode( Object object )
{
super( object );
}
/**
* Override this method to return a custom icon for the node
* @return
*/
public String getIconPath()
{
return null;
}
public Color getBackgroundColor()
{
return null;
}
public String toString()
{
if( getUserObject() != null )
{
return (String)getUserObject();
}
else
{
return "SDRTrunk";
}
}
public JPanel getEditor()
{
return new EmptyEditor();
}
/**
* Comparator to support nodal sorting/ordering
*/
@Override
public int compareTo( BaseNode node )
{
return toString().compareTo( node.toString() );
}
/**
* This method only needs to be called once on the root node and all nodes
* in the tree will then have a reference to the model via getModel()
*/
public void setModel( ConfigurationControllerModel model )
{
mModel = model;
}
/**
* Returns reference to the SystemTreeModel. Only ConfigurableNode types
* or children are allowed in this tree, so this method assumes that the
* node or parent is of ConfigurableNode class or subclass.
*
* Reference to the model is required to enable node context operations
* like adding/deleting/stopping/starting.
*/
public ConfigurationControllerModel getModel()
{
if( mModel == null )
{
TreeNode parent = getParent();
if( parent != null )
{
return ((BaseNode)parent).getModel();
}
else
{
return null;
}
}
else
{
return mModel;
}
}
/**
* Supports a context menu for any children of the BaseNode. Override the
* method in the child node to provide a custom context menu for that node.
*/
public JPopupMenu getContextMenu()
{
return null;
}
/**
* Invokes a recursive delete() on all children to perform any cleanup
* operations prior to deleting. Override this method to perform cleanup
* operations specific to the node. Remember to also either invoke
* super.delete(), or specifically call .delete() on any children of the
* node with the custom delete method.
*/
public void delete()
{
for( int x = 0; x < getChildCount(); x++ )
{
BaseNode node = (BaseNode)getChildAt( x );
//Tell the node to delete its children
node.delete();
//Delete the child node
getModel().deleteNode( node );
}
}
public void show()
{
getModel().showNode( this );
}
public void refresh()
{
if( getModel() != null )
{
getModel().nodeChanged( this );
}
}
public void sort()
{
List<BaseNode> nodesToSort = new ArrayList<BaseNode>();
while( children().hasMoreElements() )
{
BaseNode child = (BaseNode)children().nextElement();
nodesToSort.add( child );
getModel().removeNodeFromParent( child );
}
if( !nodesToSort.isEmpty() )
{
Collections.sort( nodesToSort );
for( BaseNode node: nodesToSort )
{
getModel().insertNodeInto( node, this, getChildCount() );
}
}
}
}

View File

@@ -1,54 +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 playlist.PlaylistManager;
public abstract class ConfigurableNode extends BaseNode
{
private static final long serialVersionUID = 1L;
private PlaylistManager mPlaylistManager;
public ConfigurableNode( PlaylistManager playlistManager, Object object )
{
super( object );
mPlaylistManager = playlistManager;
}
protected PlaylistManager getPlaylistManager()
{
return mPlaylistManager;
}
/**
* Saves changes to the node
*/
public void save()
{
mPlaylistManager.save();
BaseNode parent = (BaseNode)getParent();
if( parent instanceof ConfigurableNode )
{
((ConfigurableNode)parent).sort();
}
}
}

View File

@@ -1,246 +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;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import javax.swing.JTree;
import javax.swing.tree.DefaultMutableTreeNode;
import javax.swing.tree.DefaultTreeModel;
import javax.swing.tree.MutableTreeNode;
import javax.swing.tree.TreePath;
import module.decode.DecoderType;
import settings.SettingsManager;
import source.SourceManager;
import source.tuner.Tuner;
import source.tuner.TunerGroupNode;
import source.tuner.TunerNode;
import source.tuner.TunerSelectionListener;
import controller.channel.Channel;
import controller.channel.ChannelModel;
import controller.channel.ChannelProcessingManager;
public class ConfigurationControllerModel extends DefaultTreeModel
{
private static final long serialVersionUID = 1L;
private JTree mTree;
private ArrayList<TunerSelectionListener> mTunerSelectionListeners =
new ArrayList<TunerSelectionListener>();
private TunerGroupNode mTunerGroupNode;
private ChannelModel mChannelModel;
private ChannelProcessingManager mChannelProcessingManager;
private SettingsManager mSettingsManager;
private SourceManager mSourceManager;
/**
* Implements a merged system controller and (tree) model. The user will
* primarily interact with the system nodes via the tree view, so from a
* design perspective, the model and the control are necessarily merged to
* work well with the JTree as the system view.
*/
public ConfigurationControllerModel( ChannelModel channelModel,
ChannelProcessingManager channelProcessingManager,
SettingsManager settingsManager,
SourceManager sourceManager )
{
super( new BaseNode( null ) );
mChannelModel = channelModel;
mChannelProcessingManager = channelProcessingManager;
mSettingsManager = settingsManager;
mSourceManager = sourceManager;
/**
* Give the root node a reference to this model, so that all nodes can
* invoke add/delete operations on the tree via context menu
*/
((BaseNode)getRoot()).setModel( this );
}
public JTree getTree()
{
return mTree;
}
/**
* init() gets invoked manually/externally, after all of the references
* are established in the constructor
*/
public void init()
{
/**
* Add the tuner group node
*/
mTunerGroupNode = new TunerGroupNode();
insertNodeInto( mTunerGroupNode, (MutableTreeNode)root, 0 );
addTuners( mTunerGroupNode );
/**
* Add the recording group node
*/
// mRecordingGroupNode = new RecordingGroupNode();
// insertNodeInto( mRecordingGroupNode, (MutableTreeNode)root, 1 );
// mRecordingGroupNode.loadRecordings();
// /**
// * Add the playlist node
// */
// mPlaylistNode = new PlaylistNode( mChannelModel, mChannelProcessingManager,
// mPlaylistManager, mSettingsManager, mSourceManager );
// insertNodeInto( mPlaylistNode, (MutableTreeNode)root, 1 );
// mPlaylistNode.loadPlaylist();
}
public void showNode( DefaultMutableTreeNode node )
{
if( mTree != null && node != null )
{
mTree.setSelectionPath( new TreePath( node.getPath() ) );
}
}
public void setTree( JTree tree )
{
mTree = tree;
}
private void addTuners( TunerGroupNode parent )
{
List<Tuner> tuners = mSourceManager.getTunerManager().getTuners();
for( Tuner tuner: tuners )
{
TunerNode child = new TunerNode( mChannelModel,
mChannelProcessingManager, mSettingsManager, tuner );
insertNodeInto( child, parent, parent.getChildCount() );
parent.sort();
show( child );
}
}
/**
* Convenience method to add a new default system, site and channel to
* the tree
*/
public void createChannel( long frequency, DecoderType decoder )
{
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 )
{
insertNodeInto( child, parent, index );
show( child );
}
public void deleteNode( BaseNode node )
{
node.delete();
}
private void show( BaseNode node )
{
if( mTree != null )
{
mTree.scrollPathToVisible( new TreePath( node.getPath() ) );
}
}
public void addListener( TunerSelectionListener listener )
{
mTunerSelectionListeners.add( listener );
}
public void removeListener( TunerSelectionListener listener )
{
mTunerSelectionListeners.remove( listener );
}
/**
* Notifies registered listeners that the tuner has been selected
*/
public void fireTunerSelectedEvent( Tuner tuner )
{
Iterator<TunerSelectionListener> it =
mTunerSelectionListeners.iterator();
while( it.hasNext() )
{
it.next().tunerSelected( tuner );
}
}
/**
* Fires a tuner selection event for the first tuner listed in the tree.
* This is mainly used on application startup to show the spectral display
* of the first tuner in the spectrum panel.
*/
public void fireFirstTunerSelected()
{
if( mTunerGroupNode.getChildCount() > 0 )
{
TunerNode node = (TunerNode)mTunerGroupNode.getChildAt( 0 );
fireTunerSelectedEvent( node.getTuner() );
}
}
public ArrayList<Channel> getCurrentChannelConfigs()
{
return null;
}
private ArrayList<Channel> getChannelConfigs( DefaultMutableTreeNode parent )
{
return null;
}
}

View File

@@ -1,117 +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 java.awt.event.MouseEvent;
import java.awt.event.MouseListener;
import javax.swing.JPanel;
import javax.swing.JPopupMenu;
import javax.swing.JScrollPane;
import javax.swing.JTree;
import javax.swing.SwingUtilities;
import javax.swing.event.TreeSelectionListener;
import javax.swing.tree.TreeSelectionModel;
import net.miginfocom.swing.MigLayout;
public class ConfigurationTreePanel extends JPanel
{
private static final long serialVersionUID = 1L;
protected JTree mSystemTree;
protected ConfigurationControllerModel mTreeModel;
public ConfigurationTreePanel( ConfigurationControllerModel model )
{
mTreeModel = model;
initGUI();
}
private void initGUI()
{
setLayout( new MigLayout( "insets 0 0 0 0", "[grow,fill]", "[grow,fill][]") );
mSystemTree = new JTree( mTreeModel );
mSystemTree.getSelectionModel().setSelectionMode(
TreeSelectionModel.SINGLE_TREE_SELECTION );
mSystemTree.setShowsRootHandles( true );
mSystemTree.addMouseListener( new MouseHandler() );
mSystemTree.setCellRenderer( new ControllerTreeCellRenderer() );
//Give the model a reference to the tree, so that it can force newly
//added nodes to be displayed
mTreeModel.setTree( mSystemTree );
JScrollPane treeScroll = new JScrollPane( mSystemTree );
add( treeScroll, "cell 0 0,span,grow" );
}
public void addTreeSelectionListener( TreeSelectionListener listener )
{
mSystemTree.addTreeSelectionListener( listener );
}
public class MouseHandler implements MouseListener
{
public MouseHandler()
{
}
@Override
public void mouseClicked( MouseEvent event )
{
if( SwingUtilities.isRightMouseButton( event ) )
{
int row = mSystemTree.getRowForLocation( event.getX(),
event.getY() );
if( row != -1 )
{
mSystemTree.setSelectionRow( row );
Object selectedNode =
mSystemTree.getLastSelectedPathComponent();
if( selectedNode instanceof BaseNode )
{
JPopupMenu contextMenu =
((BaseNode)selectedNode).getContextMenu();
if( contextMenu != null )
{
contextMenu.show( mSystemTree,
event.getX(),
event.getY() );
}
}
}
}
}
@Override
public void mousePressed( MouseEvent e ){}
@Override
public void mouseReleased( MouseEvent e ){}
@Override
public void mouseEntered( MouseEvent e ){}
@Override
public void mouseExited( MouseEvent e ){}
}
}

View File

@@ -35,8 +35,8 @@ import module.decode.state.ChannelList;
import net.miginfocom.swing.MigLayout;
import settings.SettingsManager;
import source.SourceManager;
import source.TunerViewPanel;
import source.TunerModel;
import source.tuner.TunerModel;
import source.tuner.TunerViewPanel;
import spectrum.ChannelSpectrumPanel;
import alias.AliasController;
import alias.AliasModel;
@@ -55,36 +55,21 @@ public class ControllerPanel extends JPanel
{
private static final long serialVersionUID = 1L;
private ChannelList mChannelStateList;
private TunerViewPanel mTunerManagerPanel;
private CallEventPanel mCallEventPanel;
private MessageActivityPanel mMessageActivityPanel;
private ChannelSpectrumPanel mChannelSpectrumPanel;
private AliasController mAliasController;
private ChannelController mChannelController;
private JideTabbedPane mTabbedPane;
// protected ConfigurationTreePanel mSystemControlViewPanel;
// protected OldConfigurationEditor mConfigurationEditor;
// protected JideSplitPane mSystemControlSplitPane;
protected JTable mChannelActivityTable = new JTable();
private AudioPanel mAudioPanel;
private MapPanel mMapPanel;
private CallEventPanel mCallEventPanel;
private ChannelController mChannelController;
private ChannelList mChannelStateList;
private ChannelModel mChannelModel;
private ConfigurationControllerModel mController;
protected SettingsManager mSettingsManager;
private ChannelSpectrumPanel mChannelSpectrumPanel;
private MapPanel mMapPanel;
private MessageActivityPanel mMessageActivityPanel;
private TunerViewPanel mTunerManagerPanel;
private JideTabbedPane mTabbedPane;
protected JTable mChannelActivityTable = new JTable();
public ControllerPanel( AudioManager audioManager,
ConfigurationControllerModel controller,
AliasModel aliasModel,
ChannelModel channelModel,
ChannelMapModel channelMapModel,
@@ -95,29 +80,27 @@ public class ControllerPanel extends JPanel
TunerModel tunerModel )
{
mChannelModel = channelModel;
mController = controller;
mSettingsManager = settingsManager;
mAudioPanel = new AudioPanel( mSettingsManager, sourceManager, audioManager );
mAudioPanel = new AudioPanel( settingsManager, sourceManager, audioManager );
mMapPanel = new MapPanel( mapService, mSettingsManager );
mMapPanel = new MapPanel( mapService, settingsManager );
mMessageActivityPanel = new MessageActivityPanel( channelProcessingManager );
mCallEventPanel = new CallEventPanel( mSettingsManager, channelProcessingManager );
mCallEventPanel = new CallEventPanel( settingsManager, channelProcessingManager );
mChannelSpectrumPanel = new ChannelSpectrumPanel( mSettingsManager,
mChannelSpectrumPanel = new ChannelSpectrumPanel( settingsManager,
channelProcessingManager );
mChannelStateList = new ChannelList( channelModel, channelProcessingManager,
mSettingsManager );
settingsManager );
mChannelController = new ChannelController( channelModel, channelMapModel,
sourceManager, aliasModel );
mAliasController = new AliasController( aliasModel, mSettingsManager );
mAliasController = new AliasController( aliasModel, settingsManager );
mTunerManagerPanel = new TunerViewPanel( tunerModel, mSettingsManager );
mTunerManagerPanel = new TunerViewPanel( tunerModel );
init();
}
@@ -128,17 +111,6 @@ public class ControllerPanel extends JPanel
"[grow,fill]",
"[grow,fill]") );
// //System Configuration View and Editor
// mConfigurationEditor = new OldConfigurationEditor();
//
// mSystemControlViewPanel = new ConfigurationTreePanel( mController );
// mSystemControlViewPanel.addTreeSelectionListener( mConfigurationEditor );
// mSystemControlSplitPane = new JideSplitPane( JideSplitPane.HORIZONTAL_SPLIT );
// mSystemControlSplitPane.setDividerSize( 5 );
// mSystemControlSplitPane.add( mSystemControlViewPanel );
// mSystemControlSplitPane.add( mConfigurationEditor );
//Tabbed View - configuration, calls, messages, map
mTabbedPane = new JideTabbedPane();
mTabbedPane.setFont( this.getFont() );
@@ -146,7 +118,6 @@ public class ControllerPanel extends JPanel
mTabbedPane.addTab( "Tuners", mTunerManagerPanel );
mTabbedPane.addTab( "Channels", mChannelController );
mTabbedPane.addTab( "Aliases", mAliasController );
// mTabbedPane.addTab( "Configuration", mSystemControlSplitPane );
mTabbedPane.addTab( "Channel Spectrum", mChannelSpectrumPanel );
mTabbedPane.addTab( "Events", mCallEventPanel );
mTabbedPane.addTab( "Messages", mMessageActivityPanel );
@@ -191,6 +162,10 @@ public class ControllerPanel extends JPanel
audioChannelListSplit.setDividerSize( 5 );
audioChannelListSplit.add( mAudioPanel );
audioChannelListSplit.add( channelStateListScroll );
//Set preferred size to influence the split between these panels
audioChannelListSplit.setPreferredSize( new Dimension( 400, 500 ) );
mTabbedPane.setPreferredSize( new Dimension( 880, 500 ) );
JideSplitPane channelSplit = new JideSplitPane( JideSplitPane.HORIZONTAL_SPLIT );
channelSplit.setDividerSize( 5 );
@@ -199,9 +174,4 @@ public class ControllerPanel extends JPanel
add( channelSplit );
}
public ConfigurationControllerModel getController()
{
return mController;
}
}

View File

@@ -1,127 +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 java.awt.Color;
import java.awt.Component;
import java.awt.Image;
import java.util.HashMap;
import javax.swing.ImageIcon;
import javax.swing.JTree;
import javax.swing.tree.DefaultTreeCellRenderer;
public class ControllerTreeCellRenderer extends DefaultTreeCellRenderer
{
private static final long serialVersionUID = 1L;
public static final int MAX_ICON_HEIGHT = 16;
private HashMap<String,ImageIcon> mIcons = new HashMap<String,ImageIcon>();
public ControllerTreeCellRenderer()
{
}
@Override
public Component getTreeCellRendererComponent( JTree tree,
Object value, boolean selected, boolean expanded, boolean isLeaf,
int row, boolean focused )
{
Component c = super.getTreeCellRendererComponent( tree, value, selected,
expanded, isLeaf, row, focused );
if( value instanceof BaseNode )
{
BaseNode node = (BaseNode)value;
ImageIcon icon = getIcon( node );
setIcon( icon );
Color background = node.getBackgroundColor();
if( background != null )
{
setBackground( background );
setOpaque( true );
if( selected )
{
if( background == Color.CYAN )
{
setForeground( Color.ORANGE );
}
else if( background == Color.GREEN )
{
setForeground( Color.MAGENTA );
}
else if( background == Color.RED )
{
setForeground( Color.YELLOW );
}
}
}
else
{
setOpaque( false );
}
}
return c;
}
private ImageIcon getIcon( BaseNode node )
{
ImageIcon icon = null;
String filepath = node.getIconPath();
if( filepath != null )
{
if( mIcons.containsKey( filepath ) )
{
icon = mIcons.get( filepath );
}
else
{
icon = new ImageIcon( filepath );
if( icon.getIconHeight() > MAX_ICON_HEIGHT )
{
Image image = icon.getImage();
double scale = (double)icon.getIconHeight() / (double)MAX_ICON_HEIGHT;
int scaledWidth = (int)( (double)icon.getIconWidth() / scale );
Image scaledImage = image.getScaledInstance( scaledWidth,
MAX_ICON_HEIGHT, java.awt.Image.SCALE_SMOOTH );
mIcons.put( filepath, new ImageIcon( scaledImage ) );
}
else
{
mIcons.put( filepath, icon );
}
}
}
return icon;
}
}

View File

@@ -1,59 +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 java.awt.BorderLayout;
import java.awt.Dimension;
import javax.swing.JLabel;
import javax.swing.JPanel;
public class EmptyEditor extends JPanel
{
private static final long serialVersionUID = 1L;
public EmptyEditor()
{
setLayout( new BorderLayout() );
setPreferredSize( new Dimension( 200, (int)getPreferredSize().getHeight() ) );
String text = "<html>"
+ "<p>SDR Trunk</p>"
+ "<br>"
+ "<p>Use the tree structure to the left to configure SDRTrunk"
+ " to use multiple SDR tuners and sound card sources to"
+ " decode multiple trunked and digital radio channels.</p>"
+ "<br>"
+ "<p>Each tree branch can be accessed by clicking on the branch"
+ " and a configuration editor will appear here.</p>"
+ "<br>"
+ "<p>Many of the branches contain context sensitive menus that "
+ " you can access by right-clicking on the node.</p>"
+ "<br>"
+ "<p>To begin, right-click on the 'Systems' branch under 'Playlist'"
+ "and create a new 'System'. Right-click the 'System' node to create "
+ "a new 'Site'. Right-click on the 'Site' node to create a new Channel.</p>"
+ "<br>"
+ "<p>In the new channel, select a channel source and decoder "
+ "and select event logging and recording options. Check 'Enabled'"
+ " and hit the 'Save' button to begin decoding.</p>"
+ "</html>";
add( new JLabel( text ), BorderLayout.NORTH );
}
}

View File

@@ -1,74 +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 java.awt.BorderLayout;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.JTree;
import javax.swing.event.TreeSelectionEvent;
import javax.swing.event.TreeSelectionListener;
public class OldConfigurationEditor extends JPanel
implements TreeSelectionListener
{
private static final long serialVersionUID = 1L;
/**
* Host for configuration editor display panels
*/
public OldConfigurationEditor()
{
init();
}
public void init()
{
setPanel( new EmptyEditor() );
}
public void setPanel( JPanel display )
{
removeAll();
setLayout( new BorderLayout() );
JScrollPane scroll = new JScrollPane( display );
add( scroll, BorderLayout.CENTER );
revalidate();
repaint();
}
@Override
public void valueChanged( TreeSelectionEvent e )
{
JTree tree = (JTree)e.getSource();
BaseNode node =
(BaseNode)tree.getLastSelectedPathComponent();
if( node != null )
{
setPanel( node.getEditor() );
}
}
}

View File

@@ -54,11 +54,12 @@ import org.slf4j.LoggerFactory;
import playlist.PlaylistManager;
import properties.SystemProperties;
import record.RecorderManager;
import sample.Listener;
import settings.SettingsManager;
import source.SourceManager;
import source.TunerModel;
import source.tuner.Tuner;
import source.tuner.TunerSelectionListener;
import source.tuner.TunerEvent;
import source.tuner.TunerModel;
import source.tuner.configuration.TunerConfigurationModel;
import spectrum.SpectralDisplayPanel;
import util.TimeStamp;
import alias.AliasModel;
@@ -67,7 +68,6 @@ import audio.AudioManager;
import com.jidesoft.swing.JideSplitPane;
import controller.ConfigurationControllerModel;
import controller.ControllerPanel;
import controller.ThreadPoolManager;
import controller.ThreadPoolManager.ThreadType;
@@ -77,7 +77,7 @@ import controller.channel.ChannelProcessingManager;
import controller.channel.ChannelSelectionManager;
import controller.channel.map.ChannelMapModel;
public class SDRTrunk
public class SDRTrunk implements Listener<TunerEvent>
{
private final static Logger mLog = LoggerFactory.getLogger( SDRTrunk.class );
@@ -115,7 +115,10 @@ public class SDRTrunk
//Log current properties setting
SystemProperties.getInstance().logCurrentSettings();
mSettingsManager = new SettingsManager();
TunerConfigurationModel tunerConfigurationModel = new TunerConfigurationModel();
TunerModel tunerModel = new TunerModel( tunerConfigurationModel );
mSettingsManager = new SettingsManager( tunerConfigurationModel );
ThreadPoolManager threadPoolManager = new ThreadPoolManager();
@@ -129,12 +132,9 @@ public class SDRTrunk
RecorderManager recorderManager = new RecorderManager( threadPoolManager );
SourceManager sourceManager = new SourceManager( mSettingsManager,
threadPoolManager );
SourceManager sourceManager = new SourceManager( tunerModel,
mSettingsManager, threadPoolManager );
TunerModel tunerModel = new TunerModel();
tunerModel.addTuners( sourceManager.getTunerManager().getTuners() );
ChannelProcessingManager channelProcessingManager =
new ChannelProcessingManager( channelModel, channelMapModel,
aliasModel, eventLogManager, recorderManager,
@@ -156,18 +156,15 @@ public class SDRTrunk
MapService mapService = new MapService( mSettingsManager );
channelProcessingManager.addMessageListener( mapService );
ConfigurationControllerModel configurationControllerModel =
new ConfigurationControllerModel( channelModel, channelProcessingManager,
mSettingsManager, sourceManager );
mControllerPanel = new ControllerPanel( audioManager, configurationControllerModel,
aliasModel, channelModel, channelMapModel, channelProcessingManager,
mControllerPanel = new ControllerPanel( audioManager, aliasModel,
channelModel, channelMapModel, channelProcessingManager,
mapService, mSettingsManager, sourceManager, tunerModel );
mSpectralPanel = new SpectralDisplayPanel( configurationControllerModel,
channelModel, channelProcessingManager, mSettingsManager );
mTitle = getTitle();
mSpectralPanel = new SpectralDisplayPanel( channelModel,
channelProcessingManager, mSettingsManager );
tunerModel.addListener( mSpectralPanel.getTunerEventListener() );
tunerModel.addListener( this );
PlaylistManager playlistManager = new PlaylistManager( threadPoolManager,
aliasModel, channelModel, channelMapModel );
@@ -186,6 +183,8 @@ public class SDRTrunk
//Initialize the GUI
initGUI();
tunerModel.requestFirstTunerDisplay();
//Start the gui
EventQueue.invokeLater( new Runnable()
@@ -221,36 +220,17 @@ public class SDRTrunk
"[grow,fill]",
"[grow,fill]") );
//init() the controller to load tuners and playlists
mControllerPanel.getController().init();
/**
* Setup main JFrame window
*/
mTitle = getTitle();
mMainGui.setTitle( mTitle );
mMainGui.setBounds( 100, 100, 1280, 800 );
mMainGui.setDefaultCloseOperation( JFrame.EXIT_ON_CLOSE );
mControllerPanel.getController().addListener( new TunerSelectionListener()
{
@Override
public void tunerSelected( Tuner tuner )
{
if( tuner != null )
{
mMainGui.setTitle( mTitle + " - " + tuner.getName() );
}
else
{
mMainGui.setTitle( mTitle );
}
}
} );
//Fire first tuner selection so it is displayed in the spectrum/waterfall
mControllerPanel.getController().fireFirstTunerSelected();
mSpectralPanel.setPreferredSize( new Dimension( 1280, 400 ) );
//Set preferred sizes to influence the split
mSpectralPanel.setPreferredSize( new Dimension( 1280, 300 ) );
mControllerPanel.setPreferredSize( new Dimension( 1280, 500 ) );
JideSplitPane splitPane = new JideSplitPane( JideSplitPane.VERTICAL_SPLIT );
splitPane.setDividerSize( 5 );
@@ -487,5 +467,13 @@ public class SDRTrunk
return sb.toString();
}
@Override
public void receive( TunerEvent event )
{
if( event.getEvent() == TunerEvent.Event.REQUEST_MAIN_SPECTRAL_DISPLAY )
{
mMainGui.setTitle( mTitle + " - " + event.getTuner().getName() );
}
}
}

View File

@@ -10,7 +10,7 @@ public class EmptyEditor<T> extends Editor<T>
public EmptyEditor()
{
setLayout( new MigLayout( "", "[center]", "[grow]" ) );
setLayout( new MigLayout( "insets 0 0 0 0", "[center]", "[grow]" ) );
add( new JLabel( "Please select an item" ), "wrap" );
}

View File

@@ -33,7 +33,7 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import source.SourceEditor;
import source.tuner.TunerEditor;
import source.tuner.TunerEditorOld;
import controller.channel.ChannelConfigurationEditor;
import controller.channel.ConfigurationValidationException;

View File

@@ -28,10 +28,10 @@ import map.DefaultIcon;
import map.MapIcon;
import settings.ColorSetting.ColorSettingName;
import source.recording.RecordingConfiguration;
import source.tuner.TunerConfiguration;
import source.tuner.TunerConfigurationAssignment;
import source.tuner.TunerType;
import source.tuner.airspy.AirspyTunerConfiguration;
import source.tuner.configuration.TunerConfiguration;
import source.tuner.configuration.TunerConfigurationAssignment;
import source.tuner.fcd.proV1.FCD1TunerConfiguration;
import source.tuner.fcd.proplusV2.FCD2TunerConfiguration;
import source.tuner.hackrf.HackRFTunerConfiguration;
@@ -60,15 +60,15 @@ import source.tuner.rtl.r820t.R820TTunerConfiguration;
@XmlRootElement( name = "SDRTrunk_settings" )
public class Settings
{
private ArrayList<Setting> mSettings = new ArrayList<Setting>();
private List<Setting> mSettings = new ArrayList<Setting>();
private ArrayList<TunerConfiguration> mTunerConfiguration =
private List<TunerConfiguration> mTunerConfiguration =
new ArrayList<TunerConfiguration>();
private ArrayList<TunerConfigurationAssignment> mConfigurationAssignments =
private List<TunerConfigurationAssignment> mConfigurationAssignments =
new ArrayList<TunerConfigurationAssignment>();
private ArrayList<RecordingConfiguration> mRecordingConfigurations =
private List<RecordingConfiguration> mRecordingConfigurations =
new ArrayList<RecordingConfiguration>();
public Settings()
@@ -76,7 +76,7 @@ public class Settings
}
@XmlElement( name="recording_configuration" )
public ArrayList<RecordingConfiguration> getRecordingConfigurations()
public List<RecordingConfiguration> getRecordingConfigurations()
{
return mRecordingConfigurations;
}
@@ -98,12 +98,12 @@ public class Settings
}
@XmlElement( name="tuner_configuration" )
public ArrayList<TunerConfiguration> getTunerConfigurations()
public List<TunerConfiguration> getTunerConfigurations()
{
return mTunerConfiguration;
}
public void setTunerConfigurations( ArrayList<TunerConfiguration> configs )
public void setTunerConfigurations( List<TunerConfiguration> configs )
{
mTunerConfiguration = configs;
}
@@ -136,7 +136,7 @@ public class Settings
}
@XmlElement( name="setting" )
public ArrayList<Setting> getSettings()
public List<Setting> getSettings()
{
return mSettings;
}
@@ -255,12 +255,12 @@ public class Settings
}
@XmlElement( name="tuner_configuration_assignment" )
public ArrayList<TunerConfigurationAssignment> getSelectedTunerConfiguration()
public List<TunerConfigurationAssignment> getSelectedTunerConfiguration()
{
return mConfigurationAssignments;
}
public void setSelectedTunerConfiguration( ArrayList<TunerConfigurationAssignment> configs )
public void setSelectedTunerConfiguration( List<TunerConfigurationAssignment> configs )
{
mConfigurationAssignments = configs;
}

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
@@ -30,6 +30,7 @@ import java.nio.file.Path;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import javax.swing.ImageIcon;
import javax.xml.bind.JAXBContext;
@@ -45,19 +46,13 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import properties.SystemProperties;
import sample.Listener;
import settings.ColorSetting.ColorSettingName;
import source.recording.RecordingConfiguration;
import source.tuner.TunerConfiguration;
import source.tuner.TunerConfigurationAssignment;
import source.tuner.TunerType;
import source.tuner.airspy.AirspyTunerConfiguration;
import source.tuner.fcd.proV1.FCD1TunerConfiguration;
import source.tuner.fcd.proplusV2.FCD2TunerConfiguration;
import source.tuner.hackrf.HackRFTunerConfiguration;
import source.tuner.rtl.e4k.E4KTunerConfiguration;
import source.tuner.rtl.r820t.R820TTunerConfiguration;
import source.tuner.configuration.TunerConfigurationEvent;
import source.tuner.configuration.TunerConfigurationModel;
public class SettingsManager
public class SettingsManager implements Listener<TunerConfigurationEvent>
{
private final static Logger mLog =
LoggerFactory.getLogger( SettingsManager.class );
@@ -76,8 +71,20 @@ public class SettingsManager
private HashMap<String,ImageIcon> mResizedIcons =
new HashMap<String,ImageIcon>();
public SettingsManager()
private TunerConfigurationModel mTunerConfigurationModel;
private boolean mLoading = false;
public SettingsManager( TunerConfigurationModel tunerConfigurationModel )
{
//TODO: move settings and icons into a SettingsModel and an IconModel
//and update this class to only provide loading, saving, and model
//change detection producing a save.
mTunerConfigurationModel = tunerConfigurationModel;
//Register for tuner config events so that we can save the settings
mTunerConfigurationModel.addListener( this );
init();
}
@@ -101,6 +108,15 @@ public class SettingsManager
refreshIcons();
}
@Override
public void receive( TunerConfigurationEvent t )
{
if( !mLoading )
{
save();
}
}
/**
* Reloads the icon hash map, and sets up the default iconology. If the
@@ -542,7 +558,7 @@ public class SettingsManager
broadcastSettingChange( setting );
}
public ArrayList<RecordingConfiguration> getRecordingConfigurations()
public List<RecordingConfiguration> getRecordingConfigurations()
{
return mSettings.getRecordingConfigurations();
}
@@ -559,98 +575,6 @@ public class SettingsManager
save();
}
public ArrayList<TunerConfiguration> getTunerConfigurations( TunerType type )
{
ArrayList<TunerConfiguration> configs = getSettings()
.getTunerConfigurations( type );
return configs;
}
public void deleteTunerConfiguration( TunerConfiguration config )
{
getSettings().removeTunerConfiguration( config );
save();
}
public TunerConfiguration addNewTunerConfiguration( TunerType type,
String name )
{
switch( type )
{
case AIRSPY_R820T:
AirspyTunerConfiguration airspyConfig =
new AirspyTunerConfiguration( name );
getSettings().addTunerConfiguration( airspyConfig );
save();
return airspyConfig;
case ELONICS_E4000:
E4KTunerConfiguration e4KConfig =
new E4KTunerConfiguration( name );
getSettings().addTunerConfiguration( e4KConfig );
save();
return e4KConfig;
case FUNCUBE_DONGLE_PRO:
FCD1TunerConfiguration config =
new FCD1TunerConfiguration( name );
getSettings().addTunerConfiguration( config );
save();
return config;
case FUNCUBE_DONGLE_PRO_PLUS:
FCD2TunerConfiguration configPlus =
new FCD2TunerConfiguration( name );
getSettings().addTunerConfiguration( configPlus );
save();
return configPlus;
case HACKRF:
HackRFTunerConfiguration hackConfig =
new HackRFTunerConfiguration( name );
getSettings().addTunerConfiguration( hackConfig );
save();
return hackConfig;
case RAFAELMICRO_R820T:
R820TTunerConfiguration r820TConfig =
new R820TTunerConfiguration( name );
getSettings().addTunerConfiguration( r820TConfig );
save();
return r820TConfig;
default:
throw new IllegalArgumentException( "TunerConfiguration"
+ "Directory - tuner type is unrecognized [" +
type.toString() + "]" );
}
}
public TunerConfigurationAssignment getSelectedTunerConfiguration(
TunerType type, String address )
{
return mSettings.getConfigurationAssignment( type, address );
}
public void setSelectedTunerConfiguration( TunerType type,
String address, TunerConfiguration config )
{
mSettings.setConfigurationAssignment( type, address, config.getName() );
save();
}
public MapViewSetting getMapViewSetting( String name, GeoPosition position, int zoom )
{
MapViewSetting loc = mSettings.getMapViewSetting( name );
@@ -681,6 +605,8 @@ public class SettingsManager
public void save()
{
saveTunerConfigurationModel();
JAXBContext context = null;
SystemProperties props = SystemProperties.getInstance();
@@ -759,6 +685,8 @@ public class SettingsManager
*/
public void load( Path settingsPath )
{
mLoading = true;
if( Files.exists( settingsPath ) )
{
mLog.info( "SettingsManager - loading settings file [" +
@@ -817,6 +745,36 @@ public class SettingsManager
{
mSettings = new Settings();
}
loadTunerConfigurationModel();
mLoading = false;
}
private void loadTunerConfigurationModel()
{
if( mSettings != null )
{
mTunerConfigurationModel.clear();
mTunerConfigurationModel.addTunerConfigurations(
mSettings.getTunerConfigurations() );
mTunerConfigurationModel.addTunerConfigurationAssignments(
mSettings.getSelectedTunerConfiguration() );
}
}
private void saveTunerConfigurationModel()
{
if( mSettings != null )
{
mSettings.setTunerConfigurations(
mTunerConfigurationModel.getTunerConfigurations() );
mSettings.setSelectedTunerConfiguration(
mTunerConfigurationModel.getTunerConfigurationAssignments() );
}
}
public void broadcastSettingChange( Setting setting )

View File

@@ -18,13 +18,15 @@
package source;
import settings.SettingsManager;
import source.config.SourceConfigTuner;
import source.config.SourceConfiguration;
import source.mixer.MixerEditor;
import source.mixer.MixerManager;
import source.recording.RecordingEditor;
import source.recording.RecordingSourceManager;
import source.tuner.TunerEditor;
import source.tuner.TunerEditorOld;
import source.tuner.TunerManager;
import source.tuner.TunerModel;
import controller.ThreadPoolManager;
public class SourceManager
@@ -32,13 +34,19 @@ public class SourceManager
private MixerManager mMixerManager;
private RecordingSourceManager mRecordingSourceManager;
private TunerManager mTunerManager;
private TunerModel mTunerModel;
public SourceManager( SettingsManager settingsManager,
public SourceManager( TunerModel tunerModel,
SettingsManager settingsManager,
ThreadPoolManager threadPoolManager )
{
mTunerModel = tunerModel;
mMixerManager = new MixerManager();
mRecordingSourceManager = new RecordingSourceManager( settingsManager );
mTunerManager = new TunerManager( mMixerManager, settingsManager, threadPoolManager );
mTunerManager = new TunerManager( mMixerManager, tunerModel, threadPoolManager );
//TODO: change mixer & recording managers to be models and hand them
//in via the constructor. Perform loading outside of this class.
}
public MixerManager getMixerManager()
@@ -67,7 +75,7 @@ public class SourceManager
retVal = mMixerManager.getSource( config );
break;
case TUNER:
retVal = mTunerManager.getSource( config, bandwidth );
retVal = mTunerModel.getSource( (SourceConfigTuner)config, bandwidth );
break;
case RECORDING:
retVal = mRecordingSourceManager.getSource( config, bandwidth );
@@ -89,7 +97,7 @@ public class SourceManager
configuredPanel = new MixerEditor( this, config );
break;
case TUNER:
configuredPanel = new TunerEditor( this, config );
configuredPanel = new TunerEditorOld( this, config );
break;
case RECORDING:
configuredPanel = new RecordingEditor( this, config );

View File

@@ -1,184 +0,0 @@
package source;
import java.text.DecimalFormat;
import java.util.ArrayList;
import java.util.List;
import javax.swing.table.AbstractTableModel;
import sample.Listener;
import source.tuner.Tuner;
import source.tuner.TunerChangeEvent;
public class TunerModel extends AbstractTableModel
implements Listener<TunerChangeEvent>
{
private static final long serialVersionUID = 1L;
private static final int TUNER_CLASS = 0;
private static final int TUNER_TYPE = 1;
private static final int SAMPLE_RATE = 2;
private static final int FREQUENCY = 3;
private static final int CHANNEL_COUNT = 4;
private static final int SPECTRAL_DISPLAY = 5;
private static final String MHZ = " MHz";
private static final String[] COLUMNS =
{ "Class", "Type", "Sample Rate", "Frequency", "Channels", "Spectrum" };
private List<Tuner> mTuners = new ArrayList<>();
private DecimalFormat mFrequencyFormat = new DecimalFormat( "0.00000" );
private DecimalFormat mSampleRateFormat = new DecimalFormat( "0.000" );
public TunerModel()
{
}
/**
* List of Tuners currently in the model
*/
public List<Tuner> getTuners()
{
return mTuners;
}
public Tuner getTuner( int index )
{
if( index < mTuners.size() )
{
return mTuners.get( index );
}
return null;
}
public void addTuners( List<Tuner> Tuners )
{
for( Tuner tuner: Tuners )
{
addTuner( tuner );
}
}
/**
* Adds the Tuner to this model
*/
public void addTuner( Tuner tuner )
{
if( !mTuners.contains( tuner ) )
{
mTuners.add( tuner );
int index = mTuners.indexOf( tuner );
fireTableRowsInserted( index, index );
tuner.addTunerChangeListener( this );
}
}
/**
* Removes the Tuner from this model
*/
public void removeTuner( Tuner tuner )
{
if( mTuners.contains( tuner ) )
{
tuner.removeTunerChangeListener( this );
int index = mTuners.indexOf( tuner );
mTuners.remove( tuner );
fireTableRowsDeleted( index, index );
}
}
@Override
public void receive( TunerChangeEvent event )
{
if( event.getTuner() != null )
{
int index = mTuners.indexOf( event.getTuner() );
if( index >= 0 )
{
switch( event.getEvent() )
{
case CHANNEL_COUNT:
fireTableCellUpdated( index, CHANNEL_COUNT );
break;
case FREQUENCY:
fireTableCellUpdated( index, FREQUENCY );
break;
case SAMPLE_RATE:
fireTableCellUpdated( index, SAMPLE_RATE );
break;
case SPECTRAL_DISPLAY:
fireTableCellUpdated( index, SPECTRAL_DISPLAY );
default:
break;
}
}
}
}
@Override
public int getRowCount()
{
return mTuners.size();
}
@Override
public int getColumnCount()
{
return 6;
}
@Override
public Object getValueAt( int rowIndex, int columnIndex )
{
if( rowIndex < mTuners.size() )
{
Tuner tuner = mTuners.get( rowIndex );
switch( columnIndex )
{
case TUNER_CLASS:
return tuner.getTunerClass().getVendorDescription();
case TUNER_TYPE:
return tuner.getTunerType().getLabel();
case SAMPLE_RATE:
int sampleRate = tuner.getSampleRate();
return mSampleRateFormat.format( sampleRate / 1E6D ) + MHZ;
case FREQUENCY:
try
{
long frequency = tuner.getFrequency();
return mFrequencyFormat.format( frequency / 1E6D ) + MHZ;
}
catch( Exception e )
{
return 0;
}
case CHANNEL_COUNT:
return tuner.getChannelCount();
case SPECTRAL_DISPLAY:
return "TBD";
default:
break;
}
}
return null;
}
@Override
public String getColumnName( int columnIndex )
{
return COLUMNS[ columnIndex ];
}
}

View File

@@ -1,130 +0,0 @@
package source.recording;
import gui.control.JFrequencyControl;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.FocusEvent;
import java.awt.event.FocusListener;
import java.io.File;
import javax.swing.JButton;
import javax.swing.JFileChooser;
import javax.swing.JLabel;
import javax.swing.JOptionPane;
import javax.swing.JPanel;
import javax.swing.JTextField;
import net.miginfocom.swing.MigLayout;
public class RecordingEditorPanel extends JPanel
{
private static final long serialVersionUID = 1L;
private RecordingNode mRecordingNode;
private JTextField mRecordingAlias;
private JLabel mFilePathLabel;
public RecordingEditorPanel( RecordingNode recordingNode )
{
mRecordingNode = recordingNode;
initGUI();
}
private void initGUI()
{
setLayout( new MigLayout( "fill,wrap 2", "[right,grow][grow]", "[][][][][][grow]" ) );
add( new JLabel( "I/Q Recording" ), "span,align left" );
add( new JLabel( "Alias:" ) );
mRecordingAlias = new JTextField( mRecordingNode.getRecording()
.getRecordingConfiguration().getAlias() );
mRecordingAlias.addFocusListener( new FocusListener()
{
@Override
public void focusLost( FocusEvent arg0 )
{
String alias = mRecordingAlias.getText();
if( alias != null )
{
mRecordingNode.getRecording().setAlias( alias );
}
}
@Override
public void focusGained( FocusEvent arg0 ) {}
} );
add( mRecordingAlias, "wrap" );
JButton mFileSelectionButton = new JButton( "File ..." );
mFileSelectionButton.addActionListener( new ActionListener()
{
@Override
public void actionPerformed( ActionEvent arg0 )
{
if( mRecordingNode.getRecording().hasChannels() )
{
JOptionPane.showMessageDialog( RecordingEditorPanel.this,
"This recording is currently in replay. Please "
+ "disable any channels that are using this "
+ "recording before changing the recording file." );
}
else
{
final JFileChooser fc = new JFileChooser();
int returnVal = fc.showOpenDialog( RecordingEditorPanel.this );
if ( returnVal == JFileChooser.APPROVE_OPTION )
{
File file = fc.getSelectedFile();
if( file != null && file.exists() )
{
mRecordingNode.getRecording()
.getRecordingConfiguration()
.setFilePath( file.getAbsolutePath() );
if( mFilePathLabel != null )
{
mFilePathLabel.setText( file.getName() );
}
}
}
}
}
} );
add( mFileSelectionButton );
String filePath = mRecordingNode.getRecording()
.getRecordingConfiguration().getFilePath();
if( filePath != null )
{
mFilePathLabel = new JLabel( filePath );
}
else
{
mFilePathLabel = new JLabel( "Please select a recording" );
}
add( mFilePathLabel, "wrap" );
add( new JLabel( "Center Frequency:" ), "span,align left" );
JFrequencyControl frequencyControl = new JFrequencyControl(
mRecordingNode.getRecording().getRecordingConfiguration()
.getCenterFrequency() );
frequencyControl.addListener( mRecordingNode.getRecording() );
add( frequencyControl, "span,align left" );
}
}

View File

@@ -1,101 +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 source.recording;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.util.List;
import javax.swing.JMenuItem;
import javax.swing.JPopupMenu;
import settings.SettingsManager;
import source.SourceManager;
import controller.BaseNode;
public class RecordingGroupNode extends BaseNode
{
private static final long serialVersionUID = 1L;
private SettingsManager mSettingsManager;
public RecordingGroupNode( SourceManager sourceManager, SettingsManager settingsManager )
{
super( sourceManager );
mSettingsManager = settingsManager;
}
private SourceManager getSourceManager()
{
return (SourceManager)getUserObject();
}
public String toString()
{
return "Recordings [" + this.getChildCount() + "]";
}
public JPopupMenu getContextMenu()
{
JPopupMenu menu = new JPopupMenu();
JMenuItem addRecordingItem = new JMenuItem( "Add Recording" );
addRecordingItem.addActionListener( new ActionListener()
{
@Override
public void actionPerformed( ActionEvent e )
{
RecordingConfiguration config = new RecordingConfiguration();
mSettingsManager.addRecordingConfiguration( config );
Recording recording = getSourceManager()
.getRecordingSourceManager().addRecording( config );
RecordingNode node = new RecordingNode( getSourceManager(), recording );
getModel().addNode( node, RecordingGroupNode.this, 0 );
sort();
node.show();
}
} );
menu.add( addRecordingItem );
return menu;
}
public void loadRecordings()
{
List<Recording> recordings = getSourceManager()
.getRecordingSourceManager().getRecordings();
for( Recording recording: recordings )
{
RecordingNode node = new RecordingNode( getSourceManager(), recording );
getModel().addNode( node, this, 0 );
}
sort();
}
}

View File

@@ -1,82 +0,0 @@
package source.recording;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.JMenuItem;
import javax.swing.JOptionPane;
import javax.swing.JPanel;
import javax.swing.JPopupMenu;
import source.SourceManager;
import controller.BaseNode;
public class RecordingNode extends BaseNode
{
private static final long serialVersionUID = 1L;
private JPanel mEditor;
private SourceManager mSourceManager;
public RecordingNode( SourceManager sourceManager, Recording recording )
{
super( recording );
}
public Recording getRecording()
{
return (Recording)getUserObject();
}
public String toString()
{
return getRecording().toString();
}
@Override
public JPanel getEditor()
{
if( mEditor == null )
{
mEditor = new RecordingEditorPanel( this );
}
return mEditor;
}
public JPopupMenu getContextMenu()
{
JPopupMenu menu = new JPopupMenu();
JMenuItem deleteItem = new JMenuItem( "Delete" );
deleteItem.addActionListener( new ActionListener()
{
@Override
public void actionPerformed( ActionEvent e )
{
if( getRecording().hasChannels() )
{
JOptionPane.showMessageDialog( getModel().getTree(),
"Can't delete recording - currently in use. Please"
+ " disable any channel(s) that are using this "
+ "recording before deleting it",
"Can't delete recording",
JOptionPane.ERROR_MESSAGE );
}
else
{
mSourceManager.getRecordingSourceManager()
.removeRecording( getRecording() );
getModel().removeNodeFromParent( RecordingNode.this );
}
}
} );
menu.add( deleteItem );
return menu;
}
}

View File

@@ -131,7 +131,7 @@ public class RecordingSourceManager
private void loadRecordings()
{
ArrayList<RecordingConfiguration> recordingConfigurations =
List<RecordingConfiguration> recordingConfigurations =
mSettingsManager.getRecordingConfigurations();
mLog.info( "RecordingSourceManager - discovered [" +

View File

@@ -31,6 +31,7 @@ import sample.Listener;
import sample.complex.ComplexBuffer;
import settings.SettingsManager;
import source.SourceException;
import source.tuner.configuration.TunerConfiguration;
import source.tuner.frequency.FrequencyChangeEvent;
import source.tuner.frequency.FrequencyChangeEvent.Event;
import source.tuner.frequency.IFrequencyChangeProcessor;
@@ -55,7 +56,7 @@ public abstract class Tuner implements IFrequencyChangeProcessor,
protected List<IFrequencyChangeProcessor> mFrequencyChangeProcessors =
new CopyOnWriteArrayList<>();
protected List<Listener<TunerChangeEvent>> mTunerChangeListeners =
protected List<Listener<TunerEvent>> mTunerChangeListeners =
new ArrayList<>();
public Tuner( String name )
@@ -79,12 +80,6 @@ public abstract class Tuner implements IFrequencyChangeProcessor,
mName = name;
}
/**
* Return an editor panel for the tuner
*/
public abstract JPanel getEditor( SettingsManager settingsManager );
/**
* Applies the settings from a saved tuner configuration setting object
*/
@@ -223,7 +218,7 @@ public abstract class Tuner implements IFrequencyChangeProcessor,
/**
* Registers the listener
*/
public void addTunerChangeListener( Listener<TunerChangeEvent> listener )
public void addTunerChangeListener( Listener<TunerEvent> listener )
{
mTunerChangeListeners.add( listener );
}
@@ -231,7 +226,7 @@ public abstract class Tuner implements IFrequencyChangeProcessor,
/**
* Removes the registered listener
*/
public void removeTunerChangeListener( Listener<TunerChangeEvent> listener )
public void removeTunerChangeListener( Listener<TunerEvent> listener )
{
mTunerChangeListeners.remove( listener );
}
@@ -239,9 +234,9 @@ public abstract class Tuner implements IFrequencyChangeProcessor,
/**
* Broadcasts the tuner change event
*/
public void broadcast( TunerChangeEvent event )
public void broadcast( TunerEvent event )
{
for( Listener<TunerChangeEvent> listener: mTunerChangeListeners )
for( Listener<TunerEvent> listener: mTunerChangeListeners )
{
listener.receive( event );
}
@@ -277,11 +272,11 @@ public abstract class Tuner implements IFrequencyChangeProcessor,
if( event.getEvent() == Event.NOTIFICATION_FREQUENCY_CHANGE )
{
broadcast( new TunerChangeEvent( this, TunerChangeEvent.Event.FREQUENCY ) );
broadcast( new TunerEvent( this, TunerEvent.Event.FREQUENCY ) );
}
else if( event.getEvent() == Event.NOTIFICATION_SAMPLE_RATE_CHANGE )
{
broadcast( new TunerChangeEvent( this, TunerChangeEvent.Event.SAMPLE_RATE ) );
broadcast( new TunerEvent( this, TunerEvent.Event.SAMPLE_RATE ) );
}
}

View File

@@ -25,6 +25,7 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import source.SourceException;
import source.tuner.configuration.TunerConfiguration;
import source.tuner.frequency.FrequencyController;
import source.tuner.frequency.FrequencyController.Tunable;
import source.tuner.frequency.IFrequencyChangeProcessor;

View File

@@ -1,75 +1,168 @@
/*******************************************************************************
* 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 source.tuner;
import controller.channel.Channel;
import controller.channel.ConfigurationValidationException;
import gui.control.JFrequencyControl;
import source.SourceEditor;
import source.SourceManager;
import source.config.SourceConfigTuner;
import source.config.SourceConfiguration;
import gui.editor.Editor;
import gui.editor.EmptyEditor;
public class TunerEditor extends SourceEditor
import java.awt.Dimension;
import javax.swing.JButton;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.JTable;
import javax.swing.RowFilter;
import javax.swing.table.TableRowSorter;
import net.miginfocom.swing.MigLayout;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import source.tuner.configuration.TunerConfiguration;
import source.tuner.configuration.TunerConfigurationModel;
import com.jidesoft.swing.JideSplitPane;
public class TunerEditor extends Editor<Tuner>
{
private static final long serialVersionUID = 1L;
private JFrequencyControl mFrequencyControl;
public TunerEditor( SourceManager sourceManager,
SourceConfiguration config )
{
super( sourceManager, config );
initGUI();
}
private static final long serialVersionUID = 1L;
public void reset()
private final static Logger mLog = LoggerFactory.getLogger( TunerEditor.class );
private TunerConfigurationModel mTunerConfigurationModel;
private JTable mTunerConfigurationTable;
private TableRowSorter<TunerConfigurationModel> mRowSorter;
private ConfigurationRowFilter mRowFilter = new ConfigurationRowFilter();
private JFrequencyControl mFrequencyControl = new JFrequencyControl();
public TunerEditor( TunerConfigurationModel tunerConfigurationModel )
{
mFrequencyControl.setFrequency(
((SourceConfigTuner)mConfig).getFrequency(), false );
mTunerConfigurationModel = tunerConfigurationModel;
init();
}
public void init()
{
setLayout( new MigLayout( "insets 0 0 0 0", "[grow,fill]", "[grow,fill]" ) );
JPanel listPanel = new JPanel();
listPanel.setLayout( new MigLayout( "fill,wrap 1",
"[grow,fill]", "[][][grow,fill][]" ) );
listPanel.add( mFrequencyControl );
// mFrequencyControl.addListener( this );
// /* Add frequency control as frequency change listener. */
// mController.addListener( mFrequencyControl );
// mFrequencyControl.setFrequency( mController.getFrequency(), false );
mTunerConfigurationTable = new JTable( mTunerConfigurationModel );
mRowSorter = new TableRowSorter<>( mTunerConfigurationModel );
mRowSorter.setRowFilter( mRowFilter );
mTunerConfigurationTable.setRowSorter( mRowSorter );
listPanel.add( new JLabel( "Tuner Configurations" ) );
listPanel.add( mTunerConfigurationTable );
JPanel buttonPanel = new JPanel();
buttonPanel.setLayout( new MigLayout( "insets 0 0 0 0",
"[grow,fill][grow,fill]", "[grow,fill]" ) );
JButton newButton = new JButton( "New" );
buttonPanel.add( newButton );
JButton deleteButton = new JButton( "Delete" );
buttonPanel.add( deleteButton );
listPanel.add( buttonPanel );
//Set preferred size on both scrollers to same width, so they split the space
JScrollPane listScroller = new JScrollPane( listPanel );
listScroller.setPreferredSize( new Dimension( 200, 80 ) );
JPanel editorPanel = new EmptyEditor<TunerConfiguration>();
JScrollPane editorScroller = new JScrollPane( editorPanel );
editorScroller.setPreferredSize( new Dimension( 200, 80 ) );
JideSplitPane splitPane =
new JideSplitPane( JideSplitPane.HORIZONTAL_SPLIT );
splitPane.add( listScroller );
splitPane.add( editorScroller );
add( splitPane );
}
@Override
public void save()
{
((SourceConfigTuner)mConfig).setFrequency( mFrequencyControl.getFrequency() );
}
@Override
public void setItem( Tuner tuner )
{
super.setItem( tuner );
if( hasItem() )
{
mRowFilter.setTunerType( tuner.getTunerType() );
TunerConfiguration assigned = mTunerConfigurationModel
.getTunerConfiguration( tuner.getTunerType(), tuner.getUniqueID() );
int modelIndex = mTunerConfigurationModel.getRowIndex( assigned );
if( modelIndex >= 0 )
{
int viewIndex = mTunerConfigurationTable.convertRowIndexToView( modelIndex );
if( viewIndex >= 0 )
{
mTunerConfigurationTable.setRowSelectionInterval( viewIndex, viewIndex );
}
}
}
else
{
mRowFilter.setTunerType( null );
}
mRowSorter.setRowFilter( mRowFilter );
}
private void initGUI()
public class ConfigurationRowFilter extends RowFilter<TunerConfigurationModel,Integer>
{
mFrequencyControl = new JFrequencyControl();
private TunerType mTunerType;
mFrequencyControl.setFrequency(
((SourceConfigTuner)mConfig).getFrequency(), false );
add( mFrequencyControl );
}
@Override
public void setConfiguration( Channel channel )
{
// TODO Auto-generated method stub
}
@Override
public void validateConfiguration() throws ConfigurationValidationException
{
// TODO Auto-generated method stub
public ConfigurationRowFilter()
{
}
public void setTunerType( TunerType type )
{
mTunerType = type;
}
@Override
public boolean include( javax.swing.RowFilter.Entry<? extends TunerConfigurationModel,
? extends Integer> entry )
{
if( mTunerType == null )
{
return true;
}
else
{
TunerConfigurationModel model = entry.getModel();
TunerConfiguration config = model.getTunerConfiguration( entry.getIdentifier() );
if( config != null )
{
return config.getTunerType() == mTunerType;
}
}
return false;
}
}
}

View File

@@ -0,0 +1,75 @@
/*******************************************************************************
* 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 source.tuner;
import controller.channel.Channel;
import controller.channel.ConfigurationValidationException;
import gui.control.JFrequencyControl;
import source.SourceEditor;
import source.SourceManager;
import source.config.SourceConfigTuner;
import source.config.SourceConfiguration;
public class TunerEditorOld extends SourceEditor
{
private static final long serialVersionUID = 1L;
private JFrequencyControl mFrequencyControl;
public TunerEditorOld( SourceManager sourceManager,
SourceConfiguration config )
{
super( sourceManager, config );
initGUI();
}
public void reset()
{
mFrequencyControl.setFrequency(
((SourceConfigTuner)mConfig).getFrequency(), false );
}
public void save()
{
((SourceConfigTuner)mConfig).setFrequency( mFrequencyControl.getFrequency() );
}
private void initGUI()
{
mFrequencyControl = new JFrequencyControl();
mFrequencyControl.setFrequency(
((SourceConfigTuner)mConfig).getFrequency(), false );
add( mFrequencyControl );
}
@Override
public void setConfiguration( Channel channel )
{
// TODO Auto-generated method stub
}
@Override
public void validateConfiguration() throws ConfigurationValidationException
{
// TODO Auto-generated method stub
}
}

View File

@@ -1,11 +1,11 @@
package source.tuner;
public class TunerChangeEvent
public class TunerEvent
{
private Tuner mTuner;
private Event mEvent;
public TunerChangeEvent( Tuner tuner, Event event )
public TunerEvent( Tuner tuner, Event event )
{
mTuner = tuner;
mEvent = event;
@@ -28,6 +28,7 @@ public class TunerChangeEvent
CHANNEL_COUNT,
FREQUENCY,
SAMPLE_RATE,
SPECTRAL_DISPLAY;
REQUEST_MAIN_SPECTRAL_DISPLAY,
REQUEST_SECONDARY_SPECTRAL_DISPLAY;
}
}

View File

@@ -1,35 +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 source.tuner;
import controller.BaseNode;
public class TunerGroupNode extends BaseNode
{
private static final long serialVersionUID = 1L;
public TunerGroupNode()
{
super( null );
}
public String toString()
{
return "Tuners [" + this.getChildCount() + "]";
}
}

View File

@@ -1,6 +1,6 @@
/*******************************************************************************
* SDR Trunk
* Copyright (C) 2014,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
@@ -17,15 +17,7 @@
******************************************************************************/
package source.tuner;
import gui.editor.EmptyEditor;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Iterator;
import java.util.List;
import java.util.concurrent.RejectedExecutionException;
import javax.swing.JPanel;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -34,15 +26,10 @@ import org.usb4java.DeviceDescriptor;
import org.usb4java.DeviceList;
import org.usb4java.LibUsb;
import settings.SettingsManager;
import source.Source;
import source.SourceException;
import source.config.SourceConfigTuner;
import source.config.SourceConfiguration;
import source.mixer.MixerManager;
import source.tuner.airspy.AirspyTuner;
import source.tuner.airspy.AirspyTunerController;
import source.tuner.airspy.AirspyTunerEditorPanel;
import source.tuner.fcd.FCDTuner;
import source.tuner.fcd.proV1.FCD1TunerController;
import source.tuner.fcd.proplusV2.FCD2TunerController;
@@ -51,7 +38,6 @@ import source.tuner.hackrf.HackRFTunerController;
import source.tuner.rtl.RTL2832Tuner;
import source.tuner.rtl.RTL2832TunerController;
import source.tuner.rtl.e4k.E4KTunerController;
import source.tuner.rtl.e4k.E4KTunerEditorPanel;
import source.tuner.rtl.r820t.R820TTunerController;
import controller.ThreadPoolManager;
@@ -60,17 +46,15 @@ public class TunerManager
private final static Logger mLog =
LoggerFactory.getLogger( TunerManager.class );
private ArrayList<Tuner> mTuners = new ArrayList<Tuner>();
private MixerManager mMixerManager;
private SettingsManager mSettingsManager;
private TunerModel mTunerModel;
private ThreadPoolManager mThreadPoolManager;
public TunerManager( MixerManager mixerManager,
SettingsManager settingsManager,
TunerModel tunerModel,
ThreadPoolManager threadPoolManager )
{
mSettingsManager = settingsManager;
mTunerModel = tunerModel;
mThreadPoolManager = threadPoolManager;
initTuners();
@@ -84,57 +68,6 @@ public class TunerManager
LibUsb.exit( null );
}
/**
* Iterates current tuners to get a tuner channel source for the frequency
* specified in the channel config's source config object
*/
public Source getSource( SourceConfiguration config, int bandwidth )
{
TunerChannelSource retVal = null;
if( config instanceof SourceConfigTuner )
{
SourceConfigTuner tunerConfig = (SourceConfigTuner)config;
TunerChannel tunerChannel = tunerConfig.getTunerChannel();
tunerChannel.setBandwidth( bandwidth );
Iterator<Tuner> it = mTuners.iterator();
Tuner tuner;
while( it.hasNext() && retVal == null )
{
tuner = it.next();
try
{
retVal = tuner.getChannel( tunerChannel );
}
catch ( RejectedExecutionException ree )
{
mLog.error( "couldn't provide tuner channel source", ree );
}
catch ( SourceException e )
{
mLog.error( "error obtaining channel from tuner [" +
tuner.getName() + "]", e );
}
}
}
return retVal;
}
/**
* Get list of current tuners
*/
public List<Tuner> getTuners()
{
return mTuners;
}
/**
* Loads all USB tuners and USB/Mixer tuner devices
*/
@@ -192,9 +125,19 @@ public class TunerManager
if( status.isLoaded() )
{
Tuner tuner = status.getTuner();
sb.append( "] LOADED: " );
sb.append( tuner.toString() );
mTuners.add( tuner );
try
{
mTunerModel.addTuner( tuner );
sb.append( "] LOADED: " );
sb.append( tuner.toString() );
}
catch( Exception e )
{
sb.append( "] NOT LOADED: " );
sb.append( status.getInfo() );
sb.append( " Error:" + e.getMessage() );
}
}
else
{
@@ -276,13 +219,6 @@ public class TunerManager
AirspyTuner tuner = new AirspyTuner( airspyController );
TunerConfiguration config = getTunerConfiguration( tuner );
if( config != null )
{
tuner.apply( config );
}
return new TunerInitStatus( tuner, "LOADED" );
}
catch( SourceException se )
@@ -301,11 +237,6 @@ public class TunerManager
{
return new TunerInitStatus( null, "Ettus B100 tuner not currently "
+ "supported" );
// case ETTUS_USRP_B100:
// mTuners.add( new B100Tuner( device ) );
// status = sLOADED;
// reason = null;
// break;
}
private TunerInitStatus initFuncubeProTuner( Device device,
@@ -328,13 +259,6 @@ public class TunerManager
FCDTuner tuner =
new FCDTuner( dataline, controller );
TunerConfiguration config = getTunerConfiguration( tuner );
if( config != null )
{
tuner.apply( config );
}
return new TunerInitStatus( tuner, "LOADED" );
}
catch ( SourceException e )
@@ -373,13 +297,6 @@ public class TunerManager
FCDTuner tuner =
new FCDTuner( dataline, controller );
TunerConfiguration config = getTunerConfiguration( tuner );
if( config != null )
{
tuner.apply( config );
}
return new TunerInitStatus( tuner, "LOADED" );
}
catch ( SourceException e )
@@ -412,13 +329,6 @@ public class TunerManager
HackRFTuner tuner = new HackRFTuner( hackRFController );
TunerConfiguration config = getTunerConfiguration( tuner );
if( config != null )
{
tuner.apply( config );
}
return new TunerInitStatus( tuner, "LOADED" );
}
catch( SourceException se )
@@ -465,14 +375,6 @@ public class TunerManager
RTL2832Tuner rtlTuner =
new RTL2832Tuner( tunerClass, controller );
TunerConfiguration config =
getTunerConfiguration( rtlTuner );
if( config != null )
{
rtlTuner.apply( config );
}
return new TunerInitStatus( rtlTuner, "LOADED" );
}
catch( SourceException se )
@@ -492,14 +394,6 @@ public class TunerManager
RTL2832Tuner rtlTuner =
new RTL2832Tuner( tunerClass, controller );
TunerConfiguration config =
getTunerConfiguration( rtlTuner );
if( config != null )
{
rtlTuner.apply( config );
}
return new TunerInitStatus( rtlTuner, "LOADED" );
}
catch( SourceException se )
@@ -522,54 +416,6 @@ public class TunerManager
return new TunerInitStatus( null, reason );
}
/**
* Get a stored tuner configuration or create a default tuner configuration
* for the tuner type, connected at the address.
*
* Note: a named tuner configuration will be stored for for each tuner type
* and address combination.
* @param type - tuner type
* @param address - current usb address/port
* @return - stored tuner configuration or default configuration
*/
private TunerConfiguration getTunerConfiguration( Tuner tuner )
{
TunerConfigurationAssignment selected = mSettingsManager
.getSelectedTunerConfiguration( tuner.getTunerType(), tuner.getUniqueID() );
ArrayList<TunerConfiguration> configs = mSettingsManager
.getTunerConfigurations( tuner.getTunerType() );
TunerConfiguration config = null;
if( selected != null )
{
for( TunerConfiguration tunerConfig: configs )
{
if( tunerConfig.getName().contentEquals( selected.getTunerConfigurationName() ) )
{
config = tunerConfig;
}
}
}
//If we're still null at this point, create a default config
if( config == null )
{
String name = "Default-" + tuner.getUniqueID();
config = mSettingsManager.addNewTunerConfiguration(
tuner.getTunerType(), name );
}
//Persist the config as the selected tuner configuration. The method
//auto-saves the setting
mSettingsManager.setSelectedTunerConfiguration(
tuner.getTunerType(), tuner.getUniqueID(), config );
return config;
}
/**
* Gets the first tuner mixer dataline that corresponds to the tuner class.
@@ -625,15 +471,4 @@ public class TunerManager
}
}
public static JPanel getEditor( SettingsManager settingsManager, Tuner tuner )
{
JPanel editor = tuner.getEditor( settingsManager );
if( editor != null )
{
return editor;
}
return new EmptyEditor<Tuner>();
}
}

View File

@@ -0,0 +1,294 @@
package source.tuner;
import java.text.DecimalFormat;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import java.util.concurrent.RejectedExecutionException;
import javax.swing.table.AbstractTableModel;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import sample.Listener;
import source.Source;
import source.SourceException;
import source.config.SourceConfigTuner;
import source.tuner.TunerEvent.Event;
import source.tuner.configuration.TunerConfiguration;
import source.tuner.configuration.TunerConfigurationModel;
public class TunerModel extends AbstractTableModel implements Listener<TunerEvent>
{
private static final long serialVersionUID = 1L;
private final static Logger mLog = LoggerFactory.getLogger( TunerModel.class );
private static final int TUNER_CLASS = 0;
private static final int TUNER_TYPE = 1;
private static final int SAMPLE_RATE = 2;
private static final int FREQUENCY = 3;
private static final int CHANNEL_COUNT = 4;
private static final int SPECTRAL_DISPLAY = 5;
private static final String MHZ = " MHz";
private static final String[] COLUMNS =
{ "Class", "Type", "Sample Rate", "Frequency", "Channels", "Spectrum" };
private List<Tuner> mTuners = new ArrayList<>();
private List<Listener<TunerEvent>> mTunerEventListeners = new ArrayList<>();
private DecimalFormat mFrequencyFormat = new DecimalFormat( "0.00000" );
private DecimalFormat mSampleRateFormat = new DecimalFormat( "0.000" );
private TunerConfigurationModel mTunerConfigurationModel;
public TunerModel( TunerConfigurationModel tunerConfigurationModel )
{
mTunerConfigurationModel = tunerConfigurationModel;
}
public TunerConfigurationModel getTunerConfigurationModel()
{
return mTunerConfigurationModel;
}
/**
* List of Tuners currently in the model
*/
public List<Tuner> getTuners()
{
return mTuners;
}
public Tuner getTuner( int index )
{
if( index < mTuners.size() )
{
return mTuners.get( index );
}
return null;
}
public void addTuners( List<Tuner> Tuners )
{
for( Tuner tuner: Tuners )
{
addTuner( tuner );
}
}
/**
* Adds the Tuner to this model
*/
public void addTuner( Tuner tuner )
{
if( !mTuners.contains( tuner ) )
{
//Get the tuner configuration and apply it to the tuner - this
//call should always produce a tuner configuration
TunerConfiguration config = mTunerConfigurationModel
.getTunerConfiguration( tuner.getTunerType(), tuner.getUniqueID() );
try
{
tuner.apply( config );
mTuners.add( tuner );
int index = mTuners.indexOf( tuner );
fireTableRowsInserted( index, index );
tuner.addTunerChangeListener( this );
}
catch( SourceException se )
{
mLog.error( "Couldn't apply tuner configuration to tuner - ["
+ tuner.getTunerType().name() + "] with id ["
+ tuner.getUniqueID() + "] - tuner will not be included" );
}
}
}
/**
* Removes the Tuner from this model
*/
public void removeTuner( Tuner tuner )
{
if( mTuners.contains( tuner ) )
{
tuner.removeTunerChangeListener( this );
int index = mTuners.indexOf( tuner );
mTuners.remove( tuner );
fireTableRowsDeleted( index, index );
}
}
public void addListener( Listener<TunerEvent> listener )
{
mTunerEventListeners.add( listener );
}
public void removeListener( Listener<TunerEvent> listener )
{
mTunerEventListeners.remove( listener );
}
public void broadcast( TunerEvent event )
{
for( Listener<TunerEvent> listener: mTunerEventListeners )
{
listener.receive( event );
}
}
/**
* Requests to display the first tuner in this model. Invoke this method
* after all listeners have registered and tuners have been added to this
* model, in order to inform the primary display to use the first tuner.
*/
public void requestFirstTunerDisplay()
{
if( mTuners.size() > 0 )
{
broadcast( new TunerEvent( mTuners.get( 0 ),
Event.REQUEST_MAIN_SPECTRAL_DISPLAY ) );
}
}
@Override
public void receive( TunerEvent event )
{
if( event.getTuner() != null )
{
int index = mTuners.indexOf( event.getTuner() );
if( index >= 0 )
{
switch( event.getEvent() )
{
case CHANNEL_COUNT:
fireTableCellUpdated( index, CHANNEL_COUNT );
break;
case FREQUENCY:
fireTableCellUpdated( index, FREQUENCY );
break;
case SAMPLE_RATE:
fireTableCellUpdated( index, SAMPLE_RATE );
break;
case REQUEST_MAIN_SPECTRAL_DISPLAY:
fireTableCellUpdated( index, SPECTRAL_DISPLAY );
default:
break;
}
}
}
broadcast( event );
}
@Override
public int getRowCount()
{
return mTuners.size();
}
@Override
public int getColumnCount()
{
return 6;
}
@Override
public Object getValueAt( int rowIndex, int columnIndex )
{
if( rowIndex < mTuners.size() )
{
Tuner tuner = mTuners.get( rowIndex );
switch( columnIndex )
{
case TUNER_CLASS:
return tuner.getTunerClass().getVendorDescription();
case TUNER_TYPE:
return tuner.getTunerType().getLabel();
case SAMPLE_RATE:
int sampleRate = tuner.getSampleRate();
return mSampleRateFormat.format( sampleRate / 1E6D ) + MHZ;
case FREQUENCY:
try
{
long frequency = tuner.getFrequency();
return mFrequencyFormat.format( frequency / 1E6D ) + MHZ;
}
catch( Exception e )
{
return 0;
}
case CHANNEL_COUNT:
return tuner.getChannelCount();
case SPECTRAL_DISPLAY:
return "TBD";
default:
break;
}
}
return null;
}
@Override
public String getColumnName( int columnIndex )
{
return COLUMNS[ columnIndex ];
}
/**
* Iterates current tuners to get a tuner channel source for the frequency
* specified in the channel config's source config object.
*
* Returns null if no tuner can source the channel
*/
public Source getSource( SourceConfigTuner config, int bandwidth )
{
TunerChannelSource retVal = null;
TunerChannel tunerChannel = config.getTunerChannel();
tunerChannel.setBandwidth( bandwidth );
Iterator<Tuner> it = mTuners.iterator();
Tuner tuner;
while( it.hasNext() && retVal == null )
{
tuner = it.next();
try
{
retVal = tuner.getChannel( tunerChannel );
}
catch ( RejectedExecutionException ree )
{
mLog.error( "couldn't provide tuner channel source", ree );
}
catch ( SourceException e )
{
mLog.error( "error obtaining channel from tuner [" +
tuner.getName() + "]", e );
}
}
return retVal;
}
}

View File

@@ -1,166 +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 source.tuner;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.text.DecimalFormat;
import javax.swing.JMenuItem;
import javax.swing.JPanel;
import javax.swing.JPopupMenu;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import playlist.PlaylistManager;
import settings.SettingsManager;
import source.SourceException;
import source.tuner.frequency.FrequencyChangeEvent;
import source.tuner.frequency.IFrequencyChangeProcessor;
import spectrum.SpectrumFrame;
import controller.BaseNode;
import controller.channel.ChannelModel;
import controller.channel.ChannelProcessingManager;
public class TunerNode extends BaseNode implements IFrequencyChangeProcessor
{
private final static Logger mLog =
LoggerFactory.getLogger( TunerNode.class );
private static final long serialVersionUID = 1L;
private static DecimalFormat FREQUENCY_FORMAT = new DecimalFormat( "0.00000" );
private static DecimalFormat SAMPLE_RATE_FORMAT = new DecimalFormat( "0.000" );
private long mFrequency;
private int mSampleRate;
private ChannelModel mChannelModel;
private ChannelProcessingManager mChannelProcessingManager;
private SettingsManager mSettingsManager;
public TunerNode( ChannelModel channelModel,
ChannelProcessingManager channelProcessingManager,
SettingsManager settingsManager,
Tuner tuner )
{
super( tuner ); //does this make it a super tuner?
mChannelModel = channelModel;
mChannelProcessingManager = channelProcessingManager;
mSettingsManager = settingsManager;
tuner.addFrequencyChangeProcessor( this );
try
{
mFrequency = tuner.getFrequency();
mSampleRate = tuner.getSampleRate();
}
catch ( SourceException e )
{
mLog.error( "TunerNode - error reading frequency and sample rate "
+ "from tuner", e );
}
}
@Override
public JPanel getEditor()
{
return getTuner().getEditor( mSettingsManager );
}
public Tuner getTuner()
{
return (Tuner)getUserObject();
}
public String toString()
{
StringBuilder sb = new StringBuilder();
sb.append( getTuner().getName() );
sb.append( " " );
sb.append( FREQUENCY_FORMAT.format( (double)mFrequency / 1E6d ) );
sb.append( " [" );
sb.append( SAMPLE_RATE_FORMAT.format( (double)mSampleRate / 1E6d ) );
sb.append( "] MHz" );
return sb.toString();
}
public JPopupMenu getContextMenu()
{
JPopupMenu retVal = new JPopupMenu();
JMenuItem showSpectrumItem = new JMenuItem( "Show in Main Spectrum" );
showSpectrumItem.addActionListener( new ActionListener()
{
@Override
public void actionPerformed( ActionEvent e )
{
getModel().fireTunerSelectedEvent( getTuner() );
}
} );
retVal.add( showSpectrumItem );
JMenuItem newSpectrumItem = new JMenuItem( "New Spectrum Window" );
newSpectrumItem.addActionListener( new ActionListener()
{
@Override
public void actionPerformed( ActionEvent e )
{
SpectrumFrame frame = new SpectrumFrame( getModel(), mChannelModel,
mChannelProcessingManager, mSettingsManager, getTuner() );
}
} );
retVal.add( newSpectrumItem );
return retVal;
}
@Override
public void frequencyChanged( FrequencyChangeEvent event )
{
switch( event.getEvent() )
{
case NOTIFICATION_FREQUENCY_CHANGE:
long frequency = event.getValue().longValue();
if( mFrequency != frequency )
{
mFrequency = frequency;
getModel().nodeChanged( TunerNode.this );
}
break;
case NOTIFICATION_SAMPLE_RATE_CHANGE:
int sampleRate = event.getValue().intValue();
if( mSampleRate != sampleRate )
{
mSampleRate = sampleRate;
getModel().nodeChanged( TunerNode.this );
}
break;
default:
break;
}
}
}

View File

@@ -1,23 +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 source.tuner;
public interface TunerSelectionListener
{
public void tunerSelected( Tuner tuner );
}

View File

@@ -19,7 +19,7 @@ package source.tuner;
public enum TunerType
{
AIRSPY_R820T( "R820T/R820T2" ),
AIRSPY_R820T( "Airspy R820T" ),
ELONICS_E4000( "E4000" ),
ETTUS_WBX( "WBX" ),
ETTUS_VARIOUS( "Ettus Tuner" ),

View File

@@ -1,8 +1,5 @@
package source;
package source.tuner;
import gui.editor.EmptyEditor;
import java.awt.Component;
import java.awt.Dimension;
import javax.swing.JPanel;
@@ -17,10 +14,6 @@ import net.miginfocom.swing.MigLayout;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import settings.SettingsManager;
import source.tuner.Tuner;
import source.tuner.TunerManager;
import com.jidesoft.swing.JideSplitPane;
public class TunerViewPanel extends JPanel
@@ -29,21 +22,22 @@ public class TunerViewPanel extends JPanel
private final static Logger mLog = LoggerFactory.getLogger( TunerViewPanel.class );
private TunerModel mTunerModel;
private SettingsManager mSettingsManager;
private JideSplitPane mSplitPane;
private JTable mTunerTable;
private JideSplitPane mSplitPane;
private TunerEditor mTunerEditor;
public TunerViewPanel( TunerModel tunerModel, SettingsManager settingsManager )
public TunerViewPanel( TunerModel tunerModel )
{
mTunerModel = tunerModel;
mSettingsManager = settingsManager;
mTunerEditor = new TunerEditor( mTunerModel.getTunerConfigurationModel() );
init();
}
private void init()
{
setLayout( new MigLayout( "insets 1 1 1 1", "[fill,grow]", "[fill,grow]" ) );
setLayout( new MigLayout( "insets 0 0 0 0", "[fill,grow]", "[fill,grow]" ) );
mTunerTable = new JTable( mTunerModel );
mTunerTable.setSelectionMode( ListSelectionModel.SINGLE_SELECTION );
@@ -56,29 +50,8 @@ public class TunerViewPanel extends JPanel
{
int row = mTunerTable.getSelectedRow();
int modelRow = mTunerTable.convertRowIndexToModel( row );
Tuner selected = mTunerModel.getTuner( modelRow );
Component component = null;
if( selected != null )
{
JPanel tunerEditor = TunerManager
.getEditor( mSettingsManager, selected );
component = new JScrollPane( tunerEditor );
}
else
{
component = new EmptyEditor<Tuner>();
}
int split = mSplitPane.getDividerLocation( 0 );
mSplitPane.remove( 2 );
mSplitPane.add( component );
mSplitPane.setDividerLocation( 0, split );
validate();
mTunerEditor.setItem( mTunerModel.getTuner( modelRow ) );
}
}
} );
@@ -86,7 +59,7 @@ public class TunerViewPanel extends JPanel
JScrollPane listScroller = new JScrollPane( mTunerTable );
listScroller.setPreferredSize( new Dimension( 400, 20 ) );
JScrollPane editorScroller = new JScrollPane( new EmptyEditor<Tuner>() );
JScrollPane editorScroller = new JScrollPane( mTunerEditor );
editorScroller.setPreferredSize( new Dimension( 400, 80 ) );
mSplitPane = new JideSplitPane();
@@ -96,4 +69,6 @@ public class TunerViewPanel extends JPanel
add( mSplitPane );
}
}

View File

@@ -29,13 +29,13 @@ import sample.complex.ComplexBuffer;
import settings.SettingsManager;
import source.SourceException;
import source.tuner.Tuner;
import source.tuner.TunerChangeEvent;
import source.tuner.TunerEvent;
import source.tuner.TunerChannel;
import source.tuner.TunerChannelSource;
import source.tuner.TunerClass;
import source.tuner.TunerConfiguration;
import source.tuner.TunerType;
import source.tuner.airspy.AirspyTunerController.BoardID;
import source.tuner.configuration.TunerConfiguration;
public class AirspyTuner extends Tuner
{
@@ -54,12 +54,6 @@ public class AirspyTuner extends Tuner
mController.addListener( this );
}
@Override
public JPanel getEditor( SettingsManager settingsManager )
{
return new AirspyTunerEditorPanel( this, settingsManager );
}
public AirspyTunerController getController()
{
return mController;
@@ -142,7 +136,7 @@ public class AirspyTuner extends Tuner
if( source != null )
{
broadcast( new TunerChangeEvent( this, TunerChangeEvent.Event.CHANNEL_COUNT ) );
broadcast( new TunerEvent( this, TunerEvent.Event.CHANNEL_COUNT ) );
}
return source;

View File

@@ -19,9 +19,9 @@ package source.tuner.airspy;
import javax.xml.bind.annotation.XmlAttribute;
import source.tuner.TunerConfiguration;
import source.tuner.TunerType;
import source.tuner.airspy.AirspyTunerController.Gain;
import source.tuner.configuration.TunerConfiguration;
public class AirspyTunerConfiguration extends TunerConfiguration
{

View File

@@ -47,11 +47,11 @@ import org.usb4java.LibUsbException;
import settings.SettingsManager;
import source.SourceException;
import source.tuner.TunerConfiguration;
import source.tuner.TunerConfigurationAssignment;
import source.tuner.TunerType;
import source.tuner.airspy.AirspyTunerController.Gain;
import source.tuner.airspy.AirspyTunerController.GainMode;
import source.tuner.configuration.TunerConfiguration;
import source.tuner.configuration.TunerConfigurationAssignment;
public class AirspyTunerConfigurationPanel extends JPanel
{
@@ -126,8 +126,8 @@ public class AirspyTunerConfigurationPanel extends JPanel
if( serial != null )
{
savedConfig = mSettingsManager.getSelectedTunerConfiguration(
TunerType.AIRSPY_R820T, serial );
// savedConfig = mSettingsManager.getSelectedTunerConfiguration(
// TunerType.AIRSPY_R820T, serial );
}
if( savedConfig != null )
@@ -145,8 +145,8 @@ public class AirspyTunerConfigurationPanel extends JPanel
if( serial != null )
{
mSettingsManager.setSelectedTunerConfiguration( TunerType.AIRSPY_R820T,
serial, mSelectedConfig );
// mSettingsManager.setSelectedTunerConfiguration( TunerType.AIRSPY_R820T,
// serial, mSelectedConfig );
}
}
@@ -515,16 +515,16 @@ public class AirspyTunerConfigurationPanel extends JPanel
@Override
public void actionPerformed( ActionEvent e )
{
TunerConfiguration config =
mSettingsManager.addNewTunerConfiguration(
TunerType.AIRSPY_R820T,
"New Configuration" );
mComboConfigurations.setModel( getModel() );
mComboConfigurations.setSelectedItem( config );
repaint();
// TunerConfiguration config =
// mSettingsManager.addNewTunerConfiguration(
// TunerType.AIRSPY_R820T,
// "New Configuration" );
//
// mComboConfigurations.setModel( getModel() );
//
// mComboConfigurations.setSelectedItem( config );
//
// repaint();
}
} );
@@ -555,7 +555,7 @@ public class AirspyTunerConfigurationPanel extends JPanel
if( n == JOptionPane.YES_OPTION )
{
mSettingsManager.deleteTunerConfiguration( selected );
// mSettingsManager.deleteTunerConfiguration( selected );
mComboConfigurations.setModel( getModel() );
@@ -631,8 +631,8 @@ public class AirspyTunerConfigurationPanel extends JPanel
mGainModeCombo.setSelectedItem( Gain.getGainMode( gain ) );
mGain.setValue( gain.getValue() );
mSettingsManager.setSelectedTunerConfiguration(
TunerType.AIRSPY_R820T, mController.getDeviceInfo().getSerialNumber(), config );
// mSettingsManager.setSelectedTunerConfiguration(
// TunerType.AIRSPY_R820T, mController.getDeviceInfo().getSerialNumber(), config );
save();
}
@@ -656,16 +656,16 @@ public class AirspyTunerConfigurationPanel extends JPanel
*/
private ComboBoxModel<AirspyTunerConfiguration> getModel()
{
ArrayList<TunerConfiguration> configs =
mSettingsManager.getTunerConfigurations( TunerType.AIRSPY_R820T );
// ArrayList<TunerConfiguration> configs =
// mSettingsManager.getTunerConfigurations( TunerType.AIRSPY_R820T );
DefaultComboBoxModel<AirspyTunerConfiguration> model =
new DefaultComboBoxModel<AirspyTunerConfiguration>();
for( TunerConfiguration config: configs )
{
model.addElement( (AirspyTunerConfiguration)config );
}
// for( TunerConfiguration config: configs )
// {
// model.addElement( (AirspyTunerConfiguration)config );
// }
return model;
}
@@ -675,16 +675,16 @@ public class AirspyTunerConfigurationPanel extends JPanel
*/
private AirspyTunerConfiguration getNamedConfiguration( String name )
{
ArrayList<TunerConfiguration> configs =
mSettingsManager.getTunerConfigurations( TunerType.AIRSPY_R820T );
// ArrayList<TunerConfiguration> configs =
// mSettingsManager.getTunerConfigurations( TunerType.AIRSPY_R820T );
for( TunerConfiguration config: configs )
{
if( config.getName().contentEquals( name ) )
{
return (AirspyTunerConfiguration)config;
}
}
// for( TunerConfiguration config: configs )
// {
// if( config.getName().contentEquals( name ) )
// {
// return (AirspyTunerConfiguration)config;
// }
// }
return null;
}

View File

@@ -28,8 +28,8 @@ import sample.Broadcaster;
import sample.Listener;
import sample.complex.ComplexBuffer;
import source.SourceException;
import source.tuner.TunerConfiguration;
import source.tuner.TunerController;
import source.tuner.configuration.TunerConfiguration;
import controller.ThreadPoolManager;
import controller.ThreadPoolManager.ThreadType;
import dsp.filter.dc.DCRemovalFilter_RB;

View File

@@ -15,11 +15,13 @@
* 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 source.tuner;
package source.tuner.configuration;
import javax.xml.bind.annotation.XmlAttribute;
import javax.xml.bind.annotation.XmlType;
import source.tuner.TunerType;
/**
* Abstract class to hold a named configuration for a specific type of tuner
*/

View File

@@ -15,10 +15,12 @@
* 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 source.tuner;
package source.tuner.configuration;
import javax.xml.bind.annotation.XmlAttribute;
import source.tuner.TunerType;
public class TunerConfigurationAssignment
{
private TunerType mTunerType;

View File

@@ -0,0 +1,20 @@
package source.tuner.configuration;
import gui.editor.Editor;
public abstract class TunerConfigurationEditor extends Editor<TunerConfiguration>
{
private static final long serialVersionUID = 1L;
private TunerConfigurationModel mTunerConfigurationModel;
public TunerConfigurationEditor( TunerConfigurationModel model )
{
mTunerConfigurationModel = model;
}
public TunerConfigurationModel getTunerConfigurationModel()
{
return mTunerConfigurationModel;
}
}

View File

@@ -0,0 +1,45 @@
package source.tuner.configuration;
public class TunerConfigurationEvent
{
private TunerConfiguration mTunerConfiguration;
private TunerConfigurationAssignment mTunerConfigurationAssignment;
private Event mEvent;
public TunerConfigurationEvent( TunerConfiguration configuration, Event event )
{
mTunerConfiguration = configuration;
mEvent = event;
}
public TunerConfigurationEvent( TunerConfigurationAssignment assignment, Event event )
{
mTunerConfigurationAssignment = assignment;
mEvent = event;
}
public TunerConfiguration getConfiguration()
{
return mTunerConfiguration;
}
public TunerConfigurationAssignment getAssignment()
{
return mTunerConfigurationAssignment;
}
public Event getEvent()
{
return mEvent;
}
public enum Event
{
CONFIGURATION_ADD,
CONFIGURATION_REMOVE,
CONFIGURATION_CHANGE,
ASSIGNMENT_ADD,
ASSIGNMENT_REMOVE,
ASSIGNMENT_CHANGE;
}
}

View File

@@ -0,0 +1,64 @@
package source.tuner.configuration;
import source.tuner.Tuner;
import source.tuner.TunerType;
import source.tuner.airspy.AirspyTunerConfiguration;
import source.tuner.fcd.proV1.FCD1TunerConfiguration;
import source.tuner.fcd.proplusV2.FCD2TunerConfiguration;
import source.tuner.hackrf.HackRFTunerConfiguration;
import source.tuner.rtl.RTL2832Tuner;
import source.tuner.rtl.e4k.E4KTunerConfiguration;
import source.tuner.rtl.r820t.R820TTunerConfiguration;
import source.tuner.rtl.r820t.R820TTunerEditor;
public class TunerConfigurationFactory
{
public static TunerConfiguration getTunerConfiguration( TunerType type, String name )
{
switch( type )
{
case AIRSPY_R820T:
return new AirspyTunerConfiguration( name );
case ELONICS_E4000:
return new E4KTunerConfiguration( name );
case FUNCUBE_DONGLE_PRO:
return new FCD1TunerConfiguration( name );
case FUNCUBE_DONGLE_PRO_PLUS:
return new FCD2TunerConfiguration( name );
case HACKRF:
return new HackRFTunerConfiguration( name );
case RAFAELMICRO_R820T:
return new R820TTunerConfiguration( name );
default:
throw new IllegalArgumentException( "Unrecognized tuner type ["
+ type.name() + "] - can't create named [" + name + "] tuner"
+ " configuration" );
}
}
public static TunerConfigurationEditor getEditor( Tuner tuner,
TunerConfigurationModel model )
{
switch( tuner.getTunerType() )
{
case AIRSPY_R820T:
break;
case ELONICS_E4000:
break;
case FUNCUBE_DONGLE_PRO:
break;
case FUNCUBE_DONGLE_PRO_PLUS:
break;
case HACKRF:
break;
case RAFAELMICRO_R820T:
return new R820TTunerEditor( model, (RTL2832Tuner)tuner );
case UNKNOWN:
default:
break;
}
return null;
}
}

View File

@@ -0,0 +1,370 @@
package source.tuner.configuration;
import java.util.ArrayList;
import java.util.List;
import javax.swing.RowFilter;
import javax.swing.table.AbstractTableModel;
import javax.swing.table.TableRowSorter;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import sample.Listener;
import source.tuner.TunerType;
import source.tuner.TunerViewPanel;
import source.tuner.configuration.TunerConfigurationEvent.Event;
public class TunerConfigurationModel extends AbstractTableModel
{
private static final long serialVersionUID = 1L;
private final static Logger mLog =
LoggerFactory.getLogger( TunerConfigurationModel.class );
private static final int TUNER_TYPE = 0;
private static final int CONFIGURATION_NAME = 1;
private static final String[] COLUMN_HEADERS = { "Tuner Type", "Name" };
private List<Listener<TunerConfigurationEvent>> mConfigurationListeners = new ArrayList<>();
private List<TunerConfiguration> mTunerConfigurations = new ArrayList<>();
private List<TunerConfigurationAssignment> mTunerConfigurationAssignments = new ArrayList<>();
/**
* Table model for managing tuner configurations and tuner configuration
* assignments. Provides tuner configuration events to registered listeners
*/
public TunerConfigurationModel()
{
}
/**
* Adds the list of tuner configurations to the model
*/
public void addTunerConfigurations( List<TunerConfiguration> configs )
{
for( TunerConfiguration config: configs )
{
addTunerConfiguration( config );
}
}
/**
* Returns of list of tuner configurations from the model
*/
public List<TunerConfiguration> getTunerConfigurations()
{
return mTunerConfigurations;
}
/**
* Adds the tuner configuration to the model firing a table model row add
* event and broadcasting a tuner configuration event.
*/
public void addTunerConfiguration( TunerConfiguration config )
{
if( !mTunerConfigurations.contains( config ) )
{
mTunerConfigurations.add( config );
int index = mTunerConfigurations.indexOf( config );
fireTableRowsInserted( index, index );
broadcast( new TunerConfigurationEvent( config, Event.CONFIGURATION_ADD ) );
}
}
/**
* Removes the tuner configuration from the model firing a table model row
* delete event and broadcasting a tuner configuration event.
*/
public void removeTunerConfiguration( TunerConfiguration config )
{
if( mTunerConfigurations.contains( config ) )
{
int index = mTunerConfigurations.indexOf( config );
mTunerConfigurations.remove( config );
fireTableRowsDeleted( index, index );
broadcast( new TunerConfigurationEvent( config, Event.CONFIGURATION_REMOVE ) );
}
}
/**
* Removes all tuner configurations and assignments from the model and
* fires a table clear event and broadcasts a tuner configuration event for
* each row removed.
*/
public void clear()
{
for( TunerConfiguration config: mTunerConfigurations )
{
broadcast( new TunerConfigurationEvent( config, Event.CONFIGURATION_REMOVE ) );
}
int size = mTunerConfigurations.size();
mTunerConfigurations.clear();
fireTableRowsDeleted( 0, size - 1 );
for( TunerConfigurationAssignment assignment: mTunerConfigurationAssignments )
{
broadcast( new TunerConfigurationEvent( assignment, Event.ASSIGNMENT_REMOVE ) );
}
mTunerConfigurationAssignments.clear();
}
/**
* Registers a tuner configuration event listener
*/
public void addListener( Listener<TunerConfigurationEvent> listener )
{
mConfigurationListeners.add( listener );
}
/**
* Removes the tuner configuration event listener
*/
public void removeListener( Listener<TunerConfigurationEvent> listener )
{
mConfigurationListeners.remove( listener );
}
/**
* Broadcasts a tuner configuration event
*/
public void broadcast( TunerConfigurationEvent event )
{
for( Listener<TunerConfigurationEvent> listener: mConfigurationListeners )
{
listener.receive( event );
}
}
/**
* Adds a list of tuner configuration assignments to the model
*/
public void addTunerConfigurationAssignments( List<TunerConfigurationAssignment> assignments )
{
for( TunerConfigurationAssignment assigment: assignments )
{
addTunerConfigurationAssignment( assigment );
}
}
/**
* Returns of list of tuner configurations from the model
*/
public List<TunerConfigurationAssignment> getTunerConfigurationAssignments()
{
return mTunerConfigurationAssignments;
}
/**
* Adds a tuner configuration assigment to the model
*/
public void addTunerConfigurationAssignment( TunerConfigurationAssignment assignment )
{
mTunerConfigurationAssignments.add( assignment );
broadcast( new TunerConfigurationEvent( assignment, Event.ASSIGNMENT_ADD ) );
}
/**
* Removes a tuner configuration assignment from the model
*/
public void removeTunerConfigurationAssignment( TunerConfigurationAssignment assignment )
{
mTunerConfigurationAssignments.remove( assignment );
broadcast( new TunerConfigurationEvent( assignment, Event.ASSIGNMENT_REMOVE ) );
}
/**
* Returns the tuner configuration that is assigned to the tuner with the
* tuner type and uniqueID, or creates a new tuner configuration and tuner
* configuration assignment for the tuner.
*/
public TunerConfiguration getTunerConfiguration( TunerType type, String uniqueID )
{
String configurationName = null;
TunerConfigurationAssignment assignment = getTunerConfigurationAssignment( type, uniqueID );
if( assignment != null )
{
configurationName = assignment.getTunerConfigurationName();
}
if( configurationName == null )
{
configurationName = "Default-" + uniqueID;
}
List<TunerConfiguration> configs = getTunerConfigurations( type );
for( TunerConfiguration config: configs )
{
if( config.getName().contentEquals( configurationName ) )
{
if( assignment == null )
{
assignTunerConfiguration( config, configurationName );
}
return config;
}
}
//We didn't find the config so create a new one and assign it
TunerConfiguration config = TunerConfigurationFactory
.getTunerConfiguration( type, configurationName );
addTunerConfiguration( config );
assignTunerConfiguration( config, configurationName );
return config;
}
/**
* Assigns the tuner configuration to the tuner identified by the uniqueID
*/
public void assignTunerConfiguration( TunerConfiguration config, String uniqueID )
{
TunerConfigurationAssignment assignment =
getTunerConfigurationAssignment( config.getTunerType(), uniqueID );
Event event = Event.ASSIGNMENT_CHANGE;
if( assignment == null )
{
assignment = new TunerConfigurationAssignment();
assignment.setUniqueID( uniqueID );
addTunerConfigurationAssignment( assignment );
event = Event.ASSIGNMENT_ADD;
}
assignment.setTunerConfigurationName( config.getName() );
broadcast( new TunerConfigurationEvent( assignment, event ) );
}
/**
* Returns the tuner configuration assiged to the tuner type and unique id
*/
private TunerConfigurationAssignment getTunerConfigurationAssignment( TunerType type, String uniqueID )
{
for( TunerConfigurationAssignment assignment: mTunerConfigurationAssignments )
{
if( assignment.getTunerType() == type &&
assignment.getUniqueID().contentEquals( uniqueID ) )
{
return assignment;
}
}
return null;
}
/**
* Returns all tuner configurations for the specified tuner type
*/
public List<TunerConfiguration> getTunerConfigurations( TunerType type )
{
List<TunerConfiguration> configs = new ArrayList<>();
for( TunerConfiguration config: mTunerConfigurations )
{
if( config.getTunerType() == type )
{
configs.add( config );
}
}
return configs;
}
/**
* Column names for the table model
*/
@Override
public String getColumnName( int column )
{
return COLUMN_HEADERS[ column ];
}
/**
* Tuner configuration model row count
*/
@Override
public int getRowCount()
{
return mTunerConfigurations.size();
}
/**
* Tuner configuration model column count
*/
@Override
public int getColumnCount()
{
return COLUMN_HEADERS.length;
}
/**
* Returns the row index for the specified configuration or -1
*/
public int getRowIndex( TunerConfiguration configuration )
{
if( mTunerConfigurations.contains( configuration ) )
{
return mTunerConfigurations.indexOf( configuration );
}
return -1;
}
/**
* Returns the configuration at the specified index or null
*/
public TunerConfiguration getTunerConfiguration( int index )
{
if( index >= 0 && index < mTunerConfigurations.size() )
{
return mTunerConfigurations.get( index );
}
return null;
}
/**
* Returns the value at the indicated table cell
*/
@Override
public Object getValueAt( int row, int column )
{
if( row >= 0 && row < mTunerConfigurations.size() )
{
TunerConfiguration config = mTunerConfigurations.get( row );
switch( column )
{
case TUNER_TYPE:
return config.getTunerType().getLabel();
case CONFIGURATION_NAME:
return config.getName();
default:
break;
}
}
return null;
}
}

View File

@@ -30,8 +30,8 @@ import source.tuner.Tuner;
import source.tuner.TunerChannel;
import source.tuner.TunerChannelSource;
import source.tuner.TunerClass;
import source.tuner.TunerConfiguration;
import source.tuner.TunerType;
import source.tuner.configuration.TunerConfiguration;
import source.tuner.usb.USBTunerDevice;
import controller.ThreadPoolManager;
@@ -68,12 +68,6 @@ public class B100Tuner extends Tuner
return TunerType.ETTUS_WBX;
}
@Override
public JPanel getEditor( SettingsManager settingsManager )
{
return new B100TunerEditorPanel( this, settingsManager );
}
@Override
public void apply( TunerConfiguration config ) throws SourceException
{

View File

@@ -28,12 +28,12 @@ import settings.SettingsManager;
import source.SourceException;
import source.tuner.MixerTuner;
import source.tuner.MixerTunerDataLine;
import source.tuner.TunerChangeEvent;
import source.tuner.TunerEvent;
import source.tuner.TunerChannel;
import source.tuner.TunerChannelSource;
import source.tuner.TunerClass;
import source.tuner.TunerConfiguration;
import source.tuner.TunerType;
import source.tuner.configuration.TunerConfiguration;
public class FCDTuner extends MixerTuner
{
@@ -80,12 +80,6 @@ public class FCDTuner extends MixerTuner
return mController.getUSBAddress();
}
@Override
public JPanel getEditor( SettingsManager settingsManager )
{
return mController.getEditor( this, settingsManager );
}
@Override
public void apply( TunerConfiguration config )throws SourceException
{
@@ -118,7 +112,7 @@ public class FCDTuner extends MixerTuner
if( source != null )
{
broadcast( new TunerChangeEvent( this, TunerChangeEvent.Event.CHANNEL_COUNT ) );
broadcast( new TunerEvent( this, TunerEvent.Event.CHANNEL_COUNT ) );
}
return source;

View File

@@ -36,9 +36,9 @@ import org.usb4java.LibUsbException;
import settings.SettingsManager;
import source.SourceException;
import source.tuner.TunerClass;
import source.tuner.TunerConfiguration;
import source.tuner.TunerController;
import source.tuner.TunerType;
import source.tuner.configuration.TunerConfiguration;
import source.tuner.fcd.proV1.FCD1TunerController.Block;
public abstract class FCDTunerController extends TunerController

View File

@@ -19,8 +19,8 @@ package source.tuner.fcd.proV1;
import javax.xml.bind.annotation.XmlAttribute;
import source.tuner.TunerConfiguration;
import source.tuner.TunerType;
import source.tuner.configuration.TunerConfiguration;
import source.tuner.fcd.proV1.FCD1TunerController.LNAEnhance;
import source.tuner.fcd.proV1.FCD1TunerController.LNAGain;
import source.tuner.fcd.proV1.FCD1TunerController.MixerGain;

View File

@@ -49,8 +49,8 @@ import org.slf4j.LoggerFactory;
import settings.SettingsManager;
import source.SourceException;
import source.tuner.TunerConfiguration;
import source.tuner.TunerType;
import source.tuner.configuration.TunerConfiguration;
import source.tuner.fcd.proV1.FCD1TunerController.LNAEnhance;
import source.tuner.fcd.proV1.FCD1TunerController.LNAGain;
import source.tuner.fcd.proV1.FCD1TunerController.MixerGain;
@@ -426,14 +426,14 @@ public class FCD1TunerConfigurationPanel extends JPanel
@Override
public void actionPerformed( ActionEvent e )
{
TunerConfiguration config =
mSettingsManager.addNewTunerConfiguration(
TunerType.FUNCUBE_DONGLE_PRO,
"New Configuration" );
// TunerConfiguration config =
// mSettingsManager.addNewTunerConfiguration(
// TunerType.FUNCUBE_DONGLE_PRO,
// "New Configuration" );
mComboConfigurations.setModel( getModel() );
mComboConfigurations.setSelectedItem( config );
// mComboConfigurations.setSelectedItem( config );
repaint();
}
@@ -470,7 +470,7 @@ public class FCD1TunerConfigurationPanel extends JPanel
if( n == JOptionPane.YES_OPTION )
{
mSettingsManager.deleteTunerConfiguration( selected );
// mSettingsManager.deleteTunerConfiguration( selected );
mComboConfigurations.setModel( getModel() );
@@ -505,9 +505,9 @@ public class FCD1TunerConfigurationPanel extends JPanel
mCorrectionGain.setValue( config.getGainCorrection() );
mCorrectionPhase.setValue( config.getPhaseCorrection() );
mSettingsManager.setSelectedTunerConfiguration(
TunerType.FUNCUBE_DONGLE_PRO,
mController.getUSBAddress(), config );
// mSettingsManager.setSelectedTunerConfiguration(
// TunerType.FUNCUBE_DONGLE_PRO,
// mController.getUSBAddress(), config );
}
catch ( SourceException e1 )
{
@@ -524,16 +524,16 @@ public class FCD1TunerConfigurationPanel extends JPanel
private ComboBoxModel<FCD1TunerConfiguration> getModel()
{
ArrayList<TunerConfiguration> configs =
mSettingsManager.getTunerConfigurations( TunerType.FUNCUBE_DONGLE_PRO );
// ArrayList<TunerConfiguration> configs =
// mSettingsManager.getTunerConfigurations( TunerType.FUNCUBE_DONGLE_PRO );
DefaultComboBoxModel<FCD1TunerConfiguration> model =
new DefaultComboBoxModel<FCD1TunerConfiguration>();
for( TunerConfiguration config: configs )
{
model.addElement( (FCD1TunerConfiguration)config );
}
// for( TunerConfiguration config: configs )
// {
// model.addElement( (FCD1TunerConfiguration)config );
// }
return model;
}
@@ -541,16 +541,16 @@ public class FCD1TunerConfigurationPanel extends JPanel
@SuppressWarnings( "unused" )
private FCD1TunerConfiguration getNamedConfiguration( String name )
{
ArrayList<TunerConfiguration> configs =
mSettingsManager.getTunerConfigurations( TunerType.FUNCUBE_DONGLE_PRO );
// ArrayList<TunerConfiguration> configs =
// mSettingsManager.getTunerConfigurations( TunerType.FUNCUBE_DONGLE_PRO );
for( TunerConfiguration config: configs )
{
if( config.getName().contentEquals( name ) )
{
return (FCD1TunerConfiguration)config;
}
}
// for( TunerConfiguration config: configs )
// {
// if( config.getName().contentEquals( name ) )
// {
// return (FCD1TunerConfiguration)config;
// }
// }
return null;
}

View File

@@ -32,8 +32,8 @@ import org.usb4java.DeviceDescriptor;
import settings.SettingsManager;
import source.SourceException;
import source.tuner.TunerClass;
import source.tuner.TunerConfiguration;
import source.tuner.TunerType;
import source.tuner.configuration.TunerConfiguration;
import source.tuner.fcd.FCDCommand;
import source.tuner.fcd.FCDTuner;
import source.tuner.fcd.FCDTunerController;

View File

@@ -19,8 +19,8 @@ package source.tuner.fcd.proplusV2;
import javax.xml.bind.annotation.XmlAttribute;
import source.tuner.TunerConfiguration;
import source.tuner.TunerType;
import source.tuner.configuration.TunerConfiguration;
public class FCD2TunerConfiguration extends TunerConfiguration
{

View File

@@ -48,9 +48,9 @@ import org.slf4j.LoggerFactory;
import settings.SettingsManager;
import source.SourceException;
import source.tuner.TunerConfiguration;
import source.tuner.TunerConfigurationAssignment;
import source.tuner.TunerType;
import source.tuner.configuration.TunerConfiguration;
import source.tuner.configuration.TunerConfigurationAssignment;
public class FCD2TunerConfigurationPanel extends JPanel
{
@@ -218,26 +218,26 @@ public class FCD2TunerConfigurationPanel extends JPanel
* Lookup the save config and apply that config to update all of the
* controls
*/
TunerConfigurationAssignment savedConfig = mSettingsManager
.getSelectedTunerConfiguration(
TunerType.FUNCUBE_DONGLE_PRO_PLUS,
mController.getUSBAddress() );
if( savedConfig != null )
{
mSelectedConfig = getNamedConfiguration(
savedConfig.getTunerConfigurationName() );
}
// TunerConfigurationAssignment savedConfig = mSettingsManager
// .getSelectedTunerConfiguration(
// TunerType.FUNCUBE_DONGLE_PRO_PLUS,
// mController.getUSBAddress() );
//
// if( savedConfig != null )
// {
// mSelectedConfig = getNamedConfiguration(
// savedConfig.getTunerConfigurationName() );
// }
if( mSelectedConfig == null )
{
mSelectedConfig = mComboConfigurations.getItemAt( 0 );
//Store this config as the default for this tuner at this address
mSettingsManager
.setSelectedTunerConfiguration(
TunerType.FUNCUBE_DONGLE_PRO_PLUS,
mController.getUSBAddress(), mSelectedConfig );
// //Store this config as the default for this tuner at this address
// mSettingsManager
// .setSelectedTunerConfiguration(
// TunerType.FUNCUBE_DONGLE_PRO_PLUS,
// mController.getUSBAddress(), mSelectedConfig );
}
mComboConfigurations.setSelectedItem( mSelectedConfig );
@@ -252,15 +252,15 @@ public class FCD2TunerConfigurationPanel extends JPanel
@Override
public void actionPerformed( ActionEvent e )
{
TunerConfiguration config =
mSettingsManager
.addNewTunerConfiguration(
TunerType.FUNCUBE_DONGLE_PRO_PLUS,
"New Configuration" );
// TunerConfiguration config =
// mSettingsManager
// .addNewTunerConfiguration(
// TunerType.FUNCUBE_DONGLE_PRO_PLUS,
// "New Configuration" );
mComboConfigurations.setModel( getModel() );
mComboConfigurations.setSelectedItem( config );
// mComboConfigurations.setSelectedItem( config );
repaint();
}
@@ -293,8 +293,8 @@ public class FCD2TunerConfigurationPanel extends JPanel
if( n == JOptionPane.YES_OPTION )
{
mSettingsManager
.deleteTunerConfiguration( selected );
// mSettingsManager
// .deleteTunerConfiguration( selected );
mComboConfigurations.setModel( getModel() );
@@ -322,9 +322,9 @@ public class FCD2TunerConfigurationPanel extends JPanel
mMixerGain.setSelected( config.getGainMixer() );
mFrequencyCorrection.setValue( config.getFrequencyCorrection() );
mSettingsManager.setSelectedTunerConfiguration(
TunerType.FUNCUBE_DONGLE_PRO_PLUS,
mController.getUSBAddress(), config );
// mSettingsManager.setSelectedTunerConfiguration(
// TunerType.FUNCUBE_DONGLE_PRO_PLUS,
// mController.getUSBAddress(), config );
}
catch ( SourceException e1 )
{
@@ -341,34 +341,34 @@ public class FCD2TunerConfigurationPanel extends JPanel
private ComboBoxModel<FCD2TunerConfiguration> getModel()
{
ArrayList<TunerConfiguration> configs =
mSettingsManager
.getTunerConfigurations( TunerType.FUNCUBE_DONGLE_PRO_PLUS );
// ArrayList<TunerConfiguration> configs =
// mSettingsManager
// .getTunerConfigurations( TunerType.FUNCUBE_DONGLE_PRO_PLUS );
DefaultComboBoxModel<FCD2TunerConfiguration> model =
new DefaultComboBoxModel<FCD2TunerConfiguration>();
for( TunerConfiguration config: configs )
{
model.addElement( (FCD2TunerConfiguration)config );
}
// for( TunerConfiguration config: configs )
// {
// model.addElement( (FCD2TunerConfiguration)config );
// }
return model;
}
private FCD2TunerConfiguration getNamedConfiguration( String name )
{
ArrayList<TunerConfiguration> configs =
mSettingsManager
.getTunerConfigurations( TunerType.FUNCUBE_DONGLE_PRO_PLUS );
// ArrayList<TunerConfiguration> configs =
// mSettingsManager
// .getTunerConfigurations( TunerType.FUNCUBE_DONGLE_PRO_PLUS );
for( TunerConfiguration config: configs )
{
if( config.getName().contentEquals( name ) )
{
return (FCD2TunerConfiguration)config;
}
}
// for( TunerConfiguration config: configs )
// {
// if( config.getName().contentEquals( name ) )
// {
// return (FCD2TunerConfiguration)config;
// }
// }
return null;
}

View File

@@ -30,8 +30,8 @@ import org.usb4java.DeviceDescriptor;
import settings.SettingsManager;
import source.SourceException;
import source.tuner.TunerClass;
import source.tuner.TunerConfiguration;
import source.tuner.TunerType;
import source.tuner.configuration.TunerConfiguration;
import source.tuner.fcd.FCDCommand;
import source.tuner.fcd.FCDTuner;
import source.tuner.fcd.FCDTunerController;

View File

@@ -29,12 +29,12 @@ import sample.complex.ComplexBuffer;
import settings.SettingsManager;
import source.SourceException;
import source.tuner.Tuner;
import source.tuner.TunerChangeEvent;
import source.tuner.TunerEvent;
import source.tuner.TunerChannel;
import source.tuner.TunerChannelSource;
import source.tuner.TunerClass;
import source.tuner.TunerConfiguration;
import source.tuner.TunerType;
import source.tuner.configuration.TunerConfiguration;
import source.tuner.hackrf.HackRFTunerController.BoardID;
public class HackRFTuner extends Tuner
@@ -75,12 +75,6 @@ public class HackRFTuner extends Tuner
return TunerType.HACKRF;
}
@Override
public JPanel getEditor( SettingsManager settingsManager )
{
return new HackRFTunerEditorPanel( this, settingsManager );
}
@Override
public void apply( TunerConfiguration config ) throws SourceException
{
@@ -113,7 +107,7 @@ public class HackRFTuner extends Tuner
if( source != null )
{
broadcast( new TunerChangeEvent( this, TunerChangeEvent.Event.CHANNEL_COUNT ) );
broadcast( new TunerEvent( this, TunerEvent.Event.CHANNEL_COUNT ) );
}
return source;

View File

@@ -20,8 +20,8 @@ package source.tuner.hackrf;
import javax.xml.bind.annotation.XmlAttribute;
import source.tuner.TunerConfiguration;
import source.tuner.TunerType;
import source.tuner.configuration.TunerConfiguration;
import source.tuner.hackrf.HackRFTunerController.HackRFLNAGain;
import source.tuner.hackrf.HackRFTunerController.HackRFSampleRate;
import source.tuner.hackrf.HackRFTunerController.HackRFVGAGain;

View File

@@ -50,9 +50,9 @@ import org.slf4j.LoggerFactory;
import settings.SettingsManager;
import source.SourceException;
import source.tuner.TunerConfiguration;
import source.tuner.TunerConfigurationAssignment;
import source.tuner.TunerType;
import source.tuner.configuration.TunerConfiguration;
import source.tuner.configuration.TunerConfigurationAssignment;
import source.tuner.hackrf.HackRFTunerController.HackRFLNAGain;
import source.tuner.hackrf.HackRFTunerController.HackRFSampleRate;
import source.tuner.hackrf.HackRFTunerController.HackRFVGAGain;
@@ -117,11 +117,11 @@ public class HackRFTunerConfigurationPanel extends JPanel
mLog.error( "couldn't read hackrf serial number", e2 );
}
if( serial != null )
{
savedConfig = mSettingsManager.getSelectedTunerConfiguration(
TunerType.HACKRF, serial );
}
// if( serial != null )
// {
// savedConfig = mSettingsManager.getSelectedTunerConfiguration(
// TunerType.HACKRF, serial );
// }
if( savedConfig != null )
{
@@ -136,12 +136,12 @@ public class HackRFTunerConfigurationPanel extends JPanel
//Store this config as the default for this tuner at this address
if( serial != null )
{
mSettingsManager
.setSelectedTunerConfiguration( TunerType.HACKRF,
serial, mSelectedConfig );
}
// if( serial != null )
// {
// mSettingsManager
// .setSelectedTunerConfiguration( TunerType.HACKRF,
// serial, mSelectedConfig );
// }
}
mComboConfigurations.setSelectedItem( mSelectedConfig );
@@ -416,15 +416,15 @@ public class HackRFTunerConfigurationPanel extends JPanel
@Override
public void actionPerformed( ActionEvent e )
{
TunerConfiguration config =
mSettingsManager
.addNewTunerConfiguration(
TunerType.HACKRF,
"New Configuration" );
// TunerConfiguration config =
// mSettingsManager
// .addNewTunerConfiguration(
// TunerType.HACKRF,
// "New Configuration" );
mComboConfigurations.setModel( getModel() );
mComboConfigurations.setSelectedItem( config );
// mComboConfigurations.setSelectedItem( config );
repaint();
}
@@ -457,8 +457,8 @@ public class HackRFTunerConfigurationPanel extends JPanel
if( n == JOptionPane.YES_OPTION )
{
mSettingsManager
.deleteTunerConfiguration( selected );
// mSettingsManager
// .deleteTunerConfiguration( selected );
mComboConfigurations.setModel( getModel() );
@@ -493,10 +493,10 @@ public class HackRFTunerConfigurationPanel extends JPanel
mComboSampleRate.setSelectedItem( mSelectedConfig.getSampleRate() );
mSettingsManager.setSelectedTunerConfiguration(
TunerType.HACKRF, mController.getSerial().getSerialNumber(), config );
// mSettingsManager.setSelectedTunerConfiguration(
// TunerType.HACKRF, mController.getSerial().getSerialNumber(), config );
}
catch ( UsbException | SourceException e1 )
catch ( SourceException e1 )
{
JOptionPane.showMessageDialog(
HackRFTunerConfigurationPanel.this,
@@ -516,17 +516,17 @@ public class HackRFTunerConfigurationPanel extends JPanel
*/
private ComboBoxModel<HackRFTunerConfiguration> getModel()
{
ArrayList<TunerConfiguration> configs =
mSettingsManager
.getTunerConfigurations( TunerType.HACKRF );
// ArrayList<TunerConfiguration> configs =
// mSettingsManager
// .getTunerConfigurations( TunerType.HACKRF );
DefaultComboBoxModel<HackRFTunerConfiguration> model =
new DefaultComboBoxModel<HackRFTunerConfiguration>();
for( TunerConfiguration config: configs )
{
model.addElement( (HackRFTunerConfiguration)config );
}
// for( TunerConfiguration config: configs )
// {
// model.addElement( (HackRFTunerConfiguration)config );
// }
return model;
}
@@ -536,17 +536,17 @@ public class HackRFTunerConfigurationPanel extends JPanel
*/
private HackRFTunerConfiguration getNamedConfiguration( String name )
{
ArrayList<TunerConfiguration> configs =
mSettingsManager
.getTunerConfigurations( TunerType.HACKRF );
// ArrayList<TunerConfiguration> configs =
// mSettingsManager
// .getTunerConfigurations( TunerType.HACKRF );
for( TunerConfiguration config: configs )
{
if( config.getName().contentEquals( name ) )
{
return (HackRFTunerConfiguration)config;
}
}
// for( TunerConfiguration config: configs )
// {
// if( config.getName().contentEquals( name ) )
// {
// return (HackRFTunerConfiguration)config;
// }
// }
return null;
}

View File

@@ -81,8 +81,8 @@ import sample.Listener;
import sample.adapter.ByteSampleAdapter;
import sample.complex.ComplexBuffer;
import source.SourceException;
import source.tuner.TunerConfiguration;
import source.tuner.TunerController;
import source.tuner.configuration.TunerConfiguration;
import controller.ThreadPoolManager;
import controller.ThreadPoolManager.ThreadType;

View File

@@ -30,12 +30,12 @@ import sample.complex.ComplexBuffer;
import settings.SettingsManager;
import source.SourceException;
import source.tuner.Tuner;
import source.tuner.TunerChangeEvent;
import source.tuner.TunerEvent;
import source.tuner.TunerChannel;
import source.tuner.TunerChannelSource;
import source.tuner.TunerClass;
import source.tuner.TunerConfiguration;
import source.tuner.TunerType;
import source.tuner.configuration.TunerConfiguration;
import source.tuner.frequency.IFrequencyChangeListener;
import source.tuner.rtl.RTL2832TunerController.SampleRate;
import controller.ThreadPoolManager;
@@ -89,12 +89,6 @@ public class RTL2832Tuner extends Tuner
return mController.getTunerType();
}
@Override
public JPanel getEditor( SettingsManager settingsManager )
{
return mController.getEditor( settingsManager );
}
@Override
public void apply( TunerConfiguration config ) throws SourceException
{
@@ -161,7 +155,7 @@ public class RTL2832Tuner extends Tuner
if( source != null )
{
broadcast( new TunerChangeEvent( this, TunerChangeEvent.Event.CHANNEL_COUNT ) );
broadcast( new TunerEvent( this, TunerEvent.Event.CHANNEL_COUNT ) );
}
}
catch( Exception e )

View File

@@ -363,8 +363,6 @@ public abstract class RTL2832TunerController extends TunerController
}
}
public abstract JPanel getEditor( SettingsManager settingsManager );
public abstract void setSampleRateFilters( int sampleRate )
throws SourceException;

View File

@@ -19,8 +19,8 @@ package source.tuner.rtl.e4k;
import javax.xml.bind.annotation.XmlAttribute;
import source.tuner.TunerConfiguration;
import source.tuner.TunerType;
import source.tuner.configuration.TunerConfiguration;
import source.tuner.rtl.RTL2832TunerController.SampleRate;
import source.tuner.rtl.e4k.E4KTunerController.E4KEnhanceGain;
import source.tuner.rtl.e4k.E4KTunerController.E4KGain;

View File

@@ -50,9 +50,9 @@ import org.usb4java.LibUsbException;
import settings.SettingsManager;
import source.SourceException;
import source.tuner.TunerConfiguration;
import source.tuner.TunerConfigurationAssignment;
import source.tuner.TunerType;
import source.tuner.configuration.TunerConfiguration;
import source.tuner.configuration.TunerConfigurationAssignment;
import source.tuner.rtl.RTL2832TunerController.SampleRate;
import source.tuner.rtl.e4k.E4KTunerController.E4KEnhanceGain;
import source.tuner.rtl.e4k.E4KTunerController.E4KGain;
@@ -108,15 +108,15 @@ public class E4KTunerConfigurationPanel extends JPanel
mComboConfigurations.setModel( getModel() );
/* Determine which tuner configuration should be selected/displayed */
TunerConfigurationAssignment savedConfig = mSettingsManager
.getSelectedTunerConfiguration(
TunerType.ELONICS_E4000, mController.getUniqueID() );
if( savedConfig != null )
{
mSelectedConfig = getNamedConfiguration(
savedConfig.getTunerConfigurationName() );
}
// TunerConfigurationAssignment savedConfig = mSettingsManager
// .getSelectedTunerConfiguration(
// TunerType.ELONICS_E4000, mController.getUniqueID() );
//
// if( savedConfig != null )
// {
// mSelectedConfig = getNamedConfiguration(
// savedConfig.getTunerConfigurationName() );
// }
/* If we couldn't determine the saved/selected config, use the first one */
if( mSelectedConfig == null )
@@ -124,10 +124,10 @@ public class E4KTunerConfigurationPanel extends JPanel
mSelectedConfig = mComboConfigurations.getItemAt( 0 );
//Store this config as the default for this tuner at this address
mSettingsManager
.setSelectedTunerConfiguration(
TunerType.ELONICS_E4000,
mController.getUniqueID(), mSelectedConfig );
// mSettingsManager
// .setSelectedTunerConfiguration(
// TunerType.ELONICS_E4000,
// mController.getUniqueID(), mSelectedConfig );
}
mComboConfigurations.setSelectedItem( mSelectedConfig );
@@ -168,10 +168,10 @@ public class E4KTunerConfigurationPanel extends JPanel
/* Reset this named config as the assigned config for this
* tuner */
mSettingsManager
.setSelectedTunerConfiguration(
TunerType.ELONICS_E4000,
mController.getUniqueID(), mSelectedConfig );
// mSettingsManager
// .setSelectedTunerConfiguration(
// TunerType.ELONICS_E4000,
// mController.getUniqueID(), mSelectedConfig );
save();
}
@@ -541,15 +541,15 @@ public class E4KTunerConfigurationPanel extends JPanel
@Override
public void actionPerformed( ActionEvent e )
{
TunerConfiguration config =
mSettingsManager
.addNewTunerConfiguration(
TunerType.ELONICS_E4000,
"New Configuration" );
// TunerConfiguration config =
// mSettingsManager
// .addNewTunerConfiguration(
// TunerType.ELONICS_E4000,
// "New Configuration" );
mComboConfigurations.setModel( getModel() );
mComboConfigurations.setSelectedItem( config );
// mComboConfigurations.setSelectedItem( config );
repaint();
}
@@ -582,8 +582,8 @@ public class E4KTunerConfigurationPanel extends JPanel
if( n == JOptionPane.YES_OPTION )
{
mSettingsManager
.deleteTunerConfiguration( selected );
// mSettingsManager
// .deleteTunerConfiguration( selected );
mComboConfigurations.setModel( getModel() );
@@ -623,8 +623,8 @@ public class E4KTunerConfigurationPanel extends JPanel
mComboSampleRate.setSelectedItem( mSelectedConfig.getSampleRate() );
mSettingsManager.setSelectedTunerConfiguration(
TunerType.ELONICS_E4000, mController.getUniqueID(), config );
// mSettingsManager.setSelectedTunerConfiguration(
// TunerType.ELONICS_E4000, mController.getUniqueID(), config );
}
catch ( SourceException e1 )
{
@@ -646,17 +646,17 @@ public class E4KTunerConfigurationPanel extends JPanel
*/
private ComboBoxModel<E4KTunerConfiguration> getModel()
{
ArrayList<TunerConfiguration> configs =
mSettingsManager
.getTunerConfigurations( TunerType.ELONICS_E4000 );
// ArrayList<TunerConfiguration> configs =
// mSettingsManager
// .getTunerConfigurations( TunerType.ELONICS_E4000 );
DefaultComboBoxModel<E4KTunerConfiguration> model =
new DefaultComboBoxModel<E4KTunerConfiguration>();
for( TunerConfiguration config: configs )
{
model.addElement( (E4KTunerConfiguration)config );
}
// for( TunerConfiguration config: configs )
// {
// model.addElement( (E4KTunerConfiguration)config );
// }
return model;
}
@@ -666,17 +666,17 @@ public class E4KTunerConfigurationPanel extends JPanel
*/
private E4KTunerConfiguration getNamedConfiguration( String name )
{
ArrayList<TunerConfiguration> configs =
mSettingsManager
.getTunerConfigurations( TunerType.ELONICS_E4000 );
for( TunerConfiguration config: configs )
{
if( config.getName().contentEquals( name ) )
{
return (E4KTunerConfiguration)config;
}
}
// ArrayList<TunerConfiguration> configs =
// mSettingsManager
// .getTunerConfigurations( TunerType.ELONICS_E4000 );
//
// for( TunerConfiguration config: configs )
// {
// if( config.getName().contentEquals( name ) )
// {
// return (E4KTunerConfiguration)config;
// }
// }
return null;
}

View File

@@ -32,8 +32,8 @@ import org.usb4java.LibUsbException;
import settings.SettingsManager;
import source.SourceException;
import source.tuner.TunerConfiguration;
import source.tuner.TunerType;
import source.tuner.configuration.TunerConfiguration;
import source.tuner.rtl.RTL2832TunerController;
import controller.ThreadPoolManager;

View File

@@ -19,8 +19,8 @@ package source.tuner.rtl.r820t;
import javax.xml.bind.annotation.XmlAttribute;
import source.tuner.TunerConfiguration;
import source.tuner.TunerType;
import source.tuner.configuration.TunerConfiguration;
import source.tuner.rtl.RTL2832TunerController.SampleRate;
import source.tuner.rtl.r820t.R820TTunerController.R820TGain;
import source.tuner.rtl.r820t.R820TTunerController.R820TLNAGain;

View File

@@ -50,21 +50,22 @@ import org.usb4java.LibUsbException;
import settings.SettingsManager;
import source.SourceException;
import source.tuner.TunerConfiguration;
import source.tuner.TunerConfigurationAssignment;
import source.tuner.TunerType;
import source.tuner.configuration.TunerConfiguration;
import source.tuner.configuration.TunerConfigurationAssignment;
import source.tuner.rtl.RTL2832TunerController.SampleRate;
import source.tuner.rtl.r820t.R820TTunerController.R820TGain;
import source.tuner.rtl.r820t.R820TTunerController.R820TLNAGain;
import source.tuner.rtl.r820t.R820TTunerController.R820TMixerGain;
import source.tuner.rtl.r820t.R820TTunerController.R820TVGAGain;
public class R820TTunerConfigurationPanel extends JPanel
public class R820TTunerConfigurationEditorOld extends JPanel
{
private final static Logger mLog =
LoggerFactory.getLogger( R820TTunerConfigurationPanel.class );
private static final long serialVersionUID = 1L;
private final static Logger mLog =
LoggerFactory.getLogger( R820TTunerConfigurationEditorOld.class );
private static final R820TGain DEFAULT_GAIN = R820TGain.GAIN_279;
private SettingsManager mSettingsManager;
@@ -86,7 +87,7 @@ public class R820TTunerConfigurationPanel extends JPanel
private JComboBox<SampleRate> mComboSampleRate;
public R820TTunerConfigurationPanel( SettingsManager settingsManager,
public R820TTunerConfigurationEditorOld( SettingsManager settingsManager,
R820TTunerController controller )
{
mSettingsManager = settingsManager;
@@ -110,27 +111,27 @@ public class R820TTunerConfigurationPanel extends JPanel
mComboConfigurations.setModel( getModel() );
/* Determine which tuner configuration should be selected/displayed */
TunerConfigurationAssignment savedConfig = mSettingsManager
.getSelectedTunerConfiguration(
TunerType.RAFAELMICRO_R820T, mController.getUniqueID() );
if( savedConfig != null )
{
mSelectedConfig = getNamedConfiguration(
savedConfig.getTunerConfigurationName() );
}
// TunerConfigurationAssignment savedConfig = mSettingsManager
// .getSelectedTunerConfiguration(
// TunerType.RAFAELMICRO_R820T, mController.getUniqueID() );
//
// if( savedConfig != null )
// {
// mSelectedConfig = getNamedConfiguration(
// savedConfig.getTunerConfigurationName() );
// }
/* If we couldn't determine the saved/selected config, use the first one */
if( mSelectedConfig == null )
{
mSelectedConfig = mComboConfigurations.getItemAt( 0 );
//Store this config as the default for this tuner at this address
mSettingsManager
.setSelectedTunerConfiguration(
TunerType.RAFAELMICRO_R820T,
mController.getUniqueID(), mSelectedConfig );
}
// if( mSelectedConfig == null )
// {
// mSelectedConfig = mComboConfigurations.getItemAt( 0 );
//
// //Store this config as the default for this tuner at this address
// mSettingsManager
// .setSelectedTunerConfiguration(
// TunerType.RAFAELMICRO_R820T,
// mController.getUniqueID(), mSelectedConfig );
// }
mComboConfigurations.setSelectedItem( mSelectedConfig );
@@ -217,7 +218,7 @@ public class R820TTunerConfigurationPanel extends JPanel
catch ( SourceException e1 )
{
JOptionPane.showMessageDialog(
R820TTunerConfigurationPanel.this,
R820TTunerConfigurationEditorOld.this,
"R820T Tuner Controller - couldn't apply "
+ "frequency correction value: " + value +
e1.getLocalizedMessage() );
@@ -256,7 +257,7 @@ public class R820TTunerConfigurationPanel extends JPanel
catch ( SourceException | LibUsbException eSampleRate )
{
JOptionPane.showMessageDialog(
R820TTunerConfigurationPanel.this,
R820TTunerConfigurationEditorOld.this,
"R820T Tuner Controller - couldn't apply the sample "
+ "rate setting [" + sampleRate.getLabel() + "] " +
eSampleRate.getLocalizedMessage() );
@@ -380,7 +381,7 @@ public class R820TTunerConfigurationPanel extends JPanel
catch ( UsbException e )
{
JOptionPane.showMessageDialog(
R820TTunerConfigurationPanel.this,
R820TTunerConfigurationEditorOld.this,
"R820T Tuner Controller - couldn't apply the gain "
+ "setting - " + e.getLocalizedMessage() );
@@ -431,7 +432,7 @@ public class R820TTunerConfigurationPanel extends JPanel
catch ( UsbException e )
{
JOptionPane.showMessageDialog(
R820TTunerConfigurationPanel.this,
R820TTunerConfigurationEditorOld.this,
"R820T Tuner Controller - couldn't apply the mixer "
+ "gain setting - " + e.getLocalizedMessage() );
@@ -477,7 +478,7 @@ public class R820TTunerConfigurationPanel extends JPanel
catch ( UsbException e )
{
JOptionPane.showMessageDialog(
R820TTunerConfigurationPanel.this,
R820TTunerConfigurationEditorOld.this,
"R820T Tuner Controller - couldn't apply the LNA "
+ "gain setting - " + e.getLocalizedMessage() );
@@ -521,7 +522,7 @@ public class R820TTunerConfigurationPanel extends JPanel
catch ( UsbException e )
{
JOptionPane.showMessageDialog(
R820TTunerConfigurationPanel.this,
R820TTunerConfigurationEditorOld.this,
"R820T Tuner Controller - couldn't apply the VGA "
+ "gain setting - " + e.getLocalizedMessage() );
@@ -548,17 +549,17 @@ public class R820TTunerConfigurationPanel extends JPanel
@Override
public void actionPerformed( ActionEvent e )
{
TunerConfiguration config =
mSettingsManager
.addNewTunerConfiguration(
TunerType.RAFAELMICRO_R820T,
"New Configuration" );
mComboConfigurations.setModel( getModel() );
mComboConfigurations.setSelectedItem( config );
repaint();
// TunerConfiguration config =
// mSettingsManager
// .addNewTunerConfiguration(
// TunerType.RAFAELMICRO_R820T,
// "New Configuration" );
//
// mComboConfigurations.setModel( getModel() );
//
// mComboConfigurations.setSelectedItem( config );
//
// repaint();
}
} );
@@ -581,7 +582,7 @@ public class R820TTunerConfigurationPanel extends JPanel
if( selected != null )
{
int n = JOptionPane.showConfirmDialog(
R820TTunerConfigurationPanel.this,
R820TTunerConfigurationEditorOld.this,
"Are you sure you want to delete '"
+ selected.getName() + "'?",
"Are you sure?",
@@ -589,8 +590,8 @@ public class R820TTunerConfigurationPanel extends JPanel
if( n == JOptionPane.YES_OPTION )
{
mSettingsManager
.deleteTunerConfiguration( selected );
// mSettingsManager
// .deleteTunerConfiguration( selected );
mComboConfigurations.setModel( getModel() );
@@ -630,13 +631,13 @@ public class R820TTunerConfigurationPanel extends JPanel
mComboSampleRate.setSelectedItem( mSelectedConfig.getSampleRate() );
mSettingsManager.setSelectedTunerConfiguration(
TunerType.RAFAELMICRO_R820T, mController.getUniqueID(), config );
// mSettingsManager.setSelectedTunerConfiguration(
// TunerType.RAFAELMICRO_R820T, mController.getUniqueID(), config );
}
catch ( SourceException e1 )
{
JOptionPane.showMessageDialog(
R820TTunerConfigurationPanel.this,
R820TTunerConfigurationEditorOld.this,
"R820T Tuner Controller - couldn't "
+ "apply the tuner configuration settings - " +
e1.getLocalizedMessage() );
@@ -653,17 +654,17 @@ public class R820TTunerConfigurationPanel extends JPanel
*/
private ComboBoxModel<R820TTunerConfiguration> getModel()
{
ArrayList<TunerConfiguration> configs =
mSettingsManager
.getTunerConfigurations( TunerType.RAFAELMICRO_R820T );
// ArrayList<TunerConfiguration> configs =
// mSettingsManager
// .getTunerConfigurations( TunerType.RAFAELMICRO_R820T );
DefaultComboBoxModel<R820TTunerConfiguration> model =
new DefaultComboBoxModel<R820TTunerConfiguration>();
for( TunerConfiguration config: configs )
{
model.addElement( (R820TTunerConfiguration)config );
}
// for( TunerConfiguration config: configs )
// {
// model.addElement( (R820TTunerConfiguration)config );
// }
return model;
}
@@ -673,17 +674,17 @@ public class R820TTunerConfigurationPanel extends JPanel
*/
private R820TTunerConfiguration getNamedConfiguration( String name )
{
ArrayList<TunerConfiguration> configs =
mSettingsManager
.getTunerConfigurations( TunerType.RAFAELMICRO_R820T );
for( TunerConfiguration config: configs )
{
if( config.getName().contentEquals( name ) )
{
return (R820TTunerConfiguration)config;
}
}
// ArrayList<TunerConfiguration> configs =
// mSettingsManager
// .getTunerConfigurations( TunerType.RAFAELMICRO_R820T );
//
// for( TunerConfiguration config: configs )
// {
// if( config.getName().contentEquals( name ) )
// {
// return (R820TTunerConfiguration)config;
// }
// }
return null;
}

View File

@@ -1,6 +1,6 @@
/*******************************************************************************
* SDR Trunk
* Copyright (C) 2014 Dennis Sheirer
* Copyright (C) 2014-2016 Dennis Sheirer
*
* Java port of librtlsdr <https://github.com/steve-m/librtlsdr>
*
@@ -33,10 +33,9 @@ import org.usb4java.Device;
import org.usb4java.DeviceDescriptor;
import org.usb4java.LibUsbException;
import settings.SettingsManager;
import source.SourceException;
import source.tuner.TunerConfiguration;
import source.tuner.TunerType;
import source.tuner.configuration.TunerConfiguration;
import source.tuner.rtl.RTL2832TunerController;
import controller.ThreadPoolManager;
@@ -136,19 +135,6 @@ public class R820TTunerController extends RTL2832TunerController
}
}
/**
* Controller gui editor component for this tuner
*/
public JPanel getEditor( SettingsManager settingsManager )
{
if( mEditor == null )
{
mEditor = new R820TTunerEditorPanel( this, settingsManager );
}
return mEditor;
}
/**
* Not implemented.
*/

View File

@@ -0,0 +1,446 @@
/*******************************************************************************
* 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 source.tuner.rtl.r820t;
import java.awt.EventQueue;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.FocusEvent;
import java.awt.event.FocusListener;
import java.text.DecimalFormat;
import javax.swing.BorderFactory;
import javax.swing.JComboBox;
import javax.swing.JLabel;
import javax.swing.JOptionPane;
import javax.swing.JPanel;
import javax.swing.JSpinner;
import javax.swing.JTextField;
import javax.swing.SpinnerModel;
import javax.swing.SpinnerNumberModel;
import javax.swing.SwingConstants;
import javax.swing.event.ChangeEvent;
import javax.swing.event.ChangeListener;
import javax.usb.UsbException;
import net.miginfocom.swing.MigLayout;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.usb4java.LibUsbException;
import source.SourceException;
import source.tuner.configuration.TunerConfiguration;
import source.tuner.configuration.TunerConfigurationEditor;
import source.tuner.configuration.TunerConfigurationEvent;
import source.tuner.configuration.TunerConfigurationEvent.Event;
import source.tuner.configuration.TunerConfigurationModel;
import source.tuner.rtl.RTL2832Tuner;
import source.tuner.rtl.RTL2832TunerController.SampleRate;
import source.tuner.rtl.r820t.R820TTunerController.R820TGain;
import source.tuner.rtl.r820t.R820TTunerController.R820TLNAGain;
import source.tuner.rtl.r820t.R820TTunerController.R820TMixerGain;
import source.tuner.rtl.r820t.R820TTunerController.R820TVGAGain;
public class R820TTunerEditor extends TunerConfigurationEditor
{
private final static Logger mLog =
LoggerFactory.getLogger( R820TTunerEditor.class );
private static final long serialVersionUID = 1L;
private static final R820TGain DEFAULT_GAIN = R820TGain.GAIN_279;
private R820TTunerController mController;
private JTextField mConfigurationName;
private JSpinner mFrequencyCorrection;
private JComboBox<R820TGain> mComboMasterGain;
private JComboBox<R820TMixerGain> mComboMixerGain;
private JComboBox<R820TLNAGain> mComboLNAGain;
private JComboBox<R820TVGAGain> mComboVGAGain;
private JComboBox<SampleRate> mComboSampleRate;
public R820TTunerEditor( TunerConfigurationModel tunerConfigurationModel,
RTL2832Tuner tuner )
{
super( tunerConfigurationModel );
mController = (R820TTunerController)tuner.getController();
init();
}
@Override
public void save()
{
if( hasItem() )
{
R820TTunerConfiguration config = getConfiguration();
config.setName( mConfigurationName.getText() );
double value = ((SpinnerNumberModel)mFrequencyCorrection
.getModel()).getNumber().doubleValue();
config.setFrequencyCorrection( value );
config.setSampleRate( (SampleRate)mComboSampleRate.getSelectedItem() );
R820TGain gain = (R820TGain)mComboMasterGain.getSelectedItem();
config.setMasterGain( gain );
R820TMixerGain mixerGain = (R820TMixerGain)mComboMixerGain.getSelectedItem();
config.setMixerGain( mixerGain );
R820TLNAGain lnaGain = (R820TLNAGain)mComboLNAGain.getSelectedItem();
config.setLNAGain( lnaGain );
R820TVGAGain vgaGain = (R820TVGAGain)mComboVGAGain.getSelectedItem();
config.setVGAGain( vgaGain );
getTunerConfigurationModel().broadcast(
new TunerConfigurationEvent( getConfiguration(), Event.CONFIGURATION_CHANGE ) );
}
}
@Override
public void setItem( TunerConfiguration item )
{
super.setItem( item );
if( hasItem() )
{
R820TTunerConfiguration config = getConfiguration();
mConfigurationName.setText( config.getName() );
mFrequencyCorrection.setValue( config.getFrequencyCorrection() );
mComboSampleRate.setSelectedItem( config.getSampleRate() );
mComboMasterGain.setSelectedItem( config.getMasterGain() );
mComboMixerGain.setSelectedItem( config.getMixerGain() );
mComboLNAGain.setSelectedItem( config.getLNAGain() );
mComboVGAGain.setSelectedItem( config.getVGAGain() );
}
}
private R820TTunerConfiguration getConfiguration()
{
if( hasItem() )
{
return (R820TTunerConfiguration)getItem();
}
return null;
}
private void init()
{
setLayout( new MigLayout( "fill,wrap 2", "[right][grow]", "[][][grow]" ) );
add( new JLabel( "R820T Tuner" ), "span, align center" );
/**
* Tuner Configuration Name
*/
mConfigurationName = new JTextField();
mConfigurationName.addFocusListener( new FocusListener()
{
@Override
public void focusLost( FocusEvent e )
{
save();
}
@Override
public void focusGained( FocusEvent e ) {}
} );
add( new JLabel( "Configuration:" ) );
add( mConfigurationName, "growx,push" );
/**
* Frequency Correction
*/
SpinnerModel model =
new SpinnerNumberModel( 0.0, //initial value
-1000.0, //min
1000.0, //max
0.1 ); //step
mFrequencyCorrection = new JSpinner( model );
JSpinner.NumberEditor editor =
(JSpinner.NumberEditor)mFrequencyCorrection.getEditor();
DecimalFormat format = editor.getFormat();
format.setMinimumFractionDigits( 1 );
editor.getTextField().setHorizontalAlignment( SwingConstants.CENTER );
mFrequencyCorrection.addChangeListener( new ChangeListener()
{
@Override
public void stateChanged( ChangeEvent e )
{
final double value = ((SpinnerNumberModel)mFrequencyCorrection
.getModel()).getNumber().doubleValue();
try
{
mController.setFrequencyCorrection( value );
}
catch ( SourceException e1 )
{
mLog.error( "Error setting frequency correction value", e1 );
}
save();
}
} );
add( new JLabel( "Correction PPM:" ) );
add( mFrequencyCorrection, "growx,push" );
/**
* Sample Rate
*/
mComboSampleRate = new JComboBox<>( SampleRate.values() );
mComboSampleRate.addActionListener( new ActionListener()
{
@Override
public void actionPerformed( ActionEvent e )
{
SampleRate sampleRate =
(SampleRate)mComboSampleRate.getSelectedItem();
try
{
mController.setSampleRate( sampleRate );
save();
}
catch ( SourceException | LibUsbException eSampleRate )
{
JOptionPane.showMessageDialog(
R820TTunerEditor.this,
"R820T Tuner Controller - couldn't apply the sample "
+ "rate setting [" + sampleRate.getLabel() + "] " +
eSampleRate.getLocalizedMessage() );
mLog.error( "R820T Tuner Controller - couldn't apply sample "
+ "rate setting [" + sampleRate.getLabel() + "]",
eSampleRate );
}
}
} );
add( new JLabel( "Sample Rate:" ) );
add( mComboSampleRate, "growx,push" );
/**
* Gain Controls
*/
JPanel gainPanel = new JPanel();
gainPanel.setLayout( new MigLayout( "", "[grow,fill]", "[grow,fill]" ) );
gainPanel.setBorder( BorderFactory.createTitledBorder( "Gain" ) );
/* Master Gain Control */
mComboMasterGain = new JComboBox<R820TGain>( R820TGain.values() );
mComboMasterGain.addActionListener( new ActionListener()
{
@Override
public void actionPerformed( ActionEvent arg0 )
{
try
{
R820TGain gain = (R820TGain)mComboMasterGain.getSelectedItem();
mController.setGain( (R820TGain)mComboMasterGain.getSelectedItem(), true );
if( gain == R820TGain.MANUAL )
{
mComboMixerGain.setSelectedItem( gain.getMixerGain() );
mComboMixerGain.setEnabled( true );
mComboLNAGain.setSelectedItem( gain.getLNAGain() );
mComboLNAGain.setEnabled( true );
mComboVGAGain.setSelectedItem( gain.getVGAGain() );
mComboVGAGain.setEnabled( true );
}
else
{
mComboMixerGain.setEnabled( false );
mComboMixerGain.setSelectedItem( gain.getMixerGain() );
mComboLNAGain.setEnabled( false );
mComboLNAGain.setSelectedItem( gain.getLNAGain() );
mComboVGAGain.setEnabled( false );
mComboVGAGain.setSelectedItem( gain.getVGAGain() );
}
save();
}
catch ( UsbException e )
{
JOptionPane.showMessageDialog(
R820TTunerEditor.this,
"R820T Tuner Controller - couldn't apply the gain "
+ "setting - " + e.getLocalizedMessage() );
mLog.error( "R820T Tuner Controller - couldn't apply "
+ "gain setting - ", e );
}
}
} );
mComboMasterGain.setToolTipText( "<html>Select <b>AUTOMATIC</b> for auto "
+ "gain, <b>MANUAL</b> to enable<br> independent control of "
+ "<i>Mixer</i>, <i>LNA</i> and <i>Enhance</i> gain<br>"
+ "settings, or one of the individual gain settings for<br>"
+ "semi-manual gain control</html>" );
gainPanel.add( new JLabel( "Master" ) );
gainPanel.add( mComboMasterGain );
/* Mixer Gain Control */
mComboMixerGain = new JComboBox<R820TMixerGain>( R820TMixerGain.values() );
mComboMixerGain.addActionListener( new ActionListener()
{
@Override
public void actionPerformed( ActionEvent arg0 )
{
EventQueue.invokeLater( new Runnable()
{
@Override
public void run()
{
try
{
R820TMixerGain mixerGain =
(R820TMixerGain)mComboMixerGain.getSelectedItem();
if( mixerGain == null )
{
mixerGain = DEFAULT_GAIN.getMixerGain();
}
if( mComboMixerGain.isEnabled() )
{
mController.setMixerGain( mixerGain, true );
}
save();
}
catch ( UsbException e )
{
JOptionPane.showMessageDialog( R820TTunerEditor.this,
"R820T Tuner Controller - couldn't apply the mixer "
+ "gain setting - " + e.getLocalizedMessage() );
mLog.error( "R820T Tuner Controller - couldn't apply mixer "
+ "gain setting - ", e );
}
}
} );
}
} );
mComboMixerGain.setToolTipText( "<html>Mixer Gain. Set master gain "
+ "to <b>MASTER</b> to enable adjustment</html>" );
mComboMixerGain.setEnabled( false );
gainPanel.add( new JLabel( "Mixer" ) );
gainPanel.add( mComboMixerGain, "wrap" );
/* LNA Gain Control */
mComboLNAGain = new JComboBox<R820TLNAGain>( R820TLNAGain.values() );
mComboLNAGain.addActionListener( new ActionListener()
{
@Override
public void actionPerformed( ActionEvent arg0 )
{
try
{
R820TLNAGain lnaGain =
(R820TLNAGain)mComboLNAGain.getSelectedItem();
if ( lnaGain == null )
{
lnaGain = DEFAULT_GAIN.getLNAGain();
}
if( mComboLNAGain.isEnabled() )
{
mController.setLNAGain( lnaGain, true );
}
save();
}
catch ( UsbException e )
{
JOptionPane.showMessageDialog( R820TTunerEditor.this,
"R820T Tuner Controller - couldn't apply the LNA "
+ "gain setting - " + e.getLocalizedMessage() );
mLog.error( "R820T Tuner Controller - couldn't apply LNA "
+ "gain setting - ", e );
}
}
} );
mComboLNAGain.setToolTipText( "<html>LNA Gain. Set master gain "
+ "to <b>MANUAL</b> to enable adjustment</html>" );
mComboLNAGain.setEnabled( false );
gainPanel.add( new JLabel( "LNA" ) );
gainPanel.add( mComboLNAGain );
/* VGA Gain Control */
mComboVGAGain = new JComboBox<R820TVGAGain>( R820TVGAGain.values() );
mComboVGAGain.addActionListener( new ActionListener()
{
@Override
public void actionPerformed( ActionEvent arg0 )
{
try
{
R820TVGAGain vgaGain =
(R820TVGAGain)mComboVGAGain.getSelectedItem();
if( vgaGain == null )
{
vgaGain = DEFAULT_GAIN.getVGAGain();
}
if( mComboVGAGain.isEnabled() )
{
mController.setVGAGain( vgaGain, true );
}
save();
}
catch ( UsbException e )
{
JOptionPane.showMessageDialog( R820TTunerEditor.this,
"R820T Tuner Controller - couldn't apply the VGA "
+ "gain setting - " + e.getLocalizedMessage() );
mLog.error( "R820T Tuner Controller - couldn't apply VGA "
+ "gain setting", e );
}
}
} );
mComboVGAGain.setToolTipText( "<html>VGA Gain. Set master gain "
+ "to <b>MANUAL</b> to enable adjustment</html>" );
mComboVGAGain.setEnabled( false );
gainPanel.add( new JLabel( "VGA" ) );
gainPanel.add( mComboVGAGain, "wrap" );
add( gainPanel, "span" );
}
}

View File

@@ -1,121 +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 source.tuner.rtl.r820t;
import gui.control.JFrequencyControl;
import java.awt.Color;
import java.awt.EventQueue;
import javax.swing.JLabel;
import javax.swing.JPanel;
import net.miginfocom.swing.MigLayout;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import settings.SettingsManager;
import source.SourceException;
import source.tuner.frequency.FrequencyChangeEvent;
import source.tuner.frequency.FrequencyChangeEvent.Event;
import source.tuner.frequency.IFrequencyChangeProcessor;
import source.tuner.rtl.RTL2832InfoPanel;
import com.jidesoft.swing.JideTabbedPane;
public class R820TTunerEditorPanel extends JPanel implements IFrequencyChangeProcessor
{
private final static Logger mLog =
LoggerFactory.getLogger( R820TTunerEditorPanel.class );
private static final long serialVersionUID = 1L;
private R820TTunerController mController;
private SettingsManager mSettingsManager;
private JFrequencyControl mFrequencyControl;
public R820TTunerEditorPanel( R820TTunerController controller,
SettingsManager settingsManager )
{
mController = controller;
mSettingsManager = settingsManager;
initGUI();
}
private void initGUI()
{
setLayout( new MigLayout( "fill,wrap 2", "[right][grow]", "[][][grow]" ) );
add( new JLabel( "RTL2832 with R820T Tuner" ), "span 2, align center, wrap" );
mFrequencyControl = new JFrequencyControl();
mFrequencyControl.addListener( this );
/* Add frequency control as frequency change listener. */
mController.addListener( mFrequencyControl );
mFrequencyControl.setFrequency( mController.getFrequency(), false );
add( mFrequencyControl, "span 2, align center, wrap" );
JideTabbedPane tabs = new JideTabbedPane();
tabs.setFont( this.getFont() );
tabs.setForeground( Color.BLACK );
tabs.addTab( "Configuration",
new R820TTunerConfigurationPanel( mSettingsManager, mController ) );
tabs.addTab( "Info", new RTL2832InfoPanel( mController ) );
add( tabs, "grow,push,span" );
}
/**
* Frequency change listener for the frequency control gui component to
* apply end-user requested frequency changes against the tuner
*/
@Override
public void frequencyChanged( FrequencyChangeEvent event )
{
if( event.getEvent() == Event.NOTIFICATION_FREQUENCY_CHANGE )
{
final long frequency = event.getValue().longValue();
EventQueue.invokeLater( new Runnable()
{
@Override
public void run()
{
try
{
mController.setFrequency( frequency );
}
catch ( SourceException e )
{
mLog.error( "R820T Tuner Controller - error setting frequency [" +
frequency + "]", e );
}
}
} );
}
}
}

View File

@@ -62,7 +62,7 @@ import settings.ColorSettingMenuItem;
import settings.SettingsManager;
import source.SourceException;
import source.tuner.Tuner;
import source.tuner.TunerSelectionListener;
import source.tuner.TunerEvent;
import source.tuner.frequency.FrequencyChangeEvent;
import source.tuner.frequency.FrequencyChangeEvent.Event;
import source.tuner.frequency.IFrequencyChangeProcessor;
@@ -78,7 +78,6 @@ import spectrum.menu.SmoothingTypeItem;
import com.jidesoft.swing.JideSplitPane;
import controller.ConfigurationControllerModel;
import controller.channel.Channel;
import controller.channel.ChannelModel;
import controller.channel.ChannelProcessingManager;
@@ -89,8 +88,7 @@ import dsp.filter.smoothing.SmoothingFilter.SmoothingType;
public class SpectralDisplayPanel extends JPanel
implements Listener<ComplexBuffer>,
IFrequencyChangeProcessor,
IDFTWidthChangeProcessor,
TunerSelectionListener
IDFTWidthChangeProcessor
{
private static final long serialVersionUID = 1L;
@@ -114,7 +112,6 @@ public class SpectralDisplayPanel extends JPanel
private OverlayPanel mOverlayPanel;
private DFTProcessor mDFTProcessor;
private DFTResultsConverter mDFTConverter;
private ConfigurationControllerModel mControllerModel;
private ChannelModel mChannelModel;
private ChannelProcessingManager mChannelProcessingManager;
private SettingsManager mSettingsManager;
@@ -132,12 +129,10 @@ public class SpectralDisplayPanel extends JPanel
* the DFT is translated to decibels for display in the spectrum and
* waterfall components.
*/
public SpectralDisplayPanel( ConfigurationControllerModel controllerModel,
ChannelModel channelModel,
public SpectralDisplayPanel( ChannelModel channelModel,
ChannelProcessingManager channelProcessingManager,
SettingsManager settingsManager )
{
mControllerModel = controllerModel;
mChannelModel = channelModel;
mChannelProcessingManager = channelProcessingManager;
mSettingsManager = settingsManager;
@@ -146,12 +141,6 @@ public class SpectralDisplayPanel extends JPanel
mOverlayPanel = new OverlayPanel( mSettingsManager, mChannelModel );
mWaterfallPanel = new WaterfallPanel( mSettingsManager );
//Register to receive tuner selection events
if( mControllerModel != null )
{
mControllerModel.addListener( (TunerSelectionListener)this );
}
init();
loadSettings();
@@ -190,12 +179,6 @@ public class SpectralDisplayPanel extends JPanel
/* De-register from receiving samples when the window closes */
clearTuner();
if( mControllerModel != null )
{
mControllerModel.removeListener( (TunerSelectionListener)this );
}
mControllerModel = null;
mSettingsManager = null;
mDFTProcessor.dispose();
@@ -217,6 +200,11 @@ public class SpectralDisplayPanel extends JPanel
mTuner = null;
}
public Listener<TunerEvent> getTunerEventListener()
{
return new TunerSelectionListener( this );
}
/**
* Queues an FFT size change request. The scheduled executor will apply
* the change when it runs.
@@ -442,11 +430,10 @@ public class SpectralDisplayPanel extends JPanel
}
/**
* Responds to tuner selection event by deregistering from the current
* Responds to tuner event by deregistering from the current
* complex sample buffer source and registering with the tuner argument.
*/
@Override
public void tunerSelected( Tuner tuner )
public void showTuner( Tuner tuner )
{
clearTuner();
@@ -975,4 +962,26 @@ public class SpectralDisplayPanel extends JPanel
} );
}
}
/**
* Provides tuner event listener interface for showing tuners in this display
*/
public class TunerSelectionListener implements Listener<TunerEvent>
{
private SpectralDisplayPanel mSpectralDisplayPanel;
public TunerSelectionListener( SpectralDisplayPanel spectralDisplayPanel )
{
mSpectralDisplayPanel = spectralDisplayPanel;
}
@Override
public void receive( TunerEvent event )
{
if( event.getEvent() == TunerEvent.Event.REQUEST_MAIN_SPECTRAL_DISPLAY )
{
mSpectralDisplayPanel.showTuner( event.getTuner() );
}
}
}
}

View File

@@ -26,7 +26,6 @@ import javax.swing.JFrame;
import net.miginfocom.swing.MigLayout;
import settings.SettingsManager;
import source.tuner.Tuner;
import controller.ConfigurationControllerModel;
import controller.channel.ChannelModel;
import controller.channel.ChannelProcessingManager;
@@ -36,8 +35,7 @@ public class SpectrumFrame extends JFrame implements WindowListener
private SpectralDisplayPanel mSpectralDisplayPanel;
public SpectrumFrame( ConfigurationControllerModel controllerModel,
ChannelModel channelModel,
public SpectrumFrame( ChannelModel channelModel,
ChannelProcessingManager channelProcessingManager,
SettingsManager settingsManager,
Tuner tuner )
@@ -48,10 +46,10 @@ public class SpectrumFrame extends JFrame implements WindowListener
setLayout( new MigLayout( "insets 0 0 0 0", "[grow]", "[grow]") );
mSpectralDisplayPanel = new SpectralDisplayPanel( controllerModel,
channelModel, channelProcessingManager, settingsManager );
mSpectralDisplayPanel.tunerSelected( tuner );
mSpectralDisplayPanel = new SpectralDisplayPanel( channelModel,
channelProcessingManager, settingsManager );
mSpectralDisplayPanel.showTuner( tuner );
add( mSpectralDisplayPanel, "grow" );
/* Register a shutdown listener */