mirror of
https://github.com/DSheirer/sdrtrunk.git
synced 2026-11-13 00:57:31 -05:00
P25 work in progress
This commit is contained in:
@@ -22,6 +22,8 @@ import instrument.tap.Tap;
|
||||
import instrument.tap.TapViewPanel;
|
||||
import instrument.tap.stream.BinaryTap;
|
||||
import instrument.tap.stream.BinaryTapViewPanel;
|
||||
import instrument.tap.stream.DibitTap;
|
||||
import instrument.tap.stream.DibitTapViewPanel;
|
||||
import instrument.tap.stream.FloatTap;
|
||||
import instrument.tap.stream.FloatTapViewPanel;
|
||||
import instrument.tap.stream.SymbolEventTap;
|
||||
@@ -166,6 +168,9 @@ public class DecoderViewFrame extends JInternalFrame
|
||||
break;
|
||||
case STREAM_COMPLEX:
|
||||
break;
|
||||
case STREAM_DIBIT:
|
||||
panel = new DibitTapViewPanel( (DibitTap)tap );
|
||||
break;
|
||||
case STREAM_FLOAT:
|
||||
panel = new FloatTapViewPanel( (FloatTap)tap );
|
||||
break;
|
||||
|
||||
@@ -22,6 +22,7 @@ public enum TapType
|
||||
EVENT_SYNC_DETECT,
|
||||
STREAM_BINARY,
|
||||
STREAM_COMPLEX,
|
||||
STREAM_DIBIT,
|
||||
STREAM_FLOAT,
|
||||
STREAM_SYMBOL;
|
||||
}
|
||||
|
||||
60
src/instrument/tap/stream/DibitTap.java
Normal file
60
src/instrument/tap/stream/DibitTap.java
Normal file
@@ -0,0 +1,60 @@
|
||||
/*******************************************************************************
|
||||
* 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 instrument.tap.TapListener;
|
||||
import instrument.tap.TapType;
|
||||
import sample.Listener;
|
||||
import dsp.fsk.Dibit;
|
||||
|
||||
public class DibitTap extends StreamTap implements Listener<Dibit>
|
||||
|
||||
{
|
||||
private Listener<Dibit> mListener;
|
||||
|
||||
public DibitTap( String name,
|
||||
int delay,
|
||||
float sampleRateRatio )
|
||||
{
|
||||
super( TapType.STREAM_DIBIT, name, delay, sampleRateRatio );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void receive( Dibit dibit )
|
||||
{
|
||||
if( mListener != null )
|
||||
{
|
||||
mListener.receive( dibit );
|
||||
}
|
||||
|
||||
for( TapListener listener: mListeners )
|
||||
{
|
||||
listener.receive( dibit );
|
||||
}
|
||||
}
|
||||
|
||||
public void setListener( Listener<Dibit> listener )
|
||||
{
|
||||
mListener = listener;
|
||||
}
|
||||
|
||||
public void removeListener( Listener<Dibit> listener )
|
||||
{
|
||||
mListener = null;
|
||||
}
|
||||
}
|
||||
190
src/instrument/tap/stream/DibitTapViewPanel.java
Normal file
190
src/instrument/tap/stream/DibitTapViewPanel.java
Normal file
@@ -0,0 +1,190 @@
|
||||
/*******************************************************************************
|
||||
* 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 instrument.gui.SampleModel;
|
||||
import instrument.tap.Tap;
|
||||
import instrument.tap.TapViewPanel;
|
||||
|
||||
import java.awt.Color;
|
||||
import java.awt.FontMetrics;
|
||||
import java.awt.Graphics;
|
||||
import java.awt.Graphics2D;
|
||||
import java.awt.geom.Path2D;
|
||||
import java.awt.geom.Rectangle2D;
|
||||
import java.util.List;
|
||||
import java.util.Observable;
|
||||
|
||||
import dsp.fsk.Dibit;
|
||||
|
||||
public class DibitTapViewPanel extends TapViewPanel
|
||||
{
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
private Tap mTap;
|
||||
private List<Dibit> mSamples;
|
||||
private int mSampleCount;
|
||||
private int mOffset = 0;
|
||||
|
||||
public DibitTapViewPanel( DibitTap tap )
|
||||
{
|
||||
super( new SampleModel<Dibit>(), tap.getName() );
|
||||
|
||||
mTap = tap;
|
||||
mTap.addListener( getModel() );
|
||||
|
||||
getModel().setSampleCount(
|
||||
(int)( getModel().getSampleCount() * tap.getSampleRateRatio() ) );
|
||||
|
||||
getModel().setDelay( tap.getDelay() );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void update( Observable arg0, Object arg1 )
|
||||
{
|
||||
mSamples = (List<Dibit>)getModel().getSamples();
|
||||
mSampleCount = getModel().getSampleCount();
|
||||
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 / 2.0f;
|
||||
|
||||
g2.drawLine( 0, (int)middle, width, (int)middle );
|
||||
|
||||
if( mSamples != null && mSamples.size() > 0 )
|
||||
{
|
||||
g2.setColor( getForeground() );
|
||||
|
||||
g2.drawString( mLabel, 5 , 15 );
|
||||
|
||||
for( int x = 1; x < mSamples.size(); x++ )
|
||||
{
|
||||
paintDibit( g, x, mSamples.get( x ) );
|
||||
}
|
||||
}
|
||||
|
||||
g2.dispose();
|
||||
}
|
||||
|
||||
/**
|
||||
* Paints a polyline representing a boolean value with a 0 or 1 label in
|
||||
* the middle of it
|
||||
*
|
||||
* @param graphics
|
||||
* @param index - index of the sample int the sample buffer
|
||||
* @param value - bit value, 0 or 1
|
||||
*/
|
||||
private void paintDibit( Graphics graphics, int index, Dibit value )
|
||||
{
|
||||
Graphics2D g2 = (Graphics2D)graphics;
|
||||
|
||||
Path2D.Float polyline =
|
||||
new Path2D.Float( Path2D.Float.WIND_EVEN_ODD, mSamples.size() );
|
||||
|
||||
float middleY = ( (float)getHeight() / 2.0f );
|
||||
|
||||
float indexWidth = (float)( getWidth() ) / (float)mSampleCount;
|
||||
|
||||
float startX = (float)index * indexWidth;
|
||||
float stopX = (float)(index + 1 ) * indexWidth;
|
||||
float fivePercent = indexWidth * .05f;
|
||||
float leftX = startX + fivePercent;
|
||||
float rightX = stopX - fivePercent;
|
||||
|
||||
/* Start */
|
||||
polyline.moveTo( startX, middleY );
|
||||
|
||||
/* Left horizonal segment */
|
||||
polyline.lineTo( leftX, middleY );
|
||||
|
||||
float y = middleY;
|
||||
|
||||
switch( value )
|
||||
{
|
||||
case D01_PLUS_3:
|
||||
y = middleY - ( middleY * 0.75f);
|
||||
break;
|
||||
case D00_PLUS_1:
|
||||
y = middleY - ( middleY * 0.25f);
|
||||
break;
|
||||
case D10_MINUS_1:
|
||||
y = middleY + ( middleY * 0.25f);
|
||||
break;
|
||||
case D11_MINUS_3:
|
||||
y = middleY + ( middleY * 0.75f);
|
||||
break;
|
||||
}
|
||||
|
||||
/* Left vertical segment */
|
||||
polyline.lineTo( leftX, y );
|
||||
|
||||
/* Middle horizontal segment */
|
||||
polyline.lineTo( rightX, y );
|
||||
|
||||
/* Right vertical segment */
|
||||
polyline.lineTo( rightX, middleY );
|
||||
|
||||
/* Right horizontal segment */
|
||||
polyline.lineTo( stopX, middleY );
|
||||
|
||||
g2.draw( polyline );
|
||||
|
||||
/* Draw the bit value label */
|
||||
String bit = null;
|
||||
|
||||
switch( value )
|
||||
{
|
||||
case D00_PLUS_1:
|
||||
bit = "+1";
|
||||
break;
|
||||
case D01_PLUS_3:
|
||||
bit = "+3";
|
||||
break;
|
||||
case D10_MINUS_1:
|
||||
bit = "-1";
|
||||
break;
|
||||
case D11_MINUS_3:
|
||||
bit = "-3";
|
||||
break;
|
||||
}
|
||||
|
||||
FontMetrics fontMetrics = graphics.getFontMetrics( this.getFont() );
|
||||
|
||||
Rectangle2D label = fontMetrics.getStringBounds( bit, graphics );
|
||||
|
||||
float offsetX = (float)label.getWidth() / 2.0f;
|
||||
float offsetY = (float)label.getWidth() / 2.0f;
|
||||
|
||||
float middleX = startX + ( indexWidth / 2.0f );
|
||||
|
||||
graphics.drawString( bit,
|
||||
(int)( middleX - offsetX ),
|
||||
(int)( middleY - offsetY ) );
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user