Adds tuner preference editor with channelizer type options. Updates (#456)

tuners to use the preference to select either polyphase or heterodyne
channelizers.
This commit is contained in:
Denny Sheirer
2018-12-25 06:43:10 -05:00
committed by GitHub
parent b67d4d92dc
commit efd811407e
25 changed files with 717 additions and 249 deletions

View File

@@ -26,6 +26,7 @@ package io.github.dsheirer.preference;
public enum PreferenceType
{
DECODE_EVENT,
FILES,
IDENTIFIER,
FILES;
TUNER;
}

View File

@@ -24,6 +24,7 @@ import io.github.dsheirer.eventbus.MyEventBus;
import io.github.dsheirer.preference.event.DecodeEventPreference;
import io.github.dsheirer.preference.identifier.TalkgroupFormatPreference;
import io.github.dsheirer.preference.playlist.FilePreferences;
import io.github.dsheirer.preference.tuner.TunerPreference;
import io.github.dsheirer.sample.Listener;
/**
@@ -34,6 +35,7 @@ public class UserPreferences implements Listener<PreferenceType>
private DecodeEventPreference mDecodeEventPreference;
private FilePreferences mFilePreferences;
private TalkgroupFormatPreference mTalkgroupFormatPreference;
private TunerPreference mTunerPreference;
/**
* Constructs a new user preferences instance
@@ -67,6 +69,14 @@ public class UserPreferences implements Listener<PreferenceType>
return mTalkgroupFormatPreference;
}
/**
* Tuner preferences
*/
public TunerPreference getTunerPreference()
{
return mTunerPreference;
}
/**
* Loads the managed preferences
*/
@@ -75,6 +85,7 @@ public class UserPreferences implements Listener<PreferenceType>
mDecodeEventPreference = new DecodeEventPreference(this);
mFilePreferences = new FilePreferences(this::receive);
mTalkgroupFormatPreference = new TalkgroupFormatPreference(this);
mTunerPreference = new TunerPreference(this);
}
/**

View File

@@ -0,0 +1,42 @@
/*
* ******************************************************************************
* sdrtrunk
* Copyright (C) 2014-2018 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.preference.tuner;
/**
* Channelizer Type - identifies the type of channelizer that the tuner will use to provide DDR channels
*/
public enum ChannelizerType
{
POLYPHASE("Polyphase"),
HETERODYNE(" Heterodyne");
private String mLabel;
ChannelizerType(String label)
{
mLabel = label;
}
public String toString()
{
return mLabel;
}
}

View File

@@ -0,0 +1,98 @@
/*
* ******************************************************************************
* sdrtrunk
* Copyright (C) 2014-2018 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.preference.tuner;
import io.github.dsheirer.preference.Preference;
import io.github.dsheirer.preference.PreferenceType;
import io.github.dsheirer.sample.Listener;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.util.prefs.Preferences;
/**
* Tuner preferences
*/
public class TunerPreference extends Preference
{
private final static Logger mLog = LoggerFactory.getLogger(TunerPreference.class);
private Preferences mPreferences = Preferences.userNodeForPackage(TunerPreference.class);
private static final String PREFERENCE_KEY_CHANNELIZER_TYPE = "channelizer.type";
private ChannelizerType mChannelizerType;
/**
* Constructs a tuner preference with the update listener
*
* @param updateListener
*/
public TunerPreference(Listener<PreferenceType> updateListener)
{
super(updateListener);
}
@Override
public PreferenceType getPreferenceType()
{
return PreferenceType.TUNER;
}
/**
* Channelizer type used by the tuners
*/
public ChannelizerType getChannelizerType()
{
if(mChannelizerType == null)
{
String type = mPreferences.get(PREFERENCE_KEY_CHANNELIZER_TYPE, ChannelizerType.POLYPHASE.name());
if(type != null)
{
if(type.equalsIgnoreCase(ChannelizerType.POLYPHASE.name()))
{
mChannelizerType = ChannelizerType.POLYPHASE;
}
else if(type.equalsIgnoreCase(ChannelizerType.HETERODYNE.name()))
{
mChannelizerType = ChannelizerType.HETERODYNE;
}
}
if(type == null)
{
mChannelizerType = ChannelizerType.POLYPHASE;
}
}
return mChannelizerType;
}
/**
* Sets the channelizer type use by tuners
*/
public void setChannelizerType(ChannelizerType type)
{
mChannelizerType = type;
mPreferences.put(PREFERENCE_KEY_CHANNELIZER_TYPE, mChannelizerType.name());
notifyPreferenceUpdated();
}
}