mirror of
https://github.com/DSheirer/sdrtrunk.git
synced 2026-11-11 16:17:24 -05:00
Note: Several of the decoders are currently non-functioning in this commit. If you want the latest functioning codebase, please checkout the commit prior to this one. All decoders will eventually be updated with this new architecture. Currently broken: - Logging and recording - Aux decoders (Fleetsync/MDC/LoJack/Tait) - LTR/Passport decoders Changes in this commit: - Module architecture for decoders and components with central provisioning by the DecoderFactory - Transition from Complex sample stream processing to float buffer processing for improved memory management - Redesigned filter structures - to support buffers and streams - Resolved several memory leak issues - Universal sharing of the thread pool manager - Added centralized audio management with call/user prioritization and new gui with mute/volume controls - Embedded audio metadata for eventual streaming support - Redesigned ProcessingChain to support independent re-use - Added new TrafficChannelManager to handle traffic channel allocations - Traffic Channel pool size and Call timeout available in P25 and MPT1327 configs - Redesigned channel and decoder gui components
171 lines
4.1 KiB
Java
171 lines
4.1 KiB
Java
/*******************************************************************************
|
|
* SDR Trunk
|
|
* Copyright (C) 2014 Dennis Sheirer
|
|
*
|
|
* This program is free software: you can redistribute it and/or modify
|
|
* it under the terms of the GNU General Public License as published by
|
|
* the Free Software Foundation, either version 3 of the License, or
|
|
* (at your option) any later version.
|
|
*
|
|
* This program is distributed in the hope that it will be useful,
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
* GNU General Public License for more details.
|
|
*
|
|
* You should have received a copy of the GNU General Public License
|
|
* along with this program. If not, see <http://www.gnu.org/licenses/>
|
|
******************************************************************************/
|
|
package controller.channel;
|
|
|
|
import java.awt.Color;
|
|
import java.text.DecimalFormat;
|
|
|
|
import javax.swing.JPanel;
|
|
import javax.swing.JPopupMenu;
|
|
|
|
import source.tuner.TunerChannel;
|
|
import controller.ConfigurableNode;
|
|
import controller.site.SiteNode;
|
|
import controller.system.SystemNode;
|
|
|
|
/**
|
|
* A channel has all of the pieces needed to wire together a source, decoder,
|
|
* event logger and recorder and be started and stopped.
|
|
*/
|
|
public class ChannelNode extends ConfigurableNode implements ChannelEventListener
|
|
{
|
|
private static final long serialVersionUID = 1L;
|
|
|
|
private static DecimalFormat sFORMAT = new DecimalFormat( "0.0000" );
|
|
|
|
public ChannelNode( Channel channel )
|
|
{
|
|
super( channel );
|
|
}
|
|
|
|
public void init()
|
|
{
|
|
/* Set the owning system and site names for the channel */
|
|
SiteNode siteNode = (SiteNode)getParent();
|
|
|
|
if( siteNode != null )
|
|
{
|
|
getChannel().setSite( siteNode.getSite(), false );
|
|
|
|
SystemNode systemNode = (SystemNode)siteNode.getParent();
|
|
|
|
if( systemNode != null )
|
|
{
|
|
getChannel().setSystem( systemNode.getSystem(), false );
|
|
}
|
|
}
|
|
|
|
/* Add this node as listener to receive changes from underlying channel */
|
|
getChannel().addListener( this );
|
|
|
|
/* Add the resource manager to the channel so that the channel
|
|
* can provide channel change events to all system resources */
|
|
getChannel().setResourceManager( getModel().getResourceManager() );
|
|
}
|
|
|
|
/**
|
|
* Listener method to receive channel changes from the underlying chnannel
|
|
*/
|
|
@Override
|
|
public void channelChanged( ChannelEvent event )
|
|
{
|
|
switch( event.getEvent() )
|
|
{
|
|
/* Refresh the node for each of these events */
|
|
case CHANGE_DECODER:
|
|
case CHANGE_NAME:
|
|
case CHANGE_SELECTED:
|
|
case CHANGE_SITE:
|
|
case CHANGE_SYSTEM:
|
|
case CHANNEL_ENABLED:
|
|
case CHANNEL_PROCESSING_STARTED:
|
|
case CHANNEL_PROCESSING_STOPPED:
|
|
this.refresh();
|
|
break;
|
|
/* We're being deleted, so cleanup */
|
|
case CHANNEL_DISABLED:
|
|
delete();
|
|
break;
|
|
default:
|
|
break;
|
|
}
|
|
}
|
|
|
|
@Override
|
|
public String getIconPath()
|
|
{
|
|
return getChannel().getDecodeConfiguration().getDecoderType()
|
|
.getIconFilename();
|
|
}
|
|
|
|
@Override
|
|
public Color getBackgroundColor()
|
|
{
|
|
if( getChannel().getEnabled() )
|
|
{
|
|
if( getChannel().isProcessing() )
|
|
{
|
|
return Color.GREEN;
|
|
}
|
|
else
|
|
{
|
|
return Color.RED;
|
|
}
|
|
}
|
|
|
|
return null;
|
|
}
|
|
|
|
@Override
|
|
public JPanel getEditor()
|
|
{
|
|
return new ChannelEditor( this );
|
|
}
|
|
|
|
public Channel getChannel()
|
|
{
|
|
return (Channel)this.getUserObject();
|
|
}
|
|
|
|
public String toString()
|
|
{
|
|
StringBuilder sb = new StringBuilder();
|
|
|
|
sb.append( getChannel().getName() );
|
|
|
|
TunerChannel channel = getChannel().getTunerChannel();
|
|
|
|
if( channel != null )
|
|
{
|
|
sb.append( " (" );
|
|
sb.append( sFORMAT.format( (double)channel.getFrequency() / 1000000.0d ) + " MHz" );
|
|
sb.append( ")" );
|
|
|
|
}
|
|
|
|
return sb.toString();
|
|
}
|
|
|
|
public JPopupMenu getContextMenu()
|
|
{
|
|
JPopupMenu popupMenu = new JPopupMenu( "Channel Menu" );
|
|
// popupMenu.add( getChannel().getContextMenu() );
|
|
|
|
return popupMenu;
|
|
}
|
|
|
|
public void delete()
|
|
{
|
|
((SiteNode)getParent()).getSite().removeChannel( getChannel() );
|
|
|
|
save();
|
|
|
|
getModel().removeNodeFromParent( ChannelNode.this );
|
|
}
|
|
}
|