# Path: ogn/parser/utils.py
# FPM_TO_MS = FEETS_TO_METER / 60     # ratio fpm to m/s
# 
# HPM_TO_DEGS = 180 / 60              # ratio between half turn per minute and degrees/s
# 
# Path: ogn/parser/pattern.py
# PATTERN_RECEIVER_BEACON = re.compile(r"""
#     (?:
#         v(?P<version>\d+\.\d+\.\d+)
#         (?:\.(?P<platform>.+?))?
#     \s)?
#     CPU:(?P<cpu_load>[\d.]+)\s
#     RAM:(?P<ram_free>[\d.]+)/(?P<ram_total>[\d.]+)MB\s
#     NTP:(?P<ntp_offset>[\d.]+)ms/(?P<ntp_correction>[+-][\d.]+)ppm\s?
#     (?:(?P<voltage>[\d.]+)V\s)?
#     (?:(?P<amperage>[\d.]+)A\s)?
#     (?:(?P<cpu_temperature>[+-][\d.]+)C\s*)?
#     (?:(?P<visible_senders>\d+)/(?P<senders>\d+)Acfts\[1h\]\s*)?
#     (Lat\:(?P<latency>\d+\.\d+)s\s*)?
#     (?:RF:
#         (?:
#             (?P<rf_correction_manual>[+-][\d]+)
#             (?P<rf_correction_automatic>[+-][\d.]+)ppm/
#         )?
#         (?P<signal_quality>[+-][\d.]+)dB
#         (?:/(?P<senders_signal_quality>[+-][\d.]+)dB@10km\[(?P<senders_messages>\d+)\])?
#         (?:/(?P<good_senders_signal_quality>[+-][\d.]+)dB@10km\[(?P<good_senders>\d+)/(?P<good_and_bad_senders>\d+)\])?
#     )?
# """, re.VERBOSE | re.MULTILINE)
# 
# PATTERN_AIRCRAFT_BEACON = re.compile(r"""
#     id(?P<details>[\dA-F]{2})(?P<address>[\dA-F]{6}?)\s?
#     (?:(?P<climb_rate>[+-]\d+?)fpm\s)?
#     (?:(?P<turn_rate>[+-][\d.]+?)rot\s)?
#     (?:FL(?P<flight_level>[\d.]+)\s)?
#     (?:(?P<signal_quality>[\d.]+?)dB\s)?
#     (?:(?P<errors>\d+)e\s)?
#     (?:(?P<frequency_offset>[+-][\d.]+?)kHz\s?)?
#     (?:gps(?P<gps_quality>(?P<gps_quality_horizontal>(\d+))x(?P<gps_quality_vertical>(\d+)))\s?)?
#     (?:s(?P<flarm_software_version>[\d.]+)\s?)?
#     (?:h(?P<flarm_hardware_version>[\dA-F]{2})\s?)?
#     (?:r(?P<flarm_id>[\dA-F]+)\s?)?
#     (?:(?P<signal_power>[+-][\d.]+)dBm\s?)?
#     (?:(?P<proximity>(hear[\dA-F]{4}\s?)+))?
# """, re.VERBOSE | re.MULTILINE)
# 
# Path: ogn/parser/aprs_comment/base.py
# class BaseParser():
#     def __init__(self):
#         self.beacon_type = 'unknown'
# 
#     def parse(self, aprs_comment, aprs_type):
#         if aprs_type.startswith('position'):
#             data = self.parse_position(aprs_comment)
#         elif aprs_type.startswith('status'):
#             data = self.parse_status(aprs_comment)
#         else:
#             raise ValueError("aprs_type {} unknown".format(aprs_type))
#         data.update({'beacon_type': self.beacon_type})
#         return data
# 
#     def parse_position(self, aprs_comment):
#         raise NotImplementedError("Position parser for parser '{}' not yet implemented".format(self.beacon_type))
# 
#     def parse_status(self, aprs_comment):
#         raise NotImplementedError("Status parser for parser '{}' not yet implemented".format(self.beacon_type))


from ogn.parser.utils import FPM_TO_MS, HPM_TO_DEGS
from ogn.parser.pattern import PATTERN_RECEIVER_BEACON, PATTERN_AIRCRAFT_BEACON
from .base import BaseParser



class OgnParser(BaseParser):
    def __init__(self):
        self.beacon_type = None
        self.aircraft_pattern = PATTERN_AIRCRAFT_BEACON
        self.receiver_pattern = PATTERN_RECEIVER_BEACON

    def parse(self, aprs_comment, aprs_type):
        if not aprs_comment:

# Path: ogn/parser/utils.py
# FPM_TO_MS = FEETS_TO_METER / 60     # ratio fpm to m/s
# 
# HPM_TO_DEGS = 180 / 60              # ratio between half turn per minute and degrees/s
# 
# Path: ogn/parser/pattern.py
# PATTERN_RECEIVER_BEACON = re.compile(r"""
#     (?:
#         v(?P<version>\d+\.\d+\.\d+)
#         (?:\.(?P<platform>.+?))?
#     \s)?
#     CPU:(?P<cpu_load>[\d.]+)\s
#     RAM:(?P<ram_free>[\d.]+)/(?P<ram_total>[\d.]+)MB\s
#     NTP:(?P<ntp_offset>[\d.]+)ms/(?P<ntp_correction>[+-][\d.]+)ppm\s?
#     (?:(?P<voltage>[\d.]+)V\s)?
#     (?:(?P<amperage>[\d.]+)A\s)?
#     (?:(?P<cpu_temperature>[+-][\d.]+)C\s*)?
#     (?:(?P<visible_senders>\d+)/(?P<senders>\d+)Acfts\[1h\]\s*)?
#     (Lat\:(?P<latency>\d+\.\d+)s\s*)?
#     (?:RF:
#         (?:
#             (?P<rf_correction_manual>[+-][\d]+)
#             (?P<rf_correction_automatic>[+-][\d.]+)ppm/
#         )?
#         (?P<signal_quality>[+-][\d.]+)dB
#         (?:/(?P<senders_signal_quality>[+-][\d.]+)dB@10km\[(?P<senders_messages>\d+)\])?
#         (?:/(?P<good_senders_signal_quality>[+-][\d.]+)dB@10km\[(?P<good_senders>\d+)/(?P<good_and_bad_senders>\d+)\])?
#     )?
# """, re.VERBOSE | re.MULTILINE)
# 
# PATTERN_AIRCRAFT_BEACON = re.compile(r"""
#     id(?P<details>[\dA-F]{2})(?P<address>[\dA-F]{6}?)\s?
#     (?:(?P<climb_rate>[+-]\d+?)fpm\s)?
#     (?:(?P<turn_rate>[+-][\d.]+?)rot\s)?
#     (?:FL(?P<flight_level>[\d.]+)\s)?
#     (?:(?P<signal_quality>[\d.]+?)dB\s)?
#     (?:(?P<errors>\d+)e\s)?
#     (?:(?P<frequency_offset>[+-][\d.]+?)kHz\s?)?
#     (?:gps(?P<gps_quality>(?P<gps_quality_horizontal>(\d+))x(?P<gps_quality_vertical>(\d+)))\s?)?
#     (?:s(?P<flarm_software_version>[\d.]+)\s?)?
#     (?:h(?P<flarm_hardware_version>[\dA-F]{2})\s?)?
#     (?:r(?P<flarm_id>[\dA-F]+)\s?)?
#     (?:(?P<signal_power>[+-][\d.]+)dBm\s?)?
#     (?:(?P<proximity>(hear[\dA-F]{4}\s?)+))?
# """, re.VERBOSE | re.MULTILINE)
# 
# Path: ogn/parser/aprs_comment/base.py
# class BaseParser():
#     def __init__(self):
#         self.beacon_type = 'unknown'
# 
#     def parse(self, aprs_comment, aprs_type):
#         if aprs_type.startswith('position'):
#             data = self.parse_position(aprs_comment)
#         elif aprs_type.startswith('status'):
#             data = self.parse_status(aprs_comment)
#         else:
#             raise ValueError("aprs_type {} unknown".format(aprs_type))
#         data.update({'beacon_type': self.beacon_type})
#         return data
# 
#     def parse_position(self, aprs_comment):
#         raise NotImplementedError("Position parser for parser '{}' not yet implemented".format(self.beacon_type))
# 
#     def parse_status(self, aprs_comment):
#         raise NotImplementedError("Status parser for parser '{}' not yet implemented".format(self.beacon_type))


# Path: ogn/parser/aprs_comment/ogn_parser.py
from ogn.parser.utils import FPM_TO_MS, HPM_TO_DEGS
from ogn.parser.pattern import PATTERN_RECEIVER_BEACON, PATTERN_AIRCRAFT_BEACON
from .base import BaseParser




class OgnParser(BaseParser):
    def __init__(self):
        self.beacon_type = None
        self.aircraft_pattern = PATTERN_AIRCRAFT_BEACON
        self.receiver_pattern = PATTERN_RECEIVER_BEACON

    def parse(self, aprs_comment, aprs_type):
        if not aprs_comment:

            return {'beacon_type': 'aprs_receiver'}