mirror of
https://github.com/DSheirer/sdrtrunk.git
synced 2026-11-12 16:47:31 -05:00
* #6 DMR decoder feature - work in progress * #6 DMR Decoder. * #6 DMR Decoder. Code review updates. Co-authored-by: Zhenyu Mao <maozhenyu@foxmail.com> Co-authored-by: Denny <denny@denny-desktop>
This commit is contained in:
@@ -208,6 +208,6 @@ public class UserPreferences implements Listener<PreferenceType>
|
||||
@Override
|
||||
public void receive(PreferenceType preferenceType)
|
||||
{
|
||||
MyEventBus.getEventBus().post(preferenceType);
|
||||
MyEventBus.getGlobalEventBus().post(preferenceType);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -29,6 +29,7 @@ import io.github.dsheirer.identifier.talkgroup.TalkgroupIdentifier;
|
||||
import io.github.dsheirer.preference.Preference;
|
||||
import io.github.dsheirer.preference.PreferenceType;
|
||||
import io.github.dsheirer.preference.identifier.talkgroup.APCO25TalkgroupFormatter;
|
||||
import io.github.dsheirer.preference.identifier.talkgroup.DMRTalkgroupFormatter;
|
||||
import io.github.dsheirer.preference.identifier.talkgroup.FleetsyncTalkgroupFormatter;
|
||||
import io.github.dsheirer.preference.identifier.talkgroup.LTRTalkgroupFormatter;
|
||||
import io.github.dsheirer.preference.identifier.talkgroup.MDC1200TalkgroupFormatter;
|
||||
@@ -40,7 +41,6 @@ import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import java.util.EnumMap;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.prefs.Preferences;
|
||||
@@ -150,6 +150,7 @@ public class TalkgroupFormatPreference extends Preference
|
||||
case MPT1327:
|
||||
return IntegerFormat.FORMATTED;
|
||||
case APCO25:
|
||||
case DMR:
|
||||
case MDC1200:
|
||||
case PASSPORT:
|
||||
case UNKNOWN:
|
||||
@@ -168,6 +169,7 @@ public class TalkgroupFormatPreference extends Preference
|
||||
case MPT1327:
|
||||
return IntegerFormat.DECIMAL_FORMATTED;
|
||||
case APCO25:
|
||||
case DMR:
|
||||
case MDC1200:
|
||||
case PASSPORT:
|
||||
case UNKNOWN:
|
||||
@@ -184,6 +186,7 @@ public class TalkgroupFormatPreference extends Preference
|
||||
case PASSPORT:
|
||||
return false;
|
||||
case APCO25:
|
||||
case DMR:
|
||||
case FLEETSYNC:
|
||||
case LTR:
|
||||
case LTR_NET:
|
||||
@@ -311,6 +314,9 @@ public class TalkgroupFormatPreference extends Preference
|
||||
case APCO25:
|
||||
return APCO25TalkgroupFormatter.format(talkgroupIdentifier, getTalkgroupFormat(Protocol.APCO25),
|
||||
isTalkgroupFixedWidth(Protocol.APCO25));
|
||||
case DMR:
|
||||
return DMRTalkgroupFormatter.format(talkgroupIdentifier, getTalkgroupFormat(Protocol.DMR),
|
||||
isTalkgroupFixedWidth(Protocol.DMR));
|
||||
case FLEETSYNC:
|
||||
return FleetsyncTalkgroupFormatter.format(talkgroupIdentifier, getTalkgroupFormat(Protocol.FLEETSYNC),
|
||||
isTalkgroupFixedWidth(Protocol.FLEETSYNC));
|
||||
@@ -362,6 +368,9 @@ public class TalkgroupFormatPreference extends Preference
|
||||
case APCO25:
|
||||
return APCO25TalkgroupFormatter.format(radioIdentifier, getTalkgroupFormat(Protocol.APCO25),
|
||||
isTalkgroupFixedWidth(Protocol.APCO25));
|
||||
case DMR:
|
||||
return DMRTalkgroupFormatter.format(radioIdentifier, getTalkgroupFormat(Protocol.DMR),
|
||||
isTalkgroupFixedWidth(Protocol.DMR));
|
||||
case PASSPORT:
|
||||
return PassportTalkgroupFormatter.format(radioIdentifier, getTalkgroupFormat(Protocol.PASSPORT),
|
||||
isTalkgroupFixedWidth(Protocol.PASSPORT));
|
||||
|
||||
@@ -0,0 +1,113 @@
|
||||
/*
|
||||
* *****************************************************************************
|
||||
* Copyright (C) 2014-2020 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.identifier.talkgroup;
|
||||
|
||||
import io.github.dsheirer.identifier.radio.RadioIdentifier;
|
||||
import io.github.dsheirer.identifier.talkgroup.TalkgroupIdentifier;
|
||||
import io.github.dsheirer.preference.identifier.IntegerFormat;
|
||||
|
||||
public class DMRTalkgroupFormatter extends AbstractIntegerFormatter
|
||||
{
|
||||
public static final int GROUP_DECIMAL_WIDTH = 8;
|
||||
public static final int UNIT_DECIMAL_WIDTH = 8;
|
||||
public static final int GROUP_HEXADECIMAL_WIDTH = 6;
|
||||
public static final int UNIT_HEXADECIMAL_WIDTH = 6;
|
||||
|
||||
/**
|
||||
* Formats the individual or group identifier to the specified format and width.
|
||||
*/
|
||||
public static String format(TalkgroupIdentifier identifier, IntegerFormat format, boolean fixedWidth)
|
||||
{
|
||||
if(fixedWidth)
|
||||
{
|
||||
switch(format)
|
||||
{
|
||||
case DECIMAL:
|
||||
case FORMATTED:
|
||||
return toDecimal(identifier.getValue(), GROUP_DECIMAL_WIDTH);
|
||||
case HEXADECIMAL:
|
||||
return toHex(identifier.getValue(), GROUP_HEXADECIMAL_WIDTH);
|
||||
default:
|
||||
throw new IllegalArgumentException("Unrecognized integer format: " + format);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
switch(format)
|
||||
{
|
||||
case DECIMAL:
|
||||
case FORMATTED:
|
||||
return identifier.getValue().toString();
|
||||
case HEXADECIMAL:
|
||||
return toHex(identifier.getValue());
|
||||
default:
|
||||
throw new IllegalArgumentException("Unrecognized integer format: " + format);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Formats the radio identifier to the specified format and width.
|
||||
*/
|
||||
public static String format(RadioIdentifier identifier, IntegerFormat format, boolean fixedWidth)
|
||||
{
|
||||
if(fixedWidth)
|
||||
{
|
||||
switch(format)
|
||||
{
|
||||
case DECIMAL:
|
||||
case FORMATTED:
|
||||
return toDecimal(identifier.getValue(), UNIT_DECIMAL_WIDTH);
|
||||
case HEXADECIMAL:
|
||||
return toHex(identifier.getValue(), UNIT_HEXADECIMAL_WIDTH);
|
||||
default:
|
||||
throw new IllegalArgumentException("Unrecognized integer format: " + format);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
switch(format)
|
||||
{
|
||||
case DECIMAL:
|
||||
case FORMATTED:
|
||||
return identifier.getValue().toString();
|
||||
case HEXADECIMAL:
|
||||
return toHex(identifier.getValue());
|
||||
default:
|
||||
throw new IllegalArgumentException("Unrecognized integer format: " + format);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String format(int value, IntegerFormat integerFormat)
|
||||
{
|
||||
switch(integerFormat)
|
||||
{
|
||||
case DECIMAL:
|
||||
case FORMATTED:
|
||||
return format(value);
|
||||
case HEXADECIMAL:
|
||||
return toHex(value);
|
||||
default:
|
||||
throw new IllegalArgumentException("Unrecognized integer format: " + integerFormat);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user