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:
72
src/main/java/io/github/dsheirer/message/MessageHistory.java
Normal file
72
src/main/java/io/github/dsheirer/message/MessageHistory.java
Normal file
@@ -0,0 +1,72 @@
|
||||
/*
|
||||
* *****************************************************************************
|
||||
* 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.message;
|
||||
|
||||
import com.google.common.eventbus.Subscribe;
|
||||
import io.github.dsheirer.module.HistoryModule;
|
||||
import io.github.dsheirer.sample.Listener;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
/**
|
||||
* Decode event history module. Maintains a history of decode events and constrains the total history size.
|
||||
*/
|
||||
public class MessageHistory extends HistoryModule<IMessage> implements IMessageListener
|
||||
{
|
||||
private final static Logger mLog = LoggerFactory.getLogger(MessageHistory.class);
|
||||
|
||||
/**
|
||||
* Constructs an instance
|
||||
*/
|
||||
public MessageHistory(int historySize)
|
||||
{
|
||||
super(historySize);
|
||||
}
|
||||
|
||||
/**
|
||||
* Implements the IDecodeEventListener interface - delegates to receive(event) method.
|
||||
*/
|
||||
@Override
|
||||
public Listener<IMessage> getMessageListener()
|
||||
{
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Process a request for message history and post the response to the module event bus
|
||||
*/
|
||||
@Subscribe
|
||||
public void process(MessageHistoryRequest request)
|
||||
{
|
||||
getInterModuleEventBus().post(new MessageHistoryResponse(getItems()));
|
||||
}
|
||||
|
||||
/**
|
||||
* Processes a request to preload message history
|
||||
*/
|
||||
@Subscribe
|
||||
public void process(MessageHistoryPreloadData preloadData)
|
||||
{
|
||||
for(IMessage message: preloadData.getData())
|
||||
{
|
||||
receive(message);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,39 @@
|
||||
/*
|
||||
* *****************************************************************************
|
||||
* 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.message;
|
||||
|
||||
import io.github.dsheirer.controller.channel.event.PreloadDataContent;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Message history to preload into the message history module.
|
||||
*/
|
||||
public class MessageHistoryPreloadData extends PreloadDataContent<List<IMessage>>
|
||||
{
|
||||
/**
|
||||
* Constructs an instance
|
||||
* @param messages from the history
|
||||
*/
|
||||
public MessageHistoryPreloadData(List<IMessage> messages)
|
||||
{
|
||||
super(messages);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
/*
|
||||
* *****************************************************************************
|
||||
* 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.message;
|
||||
|
||||
import io.github.dsheirer.module.ModuleEventBusMessage;
|
||||
|
||||
/**
|
||||
* Request for message history from the message history module.
|
||||
*/
|
||||
public class MessageHistoryRequest extends ModuleEventBusMessage
|
||||
{
|
||||
}
|
||||
@@ -0,0 +1,49 @@
|
||||
/*
|
||||
* *****************************************************************************
|
||||
* 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.message;
|
||||
|
||||
import io.github.dsheirer.module.ModuleEventBusMessage;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Response to message history request.
|
||||
*/
|
||||
public class MessageHistoryResponse extends ModuleEventBusMessage
|
||||
{
|
||||
private List<IMessage> mMessages;
|
||||
|
||||
/**
|
||||
* Constructs an instance
|
||||
* @param messages from the history
|
||||
*/
|
||||
public MessageHistoryResponse(List<IMessage> messages)
|
||||
{
|
||||
mMessages = messages;
|
||||
}
|
||||
|
||||
/**
|
||||
* Message history
|
||||
*/
|
||||
public List<IMessage> getMessages()
|
||||
{
|
||||
return mMessages;
|
||||
}
|
||||
}
|
||||
@@ -55,12 +55,6 @@ public class MessageProviderModule extends Module implements IMessageProvider
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void dispose()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public void receive(IMessage message)
|
||||
{
|
||||
if(mMessageListener != null)
|
||||
|
||||
@@ -30,6 +30,22 @@ public class SyncLossMessage extends Message
|
||||
{
|
||||
private int mBitsProcessed;
|
||||
private Protocol mProtocol;
|
||||
private int mTimeslot = 0;
|
||||
|
||||
/**
|
||||
* Constructs a sync loss message.
|
||||
*
|
||||
* @param timestamp of the message
|
||||
* @param bitsProcessed without a sync pattern detection of message decode
|
||||
* @param timeslot that lost the sync
|
||||
*/
|
||||
public SyncLossMessage(long timestamp, int bitsProcessed, Protocol protocol, int timeslot)
|
||||
{
|
||||
super(timestamp);
|
||||
mBitsProcessed = bitsProcessed;
|
||||
mProtocol = protocol;
|
||||
mTimeslot = timeslot;
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructs a sync loss message.
|
||||
@@ -39,13 +55,21 @@ public class SyncLossMessage extends Message
|
||||
*/
|
||||
public SyncLossMessage(long timestamp, int bitsProcessed, Protocol protocol)
|
||||
{
|
||||
super(timestamp);
|
||||
mBitsProcessed = bitsProcessed;
|
||||
mProtocol = protocol;
|
||||
this(timestamp, bitsProcessed, protocol, 0);
|
||||
}
|
||||
|
||||
/**
|
||||
* Indicates the number of bits that were processed without a sync dectection or message decode
|
||||
* Timeslot that lost the sync
|
||||
* @return timeslot or a default of 0
|
||||
*/
|
||||
@Override
|
||||
public int getTimeslot()
|
||||
{
|
||||
return mTimeslot;
|
||||
}
|
||||
|
||||
/**
|
||||
* Indicates the number of bits that were processed without a sync detection or message decode
|
||||
*/
|
||||
public int getBitsProcessed()
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user