move decoding to InputBase.addToQueue()

This commit is contained in:
Schrolli91 2021-01-08 21:39:41 +01:00
parent a697564294
commit f3f188f93b
No known key found for this signature in database
GPG key ID: 0AE96912A20E9F5F
2 changed files with 7 additions and 10 deletions

View file

@ -20,6 +20,7 @@ import threading
from abc import ABC, abstractmethod
from boswatch.utils import paths
from boswatch.processManager import ProcessManager
from boswatch.decoder.decoder import Decoder
logging.debug("- %s loaded", __name__)
@ -61,10 +62,11 @@ class InputBase(ABC):
logging.debug("input thread stopped")
def addToQueue(self, data):
"""!Adds alarm data to the queue for further processing during boswatch client"""
self._inputQueue.put_nowait((data, time.time()))
logging.debug("Add received data to queue")
print(data)
"""!Decode and add alarm data to the queue for further processing during boswatch client"""
bwPacket = Decoder.decode(data)
if bwPacket is not None:
self._inputQueue.put_nowait((bwPacket, time.time()))
logging.debug("Added received data to queue")
def getDecoderInstance(self, decoderConfig, StdIn):
mmProc = ProcessManager(str(decoderConfig.get("path", default="multimon-ng")), textMode=True)

View file

@ -46,7 +46,6 @@ logging.debug("Import BOSWatch modules")
from boswatch.configYaml import ConfigYAML
from boswatch.network.client import TCPClient
from boswatch.network.broadcast import BroadcastClient
from boswatch.decoder.decoder import Decoder
from boswatch.utils import header
from boswatch.utils import misc
from boswatch.inputSource.sdrInput import SdrInput
@ -123,13 +122,9 @@ try:
data = inputQueue.get()
logging.info("get data from queue (waited %0.3f sec.)", time.time() - data[1])
logging.debug("%s packet(s) still waiting in queue", inputQueue.qsize())
bwPacket = Decoder.decode(data[0])
bwPacket = data[0]
inputQueue.task_done()
if bwPacket is None:
continue
bwPacket.printInfo()
misc.addClientDataToPacket(bwPacket, bwConfig)