BW3-Core/boswatch/decoder/decoder.py

44 lines
1.3 KiB
Python
Raw Normal View History

2018-01-07 14:09:40 +01:00
#!/usr/bin/python
# -*- coding: utf-8 -*-
r"""!
2018-01-07 14:09:40 +01:00
____ ____ ______ __ __ __ _____
/ __ )/ __ \/ ___/ | / /___ _/ /______/ /_ |__ /
/ __ / / / /\__ \| | /| / / __ `/ __/ ___/ __ \ /_ <
/ /_/ / /_/ /___/ /| |/ |/ / /_/ / /_/ /__/ / / / ___/ /
/_____/\____//____/ |__/|__/\__,_/\__/\___/_/ /_/ /____/
German BOS Information Script
by Bastian Schroll
@file: decoder.py
@date: 06.01.2018
@author: Bastian Schroll
@description: Some utils for the decoding
"""
import logging
2019-09-20 18:27:20 +02:00
from boswatch.decoder.fmsDecoder import FmsDecoder
from boswatch.decoder.pocsagDecoder import PocsagDecoder
from boswatch.decoder.zveiDecoder import ZveiDecoder
2018-01-07 14:09:40 +01:00
logging.debug("- %s loaded", __name__)
2018-09-09 16:34:44 +02:00
class Decoder:
2018-01-07 14:09:40 +01:00
2018-09-09 16:34:44 +02:00
@staticmethod
def decode(data):
r"""!Choose the right decoder and return a bwPacket instance
2018-09-09 16:34:44 +02:00
@param data: data to decode
@return bwPacket instance"""
2019-09-20 17:38:33 +02:00
data = str(data)
2018-09-09 16:34:44 +02:00
if "FMS" in data:
return FmsDecoder.decode(data)
elif "POCSAG" in data:
return PocsagDecoder.decode(data)
elif "ZVEI" in data:
return ZveiDecoder.decode(data)
else:
2019-10-10 19:34:03 +02:00
logging.warning("no decoder found for: %s", data)
2018-09-09 16:34:44 +02:00
return None