mirror of
https://github.com/DSheirer/sdrtrunk.git
synced 2026-11-13 00:57:31 -05:00
P25 LSM decoder work in progress. Adds a CQPSK decoder based on Max's (KA1RBI) scope.py and gardner loop.
The CQPSK decoder is starting to take shape, but needs more tweaking and testing. It's not keeping a good lock on strong P25 signals. I have to add some more features to the intrumentation package to allow me to visualize the internals of the CQPSK decoder so that I can get a better sense of what needs fine tuning. The CQPSK decoder may work for anyone that wants to sync the repo and run the build script.
This commit is contained in:
@@ -40,7 +40,6 @@ import net.miginfocom.swing.MigLayout;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import source.Source.SampleType;
|
||||
import source.wave.WaveSource;
|
||||
import source.wave.WaveSource.PositionListener;
|
||||
import decode.Decoder;
|
||||
@@ -52,6 +51,7 @@ import decode.mdc1200.MDCDecoder;
|
||||
import decode.mpt1327.MPT1327Decoder;
|
||||
import decode.mpt1327.MPT1327Decoder.Sync;
|
||||
import decode.p25.P25Decoder;
|
||||
import decode.p25.P25Decoder.Modulation;
|
||||
import decode.passport.PassportDecoder;
|
||||
import decode.tait.Tait1200Decoder;
|
||||
|
||||
@@ -66,6 +66,8 @@ public class AudioSourceFrame extends JInternalFrame implements PositionListener
|
||||
|
||||
private JLabel mCurrentPosition = new JLabel( "0" );
|
||||
private JComboBox<DecoderType> mComboDecoders;
|
||||
private JComboBox<Modulation> mComboModulations;
|
||||
private JLabel mModulationLabel = new JLabel( "Modulation:" );
|
||||
|
||||
public AudioSourceFrame( WaveSource source, JDesktopPane desktop )
|
||||
{
|
||||
@@ -115,10 +117,39 @@ public class AudioSourceFrame extends JInternalFrame implements PositionListener
|
||||
}
|
||||
|
||||
mComboDecoders.setModel( model );
|
||||
|
||||
mComboDecoders.addActionListener( new ActionListener()
|
||||
{
|
||||
@Override
|
||||
public void actionPerformed( ActionEvent e )
|
||||
{
|
||||
DecoderType selected = (DecoderType)mComboDecoders.getSelectedItem();
|
||||
|
||||
if( selected == DecoderType.P25_PHASE1 )
|
||||
{
|
||||
mComboModulations.setVisible( true );
|
||||
mModulationLabel.setVisible( true );
|
||||
}
|
||||
else
|
||||
{
|
||||
mComboModulations.setVisible( false );
|
||||
mModulationLabel.setVisible( false );
|
||||
}
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
panel.add( new JLabel( "Decoders:" ) );
|
||||
panel.add( mComboDecoders, "span 3,grow" );
|
||||
panel.add( new AddDecoderButton(), "grow" );
|
||||
panel.add( new AddDecoderButton(), "grow,wrap" );
|
||||
|
||||
mComboModulations = new JComboBox<Modulation>(
|
||||
new DefaultComboBoxModel<Modulation>( Modulation.values() ) );
|
||||
mComboModulations.setVisible( false );
|
||||
mModulationLabel.setVisible( false );
|
||||
|
||||
panel.add( mModulationLabel );
|
||||
panel.add( mComboModulations );
|
||||
|
||||
add( panel );
|
||||
}
|
||||
@@ -152,19 +183,20 @@ public class AudioSourceFrame extends JInternalFrame implements PositionListener
|
||||
decoder = new LJ1200Decoder( null );
|
||||
break;
|
||||
case LTR_NET:
|
||||
decoder = new LTRNetDecoder( SampleType.REAL, null, MessageDirection.OSW );
|
||||
decoder = new LTRNetDecoder( mSource.getSampleType(), null, MessageDirection.OSW );
|
||||
break;
|
||||
case MDC1200:
|
||||
decoder = new MDCDecoder( null );
|
||||
break;
|
||||
case MPT1327:
|
||||
decoder = new MPT1327Decoder( SampleType.REAL, null, Sync.NORMAL );
|
||||
decoder = new MPT1327Decoder( mSource.getSampleType(), null, Sync.NORMAL );
|
||||
break;
|
||||
case PASSPORT:
|
||||
decoder = new PassportDecoder( SampleType.REAL, null );
|
||||
decoder = new PassportDecoder( mSource.getSampleType(), null );
|
||||
break;
|
||||
case P25_PHASE1:
|
||||
decoder = new P25Decoder( SampleType.REAL, null );
|
||||
decoder = new P25Decoder( mSource.getSampleType(),
|
||||
(Modulation)mComboModulations.getSelectedItem(), null );
|
||||
break;
|
||||
case TAIT_1200:
|
||||
decoder = new Tait1200Decoder( null );
|
||||
|
||||
@@ -1,240 +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 instrument.gui;
|
||||
|
||||
import java.awt.Dimension;
|
||||
import java.awt.event.ActionEvent;
|
||||
import java.awt.event.ActionListener;
|
||||
import java.awt.event.FocusEvent;
|
||||
import java.awt.event.FocusListener;
|
||||
import java.io.IOException;
|
||||
|
||||
import javax.swing.DefaultComboBoxModel;
|
||||
import javax.swing.JButton;
|
||||
import javax.swing.JComboBox;
|
||||
import javax.swing.JDesktopPane;
|
||||
import javax.swing.JInternalFrame;
|
||||
import javax.swing.JLabel;
|
||||
import javax.swing.JOptionPane;
|
||||
import javax.swing.JPanel;
|
||||
import javax.swing.JTextField;
|
||||
|
||||
import net.miginfocom.swing.MigLayout;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import sample.Listener;
|
||||
import sample.complex.ComplexSample;
|
||||
import source.wave.ComplexWaveSource;
|
||||
import source.wave.WaveSource;
|
||||
import source.wave.WaveSource.PositionListener;
|
||||
|
||||
public class BasebandSourceFrame extends JInternalFrame implements PositionListener
|
||||
{
|
||||
private static final long serialVersionUID = 1L;
|
||||
private final static Logger mLog =
|
||||
LoggerFactory.getLogger( BasebandSourceFrame.class );
|
||||
|
||||
private ComplexWaveSource mSource;
|
||||
private JDesktopPane mDesktop;
|
||||
|
||||
private JLabel mCurrentPosition = new JLabel( "0" );
|
||||
private JComboBox<Panels> mComboPanels;
|
||||
|
||||
public BasebandSourceFrame( ComplexWaveSource source, JDesktopPane desktop )
|
||||
{
|
||||
mSource = source;
|
||||
mSource.addListener( this );
|
||||
|
||||
mDesktop = desktop;
|
||||
|
||||
initGui();
|
||||
}
|
||||
|
||||
private void initGui()
|
||||
{
|
||||
setTitle( "Baseband Source [" + mSource.getSampleType().toString() + "]" );
|
||||
setPreferredSize( new Dimension( 600, 150 ) );
|
||||
setSize( 600, 150 );
|
||||
|
||||
setResizable( true );
|
||||
setClosable( true );
|
||||
setIconifiable( true );
|
||||
setMaximizable( false );
|
||||
|
||||
JPanel panel = new JPanel();
|
||||
panel.setLayout( new MigLayout() );
|
||||
|
||||
JLabel fileLabel = new JLabel( "File: " + mSource.getFile().getName() );
|
||||
fileLabel.setToolTipText( mSource.getFile().getName() );
|
||||
panel.add( fileLabel, "span,wrap" );
|
||||
|
||||
panel.add( new JLabel( "Jump:" ) );
|
||||
panel.add( new JumpToField( mSource ) );
|
||||
panel.add( new NextSampleButton( mSource, ">", 1 ) );
|
||||
panel.add( new NextSampleButton( mSource, "> 100 >", 100 ) );
|
||||
panel.add( new NextSampleButton( mSource, "> 1000 >", 1000 ) );
|
||||
panel.add( new JLabel( "Posn:" ) );
|
||||
panel.add( mCurrentPosition, "wrap" );
|
||||
|
||||
/* ComboBox: Viewer Panels */
|
||||
mComboPanels = new JComboBox<Panels>(
|
||||
new DefaultComboBoxModel<Panels>( Panels.values() ) );
|
||||
|
||||
panel.add( new JLabel( "Panels:" ) );
|
||||
panel.add( mComboPanels, "span 3,grow" );
|
||||
panel.add( new AddPanelButton(), "grow" );
|
||||
|
||||
add( panel );
|
||||
}
|
||||
|
||||
public class AddPanelButton extends JButton
|
||||
{
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
public AddPanelButton()
|
||||
{
|
||||
super( "Add" );
|
||||
|
||||
addActionListener( new ActionListener()
|
||||
{
|
||||
@Override
|
||||
public void actionPerformed( ActionEvent arg0 )
|
||||
{
|
||||
Panels selected =
|
||||
(Panels)mComboPanels.getSelectedItem();
|
||||
|
||||
mLog.info( "Selected:" + selected.name() );
|
||||
|
||||
switch( selected )
|
||||
{
|
||||
case CONSTELLATION:
|
||||
ConstellationPanel con = new ConstellationPanel();
|
||||
mDesktop.add( con );
|
||||
con.setVisible( true );
|
||||
|
||||
if( mSource != null )
|
||||
{
|
||||
mSource.addListener( (Listener<ComplexSample>)con );
|
||||
}
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
} );
|
||||
}
|
||||
}
|
||||
|
||||
public class NextSampleButton extends JButton
|
||||
{
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
private WaveSource mSource;
|
||||
private int mCount;
|
||||
|
||||
public NextSampleButton( WaveSource source, String label, int count )
|
||||
{
|
||||
super( label );
|
||||
mSource = source;
|
||||
mCount = count;
|
||||
|
||||
addActionListener( new ActionListener()
|
||||
{
|
||||
@Override
|
||||
public void actionPerformed( ActionEvent arg0 )
|
||||
{
|
||||
try
|
||||
{
|
||||
mSource.next( mCount );
|
||||
}
|
||||
catch ( IOException e )
|
||||
{
|
||||
mLog.error( "Viewer - error trying to fetch next [" +
|
||||
mCount + "] samples", e );
|
||||
|
||||
JOptionPane.showMessageDialog( BasebandSourceFrame.this,
|
||||
"Cannot read " + mCount + " more samples [" +
|
||||
e.getLocalizedMessage() + "]",
|
||||
"Wave File Error",
|
||||
JOptionPane.ERROR_MESSAGE );
|
||||
}
|
||||
}
|
||||
} );
|
||||
}
|
||||
}
|
||||
|
||||
public class JumpToField extends JTextField
|
||||
{
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
private WaveSource mSource;
|
||||
|
||||
public JumpToField( WaveSource source )
|
||||
{
|
||||
super( "0" );
|
||||
|
||||
mSource = source;
|
||||
|
||||
setMinimumSize( new Dimension( 100, getHeight() ) );
|
||||
|
||||
addFocusListener( new FocusListener()
|
||||
{
|
||||
@Override
|
||||
public void focusGained( FocusEvent arg0 ) {}
|
||||
|
||||
@Override
|
||||
public void focusLost( FocusEvent arg0 )
|
||||
{
|
||||
try
|
||||
{
|
||||
long position = Long.parseLong( getText() );
|
||||
mSource.jumpTo( position );
|
||||
}
|
||||
catch( Exception e )
|
||||
{
|
||||
mLog.error( "WaveSourceFrame - exception during jump "
|
||||
+ "to", e );
|
||||
|
||||
JOptionPane.showMessageDialog( BasebandSourceFrame.this,
|
||||
"Can't jump to position [" + getText() + "]",
|
||||
"Error",
|
||||
JOptionPane.ERROR_MESSAGE );
|
||||
}
|
||||
}
|
||||
} );
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void positionUpdated( long position, boolean reset )
|
||||
{
|
||||
mCurrentPosition.setText( String.valueOf( position ) );
|
||||
|
||||
if( reset )
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
public enum Panels
|
||||
{
|
||||
CONSTELLATION;
|
||||
}
|
||||
}
|
||||
@@ -22,10 +22,14 @@ import instrument.tap.Tap;
|
||||
import instrument.tap.TapViewPanel;
|
||||
import instrument.tap.stream.BinaryTap;
|
||||
import instrument.tap.stream.BinaryTapViewPanel;
|
||||
import instrument.tap.stream.ComplexTap;
|
||||
import instrument.tap.stream.ComplexTapViewPanel;
|
||||
import instrument.tap.stream.DibitTap;
|
||||
import instrument.tap.stream.DibitTapViewPanel;
|
||||
import instrument.tap.stream.FloatTap;
|
||||
import instrument.tap.stream.FloatTapViewPanel;
|
||||
import instrument.tap.stream.QPSKTap;
|
||||
import instrument.tap.stream.QPSKTapPanel;
|
||||
import instrument.tap.stream.SymbolEventTap;
|
||||
import instrument.tap.stream.SymbolEventTapViewPanel;
|
||||
|
||||
@@ -52,6 +56,7 @@ import org.slf4j.LoggerFactory;
|
||||
|
||||
import sample.Listener;
|
||||
import source.Source.SampleType;
|
||||
import source.wave.ComplexWaveSource;
|
||||
import source.wave.FloatWaveSource;
|
||||
import source.wave.WaveSource;
|
||||
import source.wave.WaveSource.PositionListener;
|
||||
@@ -77,7 +82,8 @@ public class DecoderViewFrame extends JInternalFrame
|
||||
|
||||
if( source.getSampleType() == SampleType.COMPLEX )
|
||||
{
|
||||
mLog.error( "Hey, we're not wired up yet for complex" );
|
||||
ComplexWaveSource cws = (ComplexWaveSource)mWaveSource;
|
||||
cws.addListener( mDecoder.getComplexReceiver() );
|
||||
}
|
||||
else if( source.getSampleType() == SampleType.REAL )
|
||||
{
|
||||
@@ -167,6 +173,7 @@ public class DecoderViewFrame extends JInternalFrame
|
||||
panel = new BinaryTapViewPanel( (BinaryTap)tap );
|
||||
break;
|
||||
case STREAM_COMPLEX:
|
||||
panel = new ComplexTapViewPanel( (ComplexTap)tap );
|
||||
break;
|
||||
case STREAM_DIBIT:
|
||||
panel = new DibitTapViewPanel( (DibitTap)tap );
|
||||
@@ -174,6 +181,9 @@ public class DecoderViewFrame extends JInternalFrame
|
||||
case STREAM_FLOAT:
|
||||
panel = new FloatTapViewPanel( (FloatTap)tap );
|
||||
break;
|
||||
case STREAM_QPSK:
|
||||
panel = new QPSKTapPanel( (QPSKTap)tap );
|
||||
break;
|
||||
case STREAM_SYMBOL:
|
||||
panel = new SymbolEventTapViewPanel( (SymbolEventTap)tap );
|
||||
break;
|
||||
@@ -211,6 +221,8 @@ public class DecoderViewFrame extends JInternalFrame
|
||||
|
||||
public class AddAllTapsItem extends JMenuItem
|
||||
{
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
private final List<Tap> mTaps;
|
||||
|
||||
public AddAllTapsItem( final List<Tap> taps )
|
||||
|
||||
@@ -137,10 +137,6 @@ public class Viewer
|
||||
|
||||
mLog.info( "File opened as float wave file" );
|
||||
|
||||
AudioSourceFrame sourcePanel =
|
||||
new AudioSourceFrame( source, mDesktop );
|
||||
sourcePanel.setVisible( true );
|
||||
mDesktop.add( sourcePanel );
|
||||
}
|
||||
catch( Exception e )
|
||||
{
|
||||
@@ -158,13 +154,6 @@ public class Viewer
|
||||
source = complex;
|
||||
|
||||
mLog.info( "File opened as complex wave file" );
|
||||
|
||||
BasebandSourceFrame sourcePanel =
|
||||
new BasebandSourceFrame( complex, mDesktop );
|
||||
|
||||
sourcePanel.setVisible( true );
|
||||
|
||||
mDesktop.add( sourcePanel );
|
||||
}
|
||||
catch( Exception e )
|
||||
{
|
||||
@@ -175,7 +164,11 @@ public class Viewer
|
||||
if( source != null )
|
||||
{
|
||||
mSource = source;
|
||||
|
||||
|
||||
AudioSourceFrame sourcePanel =
|
||||
new AudioSourceFrame( source, mDesktop );
|
||||
sourcePanel.setVisible( true );
|
||||
mDesktop.add( sourcePanel );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -24,5 +24,6 @@ public enum TapType
|
||||
STREAM_COMPLEX,
|
||||
STREAM_DIBIT,
|
||||
STREAM_FLOAT,
|
||||
STREAM_QPSK,
|
||||
STREAM_SYMBOL;
|
||||
}
|
||||
|
||||
@@ -32,6 +32,8 @@ import java.util.Observable;
|
||||
|
||||
public class BinaryTapViewPanel extends TapViewPanel
|
||||
{
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
private Tap mTap;
|
||||
private List<Boolean> mSamples;
|
||||
private int mSampleCount;
|
||||
|
||||
@@ -33,6 +33,11 @@ public class ComplexTap extends StreamTap
|
||||
{
|
||||
super( TapType.STREAM_COMPLEX, name, delay, sampleRateRatio );
|
||||
}
|
||||
|
||||
public ComplexTap( TapType tapType, String name, int delay, float sampleRateRatio )
|
||||
{
|
||||
super( tapType, name, delay, sampleRateRatio );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void receive( ComplexSample t )
|
||||
|
||||
155
src/instrument/tap/stream/ComplexTapViewPanel.java
Normal file
155
src/instrument/tap/stream/ComplexTapViewPanel.java
Normal file
@@ -0,0 +1,155 @@
|
||||
/*******************************************************************************
|
||||
* 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 instrument.tap.stream;
|
||||
|
||||
import gui.SDRTrunk;
|
||||
import instrument.gui.SampleModel;
|
||||
import instrument.tap.Tap;
|
||||
import instrument.tap.TapViewPanel;
|
||||
|
||||
import java.awt.Color;
|
||||
import java.awt.Dimension;
|
||||
import java.awt.Graphics;
|
||||
import java.awt.Graphics2D;
|
||||
import java.awt.geom.Path2D;
|
||||
import java.awt.geom.Point2D;
|
||||
import java.util.List;
|
||||
import java.util.Observable;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import sample.complex.ComplexSample;
|
||||
|
||||
public class ComplexTapViewPanel extends TapViewPanel
|
||||
{
|
||||
private static final long serialVersionUID = 1L;
|
||||
private final static Logger mLog = LoggerFactory.getLogger( SDRTrunk.class );
|
||||
|
||||
private Tap mTap;
|
||||
private List<ComplexSample> mSamples;
|
||||
private int mSampleCount;
|
||||
|
||||
public ComplexTapViewPanel( ComplexTap tap )
|
||||
{
|
||||
super( new SampleModel<ComplexTap>(), tap.getName() );
|
||||
|
||||
setSize( new Dimension( 400, 400 ) );
|
||||
|
||||
mTap = tap;
|
||||
mTap.addListener( getModel() );
|
||||
|
||||
mSampleCount = (int)( 2000 * tap.getSampleRateRatio() );
|
||||
|
||||
getModel().setSampleCount( mSampleCount );
|
||||
getModel().setDelay( tap.getDelay() );
|
||||
|
||||
mLog.info( "Complex Tap Panel [" + tap.getName() + "] count: " +
|
||||
getModel().getSampleCount() + " delay:" + getModel().getDelay() );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void update( Observable arg0, Object arg1 )
|
||||
{
|
||||
mSamples = (List<ComplexSample>)getModel().getSamples();
|
||||
repaint();
|
||||
}
|
||||
|
||||
public void paintComponent( Graphics g )
|
||||
{
|
||||
super.paintComponent( g );
|
||||
|
||||
Graphics2D g2 = (Graphics2D)g;
|
||||
|
||||
int height = getHeight();
|
||||
int width = getWidth();
|
||||
|
||||
g2.setColor( Color.DARK_GRAY );
|
||||
|
||||
float middle = (float)height / 4.0f;
|
||||
|
||||
g2.drawLine( 0, (int)middle, width, (int)middle );
|
||||
g2.drawLine( 0, (int)( 3 * middle ), width, (int)( 3 * middle ) );
|
||||
|
||||
if( mSamples != null &&
|
||||
mSamples.size() > 0 )
|
||||
{
|
||||
g2.setColor( getForeground() );
|
||||
|
||||
g2.drawString( mLabel, 5 , 15 );
|
||||
|
||||
Path2D.Float polylineReal =
|
||||
new Path2D.Float( Path2D.Float.WIND_EVEN_ODD, mSamples.size() );
|
||||
Path2D.Float polylineImag =
|
||||
new Path2D.Float( Path2D.Float.WIND_EVEN_ODD, mSamples.size() );
|
||||
|
||||
/* Move to the first point */
|
||||
Point2D.Float firstReal = resolve( 0, mSamples.get( 0 ), Type.REAL );
|
||||
polylineReal.moveTo( firstReal.x, firstReal.y );
|
||||
|
||||
Point2D.Float firstImag = resolve( 0, mSamples.get( 0 ), Type.IMAGINERY );
|
||||
polylineImag.moveTo( firstImag.x, firstImag.y );
|
||||
|
||||
for( int x = 1; x < mSamples.size(); x++ )
|
||||
{
|
||||
Point2D.Float pointReal = resolve( x, mSamples.get( x ), Type.REAL );
|
||||
polylineReal.lineTo( pointReal.x, pointReal.y );
|
||||
|
||||
Point2D.Float pointImag = resolve( x, mSamples.get( x ), Type.IMAGINERY );
|
||||
polylineImag.lineTo( pointImag.x, pointImag.y );
|
||||
|
||||
// mLog.debug( "Imag y:" + pointImag.getY() + " height:" + getHeight() );
|
||||
}
|
||||
|
||||
g2.draw( polylineReal );
|
||||
g2.draw( polylineImag );
|
||||
}
|
||||
|
||||
g2.dispose();
|
||||
}
|
||||
|
||||
|
||||
private Point2D.Float resolve( int index, ComplexSample sample, Type type )
|
||||
{
|
||||
int middle = (int)( getHeight() / 4 );
|
||||
|
||||
float y = middle - ( middle * mVerticalZoom * ( type == Type.REAL ?
|
||||
sample.real() : sample.imaginary()) );
|
||||
|
||||
if( type == Type.IMAGINERY )
|
||||
{
|
||||
y += ( middle * 2 );
|
||||
}
|
||||
|
||||
/* Clip y to zero as necessary */
|
||||
y = ( y < 0 ) ? 0 : y;
|
||||
|
||||
/* Clip y to max height as necessary */
|
||||
y = ( y > getHeight() ) ? getHeight() : y;
|
||||
|
||||
float indexWidth = (float)getWidth() / (float)mSampleCount;
|
||||
|
||||
float x = (float)index * indexWidth;
|
||||
|
||||
Point2D.Float point = new Point2D.Float( x, y );
|
||||
|
||||
return new Point2D.Float( x , y );
|
||||
}
|
||||
|
||||
public enum Type{ REAL,IMAGINERY };
|
||||
}
|
||||
11
src/instrument/tap/stream/QPSKTap.java
Normal file
11
src/instrument/tap/stream/QPSKTap.java
Normal file
@@ -0,0 +1,11 @@
|
||||
package instrument.tap.stream;
|
||||
|
||||
import instrument.tap.TapType;
|
||||
|
||||
public class QPSKTap extends ComplexTap
|
||||
{
|
||||
public QPSKTap( String name, int delay, float sampleRateRatio )
|
||||
{
|
||||
super( TapType.STREAM_QPSK, name, delay, sampleRateRatio );
|
||||
}
|
||||
}
|
||||
145
src/instrument/tap/stream/QPSKTapPanel.java
Normal file
145
src/instrument/tap/stream/QPSKTapPanel.java
Normal file
@@ -0,0 +1,145 @@
|
||||
/*******************************************************************************
|
||||
* 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 instrument.tap.stream;
|
||||
|
||||
import gui.SDRTrunk;
|
||||
import instrument.gui.SampleModel;
|
||||
import instrument.tap.Tap;
|
||||
import instrument.tap.TapViewPanel;
|
||||
|
||||
import java.awt.Color;
|
||||
import java.awt.Graphics;
|
||||
import java.awt.Graphics2D;
|
||||
import java.awt.geom.Ellipse2D;
|
||||
import java.util.List;
|
||||
import java.util.Observable;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import sample.complex.ComplexSample;
|
||||
|
||||
public class QPSKTapPanel extends TapViewPanel
|
||||
{
|
||||
private static final long serialVersionUID = 1L;
|
||||
private final static Logger mLog = LoggerFactory.getLogger( SDRTrunk.class );
|
||||
|
||||
private Tap mTap;
|
||||
private List<ComplexSample> mSamples;
|
||||
private int mSampleCount;
|
||||
|
||||
public QPSKTapPanel( ComplexTap tap )
|
||||
{
|
||||
super( new SampleModel<ComplexTap>(), tap.getName() );
|
||||
|
||||
mTap = tap;
|
||||
mTap.addListener( getModel() );
|
||||
|
||||
mSampleCount = (int)( 500 * tap.getSampleRateRatio() );
|
||||
|
||||
getModel().setSampleCount( mSampleCount );
|
||||
getModel().setDelay( tap.getDelay() );
|
||||
|
||||
mLog.info( "Complex Tap Panel [" + tap.getName() + "] count: " +
|
||||
getModel().getSampleCount() + " delay:" + getModel().getDelay() );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void update( Observable arg0, Object arg1 )
|
||||
{
|
||||
mSamples = (List<ComplexSample>)getModel().getSamples();
|
||||
repaint();
|
||||
}
|
||||
|
||||
public void paintComponent( Graphics g )
|
||||
{
|
||||
super.paintComponent( g );
|
||||
|
||||
Graphics2D g2 = (Graphics2D)g;
|
||||
|
||||
int min = ( getHeight() < getWidth() ? getHeight() : getWidth() );
|
||||
|
||||
float middle = (float)min / 2.0f;
|
||||
|
||||
g2.setColor( Color.DARK_GRAY );
|
||||
|
||||
g2.drawLine( getWidth() / 2, 5, getWidth() / 2, getHeight() - 5 );
|
||||
g2.drawLine( getWidth() / 2 - (int)( middle ), getHeight() / 2,
|
||||
getWidth() / 2 + (int)( middle ), getHeight() / 2 );
|
||||
|
||||
|
||||
if( mSamples != null &&
|
||||
mSamples.size() > 0 )
|
||||
{
|
||||
g2.drawString( mLabel, 5 , 15 );
|
||||
|
||||
/* Set color to light gray for oldest 90% of constellations */
|
||||
g2.setColor( Color.LIGHT_GRAY );
|
||||
|
||||
int counter = 0;
|
||||
|
||||
int threshold = (int)( mSamples.size() * 0.9f );
|
||||
|
||||
for( ComplexSample sample: mSamples )
|
||||
{
|
||||
/* Set color to foreground for newest 10% of constellations */
|
||||
if( counter == threshold )
|
||||
{
|
||||
g2.setColor( getForeground() );
|
||||
}
|
||||
|
||||
float scale;
|
||||
|
||||
if( sample.real() != 0 && sample.imaginary() != 0 )
|
||||
{
|
||||
scale = 1.0f / sample.magnitude();
|
||||
}
|
||||
else if( sample.real() == 0 )
|
||||
{
|
||||
scale = 1.0f / sample.imaginary();
|
||||
}
|
||||
else
|
||||
{
|
||||
scale = 1.0f / sample.real();
|
||||
}
|
||||
|
||||
float x = ( getWidth() / 2 ) +
|
||||
( scale * sample.real() * middle * 0.75f * mVerticalZoom );
|
||||
|
||||
if( Float.isNaN( x ) )
|
||||
{
|
||||
x = getWidth() / 2;
|
||||
}
|
||||
|
||||
float y = ( getHeight() / 2 ) +
|
||||
( scale * sample.imaginary() * middle * 0.75f * mVerticalZoom );
|
||||
|
||||
if( Float.isNaN( y ) )
|
||||
{
|
||||
y = getHeight() / 2;
|
||||
}
|
||||
|
||||
g2.draw( new Ellipse2D.Float( x, y, 4.0f, 4.0f ) );
|
||||
|
||||
counter++;
|
||||
}
|
||||
}
|
||||
|
||||
g2.dispose();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user