mirror of
https://github.com/DSheirer/sdrtrunk.git
synced 2026-11-12 08:37:25 -05:00
Updates PlaylistManager to use faster jackson XML serialization.
Removes native xml.bind serialization for improved compatibility with Java 9. Global optimize imports on the entire project.
This commit is contained in:
@@ -19,6 +19,8 @@
|
||||
package io.github.dsheirer.controller;
|
||||
|
||||
import com.jidesoft.swing.JideTabbedPane;
|
||||
import io.github.dsheirer.alias.AliasController;
|
||||
import io.github.dsheirer.alias.AliasModel;
|
||||
import io.github.dsheirer.audio.AudioManager;
|
||||
import io.github.dsheirer.audio.AudioPanel;
|
||||
import io.github.dsheirer.audio.broadcast.BroadcastModel;
|
||||
@@ -36,8 +38,6 @@ import io.github.dsheirer.source.SourceManager;
|
||||
import io.github.dsheirer.source.tuner.TunerModel;
|
||||
import io.github.dsheirer.source.tuner.TunerViewPanel;
|
||||
import net.miginfocom.swing.MigLayout;
|
||||
import io.github.dsheirer.alias.AliasController;
|
||||
import io.github.dsheirer.alias.AliasModel;
|
||||
|
||||
import javax.swing.*;
|
||||
import java.awt.*;
|
||||
|
||||
@@ -18,6 +18,9 @@
|
||||
******************************************************************************/
|
||||
package io.github.dsheirer.controller.channel;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonIgnore;
|
||||
import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlProperty;
|
||||
import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlRootElement;
|
||||
import io.github.dsheirer.controller.config.Configuration;
|
||||
import io.github.dsheirer.module.decode.DecoderFactory;
|
||||
import io.github.dsheirer.module.decode.DecoderType;
|
||||
@@ -38,24 +41,11 @@ import io.github.dsheirer.source.tuner.TunerChannel.Type;
|
||||
import io.github.dsheirer.source.tuner.frequency.FrequencyChangeEvent;
|
||||
import io.github.dsheirer.source.tuner.frequency.FrequencyChangeEvent.Event;
|
||||
|
||||
import javax.xml.bind.annotation.XmlAttribute;
|
||||
import javax.xml.bind.annotation.XmlElement;
|
||||
import javax.xml.bind.annotation.XmlRootElement;
|
||||
import javax.xml.bind.annotation.XmlSeeAlso;
|
||||
import javax.xml.bind.annotation.XmlTransient;
|
||||
|
||||
@XmlSeeAlso({Configuration.class})
|
||||
@XmlRootElement(name = "channel")
|
||||
@JacksonXmlRootElement(localName = "channel")
|
||||
public class Channel extends Configuration implements Listener<FrequencyChangeEvent>
|
||||
{
|
||||
// Standard channels are persisted and traffic channels are temporary
|
||||
public enum ChannelType
|
||||
{
|
||||
STANDARD, TRAFFIC
|
||||
}
|
||||
|
||||
;
|
||||
|
||||
public enum ChannelType {STANDARD, TRAFFIC}
|
||||
|
||||
// Static unique channel identifier tracking
|
||||
private static int UNIQUE_ID = 0;
|
||||
@@ -161,7 +151,7 @@ public class Channel extends Configuration implements Listener<FrequencyChangeEv
|
||||
/**
|
||||
* Unique identifier for this channel. Value is transient (not persisted).
|
||||
*/
|
||||
@XmlTransient
|
||||
@JsonIgnore
|
||||
public int getChannelID()
|
||||
{
|
||||
return mChannelID;
|
||||
@@ -171,7 +161,7 @@ public class Channel extends Configuration implements Listener<FrequencyChangeEv
|
||||
* Indicates if this channel has been selected for prioritized audio output
|
||||
* and display of processing chain products
|
||||
*/
|
||||
@XmlTransient
|
||||
@JsonIgnore
|
||||
public boolean isSelected()
|
||||
{
|
||||
return mSelected;
|
||||
@@ -191,7 +181,7 @@ public class Channel extends Configuration implements Listener<FrequencyChangeEv
|
||||
mSelected = selected;
|
||||
}
|
||||
|
||||
@XmlTransient
|
||||
@JsonIgnore
|
||||
public ChannelType getChannelType()
|
||||
{
|
||||
return mChannelType;
|
||||
@@ -200,7 +190,7 @@ public class Channel extends Configuration implements Listener<FrequencyChangeEv
|
||||
/**
|
||||
* Returns the owning system for this channel.
|
||||
*/
|
||||
@XmlAttribute(name = "system")
|
||||
@JacksonXmlProperty(isAttribute = true, localName = "system")
|
||||
public String getSystem()
|
||||
{
|
||||
return mSystem;
|
||||
@@ -219,7 +209,7 @@ public class Channel extends Configuration implements Listener<FrequencyChangeEv
|
||||
/**
|
||||
* Returns the owning site for this channel.
|
||||
*/
|
||||
@XmlAttribute(name = "site")
|
||||
@JacksonXmlProperty(isAttribute = true, localName = "site")
|
||||
public String getSite()
|
||||
{
|
||||
return mSite;
|
||||
@@ -238,7 +228,7 @@ public class Channel extends Configuration implements Listener<FrequencyChangeEv
|
||||
/**
|
||||
* Returns the name of this channel.
|
||||
*/
|
||||
@XmlAttribute(name = "name")
|
||||
@JacksonXmlProperty(isAttribute = true, localName = "name")
|
||||
public String getName()
|
||||
{
|
||||
return mName;
|
||||
@@ -270,7 +260,7 @@ public class Channel extends Configuration implements Listener<FrequencyChangeEv
|
||||
/**
|
||||
* Indicates if this channel is enabled for processing.
|
||||
*/
|
||||
@XmlAttribute(name = "enabled")
|
||||
@JacksonXmlProperty(isAttribute = true, localName = "enabled")
|
||||
public boolean getEnabled()
|
||||
{
|
||||
return mEnabled;
|
||||
@@ -295,7 +285,7 @@ public class Channel extends Configuration implements Listener<FrequencyChangeEv
|
||||
* Returns the alias list that is used by this channel for looking up alias
|
||||
* values for the various identifiers produced by the decoder(s).
|
||||
*/
|
||||
@XmlElement(name = "alias_list_name")
|
||||
@JacksonXmlProperty(isAttribute = false, localName = "alias_list_name")
|
||||
public String getAliasListName()
|
||||
{
|
||||
return mAliasListName;
|
||||
@@ -313,7 +303,7 @@ public class Channel extends Configuration implements Listener<FrequencyChangeEv
|
||||
/**
|
||||
* Gets the primary decoder configuration used by this channel
|
||||
*/
|
||||
@XmlElement(name = "decode_configuration")
|
||||
@JacksonXmlProperty(isAttribute = false, localName = "decode_configuration")
|
||||
public DecodeConfiguration getDecodeConfiguration()
|
||||
{
|
||||
return mDecodeConfiguration;
|
||||
@@ -331,7 +321,7 @@ public class Channel extends Configuration implements Listener<FrequencyChangeEv
|
||||
* Gets the aux decoder configuration used by this channel. Aux decoders
|
||||
* operate on demodulated audio
|
||||
*/
|
||||
@XmlElement(name = "aux_decode_configuration")
|
||||
@JacksonXmlProperty(isAttribute = false, localName = "aux_decode_configuration")
|
||||
public AuxDecodeConfiguration getAuxDecodeConfiguration()
|
||||
{
|
||||
return mAuxDecodeConfiguration;
|
||||
@@ -349,7 +339,7 @@ public class Channel extends Configuration implements Listener<FrequencyChangeEv
|
||||
* Returns the source configuration for this channel. A channel source
|
||||
* identifies where the processing chain will get source sample data from.
|
||||
*/
|
||||
@XmlElement(name = "source_configuration")
|
||||
@JacksonXmlProperty(isAttribute = false, localName = "source_configuration")
|
||||
public SourceConfiguration getSourceConfiguration()
|
||||
{
|
||||
return mSourceConfiguration;
|
||||
@@ -370,7 +360,7 @@ public class Channel extends Configuration implements Listener<FrequencyChangeEv
|
||||
/**
|
||||
* Returns the event logger configuration for this channel.
|
||||
*/
|
||||
@XmlElement(name = "event_log_configuration")
|
||||
@JacksonXmlProperty(isAttribute = false, localName = "event_log_configuration")
|
||||
public EventLogConfiguration getEventLogConfiguration()
|
||||
{
|
||||
return mEventLogConfiguration;
|
||||
@@ -387,7 +377,7 @@ public class Channel extends Configuration implements Listener<FrequencyChangeEv
|
||||
/**
|
||||
* Returns the recorder configuration for this channel.
|
||||
*/
|
||||
@XmlElement(name = "record_configuration")
|
||||
@JacksonXmlProperty(isAttribute = false, localName = "record_configuration")
|
||||
public RecordConfiguration getRecordConfiguration()
|
||||
{
|
||||
return mRecordConfiguration;
|
||||
@@ -409,7 +399,7 @@ public class Channel extends Configuration implements Listener<FrequencyChangeEv
|
||||
* If the source configuration is not a tuner or recording, this method
|
||||
* returns null.
|
||||
*/
|
||||
@XmlTransient
|
||||
@JsonIgnore
|
||||
public TunerChannel getTunerChannel()
|
||||
{
|
||||
if(mTunerChannel == null)
|
||||
@@ -462,9 +452,10 @@ public class Channel extends Configuration implements Listener<FrequencyChangeEv
|
||||
|
||||
/**
|
||||
* Current channel frequency correction value (when this channel is processing)
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
@XmlTransient
|
||||
@JsonIgnore
|
||||
public int getChannelFrequencyCorrection()
|
||||
{
|
||||
return mChannelFrequencyCorrection;
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
package io.github.dsheirer.controller.channel;
|
||||
|
||||
import com.jidesoft.swing.JideSplitPane;
|
||||
import io.github.dsheirer.alias.AliasModel;
|
||||
import io.github.dsheirer.controller.channel.map.ChannelMapModel;
|
||||
import io.github.dsheirer.source.SourceManager;
|
||||
import net.coderazzi.filters.gui.AutoChoices;
|
||||
import net.coderazzi.filters.gui.TableFilterHeader;
|
||||
import net.miginfocom.swing.MigLayout;
|
||||
import io.github.dsheirer.alias.AliasModel;
|
||||
|
||||
import javax.swing.*;
|
||||
import javax.swing.event.ListSelectionEvent;
|
||||
|
||||
@@ -18,17 +18,17 @@
|
||||
package io.github.dsheirer.controller.channel;
|
||||
|
||||
import com.jidesoft.swing.JideTabbedPane;
|
||||
import io.github.dsheirer.alias.AliasModel;
|
||||
import io.github.dsheirer.controller.channel.map.ChannelMapModel;
|
||||
import io.github.dsheirer.gui.editor.Editor;
|
||||
import io.github.dsheirer.gui.editor.EditorValidationException;
|
||||
import io.github.dsheirer.module.decode.AuxDecodeConfigurationEditor;
|
||||
import io.github.dsheirer.module.decode.DecodeConfigurationEditor;
|
||||
import io.github.dsheirer.module.log.EventLogConfigurationEditor;
|
||||
import io.github.dsheirer.record.RecordConfigurationEditor;
|
||||
import io.github.dsheirer.source.SourceConfigurationEditor;
|
||||
import io.github.dsheirer.source.SourceManager;
|
||||
import net.miginfocom.swing.MigLayout;
|
||||
import io.github.dsheirer.alias.AliasModel;
|
||||
import io.github.dsheirer.module.decode.AuxDecodeConfigurationEditor;
|
||||
import io.github.dsheirer.module.decode.DecodeConfigurationEditor;
|
||||
import io.github.dsheirer.module.log.EventLogConfigurationEditor;
|
||||
|
||||
import javax.swing.*;
|
||||
import java.awt.*;
|
||||
|
||||
@@ -18,6 +18,7 @@
|
||||
******************************************************************************/
|
||||
package io.github.dsheirer.controller.channel;
|
||||
|
||||
import io.github.dsheirer.alias.AliasModel;
|
||||
import io.github.dsheirer.audio.AudioPacket;
|
||||
import io.github.dsheirer.channel.metadata.Attribute;
|
||||
import io.github.dsheirer.channel.metadata.AttributeChangeRequest;
|
||||
@@ -25,6 +26,12 @@ import io.github.dsheirer.channel.metadata.ChannelMetadataModel;
|
||||
import io.github.dsheirer.controller.channel.map.ChannelMapModel;
|
||||
import io.github.dsheirer.filter.FilterSet;
|
||||
import io.github.dsheirer.message.Message;
|
||||
import io.github.dsheirer.module.Module;
|
||||
import io.github.dsheirer.module.ProcessingChain;
|
||||
import io.github.dsheirer.module.decode.DecoderFactory;
|
||||
import io.github.dsheirer.module.decode.DecoderType;
|
||||
import io.github.dsheirer.module.decode.event.MessageActivityModel;
|
||||
import io.github.dsheirer.module.log.EventLogManager;
|
||||
import io.github.dsheirer.record.RecorderManager;
|
||||
import io.github.dsheirer.record.RecorderType;
|
||||
import io.github.dsheirer.sample.Listener;
|
||||
@@ -35,13 +42,6 @@ import io.github.dsheirer.source.SourceType;
|
||||
import io.github.dsheirer.source.config.SourceConfigTuner;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import io.github.dsheirer.alias.AliasModel;
|
||||
import io.github.dsheirer.module.Module;
|
||||
import io.github.dsheirer.module.ProcessingChain;
|
||||
import io.github.dsheirer.module.decode.DecoderFactory;
|
||||
import io.github.dsheirer.module.decode.DecoderType;
|
||||
import io.github.dsheirer.module.decode.event.MessageActivityModel;
|
||||
import io.github.dsheirer.module.log.EventLogManager;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
|
||||
@@ -17,11 +17,11 @@
|
||||
******************************************************************************/
|
||||
package io.github.dsheirer.controller.channel;
|
||||
|
||||
import io.github.dsheirer.alias.AliasModel;
|
||||
import io.github.dsheirer.gui.editor.Editor;
|
||||
import net.miginfocom.swing.MigLayout;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import io.github.dsheirer.alias.AliasModel;
|
||||
|
||||
import javax.swing.*;
|
||||
import javax.swing.event.DocumentEvent;
|
||||
|
||||
@@ -1,144 +1,142 @@
|
||||
/*******************************************************************************
|
||||
* 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 io.github.dsheirer.controller.channel.map;
|
||||
|
||||
import javax.xml.bind.annotation.XmlAttribute;
|
||||
import javax.xml.bind.annotation.XmlElement;
|
||||
import javax.xml.bind.annotation.XmlSeeAlso;
|
||||
import javax.xml.bind.annotation.XmlTransient;
|
||||
import com.fasterxml.jackson.annotation.JsonIgnore;
|
||||
import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlProperty;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
@XmlSeeAlso( { ChannelRange.class } )
|
||||
public class ChannelMap
|
||||
{
|
||||
private String mName;
|
||||
private boolean mInvalid = false;
|
||||
|
||||
private List<ChannelRange> mRanges = new ArrayList<ChannelRange>();
|
||||
|
||||
public ChannelMap()
|
||||
{
|
||||
this( "New Channel Map" );
|
||||
}
|
||||
|
||||
public ChannelMap( String name )
|
||||
{
|
||||
mName = name;
|
||||
}
|
||||
|
||||
public ChannelMap copyOf()
|
||||
{
|
||||
ChannelMap map = new ChannelMap( new String( mName ) );
|
||||
|
||||
for( ChannelRange range: mRanges )
|
||||
{
|
||||
map.addRange( range.copyOf() );
|
||||
}
|
||||
|
||||
return map;
|
||||
}
|
||||
private String mName;
|
||||
private boolean mInvalid = false;
|
||||
|
||||
@XmlTransient
|
||||
public boolean isInvalid()
|
||||
{
|
||||
return mInvalid;
|
||||
}
|
||||
private List<ChannelRange> mRanges = new ArrayList<ChannelRange>();
|
||||
|
||||
public String toString()
|
||||
{
|
||||
return mName + ( mInvalid ? " - Error" : "" );
|
||||
}
|
||||
|
||||
@XmlElement( name = "range" )
|
||||
public List<ChannelRange> getRanges()
|
||||
{
|
||||
return mRanges;
|
||||
}
|
||||
public ChannelMap()
|
||||
{
|
||||
this("New Channel Map");
|
||||
}
|
||||
|
||||
public void setRanges( List<ChannelRange> ranges )
|
||||
{
|
||||
mRanges = ranges;
|
||||
|
||||
validate();
|
||||
}
|
||||
|
||||
@XmlAttribute
|
||||
public String getName()
|
||||
{
|
||||
return mName;
|
||||
}
|
||||
|
||||
public void setName( String name )
|
||||
{
|
||||
mName = name;
|
||||
}
|
||||
|
||||
public long getFrequency( int channelNumber )
|
||||
{
|
||||
for( ChannelRange range: mRanges )
|
||||
{
|
||||
if( range.hasChannel( channelNumber ) )
|
||||
{
|
||||
return range.getFrequency( channelNumber );
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
public ChannelMap(String name)
|
||||
{
|
||||
mName = name;
|
||||
}
|
||||
|
||||
/**
|
||||
* Validates each of the channel ranges for overlap
|
||||
*/
|
||||
private void validate()
|
||||
{
|
||||
mInvalid = false;
|
||||
|
||||
for( int x = 0; x < mRanges.size(); x++ )
|
||||
{
|
||||
if( !mRanges.get( x ).isValid() )
|
||||
{
|
||||
mInvalid = true;
|
||||
}
|
||||
|
||||
for( int y = x + 1; y < mRanges.size(); y++ )
|
||||
{
|
||||
if( mRanges.get( x ).overlaps( mRanges.get( y ) ) )
|
||||
{
|
||||
mInvalid = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public void addRange( ChannelRange range )
|
||||
{
|
||||
mRanges.add( range );
|
||||
|
||||
validate();
|
||||
}
|
||||
|
||||
public void removeRange( ChannelRange range )
|
||||
{
|
||||
mRanges.remove( range );
|
||||
|
||||
validate();
|
||||
}
|
||||
public ChannelMap copyOf()
|
||||
{
|
||||
ChannelMap map = new ChannelMap(new String(mName));
|
||||
|
||||
for(ChannelRange range : mRanges)
|
||||
{
|
||||
map.addRange(range.copyOf());
|
||||
}
|
||||
|
||||
return map;
|
||||
}
|
||||
|
||||
@JsonIgnore
|
||||
public boolean isInvalid()
|
||||
{
|
||||
return mInvalid;
|
||||
}
|
||||
|
||||
public String toString()
|
||||
{
|
||||
return mName + (mInvalid ? " - Error" : "");
|
||||
}
|
||||
|
||||
@JacksonXmlProperty(isAttribute = false, localName = "range")
|
||||
public List<ChannelRange> getRanges()
|
||||
{
|
||||
return mRanges;
|
||||
}
|
||||
|
||||
public void setRanges(List<ChannelRange> ranges)
|
||||
{
|
||||
mRanges = ranges;
|
||||
|
||||
validate();
|
||||
}
|
||||
|
||||
@JacksonXmlProperty(isAttribute = true, localName = "name")
|
||||
public String getName()
|
||||
{
|
||||
return mName;
|
||||
}
|
||||
|
||||
public void setName(String name)
|
||||
{
|
||||
mName = name;
|
||||
}
|
||||
|
||||
public long getFrequency(int channelNumber)
|
||||
{
|
||||
for(ChannelRange range : mRanges)
|
||||
{
|
||||
if(range.hasChannel(channelNumber))
|
||||
{
|
||||
return range.getFrequency(channelNumber);
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Validates each of the channel ranges for overlap
|
||||
*/
|
||||
private void validate()
|
||||
{
|
||||
mInvalid = false;
|
||||
|
||||
for(int x = 0; x < mRanges.size(); x++)
|
||||
{
|
||||
if(!mRanges.get(x).isValid())
|
||||
{
|
||||
mInvalid = true;
|
||||
}
|
||||
|
||||
for(int y = x + 1; y < mRanges.size(); y++)
|
||||
{
|
||||
if(mRanges.get(x).overlaps(mRanges.get(y)))
|
||||
{
|
||||
mInvalid = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public void addRange(ChannelRange range)
|
||||
{
|
||||
mRanges.add(range);
|
||||
|
||||
validate();
|
||||
}
|
||||
|
||||
public void removeRange(ChannelRange range)
|
||||
{
|
||||
mRanges.remove(range);
|
||||
|
||||
validate();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,185 +1,188 @@
|
||||
/*******************************************************************************
|
||||
* 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 io.github.dsheirer.controller.channel.map;
|
||||
|
||||
import javax.xml.bind.annotation.XmlAttribute;
|
||||
import javax.xml.bind.annotation.XmlRootElement;
|
||||
import javax.xml.bind.annotation.XmlTransient;
|
||||
import javax.xml.bind.annotation.XmlType;
|
||||
import com.fasterxml.jackson.annotation.JsonIgnore;
|
||||
import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlProperty;
|
||||
import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlRootElement;
|
||||
|
||||
import java.text.DecimalFormat;
|
||||
|
||||
@XmlRootElement
|
||||
@XmlType( name = "range" )
|
||||
@JacksonXmlRootElement(localName = "range")
|
||||
public class ChannelRange
|
||||
{
|
||||
private static final DecimalFormat FREQUENCY_FORMATTER = new DecimalFormat( "#.0000" );
|
||||
private static final DecimalFormat FREQUENCY_FORMATTER = new DecimalFormat("#.0000");
|
||||
|
||||
private int mFirst = 1;
|
||||
private int mLast = 1023;
|
||||
private int mBase = 450000000;
|
||||
private int mSize = 12500;
|
||||
|
||||
private boolean mOverlapping = false;
|
||||
private int mFirst = 1;
|
||||
private int mLast = 1023;
|
||||
private int mBase = 450000000;
|
||||
private int mSize = 12500;
|
||||
|
||||
public ChannelRange()
|
||||
{
|
||||
}
|
||||
|
||||
public ChannelRange( int first, int last, int base, int size )
|
||||
{
|
||||
mFirst = first;
|
||||
mLast = last;
|
||||
mBase = base;
|
||||
mSize = size;
|
||||
}
|
||||
private boolean mOverlapping = false;
|
||||
|
||||
public ChannelRange copyOf()
|
||||
{
|
||||
return new ChannelRange( mFirst, mLast, mBase, mSize );
|
||||
}
|
||||
|
||||
public String getDescription()
|
||||
{
|
||||
StringBuilder sb = new StringBuilder();
|
||||
|
||||
if( isValid() )
|
||||
{
|
||||
sb.append( "First: " );
|
||||
sb.append( mFirst + "=" );
|
||||
|
||||
long frequency = getFrequency( mFirst );
|
||||
|
||||
sb.append( FREQUENCY_FORMATTER.format( (double)frequency / 1E6D ) );
|
||||
sb.append( " Last: " );
|
||||
sb.append( mLast + "=" );
|
||||
|
||||
frequency = getFrequency( mLast );
|
||||
sb.append( FREQUENCY_FORMATTER.format( (double)frequency / 1E6D ) );
|
||||
sb.append( " MHz" );
|
||||
}
|
||||
else
|
||||
{
|
||||
sb.append( "First channel must be smaller than last channel" );
|
||||
}
|
||||
|
||||
if( isOverlapping() )
|
||||
{
|
||||
if( sb.length() > 0 )
|
||||
{
|
||||
sb.append( ", " );
|
||||
}
|
||||
|
||||
sb.append( "Overlap!" );
|
||||
}
|
||||
public ChannelRange()
|
||||
{
|
||||
}
|
||||
|
||||
return sb.toString();
|
||||
}
|
||||
|
||||
public boolean isValid()
|
||||
{
|
||||
return mFirst < mLast;
|
||||
}
|
||||
|
||||
public boolean overlaps( ChannelRange other )
|
||||
{
|
||||
return ( mFirst <= other.mFirst && other.mFirst <= mLast ) ||
|
||||
( mFirst <= other.mLast && other.mLast <= mLast ) ||
|
||||
( mFirst <= other.mFirst && other.mLast <= mLast ) ||
|
||||
( other.mFirst <= mFirst && mLast <= other.mLast );
|
||||
}
|
||||
public ChannelRange(int first, int last, int base, int size)
|
||||
{
|
||||
mFirst = first;
|
||||
mLast = last;
|
||||
mBase = base;
|
||||
mSize = size;
|
||||
}
|
||||
|
||||
@XmlTransient
|
||||
public boolean isOverlapping()
|
||||
{
|
||||
return mOverlapping;
|
||||
}
|
||||
|
||||
public void setOverlapping( boolean overlapping )
|
||||
{
|
||||
mOverlapping = overlapping;
|
||||
}
|
||||
|
||||
public boolean hasChannel( int channel )
|
||||
{
|
||||
return mFirst <= channel && channel <= mLast;
|
||||
}
|
||||
|
||||
public long getFrequency( int channel )
|
||||
{
|
||||
if( hasChannel( channel ) )
|
||||
{
|
||||
return mBase + ( ( channel - mFirst ) * mSize );
|
||||
}
|
||||
else
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
@XmlAttribute( name = "first" )
|
||||
public int getFirstChannelNumber()
|
||||
{
|
||||
return mFirst;
|
||||
}
|
||||
|
||||
public void setFirstChannelNumber( int first )
|
||||
{
|
||||
mFirst = first;
|
||||
}
|
||||
public ChannelRange copyOf()
|
||||
{
|
||||
return new ChannelRange(mFirst, mLast, mBase, mSize);
|
||||
}
|
||||
|
||||
@XmlAttribute( name = "last" )
|
||||
public void setLastChannelNumber( int last )
|
||||
{
|
||||
mLast = last;
|
||||
}
|
||||
|
||||
public int getLastChannelNumber()
|
||||
{
|
||||
return mLast;
|
||||
}
|
||||
@JsonIgnore
|
||||
public String getDescription()
|
||||
{
|
||||
StringBuilder sb = new StringBuilder();
|
||||
|
||||
/**
|
||||
* Sets the base frequency
|
||||
* @param base frequency in hertz
|
||||
*/
|
||||
@XmlAttribute( name = "base" )
|
||||
public void setBase( int base )
|
||||
{
|
||||
mBase = base;
|
||||
}
|
||||
|
||||
public int getBase()
|
||||
{
|
||||
return mBase;
|
||||
}
|
||||
if(isValid())
|
||||
{
|
||||
sb.append("First: ");
|
||||
sb.append(mFirst + "=");
|
||||
|
||||
/**
|
||||
* Sets the channel size
|
||||
* @param size in hertz
|
||||
*/
|
||||
@XmlAttribute( name = "size" )
|
||||
public void setSize( int size )
|
||||
{
|
||||
mSize = size;
|
||||
}
|
||||
|
||||
public int getSize()
|
||||
{
|
||||
return mSize;
|
||||
}
|
||||
long frequency = getFrequency(mFirst);
|
||||
|
||||
sb.append(FREQUENCY_FORMATTER.format((double)frequency / 1E6D));
|
||||
sb.append(" Last: ");
|
||||
sb.append(mLast + "=");
|
||||
|
||||
frequency = getFrequency(mLast);
|
||||
sb.append(FREQUENCY_FORMATTER.format((double)frequency / 1E6D));
|
||||
sb.append(" MHz");
|
||||
}
|
||||
else
|
||||
{
|
||||
sb.append("First channel must be smaller than last channel");
|
||||
}
|
||||
|
||||
if(isOverlapping())
|
||||
{
|
||||
if(sb.length() > 0)
|
||||
{
|
||||
sb.append(", ");
|
||||
}
|
||||
|
||||
sb.append("Overlap!");
|
||||
}
|
||||
|
||||
return sb.toString();
|
||||
}
|
||||
|
||||
@JsonIgnore
|
||||
public boolean isValid()
|
||||
{
|
||||
return mFirst < mLast;
|
||||
}
|
||||
|
||||
public boolean overlaps(ChannelRange other)
|
||||
{
|
||||
return (mFirst <= other.mFirst && other.mFirst <= mLast) ||
|
||||
(mFirst <= other.mLast && other.mLast <= mLast) ||
|
||||
(mFirst <= other.mFirst && other.mLast <= mLast) ||
|
||||
(other.mFirst <= mFirst && mLast <= other.mLast);
|
||||
}
|
||||
|
||||
@JsonIgnore
|
||||
public boolean isOverlapping()
|
||||
{
|
||||
return mOverlapping;
|
||||
}
|
||||
|
||||
public void setOverlapping(boolean overlapping)
|
||||
{
|
||||
mOverlapping = overlapping;
|
||||
}
|
||||
|
||||
public boolean hasChannel(int channel)
|
||||
{
|
||||
return mFirst <= channel && channel <= mLast;
|
||||
}
|
||||
|
||||
public long getFrequency(int channel)
|
||||
{
|
||||
if(hasChannel(channel))
|
||||
{
|
||||
return mBase + ((channel - mFirst) * mSize);
|
||||
}
|
||||
else
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
@JacksonXmlProperty(isAttribute = true, localName = "first")
|
||||
public int getFirstChannelNumber()
|
||||
{
|
||||
return mFirst;
|
||||
}
|
||||
|
||||
public void setFirstChannelNumber(int first)
|
||||
{
|
||||
mFirst = first;
|
||||
}
|
||||
|
||||
@JacksonXmlProperty(isAttribute = true, localName = "last")
|
||||
public void setLastChannelNumber(int last)
|
||||
{
|
||||
mLast = last;
|
||||
}
|
||||
|
||||
public int getLastChannelNumber()
|
||||
{
|
||||
return mLast;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the base frequency
|
||||
*
|
||||
* @param base frequency in hertz
|
||||
*/
|
||||
@JacksonXmlProperty(isAttribute = true, localName = "base")
|
||||
public void setBase(int base)
|
||||
{
|
||||
mBase = base;
|
||||
}
|
||||
|
||||
public int getBase()
|
||||
{
|
||||
return mBase;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the channel size
|
||||
*
|
||||
* @param size in hertz
|
||||
*/
|
||||
@JacksonXmlProperty(isAttribute = true, localName = "size")
|
||||
public void setSize(int size)
|
||||
{
|
||||
mSize = size;
|
||||
}
|
||||
|
||||
public int getSize()
|
||||
{
|
||||
return mSize;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,40 +1,28 @@
|
||||
/*******************************************************************************
|
||||
* 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 io.github.dsheirer.controller.config;
|
||||
|
||||
import io.github.dsheirer.record.config.RecordConfiguration;
|
||||
import io.github.dsheirer.source.config.SourceConfiguration;
|
||||
import io.github.dsheirer.module.decode.config.AuxDecodeConfiguration;
|
||||
import io.github.dsheirer.module.decode.config.DecodeConfiguration;
|
||||
import io.github.dsheirer.module.log.config.EventLogConfiguration;
|
||||
import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlRootElement;
|
||||
|
||||
import javax.xml.bind.annotation.XmlRootElement;
|
||||
import javax.xml.bind.annotation.XmlSeeAlso;
|
||||
|
||||
@XmlSeeAlso( { AuxDecodeConfiguration.class,
|
||||
DecodeConfiguration.class,
|
||||
EventLogConfiguration.class,
|
||||
RecordConfiguration.class,
|
||||
SourceConfiguration.class } )
|
||||
@XmlRootElement( name = "configuration" )
|
||||
@JacksonXmlRootElement(localName = "configuration")
|
||||
public abstract class Configuration
|
||||
{
|
||||
public Configuration()
|
||||
{
|
||||
}
|
||||
public Configuration()
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user