mirror of
https://github.com/DSheirer/sdrtrunk.git
synced 2026-11-13 17:17:29 -05:00
Instrumentation updates for eye diagram data and removed stack trace logging when JMBE library is not discovered.
This commit is contained in:
@@ -17,11 +17,18 @@
|
||||
******************************************************************************/
|
||||
package instrument.gui;
|
||||
|
||||
import java.awt.AWTException;
|
||||
import java.awt.EventQueue;
|
||||
import java.awt.Robot;
|
||||
import java.awt.event.ActionEvent;
|
||||
import java.awt.event.ActionListener;
|
||||
import java.awt.image.BufferedImage;
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Path;
|
||||
|
||||
import javax.imageio.ImageIO;
|
||||
import javax.swing.JDesktopPane;
|
||||
import javax.swing.JFileChooser;
|
||||
import javax.swing.JFrame;
|
||||
@@ -34,10 +41,12 @@ import javax.swing.filechooser.FileFilter;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import properties.SystemProperties;
|
||||
import source.Source;
|
||||
import source.wave.ComplexWaveSource;
|
||||
import source.wave.FloatWaveSource;
|
||||
import source.wave.WaveSource;
|
||||
import util.TimeStamp;
|
||||
|
||||
public class Viewer
|
||||
{
|
||||
@@ -101,24 +110,67 @@ public class Viewer
|
||||
|
||||
fileMenu.add( exitMenu );
|
||||
|
||||
// JMenuItem windowItem = new JMenuItem( "New Window" );
|
||||
// windowItem.addActionListener( new ActionListener()
|
||||
// {
|
||||
// @Override
|
||||
// public void actionPerformed( ActionEvent arg0 )
|
||||
// {
|
||||
// JInternalFrame frame =
|
||||
// new JInternalFrame( "New", true, true, true, true );
|
||||
//
|
||||
// frame.add( new JLabel( "This is a test" ) );
|
||||
// frame.pack();
|
||||
//
|
||||
// mDesktop.add( frame );
|
||||
//
|
||||
// frame.setVisible( true );
|
||||
// }
|
||||
// } );
|
||||
// menuBar.add( windowItem );
|
||||
JMenuItem screenCaptureItem = new JMenuItem( "Screen Capture" );
|
||||
screenCaptureItem.addActionListener( new ActionListener()
|
||||
{
|
||||
@Override
|
||||
public void actionPerformed( ActionEvent arg0 )
|
||||
{
|
||||
try
|
||||
{
|
||||
Robot robot = new Robot();
|
||||
|
||||
final BufferedImage image =
|
||||
robot.createScreenCapture( mFrame.getBounds() );
|
||||
|
||||
SystemProperties props = SystemProperties.getInstance();
|
||||
|
||||
Path capturePath = props.getApplicationFolder( "screen_captures" );
|
||||
|
||||
if( !Files.exists( capturePath ) )
|
||||
{
|
||||
try
|
||||
{
|
||||
Files.createDirectory( capturePath );
|
||||
}
|
||||
catch ( IOException e )
|
||||
{
|
||||
mLog.error( "Couldn't create 'screen_captures' "
|
||||
+ "subdirectory in the " +
|
||||
"SDRTrunk application directory", e );
|
||||
}
|
||||
}
|
||||
|
||||
String filename = TimeStamp.getTimeStamp( "_" ) +
|
||||
"_screen_capture.png";
|
||||
|
||||
final Path captureFile = capturePath.resolve( filename );
|
||||
|
||||
EventQueue.invokeLater( new Runnable()
|
||||
{
|
||||
@Override
|
||||
public void run()
|
||||
{
|
||||
try
|
||||
{
|
||||
ImageIO.write( image, "png",
|
||||
captureFile.toFile() );
|
||||
}
|
||||
catch ( IOException e )
|
||||
{
|
||||
mLog.error( "Couldn't write screen capture to "
|
||||
+ "file [" + captureFile.toString() + "]", e );
|
||||
}
|
||||
}} );
|
||||
}
|
||||
catch ( AWTException e )
|
||||
{
|
||||
mLog.error( "Exception while taking screen capture", e );
|
||||
}
|
||||
}
|
||||
} );
|
||||
|
||||
menuBar.add( screenCaptureItem );
|
||||
}
|
||||
|
||||
private void setSourceFile( File file )
|
||||
|
||||
40
src/instrument/tap/stream/EyeDiagramData.java
Normal file
40
src/instrument/tap/stream/EyeDiagramData.java
Normal file
@@ -0,0 +1,40 @@
|
||||
package instrument.tap.stream;
|
||||
|
||||
import sample.complex.ComplexSample;
|
||||
|
||||
public class EyeDiagramData
|
||||
{
|
||||
private ComplexSample[] mSamples;
|
||||
private float mLeftPoint;
|
||||
private float mRightPoint;
|
||||
private float mError;
|
||||
|
||||
public EyeDiagramData( ComplexSample[] samples, float leftPoint,
|
||||
float rightPoint, float error )
|
||||
{
|
||||
mSamples = samples;
|
||||
mLeftPoint = leftPoint;
|
||||
mRightPoint = rightPoint;
|
||||
mError = error;
|
||||
}
|
||||
|
||||
public ComplexSample[] getSamples()
|
||||
{
|
||||
return mSamples;
|
||||
}
|
||||
|
||||
public float getLeftPoint()
|
||||
{
|
||||
return mLeftPoint;
|
||||
}
|
||||
|
||||
public float getRightPoint()
|
||||
{
|
||||
return mRightPoint;
|
||||
}
|
||||
|
||||
public float getError()
|
||||
{
|
||||
return mError;
|
||||
}
|
||||
}
|
||||
@@ -17,13 +17,18 @@
|
||||
******************************************************************************/
|
||||
package instrument.tap.stream;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import decode.p25.P25Decoder;
|
||||
import instrument.tap.TapListener;
|
||||
import instrument.tap.TapType;
|
||||
import sample.Listener;
|
||||
import dsp.psk.EyeDiagramData;
|
||||
|
||||
public class EyeDiagramDataTap extends StreamTap implements Listener<EyeDiagramData>
|
||||
{
|
||||
private final static Logger mLog = LoggerFactory.getLogger( EyeDiagramDataTap.class );
|
||||
|
||||
private Listener<EyeDiagramData> mListener;
|
||||
|
||||
public EyeDiagramDataTap( String name, int delay, float sampleRate )
|
||||
|
||||
@@ -33,7 +33,6 @@ import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import sample.complex.ComplexSample;
|
||||
import dsp.psk.EyeDiagramData;
|
||||
|
||||
public class EyeDiagramDataTapPanel extends TapViewPanel
|
||||
{
|
||||
@@ -69,135 +68,158 @@ public class EyeDiagramDataTapPanel extends TapViewPanel
|
||||
|
||||
Graphics2D g2 = (Graphics2D)g;
|
||||
|
||||
|
||||
int min = ( getHeight() < getWidth() ? getHeight() : getWidth() );
|
||||
|
||||
|
||||
float halfWidth = getWidth() / 2.0f;
|
||||
float third = getWidth() / 3.0f;
|
||||
float two_thirds = 2.0f * third;
|
||||
float halfHeight = getHeight() / 2.0f;
|
||||
float xAxisIncrement = getWidth() / 19.0f / 4.0f;
|
||||
float middle = 6.0f * xAxisIncrement;
|
||||
|
||||
g2.setColor( Color.BLUE );
|
||||
g2.drawString( "Eye Diagram - I Leg", 5 , 15 );
|
||||
g2.drawString( "Eye Diagram - Q Leg", halfWidth , 15 );
|
||||
|
||||
float xAxisIncrement = third / 20.0f;
|
||||
|
||||
/* Vertical Line */
|
||||
g2.drawLine( getWidth() / 8, 5, getWidth() / 8, getHeight() - 5 );
|
||||
g2.drawLine( (int)( halfWidth + ( getWidth() / 8 ) ), 5,
|
||||
(int)( halfWidth + ( getWidth() / 8 ) ), getHeight() - 5 );
|
||||
|
||||
g2.setColor( Color.LIGHT_GRAY );
|
||||
|
||||
g2.drawLine( (int)( getWidth() / 8 - xAxisIncrement ), 5, (int)( getWidth() / 8 - xAxisIncrement ), getHeight() - 5 );
|
||||
g2.drawLine( (int)( halfWidth + ( getWidth() / 8 ) - xAxisIncrement ), 5,
|
||||
(int)( halfWidth + ( getWidth() / 8 ) - xAxisIncrement ), getHeight() - 5 );
|
||||
|
||||
g2.drawLine( (int)( getWidth() / 8 + xAxisIncrement ), 5, (int)( getWidth() / 8 + xAxisIncrement ), getHeight() - 5 );
|
||||
g2.drawLine( (int)( halfWidth + ( getWidth() / 8 ) + xAxisIncrement ), 5,
|
||||
(int)( halfWidth + ( getWidth() / 8 ) + xAxisIncrement ), getHeight() - 5 );
|
||||
|
||||
/* Horizontal Line */
|
||||
g2.drawLine( 0, getHeight() / 2, getWidth() / 4, getHeight() / 2 );
|
||||
g2.drawLine( (int)halfWidth, getHeight() / 2, (int)(getWidth() * .75),
|
||||
getHeight() / 2 );
|
||||
|
||||
if( mSamples != null &&
|
||||
mSamples.size() > 0 )
|
||||
if( mSamples != null && mSamples.size() > 0 )
|
||||
{
|
||||
|
||||
g2.setColor( Color.BLUE );
|
||||
|
||||
/* Draw each of the sample sets */
|
||||
for( int z = 0; z < mSamples.size(); z++ )
|
||||
{
|
||||
EyeDiagramData data = mSamples.get( z );
|
||||
|
||||
if( z < mSamples.size() * .75 )
|
||||
{
|
||||
g2.setColor( Color.LIGHT_GRAY );
|
||||
}
|
||||
else if( z == mSamples.size() - 1 )
|
||||
if( z == mSamples.size() - 1 )
|
||||
{
|
||||
g2.setColor( Color.BLUE );
|
||||
}
|
||||
else if( z > ( mSamples.size() * .75 ) )
|
||||
{
|
||||
g2.setColor( Color.DARK_GRAY );
|
||||
}
|
||||
else
|
||||
{
|
||||
g2.setColor( Color.GRAY );
|
||||
g2.setColor( Color.LIGHT_GRAY );
|
||||
}
|
||||
|
||||
EyeDiagramData data = mSamples.get( z );
|
||||
|
||||
ComplexSample[] samples = data.getSamples();
|
||||
|
||||
Path2D.Float iLine = new Path2D.Float( GeneralPath.WIND_EVEN_ODD, 20 );
|
||||
Path2D.Float qLine = new Path2D.Float( GeneralPath.WIND_EVEN_ODD, 20 );
|
||||
|
||||
float xAxis = middle - ( data.getMiddlePoint() * xAxisIncrement );
|
||||
|
||||
iLine.moveTo( xAxis, halfHeight );
|
||||
qLine.moveTo( xAxis + halfWidth, halfHeight );
|
||||
|
||||
for( int x = 0; x < samples.length; x++ )
|
||||
/* Draw the sample set containing two symbol periods of data */
|
||||
if( samples.length >= 1 )
|
||||
{
|
||||
float i = samples[ x ].inphase();
|
||||
Path2D.Float iLine = new Path2D.Float( GeneralPath.WIND_EVEN_ODD, 20 );
|
||||
Path2D.Float qLine = new Path2D.Float( GeneralPath.WIND_EVEN_ODD, 20 );
|
||||
Path2D.Float mLine = new Path2D.Float( GeneralPath.WIND_EVEN_ODD, 20 );
|
||||
|
||||
if( i > 1.0 )
|
||||
float xAxis = 0;
|
||||
|
||||
iLine.moveTo( xAxis, getSampleHeight( halfHeight, samples[ 0 ].inphase() ) );
|
||||
qLine.moveTo( xAxis + third, getSampleHeight( halfHeight, samples[ 0 ].quadrature() ) );
|
||||
mLine.moveTo( xAxis + ( two_thirds ), getMagnitudeHeight( samples[ 0 ].magnitude() ) );
|
||||
|
||||
for( int x = 1; x < samples.length; x++ )
|
||||
{
|
||||
i = 1.0f;
|
||||
}
|
||||
if( i < -1.0 )
|
||||
{
|
||||
i = -1.0f;
|
||||
xAxis += xAxisIncrement;
|
||||
|
||||
iLine.lineTo( xAxis, getSampleHeight( halfHeight, samples[ x ].inphase() ) );
|
||||
qLine.lineTo( xAxis + third, getSampleHeight( halfHeight, samples[ x ].quadrature() ) );
|
||||
mLine.lineTo( xAxis + two_thirds, getMagnitudeHeight( samples[ x ].magnitude() ) );
|
||||
}
|
||||
|
||||
float iy = halfHeight + ( .85f * ( halfHeight * i ) );
|
||||
g2.draw( iLine );
|
||||
g2.draw( qLine );
|
||||
g2.draw( mLine );
|
||||
|
||||
iLine.lineTo( xAxis, iy );
|
||||
|
||||
float q = samples[ x ].quadrature();
|
||||
|
||||
if( q > 1.0 )
|
||||
/* Left Sample line */
|
||||
if( z == mSamples.size() - 1 )
|
||||
{
|
||||
q = 1.0f;
|
||||
g2.setColor( Color.GREEN );
|
||||
}
|
||||
if( q < -1.0 )
|
||||
else
|
||||
{
|
||||
q = -1.0f;
|
||||
g2.setColor( Color.LIGHT_GRAY );
|
||||
}
|
||||
xAxis = xAxisIncrement * data.getLeftPoint();
|
||||
g2.drawLine( (int)xAxis, 5, (int)xAxis, getHeight() - 5 );
|
||||
g2.drawLine( (int)( xAxis + third ), 5, (int)( xAxis + third ), getHeight() - 5 );
|
||||
g2.drawLine( (int)( xAxis + two_thirds ), 5, (int)( xAxis + two_thirds ), getHeight() - 5 );
|
||||
|
||||
/* Right Sample line */
|
||||
if( z == mSamples.size() - 1 )
|
||||
{
|
||||
g2.setColor( Color.GREEN );
|
||||
}
|
||||
else
|
||||
{
|
||||
g2.setColor( Color.LIGHT_GRAY );
|
||||
}
|
||||
xAxis = xAxisIncrement * data.getRightPoint();
|
||||
g2.drawLine( (int)xAxis, 5, (int)xAxis, getHeight() - 5 );
|
||||
g2.drawLine( (int)( xAxis + third ), 5, (int)( xAxis + third ), getHeight() - 5 );
|
||||
g2.drawLine( (int)( xAxis + two_thirds ), 5, (int)( xAxis + two_thirds ), getHeight() - 5 );
|
||||
|
||||
/* Error indicator */
|
||||
float error = data.getError();
|
||||
|
||||
if( z == mSamples.size() - 1 )
|
||||
{
|
||||
g2.setColor( Color.BLACK );
|
||||
|
||||
float xFrom;
|
||||
float xTo;
|
||||
|
||||
if( error < 0.0f )
|
||||
{
|
||||
xFrom = (int)( xAxisIncrement * data.getLeftPoint() );
|
||||
xTo = xFrom - 25.0f;
|
||||
}
|
||||
else
|
||||
{
|
||||
xFrom = (int)( xAxisIncrement * data.getRightPoint() );
|
||||
xTo = xFrom + 25.0f;
|
||||
}
|
||||
|
||||
g2.drawLine( (int)xFrom, (int)halfHeight - 15, (int)xTo, (int)halfHeight );
|
||||
g2.drawLine( (int)xFrom, (int)halfHeight + 15, (int)xTo, (int)halfHeight );
|
||||
g2.drawLine( (int)( xFrom + third ), (int)halfHeight - 15, (int)( xTo + third ), (int)halfHeight );
|
||||
g2.drawLine( (int)( xFrom + third ), (int)halfHeight + 15, (int)( xTo + third ), (int)halfHeight );
|
||||
g2.drawLine( (int)( xFrom + two_thirds ), (int)halfHeight - 15, (int)( xTo + two_thirds ), (int)halfHeight );
|
||||
g2.drawLine( (int)( xFrom + two_thirds ), (int)halfHeight + 15, (int)( xTo + two_thirds ), (int)halfHeight );
|
||||
}
|
||||
|
||||
|
||||
float qy = halfHeight + ( .85f * ( halfHeight * q ) );
|
||||
|
||||
qLine.lineTo( xAxis + halfWidth, qy );
|
||||
|
||||
xAxis += xAxisIncrement;
|
||||
}
|
||||
|
||||
g2.draw( iLine );
|
||||
g2.draw( qLine );
|
||||
}
|
||||
}
|
||||
|
||||
if( mSamples.size() > 0 )
|
||||
{
|
||||
EyeDiagramData data = mSamples.get( mSamples.size() - 1 );
|
||||
g2.setColor( Color.BLUE );
|
||||
g2.drawString( "Eye Diagram - I Leg", 5, 15 );
|
||||
g2.drawString( "Eye Diagram - Q Leg", third, 15 );
|
||||
g2.drawString( "Eye Diagram - Magnitude", two_thirds, 15 );
|
||||
|
||||
g2.setColor( Color.GREEN );
|
||||
|
||||
float xAxis = middle - ( data.getMiddlePoint() * xAxisIncrement );
|
||||
|
||||
Path2D.Float magnitude = new Path2D.Float( GeneralPath.WIND_EVEN_ODD, 20 );
|
||||
magnitude.moveTo( xAxis, halfHeight );
|
||||
|
||||
for( ComplexSample sample: data.getSamples() )
|
||||
{
|
||||
magnitude.lineTo( xAxis, getHeight() - ( getHeight() * sample.magnitude() ) );
|
||||
|
||||
xAxis += xAxisIncrement;
|
||||
}
|
||||
|
||||
g2.setStroke( new BasicStroke( 3 ) );
|
||||
g2.draw( magnitude );
|
||||
}
|
||||
/* Horizontal middle line */
|
||||
g2.setColor( Color.CYAN );
|
||||
g2.drawLine( 0, (int)halfHeight, getWidth(), (int)halfHeight );
|
||||
|
||||
g2.dispose();
|
||||
}
|
||||
|
||||
private float getSampleHeight( float halfHeight, float value )
|
||||
{
|
||||
if( value > 1.0 )
|
||||
{
|
||||
value = 1.0f;
|
||||
}
|
||||
if( value < -1.0 )
|
||||
{
|
||||
value = -1.0f;
|
||||
}
|
||||
|
||||
return halfHeight + ( .95f * ( halfHeight * value ) );
|
||||
}
|
||||
|
||||
private float getMagnitudeHeight( float magnitude )
|
||||
{
|
||||
if( magnitude > 1.0 )
|
||||
{
|
||||
magnitude = 1.0f;
|
||||
}
|
||||
|
||||
return getHeight() - ( getHeight() * magnitude );
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user