make decoder classes <<static>>

This commit is contained in:
Bastian Schroll 2018-09-09 16:34:44 +02:00
parent a6542f0b63
commit f1bf468c2a
6 changed files with 60 additions and 69 deletions

View file

@ -23,18 +23,21 @@ from boswatch.decoder.zveidecoder import ZveiDecoder
logging.debug("- %s loaded", __name__)
def decode(data):
"""!Choose the right decoder and return a bwPacket instance
class Decoder:
@param data: data to decode
@return bwPacket instance"""
logging.debug("search decoder")
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:
logging.error("no decoder found for: %s", data)
return None
@staticmethod
def decode(data):
"""!Choose the right decoder and return a bwPacket instance
@param data: data to decode
@return bwPacket instance"""
logging.debug("search decoder")
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:
logging.error("no decoder found for: %s", data)
return None

View file

@ -30,10 +30,6 @@ class FmsDecoder:
First step is to validate the data and _check if the format is correct.
In the last step a valid BOSWatch packet is created and returned"""
def __init__(self):
"""!Create a new instance"""
logging.debug("FMS decoder started")
@staticmethod
def decode(data):
"""!Decodes FMS

View file

@ -30,10 +30,6 @@ class PocsagDecoder:
First step is to validate the data and _check if the format is correct.
In the last step a valid BOSWatch packet is created and returned"""
def __init__(self):
"""!Create a new instance"""
logging.debug("POCSAG decoder started")
@staticmethod
def decode(data):
"""!Decodes POCSAG

View file

@ -31,10 +31,6 @@ class ZveiDecoder:
After that the double-tone-sign 'E' is replaced.
In the last step a valid BOSWatch packet is created and returned"""
def __init__(self):
"""!Create a new instance"""
logging.debug("ZVEI decoder started")
@staticmethod
def decode(data):
"""!Decodes ZVEI