mirror of
https://github.com/DSheirer/sdrtrunk.git
synced 2026-11-14 17:47:32 -05:00
Resolves issue with the multi-frequency tuner source and P25/MPT1327 (#603)
Resolves issue with the multi-frequency tuner source and P25/MPT1327 (#603) rotating channel frequency configurations failing to maintain lock on the channel. Converted the ChannelRotationMonitor from using identifier updates to now using DecoderStateEvents so that the ChannelState can supply a steady stream of channel state events to the monitor.
This commit is contained in:
@@ -24,6 +24,14 @@ package io.github.dsheirer.channel.state;
|
|||||||
|
|
||||||
public class DecoderStateEvent
|
public class DecoderStateEvent
|
||||||
{
|
{
|
||||||
|
private static final DecoderStateEvent ACTIVE_STATE_TIMESLOT_0 =
|
||||||
|
new DecoderStateEvent(null, Event.NOTIFICATION_CHANNEL_ACTIVE_STATE, State.ACTIVE, 0);
|
||||||
|
private static final DecoderStateEvent ACTIVE_STATE_TIMESLOT_1 =
|
||||||
|
new DecoderStateEvent(null, Event.NOTIFICATION_CHANNEL_ACTIVE_STATE, State.ACTIVE, 1);
|
||||||
|
private static final DecoderStateEvent INACTIVE_STATE_TIMESLOT_0 =
|
||||||
|
new DecoderStateEvent(null, Event.NOTIFICATION_CHANNEL_INACTIVE_STATE, State.ACTIVE, 0);
|
||||||
|
private static final DecoderStateEvent INACTIVE_STATE_TIMESLOT_1 =
|
||||||
|
new DecoderStateEvent(null, Event.NOTIFICATION_CHANNEL_INACTIVE_STATE, State.ACTIVE, 1);
|
||||||
private Object mSource;
|
private Object mSource;
|
||||||
private Event mEvent;
|
private Event mEvent;
|
||||||
private State mState;
|
private State mState;
|
||||||
@@ -54,6 +62,68 @@ public class DecoderStateEvent
|
|||||||
this(source, event, state, 0, frequency);
|
this(source, event, state, 0, frequency);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates a channel state active event for the specified timeslot
|
||||||
|
* @param timeslot that the state applies to
|
||||||
|
* @return new event
|
||||||
|
*/
|
||||||
|
public static DecoderStateEvent activeState(int timeslot)
|
||||||
|
{
|
||||||
|
if(timeslot == 0)
|
||||||
|
{
|
||||||
|
return ACTIVE_STATE_TIMESLOT_0;
|
||||||
|
}
|
||||||
|
else if(timeslot == 1)
|
||||||
|
{
|
||||||
|
return ACTIVE_STATE_TIMESLOT_1;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
throw new IllegalArgumentException("Only timeslots 0 and 1 are currently supported");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates a channel state active event for the specified timeslot.
|
||||||
|
* @param state currently
|
||||||
|
* @return new event
|
||||||
|
*/
|
||||||
|
public static DecoderStateEvent activeState()
|
||||||
|
{
|
||||||
|
return activeState(0);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates a channel state inactive event for the specified timeslot
|
||||||
|
* @param timeslot that the state applies to
|
||||||
|
* @return new event
|
||||||
|
*/
|
||||||
|
public static DecoderStateEvent inactiveState(int timeslot)
|
||||||
|
{
|
||||||
|
if(timeslot == 0)
|
||||||
|
{
|
||||||
|
return INACTIVE_STATE_TIMESLOT_0;
|
||||||
|
}
|
||||||
|
else if(timeslot == 1)
|
||||||
|
{
|
||||||
|
return INACTIVE_STATE_TIMESLOT_1;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
throw new IllegalArgumentException("Only timeslots 0 and 1 are currently supported");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates a channel state active event for the specified timeslot.
|
||||||
|
* @param state currently
|
||||||
|
* @return new event
|
||||||
|
*/
|
||||||
|
public static DecoderStateEvent inactiveState()
|
||||||
|
{
|
||||||
|
return inactiveState(0);
|
||||||
|
}
|
||||||
|
|
||||||
public String toString()
|
public String toString()
|
||||||
{
|
{
|
||||||
StringBuilder sb = new StringBuilder();
|
StringBuilder sb = new StringBuilder();
|
||||||
@@ -99,6 +169,8 @@ public class DecoderStateEvent
|
|||||||
CONTINUATION,
|
CONTINUATION,
|
||||||
DECODE,
|
DECODE,
|
||||||
END,
|
END,
|
||||||
|
NOTIFICATION_CHANNEL_ACTIVE_STATE,
|
||||||
|
NOTIFICATION_CHANNEL_INACTIVE_STATE,
|
||||||
RESET,
|
RESET,
|
||||||
SOURCE_FREQUENCY,
|
SOURCE_FREQUENCY,
|
||||||
START;
|
START;
|
||||||
|
|||||||
@@ -132,6 +132,16 @@ public class MultiChannelState extends AbstractChannelState implements IDecoderS
|
|||||||
@Override
|
@Override
|
||||||
public void stateChanged(State state, int timeslot)
|
public void stateChanged(State state, int timeslot)
|
||||||
{
|
{
|
||||||
|
//Broadcast current channel state so that channel rotation monitor can track
|
||||||
|
if(state.isActiveState())
|
||||||
|
{
|
||||||
|
broadcast(DecoderStateEvent.activeState(timeslot));
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
broadcast(DecoderStateEvent.inactiveState(timeslot));
|
||||||
|
}
|
||||||
|
|
||||||
ChannelStateIdentifier stateIdentifier = ChannelStateIdentifier.create(state);
|
ChannelStateIdentifier stateIdentifier = ChannelStateIdentifier.create(state);
|
||||||
mIdentifierCollectionMap.get(timeslot).update(stateIdentifier);
|
mIdentifierCollectionMap.get(timeslot).update(stateIdentifier);
|
||||||
mChannelMetadataMap.get(timeslot).receive(new IdentifierUpdateNotification(stateIdentifier, IdentifierUpdateNotification.Operation.ADD, timeslot));
|
mChannelMetadataMap.get(timeslot).receive(new IdentifierUpdateNotification(stateIdentifier, IdentifierUpdateNotification.Operation.ADD, timeslot));
|
||||||
|
|||||||
@@ -122,6 +122,16 @@ public class SingleChannelState extends AbstractChannelState implements IDecoder
|
|||||||
@Override
|
@Override
|
||||||
public void stateChanged(State state, int timeslot)
|
public void stateChanged(State state, int timeslot)
|
||||||
{
|
{
|
||||||
|
//Broadcast current channel state so that channel rotation monitor can track
|
||||||
|
if(state.isActiveState())
|
||||||
|
{
|
||||||
|
broadcast(DecoderStateEvent.activeState(timeslot));
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
broadcast(DecoderStateEvent.inactiveState(timeslot));
|
||||||
|
}
|
||||||
|
|
||||||
ChannelStateIdentifier stateIdentifier = ChannelStateIdentifier.create(state);
|
ChannelStateIdentifier stateIdentifier = ChannelStateIdentifier.create(state);
|
||||||
mIdentifierCollection.update(stateIdentifier);
|
mIdentifierCollection.update(stateIdentifier);
|
||||||
mChannelMetadata.receive(new IdentifierUpdateNotification(stateIdentifier, IdentifierUpdateNotification.Operation.ADD, timeslot));
|
mChannelMetadata.receive(new IdentifierUpdateNotification(stateIdentifier, IdentifierUpdateNotification.Operation.ADD, timeslot));
|
||||||
|
|||||||
@@ -1,32 +1,32 @@
|
|||||||
/*
|
/*
|
||||||
* ******************************************************************************
|
|
||||||
* sdrtrunk
|
|
||||||
* Copyright (C) 2014-2019 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
|
* * Copyright (C) 2014-2019 Dennis Sheirer
|
||||||
* the Free Software Foundation, either version 3 of the License, or
|
* *
|
||||||
* (at your option) any later version.
|
* * 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/>
|
||||||
|
* * *****************************************************************************
|
||||||
*
|
*
|
||||||
* 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.source.tuner.channel;
|
package io.github.dsheirer.source.tuner.channel;
|
||||||
|
|
||||||
import com.google.common.eventbus.Subscribe;
|
import com.google.common.eventbus.Subscribe;
|
||||||
|
import io.github.dsheirer.channel.state.DecoderStateEvent;
|
||||||
|
import io.github.dsheirer.channel.state.IDecoderStateEventListener;
|
||||||
import io.github.dsheirer.channel.state.State;
|
import io.github.dsheirer.channel.state.State;
|
||||||
import io.github.dsheirer.eventbus.MyEventBus;
|
import io.github.dsheirer.eventbus.MyEventBus;
|
||||||
import io.github.dsheirer.identifier.Identifier;
|
|
||||||
import io.github.dsheirer.identifier.IdentifierUpdateListener;
|
|
||||||
import io.github.dsheirer.identifier.IdentifierUpdateNotification;
|
|
||||||
import io.github.dsheirer.identifier.decoder.ChannelStateIdentifier;
|
|
||||||
import io.github.dsheirer.module.Module;
|
import io.github.dsheirer.module.Module;
|
||||||
import io.github.dsheirer.preference.PreferenceType;
|
import io.github.dsheirer.preference.PreferenceType;
|
||||||
import io.github.dsheirer.preference.UserPreferences;
|
import io.github.dsheirer.preference.UserPreferences;
|
||||||
@@ -43,10 +43,11 @@ import java.util.concurrent.TimeUnit;
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Monitors channel state to detect when a channel is not in an identified active state and issues a request to rotate
|
* Monitors channel state to detect when a channel is not in an identified active state and issues a request to rotate
|
||||||
* the next channel frequency in the list.
|
* the next channel frequency in the list. This class depends on the ChannelState to provide a continuous
|
||||||
|
* stream of channel active/inactive messaging in the form of DecoderStateEvents.
|
||||||
*/
|
*/
|
||||||
public class ChannelRotationMonitor extends Module implements ISourceEventProvider, IdentifierUpdateListener,
|
public class ChannelRotationMonitor extends Module implements ISourceEventProvider, IDecoderStateEventListener,
|
||||||
Listener<IdentifierUpdateNotification>
|
Listener<DecoderStateEvent>
|
||||||
{
|
{
|
||||||
private final static Logger mLog = LoggerFactory.getLogger(ChannelRotationMonitor.class);
|
private final static Logger mLog = LoggerFactory.getLogger(ChannelRotationMonitor.class);
|
||||||
|
|
||||||
@@ -93,33 +94,27 @@ public class ChannelRotationMonitor extends Module implements ISourceEventProvid
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Listener<IdentifierUpdateNotification> getIdentifierUpdateListener()
|
public Listener<DecoderStateEvent> getDecoderStateListener()
|
||||||
{
|
{
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Primary method for receiving channel state identifier notifications, enabling this module to track the
|
|
||||||
* current channel state being provided by the Channel State module.
|
|
||||||
*/
|
|
||||||
@Override
|
@Override
|
||||||
public void receive(IdentifierUpdateNotification identifierUpdateNotification)
|
public void receive(DecoderStateEvent decoderStateEvent)
|
||||||
{
|
{
|
||||||
Identifier identifier = identifierUpdateNotification.getIdentifier();
|
if(decoderStateEvent.getEvent() == DecoderStateEvent.Event.NOTIFICATION_CHANNEL_ACTIVE_STATE)
|
||||||
|
|
||||||
if(identifier instanceof ChannelStateIdentifier)
|
|
||||||
{
|
{
|
||||||
State currentState = ((ChannelStateIdentifier)identifier).getValue();
|
mActive = true;
|
||||||
|
}
|
||||||
if(mActiveStates.contains(currentState))
|
else if(decoderStateEvent.getEvent() == DecoderStateEvent.Event.NOTIFICATION_CHANNEL_INACTIVE_STATE)
|
||||||
|
{
|
||||||
|
if(mActive)
|
||||||
{
|
{
|
||||||
mActive = true;
|
//If we're toggling from active to inactive, update the timestamp,
|
||||||
}
|
|
||||||
else if(mActive)
|
|
||||||
{
|
|
||||||
mActive = false;
|
|
||||||
mInactiveTimestamp = System.currentTimeMillis();
|
mInactiveTimestamp = System.currentTimeMillis();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
mActive = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user